This commit is contained in:
Phillip Stephens 2016-08-20 22:48:06 -07:00
commit c78916465c
15 changed files with 447 additions and 77 deletions

View File

@ -1,10 +1,112 @@
#include "CActorLights.hpp" #include "CActorLights.hpp"
#include "Graphics/CModel.hpp"
namespace urde namespace urde
{ {
CActorLights::CActorLights(u32, const zeus::CVector3f& vec, int, int, float) CActorLights::CActorLights(u32 unk, const zeus::CVector3f& vec, int a, int b, int c, int d, int e, float f1)
: x2a8_(unk), x2ac_(vec), x2b8_b(b), x2bc_a(a), x2cc_(f1 * f1)
{
x298_24_ = true;
x298_25_ = true;
x298_28_inArea = (!e && b > 0) ? true : false;
x298_29_ = c;
x298_30_ = d;
x298_31_ = e;
x299_24_ = true;
}
void CActorLights::BuildConstantAmbientLighting()
{
x299_26_ = true;
x298_24_ = true;
x29c_ = -1;
x2a0_ = -1;
}
void CActorLights::BuildConstantAmbientLighting(const zeus::CColor& color)
{
x299_26_ = false;
x288_ambientColor = color;
x294_aid = kInvalidAreaId;
x298_24_ = true;
x298_26_ = true;
x29c_ = -1;
x2a0_ = -1;
}
void CActorLights::BuildFakeLightList(const std::vector<CLight>& lights, const zeus::CColor& color)
{
BuildConstantAmbientLighting(color);
x144_dynamicLights = lights;
}
void CActorLights::BuildFaceLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb)
{ {
} }
void CActorLights::BuildDynamicLightList(CStateManager& mgr, const zeus::CAABox& aabb)
{
}
void CActorLights::MoveAmbienceToLights(const zeus::CVector3f& vec)
{
}
void CActorLights::ActivateLights(CBooModel& model) const
{
std::vector<CLight> lights;
if (x298_28_inArea)
{
if (!x298_26_ || !x299_26_)
{
model.ActivateLights(lights);
return;
}
}
lights.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, x288_ambientColor));
if (x0_areaLights.size())
{
if (x2dc_overrideDist && x299_25_overrideFirstDist)
{
CLight overrideLight = x0_areaLights[0];
overrideLight.SetColor(overrideLight.GetColor() * (1.f - x2dc_overrideDist / 15.f));
lights.push_back(overrideLight);
}
else
lights.push_back(x0_areaLights[0]);
for (auto it = x0_areaLights.begin() + 1 ; it != x0_areaLights.end() ; ++it)
{
lights.push_back(*it);
}
}
for (const CLight& light : x144_dynamicLights)
lights.push_back(light);
model.ActivateLights(lights);
}
const CLight& CActorLights::GetLight(u32 idx) const
{
if (x298_28_inArea)
{
if (idx < x0_areaLights.size())
return x0_areaLights[idx];
return x144_dynamicLights[idx - x0_areaLights.size()];
}
return x144_dynamicLights[idx];
}
u32 CActorLights::GetActiveLightCount() const
{
if (x298_28_inArea)
return x0_areaLights.size() + x144_dynamicLights.size();
return x144_dynamicLights.size();
}
} }

View File

@ -3,15 +3,70 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp" #include "zeus/CVector3f.hpp"
#include "zeus/CColor.hpp"
#include "zeus/CAABox.hpp"
#include "Graphics/CLight.hpp"
namespace urde namespace urde
{ {
class CBooModel;
class CStateManager;
class CGameArea;
class CActorLights class CActorLights
{ {
std::vector<CLight> x0_areaLights;
std::vector<CLight> x144_dynamicLights;
zeus::CColor x288_ambientColor;
TAreaId x294_aid = kInvalidAreaId;
union
{
struct
{
bool x298_24_ : 1;
bool x298_25_ : 1;
bool x298_26_ : 1;
bool x298_27_ : 1;
bool x298_28_inArea : 1;
bool x298_29_ : 1;
bool x298_30_ : 1;
bool x298_31_ : 1;
bool x299_24_ : 1;
bool x299_25_overrideFirstDist : 1;
bool x299_26_ : 1;
};
u16 _dummy = 0;
};
bool x29a_ = false;
u32 x29c_ = -1;
u32 x2a0_ = -1;
u32 x2a4_ = 0;
u32 x2a8_;
zeus::CVector3f x2ac_;
int x2b8_b;
int x2bc_a;
zeus::CVector3f x2c0_;
float x2cc_;
float x2d0_ = 0.f;
float x2d4_ = 1.f;
u32 x2d8_ = -1;
u32 x2dc_overrideDist = 0;
public: public:
CActorLights(u32, const zeus::CVector3f& vec, int, int, float); CActorLights(u32, const zeus::CVector3f& vec, int, int, int, int, int, float);
void ActivateLights() const {}
void BuildConstantAmbientLighting();
void BuildConstantAmbientLighting(const zeus::CColor& color);
void BuildFakeLightList(const std::vector<CLight>& lights, const zeus::CColor& color);
void BuildFaceLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
void BuildDynamicLightList(CStateManager& mgr, const zeus::CAABox& aabb);
void MoveAmbienceToLights(const zeus::CVector3f& vec);
void ActivateLights(CBooModel& model) const;
void SetAmbientColor(const zeus::CColor& color) { x288_ambientColor = color; }
const CLight& GetLight(u32 idx) const;
u32 GetActiveLightCount() const;
}; };
} }

View File

@ -13,6 +13,8 @@
#include "CParticleGenInfo.hpp" #include "CParticleGenInfo.hpp"
#include "IAnimReader.hpp" #include "IAnimReader.hpp"
#include "CAnimTreeNode.hpp" #include "CAnimTreeNode.hpp"
#include "CAnimPerSegmentData.hpp"
#include "CSegStatementSet.hpp"
namespace urde namespace urde
{ {
@ -49,9 +51,9 @@ CAnimData::CAnimData(ResId id,
x1fc_transMgr(transMgr), x1fc_transMgr(transMgr),
x204_charIdx(charIdx), x204_charIdx(charIdx),
x208_defaultAnim(defaultAnim), x208_defaultAnim(defaultAnim),
x21c_25_loop(loop), x220_25_loop(loop),
x220_pose(layout->GetSegIdList().GetList().size()), x224_pose(layout->GetSegIdList().GetList().size()),
x2f8_poseBuilder(layout) x2fc_poseBuilder(layout)
{ {
if (iceModel) if (iceModel)
xe4_iceModelData = *iceModel; xe4_iceModelData = *iceModel;
@ -72,7 +74,7 @@ ResId CAnimData::GetEventResourceIdForAnimResourceId(ResId id) const
void CAnimData::AddAdditiveSegData(const CSegIdList& list, CSegStatementSet& stSet) void CAnimData::AddAdditiveSegData(const CSegIdList& list, CSegStatementSet& stSet)
{ {
for (std::pair<u32, CAdditiveAnimPlayback>& additive : x1044_additiveAnims) for (std::pair<u32, CAdditiveAnimPlayback>& additive : x1048_additiveAnims)
if (additive.second.GetTargetWeight() > 0.00001f) if (additive.second.GetTargetWeight() > 0.00001f)
additive.second.AddToSegStatementSet(list, *xcc_layoutData.GetObj(), stSet); additive.second.AddToSegStatementSet(list, *xcc_layoutData.GetObj(), stSet);
} }
@ -85,7 +87,7 @@ void CAnimData::AdvanceAdditiveAnims(float dt)
{ {
CCharAnimTime time(dt); CCharAnimTime time(dt);
for (std::pair<u32, CAdditiveAnimPlayback>& additive : x1044_additiveAnims) for (std::pair<u32, CAdditiveAnimPlayback>& additive : x1048_additiveAnims)
{ {
if (additive.second.GetA()) if (additive.second.GetA())
{ {
@ -203,8 +205,23 @@ std::shared_ptr<CAnimationManager> CAnimData::GetAnimationManager() const
return {}; return {};
} }
void CAnimData::RecalcPoseBuilder(const CCharAnimTime*) const void CAnimData::RecalcPoseBuilder(const CCharAnimTime* time)
{ {
const CSegIdList& segIdList = GetCharLayoutInfo().GetSegIdList();
CSegStatementSet segSet;
if (time)
x1f8_animRoot->VGetSegStatementSet(segIdList, segSet, *time);
else
x1f8_animRoot->VGetSegStatementSet(segIdList, segSet);
AddAdditiveSegData(segIdList, segSet);
for (const CSegId& id : segIdList.GetList())
{
if (id == 3)
continue;
CAnimPerSegmentData& segData = segSet[id];
x2fc_poseBuilder.Insert(id, segData.x0_rotation, segData.x10_offset);
}
} }
void CAnimData::RenderAuxiliary(const CFrustumPlanes& frustum) const void CAnimData::RenderAuxiliary(const CFrustumPlanes& frustum) const
@ -225,6 +242,12 @@ void CAnimData::SetupRender(const CSkinnedModel& model,
void CAnimData::PreRender() void CAnimData::PreRender()
{ {
if (!x220_31_poseCached)
{
RecalcPoseBuilder(nullptr);
x220_31_poseCached = true;
x220_30_ = false;
}
} }
void CAnimData::BuildPose() void CAnimData::BuildPose()

View File

@ -61,7 +61,7 @@ class CAnimData
ResId x1d8_selfId; ResId x1d8_selfId;
zeus::CVector3f x1dc_; zeus::CVector3f x1dc_;
zeus::CQuaternion x1e8_; zeus::CQuaternion x1e8_;
std::shared_ptr<IMetaAnim> x1f8_animRoot; std::shared_ptr<CAnimTreeNode> x1f8_animRoot;
std::shared_ptr<CTransitionManager> x1fc_transMgr; std::shared_ptr<CTransitionManager> x1fc_transMgr;
float x200_ = 1.f; float x200_ = 1.f;
@ -74,34 +74,34 @@ class CAnimData
union union
{ {
u32 x21c_flags = 0; u32 x220_flags = 0;
struct struct
{ {
bool x21c_24_animating : 1; bool x220_24_animating : 1;
bool x21c_25_loop : 1; bool x220_25_loop : 1;
bool x21c_26_ : 1; bool x220_26_ : 1;
bool x21c_27_ : 1; bool x220_27_ : 1;
bool x21c_28_ : 1; bool x220_28_ : 1;
bool x21c_29_ : 1; bool x220_29_ : 1;
bool x21c_30_ : 1; bool x220_30_ : 1;
bool x21c_31_ : 1; bool x220_31_poseCached : 1;
}; };
}; };
CPoseAsTransforms x220_pose; CPoseAsTransforms x224_pose;
CHierarchyPoseBuilder x2f8_poseBuilder; CHierarchyPoseBuilder x2fc_poseBuilder;
u32 x101c_ = -1;
u32 x1020_ = -1; u32 x1020_ = -1;
float x1024_ = 1.f; u32 x10204_ = -1;
bool x1028_ = true; float x1028_ = 1.f;
u32 x102c_ = 0; bool x102c_ = true;
u32 x1030_ = 0; u32 x1030_ = 0;
bool x1034_ = false; u32 x1034_ = 0;
u32 x1038_ = 0; bool x1038_ = false;
u32 x103c_ = 0; u32 x103c_ = 0;
u32 x1040_ = 0; u32 x1040_ = 0;
rstl::reserved_vector<std::pair<u32, CAdditiveAnimPlayback>, 8> x1044_additiveAnims; u32 x1044_ = 0;
rstl::reserved_vector<std::pair<u32, CAdditiveAnimPlayback>, 8> x1048_additiveAnims;
static rstl::reserved_vector<CBoolPOINode, 8> g_BoolPOINodes; static rstl::reserved_vector<CBoolPOINode, 8> g_BoolPOINodes;
static rstl::reserved_vector<CInt32POINode, 16> g_Int32POINodes; static rstl::reserved_vector<CInt32POINode, 16> g_Int32POINodes;
@ -130,6 +130,7 @@ public:
void DelAdditiveAnimation(u32); void DelAdditiveAnimation(u32);
void AddAdditiveAnimation(u32, float, bool, bool); void AddAdditiveAnimation(u32, float, bool, bool);
std::shared_ptr<CAnimationManager> GetAnimationManager(); std::shared_ptr<CAnimationManager> GetAnimationManager();
const CCharLayoutInfo& GetCharLayoutInfo() const { return *xcc_layoutData.GetObj(); }
void SetPhase(float); void SetPhase(float);
void Touch(const CSkinnedModel& model, int shaderIdx) const; void Touch(const CSkinnedModel& model, int shaderIdx) const;
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const; SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
@ -144,12 +145,12 @@ public:
bool IsAnimTimeRemaining(float, const std::string& name) const; bool IsAnimTimeRemaining(float, const std::string& name) const;
float GetAnimTimeRemaining(const std::string& name) const; float GetAnimTimeRemaining(const std::string& name) const;
float GetAnimationDuration(int) const; float GetAnimationDuration(int) const;
bool GetIsLoop() const {return x21c_25_loop;} bool GetIsLoop() const {return x220_25_loop;}
void EnableLooping(bool val) {x21c_25_loop = val; x21c_24_animating = true;} void EnableLooping(bool val) {x220_25_loop = val; x220_24_animating = true;}
bool IsAnimating() const {return x21c_24_animating;} bool IsAnimating() const {return x220_24_animating;}
std::shared_ptr<CAnimSysContext> GetAnimSysContext() const; std::shared_ptr<CAnimSysContext> GetAnimSysContext() const;
std::shared_ptr<CAnimationManager> GetAnimationManager() const; std::shared_ptr<CAnimationManager> GetAnimationManager() const;
void RecalcPoseBuilder(const CCharAnimTime*) const; void RecalcPoseBuilder(const CCharAnimTime*);
void RenderAuxiliary(const CFrustumPlanes& frustum) const; void RenderAuxiliary(const CFrustumPlanes& frustum) const;
void Render(const CSkinnedModel& model, const CModelFlags& drawFlags, void Render(const CSkinnedModel& model, const CModelFlags& drawFlags,
const std::experimental::optional<CVertexMorphEffect>& morphEffect, const std::experimental::optional<CVertexMorphEffect>& morphEffect,

View File

@ -135,6 +135,16 @@ void CHierarchyPoseBuilder::BuildNoScale(CPoseAsTransforms& pose)
RecursivelyBuildNoScale(xcec_rootId, node, pose, quat, mtx, vec); RecursivelyBuildNoScale(xcec_rootId, node, pose, quat, mtx, vec);
} }
void CHierarchyPoseBuilder::Insert(const CSegId& boneId, const zeus::CQuaternion& quat)
{
x0_treeMap[boneId] = CTreeNode(quat);
}
void CHierarchyPoseBuilder::Insert(const CSegId& boneId, const zeus::CQuaternion& quat, const zeus::CVector3f& offset)
{
x0_treeMap[boneId] = CTreeNode(quat, offset);
}
CHierarchyPoseBuilder::CHierarchyPoseBuilder(const CLayoutDescription& layout) CHierarchyPoseBuilder::CHierarchyPoseBuilder(const CLayoutDescription& layout)
: xcf4_layoutDesc(layout) : xcf4_layoutDesc(layout)
{ {

View File

@ -22,6 +22,9 @@ class CHierarchyPoseBuilder
zeus::CVector3f x14_offset; zeus::CVector3f x14_offset;
CTreeNode() = default; CTreeNode() = default;
CTreeNode(const zeus::CVector3f& offset) : x14_offset(offset) {} CTreeNode(const zeus::CVector3f& offset) : x14_offset(offset) {}
CTreeNode(const zeus::CQuaternion& quat) : x4_rotation(quat) {}
CTreeNode(const zeus::CQuaternion& quat, const zeus::CVector3f& offset)
: x4_rotation(quat), x14_offset(offset) {}
}; };
TSegIdMap<CTreeNode> x0_treeMap; TSegIdMap<CTreeNode> x0_treeMap;
@ -42,6 +45,8 @@ public:
void BuildTransform(const CSegId& boneId, zeus::CTransform& xfOut) const; void BuildTransform(const CSegId& boneId, zeus::CTransform& xfOut) const;
void BuildNoScale(CPoseAsTransforms& pose); void BuildNoScale(CPoseAsTransforms& pose);
void Insert(const CSegId& boneId, const zeus::CQuaternion& quat);
void Insert(const CSegId& boneId, const zeus::CQuaternion& quat, const zeus::CVector3f& offset);
}; };
} }

View File

@ -45,7 +45,7 @@ SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a,
} }
void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& xf, void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const const CActorLights* lights, const CModelFlags& drawFlags)
{ {
Render(GetRenderingModel(stateMgr), xf, lights, drawFlags); Render(GetRenderingModel(stateMgr), xf, lights, drawFlags);
} }
@ -63,9 +63,9 @@ CModelData::EWhichModel CModelData::GetRenderingModel(const CStateManager& state
} }
} }
const CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const
{ {
const CSkinnedModel* ret = nullptr; CSkinnedModel* ret = nullptr;
switch (which) switch (which)
{ {
case EWhichModel::XRay: case EWhichModel::XRay:
@ -79,9 +79,9 @@ const CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const
return *x10_animData->xd8_modelData.GetObj(); return *x10_animData->xd8_modelData.GetObj();
} }
const TLockedToken<CModel>& CModelData::PickStaticModel(EWhichModel which) const TLockedToken<CModel>& CModelData::PickStaticModel(EWhichModel which)
{ {
const TLockedToken<CModel>* ret = nullptr; TLockedToken<CModel>* ret = nullptr;
switch (which) switch (which)
{ {
case EWhichModel::XRay: case EWhichModel::XRay:
@ -135,16 +135,16 @@ void CModelData::SetInfraModel(const std::pair<ResId, ResId>& modelSkin)
} }
} }
bool CModelData::IsDefinitelyOpaque(EWhichModel which) const bool CModelData::IsDefinitelyOpaque(EWhichModel which)
{ {
if (x10_animData) if (x10_animData)
{ {
const CSkinnedModel& model = PickAnimatedModel(which); CSkinnedModel& model = PickAnimatedModel(which);
return model.GetModel()->GetInstance().IsOpaque(); return model.GetModel()->GetInstance().IsOpaque();
} }
else else
{ {
const TLockedToken<CModel>& model = PickStaticModel(which); TLockedToken<CModel>& model = PickStaticModel(which);
return model->GetInstance().IsOpaque(); return model->GetInstance().IsOpaque();
} }
} }
@ -269,7 +269,7 @@ void CModelData::RenderParticles(const CFrustumPlanes& frustum) const
x10_animData->RenderAuxiliary(frustum); x10_animData->RenderAuxiliary(frustum);
} }
void CModelData::Touch(EWhichModel which, int shaderIdx) const void CModelData::Touch(EWhichModel which, int shaderIdx)
{ {
if (x10_animData) if (x10_animData)
x10_animData->Touch(PickAnimatedModel(which), shaderIdx); x10_animData->Touch(PickAnimatedModel(which), shaderIdx);
@ -277,13 +277,13 @@ void CModelData::Touch(EWhichModel which, int shaderIdx) const
PickStaticModel(which)->Touch(shaderIdx); PickStaticModel(which)->Touch(shaderIdx);
} }
void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) const void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx)
{ {
Touch(GetRenderingModel(stateMgr), shaderIdx); Touch(GetRenderingModel(stateMgr), shaderIdx);
} }
void CModelData::RenderThermal(const zeus::CTransform& xf, void CModelData::RenderThermal(const zeus::CTransform& xf,
const zeus::CColor& a, const zeus::CColor& b) const const zeus::CColor& a, const zeus::CColor& b)
{ {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale)); CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale));
CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
@ -304,7 +304,7 @@ void CModelData::RenderThermal(const zeus::CTransform& xf,
} }
void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& xf, void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const const CActorLights* lights, const CModelFlags& drawFlags)
{ {
if ((x14_25_sortThermal && which == EWhichModel::Thermal) || if ((x14_25_sortThermal && which == EWhichModel::Thermal) ||
x10_animData || !x1c_normalModel || drawFlags.m_blendMode > 2) x10_animData || !x1c_normalModel || drawFlags.m_blendMode > 2)
@ -314,23 +314,22 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform&
} }
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale)); CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale));
if (lights)
lights->ActivateLights();
else
{
CGraphics::DisableAllLights();
// Also set ambient to x18_ambientColor
}
PickStaticModel(which)->DrawUnsortedParts(drawFlags); TLockedToken<CModel>& model = PickStaticModel(which);
if (lights)
lights->ActivateLights(model->GetInstance());
else
model->GetInstance().ActivateLights({});
model->DrawUnsortedParts(drawFlags);
// Set ambient to white // Set ambient to white
CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
((CModelData*)this)->x14_24_renderSorted = true; ((CModelData*)this)->x14_24_renderSorted = true;
} }
void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, void CModelData::Render(EWhichModel which, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const const CActorLights* lights, const CModelFlags& drawFlags)
{ {
if (x14_25_sortThermal && which == EWhichModel::Thermal) if (x14_25_sortThermal && which == EWhichModel::Thermal)
{ {
zeus::CColor mul(drawFlags.color.a, drawFlags.color.a, drawFlags.color.a, drawFlags.color.a); zeus::CColor mul(drawFlags.color.a, drawFlags.color.a, drawFlags.color.a, drawFlags.color.a);
@ -339,21 +338,25 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf,
else else
{ {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale)); CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_particleScale));
if (lights)
lights->ActivateLights();
else
{
CGraphics::DisableAllLights();
// Also set ambient to x18_ambientColor
}
if (x10_animData) if (x10_animData)
{ {
x10_animData->Render(PickAnimatedModel(which), drawFlags, {}, nullptr); CSkinnedModel& model = PickAnimatedModel(which);
if (lights)
lights->ActivateLights(model.GetModel()->GetInstance());
else
model.GetModel()->GetInstance().ActivateLights({});
x10_animData->Render(model, drawFlags, {}, nullptr);
} }
else else
{ {
const TLockedToken<CModel>& model = PickStaticModel(which); TLockedToken<CModel>& model = PickStaticModel(which);
if (lights)
lights->ActivateLights(model->GetInstance());
else
model->GetInstance().ActivateLights({});
if (x14_24_renderSorted) if (x14_24_renderSorted)
model->DrawSortedParts(drawFlags); model->DrawSortedParts(drawFlags);
else else

View File

@ -101,13 +101,13 @@ public:
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const; SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, void Render(const CStateManager& stateMgr, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const; const CActorLights* lights, const CModelFlags& drawFlags);
EWhichModel GetRenderingModel(const CStateManager& stateMgr) const; EWhichModel GetRenderingModel(const CStateManager& stateMgr) const;
const CSkinnedModel& PickAnimatedModel(EWhichModel which) const; CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
const TLockedToken<CModel>& PickStaticModel(EWhichModel which) const; TLockedToken<CModel>& PickStaticModel(EWhichModel which);
void SetXRayModel(const std::pair<ResId, ResId>& modelSkin); void SetXRayModel(const std::pair<ResId, ResId>& modelSkin);
void SetInfraModel(const std::pair<ResId, ResId>& modelSkin); void SetInfraModel(const std::pair<ResId, ResId>& modelSkin);
bool IsDefinitelyOpaque(EWhichModel) const; bool IsDefinitelyOpaque(EWhichModel);
bool GetIsLoop() const; bool GetIsLoop() const;
float GetAnimationDuration(int) const; float GetAnimationDuration(int) const;
void EnableLooping(bool); void EnableLooping(bool);
@ -123,13 +123,13 @@ public:
bool IsAnimating() const; bool IsAnimating() const;
bool IsInFrustum(const zeus::CTransform& xf, const CFrustumPlanes& frustum) const; bool IsInFrustum(const zeus::CTransform& xf, const CFrustumPlanes& frustum) const;
void RenderParticles(const CFrustumPlanes& frustum) const; void RenderParticles(const CFrustumPlanes& frustum) const;
void Touch(EWhichModel, int shaderIdx) const; void Touch(EWhichModel, int shaderIdx);
void Touch(const CStateManager& stateMgr, int shaderIdx) const; void Touch(const CStateManager& stateMgr, int shaderIdx);
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& a, const zeus::CColor& b) const; void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& a, const zeus::CColor& b);
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const; const CActorLights* lights, const CModelFlags& drawFlags);
void Render(EWhichModel, const zeus::CTransform& xf, void Render(EWhichModel, const zeus::CTransform& xf,
const CActorLights* lights, const CModelFlags& drawFlags) const; const CActorLights* lights, const CModelFlags& drawFlags);
CAnimData* AnimationData() { return x10_animData.get(); } CAnimData* AnimationData() { return x10_animData.get(); }
bool IsNull() { return !x10_animData && !x1c_normalModel; } bool IsNull() { return !x10_animData && !x1c_normalModel; }

View File

@ -16,6 +16,8 @@ public:
CAnimPerSegmentData x4_segData[100]; CAnimPerSegmentData x4_segData[100];
void Add(const CSegIdList& list, const CCharLayoutInfo& layout, void Add(const CSegIdList& list, const CCharLayoutInfo& layout,
const CSegStatementSet& other, float weight); const CSegStatementSet& other, float weight);
CAnimPerSegmentData& operator[](size_t idx) { return x4_segData[idx]; }
}; };
} }

View File

@ -108,6 +108,7 @@ public:
} }
float GetIntensity() const; float GetIntensity() const;
const zeus::CColor& GetColor() const { return x18_color; }
static CLight BuildDirectional(const zeus::CVector3f& dir, const zeus::CColor& color); static CLight BuildDirectional(const zeus::CVector3f& dir, const zeus::CColor& color);
static CLight BuildSpot(const zeus::CVector3f& pos, const zeus::CVector3f& dir, static CLight BuildSpot(const zeus::CVector3f& pos, const zeus::CVector3f& dir,

View File

@ -32,9 +32,9 @@ public:
CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules,
ResId layoutInfo, EDataOwnership ownership); ResId layoutInfo, EDataOwnership ownership);
const TLockedToken<CModel>& GetModel() const {return x4_model;} TLockedToken<CModel>& GetModel() {return x4_model;}
const TLockedToken<CSkinRules>& GetSkinRules() const {return x10_skinRules;} TLockedToken<CSkinRules>& GetSkinRules() {return x10_skinRules;}
const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const {return x1c_layoutInfo;} TLockedToken<CCharLayoutInfo>& GetLayoutInfo() {return x1c_layoutInfo;}
void Calculate(const CPoseAsTransforms& pose, const std::experimental::optional<CVertexMorphEffect>&); void Calculate(const CPoseAsTransforms& pose, const std::experimental::optional<CVertexMorphEffect>&);
void Draw(const CModelFlags& drawFlags) const {} void Draw(const CModelFlags& drawFlags) const {}

View File

@ -44,7 +44,7 @@ void CCameraBlurFilter::draw(float amount)
tmp /= 6.f; tmp /= 6.f;
float amtX = std::cos(tmp); float amtX = std::cos(tmp);
amtX *= amount / 448.f * aspect; amtX *= amount / 448.f / aspect;
float amtY = std::sin(tmp); float amtY = std::sin(tmp);
amtY *= amount / 448.f; amtY *= amount / 448.f;

View File

@ -0,0 +1,124 @@
#include "CCameraBlurFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{
static const char* VS =
"struct VertData\n"
"{\n"
" float4 posIn : POSITION;\n"
" float4 uvIn : UV;\n"
"};\n"
"\n"
"cbuffer CameraBlurUniform : register(b0)\n"
"{\n"
" float4 uv0;\n"
" float4 uv1;\n"
" float4 uv2;\n"
" float4 uv3;\n"
" float4 uv4;\n"
" float4 uv5;\n"
" float opacity;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float2 uvReg : UV6;\n"
" float2 uv0 : UV0;\n"
" float2 uv1 : UV1;\n"
" float2 uv2 : UV2;\n"
" float2 uv3 : UV3;\n"
" float2 uv4 : UV4;\n"
" float2 uv5 : UV5;\n"
" float opacity : OPACITY;\n"
"};\n"
"\n"
"VertToFrag main(in VertData v)\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.uvReg = v.uvIn.xy;\n"
" vtf.uvReg.y = -vtf.uvReg.y;\n"
" vtf.uv0 = uv0.xy + v.uvIn.xy;\n"
" vtf.uv0.y = -vtf.uv0.y;\n"
" vtf.uv1 = uv1.xy + v.uvIn.xy;\n"
" vtf.uv1.y = -vtf.uv1.y;\n"
" vtf.uv2 = uv2.xy + v.uvIn.xy;\n"
" vtf.uv2.y = -vtf.uv2.y;\n"
" vtf.uv3 = uv3.xy + v.uvIn.xy;\n"
" vtf.uv3.y = -vtf.uv3.y;\n"
" vtf.uv4 = uv4.xy + v.uvIn.xy;\n"
" vtf.uv4.y = -vtf.uv4.y;\n"
" vtf.uv5 = uv5.xy + v.uvIn.xy;\n"
" vtf.uv5.y = -vtf.uv5.y;\n"
" vtf.opacity = opacity;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";
static const char* FS =
"Texture2D sceneTex : register(t0);\n"
"SamplerState samp : register(s0);\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float2 uvReg : UV6;\n"
" float2 uv0 : UV0;\n"
" float2 uv1 : UV1;\n"
" float2 uv2 : UV2;\n"
" float2 uv3 : UV3;\n"
" float2 uv4 : UV4;\n"
" float2 uv5 : UV5;\n"
" float opacity : OPACITY;\n"
"};\n"
"\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" float4 colorSample = sceneTex.Sample(samp, vtf.uvReg) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv0) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv1) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv2) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv3) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv4) * 0.14285715;\n"
" colorSample += sceneTex.Sample(samp, vtf.uv5) * 0.14285715;\n"
" return float4(colorSample.rgb, vtf.opacity);\n"
"}\n";
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
struct CCameraBlurFilterD3DDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraBlurFilter& filter)
{
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::ID3DDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(),
vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
return new CCameraBlurFilterD3DDataBindingFactory;
}
}

View File

@ -6,7 +6,7 @@ namespace urde
{ {
CPlayerGun::CPlayerGun(TUniqueId id) CPlayerGun::CPlayerGun(TUniqueId id)
: x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0), x538_thisId(id), : x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0, 0, 0, 0.1f), x538_thisId(id),
x550_camBob(CPlayerCameraBob::ECameraBobType::One, x550_camBob(CPlayerCameraBob::ECameraBobType::One,
zeus::CVector2f(0.071f, 0.141f), 0.47f), zeus::CVector2f(0.071f, 0.141f), 0.47f),
x678_morph(g_tweakPlayerGun->GetSomething6(), g_tweakPlayerGun->GetSomething5()) x678_morph(g_tweakPlayerGun->GetSomething6(), g_tweakPlayerGun->GetSomething5())

View File

@ -11,6 +11,7 @@
#include "Graphics/CModel.hpp" #include "Graphics/CModel.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Graphics/CBooRenderer.hpp"
#include "Camera/CCameraManager.hpp" #include "Camera/CCameraManager.hpp"
#include "Character/CActorLights.hpp"
namespace urde namespace urde
{ {
@ -150,6 +151,39 @@ void CWorldTransManager::Update(float dt)
void CWorldTransManager::DrawAllModels() void CWorldTransManager::DrawAllModels()
{ {
CActorLights lights(0, zeus::CVector3f::skZero, 4, 4, 0, 0, 0, 0.1f);
lights.BuildFakeLightList(x4_modelData->x1a0_lights, zeus::CColor{0.1f, 0.1f, 0.1f, 1.0f});
CModelFlags flags = {};
flags.m_extendedShaderIdx = 1;
if (!x4_modelData->x100_bgModelData.IsNull())
{
zeus::CTransform xf0 = zeus::CTransform::Translate(0.f, 0.f, -(2.f * x1c_bgHeight - x18_bgOffset));
x4_modelData->x100_bgModelData.Render(CModelData::EWhichModel::Normal, xf0, &lights, flags);
zeus::CTransform xf1 = zeus::CTransform::Translate(0.f, 0.f, x18_bgOffset - x1c_bgHeight);
x4_modelData->x100_bgModelData.Render(CModelData::EWhichModel::Normal, xf1, &lights, flags);
zeus::CTransform xf2 = zeus::CTransform::Translate(0.f, 0.f, x18_bgOffset);
x4_modelData->x100_bgModelData.Render(CModelData::EWhichModel::Normal, xf2, &lights, flags);
}
if (!x4_modelData->xb4_platformModelData.IsNull())
{
x4_modelData->xb4_platformModelData.Render(CModelData::EWhichModel::Normal, zeus::CTransform::Identity(), &lights, flags);
}
if (!x4_modelData->x1c_samusModelData.IsNull())
{
x4_modelData->x1c_samusModelData.AnimationData()->PreRender();
x4_modelData->x1c_samusModelData.Render(CModelData::EWhichModel::Normal, zeus::CTransform::Identity(), &lights, flags);
if (!x4_modelData->x68_beamModelData.IsNull())
{
x4_modelData->x68_beamModelData.Render(CModelData::EWhichModel::Normal, x4_modelData->x170_gunXf, &lights, flags);
}
}
} }
void CWorldTransManager::DrawFirstPass() void CWorldTransManager::DrawFirstPass()
@ -167,6 +201,16 @@ void CWorldTransManager::DrawFirstPass()
void CWorldTransManager::DrawSecondPass() void CWorldTransManager::DrawSecondPass()
{ {
const zeus::CVector3f& samusScale = x4_modelData->x0_samusRes.GetScale();
zeus::CTransform translateXf =
zeus::CTransform::Translate(-0.1f * samusScale.x,
-0.5f * samusScale.y,
1.5f * samusScale.z);
zeus::CTransform rotateXf =
zeus::CTransform::RotateZ(zeus::degToRad(48.f *
zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime + 2.f) / 5.f, 1.f) + 180.f - 24.f));
CGraphics::SetViewPointMatrix(rotateXf * translateXf);
DrawAllModels();
} }
void CWorldTransManager::DrawEnabled() void CWorldTransManager::DrawEnabled()