Added viewer-relative directions
Former-commit-id: 9d80744bd227689426b76df7e3c273de13424041
This commit is contained in:
parent
596f407a79
commit
ed1cc7a092
|
|
@ -28,6 +28,9 @@ class NAZARA_API NzAbstractViewer
|
|||
virtual NzVector3f GetEyePosition() const = 0;
|
||||
virtual NzVector3f GetForward() const = 0;
|
||||
virtual const NzFrustumf& GetFrustum() const = 0;
|
||||
virtual NzVector3f GetGlobalForward() const = 0;
|
||||
virtual NzVector3f GetGlobalRight() const = 0;
|
||||
virtual NzVector3f GetGlobalUp() const = 0;
|
||||
virtual const NzMatrix4f& GetProjectionMatrix() const = 0;
|
||||
virtual const NzRenderTarget* GetTarget() const = 0;
|
||||
virtual const NzMatrix4f& GetViewMatrix() const = 0;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ class NAZARA_API NzCamera : public NzAbstractViewer, public NzNode, NzRenderTarg
|
|||
NzVector3f GetForward() const;
|
||||
float GetFOV() const;
|
||||
const NzFrustumf& GetFrustum() const;
|
||||
NzVector3f GetGlobalForward() const;
|
||||
NzVector3f GetGlobalRight() const;
|
||||
NzVector3f GetGlobalUp() const;
|
||||
const NzMatrix4f& GetProjectionMatrix() const;
|
||||
const NzRenderTarget* GetTarget() const;
|
||||
const NzRectf& GetTargetRegion() const;
|
||||
|
|
|
|||
|
|
@ -41,9 +41,15 @@ class NAZARA_API NzScene
|
|||
|
||||
NzColor GetAmbientColor() const;
|
||||
NzAbstractBackground* GetBackground() const;
|
||||
NzVector3f GetBackward() const;
|
||||
NzVector3f GetDown() const;
|
||||
NzVector3f GetForward() const;
|
||||
NzVector3f GetLeft() const;
|
||||
NzAbstractRenderTechnique* GetRenderTechnique() const;
|
||||
NzVector3f GetRight() const;
|
||||
NzSceneNode& GetRoot() const;
|
||||
NzAbstractViewer* GetViewer() const;
|
||||
NzVector3f GetUp() const;
|
||||
float GetUpdateTime() const;
|
||||
unsigned int GetUpdatePerSecond() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,16 @@ class NAZARA_API NzSceneNode : public NzNode
|
|||
|
||||
void EnableDrawing(bool drawingEnabled);
|
||||
|
||||
NzVector3f GetBackward() const;
|
||||
virtual const NzBoundingVolumef& GetBoundingVolume() const = 0;
|
||||
NzVector3f GetDown() const;
|
||||
NzVector3f GetForward() const;
|
||||
NzVector3f GetLeft() const;
|
||||
nzNodeType GetNodeType() const final;
|
||||
NzVector3f GetRight() const;
|
||||
NzScene* GetScene() const;
|
||||
virtual nzSceneNodeType GetSceneNodeType() const = 0;
|
||||
NzVector3f GetUp() const;
|
||||
|
||||
virtual bool IsDrawable() const = 0;
|
||||
bool IsDrawingEnabled() const;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
|||
NzVector3f GetEyePosition() const;
|
||||
NzVector3f GetForward() const;
|
||||
const NzFrustumf& GetFrustum() const;
|
||||
NzVector3f GetGlobalForward() const;
|
||||
NzVector3f GetGlobalRight() const;
|
||||
NzVector3f GetGlobalUp() const;
|
||||
const NzMatrix4f& GetProjectionMatrix() const;
|
||||
const NzVector2f& GetSize() const;
|
||||
const NzRenderTarget* GetTarget() const;
|
||||
|
|
|
|||
|
|
@ -24,26 +24,26 @@ class NAZARA_API NzNode
|
|||
void EnsureDerivedUpdate() const;
|
||||
void EnsureTransformMatrixUpdate() const;
|
||||
|
||||
NzVector3f GetBackward() const;
|
||||
virtual NzVector3f GetBackward() const;
|
||||
const std::vector<NzNode*>& GetChilds() const;
|
||||
NzVector3f GetDown() const;
|
||||
NzVector3f GetForward() const;
|
||||
virtual NzVector3f GetDown() const;
|
||||
virtual NzVector3f GetForward() const;
|
||||
bool GetInheritPosition() const;
|
||||
bool GetInheritRotation() const;
|
||||
bool GetInheritScale() const;
|
||||
NzVector3f GetInitialPosition() const;
|
||||
NzQuaternionf GetInitialRotation() const;
|
||||
NzVector3f GetInitialScale() const;
|
||||
NzVector3f GetLeft() const;
|
||||
virtual NzVector3f GetLeft() const;
|
||||
const NzString& GetName() const;
|
||||
virtual nzNodeType GetNodeType() const;
|
||||
const NzNode* GetParent() const;
|
||||
NzVector3f GetPosition(nzCoordSys coordSys = nzCoordSys_Global) const;
|
||||
NzVector3f GetRight() const;
|
||||
virtual NzVector3f GetRight() const;
|
||||
NzQuaternionf GetRotation(nzCoordSys coordSys = nzCoordSys_Global) const;
|
||||
NzVector3f GetScale(nzCoordSys coordSys = nzCoordSys_Global) const;
|
||||
const NzMatrix4f& GetTransformMatrix() const;
|
||||
NzVector3f GetUp() const;
|
||||
virtual NzVector3f GetUp() const;
|
||||
|
||||
bool HasChilds() const;
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ class NAZARA_API NzNode
|
|||
virtual void InvalidateNode();
|
||||
virtual void OnParenting(const NzNode* parent);
|
||||
void RemoveChild(NzNode* node) const;
|
||||
void UpdateDerived() const;
|
||||
virtual void UpdateDerived() const;
|
||||
virtual void UpdateTransformMatrix() const;
|
||||
|
||||
mutable std::vector<NzNode*> m_childs;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,21 @@ const NzFrustumf& NzCamera::GetFrustum() const
|
|||
return m_frustum;
|
||||
}
|
||||
|
||||
NzVector3f NzCamera::GetGlobalForward() const
|
||||
{
|
||||
return NzVector3f::Forward();
|
||||
}
|
||||
|
||||
NzVector3f NzCamera::GetGlobalRight() const
|
||||
{
|
||||
return NzVector3f::Right();
|
||||
}
|
||||
|
||||
NzVector3f NzCamera::GetGlobalUp() const
|
||||
{
|
||||
return NzVector3f::Up();
|
||||
}
|
||||
|
||||
const NzMatrix4f& NzCamera::GetProjectionMatrix() const
|
||||
{
|
||||
if (!m_projectionMatrixUpdated)
|
||||
|
|
|
|||
|
|
@ -134,6 +134,58 @@ NzAbstractBackground* NzScene::GetBackground() const
|
|||
return m_impl->background.get();
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetBackward() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Backward();
|
||||
}
|
||||
#endif
|
||||
|
||||
return -m_impl->viewer->GetGlobalForward();
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetDown() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Down();
|
||||
}
|
||||
#endif
|
||||
|
||||
return -m_impl->viewer->GetGlobalUp();
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetForward() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Forward();
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_impl->viewer->GetGlobalForward();
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetLeft() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Left();
|
||||
}
|
||||
#endif
|
||||
|
||||
return -m_impl->viewer->GetGlobalRight();
|
||||
}
|
||||
|
||||
NzAbstractRenderTechnique* NzScene::GetRenderTechnique() const
|
||||
{
|
||||
if (!m_impl->renderTechnique)
|
||||
|
|
@ -142,6 +194,19 @@ NzAbstractRenderTechnique* NzScene::GetRenderTechnique() const
|
|||
return m_impl->renderTechnique.get();
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetRight() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Right();
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_impl->viewer->GetGlobalRight();
|
||||
}
|
||||
|
||||
NzSceneNode& NzScene::GetRoot() const
|
||||
{
|
||||
return m_impl->root;
|
||||
|
|
@ -152,6 +217,19 @@ NzAbstractViewer* NzScene::GetViewer() const
|
|||
return m_impl->viewer;
|
||||
}
|
||||
|
||||
NzVector3f NzScene::GetUp() const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!m_impl->viewer)
|
||||
{
|
||||
NazaraError("No viewer");
|
||||
return NzVector3f::Up();
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_impl->viewer->GetGlobalUp();
|
||||
}
|
||||
|
||||
float NzScene::GetUpdateTime() const
|
||||
{
|
||||
return m_impl->updateTime;
|
||||
|
|
@ -197,7 +275,13 @@ void NzScene::SetRenderTechnique(NzAbstractRenderTechnique* renderTechnique)
|
|||
|
||||
void NzScene::SetViewer(NzAbstractViewer* viewer)
|
||||
{
|
||||
m_impl->viewer = viewer;
|
||||
if (m_impl->viewer != viewer)
|
||||
{
|
||||
m_impl->viewer = viewer;
|
||||
|
||||
// Invalidation de tous les nodes de la scène (utile pour la régénération des sommets dépendant du viewer)
|
||||
m_impl->root.InvalidateNode();
|
||||
}
|
||||
}
|
||||
|
||||
void NzScene::SetViewer(NzAbstractViewer& viewer)
|
||||
|
|
|
|||
|
|
@ -31,16 +31,94 @@ void NzSceneNode::EnableDrawing(bool drawingEnabled)
|
|||
m_drawingEnabled = drawingEnabled;
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetBackward() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetBackward();
|
||||
}
|
||||
else
|
||||
return NzNode::GetBackward();
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetDown() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetDown();
|
||||
}
|
||||
else
|
||||
return NzNode::GetDown();
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetForward() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetForward();
|
||||
}
|
||||
else
|
||||
return NzNode::GetForward();
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetLeft() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetLeft();
|
||||
}
|
||||
else
|
||||
return NzNode::GetLeft();
|
||||
}
|
||||
|
||||
nzNodeType NzSceneNode::GetNodeType() const
|
||||
{
|
||||
return nzNodeType_Scene;
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetRight() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetRight();
|
||||
}
|
||||
else
|
||||
return NzNode::GetRight();
|
||||
}
|
||||
|
||||
NzScene* NzSceneNode::GetScene() const
|
||||
{
|
||||
return m_scene;
|
||||
}
|
||||
|
||||
NzVector3f NzSceneNode::GetUp() const
|
||||
{
|
||||
if (m_scene)
|
||||
{
|
||||
if (!m_derivedUpdated)
|
||||
UpdateDerived();
|
||||
|
||||
return m_derivedRotation * m_scene->GetUp();
|
||||
}
|
||||
else
|
||||
return NzNode::GetUp();
|
||||
}
|
||||
|
||||
bool NzSceneNode::IsDrawingEnabled() const
|
||||
{
|
||||
return m_drawingEnabled;
|
||||
|
|
@ -82,6 +160,7 @@ void NzSceneNode::OnParenting(const NzNode* parent)
|
|||
{
|
||||
if (parent)
|
||||
{
|
||||
///FIXME: Remonter jusqu'au premier parent de type SceneNode plutôt que de s'arrêter au premier venu
|
||||
if (parent->GetNodeType() == nzNodeType_Scene)
|
||||
SetScene(static_cast<const NzSceneNode*>(parent)->m_scene);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,21 @@ const NzFrustumf& NzView::GetFrustum() const
|
|||
return m_frustum;
|
||||
}
|
||||
|
||||
NzVector3f NzView::GetGlobalForward() const
|
||||
{
|
||||
return NzVector3f::UnitZ();
|
||||
}
|
||||
|
||||
NzVector3f NzView::GetGlobalRight() const
|
||||
{
|
||||
return NzVector3f::UnitX();
|
||||
}
|
||||
|
||||
NzVector3f NzView::GetGlobalUp() const
|
||||
{
|
||||
return -NzVector3f::UnitY();
|
||||
}
|
||||
|
||||
const NzMatrix4f& NzView::GetProjectionMatrix() const
|
||||
{
|
||||
if (!m_projectionMatrixUpdated)
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ void NzNode::UpdateDerived() const
|
|||
m_derivedRotation.Normalize();
|
||||
}
|
||||
else
|
||||
m_derivedRotation = m_initialRotation * m_rotation; ///FIXME: Besoin d'une normalisation ?
|
||||
m_derivedRotation = m_initialRotation * m_rotation;
|
||||
|
||||
m_derivedScale = m_initialScale * m_scale;
|
||||
if (m_inheritScale)
|
||||
|
|
|
|||
Loading…
Reference in New Issue