CSamusFaceReflection progress

Former-commit-id: 0025d54cea52ca43dfe2a7a5825ab171ccbc57cd
This commit is contained in:
Luke Street 2023-10-11 23:38:49 -04:00
parent 9a52da8ba6
commit 5e47494749
5 changed files with 37 additions and 40 deletions

View File

@ -13656,7 +13656,7 @@ GetRotation__12CTransform4fCFv = .text:0x80312C40; // type:function size:0x5C sc
GetQuickInverse__12CTransform4fCFv = .text:0x80312C9C; // type:function size:0x8C scope:global GetQuickInverse__12CTransform4fCFv = .text:0x80312C9C; // type:function size:0x8C scope:global
__eq__FRC12CTransform4fRC12CTransform4f = .text:0x80312D28; // type:function size:0xD0 scope:global __eq__FRC12CTransform4fRC12CTransform4f = .text:0x80312D28; // type:function size:0xD0 scope:global
FromColumns__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312DF8; // type:function size:0x64 scope:global FromColumns__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312DF8; // type:function size:0x64 scope:global
__ct__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f_0 = .text:0x80312E5C; // type:function size:0x64 scope:global __ct__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312E5C; // type:function size:0x64 scope:global
ScaleBy__12CTransform4fFf = .text:0x80312EC0; // type:function size:0x70 scope:global ScaleBy__12CTransform4fFf = .text:0x80312EC0; // type:function size:0x70 scope:global
MultiplyIgnoreTranslation__12CTransform4fCFRC12CTransform4f = .text:0x80312F30; // type:function size:0x1C4 scope:global MultiplyIgnoreTranslation__12CTransform4fCFRC12CTransform4f = .text:0x80312F30; // type:function size:0x1C4 scope:global
BuildMatrix3f__12CTransform4fCFv = .text:0x803130F4; // type:function size:0x4C scope:global BuildMatrix3f__12CTransform4fCFv = .text:0x803130F4; // type:function size:0x4C scope:global

View File

@ -13671,7 +13671,7 @@ GetRotation__12CTransform4fCFv = .text:0x80312D20; // type:function size:0x5C sc
GetQuickInverse__12CTransform4fCFv = .text:0x80312D7C; // type:function size:0x8C scope:global GetQuickInverse__12CTransform4fCFv = .text:0x80312D7C; // type:function size:0x8C scope:global
__eq__FRC12CTransform4fRC12CTransform4f = .text:0x80312E08; // type:function size:0xD0 scope:global __eq__FRC12CTransform4fRC12CTransform4f = .text:0x80312E08; // type:function size:0xD0 scope:global
FromColumns__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312ED8; // type:function size:0x64 scope:global FromColumns__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312ED8; // type:function size:0x64 scope:global
__ct__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f_0 = .text:0x80312F3C; // type:function size:0x64 scope:global __ct__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x80312F3C; // type:function size:0x64 scope:global
ScaleBy__12CTransform4fFf = .text:0x80312FA0; // type:function size:0x70 scope:global ScaleBy__12CTransform4fFf = .text:0x80312FA0; // type:function size:0x70 scope:global
MultiplyIgnoreTranslation__12CTransform4fCFRC12CTransform4f = .text:0x80313010; // type:function size:0x1C4 scope:global MultiplyIgnoreTranslation__12CTransform4fCFRC12CTransform4f = .text:0x80313010; // type:function size:0x1C4 scope:global
BuildMatrix3f__12CTransform4fCFv = .text:0x803131D4; // type:function size:0x4C scope:global BuildMatrix3f__12CTransform4fCFv = .text:0x803131D4; // type:function size:0x4C scope:global

View File

@ -20,16 +20,18 @@ class CActorLights {
public: public:
static const float kDefaultPositionUpdateThreshold; static const float kDefaultPositionUpdateThreshold;
CActorLights(const uint areaUpdateFramePeriod, CVector3f lightingPositionOffset, const int maxDynamicLights, CActorLights(const uint areaUpdateFramePeriod, CVector3f lightingPositionOffset,
const int maxAreaLights, float positionUpdateThreshold, const bool ambientChannelOverflow, const int maxDynamicLights, const int maxAreaLights,
const bool useLightSet2, const bool disableWorldLights); float positionUpdateThreshold = kDefaultPositionUpdateThreshold,
const bool ambientChannelOverflow = false, const bool useLightSet2 = false,
const bool disableWorldLights = false);
~CActorLights(); ~CActorLights();
void BuildConstantAmbientLighting(); void BuildConstantAmbientLighting();
void BuildConstantAmbientLighting(const CColor&); void BuildConstantAmbientLighting(const CColor&);
bool BuildAreaLightList(const CStateManager& mgr, const CGameArea& area, const CAABox& bounds); bool BuildAreaLightList(const CStateManager& mgr, const CGameArea& area, const CAABox& bounds);
void BuildDynamicLightList(const CStateManager& mgr, const CAABox& bounds); void BuildDynamicLightList(const CStateManager& mgr, const CAABox& bounds);
void BuildFakeLightList(const rstl::vector<CLight>&, const CColor&); void BuildFakeLightList(const rstl::vector< CLight >&, const CColor&);
void BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const CAABox& aabb); void BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const CAABox& aabb);
void ActivateLights() const; void ActivateLights() const;

View File

@ -15,10 +15,10 @@ class CActorLights;
class CSamusFaceReflection { class CSamusFaceReflection {
public: public:
explicit CSamusFaceReflection(const CStateManager& stateMgr); explicit CSamusFaceReflection(const CStateManager& mgr);
void PreDraw(const CStateManager& stateMgr); void PreDraw(const CStateManager& mgr);
void Draw(const CStateManager& stateMgr) const; void Draw(const CStateManager& mgr) const;
void Update(float dt, const CStateManager& stateMgr, CRandom16& rand); void Update(float dt, const CStateManager& mgr, CRandom16& rand);
private: private:
CModelData x0_modelData; CModelData x0_modelData;
@ -29,5 +29,4 @@ private:
bool x70_hidden; bool x70_hidden;
}; };
#endif // _CSAMUSFACEREFLECTION #endif // _CSAMUSFACEREFLECTION

View File

@ -13,25 +13,23 @@
#include "MetroidPrime/Tweaks/CTweakGui.hpp" #include "MetroidPrime/Tweaks/CTweakGui.hpp"
#include "MetroidPrime/Tweaks/CTweakPlayer.hpp" #include "MetroidPrime/Tweaks/CTweakPlayer.hpp"
#include "Kyoto/CResFactory.hpp" #include "Kyoto/CResFactory.hpp"
#include "Kyoto/Graphics/CGraphics.hpp" #include "Kyoto/Graphics/CGraphics.hpp"
#include "Kyoto/Graphics/CModelFlags.hpp" #include "Kyoto/Graphics/CModelFlags.hpp"
#include "Kyoto/Math/CRelAngle.hpp" #include "Kyoto/Math/CRelAngle.hpp"
static const char* const skFaceAssetIdName = "ACS_SamusFace";
static const CTransform4f PreXf = static const CTransform4f skFaceModelViewAdjust =
CTransform4f::Scale(0.3f) * CTransform4f::Translate(CVector3f(0.f, 0.5f, 0.f)); CTransform4f::Scale(0.3f) * CTransform4f::Translate(CVector3f(0.f, 0.5f, 0.f));
CSamusFaceReflection::CSamusFaceReflection(const CStateManager& stateMgr) CSamusFaceReflection::CSamusFaceReflection(const CStateManager& mgr)
: x0_modelData(CModelData(CAnimRes(gpResourceFactory->GetResourceIdByName("ACS_SamusFace")->id, : x0_modelData(CModelData(CAnimRes(gpResourceFactory->GetResourceIdByName(skFaceAssetIdName)->id,
CAnimRes::kDefaultCharIdx, CVector3f(1.f, 1.f, 1.f), 0, true))) CAnimRes::kDefaultCharIdx, CVector3f(1.f, 1.f, 1.f), 0, true)))
, x4c_lights(new CActorLights(8, CVector3f::Zero(), 4, 4, 0.1f, false, false, false)) , x4c_lights(new CActorLights(8, CVector3f::Zero(), 4, 4))
, x50_lookRot(CQuaternion::NoRotation()) , x50_lookRot(CQuaternion::NoRotation())
, x60_lookDir(CVector3f::Forward()) , x60_lookDir(CVector3f::Forward())
, x6c_(0) , x6c_(0)
, x70_hidden(true) { , x70_hidden(true) {
CAnimPlaybackParms parms(0, -1, 1.f, true); CAnimPlaybackParms parms(0, -1, 1.f, true);
x0_modelData.AnimationData()->SetAnimation(parms, false); x0_modelData.AnimationData()->SetAnimation(parms, false);
} }
@ -41,17 +39,19 @@ void CSamusFaceReflection::Update(float dt, const CStateManager& mgr, CRandom16&
TCastToConstPtr< CFirstPersonCamera >(mgr.GetCameraManager()->GetCurrentCamera(mgr))) { TCastToConstPtr< CFirstPersonCamera >(mgr.GetCameraManager()->GetCurrentCamera(mgr))) {
CVector3f camTrans = fpCam->GetTranslation(); CVector3f camTrans = fpCam->GetTranslation();
x0_modelData.AdvanceAnimationIgnoreParticles(dt, rand, true); x0_modelData.AdvanceAnimationIgnoreParticles(dt, rand, true);
x4c_lights->SetFindShadowLight(false);
CActorLights* lights = x4c_lights.get();
lights->SetFindShadowLight(false);
TAreaId areaId = mgr.GetPlayer()->GetCurrentAreaId(); TAreaId areaId = mgr.GetPlayer()->GetCurrentAreaId();
if (areaId == kInvalidAreaId) if (areaId == kInvalidAreaId)
return; return;
CAABox aabb( const CVector3f offset(0.125f, 0.125f, 0.125f);
CVector3f(camTrans.GetX() - 0.125f, camTrans.GetY() - 0.125f, camTrans.GetZ() - 0.125f), CAABox aabb(camTrans - offset, camTrans + offset);
CVector3f(camTrans.GetX() + 0.125f, camTrans.GetY() + 0.125f, camTrans.GetZ() + 0.125f));
const CGameArea& area = mgr.GetWorld()->GetAreaAlways(areaId); const CGameArea& area = mgr.GetWorld()->GetAreaAlways(areaId);
x4c_lights->BuildFaceLightList(mgr, area, aabb); lights->BuildFaceLightList(mgr, mgr.GetWorld()->GetAreaAlways(areaId), aabb);
CMatrix3f matrix = fpCam->GetTransform().BuildMatrix3f(); CMatrix3f matrix = fpCam->GetTransform().BuildMatrix3f();
CUnitVector3f lookDir(matrix.GetColumn(kDY)); CUnitVector3f lookDir(matrix.GetColumn(kDY));
@ -68,17 +68,12 @@ void CSamusFaceReflection::Update(float dt, const CStateManager& mgr, CRandom16&
float freeLookSpeed = dt * gpTweakPlayer->GetFreeLookSpeed() * 0.5f; float freeLookSpeed = dt * gpTweakPlayer->GetFreeLookSpeed() * 0.5f;
if (fabsf(lookDot) >= 1.f) float lookAng = acos(CMath::Limit(lookDot, 1.f));
lookDot = 1.f;
float lookAng = acos(lookDot); float f = lookAng > 0.0f ? freeLookSpeed / lookAng : 0.0f;
xfLook2 =
float f = 0.0f;
if (lookAng > 0.0f) {
f = freeLookSpeed / lookAng;
}
x50_lookRot =
CQuaternion::SlerpLocal(x50_lookRot, xfLook2, CMath::Clamp(0.0f, dt * 18.0f * f, 1.0f)); CQuaternion::SlerpLocal(x50_lookRot, xfLook2, CMath::Clamp(0.0f, dt * 18.0f * f, 1.0f));
x50_lookRot = xfLook2;
x60_lookDir = lookDir; x60_lookDir = lookDir;
} }
} }
@ -119,12 +114,11 @@ void CSamusFaceReflection::Draw(const CStateManager& mgr) const {
CVector3f camZHeight = height * camZcol; CVector3f camZHeight = height * camZcol;
CVector3f camYDist = dist * camYcol; CVector3f camYDist = dist * camYcol;
CVector3f vec1( CVector3f vec1(camTranslation.GetX() + camYDist.GetX() + camZHeight.GetX(),
camTranslation.GetX() + camYDist.GetX() + camZHeight.GetX(), camTranslation.GetY() + camYDist.GetY() + camZHeight.GetY(),
camTranslation.GetY() + camYDist.GetY() + camZHeight.GetY(), camTranslation.GetZ() + camYDist.GetZ() + camZHeight.GetZ());
camTranslation.GetZ() + camYDist.GetZ() + camZHeight.GetZ()); CTransform4f modelXf =
; CTransform4f((camRot * x50_lookRot).BuildTransform(), vec1) * skFaceModelViewAdjust;
CTransform4f modelXf = CTransform4f((camRot * x50_lookRot).BuildTransform(), vec1) * PreXf;
CGraphics::SetViewPointMatrix(fpCam->GetTransform()); CGraphics::SetViewPointMatrix(fpCam->GetTransform());
CGraphics::SetOrtho(aspect * -orthoWidth, aspect * orthoWidth, orthoHeight, -orthoHeight, -10.f, CGraphics::SetOrtho(aspect * -orthoWidth, aspect * orthoWidth, orthoHeight, -orthoHeight, -10.f,
@ -141,8 +135,10 @@ void CSamusFaceReflection::Draw(const CStateManager& mgr) const {
else else
transFactor = 0.f; transFactor = 0.f;
if (transFactor > 0.f) { if (transFactor > 0.f) {
x0_modelData.Render(mgr, modelXf, nullptr, CModelFlags::Additive(CColor::Black()).DepthCompareUpdate(true, true)); x0_modelData.Render(mgr, modelXf, nullptr,
x0_modelData.Render(mgr, modelXf, lights, CModelFlags::Additive(transFactor).DepthCompareUpdate(true, false)); CModelFlags::Additive(CColor::Black()).DepthCompareUpdate(true, true));
x0_modelData.Render(mgr, modelXf, lights,
CModelFlags::Additive(transFactor).DepthCompareUpdate(true, false));
} }
} }
} }