Game Development Community

Getting the position of the orbit camera

by Bryce · in Torque Game Engine · 01/09/2010 (8:01 pm) · 2 replies

I'm almost positive that I'll need to dig into the engine code for this one. Does anybody know how I could access the exact position of the camera when it is in orbit mode? If I use:
%camPos = ServerConnection.camera.getPosition();

It will return the position of the observer (Alt+C) camera. Camera code is not my specialty, so help is very much appreciated!

Thanks,
Bryce

#1
01/09/2010 (10:01 pm)
When you're in orbit mode, just like when you're in 3rd person, you're not actually using the camera object. (I think.) Have a look at getCameraTransform methods in Shapebase or Player - I think that should be where that stuff is worked out.
#2
01/10/2010 (12:17 am)
Yes, got it! Put this into GameConnection.cc:

ConsoleMethod(GameConnection, getThirdPersonCameraPosition, const char *, 2, 2, "() Gets the position of the third person camera")
{
	MatrixF cam;
	Point3F camPos;
	object->getControlCameraTransform(0,&cam);
	cam.getColumn(3, &camPos);

   char *returnBuffer = Con::getReturnBuffer( 256 );
   dSprintf( returnBuffer, 256, "%g %g %g", camPos.x, camPos.y, camPos.z );

   return returnBuffer;
}

Usage in script:
%camPos = ServerConnection.getThirdPersonCameraPosition();