forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSound3D.h
More file actions
193 lines (161 loc) · 8.75 KB
/
Sound3D.h
File metadata and controls
193 lines (161 loc) · 8.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : WWAudio *
* *
* $Archive:: /Commando/Code/WWAudio/Sound3D.h $*
* *
* Author:: Patrick Smith *
* *
* $Modtime:: 8/13/01 12:06p $*
* *
* $Revision:: 13 $*
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#pragma once
#include "AudibleSound.h"
#include "mempool.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Sound3DClass
//
// Class defining a 3D sound. A 3D sound uses position and velocity information
// to determine volume/panning/doppler etc.
//
// A 3D sound should be added to the SoundScene rather than explicitly played. The
// SoundScene will determine when a 3D sound is 'in range' and play it...
//
class Sound3DClass : public AudibleSoundClass
{
public:
//////////////////////////////////////////////////////////////////////
// Friend classes
//////////////////////////////////////////////////////////////////////
friend class SoundSceneClass;
//////////////////////////////////////////////////////////////////////
// Public constructors/destructors
//////////////////////////////////////////////////////////////////////
Sound3DClass (const Sound3DClass &src);
Sound3DClass ();
virtual ~Sound3DClass () override;
//////////////////////////////////////////////////////////////////////
// Public operators
//////////////////////////////////////////////////////////////////////
const Sound3DClass &operator= (const Sound3DClass &src);
//////////////////////////////////////////////////////////////////////
// Identification methods
//////////////////////////////////////////////////////////////////////
virtual SOUND_CLASSID Get_Class_ID () const override { return CLASSID_3D; }
virtual void Make_Static (bool is_static = true) { m_IsStatic = is_static; }
virtual bool Is_Static () const { return m_IsStatic; }
//////////////////////////////////////////////////////////////////////
// Conversion methods
//////////////////////////////////////////////////////////////////////
virtual Sound3DClass * As_Sound3DClass () override { return this; }
//////////////////////////////////////////////////////////////////////
// State control methods
//////////////////////////////////////////////////////////////////////
virtual bool Play (bool alloc_handle = true) override;
//////////////////////////////////////////////////////////////////////
// Priority control
//////////////////////////////////////////////////////////////////////
virtual float Get_Priority () const override { if (m_IsCulled) return 0; return m_Priority; }
//////////////////////////////////////////////////////////////////////
// Scene integration
//////////////////////////////////////////////////////////////////////
virtual void Add_To_Scene (bool start_playing = true) override;
virtual void Remove_From_Scene () override;
//////////////////////////////////////////////////////////////////////
// Position/direction methods
//////////////////////////////////////////////////////////////////////
virtual void Set_Position (const Vector3 &position) override;
virtual Vector3 Get_Position () const override { return m_Transform.Get_Translation (); }
virtual void Set_Listener_Transform (const Matrix3D &tm) override;
virtual void Set_Transform (const Matrix3D &transform) override;
virtual Matrix3D Get_Transform () const override { return m_Transform; }
void Update_Miles_Transform ();
//////////////////////////////////////////////////////////////////////
// Velocity methods
//////////////////////////////////////////////////////////////////////
//
// The velocity settings are in meters per millisecond.
//
virtual void Set_Velocity (const Vector3 &velocity);
virtual Vector3 Get_Velocity () const { return m_CurrentVelocity; }
virtual void Get_Velocity (Vector3 &velocity) const { velocity = m_CurrentVelocity; }
virtual void Auto_Calc_Velocity (bool autocalc = true) { m_bAutoCalcVel = autocalc; }
virtual bool Is_Auto_Calc_Velocity_On () const { return m_bAutoCalcVel; }
//////////////////////////////////////////////////////////////////////
// Attenuation settings
//////////////////////////////////////////////////////////////////////
//
// The maximum-volume radius is the distance from the sound-emitter where
// it seems as loud as it is going to get. Volume does not increase after this
// point. Volume is linerally interpolated from the DropOff distance to the MaxVol
// distance. For some objects (like an airplane) the max-vol distance is
// not 0, but would be 100 or so meters away.
//
virtual void Set_Max_Vol_Radius (float radius = 0);
virtual float Get_Max_Vol_Radius () const { return m_MaxVolRadius; }
//
// This is the distance where the sound can not be heard any longer. (its vol is 0)
//
virtual void Set_DropOff_Radius (float radius = 1) override;
virtual float Get_DropOff_Radius () const override {return(m_DropOffRadius);}
// From PersistClass
virtual const PersistFactoryClass & Get_Factory () const override;
//
// From PersistClass
//
virtual bool Save (ChunkSaveClass &csave) override;
virtual bool Load (ChunkLoadClass &cload) override;
protected:
//////////////////////////////////////////////////////////////////////
// Handle information
//////////////////////////////////////////////////////////////////////
virtual SoundCullObjClass * Peek_Cullable_Wrapper () const override { return m_PhysWrapper; }
virtual void Set_Cullable_Wrapper (SoundCullObjClass *obj) override { m_PhysWrapper = obj; }
//////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////
virtual bool On_Frame_Update (unsigned int milliseconds) override;
//////////////////////////////////////////////////////////////////////
// Handle information
//////////////////////////////////////////////////////////////////////
virtual void Set_Miles_Handle (MILES_HANDLE handle) override;
virtual void Initialize_Miles_Handle () override;
virtual void Allocate_Miles_Handle () override;
//////////////////////////////////////////////////////////////////////
// Event handling
//////////////////////////////////////////////////////////////////////
virtual void On_Loop_End () override;
//////////////////////////////////////////////////////////////////////
// Protected member data
//////////////////////////////////////////////////////////////////////
bool m_IsTransformInitted;
bool m_bAutoCalcVel;
Vector3 m_CurrentVelocity;
float m_MaxVolRadius;
bool m_IsStatic;
unsigned int m_LastUpdate;
};