mirror of https://github.com/AxioDL/metaforce.git
Begin transitioning to new CModel/CCubeModel & friends
This commit is contained in:
parent
c3c9f9d601
commit
832eb180bd
|
@ -1444,7 +1444,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
|
|||
zeus::CColor modColor = g_tweakAutoMapper->GetMiniMapSamusModColor();
|
||||
modColor.a() *= colorAlpha;
|
||||
CModelFlags flags(5, 0, 8 | 1, modColor); /* Depth GEqual */
|
||||
flags.m_extendedShader = EExtendedShader::DepthGEqualNoZWrite;
|
||||
// flags.m_extendedShader = EExtendedShader::DepthGEqualNoZWrite;
|
||||
x30_miniMapSamus->Draw(flags);
|
||||
}
|
||||
if (IsInMapperState(EAutoMapperState::MapScreen)) {
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
static u16 SwapBytes(u16 v);
|
||||
static u32 SwapBytes(u32 v);
|
||||
static u64 SwapBytes(u64 v);
|
||||
static s16 SwapBytes(s16 v);
|
||||
static s32 SwapBytes(s32 v);
|
||||
static s64 SwapBytes(s64 v);
|
||||
static float SwapBytes(float v);
|
||||
static double SwapBytes(double s);
|
||||
static void Swap2Bytes(u8* v);
|
||||
|
|
|
@ -155,6 +155,7 @@ u16 CBasics::SwapBytes(u16 v) {
|
|||
Swap2Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
u32 CBasics::SwapBytes(u32 v) {
|
||||
Swap4Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
|
@ -164,10 +165,27 @@ u64 CBasics::SwapBytes(u64 v) {
|
|||
Swap8Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
s16 CBasics::SwapBytes(s16 v) {
|
||||
Swap2Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
s32 CBasics::SwapBytes(s32 v) {
|
||||
Swap4Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
s64 CBasics::SwapBytes(s64 v) {
|
||||
Swap8Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
float CBasics::SwapBytes(float v) {
|
||||
Swap4Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
double CBasics::SwapBytes(double v) {
|
||||
Swap8Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
|
|
|
@ -411,7 +411,6 @@ public:
|
|||
if (m_voiceEngine) {
|
||||
m_voiceEngine->pumpAndMixVoices();
|
||||
}
|
||||
CBooModel::ClearModelUniformCounters();
|
||||
CGraphics::TickRenderTimings();
|
||||
++logvisor::FrameIndex;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "Runtime/CSortedLists.hpp"
|
||||
#include "Runtime/CTimeProvider.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CLight.hpp"
|
||||
#include "Runtime/Input/ControlMapper.hpp"
|
||||
#include "Runtime/Input/CRumbleManager.hpp"
|
||||
|
@ -658,7 +658,7 @@ zeus::CFrustum CStateManager::SetupViewForDraw(const SViewport& vp) const {
|
|||
const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this);
|
||||
const zeus::CTransform camXf = x870_cameraManager->GetCurrentCameraTransform(*this);
|
||||
g_Renderer->SetWorldViewpoint(camXf);
|
||||
CBooModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation());
|
||||
CCubeModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation(), CStopwatch::GetGlobalTimerObj());
|
||||
const int vpWidth = static_cast<int>(xf2c_viewportScale.x() * vp.x8_width);
|
||||
const int vpHeight = static_cast<int>(xf2c_viewportScale.y() * vp.xc_height);
|
||||
const int vpLeft = static_cast<int>((vp.x8_width - vpWidth) / 2 + vp.x0_left);
|
||||
|
@ -677,7 +677,7 @@ zeus::CFrustum CStateManager::SetupViewForDraw(const SViewport& vp) const {
|
|||
// g_Renderer->PrimColor(zeus::skWhite);
|
||||
CGraphics::SetModelMatrix(zeus::CTransform());
|
||||
x87c_fluidPlaneManager->StartFrame(false);
|
||||
g_Renderer->SetDebugOption(IRenderer::EDebugOption::One, 1);
|
||||
g_Renderer->SetDebugOption(IRenderer::EDebugOption::PVSState, int(EPVSVisSetState::NodeFound));
|
||||
return frustum;
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ zeus::CFrustum CStateManager::SetupViewForCubeFaceDraw(const zeus::CVector3f& po
|
|||
const zeus::CTransform mainCamXf = x870_cameraManager->GetCurrentCameraTransform(*this);
|
||||
const zeus::CTransform camXf = zeus::CTransform(mainCamXf.basis * CGraphics::skCubeBasisMats[face], pos);
|
||||
g_Renderer->SetWorldViewpoint(camXf);
|
||||
CBooModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation());
|
||||
CCubeModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation(), CStopwatch::GetGlobalTimerObj());
|
||||
constexpr float width = CUBEMAP_RES;
|
||||
g_Renderer->SetViewport(0, 0, width, width);
|
||||
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);
|
||||
|
@ -790,7 +790,6 @@ void CStateManager::DrawWorld() {
|
|||
SetupFogForArea(area);
|
||||
g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx);
|
||||
g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||
g_Renderer->UpdateAreaUniforms(area.x4_selfIdx);
|
||||
g_Renderer->DrawUnsortedGeometry(area.x4_selfIdx, mask, targetMask);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace metaforce {
|
|||
class CStopwatch {
|
||||
std::chrono::steady_clock::time_point m_start;
|
||||
|
||||
static CStopwatch g_globalTimer;
|
||||
|
||||
public:
|
||||
CStopwatch() : m_start(std::chrono::steady_clock::now()) {}
|
||||
double report(const char* name) const {
|
||||
|
@ -27,5 +29,7 @@ public:
|
|||
m_start = now;
|
||||
return t;
|
||||
}
|
||||
|
||||
static CStopwatch& GetGlobalTimerObj() { return g_globalTimer; }
|
||||
};
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool IsNull() { return m_obj == nullptr; }
|
||||
bool IsNull() const { return m_obj == nullptr; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
||||
#include "Runtime/Collision/CGameCollision.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/World/CExplosion.hpp"
|
||||
#include "Runtime/World/CGameArea.hpp"
|
||||
|
@ -435,52 +435,55 @@ void CActorLights::BuildDynamicLightList(const CStateManager& mgr, const zeus::C
|
|||
std::vector<CLight> CActorLights::BuildLightVector() const {
|
||||
std::vector<CLight> lights;
|
||||
|
||||
if (x0_areaLights.size()) {
|
||||
if (x2dc_brightLightLag && x299_25_useBrightLightLag) {
|
||||
if (!x0_areaLights.empty()) {
|
||||
if (x2dc_brightLightLag != 0 && x299_25_useBrightLightLag) {
|
||||
CLight overrideLight = x0_areaLights[0];
|
||||
overrideLight.SetColor(overrideLight.GetColor() * (1.f - x2dc_brightLightLag / 15.f));
|
||||
lights.push_back(overrideLight);
|
||||
} else
|
||||
} else {
|
||||
lights.push_back(x0_areaLights[0]);
|
||||
}
|
||||
|
||||
for (auto it = x0_areaLights.begin() + 1; it != x0_areaLights.end(); ++it) {
|
||||
lights.push_back(*it);
|
||||
}
|
||||
|
||||
if (x29c_shadowLightArrIdx > 0) {
|
||||
/* Ensure shadow light comes first for shader extension */
|
||||
std::swap(lights[0], lights[x29c_shadowLightArrIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const CLight& light : x144_dynamicLights)
|
||||
for (const CLight& light : x144_dynamicLights) {
|
||||
lights.push_back(light);
|
||||
|
||||
zeus::CColor ambColor = x288_ambientColor;
|
||||
ambColor.a() = 1.f;
|
||||
lights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor));
|
||||
}
|
||||
|
||||
return lights;
|
||||
}
|
||||
|
||||
void CActorLights::ActivateLights(CBooModel& model) const {
|
||||
std::vector<CLight> lights;
|
||||
|
||||
void CActorLights::ActivateLights() const {
|
||||
if (x298_28_inArea) {
|
||||
if (!x298_26_hasAreaLights || x299_26_ambientOnly) {
|
||||
// g_Renderer->SetAmbientColor(zeus::skWhite);
|
||||
lights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite));
|
||||
model.ActivateLights(lights);
|
||||
g_Renderer->SetAmbientColor(zeus::skWhite);
|
||||
CGraphics::DisableAllLights();
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto ambient = x288_ambientColor;
|
||||
ambient.a() = 1.f;
|
||||
g_Renderer->SetAmbientColor(ambient);
|
||||
|
||||
lights = BuildLightVector();
|
||||
model.ActivateLights(lights);
|
||||
const auto lights = BuildLightVector();
|
||||
if (lights.empty()) {
|
||||
CGraphics::DisableAllLights();
|
||||
} else {
|
||||
for (int idx = 0; const auto& item : lights) {
|
||||
CGraphics::LoadLight(static_cast<ERglLight>(idx), item);
|
||||
idx++;
|
||||
}
|
||||
// Sets n LSB to 1
|
||||
auto bits = static_cast<u8>((1 << lights.size()) + 255);
|
||||
CGraphics::SetLightState(static_cast<ERglLightBits>(bits));
|
||||
}
|
||||
|
||||
if (x298_31_disableWorldLights) {
|
||||
zeus::CColor color(x2d4_worldLightingLevel);
|
||||
g_Renderer->SetGXRegister1Color(color);
|
||||
g_Renderer->SetAmbientColor(zeus::skBlack);
|
||||
g_Renderer->SetGXRegister1Color({x2d4_worldLightingLevel});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
bool BuildAreaLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
|
||||
void BuildDynamicLightList(const CStateManager& mgr, const zeus::CAABox& aabb);
|
||||
std::vector<CLight> BuildLightVector() const;
|
||||
void ActivateLights(CBooModel& model) const;
|
||||
void ActivateLights() const;
|
||||
void SetCastShadows(bool v) { x298_25_castShadows = v; }
|
||||
void SetHasAreaLights(bool v) { x298_26_hasAreaLights = v; }
|
||||
void SetFindShadowLight(bool v) { x298_27_findShadowLight = v; }
|
||||
|
|
|
@ -258,7 +258,7 @@ std::shared_ptr<CAnimationManager> CAnimData::GetAnimationManager() { return x10
|
|||
|
||||
void CAnimData::SetPhase(float ph) { x1f8_animRoot->VSetPhase(ph); }
|
||||
|
||||
void CAnimData::Touch(const CSkinnedModel& model, int shadIdx) const { model.GetModelInst()->Touch(shadIdx); }
|
||||
void CAnimData::Touch(CSkinnedModel& model, int shadIdx) const { model.GetModel()->Touch(shadIdx); }
|
||||
|
||||
SAdvancementDeltas CAnimData::GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const {
|
||||
return x1f8_animRoot->VGetAdvancementResults(a, b).x8_deltas;
|
||||
|
@ -559,7 +559,10 @@ void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags,
|
|||
PoseSkinnedModel(model, x224_pose, drawFlags, morphEffect, morphMagnitudes);
|
||||
}
|
||||
|
||||
void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) { model.Draw(flags); }
|
||||
void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) {
|
||||
// TODO: some GX light stuff?
|
||||
model.Draw(flags);
|
||||
}
|
||||
|
||||
void CAnimData::PreRender() {
|
||||
if (!x220_31_poseCached) {
|
||||
|
@ -795,11 +798,11 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
|
|||
}
|
||||
|
||||
void CAnimData::SetXRayModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
||||
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0);
|
||||
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo());
|
||||
}
|
||||
|
||||
void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
||||
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0);
|
||||
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo());
|
||||
}
|
||||
|
||||
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
||||
|
@ -882,7 +885,9 @@ zeus::CAABox CAnimData::GetBoundingBox() const {
|
|||
|
||||
void CAnimData::SubstituteModelData(const TCachedToken<CSkinnedModel>& model) {
|
||||
xd8_modelData = model;
|
||||
x108_aabb = xd8_modelData->GetModel()->GetAABB();
|
||||
// TODO
|
||||
// xd8_modelData.CalculateDefault();
|
||||
// x108_aabb = xd8_modelData->GetBounds();
|
||||
}
|
||||
|
||||
void CAnimData::SetParticleCEXTValue(std::string_view name, int idx, float value) {
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
const CCharacterInfo& GetCharacterInfo() const { return xc_charInfo; }
|
||||
const CCharLayoutInfo& GetCharLayoutInfo() const { return *xcc_layoutData.GetObj(); }
|
||||
void SetPhase(float ph);
|
||||
void Touch(const CSkinnedModel& model, int shaderIdx) const;
|
||||
void Touch(CSkinnedModel& model, int shaderIdx) const;
|
||||
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
|
||||
CCharAnimTime GetTimeOfUserEvent(EUserEventType type, const CCharAnimTime& time) const;
|
||||
void MultiplyPlaybackRate(float mul);
|
||||
|
|
|
@ -25,10 +25,10 @@ CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag& tag,
|
|||
switch (tag.type.toUint32() & 0x1) {
|
||||
case 0:
|
||||
return TToken<CSkinnedModel>::GetIObjObjectFor(std::make_unique<CSkinnedModel>(
|
||||
*g_SimplePool, charInfo.GetModelId(), charInfo.GetSkinRulesId(), charInfo.GetCharLayoutInfoId(), 0));
|
||||
*g_SimplePool, charInfo.GetModelId(), charInfo.GetSkinRulesId(), charInfo.GetCharLayoutInfoId()));
|
||||
case 1:
|
||||
return TToken<CSkinnedModel>::GetIObjObjectFor(std::make_unique<CMorphableSkinnedModel>(
|
||||
*g_SimplePool, charInfo.GetIceModelId(), charInfo.GetIceSkinRulesId(), charInfo.GetCharLayoutInfoId(), 0));
|
||||
*g_SimplePool, charInfo.GetIceModelId(), charInfo.GetIceSkinRulesId(), charInfo.GetCharLayoutInfoId()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CSkinnedModel.hpp"
|
||||
#include "Runtime/Graphics/CVertexMorphEffect.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
|
@ -27,13 +28,11 @@ CModelData::CModelData(const CStaticRes& res) : x0_scale(res.GetScale()) {
|
|||
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
|
||||
if (!x1c_normalModel)
|
||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), res.GetId());
|
||||
m_normalModelInst = x1c_normalModel->MakeNewInstance(0);
|
||||
}
|
||||
|
||||
CModelData::CModelData(const CAnimRes& res) : x0_scale(res.GetScale()) {
|
||||
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
|
||||
x10_animData =
|
||||
factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim());
|
||||
x10_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim());
|
||||
}
|
||||
|
||||
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const {
|
||||
|
@ -48,25 +47,25 @@ void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& x
|
|||
Render(GetRenderingModel(stateMgr), xf, lights, drawFlags);
|
||||
}
|
||||
|
||||
bool CModelData::IsLoaded(int shaderIdx) const {
|
||||
bool CModelData::IsLoaded(int shaderIdx) {
|
||||
if (x10_animData) {
|
||||
if (!x10_animData->xd8_modelData->GetModel()->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
if (const CSkinnedModel* model = x10_animData->xf4_xrayModel.get())
|
||||
if (auto* model = x10_animData->xf4_xrayModel.get())
|
||||
if (!model->GetModel()->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
if (const CSkinnedModel* model = x10_animData->xf8_infraModel.get())
|
||||
if (auto* model = x10_animData->xf8_infraModel.get())
|
||||
if (!model->GetModel()->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (const CModel* model = x1c_normalModel.GetObj())
|
||||
if (auto* model = x1c_normalModel.GetObj())
|
||||
if (!model->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
if (const CModel* model = x2c_xrayModel.GetObj())
|
||||
if (auto* model = x2c_xrayModel.GetObj())
|
||||
if (!model->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
if (const CModel* model = x3c_infraModel.GetObj())
|
||||
if (auto* model = x3c_infraModel.GetObj())
|
||||
if (!model->IsLoaded(shaderIdx))
|
||||
return false;
|
||||
|
||||
|
@ -114,22 +113,23 @@ CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const {
|
|||
return *x10_animData->xd8_modelData.GetObj();
|
||||
}
|
||||
|
||||
const std::unique_ptr<CBooModel>& CModelData::PickStaticModel(EWhichModel which) const {
|
||||
const std::unique_ptr<CBooModel>* ret = nullptr;
|
||||
TLockedToken<CModel>& CModelData::PickStaticModel(EWhichModel which) {
|
||||
switch (which) {
|
||||
case EWhichModel::XRay:
|
||||
ret = &m_xrayModelInst;
|
||||
if (x2c_xrayModel) {
|
||||
return x2c_xrayModel;
|
||||
}
|
||||
break;
|
||||
case EWhichModel::Thermal:
|
||||
case EWhichModel::ThermalHot:
|
||||
ret = &m_infraModelInst;
|
||||
if (x3c_infraModel) {
|
||||
return x3c_infraModel;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ret && *ret)
|
||||
return *ret;
|
||||
return m_normalModelInst;
|
||||
return x1c_normalModel;
|
||||
}
|
||||
|
||||
void CModelData::SetXRayModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
||||
|
@ -143,7 +143,6 @@ void CModelData::SetXRayModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
|||
x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
||||
if (!x2c_xrayModel)
|
||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
||||
m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +159,6 @@ void CModelData::SetInfraModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
|||
x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
||||
if (!x3c_infraModel)
|
||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
||||
m_infraModelInst = x3c_infraModel->MakeNewInstance(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +167,7 @@ void CModelData::SetInfraModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
|||
bool CModelData::IsDefinitelyOpaque(EWhichModel which) const {
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(which);
|
||||
return model.GetModelInst()->IsOpaque();
|
||||
return model.GetModel()->IsOpaque();
|
||||
} else {
|
||||
const auto& model = PickStaticModel(which);
|
||||
return model->IsOpaque();
|
||||
|
@ -274,39 +272,33 @@ void CModelData::RenderParticles(const zeus::CFrustum& frustum) const {
|
|||
x10_animData->RenderAuxiliary(frustum);
|
||||
}
|
||||
|
||||
void CModelData::Touch(EWhichModel which, int shaderIdx) const {
|
||||
void CModelData::Touch(EWhichModel which, int shaderIdx) {
|
||||
if (x10_animData)
|
||||
x10_animData->Touch(PickAnimatedModel(which), shaderIdx);
|
||||
else
|
||||
PickStaticModel(which)->Touch(shaderIdx);
|
||||
}
|
||||
|
||||
void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) const {
|
||||
Touch(GetRenderingModel(stateMgr), shaderIdx);
|
||||
}
|
||||
void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) { Touch(GetRenderingModel(stateMgr), shaderIdx); }
|
||||
|
||||
void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor,
|
||||
const CModelFlags& flags) const {
|
||||
CModelFlags drawFlags = flags;
|
||||
drawFlags.x4_color *= mulColor;
|
||||
drawFlags.addColor = addColor;
|
||||
drawFlags.m_extendedShader = EExtendedShader::ThermalModel;
|
||||
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot);
|
||||
x10_animData->SetupRender(model, drawFlags, {}, nullptr);
|
||||
model.Draw(drawFlags);
|
||||
} else {
|
||||
const auto& model = PickStaticModel(EWhichModel::ThermalHot);
|
||||
model->Draw(drawFlags, nullptr, nullptr);
|
||||
}
|
||||
void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) {
|
||||
// TODO float* params and xc_
|
||||
// g_Renderer->DrawThermalModel(xc_, mulColor, addColor, nullptr, nullptr, flags);
|
||||
}
|
||||
|
||||
void CModelData::RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
|
||||
const CModelFlags& flags) const {
|
||||
const CModelFlags& flags) {
|
||||
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
||||
CGraphics::DisableAllLights();
|
||||
RenderThermal(mulColor, addColor, flags);
|
||||
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot);
|
||||
x10_animData->SetupRender(model, flags, {}, nullptr);
|
||||
ThermalDraw(mulColor, addColor, flags);
|
||||
} else {
|
||||
auto& model = PickStaticModel(EWhichModel::ThermalHot);
|
||||
g_Renderer->DrawThermalModel(*model, mulColor, addColor, {}, {}, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
|
@ -319,17 +311,15 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform&
|
|||
|
||||
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
||||
|
||||
const auto& model = PickStaticModel(which);
|
||||
if (lights) {
|
||||
lights->ActivateLights(*model);
|
||||
if (lights != nullptr) {
|
||||
lights->ActivateLights();
|
||||
} else {
|
||||
std::vector<CLight> useLights;
|
||||
useLights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, x18_ambientColor));
|
||||
model->ActivateLights(useLights);
|
||||
CGraphics::DisableAllLights();
|
||||
g_Renderer->SetAmbientColor(x18_ambientColor);
|
||||
}
|
||||
|
||||
model->DrawNormal(drawFlags, nullptr, nullptr);
|
||||
// Set ambient to white
|
||||
PickStaticModel(which)->DrawUnsortedParts(drawFlags);
|
||||
g_Renderer->SetAmbientColor(zeus::skWhite);
|
||||
CGraphics::DisableAllLights();
|
||||
x14_24_renderSorted = true;
|
||||
}
|
||||
|
@ -339,86 +329,82 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CAc
|
|||
if (x14_25_sortThermal && which == EWhichModel::ThermalHot) {
|
||||
zeus::CColor mul(drawFlags.x4_color.a(), drawFlags.x4_color.a());
|
||||
RenderThermal(xf, mul, {0.f, 0.f, 0.f, 0.25f}, drawFlags);
|
||||
} else {
|
||||
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
||||
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(which);
|
||||
if (lights) {
|
||||
lights->ActivateLights(*model.GetModelInst());
|
||||
} else {
|
||||
std::vector<CLight> useLights;
|
||||
useLights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, x18_ambientColor));
|
||||
model.GetModelInst()->ActivateLights(useLights);
|
||||
}
|
||||
|
||||
x10_animData->Render(model, drawFlags, std::nullopt, nullptr);
|
||||
} else {
|
||||
const auto& model = PickStaticModel(which);
|
||||
if (lights) {
|
||||
lights->ActivateLights(*model);
|
||||
} else {
|
||||
std::vector<CLight> useLights;
|
||||
useLights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, x18_ambientColor));
|
||||
model->ActivateLights(useLights);
|
||||
}
|
||||
|
||||
if (x14_24_renderSorted)
|
||||
model->DrawAlpha(drawFlags, nullptr, nullptr);
|
||||
else
|
||||
model->Draw(drawFlags, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// Set ambient to white
|
||||
CGraphics::DisableAllLights();
|
||||
x14_24_renderSorted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
||||
|
||||
if (lights != nullptr) {
|
||||
lights->ActivateLights();
|
||||
} else {
|
||||
CGraphics::DisableAllLights();
|
||||
g_Renderer->SetAmbientColor(x18_ambientColor);
|
||||
}
|
||||
|
||||
if (x10_animData) {
|
||||
x10_animData->Render(PickAnimatedModel(which), drawFlags, {}, nullptr);
|
||||
} else {
|
||||
// TODO supposed to be optional_object?
|
||||
if (x1c_normalModel) {
|
||||
auto& model = PickStaticModel(which);
|
||||
if (x14_24_renderSorted) {
|
||||
model->DrawSortedParts(drawFlags);
|
||||
} else {
|
||||
model->Draw(drawFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_Renderer->SetAmbientColor(zeus::skWhite);
|
||||
CGraphics::DisableAllLights();
|
||||
x14_24_renderSorted = false;
|
||||
}
|
||||
|
||||
void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor) {
|
||||
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(which);
|
||||
model.GetModelInst()->DisableAllLights();
|
||||
CModelFlags flags = {};
|
||||
|
||||
/* Z-prime */
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
|
||||
/* Normal Blended */
|
||||
lights->ActivateLights(*model.GetModelInst());
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = alphaColor;
|
||||
x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
|
||||
/* Selection Additive */
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = additiveColor;
|
||||
x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
} else {
|
||||
CBooModel& model = *PickStaticModel(which);
|
||||
model.DisableAllLights();
|
||||
CModelFlags flags = {};
|
||||
|
||||
/* Z-prime */
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
model.Draw(flags, nullptr, nullptr);
|
||||
|
||||
/* Normal Blended */
|
||||
lights->ActivateLights(model);
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = alphaColor;
|
||||
model.Draw(flags, nullptr, nullptr);
|
||||
|
||||
/* Selection Additive */
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = additiveColor;
|
||||
model.Draw(flags, nullptr, nullptr);
|
||||
}
|
||||
// TODO where is this method?
|
||||
// if (x10_animData) {
|
||||
// CSkinnedModel& model = PickAnimatedModel(which);
|
||||
// model.GetModelInst()->DisableAllLights();
|
||||
// CModelFlags flags = {};
|
||||
//
|
||||
// /* Z-prime */
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.x4_color = zeus::skWhite;
|
||||
// x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
//
|
||||
// /* Normal Blended */
|
||||
// lights->ActivateLights(*model.GetModelInst());
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.x4_color = alphaColor;
|
||||
// x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
//
|
||||
// /* Selection Additive */
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.x4_color = additiveColor;
|
||||
// x10_animData->Render(model, flags, std::nullopt, nullptr);
|
||||
// } else {
|
||||
// CBooModel& model = *PickStaticModel(which);
|
||||
// model.DisableAllLights();
|
||||
// CModelFlags flags = {};
|
||||
//
|
||||
// /* Z-prime */
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.x4_color = zeus::skWhite;
|
||||
// model.Draw(flags, nullptr, nullptr);
|
||||
//
|
||||
// /* Normal Blended */
|
||||
// lights->ActivateLights(model);
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.x4_color = alphaColor;
|
||||
// model.Draw(flags, nullptr, nullptr);
|
||||
//
|
||||
// /* Selection Additive */
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.x4_color = additiveColor;
|
||||
// model.Draw(flags, nullptr, nullptr);
|
||||
// }
|
||||
}
|
||||
|
||||
void CModelData::DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, const CTexture& tex,
|
||||
|
@ -430,20 +416,31 @@ void CModelData::DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf,
|
|||
const zeus::CColor& addColor, float t) {
|
||||
zeus::CTransform scaledXf = xf * zeus::CTransform::Scale(x0_scale);
|
||||
CGraphics::SetModelMatrix(scaledXf);
|
||||
|
||||
CBooModel::SetDisintegrateTexture(tex.GetTexture());
|
||||
CModelFlags flags(5, 0, 3, zeus::skWhite);
|
||||
flags.m_extendedShader = EExtendedShader::Disintegrate;
|
||||
flags.addColor = addColor;
|
||||
flags.addColor.a() = t; // Stash T value in here (shader does not care)
|
||||
|
||||
CGraphics::DisableAllLights();
|
||||
const auto aabb = GetBounds(scaledXf);
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& sModel = PickAnimatedModel(which);
|
||||
x10_animData->Render(sModel, flags, std::nullopt, nullptr);
|
||||
auto& model = PickAnimatedModel(which);
|
||||
// x10_animData->SetupRender(model, CModelFlags{}, {}, ?)
|
||||
model.DoDrawCallback([](auto positions, auto normals) {
|
||||
// TODO
|
||||
});
|
||||
} else {
|
||||
CBooModel& model = *PickStaticModel(which);
|
||||
model.Draw(flags, nullptr, nullptr);
|
||||
g_Renderer->DrawModelDisintegrate(*PickStaticModel(which), tex, addColor, {}, {});
|
||||
}
|
||||
|
||||
// CBooModel::SetDisintegrateTexture(tex.GetTexture());
|
||||
// CModelFlags flags(5, 0, 3, zeus::skWhite);
|
||||
// flags.m_extendedShader = EExtendedShader::Disintegrate;
|
||||
// flags.addColor = addColor;
|
||||
// flags.addColor.a() = t; // Stash T value in here (shader does not care)
|
||||
//
|
||||
// if (x10_animData) {
|
||||
// CSkinnedModel& sModel = PickAnimatedModel(which);
|
||||
// x10_animData->Render(sModel, flags, std::nullopt, nullptr);
|
||||
// } else {
|
||||
// CBooModel& model = *PickStaticModel(which);
|
||||
// model.Draw(flags, nullptr, nullptr);
|
||||
// }
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -71,10 +71,6 @@ class CModelData {
|
|||
TLockedToken<CModel> x2c_xrayModel;
|
||||
TLockedToken<CModel> x3c_infraModel;
|
||||
|
||||
std::unique_ptr<CBooModel> m_normalModelInst;
|
||||
std::unique_ptr<CBooModel> m_xrayModelInst;
|
||||
std::unique_ptr<CBooModel> m_infraModelInst;
|
||||
|
||||
public:
|
||||
enum class EWhichModel { Normal, XRay, Thermal, ThermalHot };
|
||||
|
||||
|
@ -90,12 +86,13 @@ public:
|
|||
static CModelData CModelDataNull();
|
||||
|
||||
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
|
||||
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
const CModelFlags& drawFlags);
|
||||
bool IsLoaded(int shaderIdx) const;
|
||||
bool IsLoaded(int shaderIdx);
|
||||
static EWhichModel GetRenderingModel(const CStateManager& stateMgr);
|
||||
CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
|
||||
const std::unique_ptr<CBooModel>& PickStaticModel(EWhichModel which) const;
|
||||
TLockedToken<CModel>& PickStaticModel(EWhichModel which);
|
||||
const TLockedToken<CModel>& PickStaticModel(EWhichModel which) const {
|
||||
return const_cast<CModelData*>(this)->PickStaticModel(which);
|
||||
}
|
||||
void SetXRayModel(const std::pair<CAssetId, CAssetId>& modelSkin);
|
||||
void SetInfraModel(const std::pair<CAssetId, CAssetId>& modelSkin);
|
||||
bool IsDefinitelyOpaque(EWhichModel) const;
|
||||
|
@ -114,13 +111,15 @@ public:
|
|||
bool IsAnimating() const;
|
||||
bool IsInFrustum(const zeus::CTransform& xf, const zeus::CFrustum& frustum) const;
|
||||
void RenderParticles(const zeus::CFrustum& frustum) const;
|
||||
void Touch(EWhichModel, int shaderIdx) const;
|
||||
void Touch(const CStateManager& stateMgr, int shaderIdx) const;
|
||||
void RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) const;
|
||||
void Touch(EWhichModel, int shaderIdx);
|
||||
void Touch(const CStateManager& stateMgr, int shaderIdx);
|
||||
void RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags);
|
||||
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
|
||||
const CModelFlags& flags) const;
|
||||
const CModelFlags& flags);
|
||||
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
const CModelFlags& drawFlags);
|
||||
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
const CModelFlags& drawFlags);
|
||||
void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags);
|
||||
|
||||
void InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
|
||||
|
@ -129,6 +128,7 @@ public:
|
|||
const zeus::CColor& addColor, float t);
|
||||
void DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf, const CTexture& tex,
|
||||
const zeus::CColor& addColor, float t);
|
||||
void ThermalDraw(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags);
|
||||
|
||||
CAnimData* GetAnimationData() { return x10_animData.get(); }
|
||||
const CAnimData* GetAnimationData() const { return x10_animData.get(); }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/IRenderer.hpp"
|
||||
#include "Runtime/Particle/CParticleGen.hpp"
|
||||
#include "Runtime/World/CGameLight.hpp"
|
||||
|
|
|
@ -19,6 +19,8 @@ struct SSkinWeighting {
|
|||
};
|
||||
|
||||
class CVirtualBone {
|
||||
friend class CSkinnedModel;
|
||||
|
||||
rstl::reserved_vector<SSkinWeighting, 3> x0_weights;
|
||||
u32 x1c_vertexCount;
|
||||
zeus::CTransform x20_xf;
|
||||
|
@ -31,6 +33,8 @@ public:
|
|||
};
|
||||
|
||||
class CSkinRules {
|
||||
friend class CSkinnedModel;
|
||||
|
||||
std::vector<CVirtualBone> x0_bones;
|
||||
u32 x10_vertexCount = 0;
|
||||
u32 x14_normalCount = 0;
|
||||
|
@ -38,17 +42,17 @@ class CSkinRules {
|
|||
public:
|
||||
explicit CSkinRules(CInputStream& in);
|
||||
|
||||
// void GetBankTransforms(std::vector<const zeus::CTransform*>& out, const CPoseAsTransforms& pose,
|
||||
// int skinBankIdx) const {
|
||||
// // FIXME: This is definitely not proper behavior, this is here to fix the phazon suit crashing
|
||||
// if (x0_skinBanks.size() <= skinBankIdx) {
|
||||
// return;
|
||||
// }
|
||||
// x0_skinBanks[skinBankIdx].GetBankTransforms(out, pose);
|
||||
// }
|
||||
// void GetBankTransforms(std::vector<const zeus::CTransform*>& out, const CPoseAsTransforms& pose,
|
||||
// int skinBankIdx) const {
|
||||
// // FIXME: This is definitely not proper behavior, this is here to fix the phazon suit crashing
|
||||
// if (x0_skinBanks.size() <= skinBankIdx) {
|
||||
// return;
|
||||
// }
|
||||
// x0_skinBanks[skinBankIdx].GetBankTransforms(out, pose);
|
||||
// }
|
||||
|
||||
// void TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
||||
// const CPoseAsTransforms& pose, const CModel& model) const;
|
||||
// void TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
||||
// const CPoseAsTransforms& pose, const CModel& model) const;
|
||||
};
|
||||
|
||||
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
||||
|
|
|
@ -13,7 +13,7 @@ class CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
|
|||
class CAiFuncMap* g_AiFuncMap = nullptr;
|
||||
class CGameState* g_GameState = nullptr;
|
||||
class CInGameTweakManagerBase* g_TweakManager = nullptr;
|
||||
class CBooRenderer* g_Renderer = nullptr;
|
||||
class CCubeRenderer* g_Renderer = nullptr;
|
||||
class CStringTable* g_MainStringTable = nullptr;
|
||||
class CTextureCache* g_TextureCache = nullptr;
|
||||
class CInputGenerator* g_InputGenerator = nullptr;
|
||||
|
|
|
@ -50,7 +50,7 @@ extern class CCharacterFactoryBuilder* g_CharFactoryBuilder;
|
|||
extern class CAiFuncMap* g_AiFuncMap;
|
||||
extern class CGameState* g_GameState;
|
||||
extern class CInGameTweakManagerBase* g_TweakManager;
|
||||
extern class CBooRenderer* g_Renderer;
|
||||
extern class CCubeRenderer* g_Renderer;
|
||||
extern class CStringTable* g_MainStringTable;
|
||||
extern class CTextureCache* g_TextureCache;
|
||||
extern class CInputGenerator* g_InputGenerator;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "Runtime/Graphics/Shaders/CThermalColdFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CThermalHotFilter.hpp"
|
||||
#include "Runtime/World/CGameArea.hpp"
|
||||
#include "CMetroidModelInstance.hpp"
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CColor.hpp>
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CToken.hpp"
|
||||
#include "GCNTypes.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "IObjectStore.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
enum class EStateFlags {
|
||||
Unused1 = 1 << 0,
|
||||
Unused2 = 1 << 1,
|
||||
Unused3 = 1 << 2,
|
||||
KonstEnabled = 1 << 3,
|
||||
DepthSorting = 1 << 4,
|
||||
AlphaTest = 1 << 5,
|
||||
Reflection = 1 << 6,
|
||||
DepthWrite = 1 << 7,
|
||||
ReflectionSurfaceEye = 1 << 8,
|
||||
OccluderMesh = 1 << 9,
|
||||
ReflectionIndirectTexture = 1 << 10,
|
||||
LightMap = 1 << 11,
|
||||
Unused4 = 1 << 12,
|
||||
LightmapUVArray = 1 << 13,
|
||||
};
|
||||
ENABLE_BITWISE_ENUM(EStateFlags);
|
||||
|
||||
class CCubeMaterial {
|
||||
const u8* x0_data;
|
||||
|
||||
public:
|
||||
explicit CCubeMaterial(const u8* data) : x0_data(data) {}
|
||||
|
||||
void SetCurrent(CModelFlags flags, const CCubeSurface& surface, const CCubeModel& model);
|
||||
|
||||
[[nodiscard]] u32 GetCompressedBlend() {
|
||||
const u32* ptr = reinterpret_cast<const u32*>(x0_data[(GetTextureCount() * 4) + 16]);
|
||||
if (IsFlagSet(EStateFlags::KonstEnabled)) {
|
||||
ptr += SBig(*ptr) + 1;
|
||||
}
|
||||
|
||||
return SBig(*ptr);
|
||||
}
|
||||
[[nodiscard]] EStateFlags GetFlags() const { return EStateFlags(SBig(*reinterpret_cast<const u32*>(x0_data))); }
|
||||
[[nodiscard]] bool IsFlagSet(EStateFlags flag) const { return True(GetFlags() & flag); }
|
||||
[[nodiscard]] u32 GetUsedTextureSlots() const { return static_cast<u32>(GetFlags()) >> 16; }
|
||||
[[nodiscard]] u32 GetTextureCount() const { return SBig(*reinterpret_cast<const u32*>(&x0_data[4])); }
|
||||
[[nodiscard]] u32 GetVertexDesc() const {
|
||||
return SBig(*reinterpret_cast<const u32*>(&x0_data[(GetTextureCount() * 4) + 8]));
|
||||
}
|
||||
|
||||
static void ResetCachedMaterials();
|
||||
};
|
||||
} // namespace metaforce
|
|
@ -1,218 +1,35 @@
|
|||
#include "Runtime/Graphics/CCubeModel.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "CCubeModel.hpp"
|
||||
|
||||
// TODO Remove WIP once we've transitioned to this
|
||||
namespace metaforce::WIP {
|
||||
#pragma region CModel
|
||||
u32 CModel::sTotalMemory = 0;
|
||||
u32 CModel::sFrameCounter = 0;
|
||||
bool CModel::sIsTextureTimeoutEnabled = true;
|
||||
CModel* CModel::sThisFrameList = nullptr;
|
||||
CModel* CModel::sOneFrameList = nullptr;
|
||||
CModel* CModel::sTwoFrameList = nullptr;
|
||||
#include "CSimplePool.hpp"
|
||||
#include "Graphics/CCubeMaterial.hpp"
|
||||
#include "Graphics/CCubeSurface.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
static u8* MemoryFromPartData(u8*& dataCur, const u32*& secSizeCur) {
|
||||
u8* ret = nullptr;
|
||||
if (*secSizeCur != 0) {
|
||||
ret = dataCur;
|
||||
}
|
||||
dataCur += SBig(*secSizeCur);
|
||||
++secSizeCur;
|
||||
return ret;
|
||||
}
|
||||
namespace metaforce {
|
||||
|
||||
CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
|
||||
: x0_data(std::move(in))
|
||||
, x4_dataLen(dataLen)
|
||||
, x34_next(sThisFrameList)
|
||||
, x38_lastFrame(CGraphics::GetFrameCounter() - 2) {
|
||||
u8* data = x0_data.get();
|
||||
u32 flags = SBig(*reinterpret_cast<u32*>(data + 8));
|
||||
u32 sectionSizeStart = 0x2c;
|
||||
if (SBig(*reinterpret_cast<u32*>(data + 4)) == 1) {
|
||||
sectionSizeStart = 0x28;
|
||||
}
|
||||
const u32* secSizeCur = reinterpret_cast<u32*>(data + sectionSizeStart);
|
||||
s32 numMatSets = 1;
|
||||
if (SBig(*reinterpret_cast<u32*>(data + 4)) > 1) {
|
||||
numMatSets = SBig(*reinterpret_cast<s32*>(data + 0x28));
|
||||
}
|
||||
u8* dataCur = data + ROUND_UP_32(sectionSizeStart + SBig(*reinterpret_cast<s32*>(data + 0x24)) * 4);
|
||||
x18_matSets.reserve(numMatSets);
|
||||
for (s32 i = 0; i < numMatSets; ++i) {
|
||||
x18_matSets.emplace_back(static_cast<u8*>(MemoryFromPartData(dataCur, secSizeCur)));
|
||||
auto& shader = x18_matSets.back();
|
||||
CCubeModel::MakeTexturesFromMats(shader.x10_data, shader.x0_textures, store, true);
|
||||
x4_dataLen += shader.x0_textures.size() * sizeof(TCachedToken<CTexture>);
|
||||
}
|
||||
|
||||
/* Metaforce note: Due to padding in zeus types we need to convert these and store locally */
|
||||
u32 numVertices = SBig(*secSizeCur) / (sizeof(float) * 3);
|
||||
const u8* positions = MemoryFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numVertices; ++i) {
|
||||
const auto* pos = reinterpret_cast<const float*>(positions + (i * (sizeof(float) * 3)));
|
||||
m_positions.emplace_back(SBig(pos[0]), SBig(pos[1]), SBig(pos[2]));
|
||||
}
|
||||
u32 numNormals = SBig(*secSizeCur);
|
||||
numNormals /= ((flags & 2) == 0 ? sizeof(float) : sizeof(s16)) * 3;
|
||||
const u8* normals = MemoryFromPartData(dataCur, secSizeCur);
|
||||
|
||||
for (u32 i = 0; i < numNormals; ++i) {
|
||||
if ((flags & 2) == 0) {
|
||||
const auto* norm = reinterpret_cast<const float*>(normals + (i * (sizeof(float) * 3)));
|
||||
m_normals.emplace_back(SBig(norm[0]), SBig(norm[1]), SBig(norm[2]));
|
||||
} else {
|
||||
const auto* norm = reinterpret_cast<const s16*>(normals + (i * (sizeof(s16) * 3)));
|
||||
m_normals.emplace_back(SBig(norm[0]) / 32767.f, SBig(norm[1]) / 32767.f,
|
||||
SBig(norm[2]) / 32767.f);
|
||||
}
|
||||
}
|
||||
u32 numColors = SBig(*secSizeCur) / (sizeof(int));
|
||||
const u8* vtxColors = MemoryFromPartData(dataCur, secSizeCur);
|
||||
|
||||
for (u32 i = 0; i < numColors; ++i) {
|
||||
const u32 col = SBig(*reinterpret_cast<const u32*>(vtxColors + (i * (sizeof(u32)))));
|
||||
m_colors.emplace_back(zeus::CColor(zeus::Comp32(col)));
|
||||
}
|
||||
|
||||
u32 numFloatUVs = SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(float) * 2);
|
||||
const u8* floatUVs = MemoryFromPartData(dataCur, secSizeCur);
|
||||
|
||||
for (u32 i = 0; i < numFloatUVs; ++i) {
|
||||
const auto* norm = reinterpret_cast<const float*>(floatUVs + (i * (sizeof(float) * 2)));
|
||||
m_floatUVs.emplace_back(SBig(norm[0]), SBig(norm[1]));
|
||||
}
|
||||
|
||||
if ((flags & 4) != 0) {
|
||||
u32 numShortUVs = SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(s16) * 2);
|
||||
const u8* shortUVs = MemoryFromPartData(dataCur, secSizeCur);
|
||||
|
||||
for (u32 i = 0; i < numShortUVs; ++i) {
|
||||
const auto* norm = reinterpret_cast<const s16*>(shortUVs + (i * (sizeof(s16) * 2)));
|
||||
m_shortUVs.emplace_back(std::array{SBig(norm[0]), SBig(norm[1])});
|
||||
}
|
||||
}
|
||||
|
||||
const u8* surfaceInfo = MemoryFromPartData(dataCur, secSizeCur);
|
||||
u32 surfaceCount = SBig(*reinterpret_cast<const u32*>(surfaceInfo));
|
||||
x8_surfaces.reserve(surfaceCount);
|
||||
|
||||
for (u32 i = 0; i < surfaceCount; ++i) {
|
||||
if (x8_surfaces.capacity() <= x8_surfaces.size()) {
|
||||
x8_surfaces.reserve(x8_surfaces.capacity() * 2);
|
||||
}
|
||||
|
||||
x8_surfaces.emplace_back(std::make_unique<CCubeSurface>(MemoryFromPartData(dataCur, secSizeCur)));
|
||||
}
|
||||
|
||||
const float* bounds = reinterpret_cast<float*>(data + 12);
|
||||
zeus::CAABox aabox = zeus::skNullBox;
|
||||
aabox.min = {SBig(bounds[0]), SBig(bounds[1]), SBig(bounds[2])};
|
||||
aabox.max = {SBig(bounds[3]), SBig(bounds[4]), SBig(bounds[5])};
|
||||
|
||||
/* This constructor has been changed from the original to take into account platform differences */
|
||||
x28_modelInst =
|
||||
std::make_unique<CCubeModel>(&x8_surfaces, &x18_matSets[0].x0_textures, x18_matSets[0].x10_data, &m_positions,
|
||||
&m_colors, &m_normals, &m_floatUVs, &m_shortUVs, aabox, flags, true, -1);
|
||||
|
||||
sThisFrameList = this;
|
||||
if (x34_next != nullptr) {
|
||||
x34_next->x30_prev = this;
|
||||
}
|
||||
x4_dataLen += x8_surfaces.size() * 4;
|
||||
sTotalMemory += x4_dataLen;
|
||||
// DCFlushRange(x0_data, dataLen);
|
||||
}
|
||||
|
||||
void CModel::UpdateLastFrame() { x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
void CModel::MoveToThisFrameList() {
|
||||
UpdateLastFrame();
|
||||
if (sThisFrameList == this) {
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveFromList();
|
||||
if (sThisFrameList != nullptr) {
|
||||
x34_next = sThisFrameList;
|
||||
x34_next->x30_prev = this;
|
||||
}
|
||||
|
||||
sThisFrameList = this;
|
||||
}
|
||||
|
||||
void CModel::RemoveFromList() {
|
||||
if (x30_prev == nullptr) {
|
||||
if (sThisFrameList == this) {
|
||||
sThisFrameList = x34_next;
|
||||
} else if (sOneFrameList == this) {
|
||||
sOneFrameList = x34_next;
|
||||
} else if (sTwoFrameList == this) {
|
||||
sTwoFrameList = x34_next;
|
||||
}
|
||||
} else {
|
||||
x30_prev->x34_next = x34_next;
|
||||
}
|
||||
if (x34_next != nullptr) {
|
||||
x34_next->x30_prev = x30_prev;
|
||||
}
|
||||
x30_prev = nullptr;
|
||||
x34_next = nullptr;
|
||||
}
|
||||
|
||||
void CModel::FrameDone() {
|
||||
++sFrameCounter;
|
||||
if (sIsTextureTimeoutEnabled) {
|
||||
auto* iter = sTwoFrameList;
|
||||
while (iter != nullptr) {
|
||||
auto* next = iter->x34_next;
|
||||
iter->VerifyCurrentShader(0);
|
||||
for (auto& shader : iter->x18_matSets) {
|
||||
shader.UnlockTextures();
|
||||
}
|
||||
|
||||
iter->x28_modelInst->UnlockTextures();
|
||||
iter->x34_next = nullptr;
|
||||
iter->x30_prev = nullptr;
|
||||
iter = next;
|
||||
}
|
||||
|
||||
sTwoFrameList = sOneFrameList;
|
||||
sOneFrameList = sThisFrameList;
|
||||
sThisFrameList = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CModel::EnableTextureTimeout() { sIsTextureTimeoutEnabled = true; }
|
||||
void CModel::DisableTextureTimeout() { sIsTextureTimeoutEnabled = false; }
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CCubeModel
|
||||
|
||||
CCubeModel::CCubeModel(std::vector<std::unique_ptr<CCubeSurface>>* surfaces,
|
||||
std::vector<TCachedToken<CTexture>>* textures, const u8* materialData,
|
||||
const std::vector<zeus::CVector3f>* positions, const std::vector<zeus::CColor>* colors,
|
||||
const std::vector<zeus::CVector3f>* normals, const std::vector<zeus::CVector2f>* texCoords,
|
||||
const std::vector<std::array<s16, 2>>* packedTexCoords, const zeus::CAABox& aabox, u8 flags,
|
||||
bool b1, u32 idx)
|
||||
CCubeModel::CCubeModel(std::vector<CCubeSurface>* surfaces, std::vector<TCachedToken<CTexture>>* textures,
|
||||
u8* materialData, std::vector<zeus::CVector3f>* positions, std::vector<zeus::CColor>* colors,
|
||||
std::vector<zeus::CVector3f>* normals, std::vector<zeus::CVector2f>* texCoords,
|
||||
std::vector<zeus::CVector2f>* packedTexCoords, const zeus::CAABox& aabb, u8 flags, bool b1,
|
||||
u32 idx)
|
||||
: x0_modelInstance(surfaces, materialData, positions, colors, normals, texCoords, packedTexCoords)
|
||||
, x1c_textures(textures)
|
||||
, x20_worldAABB(aabox)
|
||||
, x40_24_(!b1)
|
||||
, x20_worldAABB(aabb)
|
||||
, x40_24_texturesLoaded(!b1)
|
||||
, x41_visorFlags(flags)
|
||||
, x44_idx(idx) {
|
||||
for (const auto& surf : x0_modelInstance.Surfaces()) {
|
||||
surf->SetParent(this);
|
||||
for (auto& surf : *x0_modelInstance.Surfaces()) {
|
||||
surf.SetParent(this);
|
||||
}
|
||||
|
||||
for (u32 i = x0_modelInstance.Surfaces().size(); i > 0; --i) {
|
||||
const auto& surf = x0_modelInstance.Surfaces()[i - 1];
|
||||
if (!GetMaterialByIndex(surf->GetMaterialIndex()).IsFlagSet(EStateFlags::DepthSorting)) {
|
||||
surf->SetNextSurface(x38_firstUnsortedSurf);
|
||||
x38_firstUnsortedSurf = surf.get();
|
||||
for (u32 i = x0_modelInstance.Surfaces()->size(); i > 0; --i) {
|
||||
auto& surf = (*x0_modelInstance.Surfaces())[i - 1];
|
||||
if (!GetMaterialByIndex(surf.GetMaterialIndex()).IsFlagSet(EStateFlags::DepthSorting)) {
|
||||
surf.SetNextSurface(x38_firstUnsortedSurf);
|
||||
x38_firstUnsortedSurf = &surf;
|
||||
} else {
|
||||
surf->SetNextSurface(x3c_firstSortedSurf);
|
||||
x3c_firstSortedSurf = surf.get();
|
||||
surf.SetNextSurface(x3c_firstSortedSurf);
|
||||
x3c_firstSortedSurf = &surf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,10 +46,41 @@ CCubeMaterial CCubeModel::GetMaterialByIndex(u32 idx) {
|
|||
return CCubeMaterial(matData + materialOffset + (materialCount * 4) + 4);
|
||||
}
|
||||
|
||||
void CCubeModel::UnlockTextures() {
|
||||
for (TCachedToken<CTexture>& tex : *x1c_textures) {
|
||||
tex.Unlock();
|
||||
bool CCubeModel::TryLockTextures() {
|
||||
if (!x40_24_texturesLoaded) {
|
||||
bool texturesPumped = false;
|
||||
for (auto& texture : *x1c_textures) {
|
||||
texture.Lock();
|
||||
bool loadTexture = true;
|
||||
if (!texture.HasReference()) {
|
||||
if (!texture.IsLocked() || texture.IsNull()) {
|
||||
loadTexture = false;
|
||||
} else {
|
||||
texture.GetObj();
|
||||
}
|
||||
}
|
||||
if (loadTexture) {
|
||||
// texture->LoadToMRAM();
|
||||
texturesPumped = true;
|
||||
}
|
||||
}
|
||||
if (!texturesPumped) {
|
||||
x40_24_texturesLoaded = true;
|
||||
}
|
||||
}
|
||||
return x40_24_texturesLoaded;
|
||||
}
|
||||
|
||||
void CCubeModel::UnlockTextures() {
|
||||
for (auto& token : *x1c_textures) {
|
||||
token.Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void CCubeModel::RemapMaterialData(u8* data, std::vector<TCachedToken<CTexture>>& textures) {
|
||||
x0_modelInstance.SetMaterialPointer(data);
|
||||
x1c_textures = &textures;
|
||||
x40_24_texturesLoaded = false;
|
||||
}
|
||||
|
||||
void CCubeModel::MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CTexture>>& textures, IObjectStore* store,
|
||||
|
@ -249,30 +97,4 @@ void CCubeModel::MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CT
|
|||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CCubeSurface
|
||||
CCubeSurface::CCubeSurface(u8* ptr) : x0_data(ptr) {
|
||||
CMemoryInStream mem(ptr, 10000, CMemoryInStream::EOwnerShip::NotOwned); // Oversized so we can read everything in
|
||||
x0_center = mem.Get<zeus::CVector3f>();
|
||||
xc_materialIndex = mem.ReadLong();
|
||||
x10_displayListSize = mem.ReadLong();
|
||||
x14_parent = reinterpret_cast<CCubeModel*>(mem.ReadLong());
|
||||
x18_nextSurface = reinterpret_cast<CCubeSurface*>(mem.ReadLong());
|
||||
x1c_extraSize = mem.ReadLong();
|
||||
x20_normal = mem.Get<zeus::CVector3f>();
|
||||
if (x1c_extraSize > 0) {
|
||||
x2c_bounds = mem.Get<zeus::CAABox>();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
CFactoryFnReturn FModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) {
|
||||
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
||||
CFactoryFnReturn ret = TToken<CModel>::GetIObjObjectFor(std::make_unique<CModel>(std::move(in), len, sp));
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace metaforce::WIP
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -3,84 +3,42 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
#include "Runtime/IObjectStore.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "CStopwatch.hpp"
|
||||
#include "CToken.hpp"
|
||||
#include "GCNTypes.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "IObjectStore.hpp"
|
||||
|
||||
namespace metaforce::WIP {
|
||||
namespace metaforce {
|
||||
class CCubeSurface;
|
||||
class CCubeModel;
|
||||
class CCubeMaterial;
|
||||
struct CModelFlags;
|
||||
|
||||
#pragma region CModel
|
||||
class CModel {
|
||||
public:
|
||||
struct SShader {
|
||||
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||
const u8* x10_data;
|
||||
|
||||
explicit SShader(const u8* data) : x10_data(data) {}
|
||||
|
||||
void UnlockTextures(){};
|
||||
};
|
||||
|
||||
private:
|
||||
static u32 sTotalMemory;
|
||||
static u32 sFrameCounter;
|
||||
static bool sIsTextureTimeoutEnabled;
|
||||
static CModel* sThisFrameList;
|
||||
static CModel* sOneFrameList;
|
||||
static CModel* sTwoFrameList;
|
||||
|
||||
std::unique_ptr<u8[]> x0_data;
|
||||
u32 x4_dataLen;
|
||||
std::vector<std::unique_ptr<CCubeSurface>> x8_surfaces; // Was a vector of void*
|
||||
std::vector<SShader> x18_matSets;
|
||||
std::unique_ptr<CCubeModel> x28_modelInst = nullptr;
|
||||
u16 x2c_ = 0;
|
||||
u16 x2e_ = 0;
|
||||
CModel* x30_prev = nullptr;
|
||||
CModel* x34_next;
|
||||
u32 x38_lastFrame;
|
||||
/* Resident copies of maintained data */
|
||||
std::vector<zeus::CVector3f> m_positions;
|
||||
std::vector<zeus::CVector3f> m_normals;
|
||||
std::vector<zeus::CColor> m_colors;
|
||||
std::vector<zeus::CVector2f> m_floatUVs;
|
||||
std::vector<std::array<s16, 2>> m_shortUVs;
|
||||
|
||||
public:
|
||||
CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store);
|
||||
|
||||
void UpdateLastFrame();
|
||||
void MoveToThisFrameList();
|
||||
void RemoveFromList();
|
||||
void VerifyCurrentShader(s32 idx){};
|
||||
static void FrameDone();
|
||||
static void EnableTextureTimeout();
|
||||
static void DisableTextureTimeout();
|
||||
enum class ESurfaceSelection {
|
||||
Unsorted,
|
||||
Sorted,
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
// These parameters were originally float*
|
||||
using TVectorRef = const std::vector<zeus::CVector3f>*;
|
||||
|
||||
#pragma region CCubeModel
|
||||
class CCubeModel {
|
||||
friend class CModel;
|
||||
|
||||
private:
|
||||
class ModelInstance {
|
||||
const std::vector<std::unique_ptr<CCubeSurface>>* x0_surfacePtrs; // was a pointer to vector of void
|
||||
const u8* x4_materialData;
|
||||
const std::vector<zeus::CVector3f>* x8_positions; // was a pointer to void
|
||||
const std::vector<zeus::CVector3f>* xc_normals; // was a pointer to void
|
||||
const std::vector<zeus::CColor>* x10_colors; // was a pointer to void
|
||||
const std::vector<zeus::CVector2f>* x14_texCoords; // was a pointer to void
|
||||
const std::vector<std::array<s16, 2>>* x18_packedTexCoords; // was a pointer to void
|
||||
std::vector<CCubeSurface>* x0_surfacePtrs; // was rstl::vector<void*>*
|
||||
u8* x4_materialData; //
|
||||
std::vector<zeus::CVector3f>* x8_positions; // was void*
|
||||
std::vector<zeus::CVector3f>* xc_normals; // was void*
|
||||
std::vector<zeus::CColor>* x10_colors; // was void*
|
||||
std::vector<zeus::CVector2f>* x14_texCoords; // was void*
|
||||
std::vector<zeus::CVector2f>* x18_packedTexCoords; // was void*
|
||||
|
||||
public:
|
||||
ModelInstance(std::vector<std::unique_ptr<CCubeSurface>>* surfaces, const u8* material,
|
||||
const std::vector<zeus::CVector3f>* positions, const std::vector<zeus::CColor>* colors,
|
||||
const std::vector<zeus::CVector3f>* normals, const std::vector<zeus::CVector2f>* texCoords,
|
||||
const std::vector<std::array<s16, 2>>* packedTexCoords)
|
||||
ModelInstance(std::vector<CCubeSurface>* surfaces, u8* material, std::vector<zeus::CVector3f>* positions,
|
||||
std::vector<zeus::CColor>* colors, std::vector<zeus::CVector3f>* normals,
|
||||
std::vector<zeus::CVector2f>* texCoords, std::vector<zeus::CVector2f>* packedTexCoords)
|
||||
: x0_surfacePtrs(surfaces)
|
||||
, x4_materialData(material)
|
||||
, x8_positions(positions)
|
||||
|
@ -89,17 +47,18 @@ private:
|
|||
, x14_texCoords(texCoords)
|
||||
, x18_packedTexCoords(packedTexCoords) {}
|
||||
|
||||
/* These functions have been slightly modified from their original to return the actual vector instead of a raw
|
||||
/*
|
||||
* These functions have been slightly modified from their original to return the actual vector instead of a raw
|
||||
* pointer
|
||||
*/
|
||||
[[nodiscard]] const std::vector<std::unique_ptr<CCubeSurface>>& Surfaces() const { return *x0_surfacePtrs; }
|
||||
[[nodiscard]] const u8* GetMaterialPointer() const { return x4_materialData; }
|
||||
void SetMaterialPointer(const u8* mat) { x4_materialData = mat; }
|
||||
[[nodiscard]] const std::vector<zeus::CVector3f>& GetVertexPointer() const { return *x8_positions; }
|
||||
[[nodiscard]] const std::vector<zeus::CVector3f>& GetNormalPointer() const { return *xc_normals; }
|
||||
[[nodiscard]] const std::vector<zeus::CColor>& GetColorPointer() const { return *x10_colors; }
|
||||
[[nodiscard]] const std::vector<zeus::CVector2f>& GetTCPointer() const { return *x14_texCoords; }
|
||||
[[nodiscard]] const std::vector<std::array<s16, 2>>& GetPackedTCPointer() const { return *x18_packedTexCoords; }
|
||||
[[nodiscard]] std::vector<CCubeSurface>* Surfaces() const { return x0_surfacePtrs; }
|
||||
[[nodiscard]] u8* GetMaterialPointer() const { return x4_materialData; }
|
||||
void SetMaterialPointer(u8* mat) { x4_materialData = mat; }
|
||||
[[nodiscard]] TVectorRef GetVertexPointer() const { return x8_positions; }
|
||||
[[nodiscard]] TVectorRef GetNormalPointer() const { return xc_normals; }
|
||||
[[nodiscard]] std::vector<zeus::CColor>* GetColorPointer() const { return x10_colors; }
|
||||
[[nodiscard]] std::vector<zeus::CVector2f>* GetTCPointer() const { return x14_texCoords; }
|
||||
[[nodiscard]] std::vector<zeus::CVector2f>* GetPackedTCPointer() const { return x18_packedTexCoords; }
|
||||
};
|
||||
|
||||
ModelInstance x0_modelInstance;
|
||||
|
@ -107,98 +66,51 @@ private:
|
|||
zeus::CAABox x20_worldAABB;
|
||||
CCubeSurface* x38_firstUnsortedSurf = nullptr;
|
||||
CCubeSurface* x3c_firstSortedSurf = nullptr;
|
||||
bool x40_24_;
|
||||
bool x40_24_texturesLoaded : 1 = false;
|
||||
bool x40_25_modelVisible : 1 = false;
|
||||
u8 x41_visorFlags;
|
||||
u32 x44_idx;
|
||||
|
||||
public:
|
||||
CCubeModel(std::vector<std::unique_ptr<CCubeSurface>>* surfaces,
|
||||
std::vector<TCachedToken<CTexture>>* textures, const u8* materialData,
|
||||
const std::vector<zeus::CVector3f>* positions, const std::vector<zeus::CColor>* colors,
|
||||
const std::vector<zeus::CVector3f>* normals, const std::vector<zeus::CVector2f>* texCoords,
|
||||
const std::vector<std::array<s16, 2>>* packedTexCoords, const zeus::CAABox& aabox, u8 flags, bool b1,
|
||||
u32 idx);
|
||||
CCubeModel(std::vector<CCubeSurface>* surfaces, std::vector<TCachedToken<CTexture>>* textures, u8* materialData,
|
||||
std::vector<zeus::CVector3f>* positions, std::vector<zeus::CColor>* colors,
|
||||
std::vector<zeus::CVector3f>* normals, std::vector<zeus::CVector2f>* texCoords,
|
||||
std::vector<zeus::CVector2f>* packedTexCoords, const zeus::CAABox& aabb, u8 flags, bool b1, u32 idx);
|
||||
|
||||
CCubeMaterial GetMaterialByIndex(u32 idx);
|
||||
bool TryLockTextures();
|
||||
void UnlockTextures();
|
||||
static void MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CTexture>>& texture, IObjectStore* store, bool b1);
|
||||
void RemapMaterialData(u8* data, std::vector<TCachedToken<CTexture>>& textures);
|
||||
void Draw(CModelFlags flags);
|
||||
void DrawAlpha(CModelFlags flags);
|
||||
void DrawFlat(TVectorRef positions, TVectorRef normals, ESurfaceSelection surfaces);
|
||||
void DrawNormal(TVectorRef positions, TVectorRef normals, ESurfaceSelection surfaces);
|
||||
void DrawNormal(CModelFlags flags);
|
||||
void DrawSurface(const CCubeSurface& surface, CModelFlags flags);
|
||||
void DrawSurfaceWireframe(const CCubeSurface& surface);
|
||||
void SetArraysCurrent();
|
||||
|
||||
TVectorRef GetPositions() const { return x0_modelInstance.GetVertexPointer(); }
|
||||
TVectorRef GetNormals() const { return x0_modelInstance.GetNormalPointer(); }
|
||||
|
||||
static void EnableShadowMaps(CTexture shadowTex, zeus::CTransform textureProjXf, u8 chan0DisableMask,
|
||||
u8 chan1EnableLightMask);
|
||||
static void DisableShadowMaps();
|
||||
static void MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CTexture>>& texture, IObjectStore* store,
|
||||
bool b1);
|
||||
static void KillCachedViewDepState();
|
||||
static void SetDrawingOccluders(bool v);
|
||||
static void SetModelWireframe();
|
||||
static void SetNewPlayerPositionAndTime(const zeus::CVector3f& pos, const CStopwatch& time);
|
||||
static void SetRenderModelBlack(bool v);
|
||||
|
||||
private:
|
||||
void Draw(TVectorRef positions, TVectorRef normals, CModelFlags flags);
|
||||
void DrawAlphaSurfaces(CModelFlags flags);
|
||||
void DrawNormalSurfaces(CModelFlags flags);
|
||||
void DrawSurfaces(CModelFlags flags);
|
||||
void SetSkinningArraysCurrent(TVectorRef positions, TVectorRef normals);
|
||||
void SetStaticArraysCurrent();
|
||||
void SetUsingPackedLightmaps(bool v);
|
||||
};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CCubeSurface
|
||||
class CCubeSurface {
|
||||
static constexpr zeus::CVector3f skDefaultNormal{1.f, 0.f, 0.f};
|
||||
u8* x0_data;
|
||||
zeus::CVector3f x0_center;
|
||||
u32 xc_materialIndex;
|
||||
u32 x10_displayListSize;
|
||||
CCubeModel* x14_parent;
|
||||
CCubeSurface* x18_nextSurface;
|
||||
u32 x1c_extraSize;
|
||||
zeus::CVector3f x20_normal;
|
||||
zeus::CAABox x2c_bounds;
|
||||
|
||||
public:
|
||||
explicit CCubeSurface(u8* ptr);
|
||||
bool IsValid() const;
|
||||
void SetParent(CCubeModel* parent) { x14_parent = parent; }
|
||||
void SetNextSurface(CCubeSurface* next) { x18_nextSurface = next; }
|
||||
[[nodiscard]] u32 GetMaterialIndex() const { return xc_materialIndex; }
|
||||
[[nodiscard]] u32 GetDisplayListSize() const { return x10_displayListSize & 0x7fffffff; }
|
||||
[[nodiscard]] u32 GetNormalHint() const { return (x10_displayListSize >> 31) & 1; }
|
||||
[[nodiscard]] u8* GetDisplayList() const {
|
||||
return reinterpret_cast<u8*>(reinterpret_cast<uintptr_t>(x0_data) + GetSurfaceHeaderSize());
|
||||
}
|
||||
u32 GetSurfaceHeaderSize() const { return (0x4b + x1c_extraSize) & ~31; }
|
||||
[[nodiscard]] zeus::CVector3f GetCenter() const { return x0_center; }
|
||||
[[nodiscard]] zeus::CAABox GetBounds() const {
|
||||
return x1c_extraSize != 0 ? x2c_bounds : zeus::CAABox{x0_center, x0_center};
|
||||
}
|
||||
};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CCubeMaterial
|
||||
|
||||
enum class EStateFlags {
|
||||
Unused1 = 1 << 0,
|
||||
Unused2 = 1 << 1,
|
||||
Unused3 = 1 << 2,
|
||||
KonstEnabled = 1 << 3,
|
||||
DepthSorting = 1 << 4,
|
||||
AlphaTest = 1 << 5,
|
||||
Reflection = 1 << 6,
|
||||
DepthWrite = 1 << 7,
|
||||
ReflectionSurfaceEye = 1 << 8,
|
||||
OccluderMesh = 1 << 9,
|
||||
ReflectionIndirectTexture = 1 << 10,
|
||||
LightMap = 1 << 11,
|
||||
Unused4 = 1 << 12,
|
||||
LightmapUVArray = 1 << 13,
|
||||
};
|
||||
ENABLE_BITWISE_ENUM(EStateFlags);
|
||||
|
||||
class CCubeMaterial {
|
||||
const u8* x0_data;
|
||||
|
||||
public:
|
||||
explicit CCubeMaterial(const u8* data) : x0_data(data) {}
|
||||
|
||||
[[nodiscard]] u32 GetCompressedBlend() {
|
||||
const u32* ptr = reinterpret_cast<const u32*>(x0_data[(GetTextureCount() * 4) + 16]);
|
||||
if (IsFlagSet(EStateFlags::KonstEnabled)) {
|
||||
ptr += SBig(*ptr) + 1;
|
||||
}
|
||||
|
||||
return SBig(*ptr);
|
||||
}
|
||||
[[nodiscard]] EStateFlags GetFlags() const { return EStateFlags(SBig(*reinterpret_cast<const u32*>(x0_data))); }
|
||||
[[nodiscard]] bool IsFlagSet(EStateFlags flag) const { return True(GetFlags() & flag); }
|
||||
[[nodiscard]] u32 GetUsedTextureSlots() const { return static_cast<u32>(GetFlags()) >> 16; }
|
||||
[[nodiscard]] u32 GetTextureCount() const { return SBig(*reinterpret_cast<const u32*>(&x0_data[4])); }
|
||||
[[nodiscard]] u32 GetVertexDesc() const { return SBig(*reinterpret_cast<const u32*>(&x0_data[(GetTextureCount() * 4) + 8])); }
|
||||
};
|
||||
#pragma endregion
|
||||
|
||||
CFactoryFnReturn FModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
||||
} // namespace metaforce::WIP
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
#include "CCubeRenderer.hpp"
|
||||
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CDrawable.hpp"
|
||||
#include "Graphics/CDrawablePlaneObject.hpp"
|
||||
#include "Graphics/CLight.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
static logvisor::Module Log("CCubeRenderer");
|
||||
|
||||
static rstl::reserved_vector<CDrawable, 512> sDataHolder;
|
||||
static rstl::reserved_vector<rstl::reserved_vector<CDrawable*, 128>, 50> sBucketsHolder;
|
||||
static rstl::reserved_vector<CDrawablePlaneObject, 8> sPlaneObjectDataHolder;
|
||||
static rstl::reserved_vector<u16, 8> sPlaneObjectBucketHolder;
|
||||
|
||||
class Buckets {
|
||||
friend class CCubeRenderer;
|
||||
|
||||
static inline rstl::reserved_vector<u16, 50> sBucketIndex;
|
||||
static inline rstl::reserved_vector<CDrawable, 512>* sData = nullptr;
|
||||
static inline rstl::reserved_vector<rstl::reserved_vector<CDrawable*, 128>, 50>* sBuckets = nullptr;
|
||||
static inline rstl::reserved_vector<CDrawablePlaneObject, 8>* sPlaneObjectData = nullptr;
|
||||
static inline rstl::reserved_vector<u16, 8>* sPlaneObjectBucket = nullptr;
|
||||
static constexpr std::array skWorstMinMaxDistance{99999.0f, -99999.0f};
|
||||
static inline std::array sMinMaxDistance{0.0f, 0.0f};
|
||||
|
||||
public:
|
||||
static void Clear();
|
||||
static void Sort();
|
||||
static void InsertPlaneObject(float closeDist, float farDist, const zeus::CAABox& aabb, bool invertTest,
|
||||
const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, void* data);
|
||||
static void Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, void* data,
|
||||
const zeus::CPlane& plane, u16 extraSort);
|
||||
static void Shutdown();
|
||||
static void Init();
|
||||
};
|
||||
|
||||
void Buckets::Clear() {
|
||||
sData->clear();
|
||||
sBucketIndex.clear();
|
||||
sPlaneObjectData->clear();
|
||||
sPlaneObjectBucket->clear();
|
||||
for (rstl::reserved_vector<CDrawable*, 128>& bucket : *sBuckets) {
|
||||
bucket.clear();
|
||||
}
|
||||
sMinMaxDistance = skWorstMinMaxDistance;
|
||||
}
|
||||
|
||||
void Buckets::Sort() {
|
||||
float delta = std::max(1.f, sMinMaxDistance[1] - sMinMaxDistance[0]);
|
||||
float pitch = 49.f / delta;
|
||||
for (auto it = sPlaneObjectData->begin(); it != sPlaneObjectData->end(); ++it)
|
||||
if (sPlaneObjectBucket->size() != sPlaneObjectBucket->capacity())
|
||||
sPlaneObjectBucket->push_back(s16(it - sPlaneObjectData->begin()));
|
||||
|
||||
u32 precision = 50;
|
||||
if (sPlaneObjectBucket->size()) {
|
||||
std::sort(sPlaneObjectBucket->begin(), sPlaneObjectBucket->end(),
|
||||
[](u16 a, u16 b) { return (*sPlaneObjectData)[a].GetDistance() < (*sPlaneObjectData)[b].GetDistance(); });
|
||||
precision = 50 / u32(sPlaneObjectBucket->size() + 1);
|
||||
pitch = 1.f / (delta / float(precision - 2));
|
||||
|
||||
int accum = 0;
|
||||
for (u16 idx : *sPlaneObjectBucket) {
|
||||
++accum;
|
||||
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
||||
planeObj.x24_targetBucket = u16(precision * accum);
|
||||
}
|
||||
}
|
||||
|
||||
for (CDrawable& drawable : *sData) {
|
||||
int slot;
|
||||
float relDist = drawable.GetDistance() - sMinMaxDistance[0];
|
||||
if (sPlaneObjectBucket->empty()) {
|
||||
slot = zeus::clamp(1, int(relDist * pitch), 49);
|
||||
} else {
|
||||
slot = zeus::clamp(0, int(relDist * pitch), int(precision) - 2);
|
||||
for (u16 idx : *sPlaneObjectBucket) {
|
||||
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
||||
bool partial, full;
|
||||
if (planeObj.x3c_25_zOnly) {
|
||||
partial = drawable.GetBounds().max.z() > planeObj.GetPlane().d();
|
||||
full = drawable.GetBounds().min.z() > planeObj.GetPlane().d();
|
||||
} else {
|
||||
partial = planeObj.GetPlane().pointToPlaneDist(
|
||||
drawable.GetBounds().closestPointAlongVector(planeObj.GetPlane().normal())) > 0.f;
|
||||
full = planeObj.GetPlane().pointToPlaneDist(
|
||||
drawable.GetBounds().furthestPointAlongVector(planeObj.GetPlane().normal())) > 0.f;
|
||||
}
|
||||
bool cont;
|
||||
if (drawable.GetType() == EDrawableType::Particle)
|
||||
cont = planeObj.x3c_24_invertTest ? !partial : full;
|
||||
else
|
||||
cont = planeObj.x3c_24_invertTest ? (!partial || !full) : (partial || full);
|
||||
if (!cont)
|
||||
break;
|
||||
slot += precision;
|
||||
}
|
||||
}
|
||||
|
||||
if (slot == -1)
|
||||
slot = 49;
|
||||
rstl::reserved_vector<CDrawable*, 128>& bucket = (*sBuckets)[slot];
|
||||
if (bucket.size() < bucket.capacity())
|
||||
bucket.push_back(&drawable);
|
||||
// else
|
||||
// Log.report(logvisor::Fatal, FMT_STRING("Full bucket!!!"));
|
||||
}
|
||||
|
||||
u16 bucketIdx = u16(sBuckets->size());
|
||||
for (auto it = sBuckets->rbegin(); it != sBuckets->rend(); ++it) {
|
||||
--bucketIdx;
|
||||
sBucketIndex.push_back(bucketIdx);
|
||||
rstl::reserved_vector<CDrawable*, 128>& bucket = *it;
|
||||
if (bucket.size()) {
|
||||
std::sort(bucket.begin(), bucket.end(), [](CDrawable* a, CDrawable* b) {
|
||||
if (a->GetDistance() == b->GetDistance())
|
||||
return a->GetExtraSort() > b->GetExtraSort();
|
||||
return a->GetDistance() > b->GetDistance();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = sPlaneObjectBucket->rbegin(); it != sPlaneObjectBucket->rend(); ++it) {
|
||||
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[*it];
|
||||
rstl::reserved_vector<CDrawable*, 128>& bucket = (*sBuckets)[planeObj.x24_targetBucket];
|
||||
bucket.push_back(&planeObj);
|
||||
}
|
||||
}
|
||||
|
||||
void Buckets::InsertPlaneObject(float closeDist, float farDist, const zeus::CAABox& aabb, bool invertTest,
|
||||
const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, void* data) {
|
||||
if (sPlaneObjectData->size() == sPlaneObjectData->capacity()) {
|
||||
return;
|
||||
}
|
||||
sPlaneObjectData->emplace_back(dtype, closeDist, farDist, aabb, invertTest, plane, zOnly, data);
|
||||
}
|
||||
|
||||
void Buckets::Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, void* data,
|
||||
const zeus::CPlane& plane, u16 extraSort) {
|
||||
if (sData->size() == sData->capacity()) {
|
||||
Log.report(logvisor::Fatal, FMT_STRING("Rendering buckets filled to capacity"));
|
||||
return;
|
||||
}
|
||||
|
||||
const float dist = plane.pointToPlaneDist(pos);
|
||||
sData->emplace_back(dtype, extraSort, dist, aabb, data);
|
||||
sMinMaxDistance[0] = std::min(sMinMaxDistance[0], dist);
|
||||
sMinMaxDistance[1] = std::max(sMinMaxDistance[1], dist);
|
||||
}
|
||||
|
||||
void Buckets::Shutdown() {
|
||||
sData = nullptr;
|
||||
sBuckets = nullptr;
|
||||
sPlaneObjectData = nullptr;
|
||||
sPlaneObjectBucket = nullptr;
|
||||
}
|
||||
|
||||
void Buckets::Init() {
|
||||
sData = &sDataHolder;
|
||||
sBuckets = &sBucketsHolder;
|
||||
sBuckets->resize(50);
|
||||
sPlaneObjectData = &sPlaneObjectDataHolder;
|
||||
sPlaneObjectBucket = &sPlaneObjectBucketHolder;
|
||||
sMinMaxDistance = skWorstMinMaxDistance;
|
||||
}
|
||||
|
||||
CCubeRenderer::CCubeRenderer(IObjectStore& store, IFactory& resFac) : x8_factory(resFac), xc_store(store) {
|
||||
// void* data = xe4_blackTex.GetBitMapData();
|
||||
// memset(data, 0, 32);
|
||||
// xe4_blackTex.UnLock();
|
||||
GenerateReflectionTex();
|
||||
GenerateFogVolumeRampTex();
|
||||
GenerateSphereRampTex();
|
||||
LoadThermoPalette();
|
||||
g_Renderer = this;
|
||||
Buckets::Init();
|
||||
// GX draw sync
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,210 @@
|
|||
#pragma once
|
||||
|
||||
#include "Graphics/CCubeModel.hpp"
|
||||
#include "Graphics/CPVSVisSet.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "IRenderer.hpp"
|
||||
#include "CRandom16.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace metaforce {
|
||||
class IObjectStore;
|
||||
class IFactory;
|
||||
|
||||
class CCubeRenderer final : public IRenderer {
|
||||
// TODO function for controlling x318_26_requestRGBA6
|
||||
// then these can be removed
|
||||
friend class CMorphBallShadow;
|
||||
friend class CWorldTransManager;
|
||||
|
||||
struct CAreaListItem {
|
||||
const std::vector<CMetroidModelInstance>* x0_geometry;
|
||||
const CAreaRenderOctTree* x4_octTree;
|
||||
/* originally auto_ptrs of vectors */
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x8_textures;
|
||||
std::vector<CCubeModel*> x10_models;
|
||||
int x18_areaIdx;
|
||||
/* Per-area octree-word major, light bits minor */
|
||||
std::vector<u32> x1c_lightOctreeWords;
|
||||
|
||||
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>&& textures, std::vector<CCubeModel*>&& models,
|
||||
int areaIdx);
|
||||
};
|
||||
|
||||
struct CFogVolumeListItem {
|
||||
zeus::CTransform x0_transform;
|
||||
zeus::CColor x30_color;
|
||||
zeus::CAABox x34_aabb;
|
||||
TLockedToken<CModel> x4c_model;
|
||||
// bool x58_b; Optional for model token
|
||||
const CSkinnedModel* x5c_skinnedModel = nullptr;
|
||||
CFogVolumeListItem(const zeus::CTransform& xf, const zeus::CColor& color, const zeus::CAABox& aabb,
|
||||
const TLockedToken<CModel>* model, const CSkinnedModel* sModel)
|
||||
: x0_transform(xf), x30_color(color), x34_aabb(aabb), x5c_skinnedModel(sModel) {
|
||||
if (model)
|
||||
x4c_model = *model;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
IFactory& x8_factory;
|
||||
IObjectStore& xc_store;
|
||||
// CFont x10_font{1.f};
|
||||
// u32 x18_ = 0;
|
||||
std::list<CAreaListItem> x1c_areaListItems;
|
||||
// TODO x34...x40
|
||||
zeus::CFrustum x44_frustumPlanes; // {zeus::skIdentityMatrix4f, 1.5707964f, 1.f, 1.f, false, 100.f}
|
||||
TDrawableCallback xa8_drawableCallback = nullptr;
|
||||
void* xac_drawableCallbackUserData = nullptr;
|
||||
zeus::CPlane xb0_viewPlane{0.f, 1.f, 0.f, 0.f};
|
||||
enum class EPVSMode : u8 { Mask, PVS, PVSAndMask } xc0_pvsMode = EPVSMode::Mask;
|
||||
std::optional<CPVSVisSet> xc8_pvs;
|
||||
// bool xdc_;
|
||||
u32 xe0_pvsAreaIdx = UINT32_MAX;
|
||||
CTexture xe4_blackTex{ETexelFormat::RGB565, 4, 4, 1};
|
||||
u32 x14c_ = 0;
|
||||
CTexture x150_reflectionTex{ETexelFormat::IA8, 32, 32, 1};
|
||||
CTexture x1b8_fogVolumeRamp{ETexelFormat::I8, 256, 256, 1};
|
||||
CTexture x220_sphereRamp{ETexelFormat::I8, 32, 32, 1};
|
||||
// CGraphicsPalette x288_thermoPalette{1, 16};
|
||||
CRandom16 x2a8_thermalRand{20};
|
||||
std::list<CFogVolumeListItem> x2ac_fogVolumes;
|
||||
std::list<std::pair<zeus::CVector3f, float>> x2c4_spaceWarps;
|
||||
u32 x2dc_reflectionAge = 2;
|
||||
zeus::CColor x2e0_ = zeus::skWhite;
|
||||
zeus::CVector3f x2e4_ = zeus::skForward;
|
||||
float x2f0_thermalVisorLevel = 1.f;
|
||||
zeus::CColor x2f4_thermColor{1.f, 0.f, 1.f, 1.f};
|
||||
float x2f8_thermColdScale = 0.f; // ??? byte in code
|
||||
zeus::CColor x2fc_tevReg1Color{1.f, 0.f, 1.f, 1.f};
|
||||
std::vector<CLight> x300_dynamicLights;
|
||||
u32 x310_phazonSuitMaskCountdown = 0;
|
||||
CTexture* x314_phazonSuitMask = nullptr;
|
||||
bool x318_24_refectionDirty : 1 = false;
|
||||
bool x318_25_drawWireframe : 1 = false;
|
||||
bool x318_26_requestRGBA6 : 1 = false;
|
||||
bool x318_27_currentRGBA6 : 1 = false;
|
||||
bool x318_28_disableFog : 1 = false;
|
||||
bool x318_29_thermalVisor : 1 = false;
|
||||
bool x318_30_inAreaDraw : 1 = false;
|
||||
bool x318_31_persistRGBA6 : 1 = false;
|
||||
|
||||
void GenerateReflectionTex();
|
||||
void GenerateFogVolumeRampTex();
|
||||
void GenerateSphereRampTex();
|
||||
void LoadThermoPalette();
|
||||
|
||||
void ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertColor, const CTexture& maskTex,
|
||||
const CTexture& indTex, const zeus::CColor& modColor, float scale, float offX,
|
||||
float offY);
|
||||
void ReallyDrawPhazonSuitEffect(const zeus::CColor& modColor, const CTexture& maskTex);
|
||||
void DoPhazonSuitIndirectAlphaBlur(float blurRadius, float f2, const TLockedToken<CTexture>& indTex);
|
||||
|
||||
public:
|
||||
CCubeRenderer(IObjectStore& store, IFactory& resFac);
|
||||
~CCubeRenderer() override;
|
||||
|
||||
void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
||||
int areaIdx) override;
|
||||
void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override;
|
||||
void DisablePVS() override;
|
||||
void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) override;
|
||||
void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender = false) override;
|
||||
void DrawSortedGeometry(int areaIdx, int mask, int targetMask) override;
|
||||
void DrawStaticGeometry(int areaIdx, int mask, int targetMask) override;
|
||||
void DrawAreaGeometry(int areaIdx, int mask, int targetMask) override;
|
||||
void PostRenderFogs() override;
|
||||
void SetModelMatrix(const zeus::CTransform& xf) override;
|
||||
void AddParticleGen(CParticleGen& gen) override;
|
||||
void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override;
|
||||
void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) override;
|
||||
void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode,
|
||||
EDrawableSorting sorting) override;
|
||||
void SetDrawableCallback(TDrawableCallback cb, void* ctx) override;
|
||||
void SetWorldViewpoint(const zeus::CTransform& xf) override;
|
||||
void SetPerspective(float fovy, float aspect, float znear, float zfar) override;
|
||||
void SetPerspective(float fovy, float width, float height, float znear, float zfar) override;
|
||||
std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) override;
|
||||
void SetClippingPlanes(const zeus::CFrustum& frustum) override;
|
||||
void SetViewport(int left, int bottom, int width, int height) override;
|
||||
void SetDepthReadWrite(bool read, bool write) override {
|
||||
CGraphics::SetDepthWriteMode(read, ERglEnum::LEqual, write);
|
||||
}
|
||||
void SetBlendMode_AdditiveAlpha() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_AlphaBlended() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
|
||||
ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_ColorMultiply() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::Zero, ERglBlendFactor::SrcColor, ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_InvertDst() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::InvSrcColor, ERglBlendFactor::Zero,
|
||||
ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_InvertSrc() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Logic, ERglBlendFactor::One, ERglBlendFactor::Zero, ERglLogicOp::InvCopy);
|
||||
}
|
||||
void SetBlendMode_NoColorWrite() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::Zero, ERglBlendFactor::One, ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_Replace() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::Zero, ERglLogicOp::Clear);
|
||||
}
|
||||
void SetBlendMode_AdditiveDestColor() override {
|
||||
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcColor, ERglBlendFactor::One, ERglLogicOp::Clear);
|
||||
}
|
||||
void BeginScene() override;
|
||||
void EndScene() override;
|
||||
void SetDebugOption(EDebugOption, int) override;
|
||||
void BeginPrimitive(EPrimitiveType, int) override;
|
||||
void BeginLines(int) override;
|
||||
void BeginLineStrip(int) override;
|
||||
void BeginTriangles(int) override;
|
||||
void BeginTriangleStrip(int) override;
|
||||
void BeginTriangleFan(int) override;
|
||||
void PrimVertex(const zeus::CVector3f&) override;
|
||||
void PrimNormal(const zeus::CVector3f&) override;
|
||||
void PrimColor(float, float, float, float) override;
|
||||
void PrimColor(const zeus::CColor&) override;
|
||||
void EndPrimitive() override;
|
||||
void SetAmbientColor(const zeus::CColor& color) override;
|
||||
void DrawString(const char* string, int, int) override;
|
||||
u32 GetFPS() override;
|
||||
void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) override;
|
||||
void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) override;
|
||||
void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
|
||||
TVectorRef positions, TVectorRef normals, CModelFlags flags) override;
|
||||
void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color, TVectorRef positions,
|
||||
TVectorRef normals) override;
|
||||
void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override;
|
||||
void SetWireframeFlags(int flags) override;
|
||||
void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) override;
|
||||
void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
||||
const CSkinnedModel* sModel) override;
|
||||
void SetThermal(bool thermal, float level, const zeus::CColor& color) override;
|
||||
void SetThermalColdScale(float scale) override;
|
||||
void DoThermalBlendCold() override;
|
||||
void DoThermalBlendHot() override;
|
||||
u32 GetStaticWorldDataSize() override;
|
||||
void SetGXRegister1Color(const zeus::CColor& color) override;
|
||||
void SetWorldLightFadeLevel(float level) override;
|
||||
void SetWorldLightMultiplyColor(const zeus::CColor& color) override;
|
||||
void PrepareDynamicLights(const std::vector<CLight>& lights) override;
|
||||
|
||||
// Non-virtual functions
|
||||
void AllocatePhazonSuitMaskTexture();
|
||||
void DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod, const TLockedToken<CTexture>& indTex,
|
||||
const zeus::CColor& indirectMod, float blurRadius, float scale, float offX,
|
||||
float offY);
|
||||
void DrawXRayOutline(const zeus::CAABox& aabb);
|
||||
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
||||
int DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb);
|
||||
void DrawOverlappingWorldModelShadows(int alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb,
|
||||
float alpha);
|
||||
};
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,19 @@
|
|||
#include "CCubeSurface.hpp"
|
||||
|
||||
#include "Streams/IOStreams.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
CCubeSurface::CCubeSurface(const u8* ptr, u32 len) : x0_data(ptr) {
|
||||
CMemoryInStream mem(ptr, len, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
x0_center = mem.Get<zeus::CVector3f>();
|
||||
xc_materialIndex = mem.ReadLong();
|
||||
x10_displayListSize = mem.ReadLong();
|
||||
mem.ReadLong(); // x14_parent
|
||||
mem.ReadLong(); // x18_nextSurface
|
||||
x1c_extraSize = mem.ReadLong();
|
||||
x20_normal = mem.Get<zeus::CVector3f>();
|
||||
if (x1c_extraSize > 0) {
|
||||
x24_bounds = mem.Get<zeus::CAABox>();
|
||||
}
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GCNTypes.hpp"
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
class CCubeModel;
|
||||
|
||||
class CCubeSurface {
|
||||
static constexpr zeus::CVector3f skDefaultNormal{1.f, 0.f, 0.f};
|
||||
const u8* x0_data;
|
||||
|
||||
// Extracted from surface data
|
||||
zeus::CVector3f x0_center;
|
||||
u32 xc_materialIndex;
|
||||
u32 x10_displayListSize;
|
||||
CCubeModel* x14_parent = nullptr;
|
||||
CCubeSurface* x18_nextSurface = nullptr;
|
||||
u32 x1c_extraSize;
|
||||
zeus::CVector3f x20_normal;
|
||||
zeus::CAABox x24_bounds;
|
||||
|
||||
public:
|
||||
explicit CCubeSurface(const u8* ptr, u32 len); // Metaforce addition for extracting surface data
|
||||
// bool IsValid() const;
|
||||
void SetParent(CCubeModel* parent) { x14_parent = parent; }
|
||||
void SetNextSurface(CCubeSurface* next) { x18_nextSurface = next; }
|
||||
[[nodiscard]] u32 GetMaterialIndex() const { return xc_materialIndex; }
|
||||
[[nodiscard]] u32 GetDisplayListSize() const { return x10_displayListSize & 0x7fffffff; }
|
||||
[[nodiscard]] u32 GetNormalHint() const { return (x10_displayListSize >> 31) & 1; }
|
||||
[[nodiscard]] const u8* GetDisplayList() const { return x0_data + GetSurfaceHeaderSize(); }
|
||||
[[nodiscard]] u32 GetSurfaceHeaderSize() const { return (0x4b + x1c_extraSize) & ~31; }
|
||||
[[nodiscard]] zeus::CVector3f GetCenter() const { return x0_center; }
|
||||
[[nodiscard]] zeus::CAABox GetBounds() const {
|
||||
return x1c_extraSize != 0 ? x24_bounds : zeus::CAABox{x0_center, x0_center};
|
||||
}
|
||||
};
|
||||
} // namespace metaforce
|
|
@ -37,7 +37,7 @@ u32 CGraphics::g_FrameCounter = 0;
|
|||
u32 CGraphics::g_Framerate = 0;
|
||||
u32 CGraphics::g_FramesPast = 0;
|
||||
frame_clock::time_point CGraphics::g_FrameStartTime = frame_clock::now();
|
||||
//bool CGraphics::g_commitAsLazy = false;
|
||||
// bool CGraphics::g_commitAsLazy = false;
|
||||
|
||||
const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
||||
/* Right */
|
||||
|
@ -100,13 +100,23 @@ void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::C
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics::SetDepthWriteMode(bool test, ERglEnum comp, bool write) {}
|
||||
void CGraphics::SetDepthWriteMode(bool test, ERglEnum comp, bool write) {
|
||||
g_depthFunc = comp;
|
||||
aurora::gfx::set_depth_mode(test, comp, write);
|
||||
}
|
||||
|
||||
void CGraphics::SetBlendMode(ERglBlendMode, ERglBlendFactor, ERglBlendFactor, ERglLogicOp) {}
|
||||
void CGraphics::SetBlendMode(ERglBlendMode mode, ERglBlendFactor src, ERglBlendFactor dst, ERglLogicOp op) {
|
||||
aurora::gfx::set_blend_mode(mode, src, dst, op);
|
||||
}
|
||||
|
||||
void CGraphics::SetCullMode(ERglCullMode) {}
|
||||
void CGraphics::SetCullMode(ERglCullMode mode) {
|
||||
g_cullMode = mode;
|
||||
aurora::gfx::set_cull_mode(mode);
|
||||
}
|
||||
|
||||
void CGraphics::BeginScene() {}
|
||||
void CGraphics::BeginScene() {
|
||||
// ClearBackAndDepthBuffers();
|
||||
}
|
||||
|
||||
void CGraphics::EndScene() {
|
||||
/* Spinwait until g_NumBreakpointsWaiting is 0 */
|
||||
|
@ -127,7 +137,7 @@ void CGraphics::EndScene() {
|
|||
CTextSupportShader::UpdateBuffers();
|
||||
|
||||
/* Same with line renderer */
|
||||
// CLineRenderer::UpdateBuffers();
|
||||
// CLineRenderer::UpdateBuffers();
|
||||
|
||||
++g_FrameCounter;
|
||||
|
||||
|
@ -193,24 +203,25 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect,
|
|||
0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
}
|
||||
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
// 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
0.f, 0.f, st.x18_far / fmn, st.x14_near * st.x18_far / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
// 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb,
|
||||
// 0.f,
|
||||
// 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f, 0.f,
|
||||
0.f, st.x18_far / fmn, st.x14_near * st.x18_far / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
// 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
||||
|
@ -228,27 +239,27 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
|||
0.f, -1.f, 0.f);
|
||||
}
|
||||
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
// tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f,
|
||||
// 0.f, -1.f, 0.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
tpb / tmb, 0.f, 0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn, 0.f,
|
||||
0.f, -1.f, 0.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
// tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f,
|
||||
// 0.f, -1.f, 0.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
// tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
|
||||
// 0.f, 0.f, -1.f, 0.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb,
|
||||
0.f, 0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn, 0.f, 0.f, -1.f,
|
||||
0.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
// tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
|
||||
// 0.f, 0.f, -1.f, 0.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
float rml = g_Proj.x8_right - g_Proj.x4_left;
|
||||
float rpl = g_Proj.x8_right + g_Proj.x4_left;
|
||||
|
@ -262,24 +273,25 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
|||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, 1.f / fmn,
|
||||
g_Proj.x14_near / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
// switch (g_BooPlatform) {
|
||||
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
// default: {
|
||||
// return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f /
|
||||
// fmn,
|
||||
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
// case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, 1.f / fmn,
|
||||
g_Proj.x14_near / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
return PlusOneZ * mat2;
|
||||
// }
|
||||
// case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
// zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
// return VulkanCorrect * mat2;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,11 +476,11 @@ void CGraphics::UpdateFPSCounter() {
|
|||
}
|
||||
}
|
||||
|
||||
//boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
||||
//boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
|
||||
//boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
|
||||
//boo::ObjToken<boo::ITextureR> CGraphics::g_SpareTexture;
|
||||
//const char* CGraphics::g_BooPlatformName = nullptr;
|
||||
// boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
||||
// boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
|
||||
// boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
|
||||
// boo::ObjToken<boo::ITextureR> CGraphics::g_SpareTexture;
|
||||
// const char* CGraphics::g_BooPlatformName = nullptr;
|
||||
|
||||
const CTevCombiners::CTevPass CGraphics::sTevPass805a564c({GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO,
|
||||
GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC},
|
||||
|
|
|
@ -40,55 +40,6 @@ enum class ERglLightBits : u8 {
|
|||
};
|
||||
ENABLE_BITWISE_ENUM(ERglLightBits)
|
||||
|
||||
enum class ERglEnum { Never = 0, Less = 1, Equal = 2, LEqual = 3, Greater = 4, NEqual = 5, GEqual = 6, Always = 7 };
|
||||
|
||||
enum class ERglBlendMode { None = 0, Blend = 1, Logic = 2, Subtract = 3 };
|
||||
|
||||
enum class ERglBlendFactor {
|
||||
Zero = 0,
|
||||
One = 1,
|
||||
SrcColor = 2,
|
||||
InvSrcColor = 3,
|
||||
SrcAlpha = 4,
|
||||
InvSrcAlpha = 5,
|
||||
DstAlpha = 6,
|
||||
InvDstAlpha = 7
|
||||
};
|
||||
|
||||
enum class ERglLogicOp {
|
||||
Clear = 0,
|
||||
And = 1,
|
||||
RevAnd = 2,
|
||||
Copy = 3,
|
||||
InvAnd = 4,
|
||||
NoOp = 5,
|
||||
Xor = 6,
|
||||
Or = 7,
|
||||
Nor = 8,
|
||||
Equiv = 9,
|
||||
Inv = 10,
|
||||
RevOr = 11,
|
||||
InvCopy = 12,
|
||||
InvOr = 13,
|
||||
NAnd = 14,
|
||||
Set = 15
|
||||
};
|
||||
|
||||
enum class ERglCullMode { None = 0, Front = 1, Back = 2, All = 3 };
|
||||
|
||||
enum class ERglAlphaFunc {
|
||||
Never = 0,
|
||||
Less = 1,
|
||||
Equal = 2,
|
||||
LEqual = 3,
|
||||
Greater = 4,
|
||||
NEqual = 5,
|
||||
GEqual = 6,
|
||||
Always = 7
|
||||
};
|
||||
|
||||
enum class ERglAlphaOp { And = 0, Or = 1, Xor = 2, XNor = 3 };
|
||||
|
||||
struct SViewport {
|
||||
u32 x0_left;
|
||||
u32 x4_top;
|
||||
|
@ -247,6 +198,9 @@ public:
|
|||
static SClipScreenRect g_CroppedViewport;
|
||||
static bool g_IsGXModelMatrixIdentity;
|
||||
|
||||
static ERglEnum g_depthFunc;
|
||||
static ERglCullMode g_cullMode;
|
||||
|
||||
static void DisableAllLights();
|
||||
static void LoadLight(ERglLight light, const CLight& info);
|
||||
static void EnableLight(ERglLight light);
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
set(GRAPHICS_SOURCES
|
||||
IRenderer.hpp
|
||||
IWeaponRenderer.hpp IWeaponRenderer.cpp
|
||||
CCubeMaterial.cpp CCubeMaterial.hpp
|
||||
CCubeModel.cpp CCubeModel.hpp
|
||||
CBooRenderer.hpp CBooRenderer.cpp
|
||||
CCubeRenderer.cpp CCubeRenderer.hpp
|
||||
CCubeSurface.cpp CCubeSurface.hpp
|
||||
CDrawable.hpp
|
||||
CDrawablePlaneObject.hpp
|
||||
CLineRenderer.hpp CLineRenderer.cpp
|
||||
CMetroidModelInstance.hpp
|
||||
CMetroidModelInstance.cpp CMetroidModelInstance.hpp
|
||||
CLight.hpp CLight.cpp
|
||||
CTexture.hpp CTextureBoo.cpp
|
||||
CModel.hpp CModelBoo.cpp
|
||||
CModel.cpp CModel.hpp
|
||||
CSkinnedModel.hpp CSkinnedModel.cpp
|
||||
CVertexMorphEffect.hpp CVertexMorphEffect.cpp
|
||||
CMoviePlayer.hpp CMoviePlayer.cpp
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#include "CMetroidModelInstance.hpp"
|
||||
|
||||
#include "Graphics/CCubeSurface.hpp"
|
||||
#include "Streams/IOStreams.hpp"
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
CMetroidModelInstance::CMetroidModelInstance(std::pair<const u8*, u32> modelHeader, const u8* materialData,
|
||||
std::pair<const u8*, u32> positions, std::pair<const u8*, u32> normals,
|
||||
std::pair<const u8*, u32> colors, std::pair<const u8*, u32> texCoords,
|
||||
std::pair<const u8*, u32> packedTexCoords,
|
||||
std::vector<CCubeSurface>&& surfaces)
|
||||
: x4c_materialData(materialData), x50_surfaces(std::move(surfaces)) {
|
||||
{
|
||||
CMemoryInStream stream{modelHeader.first, modelHeader.second};
|
||||
x0_visorFlags = stream.Get<u32>();
|
||||
x4_worldXf = stream.Get<zeus::CTransform>();
|
||||
x34_worldAABB = stream.Get<zeus::CAABox>();
|
||||
}
|
||||
{
|
||||
u32 numVertices = positions.second / 12;
|
||||
CMemoryInStream stream{positions.first, positions.second};
|
||||
for (u32 i = 0; i < numVertices; ++i) {
|
||||
x60_positions.emplace_back(stream.Get<zeus::CVector3f>());
|
||||
}
|
||||
}
|
||||
{
|
||||
// Always short normals in MREA
|
||||
u32 numNormals = normals.second / 6;
|
||||
CMemoryInStream stream{normals.first, normals.second};
|
||||
for (u32 i = 0; i < numNormals; ++i) {
|
||||
x64_normals.emplace_back(static_cast<float>(stream.ReadShort()) / 16384.f,
|
||||
static_cast<float>(stream.ReadShort()) / 16384.f,
|
||||
static_cast<float>(stream.ReadShort()) / 16384.f);
|
||||
}
|
||||
}
|
||||
{
|
||||
u32 numColors = colors.second / 4;
|
||||
CMemoryInStream stream{colors.first, colors.second};
|
||||
for (u32 i = 0; i < numColors; ++i) {
|
||||
x68_colors.emplace_back(zeus::CColor(stream.ReadUint32()));
|
||||
}
|
||||
}
|
||||
{
|
||||
u32 numTexCoords = texCoords.second / 8;
|
||||
CMemoryInStream stream{texCoords.first, texCoords.second};
|
||||
for (u32 i = 0; i < numTexCoords; ++i) {
|
||||
x6c_texCoords.emplace_back(stream.Get<zeus::CVector2f>());
|
||||
}
|
||||
}
|
||||
{
|
||||
u32 numPackedTexCoords = packedTexCoords.second / 4;
|
||||
CMemoryInStream stream{packedTexCoords.first, packedTexCoords.second};
|
||||
for (u32 i = 0; i < numPackedTexCoords; ++i) {
|
||||
x70_packedTexCoords.emplace_back(static_cast<float>(stream.ReadShort()) / 32768.f,
|
||||
static_cast<float>(stream.ReadShort()) / 32768.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -5,42 +5,42 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include "Shaders/CModelShaders.hpp"
|
||||
|
||||
//#include <hecl/HMDLMeta.hpp>
|
||||
#include "Graphics/CCubeModel.hpp"
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CTransform.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
class CBooModel;
|
||||
struct CBooSurface;
|
||||
class CCubeSurface;
|
||||
|
||||
class CMetroidModelInstance {
|
||||
friend class CBooRenderer;
|
||||
friend class CGameArea;
|
||||
|
||||
int x0_visorFlags;
|
||||
zeus::CTransform x4_xf;
|
||||
zeus::CAABox x34_aabb;
|
||||
std::vector<CBooSurface> m_surfaces;
|
||||
std::unique_ptr<CBooModel> m_instance;
|
||||
// hecl::HMDLMeta m_hmdlMeta;
|
||||
// std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
u32 x0_visorFlags = 0;
|
||||
zeus::CTransform x4_worldXf;
|
||||
zeus::CAABox x34_worldAABB;
|
||||
const u8* x4c_materialData = nullptr;
|
||||
std::vector<CCubeSurface> x50_surfaces; // was rstl::vector<void*>*
|
||||
std::vector<zeus::CVector3f> x60_positions; // was void*
|
||||
std::vector<zeus::CVector3f> x64_normals; // was void*
|
||||
std::vector<zeus::CColor> x68_colors; // was void*
|
||||
std::vector<zeus::CVector2f> x6c_texCoords; // was void*
|
||||
std::vector<zeus::CVector2f> x70_packedTexCoords; // was void*
|
||||
|
||||
public:
|
||||
CMetroidModelInstance() = default;
|
||||
CMetroidModelInstance(CMetroidModelInstance&&) = default;
|
||||
void Clear() {
|
||||
x0_visorFlags = 0;
|
||||
x4_xf = {};
|
||||
x34_aabb = {};
|
||||
m_surfaces.clear();
|
||||
m_instance.reset();
|
||||
// m_hmdlMeta = {};
|
||||
// m_shaders.clear();
|
||||
}
|
||||
CMetroidModelInstance(std::pair<const u8*, u32> modelHeader, const u8* materialData,
|
||||
std::pair<const u8*, u32> positions, std::pair<const u8*, u32> normals,
|
||||
std::pair<const u8*, u32> colors, std::pair<const u8*, u32> texCoords,
|
||||
std::pair<const u8*, u32> packedTexCoords, std::vector<CCubeSurface>&& surfaces);
|
||||
|
||||
[[nodiscard]] u32 GetFlags() const { return x0_visorFlags; }
|
||||
[[nodiscard]] const zeus::CAABox& GetBoundingBox() const { return x34_worldAABB; }
|
||||
[[nodiscard]] const std::vector<CCubeSurface>* GetSurfaces() const { return &x50_surfaces; }
|
||||
[[nodiscard]] const u8* GetMaterialPointer() const { return x4c_materialData; }
|
||||
[[nodiscard]] TVectorRef GetVertexPointer() const { return &x60_positions; }
|
||||
[[nodiscard]] TVectorRef GetNormalPointer() const { return &x64_normals; }
|
||||
[[nodiscard]] const std::vector<zeus::CColor>* GetColorPointer() const { return &x68_colors; }
|
||||
[[nodiscard]] const std::vector<zeus::CVector2f>* GetTCPointer() const { return &x6c_texCoords; }
|
||||
[[nodiscard]] const std::vector<zeus::CVector2f>* GetPackedTCPointer() const { return &x70_packedTexCoords; }
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
#include "CModel.hpp"
|
||||
|
||||
#include "CBasics.hpp"
|
||||
#include "Graphics/CCubeMaterial.hpp"
|
||||
#include "Graphics/CCubeModel.hpp"
|
||||
#include "Graphics/CCubeSurface.hpp"
|
||||
#include "Streams/IOStreams.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
void CModel::SShader::UnlockTextures() {
|
||||
for (auto& token : x0_textures) {
|
||||
token.Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
u32 CModel::sTotalMemory = 0;
|
||||
u32 CModel::sFrameCounter = 0;
|
||||
bool CModel::sIsTextureTimeoutEnabled = true;
|
||||
CModel* CModel::sThisFrameList = nullptr;
|
||||
CModel* CModel::sOneFrameList = nullptr;
|
||||
CModel* CModel::sTwoFrameList = nullptr;
|
||||
|
||||
static u8* MemoryFromPartData(u8*& dataCur, const u32*& secSizeCur) {
|
||||
u8* ret = nullptr;
|
||||
if (*secSizeCur != 0) {
|
||||
ret = dataCur;
|
||||
}
|
||||
dataCur += CBasics::SwapBytes(*secSizeCur);
|
||||
++secSizeCur;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// For ease of reading byte swapped data
|
||||
static CMemoryInStream StreamFromPartData(u8*& dataCur, const u32*& secSizeCur) {
|
||||
const auto secSize = CBasics::SwapBytes(*secSizeCur);
|
||||
return {MemoryFromPartData(dataCur, secSizeCur), secSize};
|
||||
}
|
||||
|
||||
CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
|
||||
: x0_data(std::move(in))
|
||||
, x4_dataLen(dataLen)
|
||||
, x34_next(sThisFrameList)
|
||||
, x38_lastFrame(CGraphics::GetFrameCounter() - 2) {
|
||||
u8* data = x0_data.get();
|
||||
u32 flags = CBasics::SwapBytes(*reinterpret_cast<u32*>(data + 8));
|
||||
u32 sectionSizeStart = 0x2c;
|
||||
if (CBasics::SwapBytes(*reinterpret_cast<u32*>(data + 4)) == 1) {
|
||||
sectionSizeStart = 0x28;
|
||||
}
|
||||
const u32* secSizeCur = reinterpret_cast<u32*>(data + sectionSizeStart);
|
||||
s32 numMatSets = 1;
|
||||
if (CBasics::SwapBytes(*reinterpret_cast<u32*>(data + 4)) > 1) {
|
||||
numMatSets = CBasics::SwapBytes(*reinterpret_cast<s32*>(data + 0x28));
|
||||
}
|
||||
u8* dataCur = data + ROUND_UP_32(sectionSizeStart + CBasics::SwapBytes(*reinterpret_cast<s32*>(data + 0x24)) * 4);
|
||||
x18_matSets.reserve(numMatSets);
|
||||
for (s32 i = 0; i < numMatSets; ++i) {
|
||||
x18_matSets.emplace_back(MemoryFromPartData(dataCur, secSizeCur));
|
||||
auto& shader = x18_matSets.back();
|
||||
CCubeModel::MakeTexturesFromMats(shader.x10_data, shader.x0_textures, store, true);
|
||||
x4_dataLen += shader.x0_textures.size() * sizeof(TCachedToken<CTexture>);
|
||||
}
|
||||
|
||||
/* Metaforce note: Due to padding in zeus types we need to convert these and store locally */
|
||||
u32 numVertices = CBasics::SwapBytes(*secSizeCur) / 12;
|
||||
auto positions = StreamFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numVertices; ++i) {
|
||||
m_positions.emplace_back(positions.Get<zeus::CVector3f>());
|
||||
}
|
||||
|
||||
u32 numNormals = CBasics::SwapBytes(*secSizeCur);
|
||||
numNormals /= (flags & 2) == 0 ? 12 : 6;
|
||||
auto normals = StreamFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numNormals; ++i) {
|
||||
if ((flags & 2) == 0) {
|
||||
m_normals.emplace_back(normals.Get<zeus::CVector3f>());
|
||||
} else {
|
||||
m_normals.emplace_back(static_cast<float>(normals.ReadShort()) / 16384.f,
|
||||
static_cast<float>(normals.ReadShort()) / 16384.f,
|
||||
static_cast<float>(normals.ReadShort()) / 16384.f);
|
||||
}
|
||||
}
|
||||
|
||||
u32 numColors = CBasics::SwapBytes(*secSizeCur) / 4;
|
||||
auto vtxColors = StreamFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numColors; ++i) {
|
||||
m_colors.emplace_back(zeus::CColor(vtxColors.ReadUint32()));
|
||||
}
|
||||
|
||||
u32 numFloatUVs = CBasics::SwapBytes(*secSizeCur) / 8;
|
||||
auto floatUVs = StreamFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numFloatUVs; ++i) {
|
||||
m_floatUVs.emplace_back(floatUVs.Get<zeus::CVector2f>());
|
||||
}
|
||||
|
||||
if ((flags & 4) != 0) {
|
||||
u32 numShortUVs = CBasics::SwapBytes(*secSizeCur) / 4;
|
||||
auto shortUVs = StreamFromPartData(dataCur, secSizeCur);
|
||||
for (u32 i = 0; i < numShortUVs; ++i) {
|
||||
m_shortUVs.emplace_back(static_cast<float>(shortUVs.ReadShort()) / 32768.f,
|
||||
static_cast<float>(shortUVs.ReadShort()) / 32768.f);
|
||||
}
|
||||
}
|
||||
|
||||
auto surfaceInfo = StreamFromPartData(dataCur, secSizeCur);
|
||||
auto surfaceCount = surfaceInfo.ReadUint32();
|
||||
x8_surfaces.reserve(surfaceCount);
|
||||
for (u32 i = 0; i < surfaceCount; ++i) {
|
||||
if (x8_surfaces.capacity() <= x8_surfaces.size()) {
|
||||
x8_surfaces.reserve(x8_surfaces.capacity() * 2);
|
||||
}
|
||||
const auto secSize = CBasics::SwapBytes(*secSizeCur);
|
||||
x8_surfaces.emplace_back(MemoryFromPartData(dataCur, secSizeCur), secSize);
|
||||
}
|
||||
|
||||
const float* bounds = reinterpret_cast<float*>(data + 12);
|
||||
const zeus::CAABox aabb{
|
||||
{CBasics::SwapBytes(bounds[0]), CBasics::SwapBytes(bounds[1]), CBasics::SwapBytes(bounds[2])},
|
||||
{CBasics::SwapBytes(bounds[3]), CBasics::SwapBytes(bounds[4]), CBasics::SwapBytes(bounds[5])},
|
||||
};
|
||||
|
||||
/* This constructor has been changed from the original to take into account platform differences */
|
||||
x28_modelInst =
|
||||
std::make_unique<CCubeModel>(&x8_surfaces, &x18_matSets[0].x0_textures, x18_matSets[0].x10_data, &m_positions,
|
||||
&m_colors, &m_normals, &m_floatUVs, &m_shortUVs, aabb, flags, true, -1);
|
||||
|
||||
sThisFrameList = this;
|
||||
if (x34_next != nullptr) {
|
||||
x34_next->x30_prev = this;
|
||||
}
|
||||
x4_dataLen += x8_surfaces.size() * 4;
|
||||
sTotalMemory += x4_dataLen;
|
||||
// DCFlushRange(x0_data, dataLen);
|
||||
}
|
||||
|
||||
void CModel::UpdateLastFrame() { x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
|
||||
void CModel::MoveToThisFrameList() {
|
||||
UpdateLastFrame();
|
||||
if (sThisFrameList == this) {
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveFromList();
|
||||
if (sThisFrameList != nullptr) {
|
||||
x34_next = sThisFrameList;
|
||||
x34_next->x30_prev = this;
|
||||
}
|
||||
|
||||
sThisFrameList = this;
|
||||
}
|
||||
|
||||
void CModel::RemoveFromList() {
|
||||
if (x30_prev == nullptr) {
|
||||
if (sThisFrameList == this) {
|
||||
sThisFrameList = x34_next;
|
||||
} else if (sOneFrameList == this) {
|
||||
sOneFrameList = x34_next;
|
||||
} else if (sTwoFrameList == this) {
|
||||
sTwoFrameList = x34_next;
|
||||
}
|
||||
} else {
|
||||
x30_prev->x34_next = x34_next;
|
||||
}
|
||||
if (x34_next != nullptr) {
|
||||
x34_next->x30_prev = x30_prev;
|
||||
}
|
||||
x30_prev = nullptr;
|
||||
x34_next = nullptr;
|
||||
}
|
||||
|
||||
void CModel::FrameDone() {
|
||||
++sFrameCounter;
|
||||
if (sIsTextureTimeoutEnabled) {
|
||||
auto* iter = sTwoFrameList;
|
||||
while (iter != nullptr) {
|
||||
auto* next = iter->x34_next;
|
||||
iter->VerifyCurrentShader(0);
|
||||
for (auto& shader : iter->x18_matSets) {
|
||||
shader.UnlockTextures();
|
||||
}
|
||||
|
||||
iter->x28_modelInst->UnlockTextures();
|
||||
iter->x34_next = nullptr;
|
||||
iter->x30_prev = nullptr;
|
||||
iter = next;
|
||||
}
|
||||
|
||||
sTwoFrameList = sOneFrameList;
|
||||
sOneFrameList = sThisFrameList;
|
||||
sThisFrameList = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CModel::EnableTextureTimeout() { sIsTextureTimeoutEnabled = true; }
|
||||
|
||||
void CModel::DisableTextureTimeout() { sIsTextureTimeoutEnabled = false; }
|
||||
|
||||
TVectorRef CModel::GetPositions() const { return x28_modelInst->GetPositions(); }
|
||||
|
||||
TVectorRef CModel::GetNormals() const { return x28_modelInst->GetNormals(); }
|
||||
|
||||
void CModel::VerifyCurrentShader(u32 matIdx) {
|
||||
if (matIdx > x18_matSets.size()) {
|
||||
matIdx = 0;
|
||||
}
|
||||
if (matIdx == x2c_currentMatIdx) {
|
||||
if (x2e_lastFrame != 0 && x2e_lastFrame < sFrameCounter) {
|
||||
for (size_t idx = 0; auto& mat : x18_matSets) {
|
||||
if (idx != matIdx) {
|
||||
mat.UnlockTextures();
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
x2c_currentMatIdx = matIdx;
|
||||
auto& mat = x18_matSets[matIdx];
|
||||
x28_modelInst->RemapMaterialData(mat.x10_data, mat.x0_textures);
|
||||
if (x18_matSets.size() > 1) {
|
||||
x2e_lastFrame = sFrameCounter + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CModel::IsLoaded(u32 matIdx) {
|
||||
VerifyCurrentShader(matIdx);
|
||||
const auto& textures = *x28_modelInst->x1c_textures;
|
||||
if (textures.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (const auto& token : textures) {
|
||||
if (token.IsNull() && !token.IsLoaded()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CModel::Touch(u32 matIdx) {
|
||||
MoveToThisFrameList();
|
||||
VerifyCurrentShader(matIdx);
|
||||
if (x28_modelInst->TryLockTextures()) {
|
||||
for (auto& texture : *x28_modelInst->x1c_textures) {
|
||||
if (!texture.IsNull()) {
|
||||
// texture->LoadToMRAM();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CModel::DrawSortedParts(CModelFlags flags) {
|
||||
if ((flags.x2_flags & 0x20) != 0) {
|
||||
x28_modelInst->DrawNormal(nullptr, nullptr, ESurfaceSelection::Sorted);
|
||||
}
|
||||
CCubeMaterial::ResetCachedMaterials();
|
||||
MoveToThisFrameList();
|
||||
VerifyCurrentShader(flags.x1_matSetIdx);
|
||||
x28_modelInst->DrawAlpha(flags);
|
||||
}
|
||||
|
||||
void CModel::DrawUnsortedParts(CModelFlags flags) {
|
||||
if ((flags.x2_flags & 0x20) != 0) {
|
||||
x28_modelInst->DrawNormal(nullptr, nullptr, ESurfaceSelection::Unsorted);
|
||||
}
|
||||
CCubeMaterial::ResetCachedMaterials();
|
||||
MoveToThisFrameList();
|
||||
VerifyCurrentShader(flags.x1_matSetIdx);
|
||||
x28_modelInst->DrawNormal(flags);
|
||||
}
|
||||
|
||||
CFactoryFnReturn FModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) {
|
||||
IObjectStore* store = vparms.GetOwnedObj<IObjectStore*>();
|
||||
CFactoryFnReturn ret = TToken<CModel>::GetIObjObjectFor(std::make_unique<CModel>(std::move(in), len, store));
|
||||
return ret;
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -1,57 +1,43 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
//#include "DataSpec/DNACommon/CMDL.hpp"
|
||||
//#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
||||
#include "Runtime/CFactoryMgr.hpp"
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
//#include <hecl/HMDLMeta.hpp>
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
#include "CToken.hpp"
|
||||
#include "GCNTypes.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "IObjectStore.hpp"
|
||||
#include "Graphics/CCubeModel.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CLight;
|
||||
class CModel;
|
||||
class CPoseAsTransforms;
|
||||
class CSkinRules;
|
||||
class IObjectStore;
|
||||
class CCubeSurface;
|
||||
class CCubeMaterial;
|
||||
|
||||
struct CModelFlags {
|
||||
u8 x0_blendMode = 0; /* 2: add color, >6: additive, >4: blend, else opaque */
|
||||
/**
|
||||
* 2: add color
|
||||
* >6: additive
|
||||
* >4: blend
|
||||
* else opaque
|
||||
*/
|
||||
u8 x0_blendMode = 0;
|
||||
u8 x1_matSetIdx = 0;
|
||||
EExtendedShader m_extendedShader = EExtendedShader::Lighting;
|
||||
bool m_noCull = false;
|
||||
bool m_noZTest = false;
|
||||
bool m_noZWrite = false;
|
||||
bool m_depthGreater = false;
|
||||
u16 x2_flags = 0; /* Flags */
|
||||
zeus::CColor x4_color; /* Set into kcolor slot specified by material */
|
||||
zeus::CColor addColor = zeus::skClear;
|
||||
zeus::CAABox mbShadowBox;
|
||||
/**
|
||||
* 0x1: depth equal
|
||||
* 0x2: depth update
|
||||
* 0x4: render without texture lock
|
||||
* 0x8: depth greater
|
||||
* 0x10: depth non-inclusive
|
||||
*/
|
||||
u16 x2_flags = 0;
|
||||
/**
|
||||
* Set into kcolor slot specified by material
|
||||
*/
|
||||
zeus::CColor x4_color;
|
||||
|
||||
constexpr CModelFlags() = default;
|
||||
constexpr CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col)
|
||||
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {
|
||||
/* Blend mode will override this if the surface's original material is opaque */
|
||||
m_noZWrite = (x2_flags & 0x2) == 0;
|
||||
m_depthGreater = (x2_flags & 0x8) != 0;
|
||||
}
|
||||
|
||||
/* Flags
|
||||
0x1: depth lequal
|
||||
0x2: depth update
|
||||
0x4: render without texture lock
|
||||
0x8: depth greater
|
||||
0x10: depth non-inclusive
|
||||
*/
|
||||
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {}
|
||||
|
||||
bool operator==(const CModelFlags& other) const {
|
||||
return x0_blendMode == other.x0_blendMode && x1_matSetIdx == other.x1_matSetIdx && x2_flags == other.x2_flags &&
|
||||
|
@ -61,252 +47,68 @@ struct CModelFlags {
|
|||
bool operator!=(const CModelFlags& other) const { return !operator==(other); }
|
||||
};
|
||||
|
||||
/* metaforce addition: doesn't require hacky stashing of
|
||||
* pointers within loaded CMDL buffer */
|
||||
struct CBooSurface {
|
||||
// DataSpec::DNACMDL::SurfaceHeader_2 m_data;
|
||||
size_t selfIdx;
|
||||
class CBooModel* m_parent = nullptr;
|
||||
CBooSurface* m_next = nullptr;
|
||||
|
||||
zeus::CAABox GetBounds() const {
|
||||
// if (!m_data.aabbSz)
|
||||
// return zeus::CAABox(m_data.centroid, m_data.centroid);
|
||||
// else
|
||||
// return zeus::CAABox(m_data.aabb[0], m_data.aabb[1]);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
//using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
||||
//struct GeometryUniformLayout {
|
||||
// mutable std::vector<boo::ObjToken<boo::IGraphicsBufferD>> m_sharedBuffer;
|
||||
// size_t m_geomBufferSize = 0;
|
||||
// size_t m_skinBankCount = 0;
|
||||
// size_t m_weightVecCount = 0;
|
||||
//
|
||||
// std::vector<size_t> m_skinOffs;
|
||||
// std::vector<size_t> m_skinSizes;
|
||||
//
|
||||
// std::vector<size_t> m_uvOffs;
|
||||
// std::vector<size_t> m_uvSizes;
|
||||
//
|
||||
// GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
||||
// void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
||||
// const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||
// const CBooModel* parent) const;
|
||||
//
|
||||
// void ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size);
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> GetSharedBuffer(int idx) const;
|
||||
//};
|
||||
|
||||
struct SShader {
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
||||
// std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
// MaterialSet m_matSet;
|
||||
// std::optional<GeometryUniformLayout> m_geomLayout;
|
||||
int m_matSetIdx;
|
||||
explicit SShader(int idx) : m_matSetIdx(idx) {
|
||||
x0_textures.clear();
|
||||
// m_shaders.clear();
|
||||
}
|
||||
// void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||
void UnlockTextures();
|
||||
// CModelShaders::ShaderPipelines BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
||||
// void BuildShaders(const hecl::HMDLMeta& meta, std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||
// void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||
};
|
||||
|
||||
class CBooModel {
|
||||
friend class CBooRenderer;
|
||||
friend class CGameArea;
|
||||
friend class CMetroidModelInstance;
|
||||
friend class CModel;
|
||||
friend class CSkinnedModel;
|
||||
friend struct GeometryUniformLayout;
|
||||
|
||||
class CModel {
|
||||
public:
|
||||
enum class ESurfaceSelection { UnsortedOnly, SortedOnly, All };
|
||||
struct SShader {
|
||||
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||
u8* x10_data;
|
||||
|
||||
explicit SShader(u8* data) : x10_data(data) {}
|
||||
|
||||
void UnlockTextures();
|
||||
};
|
||||
|
||||
private:
|
||||
CBooModel* m_next = nullptr;
|
||||
CBooModel* m_prev = nullptr;
|
||||
size_t m_uniUpdateCount = 0;
|
||||
TToken<CModel> m_modelTok;
|
||||
CModel* m_model;
|
||||
std::vector<CBooSurface>* x0_surfaces;
|
||||
// const MaterialSet* x4_matSet;
|
||||
// const GeometryUniformLayout* m_geomLayout;
|
||||
int m_matSetIdx = -1;
|
||||
// const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
CBooSurface* x3c_firstSortedSurface = nullptr;
|
||||
bool x40_24_texturesLoaded : 1 = false;
|
||||
bool x40_25_modelVisible : 1 = false;
|
||||
u8 x41_mask;
|
||||
u32 x44_areaInstanceIdx = UINT32_MAX;
|
||||
static u32 sTotalMemory;
|
||||
static u32 sFrameCounter;
|
||||
static bool sIsTextureTimeoutEnabled;
|
||||
static CModel* sThisFrameList;
|
||||
static CModel* sOneFrameList;
|
||||
static CModel* sTwoFrameList;
|
||||
|
||||
// struct UVAnimationBuffer {
|
||||
// static void ProcessAnimation(u8*& bufOut, const MaterialSet::Material::PASS& anim);
|
||||
// static void PadOutBuffer(u8*& bufStart, u8*& bufOut);
|
||||
// static void Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags, const CBooModel* parent);
|
||||
// };
|
||||
|
||||
CModelShaders::LightingUniform m_lightingData;
|
||||
|
||||
/* metaforce addition: boo! */
|
||||
// size_t m_uniformDataSize = 0;
|
||||
// struct ModelInstance {
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
// std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
//
|
||||
// boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
// };
|
||||
// std::vector<ModelInstance> m_instances;
|
||||
// ModelInstance m_ballShadowInstance;
|
||||
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
//
|
||||
// boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||
// boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||
// boo::ObjToken<boo::ITextureCubeR> m_lastDrawnReflectionCube;
|
||||
|
||||
// ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1, boo::IGraphicsDataFactory::Context* ctx = nullptr);
|
||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||
void DrawNormalSurfaces(const CModelFlags& flags) const;
|
||||
void DrawSurfaces(const CModelFlags& flags) const;
|
||||
void DrawSurface(const CBooSurface& surf, const CModelFlags& flags) const;
|
||||
void WarmupDrawSurfaces() const;
|
||||
void WarmupDrawSurface(const CBooSurface& surf) const;
|
||||
|
||||
static inline zeus::CVector3f g_PlayerPosition;
|
||||
static inline float g_ModSeconds = 0.0f;
|
||||
static inline float g_TransformedTime = 0.0f;
|
||||
static inline float g_TransformedTime2 = 0.0f;
|
||||
static inline CBooModel* g_LastModelCached = nullptr;
|
||||
|
||||
static inline bool g_DummyTextures = false;
|
||||
static inline bool g_RenderModelBlack = false;
|
||||
|
||||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
// TODO
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> vbo, boo::ObjToken<boo::IGraphicsBufferS> ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask);
|
||||
|
||||
// static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
// std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
void MakeTexturesFromMats(std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
|
||||
bool IsOpaque() const { return x3c_firstSortedSurface == nullptr; }
|
||||
void ActivateLights(const std::vector<CLight>& lights);
|
||||
void SetAmbientColor(const zeus::CColor& color) { m_lightingData.ambient = color; }
|
||||
void DisableAllLights();
|
||||
void RemapMaterialData(SShader& shader);
|
||||
bool TryLockTextures();
|
||||
void UnlockTextures();
|
||||
void SyncLoadTextures();
|
||||
void Touch(int shaderIdx);
|
||||
void VerifyCurrentShader(int shaderIdx);
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
// const CPoseAsTransforms* pose, int sharedLayoutBuf = -1);
|
||||
void DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void DrawNormal(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void Draw(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void DrawFlat(ESurfaceSelection sel, EExtendedShader extendedIdx) const;
|
||||
|
||||
void LockParent() { m_modelTok.Lock(); }
|
||||
void UnlockParent() { m_modelTok.Unlock(); }
|
||||
|
||||
// const MaterialSet::Material& GetMaterialByIndex(int idx) const { return x4_matSet->materials.at(idx); }
|
||||
|
||||
void ClearUniformCounter() { m_uniUpdateCount = 0; }
|
||||
static void ClearModelUniformCounters();
|
||||
|
||||
static inline bool g_DrawingOccluders = false;
|
||||
static void SetDrawingOccluders(bool occ) { g_DrawingOccluders = occ; }
|
||||
|
||||
static void SetNewPlayerPositionAndTime(const zeus::CVector3f& pos);
|
||||
|
||||
static inline zeus::CVector3f g_ReflectViewPos;
|
||||
static void KillCachedViewDepState();
|
||||
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
|
||||
float& alphaOut);
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_shadowMap;
|
||||
static inline zeus::CTransform g_shadowTexXf;
|
||||
static void EnableShadowMaps(const aurora::gfx::TextureHandle& map, const zeus::CTransform& texXf);
|
||||
static void DisableShadowMaps();
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_disintegrateTexture;
|
||||
static void SetDisintegrateTexture(const aurora::gfx::TextureHandle& map) { g_disintegrateTexture = map; }
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_reflectionCube;
|
||||
static void SetReflectionCube(const aurora::gfx::TextureHandle& map) { g_reflectionCube = map; }
|
||||
|
||||
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
||||
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
const zeus::CAABox& GetAABB() const { return x20_aabb; }
|
||||
};
|
||||
|
||||
class CModel {
|
||||
friend class CBooModel;
|
||||
friend struct GeometryUniformLayout;
|
||||
// std::unique_ptr<u8[]> x0_data;
|
||||
// u32 x4_dataLen;
|
||||
TToken<CModel> m_selfToken; /* DO NOT LOCK! */
|
||||
zeus::CAABox m_aabb;
|
||||
u32 m_flags;
|
||||
std::vector<CBooSurface> x8_surfaces;
|
||||
std::unique_ptr<u8[]> x0_data;
|
||||
u32 x4_dataLen;
|
||||
std::vector<CCubeSurface> x8_surfaces; // was rstl::vector<void*>
|
||||
std::vector<SShader> x18_matSets;
|
||||
std::unique_ptr<CBooModel> x28_modelInst;
|
||||
// CModel* x30_next = nullptr;
|
||||
// CModel* x34_prev = nullptr;
|
||||
int x38_lastFrame;
|
||||
std::unique_ptr<CCubeModel> x28_modelInst = nullptr;
|
||||
u16 x2c_currentMatIdx = 0;
|
||||
u16 x2e_lastFrame = 0; // Last frame that the model switched materials
|
||||
CModel* x30_prev = nullptr;
|
||||
CModel* x34_next;
|
||||
u32 x38_lastFrame;
|
||||
|
||||
/* metaforce addition: boo! */
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
// hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
/* Resident copies of maintained data */
|
||||
std::vector<zeus::CVector3f> m_positions;
|
||||
std::vector<zeus::CVector3f> m_normals;
|
||||
std::vector<zeus::CColor> m_colors;
|
||||
std::vector<zeus::CVector2f> m_floatUVs;
|
||||
std::vector<zeus::CVector2f> m_shortUVs;
|
||||
|
||||
public:
|
||||
// using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store);
|
||||
|
||||
CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store, CObjectReference* selfRef);
|
||||
void DrawSortedParts(const CModelFlags& flags) const;
|
||||
void DrawUnsortedParts(const CModelFlags& flags) const;
|
||||
void Draw(const CModelFlags& flags) const;
|
||||
bool IsLoaded(int shaderIdx) const;
|
||||
void Touch(int shaderIdx) { x28_modelInst->Touch(shaderIdx); }
|
||||
void UpdateLastFrame();
|
||||
void MoveToThisFrameList();
|
||||
void RemoveFromList();
|
||||
void VerifyCurrentShader(u32 matIdx);
|
||||
void Touch(u32 matIdx);
|
||||
void Draw(CModelFlags flags) const;
|
||||
void Draw(TVectorRef positions, TVectorRef normals, CModelFlags flags);
|
||||
void DrawSortedParts(CModelFlags flags);
|
||||
void DrawUnsortedParts(CModelFlags flags);
|
||||
bool IsLoaded(u32 matIdx);
|
||||
|
||||
const zeus::CAABox& GetAABB() const { return m_aabb; }
|
||||
CBooModel& GetInstance() { return *x28_modelInst; }
|
||||
const CBooModel& GetInstance() const { return *x28_modelInst; }
|
||||
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, bool lockParent = true);
|
||||
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
TVectorRef GetPositions() const;
|
||||
TVectorRef GetNormals() const;
|
||||
u32 GetNumMaterialSets() const { return x18_matSets.size(); }
|
||||
bool IsOpaque() const { return x28_modelInst->x3c_firstSortedSurf == nullptr; }
|
||||
const zeus::CAABox& GetAABB() const { return x28_modelInst->x20_worldAABB; }
|
||||
|
||||
size_t GetPoolVertexOffset(size_t idx) const;
|
||||
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
||||
size_t GetPoolNormalOffset(size_t idx) const;
|
||||
zeus::CVector3f GetPoolNormal(size_t idx) const;
|
||||
// void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
||||
// const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
|
||||
// void RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const;
|
||||
static void FrameDone();
|
||||
static void EnableTextureTimeout();
|
||||
static void DisableTextureTimeout();
|
||||
};
|
||||
|
||||
CFactoryFnReturn FPCModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
CFactoryFnReturn FModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -0,0 +1,312 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
//#include "DataSpec/DNACommon/CMDL.hpp"
|
||||
//#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
||||
#include "Runtime/CFactoryMgr.hpp"
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
//#include <hecl/HMDLMeta.hpp>
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
class CLight;
|
||||
class CModel;
|
||||
class CPoseAsTransforms;
|
||||
class CSkinRules;
|
||||
class IObjectStore;
|
||||
|
||||
struct CModelFlags {
|
||||
u8 x0_blendMode = 0; /* 2: add color, >6: additive, >4: blend, else opaque */
|
||||
u8 x1_matSetIdx = 0;
|
||||
EExtendedShader m_extendedShader = EExtendedShader::Lighting;
|
||||
bool m_noCull = false;
|
||||
bool m_noZTest = false;
|
||||
bool m_noZWrite = false;
|
||||
bool m_depthGreater = false;
|
||||
u16 x2_flags = 0; /* Flags */
|
||||
zeus::CColor x4_color; /* Set into kcolor slot specified by material */
|
||||
zeus::CColor addColor = zeus::skClear;
|
||||
zeus::CAABox mbShadowBox;
|
||||
|
||||
constexpr CModelFlags() = default;
|
||||
constexpr CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col)
|
||||
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {
|
||||
/* Blend mode will override this if the surface's original material is opaque */
|
||||
m_noZWrite = (x2_flags & 0x2) == 0;
|
||||
m_depthGreater = (x2_flags & 0x8) != 0;
|
||||
}
|
||||
|
||||
/* Flags
|
||||
0x1: depth lequal
|
||||
0x2: depth update
|
||||
0x4: render without texture lock
|
||||
0x8: depth greater
|
||||
0x10: depth non-inclusive
|
||||
*/
|
||||
|
||||
bool operator==(const CModelFlags& other) const {
|
||||
return x0_blendMode == other.x0_blendMode && x1_matSetIdx == other.x1_matSetIdx && x2_flags == other.x2_flags &&
|
||||
x4_color == other.x4_color;
|
||||
}
|
||||
|
||||
bool operator!=(const CModelFlags& other) const { return !operator==(other); }
|
||||
};
|
||||
|
||||
/* metaforce addition: doesn't require hacky stashing of
|
||||
* pointers within loaded CMDL buffer */
|
||||
struct CBooSurface {
|
||||
// DataSpec::DNACMDL::SurfaceHeader_2 m_data;
|
||||
size_t selfIdx;
|
||||
class CBooModel* m_parent = nullptr;
|
||||
CBooSurface* m_next = nullptr;
|
||||
|
||||
zeus::CAABox GetBounds() const {
|
||||
// if (!m_data.aabbSz)
|
||||
// return zeus::CAABox(m_data.centroid, m_data.centroid);
|
||||
// else
|
||||
// return zeus::CAABox(m_data.aabb[0], m_data.aabb[1]);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
//using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
||||
//struct GeometryUniformLayout {
|
||||
// mutable std::vector<boo::ObjToken<boo::IGraphicsBufferD>> m_sharedBuffer;
|
||||
// size_t m_geomBufferSize = 0;
|
||||
// size_t m_skinBankCount = 0;
|
||||
// size_t m_weightVecCount = 0;
|
||||
//
|
||||
// std::vector<size_t> m_skinOffs;
|
||||
// std::vector<size_t> m_skinSizes;
|
||||
//
|
||||
// std::vector<size_t> m_uvOffs;
|
||||
// std::vector<size_t> m_uvSizes;
|
||||
//
|
||||
// GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
||||
// void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
||||
// const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||
// const CBooModel* parent) const;
|
||||
//
|
||||
// void ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size);
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> GetSharedBuffer(int idx) const;
|
||||
//};
|
||||
|
||||
struct SShader {
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
||||
// std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
// MaterialSet m_matSet;
|
||||
// std::optional<GeometryUniformLayout> m_geomLayout;
|
||||
int m_matSetIdx;
|
||||
explicit SShader(int idx) : m_matSetIdx(idx) {
|
||||
x0_textures.clear();
|
||||
// m_shaders.clear();
|
||||
}
|
||||
// void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||
void UnlockTextures();
|
||||
// CModelShaders::ShaderPipelines BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
||||
// void BuildShaders(const hecl::HMDLMeta& meta, std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||
// void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||
};
|
||||
|
||||
class CBooModel {
|
||||
friend class CBooRenderer;
|
||||
friend class CGameArea;
|
||||
friend class CMetroidModelInstance;
|
||||
friend class CModel;
|
||||
friend class CSkinnedModel;
|
||||
friend struct GeometryUniformLayout;
|
||||
|
||||
public:
|
||||
enum class ESurfaceSelection { UnsortedOnly, SortedOnly, All };
|
||||
|
||||
private:
|
||||
CBooModel* m_next = nullptr;
|
||||
CBooModel* m_prev = nullptr;
|
||||
size_t m_uniUpdateCount = 0;
|
||||
TToken<CModel> m_modelTok;
|
||||
CModel* m_model;
|
||||
std::vector<CBooSurface>* x0_surfaces;
|
||||
// const MaterialSet* x4_matSet;
|
||||
// const GeometryUniformLayout* m_geomLayout;
|
||||
int m_matSetIdx = -1;
|
||||
// const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
CBooSurface* x3c_firstSortedSurface = nullptr;
|
||||
bool x40_24_texturesLoaded : 1 = false;
|
||||
bool x40_25_modelVisible : 1 = false;
|
||||
u8 x41_mask;
|
||||
u32 x44_areaInstanceIdx = UINT32_MAX;
|
||||
|
||||
// struct UVAnimationBuffer {
|
||||
// static void ProcessAnimation(u8*& bufOut, const MaterialSet::Material::PASS& anim);
|
||||
// static void PadOutBuffer(u8*& bufStart, u8*& bufOut);
|
||||
// static void Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags, const CBooModel* parent);
|
||||
// };
|
||||
|
||||
CModelShaders::LightingUniform m_lightingData;
|
||||
|
||||
/* metaforce addition: boo! */
|
||||
// size_t m_uniformDataSize = 0;
|
||||
// struct ModelInstance {
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
// std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
//
|
||||
// boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
// };
|
||||
// std::vector<ModelInstance> m_instances;
|
||||
// ModelInstance m_ballShadowInstance;
|
||||
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
//
|
||||
// boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||
// boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||
// boo::ObjToken<boo::ITextureCubeR> m_lastDrawnReflectionCube;
|
||||
|
||||
// ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1, boo::IGraphicsDataFactory::Context* ctx = nullptr);
|
||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||
void DrawNormalSurfaces(const CModelFlags& flags) const;
|
||||
void DrawSurfaces(const CModelFlags& flags) const;
|
||||
void DrawSurface(const CBooSurface& surf, const CModelFlags& flags) const;
|
||||
void WarmupDrawSurfaces() const;
|
||||
void WarmupDrawSurface(const CBooSurface& surf) const;
|
||||
|
||||
static inline zeus::CVector3f g_PlayerPosition;
|
||||
static inline float g_ModSeconds = 0.0f;
|
||||
static inline float g_TransformedTime = 0.0f;
|
||||
static inline float g_TransformedTime2 = 0.0f;
|
||||
static inline CBooModel* g_LastModelCached = nullptr;
|
||||
|
||||
static inline bool g_DummyTextures = false;
|
||||
static inline bool g_RenderModelBlack = false;
|
||||
|
||||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
// TODO
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> vbo, boo::ObjToken<boo::IGraphicsBufferS> ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask);
|
||||
|
||||
// static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
// std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
void MakeTexturesFromMats(std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
|
||||
bool IsOpaque() const { return x3c_firstSortedSurface == nullptr; }
|
||||
void ActivateLights(const std::vector<CLight>& lights);
|
||||
void SetAmbientColor(const zeus::CColor& color) { m_lightingData.ambient = color; }
|
||||
void DisableAllLights();
|
||||
void RemapMaterialData(SShader& shader);
|
||||
bool TryLockTextures();
|
||||
void UnlockTextures();
|
||||
void SyncLoadTextures();
|
||||
void Touch(int shaderIdx);
|
||||
void VerifyCurrentShader(int shaderIdx);
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
// const CPoseAsTransforms* pose, int sharedLayoutBuf = -1);
|
||||
void DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void DrawNormal(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void Draw(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void DrawFlat(ESurfaceSelection sel, EExtendedShader extendedIdx) const;
|
||||
|
||||
void LockParent() { m_modelTok.Lock(); }
|
||||
void UnlockParent() { m_modelTok.Unlock(); }
|
||||
|
||||
// const MaterialSet::Material& GetMaterialByIndex(int idx) const { return x4_matSet->materials.at(idx); }
|
||||
|
||||
void ClearUniformCounter() { m_uniUpdateCount = 0; }
|
||||
static void ClearModelUniformCounters();
|
||||
|
||||
static inline bool g_DrawingOccluders = false;
|
||||
static void SetDrawingOccluders(bool occ) { g_DrawingOccluders = occ; }
|
||||
|
||||
static void SetNewPlayerPositionAndTime(const zeus::CVector3f& pos);
|
||||
|
||||
static inline zeus::CVector3f g_ReflectViewPos;
|
||||
static void KillCachedViewDepState();
|
||||
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
|
||||
float& alphaOut);
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_shadowMap;
|
||||
static inline zeus::CTransform g_shadowTexXf;
|
||||
static void EnableShadowMaps(const aurora::gfx::TextureHandle& map, const zeus::CTransform& texXf);
|
||||
static void DisableShadowMaps();
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_disintegrateTexture;
|
||||
static void SetDisintegrateTexture(const aurora::gfx::TextureHandle& map) { g_disintegrateTexture = map; }
|
||||
|
||||
static inline aurora::gfx::TextureHandle g_reflectionCube;
|
||||
static void SetReflectionCube(const aurora::gfx::TextureHandle& map) { g_reflectionCube = map; }
|
||||
|
||||
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
||||
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
const zeus::CAABox& GetAABB() const { return x20_aabb; }
|
||||
};
|
||||
|
||||
class CModel {
|
||||
friend class CBooModel;
|
||||
friend struct GeometryUniformLayout;
|
||||
// std::unique_ptr<u8[]> x0_data;
|
||||
// u32 x4_dataLen;
|
||||
TToken<CModel> m_selfToken; /* DO NOT LOCK! */
|
||||
zeus::CAABox m_aabb;
|
||||
u32 m_flags;
|
||||
std::vector<CBooSurface> x8_surfaces;
|
||||
std::vector<SShader> x18_matSets;
|
||||
std::unique_ptr<CBooModel> x28_modelInst;
|
||||
// CModel* x30_next = nullptr;
|
||||
// CModel* x34_prev = nullptr;
|
||||
int x38_lastFrame;
|
||||
|
||||
/* metaforce addition: boo! */
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
// hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
|
||||
public:
|
||||
// using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
||||
CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store, CObjectReference* selfRef);
|
||||
void DrawSortedParts(const CModelFlags& flags) const;
|
||||
void DrawUnsortedParts(const CModelFlags& flags) const;
|
||||
void Draw(const CModelFlags& flags) const;
|
||||
bool IsLoaded(int shaderIdx) const;
|
||||
void Touch(int shaderIdx) { x28_modelInst->Touch(shaderIdx); }
|
||||
|
||||
const zeus::CAABox& GetAABB() const { return m_aabb; }
|
||||
CBooModel& GetInstance() { return *x28_modelInst; }
|
||||
const CBooModel& GetInstance() const { return *x28_modelInst; }
|
||||
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, bool lockParent = true);
|
||||
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
u32 GetNumMaterialSets() const { return x18_matSets.size(); }
|
||||
|
||||
size_t GetPoolVertexOffset(size_t idx) const;
|
||||
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
||||
size_t GetPoolNormalOffset(size_t idx) const;
|
||||
zeus::CVector3f GetPoolNormal(size_t idx) const;
|
||||
// void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
||||
// const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
|
||||
// void RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const;
|
||||
};
|
||||
|
||||
CFactoryFnReturn FPCModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
||||
|
||||
} // namespace metaforce
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Character/CSkinRules.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CLight.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <zeus/CVector3f.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/World/CWorld.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
|
@ -30,7 +30,7 @@ void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const zeus::
|
|||
vt += delta;
|
||||
m_renderer.AddVertex(vec, zeus::CColor(1.f, vertAlpha), 1);
|
||||
}
|
||||
m_renderer.Render(g_Renderer->IsThermalVisorHotPass());
|
||||
// m_renderer.Render(g_Renderer->IsThermalVisorHotPass());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
namespace metaforce {
|
||||
static logvisor::Module Log("metaforce::CSkinnedModel");
|
||||
|
||||
CSkinnedModel::CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
||||
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx)
|
||||
CSkinnedModel::CSkinnedModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules,
|
||||
const TLockedToken<CCharLayoutInfo>& layoutInfo)
|
||||
: x4_model(std::move(model)), x10_skinRules(std::move(skinRules)), x1c_layoutInfo(std::move(layoutInfo)) {
|
||||
if (!x4_model) {
|
||||
Log.report(logvisor::Fatal, FMT_STRING("bad model token provided to CSkinnedModel"));
|
||||
|
@ -20,47 +20,74 @@ CSkinnedModel::CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules
|
|||
if (!x1c_layoutInfo) {
|
||||
Log.report(logvisor::Fatal, FMT_STRING("bad character layout token provided to CSkinnedModel"));
|
||||
}
|
||||
m_modelInst = x4_model->MakeNewInstance(shaderIdx);
|
||||
}
|
||||
|
||||
CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo,
|
||||
int shaderIdx)
|
||||
CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo)
|
||||
: CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}),
|
||||
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo}), shaderIdx) {}
|
||||
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo})) {}
|
||||
|
||||
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
||||
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
|
||||
// TODO
|
||||
// if (morphEffect || g_PointGenFunc) {
|
||||
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) {
|
||||
// x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
|
||||
// if (morphEffect)
|
||||
// morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
||||
// if (g_PointGenFunc)
|
||||
// g_PointGenFunc(g_PointGenCtx, m_vertWorkspace);
|
||||
// x4_model->ApplyVerticesCPU(vertBuf, m_vertWorkspace);
|
||||
// m_modifiedVBO = true;
|
||||
// }
|
||||
// } else {
|
||||
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf =
|
||||
// m_modelInst->UpdateUniformData(drawFlags, x10_skinRules.GetObj(), &pose)) {
|
||||
// if (m_modifiedVBO) {
|
||||
// x4_model->RestoreVerticesCPU(vertBuf);
|
||||
// m_modifiedVBO = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (morphEffect || g_PointGenFunc) {
|
||||
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr))
|
||||
// {
|
||||
// x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
|
||||
// if (morphEffect)
|
||||
// morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
||||
// if (g_PointGenFunc)
|
||||
// g_PointGenFunc(g_PointGenCtx, m_vertWorkspace);
|
||||
// x4_model->ApplyVerticesCPU(vertBuf, m_vertWorkspace);
|
||||
// m_modifiedVBO = true;
|
||||
// }
|
||||
// } else {
|
||||
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf =
|
||||
// m_modelInst->UpdateUniformData(drawFlags, x10_skinRules.GetObj(), &pose)) {
|
||||
// if (m_modifiedVBO) {
|
||||
// x4_model->RestoreVerticesCPU(vertBuf);
|
||||
// m_modifiedVBO = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void CSkinnedModel::Draw(const CModelFlags& drawFlags) const {
|
||||
void CSkinnedModel::Draw(TVectorRef verts, TVectorRef norms, const CModelFlags& drawFlags) {
|
||||
OPTICK_EVENT();
|
||||
if (m_modelInst->TryLockTextures())
|
||||
m_modelInst->DrawSurfaces(drawFlags);
|
||||
x4_model->Draw(verts, norms, drawFlags);
|
||||
// PostDrawFunc();
|
||||
}
|
||||
|
||||
void CSkinnedModel::Draw(const CModelFlags& drawFlags) {
|
||||
if (x35_disableWorkspaces) {
|
||||
const auto mtx = CGraphics::g_GXModelMatrix;
|
||||
CGraphics::SetModelMatrix(mtx * x10_skinRules->x0_bones.front().x20_xf);
|
||||
x4_model->Draw(drawFlags);
|
||||
CGraphics::SetModelMatrix(mtx);
|
||||
} else if (x24_vertWorkspace.empty()) {
|
||||
x4_model->Draw(drawFlags);
|
||||
} else {
|
||||
x4_model->Draw(&x24_vertWorkspace, &x2c_normalWorkspace, drawFlags);
|
||||
// PostDrawFunc();
|
||||
}
|
||||
}
|
||||
|
||||
void CSkinnedModel::DoDrawCallback(const FCustomDraw& func) const {
|
||||
if (x35_disableWorkspaces) {
|
||||
const auto mtx = CGraphics::g_GXModelMatrix;
|
||||
CGraphics::SetModelMatrix(mtx * x10_skinRules->x0_bones.front().x20_xf);
|
||||
func(x4_model->GetPositions(), x4_model->GetNormals());
|
||||
CGraphics::SetModelMatrix(mtx);
|
||||
} else if (x24_vertWorkspace.empty()) {
|
||||
func(x4_model->GetPositions(), x4_model->GetNormals());
|
||||
} else {
|
||||
func(&x24_vertWorkspace, &x2c_normalWorkspace);
|
||||
// PostDrawFunc();
|
||||
}
|
||||
}
|
||||
|
||||
CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules,
|
||||
CAssetId layoutInfo, int shaderIdx)
|
||||
: CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx) {}
|
||||
CAssetId layoutInfo)
|
||||
: CSkinnedModel(store, model, skinRules, layoutInfo) {}
|
||||
|
||||
CSkinnedModel::FPointGenerator CSkinnedModel::g_PointGenFunc = nullptr;
|
||||
void* CSkinnedModel::g_PointGenCtx = nullptr;
|
||||
|
|
|
@ -18,33 +18,35 @@ class CPoseAsTransforms;
|
|||
class CVertexMorphEffect;
|
||||
class IObjectStore;
|
||||
|
||||
// Lambda instead of userdata pointer
|
||||
using FCustomDraw = std::function<void(TVectorRef positions, TVectorRef normals)>;
|
||||
|
||||
class CSkinnedModel {
|
||||
friend class CBooModel;
|
||||
std::unique_ptr<CBooModel> m_modelInst;
|
||||
TLockedToken<CModel> x4_model;
|
||||
TLockedToken<CSkinRules> x10_skinRules;
|
||||
TLockedToken<CCharLayoutInfo> x1c_layoutInfo;
|
||||
std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>> m_vertWorkspace;
|
||||
bool m_modifiedVBO = false;
|
||||
std::vector<zeus::CVector3f> x24_vertWorkspace; // was rstl::auto_ptr<float[]>
|
||||
std::vector<zeus::CVector3f> x2c_normalWorkspace; // was rstl::auto_ptr<float[]>
|
||||
bool x34_owned = true;
|
||||
bool x35_disableWorkspaces = false;
|
||||
|
||||
public:
|
||||
enum class EDataOwnership { Zero, One };
|
||||
CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
||||
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx);
|
||||
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
||||
std::unique_ptr<CSkinnedModel> Clone(int shaderIdx = 0) const {
|
||||
return std::make_unique<CSkinnedModel>(x4_model, x10_skinRules, x1c_layoutInfo, shaderIdx);
|
||||
}
|
||||
enum class EDataOwnership { Unowned, Owned };
|
||||
CSkinnedModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules,
|
||||
const TLockedToken<CCharLayoutInfo>& layoutInfo /*, EDataOwnership ownership*/);
|
||||
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo);
|
||||
|
||||
TLockedToken<CModel>& GetModel() { return x4_model; }
|
||||
const TLockedToken<CModel>& GetModel() const { return x4_model; }
|
||||
const std::unique_ptr<CBooModel>& GetModelInst() const { return m_modelInst; }
|
||||
const TLockedToken<CSkinRules>& GetSkinRules() const { return x10_skinRules; }
|
||||
void SetLayoutInfo(const TLockedToken<CCharLayoutInfo>& inf) { x1c_layoutInfo = inf; }
|
||||
const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const { return x1c_layoutInfo; }
|
||||
|
||||
void Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
||||
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes);
|
||||
void Draw(const CModelFlags& drawFlags) const;
|
||||
void Draw(TVectorRef verts, TVectorRef normals, const CModelFlags& drawFlags);
|
||||
void Draw(const CModelFlags& drawFlags);
|
||||
void DoDrawCallback(const FCustomDraw& func) const;
|
||||
|
||||
using FPointGenerator = void (*)(void* item, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
|
||||
static void SetPointGeneratorFunc(void* ctx, FPointGenerator func) {
|
||||
|
@ -60,7 +62,7 @@ class CMorphableSkinnedModel : public CSkinnedModel {
|
|||
std::unique_ptr<float[]> x40_morphMagnitudes;
|
||||
|
||||
public:
|
||||
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
||||
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo);
|
||||
const float* GetMorphMagnitudes() const { return x40_morphMagnitudes.get(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
|
@ -31,20 +31,19 @@ public:
|
|||
using TReflectionCallback = std::function<void(void*, const zeus::CVector3f&)>;
|
||||
|
||||
enum class EDrawableSorting { SortedCallback, UnsortedCallback };
|
||||
enum class EDebugOption { Zero, One };
|
||||
enum class EDebugOption { Invalid = -1, PVSMode, PVSState, FogDisabled };
|
||||
enum class EPrimitiveType {};
|
||||
|
||||
virtual ~IRenderer() = default;
|
||||
virtual void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
||||
int areaIdx, const SShader* shaderSet) = 0;
|
||||
int areaIdx) = 0;
|
||||
virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0;
|
||||
virtual void DisablePVS() = 0;
|
||||
virtual void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) = 0;
|
||||
virtual void DrawAreaGeometry(int areaIdx, int mask, int targetMask) = 0;
|
||||
virtual void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender = false) = 0;
|
||||
virtual void DrawSortedGeometry(int areaIdx, int mask, int targetMask) = 0;
|
||||
virtual void DrawStaticGeometry(int areaIdx, int mask, int targetMask) = 0;
|
||||
virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0;
|
||||
virtual void DrawAreaGeometry(int areaIdx, int mask, int targetMask) = 0;
|
||||
virtual void PostRenderFogs() = 0;
|
||||
virtual void SetModelMatrix(const zeus::CTransform& xf) = 0;
|
||||
virtual void AddParticleGen(CParticleGen& gen) = 0;
|
||||
|
@ -59,36 +58,39 @@ public:
|
|||
virtual std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) = 0;
|
||||
virtual void SetClippingPlanes(const zeus::CFrustum& frustum) = 0;
|
||||
virtual void SetViewport(int left, int bottom, int width, int height) = 0;
|
||||
// virtual void SetDepthReadWrite(bool, bool)=0;
|
||||
// virtual void SetBlendMode_AdditiveAlpha()=0;
|
||||
// virtual void SetBlendMode_AlphaBlended()=0;
|
||||
// virtual void SetBlendMode_NoColorWrite()=0;
|
||||
// virtual void SetBlendMode_ColorMultiply()=0;
|
||||
// virtual void SetBlendMode_InvertDst()=0;
|
||||
// virtual void SetBlendMode_InvertSrc()=0;
|
||||
// virtual void SetBlendMode_Replace()=0;
|
||||
// virtual void SetBlendMode_AdditiveDestColor()=0;
|
||||
virtual void SetDepthReadWrite(bool, bool) = 0;
|
||||
virtual void SetBlendMode_AdditiveAlpha() = 0;
|
||||
virtual void SetBlendMode_AlphaBlended() = 0;
|
||||
virtual void SetBlendMode_NoColorWrite() = 0;
|
||||
virtual void SetBlendMode_ColorMultiply() = 0;
|
||||
virtual void SetBlendMode_InvertDst() = 0;
|
||||
virtual void SetBlendMode_InvertSrc() = 0;
|
||||
virtual void SetBlendMode_Replace() = 0;
|
||||
virtual void SetBlendMode_AdditiveDestColor() = 0;
|
||||
virtual void SetDebugOption(EDebugOption, int) = 0;
|
||||
virtual void BeginScene() = 0;
|
||||
virtual void EndScene() = 0;
|
||||
// virtual void BeginPrimitive(EPrimitiveType, int)=0;
|
||||
// virtual void BeginLines(int)=0;
|
||||
// virtual void BeginLineStrip(int)=0;
|
||||
// virtual void BeginTriangles(int)=0;
|
||||
// virtual void BeginTriangleStrip(int)=0;
|
||||
// virtual void BeginTriangleFan(int)=0;
|
||||
// virtual void PrimVertex(const zeus::CVector3f&)=0;
|
||||
// virtual void PrimNormal(const zeus::CVector3f&)=0;
|
||||
// virtual void PrimColor(float, float, float, float)=0;
|
||||
// virtual void PrimColor(const zeus::CColor&)=0;
|
||||
// virtual void EndPrimitive()=0;
|
||||
virtual void BeginPrimitive(EPrimitiveType, int) = 0;
|
||||
virtual void BeginLines(int) = 0;
|
||||
virtual void BeginLineStrip(int) = 0;
|
||||
virtual void BeginTriangles(int) = 0;
|
||||
virtual void BeginTriangleStrip(int) = 0;
|
||||
virtual void BeginTriangleFan(int) = 0;
|
||||
virtual void PrimVertex(const zeus::CVector3f&) = 0;
|
||||
virtual void PrimNormal(const zeus::CVector3f&) = 0;
|
||||
virtual void PrimColor(float, float, float, float) = 0;
|
||||
virtual void PrimColor(const zeus::CColor&) = 0;
|
||||
virtual void EndPrimitive() = 0;
|
||||
virtual void SetAmbientColor(const zeus::CColor& color) = 0;
|
||||
virtual void DrawString(const char* string, int, int) = 0;
|
||||
virtual u32 GetFPS() = 0;
|
||||
virtual void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) = 0;
|
||||
virtual void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) = 0;
|
||||
virtual void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol) = 0;
|
||||
virtual void DrawXRayOutline(const zeus::CAABox& aabb) = 0;
|
||||
virtual void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
|
||||
TVectorRef positions, TVectorRef normals, CModelFlags flags) = 0;
|
||||
virtual void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
|
||||
TVectorRef positions, TVectorRef normals) = 0;
|
||||
virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0;
|
||||
virtual void SetWireframeFlags(int flags) = 0;
|
||||
virtual void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) = 0;
|
||||
virtual void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
||||
|
@ -99,8 +101,8 @@ public:
|
|||
virtual void DoThermalBlendHot() = 0;
|
||||
virtual u32 GetStaticWorldDataSize() = 0;
|
||||
virtual void SetGXRegister1Color(const zeus::CColor& color) = 0;
|
||||
virtual void SetWorldLightMultiplyColor(const zeus::CColor& color) = 0;
|
||||
virtual void SetWorldLightFadeLevel(float level) = 0;
|
||||
virtual void SetWorldLightMultiplyColor(const zeus::CColor& color) = 0;
|
||||
virtual void PrepareDynamicLights(const std::vector<CLight>& lights) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <array>
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <array>
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp"
|
||||
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Runtime/Graphics/Shaders/CThermalColdFilter.hpp"
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Runtime/Graphics/Shaders/CThermalHotFilter.hpp"
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
//#include <hecl/Pipeline.hpp>
|
||||
|
|
|
@ -44,7 +44,7 @@ void CGuiFrame::SortDrawOrder() {
|
|||
});
|
||||
}
|
||||
|
||||
void CGuiFrame::EnableLights(u32 lights, CBooModel& model) const {
|
||||
void CGuiFrame::EnableLights(u32 lights) const {
|
||||
std::vector<CLight> lightsOut;
|
||||
lightsOut.reserve(m_indexedLights.size() + 1);
|
||||
CGraphics::DisableAllLights();
|
||||
|
@ -80,7 +80,7 @@ void CGuiFrame::EnableLights(u32 lights, CBooModel& model) const {
|
|||
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor));
|
||||
}
|
||||
|
||||
model.ActivateLights(lightsOut);
|
||||
// TODO model.ActivateLights(lightsOut);
|
||||
}
|
||||
|
||||
void CGuiFrame::DisableLights() const { CGraphics::DisableAllLights(); }
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CBooModel;
|
||||
class CGuiCamera;
|
||||
class CGuiLight;
|
||||
class CGuiSys;
|
||||
|
@ -70,7 +69,7 @@ public:
|
|||
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }
|
||||
CGuiHeadWidget* GetHeadWidget() const { return xc_headWidget.get(); }
|
||||
void SortDrawOrder();
|
||||
void EnableLights(u32 lights, CBooModel& model) const;
|
||||
void EnableLights(u32 lights) const;
|
||||
void DisableLights() const;
|
||||
void RemoveLight(CGuiLight* light);
|
||||
void AddLight(CGuiLight* light);
|
||||
|
|
|
@ -35,7 +35,7 @@ void CGuiModel::Touch() {
|
|||
return;
|
||||
}
|
||||
|
||||
model->GetInstance().Touch(0);
|
||||
model->Touch(0);
|
||||
}
|
||||
|
||||
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
|
||||
|
@ -56,49 +56,49 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
|
|||
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CGuiModel::Draw {}"), m_name).c_str(), zeus::skCyan);
|
||||
zeus::CColor moduCol = xa8_color2;
|
||||
moduCol.a() *= parms.x0_alphaMod;
|
||||
xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
|
||||
// TODO xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
|
||||
// if (xb6_29_cullFaces)
|
||||
// CGraphics::SetCullMode(ERglCullMode::Front);
|
||||
|
||||
switch (xac_drawFlags) {
|
||||
case EGuiModelDrawFlags::Shadeless: {
|
||||
CModelFlags flags(0, 0, 3, zeus::skWhite);
|
||||
flags.m_extendedShader = EExtendedShader::Flat;
|
||||
// flags.m_extendedShader = EExtendedShader::Flat;
|
||||
model->Draw(flags);
|
||||
break;
|
||||
}
|
||||
case EGuiModelDrawFlags::Opaque: {
|
||||
CModelFlags flags(1, 0, 3, moduCol);
|
||||
flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
// flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
model->Draw(flags);
|
||||
break;
|
||||
}
|
||||
case EGuiModelDrawFlags::Alpha: {
|
||||
CModelFlags flags(5, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
|
||||
flags.m_noCull = !xb6_29_cullFaces;
|
||||
flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
// flags.m_noCull = !xb6_29_cullFaces;
|
||||
// flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
model->Draw(flags);
|
||||
break;
|
||||
}
|
||||
case EGuiModelDrawFlags::Additive: {
|
||||
CModelFlags flags(7, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
|
||||
flags.m_noCull = !xb6_29_cullFaces;
|
||||
flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
flags.m_depthGreater = xb6_30_depthGreater;
|
||||
// flags.m_noCull = !xb6_29_cullFaces;
|
||||
// flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
// flags.m_depthGreater = xb6_30_depthGreater;
|
||||
model->Draw(flags);
|
||||
break;
|
||||
}
|
||||
case EGuiModelDrawFlags::AlphaAdditiveOverdraw: {
|
||||
CModelFlags flags(5, 0, xb6_31_depthTest, moduCol);
|
||||
flags.m_noCull = !xb6_29_cullFaces;
|
||||
flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
// flags.m_noCull = !xb6_29_cullFaces;
|
||||
// flags.m_noZWrite = !xb7_24_depthWrite;
|
||||
model->Draw(flags);
|
||||
|
||||
flags.x0_blendMode = 7;
|
||||
flags.x1_matSetIdx = 0;
|
||||
flags.x2_flags = (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest);
|
||||
flags.x4_color = moduCol;
|
||||
flags.m_noCull = !xb6_29_cullFaces;
|
||||
// flags.m_noCull = !xb6_29_cullFaces;
|
||||
model->Draw(flags);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CGameCamera.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/GuiSys/CGuiCamera.hpp"
|
||||
#include "Runtime/GuiSys/CGuiFrame.hpp"
|
||||
#include "Runtime/GuiSys/CGuiWidgetDrawParms.hpp"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CGameCamera.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/World/CPlayer.hpp"
|
||||
|
||||
#include <zeus/CEulerAngles.hpp>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Audio/CSfxManager.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/GuiSys/CAuiImagePane.hpp"
|
||||
#include "Runtime/GuiSys/CGuiCamera.hpp"
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
#include "Runtime/GuiSys/CSplashScreen.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/CArchitectureMessage.hpp"
|
||||
#include "Runtime/CArchitectureQueue.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "CArchitectureMessage.hpp"
|
||||
#include "CArchitectureQueue.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CCubeRenderer.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
constexpr std::array SplashTextures{"TXTR_NintendoLogo"sv, "TXTR_RetroLogo"sv, "TXTR_DolbyLogo"sv};
|
||||
|
||||
CSplashScreen::CSplashScreen(ESplashScreen which)
|
||||
: CIOWin("SplashScreen")
|
||||
, x14_which(which)
|
||||
, m_texture(g_SimplePool->GetObj(SplashTextures[size_t(which)])) {}
|
||||
: CIOWin("SplashScreen"), x14_which(which), x28_texture(g_SimplePool->GetObj(SplashTextures[size_t(which)])) {}
|
||||
|
||||
CIOWin::EMessageReturn CSplashScreen::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) {
|
||||
switch (msg.GetType()) {
|
||||
case EArchMsgType::TimerTick: {
|
||||
if (!x25_textureLoaded) {
|
||||
if (!m_texture.IsLoaded())
|
||||
if (!x28_texture.IsLoaded())
|
||||
return EMessageReturn::Exit;
|
||||
x25_textureLoaded = true;
|
||||
}
|
||||
|
@ -56,7 +52,7 @@ void CSplashScreen::Draw() {
|
|||
}
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CSplashScreen::Draw", zeus::skGreen);
|
||||
|
||||
zeus::CColor color;
|
||||
zeus::CColor color = zeus::skWhite;
|
||||
if (x14_which == ESplashScreen::Nintendo) {
|
||||
color = zeus::CColor{0.86f, 0.f, 0.f, 1.f};
|
||||
}
|
||||
|
@ -67,22 +63,34 @@ void CSplashScreen::Draw() {
|
|||
color.a() = x18_splashTimeout * 2.f;
|
||||
}
|
||||
|
||||
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
|
||||
g_Renderer->SetModelMatrix({});
|
||||
CGraphics::SetViewPointMatrix({});
|
||||
// CGraphics::SetTevOp(Stage0, ?);
|
||||
// CGraphics::SetTevOp(Stage1, skPassThru);
|
||||
g_Renderer->SetBlendMode_AlphaBlended();
|
||||
const auto& tex = *x28_texture.GetObj();
|
||||
const auto width = tex.GetWidth();
|
||||
const auto height = tex.GetHeight();
|
||||
if (x14_which == ESplashScreen::Nintendo || x14_which == ESplashScreen::Retro) {
|
||||
CGraphics::SetOrtho(-10.f, 650.f, -5.5f, 484.5f, -1.f, 1.f);
|
||||
CGraphics::SetCullMode(ERglCullMode::None);
|
||||
// TODO
|
||||
CGraphics::SetCullMode(ERglCullMode::Front);
|
||||
} else {
|
||||
// TODO
|
||||
// CGraphics::Render2D();
|
||||
}
|
||||
|
||||
zeus::CRectangle rect;
|
||||
rect.size.x() = m_texture->GetWidth() / (480.f * g_Viewport.aspect);
|
||||
rect.size.y() = m_texture->GetHeight() / 480.f;
|
||||
rect.size.x() = width / (480.f * g_Viewport.aspect);
|
||||
rect.size.y() = height / 480.f;
|
||||
rect.position.x() = 0.5f - rect.size.x() / 2.f;
|
||||
rect.position.y() = 0.5f - rect.size.y() / 2.f;
|
||||
aurora::gfx::queue_textured_quad(aurora::gfx::CameraFilterType::Blend, tex.GetTexture(),
|
||||
aurora::gfx::ZComp::Always, false, color, 1.f, rect, 0.f);
|
||||
|
||||
aurora::gfx::queue_textured_quad(
|
||||
aurora::gfx::CameraFilterType::Blend,
|
||||
m_texture->GetTexture(),
|
||||
aurora::gfx::ZComp::Always,
|
||||
false,
|
||||
color,
|
||||
1.f,
|
||||
rect,
|
||||
0.f
|
||||
);
|
||||
// Progressive scan options omitted
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -19,7 +19,7 @@ private:
|
|||
// EProgressivePhase x20_progressivePhase = EProgressivePhase::Before;
|
||||
// bool x24_progressiveSelection = true;
|
||||
bool x25_textureLoaded = false;
|
||||
TLockedToken<CTexture> m_texture;
|
||||
TLockedToken<CTexture> x28_texture;
|
||||
|
||||
public:
|
||||
explicit CSplashScreen(ESplashScreen);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CGameCamera.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
|
@ -125,13 +125,13 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC
|
|||
}
|
||||
|
||||
CModelFlags flags(7, 0, 3, zeus::CColor(1.f, 0.f));
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly;
|
||||
x20_actorLights->ActivateLights(model->GetInstance());
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly;
|
||||
// x20_actorLights->ActivateLights(model->GetInstance());
|
||||
model->Draw(flags);
|
||||
|
||||
flags.x4_color = color;
|
||||
flags.x4_color.a() *= alpha;
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
model->Draw(flags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
#include "Runtime/MP1/CCredits.hpp"
|
||||
|
||||
#include "Runtime/CArchitectureMessage.hpp"
|
||||
#include "Runtime/CArchitectureQueue.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CMoviePlayer.hpp"
|
||||
#include "Runtime/GuiSys/CRasterFont.hpp"
|
||||
#include "Runtime/GuiSys/CStringTable.hpp"
|
||||
#include "Runtime/GuiSys/CGuiTextSupport.hpp"
|
||||
#include "Runtime/GuiSys/CStringTable.hpp"
|
||||
#include "Runtime/Input/CFinalInput.hpp"
|
||||
#include "Runtime/MP1/CPlayMovie.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace metaforce::MP1 {
|
||||
namespace {
|
||||
logvisor::Module Log("CCredits");
|
||||
}
|
||||
static logvisor::Module Log("CCredits");
|
||||
|
||||
CCredits::CCredits()
|
||||
: CIOWin("Credits")
|
||||
, x18_creditsTable(g_SimplePool->GetObj(g_tweakGui->GetCreditsTable()))
|
||||
|
@ -199,6 +198,7 @@ CIOWin::EMessageReturn CCredits::ProcessUserInput(const CFinalInput& input) {
|
|||
}
|
||||
return EMessageReturn::Exit;
|
||||
}
|
||||
|
||||
void CCredits::DrawVideo() {
|
||||
/* Correct movie aspect ratio */
|
||||
float hPad, vPad;
|
||||
|
@ -247,9 +247,10 @@ void CCredits::DrawText() {
|
|||
}
|
||||
|
||||
void CCredits::DrawText(CGuiTextSupport& text, const zeus::CVector3f& translation) {
|
||||
// auto region = g_Renderer->SetViewportOrtho(false, -4096, 4096);
|
||||
zeus::CTransform xf = zeus::CTransform::Translate(translation);
|
||||
g_Renderer->SetModelMatrix(xf);
|
||||
CGraphics::SetCullMode(ERglCullMode::None);
|
||||
g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
|
||||
g_Renderer->SetModelMatrix(zeus::CTransform::Translate(translation));
|
||||
g_Renderer->SetDepthReadWrite(false, false);
|
||||
text.Render();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
|
||||
namespace metaforce::MP1 {
|
||||
|
||||
|
@ -32,7 +33,7 @@ void CGameCubeDoll::Draw(float alpha) {
|
|||
|
||||
g_Renderer->SetPerspective(55.f, g_Viewport.x8_width, g_Viewport.xc_height, 0.2f, 4096.f);
|
||||
CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -2.f, 0.f));
|
||||
x18_actorLights->ActivateLights(x0_model->GetInstance());
|
||||
x18_actorLights->ActivateLights();
|
||||
CGraphics::SetModelMatrix(zeus::CTransform::RotateZ(zeus::degToRad(360.f * CGraphics::GetSecondsMod900() * -0.25f)) *
|
||||
zeus::CTransform::Scale(0.2f));
|
||||
CModelFlags flags(5, 0, 3, zeus::CColor(1.f, alpha * x1c_fader));
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Runtime/Audio/CSfxManager.hpp"
|
||||
#include "Runtime/AutoMapper/CAutoMapper.hpp"
|
||||
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/GuiSys/CGuiCamera.hpp"
|
||||
#include "Runtime/GuiSys/CGuiFrame.hpp"
|
||||
#include "Runtime/GuiSys/CGuiModel.hpp"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Camera/CGameCamera.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/GuiSys/CCompoundTargetReticle.hpp"
|
||||
#include "Runtime/GuiSys/CTargetingManager.hpp"
|
||||
|
@ -395,7 +395,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
|
|||
CModelFlags flags(5, 0, 0,
|
||||
frameColor + g_tweakGuiColors->GetScanFrameImpulseColor() *
|
||||
zeus::CColor(x550_scanFrameColorImpulseInterp, x550_scanFrameColorImpulseInterp));
|
||||
flags.m_noCull = true;
|
||||
// TODO flags.m_noCull = true;
|
||||
|
||||
const zeus::CTransform verticalFlip = zeus::CTransform::Scale(1.f, 1.f, -1.f);
|
||||
const zeus::CTransform horizontalFlip = zeus::CTransform::Scale(-1.f, 1.f, 1.f);
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
#include "Runtime/CDependencyGroup.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Collision/CollisionUtil.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/World/CMorphBall.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
@ -348,18 +347,20 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
|
||||
{
|
||||
CGraphics::SetModelMatrix(gunXf);
|
||||
x1f4_invBeam->GetInstance().ActivateLights(x23c_lights);
|
||||
// TODO
|
||||
// CGraphics::LoadLight(ERglLight::Zero, x248_);
|
||||
// old: x1f4_invBeam->GetInstance().ActivateLights(x23c_lights);
|
||||
CModelFlags flags = {};
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
x1f4_invBeam->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha);
|
||||
x1f4_invBeam->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha * itemPulse * x5c_beamPulseFactor);
|
||||
x1f4_invBeam->Draw(flags);
|
||||
}
|
||||
|
@ -371,14 +372,14 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
float alphaBlend = (visorT < 0.25f) ? 1.f - 2.f * visorT : (visorT < 0.5f) ? 2.f * (visorT - 0.25f) + 0.5f : 1.f;
|
||||
float addBlend = (visorT > 0.75f) ? 1.f - 4.f * (visorT - 0.75f) : (visorT > 0.5f) ? 4.f * (visorT - 0.5f) : 0.f;
|
||||
|
||||
x200_invVisor->GetInstance().ActivateLights(x23c_lights);
|
||||
// x200_invVisor->GetInstance().ActivateLights(x23c_lights);
|
||||
CModelFlags flags = {};
|
||||
flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
// flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
flags.x4_color =
|
||||
zeus::CColor::lerp(zeus::CColor(1.f, alpha), zeus::CColor(alphaBlend, alpha), x68_visorPulseFactor);
|
||||
x200_invVisor->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha * addBlend * x68_visorPulseFactor);
|
||||
x200_invVisor->Draw(flags);
|
||||
}
|
||||
|
@ -386,25 +387,25 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
if (x270_25_hasGrappleBeam) {
|
||||
CGraphics::SetModelMatrix(grappleXf);
|
||||
|
||||
x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights);
|
||||
// x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights);
|
||||
CModelFlags flags = {};
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha);
|
||||
x20c_invGrappleBeam->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha * itemPulse * x60_grapplePulseFactor);
|
||||
x20c_invGrappleBeam->Draw(flags);
|
||||
} else if (x44_suit >= CPlayerState::EPlayerSuit::FusionPower) {
|
||||
CGraphics::SetModelMatrix(grappleXf);
|
||||
|
||||
x218_invFins->GetInstance().ActivateLights(x23c_lights);
|
||||
// x218_invFins->GetInstance().ActivateLights(x23c_lights);
|
||||
CModelFlags flags = {};
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha);
|
||||
x218_invFins->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::CColor(1.f, alpha * suitPulse);
|
||||
x218_invFins->Draw(flags);
|
||||
}
|
||||
|
@ -421,16 +422,16 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
if (ballAlpha > 0.f) {
|
||||
CModelFlags flags = {};
|
||||
flags.x1_matSetIdx = x1e0_ballMatIdx;
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = alpha * ballAlpha;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = x6c_ballPulseFactor * alpha * ballAlpha * itemPulse;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
@ -455,7 +456,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
spinAlpha *= 0.5f;
|
||||
if (spinAlpha > 0.f) {
|
||||
CModelFlags flags = {};
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x1_matSetIdx = x1e0_ballMatIdx;
|
||||
flags.x4_color = zeus::CColor(1.f, spinAlpha * alpha);
|
||||
x184_ballModelData->Render(
|
||||
|
@ -468,18 +469,18 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
CGraphics::SetModelMatrix(x10_ballXf);
|
||||
CModelFlags flags = {};
|
||||
flags.x1_matSetIdx = x1e4_glassMatIdx;
|
||||
x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
|
||||
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
x1d4_spiderBallGlass->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = alpha;
|
||||
x1d4_spiderBallGlass->Draw(flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
|
||||
x1d4_spiderBallGlass->Draw(flags);
|
||||
|
@ -497,16 +498,16 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
} else {
|
||||
CModelFlags flags = {};
|
||||
flags.x1_matSetIdx = x1e0_ballMatIdx;
|
||||
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = alpha;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
flags.x4_color = zeus::skWhite;
|
||||
flags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
|
||||
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
|
||||
|
@ -549,18 +550,18 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
|
|||
CGraphics::SetModelMatrix(x10_ballXf);
|
||||
CModelFlags spiderBallGlassFlags = {};
|
||||
spiderBallGlassFlags.x1_matSetIdx = x1e4_glassMatIdx;
|
||||
x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
|
||||
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
|
||||
|
||||
spiderBallGlassFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
||||
spiderBallGlassFlags.x4_color = zeus::skWhite;
|
||||
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
|
||||
|
||||
spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
spiderBallGlassFlags.x4_color = zeus::skWhite;
|
||||
spiderBallGlassFlags.x4_color.a() = alpha;
|
||||
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
|
||||
|
||||
spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
||||
spiderBallGlassFlags.x4_color = zeus::skWhite;
|
||||
spiderBallGlassFlags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
|
||||
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
|
||||
|
|
|
@ -2,30 +2,6 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "NESEmulator/CNESShader.hpp"
|
||||
|
||||
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CColoredStripShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CEnvFxShaders.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CFluidPlaneShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CPhazonSuitFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CRadarPaintShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CTextSupportShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CThermalColdFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CThermalHotFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp"
|
||||
|
||||
#include "Runtime/CDependencyGroup.hpp"
|
||||
#include "Runtime/CGameHintInfo.hpp"
|
||||
#include "Runtime/CWorldSaveGameInfo.hpp"
|
||||
|
@ -64,12 +40,6 @@
|
|||
#include "Runtime/World/CStateMachine.hpp"
|
||||
#include "Runtime/World/CScriptMazeNode.hpp"
|
||||
|
||||
#include "Audio/SFX/Misc.h"
|
||||
#include "Audio/SFX/MiscSamus.h"
|
||||
#include "Audio/SFX/UI.h"
|
||||
#include "Audio/SFX/Weapons.h"
|
||||
#include "Audio/SFX/ZZZ.h"
|
||||
|
||||
#include "Runtime/MP1/CCredits.hpp"
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
|
@ -127,7 +97,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
|
|||
, x44_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) {
|
||||
auto* m = static_cast<CMain*>(g_Main);
|
||||
|
||||
// x30_inputGenerator.startScanning();
|
||||
g_InputGenerator = &x30_inputGenerator;
|
||||
|
||||
CAudioSys::SysSetVolume(0x7f);
|
||||
|
@ -253,54 +222,22 @@ CGameArchitectureSupport::~CGameArchitectureSupport() {
|
|||
|
||||
void CGameArchitectureSupport::charKeyDown(uint8_t charCode, aurora::ModifierKey mods, bool isRepeat) {
|
||||
x30_inputGenerator.charKeyDown(charCode, mods, isRepeat);
|
||||
// m_parent.m_console->handleCharCode(charCode, mods, isRepeat);
|
||||
}
|
||||
|
||||
void CGameArchitectureSupport::specialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat) {
|
||||
x30_inputGenerator.specialKeyDown(key, mods, isRepeat);
|
||||
// m_parent.m_console->handleSpecialKeyDown(key, mods, isRepeat);
|
||||
}
|
||||
|
||||
void CGameArchitectureSupport::specialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods) {
|
||||
x30_inputGenerator.specialKeyUp(key, mods);
|
||||
// m_parent.m_console->handleSpecialKeyUp(key, mods);
|
||||
}
|
||||
|
||||
CMain::CMain(IFactory* resFactory, CSimplePool* resStore)
|
||||
: m_booSetter()
|
||||
, xe4_gameplayResult(EGameplayResult::Playing)
|
||||
: xe4_gameplayResult(EGameplayResult::Playing)
|
||||
, x128_globalObjects(std::make_unique<CGameGlobalObjects>(resFactory, resStore)) {
|
||||
g_Main = this;
|
||||
}
|
||||
|
||||
CMain::BooSetter::BooSetter() {
|
||||
// CGraphics::InitializeBoo();
|
||||
CParticleSwooshShaders::Initialize();
|
||||
CThermalColdFilter::Initialize();
|
||||
CThermalHotFilter::Initialize();
|
||||
CSpaceWarpFilter::Initialize();
|
||||
CCameraBlurFilter::Initialize();
|
||||
CXRayBlurFilter::Initialize();
|
||||
// CFogVolumePlaneShader::Initialize();
|
||||
CFogVolumeFilter::Initialize();
|
||||
CEnergyBarShader::Initialize();
|
||||
CRadarPaintShader::Initialize();
|
||||
CMapSurfaceShader::Initialize();
|
||||
CPhazonSuitFilter::Initialize();
|
||||
CAABoxShader::Initialize();
|
||||
CWorldShadowShader::Initialize();
|
||||
CColoredQuadFilter::Initialize();
|
||||
CColoredStripShader::Initialize();
|
||||
CTexturedQuadFilter::Initialize();
|
||||
CTexturedQuadFilterAlpha::Initialize();
|
||||
CTextSupportShader::Initialize();
|
||||
CScanLinesFilter::Initialize();
|
||||
CRandomStaticFilter::Initialize();
|
||||
CEnvFxShaders::Initialize();
|
||||
CNESShader::Initialize();
|
||||
CMoviePlayer::Initialize();
|
||||
}
|
||||
|
||||
void CMain::RegisterResourceTweaks() {}
|
||||
|
||||
void CGameGlobalObjects::AddPaksAndFactories() {
|
||||
|
@ -324,7 +261,7 @@ void CGameGlobalObjects::AddPaksAndFactories() {
|
|||
fmgr->AddFactory(FOURCC('PART'), FFactoryFunc(FParticleFactory));
|
||||
fmgr->AddFactory(FOURCC('FRME'), FFactoryFunc(RGuiFrameFactoryInGame));
|
||||
fmgr->AddFactory(FOURCC('FONT'), FFactoryFunc(FRasterFontFactory));
|
||||
fmgr->AddFactory(FOURCC('CMDL'), FMemFactoryFunc(FPCModelFactory));
|
||||
fmgr->AddFactory(FOURCC('CMDL'), FMemFactoryFunc(FModelFactory));
|
||||
fmgr->AddFactory(FOURCC('CINF'), FFactoryFunc(FCharLayoutInfo));
|
||||
fmgr->AddFactory(FOURCC('CSKR'), FFactoryFunc(FSkinRulesFactory));
|
||||
fmgr->AddFactory(FOURCC('ANCS'), FFactoryFunc(FAnimCharacterSet));
|
||||
|
@ -436,14 +373,11 @@ void CMain::ResetGameState() {
|
|||
|
||||
void CMain::InitializeSubsystems() {
|
||||
CBasics::Initialize();
|
||||
CModelShaders::Initialize();
|
||||
CLineRenderer::Initialize();
|
||||
CElementGen::Initialize();
|
||||
CAnimData::InitializeCache();
|
||||
CDecalManager::Initialize();
|
||||
CGBASupport::Initialize();
|
||||
CPatterned::Initialize();
|
||||
// CGraphics::g_BooFactory->waitUntilShadersReady();
|
||||
}
|
||||
|
||||
void CMain::MemoryCardInitializePump() {
|
||||
|
@ -760,12 +694,10 @@ void CMain::Draw() {
|
|||
|
||||
void CMain::ShutdownSubsystems() {
|
||||
CMoviePlayer::Shutdown();
|
||||
CLineRenderer::Shutdown();
|
||||
CDecalManager::Shutdown();
|
||||
CElementGen::Shutdown();
|
||||
CAnimData::FreeCache();
|
||||
CMemoryCardSys::Shutdown();
|
||||
CModelShaders::Shutdown();
|
||||
CMappableObject::Shutdown();
|
||||
}
|
||||
|
||||
|
@ -773,32 +705,7 @@ void CMain::Shutdown() {
|
|||
x128_globalObjects->m_gameResFactory->UnloadPersistentResources();
|
||||
x164_archSupport.reset();
|
||||
ShutdownSubsystems();
|
||||
CParticleSwooshShaders::Shutdown();
|
||||
CThermalColdFilter::Shutdown();
|
||||
CThermalHotFilter::Shutdown();
|
||||
CSpaceWarpFilter::Shutdown();
|
||||
CCameraBlurFilter::Shutdown();
|
||||
CXRayBlurFilter::Shutdown();
|
||||
// CFogVolumePlaneShader::Shutdown();
|
||||
CFogVolumeFilter::Shutdown();
|
||||
CEnergyBarShader::Shutdown();
|
||||
CRadarPaintShader::Shutdown();
|
||||
CMapSurfaceShader::Shutdown();
|
||||
CPhazonSuitFilter::Shutdown();
|
||||
CAABoxShader::Shutdown();
|
||||
CWorldShadowShader::Shutdown();
|
||||
CColoredQuadFilter::Shutdown();
|
||||
CColoredStripShader::Shutdown();
|
||||
CTexturedQuadFilter::Shutdown();
|
||||
CTexturedQuadFilterAlpha::Shutdown();
|
||||
CTextSupportShader::Shutdown();
|
||||
CScanLinesFilter::Shutdown();
|
||||
CRandomStaticFilter::Shutdown();
|
||||
CEnvFxShaders::Shutdown();
|
||||
CFluidPlaneShader::Shutdown();
|
||||
CFluidPlaneManager::RippleMapTex.reset();
|
||||
CNESShader::Shutdown();
|
||||
CBooModel::Shutdown();
|
||||
// CBooModel::Shutdown();
|
||||
// CGraphics::ShutdownBoo();
|
||||
ShutdownDiscord();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "Runtime/Character/CAnimData.hpp"
|
||||
#include "Runtime/Particle/CDecalManager.hpp"
|
||||
#include "Runtime/Particle/CGenDescription.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Audio/CAudioSys.hpp"
|
||||
#include "Runtime/Input/CInputGenerator.hpp"
|
||||
#include "Runtime/GuiSys/CGuiSys.hpp"
|
||||
|
@ -71,7 +71,7 @@ class CGameGlobalObjects {
|
|||
}
|
||||
void AddPaksAndFactories();
|
||||
static IRenderer* AllocateRenderer(IObjectStore& store, IFactory& resFactory) {
|
||||
g_Renderer = new CBooRenderer(store, resFactory);
|
||||
g_Renderer = new CCubeRenderer(store, resFactory);
|
||||
return g_Renderer;
|
||||
}
|
||||
|
||||
|
@ -174,10 +174,6 @@ class CMain : public IMain {
|
|||
friend class CGameArchitectureSupport;
|
||||
|
||||
private:
|
||||
struct BooSetter {
|
||||
BooSetter();
|
||||
} m_booSetter;
|
||||
|
||||
// COsContext x0_osContext;
|
||||
// CMemorySys x6c_memSys;
|
||||
CTweaks x70_tweaks;
|
||||
|
|
|
@ -84,7 +84,7 @@ CBabygoth::CBabygoth(TUniqueId uid, std::string_view name, const CEntityInfo& in
|
|||
TLockedToken<CSkinRules> skin = g_SimplePool->GetObj({SBIG('CSKR'), babyData.x13c_noShellSkin});
|
||||
xa08_noShellModel =
|
||||
CToken(TObjOwnerDerivedFromIObj<CSkinnedModel>::GetNewDerivedObject(std::make_unique<CSkinnedModel>(
|
||||
model, skin, x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo(), 1)));
|
||||
model, skin, x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo())));
|
||||
xa14_crackOneParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x14c_crackOneParticle});
|
||||
xa20_crackTwoParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x150_crackTwoParticle});
|
||||
xa2c_destroyShellParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x154_destroyShellParticle});
|
||||
|
|
|
@ -156,7 +156,7 @@ void CBeetle::Render(CStateManager& mgr) {
|
|||
if (x428_damageCooldownTimer >= 0.f && x42c_color.a() == 1.f) {
|
||||
if (x5ac_tailModel) {
|
||||
CModelFlags flags(2, 0, 3, zeus::skWhite);
|
||||
flags.addColor = x42c_color;
|
||||
// TODO flags.addColor = x42c_color;
|
||||
x5ac_tailModel->Render(mgr, tailXf, x90_actorLights.get(), flags);
|
||||
}
|
||||
} else if (x5ac_tailModel) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/World/CPlayer.hpp"
|
||||
#include "Runtime/Collision/CCollisionActor.hpp"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Runtime/MP1/World/CBurrower.hpp"
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Particle/CElementGen.hpp"
|
||||
#include "Runtime/World/CGameArea.hpp"
|
||||
#include "Runtime/World/CPatternedInfo.hpp"
|
||||
|
@ -295,4 +295,4 @@ const std::optional<TLockedToken<CGenDescription>>& CBurrower::GetDeathExplosion
|
|||
return x520_deathExplosionParticle;
|
||||
}
|
||||
|
||||
} // namespace metaforce::MP1
|
||||
} // namespace metaforce::MP1
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Particle/CElementGen.hpp"
|
||||
#include "Runtime/World/CActorParameters.hpp"
|
||||
#include "Runtime/World/CGameLight.hpp"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Runtime/Collision/CCollisionActor.hpp"
|
||||
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/MP1/World/CFlaahgraProjectile.hpp"
|
||||
#include "Runtime/Particle/CElementGen.hpp"
|
||||
#include "Runtime/World/CActorParameters.hpp"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/Character/CPASAnimParmData.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/MP1/World/CSpacePirate.hpp"
|
||||
#include "Runtime/Weapon/CEnergyProjectile.hpp"
|
||||
#include "Runtime/Weapon/CGameProjectile.hpp"
|
||||
|
|
|
@ -130,7 +130,7 @@ void CGrenadeLauncher::PreRender(CStateManager& mgr, const zeus::CFrustum& frust
|
|||
if (x3f4_damageAddColor.a() == 1.f) {
|
||||
xb4_drawFlags = CModelFlags{2, 0, 3, zeus::skWhite};
|
||||
// Original code redundantly sets a() = 1.f
|
||||
xb4_drawFlags.addColor = x3f4_damageAddColor;
|
||||
// TODO xb4_drawFlags.addColor = x3f4_damageAddColor;
|
||||
} else {
|
||||
xb4_drawFlags = CModelFlags{5, 0, 3, x3f4_damageAddColor};
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Runtime/Collision/CCollisionActor.hpp"
|
||||
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Particle/CElementGen.hpp"
|
||||
#include "Runtime/Particle/CParticleElectric.hpp"
|
||||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||
|
|
|
@ -53,7 +53,7 @@ CMagdolite::CMagdolite(TUniqueId uid, std::string_view name, const CEntityInfo&
|
|||
, x690_headlessModel(
|
||||
CToken(TObjOwnerDerivedFromIObj<CSkinnedModel>::GetNewDerivedObject(std::make_unique<CSkinnedModel>(
|
||||
g_SimplePool->GetObj({SBIG('CMDL'), modelId}), g_SimplePool->GetObj({SBIG('CSKR'), skinId}),
|
||||
x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo(), 1))))
|
||||
x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo()))))
|
||||
, x6a8_flameInfo(magData)
|
||||
, x6cc_flameThrowerDesc(g_SimplePool->GetObj("FlameThrower"sv))
|
||||
, x6d4_flameThrowerDamage(dInfo1)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
||||
#include "Runtime/Collision/CGameCollision.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Weapon/CGameProjectile.hpp"
|
||||
#include "Runtime/World/CGameArea.hpp"
|
||||
#include "Runtime/World/CPatternedInfo.hpp"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Runtime/Collision/CCollisionActor.hpp"
|
||||
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/MP1/World/CEnergyBall.hpp"
|
||||
#include "Runtime/MP1/World/CIceAttackProjectile.hpp"
|
||||
#include "Runtime/MP1/World/CMetroidPrimeRelay.hpp"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Runtime/Collision/CGameCollision.hpp"
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Weapon/CGameProjectile.hpp"
|
||||
#include "Runtime/World/CPlayer.hpp"
|
||||
#include "Runtime/World/CScriptEffect.hpp"
|
||||
|
@ -124,7 +124,7 @@ COmegaPirate::COmegaPirate(TUniqueId uid, std::string_view name, const CEntityIn
|
|||
CAssetId skeletonLayoutInfoId)
|
||||
: CElitePirate(uid, name, info, xf, std::move(mData), pInfo, actParms, data)
|
||||
, x9d0_initialScale(GetModelData()->GetScale())
|
||||
, x9f0_skeletonModel(*g_SimplePool, skeletonModelId, skeletonSkinRulesId, skeletonLayoutInfoId, 0)
|
||||
, x9f0_skeletonModel(*g_SimplePool, skeletonModelId, skeletonSkinRulesId, skeletonLayoutInfoId)
|
||||
, xb70_thermalSpot(g_SimplePool->GetObj("Thermal_Spot_2"sv)) {
|
||||
x9a4_scriptWaypointPlatforms.reserve(3);
|
||||
x9b8_scriptEffects.reserve(24);
|
||||
|
|
|
@ -71,7 +71,7 @@ CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, c
|
|||
TLockedToken<CModel> skin = g_SimplePool->GetObj({FOURCC('CSKR'), skinRes});
|
||||
x624_extraModel =
|
||||
CToken(TObjOwnerDerivedFromIObj<CSkinnedModel>::GetNewDerivedObject(std::make_unique<CSkinnedModel>(
|
||||
model, skin, x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo(), 1)));
|
||||
model, skin, x64_modelData->GetAnimationData()->GetModelData()->GetLayoutInfo())));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
|
||||
#include "TCastTo.hpp" // Generated file, do not modify include path
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Particle/CElementGen.hpp"
|
||||
#include "Runtime/Particle/CParticleElectric.hpp"
|
||||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/World/CActorParameters.hpp"
|
||||
#include "Runtime/World/CGameLight.hpp"
|
||||
#include "Runtime/World/CHUDBillboardEffect.hpp"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Runtime/Character/CCharLayoutInfo.hpp"
|
||||
#include "Runtime/Character/CPASAnimParmData.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/MP1/World/CMetroid.hpp"
|
||||
#include "Runtime/Weapon/CGameProjectile.hpp"
|
||||
#include "Runtime/World/CPatternedInfo.hpp"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CDecalShaders.hpp"
|
||||
#include "Runtime/Particle/CDecal.hpp"
|
||||
#include "Runtime/Particle/CDecalDescription.hpp"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Character/CActorLights.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CElementGenShaders.hpp"
|
||||
#include "Runtime/Particle/CElectricDescription.hpp"
|
||||
|
@ -1077,12 +1077,12 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
|
|||
} else {
|
||||
CModel* model = desc->x5c_x48_PMDL.m_token.GetObj();
|
||||
if (actorLights)
|
||||
actorLights->ActivateLights(model->GetInstance());
|
||||
actorLights->ActivateLights();
|
||||
if (g_subtractBlend) {
|
||||
model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)});
|
||||
} else if (desc->x44_31_x31_25_PMAB) {
|
||||
CModelFlags flags{7, 0, 1, col};
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditiveNoZWrite;
|
||||
// flags.m_extendedShader = EExtendedShader::ForcedAdditiveNoZWrite;
|
||||
model->Draw(flags);
|
||||
} else if (1.f == col.a()) {
|
||||
model->Draw({0, 0, 3, zeus::skWhite});
|
||||
|
@ -1215,7 +1215,7 @@ void CElementGen::RenderLines() {
|
|||
}
|
||||
}
|
||||
|
||||
m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass(), moduColor);
|
||||
// m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass(), moduColor);
|
||||
}
|
||||
|
||||
void CElementGen::RenderParticles() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/Particle/CElectricDescription.hpp"
|
||||
|
@ -108,7 +108,7 @@ void CParticleElectric::DrawLineStrip(const std::vector<zeus::CVector3f>& verts,
|
|||
for (const zeus::CVector3f& vert : verts) {
|
||||
renderer.AddVertex(vert, useColor, width);
|
||||
}
|
||||
renderer.Render(g_Renderer->IsThermalVisorHotPass());
|
||||
renderer.Render(); // g_Renderer->IsThermalVisorHotPass()
|
||||
}
|
||||
|
||||
void CParticleElectric::RenderLines() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
||||
#include "Runtime/Particle/CParticleGlobals.hpp"
|
||||
#include "Runtime/Particle/CSwooshDescription.hpp"
|
||||
|
||||
|
@ -479,7 +479,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
|
|||
}
|
||||
|
||||
if (x1bc_prim == GX::LINES) {
|
||||
m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass());
|
||||
// m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace metaforce {
|
||||
static u32 min_containing_bytes(u32 v) {
|
||||
v = 32 - v;
|
||||
v = (v >> 3) - ((s32) - (v & 7) >> 31);
|
||||
v = (v >> 3) - (static_cast<s32>(-(v & 7)) >> 31);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace metaforce {
|
||||
|
@ -46,7 +48,7 @@ public:
|
|||
double ReadDouble();
|
||||
|
||||
void Get(u8* dest, u32 len);
|
||||
template <class T>
|
||||
template <typename T>
|
||||
T Get() {
|
||||
return cinput_stream_helper<T>(*this);
|
||||
}
|
||||
|
@ -80,4 +82,4 @@ template <>
|
|||
double cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
std::string cinput_stream_helper(CInputStream& in);
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -9,11 +9,9 @@ public:
|
|||
Owned,
|
||||
};
|
||||
|
||||
public:
|
||||
CMemoryInStream(const void* ptr, u32 len) : CInputStream(ptr, len, false) {}
|
||||
CMemoryInStream(const void* ptr, u32 len, EOwnerShip ownership)
|
||||
: CInputStream(ptr, len, ownership == EOwnerShip::Owned) {}
|
||||
u32 Read(void* dest, u32 len) override { return 0; }
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "CMemoryStreamOut.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace metaforce {
|
||||
|
@ -9,6 +10,7 @@ CMemoryStreamOut::~CMemoryStreamOut() {
|
|||
delete[] x7c_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryStreamOut::Write(const u8* ptr, u32 len) {
|
||||
const auto offset = (x80_len - x84_position);
|
||||
if (offset < len) {
|
||||
|
@ -19,4 +21,4 @@ void CMemoryStreamOut::Write(const u8* ptr, u32 len) {
|
|||
memcpy(x7c_ptr + x84_position, ptr, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -8,6 +8,7 @@ public:
|
|||
NotOwned,
|
||||
Owned,
|
||||
};
|
||||
|
||||
private:
|
||||
u8* x7c_ptr = nullptr;
|
||||
u32 x80_len = 0;
|
||||
|
@ -22,4 +23,4 @@ public:
|
|||
|
||||
void Write(const u8* ptr, u32 len) override;
|
||||
};
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace metaforce {
|
||||
static u32 min_containing_bytes(u32 v) {
|
||||
v = 32 - v;
|
||||
v = (v >> 3) - ((s32) - (v & 7) >> 31);
|
||||
v = (v >> 3) - (static_cast<s32>(-(v & 7)) >> 31);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,13 @@ CZipInputStream::CZipInputStream(std::unique_ptr<CInputStream>&& strm)
|
|||
CZipInputStream::~CZipInputStream() { inflateEnd(x30_zstrm.get()); }
|
||||
|
||||
u32 CZipInputStream::Read(void* buf, u32 len) {
|
||||
x30_zstrm->next_out = static_cast<Bytef *>(buf);
|
||||
x30_zstrm->next_out = static_cast<Bytef*>(buf);
|
||||
x30_zstrm->avail_out = len;
|
||||
if (x30_zstrm->avail_in == 0) {
|
||||
x30_zstrm->avail_in = x28_strm->ReadBytes(x24_compBuf.get(),4096);
|
||||
x30_zstrm->avail_in = x28_strm->ReadBytes(x24_compBuf.get(), 4096);
|
||||
x30_zstrm->next_in = x24_compBuf.get();
|
||||
}
|
||||
inflate(x30_zstrm.get(), Z_NO_FLUSH);
|
||||
return len - x30_zstrm->avail_out;
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
namespace metaforce {
|
||||
class CZipInputStream : public CInputStream {
|
||||
std::unique_ptr<u8[]> x24_compBuf;
|
||||
|
@ -17,5 +18,4 @@ public:
|
|||
|
||||
u32 Read(void* ptr, u32 len) override;
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Runtime/rstl.hpp"
|
||||
#include "Runtime/Streams/CInputStream.hpp"
|
||||
#include "Runtime/rstl.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
template <class T, size_t N>
|
||||
void read_reserved_vector(rstl::reserved_vector<T, N>& v, CInputStream& in) {
|
||||
|
@ -11,4 +11,4 @@ void read_reserved_vector(rstl::reserved_vector<T, N>& v, CInputStream& in) {
|
|||
v[i] = in.Get<T>();
|
||||
}
|
||||
}
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -46,7 +46,6 @@ zeus::CAABox cinput_stream_helper(CInputStream& in) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
zeus::COBBox cinput_stream_helper(CInputStream& in) {
|
||||
zeus::COBBox ret;
|
||||
|
@ -95,13 +94,13 @@ zeus::CMatrix4f cinput_stream_helper(CInputStream& in) {
|
|||
return ret.transposed();
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
rstl::reserved_vector<T,N> cinput_stream_helper(CInputStream& in) {
|
||||
return rstl::reserved_vector<T,N>(in);
|
||||
template <typename T, size_t N>
|
||||
rstl::reserved_vector<T, N> cinput_stream_helper(CInputStream& in) {
|
||||
return rstl::reserved_vector<T, N>(in);
|
||||
}
|
||||
|
||||
// Output
|
||||
template<>
|
||||
template <>
|
||||
void coutput_stream_helper(const zeus::CVector3f& v, COutputStream& out) {
|
||||
out.Put(v.x());
|
||||
out.Put(v.y());
|
||||
|
|
|
@ -18,6 +18,7 @@ class COBBox;
|
|||
class CQuaternion;
|
||||
class CColor;
|
||||
} // namespace zeus
|
||||
|
||||
namespace metaforce {
|
||||
// Custom helpers for input/output
|
||||
template <>
|
||||
|
@ -43,5 +44,4 @@ zeus::CMatrix4f cinput_stream_helper(CInputStream& in);
|
|||
|
||||
template <>
|
||||
void coutput_stream_helper(const zeus::CVector3f& v, COutputStream& out);
|
||||
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue