This commit is contained in:
intns 2024-01-03 15:28:42 +00:00
parent 82c78074a0
commit df4dc5ad04
6 changed files with 54 additions and 51 deletions

View File

@ -259,7 +259,7 @@ struct PlayCamera : public LookAtCamera {
f32 mCurrTargetDistance; // _1A8
f32 mGoalTargetDistance; // _1AC
f32 mCameraAngleCurrent; // _1B0
f32 mCameraAngleGoal; // _1B4
f32 mCameraAngleTarget; // _1B4
f32 mCurrVerticalAngle; // _1B8
f32 mGoalVerticalAngle; // _1BC
f32 mGoalFOV; // _1C0

View File

@ -22,6 +22,14 @@ struct JointShadowParm {
f32 _1C; // _1C
f32 mShadowScale; // _20
f32 _24; // _24
inline void setBoth(f32 x, f32 y)
{
mShadowScale = 0.0f;
_24 = -17.5f;
_18 = x;
_1C = y;
}
};
struct JointShadowNode : public CNode {

View File

@ -64,11 +64,11 @@ struct Matrixf {
/**
* @fabricated
*/
void setBasis(int p1, Vector3f& p2)
void setBasis(int index, Vector3f& v)
{
(*this)(0, p1) = p2.x;
(*this)(1, p1) = p2.y;
(*this)(2, p1) = p2.z;
(*this)(0, index) = v.x;
(*this)(1, index) = v.y;
(*this)(2, index) = v.z;
}
inline Vector3f mtxMult(Vector3f& vec)

View File

@ -8,41 +8,41 @@ namespace Game {
* @note Address: 0x802F2040
* @note Size: 0x278
*/
void TubeShadowTransNode::makeShadowSRT(JointShadowParm& parm, Vector3f& pos1, Vector3f& pos2)
void TubeShadowTransNode::makeShadowSRT(JointShadowParm& parm, Vector3f& originalPos, Vector3f& transformedPos)
{
Matrixf* mat = mJoint->getWorldMatrix();
Matrixf* worldMtx = mJoint->getWorldMatrix();
Vector3f xVec, yVec;
mat->getBasis(0, xVec);
mat->getBasis(1, yVec);
Vector3f xAxis, yAxis;
worldMtx->getBasis(0, xAxis);
worldMtx->getBasis(1, yAxis);
mat->getTranslation(pos1);
pos2.x = pos1.x + (xVec.x * parm._18 + yVec.x * parm._1C);
pos2.y = pos1.y + (xVec.y * parm._18 + yVec.y * parm._1C);
pos2.z = pos1.z + (xVec.z * parm._18 + yVec.z * parm._1C);
worldMtx->getTranslation(originalPos);
transformedPos.x = originalPos.x + (xAxis.x * parm._18 + yAxis.x * parm._1C);
transformedPos.y = originalPos.y + (xAxis.y * parm._18 + yAxis.y * parm._1C);
transformedPos.z = originalPos.z + (xAxis.z * parm._18 + yAxis.z * parm._1C);
Vector3f newX;
newX.x = (pos2.x - pos1.x) * 0.5f;
newX.y = (pos2.y - pos1.y) * 0.5f;
newX.z = (pos2.z - pos1.z) * 0.5f;
Vector3f x;
x.x = (transformedPos.x - originalPos.x) * 0.5f;
x.y = (transformedPos.y - originalPos.y) * 0.5f;
x.z = (transformedPos.z - originalPos.z) * 0.5f;
Vector3f newZ(newX.y * parm.mRotation.z - newX.z * parm.mRotation.y, newX.z * parm.mRotation.x - newX.x * parm.mRotation.z,
newX.x * parm.mRotation.y - newX.y * parm.mRotation.x);
newZ.normalise();
Vector3f scale(x.y * parm.mRotation.z - x.z * parm.mRotation.y, x.z * parm.mRotation.x - x.x * parm.mRotation.z,
x.x * parm.mRotation.y - x.y * parm.mRotation.x);
scale.normalise();
Vector3f newPos;
newPos.x = (pos2.x + pos1.x) * 0.5f + parm.mRotation.x * parm._24;
newPos.y = (pos2.y + pos1.y) * 0.5f + parm.mRotation.y * parm._24;
newPos.z = (pos2.z + pos1.z) * 0.5f + parm.mRotation.z * parm._24;
Vector3f w;
w.x = (transformedPos.x + originalPos.x) * 0.5f + parm.mRotation.x * parm._24;
w.y = (transformedPos.y + originalPos.y) * 0.5f + parm.mRotation.y * parm._24;
w.z = (transformedPos.z + originalPos.z) * 0.5f + parm.mRotation.z * parm._24;
Vector3f newY = parm.mRotation;
newY *= (100.0f + (newPos.y - parm.mPosition.y));
newZ *= parm.mShadowScale;
Vector3f y = parm.mRotation;
y *= (100.0f + (w.y - parm.mPosition.y));
scale *= parm.mShadowScale;
mMainMtx->setBasis(0, newX);
mMainMtx->setBasis(1, newY);
mMainMtx->setBasis(2, newZ);
mMainMtx->setBasis(3, newPos);
mMainMtx->setBasis(0, x);
mMainMtx->setBasis(1, y);
mMainMtx->setBasis(2, scale);
mMainMtx->setBasis(3, w);
/*
.loc_0x0:
stwu r1, -0x80(r1)

View File

@ -253,12 +253,7 @@ void TyreShadowMgr::update()
f32 scale1 = 31.5f * mGlobalScale;
f32 scale2 = 17.5f * mGlobalScale;
parm.mShadowScale = 0.0f;
parm._24 = -17.5f;
parm._18 = scale1;
parm._1C = scale2;
parm.setBoth(scale1, scale2);
mFrontShadow->makeShadowSRT(parm, mFrontMatrix);
mBackShadow->makeShadowSRT(parm, mBackMatrix);
/*

View File

@ -22,7 +22,7 @@ PlayCamera::PlayCamera(Navi* target)
mGoalTargetDistance = 100.0f;
mCurrTargetDistance = 100.0f;
mCameraAngleGoal = 0.0f;
mCameraAngleTarget = 0.0f;
mCameraAngleCurrent = 0.0f;
mGoalVerticalAngle = 0.0f;
mCurrVerticalAngle = 0.0f;
@ -88,7 +88,7 @@ void PlayCamera::init()
f32 angle = mTargetObj->getFaceDir() + PI;
clampAngle(angle);
mCameraAngleGoal = angle;
mCameraAngleTarget = angle;
mCameraAngleCurrent = angle;
mCurrVerticalAngle = mGoalVerticalAngle;
mViewAngle = mGoalFOV;
@ -104,7 +104,7 @@ void PlayCamera::init()
*/
void PlayCamera::setCameraAngle(f32 angle)
{
mCameraAngleGoal = angle;
mCameraAngleTarget = angle;
mCameraAngleCurrent = angle;
updateMatrix();
}
@ -155,7 +155,7 @@ void PlayCamera::changePlayerMode(bool updateDir)
if (updateDir) {
setTargetThetaToWhistle();
} else {
mCameraAngleGoal = mCameraAngleCurrent;
mCameraAngleTarget = mCameraAngleCurrent;
}
updateMatrix();
setProjection();
@ -519,7 +519,7 @@ void PlayCamera::setTargetThetaToWhistle()
{
Vector3f pos = mTargetObj->getPosition();
NaviWhistle* whistle = mTargetObj->mWhistle;
mCameraAngleGoal = JMath::atanTable_.atan2_(pos.x - whistle->mPosition.x, pos.z - whistle->mPosition.z);
mCameraAngleTarget = JMath::atanTable_.atan2_(pos.x - whistle->mPosition.x, pos.z - whistle->mPosition.z);
}
/**
@ -552,9 +552,9 @@ void PlayCamera::changeTargetTheta()
mFollowTime -= sys->mDeltaTime;
setTargetThetaToWhistle();
} else {
f32 angle = mCameraAngleGoal - mSmoothMoveSpeed;
f32 angle = mCameraAngleTarget - mSmoothMoveSpeed;
clampAngle(angle);
mCameraAngleGoal = angle;
mCameraAngleTarget = angle;
}
mSmoothMoveSpeed *= mCameraParms->mRotDampRate.mValue;
}
@ -613,7 +613,7 @@ void PlayCamera::updateParms(int flag)
mLookAtPosition = (mLookAtPosition * invrate) + (mGoalPosition * rate);
CameraParms* parms = mCameraParms;
f32 anglein = mCameraAngleGoal;
f32 anglein = mCameraAngleTarget;
f32 angleout = mCameraAngleCurrent;
if (anglein >= angleout) {
if (TAU - (anglein - angleout) < (anglein - angleout)) {
@ -783,7 +783,7 @@ void PlayCamera::otherVibFinished(int id)
bool PlayCamera::isModCameraFinished()
{
if (mChangePlayerState == 1) {
f32 anglein = mCameraAngleGoal;
f32 anglein = mCameraAngleTarget;
f32 angleout = mCameraAngleCurrent;
if (anglein >= angleout) {
if (TAU - (anglein - angleout) < (anglein - angleout)) {
@ -985,10 +985,10 @@ f32 PlayCamera::getCollisionCameraTargetPhi(f32 angle, f32 dist)
dist /= 15.0f; // f19
angle *= TORADIANS(1.0f);
f32 cosTheta = cosf(mCameraAngleGoal); // f22
f32 sinTheta = sinf(mCameraAngleGoal); // f26
f32 sinPhi = sinf(angle); // f24
f32 cosPhi = cosf(angle); // f23
f32 cosTheta = cosf(mCameraAngleTarget); // f22
f32 sinTheta = sinf(mCameraAngleTarget); // f26
f32 sinPhi = sinf(angle); // f24
f32 cosPhi = cosf(angle); // f23
for (int i = 1; i <= 15; i++) {
f32 rad = dist * (f32)i;