Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Camera Update question

Started by Zmax Sep 11, 2005 at 4:35 AM 3 replies 350+ views
Original Post
Zmax
Zmax
I'm using a matrix as a camera where i make all the rotations,translations modifications .After that i asign it to the device.transform.view. The rotations work well the moving too but when i rotate the camera after i moved it, it jumps in back in the (0,0,0), origin position.How do i update the new position in the camera matrix. For moving i used something like: Camera.M41 = Camera.M41 - Camera.M13 Camera.M42 = Camera.M42 - Camera.M23 Camera.M43 = Camera.M43 - Camera.M33 forward moving,...why the position is not updated?hmm...
dave
dave
Why are you not using the D3DX functions for matrix tranformation?

ace
Zmax
Zmax
Is the same thing no?For example if I use "translate" in a place is the same thing like setting the m41,m42,m43...i know i have to multiply somehow the matrix,...or i don;t know...the functions work well but from the (0,0,0) origin point. how do i change,update, that origin so i rotate from exampe form the (x,y,z) point.
Calin
Calin
Hi
To put it in a simple way: When you move you must also consider the *heading*.
You need to obtain a value that changes acording to your heading. Once you have that value you multiply it with 1,2 or whatever depending how fast you want to move across the map. Here is a snipet of code to help you:

const float piover180 = 0.0174532925f;

MoveCameraFoward(void)
{
xpos -= (float)sin(heading*piover180) * 1.0f ;
zpos -= (float)cos(heading*piover180) * 1.0f ;
}

RotateCameraRight:
{
heading += 4.0f
CameraRotation = (heading * piover180)
}

RotateCameraLeft:
{
heading -= 4.0f
CameraRotation = (heading * piover180)
}

Also as ace_lovegrove pointed out, try using D3DX functions for matrix tranformation

Hope this helps.

If you don`t understand something ask.

[Edited by - Calin on September 11, 2005 6:12:07 AM]
My project`s facebook page is “DreamLand Page”
Zmax
Zmax
This is the rotation i use...
Rotations.X = Rotations.X - MousePosition.X * 0.005
Rotations.Y = Rotations.Y - MousePosition.Y * 0.005

Camera.RotateYawPitchRoll(Rotations.X, Rotations.Y, 0)

[Edited by - Zmax on September 11, 2005 5:36:28 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.