Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)

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>
This commit is contained in:
Cyd
2026-07-02 13:21:58 -05:00
co-authored by Claude Fable 5
commit fdd9ac9d97
8682 changed files with 419927 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
//===========================================================================//
// File: affnmtrx.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the Affine matrices //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/20/94 JMA Initial coding. //
// 12/01/94 JMA Made compatible with SGI CC //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
//###########################################################################
//###########################################################################
//
Logical
AffineMatrix::TestClass()
{
DEBUG_STREAM << "Starting AffineMatrix Test...\n";
Tell(" AffineMatrix::TestClass() stubbed out!\n");
return False;
}
+170
View File
@@ -0,0 +1,170 @@
//===========================================================================//
// File: angle.tst //
// Project: MUNGA Brick: Math Library //
// Contents: Tests for angle classes //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
//#############################################################################
//#############################################################################
//
Logical
Radian::TestClass()
{
DEBUG_STREAM << "Starting Radian Test...\n";
const Radian a(1.25f);
Radian
b,c;
Test(a);
c = 0.0f;
Test(!c);
Test(Normalize(3.1f) == 3.1f);
Test(Normalize(-3.1f) == -3.1f);
Scalar f = Normalize(PI+PI_OVER_2);
Test(Close_Enough(f,PI_OVER_2 - PI));
f = Normalize(-PI-PI_OVER_2);
Test(Close_Enough(f,PI - PI_OVER_2));
c = a;
Test(c == a);
Test(c.angle == a);
Test(c == a.angle);
b.Negate(c);
Test(b == -c.angle);
#if 0
b = -c;
d.Add(b,c);
Test(d == b.angle + c.angle);
Test(a+b == a.angle + b.angle);
Test(a+c == a.angle + c.angle);
Test(a+1.25f == a.angle+1.25f);
Test(1.25f+c == 1.25f+c.angle);
c = 1.5f;
d.Subtract(c,a);
Test(d == c.angle - a.angle);
Test(c-a == c.angle - a.angle);
Test(c-1.25f == c.angle - 1.25f);
Test(1.5f-a == 1.5f - a.angle);
Test(c-b == c.angle - b.angle);
c = 2.5f;
d.Multiply(a,c);
Test(d == a.angle * c.angle);
Test(a*c == a.angle * c.angle);
Test(1.25f*c == 1.25f * c.angle);
Test(a*2.5f == a.angle * 2.5f);
Test(a*b == a.angle * b.angle);
c = 2.0f;
d.Divide(a,c);
Test(d == a.angle / c.angle);
Test(a/c == a.angle / c.angle);
Test(1.25f/c == 1.25f / c.angle);
Test(a/2.0f == a.angle / 2.0f);
Test(a/b == a.angle / b.angle);
b = a;
b += c;
b.Normalize();
Test(b == 3.25f - TWO_PI);
b += 2.0f;
b.Normalize();
Test(b == 5.25f - TWO_PI);
b -= c;
b.Normalize();
Test(b == 3.25f - TWO_PI);
b -= 2.0f;
b.Normalize();
Test(b == 1.25f);
b *= c;
b.Normalize();
Test(b == 1.25f*2.0f);
b *= 2.0f;
b.Normalize();
Test(b == 1.25f*2.0f*2.0f - TWO_PI);
b = a*c;
b.Normalize();
Test(b == 1.25f*2.0f);
b /= 2.0f;
b.Normalize();
Test(b == 1.25f);
b = -3.0f*PI_OVER_4;
c = 3.0f*PI_OVER_4;
Test(Lerp(b,c,0.25f) < b);
Test(Normalize(Lerp(b,c,0.75f)) > c);
#endif
return True;
}
//
//#############################################################################
//#############################################################################
//
Logical
Degree::TestClass()
{
DEBUG_STREAM << "Starting Degree test...\n";
const Degree a(DEG_PER_RAD);
Degree
b,c;
Radian
r(1.0f),s;
s = a;
Test(r == s);
b = r;
s = b;
Test(r == s);
c = DEG_PER_RAD;
s = c;
Test(r == s);
b = c;
s = b;
Test(r == s);
return True;
}
//
//#############################################################################
//#############################################################################
//
Logical
SinCosPair::TestClass()
{
DEBUG_STREAM << "Starting SinCos test...\n";
Radian
s,r(PI_OVER_2);
SinCosPair a;
a = r;
Test(Close_Enough(a.sine,1.0f));
Test(Small_Enough(a.cosine));
s = a;
Test(s == r);
return True;
}
+45
View File
@@ -0,0 +1,45 @@
//===========================================================================//
// File: tstapp.hh //
// Project: MUNGA Brick: Application //
// Contents: Interface specification for Application //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/06/95 ECH Added event utilities. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(APP_THP)
# define APP_THP
# if !defined(APP_HPP)
# include "app.hpp"
# endif
# if !defined(RENDERER_THP)
# include "renderer.thp"
# endif
# if !defined(VIDREND_HPP)
# include "vidrend.hpp"
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TestApplication ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class TestApplication:
public Application
{
public:
TestApplication(ResourceFile *resource_file);
~TestApplication();
void
Initialize();
void
Terminate();
};
#endif
+33
View File
@@ -0,0 +1,33 @@
#if !defined(APPMGR_HPP)
# define APPMGR_HPP
# if !defined(APP_HPP)
# include <app.hpp>
# endif
class ApplicationManager:
public Node
{
public:
ApplicationManager(Scalar frame_rate);
~ApplicationManager();
void
StartApplication(Application *new_app);
void
RunMissions();
Scalar
GetFrameRate()
{Check(this); return frameRate;}
protected:
Scalar
frameDuration,
frameRate;
SChainOf<Application*>
runningApplications;
};
#endif
+87
View File
@@ -0,0 +1,87 @@
//===========================================================================//
// File: audtime.cpp //
// Project: MUNGA Brick: Audio Renderer //
// Contents: Interface declarations for AudioTim //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 05/08/96 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(AUDIO_HPP)
#include <audio.hpp>
#endif
#if !defined(AUDTIME_HPP)
#include <audtime.hpp>
#endif
#if !defined(APP_HPP)
#include <app.hpp>
#endif
#if !defined(AUDREND_HPP)
#include <audrend.hpp>
#endif
//#############################################################################
//############################# AudioTime ###############################
//#############################################################################
const AudioTime
AudioTime::Null;
//
//#############################################################################
//#############################################################################
//
Logical
AudioTime::TestInstance() const
{
return True;
}
//
//#############################################################################
//#############################################################################
//
AudioTime
AudioTime::Now()
{
Check(application);
Check(application->GetAudioRenderer());
return AudioTime(application->GetAudioRenderer()->GetAudioFrameCount());
}
//
//#############################################################################
//#############################################################################
//
AudioFrameCount
AudioTime::Seconds_To_Frames(Scalar seconds) const
{
Check(application);
Check(application->GetAudioRenderer());
return
(seconds * application->GetAudioRenderer()->GetCalibrationRate() + 0.5f);
}
//
//#############################################################################
//#############################################################################
//
Scalar
AudioTime::Frames_To_Seconds(AudioFrameCount frames) const
{
Check(application);
Check(application->GetAudioRenderer());
return
((Scalar)frames / application->GetAudioRenderer()->GetCalibrationRate());
}
+51
View File
@@ -0,0 +1,51 @@
//===========================================================================//
// File: audtools.hpp //
// Project: MUNGA Brick: Audio Renderer Manager //
// Contents: //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 05/10/95 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(AUDTOOLS_HPP)
# define AUDTOOLS_HPP
# if !defined(STYLE_HPP)
# include <style.hpp>
# endif
# if !defined(CSTR_HPP)
# include <cstr.hpp>
# endif
//##########################################################################
//##################### AudioCreateSymbols ###########################
//##########################################################################
class AudioCreateSymbols
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction, Destruction and testing
//
public:
AudioCreateSymbols();
~AudioCreateSymbols();
void Execute();
private:
static void
MakeFileReadWrite(const CString &file_name);
protected:
virtual void
WriteEntryStream(ofstream &symbol_file);
};
#endif
+38
View File
@@ -0,0 +1,38 @@
//===========================================================================//
// File: audwgt.cpp //
// Project: MUNGA Brick: Audio Renderer //
// Contents: Implementation for audio weighting //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 05/02/96 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1996, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(AUDWGT_HPP)
# include <audwgt.hpp>
#endif
//#############################################################################
//########################## AudioWeighting #############################
//#############################################################################
const AudioWeighting
AudioWeighting::Null;
//
//#############################################################################
//#############################################################################
//
Logical
AudioWeighting::TestInstance() const
{
return True;
}
+21
View File
@@ -0,0 +1,21 @@
//===========================================================================//
// File: average.cpp //
// Project: MUNGA Brick: Renderer //
// Contents: //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- -----------------------------------------------------------//
// 12/14/94 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(AVERAGE_HPP)
# include <average.hpp>
#endif
+177
View File
@@ -0,0 +1,177 @@
//===========================================================================//
// File: bndgbox.hh //
// Project: MUNGA Brick: Spatializer Library //
// Contents: Interface specification of bounding-box based spatialization //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/08/95 JMA Initial port back to C++ //
//---------------------------------------------------------------------------//
// Copyright (C) 1993-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(BOXLIST_HPP)
# define BOXLIST_HPP
# if !defined(BNDGBOX_HPP)
# include <bndgbox.hpp>
# endif
# if !defined(MEMBLOCK_HPP)
# include <memblock.hpp>
# endif
# if !defined(POINT3D_HPP)
# include <point3d.hpp>
# endif
//##########################################################################
//####################### BoundingBoxListNode ########################
//##########################################################################
class BoundingBoxList;
class BoxedSolidList;
class BoundingBoxTree;
class BoundingBoxListNode SIGNATURED
{
friend class BoundingBoxList;
friend class BoxedSolidList;
//##########################################################################
// Memory Allocation
//
private:
static MemoryBlock
AllocatedMemory;
void*
operator new(size_t)
{return AllocatedMemory.New();}
void
operator delete(void *where)
{AllocatedMemory.Delete(where);}
//##########################################################################
// Construction and Destruction
//
protected:
BoundingBox
*boundingBox;
BoundingBoxListNode
*previousNode;
BoundingBoxListNode(
BoundingBox *volume,
const ExtentBox &slice
):
boundingBox(volume),
solidSlice(slice),
previousNode(NULL)
{Check_Pointer(this); Check(volume);}
~BoundingBoxListNode()
{Check(this);}
public:
ExtentBox
solidSlice;
BoundingBox*
GetBoundingBox()
{Check(this); return boundingBox;}
BoundingBoxListNode*
GetNextNode()
{Check(this); return previousNode;}
//##########################################################################
// Test Support
//
public:
Logical
TestInstance() const;
};
//##########################################################################
//######################## BoundingBoxList ###########################
//##########################################################################
class BoundingBoxList SIGNATURED
{
//##########################################################################
// Construction and Destruction
//
protected:
BoundingBoxListNode
*root;
int
nodeCount;
int*
scoreBoard;
BoundingBox
**boundingBoxIndex;
Logical
isXMajorAxis;
public:
BoundingBoxList();
~BoundingBoxList();
void
Add(
BoundingBox* volume,
const ExtentBox &slice
);
void
Remove(BoundingBox* volume);
void
EraseList();
BoundingBoxListNode*
GetRoot()
{Check(this); return root;}
//##########################################################################
// Tree Traversal Functions
//
public:
BoundingBox*
FindBoundingBoxContaining(const Point3D &point);
void
FindBoundingBoxesContaining(
BoundingBox *volume,
BoundingBoxCollisionList &list
);
BoundingBox*
FindBoundingBoxUnder(
const Point3D &point,
Scalar *height
);
BoundingBox*
FindBoundingBoxHitBy(Line *line);
void
Reduce();
void
SortForTree();
protected:
void
Sort(
BoundingBoxList &active_solids,
ExtentBox &clipping_box,
BoundingBoxTree &tree_so_far
);
//##########################################################################
// Test Support
//
public:
Logical
TestInstance() const;
};
#endif
+73
View File
@@ -0,0 +1,73 @@
//===========================================================================//
// File: cmpnnt.hh //
// Project: MUNGA Brick: Watcher //
// Contents: //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- -----------------------------------------------------------//
// 12/14/94 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(CMPNNT_HPP)
# define CMPNNT_HPP
# if !defined(RECEIVER_HPP)
# include <receiver.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Component ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Component:
public Receiver
{
public:
//
//-----------------------------------------------------------------------
// Destructor
//-----------------------------------------------------------------------
//
~Component();
//
//-----------------------------------------------------------------------
// Execute
//-----------------------------------------------------------------------
//
virtual void
Execute();
//
//-----------------------------------------------------------------------
// Shared Data Support
//-----------------------------------------------------------------------
//
static Derivation
ClassDerivations;
static SharedData
DefaultData;
Logical
TestInstance() const;
protected:
//
//-----------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------
//
Component(
ClassID class_id = TrivialComponentClassID,
SharedData &shared_data = DefaultData
);
Component(
PlugStream *stream,
SharedData &shared_data = DefaultData
);
};
#endif
+106
View File
@@ -0,0 +1,106 @@
//===========================================================================//
// File: Color.cpp //
// Project: MUNGA Brick: Utility Library //
// Contents: Implementation details for color classes //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/12/95 GDU Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(COLOR_HPP)
# include <color.hpp>
#endif
#if !defined(CSTR_HPP)
#include <cstr.hpp>
#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~ RGBColor functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if defined(USE_SIGNATURE)
int
Is_Signature_Bad(const volatile RGBColor *)
{
return False;
}
#endif
//
//###########################################################################
//###########################################################################
//
void
Convert_From_Ascii(
const char *str,
RGBColor *color
)
{
Check_Pointer(str);
Check_Signature(color);
CString parse_string(str);
Check_Pointer(parse_string.GetNthToken(0));
color->Red = atof(parse_string.GetNthToken(0));
Check_Pointer(parse_string.GetNthToken(1));
color->Green = atof(parse_string.GetNthToken(1));
Check_Pointer(parse_string.GetNthToken(2));
color->Blue = atof(parse_string.GetNthToken(2));
Check(color);
}
//
//###########################################################################
//###########################################################################
//
Logical
RGBColor::TestInstance() const
{
return True;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~ RGBAColor functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###########################################################################
//###########################################################################
//
void
Convert_From_Ascii(
const char *str,
RGBAColor *color
)
{
Check_Pointer(str);
Check_Signature(color);
CString parse_string(str);
Check_Pointer(parse_string.GetNthToken(0));
color->Red = atof(parse_string.GetNthToken(0));
Check_Pointer(parse_string.GetNthToken(1));
color->Green = atof(parse_string.GetNthToken(1));
Check_Pointer(parse_string.GetNthToken(2));
color->Blue = atof(parse_string.GetNthToken(2));
Check_Pointer(parse_string.GetNthToken(3));
color->Alpha = atof(parse_string.GetNthToken(3));
Check(color);
}
+190
View File
@@ -0,0 +1,190 @@
//===========================================================================//
// File: color.hh //
// Title: Declaration of Color classes. //
// Project: Tool Architecture II //
// Author: Jerry Edsall & Ken Olsen (based on work by J.M. Albertson) //
// Purpose: Stores color information. //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 12/15/94 KEO Added RGBAColor class. //
// 11/12/95 GDU Added MUNGA signatures and stream IO, moved to MUNGA //
//---------------------------------------------------------------------------//
// Copyright (c) 1994 Virtual World Entertainment, Inc. //
// All rights reserved worldwide. //
// This unpublished source code is PROPRIETARY and CONFIDENTIAL. //
//===========================================================================//
#if !defined(COLOR_HPP)
#define COLOR_HPP
#if !defined(MEMSTRM_HPP)
#include <memstrm.hpp>
#endif
#if !defined(SCALAR_HPP)
#include <scalar.hpp>
#endif
//##########################################################################
//############## RGBColor ############################################
//##########################################################################
class RGBColor
{
friend class RGBAColor;
public:
Scalar
Red,
Green,
Blue;
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile RGBColor *p);
#endif
RGBColor()
{
Red = Green = Blue = -1.0f;
}
RGBColor(
Scalar r,
Scalar g,
Scalar b
)
{
Red = r;
Green = g;
Blue = b;
}
Logical
operator==(const RGBColor &a_RGBColor) const
{ return !memcmp(this, &a_RGBColor, sizeof(RGBColor)); }
Logical
operator!=(const RGBColor &a_RGBColor) const
{ return memcmp(this, &a_RGBColor, sizeof(RGBColor)); }
Logical
TestInstance() const;
RGBColor
operator+(const RGBColor &a_RGBColor) const
{
return RGBColor (
min(this->Red + a_RGBColor.Red, 1.0),
min(this->Green + a_RGBColor.Green, 1.0),
min(this->Blue + a_RGBColor.Blue, 1.0));
}
Scalar
Infrared() const
{ return 0.3 * this->Red + 0.5 * this->Green + 0.2 * this->Blue; }
//
// Support functions
//
friend ostream&
operator<<(
ostream& stream,
const RGBColor& C
);
private:
Scalar
min(Scalar x, Scalar y) const
{ return x < y ? x : y; }
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~ RGBColor functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void
Convert_From_Ascii(
const char *str,
RGBColor *color
);
inline MemoryStream&
MemoryStream_Read(
MemoryStream* stream,
RGBColor *output
)
{return stream->ReadBytes(output, sizeof(*output));}
inline MemoryStream&
MemoryStream_Write(
MemoryStream* stream,
const RGBColor *input
)
{return stream->WriteBytes(input, sizeof(*input));}
//##########################################################################
//############## RGBAColor ###########################################
//##########################################################################
class RGBAColor:
public RGBColor
{
public:
Scalar
Alpha;
RGBAColor():
RGBColor()
{ Alpha = -1.0f; }
RGBAColor(
Scalar r,
Scalar g,
Scalar b,
Scalar a
):
RGBColor(r, g, b)
{ Alpha = a; }
Logical
operator==(const RGBAColor &a_RGBAColor) const
{ return !memcmp(this, &a_RGBAColor, sizeof(RGBAColor)); }
Logical
operator!=(const RGBAColor &a_RGBAColor) const
{ return memcmp(this, &a_RGBAColor, sizeof(RGBAColor)); }
//
// Support functions
//
friend ostream&
operator<<(
ostream& stream,
const RGBAColor& c
);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~ RGBAColor functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void
Convert_From_Ascii(
const char *str,
RGBAColor *color
);
inline MemoryStream&
MemoryStream_Read(
MemoryStream* stream,
RGBAColor *output
)
{return stream->ReadBytes(output, sizeof(*output));}
inline MemoryStream&
MemoryStream_Write(
MemoryStream* stream,
const RGBAColor *input
)
{return stream->WriteBytes(input, sizeof(*input));}
#endif
//=============================================================================
+79
View File
@@ -0,0 +1,79 @@
#define TEST_STRING "Test String"
#define TEST_STRING_2 "Test StringTest String"
#define TEST_STRING_3 "Test StringZ"
Logical
CString::TestClass()
{
#if 1
CString string_a;
//Verify(string_a.stringSize == 0);
//Verify(string_a.stringLength == 0);
//Verify(string_a.stringText == NULL);
CString string_b(TEST_STRING);
CString string_c(string_b);
Verify(string_b.Length() == strlen(TEST_STRING));
Verify(string_b.Length() == strlen(string_c));
Verify(string_b == string_c);
CString string_d(TEST_STRING_2);
CString string_e;
string_e = string_b + string_c;
Verify(string_e == string_d);
CString string_f(TEST_STRING_3);
CString string_g;
string_g = string_b + 'Z';
Verify(string_g == string_f);
CString string_h(TEST_STRING);
string_h += string_b;
Verify(string_h == string_d);
CString string_i(TEST_STRING);
string_i += 'Z';
Verify(string_i == string_f);
CString string_j("aaa");
CString string_k("aab");
CString string_l("abb");
CString string_m("bbb");
CString string_n("aaa");
Verify(string_j < string_k);
Verify(string_l > string_k);
Verify(string_l <= string_m);
Verify(string_m >= string_j);
Verify(string_j == string_n);
Verify(string_j != string_k);
Verify(string_k[0] == 'a');
Verify(string_k[1] == 'a');
Verify(string_k[2] == 'b');
CString string_o("0.1,0.2,0.3");
CString string_p("0.1 0.2 0.3");
CString string_q("0.1");
CString string_r("0.2");
CString string_s("0.3");
Verify(string_o.GetNthToken(0) == string_q);
Verify(string_o.GetNthToken(1) == string_r);
Verify(string_o.GetNthToken(2) == string_s);
Verify(string_p.GetNthToken(0) == string_q);
Verify(string_p.GetNthToken(1) == string_r);
Verify(string_p.GetNthToken(2) == string_s);
#endif
return True;
}
+72
View File
@@ -0,0 +1,72 @@
//=======================================================================//
// File: debugoff.hpp //
// Project: Architecture //
// Author: J.M. Albertson //
// 4-12-95 CPB added Str_Cat macro //
//-----------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainments, All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#if !defined(OLD_DEBUG_LEVEL)
# define OLD_DEBUG_LEVEL 0
#else
# undef OLD_DEBUG_LEVEL
# if DEBUG_LEVEL>=3
# define OLD_DEBUG_LEVEL 3
# elif DEBUG_LEVEL==2
# define OLD_DEBUG_LEVEL 2
# elif DEBUG_LEVEL==1
# define OLD_DEBUG_LEVEL 1
# endif
#endif
#undef DEBUG_LEVEL
#undef Verify
#undef Verify_And_Dump
#undef Warn
#undef Warn_And_Dump
#undef Dump
#undef Tell
#undef Check_Signature
#undef Check_Pointer
#undef Mem_Copy
#undef Str_Copy
#undef Str_Cat
#undef Check
#undef Check_Fpu
#undef Fail
#undef Cast_Object
#undef DEBUG_CODE
#undef Sqrt
#undef Arctan
#undef Arccos
#undef Arcsin
#define DEBUG_LEVEL 0
#define DEBUG_CODE(x)
#define Verify(c)
#define Verify_And_Dump(c,v)
#define Warn(c)
#define Warn_And_Dump(c,v)
#define Dump(v)
#define Tell(m)
#define Check_Pointer(p)
#define Check_Fpu()
#define Mem_Copy(destination, source, length, available)\
memcpy(destination, source, length)
#define Str_Copy(destination, source, available)\
strcpy(destination, source);
#define Str_Cat(destination, source, available)\
strcat(destination, source);
#define Sqrt(value) sqrt(value)
#define Arctan(y,x) atan2(y,x)
#define Arccos(x) acos(x)
#define Arcsin(x) asin(x)
#define Power(x,y) pow(x,y)
#define Check(p)
#define Check_Signature(p)
#define Fail(m) Fail_To_Debugger(m,__FILE__,__LINE__)
#define Cast_Object(type, ptr) ((type)(ptr))
+24
View File
@@ -0,0 +1,24 @@
//=======================================================================//
// File: debug2on.hpp //
// Project: Architecture //
// Author: J.M. Albertson //
// 4-12-95 CPB added Str_Cat macro //
//-----------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainments, All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#if !defined(OLD_DEBUG_LEVEL)
# error Cannot revert to old debug level!
#else
# if OLD_DEBUG_LEVEL>=3
# include <debug3on.hpp>
# elif OLD_DEBUG_LEVEL==2
# include <debug2on.hpp>
# elif OLD_DEBUG_LEVEL==1
# include <debug1on.hpp>
# else
# include <debugoff.hpp>
# endif
#endif
+168
View File
@@ -0,0 +1,168 @@
//===========================================================================//
// File: evtstat.cpp //
// Project: MUNGA Brick: Event Manager //
// Contents: interface specification of event manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 05/15/96 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(EVTSTAT_HPP)
# include <evtstat.hpp>
#endif
#if !defined(APP_HPP)
# include <app.hpp>
#endif
#if !defined(REGISTRY_HPP)
# include <registry.hpp>
#endif
#if !defined(ENTITY_HPP)
# include <entity.hpp>
#endif
//#############################################################################
//########################## EventStatistics ############################
//#############################################################################
//
//#############################################################################
//#############################################################################
//
EventStatistics::EventStatistics(
ClassID class_ID,
Receiver::MessageID message_ID
):
classID(class_ID),
messageID(message_ID),
eventCount(0)
{
}
//#############################################################################
//######################## EventStatisticsManager #######################
//#############################################################################
EventStatisticsManager
event_statistics_manager;
//
//#############################################################################
//#############################################################################
//
EventStatisticsManager::EventStatisticsManager():
eventStatisticsSocket(NULL, True)
{
printedReport = False;
}
//
//#############################################################################
//#############################################################################
//
void
EventStatisticsManager::Maintain(Event *event)
{
Check(this);
Check(event);
//
// If the application is not running then it is not time to collect
// statistics yet
//
Check(application);
if (application->GetApplicationState() != Application::RunningMission)
return;
//
// Add statistics for this event
//
ClassID
class_ID;
Receiver::MessageID
message_ID;
long
index_value;
EventStatistics
*event_statistics;
message_ID = event->messageToSend->messageID;
class_ID = event->targetReceiver.GetCurrent()->GetClassID();
index_value = class_ID * 1000 + message_ID; // HACK to create unique key
if ((event_statistics = eventStatisticsSocket.Find(index_value)) == NULL)
{
event_statistics = new EventStatistics(class_ID, message_ID);
eventStatisticsSocket.AddValue(event_statistics, index_value);
}
Check(event_statistics);
event_statistics->eventCount++;
}
//
//#############################################################################
//#############################################################################
//
void
EventStatisticsManager::Report()
{
Check(this);
//
// Print Report
//
TableIteratorOf<EventStatistics*, long>
iterator(&eventStatisticsSocket);
EventStatistics
*event_statistics;
DEBUG_STREAM << "EventStatisticsManager::Report - event_count="
<< iterator.GetSize() << "\n";
while ((event_statistics = iterator.ReadAndNext()) != NULL)
{
Check(event_statistics);
Registry
*registry;
Entity::SharedData
*shared_data;
Derivation
*derivation;
Receiver::MessageHandlerSet
*handlers;
DEBUG_STREAM << "EventStatisticsManager::Report -\t";
DEBUG_STREAM << event_statistics->classID << "\t";
DEBUG_STREAM << event_statistics->messageID << "\t";
DEBUG_STREAM << event_statistics->eventCount << "\t";
Check(application);
if ((registry = application->GetRegistry()) != NULL)
{
Check(registry);
shared_data = registry->GetStaticData(event_statistics->classID);
if (shared_data != NULL)
{
Check(shared_data);
derivation = shared_data->derivedClasses;
Check(derivation);
handlers = shared_data->activeMessageHandlers;
Check(handlers);
DEBUG_STREAM << derivation->className << "::"
<< handlers->GetName(event_statistics->messageID) << "\t";
}
}
DEBUG_STREAM << "\n";
}
iterator.DeletePlugs();
}
+96
View File
@@ -0,0 +1,96 @@
//===========================================================================//
// File: evtstat.hpp //
// Project: MUNGA Brick: Event Manager //
// Contents: interface specification of event manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 05/15/96 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(EVTSTAT_HPP)
# define EVTSTAT_HPP
# if !defined(STYLE_HPP)
# include <style.hpp>
# endif
# if !defined(RECEIVER_HPP)
# include <receiver.hpp>
# endif
# if !defined(TABLE_HPP)
# include <table.hpp>
# endif
//#########################################################################
//######################## EventStatistics ##########################
//#########################################################################
class EventStatistics:
public Plug
{
friend class EventStatisticsManager;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction, Destruction
//
public:
EventStatistics::EventStatistics(
ClassID class_ID,
Receiver::MessageID message_ID
);
~EventStatistics() {}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Private Data
//
private:
ClassID
classID;
Receiver::MessageID
messageID;
long
eventCount;
};
//#########################################################################
//##################### EventStatisticsManager ######################
//#########################################################################
class EventStatisticsManager:
public Node
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction, Destruction
//
public:
EventStatisticsManager::EventStatisticsManager();
~EventStatisticsManager() {}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Statistic collection and reporting
//
public:
void
Maintain(Event *event);
void
Report();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Private Data
//
private:
TableOf<EventStatistics*, long>
eventStatisticsSocket;
Logical
printedReport;
};
extern EventStatisticsManager
event_statistics_manager;
#endif
+152
View File
@@ -0,0 +1,152 @@
#include <munga.hpp>
#pragma hdrstop
#if !defined(FILESTRM_HPP)
# include <filestrm.hpp>
#endif
//#############################################################################
//########################### FileStream ################################
//#############################################################################
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
FileStream::FileStream(
const char* file_name,
Logical writable
):
MemoryStream(NULL, 0)
{
Open(file_name, writable);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FileStream::Open(
const char* file_name,
Logical writable
)
{
readOnly = !writable;
(int)fileHandle = -1;
currentPosition = streamStart = NULL;
streamSize = 0;
if (file_name)
{
Check_Pointer(file_name);
fileHandle = OpenImplementation(file_name, readOnly);
}
if ((int) fileHandle != -1)
{
if (readOnly)
{
streamSize = SeekImplementation(fileHandle, 0, True);
SeekImplementation(fileHandle, 0);
}
else
{
streamSize = 0xFFFFFFFFU;
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FileStream::Close()
{
Check(this);
//
//---------------------------------
// If the file was opened, close it
//---------------------------------
//
if ((int) fileHandle != -1)
{
CloseImplementation(fileHandle);
}
(int)fileHandle = -1;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FileStream::SetPointer(size_t index)
{
Check(this);
Verify((int) fileHandle != -1);
currentPosition = (char*)SeekImplementation(fileHandle, index);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MemoryStream&
FileStream::AdvancePointer(size_t index)
{
Check(this);
Verify((int)fileHandle != -1);
currentPosition =
(char*)SeekImplementation(fileHandle, (size_t)currentPosition + index);
return *this;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MemoryStream&
FileStream::RewindPointer(size_t index)
{
Check(this);
Verify((int)fileHandle != -1);
currentPosition =
(char*)SeekImplementation(fileHandle, (size_t)currentPosition + index);
return *this;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MemoryStream&
FileStream::ReadBytes(
void *ptr,
size_t number_of_bytes
)
{
Check(this);
Verify((int)fileHandle != -1);
Verify(readOnly);
size_t read = ReadImplementation(fileHandle, ptr, number_of_bytes);
Verify(read == number_of_bytes);
currentPosition += read;
return *this;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MemoryStream&
FileStream::WriteBytes(
const void *ptr,
size_t number_of_bytes
)
{
Check(this);
Verify((int)fileHandle != -1);
Verify(!readOnly);
size_t written = WriteImplementation(fileHandle, ptr, number_of_bytes);
Verify(written == number_of_bytes);
currentPosition += written;
return *this;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Logical
FileStream::TestInstance() const
{
return True;
}
+121
View File
@@ -0,0 +1,121 @@
//===========================================================================//
// File: filestrm.hpp //
// Project: MUNGA Brick: Resource Manager //
// Contents: Implementation Details of resource management //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
//---------------------------------------------------------------------------//
// Copyright (C) 1996, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(FILESTRM_HPP)
# define FILESTRM_HPP
# if !defined(MEMSTRM_HPP)
# include <memstrm.hpp>
# endif
//##########################################################################
//######################## FileStream ################################
//##########################################################################
class FileStream:
public MemoryStream
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Constructors
//
public:
FileStream(
const char* file_name = NULL,
Logical writable = False
);
~FileStream()
{Close();}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Status functions
//
public:
void*
GetPointer() const
{
Fail("No implementation possible for FileStream::GetPointer()");
return NULL;
}
void
SetPointer(void *new_pointer)
{Fail("No implementation possible for FileStream::SetPointer(void*)");}
void
SetPointer(size_t index);
MemoryStream&
AdvancePointer(size_t count);
MemoryStream&
RewindPointer(size_t count);
MemoryStream&
ReadBytes(
void *ptr,
size_t number_of_bytes
);
MemoryStream&
WriteBytes(
const void *ptr,
size_t number_of_bytes
);
void
Open(
const char* file_name = NULL,
Logical writable = False
);
void
Close();
Logical
IsFileOpened()
{return ((int) fileHandle) != -1;}
Logical
TestInstance() const;
static Logical
TestClass();
protected:
void * fileHandle;
Logical readOnly;
static void*
OpenImplementation(
const char* file_name,
Logical read_only
);
static void
CloseImplementation(void * file_handle);
static size_t
SeekImplementation(
void * file_handle,
size_t where,
Logical from_end = False
);
static size_t
ReadImplementation(
void * file_handle,
void *buffer,
size_t length
);
static size_t
WriteImplementation(
void * file_handle,
const void* buffer,
size_t length
);
};
#endif
+52
View File
@@ -0,0 +1,52 @@
//===========================================================================//
// File: filestrm.tcp //
// Project: MUNGA Brick: Filestream Manager //
// Contents: Test stuff for MMIO class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 4/25/96 JTR Initial Creation //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MMIOstream ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
//#############################################################################
//
#include <time.hpp>
Logical
FileStream::TestClass()
{
char buffer[65535];
int i;
float total = 0;
Time s;
FileStream Testit;
memset(buffer,'A',65535);
DEBUG_STREAM << "Starting FileStream test...\n";
for(i=0; i < 1024; i++)
{
s = Now();
Testit.Open("mmiotest.tst",1);
Testit.WriteBytes(buffer,65535);
Testit.Close();
Testit.Open("mmiotest.tst",0);
Testit.ReadBytes(buffer,65535);
Testit.Close();
total += Now() - s;
}
for(i=0; i < 65535; i++) Verify(buffer[i] == 'A');
DEBUG_STREAM << "Opening, writing, closing, opening, reading, and closing\n 64K file 1024 times, averaging out to " << total / 1024.0f << " ticks apiece...\n";
DEBUG_STREAM << "File data checks out, as well...\n";
DEBUG_STREAM << "Leaving FileStream test...\n";
return True;
};
+78
View File
@@ -0,0 +1,78 @@
#include <munga.hpp>
#pragma hdrstop
#if !defined(FILESTRM_HPP)
# include <filestrm.hpp>
#endif
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>
//#############################################################################
//########################### FileStream ################################
//#############################################################################
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void*
FileStream::OpenImplementation(
const char *file_name,
Logical read_only
)
{
if (read_only)
{
return (void*)open(file_name, O_BINARY|O_RDONLY);
}
else
{
return (void*)
open(file_name, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY, S_IWRITE);
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FileStream::CloseImplementation(void * file_handle)
{
close((int)file_handle);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
size_t
FileStream::SeekImplementation(
void * file_handle,
size_t where,
Logical from_end
)
{
return lseek((int)file_handle, (long)where, (from_end) ? SEEK_END : SEEK_SET);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
size_t
FileStream::ReadImplementation(
void * file_handle,
void *buffer,
size_t length
)
{
return read((int)file_handle, buffer, length);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
size_t
FileStream::WriteImplementation(
void * file_handle,
const void *buffer,
size_t length
)
{
return write((int)file_handle, buffer, length);
}
+125
View File
@@ -0,0 +1,125 @@
//---------------------------------------------------------------------------
//
// Heap.h -- This file contains the definition for the Base HEAP
// Manager Class. The Base HEAP manager creates,
// manages and destroys block of memory using Win32
// virtual memory calls.
//
// Honor Bound -- FASA Interactive Technologies
//
// Copyright (c) 1995 FASA Interactive Technologies
//
//---------------------------------------------------------------------------
#if !defined(HEAP_HPP)
# define HEAP_HPP
#if !defined(STYLE_HPP)
#include <style.hpp>
#endif
# if !defined(MEMREG_HPP)
# include <memreg.hpp>
# endif
#if defined(MW3)
extern fstream debugfile;
#endif
struct HeapBlock;
struct HeapFreeBlock;
class UserHeap SIGNATURED
{
protected:
char
*bigHeap;
const char
*heapName;
HeapBlock
*heapStart,
*firstNearBlock;
size_t
heapSize,
lowestTotalHeapLeft;
size_t
allocateCount,
releaseCount;
protected:
void
Relink(HeapBlock *newBlock);
void
Unlink(HeapBlock *oldBlock);
void
Sort(HeapBlock *sortBlock);
void
MergeWithLower(HeapBlock *block);
public:
UserHeap(
const char* heap_name,
size_t mem_size
);
~UserHeap();
size_t
GetTotalHeapLeft();
size_t
GetBiggestHeapLeft();
size_t
GetLowestTotalHeapLeft()
{return lowestTotalHeapLeft;}
size_t
GetHeapUsed()
{return heapSize - GetTotalHeapLeft();}
size_t
GetMostHeapUsed()
{return heapSize - lowestTotalHeapLeft;}
Logical
TestHeap(
Logical print_it = False,
Logical skip_allocated = False,
Logical skip_free = False
);
void*
Allocate(size_t mem_size);
void
Release(void *where);
void
ReleaseAll();
Logical
TestInstance() const;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Global memory allocation
//
protected:
static LWord
HeapMark;
Logical
mainHeap;
public:
static UserHeap
MainStorage;
static size_t
GetMainHeapInitialSize();
friend void*
operator new(size_t mem_size);
friend void*
operator new(size_t mem_size, void* where);
friend void
operator delete(void *mem_block);
};
void*
Get_Caller(int levels);
#endif
+56
View File
@@ -0,0 +1,56 @@
//===========================================================================//
// File: host.tst //
// Project: MUNGA Brick: Connection Library //
// Contents: Interface specification for base Host class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 12/07/94 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
void
HostManager::TestClass()
{
DEBUG_STREAM << "Starting Host test...\n";
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
Host *local_host;
local_host = new Host(
FirstLegalHostID,
GameMachineHostType,
(NetworkAddress)1
);
Register_Object(local_host);
Check(application);
Check(application->GetHostManager());
application->GetHostManager()->AdoptLocalHost(local_host);
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
HostID localHostID;
Check(application);
localHostID = application->GetHostManager()->GetLocalHostID();
Verify(localHostID != NullHostID);
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
EntityID newEntityID;
Check(application);
newEntityID = application->GetHostManager()->MakeUniqueEntityID();
Verify(newEntityID != EntityID::Null);
}
+34
View File
@@ -0,0 +1,34 @@
//===========================================================================//
// File: network.hh //
// Project: MUNGA Brick: Network Manager //
// Contents: Interface specification for network brick //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/01/94 JMA Initial coding. //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/03/94 ECH Changed NetworkClient to inherit from Node //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(HOSTID_HPP)
# define HOSTID_HPP
# if !defined(STYLE_HPP)
# include <style.hpp>
# endif
//
//---------------------------------------------------
// Support types for host manager
//---------------------------------------------------
//
typedef Enumeration HostID;
const HostID NullHostID = 0;
const HostID MapHostID = -1;
const HostID FirstLegalHostID = 1;
#endif
+87
View File
@@ -0,0 +1,87 @@
//=======================================================================//
// File: line.cpp //
// Project: Architecture //
// Author: J.M. Albertson //
//-----------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainments, All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(LINE_HPP)
# include <line.hpp>
#endif
#if !defined(PLANE_HPP)
# include <plane.hpp>
#endif
//
//###########################################################################
//###########################################################################
//
Line&
Line::operator=(const Vector3D &vector)
{
Check_Pointer(this);
Check(&vector);
//
// Make sure length of vector is non-zero
//
length = vector.Length();
Verify(length);
//
// Normalize the vector and put it into the line
//
direction.x = vector.x/length;
direction.y = vector.y/length;
direction.z = vector.z/length;
return *this;
}
//
//###########################################################################
//###########################################################################
//
Line&
Line::operator=(const Point3D &point)
{
Check_Pointer(this);
Check(&point);
//
// Copy the point over into the line.
//
origin.x = point.x;
origin.y = point.y;
origin.z = point.z;
return *this;
}
Scalar
Line::DistanceTo(
const Plane &plane,
Scalar *product
) const
{
*product = direction * plane.normal;
if (Small_Enough(*product))
{
Check_Fpu();
return -1.0f;
}
Scalar result = -plane.DistanceTo(origin) / *product;
Check_Fpu();
return result;
}
Scalar
Line::DistanceTo(
const Sphere &,//sphere,
Scalar *//penetration
) const
{
return -1.0f; // HACK
}
+70
View File
@@ -0,0 +1,70 @@
//=======================================================================//
// File: line.hpp //
// Project: Architecture //
// Author: J.M. Albertson //
//-----------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainments, //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#if !defined(LINE_HPP)
# define LINE_HPP
# if !defined(RAY_HPP)
# include <ray.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Line3D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Line:
public Ray
{
public:
Scalar
length;
Line() {}
Line(
const Ray &ray,
Scalar length
):
Ray(ray),
length(length)
{}
Line(
const Point3D &start,
const UnitVector &direction,
Scalar length
):
Ray(start,direction),
length(length)
{}
void
FindEnd(Point3D *result)
{Check(this); Check_Pointer(result); Ray::Project(length, result);}
//
// Assignment operators
//
Line&
operator=(const Vector3D &vector);
Line&
operator=(const Point3D &point);
//
// Ray intersection functions
//
Scalar
DistanceTo(
const Plane &plane,
Scalar *product
) const;
Scalar
DistanceTo(
const Sphere &sphere,
Scalar *penetration
) const;
};
#endif
+136
View File
@@ -0,0 +1,136 @@
//===========================================================================//
// File: link.cc //
// Project: MUNGA Brick: Connection Library //
// Contents: Implementation details of base Link //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/28/94 ECH Initial coding. //
// 10/20/94 JMA Fixed style stuff. //
// 10/28/94 JMA Made compatible with SGI CC //
// 11/03/94 ECH Made compatible with BC4.0 //
// 12/12/94 ECH Changed release handling //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(LINK_HPP)
#include <link.hpp>
#endif
#if !defined(PLUG_HPP)
#include <plug.hpp>
#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
// Link
//#############################################################################
//
Link::Link(
Socket *socket,
Plug *plug
)
{
this->socket = socket;
this->plug = plug;
//
//----------------------------------------------------
// Add this new link to the plugs current set of links
//----------------------------------------------------
//
AddToPlug(plug);
}
//
//#############################################################################
// ~Link
//#############################################################################
//
Link::~Link()
{
//
//-----------------------------------------------------
// Remove this link from the plugs current set of links
//-----------------------------------------------------
//
ReleaseFromPlug();
}
//
//#############################################################################
// TestInstance
//#############################################################################
//
Logical
Link::TestInstance() const
{
Check_Signature(socket);
Check_Signature(plug);
return True;
}
//
//#############################################################################
// ReleaseFromPlug
//#############################################################################
//
void
Link::ReleaseFromPlug()
{
//
//-----------------------------------------------------
// Remove this link from the plugs current set of links
//-----------------------------------------------------
//
Check(plug);
if (plug->linkHead == this)
{
plug->linkHead = nextLink;
}
if (prevLink != NULL)
{
Check(prevLink);
prevLink->nextLink = nextLink;
}
if (nextLink != NULL)
{
Check(nextLink);
nextLink->prevLink = prevLink;
}
prevLink = nextLink = NULL;
}
//
//#############################################################################
// AddToPlug
//#############################################################################
//
void
Link::AddToPlug(Plug *plug)
{
Verify(plug);
Verify_And_Dump(!Is_Signature_Bad(plug),Is_Signature_Bad(plug));\
Verify((plug)->TestInstance());
Verify(Fpu_Ok());
Check_All_Signatures();
// Check(plug);
if ((nextLink = plug->linkHead) != NULL)
{
Check(nextLink);
nextLink->prevLink = this;
}
this->prevLink = NULL;
plug->linkHead = this;
}
+23
View File
@@ -0,0 +1,23 @@
//===========================================================================//
// File: linmtrx.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the linear matrices //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/20/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include "random.hpp"
//
//###########################################################################
//###########################################################################
//
Logical LinearMatrix::TestClass()
{
return False;
}
+22
View File
@@ -0,0 +1,22 @@
//===========================================================================//
// File: matrix.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the matrix class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/21/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
Logical
Matrix4x4::TestClass()
{
DEBUG_STREAM << "Starting Matrix4x4 test...\n";
Tell(" Matrix4x4::TestClass() is stubbed out!\n");
return False;
}
+43
View File
@@ -0,0 +1,43 @@
//===========================================================================//
// File: memblock.tst //
// Project: MUNGA Brick: Memory Manager //
// Contents: Test functions for memoryblock classes //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 10/23/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryBlock ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
//#############################################################################
//
Logical
MemoryBlock::TestClass()
{
DEBUG_STREAM << "Starting MemoryBlock test...\n";
Tell(" MemoryBlock::TestClass() is stubbed out!\n");
return False;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryStack ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###########################################################################
//###########################################################################
//
Logical
MemoryStack::TestClass()
{
DEBUG_STREAM << "Starting MemoryStack test...\n";
Tell(" MemoryStack::TestClass() is stubbed out!\n");
return False;
}
+75
View File
@@ -0,0 +1,75 @@
//==========================================================================//
// File: mode.cpp //
// Project: MUNGA Brick: Controls Manager //
// Contents: Interface specification for Controls/Gauges //
//--------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ----------------------------------------------------------//
// 02/13/96 CPB First created //
//--------------------------------------------------------------------------//
// Copyright (C) 1996, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//==========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(MODE_HPP)
# include <mode.hpp>
#endif
#if defined(DEBUG)
# define Test_Tell(n) DEBUG_STREAM << n
#else
# define Test_Tell(n)
#endif
//############################################################################
//############################ ModeManager #############################
//############################################################################
ModeManager::ModeManager(ModeMask initial_mask)
{
Check_Pointer(this);
modeMask = initial_mask;
Check_Fpu();
}
ModeManager::~ModeManager()
{
Check(this);
Check_Fpu();
}
Logical
ModeManager::TestInstance() const
{
Check_Fpu();
return True;
}
Logical
ModeManager::ModeStringLookup(
const char *name,
ModeMask *returned_value
)
{
Check(this);
// There's only one mode value available at this level.
if (stricmp(name, "ModeAlwaysActive") == 0)
{
*returned_value = ModeManager::ModeAlwaysActive;
Check_Fpu();
return True;
}
else
{
*returned_value = (ModeMask) 0;
}
Check_Fpu();
return False;
}
+88
View File
@@ -0,0 +1,88 @@
//===========================================================================//
// File: motion.hh //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the position class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/30/95 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(MOTION_HPP)
# define MOTION_HPP
# if !defined(VECTOR3D_HPP)
# include <vector3d.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ Motion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Motion
{
public:
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile Motion *);
#endif
Vector3D
linearMotion;
Vector3D
angularMotion;
static const Motion
Identity;
//
// Constructors
//
Motion()
{}
Motion(const Motion& motion);
Motion(
const Vector3D& t,
const Vector3D& q
)
{Check(&t); Check(&q); linearMotion = t; angularMotion = q;}
//
// Assignment operators
//
Motion&
operator=(const Motion& p);
//
// Equality operator
//
Logical
operator==(const Motion&) const;
//
// Origin motion
//
Motion&
AddScaled(
const Motion& source,
const Motion& delta,
Scalar t
);
//
// Support functions
//
friend ostream&
operator<<(
ostream& stream,
const Motion& p
);
Logical
TestInstance() const;
static Logical
TestClass();
};
#endif
+5
View File
@@ -0,0 +1,5 @@
SCC = This is a Source Code Control file
[MUNGA.MAK]
SCC_Aux_Path = "\\AVATAR\Mungass\VSS"
SCC_Project_Name = "$/Tesla_BT/MUNGA", WOCAAAAA
+65
View File
@@ -0,0 +1,65 @@
//===========================================================================//
// File: mtrxstk.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification for the matrix class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/21/94 JMA Initial coding. //
// 12/01/94 JMA Changed Matrix to FullMatrix, based both matrix classes on //
// Matrix44Base //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#if !defined(MTRXSTK_HPP)
# include <mtrxstk.hpp>
#endif
AffineMatrixStack&
AffineMatrixStack::Concatenate(const AffineMatrix& matrix)
{
AffineMatrix *old_top = Cast_Object(AffineMatrix*,Peek());
AffineMatrix *new_top = (AffineMatrix*)MemoryStack::Push();
new_top->Multiply(*old_top,matrix);
return *this;
}
LinearMatrixStack&
LinearMatrixStack::Concatenate(const LinearMatrix& matrix)
{
LinearMatrix *old_top = Cast_Object(LinearMatrix*,Peek());
LinearMatrix *new_top = (LinearMatrix*)MemoryStack::Push();
new_top->Multiply(*old_top,matrix);
return *this;
}
Matrix4x4Stack&
Matrix4x4Stack::Concatenate(const Matrix4x4& matrix)
{
Matrix4x4 *old_top = Cast_Object(Matrix4x4*,Peek());
Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
new_top->Multiply(*old_top,matrix);
return *this;
}
Matrix4x4Stack&
Matrix4x4Stack::Concatenate(const AffineMatrix& matrix)
{
Matrix4x4 *old_top = Cast_Object(Matrix4x4*,Peek());
Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
new_top->Multiply(*old_top,matrix);
return *this;
}
Matrix4x4&
Matrix4x4Stack::Push(const AffineMatrix& matrix)
{
Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
return *new_top = matrix;
}
+82
View File
@@ -0,0 +1,82 @@
#if !defined(MUNGA_HPP)
# define MUNGA_HPP
# include <fstream.h>
# include <stddef.h>
# include <float.h>
# include <math.h>
# include <limits.h>
# include <iostream.h>
# include <iomanip.h>
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <time.h>
# include <ctype.h>
# if defined(__BCPLUSPLUS__)
# include <alloc.h>
# endif
# if defined(LBE4)
# include <strstrea.h>
# else
# include <strstream.h>
# endif
enum {
NullExitCodeID = 0,
AbortExitCodeID
};
# if !defined(TRACE_HPP)
# include <trace.hpp>
# endif
# if !defined(NO_PRECOMPILED_HEADERS)
# if !defined(CSTR_HPP)
# include <cstr.hpp>
# endif
# if !defined(NAMELIST_HPP)
# include <namelist.hpp>
# endif
# if !defined(NOTATION_HPP)
# include <notation.hpp>
# endif
# if !defined(SLOT_HPP)
# include <slot.hpp>
# endif
# if !defined(CHAIN_HPP)
# include <chain.hpp>
# endif
# if !defined(SCHAIN_HPP)
# include <schain.hpp>
# endif
# if !defined(VCHAIN_HPP)
# include <vchain.hpp>
# endif
# if !defined(TABLE_HPP)
# include <table.hpp>
# endif
# if !defined(TREE_HPP)
# include <tree.hpp>
# endif
# if !defined(HASH_HPP)
# include <hash.hpp>
# endif
# if !defined(ORIGIN_HPP)
# include <origin.hpp>
# endif
# endif
#endif
+52
View File
@@ -0,0 +1,52 @@
//===========================================================================//
// File: node.cc //
// Project: MUNGA Brick: Connection Library //
// Contents: Implementation details of Node class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/29/94 ECH Initial coding. //
// 10/20/94 JMA Fixed style stuff. //
// 10/23/94 ECH Added greater deletion safety //
// 10/28/94 JMA Made compatible with SGI CC //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/05/94 JMA Made compatible with GNU C++, moved ReleaseSocketLink into //
// the virtual data field //
// 11/08/94 ECH Made compatible with BC4.0 //
// 12/01/94 JMA Made compatible with SGI CC //
// 12/12/94 ECH Changed release handler //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(NODE_HPP)
#include <node.hpp>
#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Node ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Node::Node(ClassID class_id):
Plug(class_id)
{
}
Node::Node(PlugStream *stream):
Plug(stream)
{
}
Node::~Node()
{
}
void
Node::ReleaseLinkHandler(Socket*, Plug*)
{
}
+69
View File
@@ -0,0 +1,69 @@
//===========================================================================//
// File: normal.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the normal class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(NORMAL_HPP)
#include <normal.hpp>
#endif
#if !defined(AFFNMTRX_HPP)
#include <affnmtrx.hpp>
#endif
//
//#############################################################################
//#############################################################################
//
Normal&
Normal::Multiply_Inverse(
const Normal &Source,
const AffineMatrix &M
)
{
Check(this);
Check(&Source);
Check(&M);
x = Source.x*M(0,0) + Source.y*M(0,1) + Source.z*M(0,2);
y = Source.x*M(1,0) + Source.y*M(1,1) + Source.z*M(1,2);
z = Source.x*M(2,0) + Source.y*M(2,1) + Source.z*M(2,2);
return *this;
}
//
//#############################################################################
//#############################################################################
//
Normal&
Normal::Multiply(
const Normal &Source,
const AffineMatrix &M
)
{
Check(this);
Check(&Source);
Check(&M);
AffineMatrix m;
m.Invert(M);
return Multiply_Inverse(Source,m);
}
#if defined(TEST_CLASS)
# include "normal.tcp"
#endif
+22
View File
@@ -0,0 +1,22 @@
//===========================================================================//
// File: normal.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the normal class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
Logical
Normal::TestClass()
{
DEBUG_STREAM << "Starting Normal Test...\n";
Tell(" Normal::TestClass() is stubbed out!\n");
return False;
}
+67
View File
@@ -0,0 +1,67 @@
//===========================================================================//
// File: origin.tst //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the position class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(LINMTRX_HPP)
#include <linmtrx.hpp>
#endif
//
//###########################################################################
//###########################################################################
//
Logical
Origin::TestClass()
{
DEBUG_STREAM << "Starting Origin test...\n";
Point3D p(1.0f,2.0f,3.0f);
Quaternion q(0.0f, 1.0f, 0.0f, 0.0f);
Quaternion r;
r = q;
const Origin
a(p,r);
Origin
b;
Quaternion t;
t = a.angularPosition;
Test(
a.linearPosition == p
&& t.x == q.x
&& t.w == q.w
);
LinearMatrix
m;
m = a;
b = m;
t = b;
Test(
a.linearPosition == b.linearPosition
&& t.y == q.y
);
b = Point3D(3.0f,2.0f,1.0f);
p = b;
Test(p == Point3D(3.0f,2.0f,1.0f));
Quaternion s(1.0f, 0.0f, 0.0f, 0.0f);
b = s;
q = b;
Test(q.x == s.x && q.y == s.y && q.z == s.z && q.w == s.w);
return True;
}
+149
View File
@@ -0,0 +1,149 @@
//===========================================================================//
// File: point.hh //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification of the point class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(POINT2D_HPP)
# define POINT2D_HPP
# if !defined(VECTOR3D_HPP)
# include <vector3d.hpp>
# endif
# if !defined(VECTOR4D_HPP)
# include <vector4d.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Point2D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T> class Point2DOf:
public Vector2DOf<T>
{
public:
//
// Constructors
//
Point2DOf()
{}
Point2DOf(
T x,
T y
):
Vector2DOf<T>(x,y)
{}
Point2DOf(const Vector2DOf<T> &v):
Vector2DOf<T>(v)
{}
//
// Assignment operators
//
Point2DOf<T>& operator=(const Vector2DOf<T>& v)
{Vector2DOf<T>::operator=(v); return *this;}
//
// Math operators
//
Point2DOf<T>&
Negate(const Vector2DOf<T> &v)
{Vector2DOf<T>::Negate(v); return *this;}
Point2DOf<T>&
Add(
const Vector2DOf<T>& v1,
const Vector2DOf<T>& v2
)
{Vector2DOf<T>::Add(v1,v2); return *this;}
Point2DOf<T>&
operator+=(const Vector2DOf<T>& v)
{return Add(*this,v);}
Point2DOf<T>&
Subtract(
const Point2DOf<T>& p,
const Vector2DOf<T>& v
)
{Vector2DOf<T>::Subtract(p,v); return *this;}
Point2DOf<T>&
operator-=(const Vector2DOf<T>& v)
{return Subtract(*this,v);}
float
operator*(const Vector2DOf<T>& v) const
{return Vector2DOf<T>::operator*(v);}
Point2DOf<T>&
Multiply(
const Point2DOf<T>& p,
float scale
)
{Vector2DOf<T>::Multiply(p,scale); return *this;}
Point2DOf<T>&
operator*=(float value)
{return Multiply(*this,value);}
Point2DOf<T>&
Multiply(
const Point2DOf<T>& p,
const Vector2DOf<T>& v
)
{Vector2DOf<T>::Multiply(p,v); return *this;}
Point2DOf<T>&
operator*=(const Vector2DOf<T> &v)
{return Multiply(*this,v);}
Point2DOf<T>&
Divide(
const Vector2DOf<T>& v,
float scale
)
{Vector2DOf<T>::Divide(v,scale); return *this;}
Point2DOf<T>&
operator/=(float value)
{return Divide(*this,value);}
Point2DOf<T>&
Divide(
const Vector2DOf<T>& v1,
const Vector2DOf<T>& v2
)
{Vector2DOf<T>::Divide(v1,v2); return *this;}
Point2DOf<T>&
operator/=(const Vector2DOf<T> &v)
{return Divide(*this,v);}
//
// Miscellaneous functions
//
Point2DOf<T>&
Combine(
const Vector2DOf<T>& v1,
float t1,
const Vector2DOf<T>& v2,
float t2
)
{Vector2DOf<T>::Combine(v1,t1,v2,t2); return *this;}
//
// Template support functions
//
Point2DOf<T>&
Lerp(
const Vector2DOf<T>& v1,
const Vector2DOf<T>& v2,
float t
)
{Vector2DOf<T>::Lerp(v1,v2,t); return *this;}
};
#endif
+74
View File
@@ -0,0 +1,74 @@
//===========================================================================//
// File: random.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification for the random number generator //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/20/93 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1993-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(RANDOM_HPP)
# define RANDOM_HPP
# if !defined(SCALAR_HPP)
# include <scalar.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Random ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class RandomGenerator SIGNATURED
{
private:
static int
Numbers[250]; // the random number table
static int
Index; // the current entry within the table
static void
Init();
static int
GetRandomInt();
public:
RandomGenerator()
{if (Index == -1) Init();}
//
//------------------------
// Random number functions
//------------------------
//
int
GetInt() // returns 0 .. RAND_MAX
{return GetRandomInt();}
operator Scalar(); // returns 0.0f <= x < 1.0f
int // returns 0 .. Range-1
operator ()(int Range);
static Logical
TestClass();
};
extern RandomGenerator Random;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Die ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Die SIGNATURED
{
private:
int
highestRandom, // the highest random number giving a uniform dist.
dieSides; // the number of sides on the die (starting from 1)
public:
Die(int sides);
operator int(); // returns 1 .. dieSides
};
#endif
+44
View File
@@ -0,0 +1,44 @@
//===========================================================================//
// File: random.tst //
// Project: MUNGA Brick: Math Library //
// Contents: test function for the random number generator //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/20/93 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1993-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
Logical
RandomGenerator::TestClass()
{
DEBUG_STREAM << "Starting Random test...\n";
#define RANDOM_TEST_COUNT 10000
int i;
for (i=0; i<RANDOM_TEST_COUNT; ++i)
{
Scalar r = Random;
Test_And_Dump(r >= 0.0f && r < 1.0f,r);
}
int array[10];
for (i = 0; i<ELEMENTS(array); ++i)
{
array[i] = 0;
}
for (i = 0; i<RANDOM_TEST_COUNT; ++i)
{
int r = Random(ELEMENTS(array));
Test(r >= 0 && r < ELEMENTS(array));
++array[r];
}
return True;
}
+101
View File
@@ -0,0 +1,101 @@
//###########################################################################
//
// $Workfile: RAY.HPP $
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Copyright(c) 1993 J. M. Albertson - All Rights Reserved
//
//###########################################################################
#if !defined(RAY_HPP)
# define RAY_HPP
# if !defined(POINT3D_HPP)
# include <point3d.hpp>
# endif
# if !defined(UNITVEC_HPP)
# include <unitvec.hpp>
# endif
class Plane;
class Sphere;
class Cylinder;
class Cone;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ray ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Ray SIGNATURED
{
public:
Point3D
origin;
UnitVector
direction;
Ray()
{}
Ray(
const Point3D &origin,
const UnitVector &direction
):
origin(origin),
direction(direction)
{}
//
// Ray projection functions
//
void
Project(
Scalar length,
Point3D *result
);
Scalar
LengthToClosestPointTo(const Point3D &point);
void
ClosestPointTo(
const Point3D &point,
Point3D *result
)
{
Check(this); Check(result); Check(&point);
Project(LengthToClosestPointTo(point),result);
}
//
// Ray intersection functions
//
Scalar
DistanceTo(
const Plane &plane,
Scalar *product
) const;
Scalar
DistanceTo(
const Sphere &sphere,
Scalar *penetration
) const;
//
// Test support
//
Logical
TestInstance() const;
static Logical
TestClass();
};
extern Scalar
Find_Closest_Approach(
const Point3D& origin1,
const Vector3D& velocity1,
Point3D *result1,
const Point3D& origin2,
const Vector3D& velocity2,
Point3D *result2,
Scalar *time,
Logical *constant
);
#endif
+22
View File
@@ -0,0 +1,22 @@
//===========================================================================//
// File: ray.tst //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for the ray class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/25/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
Logical
Ray::TestClass()
{
DEBUG_STREAM << "Starting Ray test...\n";
Tell(" Ray::TestClass is stubbed out!\n");
return True;
}
+90
View File
@@ -0,0 +1,90 @@
//===========================================================================//
// File: Rect2D.hh //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification for two-dimensional rectangle class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 2/01/95 CPB Initial coding (started from Vector2D.hh) //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved //
// PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(RECT2D_HPP)
# define RECT2D_HPP
# if !defined(VECTOR2D_HPP)
# include <vector2d.hpp>
# endif
// Note that the coordinate system used here is such that
// (0,0) is in the lower left corner.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Rectangle2D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Rectangle2D SIGNATURED
{
public:
Vector2DOf<int> bottomLeft, topRight;
Rectangle2D();
Rectangle2D(Vector2DOf<int> bl, Vector2DOf<int> tr);
Rectangle2D(int x1, int y1, int x2, int y2);
~Rectangle2D()
{}
Logical
operator==(const Rectangle2D& r) const
{return ((bottomLeft == r.bottomLeft) && (topRight == r.topRight));}
Logical
operator!=(const Rectangle2D& r) const
{return ((bottomLeft != r.bottomLeft) || (topRight != r.topRight));}
void
Union(
const Rectangle2D& r1,
const Rectangle2D& r2
);
void
Intersection(
const Rectangle2D& r1,
const Rectangle2D& r2
);
void
MakeEmpty()
{
Check(this);
bottomLeft.x = 1;
topRight.x = 0;
}
Logical
IsEmpty() const
{
if ((bottomLeft.x > topRight.x) || (bottomLeft.y > topRight.y))
{
return True;
}
else
{
return False;
}
}
friend ostream&
operator<<(
ostream& stream,
const Rectangle2D& r
);
Logical
TestInstance() const;
static Logical
TestClass();
};
#endif
+57
View File
@@ -0,0 +1,57 @@
//===========================================================================//
// File: renderer.tst //
// Project: MUNGA Brick: Renderer Manager //
// Contents: Interface specification Renderer and Renderer Manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/06/95 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include "renderer.thp"
TestRenderer::TestRenderer():
Renderer(
30.0f,
MaxRendererComplexity,
DefaultRendererPriority,
VisualInterestType,
DefaultInterestDepth
)
{
}
TestRenderer::~TestRenderer()
{
}
Logical
TestRenderer::TestInstance() const
{
Renderer::TestInstance();
return True;
}
void
TestRenderer::ExecuteImplementation(
RendererComplexity,
RendererOrigin::InterestingEntityIterator *interesting_entity_iterator
)
{
Check(interesting_entity_iterator);
//
// HACK - Just step through the entities
//
Entity *entity;
while ((entity = interesting_entity_iterator->ReadAndNext()) != NULL)
{
Check(entity);
}
}
+48
View File
@@ -0,0 +1,48 @@
//===========================================================================//
// File: tstrend.hh //
// Project: MUNGA Brick: Renderer Manager //
// Contents: Interface specification Renderer and Renderer Manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/06/95 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(TSTREND_THP)
# define TSTREND_THP
# if !defined(RENDERER_HPP)
# include <renderer.hpp>
# endif
class TestRenderer:
public Renderer
{
public:
TestRenderer();
~TestRenderer();
Logical
TestInstance() const;
private:
void
LoadMissionImplementation(Mission*) {};
void
ShutdownImplementation() {};
void
SuspendImplementation() {};
void
ResumeImplementation() {};
void
ExecuteImplementation(
RendererComplexity complexity_update,
RendererOrigin::InterestingEntityIterator *iterator
);
};
#endif
+7
View File
@@ -0,0 +1,7 @@
#if !defined(RESVER_HPP)
# define RESVER_HPP
# define RESOURCE_FORMAT_VERSION 1
#endif
+246
View File
@@ -0,0 +1,246 @@
//===========================================================================//
// File: scalar.cpp //
// Project: MUNGA Brick: None assigned - coding styles, etc. //
// Contents: Base information used by all MUNGA source files //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(SCALAR_HPP)
#include <scalar.hpp>
#endif
int
Round(Scalar value)
{
int whole_part = floor(value);
Scalar fractional_part = value - whole_part;
if (fractional_part >= 0.5)
{
return whole_part + 1;
}
else
{
return whole_part;
}
}
void
Find_Roots(
Scalar a, // a*x*x + b*x + c = 0
Scalar b,
Scalar c,
Scalar *center,
Scalar *range
)
{
//
//---------------------------------
// See if the quadratic is solvable
//---------------------------------
//
*range = b*b - 4.0f*a*c;
if (*range < 0.0f || Small_Enough(a))
{
*range = -1.0f;
}
else
{
//
//---------------------------
// Solve the single root case
//---------------------------
//
a *= 2.0f;
*center = -b / a;
if (*range < SMALL)
{
*range = 0.0f;
}
//
//--------------------------
// Find the two-root extents
//--------------------------
//
else
{
*range = Sqrt(*range);
*range /= a;
}
}
}
static void
Verify_Arguments(
const char *str,
void *value
)
{
if (str == NULL)
{
Fail("Convert_From_Ascii - str == NULL");
}
if (value == NULL)
{
Fail("Convert_From_Ascii - value == NULL");
}
if (isalpha(*str))
{
DEBUG_STREAM << "Convert_From_Ascii - str == " << str << "\n";
Fail("Convert_From_Ascii - isalpha(*str)");
}
}
void
Convert_From_Ascii(
const char *str,
char *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = (char)atoi(str);
}
void
Convert_From_Ascii(
const char *str,
unsigned char *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = (unsigned char)atoi(str);
}
void
Convert_From_Ascii(
const char *str,
int *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = atoi(str);
}
void
Convert_From_Ascii(
const char *str,
unsigned int *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = atoi(str);
}
void
Convert_From_Ascii(
const char *str,
long *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = atol(str);
}
void
Convert_From_Ascii(
const char *str,
unsigned long *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = atol(str);
}
void
Convert_From_Ascii(
const char *str,
Scalar *value
)
{
#if 0
Check_Pointer(str);
Check_Pointer(value);
if (isalpha(*str))
{
Dump(str);
}
Verify(!isalpha(*str));
#else
Verify_Arguments(str, value);
#endif
*value = atof(str);
}
+72
View File
@@ -0,0 +1,72 @@
//===========================================================================//
// File: scalar.hpp //
// Project: MUNGA Brick: None assigned - coding styles, etc. //
// Contents: Base information used by all MUNGA source files //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(SCALAR_HPP)
# define SCALAR_HPP
# if !defined(MEMSTRM_HPP)
# include <memstrm.hpp>
# endif
# if !defined(M_PI)
# define M_PI 3.14159265358979323846
# endif
typedef float Scalar;
# define PI ((Scalar)(M_PI))
# define PI_OVER_2 ((Scalar)(M_PI/2.0))
# define PI_OVER_3 ((Scalar)(M_PI/3.0))
# define PI_OVER_4 ((Scalar)(M_PI/4.0))
# define PI_OVER_6 ((Scalar)(M_PI/6.0))
# define TWO_PI ((Scalar)(2.0*M_PI))
# define DEG_PER_RAD ((Scalar)(180.0/M_PI))
# define RAD_PER_DEG ((Scalar)(M_PI/180.0))
inline Scalar Lerp(Scalar a, Scalar b, Scalar t)
{return a*(1.0f - t) + b*t;}
inline Logical Small_Enough(Scalar x,Scalar e=SMALL)
{return fabs(x) <= e;}
inline Logical Close_Enough(Scalar x,Scalar y,Scalar e=SMALL)
{return fabs(x-y) <= e;}
int
Round(Scalar value);
void
Find_Roots(
Scalar a, // a*x*x + b*x + c = 0
Scalar b,
Scalar c,
Scalar *center,
Scalar *range
);
inline MemoryStream&
MemoryStream_Read(
MemoryStream* stream,
Scalar *output
)
{return stream->ReadBytes(output, sizeof(*output));}
inline MemoryStream&
MemoryStream_Write(
MemoryStream* stream,
const Scalar *input
)
{return stream->WriteBytes(input, sizeof(*input));}
void
Convert_From_Ascii(const char *str, Scalar *value);
#endif
+175
View File
@@ -0,0 +1,175 @@
//===========================================================================//
// File: scnrole.hpp //
// Project: MUNGA //
// Contents: Scenario Mission Specific Data //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/9/96 JM initial coding //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined (SCNROLE_HPP)
# define SCNROLE_HPP
# if !defined (NODE_HPP)
# include <node.hpp>
# endif
# if !defined (CSTR_HPP)
# include <cstr.hpp>
# endif
# if !defined(RESOURCE_HPP)
# include <resource.hpp>
# endif
# if !defined(SCALAR_HPP)
# include <scalar.hpp>
# endif
class NotationFile;
//##############################################################################
//##################### ScenarioRole::ModelResource ######################
//##############################################################################
struct ScenarioRole__ModelResource
{
Scalar
killBonus,
specialCaseDeathPenalty,
damageReceivedModifier,
damageInflictedModifier,
damageBias,
friendlyFirePenalty;
int
returnFromDeath;
};
//###########################################################################
//##################### Class ScenarioRole #############################
//###########################################################################
class ScenarioRole :
public Node
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Score Support
//
public:
Scalar
CalcDamageReceivedScore(const Scalar &damage_received);
protected:
Scalar
damageInflictedModifier,
damageReceivedModifier,
friendlyFirePenalty,
damageBias,
killBonus,
specialCaseDeathPenalty;
CString
roleName;
int
returnFromDeath;
public:
const int
GetReturnFromDeath()
{ Check(this); return returnFromDeath; }
Scalar
GetDamageInflictedModifier() const
{ Check(this); return damageInflictedModifier; }
Scalar
GetDamageReceivedModifier() const
{ Check(this); return damageReceivedModifier; }
Scalar
GetFriendlyFirePenalty() const
{ Check(this); return friendlyFirePenalty; }
Scalar
GetDamageBias() const
{ Check(this); return damageBias; }
Scalar
GetKillBonus() const
{ Check(this); return killBonus; }
Scalar
GetSpecialCaseDeathPenalty() const
{ Check(this); return specialCaseDeathPenalty; }
CString
GetRoleName() const
{Check(this); return roleName; }
void
SetDamageInflictedModifier(const Scalar &value)
{ Check(this); damageInflictedModifier = value; }
void
SetDamageReceivedModifier(const Scalar value)
{ Check(this); damageReceivedModifier = value; }
void
SetFriendlyFirePenalty(const Scalar &value)
{ Check(this); friendlyFirePenalty = value; }
void
SetDamageBias(const Scalar &value)
{ Check(this); damageBias = value; }
void
SetKillBonus(const Scalar &value)
{ Check(this); killBonus = value; }
void
SetSpecialCaseDeathPenalty(const Scalar &value)
{ Check(this); specialCaseDeathPenalty = value; }
void
SetReturnFromDeath(const int &value)
{ Check(this); returnFromDeath = value ; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction / Destruction
public:
typedef ScenarioRole__ModelResource ModelResource;
ScenarioRole(
const CString &role_name,
const CString &model_file
);
ScenarioRole(const CString &role_name);
~ScenarioRole();
static ResourceDescription::ResourceID
CreateModelResource(
ResourceFile *resource_file,
const char* model_name,
NotationFile * model_file,
const ResourceDirectories *directories,
ModelResource *model = NULL
);
};
#endif
+165
View File
@@ -0,0 +1,165 @@
//===========================================================================//
// File: set.cpp //
// Project: MUNGA Brick: Connection Engine //
// Contents: Implementation of Sets and useful set operations //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/29/94 GDU Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1996 Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(SET_HPP)
# include <set.hpp>
#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
// Set
//#############################################################################
//
Set::Set(Node *node):
Socket(node),
contents(NULL)
{
}
//
//#############################################################################
// ~Set
//#############################################################################
//
Set::~Set()
{
SetReleaseNode(NULL);
if (contents)
{
delete contents;
}
}
//
//#############################################################################
// TestInstance
//#############################################################################
//
Logical
Set::TestInstance() const
{
Socket::TestInstance();
Check(contents);
return True;
}
//
//#############################################################################
// Union
//
// Merge contents of this with rhs. Items that occur in either set are placed
// in the resulting set, with no duplication. It is assumed that both operands
// are proper sets, ie. they contain no duplicates.
//#############################################################################
//
Set
Set::Union(const Set &) const
{
Check(this);
Set result(NULL);
return result;
}
//
//#############################################################################
// Intersection
//
// Merge contents of this with rhs. Items that occur in both sets are placed
// only once in the resulting set. It is assumed that both operands are proper
// sets, ie. they contain no duplicates.
//
// This implementation of set intersection is dumb and slow.
//#############################################################################
//
Set
Set::Intersection(const Set &rhs) const
{
Check(this);
Check(rhs);
// Contents iterator is a SetIterator and not a ChainIterator in order to
// have access to the ChainIterator::ReadAndNextImplentation.
// We circumvent encapsulation protections by declaring Set a friend of SetIterator
// (which derives from ChainIterator). Set is not a friend of ChainIterator.
SetIterator contents_iterator(contents);
// Casting away const is safe since our local iterator is not going to insert or
// remove items from rhs.
SetIterator rhs_iterator((Set *) &rhs);
Plug *lhs_plug;
Plug *rhs_plug;
Set result(NULL);
while ((lhs_plug = Cast_Object(Plug *, contents_iterator.ReadAndNextImplementation())) != NULL)
{
while ((rhs_plug = Cast_Object(Plug *,rhs_iterator.ReadAndNextImplementation())) != NULL)
{
if (lhs_plug == rhs_plug)
{
result.AddImplementation(lhs_plug);
}
}
}
return result;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SetIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
// SetIterator
//#############################################################################
//
SetIterator::SetIterator(Set *set):
ChainIterator(set->contents)
{
Check(set);
}
SetIterator::SetIterator(const SetIterator &iterator):
ChainIterator(Cast_Object(Chain*, (Cast_Object(Set *,iterator.socket)->contents)))
{
Check(&iterator);
}
SetIterator::SetIterator(Chain *chain):
ChainIterator(chain)
{
Check(chain);
}
SetIterator::~SetIterator()
{
}
+86
View File
@@ -0,0 +1,86 @@
//===========================================================================//
// File: sfeskt.hh //
// Project: MUNGA Brick: Connection Engine //
// Contents: Interface definition for safe socket class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/29/94 ECH Initial coding. //
// 10/28/94 JMA Made compatible with SGI CC and merged with iterator //
// 11/03/94 ECH Made compatible with BC4.0 //
// 12/12/94 ECH Changed release mechanism //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(SFESKT_HPP)
# define SFESKT_HPP
# if !defined(SOCKET_HPP)
# include <socket.hpp>
# endif
class SafeIterator;
typedef int IteratorMemo;
enum
{
PlugAdded = 0,
PlugRemoved,
NextSafeSocketMemo
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SafeSocket ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SafeSocket:
public Socket
{
friend class SafeIterator;
public:
~SafeSocket();
Logical
TestInstance() const;
protected:
SafeSocket(Node *node);
void
SendIteratorMemo(
IteratorMemo memo,
void *content
);
private:
SafeIterator *iteratorHead;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SafeIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SafeIterator:
public SocketIterator
{
friend class SafeSocket;
public:
~SafeIterator();
Logical
TestInstance() const;
protected:
SafeIterator(SafeSocket *safeSocket);
private:
virtual void
ReceiveMemo(
IteratorMemo memo,
void *content
);
SafeIterator *nextIterator;
SafeIterator *prevIterator;
};
#endif
+55
View File
@@ -0,0 +1,55 @@
//=======================================================================//
// File: sphere.cpp //
// Project: Architecture //
// Author: J.M. Albertson //
//-----------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainments, All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(SPHERE_HPP)
# include <sphere.hpp>
#endif
//
//###########################################################################
//###########################################################################
//
Logical
Sphere::Contains(const Point3D &A_Point) const
{
Vector3D
diff;
diff.Subtract(center,A_Point);
return radius*radius >= diff.LengthSquared();
}
//
//###########################################################################
//###########################################################################
//
Logical
Sphere::Intersects(const Sphere &sphere) const
{
Vector3D temp;
Scalar r;
r = radius + sphere.radius;
temp.Subtract(center, sphere.center);
return temp.LengthSquared() <= r*r;
}
//
//###########################################################################
//###########################################################################
//
ostream&
operator<<(ostream& Stream, const Sphere &A_Sphere)
{
Stream << "\n\tSphere Centerpoint: " << A_Sphere.center;
return Stream << "\n\tRadius: " << A_Sphere.radius;
}
+62
View File
@@ -0,0 +1,62 @@
//=======================================================================//
// File: sphere.hpp //
// Project: Architecture //
// Author: J.M. Albertson //
//-----------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainments, //
// PROPRIETARY AND CONFIDENTIAL //
//=======================================================================//
#if !defined(SPHERE_HPP)
# define SPHERE_HPP
# if !defined(POINT3D_HPP)
# include <point3d.hpp>
# endif
class Plane;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sphere ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Sphere SIGNATURED
{
public:
Point3D
center;
Scalar
radius;
Sphere()
{}
Sphere(
const Point3D &A_Point,
Scalar Radius
):
center(A_Point),
radius(Radius)
{}
Sphere(
Scalar X,
Scalar Y,
Scalar Z,
Scalar Radius
):
center(X,Y,Z),
radius(Radius)
{}
//
// Intersection functions
//
Logical
Contains(const Point3D &point) const;
Logical
Intersects(const Sphere &sphere) const;
Logical
Intersects(const Plane &plane) const;
friend ostream&
operator<<(ostream& Stream, const Sphere &A_Sphere);
};
#endif
+43
View File
@@ -0,0 +1,43 @@
#if !defined(SPLINE_HPP)
# define SPLINE_HPP
# if !defined(AFFNMTRX_HPP)
# include <affnmtrx.hpp>
# endif
class CubicCurve {
public:
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile CubicCurve *);
#endif
CubicCurve( // Hermite form
const Point3D& p1,
const Vector3D& r1,
const Point3D& p4,
const Vector3D& r4
);
CubicCurve( // Bezier form
const Point3D& p1,
const Point3D& p2,
const Point3D& p3,
const Point3D& p4
);
void
Evaluate(
Scalar t,
Point3D *p,
Vector3D *v
);
Logical
TestInstance() const;
protected:
AffineMatrix
basisMatrix;
};
#endif
+76
View File
@@ -0,0 +1,76 @@
#if !defined(SPOOLER_HPP)
# define SPOOLER_HPP
# if !defined(APPMGR_HPP)
# include <appmgr.hpp>
# endif
//##########################################################################
//########################### SpoolFile ################################
//##########################################################################
class SpoolFile:
public MemoryStream
{
public:
SpoolFile(
void *stream_start,
size_t stream_size,
size_t initial_offset=0
);
SpoolFile(SpoolFile& spool);
~SpoolFile();
enum SpoolState {
Empty,
Spooling,
Stored,
Playing
};
SpoolState
spoolState;
void
SaveAs(const char *name);
void
Read(const char *name);
void
SpoolPacket(NetworkPacket *packet);
NetworkPacket*
NextPacket();
};
//##########################################################################
//############## MissionReviewApplicationManager #####################
//##########################################################################
class MissionReviewApplicationManager:
public ApplicationManager
{
public:
MissionReviewApplicationManager(
Scalar frame_rate,
int spool_count,
size_t spool_size
);
~MissionReviewApplicationManager();
SpoolFile*
GetEmptySpoolFile();
SpoolFile*
GetStoredSpoolFile();
void
StoreSpoolFile(SpoolFile *spool_file);
void
ReleaseSpoolFile(SpoolFile *spool_file);
protected:
int spoolCount;
SpoolFile **spoolFiles;
char **spoolBuffers;
size_t spoolSize;
};
#endif
+75
View File
@@ -0,0 +1,75 @@
//===========================================================================//
// File: srtskt.cc //
// Project: MUNGA Brick: Connection Engine //
// Contents: Implementation of sorted socket class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/02/94 ECH Initial coding. //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/05/94 JMA Made compatible with GNU C++ //
// 12/12/94 ECH Changed release handling //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(SRTSKT_HPP)
#include <srtskt.hpp>
#endif
SortedSocket::SortedSocket(
Node *node,
Logical has_unique_entries
):
SafeSocket(node)
{
hasUniqueEntries = has_unique_entries;
}
SortedSocket::~SortedSocket()
{
}
void
SortedSocket::AddValueImplementation(
Plug*,
const void*
)
{
Fail("SortedSocket::AddValueImplementation - Should never reach here");
}
Plug*
SortedSocket::FindImplementation(const void*)
{
Fail("SortedSocket::FindImplementation - Should never reach here");
return NULL;
}
SortedIterator::SortedIterator(SortedSocket *sortedSocket):
SafeIterator(sortedSocket)
{
}
SortedIterator::~SortedIterator()
{
}
Plug*
SortedIterator::FindImplementation(const void*)
{
Fail("SortedIterator::FindImplementation - Should never reach here");
return NULL;
}
void*
SortedIterator::GetValueImplementation()
{
Fail("SortedIterator::GetValueImplementation - Should never reach here");
return NULL;
}
+88
View File
@@ -0,0 +1,88 @@
//===========================================================================//
// File: srtskt.hh //
// Project: MUNGA Brick: Connection Engine //
// Contents: Interface definition for sorted socket class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/02/94 ECH Initial coding. //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/05/94 JMA Made compatible with GNU C++ //
// 12/12/94 ECH Changed release handling //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(SRTSKT_HPP)
# define SRTSKT_HPP
# if !defined(SFESKT_HPP)
# include <sfeskt.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SortedSocket ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SortedSocket:
public SafeSocket
{
public:
~SortedSocket();
void
AddValuePlug(
Plug *plug,
const void *value
)
{AddValueImplementation(plug, value);}
Plug*
FindPlug(const void *value)
{return FindImplementation(value);}
protected:
SortedSocket(
Logical has_unique_entries = True
);
SortedSocket(
Node *node,
Logical has_unique_entries = True
);
Logical
HasUniqueEntries()
{return hasUniqueEntries;}
virtual void
AddValueImplementation(
Plug *plug,
const void *value
);
virtual Plug*
FindImplementation(const void *value);
private:
Logical
hasUniqueEntries;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SortedIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SortedIterator:
public SafeIterator
{
public:
~SortedIterator();
virtual Plug*
FindImplementation(const void *value);
virtual void*
GetValueImplementation();
protected:
SortedIterator(SortedSocket *sortedSocket);
};
#endif
+197
View File
@@ -0,0 +1,197 @@
//===========================================================================//
// File: team.hpp //
// Project: MUNGA //
// Contents: Team Specifications //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/11/96 JM initial coding //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined (TEAM_HPP)
# define TEAM_HPP
# if !defined (ENTITY_HPP)
# include <entity.hpp>
# endif
//##########################################################################
//################# Team__MakeMessage ##########################
//##########################################################################
class Team__MakeMessage :
public Entity::MakeMessage
{
public:
char
teamName[64];
int
initialScore;
Team__MakeMessage(
Receiver::MessageID message_ID,
size_t length,
Entity::ClassID class_ID,
const EntityID &owner_ID,
ResourceDescription::ResourceID resource_ID,
LWord instance_flags,
const Origin &origin,
char *team_name
) :
Entity::MakeMessage(
message_ID,
length,
class_ID,
owner_ID,
resource_ID,
instance_flags,
origin
)
{
Str_Copy(teamName, team_name, sizeof(teamName));
}
};
//##########################################################################
//################# Team__ScoreMessage ##########################
//##########################################################################
class Team__ScoreMessage :
public Entity::Message
{
public:
Scalar
scoreAward;
Team__ScoreMessage(
Receiver::MessageID message_ID,
size_t length,
Scalar score
):
Entity::Message(message_ID, length),
scoreAward(score)
{}
};
//##########################################################################
//######################## CLASS Team ################################
//##########################################################################
class Team :
public Entity
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data support
//
public:
static Derivation
ClassDerivations;
static SharedData
DefaultData;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Message Support
//
public:
enum {
ScoreMessageID = Entity::NextMessageID,
NextMessageID
};
typedef Team__ScoreMessage ScoreMessage;
void
ScoreMessageHandler(ScoreMessage *message);
private:
static const HandlerEntry MessageHandlerEntries[];
protected:
static MessageHandlerSet MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support
//
private:
static const IndexEntry
AttributePointers[];
protected:
static AttributeIndexSet
AttributeIndex;
public:
enum {
TeamNameAttributeID = Entity::NextAttributeID,
TeamScoreAttributeID,
NextAttributeID
};
char
teamName[64];
Scalar
teamScore;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
typedef void
(Team::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
virtual void
TeamSimulation(Scalar time_slice);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction / Destruction Support
//
public:
typedef Team__MakeMessage MakeMessage;
Team(
MakeMessage *creation_message,
SharedData &shared_data = DefaultData
);
~Team();
Logical
TestInstance() const;
static Team*
Make(MakeMessage *creation_message);
static Logical
CreateMakeMessage (
MakeMessage *creation_message,
NotationFile *model_file,
const ResourceDirectories *directories
);
};
#endif
+137
View File
@@ -0,0 +1,137 @@
//===========================================================================//
// File: testclas.hh //
// Project: MUNGA Brick: Dynamic Dispatch, Event and Journalling //
// Contents: defines test classes for use by Dispatch and Events //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/03/94 JMA Initial coding. //
// 11/05/94 JMA Made compatible with GNU C++ //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(TESTCLAS_HPP)
# define TESTCLAS_HPP)
# if !defined(RECEIVER_HPP)
# include <receiver.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alpha ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Alpha:
public Receiver
{
protected:
static SharedData
DefaultData;
public:
int
x;
enum {
message0ID = Receiver::NextMessageID,
message1ID,
NextMessageID
};
static Derivation
ClassDerivations;
Alpha(
ClassID class_ID = TrivialReceiverClassID,
SharedData &vdata = DefaultData);
~Alpha();
void
Method0Handler(Message*);
void
Method1Handler(Message*);
inline void Method0()
{Message m(message0ID,sizeof(Message)); Dispatch(&m);}
inline void Method1()
{Message m(message1ID,sizeof(Message)); Dispatch(&m);}
static MessageHandlerSet
handlerSet;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Beta ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Beta:
public Alpha
{
protected:
static SharedData
DefaultData;
public:
enum {
message2ID=Alpha::NextMessageID,
message3ID,
NextMessageID
};
static Derivation
ClassDerivations;
Beta(
ClassID class_id = TrivialReceiverClassID,
SharedData &vdata = DefaultData
);
~Beta();
void
Method1aHandler(Message*);
void
Method2Handler(Message*);
void
Method3Handler(Message*);
inline void Method1()
{Message m(message1ID,sizeof(Message)); Dispatch(&m);}
inline void Method2()
{Message m(message2ID,sizeof(Message)); Dispatch(&m);}
inline void Method3()
{Message m(message3ID,sizeof(Message)); Dispatch(&m);}
static MessageHandlerSet
handlerSet;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gamma ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Gamma:
public Beta
{
public:
enum {
message4ID=Beta::NextMessageID,
NextMessageID
};
static Derivation
ClassDerivations;
Gamma();
~Gamma();
void
Method4Handler(Message*);
inline void Method4()
{Message m(message4ID,sizeof(Message)); Dispatch(&m);}
static MessageHandlerSet
handlerSet;
protected:
static SharedData
DefaultData;
};
#endif
+100
View File
@@ -0,0 +1,100 @@
//===========================================================================//
// File: time.tst //
// Project: MUNGA Brick: Time Manager //
// Contents: Test stuff for time //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 10/24/94 JMA Initial coding. //
// 10/28/94 JMA Made compatible with SGI CC //
// 11/03/94 ECH Made compatible with BC4.0 //
//---------------------------------------------------------------------------//
// Copyright (C) 1994, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//#############################################################################
//#############################################################################
//
Logical
Time::TestClass()
{
DEBUG_STREAM << "Starting Time test...\n";
Time
a,
b,
c;
Scalar f;
long
t;
//
//----------------
// Test assignment
//----------------
//
a = 1.0f;
b = 2.0f;
c = Null;
c = a;
Test(a <= c);
Test(a >= c);
c = 1.0f;
Test(c <= a);
Test(c >= a);
c = b.ticks;
Test(c <= b);
Test(c >= b);
//
//----------------------
// Test time comparators
//----------------------
//
Test(a < b);
Test(a <= b);
Test(b > a);
Test(b >= a);
//
//-------------
// Test casting
//-------------
//
f = c;
Test(Close_Enough(f,2.0f));
t = a;
Test(t == a.ticks);
//
//--------------------
// Test math functions
//--------------------
//
c = a;
c += 1.0f;
Test(c.ticks == b.ticks);
c -= a;
Test(c.ticks == a.ticks);
c = b;
c -= 1.0f;
Test(c.ticks == a.ticks);
c += a;
Test(c.ticks == b.ticks);
//
// This test checks to see if the Scalar value is within the resolution
// of half a tick
//
f = b - a;
Test(Close_Enough(f, 1.0f, 0.5f * (1.0f / SystemClock::ticksPerSecond)));
return True;
}
+56
View File
@@ -0,0 +1,56 @@
//===========================================================================//
// File: time.cc //
// Project: MUNGA Brick: Time Manager //
// Contents: Implementation details of the Time Manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 10/19/94 JMA Initial coding. //
// 10/24/94 JMA Added Lester's IBM RTC code in as SystemClock class //
// 10/28/94 JMA Made compatible with SGI CC //
// 11/03/94 ECH Made compatible with BC4.0 //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(TIME_HPP)
#include <time.hpp>
#endif
//#############################################################################
//########################### System Clock ##############################
//#############################################################################
SystemClock
SystemClock::timer;
Scalar
SystemClock::ticksPerSecond = 1000.0f;
long
SystemClock::GetRTC()
{
static long time=0L;
return time++;
}
SystemClock::SystemClock()
{
pauseStart = 0L;
pauseTime = 0L;
}
void
SystemClock::Shutdown()
{
}
float
Get_Frame_Percent_Used()
{
return 0.5f;
}
+38
View File
@@ -0,0 +1,38 @@
#include <munga.hpp>
#pragma hdrstop
#if !defined(HEAP_HPP)
#include <heap.hpp>
#endif
void*
Get_Caller(int)
{
return NULL;
}
size_t
UserHeap::GetMainHeapInitialSize()
{
return 0x200000;
}
#if defined(USE_ACTIVE_PROFILE)
void
BitTrace::SetLineImplementation(Byte)
{
}
void
BitTrace::ClearLineImplementation(Byte)
{
}
Logical
BitTrace::IsLineValidImplementation(Byte)
{
return True;
}
#endif
+66
View File
@@ -0,0 +1,66 @@
//===========================================================================//
// File: unitvec.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for unit vector class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <munga.hpp>
#pragma hdrstop
#if !defined(UNITVEC_HPP)
#include <unitvec.hpp>
#endif
//
//#############################################################################
//#############################################################################
//
UnitVector&
UnitVector::Lerp(
const UnitVector&, // v1,
const UnitVector&, // v2,
Scalar // t
)
{
Check_Pointer(this);
Tell("UnitVector::Lerp stubbed out!\n");
return *this;
}
//
//#############################################################################
//#############################################################################
//
Logical
UnitVector::TestInstance() const
{
Scalar length = Vector3D::LengthSquared();
Scalar diff = 1.0f - length;
if (!Small_Enough(diff,2e-5))
{
length = x*x + y*y + z*z;
diff = 1.0f - length;
if (!Small_Enough(diff,2e-5))
{
Dump(*this);
Dump(length);
Dump(x*x + y*y + z*z);
Dump(diff);
return False;
}
}
return True;
}
#if defined(TEST_CLASS)
# include "unitvec.tcp"
#endif
+77
View File
@@ -0,0 +1,77 @@
//===========================================================================//
// File: unitvec.tst //
// Project: MUNGA Brick: Math Library //
// Contents: Implementation details for unit vector class //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(LINMTRX_HPP)
#include <linmtrx.hpp>
#endif
#if !defined(ROTATION_HPP)
#include<rotation.hpp>
#endif
//
//###########################################################################
//###########################################################################
//
Logical
UnitVector::TestClass()
{
DEBUG_STREAM << "Starting UnitVector test...\n";
UnitVector
b;
const UnitVector
c(0.6f,0.0f,0.8f);
UnitVector
d(0.8f,-0.6f,0.0f);
Test(c.x == 0.6f && c.y == 0.0f && c.z == 0.8f);
Test(c[2] == c.z);
b = c;
Test(b.x == c.x && b.y == c.y && b.z == c.z);
Test(Close_Enough(b,c));
Test(b == c);
b.Negate(c);
Test(b == UnitVector(-c.x,-c.y,-c.z));
Scalar f = c*d;
Test(Close_Enough(f,c.x*d.x + c.y*d.y + c.z*d.z));
LinearMatrix
m;
EulerAngles
r(PI_OVER_4,0.0f,0.0f);
m = r;
b.Multiply(c,m);
Test(b == UnitVector(c.x,c.y*m(1,1)+c.z*m(2,1),c.y*m(1,2)+c.z*m(2,2)));
b = c;
b *= m;
Test(b == UnitVector(c.x,c.y*m(1,1)+c.z*m(2,1),c.y*m(1,2)+c.z*m(2,2)));
f = c.LengthSquared();
Test(f == 1.0f);
f = c.Length();
Test(f == 1.0f);
Vector3D v(0.0f,1.2f,1.6f);
f = v.Length();
b = v;
Test(b == UnitVector(v.x/f, v.y/f, v.z/f));
return True;
}
+228
View File
@@ -0,0 +1,228 @@
//===========================================================================//
// File: vector4d.hh //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification for vector classes //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/19/94 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(VECTOR4D_HPP)
# define VECTOR4D_HPP
# if !defined(VECTOR3D_HPP)
# include <vector3d.hpp>
# endif
class Point3D;
class AffineMatrix;
class Matrix4x4;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Vector4D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Vector4D
{
public:
Scalar
x,
y,
z,
w;
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile Vector4D *);
#endif
static const Vector4D
Identity;
//
// Constructors
//
Vector4D()
{}
Vector4D(
Scalar X,
Scalar Y,
Scalar Z,
Scalar W)
{x=X; y=Y; z=Z; w=W;}
//
// Assignment operators
//
Vector4D&
operator=(const Vector4D &v);
Vector4D&
operator=(const Vector3D &v);
Vector4D&
operator=(const Point3D &p);
//
// Index operators
//
const Scalar&
operator[](size_t index) const
{Check_Pointer(this); Warn(index>W_Axis); return (&x)[index];}
Scalar&
operator[](size_t index)
{Check_Pointer(this); Warn(index>W_Axis); return (&x)[index];}
friend Logical
Small_Enough(const Vector4D &v,Scalar e=SMALL);
Logical
operator!() const
{return Small_Enough(*this);}
//
// "Close-enough" comparison operators
//
friend Logical
Close_Enough(
const Vector4D &v1,
const Vector4D &v2,
Scalar e=SMALL
);
Logical
operator==(const Vector4D& v) const
{return Close_Enough(*this,v);}
Logical
operator!=(const Vector4D& v) const
{return !Close_Enough(*this,v);}
//
// The following operators all assume that this points to the destination
// of the operation results
//
Vector4D&
Negate(const Vector4D &v);
Vector4D&
Add(
const Vector4D& v1,
const Vector4D& v2
);
Vector4D&
operator+=(const Vector4D& v)
{return Add(*this,v);}
Vector4D&
Subtract(
const Vector4D& v1,
const Vector4D& v2
);
Vector4D&
operator-=(const Vector4D& v)
{return Subtract(*this,v);}
Scalar
operator*(const Vector4D& v) const
{Check(this); return x*v.x + y*v.y + z*v.z + w*v.w;}
Vector4D&
Multiply(
const Vector4D& v,
Scalar scale
);
Vector4D&
operator*=(Scalar v)
{return Multiply(*this,v);}
Vector4D&
Multiply(
const Vector4D& v1,
const Vector4D& v2
);
Vector4D&
operator*=(const Vector4D &v)
{return Multiply(*this,v);}
Vector4D&
Divide(
const Vector4D& v,
Scalar scale
);
Vector4D&
operator/=(Scalar v)
{return Divide(*this,v);}
Vector4D&
Divide(
const Vector4D& v1,
const Vector4D& v2
);
Vector4D&
operator/=(const Vector4D &v)
{return Divide(*this,v);}
//
// Transforms
//
Vector4D&
Multiply(
const Vector4D &v,
const AffineMatrix &m
);
Vector4D&
operator*=(const AffineMatrix &M)
{Vector4D src(*this); return Multiply(src,M);}
Vector4D& Multiply(
const Vector4D &v,
const Matrix4x4 &m
);
Vector4D&
operator*=(const Matrix4x4 &m)
{Vector4D src(*this); return Multiply(src,m);}
Vector4D& Multiply(
const Vector3D &v,
const Matrix4x4 &m
);
Vector4D& Multiply(
const Point3D &p,
const Matrix4x4 &m
);
//
// Support functions
//
Scalar
LengthSquared() const
{return operator*(*this);}
Scalar
Length() const
{return Sqrt(LengthSquared());}
Vector4D&
Combine(
const Vector4D& v1,
Scalar t1,
const Vector4D& v2,
Scalar t2
);
Vector4D&
Lerp(
const Vector4D& v1,
const Vector4D& v2,
Scalar t
)
{return Combine(v1,1.0f-t,v2,t);}
friend ostream&
operator<<(
ostream& stream,
const Vector4D& v
);
Logical
TestInstance() const;
static Logical
TestClass();
};
#endif
+61
View File
@@ -0,0 +1,61 @@
//===========================================================================//
// File: verify.hpp //
// Contents: verification fail routines //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/29/94 JMA Initial coding. //
// 11/01/94 JMA Made compatible with SGI CC //
// 11/03/94 ECH Made compatible with BC4.0 //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(VERIFY_HPP)
# define VERIFY_HPP
# if defined(__BCPLUSPLUS__)
extern int
_matherr(struct exception *a);
# endif
extern int
Fpu_Ok();
extern void
Verify_Failed(char *message, char *file, int line);
extern void
Fail_To_Debugger(char *message, char *file, int line);
class Signature
{
private:
# if DEBUG_LEVEL>0
enum Mark
{
ok,
destroyed,
corrupted,
noMagic=(int)0xAB135795L,
magic=(int)0xFFED1231L
} mark;
# endif
protected:
Signature();
~Signature();
public:
friend int
Is_Signature_Bad(const volatile Signature *p);
};
# if defined(USE_SIGNATURE)
# define SIGNATURED : public Signature
# else
# define SIGNATURED
# define Is_Signature_Bad(p) (False)
# endif
#endif
+21
View File
@@ -0,0 +1,21 @@
//===========================================================================//
// File: vidrend.tst //
// Project: MUNGA Brick: Video Renderer Manager //
// Contents: Interface specification Video Renderer Manager //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 01/11/95 GAC Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
Logical
VideoRenderer::TestClass()
{
Tell("Starting VideoRenderer::TestClass\n");
return False;
}