Jump to content
  • Advertisement
Sign in to follow this  
Zmax

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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:
{
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]

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!