Skip to content
Permalink
Browse files
Improved peds shadow code (still needs cleaning up)
git-svn-id: svn://localhost/vcspc/trunk@36 9f344024-d43e-4b27-bde7-3d027e20192d
  • Loading branch information
silent committed Mar 3, 2014
1 parent 3402a2b commit b30a4bbc31fcb23d41dcc52d1a9328676c89e682
@@ -291,12 +291,23 @@ void CFileLoader::LoadLevels()

//DumpVehicleAudioSettings();

auto* pStorage = CModelInfo::GetDrawDistanceStorage();

pStorage->Init();
for ( int i = 0; i < 20000; ++i )
{
if ( CModelInfo::ms_modelInfoPtrs[i] )
{
CModelInfo::ms_modelInfoPtrs[i]->ConvertAnimFileIndex();

unsigned char nModelType = CModelInfo::ms_modelInfoPtrs[i]->GetModelType();
if ( nModelType == 1 || nModelType == 3 || nModelType == 5 || nModelType == 8 )
pStorage->AddToList(i, CModelInfo::ms_modelInfoPtrs[i]);
}
}

pStorage->Shrink();

// IPL
for ( auto it = m_pScenesList->cbegin(); it != m_pScenesList->cend(); it++ )
{
@@ -35,86 +35,4 @@ bool& CGame::bMissionPackGame = *(bool*)0xB72910;
RwMatrixUpdate(pMatrix);
}
}*/

void CMatrix::SetRotateXOnly(float fAngle)
{
matrix.right.x = 1.0f;
matrix.right.y = 0.0f;
matrix.right.z = 0.0f;

matrix.up.x = 0.0f;
matrix.up.y = cos(fAngle);
matrix.up.z = sin(fAngle);

matrix.at.x = 0.0f;
matrix.at.y = -sin(fAngle);
matrix.at.z = cos(fAngle);
}

void CMatrix::SetRotateYOnly(float fAngle)
{
matrix.right.x = cos(fAngle);
matrix.right.y = 0.0f;
matrix.right.z = sin(fAngle);

matrix.up.x = 0.0f;
matrix.up.y = 1.0f;
matrix.up.z = 0.0f;

matrix.at.x = -sin(fAngle);
matrix.at.y = 0.0f;
matrix.at.z = cos(fAngle);
}

void CMatrix::SetRotateZOnly(float fAngle)
{
matrix.at.x = 0.0f;
matrix.at.y = 0.0f;
matrix.at.z = 1.0f;

matrix.up.x = -sin(fAngle);
matrix.up.y = cos(fAngle);
matrix.up.z = 0.0f;

matrix.right.x = cos(fAngle);
matrix.right.y = sin(fAngle);
matrix.right.z = 0.0f;
}

void CMatrix::SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ)
{
matrix.right.x = cos(fAngleZ) * cos(fAngleY) - sin(fAngleZ) * sin(fAngleX) * sin(fAngleY);
matrix.right.y = cos(fAngleZ) * sin(fAngleX) * sin(fAngleY) + sin(fAngleZ) * cos(fAngleY);
matrix.right.z = -cos(fAngleX) * sin(fAngleY);

matrix.up.x = -sin(fAngleZ) * cos(fAngleX);
matrix.up.y = cos(fAngleZ) * cos(fAngleX);
matrix.up.z = sin(fAngleX);

matrix.at.x = sin(fAngleZ) * sin(fAngleX) * cos(fAngleY) + cos(fAngleZ) * sin(fAngleY);
matrix.at.y = sin(fAngleZ) * sin(fAngleY) - cos(fAngleZ) * sin(fAngleX) * cos(fAngleY);
matrix.at.z = cos(fAngleX) * cos(fAngleY);
}

void CMatrix::RotateX(float fAngle)
{
CMatrix RotationMatrix;
RotationMatrix.SetRotateX(fAngle);
*this = *this * RotationMatrix;
}

void CMatrix::RotateY(float fAngle)
{
CMatrix RotationMatrix;
RotationMatrix.SetRotateY(fAngle);

*this = *this * RotationMatrix;
}

void CMatrix::RotateZ(float fAngle)
{
CMatrix RotationMatrix;
RotationMatrix.SetRotateZ(fAngle);
*this = *this * RotationMatrix;
}
}*/
@@ -3,148 +3,8 @@

#include "..\common\Date.h"

#define RAD_TO_DEG (180.0/M_PI)
#define DEG_TO_RAD (M_PI/180.0)

#define FUNC_CEntity__GetBoundCentre 0x534250

class CVector
{
public:
float x, y, z;

CVector()
{}

CVector(float fX, float fY, float fZ=0.0f)
: x(fX), y(fY), z(fZ)
{}

CVector(const RwV3d& rwVec)
: x(rwVec.x), y(rwVec.y), z(rwVec.z)
{}

CVector& operator+=(const CVector& vec)
{ x += vec.x; y += vec.y; z += vec.z;
return *this; }

inline float Magnitude()
{ return sqrt(x * x + y * y + z * z); }
inline CVector& Normalize()
{ float fInvLen = 1.0f / Magnitude(); x *= fInvLen; y *= fInvLen; z *= fInvLen; return *this; }

friend inline float DotProduct(const CVector& vec1, const CVector& vec2)
{ return vec1.x * vec2.x + vec1.x * vec2.y + vec1.z * vec2.z; }

friend inline CVector operator*(const CVector& in, float fMul)
{ return CVector(in.x * fMul, in.y * fMul, in.z * fMul); }
friend inline CVector operator+(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); }
friend inline CVector operator-(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); }
friend inline CVector operator-(const CVector& vec)
{ return CVector(-vec.x, -vec.y, -vec.z); }
};

class CVector2D
{
public:
float x, y;

CVector2D()
{}

CVector2D(float fX, float fY)
: x(fX), y(fY)
{}
};

class CMatrix
{
public:
RwMatrix matrix;
RwMatrix* pMatrix;
BOOL haveRwMatrix;

public:
CMatrix()
: pMatrix(nullptr), haveRwMatrix(FALSE)
{}

CMatrix(RwMatrix* rwMatrix, bool bAttach=false)
: matrix(*rwMatrix), haveRwMatrix(bAttach), pMatrix(bAttach ? rwMatrix : nullptr)
{}

CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos)
{
matrix.right.x = vecRight.x;
matrix.right.y = vecRight.y;
matrix.right.z = vecRight.z;

matrix.up.x = vecUp.x;
matrix.up.y = vecUp.y;
matrix.up.z = vecUp.z;

matrix.at.x = vecAt.x;
matrix.at.y = vecAt.y;
matrix.at.z = vecAt.z;

matrix.pos.x = vecPos.x;
matrix.pos.y = vecPos.y;
matrix.pos.z = vecPos.z;
}

friend inline CMatrix operator*(const CMatrix& Rot1, const CMatrix& Rot2)
{ return CMatrix( CVector(Rot1.matrix.right.x * Rot2.matrix.right.x + Rot1.matrix.right.y * Rot2.matrix.up.x + Rot1.matrix.right.z * Rot2.matrix.at.x + Rot2.matrix.pos.x,
Rot1.matrix.right.x * Rot2.matrix.right.y + Rot1.matrix.right.y * Rot2.matrix.up.y + Rot1.matrix.right.z * Rot2.matrix.at.y + Rot2.matrix.pos.y,
Rot1.matrix.right.x * Rot2.matrix.right.z + Rot1.matrix.right.y * Rot2.matrix.up.z + Rot1.matrix.right.z * Rot2.matrix.at.z + Rot2.matrix.pos.z),
CVector(Rot1.matrix.up.x * Rot2.matrix.right.x + Rot1.matrix.up.y * Rot2.matrix.up.x + Rot1.matrix.up.z * Rot2.matrix.at.x + Rot2.matrix.pos.x,
Rot1.matrix.up.x * Rot2.matrix.right.y + Rot1.matrix.up.y * Rot2.matrix.up.y + Rot1.matrix.up.z * Rot2.matrix.at.y + Rot2.matrix.pos.y,
Rot1.matrix.up.x * Rot2.matrix.right.z + Rot1.matrix.up.y * Rot2.matrix.up.z + Rot1.matrix.up.z * Rot2.matrix.at.z + Rot2.matrix.pos.z),
CVector(Rot1.matrix.at.x * Rot2.matrix.right.x + Rot1.matrix.at.y * Rot2.matrix.up.x + Rot1.matrix.at.z * Rot2.matrix.at.x + Rot2.matrix.pos.x,
Rot1.matrix.at.x * Rot2.matrix.right.y + Rot1.matrix.at.y * Rot2.matrix.up.y + Rot1.matrix.at.z * Rot2.matrix.at.y + Rot2.matrix.pos.y,
Rot1.matrix.at.x * Rot2.matrix.right.z + Rot1.matrix.at.y * Rot2.matrix.up.z + Rot1.matrix.at.z * Rot2.matrix.at.z + Rot2.matrix.pos.z),
CVector(Rot1.matrix.pos.x * Rot2.matrix.right.x + Rot1.matrix.pos.y * Rot2.matrix.up.x + Rot1.matrix.pos.z * Rot2.matrix.at.x + Rot2.matrix.pos.x,
Rot1.matrix.pos.x * Rot2.matrix.right.y + Rot1.matrix.pos.y * Rot2.matrix.up.y + Rot1.matrix.pos.z * Rot2.matrix.at.y + Rot2.matrix.pos.y,
Rot1.matrix.pos.x * Rot2.matrix.right.z + Rot1.matrix.pos.y * Rot2.matrix.up.z + Rot1.matrix.pos.z * Rot2.matrix.at.z + Rot2.matrix.pos.z)); };

friend inline CVector operator*(const CMatrix& matrix, const CVector& vec)
{ return CVector(matrix.matrix.up.x * vec.y + matrix.matrix.right.x * vec.x + matrix.matrix.at.x * vec.z + matrix.matrix.pos.x,
matrix.matrix.up.y * vec.y + matrix.matrix.right.y * vec.x + matrix.matrix.at.y * vec.z + matrix.matrix.pos.y,
matrix.matrix.up.z * vec.y + matrix.matrix.right.z * vec.x + matrix.matrix.at.z * vec.z + matrix.matrix.pos.z); };

inline CVector* GetRight()
{ return reinterpret_cast<CVector*>(&matrix.right); }
inline CVector* GetUp()
{ return reinterpret_cast<CVector*>(&matrix.up); }
inline CVector* GetAt()
{ return reinterpret_cast<CVector*>(&matrix.at); }
inline CVector* GetPos()
{ return reinterpret_cast<CVector*>(&matrix.pos); }

inline void SetTranslateOnly(float fX, float fY, float fZ)
{ matrix.pos.x = fX; matrix.pos.y = fY; matrix.pos.z = fZ; }

inline void SetRotateX(float fAngle)
{ SetRotateXOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; }

inline void SetRotateY(float fAngle)
{ SetRotateYOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; }

inline void SetRotateZ(float fAngle)
{ SetRotateZOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; }

void SetRotateXOnly(float fAngle);
void SetRotateYOnly(float fAngle);
void SetRotateZOnly(float fAngle);

void RotateX(float fAngle);
void RotateY(float fAngle);
void RotateZ(float fAngle);

void SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ);
};

class CSimpleTransform
{
public:
BIN +224 Bytes (100%) VCS PC/Hud.cpp
Binary file not shown.
@@ -0,0 +1,13 @@
#include "StdAfx.h"
#include "Maths.h"

void CMatrix::SetRotateXOnly(float fAngle)


void CMatrix::SetRotateYOnly(float fAngle)


void CMatrix::SetRotateZOnly(float fAngle)


void CMatrix::SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ)

0 comments on commit b30a4bb

Please sign in to comment.