How To implement Ray Casting?

Anand
Posts: 12
Joined: Tue Apr 19, 2011 6:02 am

How To implement Ray Casting?

Post by Anand »

I am new to Bullet physics,Any how after a quick study I implemented broadphase collision detection. Now I want to implement narrow phase by means of ray casting. I referred the demo app on ray casting but i didnt understood any thing.

So can anyone briefly explain how to implement ray casting in a simple manner....


Thanks...
XMight
Posts: 32
Joined: Tue Feb 22, 2011 1:00 pm

Re: How To implement Ray Casting?

Post by XMight »

Hi,
actually this is not a trivial task. This is mostly something you must learn at university, in computer graphics. I doubt that someone will explain how to do it. The fastest way is to get a computer graphics book, the kind which explains how to construct a game engine, or image processing book.

I looked myself into the code of bullet demos, and what I understood is that there is a raycast from the camera to the 2D screen, testing the collision of the casted ray with the objects of the scene. this technique will not work if you must do a raycast from a 3D cursor in your world though.

Try to search on google books.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How To implement Ray Casting?

Post by Erwin Coumans »

Are you looking for a 3D ray cast query? Did you try using the rayTest query using the dynamics world?

Code: Select all

virtual void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const; 
"I looked myself into the code of bullet demos, and what I understood is that there is a raycast from the camera to the 2D screen, testing the collision of the casted ray with the objects of the scene. this technique will not work if you must do a raycast from a 3D cursor in your world though."

The ray cast query in Bullet is generally in 3D, with a 'from' and 'to. Why would this not work?
Thanks,
Erwin
Anand
Posts: 12
Joined: Tue Apr 19, 2011 6:02 am

Re: How To implement Ray Casting?

Post by Anand »

XMight wrote:Hi,
actually this is not a trivial task. This is mostly something you must learn at university, in computer graphics. I doubt that someone will explain how to do it. The fastest way is to get a computer graphics book, the kind which explains how to construct a game engine, or image processing book.

I looked myself into the code of bullet demos, and what I understood is that there is a raycast from the camera to the 2D screen, testing the collision of the casted ray with the objects of the scene. this technique will not work if you must do a raycast from a 3D cursor in your world though.

Try to search on google books.
Thank U....
Anand
Posts: 12
Joined: Tue Apr 19, 2011 6:02 am

Re: How To implement Ray Casting?

Post by Anand »

Erwin Coumans wrote:Are you looking for a 3D ray cast query? Did you try using the rayTest query using the dynamics world?

Code: Select all

virtual void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const; 
"I looked myself into the code of bullet demos, and what I understood is that there is a raycast from the camera to the 2D screen, testing the collision of the casted ray with the objects of the scene. this technique will not work if you must do a raycast from a 3D cursor in your world though."

The ray cast query in Bullet is generally in 3D, with a 'from' and 'to. Why would this not work?
Thanks,
Erwin

I was able to do ray casting...Thank you for the valuable information