Thanks


if ( !path.empty() )
{
//Store Pingy's bounding box.
aabbox3df pingyBB = mRenderMesh->getTransformedBoundingBox();
vector3df lastPoint;
vector3df currPoint;
vector3df nextPoint;
//Loop over list
for (int i=0; i<path.size(); ++i)
{
//Check if point has been reached.
if ( pingyBB.isPointInside( path[i]->getPosition() ) );
{
//Set the path points.
if ( path[i-1] != NULL )
lastPoint = path[i-1]->getPosition();
if ( path[i] != NULL )
currPoint = path[i]->getPosition();
if ( path[i+1] != NULL )
nextPoint = path[i+1]->getPosition();
//Check for what side pingy is on.
//=============================================
if ( mRenderMesh->getPosition().X < path[i]->getPosition().X )
{
//Set new rotation.
//=============================================
vector3df toNext = mRenderMesh->getPosition()-nextPoint;
vector3df newRot = toNext.getHorizontalAngle();
mRenderMesh->setRotation(newRot);//(Or the controller empty)
//=============================================
}
else
{
//Set new rotation.
//=============================================
vector3df toLast = mRenderMesh->getPosition()-lastPoint;
vector3df newRot = toLast.getHorizontalAngle();
mRenderMesh->setRotation(newRot);//(Or the controller empty)
//=============================================
}
}
}
}if ( pointIsInBox(playerBB) )
{
if ( playerPos > pointPos[i] && playerPos < pointPos[i+1] )
//rotate.
//do other side.
}
double PointDirection(double x1, double y1, double x2, double y2){
double angle=0;
angle=(atan2(x1-x2,y1-y2)*180)/3.14;
return angle;
}


Users browsing this forum: No registered users and 0 guests