Update of /cvsroot/gcblue/gcb_wx/src/graphics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11381/src/graphics
Modified Files:
tc3DModel.cpp tc3DWindow.cpp
Log Message:
Simple explosion effect using osgParticle::ExplosionEffect
Index: tc3DWindow.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** tc3DWindow.cpp 14 Sep 2005 01:33:24 -0000 1.26
--- tc3DWindow.cpp 19 Nov 2005 19:27:47 -0000 1.27
***************
*** 84,99 ****
* by wxWindows.
*/
! long tc3DWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
! {
! switch (nMsg)
! {
! case WM_ERASEBKGND:
! return 0;
! break;
! default:
! return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
! break;
! }
! }
--- 84,99 ----
* by wxWindows.
*/
! //long tc3DWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
! //{
! // switch (nMsg)
! // {
! // case WM_ERASEBKGND:
! // return 0;
! // break;
! // default:
! // return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
! // break;
! // }
! //}
Index: tc3DModel.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** tc3DModel.cpp 26 Jul 2005 00:37:04 -0000 1.30
--- tc3DModel.cpp 19 Nov 2005 19:27:47 -0000 1.31
***************
*** 43,46 ****
--- 43,48 ----
#include <osgDB/ReadFile>
#include <osgUtil/SmoothingVisitor>
+ #include <osgParticle/ExplosionEffect>
+ #include <osgParticle/ExplosionDebrisEffect>
//#include <osgAL/SoundNode>
***************
*** 351,354 ****
--- 353,366 ----
}
+
+ /**
+ * Queues explosion particle effect at rel_pos relative to
+ * origin of model.
+ */
+ void tc3DModel::AddExplosion(const osg::Vec3& rel_pos)
+ {
+ explosionQueue.push_back(rel_pos);
+ }
+
tc3DModel* tc3DModel::Clone()
{
***************
*** 868,871 ****
--- 880,922 ----
}
}
+
+ UpdateExplosions();
+
+ }
+
+ /**
+ * Create explosion effects for any queued explosions.
+ * Explosions are added to world frame for now
+ */
+ void tc3DModel::UpdateExplosions()
+ {
+ if (explosionQueue.size() == 0) return;
+
+ float scale = 20.0f;
+ float intensity = 5.0f;
+
+ // get location of model in world frame
+ LocationParams p;
+ GetLocationParams(p);
+
+ float& x = p.x;
+ float& y = p.y;
+ float& z = p.z;
+ float& yaw = p.yaw;
+ float& pitch = p.pitch;
+ float& roll = p.roll;
+ bool& isVisible = p.isVisible;
+
+ osg::Vec3 pos(x, y, z);
+
+
+ // just add one explosion effect for now
+ osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(pos, scale, intensity);
+ osgParticle::ExplosionDebrisEffect* explosionDebris = new osgParticle::ExplosionDebrisEffect(pos, scale, intensity);
+ world->addChild(explosion);
+ world->addChild(explosionDebris);
+
+ explosionQueue.clear();
+
}
|