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>
256 lines
7.0 KiB
Plaintext
256 lines
7.0 KiB
Plaintext
//===========================================================================//
|
|
// File: entity.tst //
|
|
// Project: MUNGA Brick: Entity Manager //
|
|
// Contents: Implementation details of the entity class //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 12/28/94 JMA Initial coding. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include "entity.thp"
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
Derivation
|
|
TestEntity::ClassDerivations(Entity::ClassDerivations,"TestEntity");
|
|
|
|
TestEntity::SharedData
|
|
TestEntity::DefaultData(
|
|
TestEntity::ClassDerivations,
|
|
TestEntity::MessageHandlers,
|
|
TestEntity::AttributeIndex,
|
|
1,
|
|
(Entity::MakeHandler)TestEntity::Make
|
|
);
|
|
|
|
//#############################################################################
|
|
// Message Support
|
|
//
|
|
const Receiver::HandlerEntry
|
|
TestEntity::MessageHandlerEntries[]=
|
|
{
|
|
{
|
|
TestEntity::TestMessageID,
|
|
"Test",
|
|
(TestEntity::Handler)&TestEntity::TestMessageHandler
|
|
}
|
|
};
|
|
|
|
TestEntity::MessageHandlerSet
|
|
TestEntity::MessageHandlers(
|
|
ELEMENTS(TestEntity::MessageHandlerEntries),
|
|
TestEntity::MessageHandlerEntries,
|
|
Entity::MessageHandlers
|
|
);
|
|
|
|
void
|
|
TestEntity::TestMessageHandler(TestEntity::Message *)
|
|
{
|
|
localOrigin = Point3D(2.0,2.0,2.0);
|
|
};
|
|
|
|
void
|
|
TestEntity::Tester()
|
|
{
|
|
TestEntity::Message message(
|
|
TestEntity::TestMessageID,
|
|
sizeof(TestEntity::Message)
|
|
);
|
|
Dispatch(&message);
|
|
}
|
|
|
|
//#############################################################################
|
|
// Attribute Support
|
|
//
|
|
const TestEntity::IndexEntry
|
|
TestEntity::AttributePointers[]=
|
|
{
|
|
{
|
|
TestEntity::VelocityVectorAttributeID,
|
|
"VelocityVector",
|
|
(Entity::AttributePointer)&TestEntity::velocityVector
|
|
}
|
|
};
|
|
|
|
TestEntity::AttributeIndexSet
|
|
TestEntity::AttributeIndex(
|
|
ELEMENTS(TestEntity::AttributePointers),
|
|
TestEntity::AttributePointers,
|
|
Entity::AttributeIndex
|
|
);
|
|
|
|
//#############################################################################
|
|
// Model Support
|
|
//
|
|
void
|
|
TestEntity::Model(
|
|
Scalar time_slice,
|
|
MemoryStream &update_stream
|
|
)
|
|
{
|
|
Vector3D diff;
|
|
diff.Multiply(velocityVector,time_slice);
|
|
localOrigin.linearPosition += diff;
|
|
localToWorld = localOrigin.linearPosition;
|
|
if (diff.LengthSquared() >= 0.009f)
|
|
{
|
|
UpdateRecord* update = (UpdateRecord*)update_stream.GetPointer();
|
|
WriteUpdateRecord(update, 0);
|
|
update_stream.AdvancePointer(update->recordLength);
|
|
}
|
|
}
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
TestEntity::TestEntity(
|
|
TestEntity::MakeMessage *creation_message,
|
|
TestEntity::SharedData &virtual_data
|
|
):
|
|
Entity(creation_message,virtual_data)
|
|
{
|
|
SetValidFlag();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
TestEntity*
|
|
TestEntity::Make(TestEntity::MakeMessage *creation_message)
|
|
{
|
|
return new TestEntity(creation_message);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
TestEntity::~TestEntity()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
Entity::TestClass()
|
|
{
|
|
DEBUG_STREAM << "Starting Entity test...\n";
|
|
|
|
//
|
|
//------------------
|
|
// Test construction
|
|
//------------------
|
|
//
|
|
TestEntity::MakeMessage
|
|
message1(
|
|
TestEntity::MakeMessageID,
|
|
sizeof(TestEntity::MakeMessage),
|
|
TestEntity::TrivialEntityClassID,
|
|
EntityID::Null,
|
|
0,
|
|
TestEntity::DefaultFlags,
|
|
Origin::Identity
|
|
);
|
|
TestEntity *test_entity = TestEntity::Make(&message1);
|
|
Register_Object(test_entity);
|
|
|
|
//
|
|
//---------------
|
|
// Test messaging
|
|
//---------------
|
|
//
|
|
test_entity->Tester();
|
|
Test(test_entity->localOrigin.linearPosition == Point3D(2.0f,2.0f,2.0f));
|
|
|
|
//
|
|
//------------------------------------------------------------
|
|
// Try posting a message through the application to the object
|
|
//------------------------------------------------------------
|
|
//
|
|
application->ProcessAllEvents();
|
|
test_entity->localOrigin.linearPosition.x = 3.0f;
|
|
TestEntity::Message message2(
|
|
TestEntity::TestMessageID,
|
|
sizeof(TestEntity::Message)
|
|
);
|
|
application->Post(0, test_entity, &message2);
|
|
application->ProcessOneEvent();
|
|
Test(test_entity->localOrigin.linearPosition == Point3D(2.0f,2.0f,2.0f));
|
|
|
|
//
|
|
//------------------------------------------------
|
|
// Try sending a timed event through to the object
|
|
//------------------------------------------------
|
|
//
|
|
test_entity->localOrigin.linearPosition.x = 3.0f;
|
|
Time t = Now();
|
|
t += 0.5f;
|
|
application->Post(0, test_entity, &message2, t);
|
|
Time t2 = t;
|
|
t2 += 0.1f;
|
|
while (!application->ProcessOneEvent())
|
|
{
|
|
Test(Now() < t2);
|
|
}
|
|
Scalar f = Now() - t;
|
|
Test(test_entity->localOrigin.linearPosition == Point3D(2.0f,2.0f,2.0f));
|
|
Test(Abs(f) < 0.06f);
|
|
|
|
//
|
|
//------------------------
|
|
// Test attribute pointers
|
|
//------------------------
|
|
//
|
|
test_entity->localOrigin = Point3D(1.0f,1.0f,1.0f);
|
|
Origin *origin =
|
|
(Origin*)test_entity->GetAttributePointer(LocalOriginAttributeID);
|
|
Test(origin->linearPosition == Point3D(1.0f,1.0f,1.0f));
|
|
|
|
test_entity->velocityVector = Vector3D(0.0f,0.0f,1.0f);
|
|
Vector3D *velocity =
|
|
(Vector3D*)test_entity->
|
|
GetAttributePointer(TestEntity::VelocityVectorAttributeID);
|
|
Test(*velocity == Vector3D(0.0f,0.0f,1.0f));
|
|
|
|
//
|
|
//---------------------
|
|
// Test Model execution
|
|
//---------------------
|
|
//
|
|
test_entity->Perform(0.1f);
|
|
Test(origin->linearPosition == Point3D(1.0f,1.0f,1.0f));
|
|
test_entity->SetPerformance(&TestEntity::Model);
|
|
test_entity->Perform(0.05f);
|
|
Test(origin->linearPosition == Point3D(1.0f,1.0f,1.05f));
|
|
|
|
//
|
|
//-------------------------------
|
|
// Test Update message generation
|
|
//-------------------------------
|
|
//
|
|
t = test_entity->creationTime;
|
|
t += 0.1f;
|
|
UpdateMessage *update = test_entity->Execute(t);
|
|
Test(update);
|
|
// Test(update->localOrigin.linearPosition == Point3D(1.0f,1.0f,1.15f));
|
|
// Unregister_Object(update);
|
|
// delete update;
|
|
|
|
//
|
|
//-----------------
|
|
// Test destruction
|
|
//-----------------
|
|
//
|
|
Unregister_Object(test_entity);
|
|
delete test_entity;
|
|
|
|
return True;
|
|
}
|
|
|