From: <axl...@us...> - 2009-06-07 23:58:41
|
Revision: 311 http://hgengine.svn.sourceforge.net/hgengine/?rev=311&view=rev Author: axlecrusher Date: 2009-06-07 23:58:40 +0000 (Sun, 07 Jun 2009) Log Message: ----------- make billboard a type of transform node Modified Paths: -------------- Mercury2/modules/BillboardNode.cpp Mercury2/modules/BillboardNode.h Mercury2/scenegraph.xml Mercury2/src/TransformNode.cpp Mercury2/src/TransformNode.h Modified: Mercury2/modules/BillboardNode.cpp =================================================================== --- Mercury2/modules/BillboardNode.cpp 2009-06-05 01:00:49 UTC (rev 310) +++ Mercury2/modules/BillboardNode.cpp 2009-06-07 23:58:40 UTC (rev 311) @@ -5,15 +5,17 @@ REGISTER_NODE_TYPE(BillboardNode); BillboardNode::BillboardNode() - :m_sphere(false) + :TransformNode(), m_sphere(false) { } -MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix) +void BillboardNode::Update(float dTime) { + TransformNode::Update( dTime ); + //Compute the object's center point (position?) in world space MercuryVertex center(0,0,0,1); - center = matrix * center; + center = TransformNode::GetGlobalMatrix() * center; MercuryVector objToEye = (EYE - center); MercuryVector objToEyeProj( objToEye ); @@ -30,7 +32,7 @@ if (up[1] < 0) f *= -1; //needs to be the local axis to rotate around - MercuryMatrix global(matrix); + MercuryMatrix global( TransformNode::GetGlobalMatrix() ); MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f); //spherical below @@ -45,12 +47,20 @@ global.Rotate( mtmp ); - return RenderableNode::ManipulateMatrix( global ); + m_billboardMatrix = global; + + //notify children that our global matrix has changed + SetTaint(true); } +const MercuryMatrix& BillboardNode::GetGlobalMatrix() const +{ + return m_billboardMatrix; +} + void BillboardNode::LoadFromXML(const XMLNode& node) { - RenderableNode::LoadFromXML(node); + TransformNode::LoadFromXML(node); if ( !node.Attribute("billboardaxis").empty() ) m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") ); Modified: Mercury2/modules/BillboardNode.h =================================================================== --- Mercury2/modules/BillboardNode.h 2009-06-05 01:00:49 UTC (rev 310) +++ Mercury2/modules/BillboardNode.h 2009-06-07 23:58:40 UTC (rev 311) @@ -1,20 +1,27 @@ #ifndef BILLBOARDNODE_H #define BILLBOARDNODE_H -#include <RenderableNode.h> +#include <TransformNode.h> #include <MercuryVertex.h> -class BillboardNode : public RenderableNode +class BillboardNode : public TransformNode { public: BillboardNode(); - virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix); + virtual void Update(float dTime); + +// virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix); + virtual const MercuryMatrix& GetGlobalMatrix() const; + virtual void LoadFromXML(const XMLNode& node); + GENRTTI(BillboardNode); + private: MercuryVector m_billboardAxis; bool m_sphere; + MercuryMatrix m_billboardMatrix; }; #endif Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-06-05 01:00:49 UTC (rev 310) +++ Mercury2/scenegraph.xml 2009-06-07 23:58:40 UTC (rev 311) @@ -17,7 +17,9 @@ <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > <node type="transformnode" rotx="-90" name="lamp"> <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" > - <asset type="hgmdlmodel" file="lamp.hgmdl" /> + <node type="renderablenode"> + <asset type="hgmdlmodel" file="lamp.hgmdl" /> + </node> </node> </node> <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" /> Modified: Mercury2/src/TransformNode.cpp =================================================================== --- Mercury2/src/TransformNode.cpp 2009-06-05 01:00:49 UTC (rev 310) +++ Mercury2/src/TransformNode.cpp 2009-06-07 23:58:40 UTC (rev 311) @@ -154,6 +154,11 @@ } } +const MercuryMatrix& TransformNode::GetGlobalMatrix() const +{ + return m_globalMatrix; +} + void RotatorNode::Update(float dTime) { MQuaternion r = GetRotation(); Modified: Mercury2/src/TransformNode.h =================================================================== --- Mercury2/src/TransformNode.h 2009-06-05 01:00:49 UTC (rev 310) +++ Mercury2/src/TransformNode.h 2009-06-07 23:58:40 UTC (rev 311) @@ -23,7 +23,8 @@ inline const MercuryVertex& GetPosition() const { return m_position; } inline const MQuaternion& GetRotation() const { return m_rotation; } - inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; } +// inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; } + virtual const MercuryMatrix& GetGlobalMatrix() const; const MercuryMatrix& GetParentMatrix() const; void SetTaint(bool taint); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |