|
From: <axl...@us...> - 2009-07-26 02:53:03
|
Revision: 441
http://hgengine.svn.sourceforge.net/hgengine/?rev=441&view=rev
Author: axlecrusher
Date: 2009-07-26 02:52:54 +0000 (Sun, 26 Jul 2009)
Log Message:
-----------
tweak how RecursiveRender and RecursivePreRender.
Orthographic view works.
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/TransformNode.cpp
Mercury2/src/TransformNode.h
Mercury2/src/Viewport.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-07-26 02:52:54 UTC (rev 441)
@@ -38,7 +38,7 @@
</node>
</node>
</node>
-<!-- <node type="orthographic" left="0" right="1" top="0" bottom="1" near="-1" far="1">
+ <node type="orthographic" left="0" right="1" top="1" bottom="0" near="-1" far="1">
<asset type="quad"/>
- </node> -->
+ </node>
</SceneGraph>
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/src/MercuryNode.cpp 2009-07-26 02:52:54 UTC (rev 441)
@@ -141,11 +141,8 @@
{
if ( IsHidden() ) return;
- MercuryMatrix matrix = FindGlobalMatrix();
- MercuryMatrix modelView = ManipulateMatrix( matrix );
+ const MercuryMatrix& matrix = FindGlobalMatrix();
- glLoadMatrix( modelView );
-
PreRender( matrix ); //calls on children assets
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
@@ -156,17 +153,21 @@
{
if ( IsHidden() || m_occlusionResult.IsOccluded() || IsCulled() ) return;
- MercuryMatrix matrix = FindGlobalMatrix();
- MercuryMatrix modelView = ManipulateMatrix( matrix );
-// if ( IsHidden() || IsCulled(modelView) ) return;
+ const MercuryMatrix& matrix = FindGlobalMatrix();
+ const MercuryMatrix& modelView = FindModelViewMatrix(); //get the one computed in the last transform
+
+ //A lot of this stuff could be moved into the transform node, BUT
+ //the alpha render path requires that all things things happen, so
+ //it is just easier to leave it here than to duplicate this code in
+ //RenderGraph::RenderAlpha
glLoadMatrix( modelView );
ShaderAttribute sa;
sa.type = ShaderAttribute::TYPE_MATRIX;
sa.value.matrix = matrix.Ptr();
Shader::SetAttribute("HG_ModelMatrix", sa);
-
+
Render( modelView ); //calls on children assets
//call render on other render graph entries under me
@@ -266,6 +267,20 @@
return MercuryMatrix::Identity();
}
+const MercuryMatrix& MercuryNode::FindModelViewMatrix() const
+{
+ const MercuryNode* n = NULL;
+ const TransformNode* tn;
+ for (n = this; n; n = n->Parent())
+ {
+ tn = TransformNode::Cast(n);
+ if ( tn )
+ return tn->GetModelViewMatrix();
+ }
+
+ return MercuryMatrix::Identity();
+}
+
void MercuryNode::AddPreRender(MercuryAsset* asset)
{
#ifdef MCHECKASSETS
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/src/MercuryNode.h 2009-07-26 02:52:54 UTC (rev 441)
@@ -57,8 +57,8 @@
void ThreadedUpdate(float dTime);
- void RecursivePreRender();
- void RecursiveRender();
+ virtual void RecursivePreRender();
+ virtual void RecursiveRender();
///Run on parent when a child is added
virtual void OnAddChild() {};
@@ -93,6 +93,7 @@
///This will get the world space matrix
const MercuryMatrix& FindGlobalMatrix() const;
+ const MercuryMatrix& FindModelViewMatrix() const;
virtual bool IsCulled(const MercuryMatrix& matrix);
inline bool IsHidden() { return m_hidden; }
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/src/TransformNode.cpp 2009-07-26 02:52:54 UTC (rev 441)
@@ -1,4 +1,6 @@
#include <TransformNode.h>
+#include <GLHeaders.h>
+#include <Shader.h>
REGISTER_NODE_TYPE(TransformNode);
REGISTER_NODE_TYPE(RotatorNode);
@@ -14,6 +16,18 @@
if (m_tainted) ComputeMatrix();
}
+void TransformNode::RecursivePreRender()
+{
+ if ( IsHidden() ) return;
+
+ const MercuryMatrix& matrix = FindGlobalMatrix();
+ m_modelView = ManipulateMatrix( matrix );
+
+ glLoadMatrix( m_modelView );
+
+ MercuryNode::RecursivePreRender();
+}
+
void TransformNode::SetScale( const MercuryVertex& scale )
{
if (scale != m_scale)
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/src/TransformNode.h 2009-07-26 02:52:54 UTC (rev 441)
@@ -25,6 +25,7 @@
// inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; }
virtual const MercuryMatrix& GetGlobalMatrix() const;
+ inline const MercuryMatrix& GetModelViewMatrix() const { return m_modelView; }
const MercuryMatrix& GetParentMatrix() const;
void SetTaint(bool taint);
@@ -34,6 +35,8 @@
virtual void LoadFromXML(const XMLNode& node);
virtual void OnAdded();
+
+ virtual void RecursivePreRender();
GENRTTI(TransformNode);
@@ -47,7 +50,7 @@
// MercuryMatrix m_localMatrix;
protected:
-
+ MercuryMatrix m_modelView;
MercuryMatrix m_globalMatrix;
bool m_tainted;
Modified: Mercury2/src/Viewport.h
===================================================================
--- Mercury2/src/Viewport.h 2009-07-26 02:13:48 UTC (rev 440)
+++ Mercury2/src/Viewport.h 2009-07-26 02:52:54 UTC (rev 441)
@@ -13,6 +13,7 @@
Viewport();
virtual void PreRender(const MercuryMatrix& matrix);
virtual void Render(const MercuryMatrix& matrix);
+ virtual void PostRender(const MercuryMatrix& matrix);
virtual void LoadFromXML(const XMLNode& node);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|