From: Andrew C. <ac...@us...> - 2004-09-07 23:31:36
|
Update of /cvsroot/planeshift/planeshift/src/client/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11513/src/client/sound Modified Files: pssoundmngr.cpp pssoundmngr.h Log Message: Added ability to specify mesh name in sound.xml file for 3d sound emitters. Index: pssoundmngr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pssoundmngr.cpp 5 Sep 2004 22:09:43 -0000 1.60 --- pssoundmngr.cpp 7 Sep 2004 23:31:24 -0000 1.61 *************** *** 548,552 **** ! psSectorSoundManager key( sectorName ); lastSoundSector = currentSoundSector; --- 548,552 ---- ! psSectorSoundManager key( sectorName, NULL ); lastSoundSector = currentSoundSector; *************** *** 634,638 **** csString sectorName = sector->GetAttributeValue("NAME"); Debug2(LOG_SOUND, "Loading Sound System for Sector: %s", sectorName.GetData() ); ! psSectorSoundManager* manager = new psSectorSoundManager( sectorName ); sectors.Add( manager ); --- 634,638 ---- csString sectorName = sector->GetAttributeValue("NAME"); Debug2(LOG_SOUND, "Loading Sound System for Sector: %s", sectorName.GetData() ); ! psSectorSoundManager* manager = new psSectorSoundManager( sectorName, sndmngr->GetEngine() ); sectors.Add( manager ); *************** *** 672,678 **** float minVol = emitter->GetAttributeValueAsFloat("MINVOL"); float maxVol = emitter->GetAttributeValueAsFloat("MAXVOL"); - csVector3 pos( emitter->GetAttributeValueAsFloat("X"), - emitter->GetAttributeValueAsFloat("Y"), - emitter->GetAttributeValueAsFloat("Z") ); float maxRange = emitter->GetAttributeValueAsFloat("MAX_RANGE"); float minRange = emitter->GetAttributeValueAsFloat("MIN_RANGE"); --- 672,675 ---- *************** *** 688,694 **** true ); ! obj->SetPosition( pos ); obj->SetRange( maxRange, minRange ); - manager->New3DSound( obj ); } --- 685,707 ---- true ); ! ! csRef<iDocumentAttribute> mesh = emitter->GetAttribute("MESH"); ! ! if ( mesh ) ! { ! obj->AttachToMesh( mesh->GetValue() ); ! manager->New3DMeshSound( obj ); ! } ! if ( !mesh ) ! { ! csVector3 pos( emitter->GetAttributeValueAsFloat("X"), ! emitter->GetAttributeValueAsFloat("Y"), ! emitter->GetAttributeValueAsFloat("Z") ); ! obj->SetPosition( pos ); ! manager->New3DSound( obj ); ! } ! ! obj->SetRange( maxRange, minRange ); } *************** *** 747,755 **** } ! psSectorSoundManager::psSectorSoundManager( csString& sectorName ) { sector = sectorName; sounds = true; music = true; } --- 760,769 ---- } ! psSectorSoundManager::psSectorSoundManager( csString& sectorName, iEngine* engine ) { sector = sectorName; sounds = true; music = true; + this->engine = engine; } *************** *** 769,772 **** --- 783,791 ---- } + void psSectorSoundManager::New3DMeshSound( psSoundObject* sound ) + { + unAssignedEmitters.Push( sound ); + } + void psSectorSoundManager::StartBackground() { *************** *** 820,823 **** --- 839,845 ---- psSoundObject* bestWeatherSong = NULL; + printf("/*****************************************************\n"); + printf("Entering a sector\n"); + size_t z; if ( music ) *************** *** 884,891 **** --- 906,940 ---- } + printf(" Checking Unassigned sector count: %d\n", unAssignedEmitters.Length() ); + if ( unAssignedEmitters.Length() > 0 ) + { + printf("We have un assigned emitters\n"); + for ( z = 0; z < unAssignedEmitters.Length(); z++ ) + { + iSector* searchSector = engine->FindSector( sector, NULL ); + if ( searchSector ) + { + psSoundObject* pso = unAssignedEmitters[z]; + printf("Attaching to mesh: %s\n", pso->GetMesh().GetData() ); + csRef<iMeshWrapper> mesh = searchSector->GetMeshes()->FindByName( pso->GetMesh() ); + csRef<iMovable> move = mesh->GetMovable(); + csVector3 rad; + csVector3 pos; + mesh->GetRadius(rad,pos); + pso->SetPosition( pos ); + emitters.Push( pso ); + } + } + unAssignedEmitters.SetLength(0); + } + + + for ( z = 0; z < emitters.Length(); z++ ) { emitters[z]->Start3DSound( position ); } + + } } Index: pssoundmngr.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** pssoundmngr.h 5 Sep 2004 22:09:43 -0000 1.30 --- pssoundmngr.h 7 Sep 2004 23:31:24 -0000 1.31 *************** *** 123,126 **** --- 123,127 ---- void StartMapSoundSystem(); + iEngine* GetEngine() { return engine; } private: bool soundEnabled; *************** *** 259,262 **** --- 260,271 ---- void Update(); + /** Attaches this sound object to a static ( ie non moving mesh ) defined in + * the map world file. + * + * @param meshName The name of the mesh in the world file. + */ + void AttachToMesh( const char* meshName ) { attachedMesh = meshName; } + + csString& GetMesh() { return attachedMesh; } /** Update a sound for a position. *************** *** 296,299 **** --- 305,309 ---- csRef<iSoundSource> sound; + csString attachedMesh; bool isPlaying; *************** *** 319,328 **** - class psSectorSoundManager; - class psSectorSoundManager { public: ! psSectorSoundManager( csString& sectorName ); void Music ( bool toggle ) { music = toggle; } void Sounds( bool toggle ) { sounds = toggle; } --- 329,336 ---- class psSectorSoundManager { public: ! psSectorSoundManager( csString& sectorName, iEngine* engine ); void Music ( bool toggle ) { music = toggle; } void Sounds( bool toggle ) { sounds = toggle; } *************** *** 331,334 **** --- 339,343 ---- void NewAmbient( psSoundObject* sound ); void New3DSound( psSoundObject* sound ); + void New3DMeshSound( psSoundObject* sound ); bool operator==(psSectorSoundManager& other ) *************** *** 354,357 **** --- 363,367 ---- bool CheckAmbient( psSoundObject* ambient ); private: + csRef<iEngine> engine; csString sector; *************** *** 359,363 **** csPDelArray<psSoundObject> ambient; csPDelArray<psSoundObject> emitters; ! bool music; bool sounds; --- 369,378 ---- csPDelArray<psSoundObject> ambient; csPDelArray<psSoundObject> emitters; ! ! // These are 3d sound emitters that are attached to a mesh but have not yet ! // had their positions set. When the map is loaded it will get their positions ! // and move them from this list into the emitters array. ! csArray<psSoundObject*> unAssignedEmitters; ! bool music; bool sounds; |