Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (581) Games in Android Showcase (162) games submitted by our members Games in WIP (632) 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 1372 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

You cannot reply to this message, because it is very, very old.

 Waterwolf (27 views) 2015-05-20 15:01:45 chrislo27 (32 views) 2015-05-20 03:42:21 BurntPizza (68 views) 2015-05-10 15:53:18 FrozenShade (53 views) 2015-05-07 09:11:21 TheLopais (215 views) 2015-05-06 13:36:48 TheLopais (199 views) 2015-05-06 13:35:14 TheLopais (205 views) 2015-05-06 13:33:39 TheLopais (225 views) 2015-05-06 13:32:48 TheLopais (222 views) 2015-05-06 13:31:28 ClaasJG (243 views) 2015-04-30 20:33:25
 Spasi 32x BurntPizza 16x DavidBVal 13x ra4king 12x EgonOlsen 11x theagentd 11x Husk 10x KevinWorkman 9x scanevaro 8x princec 8x KaiHH 7x opiop65 7x revers 6x Riven 6x SauronWatchesYou 5x Drenius 5x
 List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00
 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