MAZE3D+ODEJAVA problem

Im doing an integration of maze3d with the odejava collision system and im getting problems detecting collisions.I have used the CarTerrain example as a base, and i have used the chassis as avatar without problems (the camera moves through the maze over a GeomBox body).Im adding the Wall3D shapes as GeomTriMeshes to the odeworld.
The problem comes when the box body has to collide with the walls, as i dont get any collisions, the box goes through the walls.In fact i only get collisions in some points of the wall (more or less in the center) but not in the whole wall.That does not make much sense, as with InitXithFromOdejava Xith displays the walls correctly as Ode knows them.
So, why does Ode draw well the walls but does not get the right collisions?

More info:
-The walls are simple Geoms while the avatar box is a Body
-I check with a println the collisions in the iterateContacts() method.
-When a collision happens (in detailed spots of the wall), the contact.getBodyID / contact.getGeomID does not seem to correspond to any body/geom NativeAdress.
-I dont know why, but all my objects/bodies seem to have the same NativeAdr…that may be the cause? how is the NativeAdr calculated?

Any clue?

Any reason why your walls aren’t GeomBox’s?

The immovable walls being “simple Geoms” (i.e. static Geoms) and the avatar Geom being attached to a Body is a common setup, there is no problem with this.

The nativeAddress/GeomID setup is a bit messy. Have you checked out the new methods I added in to CVS (check the most recent CVS commit message on the mailing list). Are you using Odejava from CVS? I added some handy methods which let you get the actual Geom from the contact (with a small speed penalty - the lookup of a HashMap).

Will.

Well, i guess the only reason for walls being trimeshes and no GeomBoxes was lazyness ;D
This way I only had to create the trimesh from the shape, without caring about position, sizes,…

I have redone with GeomBoxes and works pretty decent, although if the GeomBoxes are too much slim and the avatar runs too much, it does not detect the collisions and lets it go through.Other weird thing is that when you colide with the box, sometimes you can see the ‘inside’ of the box, as if the physical barrier was inside the box, and not in the box sides.

The version Im currently using is odejava-2004-09-07_cvs.zip.The contact class has 4 methods like getGeomID1,getGeomID2,getBodyID1,getBodyID2.If i call this methods in the iterateContacs() method, i get a serie of numbers, but i still dont get what this numbers correspond to.I need to know what are this numbers i get, as i want to program some behaviour to the collisions.
For example, if i have 10 GeomBoxes with the name “door” and my avatar collides with one of this geomboxes, i want to teleport the avatar to another room.Which method in the body or the geoms returns back the same type of identifier that getGeomID1,… returns back?

Maybe my version is a bit updated and the nethods you added are useful for what im trying to do.As a start i’ll search for that CVS, thanks :slight_smile:

GeomBoxes are the far better option if they are a viable option. One important reason for this (as I realised today) is that GeomBoxes have volume. If a geom passes inside them - it will still collide and be pushed out. GeomTriMesh’s are “triangle soups” which are very thin (even enclosed Tri-Mesh’s are hollow). If a geom penetrates far enough the collision will not register at all. This is also the case with a GeomBox, but as GeomBoxes can (and generally do) have a larger volume this happens less.

This causes me problems when a ballistic is fired at a very sharp angle and is travelling at a very fast velocity when it hits the ground.

As you note - sometimes your geom will actually be inside another geom (and hence you will see the inside of the geom if your camera also penetrates). ODE and many other systems use collission detection. That is the collision is detected after it has happened, and thus the objects can intersect. ODE will correct this in subsiquent frames. One solution for this is collission prevention, that is detecting when a collision will occure and preventing it.

Increasing the World step size makes the simulation more accurate which will reduce the occurances of geoms passing though other geoms and reduce the depth of penetration in collissions. Of course this will reduce your frame rate as you will need more (CPU intensive) steps each second.

Cheers,

Will.

I have solved the ‘problem’ of the avatar entering through a wall before getting collided.It was because the avatar Body was very small, so when the collision was detected, the camera was almost inside the wall.When i made the Avatar body a bit bigger, the collisions with walls behave perfectly :slight_smile:

But i still have the problem to work out the iterateContacts method to program the collision behavior.If i use the getBodyID1/2 and getGeomID1/2, what method should i call in the Body or the Geoms to get the same type of identifier to compare? Something like:


if ((contact.getBodyID1() == avatar.methodXXX()) || (contact.getBodyID2() == avatar.methodXXX())){

Iterator it = space.getGeoms().iterator();
while(it.hasNext()){
Geom g = (Geom)it.next();
if((g.methodXXX()==contact.getGeomID1)||(g.methodXXX()==contact.getGeomID2)){
       if(g.getName().equals("door")) this.teleport();
}}

}

In this example we could have different Geoms with the same name “door”, and the teleport() method should decide where to move the avatar.

The important part is methodXXX() that returns me the identifier that matches with the getGeomID or getBodyID.I have tried with avatar.getGeom().getNativeAddr() but does not work.Which is this method??

Well, i have been investigating a bit.The numbers that getGeomID1() and getGeomID2() return seem to correspond with the ones that you get from a Geom calling

geom.getId().getSwigCPtr()

I imagine that this way you get the real native address of the geom (as far as getNativeAddr() always returns 0 for all geoms).After parsing all the geoms of my space (printing its id and its name) i can see that all my objects are correctly in introduced in my space, even the avatar geom.The problem comes when a collision occurs, as the getGeomID1 and getGeomID2 return ids of geoms that are not in my space!!!
I cant figure why this happens ???

Do’h, I meant to tell you:

I have been doing collision recently and added some conveniance methods. Please grab the latest from CVS and you will see it.

Methods of note are:
Geom getGeom1
Geom getGeom2
boolean geom1EqualTo(Geom geom)
boolean geom2EqualTo(Geom geom)

The first two are fairly self explanitory. The cost is a single lookup of a HashMap ( O(log n) I think). The second two provide ultra-fast comparison between a contact geom and an arbiturary second one.

Full commit log here: https://odejava.dev.java.net/servlets/ReadMsg?list=cvs&msgNo=381

The GeomID’s in contact are the native addresses in Geom. HOWEVER - I think there was a bug which I fixed in that commit which was causing problems.

Javadoc comments were added too and may be worth a look.

Cheers,

Will.

I think i had some problems with libraries (dont ask me how i fixed it :P) but i finally got the right NativeAddr results, so i can search my geoms in the space.Anyway i have tested your new methods, and work well…but it crashes at the clean up of the space when the program exits.So im using the NativeAddr to do my collisions, and now they work fine.

Now im heading for a new challenge, the use of ASE imported objects.If i import the objects and add them to my Xith3D scene all works fine (because i can scale and transform them using transform groups).But if i follow the example of CarTerrain and use the GeomTrimesh to get the physic ode representation of the ASE scene, i dont get it scaled or transformed, cause ode takes as base the shape3D objects (that are not transformed).I have not seen any way to scale the Geoms using any method.Do you have any suggestion that does not involve much 3D geometry skills?

Thanks for your answers, have been very useful :slight_smile:

[quote]I think i had some problems with libraries (dont ask me how i fixed it :P) but i finally got the right NativeAddr results, so i can search my geoms in the space.Anyway i have tested your new methods, and work well…but it crashes at the clean up of the space when the program exits.So im using the NativeAddr to do my collisions, and now they work fine.

Now im heading for a new challenge, the use of ASE imported objects.If i import the objects and add them to my Xith3D scene all works fine (because i can scale and transform them using transform groups).But if i follow the example of CarTerrain and use the GeomTrimesh to get the physic ode representation of the ASE scene, i dont get it scaled or transformed, cause ode takes as base the shape3D objects (that are not transformed).I have not seen any way to scale the Geoms using any method.Do you have any suggestion that does not involve much 3D geometry skills?

Thanks for your answers, have been very useful :slight_smile:
[/quote]
Got a bug report regarding the crash?

For the ASE objects, I would suggest exporting them already scaled and transformed. What are the ase objects for? Remember, it’s best to minimise the use of tri-mesh and were possible approximate with primitive geoms. This gives faster and often more accurate results.

Will.

Bug report you mean the crash message?


Exception in thread "main" java.util.ConcurrentModificationException  at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
        at java.util.LinkedList$ListItr.next(Unknown Source)
        at org.odejava.Space.delete(Space.java:169)
        at org.xith3d.agentcities3d.OdeWorld.cleanup(Unknown Source)
        at org.xith3d.agentcities3d.Agentcities3d.cleanup(Unknown Source)
        at org.xith3d.agentcities3d.Agentcities3d.main(Unknown Source)

If you need a more complex bug report, tell me how to obtain it (maybe a background running tool?).

Regarding to ASE, i cant scale and transform the scene, because i dont have the original max scenes.Im using a furnitured room scene where avatar goes at door collisions.Maybe i can use the unscaled room far from normal scene sight, and scale the avatar so it makes the feeling the room has the right size.Or as you say, aproximate the physical world with basic shapes manually.

The geoms were getting removed from the very list being iterated. I have changed the getGeoms method so it returns a copy of the list - and this copy is now used in Space.delete(). Try the latest from CVS and see how you go.

As for the second problem - sounds like you have worked out a few possible solutions. Regarding ASE, I think there are some programs which will let you import it (milkshake perhaps?). It’s not good only have the .ASE files without the .MAX sources.

Will.