Author Topic: Casting Rays for collision Detection  (Read 1330 times)

Offline Edak

  • byte
  • *
  • Posts: 14
    • View Profile
Casting Rays for collision Detection
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Casting Rays for collision Detection
« Reply #1 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.

Offline Edak

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Casting Rays for collision Detection
« Reply #2 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Casting Rays for collision Detection
« Reply #3 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

Offline Edak

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Casting Rays for collision Detection
« Reply #4 on: June 26, 2011, 12:58:01 am »
Excellent my mistake :-) Thanks.