Documentation for module 'NDK'
Former-commit-id: 63e1cac538c577a1f1aafa71fa7eef69a6d4daab [formerly b2d8769fd02a0e7d9c476d4ad7be1988a1fd6789] [formerly 636b5cb79bcb8da44d9aa45ba1023565bcf29f0d [formerly a2361ec2b8679d4d4ba096e543b5d4b91825dd62]] Former-commit-id: d402d35477f9db0135c553d55c401939426bf62d [formerly 607336ea0f42731e4604f3a8c2df06f3aecfc401] Former-commit-id: 69e23cd6c06723486de5e4641ce810012dac66da
This commit is contained in:
@@ -8,6 +8,10 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs an CameraComponent object by default
|
||||
*/
|
||||
|
||||
inline CameraComponent::CameraComponent() :
|
||||
m_projectionType(Nz::ProjectionType_Perspective),
|
||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||
@@ -25,6 +29,12 @@ namespace Ndk
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a CameraComponent object by copy semantic
|
||||
*
|
||||
* \param camera CameraComponent to copy
|
||||
*/
|
||||
|
||||
inline CameraComponent::CameraComponent(const CameraComponent& camera) :
|
||||
Component(camera),
|
||||
AbstractViewer(camera),
|
||||
@@ -45,30 +55,51 @@ namespace Ndk
|
||||
SetTarget(camera.m_target);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Ensures the frustum is up to date
|
||||
*/
|
||||
|
||||
inline void CameraComponent::EnsureFrustumUpdate() const
|
||||
{
|
||||
if (!m_frustumUpdated)
|
||||
UpdateFrustum();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Ensures the projection matrix is up to date
|
||||
*/
|
||||
|
||||
inline void CameraComponent::EnsureProjectionMatrixUpdate() const
|
||||
{
|
||||
if (!m_projectionMatrixUpdated)
|
||||
UpdateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Ensures the view matrix is up to date
|
||||
*/
|
||||
|
||||
inline void CameraComponent::EnsureViewMatrixUpdate() const
|
||||
{
|
||||
if (!m_viewMatrixUpdated)
|
||||
UpdateViewMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Ensures the view port is up to date
|
||||
*/
|
||||
|
||||
inline void CameraComponent::EnsureViewportUpdate() const
|
||||
{
|
||||
if (!m_viewportUpdated)
|
||||
UpdateViewport();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the aspect ratio of the camera
|
||||
* \return Aspect ratio of the camera
|
||||
*/
|
||||
|
||||
inline float CameraComponent::GetAspectRatio() const
|
||||
{
|
||||
EnsureViewportUpdate();
|
||||
@@ -76,11 +107,21 @@ namespace Ndk
|
||||
return m_aspectRatio;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the field of view of the camera
|
||||
* \return Field of view of the camera
|
||||
*/
|
||||
|
||||
inline float CameraComponent::GetFOV() const
|
||||
{
|
||||
return m_fov;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the frutum of the camera
|
||||
* \return A constant reference to the frustum of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Frustumf& CameraComponent::GetFrustum() const
|
||||
{
|
||||
EnsureFrustumUpdate();
|
||||
@@ -88,11 +129,21 @@ namespace Ndk
|
||||
return m_frustum;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the layer of the camera
|
||||
* \return Layer of the camera
|
||||
*/
|
||||
|
||||
inline unsigned int CameraComponent::GetLayer() const
|
||||
{
|
||||
return m_layer;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the projection matrix of the camera
|
||||
* \return A constant reference to the projection matrix of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
|
||||
{
|
||||
EnsureProjectionMatrixUpdate();
|
||||
@@ -100,26 +151,51 @@ namespace Ndk
|
||||
return m_projectionMatrix;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the projection type of the camera
|
||||
* \return Projection type of the camera
|
||||
*/
|
||||
|
||||
inline Nz::ProjectionType CameraComponent::GetProjectionType() const
|
||||
{
|
||||
return m_projectionType;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the size of the camera
|
||||
* \return Size of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Vector2f & CameraComponent::GetSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the target of the camera
|
||||
* \return A constant reference to the render target of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::RenderTarget* CameraComponent::GetTarget() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the target region of the camera
|
||||
* \return A constant reference to the target region of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Rectf& CameraComponent::GetTargetRegion() const
|
||||
{
|
||||
return m_targetRegion;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the view matrix of the camera
|
||||
* \return A constant reference to the view matrix of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
|
||||
{
|
||||
EnsureViewMatrixUpdate();
|
||||
@@ -127,6 +203,11 @@ namespace Ndk
|
||||
return m_viewMatrix;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the view port of the camera
|
||||
* \return A constant reference to the view port of the camera
|
||||
*/
|
||||
|
||||
inline const Nz::Recti& CameraComponent::GetViewport() const
|
||||
{
|
||||
EnsureViewportUpdate();
|
||||
@@ -134,16 +215,34 @@ namespace Ndk
|
||||
return m_viewport;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the Z far distance of the camera
|
||||
* \return Z far distance of the camera
|
||||
*/
|
||||
|
||||
inline float CameraComponent::GetZFar() const
|
||||
{
|
||||
return m_zFar;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the Z near distance of the camera
|
||||
* \return Z near distance of the camera
|
||||
*/
|
||||
|
||||
inline float CameraComponent::GetZNear() const
|
||||
{
|
||||
return m_zNear;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the field of view of the camera
|
||||
*
|
||||
* \param fov Field of view of the camera
|
||||
*
|
||||
* \remark Produces a NazaraAssert if angle is zero
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetFOV(float fov)
|
||||
{
|
||||
NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero");
|
||||
@@ -152,6 +251,12 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the projection type of the camera
|
||||
*
|
||||
* \param projectionType Projection type of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType)
|
||||
{
|
||||
m_projectionType = projectionType;
|
||||
@@ -159,6 +264,12 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the size of the camera
|
||||
*
|
||||
* \param size Size of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetSize(const Nz::Vector2f& size)
|
||||
{
|
||||
m_size = size;
|
||||
@@ -166,11 +277,24 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the size of the camera
|
||||
*
|
||||
* \param width Size in X of the camera
|
||||
* \param height Size in Y of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetSize(float width, float height)
|
||||
{
|
||||
SetSize({width, height});
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the target of the camera
|
||||
*
|
||||
* \param renderTarget A constant reference to the render target of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget)
|
||||
{
|
||||
m_target = renderTarget;
|
||||
@@ -186,6 +310,12 @@ namespace Ndk
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the target region of the camera
|
||||
*
|
||||
* \param region A constant reference to the target region of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region)
|
||||
{
|
||||
m_targetRegion = region;
|
||||
@@ -193,17 +323,31 @@ namespace Ndk
|
||||
InvalidateViewport();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the view port of the camera
|
||||
*
|
||||
* \param viewport A constant reference to the view port of the camera
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the camera has no target
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetViewport(const Nz::Recti& viewport)
|
||||
{
|
||||
NazaraAssert(m_target, "Component has no render target");
|
||||
|
||||
// On calcule la région nécessaire pour produire ce viewport avec la taille actuelle de la cible
|
||||
float invWidth = 1.f/m_target->GetWidth();
|
||||
float invHeight = 1.f/m_target->GetHeight();
|
||||
// We compute the region necessary to make this view port with the actual size of the target
|
||||
float invWidth = 1.f / m_target->GetWidth();
|
||||
float invHeight = 1.f / m_target->GetHeight();
|
||||
|
||||
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the Z far distance of the camera
|
||||
*
|
||||
* \param zFar Z far distance of the camera
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetZFar(float zFar)
|
||||
{
|
||||
m_zFar = zFar;
|
||||
@@ -211,6 +355,14 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the Z near distance of the camera
|
||||
*
|
||||
* \param zNear Z near distance of the camera
|
||||
*
|
||||
* \remark Produces a NazaraAssert if zNear is zero
|
||||
*/
|
||||
|
||||
inline void CameraComponent::SetZNear(float zNear)
|
||||
{
|
||||
NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero");
|
||||
@@ -219,23 +371,39 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the frustum
|
||||
*/
|
||||
|
||||
inline void CameraComponent::InvalidateFrustum() const
|
||||
{
|
||||
m_frustumUpdated = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the projection matrix
|
||||
*/
|
||||
|
||||
inline void CameraComponent::InvalidateProjectionMatrix() const
|
||||
{
|
||||
m_frustumUpdated = false;
|
||||
m_projectionMatrixUpdated = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the view matrix
|
||||
*/
|
||||
|
||||
inline void CameraComponent::InvalidateViewMatrix() const
|
||||
{
|
||||
m_frustumUpdated = false;
|
||||
m_viewMatrixUpdated = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the view port
|
||||
*/
|
||||
|
||||
inline void CameraComponent::InvalidateViewport() const
|
||||
{
|
||||
m_frustumUpdated = false;
|
||||
|
||||
Reference in New Issue
Block a user