Jump to content
  • Advertisement
Sign in to follow this  
dpoon

D3D Quaternion Camera demo released.

This topic is 4025 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

Not sure whether this should belong here or in the DirectX forums. So please move if the DirectX forums is more appropriate. I've just released the next demo in my Direct3D camera demo series over on my website. This demo shows how various camera behaviors can be combined together. The following camera behaviors are implemented in this demo: first person, spectator, flight, and orbit. The first person camera behavior simulates the view from the perspective of the player. The spectator camera behavior simulates a floating camera that moves in the direction that the camera is looking. The flight camera behavior simulates the view from the cockpit of an airplane. Finally the orbit camera behavior simulates a third person view of the player and allows the camera to orbit the player. The camera class that accompanies this demo uses quaternions throughout. I could have used vectors and/or matrices instead, but I wanted to implement as much of the camera as I could using only quaternions. Of particular note is the camera class' implementation of the orbit camera behavior. Many quaternion-based third person orbit style cameras maintain an offset vector and uses quaternions to rotate this offset vector when the camera is being rotated. The new camera position is then used to rebuild a look-at style view matrix. This demo's orbit logic begins by setting the camera's orientation to that of the orbit target. Rotating the camera will affect this orientation. So far this is exactly how the other camera behaviors (first person, spectator, and flight) work. But once the orbit camera is rotated the camera's view matrix is updated to accommodate the new orientation. To implement a third person orbit style view of the target the camera's position is calculated to be a fixed distance from the target's position. Specifically this demo takes the orbit target's world position and translates this point by a fixed amount along the camera's local negative Z axis. This new camera position is then used to update the view matrix. Further details and download links can be found here.

Share this post


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