2016-04-14 03:32:27 +00:00
|
|
|
#include "CModelData.hpp"
|
|
|
|
#include "CAnimData.hpp"
|
2016-04-14 21:42:47 +00:00
|
|
|
#include "IAnimReader.hpp"
|
|
|
|
#include "Graphics/CGraphics.hpp"
|
|
|
|
#include "Graphics/CSkinnedModel.hpp"
|
|
|
|
#include "Graphics/CVertexMorphEffect.hpp"
|
|
|
|
#include "Editor/ProjectManager.hpp"
|
|
|
|
#include "CActorLights.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CPlayerState.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "CAssetFactory.hpp"
|
|
|
|
#include "CCharacterFactory.hpp"
|
2016-04-16 03:24:25 +00:00
|
|
|
#include "CAdditiveAnimPlayback.hpp"
|
2016-04-14 03:32:27 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2016-08-31 23:08:09 +00:00
|
|
|
static logvisor::Module Log("urde::CModelData");
|
2016-04-14 03:32:27 +00:00
|
|
|
|
2016-04-15 03:02:21 +00:00
|
|
|
CModelData::~CModelData() {}
|
|
|
|
|
2016-04-14 03:32:27 +00:00
|
|
|
CModelData::CModelData() {}
|
2016-04-15 03:02:21 +00:00
|
|
|
CModelData CModelData::CModelDataNull() {return CModelData();}
|
2016-04-14 03:32:27 +00:00
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
CModelData::CModelData(const CStaticRes& res, int instCount)
|
|
|
|
: x0_scale(res.GetScale()), m_drawInstCount(instCount)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-27 19:59:38 +00:00
|
|
|
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
|
2016-08-31 23:08:09 +00:00
|
|
|
if (!x1c_normalModel)
|
|
|
|
Log.report(logvisor::Fatal, "unable to find CMDL %08X", res.GetId());
|
2016-09-12 04:53:28 +00:00
|
|
|
m_normalModelInst = x1c_normalModel->MakeNewInstance(0, instCount);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
CModelData::CModelData(const CAnimRes& res, int instCount)
|
|
|
|
: x0_scale(res.GetScale()), m_drawInstCount(instCount)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
|
2016-09-12 04:53:28 +00:00
|
|
|
x10_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory,
|
|
|
|
res.GetDefaultAnim(), instCount);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a,
|
|
|
|
const CCharAnimTime& b) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
return x10_animData->GetAdvancementDeltas(a, b);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return {};
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
Render(GetRenderingModel(stateMgr), xf, lights, drawFlags);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2017-07-31 05:19:05 +00:00
|
|
|
CModelData::EWhichModel CModelData::GetRenderingModel(const CStateManager& stateMgr)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
switch (stateMgr.GetPlayerState()->GetActiveVisor(stateMgr))
|
|
|
|
{
|
|
|
|
case CPlayerState::EPlayerVisor::XRay:
|
|
|
|
return CModelData::EWhichModel::XRay;
|
|
|
|
case CPlayerState::EPlayerVisor::Thermal:
|
|
|
|
return CModelData::EWhichModel::Thermal;
|
|
|
|
default:
|
|
|
|
return CModelData::EWhichModel::Normal;
|
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 00:04:50 +00:00
|
|
|
CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-08-21 00:04:50 +00:00
|
|
|
CSkinnedModel* ret = nullptr;
|
2016-04-14 21:42:47 +00:00
|
|
|
switch (which)
|
|
|
|
{
|
|
|
|
case EWhichModel::XRay:
|
2016-04-29 10:08:46 +00:00
|
|
|
ret = x10_animData->xf4_xrayModel.get();
|
2016-04-14 21:42:47 +00:00
|
|
|
case EWhichModel::Thermal:
|
2016-04-29 10:08:46 +00:00
|
|
|
ret = x10_animData->xf8_infraModel.get();
|
2016-04-14 21:42:47 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
if (ret)
|
|
|
|
return *ret;
|
2016-04-29 10:08:46 +00:00
|
|
|
return *x10_animData->xd8_modelData.GetObj();
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-09 04:19:19 +00:00
|
|
|
const std::unique_ptr<CBooModel>& CModelData::PickStaticModel(EWhichModel which) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-09-09 04:19:19 +00:00
|
|
|
const std::unique_ptr<CBooModel>* ret = nullptr;
|
2016-04-14 21:42:47 +00:00
|
|
|
switch (which)
|
|
|
|
{
|
|
|
|
case EWhichModel::XRay:
|
2016-09-02 19:32:57 +00:00
|
|
|
ret = &m_xrayModelInst;
|
2016-04-14 21:42:47 +00:00
|
|
|
case EWhichModel::Thermal:
|
2016-09-02 19:32:57 +00:00
|
|
|
ret = &m_infraModelInst;
|
2016-04-14 21:42:47 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
if (ret)
|
|
|
|
return *ret;
|
2016-09-02 19:32:57 +00:00
|
|
|
return m_normalModelInst;
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::SetXRayModel(const std::pair<ResId, ResId>& modelSkin)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
if (modelSkin.first)
|
|
|
|
{
|
2016-04-15 03:02:21 +00:00
|
|
|
if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData && modelSkin.second &&
|
2016-04-15 03:02:21 +00:00
|
|
|
g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR'))
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
x10_animData->SetXRayModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}),
|
2016-04-15 03:02:21 +00:00
|
|
|
g_SimplePool->GetObj({SBIG('CSKR'), modelSkin.second}));
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-15 03:02:21 +00:00
|
|
|
x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
2016-09-02 19:32:57 +00:00
|
|
|
if (!x2c_xrayModel)
|
|
|
|
Log.report(logvisor::Fatal, "unable to find CMDL %08X", modelSkin.first);
|
2016-09-12 04:53:28 +00:00
|
|
|
m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0, m_drawInstCount);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::SetInfraModel(const std::pair<ResId, ResId>& modelSkin)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
if (modelSkin.first)
|
|
|
|
{
|
2016-04-15 03:02:21 +00:00
|
|
|
if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData && modelSkin.second &&
|
2016-04-15 03:02:21 +00:00
|
|
|
g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR'))
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
x10_animData->SetInfraModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}),
|
2016-04-15 03:02:21 +00:00
|
|
|
g_SimplePool->GetObj({SBIG('CSKR'), modelSkin.second}));
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-15 03:02:21 +00:00
|
|
|
x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
2016-09-02 19:32:57 +00:00
|
|
|
if (!x3c_infraModel)
|
|
|
|
Log.report(logvisor::Fatal, "unable to find CMDL %08X", modelSkin.first);
|
2016-09-12 04:53:28 +00:00
|
|
|
m_infraModelInst = x3c_infraModel->MakeNewInstance(0, m_drawInstCount);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 00:04:50 +00:00
|
|
|
bool CModelData::IsDefinitelyOpaque(EWhichModel which)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-08-21 00:04:50 +00:00
|
|
|
CSkinnedModel& model = PickAnimatedModel(which);
|
2016-09-02 19:32:57 +00:00
|
|
|
return model.GetModelInst()->IsOpaque();
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-09 04:19:19 +00:00
|
|
|
const auto& model = PickStaticModel(which);
|
2016-09-02 19:32:57 +00:00
|
|
|
return model->IsOpaque();
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CModelData::GetIsLoop() const
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
return false;
|
2016-04-29 10:08:46 +00:00
|
|
|
return x10_animData->GetIsLoop();
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
float CModelData::GetAnimationDuration(int idx) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
return 0.f;
|
2016-04-29 10:08:46 +00:00
|
|
|
return x10_animData->GetAnimationDuration(idx);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::EnableLooping(bool enable)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
return;
|
2016-04-29 10:08:46 +00:00
|
|
|
x10_animData->EnableLooping(enable);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::AdvanceParticles(const zeus::CTransform& xf, float dt,
|
2016-04-14 03:32:27 +00:00
|
|
|
CStateManager& stateMgr)
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
return;
|
2016-09-02 22:16:34 +00:00
|
|
|
x10_animData->AdvanceParticles(xf, dt, x0_scale, stateMgr);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CAABox CModelData::GetBounds() const
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-09-02 22:16:34 +00:00
|
|
|
return x10_animData->GetBoundingBox(zeus::CTransform::Scale(x0_scale));
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const zeus::CAABox& aabb = x1c_normalModel->GetAABB();
|
2016-09-02 22:16:34 +00:00
|
|
|
return zeus::CAABox(aabb.min * x0_scale, aabb.max * x0_scale);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CAABox CModelData::GetBounds(const zeus::CTransform& xf) const
|
|
|
|
{
|
2016-09-02 22:16:34 +00:00
|
|
|
zeus::CTransform xf2 = xf * zeus::CTransform::Scale(x0_scale);
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
return x10_animData->GetBoundingBox(xf2);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return x1c_normalModel->GetAABB().getTransformedAABox(xf2);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CTransform CModelData::GetScaledLocatorTransformDynamic(const std::string& name,
|
|
|
|
const CCharAnimTime* time) const
|
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
zeus::CTransform xf = GetLocatorTransformDynamic(name, time);
|
2016-09-02 22:16:34 +00:00
|
|
|
xf.origin *= x0_scale;
|
2016-04-14 21:42:47 +00:00
|
|
|
return xf;
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CTransform CModelData::GetScaledLocatorTransform(const std::string& name) const
|
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
zeus::CTransform xf = GetLocatorTransform(name);
|
2016-09-02 22:16:34 +00:00
|
|
|
xf.origin *= x0_scale;
|
2016-04-14 21:42:47 +00:00
|
|
|
return xf;
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CTransform CModelData::GetLocatorTransformDynamic(const std::string& name,
|
|
|
|
const CCharAnimTime* time) const
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
return x10_animData->GetLocatorTransform(name, time);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return {};
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CTransform CModelData::GetLocatorTransform(const std::string& name) const
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
return x10_animData->GetLocatorTransform(name, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return {};
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 17:50:03 +00:00
|
|
|
SAdvancementDeltas CModelData::AdvanceAnimationIgnoreParticles(float dt, CRandom16& rand, bool advTree)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-09-02 17:50:03 +00:00
|
|
|
return x10_animData->AdvanceIgnoreParticles(dt, rand, advTree);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return {};
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 17:50:03 +00:00
|
|
|
SAdvancementDeltas CModelData::AdvanceAnimation(float dt, CStateManager& stateMgr, TAreaId aid, bool advTree)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-09-02 22:16:34 +00:00
|
|
|
return x10_animData->Advance(dt, x0_scale, stateMgr, aid, advTree);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
return {};
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CModelData::IsAnimating() const
|
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
return false;
|
2016-04-29 10:08:46 +00:00
|
|
|
return x10_animData->IsAnimating();
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CModelData::IsInFrustum(const zeus::CTransform& xf,
|
2016-09-04 02:27:35 +00:00
|
|
|
const zeus::CFrustum& frustum) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (!x10_animData && !x1c_normalModel)
|
2016-04-14 21:42:47 +00:00
|
|
|
return true;
|
2016-09-04 02:27:35 +00:00
|
|
|
return frustum.aabbFrustumTest(GetBounds(xf));
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-04 02:27:35 +00:00
|
|
|
void CModelData::RenderParticles(const zeus::CFrustum& frustum) const
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
x10_animData->RenderAuxiliary(frustum);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 00:04:50 +00:00
|
|
|
void CModelData::Touch(EWhichModel which, int shaderIdx)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
|
|
|
x10_animData->Touch(PickAnimatedModel(which), shaderIdx);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
|
|
|
PickStaticModel(which)->Touch(shaderIdx);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 00:04:50 +00:00
|
|
|
void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
Touch(GetRenderingModel(stateMgr), shaderIdx);
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CModelData::RenderThermal(const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const zeus::CColor& a, const zeus::CColor& b)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-09-02 22:16:34 +00:00
|
|
|
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
2016-04-14 21:42:47 +00:00
|
|
|
CGraphics::DisableAllLights();
|
|
|
|
CModelFlags drawFlags;
|
2017-03-10 20:52:53 +00:00
|
|
|
drawFlags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
2016-04-14 21:42:47 +00:00
|
|
|
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-08-21 20:39:18 +00:00
|
|
|
CSkinnedModel& model = PickAnimatedModel(EWhichModel::Thermal);
|
|
|
|
x10_animData->SetupRender(model, drawFlags, {}, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
model.Draw(drawFlags);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-09 04:19:19 +00:00
|
|
|
const auto& model = PickStaticModel(EWhichModel::Thermal);
|
2016-09-02 19:32:57 +00:00
|
|
|
model->Draw(drawFlags, nullptr, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags)
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
if ((x14_25_sortThermal && which == EWhichModel::Thermal) ||
|
2017-03-20 05:09:53 +00:00
|
|
|
x10_animData || !x1c_normalModel || drawFlags.x0_blendMode > 2)
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-08-29 04:22:54 +00:00
|
|
|
const_cast<CModelData*>(this)->x14_24_renderSorted = false;
|
2016-04-14 21:42:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-02 22:16:34 +00:00
|
|
|
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2016-09-09 04:19:19 +00:00
|
|
|
const auto& model = PickStaticModel(which);
|
2016-04-14 21:42:47 +00:00
|
|
|
if (lights)
|
2016-09-02 19:32:57 +00:00
|
|
|
lights->ActivateLights(*model);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
2016-09-02 19:32:57 +00:00
|
|
|
model->ActivateLights({});
|
2016-04-14 21:42:47 +00:00
|
|
|
|
2016-09-02 19:32:57 +00:00
|
|
|
model->DrawNormal(drawFlags, nullptr, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
// Set ambient to white
|
|
|
|
CGraphics::DisableAllLights();
|
2016-08-29 04:22:54 +00:00
|
|
|
const_cast<CModelData*>(this)->x14_24_renderSorted = true;
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
void CModelData::Render(EWhichModel which, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags)
|
2016-08-23 03:12:50 +00:00
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
if (x14_25_sortThermal && which == EWhichModel::Thermal)
|
|
|
|
{
|
2017-03-20 05:09:53 +00:00
|
|
|
zeus::CColor mul(drawFlags.x4_color.a, drawFlags.x4_color.a, drawFlags.x4_color.a, drawFlags.x4_color.a);
|
2016-04-14 21:42:47 +00:00
|
|
|
RenderThermal(xf, mul, {0.f, 0.f, 0.f, 0.25f});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-02 22:16:34 +00:00
|
|
|
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
|
2016-04-14 21:42:47 +00:00
|
|
|
|
2016-04-29 10:08:46 +00:00
|
|
|
if (x10_animData)
|
2016-04-14 21:42:47 +00:00
|
|
|
{
|
2016-08-21 00:04:50 +00:00
|
|
|
CSkinnedModel& model = PickAnimatedModel(which);
|
|
|
|
if (lights)
|
2016-09-02 19:32:57 +00:00
|
|
|
lights->ActivateLights(*model.GetModelInst());
|
2016-08-21 00:04:50 +00:00
|
|
|
else
|
2016-09-02 19:32:57 +00:00
|
|
|
model.GetModelInst()->ActivateLights({});
|
2016-08-21 00:04:50 +00:00
|
|
|
|
|
|
|
x10_animData->Render(model, drawFlags, {}, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-09 04:19:19 +00:00
|
|
|
const auto& model = PickStaticModel(which);
|
2016-08-21 00:04:50 +00:00
|
|
|
if (lights)
|
2016-09-02 19:32:57 +00:00
|
|
|
lights->ActivateLights(*model);
|
2016-08-21 00:04:50 +00:00
|
|
|
else
|
2016-09-02 19:32:57 +00:00
|
|
|
model->ActivateLights({});
|
2016-08-21 00:04:50 +00:00
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
if (x14_24_renderSorted)
|
2016-09-02 19:32:57 +00:00
|
|
|
model->DrawAlpha(drawFlags, nullptr, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
else
|
2016-09-02 19:32:57 +00:00
|
|
|
model->Draw(drawFlags, nullptr, nullptr);
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set ambient to white
|
|
|
|
CGraphics::DisableAllLights();
|
2016-08-29 04:22:54 +00:00
|
|
|
const_cast<CModelData*>(this)->x14_24_renderSorted = false;
|
2016-04-14 21:42:47 +00:00
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-06 05:21:42 +00:00
|
|
|
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::CColor::skWhite;
|
|
|
|
x10_animData->Render(model, flags, {}, nullptr);
|
|
|
|
|
|
|
|
/* Normal Blended */
|
|
|
|
lights->ActivateLights(*model.GetModelInst());
|
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
|
|
|
flags.x4_color = alphaColor;
|
|
|
|
x10_animData->Render(model, flags, {}, nullptr);
|
|
|
|
|
|
|
|
/* Selection Additive */
|
|
|
|
flags.m_extendedShader = EExtendedShader::ForcedAdditive;
|
|
|
|
flags.x4_color = additiveColor;
|
|
|
|
x10_animData->Render(model, flags, {}, nullptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CBooModel& model = *PickStaticModel(which);
|
|
|
|
model.DisableAllLights();
|
|
|
|
CModelFlags flags = {};
|
|
|
|
|
|
|
|
/* Z-prime */
|
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
|
|
|
flags.x4_color = zeus::CColor::skWhite;
|
|
|
|
model.Draw(flags, nullptr, nullptr);
|
|
|
|
|
|
|
|
/* Normal Blended */
|
|
|
|
lights->ActivateLights(model);
|
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 03:32:27 +00:00
|
|
|
}
|