Game Development Community

Using SetOrbitMode To Mimic Rotation

by Scott Doerrfeld · in Torque Game Engine · 07/19/2007 (7:48 am) · 2 replies

Can someone check this out and offer any pointers? The following code makes my camera mimic another client's player object for BOTH position and rotation, but the x-rotation (up-down) is choppy for some reason.

In game/camera.cc...

void Camera::processTick(const Move* move)
{
.
.
.
  if(mode == OrbitObjectMode || mode == OrbitPointMode)
  {
     if(mode == OrbitObjectMode && bool(mOrbitObject)) 
     {
        GameBase *castObj = mOrbitObject;
	Player* shape = dynamic_cast<Player*>(castObj);
        if( shape != NULL ) 
        {
           MatrixF ret;
           shape->getRenderEyeTransform( &ret );
	   mRot = ret.toEuler();
	   mPosition = ret.getPosition();
        }  
     }
	 setPosition(mPosition, mRot);
	 pos = mPosition;
  }
.
.
.
}

void Camera::interpolateTick(F32 dt)
{
.
.
.
  if(mode == OrbitObjectMode || mode == OrbitPointMode)
  {
     if(mode == OrbitObjectMode && bool(mOrbitObject)) 
     {
        GameBase *castObj = mOrbitObject;
	Player* shape = dynamic_cast<Player*>(castObj);
        if( shape != NULL ) 
        {
           MatrixF ret;
           shape->getRenderEyeTransform( &ret );
	   rot = ret.toEuler();
	   mPosition = ret.getPosition();
	}  
     }
	 setRenderPosition(mPosition, rot);
  }
.
.
.
}

Perhaps the issue has to do with the x-rotation being tied to the player's HEAD rotation, as opposed to the z-rotation which is probably tied to the BODY rotation. Or perhaps I need to add an extra step to calculating the deltas?

#1
07/27/2007 (7:49 am)
Maybe adjusting the player's warpTicks will help?
#2
07/27/2007 (8:12 am)
Ok so I discovered that a player's mRot must be updating differently than a player's mHead. That is, updates of a player's body rotation are updated more smoothly. Trying to find out why...