Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
soundrobj.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** 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 ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/soundrobj.h $*
26 * *
27 * Author:: Patrick Smith *
28 * *
29 * $Modtime:: 1/15/02 5:57p $*
30 * *
31 * $Revision:: 4 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#if defined(_MSC_VER)
38#pragma once
39#endif
40
41#ifndef __SOUNDROBJ_H
42#define __SOUNDROBJ_H
43
44#if noWWAUDIO // (gth) removing dependency on WWAUDIO
45
46#include "rendobj.h"
47#include "wwstring.h"
48#include "proto.h"
49#include "w3d_file.h"
50#include "w3derr.h"
51#include "audiblesound.h"
52
53
55// Forward declarations
57class ChunkSaveClass;
58class ChunkLoadClass;
59
60
62//
63// SoundRenderObjClass
64//
65// This object is used to trigger a sound effect in the world. When the object
66// is shown, its associated sound is added to the world and played, when the object
67// is hidden, the associated sound is stopped and removed from the world.
68//
69// This is handy when used in conjunction with the aggregate system for creating
70// complex animations.
71//
73class SoundRenderObjClass : public RenderObjClass
74{
75public:
76
78 // Public flags
80 typedef enum
81 {
82 FLAG_STOP_WHEN_HIDDEN = 0x00000001,
83
84 } FLAGS;
85
87 // Public constructors/destructors
89 SoundRenderObjClass (void);
90 SoundRenderObjClass (const SoundRenderObjClass &src);
91 virtual ~SoundRenderObjClass (void);
92
94 // Public operators
96 const SoundRenderObjClass &operator= (const SoundRenderObjClass &src);
97
99 // Public methods
101
102 //
103 // From RenderObjClass
104 //
105 RenderObjClass * Clone (void) const { return W3DNEW SoundRenderObjClass (*this); }
106 int Class_ID (void) const { return CLASSID_SOUND; }
107 const char * Get_Name (void) const { return Name; }
108 void Set_Name (const char *name) { Name = name; }
109 void Render (RenderInfoClass &rinfo) { }
110 void On_Frame_Update (void);
111 void Set_Hidden (int onoff);
112 void Set_Visible (int onoff);
113 void Set_Animation_Hidden (int onoff);
114 void Set_Force_Visible (int onoff);
115 void Notify_Added (SceneClass *scene);
116 void Notify_Removed (SceneClass *scene);
117 void Set_Transform(const Matrix3D &m);
118 void Set_Position(const Vector3 &v);
119
120 //
121 // SoundRenderObjClass specific
122 //
123 virtual void Set_Sound (AudibleSoundDefinitionClass *definition);
124 virtual AudibleSoundClass * Get_Sound (void) const;
125 virtual AudibleSoundClass * Peek_Sound (void) const { return Sound; }
126
127 //
128 // Flag support
129 //
130 uint32 Get_Flags (void) const { return Flags; }
131 void Set_Flags (uint32 flags) { Flags = flags; }
132 bool Get_Flag (uint32 flag) { return bool((Flags & flag) == flag); }
133 void Set_Flag (uint32 flag, bool onoff);
134
135
136protected:
137
139 // Protected methods
141 virtual void Update_On_Visibilty (void);
142
143private:
144
146 // Private member data
148 bool IsInitialized;
149 StringClass Name;
150 AudibleSoundClass * Sound;
151 uint32 Flags;
152};
153
154
156//
157// SoundRenderObjDefClass
158//
160class SoundRenderObjDefClass : public RefCountClass
161{
162public:
163
165 // Public constructors/destructors
167 SoundRenderObjDefClass (void);
168 SoundRenderObjDefClass (SoundRenderObjClass &render_obj);
169 SoundRenderObjDefClass (const SoundRenderObjDefClass &src);
170 virtual ~SoundRenderObjDefClass (void);
171
173 // Public operators
175 const SoundRenderObjDefClass &operator= (const SoundRenderObjDefClass &src);
176
178 // Public methods
180 RenderObjClass * Create (void);
181 WW3DErrorType Load_W3D (ChunkLoadClass &cload);
182 WW3DErrorType Save_W3D (ChunkSaveClass &csave);
183 const char * Get_Name (void) const { return Name; }
184 void Set_Name (const char *name) { Name = name; }
185 SoundRenderObjDefClass * Clone (void) const { return NEW_REF( SoundRenderObjDefClass, (*this,"SoundRenderObjDefClass::Clone") ); }
186
187 //
188 // Initialization
189 //
190 void Initialize (SoundRenderObjClass &render_obj);
191
192protected:
193
195 // Protected methods
197
198 //
199 // Loading methods
200 //
201 WW3DErrorType Read_Header (ChunkLoadClass &cload);
202 WW3DErrorType Read_Definition (ChunkLoadClass &cload);
203
204 //
205 // Saving methods
206 //
207 WW3DErrorType Write_Header (ChunkSaveClass &csave);
208 WW3DErrorType Write_Definition (ChunkSaveClass &csave);
209
210private:
211
213 // Private member data
215 uint32 Version;
216 StringClass Name;
217 AudibleSoundDefinitionClass Definition;
218 SoundRenderObjClass::FLAGS Flags;
219};
220
221
223//
224// SoundRenderObjPrototypeClass
225//
227class SoundRenderObjPrototypeClass : public W3DMPO, public PrototypeClass
228{
229 W3DMPO_GLUE(SoundRenderObjPrototypeClass)
230public:
231
233 // Public constructors/destructors
235 SoundRenderObjPrototypeClass (SoundRenderObjDefClass *def)
236 : Definition (NULL) { Set_Definition (def); }
237
239 // Public methods
241 const char * Get_Name(void) const { return Definition->Get_Name (); }
242 int Get_Class_ID(void) const { return RenderObjClass::CLASSID_SOUND; }
243 RenderObjClass * Create (void) { return Definition->Create (); }
244 virtual void DeleteSelf() { delete this; }
245
246 SoundRenderObjDefClass * Peek_Definition (void) const { return Definition; }
247 void Set_Definition (SoundRenderObjDefClass *def) { REF_PTR_SET (Definition, def); }
248
249protected:
250 virtual ~SoundRenderObjPrototypeClass (void) { REF_PTR_RELEASE (Definition); }
251
252private:
253
255 // Private member data
257 SoundRenderObjDefClass * Definition;
258};
259
260
262//
263// SoundRenderObjLoaderClass
264//
266class SoundRenderObjLoaderClass : public PrototypeLoaderClass
267{
268public:
269 virtual int Chunk_Type (void) { return W3D_CHUNK_SOUNDROBJ; }
270 virtual PrototypeClass * Load_W3D (ChunkLoadClass &cload);
271};
272
273
275// Global variables
277extern SoundRenderObjLoaderClass _SoundRenderObjLoader;
278
279#endif //noWWAUDIO (gth) removing dependency on wwaudio
280
281#endif //__SOUNDROBJ_H
282
#define NULL
Definition BaseType.h:92
#define bool
Definition gimex.h:284
@ W3D_CHUNK_SOUNDROBJ
Definition w3d_file.h:487
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
#define W3DNEW
Definition always.h:109
unsigned long uint32
Definition bittype.h:46
virtual RenderObjClass * Create(void)=0
virtual const char * Get_Name(void) const =0
virtual void DeleteSelf()=0
virtual int Get_Class_ID(void) const =0
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)=0
virtual int Chunk_Type(void)=0
@ CLASSID_SOUND
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define REF_PTR_SET(dst, src)
Definition refcount.h:79
#define NEW_REF(C, P)
Definition refcount.h:62
unsigned char flag
Definition vchannel.cpp:273
WW3DErrorType
Definition w3derr.h:51