Hi again.
Now i have implemented ODE into my game, but I have a problem:
I have a TransformGroup class called 'Object3D',
a ODE collision detection class called 'CollisionDetection'
and a Xith3D class called 'World3D'.
I add some Shape3D's to the Object3D and add it to my World3D, and then I am calling a method in CollisionDetection
addObject3D(Object3D),
using OdejavaToXith3D.addUserTransformGroup().
Here's the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public Body convertToBody(Object3D poObject3D) { Body oBody = new Body(poObject3D.getName(), getWorld()); addNodeRecursive(poObject3D, oBody, poObject3D); return oBody; } public void addNodeRecursive(Node poNode, Body poBody, Object3D poObject3D) { if (poNode instanceof Group) { for (Enumeration oEnumeration = ((Group)poNode).getAllChildren(); oEnumeration.hasMoreElements();) { addNodeRecursive((Node)oEnumeration.nextElement(), poBody, poObject3D); } } else if (poNode instanceof Shape3D) { Shape3D oShape3D = (Shape3D)poNode; System.out.println(poNode.getUserData()); IndexedTriangleArray oIndexedTriangleArray = (IndexedTriangleArray)oShape3D.getGeometry(); GeomTriMesh oGeomTriMesh = Xith3DToOdejava.createTriMesh(oIndexedTriangleArray); moMapToObject3D.put(new Integer(oGeomTriMesh.getNativeAddr()), poObject3D); } } |
Like you see the code isn't completed yet,
because I do not know how to do a Shape3D into a Geom, then adding all Geoms into a Body..
Note: I do not want to make every Shape3D using a IndexedTriangleArray..
Then I am doing in my update method:
1 2 3
| getJavaCollision().collide(getSpace()); iterateContacts(); getJavaCollision().applyContacts(); |
This is my goal:
I want
iterateContacts() to call Object3D if any collision occured. (
collideWith(Object3D object3D, Tuple3f collisionPoint))
Does anyone have any ideas?
Thanks,
Alonzo