Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
188 lines
4.8 KiB
C++
188 lines
4.8 KiB
C++
#include "mungal4.h"
|
|
#pragma hdrstop
|
|
|
|
#include "l4audwtr.h"
|
|
#include "..\munga\objstrm.h"
|
|
#include "..\munga\namelist.h"
|
|
|
|
//#############################################################################
|
|
//######################## L4AudioCollisionTrigger ######################
|
|
//#############################################################################
|
|
|
|
#if 0
|
|
L4AudioCollisionTrigger::L4AudioCollisionTrigger(
|
|
StateIndicator *state_attribute_ptr,
|
|
Normal *normal_attribute_ptr,
|
|
Static3DPatchSource *audio_source,
|
|
Enumeration trigger_state,
|
|
AudioControlID control_ID,
|
|
AudioControlValue control_value,
|
|
Logical dump_value
|
|
):
|
|
AudioStateWatcher(
|
|
state_attribute_ptr,
|
|
audio_source,
|
|
L4AudioCollisionTriggerClassID,
|
|
dump_value
|
|
)
|
|
{
|
|
Check(normal_attribute_ptr);
|
|
normalAttributePtr = normal_attribute_ptr;
|
|
triggerState = trigger_state;
|
|
controlID = control_ID;
|
|
controlValue = control_value;
|
|
|
|
PrimeWatcher();
|
|
}
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
L4AudioCollisionTrigger::~L4AudioCollisionTrigger()
|
|
{
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
L4AudioCollisionTrigger::L4AudioCollisionTrigger(
|
|
PlugStream *stream,
|
|
Entity *entity
|
|
):
|
|
AudioStateWatcher(stream, entity)
|
|
{
|
|
//
|
|
// HACK - Get "normal" attribute pointer with names
|
|
//
|
|
CString attribute_name;
|
|
void *attribute_ptr;
|
|
|
|
MemoryStream_Read(stream, &attribute_name);
|
|
Check(entity);
|
|
attribute_ptr = entity->GetAttributePointer(attribute_name);
|
|
normalAttributePtr = Cast_Object(Normal*, attribute_ptr);
|
|
|
|
//
|
|
// Get other fields
|
|
//
|
|
MemoryStream_Read(stream, &triggerState);
|
|
MemoryStream_Read(stream, &controlID);
|
|
MemoryStream_Read(stream, &controlValue);
|
|
|
|
PrimeWatcher();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
L4AudioCollisionTrigger::BuildFromPage(
|
|
PlugStream *stream,
|
|
NameList *name_list,
|
|
ClassID class_ID,
|
|
ObjectID object_ID
|
|
)
|
|
{
|
|
AudioStateWatcher::BuildFromPage(stream, name_list, class_ID, object_ID);
|
|
|
|
//
|
|
// HACK - Store "normal" attribute pointer with names
|
|
//
|
|
MEM_STRM_WRITE_ENTRY(*stream, name_list, CString, normal_attribute);
|
|
|
|
//
|
|
// Store fields
|
|
//
|
|
MEM_STRM_WRITE_ENTRY(*stream, name_list, Enumeration, trigger_state);
|
|
MEM_STRM_WRITE_ENTRY(*stream, name_list, Enumeration, control_ID);
|
|
MEM_STRM_WRITE_ENTRY(*stream, name_list, AudioControlValue, control_value);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
L4AudioCollisionTrigger::TestInstance() const
|
|
{
|
|
AudioStateWatcher::TestInstance();
|
|
Check(normalAttributePtr);
|
|
return True;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
L4AudioCollisionTrigger::StateChanged(
|
|
Enumeration,
|
|
Enumeration new_state
|
|
)
|
|
{
|
|
if (new_state == triggerState)
|
|
{
|
|
//
|
|
// Get static 3D source
|
|
//
|
|
AudioComponent *audio_component;
|
|
Static3DPatchSource *audio_source;
|
|
|
|
Check(&audioComponentSocket);
|
|
audio_component = audioComponentSocket.GetCurrent();
|
|
Check(audio_component);
|
|
audio_source = Cast_Object(Static3DPatchSource*, audio_component);
|
|
Check(audio_source);
|
|
|
|
//
|
|
// Get collision direction
|
|
//
|
|
Vector3D collision_direction(0.0f, 0.0f, 0.0f);
|
|
|
|
Check(normalAttributePtr);
|
|
collision_direction -= *normalAttributePtr;
|
|
Check(&collision_direction);
|
|
audio_source->SetPosition(collision_direction);
|
|
|
|
//
|
|
// Send control value
|
|
//
|
|
#if 1
|
|
audio_component->ReceiveControl(controlID, controlValue);
|
|
#else
|
|
audio_component->PostReceiveControl(controlID, controlValue);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
#if DEBUG_LEVEL>0
|
|
void
|
|
L4AudioCollisionTrigger::DumpValue(const StateIndicator *state_attribute_ptr)
|
|
#else
|
|
void
|
|
L4AudioCollisionTrigger::DumpValue(const StateIndicator*)
|
|
#endif
|
|
{
|
|
//
|
|
// Get collision direction
|
|
//
|
|
Vector3D collision_direction(0.0f, 0.0f, 0.0f);
|
|
|
|
Check(normalAttributePtr);
|
|
collision_direction -= *normalAttributePtr;
|
|
Check(&collision_direction);
|
|
|
|
Tell(
|
|
"*state_attribute_ptr = " << *state_attribute_ptr << " : " <<
|
|
"collision_direction = " << collision_direction << "\n"
|
|
);
|
|
}
|