|
using System;
using Microsoft.DirectX;
namespace Bornander.Games.Direct3D
{
/// <summary>
/// Class for grouping the camera vectors together in a convenient way.
/// </summary>
class Camera
{
#region Private members
/// <summary>
/// The cameras position in 3D space.
/// </summary>
private Vector3 position;
/// <summary>
/// This defines which direction the camera consideres to be up.
/// </summary>
private Vector3 upDirection;
/// <summary>
/// This is a point in 3D space towards which the camera will look.
/// </summary>
private Vector3 lookAtTarget;
#endregion
public Camera(Vector3 position, Vector3 upDirection, Vector3 lookAtTarget)
{
this.position = position;
this.upDirection = upDirection;
this.lookAtTarget = lookAtTarget;
}
#region Public properties
/// <summary>
/// This property in here mostly for convinience, it wraps up the call to <code>Matrix.LookAtLH</code>.
/// </summary>
public Matrix ViewMatrix
{
get { return Matrix.LookAtLH(position, lookAtTarget, upDirection); }
}
public Vector3 Position
{
get { return position; }
set { position = value; }
}
public Vector3 LookAtTarget
{
get { return lookAtTarget; }
set { lookAtTarget = value; }
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Article videos
Oakmead Apps Android Games
21 Feb 2014: Best VB.NET Article of January 2014 - Second Prize
18 Oct 2013: Best VB.NET article of September 2013
23 Jun 2012: Best C++ article of May 2012
20 Apr 2012: Best VB.NET article of March 2012
22 Feb 2010: Best overall article of January 2010
22 Feb 2010: Best C# article of January 2010