Sign in to follow this  
forsandifs

Camera control...

Recommended Posts

forsandifs    154
The following code is used to calculate new camera Look, Up, and Right vectors for a given change in Yaw, Roll, and Pitch:


D3DXMATRIX RotationAroundLook, RotationAroundUp, RotationAroundRight;
D3DXMatrixRotationAxis(&RotationAroundLook, &Look, DeltaRoll);
D3DXMatrixRotationAxis(&RotationAroundUp, &Up, DeltaYaw);
D3DXMatrixRotationAxis(&RotationAroundRight, &Right, DeltaPitch);

D3DXVec3TransformCoord(&Look, &Look, &(RotationAroundRight * RotationAroundUp) );
D3DXVec3TransformCoord(&Up, &Up, &(RotationAroundRight * RotationAroundLook) );
D3DXVec3TransformCoord(&Right, &Right, &(RotationAroundUp * RotationAroundLook) );




I thought this was working as intended until recently (today). I realised that when I move the mouse in a circular motion (which should only change the Yaw and Pitch of the camera), the image rotates around the Look axis, so after many similar cicular movements it ends up upside down...

Why is that happening and how can I implement proper camera control with Yaw, Pitch and Roll? (Actually I'm happy to dispense with Roll if it helps).

Share this post


Link to post
Share on other sites
jyk    2094
It looks like you've essentially implemented a 6DOF control scheme; with a 6DOF control scheme, cumulative yaw and pitch can indeed result in perceived roll.

It sounds like you want 'from scratch' Euler or spherical angles instead. In other words, represent the orientation using two angles (e.g. pitch and yaw), and build an orientation matrix from them 'from scratch' each update.

Share this post


Link to post
Share on other sites
Kalten    189
i think

"D3DXMatrixRotationAxis(&RotationAroundLook, &Look, DeltaRoll);"

If thats been calculated in your mouse's view change code then its possible that it is where you've come unstuck...

I'm not sure on your naming convention but...

I'm expecting 'rotation around look' is a reference to a target vector,
'rotation around up', is a reference to the 'up' vector or Y plane,
and 'rotation around right' is a reverence to the horizontal or X plane.

Your use of deltaroll against look, also reads to me that you have a roll around the target which would result in a movement in a circle on the Z,Y plane, not the X,Y plane.
ZY movement with a target point defined will cause the camera to roll with the target in the middle, kind of like an airplane doing a barrel roll.
XY movement with a defined target will cause the camera to rotate around the target much like a bucket on a string rotates around you when you spin it around you.

Share this post


Link to post
Share on other sites
forsandifs    154
Quote:
Original post by jyk
It looks like you've essentially implemented a 6DOF control scheme; with a 6DOF control scheme, cumulative yaw and pitch can indeed result in perceived roll.


Ah yes, thank you! I double checked the intended behaviour by reproducing the coning of the Look vector using my left hand and indeed it produces an overall Roll.

Given that it is actually intended behaviour, I wouldn't mind leaving it as it is..

BUT, I have seen camera control schemes implemented in games which are exactly what I want and I would love to be able implement them instead. An example that comes to mind is the ship controls in the combat prototype for Infinity: A Quest For Earth. I've spent a fair bit of time in the Infinity Combat Prototype and I'm pretty certain that moving the mouse in a circular motion does not produce an overall Roll?.. How is that done?
(EDIT: I could be wrong actually, I'm going re-install that prototype and double check it doesn't have the Roll behaviour my scheme has).
(EDIT 2: Boo, I can't re-install the prototype cos it doesn't support current ATI drivers >.< )

[Edited by - forsandifs on November 11, 2010 6:39:10 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this