Added a Size parameter to View class
Allowing independent from rendertarget size Former-commit-id: c131b6dd95692c72a969bf0cc6edd997911bbe58
This commit is contained in:
parent
e14789830c
commit
df6fdf6784
|
|
@ -20,6 +20,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzView();
|
NzView();
|
||||||
|
NzView(const NzVector2f& size);
|
||||||
~NzView();
|
~NzView();
|
||||||
|
|
||||||
void EnsureFrustumUpdate() const;
|
void EnsureFrustumUpdate() const;
|
||||||
|
|
@ -32,6 +33,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||||
NzVector3f GetForward() const;
|
NzVector3f GetForward() const;
|
||||||
const NzFrustumf& GetFrustum() const;
|
const NzFrustumf& GetFrustum() const;
|
||||||
const NzMatrix4f& GetProjectionMatrix() const;
|
const NzMatrix4f& GetProjectionMatrix() const;
|
||||||
|
const NzVector2f& GetSize() const;
|
||||||
const NzRenderTarget* GetTarget() const;
|
const NzRenderTarget* GetTarget() const;
|
||||||
const NzRectf& GetTargetRegion() const;
|
const NzRectf& GetTargetRegion() const;
|
||||||
const NzMatrix4f& GetViewMatrix() const;
|
const NzMatrix4f& GetViewMatrix() const;
|
||||||
|
|
@ -39,6 +41,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||||
float GetZFar() const;
|
float GetZFar() const;
|
||||||
float GetZNear() const;
|
float GetZNear() const;
|
||||||
|
|
||||||
|
void SetSize(const NzVector2f& size);
|
||||||
void SetTarget(const NzRenderTarget* renderTarget);
|
void SetTarget(const NzRenderTarget* renderTarget);
|
||||||
void SetTarget(const NzRenderTarget& renderTarget);
|
void SetTarget(const NzRenderTarget& renderTarget);
|
||||||
void SetTargetRegion(const NzRectf& region);
|
void SetTargetRegion(const NzRectf& region);
|
||||||
|
|
@ -63,6 +66,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||||
mutable NzMatrix4f m_viewMatrix;
|
mutable NzMatrix4f m_viewMatrix;
|
||||||
NzRectf m_targetRegion;
|
NzRectf m_targetRegion;
|
||||||
mutable NzRecti m_viewport;
|
mutable NzRecti m_viewport;
|
||||||
|
NzVector2f m_size;
|
||||||
const NzRenderTarget* m_target;
|
const NzRenderTarget* m_target;
|
||||||
mutable bool m_frustumUpdated;
|
mutable bool m_frustumUpdated;
|
||||||
mutable bool m_projectionMatrixUpdated;
|
mutable bool m_projectionMatrixUpdated;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
NzView::NzView() :
|
NzView::NzView() :
|
||||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||||
|
m_size(0.f),
|
||||||
m_target(nullptr),
|
m_target(nullptr),
|
||||||
m_frustumUpdated(false),
|
m_frustumUpdated(false),
|
||||||
m_projectionMatrixUpdated(false),
|
m_projectionMatrixUpdated(false),
|
||||||
|
|
@ -20,6 +21,12 @@ m_zNear(-1.f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzView::NzView(const NzVector2f& size) :
|
||||||
|
NzView() // On délègue
|
||||||
|
{
|
||||||
|
m_size = size;
|
||||||
|
}
|
||||||
|
|
||||||
NzView::~NzView()
|
NzView::~NzView()
|
||||||
{
|
{
|
||||||
if (m_target)
|
if (m_target)
|
||||||
|
|
@ -256,10 +263,16 @@ void NzView::UpdateFrustum() const
|
||||||
|
|
||||||
void NzView::UpdateProjectionMatrix() const
|
void NzView::UpdateProjectionMatrix() const
|
||||||
{
|
{
|
||||||
if (!m_viewportUpdated)
|
if (m_size.x <= 0.f || m_size.y <= 0.f) // Si la taille est nulle, on prendra la taille du viewport
|
||||||
UpdateViewport();
|
{
|
||||||
|
if (!m_viewportUpdated)
|
||||||
|
UpdateViewport();
|
||||||
|
|
||||||
|
m_projectionMatrix.MakeOrtho(0.f, m_viewport.width, 0.f, m_viewport.height, m_zNear, m_zFar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_projectionMatrix.MakeOrtho(0.f, m_size.x, 0.f, m_size.y, m_zNear, m_zFar);
|
||||||
|
|
||||||
m_projectionMatrix.MakeOrtho(m_viewport.x, m_viewport.x + m_viewport.width, m_viewport.y, m_viewport.y + m_viewport.height, m_zNear, m_zFar);
|
|
||||||
m_projectionMatrixUpdated = true;
|
m_projectionMatrixUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue