Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (564) Games in Android Showcase (151) games submitted by our members Games in WIP (605) 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 1346 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.

 wxwsk8er (49 views) 2015-03-20 15:39:46 Fairy Tailz (42 views) 2015-03-15 21:52:20 Olo (26 views) 2015-03-13 17:51:59 Olo (29 views) 2015-03-13 17:50:51 Olo (33 views) 2015-03-13 17:50:16 Olo (40 views) 2015-03-13 17:47:07 ClaasJG (29 views) 2015-03-10 11:36:42 ClaasJG (37 views) 2015-03-10 11:33:01 Pippogeek (45 views) 2015-03-05 14:36:23 Pippogeek (37 views) 2015-03-05 13:56:12
 LiquidNitrogen 23x KevinWorkman 22x BurntPizza 21x basil_ 21x theagentd 18x Riven 18x EgonOlsen 17x Roquen 14x princec 12x SHC 9x Varkas 9x Slyth2727 9x NegativeZero 9x wessles 7x ClaasJG 7x teletubo 7x
 How 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:00List of Learning Resources2014-08-05 19:33:27
 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