Initial import of Red Planet v4.10 Win32 source
Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,326 @@
|
||||
#pragma hdrstop
|
||||
#include <iomanip>
|
||||
#include "vector3d.h"
|
||||
#include "linmtrx.h"
|
||||
#include "cstr.h"
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AbstractVector3D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
int
|
||||
Is_Signature_Bad(const volatile AbstractVector3D *)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
AbstractVector3D& AbstractVector3D::operator=(const AbstractVector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.y;
|
||||
z = vector.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Logical Small_Enough(const AbstractVector3D &V, Scalar e)
|
||||
{
|
||||
return Small_Enough(V.x,e) && Small_Enough(V.y,e) && Small_Enough(V.z,e);
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Logical Close_Enough(const AbstractVector3D &V1, const AbstractVector3D &V2, Scalar e)
|
||||
{
|
||||
return Close_Enough(V1.x,V2.x,e) && Close_Enough(V1.y,V2.y,e) && Close_Enough(V1.z,V2.z,e);
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Logical AbstractVector3D::TestInstance() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Vector3D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const Vector3D Vector3D::Identity(0.0f, 0.0f, 0.0f);
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
inline Vector3D& Vector3D::operator = (const LBE3Vector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.z;
|
||||
z = vector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
inline Vector3D& Vector3D::operator = (const TIVector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.y;
|
||||
z = -vector.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Negate(const Vector3D &V)
|
||||
{
|
||||
x = -V.x;
|
||||
y = -V.y;
|
||||
z = -V.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Add(const Vector3D& V1, const Vector3D& V2)
|
||||
{
|
||||
x = V1.x + V2.x;
|
||||
y = V1.y + V2.y;
|
||||
z = V1.z + V2.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::AddScaled(const Vector3D& V1, const Vector3D& V2, Scalar scale)
|
||||
{
|
||||
x = V1.x + V2.x*scale;
|
||||
y = V1.y + V2.y*scale;
|
||||
z = V1.z + V2.z*scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Subtract(const Vector3D& V1, const Vector3D& V2)
|
||||
{
|
||||
x = V1.x - V2.x;
|
||||
y = V1.y - V2.y;
|
||||
z = V1.z - V2.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Cross(const Vector3D& v1, const Vector3D& v2)
|
||||
{
|
||||
Verify(this != &v1);
|
||||
Verify(this != &v2);
|
||||
|
||||
x = v1.y * v2.z - v1.z * v2.y;
|
||||
y = v1.z * v2.x - v1.x * v2.z;
|
||||
z = v1.x * v2.y - v1.y * v2.x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Multiply(const Vector3D& V, Scalar Scale)
|
||||
{
|
||||
x = V.x * Scale;
|
||||
y = V.y * Scale;
|
||||
z = V.z * Scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Multiply(const Vector3D& V1, const Vector3D& V2)
|
||||
{
|
||||
x = V1.x * V2.x;
|
||||
y = V1.y * V2.y;
|
||||
z = V1.z * V2.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Divide(const Vector3D& V, Scalar Scale)
|
||||
{
|
||||
Verify(!Small_Enough(Scale));
|
||||
x = V.x / Scale;
|
||||
y = V.y / Scale;
|
||||
z = V.z / Scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Divide(const Vector3D& V1, const Vector3D& V2)
|
||||
{
|
||||
Verify(!Small_Enough(V2.x));
|
||||
Verify(!Small_Enough(V2.y));
|
||||
Verify(!Small_Enough(V2.z));
|
||||
x = V1.x / V2.x;
|
||||
y = V1.y / V2.y;
|
||||
z = V1.z / V2.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Multiply(const Vector3D& v, const AffineMatrix& m)
|
||||
{
|
||||
Verify(this != &v);
|
||||
|
||||
x = v.x * m(0,0) + v.y * m(1,0) + v.z * m(2,0);
|
||||
y = v.x * m(0,1) + v.y * m(1,1) + v.z * m(2,1);
|
||||
z = v.x * m(0,2) + v.y * m(1,2) + v.z * m(2,2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::MultiplyByInverse(const Vector3D& v, const LinearMatrix& m)
|
||||
{
|
||||
Verify(this != &v);
|
||||
|
||||
x = v.x * m(0,0) + v.y * m(0,1) + v.z * m(0,2);
|
||||
y = v.x * m(1,0) + v.y * m(1,1) + v.z * m(1,2);
|
||||
z = v.x * m(2,0) + v.y * m(2,1) + v.z * m(2,2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Normalize(const Vector3D &V)
|
||||
{
|
||||
Scalar len = V.Length();
|
||||
Verify(len);
|
||||
|
||||
x = V.x / len;
|
||||
y = V.y / len;
|
||||
z = V.z / len;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
Vector3D& Vector3D::Combine(const Vector3D& V1, Scalar t1, const Vector3D& V2, Scalar t2)
|
||||
{
|
||||
x = t1 * V1.x + t2 * V2.x;
|
||||
y = t1 * V1.y + t2 * V2.y;
|
||||
z = t1 * V1.z + t2 * V2.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
std::ostream& operator<<(std::ostream& Stream, const Vector3D& V)
|
||||
{
|
||||
return Stream << std::setprecision(4) << '<' << V.x << ',' << V.y << ',' << V.z << '>';
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~ Vector3D functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
void Convert_From_Ascii(const char *str, Vector3D *vector_3D)
|
||||
{
|
||||
Check_Signature(vector_3D);
|
||||
|
||||
CString parse_string(str);
|
||||
|
||||
vector_3D->x = atof(parse_string.GetNthToken(0));
|
||||
vector_3D->y = atof(parse_string.GetNthToken(1));
|
||||
vector_3D->z = atof(parse_string.GetNthToken(2));
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
LBE3Vector3D& LBE3Vector3D::operator=(const Vector3D& vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.z;
|
||||
z = vector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
LBE3Vector3D& LBE3Vector3D::operator=(const TIVector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = -vector.z;
|
||||
z = vector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
TIVector3D& TIVector3D::operator=(const Vector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.y;
|
||||
z = -vector.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//###########################################################################
|
||||
//###########################################################################
|
||||
//
|
||||
TIVector3D& TIVector3D::operator=(const LBE3Vector3D &vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.z;
|
||||
z = -vector.y;
|
||||
return *this;
|
||||
}
|
||||
Reference in New Issue
Block a user