[Gcblue-commits] gcb_wx/src/sim tc3DViewer.cpp,1.30,1.31 tcAirObject.cpp,1.9,1.10 tcGameObject.cpp,1
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4924/src/sim Modified Files: tc3DViewer.cpp tcAirObject.cpp tcGameObject.cpp tcLauncherState.cpp tcMissileObject.cpp tcPlatformObject.cpp tcSurfaceObject.cpp Log Message: Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcAirObject.cpp 24 May 2004 00:14:47 -0000 1.9 --- tcAirObject.cpp 4 Jun 2004 21:39:23 -0000 1.10 *************** *** 302,305 **** --- 302,307 ---- float dt_s = (float)(afStatusTime - mfStatusTime); + UpdateEffects(); + // shouldn't be called for child objects if (parent != NULL) {return;} // captive, let parent update if applicable Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcLauncherState.cpp 29 May 2004 00:11:54 -0000 1.10 --- tcLauncherState.cpp 4 Jun 2004 21:39:23 -0000 1.11 *************** *** 301,305 **** if (statusCode == 0) { ! statusCode = GetLauncherStatus(nLauncher); pLauncher->SetErrorCode(statusCode); } --- 301,305 ---- if (statusCode == 0) { ! statusCode = GetLauncherStatus(n); pLauncher->SetErrorCode(statusCode); } Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcSurfaceObject.cpp 1 May 2004 21:49:06 -0000 1.9 --- tcSurfaceObject.cpp 4 Jun 2004 21:39:23 -0000 1.10 *************** *** 28,31 **** --- 28,33 ---- #include "tcGenericDBObject.h" #include "tcMapData.h" + #include "tcParticleEffect.h" + #include "tc3DModel.h" *************** *** 70,77 **** } ! void tcSurfaceObject::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); if (parent != NULL) {return;} // captive, let parent update if applicable if (dt_s <= min_update_s) {return;} // added for pause case --- 72,82 ---- } ! void tcSurfaceObject::Update(double afStatusTime) ! { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); + UpdateEffects(); + if (parent != NULL) {return;} // captive, let parent update if applicable if (dt_s <= min_update_s) {return;} // added for pause case *************** *** 97,100 **** --- 102,114 ---- } + void tcSurfaceObject::UpdateEffects() + { + if (model) + { + model->SetSmokeMode(tcParticleEffect::DAMAGE); + model->UpdateEffects(); + } + } + /******************************************************************************/ Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcPlatformObject.cpp 29 May 2004 00:11:54 -0000 1.24 --- tcPlatformObject.cpp 4 Jun 2004 21:39:23 -0000 1.25 *************** *** 246,249 **** --- 246,251 ---- float dt_s = (float)(afStatusTime - mfStatusTime); + UpdateEffects(); + if (parent != NULL) {return;} // captive, let parent update if applicable if (mpDBObject == NULL) {return;} Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcGameObject.cpp 1 May 2004 21:49:06 -0000 1.15 --- tcGameObject.cpp 4 Jun 2004 21:39:23 -0000 1.16 *************** *** 413,417 **** * Updates mcKin based on parent position and rel_pos. */ ! void tcGameObject::UpdateCaptivePosition(void) { if (parent == NULL) {return;} --- 413,417 ---- * Updates mcKin based on parent position and rel_pos. */ ! void tcGameObject::UpdateCaptivePosition() { if (parent == NULL) {return;} *************** *** 423,426 **** --- 423,430 ---- } + void tcGameObject::UpdateEffects() + { + } + /** * *************** *** 483,486 **** --- 487,492 ---- if (model) { + model->SetSmokeMode(0); + model->UpdateEffects(); // clear smoke particle generator model->DetachFromParent(); delete model; Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcMissileObject.cpp 1 May 2004 21:49:06 -0000 1.11 --- tcMissileObject.cpp 4 Jun 2004 21:39:23 -0000 1.12 *************** *** 21,24 **** --- 21,26 ---- #include "common/tcStream.h" #include "common/tcObjStream.h" + #include "tc3DModel.h" + #include "tcParticleEffect.h" /** *************** *** 115,118 **** --- 117,122 ---- mfStatusTime = afStatusTime; + UpdateEffects(); + if (clientMode) return; *************** *** 136,139 **** --- 140,154 ---- } + + void tcMissileObject::UpdateEffects() + { + if (model) + { + model->SetSmokeMode(tcParticleEffect::MISSILE); + model->UpdateEffects(); + } + } + + #define MISSILE_ACZ 500.0f Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tc3DViewer.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tc3DViewer.cpp 14 May 2004 23:37:08 -0000 1.30 --- tc3DViewer.cpp 4 Jun 2004 21:39:22 -0000 1.31 *************** *** 47,50 **** --- 47,52 ---- #include <osgText/Font> #include <osgText/Text> + #include <osgParticle/ParticleSystem> + #include <osgParticle/ParticleSystemUpdater> #include "ObjectUpdater.h" *************** *** 54,57 **** --- 56,60 ---- #include "cspSky.h" #include "tc3DModel.h" + #include "tcParticleEffect.h" *************** *** 245,249 **** /** ! * Sets position of camera for non-moveWithCamera modes. */ void tc3DViewer::SetGeoPosition(double lon_rad, double lat_rad, float alt_m) --- 248,252 ---- /** ! * Sets position of camera for non-movewith camera modes. */ void tc3DViewer::SetGeoPosition(double lon_rad, double lat_rad, float alt_m) *************** *** 252,255 **** --- 255,264 ---- cameraLatitude = lat_rad; cameraAltitude = alt_m; + + float x = LonToX(cameraLongitude); + float y = LatToY(cameraLatitude); + float z = cameraAltitude; + + cameraPosition.set(x,y,z); } *************** *** 337,340 **** --- 346,445 ---- } + + + #include <osgParticle/Particle> + #include <osgParticle/ParticleSystem> + #include <osgParticle/ParticleSystemUpdater> + #include <osgParticle/ModularEmitter> + #include <osgParticle/ModularProgram> + #include <osgParticle/RandomRateCounter> + #include <osgParticle/SectorPlacer> + #include <osgParticle/RadialShooter> + #include <osgParticle/AccelOperator> + #include <osgParticle/FluidFrictionOperator> + + osgParticle::ParticleSystem *create_simple_particle_system(osg::Group *root) + { + + // Ok folks, this is the first particle system we build; it will be + // very simple, with no textures and no special effects, just default + // values except for a couple of attributes. + + // First of all, we create the ParticleSystem object; it will hold + // our particles and expose the interface for managing them; this object + // is a Drawable, so we'll have to add it to a Geode later. + + osgParticle::ParticleSystem *ps = new osgParticle::ParticleSystem; + + // As for other Drawable classes, the aspect of graphical elements of + // ParticleSystem (the particles) depends on the StateAttribute's we + // give it. The ParticleSystem class has an helper function that let + // us specify a set of the most common attributes: setDefaultAttributes(). + // This method can accept up to three parameters; the first is a texture + // name (std::string), which can be empty to disable texturing, the second + // sets whether particles have to be "emissive" (additive blending) or not; + // the third parameter enables or disables lighting. + + ps->setDefaultAttributes("smoke.rgb", false, false); + + // Now that our particle system is set we have to create an emitter, that is + // an object (actually a Node descendant) that generate new particles at + // each frame. The best choice is to use a ModularEmitter, which allow us to + // achieve a wide variety of emitting styles by composing the emitter using + // three objects: a "counter", a "placer" and a "shooter". The counter must + // tell the ModularEmitter how many particles it has to create for the + // current frame; then, the ModularEmitter creates these particles, and for + // each new particle it instructs the placer and the shooter to set its + // position vector and its velocity vector, respectively. + // By default, a ModularEmitter object initializes itself with a counter of + // type RandomRateCounter, a placer of type PointPlacer and a shooter of + // type RadialShooter (see documentation for details). We are going to leave + // these default objects there, but we'll modify the counter so that it + // counts faster (more particles are emitted at each frame). + + osgParticle::ModularEmitter *emitter = new osgParticle::ModularEmitter; + + // the first thing you *MUST* do after creating an emitter is to set the + // destination particle system, otherwise it won't know where to create + // new particles. + + emitter->setParticleSystem(ps); + + // Ok, get a pointer to the emitter's Counter object. We could also + // create a new RandomRateCounter object and assign it to the emitter, + // but since the default counter is already a RandomRateCounter, we + // just get a pointer to it and change a value. + + osgParticle::RandomRateCounter *rrc = + static_cast<osgParticle::RandomRateCounter *>(emitter->getCounter()); + + // Now set the rate range to a better value. The actual rate at each frame + // will be chosen randomly within that range. + + rrc->setRateRange(20, 30); // generate 20 to 30 particles per second + + // The emitter is done! Let's add it to the scene graph. The cool thing is + // that any emitter node will take into account the accumulated local-to-world + // matrix, so you can attach an emitter to a transform node and see it move. + + root->addChild(emitter); + + // Ok folks, we have almost finished. We don't add any particle modifier + // here (see ModularProgram and Operator classes), so all we still need is + // to create a Geode and add the particle system to it, so it can be + // displayed. + + osg::Geode *geode = new osg::Geode; + geode->addDrawable(ps); + + // add the geode to the scene graph + root->addChild(geode); + + return ps; + + } + + + void tc3DViewer::CreateScene() { *************** *** 405,408 **** --- 510,515 ---- foggedObjects->addChild(terrainNode.get()); foggedObjects->addChild(skyLights.get()); + tc3DModel::SetWorldFrame(rootnode.get()); + rootnode->addChild(foggedObjects.get()); *************** *** 410,413 **** --- 517,539 ---- rootnode->addChild(orthoProjection.get()); + // tcParticleEffect* ps1 = new tcParticleEffect(); + // ps1->AddToSceneGraph(rootnode.get()); + + //osgParticle::ParticleSystem *ps1 = create_simple_particle_system(rootnode.get()); + + // Now that the particle systems and all other related objects have been + // created, we have to add an "updater" node to the scene graph. This node + // will react to cull traversal by updating the specified particles system. + + //osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; + //psu->addParticleSystem(ps1); + + // add the updater node to the scene graph + //rootnode->addChild(psu); + + + //particleSystemUpdater = new osgParticle::ParticleSystemUpdater; + //tcParticleEffect::SetParticleSystemUpdater(particleSystemUpdater.get()); + } *************** *** 567,571 **** else { ! cameraPosition = GetCameraPosition(); } --- 693,697 ---- else { ! // cameraPosition = GetCameraPosition(); // leave camera at pos set by SetGeoPosiiton } *************** *** 676,688 **** /** ! * Converts lon/lat coords to world coords. ! * @return camera position in world coordinates. */ osg::Vec3 tc3DViewer::GetCameraPosition() { ! float x = LonToX(cameraLongitude); ! float y = LatToY(cameraLatitude); ! float z = cameraAltitude; ! return osg::Vec3(x,y,z); } --- 802,810 ---- /** ! * @return camera position vec3 in world coordinates. */ osg::Vec3 tc3DViewer::GetCameraPosition() { ! return cameraPosition; } *************** *** 888,892 **** osg::StateAttribute *sa = stateSet->getAttribute(StateAttribute::POLYGONMODE); osg::PolygonMode *pm = dynamic_cast<osg::PolygonMode*>(sa); ! if (pm == NULL) return; if (viewWireframe) { --- 1010,1020 ---- osg::StateAttribute *sa = stateSet->getAttribute(StateAttribute::POLYGONMODE); osg::PolygonMode *pm = dynamic_cast<osg::PolygonMode*>(sa); ! if (pm == NULL) ! { ! pm = new osg::PolygonMode(); ! pm->setMode(osg::PolygonMode::Face::FRONT_AND_BACK, osg::PolygonMode::FILL); ! stateSet->setAttribute(pm, osg::StateAttribute::ON); ! } ! if (viewWireframe) { |