* Reverted normen's confusion

* TGA loader now properly fails on grayscale formats

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7848 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 7cc3592f0f
commit bf72c7975b
  1. 5
      engine/src/bullet/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java
  2. 3
      engine/src/bullet/com/jme3/bullet/collision/shapes/HeightfieldCollisionShape.java
  3. 3
      engine/src/bullet/com/jme3/bullet/collision/shapes/HullCollisionShape.java
  4. 5
      engine/src/bullet/com/jme3/bullet/collision/shapes/MeshCollisionShape.java
  5. 6
      engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java
  6. 6
      engine/src/core-plugins/com/jme3/texture/plugins/TGALoader.java

@ -39,6 +39,7 @@ import com.jme3.export.InputCapsule;
import com.jme3.export.OutputCapsule; import com.jme3.export.OutputCapsule;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.IndexBuffer;
import com.jme3.util.BufferUtils;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -70,8 +71,8 @@ public class GImpactCollisionShape extends CollisionShape {
} }
private void createCollisionMesh(Mesh mesh) { private void createCollisionMesh(Mesh mesh) {
triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder()); triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder()); vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4);
// triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4); // triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4);
// vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4); // vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4);
numVertices = mesh.getVertexCount(); numVertices = mesh.getVertexCount();

@ -11,6 +11,7 @@ import com.jme3.export.OutputCapsule;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.util.BufferUtils;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -94,7 +95,7 @@ public class HeightfieldCollisionShape extends CollisionShape {
} }
protected void createShape() { protected void createShape() {
bbuf = ByteBuffer.allocateDirect(heightfieldData.length * 4).order(ByteOrder.nativeOrder()); bbuf = BufferUtils.createByteBuffer(heightfieldData.length * 4);
// fbuf = bbuf.asFloatBuffer();//FloatBuffer.wrap(heightfieldData); // fbuf = bbuf.asFloatBuffer();//FloatBuffer.wrap(heightfieldData);
// fbuf.rewind(); // fbuf.rewind();
// fbuf.put(heightfieldData); // fbuf.put(heightfieldData);

@ -7,6 +7,7 @@ import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule; import com.jme3.export.OutputCapsule;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.BufferUtils;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -66,7 +67,7 @@ public class HullCollisionShape extends CollisionShape {
// objectId = new ConvexHullShape(pointList); // objectId = new ConvexHullShape(pointList);
// objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setLocalScaling(Converter.convert(getScale()));
// objectId.setMargin(margin); // objectId.setMargin(margin);
ByteBuffer bbuf=ByteBuffer.allocateDirect(points.length * 4).order(ByteOrder.nativeOrder()); ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4);
// fbuf = bbuf.asFloatBuffer(); // fbuf = bbuf.asFloatBuffer();
// fbuf.rewind(); // fbuf.rewind();
// fbuf.put(points); // fbuf.put(points);

@ -39,6 +39,7 @@ import com.jme3.export.InputCapsule;
import com.jme3.export.OutputCapsule; import com.jme3.export.OutputCapsule;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.IndexBuffer;
import com.jme3.util.BufferUtils;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -68,8 +69,8 @@ public class MeshCollisionShape extends CollisionShape {
} }
private void createCollisionMesh(Mesh mesh) { private void createCollisionMesh(Mesh mesh) {
triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder()); triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder()); vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4);
numVertices = mesh.getVertexCount(); numVertices = mesh.getVertexCount();
vertexStride = 12; //3 verts * 4 bytes per. vertexStride = 12; //3 verts * 4 bytes per.
numTriangles = mesh.getTriangleCount(); numTriangles = mesh.getTriangleCount();

@ -34,8 +34,8 @@ package com.jme3.bullet.util;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.IndexBuffer;
import com.jme3.util.BufferUtils;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
/** /**
@ -45,8 +45,8 @@ import java.nio.FloatBuffer;
public class NativeMeshUtil { public class NativeMeshUtil {
public static long getTriangleIndexVertexArray(Mesh mesh){ public static long getTriangleIndexVertexArray(Mesh mesh){
ByteBuffer triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder()); ByteBuffer triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
ByteBuffer vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder()); ByteBuffer vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4);
int numVertices = mesh.getVertexCount(); int numVertices = mesh.getVertexCount();
int vertexStride = 12; //3 verts * 4 bytes per. int vertexStride = 12; //3 verts * 4 bytes per.
int numTriangles = mesh.getTriangleCount(); int numTriangles = mesh.getTriangleCount();

@ -85,7 +85,7 @@ public final class TGALoader implements AssetLoader {
boolean flip = ((TextureKey)info.getKey()).isFlipY(); boolean flip = ((TextureKey)info.getKey()).isFlipY();
InputStream in = info.openStream(); InputStream in = info.openStream();
Image img = load(in, flip); Image img = load(in, flip);
// in.close(); in.close();
return img; return img;
} }
@ -189,7 +189,7 @@ public final class TGALoader implements AssetLoader {
// Allocate image data array // Allocate image data array
Format format = null; Format format;
byte[] rawData = null; byte[] rawData = null;
int dl; int dl;
if (pixelDepth == 32) { if (pixelDepth == 32) {
@ -442,6 +442,8 @@ public final class TGALoader implements AssetLoader {
} }
format = dl == 4 ? Format.RGBA8 : Format.RGB8; format = dl == 4 ? Format.RGBA8 : Format.RGB8;
} else {
throw new IOException("Grayscale TGA not supported");
} }

Loading…
Cancel
Save