src/soundManager.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by                                                 *
00003  *         Pierre-yves JEZEQUEL, Julien MICHOT, Loic MOISAN,               *
00004  *         Julien PAPILLON, Sebastien PINEAUD, Barthelemy SERRES           *
00005  *                                                                         *
00006  *   https://sourceforge.net/projects/anidam                               *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  ***************************************************************************/
00023 #include <vector>
00024 using std::vector;
00025 // Sound 
00026 
00027 #include <openalpp/alpp.h>
00028 #include <osgAL/SoundNode>
00029 #include <osgAL/SoundRoot>
00030 #include <osgAL/SoundManager>
00031 #include <osgAL/SoundState>
00032 #include <osgAL/OccludeCallback>
00033 
00034 // osg
00035 #include <osg/Notify>
00036 #include <osg/MatrixTransform>
00037 #include <osg/Vec3d>
00038 #include <osg/PositionAttitudeTransform>
00039 #include <osg/Geometry>
00040 #include <osg/Geode>
00041 
00042 #include <osg/ShapeDrawable>
00043 
00044 #include <osgUtil/Optimizer>
00045 
00046 #include <osgDB/Registry>
00047 #include <osgDB/ReadFile>
00048 
00049 
00050 
00051 class SoundManager {
00052 public:
00053         enum SOUND{
00054             ONE,
00055             TWO,
00056             THREE,
00057             FOUR,
00058             FIVE,
00059             SIX,
00060             SEVEN,
00061             EIGHT
00062         };
00063      /*//////////////////////////////////////////////////////////////////////////
00064         Default Constructor - This does not allocate any lights. Note that upon
00065         construction, this module is not yet ready for light allocation. The
00066         init() function must first be called.
00068         SoundManager(osg::ref_ptr<osg::Group> );
00069     
00070     /*//////////////////////////////////////////////////////////////////////////
00071         Default Constructor - Empty
00073         ~SoundManager();
00074 
00075     /*//////////////////////////////////////////////////////////////////////////
00076         This function is necessary to grab the osg::Group that will contain
00077         any lights that are requested for allocation. Note that this osg::Group,
00078         for some reason, should be DIRECTLY under the SceneView. That is, there
00079         should not be any other nodes between the SceneView and this osg::Group.
00080         It has something to do with osg::SetStates, but I have yet to figure out
00081         what.
00083         bool init();//osg::ref_ptr<osg::Group> root);
00084     
00085     /*//////////////////////////////////////////////////////////////////////////
00086         This function is used to request allocation of an osg::Light. The light
00087         is requested by passing the enumerated value representing the number
00088         of the light. If the light has not been previously allocated, it is created
00089         and added to the osg::Group for rendering. The osg::Light is returned
00090         as a pointer, which may be used to modify the light properties via
00091         the osg::Light interface.
00092         
00093         If the light has been previously allocated, it is returned as a pointer.
00094         
00095         Note that if this module has not been initialized with the init() function,
00096         NULL will be returned instead of an osg::Light.
00098         osg::ref_ptr<osgAL::SoundNode> createSound(const std::string& file,float gain=0.8, float pitch=1, bool loop=true);
00099         
00100         void playSound(SoundManager::SOUND nb,osg::ref_ptr<osgAL::SoundState> sound_state, int priority);
00101         void setSoundPosition(osg::Vec3d vect);
00102         osg::ref_ptr<osgAL::SoundNode> createSoundNode(const std::string& file, bool occlude, osg::Node *root, bool is_stream);
00103 
00104         osg::ref_ptr<osgAL::SoundRoot> getSoundRoot();
00105         osg::ref_ptr<osgAL::SoundState> getSoundState();
00106 
00107 private:
00108        osg::ref_ptr<osgAL::SoundState> m_sound_state;
00109 
00110        osg::ref_ptr<osgAL::SoundRoot> sound_root;
00111 
00112        osg::ref_ptr<osg::Group> root;
00113 
00114     };

Generated on Tue Jun 5 16:56:48 2007 for Anidam by  doxygen 1.5.1