Sign in to follow this  

Crazy Camera

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I'm trying to make your standard, fly anywhere debug Camera in DirectX and have gotten a bit stuck. Essentially, all I want the Camera to do is be rotatable and then move in the direction it's facing. I was trying to implement the rotation part by rotating the eye vector around but I now have an interesting issue when rotating the Camera all the way around. I can't really explain it, so instead I made a video of it and uploaded it. All I am doing in that video is holding the button to rotate the Camera left. The code for rotating the Camera is shown below:
void Camera::rotateCamera(const D3DXVECTOR3 &rot)
{
	D3DXMATRIX rotMat;
	D3DXMatrixRotationYawPitchRoll(&rotMat, rot.x, rot.y, rot.z);
	D3DXVec3TransformCoord(&m_at, &m_at, &rotMat);

	m_cameraMoved = true;
}
As ever, any help is appreciated.

Share this post


Link to post
Share on other sites
A couple of things:

Which parameter in the YawPitchRoll call are you changing when you rotate the camera?

Assuming y is up and your rot vector is comprised of rotation angles in radians, the normal YawPitchRoll call would be:

D3DXMatrixRotationYawPitchRoll(&rotMat, rot.y, rot.x, rot.z );

Are you interpreting the angles in degrees and not radians? The video sort of suggests that. If you input rot.y = 45 and you think that's 45 degrees, it's really 45 radians and that's really 2500 degrees.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
D3DXMatrixRotationYawPitchRoll(&rotMat, rot.y, rot.x, rot.z );
You would have thought so wouldn't you, but I'm passing in 0.01f in the X component of the vector, looks like my Yaw and Pitch got messed up somehow.

Thanks for that article MassacrerAL, the one you linked to was for Managed DirectX but I found the DirectX 9 one and took a look at that. It's a really nice description of how to setup a Camera.

[Edited by - MrDoom on February 17, 2008 9:09:02 AM]

Share this post


Link to post
Share on other sites

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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