www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Edak on June 24, 2011, 09:25:10 pm

Title: Casting Rays for collision Detection
Post by: Edak on June 24, 2011, 09:25:10 pm
I want to cast a specific ray ( ie I supply origin and direction ) and collect the first point in world-space there was a collision at.

-I've implemented the collision listener to my class.

-I've done this:

public void collision(CollisionEvent ce){
        Logger.log("Detected");
        new SimpleVector CollisionPoint = ce.getFirstContact();
}

-I've applied Object3D.COLLISION_CHECK_OTHERS to the mesh I want to test.


Now how do I cast a ray from point A to point B and have it trigger the collision event? Thus outputting to the log Detected and setting CollsionPoint
Title: Re: Casting Rays for collision Detection
Post by: EgonOlsen on June 25, 2011, 11:54:25 pm
The event will be triggered by any collision method as well as by the calcMinDistance-method in World.
Title: Re: Casting Rays for collision Detection
Post by: Edak on June 26, 2011, 12:27:16 am
Thanks but maybe I need to rephrase my question.

I want to cast a ray, what methods can I use?

I want to specify the start, and I want to specify a direction, then I want to get the first place in world space there's a collision detection.
Title: Re: Casting Rays for collision Detection
Post by: EgonOlsen on June 26, 2011, 12:30:11 am
I've actually already answered this with my first reply. Maybe the wiki helps: http://www.jpct.net/wiki/index.php/Collision_detection#Ray-Polygon (http://www.jpct.net/wiki/index.php/Collision_detection#Ray-Polygon)
Title: Re: Casting Rays for collision Detection
Post by: Edak on June 26, 2011, 12:58:01 am
Excellent my mistake :-) Thanks.