GeomTrimesh winding order question

Im having trouble getting my collision meshes to collide properly. Im able to create a GeomTrimesh for my ground using a height map and the collisions work great. But if I load a model, for example a 3ds model with the starfire loader, and then create a collision mesh from that the collisions dont work right (ie moving objects go through it usualy).

In the java3d api if I use a TriangleArray to create the collision mesh like this:

    TriangleArray ia = //load with 3ds loader
    float[] fa = new float[ia.getVertexCount() * 3];
    ia.getCoordinates(0,fa);
    int[] index = new int[fa.length / 3];
    for(int i = 0; i < index.length; i++)
    index[i] = i;
    //now create GeomTrimesh with fa and index

Or if I create and IndexedTriangleArray and just use the raw vertecies and index from that it still doesnt work right.

Ive even tried every possible way to reorder the winding of the triangles by swaping indexes. Nothing works. Anyone got any tips for creating GeomTrimeshes from java3d Geometrys?

Is this trimesh to be used as terrain? Have you checked out the CarTerrainExample demo?

Will.

No. Im creating my own IndexedTriangleArray and GeomTrimesh for my terrain. I want load arbitrary models and create collision meshes for them.

I’m not 100% sure that the version of ode we are using supports non-static tri-mesh. Also, I’m not sure if it has tri-mesh/tri-mesh support.

The better option, even if these options were supported is to approximate the shape with primitive Geoms for collission. In my tank game, I have the tank mesh files + XODE xml files which contain the primitive approximation of the tank (and also defines the joints etc). So my xith3d engine gets a nice mesh, ODE engine gets a few boxes. Using tri-mesh’s without good reason (terrain for example is a good reason) is not advised as you’ll lose out on performance. When you combine a few primitive Goems together you can still have quite realistic collission with complex shapes.

Will.