Advanced Camera Modifications
by Chris French · in Torque Game Engine · 09/16/2006 (1:32 pm) · 8 replies
This is a snipet of the advanced camera code that gets the position for the 3rd person camera. Im trying to create a camera for a sidescrolling shooter using the meat from this camera. The problem i'm havin is that when i flip the player model(turn him 180 degrees) the camera switches sides as well (Stays over the right shoulder). What i want the camera to do is use the world positioning so that the camera doesn't switch sides based on what direction the player is facing. Im pretty sure the change needs to be made "objToWorld = playerObj->getRenderTransform();" in there... but im not exactly sure how do it. How exactly do i get the player coordinates and keep them in world coordinates so that i can move the camera using world coords but still have the player as a origin point?
case ThirdPersonMode :
{
if( playerObj != NULL ) {
MatrixF objToWorld;
objToWorld = playerObj->getRenderTransform(); // gets a MatrixF of mRenderObjToWorld from sceneObject
objToWorld.mulP(mCurrentThirdPersonOffset, &cameraPosWorld); // sets Camera Position using Player coords(mat) and offset(p3F)
}
break;
}About the author
#2
09/18/2006 (10:14 am)
Please let me know if anything is unclear or perhaps I need to rethink my questions(are they too broad).
#3

edit: wierd... i can get it not to work on my computer??? tried clearing cookies, cache, used different browsers... idk
09/19/2006 (11:05 am)
Here is an image of what i am talking about:
edit: wierd... i can get it not to work on my computer??? tried clearing cookies, cache, used different browsers... idk
#4
09/19/2006 (11:07 am)
Image isn't working.
#5
09/19/2006 (10:29 pm)
What problem are you trying to fix? Can you give a succinct explanation of what's going wrong?
#6
Does this help explain the situation?
09/20/2006 (10:13 am)
I have the camera offset on the x axis 30 units from the player (straight out from the players right side). When i do a transform on the player, with a key bind, to turn him 180 degrees (face the opposite direction), the camera switches sides (continues to look over the right shoulder). It seems as if, when the player rotates 180 degrees to turn around so does the coordinate system that the camera is using to position itself.Does this help explain the situation?
#7
09/20/2006 (10:20 am)
The third person camera is tracked as being relative to the player. So if the player moves, it will, too.
#8
09/20/2006 (10:36 am)
Would it be sloppy to mulitiply the offset by -1 everytime he switches direction... it seemed hackish to me but i suppose until i can figure out a way to do it in the C++ camera code, the script hack will have to work.
Torque 3D Owner Chris French
But im guessing a lot can be said so i'll try to be more specific.
i want to get the player objects world coords and adjust those coords and set them for the camera. Looking at the code in sceneobject has me wondering if resetWorldBox(); is screwing up what im trying to do... not sure.