RayInfo.t
by Afrim Kacaj · in Torque Game Engine · 08/14/2006 (9:45 pm) · 3 replies
Does anyone know what value t holds in rayinfo?
There are no comments in the code, couldnt find much info in the forums and the link to the documentation http://www.garagegames.com/docs/tge/engine/structRayInfo.php#o0 dosent have much info.
This is how its used in vehicle.cc
First I thought it was the distance to the collision point but now I am not sure and confused. If it is distance then why the variable t?
There are no comments in the code, couldnt find much info in the forums and the link to the documentation http://www.garagegames.com/docs/tge/engine/structRayInfo.php#o0 dosent have much info.
This is how its used in vehicle.cc
RayInfo collision;
Point3F ep = sp + vec + offset + mCameraOffset;
if (mContainer->castRay(sp, ep, ~(WaterObjectType | GameBaseObjectType | DefaultObjectType), &collision) == true)
{
// Shift the collision point back a little to try and
// avoid clipping against the front camera plane.
F32 t = collision.t - (-mDot(vec, collision.normal) / vec.len()) * 0.1;
if (t > 0.00f)
{
ep = sp + offset + mCameraOffset + (vec * t);
}
else
{
//eye.getColumn(3,&ep);
ep = sp + offset + mCameraOffset + (vec * -t);
}
}
mat->setColumn(3,ep);First I thought it was the distance to the collision point but now I am not sure and confused. If it is distance then why the variable t?
#2
For example if you cast a ray straight down from a height of 250m and that line was 500m long and for arguements sake and easy math collided with an object/terrain or whatever your ray cast mask is at a height of 0m. Then that would be a collision 1/2 way along your original 500m long ray, so t would be 0.5. If the collision occurs at the end of the 500m long line then t would be 1.0 and 0.0 at the start.
08/15/2006 (5:47 am)
T is the distance to the collision point but it has been scaled into the range 0.0 .. 1.0 along the original length of your ray cast line. For example if you cast a ray straight down from a height of 250m and that line was 500m long and for arguements sake and easy math collided with an object/terrain or whatever your ray cast mask is at a height of 0m. Then that would be a collision 1/2 way along your original 500m long ray, so t would be 0.5. If the collision occurs at the end of the 500m long line then t would be 1.0 and 0.0 at the start.
#3
08/15/2006 (7:16 am)
So it's the magnitude of a normalized vector?
Torque Owner Westy