2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CWorldTransManager.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CGameState.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
|
|
|
#include "Runtime/Camera/CCameraManager.hpp"
|
|
|
|
#include "Runtime/Character/CActorLights.hpp"
|
|
|
|
#include "Runtime/Character/CAnimPlaybackParms.hpp"
|
|
|
|
#include "Runtime/Character/CAssetFactory.hpp"
|
|
|
|
#include "Runtime/Character/CCharacterFactory.hpp"
|
|
|
|
#include "Runtime/Character/CSkinRules.hpp"
|
|
|
|
#include "Runtime/Character/IAnimReader.hpp"
|
2022-02-25 07:45:25 +00:00
|
|
|
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTextSupport.hpp"
|
|
|
|
#include "Runtime/GuiSys/CStringTable.hpp"
|
|
|
|
|
2022-02-21 02:28:07 +00:00
|
|
|
#include "ConsoleVariables/CVarManager.hpp"
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
int CWorldTransManager::GetSuitCharIdx() {
|
|
|
|
CPlayerState& state = *g_GameState->GetPlayerState();
|
|
|
|
if (state.IsFusionEnabled()) {
|
|
|
|
switch (state.x20_currentSuit) {
|
|
|
|
case CPlayerState::EPlayerSuit::Power:
|
|
|
|
return 4;
|
|
|
|
case CPlayerState::EPlayerSuit::Gravity:
|
|
|
|
return 6;
|
|
|
|
case CPlayerState::EPlayerSuit::Varia:
|
|
|
|
return 7;
|
|
|
|
case CPlayerState::EPlayerSuit::Phazon:
|
|
|
|
return 8;
|
|
|
|
default:
|
|
|
|
break;
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
return int(state.x20_currentSuit);
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CWorldTransManager::SModelDatas::SModelDatas(const CAnimRes& samusRes) : x0_samusRes(samusRes) {
|
|
|
|
x1a0_lights.reserve(8);
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::UpdateLights(float dt) {
|
2020-04-07 11:23:12 +00:00
|
|
|
if (!x4_modelData) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-07 11:23:12 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
x4_modelData->x1a0_lights.clear();
|
2020-04-07 11:23:12 +00:00
|
|
|
constexpr zeus::CVector3f lightPos(0.f, 10.f, 0.f);
|
2019-02-24 07:15:54 +00:00
|
|
|
CLight spot = CLight::BuildSpot(lightPos, zeus::skBack, zeus::skWhite, 90.f);
|
2018-12-08 05:30:43 +00:00
|
|
|
spot.SetAttenuation(1.f, 0.f, 0.f);
|
|
|
|
|
|
|
|
CLight s1 = spot;
|
|
|
|
s1.SetPosition(lightPos + zeus::CVector3f{0.f, 0.f, 2.f * x18_bgOffset - x1c_bgHeight});
|
|
|
|
|
|
|
|
float z = 1.f;
|
|
|
|
float delta = x1c_bgHeight - x18_bgOffset;
|
|
|
|
if (!x44_26_goingUp && delta < 2.f)
|
|
|
|
z = delta * 0.5f;
|
|
|
|
else if (x44_26_goingUp && x18_bgOffset < 2.f)
|
|
|
|
z = x18_bgOffset * 0.5f;
|
|
|
|
|
|
|
|
if (z < 1.f) {
|
|
|
|
CLight s2 = spot;
|
|
|
|
float pos = x44_26_goingUp ? x1c_bgHeight : -x1c_bgHeight;
|
|
|
|
s2.SetPosition(lightPos + zeus::CVector3f{0.f, 0.f, pos});
|
2019-02-24 07:15:54 +00:00
|
|
|
s2.SetColor(zeus::CColor::lerp(zeus::skBlack, zeus::skWhite, 1.f - z));
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x1a0_lights.push_back(std::move(s2));
|
2019-02-24 07:15:54 +00:00
|
|
|
s1.SetColor(zeus::CColor::lerp(zeus::skBlack, zeus::skWhite, z));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x4_modelData->x1a0_lights.push_back(std::move(s1));
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::UpdateDisabled(float) {
|
|
|
|
if (x0_curTime <= 2.f)
|
|
|
|
return;
|
|
|
|
x44_24_transFinished = true;
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::UpdateEnabled(float dt) {
|
|
|
|
if (x4_modelData && !x4_modelData->x1c_samusModelData.IsNull()) {
|
|
|
|
if (x44_25_stopSoon && !x4_modelData->x1dc_dissolveStarted && x0_curTime > 2.f) {
|
|
|
|
x4_modelData->x1dc_dissolveStarted = true;
|
|
|
|
x4_modelData->x1d0_dissolveStartTime = x0_curTime;
|
|
|
|
x4_modelData->x1d4_dissolveEndTime = 4.f + x0_curTime - 2.f;
|
|
|
|
x4_modelData->x1d8_transCompleteTime = 5.f + x0_curTime - 2.f;
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_curTime > x4_modelData->x1d8_transCompleteTime && x4_modelData->x1dc_dissolveStarted)
|
|
|
|
x44_24_transFinished = true;
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x1c_samusModelData.AdvanceAnimationIgnoreParticles(dt, x20_random, true);
|
|
|
|
x4_modelData->x170_gunXf = x4_modelData->x1c_samusModelData.GetScaledLocatorTransform("GUN_LCTR");
|
2017-02-12 03:17:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x1c4_randTimeout -= dt;
|
2017-02-12 03:17:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x4_modelData->x1c4_randTimeout <= 0.f) {
|
|
|
|
x4_modelData->x1c4_randTimeout = x20_random.Range(0.016666668f, 0.1f);
|
|
|
|
zeus::CVector2f randVec(x20_random.Range(-0.025f, 0.025f), x20_random.Range(-0.075f, 0.075f));
|
|
|
|
x4_modelData->x1bc_shakeDelta = (randVec - x4_modelData->x1b4_shakeResult) / x4_modelData->x1c4_randTimeout;
|
|
|
|
x4_modelData->x1cc_blurDelta =
|
|
|
|
(x20_random.Range(-2.f, 4.f) - x4_modelData->x1c8_blurResult) / x4_modelData->x1c4_randTimeout;
|
2017-02-12 03:17:18 +00:00
|
|
|
}
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x1b4_shakeResult += x4_modelData->x1bc_shakeDelta * dt;
|
|
|
|
x4_modelData->x1c8_blurResult += dt * x4_modelData->x1cc_blurDelta;
|
|
|
|
}
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float delta = dt * 50.f;
|
|
|
|
if (x44_26_goingUp)
|
|
|
|
delta = -delta;
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x18_bgOffset += delta;
|
|
|
|
if (x18_bgOffset > x1c_bgHeight)
|
|
|
|
x18_bgOffset -= x1c_bgHeight;
|
|
|
|
if (x18_bgOffset < 0.f)
|
|
|
|
x18_bgOffset += x1c_bgHeight;
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
UpdateLights(dt);
|
|
|
|
}
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::UpdateText(float dt) {
|
|
|
|
if (x44_28_textDirty) {
|
|
|
|
if (xc_strTable.IsLoaded()) {
|
|
|
|
x8_textData->SetText(xc_strTable->GetString(x40_strIdx));
|
|
|
|
x3c_sfxInterval = 0.f;
|
|
|
|
x44_28_textDirty = false;
|
|
|
|
} else if (x0_curTime >= x38_textStartTime) {
|
|
|
|
x38_textStartTime += dt;
|
2016-08-21 00:04:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_curTime >= x38_textStartTime) {
|
|
|
|
x8_textData->Update(dt);
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float nextSfxInterval = x3c_sfxInterval + g_tweakGui->GetWorldTransManagerCharsPerSfx();
|
|
|
|
float printed = x8_textData->GetNumCharsPrinted();
|
|
|
|
if (printed >= nextSfxInterval) {
|
|
|
|
x3c_sfxInterval = nextSfxInterval;
|
|
|
|
CSfxManager::SfxStart(SFXsfx059E, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2016-08-21 00:04:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x44_25_stopSoon) {
|
|
|
|
if (x8_textData->GetTotalAnimationTime() + 1.f < x8_textData->GetCurTime()) {
|
|
|
|
/* Done typing + 1 sec */
|
|
|
|
if (x0_curTime - x34_stopTime > 1.f)
|
|
|
|
x44_24_transFinished = true;
|
|
|
|
} else {
|
|
|
|
x34_stopTime = x0_curTime;
|
|
|
|
}
|
|
|
|
}
|
2016-08-20 04:22:13 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::Update(float dt) {
|
|
|
|
x0_curTime += dt;
|
|
|
|
switch (x30_type) {
|
|
|
|
case ETransType::Disabled:
|
|
|
|
UpdateDisabled(dt);
|
|
|
|
break;
|
|
|
|
case ETransType::Enabled:
|
|
|
|
UpdateEnabled(dt);
|
|
|
|
break;
|
|
|
|
case ETransType::Text:
|
|
|
|
UpdateText(dt);
|
|
|
|
break;
|
|
|
|
}
|
2016-08-20 04:22:13 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 03:41:01 +00:00
|
|
|
void CWorldTransManager::DrawPlatformModels(CActorLights* lights) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CModelFlags flags = {};
|
2022-02-25 07:45:25 +00:00
|
|
|
// TODO flags.m_extendedShader = EExtendedShader::Lighting;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (!x4_modelData->x100_bgModelData[0].IsNull()) {
|
|
|
|
zeus::CTransform xf0 = zeus::CTransform::Translate(0.f, 0.f, -(2.f * x1c_bgHeight - x18_bgOffset));
|
2019-06-01 03:41:01 +00:00
|
|
|
x4_modelData->x100_bgModelData[0].Render(CModelData::EWhichModel::Normal, xf0, lights, flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
if (!x4_modelData->x100_bgModelData[1].IsNull()) {
|
|
|
|
zeus::CTransform xf1 = zeus::CTransform::Translate(0.f, 0.f, x18_bgOffset - x1c_bgHeight);
|
2019-06-01 03:41:01 +00:00
|
|
|
x4_modelData->x100_bgModelData[1].Render(CModelData::EWhichModel::Normal, xf1, lights, flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
if (!x4_modelData->x100_bgModelData[2].IsNull()) {
|
|
|
|
zeus::CTransform xf2 = zeus::CTransform::Translate(0.f, 0.f, x18_bgOffset);
|
2019-06-01 03:41:01 +00:00
|
|
|
x4_modelData->x100_bgModelData[2].Render(CModelData::EWhichModel::Normal, xf2, lights, flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!x4_modelData->xb4_platformModelData.IsNull()) {
|
2021-06-07 19:29:18 +00:00
|
|
|
x4_modelData->xb4_platformModelData.Render(CModelData::EWhichModel::Normal, zeus::CTransform(), lights, flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2019-06-01 03:41:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldTransManager::DrawAllModels(CActorLights* lights) {
|
2022-05-24 00:26:35 +00:00
|
|
|
// TODO this needs reimpl
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawPlatformModels(lights);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (!x4_modelData->x1c_samusModelData.IsNull()) {
|
2019-06-01 03:41:01 +00:00
|
|
|
CModelFlags flags = {};
|
2022-02-25 07:45:25 +00:00
|
|
|
// TODO flags.m_extendedShader = EExtendedShader::LightingCubeReflection;
|
2019-06-01 03:41:01 +00:00
|
|
|
|
2019-08-14 14:58:54 +00:00
|
|
|
x4_modelData->x1c_samusModelData.GetAnimationData()->PreRender();
|
2021-06-07 19:29:18 +00:00
|
|
|
x4_modelData->x1c_samusModelData.Render(CModelData::EWhichModel::Normal, zeus::CTransform(), lights, flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (!x4_modelData->x68_beamModelData.IsNull()) {
|
2019-06-01 03:41:01 +00:00
|
|
|
x4_modelData->x68_beamModelData.Render(CModelData::EWhichModel::Normal, x4_modelData->x170_gunXf, lights, flags);
|
2016-08-20 04:22:13 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-08-20 02:52:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 03:41:01 +00:00
|
|
|
void CWorldTransManager::DrawFirstPass(CActorLights* lights) {
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform translateXf = zeus::CTransform::Translate(
|
|
|
|
x4_modelData->x1b4_shakeResult.x(), -3.5f * (1.f - zeus::clamp(0.f, x0_curTime / 10.f, 1.f)) - 3.5f,
|
|
|
|
x4_modelData->x1b4_shakeResult.y() + 2.f);
|
|
|
|
zeus::CTransform rotateXf =
|
|
|
|
zeus::CTransform::RotateZ(zeus::degToRad(zeus::clamp(0.f, x0_curTime / 25.f, 100.f) * 360.f + 180.f - 90.f));
|
|
|
|
CGraphics::SetViewPointMatrix(rotateXf * translateXf);
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawAllModels(lights);
|
2022-05-19 07:57:30 +00:00
|
|
|
if (x4_modelData->x1c8_blurResult > 0.f) {
|
|
|
|
const auto backupProjectionState = CGraphics::GetProjectionState();
|
|
|
|
CCameraBlurPass blurPass;
|
|
|
|
blurPass.SetBlur(EBlurType::LoBlur, x4_modelData->x1c8_blurResult, 0.f, false);
|
|
|
|
blurPass.Draw();
|
|
|
|
CGraphics::SetProjectionState(backupProjectionState);
|
|
|
|
}
|
2015-08-20 02:52:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 03:41:01 +00:00
|
|
|
void CWorldTransManager::DrawSecondPass(CActorLights* lights) {
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CVector3f& samusScale = x4_modelData->x0_samusRes.GetScale();
|
|
|
|
zeus::CTransform translateXf =
|
|
|
|
zeus::CTransform::Translate(-0.1f * samusScale.x(), -0.5f * samusScale.y(), 1.5f * samusScale.z());
|
|
|
|
zeus::CTransform rotateXf = zeus::CTransform::RotateZ(zeus::degToRad(
|
|
|
|
48.f * zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime + 2.f) / 5.f, 1.f) + 180.f - 24.f));
|
|
|
|
CGraphics::SetViewPointMatrix(rotateXf * translateXf);
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawAllModels(lights);
|
2016-08-17 01:58:53 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::DrawEnabled() {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldTransManager::DrawEnabled", zeus::skPurple);
|
2019-06-01 03:41:01 +00:00
|
|
|
CActorLights lights(0, zeus::skZero3f, 4, 4, 0, 0, 0, 0.1f);
|
|
|
|
lights.BuildFakeLightList(x4_modelData->x1a0_lights, zeus::CColor{0.1f, 0.1f, 0.1f, 1.0f});
|
|
|
|
|
2022-05-24 00:26:35 +00:00
|
|
|
float wsAspect = 1.7777f; // TODO
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
g_Renderer->SetPerspective(CCameraManager::FirstPersonFOV(), wsAspect, CCameraManager::NearPlane(),
|
|
|
|
CCameraManager::FarPlane());
|
|
|
|
g_Renderer->x318_26_requestRGBA6 = true;
|
|
|
|
|
|
|
|
if (x0_curTime <= x4_modelData->x1d0_dissolveStartTime)
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawFirstPass(&lights);
|
2018-12-08 05:30:43 +00:00
|
|
|
else if (x0_curTime >= x4_modelData->x1d4_dissolveEndTime)
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawSecondPass(&lights);
|
2018-12-08 05:30:43 +00:00
|
|
|
else {
|
|
|
|
float t = zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime) / 2.f, 1.f);
|
2019-06-01 03:41:01 +00:00
|
|
|
DrawFirstPass(&lights);
|
2022-02-27 22:46:15 +00:00
|
|
|
SClipScreenRect rect(CGraphics::g_Viewport);
|
2022-05-13 23:40:19 +00:00
|
|
|
// CGraphics::ResolveSpareTexture(rect);
|
2022-02-01 00:06:54 +00:00
|
|
|
// CGraphics::g_BooMainCommandQueue->clearTarget(true, true);
|
2022-05-13 23:40:19 +00:00
|
|
|
// DrawSecondPass(&lights);
|
2022-02-01 00:06:54 +00:00
|
|
|
// m_dissolve.drawCropped(zeus::CColor{1.f, 1.f, 1.f, 1.f - t}, 1.f);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2022-05-19 07:57:30 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Multiply, EFilterShape::CinemaBars, zeus::skBlack, nullptr, 1.f);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
float ftbT = 0.f;
|
|
|
|
if (x0_curTime < 0.25f)
|
|
|
|
ftbT = 1.f - x0_curTime / 0.25f;
|
|
|
|
else if (x0_curTime > x4_modelData->x1d8_transCompleteTime)
|
|
|
|
ftbT = 1.f;
|
|
|
|
else if (x0_curTime > x4_modelData->x1d8_transCompleteTime - 0.25f)
|
|
|
|
ftbT = 1.f - (x4_modelData->x1d8_transCompleteTime - x0_curTime) / 0.25f;
|
|
|
|
if (ftbT > 0.f)
|
2022-05-19 07:57:30 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::CColor{0.f, ftbT}, nullptr, 1.f);
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2019-07-21 08:42:52 +00:00
|
|
|
void CWorldTransManager::DrawDisabled() {
|
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldTransManager::DrawDisabled", zeus::skPurple);
|
2022-05-19 07:57:30 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::CColor{0.f, 0.01f}, nullptr, 1.f);
|
2019-07-21 08:42:52 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void CWorldTransManager::DrawText() {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldTransManager::DrawText", zeus::skPurple);
|
2022-02-27 22:46:15 +00:00
|
|
|
float width = 448.f * CGraphics::GetViewportAspect();
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
|
2019-02-24 07:15:54 +00:00
|
|
|
CGraphics::SetViewPointMatrix(zeus::CTransform());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f));
|
2022-05-19 07:57:30 +00:00
|
|
|
// g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
|
|
|
|
// g_Renderer->SetModelMatrix(zeus::CTransform::Translate(0.f, 0.f, 0.f));
|
|
|
|
CGraphics::SetCullMode(ERglCullMode::None);
|
|
|
|
g_Renderer->SetDepthReadWrite(false, false);
|
|
|
|
g_Renderer->SetBlendMode_AdditiveAlpha();
|
2018-12-08 05:30:43 +00:00
|
|
|
x8_textData->Render();
|
|
|
|
|
|
|
|
float filterAlpha = 0.f;
|
|
|
|
if (x0_curTime < 1.f)
|
|
|
|
filterAlpha = 1.f - x0_curTime;
|
|
|
|
else if (x44_25_stopSoon)
|
|
|
|
filterAlpha = std::min(1.f, x0_curTime - x34_stopTime);
|
|
|
|
|
|
|
|
if (filterAlpha > 0.f) {
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CColor filterColor = x44_27_fadeWhite ? zeus::skWhite : zeus::skBlack;
|
2018-12-08 05:30:43 +00:00
|
|
|
filterColor.a() = filterAlpha;
|
2022-05-19 07:57:30 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, filterColor, nullptr, 1.f);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2022-05-19 07:57:30 +00:00
|
|
|
|
|
|
|
CGraphics::SetIsBeginSceneClearFb(true);
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::Draw() {
|
|
|
|
if (x30_type == ETransType::Disabled)
|
|
|
|
DrawDisabled();
|
|
|
|
else if (x30_type == ETransType::Enabled)
|
|
|
|
DrawEnabled();
|
|
|
|
else if (x30_type == ETransType::Text)
|
|
|
|
DrawText();
|
|
|
|
}
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::TouchModels() {
|
|
|
|
if (!x4_modelData)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (x4_modelData->x68_beamModelData.IsNull() && x4_modelData->x14c_beamModel.IsLoaded() &&
|
|
|
|
x4_modelData->x14c_beamModel.GetObj()) {
|
2020-03-31 03:52:22 +00:00
|
|
|
x4_modelData->x68_beamModelData = CModelData{
|
2022-02-01 00:06:54 +00:00
|
|
|
CStaticRes(x4_modelData->x14c_beamModel.GetObjectTag()->id, x4_modelData->x0_samusRes.GetScale())}; // , 2
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x4_modelData->x1c_samusModelData.IsNull() && x4_modelData->x158_suitModel.IsLoaded() &&
|
|
|
|
x4_modelData->x158_suitModel.GetObj() && x4_modelData->x164_suitSkin.IsLoaded() &&
|
|
|
|
x4_modelData->x164_suitSkin.GetObj()) {
|
|
|
|
CAnimRes animRes(x4_modelData->x0_samusRes.GetId(), GetSuitCharIdx(), x4_modelData->x0_samusRes.GetScale(),
|
|
|
|
x4_modelData->x0_samusRes.GetDefaultAnim(), true);
|
2022-02-01 00:06:54 +00:00
|
|
|
x4_modelData->x1c_samusModelData = CModelData{animRes}; // , 2
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
CAnimPlaybackParms aData(animRes.GetDefaultAnim(), -1, 1.f, true);
|
2019-08-14 14:58:54 +00:00
|
|
|
x4_modelData->x1c_samusModelData.GetAnimationData()->SetAnimation(aData, false);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!x4_modelData->x1c_samusModelData.IsNull())
|
|
|
|
x4_modelData->x1c_samusModelData.Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
|
|
|
|
if (!x4_modelData->xb4_platformModelData.IsNull())
|
|
|
|
x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
|
|
|
|
if (!x4_modelData->x100_bgModelData[0].IsNull())
|
|
|
|
x4_modelData->x100_bgModelData[0].Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
if (!x4_modelData->x100_bgModelData[1].IsNull())
|
|
|
|
x4_modelData->x100_bgModelData[1].Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
if (!x4_modelData->x100_bgModelData[2].IsNull())
|
|
|
|
x4_modelData->x100_bgModelData[2].Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
|
|
|
|
if (!x4_modelData->x68_beamModelData.IsNull())
|
|
|
|
x4_modelData->x68_beamModelData.Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
}
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, CAssetId platRes, const zeus::CVector3f& platScale,
|
|
|
|
CAssetId bgRes, const zeus::CVector3f& bgScale, bool goingUp) {
|
|
|
|
x44_25_stopSoon = false;
|
|
|
|
x44_26_goingUp = goingUp;
|
|
|
|
x30_type = ETransType::Enabled;
|
2019-09-12 03:50:38 +00:00
|
|
|
x4_modelData = std::make_unique<SModelDatas>(samusRes);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
x8_textData.reset();
|
|
|
|
x20_random.SetSeed(99);
|
|
|
|
|
|
|
|
CAssetId beamModelId = g_tweakPlayerRes->GetBeamCineModel(g_GameState->GetPlayerState()->GetCurrentBeam());
|
|
|
|
|
|
|
|
x4_modelData->x14c_beamModel = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), beamModelId});
|
|
|
|
|
|
|
|
TToken<CCharacterFactory> fac = g_CharFactoryBuilder->GetFactory(samusRes);
|
|
|
|
const CCharacterInfo& info = fac.GetObj()->GetCharInfo(GetSuitCharIdx());
|
|
|
|
x4_modelData->x158_suitModel = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), info.GetModelId()});
|
|
|
|
x4_modelData->x164_suitSkin = g_SimplePool->GetObj(SObjectTag{FOURCC('CSKR'), info.GetSkinRulesId()});
|
|
|
|
|
|
|
|
if (platRes.IsValid()) {
|
2022-02-01 00:06:54 +00:00
|
|
|
x4_modelData->xb4_platformModelData = CModelData{CStaticRes(platRes, platScale)}; // , 2
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bgRes.IsValid()) {
|
2020-03-31 03:52:22 +00:00
|
|
|
const CStaticRes bg(bgRes, bgScale);
|
|
|
|
x4_modelData->x100_bgModelData[0] = CModelData{bg};
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x100_bgModelData[0].Touch(CModelData::EWhichModel::Normal, 0);
|
2020-03-31 03:52:22 +00:00
|
|
|
x4_modelData->x100_bgModelData[1] = CModelData{bg};
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x100_bgModelData[1].Touch(CModelData::EWhichModel::Normal, 0);
|
2020-03-31 03:52:22 +00:00
|
|
|
x4_modelData->x100_bgModelData[2] = CModelData{bg};
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_modelData->x100_bgModelData[2].Touch(CModelData::EWhichModel::Normal, 0);
|
2020-03-31 03:52:22 +00:00
|
|
|
const zeus::CAABox bounds = x4_modelData->x100_bgModelData[0].GetBounds();
|
2018-12-08 05:30:43 +00:00
|
|
|
x1c_bgHeight = (bounds.max.z() - bounds.min.z()) * bgScale.z();
|
2020-03-31 03:52:22 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1c_bgHeight = 0.f;
|
2020-03-31 03:52:22 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
StartTransition();
|
|
|
|
TouchModels();
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
void CWorldTransManager::EnableTransition(CAssetId fontId, CAssetId stringId, u32 strIdx, bool fadeWhite,
|
2018-12-08 05:30:43 +00:00
|
|
|
float chFadeTime, float chFadeRate, float textStartTime) {
|
|
|
|
x40_strIdx = strIdx;
|
|
|
|
x38_textStartTime = textStartTime;
|
|
|
|
x44_25_stopSoon = false;
|
|
|
|
x30_type = ETransType::Text;
|
|
|
|
|
|
|
|
x4_modelData.reset();
|
|
|
|
x44_27_fadeWhite = fadeWhite;
|
|
|
|
|
2019-09-12 03:50:38 +00:00
|
|
|
const CGuiTextProperties props(false, true, EJustification::Center, EVerticalJustification::Center);
|
|
|
|
x8_textData = std::make_unique<CGuiTextSupport>(fontId, props, zeus::skWhite, zeus::skBlack, zeus::skWhite, 640, 448,
|
|
|
|
g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Additive);
|
2018-12-08 05:30:43 +00:00
|
|
|
x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate);
|
|
|
|
xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId});
|
|
|
|
x8_textData->SetText(u"");
|
|
|
|
StartTransition();
|
2016-08-15 20:58:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::StartTextFadeOut() {
|
|
|
|
if (!x44_25_stopSoon)
|
|
|
|
x34_stopTime = x0_curTime;
|
|
|
|
x44_25_stopSoon = true;
|
2017-02-12 03:17:18 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::DisableTransition() {
|
|
|
|
x30_type = ETransType::Disabled;
|
|
|
|
x4_modelData.reset();
|
|
|
|
x8_textData.reset();
|
|
|
|
x44_26_goingUp = false;
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::StartTransition() {
|
|
|
|
x0_curTime = 0.f;
|
|
|
|
x18_bgOffset = 0.f;
|
|
|
|
x44_24_transFinished = false;
|
|
|
|
x44_28_textDirty = true;
|
2016-08-16 22:49:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::EndTransition() { DisableTransition(); }
|
2016-08-16 22:49:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CWorldTransManager::WaitForModelsAndTextures() {
|
|
|
|
std::vector<SObjectTag> tags = g_SimplePool->GetReferencedTags();
|
|
|
|
for (const SObjectTag& tag : tags) {
|
|
|
|
if (tag.type == FOURCC('TXTR') || tag.type == FOURCC('CMDL'))
|
|
|
|
g_SimplePool->GetObj(tag).GetObj();
|
|
|
|
}
|
|
|
|
return false;
|
2017-02-12 03:17:18 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::SfxStop() {
|
|
|
|
if (x28_sfxHandle) {
|
|
|
|
CSfxManager::SfxStop(x28_sfxHandle);
|
|
|
|
x28_sfxHandle.reset();
|
|
|
|
}
|
2017-08-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWorldTransManager::SfxStart() {
|
|
|
|
if (!x28_sfxHandle && x24_sfx != 0xFFFF)
|
|
|
|
x28_sfxHandle = CSfxManager::SfxStart(x24_sfx, x2c_volume, x2d_panning, false, 127, true, -1);
|
2017-08-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|