GeometryBatchFactory.optimize crashing on imported models

I have some models (created in blender) which I want to apply GeometryBatchFactory.optimize to - but I’m getting big crashes.



doing this-

Spatial mymodel = assetManager.loadModel(“Models/mymodel.mesh.xml”);

Spatial opt = GeometryBatchFactory.optimize(mymodel);



makes this happen-



Jan 28, 2011 11:40:59 AM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException

at java.nio.Buffer.(Buffer.java:174)

at java.nio.ByteBuffer.(ByteBuffer.java:259)

at java.nio.ByteBuffer.(ByteBuffer.java:267)

at java.nio.MappedByteBuffer.(MappedByteBuffer.java:64)

at java.nio.DirectByteBuffer.(DirectByteBuffer.java:97)

at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)

at com.jme3.util.BufferUtils.createFloatBuffer(BufferUtils.java:713)

at com.jme3.scene.VertexBuffer.createBuffer(VertexBuffer.java:661)

at jme3tools.optimize.GeometryBatchFactory.mergeGeometries(GeometryBatchFactory.java:145)

at jme3tools.optimize.GeometryBatchFactory.makeBatches(GeometryBatchFactory.java:228)

at jme3tools.optimize.GeometryBatchFactory.optimize(GeometryBatchFactory.java:255)



thanks.

Is the mesh consisting only of triangles?

It has a texture with uv coords. Do I need to take this out?

I was asking about the mesh.

as far as I can tell yes - at has 24 vertices & 12 faces from looking at the xml file. is that what you mean?

24 vertices and 12 faces doesn’t sound like triangles, does it? (real question, cant imagine triangles with that right now?)

Why not? Triangle strip would have 14 verts for 12 faces, separate triangles 36 verts for 12 faces. Everything in between is possible.

yes but the faces are triangles?



so this is the indices for the first face/triangle



sorry i’m a bit confused.

this was missing in last post-



face v1=“0” v2=“1” v3=“2”

what is also strange is that i tried rebuilding the model internally by creating a new Mesh and copying over the vertices/indices/texcoords buffers. This worked to a point until I started attaching this new model to Nodes & copying/cloning the nodes around - which then sometimes crashed and sometimes didn’t.

ok i’ve got to the bottom of the problem - when i do a deep clone of the imported model - it crashes when i run the optimize on it. So deep cloning must be messing things up somehow.

Can you please provide the model file with the issue? If its small enough, you can just paste the contents here.

it’s a simple hexagonal tube, with no caps - created in blender,

i’ve just noticed that blender has created twice the amount of vertices needed for this shape, with lots of duplicates - whether this is causing the problem i don’t know.