mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 00:30:06 +00:00
Get rid of VuVector
This commit is contained in:
parent
91093305d6
commit
e6ef164441
|
@ -60,20 +60,20 @@ CMatrix::Detach(void)
|
||||||
void
|
void
|
||||||
CMatrix::Update(void)
|
CMatrix::Update(void)
|
||||||
{
|
{
|
||||||
right = m_attachment->right;
|
GetRight() = m_attachment->right;
|
||||||
forward = m_attachment->up;
|
GetForward() = m_attachment->up;
|
||||||
up = m_attachment->at;
|
GetUp() = m_attachment->at;
|
||||||
pos = m_attachment->pos;
|
GetPosition() = m_attachment->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::UpdateRW(void)
|
CMatrix::UpdateRW(void)
|
||||||
{
|
{
|
||||||
if (m_attachment) {
|
if (m_attachment) {
|
||||||
m_attachment->right = right;
|
m_attachment->right = GetRight();
|
||||||
m_attachment->up = forward;
|
m_attachment->up = GetForward();
|
||||||
m_attachment->at = up;
|
m_attachment->at = GetUp();
|
||||||
m_attachment->pos = pos;
|
m_attachment->pos = GetPosition();
|
||||||
RwMatrixUpdate(m_attachment);
|
RwMatrixUpdate(m_attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,82 +95,82 @@ CMatrix::CopyOnlyMatrix(const CMatrix &other)
|
||||||
CMatrix &
|
CMatrix &
|
||||||
CMatrix::operator+=(CMatrix const &rhs)
|
CMatrix::operator+=(CMatrix const &rhs)
|
||||||
{
|
{
|
||||||
right += rhs.right;
|
GetRight() += rhs.GetRight();
|
||||||
forward += rhs.forward;
|
GetForward() += rhs.GetForward();
|
||||||
up += rhs.up;
|
GetUp() += rhs.GetUp();
|
||||||
pos += rhs.pos;
|
GetPosition() += rhs.GetPosition();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetUnity(void)
|
CMatrix::SetUnity(void)
|
||||||
{
|
{
|
||||||
right.x = 1.0f;
|
rx = 1.0f;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = 1.0f;
|
fy = 1.0f;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = 1.0f;
|
uz = 1.0f;
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::ResetOrientation(void)
|
CMatrix::ResetOrientation(void)
|
||||||
{
|
{
|
||||||
right.x = 1.0f;
|
rx = 1.0f;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = 1.0f;
|
fy = 1.0f;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = 1.0f;
|
uz = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetScale(float s)
|
CMatrix::SetScale(float s)
|
||||||
{
|
{
|
||||||
right.x = s;
|
rx = s;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
|
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = s;
|
fy = s;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
|
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = s;
|
uz = s;
|
||||||
|
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetTranslate(float x, float y, float z)
|
CMatrix::SetTranslate(float x, float y, float z)
|
||||||
{
|
{
|
||||||
right.x = 1.0f;
|
rx = 1.0f;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
|
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = 1.0f;
|
fy = 1.0f;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
|
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = 1.0f;
|
uz = 1.0f;
|
||||||
|
|
||||||
pos.x = x;
|
px = x;
|
||||||
pos.y = y;
|
py = y;
|
||||||
pos.z = z;
|
pz = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -179,17 +179,17 @@ CMatrix::SetRotateXOnly(float angle)
|
||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
right.x = 1.0f;
|
rx = 1.0f;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
|
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = c;
|
fy = c;
|
||||||
forward.z = s;
|
fz = s;
|
||||||
|
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = -s;
|
uy = -s;
|
||||||
up.z = c;
|
uz = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -198,17 +198,17 @@ CMatrix::SetRotateYOnly(float angle)
|
||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
right.x = c;
|
rx = c;
|
||||||
right.y = 0.0f;
|
ry = 0.0f;
|
||||||
right.z = -s;
|
rz = -s;
|
||||||
|
|
||||||
forward.x = 0.0f;
|
fx = 0.0f;
|
||||||
forward.y = 1.0f;
|
fy = 1.0f;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
|
|
||||||
up.x = s;
|
ux = s;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = c;
|
uz = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -217,26 +217,26 @@ CMatrix::SetRotateZOnly(float angle)
|
||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
right.x = c;
|
rx = c;
|
||||||
right.y = s;
|
ry = s;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
|
|
||||||
forward.x = -s;
|
fx = -s;
|
||||||
forward.y = c;
|
fy = c;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
|
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = 1.0f;
|
uz = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetRotateX(float angle)
|
CMatrix::SetRotateX(float angle)
|
||||||
{
|
{
|
||||||
SetRotateXOnly(angle);
|
SetRotateXOnly(angle);
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,18 +244,18 @@ void
|
||||||
CMatrix::SetRotateY(float angle)
|
CMatrix::SetRotateY(float angle)
|
||||||
{
|
{
|
||||||
SetRotateYOnly(angle);
|
SetRotateYOnly(angle);
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMatrix::SetRotateZ(float angle)
|
CMatrix::SetRotateZ(float angle)
|
||||||
{
|
{
|
||||||
SetRotateZOnly(angle);
|
SetRotateZOnly(angle);
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -268,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);
|
||||||
|
|
||||||
right.x = cZ * cY - (sZ * sX) * sY;
|
rx = cZ * cY - (sZ * sX) * sY;
|
||||||
right.y = (cZ * sX) * sY + sZ * cY;
|
ry = (cZ * sX) * sY + sZ * cY;
|
||||||
right.z = -cX * sY;
|
rz = -cX * sY;
|
||||||
|
|
||||||
forward.x = -sZ * cX;
|
fx = -sZ * cX;
|
||||||
forward.y = cZ * cX;
|
fy = cZ * cX;
|
||||||
forward.z = sX;
|
fz = sX;
|
||||||
|
|
||||||
up.x = (sZ * sX) * cY + cZ * sY;
|
ux = (sZ * sX) * cY + cZ * sY;
|
||||||
up.y = sZ * sY - (cZ * sX) * cY;
|
uy = sZ * sY - (cZ * sX) * cY;
|
||||||
up.z = cX * cY;
|
uz = cX * cY;
|
||||||
|
|
||||||
pos.x = 0.0f;
|
px = 0.0f;
|
||||||
pos.y = 0.0f;
|
py = 0.0f;
|
||||||
pos.z = 0.0f;
|
pz = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -291,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 = right.y;
|
float ry = this->ry;
|
||||||
float rz = right.z;
|
float rz = this->rz;
|
||||||
float uy = forward.y;
|
float uy = this->fy;
|
||||||
float uz = forward.z;
|
float uz = this->fz;
|
||||||
float ay = up.y;
|
float ay = this->uy;
|
||||||
float az = up.z;
|
float az = this->uz;
|
||||||
float py = pos.y;
|
float py = this->py;
|
||||||
float pz = pos.z;
|
float pz = this->pz;
|
||||||
|
|
||||||
right.y = c * ry - s * rz;
|
this->ry = c * ry - s * rz;
|
||||||
right.z = c * rz + s * ry;
|
this->rz = c * rz + s * ry;
|
||||||
forward.y = c * uy - s * uz;
|
this->fy = c * uy - s * uz;
|
||||||
forward.z = c * uz + s * uy;
|
this->fz = c * uz + s * uy;
|
||||||
up.y = c * ay - s * az;
|
this->uy = c * ay - s * az;
|
||||||
up.z = c * az + s * ay;
|
this->uz = c * az + s * ay;
|
||||||
pos.y = c * py - s * pz;
|
this->py = c * py - s * pz;
|
||||||
pos.z = c * pz + s * py;
|
this->pz = c * pz + s * py;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -316,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 = right.x;
|
float rx = this->rx;
|
||||||
float rz = right.z;
|
float rz = this->rz;
|
||||||
float ux = forward.x;
|
float ux = this->fx;
|
||||||
float uz = forward.z;
|
float uz = this->fz;
|
||||||
float ax = up.x;
|
float ax = this->ux;
|
||||||
float az = up.z;
|
float az = this->uz;
|
||||||
float px = pos.x;
|
float px = this->px;
|
||||||
float pz = pos.z;
|
float pz = this->pz;
|
||||||
|
|
||||||
right.x = c * rx + s * rz;
|
this->rx = c * rx + s * rz;
|
||||||
right.z = c * rz - s * rx;
|
this->rz = c * rz - s * rx;
|
||||||
forward.x = c * ux + s * uz;
|
this->fx = c * ux + s * uz;
|
||||||
forward.z = c * uz - s * ux;
|
this->fz = c * uz - s * ux;
|
||||||
up.x = c * ax + s * az;
|
this->ux = c * ax + s * az;
|
||||||
up.z = c * az - s * ax;
|
this->uz = c * az - s * ax;
|
||||||
pos.x = c * px + s * pz;
|
this->px = c * px + s * pz;
|
||||||
pos.z = c * pz - s * px;
|
this->pz = c * pz - s * px;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -341,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 = right.y;
|
float ry = this->ry;
|
||||||
float rx = right.x;
|
float rx = this->rx;
|
||||||
float uy = forward.y;
|
float uy = this->fy;
|
||||||
float ux = forward.x;
|
float ux = this->fx;
|
||||||
float ay = up.y;
|
float ay = this->uy;
|
||||||
float ax = up.x;
|
float ax = this->ux;
|
||||||
float py = pos.y;
|
float py = this->py;
|
||||||
float px = pos.x;
|
float px = this->px;
|
||||||
|
|
||||||
right.x = c * rx - s * ry;
|
this->rx = c * rx - s * ry;
|
||||||
right.y = c * ry + s * rx;
|
this->ry = c * ry + s * rx;
|
||||||
forward.x = c * ux - s * uy;
|
this->fx = c * ux - s * uy;
|
||||||
forward.y = c * uy + s * ux;
|
this->fy = c * uy + s * ux;
|
||||||
up.x = c * ax - s * ay;
|
this->ux = c * ax - s * ay;
|
||||||
up.y = c * ay + s * ax;
|
this->uy = c * ay + s * ax;
|
||||||
pos.x = c * px - s * py;
|
this->px = c * px - s * py;
|
||||||
pos.y = c * py + s * px;
|
this->py = c * py + s * px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,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 = right.x;
|
float rx = this->rx;
|
||||||
float ry = right.y;
|
float ry = this->ry;
|
||||||
float rz = right.z;
|
float rz = this->rz;
|
||||||
float ux = forward.x;
|
float ux = this->fx;
|
||||||
float uy = forward.y;
|
float uy = this->fy;
|
||||||
float uz = forward.z;
|
float uz = this->fz;
|
||||||
float ax = up.x;
|
float ax = this->ux;
|
||||||
float ay = up.y;
|
float ay = this->uy;
|
||||||
float az = up.z;
|
float az = this->uz;
|
||||||
float px = pos.x;
|
float px = this->px;
|
||||||
float py = pos.y;
|
float py = this->py;
|
||||||
float pz = pos.z;
|
float pz = this->pz;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -394,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;
|
||||||
|
|
||||||
right.x = x1 * rx + y1 * ry + z1 * rz;
|
this->rx = x1 * rx + y1 * ry + z1 * rz;
|
||||||
right.y = x2 * rx + y2 * ry + z2 * rz;
|
this->ry = x2 * rx + y2 * ry + z2 * rz;
|
||||||
right.z = x3 * rx + y3 * ry + z3 * rz;
|
this->rz = x3 * rx + y3 * ry + z3 * rz;
|
||||||
forward.x = x1 * ux + y1 * uy + z1 * uz;
|
this->fx = x1 * ux + y1 * uy + z1 * uz;
|
||||||
forward.y = x2 * ux + y2 * uy + z2 * uz;
|
this->fy = x2 * ux + y2 * uy + z2 * uz;
|
||||||
forward.z = x3 * ux + y3 * uy + z3 * uz;
|
this->fz = x3 * ux + y3 * uy + z3 * uz;
|
||||||
up.x = x1 * ax + y1 * ay + z1 * az;
|
this->ux = x1 * ax + y1 * ay + z1 * az;
|
||||||
up.y = x2 * ax + y2 * ay + z2 * az;
|
this->uy = x2 * ax + y2 * ay + z2 * az;
|
||||||
up.z = x3 * ax + y3 * ay + z3 * az;
|
this->uz = x3 * ax + y3 * ay + z3 * az;
|
||||||
pos.x = x1 * px + y1 * py + z1 * pz;
|
this->px = x1 * px + y1 * py + z1 * pz;
|
||||||
pos.y = x2 * px + y2 * py + z2 * pz;
|
this->py = x2 * px + y2 * py + z2 * pz;
|
||||||
pos.z = x3 * px + y3 * py + z3 * pz;
|
this->pz = x3 * px + y3 * py + z3 * pz;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMatrix &
|
CMatrix &
|
||||||
|
@ -434,18 +434,18 @@ operator*(const CMatrix &m1, const CMatrix &m2)
|
||||||
{
|
{
|
||||||
// TODO: VU0 code
|
// TODO: VU0 code
|
||||||
CMatrix out;
|
CMatrix out;
|
||||||
out.right.x = m1.right.x * m2.right.x + m1.forward.x * m2.right.y + m1.up.x * m2.right.z;
|
out.rx = m1.rx * m2.rx + m1.fx * m2.ry + m1.ux * m2.rz;
|
||||||
out.right.y = m1.right.y * m2.right.x + m1.forward.y * m2.right.y + m1.up.y * m2.right.z;
|
out.ry = m1.ry * m2.rx + m1.fy * m2.ry + m1.uy * m2.rz;
|
||||||
out.right.z = m1.right.z * m2.right.x + m1.forward.z * m2.right.y + m1.up.z * m2.right.z;
|
out.rz = m1.rz * m2.rx + m1.fz * m2.ry + m1.uz * m2.rz;
|
||||||
out.forward.x = m1.right.x * m2.forward.x + m1.forward.x * m2.forward.y + m1.up.x * m2.forward.z;
|
out.fx = m1.rx * m2.fx + m1.fx * m2.fy + m1.ux * m2.fz;
|
||||||
out.forward.y = m1.right.y * m2.forward.x + m1.forward.y * m2.forward.y + m1.up.y * m2.forward.z;
|
out.fy = m1.ry * m2.fx + m1.fy * m2.fy + m1.uy * m2.fz;
|
||||||
out.forward.z = m1.right.z * m2.forward.x + m1.forward.z * m2.forward.y + m1.up.z * m2.forward.z;
|
out.fz = m1.rz * m2.fx + m1.fz * m2.fy + m1.uz * m2.fz;
|
||||||
out.up.x = m1.right.x * m2.up.x + m1.forward.x * m2.up.y + m1.up.x * m2.up.z;
|
out.ux = m1.rx * m2.ux + m1.fx * m2.uy + m1.ux * m2.uz;
|
||||||
out.up.y = m1.right.y * m2.up.x + m1.forward.y * m2.up.y + m1.up.y * m2.up.z;
|
out.uy = m1.ry * m2.ux + m1.fy * m2.uy + m1.uy * m2.uz;
|
||||||
out.up.z = m1.right.z * m2.up.x + m1.forward.z * m2.up.y + m1.up.z * m2.up.z;
|
out.uz = m1.rz * m2.ux + m1.fz * m2.uy + m1.uz * m2.uz;
|
||||||
out.pos.x = m1.right.x * m2.pos.x + m1.forward.x * m2.pos.y + m1.up.x * m2.pos.z + m1.pos.x;
|
out.px = m1.rx * m2.px + m1.fx * m2.py + m1.ux * m2.pz + m1.px;
|
||||||
out.pos.y = m1.right.y * m2.pos.x + m1.forward.y * m2.pos.y + m1.up.y * m2.pos.z + m1.pos.y;
|
out.py = m1.ry * m2.px + m1.fy * m2.py + m1.uy * m2.pz + m1.py;
|
||||||
out.pos.z = m1.right.z * m2.pos.x + m1.forward.z * m2.pos.y + m1.up.z * m2.pos.z + m1.pos.z;
|
out.pz = m1.rz * m2.px + m1.fz * m2.py + m1.uz * m2.pz + m1.pz;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "VuVector.h"
|
|
||||||
|
|
||||||
class CMatrix
|
class CMatrix
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -10,10 +8,10 @@ public:
|
||||||
float f[4][4];
|
float f[4][4];
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
CVuVector right;
|
float rx, ry, rz, rw;
|
||||||
CVuVector forward;
|
float fx, fy, fz, fw;
|
||||||
CVuVector up;
|
float ux, uy, uz, uw;
|
||||||
CVuVector pos;
|
float px, py, pz, pw;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,17 +36,23 @@ 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 pos; }
|
CVector &GetPosition(void) { return *(CVector*)&px; }
|
||||||
CVector &GetRight(void) { return right; }
|
CVector &GetRight(void) { return *(CVector*)℞ }
|
||||||
CVector &GetForward(void) { return forward; }
|
CVector &GetForward(void) { return *(CVector*)&fx; }
|
||||||
CVector &GetUp(void) { return up; }
|
CVector &GetUp(void) { return *(CVector*)&ux; }
|
||||||
|
|
||||||
|
const CVector &GetPosition(void) const { return *(CVector*)&px; }
|
||||||
|
const CVector &GetRight(void) const { return *(CVector*)℞ }
|
||||||
|
const CVector &GetForward(void) const { return *(CVector*)&fx; }
|
||||||
|
const CVector &GetUp(void) const { return *(CVector*)&ux; }
|
||||||
|
|
||||||
|
|
||||||
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){
|
||||||
pos.x += x;
|
px += x;
|
||||||
pos.y += y;
|
py += y;
|
||||||
pos.z += z;
|
pz += 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); }
|
||||||
|
|
||||||
|
@ -72,17 +76,17 @@ public:
|
||||||
float c = Cos(angle);
|
float c = Cos(angle);
|
||||||
float s = Sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
right.x = c * scale;
|
rx = c * scale;
|
||||||
right.y = s * scale;
|
ry = s * scale;
|
||||||
right.z = 0.0f;
|
rz = 0.0f;
|
||||||
|
|
||||||
forward.x = -s * scale;
|
fx = -s * scale;
|
||||||
forward.y = c * scale;
|
fy = c * scale;
|
||||||
forward.z = 0.0f;
|
fz = 0.0f;
|
||||||
|
|
||||||
up.x = 0.0f;
|
ux = 0.0f;
|
||||||
up.y = 0.0f;
|
uy = 0.0f;
|
||||||
up.z = scale;
|
uz = scale;
|
||||||
}
|
}
|
||||||
void SetRotateX(float angle);
|
void SetRotateX(float angle);
|
||||||
void SetRotateY(float angle);
|
void SetRotateY(float angle);
|
||||||
|
@ -98,9 +102,9 @@ public:
|
||||||
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) {
|
||||||
pos.x = x;
|
px = x;
|
||||||
pos.y = y;
|
py = y;
|
||||||
pos.z = z;
|
pz = 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);
|
||||||
|
@ -114,11 +118,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.pos.x, vec.y - mat.pos.y, vec.z - mat.pos.z);
|
CVector v(vec.x - mat.px, vec.y - mat.py, vec.z - mat.pz);
|
||||||
return CVector(
|
return CVector(
|
||||||
mat.right.x * v.x + mat.right.y * v.y + mat.right.z * v.z,
|
mat.rx * v.x + mat.ry * v.y + mat.rz * v.z,
|
||||||
mat.forward.x * v.x + mat.forward.y * v.y + mat.forward.z * v.z,
|
mat.fx * v.x + mat.fy * v.y + mat.fz * v.z,
|
||||||
mat.up.x * v.x + mat.up.y * v.y + mat.up.z * v.z);
|
mat.ux * v.x + mat.uy * v.y + mat.uz * 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.right.x * vec.x + mat.forward.x * vec.y + mat.up.x * vec.z,
|
return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z,
|
||||||
mat.right.y * vec.x + mat.forward.y * vec.y + mat.up.y * vec.z,
|
mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z,
|
||||||
mat.right.z * vec.x + mat.forward.z * vec.y + mat.up.z * vec.z);
|
mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector
|
CVector
|
||||||
Multiply3x3(const CVector &vec, const CMatrix &mat)
|
Multiply3x3(const CVector &vec, const CMatrix &mat)
|
||||||
{
|
{
|
||||||
return CVector(mat.right.x * vec.x + mat.right.y * vec.y + mat.right.z * vec.z,
|
return CVector(mat.rx * vec.x + mat.ry * vec.y + mat.rz * vec.z,
|
||||||
mat.forward.x * vec.x + mat.forward.y * vec.y + mat.forward.z * vec.z,
|
mat.fx * vec.x + mat.fy * vec.y + mat.fz * vec.z,
|
||||||
mat.up.x * vec.x + mat.up.y * vec.y + mat.up.z * vec.z);
|
mat.ux * vec.x + mat.uy * vec.y + mat.uz * 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.right.x * vec.x + mat.forward.x * vec.y + mat.up.x * vec.z + mat.pos.x,
|
return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z + mat.px,
|
||||||
mat.right.y * vec.x + mat.forward.y * vec.y + mat.up.y * vec.z + mat.pos.y,
|
mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z + mat.py,
|
||||||
mat.right.z * vec.x + mat.forward.z * vec.y + mat.up.z * vec.z + mat.pos.z);
|
mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z + mat.pz);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue