Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  MAZE3D+ODEJAVA problem  (Read 1997 times)
0 Members and 1 Guest are viewing this topic.
Offline Cristianbs

Senior Newbie




Java games rock!


« Posted 2004-10-01 09:48:48 »

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?  
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-10-02 11:46:38 »

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.


Offline Cristianbs

Senior Newbie




Java games rock!


« Reply #2 - Posted 2004-10-04 06:43:35 »

Well, i guess the only reason for walls being trimeshes and no GeomBoxes was lazyness  Grin
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 Smiley
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-04 07:26:32 »

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.

Offline Cristianbs

Senior Newbie




Java games rock!


« Reply #4 - Posted 2004-10-05 05:48:14 »

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  Smiley

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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
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??
Offline Cristianbs

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-10-05 07:27:23 »

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  Huh
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-10-05 20:47:55 »

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.

Offline Cristianbs

Senior Newbie




Java games rock!


« Reply #7 - Posted 2004-10-06 14:05:45 »

I think i had some problems with libraries (dont ask me how i fixed it  Tongue) 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  Smiley
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #8 - Posted 2004-10-06 20:44:15 »

Quote
I think i had some problems with libraries (dont ask me how i fixed it  Tongue) 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  Smiley


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.

Offline Cristianbs

Senior Newbie




Java games rock!


« Reply #9 - Posted 2004-10-07 06:25:26 »

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?

1  
2  
3  
4  
5  
6  
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.
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 #10 - Posted 2004-10-08 00:07:15 »

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.

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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (50 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (57 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!