Game Development Community

Setting up a camera at a different angle

by dArchitect · in Torque Game Engine · 02/04/2009 (11:03 am) · 2 replies

By default TGE has the camera behind a character. I want to change this default camera to the right, or left, of my main character while still using the same keyboard/mouse system that is place. I have read through a lot of forms and tutorials here but have not come close to getting this to work. An
idea of this is getting something simular to what TGB has but without being restricted to just that camera position.

#1
02/04/2009 (12:28 pm)
Have you tried something as simple as offsetting your camera node in your player model? Codewise, it is relatively easy to add a X or Y offset along with the current Z offset. Or, even better, add multiple cam nodes (L & R) along with the current cam and eye nodes, this should help: Multiple 3rd Person Cameras
#2
02/04/2009 (10:59 pm)
Open up shapebase.cpp and look in the function: void ShapeBase::getCameraTransform(F32* pos,MatrixF* mat)

Thats where all the camera positioning and rotation stuff for a ShapeBaseObject resides. You can mess around with that code to change the default camera behaviors. Heres some additional code you can use to experiment with:

Point3F camPos = getRenderPosition(); //get the shapebase's current rendering position

mat->set(EulerF(0,0,0));    //set the camera rotation along the x, y, and z axises.
mat->setColumn(3, camPos);  //set the camera position

To manipulate the position, you can use camPos.x, camPos.y, and camPos.z.

I'll leave the rest up to you as an exercise.