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>
146 lines
3.2 KiB
C++
146 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "point3d.h"
|
|
|
|
class Origin;
|
|
class TransposedMatrix;
|
|
class Hinge;
|
|
class EulerAngles;
|
|
class Quaternion;
|
|
class YawPitchRoll;
|
|
|
|
class AffineMatrix
|
|
{
|
|
public:
|
|
static const AffineMatrix Identity;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int Is_Signature_Bad(const volatile AffineMatrix *);
|
|
#endif
|
|
|
|
Scalar entries[12];
|
|
|
|
//
|
|
// Constructors
|
|
//
|
|
AffineMatrix() {}
|
|
AffineMatrix& BuildIdentity();
|
|
AffineMatrix(int) { BuildIdentity(); }
|
|
|
|
//
|
|
// Assignment Operators
|
|
//
|
|
AffineMatrix& operator=(const AffineMatrix &m);
|
|
AffineMatrix& operator=(const Origin &p);
|
|
AffineMatrix& operator=(const Hinge &hinge);
|
|
AffineMatrix& operator=(const EulerAngles &angles);
|
|
AffineMatrix& operator=(const YawPitchRoll &angles);
|
|
AffineMatrix& operator=(const Quaternion &q);
|
|
AffineMatrix& operator=(const Point3D &p) { return SetFromAxis(W_Axis, p); }
|
|
AffineMatrix& operator=(const Matrix4x4 &m);
|
|
AffineMatrix& operator=(const TransposedMatrix &m);
|
|
|
|
//
|
|
// Comparison operators
|
|
//
|
|
Logical operator==(const AffineMatrix& m) const;
|
|
Logical operator!=(const AffineMatrix& m) const;
|
|
|
|
//
|
|
// Index operators
|
|
//
|
|
Scalar& operator()(size_t row, size_t column)
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(row>3);
|
|
Warn(column>2);
|
|
return entries[(column<<2)+row];
|
|
}
|
|
const Scalar& operator()(size_t row, size_t column) const
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(row>3);
|
|
Warn(column>2);
|
|
return entries[(column<<2)+row];
|
|
}
|
|
|
|
//
|
|
// Axis Manipulation functions
|
|
//
|
|
void GetFromAxis(size_t index, Vector3D *v) const;
|
|
void GetToAxis(size_t index, Vector3D *v) const;
|
|
|
|
AffineMatrix& SetFromAxis(size_t index, const Vector3D &v);
|
|
AffineMatrix& SetToAxis(size_t index, const Vector3D &v);
|
|
|
|
//
|
|
// Matrix Multiplication
|
|
//
|
|
AffineMatrix& Multiply(const AffineMatrix& m1, const AffineMatrix& m2);
|
|
AffineMatrix& operator*=(const AffineMatrix& m)
|
|
{
|
|
AffineMatrix temp(*this);
|
|
return Multiply(temp,m);
|
|
}
|
|
|
|
//
|
|
// Matrix Inversion
|
|
//
|
|
AffineMatrix& Invert(const AffineMatrix& Source);
|
|
AffineMatrix& Invert()
|
|
{
|
|
AffineMatrix src(*this);
|
|
return Invert(src);
|
|
}
|
|
|
|
//
|
|
// Scaling, Rotation and Translation
|
|
//
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Vector3D &v);
|
|
AffineMatrix& operator*=(const Vector3D &v)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,v);
|
|
}
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Quaternion &q);
|
|
AffineMatrix& operator*=(const Quaternion &q)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,q);
|
|
}
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Point3D &p);
|
|
AffineMatrix& operator*=(const Point3D& p)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,p);
|
|
}
|
|
|
|
//
|
|
// Miscellaneous Functions
|
|
//
|
|
Scalar Determinant() const;
|
|
AffineMatrix& Solve();
|
|
|
|
//
|
|
// Support functions
|
|
//
|
|
friend std::ostream& operator <<(std::ostream& stream, const AffineMatrix& m);
|
|
Logical TestInstance() const;
|
|
static Logical TestClass();
|
|
};
|
|
|
|
inline Point3D& Point3D::operator=(const AffineMatrix& m)
|
|
{
|
|
m.GetFromAxis(W_Axis,this);
|
|
return *this;
|
|
}
|
|
|
|
inline MemoryStream& MemoryStream_Read(MemoryStream *stream, AffineMatrix *output)
|
|
{
|
|
return stream->ReadBytes(output, sizeof(*output));
|
|
}
|
|
inline MemoryStream& MemoryStream_Write(MemoryStream *stream, const AffineMatrix *input)
|
|
{
|
|
return stream->WriteBytes(input, sizeof(*input));
|
|
}
|