Added Basic camera
This commit is contained in:
parent
abdb820b09
commit
da58165645
|
@ -0,0 +1,105 @@
|
|||
#include "Camera_Basic.h"
|
||||
|
||||
using namespace ::Oyster::Math3D;
|
||||
|
||||
Camera_Basic::Camera_Basic()
|
||||
{
|
||||
this->translation = this->angularAxis = Float3::null;
|
||||
this->projection = Float4x4::identity;
|
||||
this->rotation = Quaternion::identity;
|
||||
rotationIsOutOfDate = false;
|
||||
}
|
||||
|
||||
Camera_Basic::Camera_Basic( const Float3 &position, const Float3 &angularAxis, const Float4x4 &projection )
|
||||
{
|
||||
this->translation = position;
|
||||
this->angularAxis = angularAxis;
|
||||
this->projection = projection;
|
||||
this->rotation = Quaternion::identity;
|
||||
rotationIsOutOfDate = true;
|
||||
}
|
||||
|
||||
Camera_Basic::~Camera_Basic() {}
|
||||
|
||||
Camera_Basic & Camera_Basic::operator = ( const Camera_Basic &camera )
|
||||
{
|
||||
this->translation = camera.translation;
|
||||
this->angularAxis = camera.angularAxis;
|
||||
this->projection = camera.projection;
|
||||
this->rotation = camera.rotation;
|
||||
rotationIsOutOfDate = camera.rotationIsOutOfDate;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Camera_Basic::SetPosition( const Float3 &translation )
|
||||
{
|
||||
this->translation = translation;
|
||||
}
|
||||
|
||||
void Camera_Basic::SetAngular( const Float3 &axis )
|
||||
{
|
||||
this->angularAxis = axis;
|
||||
this->rotationIsOutOfDate = true;
|
||||
}
|
||||
|
||||
void Camera_Basic::SetProjection( const Float4x4 &matrix )
|
||||
{
|
||||
this->projection = matrix;
|
||||
}
|
||||
|
||||
void Camera_Basic::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
|
||||
{
|
||||
ProjectionMatrix_Orthographic( width, height, nearClip, farClip, this->projection );
|
||||
}
|
||||
|
||||
void Camera_Basic::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
|
||||
{
|
||||
ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, this->projection );
|
||||
}
|
||||
|
||||
void Camera_Basic::Move( const Float3 &deltaPosition )
|
||||
{
|
||||
this->translation += deltaPosition;
|
||||
}
|
||||
|
||||
void Camera_Basic::Rotate( const Float3 &deltaAngularAxis )
|
||||
{
|
||||
this->angularAxis += deltaAngularAxis;
|
||||
this->rotationIsOutOfDate = true;
|
||||
}
|
||||
|
||||
const Quaternion & Camera_Basic::GetRotation() const
|
||||
{
|
||||
if( this->rotationIsOutOfDate )
|
||||
{
|
||||
this->rotation = Rotation( this->angularAxis );
|
||||
this->rotationIsOutOfDate = false;
|
||||
}
|
||||
|
||||
return this->rotation;
|
||||
}
|
||||
|
||||
Float3x3 & Camera_Basic::GetRotationMatrix( Float3x3 &targetMem ) const
|
||||
{
|
||||
return RotationMatrix( this->rotation, targetMem );
|
||||
}
|
||||
|
||||
Float4x4 & Camera_Basic::GetRotationMatrix( Float4x4 &targetMem ) const
|
||||
{
|
||||
return RotationMatrix( this->rotation, targetMem );
|
||||
}
|
||||
|
||||
Float4x4 & Camera_Basic::GetViewMatrix( Float4x4 &targetMem ) const
|
||||
{
|
||||
return ViewMatrix( this->GetRotation(), this->translation, targetMem );
|
||||
}
|
||||
|
||||
const Float4x4 & Camera_Basic::GetProjectionMatrix() const
|
||||
{
|
||||
return this->projection;
|
||||
}
|
||||
|
||||
Float4x4 & Camera_Basic::GetViewsProjMatrix( Float4x4 &targetMem ) const
|
||||
{
|
||||
return TransformMatrix( this->projection, this->GetViewMatrix(), targetMem );
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef CAMERA_BASIC_H
|
||||
#define CAMERA_BASIC_H
|
||||
|
||||
#include "OysterMath.h"
|
||||
|
||||
class Camera_Basic
|
||||
{
|
||||
public:
|
||||
Camera_Basic();
|
||||
Camera_Basic( const ::Oyster::Math::Float3 &position, const ::Oyster::Math::Float3 &angularAxis, const ::Oyster::Math::Float4x4 &projection );
|
||||
virtual ~Camera_Basic();
|
||||
|
||||
Camera_Basic & operator = ( const Camera_Basic &camera );
|
||||
|
||||
void SetPosition( const ::Oyster::Math::Float3 &translation );
|
||||
void SetAngular( const ::Oyster::Math::Float3 &axis );
|
||||
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
|
||||
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||
|
||||
void Move( const ::Oyster::Math::Float3 &deltaPosition );
|
||||
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
|
||||
|
||||
const ::Oyster::Math::Quaternion & GetRotation() const;
|
||||
::Oyster::Math::Float3x3 & GetRotationMatrix( ::Oyster::Math::Float3x3 &targetMem ) const;
|
||||
::Oyster::Math::Float4x4 & GetRotationMatrix( ::Oyster::Math::Float4x4 &targetMem ) const;
|
||||
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
|
||||
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||
|
||||
private:
|
||||
::Oyster::Math::Float3 translation, angularAxis;
|
||||
::Oyster::Math::Float4x4 projection;
|
||||
mutable ::Oyster::Math::Quaternion rotation;
|
||||
mutable bool rotationIsOutOfDate;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue