Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
263 lines
6.4 KiB
C++
263 lines
6.4 KiB
C++
//===========================================================================//
|
|
// File: eyecandy.cpp //
|
|
// Project: MUNGA Brick: Model Manager //
|
|
// Contents: Implementation details of moving entity class //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 01/21/95 JSE Initial coding. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <munga.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(RANDOM_HPP)
|
|
# include <random.hpp>
|
|
#endif
|
|
|
|
#if !defined(EYECANDY_HPP)
|
|
# include <eyecandy.hpp>
|
|
#endif
|
|
|
|
#if !defined(APP_HPP)
|
|
#include <app.hpp>
|
|
#endif
|
|
|
|
#if !defined(NOTATION_HPP)
|
|
#include <notation.hpp>
|
|
#endif
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
EyeCandy::SharedData
|
|
EyeCandy::DefaultData(
|
|
EyeCandy::ClassDerivations,
|
|
EyeCandy::MessageHandlers,
|
|
EyeCandy::AttributeIndex,
|
|
EyeCandy::StateCount,
|
|
(Entity::MakeHandler)EyeCandy::Make
|
|
);
|
|
|
|
Derivation
|
|
EyeCandy::ClassDerivations(
|
|
Entity::ClassDerivations,
|
|
"EyeCandy"
|
|
);
|
|
|
|
//#############################################################################
|
|
//############################### EyeCandy #################################
|
|
//#############################################################################
|
|
|
|
void
|
|
EyeCandy::EyeCandySimulation(Scalar)
|
|
{
|
|
Check(application);
|
|
|
|
if (simulationState.GetState() == effectOn)
|
|
{
|
|
simulationState.SetState(effectOff);
|
|
}
|
|
|
|
Scalar now = Now();
|
|
if ((now - lastTrigger) >= waitTime)
|
|
{
|
|
simulationState.SetState(effectOn);
|
|
lastTrigger = now;
|
|
|
|
RandomGenerator random_number;
|
|
waitTime = minWaitTime + (maxWaitTime - minWaitTime) * random_number;
|
|
}
|
|
}
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
EyeCandy::EyeCandy(
|
|
EyeCandy::MakeMessage *creation_message ,
|
|
EyeCandy::SharedData &virtual_data
|
|
):
|
|
Entity(creation_message, virtual_data)
|
|
{
|
|
Check_Pointer(this);
|
|
Check_Pointer(creation_message);
|
|
SetPerformance(&EyeCandy::EyeCandySimulation);
|
|
SetValidFlag();
|
|
|
|
//
|
|
//-------------------------------------------------
|
|
// Find the EyeCandy in the resource
|
|
//-------------------------------------------------
|
|
//
|
|
ResourceFile *res_file = application->GetResourceFile();
|
|
Check(res_file);
|
|
ResourceDescription *res =
|
|
res_file->SearchList(
|
|
resourceID,
|
|
ResourceDescription::GameModelResourceType
|
|
);
|
|
Check(res);
|
|
res->Lock();
|
|
|
|
ModelResource *eyecandy_res = (ModelResource*)res->resourceAddress;
|
|
maxWaitTime = eyecandy_res->maxWaitTime;
|
|
minWaitTime = eyecandy_res->minWaitTime;
|
|
res->Unlock();
|
|
|
|
waitTime = minWaitTime + (maxWaitTime - minWaitTime) * Random;
|
|
|
|
simulationState.SetState(effectOff);
|
|
lastTrigger = Now();
|
|
|
|
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
EyeCandy*
|
|
EyeCandy::Make(EyeCandy::MakeMessage *creation_message)
|
|
{
|
|
return new EyeCandy(creation_message);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
EyeCandy::CreateMakeMessage(
|
|
MakeMessage *creation_message,
|
|
NotationFile *model_file,
|
|
const ResourceDirectories *directories
|
|
)
|
|
{
|
|
Check(creation_message);
|
|
Check(model_file);
|
|
|
|
if (!Entity::CreateMakeMessage(creation_message, model_file, directories))
|
|
{
|
|
return False;
|
|
}
|
|
|
|
creation_message->classToCreate = RegisteredClass::EyeCandyClassID;
|
|
creation_message->instanceFlags = HermitInstance|DynamicFlag|TrappedFlag;
|
|
return True;
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
EyeCandy::~EyeCandy()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
|
|
ResourceDescription::ResourceID
|
|
EyeCandy::CreateModelResource(
|
|
#if DEBUG_LEVEL>0
|
|
ResourceFile *resource_file,
|
|
const char* model_name,
|
|
NotationFile * model_file,
|
|
const ResourceDirectories *directories,
|
|
ModelResource *model
|
|
#else
|
|
ResourceFile *resource_file,
|
|
const char* model_name,
|
|
NotationFile * model_file,
|
|
const ResourceDirectories *,
|
|
ModelResource *model
|
|
#endif
|
|
)
|
|
{
|
|
Check(resource_file);
|
|
Check_Pointer(model_name);
|
|
Check_Pointer(directories);
|
|
|
|
//
|
|
// If we were not provided a buffer to write the model data into, we must
|
|
// create it ourselves. Then make sure that the model stuff is read in
|
|
//
|
|
ModelResource *local_model = model;
|
|
if (!local_model)
|
|
{
|
|
local_model = new ModelResource;
|
|
Register_Pointer(local_model);
|
|
}
|
|
|
|
//----------------------------------------
|
|
// Read in the data from notation file
|
|
//----------------------------------------
|
|
//
|
|
// Get PointValue assigned to this ScoreZone
|
|
//
|
|
|
|
if(
|
|
!model_file->GetEntry(
|
|
"gamedata",
|
|
"MaxWaitTime",
|
|
&local_model->maxWaitTime
|
|
)
|
|
)
|
|
{
|
|
cerr << model_name << "Missing MaxWaitTime" << endl;
|
|
Dump_And_Die:
|
|
if (!model)
|
|
{
|
|
Unregister_Pointer(local_model);
|
|
delete local_model;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
if(
|
|
!model_file->GetEntry(
|
|
"gamedata",
|
|
"MinWaitTime",
|
|
&local_model->minWaitTime
|
|
)
|
|
)
|
|
{
|
|
cerr << model_name << "Missing MinWaitTime" << endl;
|
|
goto Dump_And_Die;
|
|
}
|
|
|
|
//
|
|
//---------------------------
|
|
// Write out the new resource
|
|
//---------------------------
|
|
//
|
|
if (!model)
|
|
{
|
|
ResourceDescription *new_res =
|
|
resource_file->AddResource(
|
|
model_name,
|
|
ResourceDescription::GameModelResourceType,
|
|
1,
|
|
ResourceDescription::Preload,
|
|
local_model,
|
|
sizeof(*local_model)
|
|
);
|
|
Unregister_Pointer(local_model);
|
|
delete local_model;
|
|
Check(new_res);
|
|
return new_res->resourceID;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
Logical
|
|
EyeCandy::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|