Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Listener.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::Scene
3 //
4 #ifndef __AUDIO_LISTENER_H__INCLUDED__
5 #define __AUDIO_LISTENER_H__INCLUDED__
6 
7 #include "Exceptions.h"
8 #include "Types.h"
9 #include "RenderableListener.h"
10 
11 namespace Audio {
12 
21  class Listener
22  {
23  LVector3 position;
24  Vector3 atDirection;
25  Vector3 upDirection;
26  Vector3 velocity;
27 
28  Scalar radius;
29 
30  Scalar gain;
31 
32  Range<Scalar> cosAngleRange;
33 
34  SharedPtr<UserData> userDataPtr;
35  SharedPtr<RenderableListener> rendererDataPtr;
36 
37  Matrix3 worldToLocal;
38 
39  protected:
44  struct Dirty
45  {
47  : location(0),
48  attributes(0),
49  gain(0)
50  {}
51 
53  int location : 1;
54 
56  int attributes : 1;
57 
59  int gain : 1;
60 
61  void reset()
62  {
63  location = 0;
64  attributes = 0;
65  gain = 0;
66  }
67 
68  void setAll()
69  {
70  location = 1;
71  attributes = 1;
72  gain = 1;
73  }
74  } dirty;
75 
76  public:
78  Listener() throw();
79 
80  virtual ~Listener();
81 
83  LVector3 getPosition() const throw() { return position; }
84 
86  void setPosition(LVector3 x) throw() { position = x; dirty.location = 1; }
87 
89  Vector3 getAtDirection() const throw() { return atDirection; }
90 
92  Vector3 getUpDirection() const throw() { return upDirection; }
93 
95  void setOrientation(Vector3 at, Vector3 up) throw() { atDirection = at; upDirection = up; dirty.location = 1; }
96 
98  Vector3 getVelocity() const throw() { return velocity; }
99 
101  void setVelocity(Vector3 x) throw() { velocity = x; dirty.location = 1; }
102 
103 
110  Range<Scalar> getAngleRange() const throw();
111 
113  void setAngleRange(Range<Scalar> r) throw();
114 
116  Range<Scalar> getCosAngleRange() const throw() { return cosAngleRange; }
117 
119  void setCosAngleRange(Range<Scalar> r) throw() { cosAngleRange = r; dirty.attributes = 1; }
120 
122  Scalar getRadius() const throw() { return radius; }
123 
125  void setRadius(Scalar r) throw() { radius = r; dirty.attributes = 1; }
126 
127 
129  Scalar getGain() const throw() { return gain; }
130 
132  void setGain(Scalar g) throw() { gain = g; dirty.gain = 1; }
133 
134 
136  SharedPtr<RenderableListener> getRenderable() const throw() { return rendererDataPtr; }
137 
139  void setRenderable(SharedPtr<RenderableListener> ptr) throw() { rendererDataPtr = ptr; dirty.setAll(); }
140 
142  SharedPtr<UserData> getUserData() const throw() { return userDataPtr; }
143 
145  void setUserData(SharedPtr<UserData> ptr) throw() { userDataPtr = ptr; }
146 
147 
153  void update(int flags) throw();
154 
155 
163  Vector3 toLocalDirection(Vector3 dir) const throw();
164 
165 
166  };
167 
168 };
169 
170 #endif//__AUDIO_LISTENER_H__INCLUDED__