Thanks that worked.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menuprivate ByteBuffer createIndexBuffer() {
setvController(new VertexController(object3D));
ByteBuffer indexBuffer = BufferUtils.createByteBuffer(object3D.getMesh().getVertexCount() * 4).order(ByteOrder.nativeOrder());
indexBuffer.clear();
PolygonManager pMgr = object3D.getPolygonManager();
SimpleVector vertices[] = vController.getSourceMesh();
SimpleVector vertex;
int index = 0;
for (int i=0; i<pMgr.getMaxPolygonID(); i++) {
vertex = null;
for(int vertexNumber=0; vertexNumber<3; vertexNumber++) {
vertex = pMgr.getTransformedVertex(i, vertexNumber);
index = 0;
for(SimpleVector sourceVertex : vertices){
if(sourceVertex.equals(vertex)) {
indexBuffer.putInt(index);
break;
}
index++;
}
vertexNumber++;
}
}
return indexBuffer;
}
private static TriangleIndexVertexArray createIndexVertexArray(Object3D obj) {
RigidObject ro = RigidObjectManager.getInstance().getRigidObject(obj.getName());
int numTriangles = obj.getMesh().getTriangleCount();
int numVertices = obj.getMesh().getVertexCount();
ByteBuffer indexBuffer = ro.getIndexBuffer();
ByteBuffer vertexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
vertexBuffer.clear();
SimpleVector[] vertices = ro.getvController().getSourceMesh();
for (int i = 0; i < vertices.length; i++) {
vertexBuffer.putFloat(vertices[i].x);
vertexBuffer.putFloat(vertices[i].y);
vertexBuffer.putFloat(vertices[i].z);
}
vertexBuffer.rewind();
indexBuffer.rewind();
TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray(numTriangles, indexBuffer, 3*4, vertices.length, vertexBuffer, 3*4);
return vertexArray;
}
private static TriangleIndexVertexArray createIndexVertexArray(Object3D obj) {
RigidObject ro = RigidObjectManager.getInstance().getRigidObject(obj.getName());
int numTriangles = obj.getMesh().getTriangleCount();
int numVertices = obj.getMesh().getVertexCount();
// int numVertices = obj.getMesh().getUniqueVertexCount();
//4 represents Byte size of Integer
ByteBuffer indexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
for (int i=0; i<numTriangles; i++) {
indexBuffer.putInt(i);
indexBuffer.putInt(i);
indexBuffer.putInt(i);
}
ByteBuffer vertexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
vertexBuffer.clear();
SimpleVector[] vertices = ro.getvController().getSourceMesh();
for (int i = 0; i < vertices.length; i++) {
vertexBuffer.putFloat(vertices[i].x);
vertexBuffer.putFloat(vertices[i].y);
vertexBuffer.putFloat(vertices[i].z);
}
vertexBuffer.rewind();
indexBuffer.rewind();
TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray(numTriangles, indexBuffer, 3*4, obj.getMesh().getVertexCount(), vertexBuffer, 3*4);
return vertexArray;
}
float distance = world.calcMinDistance(cam.getPosition(), obj.getTransformedCenter(), 10000 );
Page created in 0.019 seconds with 12 queries.