Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Odejava] GeomTriMesh collisions  (Read 1131 times)
0 Members and 1 Guest are viewing this topic.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Posted 2004-10-14 22: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
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-10-14 22: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.

Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #2 - Posted 2004-10-14 23: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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2004-10-14 23: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.

Offline darkprophet

Senior Member




Go Go Gadget Arms


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

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 Smiley

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2004-10-16 01: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.

Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #6 - Posted 2004-10-16 10: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 Cheesy

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (58 views)
2014-04-15 18:08:23

BurntPizza (56 views)
2014-04-15 03:46:01

UprightPath (69 views)
2014-04-14 17:39:50

UprightPath (52 views)
2014-04-14 17:35:47

Porlus (69 views)
2014-04-14 15:48:38

tom_mai78101 (95 views)
2014-04-10 04:04:31

BurntPizza (155 views)
2014-04-08 23:06:04

tom_mai78101 (250 views)
2014-04-05 13:34:39

trollwarrior1 (206 views)
2014-04-04 12:06:45

CJLetsGame (213 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!