Adding trigger to pathcamera.cc (HELP)
by Shez · in Torque Game Engine · 10/19/2005 (3:38 am) · 1 replies
I have done some research on player.cc and vehichle.cc in how they could detect triggers. The deeper i research, more confused i get... Please could anyone give some idea on how to add triggers to pathcamera.cc..Im still very fresh in programming.
About the author
Torque Owner Roshan Kuriyan
Default Studio Name
---------------PathCamera.h-----------------
Add this new function under the public access Specifier
bool buildPolyList(AbstractPolyList* polyList, const Box3F &box, const SphereF &sphere);
---------------PathCamera.cc-------------------
Inside the function PathCamera::advancePosition(S32 ms) add these Codes in the last line.
RayInfo collision;
Point3F startPos = getPosition();
U32 mask = TriggerObjectType;
Container* pContainer = isServerObject() ? &gServerContainer : &gClientContainer;
pContainer->castRay(startPos, startPos , mask, &collision);
if(collision.t >= 0 )
{
Trigger* sObj = NULL;
sObj = dynamic_cast<Trigger*>(collision.object);
U32 massk = collision.object->getTypeMask();
if( massk & TriggerObjectType)
{
sObj->potentialEnterObject(this);
}
}
And also add this new function
bool PathCamera::buildPolyList(AbstractPolyList* polyList, const Box3F&, const SphereF&)
{
// Collision with the player is always against the player's object
// space bounding box axis aligned in world space.
Point3F pos;
MatrixF CMat(1);
getTransform().getColumn(3,&pos);
CMat.setColumn(3,pos);
polyList->setTransform(&CMat, Point3F(1.0f,1.0f,1.0f));
polyList->setObject(this);
polyList->addBox(mObjBox);
return true;
}
That's IT