Jump to content
  • Advertisement
Sign in to follow this  
Johannes1991

Camera issue

This topic is 3542 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 cant get my camera to rotate along the player in a certain radius and in the same direction. someine got a god equation? using directX and c++ Thanks in advance [Edited by - Johannes1991 on January 6, 2009 1:49:57 PM]

Share this post


Link to post
Share on other sites
Advertisement
It sounds like you're building a third-person game of some sort and want to have the camera follow the player at some distance above and behind him, and face in the same direction as the player?

Let's say you define +Y as up, +X as right, and +Z as the direction the camera faces. What you want to do is find out a couple of points relative to the player's position.

To do this, you'll need the player's World transformation matrix. The player's World transformation is what you would use to move the player's avatar from the origin to its actual location and orientation in the game world's space.

To find a point above and behind the player (the camera's actual location), you'd take a vector like (0, 10, -20) and multiply it by the player's World matrix. Then you'll want to find the point the camera is pointing at by taking a vector like (0, 0, 100) and multiplying it by the player's World matrix. The last vector you need to produce a camera matrix is an "up" vector. For this, if you're working with a human on the ground, you can almost always just use (0,1,0).

From there, DirectX has a utility function to produce a View matrix from vectors Camera, Target, and Up.

Is that what you were looking for?

Share this post


Link to post
Share on other sites
So i should do like this
matTranslate is the players position matrix
(0,10,20)*matTranslate

can someone write an example?

[Edited by - Johannes1991 on January 7, 2009 9:01:28 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Johannes1991
So i should do like this
matTranslate is the players position matrix
(0,10,20)*matTranslate
You need the players full matrix, not just position. otherwise all that will do is move the point (0, 10, 20) relative to the player's position, not their orientation.

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!