I calculate the endpoint of the ray cast by taking the cars position and then adding a vector, taking the cars rotation into account.
example code
Code: Select all
vector3df ray_rotation;
ray_rotation = car_rotation - vector3df(0,45,0);
line3df ray1;
ray.start = car_position;
matrix4 matt;
matt.setRotationDegrees(ray_rotation);
vector3df dist(-100,0.0f,0.0f);
matt.rotateVect(dist);
ray.end.set(dist + start);
Why does this happen?
Edit
The green line on the right is where the ray is supposed to end up. But instead it points in the opposite direction.