Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving a 3d camera on XNA
    primarykey
    data
    text
    <p>Im doing some practices on XNA, and i created a class that represents a Camera.</p> <p>My objective is that when the user press some keys make a translation of the camera (not the target) 90 degrees in the X axys (to see an object that i placed in the scene from different angles). By the moment i move the camera in X, Y, and Z without problems.</p> <p>Actually to set up my camera i use the following lines of code:</p> <pre><code>public void SetUpCamera() { #region ## SET DEFAULTS ## this.FieldOfViewAngle = 45.0f; this.AspectRatio =1f; this.NearPlane = 1.0f; this.FarPlane = 10000.0f; #endregion this.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(this.FieldOfViewAngle), 16 / 9, this.NearPlane, this.FarPlane); this.ViewMatrix = Matrix.CreateLookAt(new Vector3(this.PositionX, this.PositionY, this.PositionZ), new Vector3(this.TargetX, this.TargetY, this.TargetZ), Vector3.Up); } </code></pre> <p>I have this method to move the camera:</p> <pre><code>public void UpdateView() { this.ViewMatrix = Matrix.CreateLookAt(new Vector3(this.PositionX, this.PositionY, this.PositionZ), new Vector3(this.TargetX, this.TargetY, this.TargetZ), Vector3.Up); } </code></pre> <p>Then in the game (update event handler i have the following code)</p> <pre><code>if (keyboardstate.IsKeyDown(Keys.NumPad9)) { this.GameCamera.PositionZ -= 1.0f; } if (keyboardstate.IsKeyDown(Keys.NumPad3)) { this.GameCamera.PositionZ += 1.0f; } this.GameCamera.UpdateView(); </code></pre> <p>I would like to know how to make this camera translation of 90 degrees to surround one object that i placed in the screen.</p> <p>To explain my self better about the camera movement here is a video on youtube that uses the exact movement that im trying to describe (see from 14 second) <a href="http://www.youtube.com/watch?v=19mbKZ0I5u4" rel="nofollow noreferrer">http://www.youtube.com/watch?v=19mbKZ0I5u4</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload