Public Group

# Camera

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

## Recommended Posts

Hi! I'm trying to make a camera. Can anyone point out what I'm doing wrong. It's perhaps more math then programming. I want to move in the direction v = [0, 0, S, 0], in local coordinates for the camera. Then I need to rotate that vector so I get it in global coordinates. The angles I want to rotate with is yaw, pitch and roll. Say my rotation matrix is M. Then I get Mv = [Sm13, Sm23, Sm33, Sm43]. So I only need to care about the third row in the matrix. I should multiply the seperate matricies in the order Yaw * Pitch * Roll. Then I get: m13 = sin Yaw * cos Roll + cos Yaw * sin Roll * sin Pitch m23 = cos Yaw * cos Roll * sin Pitch - sin Yaw * sin Roll m33 = cos Yaw * cos Pitch m43 = 0 My code which is trying to do this:
void movePlane(float secsPerFrame)
{
GLdouble m13, m23, m33;
m23 = cos(camera.heading) * cos(camera.roll) * sin(camera.pitch) - sin(camera.heading) * sin (camera.roll);
camera.x += secsPerFrame * -speed * m13;
camera.y += secsPerFrame * -speed * m23;
camera.z += secsPerFrame * -speed * m33;
I don't get to proper result. The plane takes off when I increase the pitch, for instance. :)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634133
• Total Posts
3015733
×