mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-12-23 08:11:49 +01:00
Get rid of RwMatrix in CMatrix
This commit is contained in:
parent
da29203219
commit
91093305d6
@ -305,7 +305,7 @@ void CReplay::RecordThisFrame(void)
|
|||||||
#endif
|
#endif
|
||||||
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
|
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
general->type = REPLAYPACKET_GENERAL;
|
general->type = REPLAYPACKET_GENERAL;
|
||||||
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
general->camera_pos.CopyOnlyMatrix(TheCamera.GetMatrix());
|
||||||
general->player_pos = FindPlayerCoors();
|
general->player_pos = FindPlayerCoors();
|
||||||
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
|
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
|
||||||
Record.m_nOffset += sizeof(*general);
|
Record.m_nOffset += sizeof(*general);
|
||||||
|
@ -3629,9 +3629,17 @@ CCamera::CalculateDerivedValues(void)
|
|||||||
bool
|
bool
|
||||||
CCamera::IsPointVisible(const CVector ¢er, const CMatrix *mat)
|
CCamera::IsPointVisible(const CVector ¢er, const CMatrix *mat)
|
||||||
{
|
{
|
||||||
RwV3d c;
|
#ifdef GTA_PS2
|
||||||
c = center;
|
CVuVector c;
|
||||||
RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
|
TransformPoint(c, *mat, center);
|
||||||
|
#else
|
||||||
|
CVector c = center;
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
c = *mat * center;
|
||||||
|
#else
|
||||||
|
RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
if(c.y < CDraw::GetNearClipZ()) return false;
|
if(c.y < CDraw::GetNearClipZ()) return false;
|
||||||
if(c.y > CDraw::GetFarClipZ()) return false;
|
if(c.y > CDraw::GetFarClipZ()) return false;
|
||||||
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > 0.0f) return false;
|
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > 0.0f) return false;
|
||||||
@ -3644,9 +3652,17 @@ CCamera::IsPointVisible(const CVector ¢er, const CMatrix *mat)
|
|||||||
bool
|
bool
|
||||||
CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat)
|
CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat)
|
||||||
{
|
{
|
||||||
RwV3d c;
|
#ifdef GTA_PS2
|
||||||
c = center;
|
CVuVector c;
|
||||||
RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
|
TransformPoint(c, *mat, center);
|
||||||
|
#else
|
||||||
|
CVector c = center;
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
c = *mat * center;
|
||||||
|
#else
|
||||||
|
RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
if(c.y + radius < CDraw::GetNearClipZ()) return false;
|
if(c.y + radius < CDraw::GetNearClipZ()) return false;
|
||||||
if(c.y - radius > CDraw::GetFarClipZ()) return false;
|
if(c.y - radius > CDraw::GetFarClipZ()) return false;
|
||||||
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > radius) return false;
|
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > radius) return false;
|
||||||
@ -3664,11 +3680,24 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CCamera::IsBoxVisible(RwV3d *box, const CMatrix *mat)
|
#ifdef GTA_PS2
|
||||||
|
CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat)
|
||||||
|
#else
|
||||||
|
CCamera::IsBoxVisible(CVector *box, const CMatrix *mat)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int frustumTests[6] = { 0 };
|
int frustumTests[6] = { 0 };
|
||||||
RwV3dTransformPoints(box, box, 8, &mat->m_matrix);
|
#ifdef GTA_PS2
|
||||||
|
TransformPoints(box, 8, *mat, box);
|
||||||
|
#else
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
box[i] = *mat * box[i];
|
||||||
|
#else
|
||||||
|
RwV3dTransformPoints(box, box, 8, (RwMatrix*)mat);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
for(i = 0; i < 8; i++){
|
for(i = 0; i < 8; i++){
|
||||||
if(box[i].y < CDraw::GetNearClipZ()) frustumTests[0]++;
|
if(box[i].y < CDraw::GetNearClipZ()) frustumTests[0]++;
|
||||||
|
@ -641,7 +641,11 @@ public:
|
|||||||
bool IsPointVisible(const CVector ¢er, const CMatrix *mat);
|
bool IsPointVisible(const CVector ¢er, const CMatrix *mat);
|
||||||
bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat);
|
bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat);
|
||||||
bool IsSphereVisible(const CVector ¢er, float radius);
|
bool IsSphereVisible(const CVector ¢er, float radius);
|
||||||
bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
|
#ifdef GTA_PS2
|
||||||
|
bool IsBoxVisible(CVuVector *box, const CMatrix *mat);
|
||||||
|
#else
|
||||||
|
bool IsBoxVisible(CVector *box, const CMatrix *mat);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
VALIDATE_SIZE(CCamera, 0xE9D8);
|
VALIDATE_SIZE(CCamera, 0xE9D8);
|
||||||
|
@ -407,7 +407,11 @@ CEntity::GetIsOnScreen(void)
|
|||||||
bool
|
bool
|
||||||
CEntity::GetIsOnScreenComplex(void)
|
CEntity::GetIsOnScreenComplex(void)
|
||||||
{
|
{
|
||||||
RwV3d boundBox[8];
|
#ifdef GTA_PS2
|
||||||
|
CVuVector boundBox[8];
|
||||||
|
#else
|
||||||
|
CVector boundBox[8];
|
||||||
|
#endif
|
||||||
|
|
||||||
if(TheCamera.IsPointVisible(GetBoundCentre(), &TheCamera.GetCameraMatrix()))
|
if(TheCamera.IsPointVisible(GetBoundCentre(), &TheCamera.GetCameraMatrix()))
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,14 +60,20 @@ CMatrix::Detach(void)
|
|||||||
void
|
void
|
||||||
CMatrix::Update(void)
|
CMatrix::Update(void)
|
||||||
{
|
{
|
||||||
m_matrix = *m_attachment;
|
right = m_attachment->right;
|
||||||
|
forward = m_attachment->up;
|
||||||
|
up = m_attachment->at;
|
||||||
|
pos = m_attachment->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::UpdateRW(void)
|
CMatrix::UpdateRW(void)
|
||||||
{
|
{
|
||||||
if (m_attachment) {
|
if (m_attachment) {
|
||||||
*m_attachment = m_matrix;
|
m_attachment->right = right;
|
||||||
|
m_attachment->up = forward;
|
||||||
|
m_attachment->at = up;
|
||||||
|
m_attachment->pos = pos;
|
||||||
RwMatrixUpdate(m_attachment);
|
RwMatrixUpdate(m_attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,104 +81,96 @@ CMatrix::UpdateRW(void)
|
|||||||
void
|
void
|
||||||
CMatrix::operator=(CMatrix const &rhs)
|
CMatrix::operator=(CMatrix const &rhs)
|
||||||
{
|
{
|
||||||
m_matrix = rhs.m_matrix;
|
memcpy(this, &rhs, sizeof(f));
|
||||||
if (m_attachment)
|
if (m_attachment)
|
||||||
UpdateRW();
|
UpdateRW();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::CopyOnlyMatrix(CMatrix *other)
|
CMatrix::CopyOnlyMatrix(const CMatrix &other)
|
||||||
{
|
{
|
||||||
m_matrix = other->m_matrix;
|
memcpy(this, &other, sizeof(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
CMatrix &
|
CMatrix &
|
||||||
CMatrix::operator+=(CMatrix const &rhs)
|
CMatrix::operator+=(CMatrix const &rhs)
|
||||||
{
|
{
|
||||||
m_matrix.right.x += rhs.m_matrix.right.x;
|
right += rhs.right;
|
||||||
m_matrix.up.x += rhs.m_matrix.up.x;
|
forward += rhs.forward;
|
||||||
m_matrix.at.x += rhs.m_matrix.at.x;
|
up += rhs.up;
|
||||||
m_matrix.right.y += rhs.m_matrix.right.y;
|
pos += rhs.pos;
|
||||||
m_matrix.up.y += rhs.m_matrix.up.y;
|
|
||||||
m_matrix.at.y += rhs.m_matrix.at.y;
|
|
||||||
m_matrix.right.z += rhs.m_matrix.right.z;
|
|
||||||
m_matrix.up.z += rhs.m_matrix.up.z;
|
|
||||||
m_matrix.at.z += rhs.m_matrix.at.z;
|
|
||||||
m_matrix.pos.x += rhs.m_matrix.pos.x;
|
|
||||||
m_matrix.pos.y += rhs.m_matrix.pos.y;
|
|
||||||
m_matrix.pos.z += rhs.m_matrix.pos.z;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetUnity(void)
|
CMatrix::SetUnity(void)
|
||||||
{
|
{
|
||||||
m_matrix.right.x = 1.0f;
|
right.x = 1.0f;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = 1.0f;
|
forward.y = 1.0f;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = 1.0f;
|
up.z = 1.0f;
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::ResetOrientation(void)
|
CMatrix::ResetOrientation(void)
|
||||||
{
|
{
|
||||||
m_matrix.right.x = 1.0f;
|
right.x = 1.0f;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = 1.0f;
|
forward.y = 1.0f;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = 1.0f;
|
up.z = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetScale(float s)
|
CMatrix::SetScale(float s)
|
||||||
{
|
{
|
||||||
m_matrix.right.x = s;
|
right.x = s;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = s;
|
forward.y = s;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = s;
|
up.z = s;
|
||||||
|
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetTranslate(float x, float y, float z)
|
CMatrix::SetTranslate(float x, float y, float z)
|
||||||
{
|
{
|
||||||
m_matrix.right.x = 1.0f;
|
right.x = 1.0f;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = 1.0f;
|
forward.y = 1.0f;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = 1.0f;
|
up.z = 1.0f;
|
||||||
|
|
||||||
m_matrix.pos.x = x;
|
pos.x = x;
|
||||||
m_matrix.pos.y = y;
|
pos.y = y;
|
||||||
m_matrix.pos.z = z;
|
pos.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -181,17 +179,17 @@ CMatrix::SetRotateXOnly(float angle)
|
|||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = 1.0f;
|
right.x = 1.0f;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = c;
|
forward.y = c;
|
||||||
m_matrix.up.z = s;
|
forward.z = s;
|
||||||
|
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = -s;
|
up.y = -s;
|
||||||
m_matrix.at.z = c;
|
up.z = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -200,17 +198,17 @@ CMatrix::SetRotateYOnly(float angle)
|
|||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = c;
|
right.x = c;
|
||||||
m_matrix.right.y = 0.0f;
|
right.y = 0.0f;
|
||||||
m_matrix.right.z = -s;
|
right.z = -s;
|
||||||
|
|
||||||
m_matrix.up.x = 0.0f;
|
forward.x = 0.0f;
|
||||||
m_matrix.up.y = 1.0f;
|
forward.y = 1.0f;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.at.x = s;
|
up.x = s;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = c;
|
up.z = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -219,26 +217,26 @@ CMatrix::SetRotateZOnly(float angle)
|
|||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = c;
|
right.x = c;
|
||||||
m_matrix.right.y = s;
|
right.y = s;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.up.x = -s;
|
forward.x = -s;
|
||||||
m_matrix.up.y = c;
|
forward.y = c;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = 1.0f;
|
up.z = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetRotateX(float angle)
|
CMatrix::SetRotateX(float angle)
|
||||||
{
|
{
|
||||||
SetRotateXOnly(angle);
|
SetRotateXOnly(angle);
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,18 +244,18 @@ void
|
|||||||
CMatrix::SetRotateY(float angle)
|
CMatrix::SetRotateY(float angle)
|
||||||
{
|
{
|
||||||
SetRotateYOnly(angle);
|
SetRotateYOnly(angle);
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetRotateZ(float angle)
|
CMatrix::SetRotateZ(float angle)
|
||||||
{
|
{
|
||||||
SetRotateZOnly(angle);
|
SetRotateZOnly(angle);
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -270,21 +268,21 @@ CMatrix::SetRotate(float xAngle, float yAngle, float zAngle)
|
|||||||
float cZ = Cos(zAngle);
|
float cZ = Cos(zAngle);
|
||||||
float sZ = Sin(zAngle);
|
float sZ = Sin(zAngle);
|
||||||
|
|
||||||
m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
|
right.x = cZ * cY - (sZ * sX) * sY;
|
||||||
m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
|
right.y = (cZ * sX) * sY + sZ * cY;
|
||||||
m_matrix.right.z = -cX * sY;
|
right.z = -cX * sY;
|
||||||
|
|
||||||
m_matrix.up.x = -sZ * cX;
|
forward.x = -sZ * cX;
|
||||||
m_matrix.up.y = cZ * cX;
|
forward.y = cZ * cX;
|
||||||
m_matrix.up.z = sX;
|
forward.z = sX;
|
||||||
|
|
||||||
m_matrix.at.x = (sZ * sX) * cY + cZ * sY;
|
up.x = (sZ * sX) * cY + cZ * sY;
|
||||||
m_matrix.at.y = sZ * sY - (cZ * sX) * cY;
|
up.y = sZ * sY - (cZ * sX) * cY;
|
||||||
m_matrix.at.z = cX * cY;
|
up.z = cX * cY;
|
||||||
|
|
||||||
m_matrix.pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
m_matrix.pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
m_matrix.pos.z = 0.0f;
|
pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -293,23 +291,23 @@ CMatrix::RotateX(float x)
|
|||||||
float c = Cos(x);
|
float c = Cos(x);
|
||||||
float s = Sin(x);
|
float s = Sin(x);
|
||||||
|
|
||||||
float ry = m_matrix.right.y;
|
float ry = right.y;
|
||||||
float rz = m_matrix.right.z;
|
float rz = right.z;
|
||||||
float uy = m_matrix.up.y;
|
float uy = forward.y;
|
||||||
float uz = m_matrix.up.z;
|
float uz = forward.z;
|
||||||
float ay = m_matrix.at.y;
|
float ay = up.y;
|
||||||
float az = m_matrix.at.z;
|
float az = up.z;
|
||||||
float py = m_matrix.pos.y;
|
float py = pos.y;
|
||||||
float pz = m_matrix.pos.z;
|
float pz = pos.z;
|
||||||
|
|
||||||
m_matrix.right.y = c * ry - s * rz;
|
right.y = c * ry - s * rz;
|
||||||
m_matrix.right.z = c * rz + s * ry;
|
right.z = c * rz + s * ry;
|
||||||
m_matrix.up.y = c * uy - s * uz;
|
forward.y = c * uy - s * uz;
|
||||||
m_matrix.up.z = c * uz + s * uy;
|
forward.z = c * uz + s * uy;
|
||||||
m_matrix.at.y = c * ay - s * az;
|
up.y = c * ay - s * az;
|
||||||
m_matrix.at.z = c * az + s * ay;
|
up.z = c * az + s * ay;
|
||||||
m_matrix.pos.y = c * py - s * pz;
|
pos.y = c * py - s * pz;
|
||||||
m_matrix.pos.z = c * pz + s * py;
|
pos.z = c * pz + s * py;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -318,23 +316,23 @@ CMatrix::RotateY(float y)
|
|||||||
float c = Cos(y);
|
float c = Cos(y);
|
||||||
float s = Sin(y);
|
float s = Sin(y);
|
||||||
|
|
||||||
float rx = m_matrix.right.x;
|
float rx = right.x;
|
||||||
float rz = m_matrix.right.z;
|
float rz = right.z;
|
||||||
float ux = m_matrix.up.x;
|
float ux = forward.x;
|
||||||
float uz = m_matrix.up.z;
|
float uz = forward.z;
|
||||||
float ax = m_matrix.at.x;
|
float ax = up.x;
|
||||||
float az = m_matrix.at.z;
|
float az = up.z;
|
||||||
float px = m_matrix.pos.x;
|
float px = pos.x;
|
||||||
float pz = m_matrix.pos.z;
|
float pz = pos.z;
|
||||||
|
|
||||||
m_matrix.right.x = c * rx + s * rz;
|
right.x = c * rx + s * rz;
|
||||||
m_matrix.right.z = c * rz - s * rx;
|
right.z = c * rz - s * rx;
|
||||||
m_matrix.up.x = c * ux + s * uz;
|
forward.x = c * ux + s * uz;
|
||||||
m_matrix.up.z = c * uz - s * ux;
|
forward.z = c * uz - s * ux;
|
||||||
m_matrix.at.x = c * ax + s * az;
|
up.x = c * ax + s * az;
|
||||||
m_matrix.at.z = c * az - s * ax;
|
up.z = c * az - s * ax;
|
||||||
m_matrix.pos.x = c * px + s * pz;
|
pos.x = c * px + s * pz;
|
||||||
m_matrix.pos.z = c * pz - s * px;
|
pos.z = c * pz - s * px;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -343,23 +341,23 @@ CMatrix::RotateZ(float z)
|
|||||||
float c = Cos(z);
|
float c = Cos(z);
|
||||||
float s = Sin(z);
|
float s = Sin(z);
|
||||||
|
|
||||||
float ry = m_matrix.right.y;
|
float ry = right.y;
|
||||||
float rx = m_matrix.right.x;
|
float rx = right.x;
|
||||||
float uy = m_matrix.up.y;
|
float uy = forward.y;
|
||||||
float ux = m_matrix.up.x;
|
float ux = forward.x;
|
||||||
float ay = m_matrix.at.y;
|
float ay = up.y;
|
||||||
float ax = m_matrix.at.x;
|
float ax = up.x;
|
||||||
float py = m_matrix.pos.y;
|
float py = pos.y;
|
||||||
float px = m_matrix.pos.x;
|
float px = pos.x;
|
||||||
|
|
||||||
m_matrix.right.x = c * rx - s * ry;
|
right.x = c * rx - s * ry;
|
||||||
m_matrix.right.y = c * ry + s * rx;
|
right.y = c * ry + s * rx;
|
||||||
m_matrix.up.x = c * ux - s * uy;
|
forward.x = c * ux - s * uy;
|
||||||
m_matrix.up.y = c * uy + s * ux;
|
forward.y = c * uy + s * ux;
|
||||||
m_matrix.at.x = c * ax - s * ay;
|
up.x = c * ax - s * ay;
|
||||||
m_matrix.at.y = c * ay + s * ax;
|
up.y = c * ay + s * ax;
|
||||||
m_matrix.pos.x = c * px - s * py;
|
pos.x = c * px - s * py;
|
||||||
m_matrix.pos.y = c * py + s * px;
|
pos.y = c * py + s * px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,18 +371,18 @@ CMatrix::Rotate(float x, float y, float z)
|
|||||||
float cZ = Cos(z);
|
float cZ = Cos(z);
|
||||||
float sZ = Sin(z);
|
float sZ = Sin(z);
|
||||||
|
|
||||||
float rx = m_matrix.right.x;
|
float rx = right.x;
|
||||||
float ry = m_matrix.right.y;
|
float ry = right.y;
|
||||||
float rz = m_matrix.right.z;
|
float rz = right.z;
|
||||||
float ux = m_matrix.up.x;
|
float ux = forward.x;
|
||||||
float uy = m_matrix.up.y;
|
float uy = forward.y;
|
||||||
float uz = m_matrix.up.z;
|
float uz = forward.z;
|
||||||
float ax = m_matrix.at.x;
|
float ax = up.x;
|
||||||
float ay = m_matrix.at.y;
|
float ay = up.y;
|
||||||
float az = m_matrix.at.z;
|
float az = up.z;
|
||||||
float px = m_matrix.pos.x;
|
float px = pos.x;
|
||||||
float py = m_matrix.pos.y;
|
float py = pos.y;
|
||||||
float pz = m_matrix.pos.z;
|
float pz = pos.z;
|
||||||
|
|
||||||
float x1 = cZ * cY - (sZ * sX) * sY;
|
float x1 = cZ * cY - (sZ * sX) * sY;
|
||||||
float x2 = (cZ * sX) * sY + sZ * cY;
|
float x2 = (cZ * sX) * sY + sZ * cY;
|
||||||
@ -396,18 +394,18 @@ CMatrix::Rotate(float x, float y, float z)
|
|||||||
float z2 = sZ * sY - (cZ * sX) * cY;
|
float z2 = sZ * sY - (cZ * sX) * cY;
|
||||||
float z3 = cX * cY;
|
float z3 = cX * cY;
|
||||||
|
|
||||||
m_matrix.right.x = x1 * rx + y1 * ry + z1 * rz;
|
right.x = x1 * rx + y1 * ry + z1 * rz;
|
||||||
m_matrix.right.y = x2 * rx + y2 * ry + z2 * rz;
|
right.y = x2 * rx + y2 * ry + z2 * rz;
|
||||||
m_matrix.right.z = x3 * rx + y3 * ry + z3 * rz;
|
right.z = x3 * rx + y3 * ry + z3 * rz;
|
||||||
m_matrix.up.x = x1 * ux + y1 * uy + z1 * uz;
|
forward.x = x1 * ux + y1 * uy + z1 * uz;
|
||||||
m_matrix.up.y = x2 * ux + y2 * uy + z2 * uz;
|
forward.y = x2 * ux + y2 * uy + z2 * uz;
|
||||||
m_matrix.up.z = x3 * ux + y3 * uy + z3 * uz;
|
forward.z = x3 * ux + y3 * uy + z3 * uz;
|
||||||
m_matrix.at.x = x1 * ax + y1 * ay + z1 * az;
|
up.x = x1 * ax + y1 * ay + z1 * az;
|
||||||
m_matrix.at.y = x2 * ax + y2 * ay + z2 * az;
|
up.y = x2 * ax + y2 * ay + z2 * az;
|
||||||
m_matrix.at.z = x3 * ax + y3 * ay + z3 * az;
|
up.z = x3 * ax + y3 * ay + z3 * az;
|
||||||
m_matrix.pos.x = x1 * px + y1 * py + z1 * pz;
|
pos.x = x1 * px + y1 * py + z1 * pz;
|
||||||
m_matrix.pos.y = x2 * px + y2 * py + z2 * pz;
|
pos.y = x2 * px + y2 * py + z2 * pz;
|
||||||
m_matrix.pos.z = x3 * px + y3 * py + z3 * pz;
|
pos.z = x3 * px + y3 * py + z3 * pz;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMatrix &
|
CMatrix &
|
||||||
@ -436,21 +434,18 @@ operator*(const CMatrix &m1, const CMatrix &m2)
|
|||||||
{
|
{
|
||||||
// TODO: VU0 code
|
// TODO: VU0 code
|
||||||
CMatrix out;
|
CMatrix out;
|
||||||
RwMatrix *dst = &out.m_matrix;
|
out.right.x = m1.right.x * m2.right.x + m1.forward.x * m2.right.y + m1.up.x * m2.right.z;
|
||||||
const RwMatrix *src1 = &m1.m_matrix;
|
out.right.y = m1.right.y * m2.right.x + m1.forward.y * m2.right.y + m1.up.y * m2.right.z;
|
||||||
const RwMatrix *src2 = &m2.m_matrix;
|
out.right.z = m1.right.z * m2.right.x + m1.forward.z * m2.right.y + m1.up.z * m2.right.z;
|
||||||
dst->right.x = src1->right.x * src2->right.x + src1->up.x * src2->right.y + src1->at.x * src2->right.z;
|
out.forward.x = m1.right.x * m2.forward.x + m1.forward.x * m2.forward.y + m1.up.x * m2.forward.z;
|
||||||
dst->right.y = src1->right.y * src2->right.x + src1->up.y * src2->right.y + src1->at.y * src2->right.z;
|
out.forward.y = m1.right.y * m2.forward.x + m1.forward.y * m2.forward.y + m1.up.y * m2.forward.z;
|
||||||
dst->right.z = src1->right.z * src2->right.x + src1->up.z * src2->right.y + src1->at.z * src2->right.z;
|
out.forward.z = m1.right.z * m2.forward.x + m1.forward.z * m2.forward.y + m1.up.z * m2.forward.z;
|
||||||
dst->up.x = src1->right.x * src2->up.x + src1->up.x * src2->up.y + src1->at.x * src2->up.z;
|
out.up.x = m1.right.x * m2.up.x + m1.forward.x * m2.up.y + m1.up.x * m2.up.z;
|
||||||
dst->up.y = src1->right.y * src2->up.x + src1->up.y * src2->up.y + src1->at.y * src2->up.z;
|
out.up.y = m1.right.y * m2.up.x + m1.forward.y * m2.up.y + m1.up.y * m2.up.z;
|
||||||
dst->up.z = src1->right.z * src2->up.x + src1->up.z * src2->up.y + src1->at.z * src2->up.z;
|
out.up.z = m1.right.z * m2.up.x + m1.forward.z * m2.up.y + m1.up.z * m2.up.z;
|
||||||
dst->at.x = src1->right.x * src2->at.x + src1->up.x * src2->at.y + src1->at.x * src2->at.z;
|
out.pos.x = m1.right.x * m2.pos.x + m1.forward.x * m2.pos.y + m1.up.x * m2.pos.z + m1.pos.x;
|
||||||
dst->at.y = src1->right.y * src2->at.x + src1->up.y * src2->at.y + src1->at.y * src2->at.z;
|
out.pos.y = m1.right.y * m2.pos.x + m1.forward.y * m2.pos.y + m1.up.y * m2.pos.z + m1.pos.y;
|
||||||
dst->at.z = src1->right.z * src2->at.x + src1->up.z * src2->at.y + src1->at.z * src2->at.z;
|
out.pos.z = m1.right.z * m2.pos.x + m1.forward.z * m2.pos.y + m1.up.z * m2.pos.z + m1.pos.z;
|
||||||
dst->pos.x = src1->right.x * src2->pos.x + src1->up.x * src2->pos.y + src1->at.x * src2->pos.z + src1->pos.x;
|
|
||||||
dst->pos.y = src1->right.y * src2->pos.x + src1->up.y * src2->pos.y + src1->at.y * src2->pos.z + src1->pos.y;
|
|
||||||
dst->pos.z = src1->right.z * src2->pos.x + src1->up.z * src2->pos.y + src1->at.z * src2->pos.z + src1->pos.z;
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,59 +455,56 @@ Invert(const CMatrix &src, CMatrix &dst)
|
|||||||
// TODO: VU0 code
|
// TODO: VU0 code
|
||||||
// GTA handles this as a raw 4x4 orthonormal matrix
|
// GTA handles this as a raw 4x4 orthonormal matrix
|
||||||
// and trashes the RW flags, let's not do that
|
// and trashes the RW flags, let's not do that
|
||||||
float (*scr_fm)[4] = (float (*)[4])&src.m_matrix;
|
dst.f[3][0] = dst.f[3][1] = dst.f[3][2] = 0.0f;
|
||||||
float (*dst_fm)[4] = (float (*)[4])&dst.m_matrix;
|
|
||||||
|
|
||||||
dst_fm[3][0] = dst_fm[3][1] = dst_fm[3][2] = 0.0f;
|
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[3][3] = scr_fm[3][3];
|
dst.f[3][3] = src.f[3][3];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dst_fm[0][0] = scr_fm[0][0];
|
dst.f[0][0] = src.f[0][0];
|
||||||
dst_fm[0][1] = scr_fm[1][0];
|
dst.f[0][1] = src.f[1][0];
|
||||||
dst_fm[0][2] = scr_fm[2][0];
|
dst.f[0][2] = src.f[2][0];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[0][3] = scr_fm[3][0];
|
dst.f[0][3] = src.f[3][0];
|
||||||
#endif
|
#endif
|
||||||
dst_fm[1][0] = scr_fm[0][1];
|
dst.f[1][0] = src.f[0][1];
|
||||||
dst_fm[1][1] = scr_fm[1][1];
|
dst.f[1][1] = src.f[1][1];
|
||||||
dst_fm[1][2] = scr_fm[2][1];
|
dst.f[1][2] = src.f[2][1];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[1][3] = scr_fm[3][1];
|
dst.f[1][3] = src.f[3][1];
|
||||||
#endif
|
#endif
|
||||||
dst_fm[2][0] = scr_fm[0][2];
|
dst.f[2][0] = src.f[0][2];
|
||||||
dst_fm[2][1] = scr_fm[1][2];
|
dst.f[2][1] = src.f[1][2];
|
||||||
dst_fm[2][2] = scr_fm[2][2];
|
dst.f[2][2] = src.f[2][2];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[2][3] = scr_fm[3][2];
|
dst.f[2][3] = src.f[3][2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dst_fm[3][0] += dst_fm[0][0] * scr_fm[3][0];
|
dst.f[3][0] += dst.f[0][0] * src.f[3][0];
|
||||||
dst_fm[3][1] += dst_fm[0][1] * scr_fm[3][0];
|
dst.f[3][1] += dst.f[0][1] * src.f[3][0];
|
||||||
dst_fm[3][2] += dst_fm[0][2] * scr_fm[3][0];
|
dst.f[3][2] += dst.f[0][2] * src.f[3][0];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[3][3] += dst_fm[0][3] * scr_fm[3][0];
|
dst.f[3][3] += dst.f[0][3] * src.f[3][0];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dst_fm[3][0] += dst_fm[1][0] * scr_fm[3][1];
|
dst.f[3][0] += dst.f[1][0] * src.f[3][1];
|
||||||
dst_fm[3][1] += dst_fm[1][1] * scr_fm[3][1];
|
dst.f[3][1] += dst.f[1][1] * src.f[3][1];
|
||||||
dst_fm[3][2] += dst_fm[1][2] * scr_fm[3][1];
|
dst.f[3][2] += dst.f[1][2] * src.f[3][1];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[3][3] += dst_fm[1][3] * scr_fm[3][1];
|
dst.f[3][3] += dst.f[1][3] * src.f[3][1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dst_fm[3][0] += dst_fm[2][0] * scr_fm[3][2];
|
dst.f[3][0] += dst.f[2][0] * src.f[3][2];
|
||||||
dst_fm[3][1] += dst_fm[2][1] * scr_fm[3][2];
|
dst.f[3][1] += dst.f[2][1] * src.f[3][2];
|
||||||
dst_fm[3][2] += dst_fm[2][2] * scr_fm[3][2];
|
dst.f[3][2] += dst.f[2][2] * src.f[3][2];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[3][3] += dst_fm[2][3] * scr_fm[3][2];
|
dst.f[3][3] += dst.f[2][3] * src.f[3][2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dst_fm[3][0] = -dst_fm[3][0];
|
dst.f[3][0] = -dst.f[3][0];
|
||||||
dst_fm[3][1] = -dst_fm[3][1];
|
dst.f[3][1] = -dst.f[3][1];
|
||||||
dst_fm[3][2] = -dst_fm[3][2];
|
dst.f[3][2] = -dst.f[3][2];
|
||||||
#ifndef FIX_BUGS
|
#ifndef FIX_BUGS
|
||||||
dst_fm[3][3] = scr_fm[3][3] - dst_fm[3][3];
|
dst.f[3][3] = src.f[3][3] - dst.f[3][3];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -1,9 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "VuVector.h"
|
||||||
|
|
||||||
class CMatrix
|
class CMatrix
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RwMatrix m_matrix;
|
union
|
||||||
|
{
|
||||||
|
float f[4][4];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
CVuVector right;
|
||||||
|
CVuVector forward;
|
||||||
|
CVuVector up;
|
||||||
|
CVuVector pos;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
RwMatrix *m_attachment;
|
RwMatrix *m_attachment;
|
||||||
bool m_hasRwMatrix; // are we the owner?
|
bool m_hasRwMatrix; // are we the owner?
|
||||||
|
|
||||||
@ -25,31 +38,30 @@ public:
|
|||||||
CMatrix &operator+=(CMatrix const &rhs);
|
CMatrix &operator+=(CMatrix const &rhs);
|
||||||
CMatrix &operator*=(CMatrix const &rhs);
|
CMatrix &operator*=(CMatrix const &rhs);
|
||||||
|
|
||||||
CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; }
|
CVector &GetPosition(void){ return pos; }
|
||||||
CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
|
CVector &GetRight(void) { return right; }
|
||||||
CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
|
CVector &GetForward(void) { return forward; }
|
||||||
CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }
|
CVector &GetUp(void) { return up; }
|
||||||
|
|
||||||
void SetTranslate(float x, float y, float z);
|
void SetTranslate(float x, float y, float z);
|
||||||
void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); }
|
void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); }
|
||||||
void Translate(float x, float y, float z){
|
void Translate(float x, float y, float z){
|
||||||
m_matrix.pos.x += x;
|
pos.x += x;
|
||||||
m_matrix.pos.y += y;
|
pos.y += y;
|
||||||
m_matrix.pos.z += z;
|
pos.z += z;
|
||||||
}
|
}
|
||||||
void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); }
|
void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); }
|
||||||
|
|
||||||
void SetScale(float s);
|
void SetScale(float s);
|
||||||
void Scale(float scale)
|
void Scale(float scale)
|
||||||
{
|
{
|
||||||
float *pFloatMatrix = (float*)&m_matrix;
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
#ifdef FIX_BUGS // BUGFIX from VC
|
#ifdef FIX_BUGS // BUGFIX from VC
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
#else
|
#else
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
#endif
|
#endif
|
||||||
pFloatMatrix[i * 4 + j] *= scale;
|
f[i][j] *= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,17 +72,17 @@ public:
|
|||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = c * scale;
|
right.x = c * scale;
|
||||||
m_matrix.right.y = s * scale;
|
right.y = s * scale;
|
||||||
m_matrix.right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.up.x = -s * scale;
|
forward.x = -s * scale;
|
||||||
m_matrix.up.y = c * scale;
|
forward.y = c * scale;
|
||||||
m_matrix.up.z = 0.0f;
|
forward.z = 0.0f;
|
||||||
|
|
||||||
m_matrix.at.x = 0.0f;
|
up.x = 0.0f;
|
||||||
m_matrix.at.y = 0.0f;
|
up.y = 0.0f;
|
||||||
m_matrix.at.z = scale;
|
up.z = scale;
|
||||||
}
|
}
|
||||||
void SetRotateX(float angle);
|
void SetRotateX(float angle);
|
||||||
void SetRotateY(float angle);
|
void SetRotateY(float angle);
|
||||||
@ -82,13 +94,13 @@ public:
|
|||||||
void RotateZ(float z);
|
void RotateZ(float z);
|
||||||
|
|
||||||
void Reorthogonalise(void);
|
void Reorthogonalise(void);
|
||||||
void CopyOnlyMatrix(CMatrix *other);
|
void CopyOnlyMatrix(const CMatrix &other);
|
||||||
void SetUnity(void);
|
void SetUnity(void);
|
||||||
void ResetOrientation(void);
|
void ResetOrientation(void);
|
||||||
void SetTranslateOnly(float x, float y, float z) {
|
void SetTranslateOnly(float x, float y, float z) {
|
||||||
m_matrix.pos.x = x;
|
pos.x = x;
|
||||||
m_matrix.pos.y = y;
|
pos.y = y;
|
||||||
m_matrix.pos.z = z;
|
pos.z = z;
|
||||||
}
|
}
|
||||||
void SetTranslateOnly(const CVector& pos) {
|
void SetTranslateOnly(const CVector& pos) {
|
||||||
SetTranslateOnly(pos.x, pos.y, pos.z);
|
SetTranslateOnly(pos.x, pos.y, pos.z);
|
||||||
@ -102,11 +114,11 @@ CMatrix Invert(const CMatrix &matrix);
|
|||||||
CMatrix operator*(const CMatrix &m1, const CMatrix &m2);
|
CMatrix operator*(const CMatrix &m1, const CMatrix &m2);
|
||||||
inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec)
|
inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec)
|
||||||
{
|
{
|
||||||
CVector v(vec.x - mat.m_matrix.pos.x, vec.y - mat.m_matrix.pos.y, vec.z - mat.m_matrix.pos.z);
|
CVector v(vec.x - mat.pos.x, vec.y - mat.pos.y, vec.z - mat.pos.z);
|
||||||
return CVector(
|
return CVector(
|
||||||
mat.m_matrix.right.x * v.x + mat.m_matrix.right.y * v.y + mat.m_matrix.right.z * v.z,
|
mat.right.x * v.x + mat.right.y * v.y + mat.right.z * v.z,
|
||||||
mat.m_matrix.up.x * v.x + mat.m_matrix.up.y * v.y + mat.m_matrix.up.z * v.z,
|
mat.forward.x * v.x + mat.forward.y * v.y + mat.forward.z * v.z,
|
||||||
mat.m_matrix.at.x * v.x + mat.m_matrix.at.y * v.y + mat.m_matrix.at.z * v.z);
|
mat.up.x * v.x + mat.up.y * v.y + mat.up.z * v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,24 +23,24 @@ CVector
|
|||||||
Multiply3x3(const CMatrix &mat, const CVector &vec)
|
Multiply3x3(const CMatrix &mat, const CVector &vec)
|
||||||
{
|
{
|
||||||
// TODO: VU0 code
|
// TODO: VU0 code
|
||||||
return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z,
|
return CVector(mat.right.x * vec.x + mat.forward.x * vec.y + mat.up.x * vec.z,
|
||||||
mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z,
|
mat.right.y * vec.x + mat.forward.y * vec.y + mat.up.y * vec.z,
|
||||||
mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z);
|
mat.right.z * vec.x + mat.forward.z * vec.y + mat.up.z * vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector
|
CVector
|
||||||
Multiply3x3(const CVector &vec, const CMatrix &mat)
|
Multiply3x3(const CVector &vec, const CMatrix &mat)
|
||||||
{
|
{
|
||||||
return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.right.y * vec.y + mat.m_matrix.right.z * vec.z,
|
return CVector(mat.right.x * vec.x + mat.right.y * vec.y + mat.right.z * vec.z,
|
||||||
mat.m_matrix.up.x * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.up.z * vec.z,
|
mat.forward.x * vec.x + mat.forward.y * vec.y + mat.forward.z * vec.z,
|
||||||
mat.m_matrix.at.x * vec.x + mat.m_matrix.at.y * vec.y + mat.m_matrix.at.z * vec.z);
|
mat.up.x * vec.x + mat.up.y * vec.y + mat.up.z * vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector
|
CVector
|
||||||
operator*(const CMatrix &mat, const CVector &vec)
|
operator*(const CMatrix &mat, const CVector &vec)
|
||||||
{
|
{
|
||||||
// TODO: VU0 code
|
// TODO: VU0 code
|
||||||
return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z + mat.m_matrix.pos.x,
|
return CVector(mat.right.x * vec.x + mat.forward.x * vec.y + mat.up.x * vec.z + mat.pos.x,
|
||||||
mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z + mat.m_matrix.pos.y,
|
mat.right.y * vec.x + mat.forward.y * vec.y + mat.up.y * vec.z + mat.pos.y,
|
||||||
mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z + mat.m_matrix.pos.z);
|
mat.right.z * vec.x + mat.forward.z * vec.y + mat.up.z * vec.z + mat.pos.z);
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size
|
|||||||
pMarker->m_Color.alpha = (float)a * 0.4f * someSin + a;
|
pMarker->m_Color.alpha = (float)a * 0.4f * someSin + a;
|
||||||
}
|
}
|
||||||
if (pMarker->m_nRotateRate) {
|
if (pMarker->m_nRotateRate) {
|
||||||
RwV3d pos = pMarker->m_Matrix.m_matrix.pos;
|
CVector pos = pMarker->m_Matrix.GetPosition();
|
||||||
pMarker->m_Matrix.RotateZ(DEGTORAD(pMarker->m_nRotateRate * CTimer::GetTimeStep()));
|
pMarker->m_Matrix.RotateZ(DEGTORAD(pMarker->m_nRotateRate * CTimer::GetTimeStep()));
|
||||||
pMarker->m_Matrix.GetPosition() = pos;
|
pMarker->m_Matrix.GetPosition() = pos;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user