[Gcblue-commits] gcb_wx/src/graphics ObjectUpdater.cpp,1.12,1.13 tc3DModel.cpp,1.20,1.21 tc3DViewer.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-01-27 01:02:51
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11058/src/graphics Modified Files: ObjectUpdater.cpp tc3DModel.cpp tc3DViewer.cpp tcButton.cpp tcCreditView.cpp tcMapView.cpp tcOOBView.cpp tcParticleEffect.cpp tcScenarioSelectView.cpp tcSmoker.cpp tcStartView.cpp Log Message: Multiple smoke trail fixes Animation tweaks Index: tcStartView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStartView.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcStartView.cpp 2 Nov 2004 04:23:56 -0000 1.5 --- tcStartView.cpp 27 Jan 2005 01:01:51 -0000 1.6 *************** *** 185,189 **** return; } ! //tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } --- 185,189 ---- return; } ! //tcSound::Get()->PlayEffect("Beep2"); } *************** *** 195,199 **** if ((maButton[i].mnState == 0)&&(bButtonEnabled)) { ! tcSound::Get()->PlayEffect(SEFFECT_THUCK); } if (bButtonEnabled) {maButton[i].mnState = 1;} --- 195,199 ---- if ((maButton[i].mnState == 0)&&(bButtonEnabled)) { ! tcSound::Get()->PlayEffect("Thuck"); } if (bButtonEnabled) {maButton[i].mnState = 1;} *************** *** 231,235 **** if (nButton != 2) { ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } int command_id; --- 231,235 ---- if (nButton != 2) { ! tcSound::Get()->PlayEffect("Beep2"); } int command_id; Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tc3DModel.cpp 16 Jan 2005 18:36:29 -0000 1.20 --- tc3DModel.cpp 27 Jan 2005 01:01:48 -0000 1.21 *************** *** 2,6 **** ** @file tc3DModel.cpp */ ! /* Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tc3DModel.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,36 **** --- 33,37 ---- #include "tcParticleEffect.h" #include "tcParticlePlacer.h" + #include "tcSound.h" #include "tcGenericDBObject.h" #include "common/tinyxml.h" *************** *** 40,43 **** --- 41,48 ---- #include <osgUtil/SmoothingVisitor> + #include <osgAL/SoundNode> + #include <osgAL/SoundRoot> + #include <osgAL/SoundManager> + #include <osgAL/SoundState> #ifdef _DEBUG *************** *** 412,415 **** --- 417,422 ---- std::cout << "Load of 3D model: " << model_name << " failed.\n"; std::cerr << "Load of 3D model: " << model_name << " failed.\n"; + + modelNode = unknownAll.get(); // use unknown model as default } *************** *** 700,703 **** --- 707,712 ---- : distanceFromCamera(1e10) { + static int addCount = 0; + wxASSERT(source->modelNode.valid()); // error if modelNode not loaded yet wxASSERT(unknownAll.valid()); *************** *** 709,712 **** --- 718,737 ---- modelTransform->addChild(root.get()); + try + { + if (addCount < 0) + { + soundNode = tcSound::Get()->CreateSound("helolaunch.wav"); + modelTransform->addChild(soundNode.get()); + addCount++; + } + } + catch (...) + { + fprintf(stderr, "Failed to load sound file\n"); + } + + + modelGroup = new osg::LOD; Index: tcSmoker.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcSmoker.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSmoker.cpp 16 Jan 2005 18:36:29 -0000 1.1 --- tcSmoker.cpp 27 Jan 2005 01:01:50 -0000 1.2 *************** *** 36,39 **** --- 36,65 ---- + + tcSmokeTrail& tcSmokeTrail::operator= (const tcSmokeTrail& rhs) + { + smokeEffect = rhs.smokeEffect; + smokePlacer = rhs.smokePlacer; + smokeSource = rhs.smokeSource; + + return *this; + } + + tcSmokeTrail::tcSmokeTrail() + { + } + + tcSmokeTrail::tcSmokeTrail(const tcSmokeTrail& source) + { + smokeEffect = source.smokeEffect; + smokePlacer = source.smokePlacer; + smokeSource = source.smokeSource; + } + + tcSmokeTrail::~tcSmokeTrail() + { + } + + osg::ref_ptr<osg::Group> tcSmoker::world; *************** *** 51,60 **** void tcSmoker::AddSmokeTrail(const osg::Vec3& smokeSource, int smokeMode) { ! tcSmokeTrail trail; ! trail.smokeEffect = new tcParticleEffect(smokeMode); ! trail.smokeEffect->AddToSceneGraph(world.get()); ! trail.smokePlacer = trail.smokeEffect->GetParticlePlacer(); ! trail.smokeSource = smokeSource; smokeTrails.push_back(trail); --- 77,86 ---- void tcSmoker::AddSmokeTrail(const osg::Vec3& smokeSource, int smokeMode) { ! osg::ref_ptr<tcSmokeTrail> trail = new tcSmokeTrail; ! trail->smokeEffect = new tcParticleEffect(smokeMode); ! trail->smokeEffect->AddToSceneGraph(world.get()); ! trail->smokePlacer = trail->smokeEffect->GetParticlePlacer(); ! trail->smokeSource = smokeSource; smokeTrails.push_back(trail); *************** *** 69,75 **** for (size_t n=0; n<nSmoke; n++) { ! tcSmokeTrail& trail = smokeTrails[n]; ! trail.smokeEffect->DetachFromSceneGraph(); ! delete trail.smokeEffect; } smokeTrails.clear(); --- 95,104 ---- for (size_t n=0; n<nSmoke; n++) { ! //smokeTrails[n]->smokeEffect->DetachFromSceneGraph(); ! smokeTrails[n]->smokeEffect->PreDestroy(); ! // delete smokeTrails[n]->smokeEffect.release(); // necessary? ! // delete smokeTrails[n]->smokePlacer.release(); ! // delete smokeTrails[n].release(); ! } smokeTrails.clear(); *************** *** 118,129 **** for (size_t n=0; n<nSmoke; n++) { ! tcSmokeTrail& trail = smokeTrails[n]; ! wxASSERT(trail.smokePlacer); ! if (trail.smokePlacer == 0) return; ! osg::Vec3 smokeOffset = rotation * trail.smokeSource; osg::Vec3 offsetPos = pos + smokeOffset; ! trail.smokePlacer->setCenter(offsetPos.x(), offsetPos.y(), offsetPos.z()); } --- 147,157 ---- for (size_t n=0; n<nSmoke; n++) { ! wxASSERT(smokeTrails[n]->smokePlacer.valid()); ! if (!smokeTrails[n]->smokePlacer.valid()) return; ! osg::Vec3 smokeOffset = rotation * smokeTrails[n]->smokeSource; osg::Vec3 offsetPos = pos + smokeOffset; ! smokeTrails[n]->smokePlacer->setCenter(offsetPos.x(), offsetPos.y(), offsetPos.z()); } *************** *** 143,145 **** --- 171,174 ---- tcSmoker::~tcSmoker() { + DeleteTrails(); } Index: tcCreditView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcCreditView.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcCreditView.cpp 5 Dec 2004 02:49:47 -0000 1.10 --- tcCreditView.cpp 27 Jan 2005 01:01:49 -0000 1.11 *************** *** 215,219 **** //mpBrush->SetColor(Color(255,255,255,255)); //pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); ! //tcSound::Get()->PlayEffect(SEFFECT_EXPLOSION2); } if (nFlashId >= 0) --- 215,219 ---- //mpBrush->SetColor(Color(255,255,255,255)); //pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); ! //tcSound::Get()->PlayEffect("Explosion2"); } if (nFlashId >= 0) Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcOOBView.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcOOBView.cpp 11 Dec 2004 01:09:06 -0000 1.6 --- tcOOBView.cpp 27 Jan 2005 01:01:50 -0000 1.7 *************** *** 652,656 **** mnSelectedKey = new_key; ! tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); mbMouseDrag = true; --- 652,656 ---- mnSelectedKey = new_key; ! tcSound::Get()->PlayEffect("ShortBeep"); mbMouseDrag = true; *************** *** 673,677 **** msFormationChangeInfo.mbApply = true; ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } } --- 673,677 ---- msFormationChangeInfo.mbApply = true; ! tcSound::Get()->PlayEffect("Beep2"); } } Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcScenarioSelectView.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcScenarioSelectView.cpp 14 Nov 2004 22:52:21 -0000 1.8 --- tcScenarioSelectView.cpp 27 Jan 2005 01:01:50 -0000 1.9 *************** *** 329,338 **** { item.drawState = scenarioInfo::ON; ! if (item.drawState != oldState) tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } else if (r.Inside(mousePosition)) { item.drawState = scenarioInfo::OVER; ! if (item.drawState != oldState) tcSound::Get()->PlayEffect(SEFFECT_THUCK); } else --- 329,338 ---- { item.drawState = scenarioInfo::ON; ! if (item.drawState != oldState) tcSound::Get()->PlayEffect("Beep2"); } else if (r.Inside(mousePosition)) { item.drawState = scenarioInfo::OVER; ! if (item.drawState != oldState) tcSound::Get()->PlayEffect("Thuck"); } else Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcMapView.cpp 10 Jan 2005 00:30:54 -0000 1.14 --- tcMapView.cpp 27 Jan 2005 01:01:49 -0000 1.15 *************** *** 2151,2155 **** { SetViewCenterZoom(buttonDownPoint, 1.5f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); return; } --- 2151,2155 ---- { SetViewCenterZoom(buttonDownPoint, 1.5f); ! tcSound::Get()->PlayEffect("Beep2"); return; } *************** *** 2157,2161 **** { SetViewCenterZoom(buttonDownPoint, 1.0f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); return; } --- 2157,2161 ---- { SetViewCenterZoom(buttonDownPoint, 1.0f); ! tcSound::Get()->PlayEffect("Beep2"); return; } *************** *** 2227,2231 **** { SetViewCenterZoom(point,0.7f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); return; // old returned true } --- 2227,2231 ---- { SetViewCenterZoom(point,0.7f); ! tcSound::Get()->PlayEffect("Beep2"); return; // old returned true } *************** *** 2285,2294 **** { SetViewCenterZoom(point,2.0f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } else if (zDelta < 0) { SetViewCenterZoom(point,0.5f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } } --- 2285,2294 ---- { SetViewCenterZoom(point,2.0f); ! tcSound::Get()->PlayEffect("Beep2"); } else if (zDelta < 0) { SetViewCenterZoom(point,0.5f); ! tcSound::Get()->PlayEffect("Beep2"); } } *************** *** 2596,2605 **** if (event.ControlDown() && event.ShiftDown()) { ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); tcPoint geoPoint = ScreenToGeo(point); // geopoint (lon,lat) in radians ChangeTheater(C_180OVERPI * geoPoint.x, C_180OVERPI * geoPoint.y); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } else if (event.ControlDown()) --- 2596,2605 ---- if (event.ControlDown() && event.ShiftDown()) { ! tcSound::Get()->PlayEffect("Beep2"); tcPoint geoPoint = ScreenToGeo(point); // geopoint (lon,lat) in radians ChangeTheater(C_180OVERPI * geoPoint.x, C_180OVERPI * geoPoint.y); ! tcSound::Get()->PlayEffect("Beep2"); } else if (event.ControlDown()) *************** *** 2608,2612 **** { SetViewCenterZoom(point,2.0f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } } --- 2608,2612 ---- { SetViewCenterZoom(point,2.0f); ! tcSound::Get()->PlayEffect("Beep2"); } } *************** *** 2614,2618 **** { SetViewCenterZoom(point,1.0f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } else --- 2614,2618 ---- { SetViewCenterZoom(point,1.0f); ! tcSound::Get()->PlayEffect("Beep2"); } else *************** *** 2628,2632 **** { SetViewCenterZoom(point,0.5f); ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } } --- 2628,2632 ---- { SetViewCenterZoom(point,0.5f); ! tcSound::Get()->PlayEffect("Beep2"); } } Index: tcButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcButton.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcButton.cpp 21 Dec 2004 02:26:17 -0000 1.16 --- tcButton.cpp 27 Jan 2005 01:01:49 -0000 1.17 *************** *** 217,221 **** isButtonOn = false; isMouseOver = false; ! soundEffect = 19; fontSize = 12.0f; sendRedraw = false; --- 217,221 ---- isButtonOn = false; isMouseOver = false; ! soundEffect = "MutedBeep"; fontSize = 12.0f; sendRedraw = false; *************** *** 299,303 **** isButtonOn = false; isMouseOver = false; ! soundEffect = -1; fontSize = 16.0f; sendRedraw = false; --- 299,303 ---- isButtonOn = false; isMouseOver = false; ! soundEffect = ""; fontSize = 16.0f; sendRedraw = false; Index: tcParticleEffect.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcParticleEffect.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcParticleEffect.cpp 21 Dec 2004 02:26:17 -0000 1.7 --- tcParticleEffect.cpp 27 Jan 2005 01:01:50 -0000 1.8 *************** *** 296,301 **** --- 296,303 ---- if (!root) { + #ifdef _DEBUG fprintf(stderr, "Warning - tcParticleEffect already removed from scene graph," "skipping\n"); + #endif return; } *************** *** 349,352 **** --- 351,385 ---- } + /** + * Workaround for circular references with ref_ptr + * Call before deleting + */ + void tcParticleEffect::PreDestroy() + { + if (emitter.valid()) + { + emitter->setParticleSystem(0); + } + + if (program.valid()) + { + program->setParticleSystem(0); + } + + if (program.valid()) + { + program->setParticleSystem(0); + } + + if (updater.valid()) + { + updater->removeParticleSystem(this); + } + + if (geode.valid()) + { + geode->removeDrawable(this); + } + } tcParticleEffect::tcParticleEffect(int smokeModeCode) *************** *** 419,422 **** --- 452,456 ---- tcParticleEffect::~tcParticleEffect() { + if (root) DetachFromSceneGraph(); } Index: ObjectUpdater.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/ObjectUpdater.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ObjectUpdater.cpp 16 Jan 2005 18:36:29 -0000 1.12 --- ObjectUpdater.cpp 27 Jan 2005 01:01:48 -0000 1.13 *************** *** 87,91 **** if (info.animationType == 0) { ! angle *= gameObject->mcKin.mfSpeed_kts; } --- 87,97 ---- if (info.animationType == 0) { ! /* for subs and surface ships change rate with speed (omega is radians per second per knot) ! ** aircraft including helos use a fixed rate (omega is radians per second) ! */ ! if (gameObject->mcKin.mfSpeed_kts < 50.0f) ! { ! angle *= gameObject->mcKin.mfSpeed_kts; ! } } Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tc3DViewer.cpp 21 Dec 2004 02:26:17 -0000 1.8 --- tc3DViewer.cpp 27 Jan 2005 01:01:49 -0000 1.9 *************** *** 50,53 **** --- 50,57 ---- #include <osgUtil/UpdateVisitor> + #include <osgAL/SoundNode> + #include <osgAL/SoundRoot> + #include <osgAL/SoundManager> + #include <osgAL/SoundState> *************** *** 1058,1061 **** --- 1062,1068 ---- sceneViewFar->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); + osgAL::SoundManager::instance()->getListener()->setPosition(cameraPosition.x(), cameraPosition.y(), + cameraPosition.z()); + // update skyTransform based on camera position skyTransform->asPositionAttitudeTransform()-> *************** *** 1871,1874 **** --- 1878,1883 ---- tc3DModel::LoadUnknowns(); + + rootnode->addChild(tcSound::Get()->GetSoundRoot()); } |