From: <axl...@us...> - 2009-06-05 00:45:56
|
Revision: 309 http://hgengine.svn.sourceforge.net/hgengine/?rev=309&view=rev Author: axlecrusher Date: 2009-06-05 00:45:50 +0000 (Fri, 05 Jun 2009) Log Message: ----------- sherical billboarding works now Modified Paths: -------------- Mercury2/modules/BillboardNode.cpp Mercury2/modules/BillboardNode.h Mercury2/scenegraph.xml Modified: Mercury2/modules/BillboardNode.cpp =================================================================== --- Mercury2/modules/BillboardNode.cpp 2009-06-04 10:46:55 UTC (rev 308) +++ Mercury2/modules/BillboardNode.cpp 2009-06-05 00:45:50 UTC (rev 309) @@ -4,6 +4,11 @@ REGISTER_NODE_TYPE(BillboardNode); +BillboardNode::BillboardNode() + :m_sphere(false) +{ +} + MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix) { //Compute the object's center point (position?) in world space @@ -27,30 +32,21 @@ //needs to be the local axis to rotate around MercuryMatrix global(matrix); MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f); - global.Rotate( mtmp ); - - MercuryMatrix m = RenderableNode::ManipulateMatrix( global ); - -/* //spherical below - objToEye.NormalizeSelf(); - angleCos = objToEyeProj.DotProduct( objToEye ); - if ((angleCos < 0.99990) && (angleCos > -0.9999)) + + //spherical below + if ( m_sphere ) { - printf("%f\n", angleCos); - float f = ACOS(angleCos)*RADDEG; - MercuryMatrix mtmp; - if (objToEye[1] < 0) - mtmp.RotateAngAxis(f, 1, 0, 0); - else - mtmp.RotateAngAxis(f, -1, 0, 0); -// m.Print(); -// m = m * mtmp; -// m.Print(); - printf("********************\n"); -// mtmp.Print(); + objToEye.NormalizeSelf(); + angleCos = objToEyeProj.DotProduct( objToEye ); + f = ACOS(angleCos); + printf("%f %f\n", angleCos, f); + if (objToEye[1] < 0) f *= -1; + if (angleCos < 0.99999) mtmp *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), f); } -*/ - return m; + + global.Rotate( mtmp ); + + return RenderableNode::ManipulateMatrix( global ); } void BillboardNode::LoadFromXML(const XMLNode& node) @@ -59,6 +55,9 @@ if ( !node.Attribute("billboardaxis").empty() ) m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") ); + + if ( !node.Attribute("spheremode").empty() ) + m_sphere = node.Attribute("spheremode") == "true"?true:false; } /**************************************************************************** Modified: Mercury2/modules/BillboardNode.h =================================================================== --- Mercury2/modules/BillboardNode.h 2009-06-04 10:46:55 UTC (rev 308) +++ Mercury2/modules/BillboardNode.h 2009-06-05 00:45:50 UTC (rev 309) @@ -7,11 +7,14 @@ class BillboardNode : public RenderableNode { public: + BillboardNode(); + virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix); virtual void LoadFromXML(const XMLNode& node); private: MercuryVector m_billboardAxis; + bool m_sphere; }; #endif Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-06-04 10:46:55 UTC (rev 308) +++ Mercury2/scenegraph.xml 2009-06-05 00:45:50 UTC (rev 309) @@ -16,7 +16,7 @@ <asset type="texture" file="lamp.png"/> <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" > + <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" > <asset type="hgmdlmodel" file="lamp.hgmdl" /> </node> </node> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |