sfx3DWorld.h

Engine/source/T3D/sfx/sfx3DWorld.h

More...

Classes:

class

SFXObject implementation for the 3D system.

class

Manager for the 3D sound world.

Public Variables

The singleton instance of SFX3DWorld, if there is one.

Detailed Description

Public Variables

SFX3DWorld * gSFX3DWorld 

The singleton instance of SFX3DWorld, if there is one.

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SFX3DWORLD_H_
 25#define _SFX3DWORLD_H_
 26
 27#ifndef _SCENETRACKER_H_
 28   #include "scene/sceneTracker.h"
 29#endif
 30#ifndef _SFXWORLD_H_
 31   #include "sfx/sfxWorld.h"
 32#endif
 33#ifndef _DATACHUNKER_H_
 34   #include "core/dataChunker.h"
 35#endif
 36#ifndef _OBJECTTYPES_H_
 37   #include "T3D/objectTypes.h"
 38#endif
 39
 40
 41class SFX3DWorld;
 42
 43
 44/// SFXObject implementation for the 3D system.
 45class SFX3DObject : public SceneObjectLink, public SFXObject< 3 >
 46{
 47   public:
 48   
 49      typedef SceneObjectLink Parent;
 50      
 51      ///
 52      SFX3DObject( SFX3DWorld* world, SceneObject* object );
 53      
 54      /// Return the transform for the ears on this object.
 55      void getEarTransform( MatrixF& transform ) const;
 56               
 57      // SFXObject.
 58      void getReferenceCenter( F32 position[ 3 ] ) const;
 59      void getBounds( F32 minBounds[ 3 ], F32 maxBounds[ 3 ] ) const;
 60      void getRealBounds( F32 minBounds[ 3 ], F32 maxBounds[ 3 ] ) const;
 61      SFXAmbience* getAmbience() const;
 62      bool containsPoint( const F32 point[ 3 ] ) const;
 63      String describeSelf() const;
 64};
 65
 66
 67/// Manager for the 3D sound world.
 68///
 69/// Any SceneObject in the world can be made the current listener.  It's ear position (if it's a ShapeBase)
 70/// will then be used as the reference center for attenuating 3D sounds, traversing ambient spaces, etc.
 71///
 72class SFX3DWorld : public SceneTracker
 73{
 74   public:
 75   
 76      typedef SceneTracker Parent;
 77      typedef SFXWorld< 3, SFX3DObject*> SFXWorldType;
 78      
 79      enum
 80      {
 81         /// The scene object type mask used to filter out the
 82         /// type of objects we are interested in.
 83         TYPEMASK = WaterObjectType       // Sound ambience.
 84                  | StaticShapeObjectType // Occlusion and sound ambience.
 85                  | StaticObjectType      // Portals and zones.
 86      };
 87      
 88   protected:
 89   
 90      /// The SFX world tracking system.
 91      SFXWorldType mSFXWorld;
 92      
 93      /// Allocator for the SFX3DObject SceneObjectLinks we attach to SceneObjects.
 94      FreeListChunker< SFX3DObject> mChunker;
 95      
 96      // SceneTracker.
 97      virtual bool _isTrackableObject( SceneObject* object ) const;
 98   
 99   public:
100   
101      ///
102      SFX3DWorld();
103      
104      ///
105      void update();
106      
107      /// Return the current listener object.
108      SceneObject* getListener() const;
109      
110      /// Make the given object the current listener object.
111      void setListener( SceneObject* object );
112      
113      /// Notify the SFX world that the given object had a (potential) change in its
114      /// sound-related properties.
115      void notifyChanged( SceneObject* object );
116      
117      ///
118      void debugDump();
119      
120      // SceneTracker.
121      virtual void registerObject( SceneObject* object );
122      virtual void unregisterObject( SceneObject* object );
123      virtual void updateObject( SceneObjectLink* object );
124};
125
126
127/// The singleton instance of SFX3DWorld, if there is one.
128extern SFX3DWorld* gSFX3DWorld;
129
130#endif // !_SFX3DWORLD_H_
131
132