Raycast on the side of an object

helloween

15-10-2007 01:43:23

Hi,
I would like to launch a ray on the side of my car constantly, to act as a sensor and get the distance to the side of the track.
How can I specify the direction of the ray ?

So I get the position of the car like this :

Vector3 pos=mCar->getChassisBody()->getOgreNode()->getPosition();

then launch the ray :
BasicRaycast ray(m_World,pos , ???! );

I am not sure , I think I have to use the orientation of the car, and from the quaternion to get the x axis ?
:oops:

Help me !
Thanks

walaber

16-10-2007 00:31:23

if you want to cast a ray 10 units in the X direction of the car's local axis, do this:


Ogre::Vector3 pos;
Ogre::Quaternion orient;

mCar->getChassisBody()->getPositionOrientation(pos, orient);

Ogre::Vector3 endPt = pos + (orient * Ogre::Vector3::UNIT_X * 10.0f);


cast the ray from pos to endPt.

helloween

16-10-2007 00:37:58

thousands thanks Walaber !! it is exactly what I wanted !!

I was almost there though but I was not additioning the pos :oops: