www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: abhi13feb on April 23, 2008, 07:41:22 am

Title: Collision detection
Post by: abhi13feb on April 23, 2008, 07:41:22 am
How sphere polygon collission detection has been carried out in jPCtDemo example.Can someone plz explain it briefly..thanks
Title: Re: Collision detection
Post by: JavaMan on April 23, 2008, 01:21:24 pm
Basically on the objects you want to test for a collision you call

object1.setCollisionMode(...); I suggest using the or operator for Collision detect self and others
object2.setCollisionMode(...); same thing.

Then you need to implement the collision listener interface, and call

Code: [Select]
object1.addCollisionListener(new YourCollisionListener());
Then when you want to test if a movement will create a collision you call
object1.checkForCollisionSpherical(...);
If you object collides with another object the collision method will be called in your listener.

Its pretty much how the Swing event system works. Hope this helps!
Jman