Jump to content

Camera Orbiting Rotation Issue And Possible Fix


Steve_Yorkshire

Recommended Posts

I have been digging around in the camera related C++ parts of the engine after noticing a few strange going ons with OrbitMode/OrbitObject.

 

function serverCmdisoCam(%client, %deg)
{
	//mDegToRad(35.264) = 0.615472907 //true isometric
   //mDegToRad(90) = 1.570796 //true top down
   echo("\c1isocam " @ %deg);
 
   %camera = %client.camera;
   %control = %client.player;
 
   if(%deg < 5)
   {
      echo("\c2error: deg < 5 setting to ServerConnection.getControlCameraDefaultFov " @ ServerConnection.getControlCameraDefaultFov());
      %deg = ServerConnection.getControlCameraDefaultFov();
   }
 
   %rad = mDegToRad(%deg);
 
   if(!isObject(%control))
      echo("\c2error: no control object for client " @ %client);
   else
      %camera.setOrbitObject(%control, %rad @ " 0 0", 5.0, 20.0, 20.0, true, "0 -4 2", false);
}

 

When orbiting a control object (such as the player) and sending a new server command to change the rotation or distance or offset of the camera, all values update except for rotation which does not change. However when checking what the rotation is with Torquescript it returns the updated rotation even though the camera/screen rotation has clearly not changed.


It turns out that in camera.cpp readPacketData does not read position for orbiting because it is inhereted from the object (makes sense) but that it also does not unpack the rotation, meaning that the orbit rotation around the object can only be called once when it is initially set to orbit the object.

 

//line 1146 camera.cpp
   _setPosition(pos,rot);
   // Movement in OrbitObjectMode is not input-based - don't reset interpolation
   if(mMode != OrbitObjectMode)
   {
      mDelta.pos = pos;
      mDelta.posVec.set(0.0f, 0.0f, 0.0f);
      mDelta.rot = rot;
      mDelta.rotVec.set(0.0f, 0.0f, 0.0f);
   }

 

I cannot see any particular reason for the rotation to be unread, so I propose the following change to add rotation for orbitModes.

 

_setPosition(pos,rot);
   // Movement in OrbitObjectMode is not input-based - don't reset interpolation
   if(mMode != OrbitObjectMode)
   {
      mDelta.pos = pos;
      mDelta.posVec.set(0.0f, 0.0f, 0.0f);
      mDelta.rot = rot;
      mDelta.rotVec.set(0.0f, 0.0f, 0.0f);
   }
   else//york new
   {
	   //yorks pass rotation for orbitmode
	   mDelta.rot = rot;
	   mDelta.rotVec.set(0.0f, 0.0f, 0.0f);
   }//yorks new end

 

Now when %client.setOrbitMode/Object is called via a server command it will update the rotation as well as all the rest of the passed values such as distance and offset.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...