# Camera Update question

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

## Recommended Posts

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

##### Share on other sites
Why are you not using the D3DX functions for matrix tranformation?

ace

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

##### Share on other sites
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:
{
}

RotateCameraLeft:
{
}

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]

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

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633338
• Total Posts
3011418
• ### Who's Online (See full list)

There are no registered users currently online

×