Help finding camera "up" & "forwards"

Blitz3D Forums/Blitz3D Programming/Help finding camera "up" & "forwards"

Roland(Posted 2006) [#1]
Hey all,

I'm hoping to write an app that is a helper to a rendering engine, and to do so, i need to convert blitz's camera, which has an X,Y,Z rotation to a "Forwards" and "Up" rotation model instead. I'm not exactly a wizard with matrices... would anyone be able to help me out with the conversion? Insight into Field of View as it pertains to the blitz camera would also be really useful!

thanks,
roland


Rob Farley(Posted 2006) [#2]
Use TranslateEntity instead of MoveEntity


big10p(Posted 2006) [#3]
I think there's some FOV code in the archives, somewhere.


Roland(Posted 2006) [#4]
Hey Rob,

I'm not sure what you mean here... I need to actually return a value for the camera's "forward" vector and the camera's "up" vector. Not sure how to do that!

Thanks, big10p... I think I found the FOV stuff I needed!

best,
roland


Rob Farley(Posted 2006) [#5]
Ah, see where you're coming from now.

Well, the simple way to do that is store the xyz of where you were and take the xyz of where you are away from it.

ie,
I was at 0,0,0 I am now at 5,3,2
so I moved 5 on X, 3 on Y and 2 on Z.
I'm now at 10,3,2
So I moved 5 on x, 0 on Y and 2 on Z.


DJWoodgate(Posted 2006) [#6]
Maybe the forward vector could also be obtained by

TformVector 0,0,1,camera,0

and the up vector by

TformVector 0,1,0,camera,0.

The tform commands take care of the matrix stuff for you. If you need go the opposite way and set the blitz object to an orientation defined by an up and forward vector you could perhaps use AlignToVector on the appropriate axis:

AlignToVector camera,upx,upy,upz,2
AlignToVector camera,fwdx,fwdy,fwdz,3


Those two vectors may well describe the exact rotation of the camera in global terms since roll and pitch would uniquely effect the global up vector and yaw and pitch would uniquely effect the global forward vector.

Thinking about it that may not be entirely correct, but it does not matter because there is only one way to interpret an up vector and a forwards vector. No need to worry about rotation order etc. Hence this may be a more reliable way to store orientation. That's my guess anyway.


Roland(Posted 2006) [#7]
Hey David,

that did the trick perfectly. Thanks so much for everyone's replies!

best, roland