Crazy Camera

Started by
2 comments, last by MrD 588 16 years, 2 months ago
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.
Advertisement
if i were you i would begin with camera from scratch. this might help.
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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]

This topic is closed to new replies.

Advertisement