Add missing Post Transform matrix to UV Animations

This commit is contained in:
Phillip Stephens 2016-07-07 20:23:58 -07:00
parent 952b96fa79
commit 746e7d9ff3
1 changed files with 61 additions and 33 deletions

View File

@ -86,7 +86,7 @@ void CBooModel::BuildGfxToken()
/* Animated UV transform matrices */
for (const MaterialSet::Material& mat : x4_matSet->materials)
{
size_t thisSz = ROUND_UP_256(mat.uvAnims.size() * sizeof(zeus::CMatrix4f));
size_t thisSz = ROUND_UP_256(mat.uvAnims.size() * (sizeof(zeus::CMatrix4f) * 2));
uvOffs.push_back(uniBufSize);
uvSizes.push_back(thisSz);
uniBufSize += thisSz;
@ -322,6 +322,7 @@ void CBooModel::DrawSurface(const CBooSurface& surf, const CModelFlags& flags) c
void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim)
{
zeus::CMatrix4f& matrixOut = reinterpret_cast<zeus::CMatrix4f&>(*bufOut);
zeus::CMatrix4f& postMtxOut = reinterpret_cast<zeus::CMatrix4f&>(*(bufOut + sizeof(zeus::CMatrix4f)));
switch (anim.mode)
{
case UVAnimation::Mode::MvInvNoTranslation:
@ -329,11 +330,19 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
matrixOut = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(
CGraphics::g_GXModelMatrix).toMatrix4f();
matrixOut.vec[3].zeroOut();
postMtxOut = zeus::CTransform(zeus::CMatrix3f(0.5, 0.0, 0.0,
0.0, 0.5, 0.0,
0.0, 0.0, 0.0),
zeus::CVector3f(0.5, 0.5, 1.0)).toMatrix4f();
break;
}
case UVAnimation::Mode::MvInv:
{
matrixOut = (CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix).toMatrix4f();
postMtxOut = zeus::CTransform(zeus::CMatrix3f(0.5, 0.0, 0.0,
0.0, 0.5, 0.0,
0.0, 0.0, 0.0),
zeus::CVector3f(0.5, 0.5, 1.0)).toMatrix4f();
break;
}
case UVAnimation::Mode::Scroll:
@ -374,14 +383,33 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
matrixOut.vec[2].y = 0.5f;
matrixOut.vec[3].x = CGraphics::g_GXModelMatrix.origin.x * 0.5f;
matrixOut.vec[3].y = CGraphics::g_GXModelMatrix.origin.y * 0.5f;
postMtxOut = zeus::CTransform(zeus::CMatrix3f(0.5, 0.0, 0.0,
0.0, 0.0, 0.5,
0.0, 0.0, 0.0),
zeus::CVector3f(CGraphics::g_GXModelMatrix.origin.x * 0.50000001,
CGraphics::g_GXModelMatrix.origin.x * 0.50000001,
1.0)).toMatrix4f();
break;
}
case UVAnimation::Mode::WhoMustNotBeNamed:
{
zeus::CTransform texmtx = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix;
texmtx.origin.zeroOut();
/* TODO: Finish */
matrixOut = texmtx.toMatrix4f();
const zeus::CVector3f& viewOrigin = CGraphics::g_ViewMatrix.origin;
float xy = (viewOrigin.x + viewOrigin.y) * 0.025f * anim.vals[1];
xy = (xy - (int)xy);
float z = (viewOrigin.z) * 0.05f * anim.vals[1];
z = (z - (int)z);
float halfA = anim.vals[0] * 0.5f;
postMtxOut = zeus::CTransform(zeus::CMatrix3f(halfA, 0.0, 0.0,
0.0, 0.0, halfA,
0.0, 0.0, 0.0),
zeus::CVector3f(xy, z, 1.0)).toMatrix4f();
break;
}
default: break;