camera rotating on its own

Blitz3D Forums/Blitz3D Beginners Area/camera rotating on its own

ryan scott(Posted 2005) [#1]
if i have a camera above and behind my car, but if the camera is moved from behind to forward of the car, so its pointing down at the car, basically tipped forward, the camera's yaw all of a sudden flips negative.

The PointEntity seems to be trying to make the camera always be right side up.

it's really annoying - i don't want it to do that. i don't need the camera deciding what way is right side up. it's important because my vehicle can climb walls, go upside down, and the cam needs to not do anything mysterious. there is no concept of 'down' in my world, except y++ relative to each object.

here's output from monitoring the camera. i'm doing nothing here except the camera gets tipped slightly from slightly behind looking down on car, to slightly ahead looking down on car. as if you looked down at something slightly behind you. Yaw immediately tries to turn the camera around once it detects you are looking upside down at your object.

; roll pitch yaw
;cam:0.0 89.7855 95.2158
;cam:0.0 89.8021 -94.8024
;cam:0.0 89.7867 94.5051
;cam:0.0 89.8002 -95.4105

it seems that it actually flips when you are looking down/backwards at the world.

it does make the world be right side up! But I really don't want that.

is there a way to turn off this behavior? i don't think i can allow it to turn it and then force the yaw back, because cam and car could really be in any orientations. it would be kludgy at best.

any ideas?


Stevie G(Posted 2005) [#2]
I'm pretty sure that this is gimbal lock .. There are ways round this

http://www.blitzbasic.com/Community/posts.php?topic=44977&hl=gimbal

... or you could use quarternions

Stevie


ryan scott(Posted 2005) [#3]
Stevie G, you seem to know your stuff! Want a project?


email me @ fortressgame at techhouseliving.com ? the system doesn't have an email address for you.


DH(Posted 2005) [#4]
I'm pretty sure that this is gimbal lock


Agreed


... or you could use quarternions


Also agreed!


SheepOnMintSauce(Posted 2005) [#5]
Just out of curiousity, what are quarternions?


DH(Posted 2005) [#6]
http://mathworld.wolfram.com/Quaternion.html


VP(Posted 2005) [#7]
So let me get this straight, you start with the idea of having a square root of -1 and then make it even more complex?

Sheesh :)


big10p(Posted 2005) [#8]
Hmm, that math-head explanation of quaternions is as clear as mud. Anyone know of a decent explanation for complete idiots? i.e. not littered with mathematic symbols and formulae that are a foreign language to someone like me. :)


SheepOnMintSauce(Posted 2005) [#9]
Whoa muma! Whoosh.. right over my head that one.


ryan scott(Posted 2005) [#10]
hmm... is there any code with examples on how to either fix the gimbal lock or use quants? unfortunately can't figure out how to call the gimbal lock workaround, there's procedures but no idea how to use em. and i can't figure it out. :/

there's a discussion here but i cannot understand how to use it in my code.
http://www.blitzbasic.com/Community/posts.php?topic=31781


DJWoodgate(Posted 2006) [#11]
I suppose you could use aligntovector, as mentioned somewhere it uses quats. Tformvector might be useful as well to position the camera relative to car orientation.


jhocking(Posted 2006) [#12]
I would always recommend AlignToVector over PointEntity. I do use the latter for roughing out implementations, because it's simpler, but I always switch to the former later because it gives so much more control.


Sir Gak(Posted 2006) [#13]
What are quaternions used for? Math to determine vectors? Also, I'm a little rusty on matrices. Anybody got a simple explanation on what they are used for, and how they work (ie how they multiply out)? Finally, are either quaternions or matrices used in the tform commands? I guess I am a dunderhead (dunce, dolt, blockhead, thick-skull, etc) on these, but like my sig says, when in doubt, find out.