• Create Account

### #ActualBacterius

Posted 22 April 2012 - 08:01 PM

As promised here is the diagram (click to enlarge):

This is for the 2D case (in 3D the concept is exactly the same, except the vectors have three components and you need two angles to describe an arbitrary direction vector instead of one - this is where spherical coordinates come in). I hope this makes it a bit clearer to you.

So basically you use your two angles (controlled by the mouse) to change the direction in which the camera is looking (and you obtain the "look" direction vector by using spherical coordinates from the two angles and an arbitrary radius*), you use the keyboard to change the camera's position as usual, and you derive the camera's target by adding these two vectors together as the diagram shows. You then give this to the D3D LookAt function which will give you the view matrix you want.

* the radius does not matter in this case because as I explained earlier, using a bigger or smaller radius wouldn't change the direction of the "look" direction vector, which means the resulting matrix will be identical (because the function normalizes the "look" direction directly, which cancels out any scaling).

### #3Bacterius

Posted 22 April 2012 - 08:00 PM

As promised here is the diagram (click to enlarge):

This is for the 2D case (in 3D the concept is exactly the same, except the vectors have three components and you need two angles to describe an arbitrary direction vector instead of one - this is where spherical coordinates come in). I hope this makes it a bit clearer to you.

So basically you use your two angles (controlled by the mouse) to change the direction in which the camera is looking (and you obtain the "look" direction vector by using spherical coordinates from the two angles and an arbitrary radius*), you use the keyboard to change the camera's position as usual, and you derive the camera's target by adding these two vectors together as the diagram shows. You then give this to the D3D lookat function which will give you the view matrix you want.

* the radius does not matter in this case because as I explained earlier, using a bigger or smaller radius wouldn't change the direction of the "look" direction vector, which means the resulting matrix will be identical (because the function normalizes the "look" direction directly, which cancels out any scaling).

### #2Bacterius

Posted 22 April 2012 - 07:56 PM

As promised here is the diagram (click to enlarge):

This is for the 2D case (in 3D the concept is exactly the same, except the vectors have three components and you need two angles to describe an arbitrary direction vector instead of one). I hope this makes it a bit clearer to you.

### #1Bacterius

Posted 22 April 2012 - 07:56 PM

As promised here is the diagram:

This is for the 2D case (in 3D the concept is exactly the same, except the vectors have three components and you need two angles to describe an arbitrary direction vector instead of one). I hope this makes it a bit clearer to you.

PARTNERS