[Odejava] GeomTriMesh collisions

Hi all,
I am having trouble obtaining collisions from a GeomTriMesh. If the GeomTriMesh is static, then collisions occur fine. However, if it is dynamic, no collisions with the trimesh take place.

The code for static is:


                  Vector3f verts[] = geo.getVertices();
                  float geomVerts[] = new float[verts.length * 3];
                  int c = 0;
                  for (int i = 0; i < verts.length; i++) {
                        geomVerts[c] = verts[i].x;
                        geomVerts[c + 1] = verts[i].y;
                        geomVerts[c + 2] = verts[i].z;
                        c += 3;
                  }

                  GeomTriMesh tMesh = new GeomTriMesh(geo.getName(), geomVerts,
                              ((TriMesh) geo).getIndices());
                  space.add(tMesh);
                  tMesh.setPosition(geo.getLocalTranslation().x, geo
                              .getLocalTranslation().y, geo.getLocalTranslation().z);
                  tMesh.setAxisAndAngle(geo.getLocalRotation().x, geo
                              .getLocalRotation().y, geo.getLocalRotation().z, geo
                              .getLocalRotation().w);

And the code for dynamic is:


                  Vector3f verts[] = geo.getVertices();
                  float geomVerts[] = new float[verts.length * 3];
                  int c = 0;
                  for (int i = 0; i < verts.length; i++) {
                        geomVerts[c] = verts[i].x;
                        geomVerts[c + 1] = verts[i].y;
                        geomVerts[c + 2] = verts[i].z;
                        c += 3;
                  }

                  GeomTriMesh tMesh = new GeomTriMesh(geo.getName(), geomVerts,
                              ((TriMesh) geo).getIndices());
                  Body body = new Body(geo.getName(), world, tMesh);
                  space.addBodyGeoms(body);
                  body.setPosition(geo.getLocalTranslation().x, geo
                              .getLocalTranslation().y, geo.getLocalTranslation().z);
                  body.setAxisAndAngle(geo.getLocalRotation().x, geo
                              .getLocalRotation().y, geo.getLocalRotation().z, geo
                              .getLocalRotation().w);
                  body.adjustMass(mass);

any assistance on this matter is appreciated.

I think the current version of ODE we are using only supports collisions with static tri-mesh.

Why the moving tri-mesh? Can you approximate with primitives? Often that is the better option anyway.

Will.

Well, Toruses (Tori?) is a primative in jME and its not a primative in ODE. So I have to rely on the TriMesh example. A pyramid is another one…

I would like to create a chain from some tori, but I can’t…

Is this an ODE-java limitation, or the native ODE limitation?

DP

A bit of both. ODE I believe has moving tri-mesh support but I don’t know how stable it is. If Odejava is upgraded to use the latest ODE CVS HEAD then the it isn’t Odejava that is limiting it.

That said, in most cases it is better to approximate your geometry using ODE primitives as you will probably get more accurate collision with the approximated Geoms than a tri-mesh (even though the tri-mesh may conform to your shape better). XODE may come in handy there as you can play with the shapes and sizes without changing yoru code. Some sort of debug mode where a graphical representation of the ODE primitives is drawn over your custom geometry is a great help.

I only use Tri-mesh in one area for my game (a tank simulation) and that is the terrain.

The big problem with Tri-Mesh is that it is a “triangle soup” and has no concept of volume. Boxes and spheres on the other hand do and they are also much faster.

Cheers,

Will.

thanks for your help.

jME has BoundingVolumes, so the approximation is basically there. all I need to do is change it from jME’s way to ODEs.

Should be fairly simple :slight_smile:

No worries.

On another topic, have you ported the OdejavaToXith3D utility class to jME and/or set jME up to use the org.odejava.display package? If you have and are willing to share, it would be good to add jME support along side Xith3D and Java3D.

Will.

I haven’t yet no. However, I have rigid functionalities in place, e.g. mass, terrain…etc. Im working on joints/hinges ATM.

I have taken a different approact to the Xith and Java3D to be honest.

Here, ive uploaded a zip to show off the things that can be done:

http://www.myjavaserver.com/~digiwired/physics-code.zip

Enjoy :smiley: