Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Major Mammories

Keeping camera upright

This topic is 5759 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

Can anyone tell me why this results in me walking with a limp neck, i.e. im rolling when im trying to keep my camera upright. Dim vT As New Vector3(0.0F, 0.0F, 0.0F) Dim vR As New Vector3(0.0F, 0.0F, 0.0F) If keyValues(Asc("W")) <> 0 Then vT.Z += 2.0F '' Move Forward If keyValues(Asc("S")) <> 0 Then vT.Z -= 2.0F '' Move Backward If keyValues(Asc("A")) <> 0 Then vT.X -= 1.0F '' Slide Left If keyValues(Asc("D")) <> 0 Then vT.X += 1.0F '' Slide Right If keyValues(CInt(Keys.Down)) <> 0 Then vT.Y -= 1.0F '' Slide Down If keyValues(CInt(Keys.Up)) <> 0 Then vT.Y += 1.0F '' Slide Up If keyValues(Asc("Q")) <> 0 Then vR.Y -= 1.0F '' Turn Right If keyValues(Asc("E")) <> 0 Then vR.Y += 1.0F '' Turn Left If keyValues(Asc("Z")) <> 0 Then vR.X -= 1.0F '' Pitch Down If keyValues(Asc("C")) <> 0 Then vR.X += 1.0F '' Pitch Up If keyValues(CInt(Keys.Left)) <> 0 Then vR.Z -= 2.0F '' Roll CW If keyValues(CInt(Keys.Right)) <> 0 Then vR.Z += 2.0F '' Roll CCW If MousePosistion.X > 1 Then vR.Y += MousePosistion.X * 0.2F ElseIf MousePosistion.X < -1 Then vR.Y += MousePosistion.X * 0.2F End If If MousePosistion.Y > 1 Then vR.X += MousePosistion.Y * 0.2F ''Look Up ElseIf MousePosistion.Y < -1 Then vR.X += MousePosistion.Y * 0.2F ''Look Down End If velocity = Vector3.Add(Vector3.Multiply(velocity, 0.9F), Vector3.Multiply(vT, 0.1F)) angularVelocity = Vector3.Add(Vector3.Multiply(angularVelocity, 0.9F), Vector3.Multiply(vR, 0.1F)) '' Update position and view matricies Dim matT, matR As Matrix Dim qR As Quaternion vT = Vector3.Multiply(Vector3.Multiply(velocity, fSecsPerFrame), speed) vR = Vector3.Multiply(Vector3.Multiply(angularVelocity, fSecsPerFrame), angularSpeed) matT = Matrix.Translation(vT.X, vT.Y, vT.Z) positionMatrix = Matrix.Multiply(matT, positionMatrix) qR = Quaternion.RotationYawPitchRoll(vR.Y, vR.X, 0.0F) matR = Matrix.RotationQuaternion(qR) positionMatrix = Matrix.Multiply(matR, positionMatrix) viewMatrix = Matrix.Invert(positionMatrix) Device.Transform.View = viewMatrix Any pointers will be great. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Seems there are only three possiblities. One the processing of the keystrokes, two the yaw/pitch/roll matrix or three the quaternion matrix. Perhaps not really the only possible errors, but the ones most immediately related to your problem. I assume these are DirectX functions so they can be assumed correct, but your usage of them may not be.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!