45 p_directSoundBuffer->QueryInterface(IID_IDirectSound3DBuffer, (
LPVOID*) &m_ds3dBuffer);
46 if (m_ds3dBuffer ==
NULL) {
56 if (m_ds3dBuffer ==
NULL || p_name ==
NULL) {
62 m_enabled = m_isActor =
TRUE;
84 m_positionROI = m_roi;
89 m_ds3dBuffer->SetPosition(position[0], position[1], position[2],
DS3D_IMMEDIATE);
93 if (entity !=
NULL && entity->
IsA(
"LegoActor") && ((
LegoActor*) entity)->GetSoundFrequencyFactor() != 0.0f) {
97 p_directSoundBuffer->GetFrequency(&m_dwFrequency);
99 if (m_actor !=
NULL) {
102 if (m_frequencyFactor != 0.0) {
103 p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency);
114 m_ds3dBuffer->Release();
136 if (m_positionROI !=
NULL) {
143 float distance =
DISTSQRD3(povPosition, position);
145 if (distance > 10000.0f) {
149 if (m_ds3dBuffer !=
NULL) {
150 m_ds3dBuffer->SetPosition(position[0], position[1], position[2],
DS3D_IMMEDIATE);
153 MxS32 newVolume = m_volume;
154 if (distance < 100.0f) {
155 newVolume = m_volume;
157 else if (distance < 400.0f) {
160 else if (distance < 3600.0f) {
163 else if (distance < 10000.0f) {
169 p_directSoundBuffer->SetVolume(newVolume);
175 if (m_actor !=
NULL) {
178 p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency);
190 assert(p_directSoundBuffer);
192 if (p_name ==
NULL) {
193 if (m_ds3dBuffer !=
NULL) {
200 m_enabled = m_isActor =
TRUE;
222 m_positionROI = m_roi;
225 if (m_ds3dBuffer !=
NULL) {
227 m_ds3dBuffer->GetMode(&dwMode);
234 m_ds3dBuffer->SetPosition(position[0], position[1], position[2],
DS3D_IMMEDIATE);
242 float distance =
DISTSQRD3(povPosition, position);
245 if (distance < 100.0f) {
246 newVolume = m_volume;
248 else if (distance < 400.0f) {
249 newVolume = m_volume * 0.4;
251 else if (distance < 3600.0f) {
252 newVolume = m_volume * 0.1;
260 p_directSoundBuffer->SetVolume(newVolume);
265 if (entity !=
NULL && entity->
IsA(
"LegoActor") && ((
LegoActor*) entity)->GetSoundFrequencyFactor() != 0.0f) {
269 p_directSoundBuffer->GetFrequency(&m_dwFrequency);
271 if (m_actor !=
NULL) {
274 if (m_frequencyFactor != 0.0) {
275 p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency);
294 m_positionROI =
NULL;
303 if (m_ds3dBuffer ==
NULL) {
[AI] Implements 3D positional sound logic for LEGO Island using DirectSound 3D buffers.
void Reset()
[AI] Releases any in-world/actor/ROI associations and resets member pointers.
MxS32 SetDistance(MxS32 p_min, MxS32 p_max)
[AI] Sets the minimum and maximum 3D sound effective distances if 3D sound is enabled.
MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer)
[AI] Recalculates and updates the sound position on the underlying DirectSound 3D buffer or the volum...
void FUN_10011a60(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char *p_name)
[AI] Associates a new in-world object to this sound, updating its 3D position tracking and (if applic...
virtual ~Lego3DSound()
[AI] Destroys the Lego3DSound object and releases associated DirectSound buffers and object reference...
void Destroy()
[AI] Cleans up and releases all resources (DirectSound 3D buffer, associated object references).
MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char *p_name, MxS32 p_volume)
[AI] Initializes 3D sound for a given DirectSound buffer and associates it with a named game object.
void Init()
[AI] Initializes internal fields to their defaults. Used by constructor and destroy logic....
[AI] Represents an actor (character) entity in the LEGO Island 3D world, providing specific actor log...
virtual MxFloat GetSoundFrequencyFactor()
[AI] Returns the current frequency factor for the actor's sound.
LegoROI * CreateAutoROI(const char *p_name, const char *p_lodName, MxBool p_createEntity)
[AI] Creates an "auto" ROI object with the given name, LOD name, and optional entity creation.
void ReleaseActor(const char *p_name)
[AI] Releases a character/ROI by name, decrementing its reference count and deleting if zero.
LegoROI * GetActorROI(const char *p_name, MxBool p_createEntity)
[AI] Returns a LegoROI for the given character name, creating and registering the actor if necessary.
void ReleaseAutoROI(LegoROI *p_roi)
[AI] Releases an "auto" ROI, used for dynamically created ROI objects by this manager.
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
MxBool IsA(const char *p_name) const override
[AI] Polymorphic type check for this entity given a string.
LegoROI * FindChildROI(const LegoChar *p_name, LegoROI *p_roi)
[AI] Recursively searches for a child ROI by name, starting at the given ROI.
LegoEntity * GetEntity()
[AI] Gets the entity associated with this ROI (or NULL).
LegoROI * GetViewROI()
[AI] Returns the viewpoint ROI for the current view/camera.
virtual MxS32 GetVolume()
[AI] Gets the current global audio volume.
static MxBool IsSound3D()
[AI] Returns current state of 3D sound configuration.
MxS32 GetAttenuation(MxU32 p_volume)
[AI] Maps a percentage volume (1-100) to a DirectSound-specific attenuation value.
const float * GetWorldPosition() const
Returns a pointer to the world position from the transformation matrix (translation row).
[AI] ViewROI objects represent viewable and placeable objects in the scene, each holding their own tr...
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DECOMP_SIZE_ASSERT(T, S)
struct IDirectSoundBuffer * LPDIRECTSOUNDBUFFER
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
LegoCharacterManager * CharacterManager()
[AI] Accessor for the character manager, which manages in-game characters/NPCs. [AI]
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
LegoROI * FindROI(const char *p_name)
[AI] Looks up a LegoROI (Real-time Object Instance) by name in the current world or global registry.