Sound.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __SOUND_H__
00030 #define __SOUND_H__
00031 
00032 
00033 #include "X3DSoundNode.h"
00034 #include "X3DSoundSourceNode.h"
00035 
00036 namespace H3D {
00037 
00128   class H3DAPI_API Sound : public X3DSoundNode {
00129   public:
00130     
00133     class H3DAPI_API SFSoundSourceNode: public TypedSFNode< X3DSoundSourceNode > {
00134     public:
00136       ~SFSoundSourceNode() { value = NULL; }
00137     protected:
00138       virtual void onAdd( Node *n );
00139       virtual void onRemove( Node *n );
00140     };
00141     
00144     class ALSoundSetup: public PeriodicUpdate< Field > {
00145     public:
00146       virtual void update() {
00147         Sound *s = 
00148           static_cast< Sound * >( getOwner());
00149         s->ALrender();
00150       }
00151     };
00152 
00154     Sound( Inst< SFNode >  _metadata   = 0,
00155            Inst< SFVec3f>  _direction  = 0,
00156            Inst< SFFloat>  _intensity  = 0,
00157            Inst< SFVec3f>  _location   = 0,
00158            Inst< SFFloat>  _maxBack    = 0,
00159            Inst< SFFloat>  _maxFront   = 0,
00160            Inst< SFFloat>  _minBack    = 0,
00161            Inst< SFFloat>  _minFront   = 0,
00162            Inst< SFFloat>  _priority   = 0,
00163            Inst< SFSoundSourceNode >  _source     = 0,
00164            Inst< SFBool >  _spatialize = 0,
00165            Inst< ALSoundSetup > _soundSetup = 0 );
00166 
00167 #ifdef USE_HAPTICS
00170     virtual void traverseSG( TraverseInfo &ti );
00171 #endif
00172 
00174     virtual void ALrender(); 
00175 
00182     auto_ptr< SFVec3f >  direction;
00183 
00198     auto_ptr< SFFloat >  intensity;
00199 
00207     auto_ptr< SFVec3f >  location;
00208 
00215     auto_ptr< SFFloat >  maxBack;
00216 
00223     auto_ptr< SFFloat >  maxFront;
00224 
00231     auto_ptr< SFFloat >  minBack;
00232 
00239     auto_ptr< SFFloat >  minFront;
00240 
00251     auto_ptr< SFFloat >  priority;
00252 
00260     auto_ptr< SFSoundSourceNode  >  source;
00261 
00275     auto_ptr< SFBool  >  spatialize;
00276 
00278     static H3DNodeDatabase database;
00279   protected:
00280     public:
00281 #ifdef HAVE_OPENAL
00282     static bool alut_initialized;
00283     static ALCdevice *al_device;
00284     static ALCcontext *al_context;
00285 #endif
00288     auto_ptr< ALSoundSetup > soundSetup;
00289 
00291     auto_ptr< SFMatrix4f > accForwardMatrix;
00292   };
00293 }
00294 
00295 #endif

Generated on Thu Aug 24 12:38:34 2006 for H3D API by  doxygen 1.4.5