#### Archived

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

# 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.

## 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 on other sites
Anyone, im still pretty stuck on this.

Thanks

##### Share on other sites
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.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011321
• ### Who's Online (See full list)

There are no registered users currently online

×