Free look clamp
by Andrew Hull · in Torque Game Engine · 11/28/2006 (8:46 pm) · 12 replies
So I implemented this change of code in player.cc to stop free look mode from clamping:
But now, whenever you let go of the 'Z' key, the camera sort of... "unwinds" itself, as many times as you rotated the camera around the player. How do I get the camera to stay where I left it?
if (move->freeLook && ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson())))
{
mHead.z += y;
//ORIGINAL CODE:
//mHead.z = mClampF(mHead.z + y,
// -mDataBlock->maxFreelookAngle,
// mDataBlock->maxFreelookAngle);
}But now, whenever you let go of the 'Z' key, the camera sort of... "unwinds" itself, as many times as you rotated the camera around the player. How do I get the camera to stay where I left it?
About the author
#2
12/06/2006 (1:13 pm)
Nobody? Anything? Anything at all?
#3
12/06/2006 (2:00 pm)
How about wrapping it around within -pi to pi ?mHead.z += y;
while (mHead.z > M_PI_F)
mHead.z -= M_2PI_F)
while(mHead.z < -M_PI_F)
mHead.z += M_2PI_F)
#4
12/06/2006 (2:58 pm)
What do you mean by "clamping"?
#5
i think that's clear from the code snippet he posted..
Andrew -
would it be sufficient for your purposes to just set the maxFreeLookAngle to pi ?
if so, that would be a simpler solution than my suggestion above.
12/06/2006 (3:32 pm)
Allyn - i think that's clear from the code snippet he posted..
Andrew -
would it be sufficient for your purposes to just set the maxFreeLookAngle to pi ?
if so, that would be a simpler solution than my suggestion above.
#6
Yes, it would suffice to set it to pi. I think that i tried that once with no luck. Maybe i did something different, but i will try that tonight. Thanks Orion.
@Allyn
Clamping, as in when you are in Free Look mode (holding down the 'Z' key in third person) you can only rotate from behind the player, to the front of the player. You can't orbit freely around the player.
And yes, i know about the Advanced Camera resource, but that is more than i need.
12/06/2006 (4:08 pm)
@OrionYes, it would suffice to set it to pi. I think that i tried that once with no luck. Maybe i did something different, but i will try that tonight. Thanks Orion.
@Allyn
Clamping, as in when you are in Free Look mode (holding down the 'Z' key in third person) you can only rotate from behind the player, to the front of the player. You can't orbit freely around the player.
And yes, i know about the Advanced Camera resource, but that is more than i need.
#7
12/07/2006 (11:48 am)
Well... setting maxFreeLookAngle to PI does not work. The code i posted above works, i just don't want the camera to spin around the player many times when FreeLook is disabled.
#9
Nope, i don't read c++. So i have no clue from that, i just wanted to know what he meant by "Clamping".
12/11/2006 (9:41 am)
Quote:i think that's clear from the code snippet he posted..
Nope, i don't read c++. So i have no clue from that, i just wanted to know what he meant by "Clamping".
#10
eg:
12/12/2006 (9:50 am)
'clamping' refers to restricting a value to some range by mapping values outside the range to the boundaries of the range.eg:
if (value < rangeMin) value = rangeMin if (value > rangeMax) value = rangeMax

Torque Owner Andrew Hull