Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (755) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 [Odejava] GeomTriMesh collisions  (Read 2445 times) 0 Members and 1 Guest are viewing this topic.
darkprophet

Senior Devvie

 « Posted 2004-10-14 20:11:19 »

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:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18 `                  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:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 `                  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.

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
William Denniss

JGO Coder

Projects: 2

Fire at will

 « Reply #1 - Posted 2004-10-14 20:20:48 »

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.

darkprophet

Senior Devvie

 « Reply #2 - Posted 2004-10-14 21:16:42 »

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

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
William Denniss

JGO Coder

Projects: 2

Fire at will

 « Reply #3 - Posted 2004-10-14 21:50:07 »

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.

darkprophet

Senior Devvie

 « Reply #4 - Posted 2004-10-15 19:50:21 »

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

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
William Denniss

JGO Coder

Projects: 2

Fire at will

 « Reply #5 - Posted 2004-10-15 23:01:47 »

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.

darkprophet

Senior Devvie

 « Reply #6 - Posted 2004-10-16 08:38:47 »

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

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Pages: [1]
 ignore  |  Print

 DesertCoockie (36 views) 2018-05-13 18:23:11 nelsongames (82 views) 2018-04-24 18:15:36 nelsongames (74 views) 2018-04-24 18:14:32 ivj94 (755 views) 2018-03-24 14:47:39 ivj94 (85 views) 2018-03-24 14:46:31 ivj94 (626 views) 2018-03-24 14:43:53 Solater (101 views) 2018-03-17 05:04:08 nelsongames (182 views) 2018-03-05 17:56:34 Gornova (408 views) 2018-03-02 22:15:33 buddyBro (1068 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org