mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/AxioDL/urde
This commit is contained in:
commit
18f1807778
|
@ -43,11 +43,8 @@ public:
|
|||
|
||||
inline s32 Range(s32 min, s32 max)
|
||||
{
|
||||
s32 diff = max - min;
|
||||
s32 rand = -1;
|
||||
while (rand < 0)
|
||||
rand = s32((Next() << 16) | Next());
|
||||
return rand % diff + min;
|
||||
const s32 rand = Next();
|
||||
return min + (rand / ((min - max) + 1)) - rand;
|
||||
}
|
||||
|
||||
static CRandom16* GetRandomNumber() {return g_randomNumber;}
|
||||
|
|
|
@ -46,7 +46,7 @@ CCharacterFactoryBuilder::CCharacterFactoryBuilder() : x4_dummyStore(x0_dummyFac
|
|||
|
||||
TToken<CCharacterFactory> CCharacterFactoryBuilder::GetFactory(const CAnimRes& res)
|
||||
{
|
||||
return x4_dummyStore.GetObj({SBIG('ANCS'), res.x0_ancsId});
|
||||
return x4_dummyStore.GetObj({SBIG('ANCS'), res.GetId()});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ set(CHARACTER_SOURCES
|
|||
CPASParmInfo.hpp CPASParmInfo.cpp
|
||||
CPASAnimInfo.hpp CPASAnimInfo.cpp
|
||||
CPASAnimParm.hpp CPASAnimParm.cpp
|
||||
CPASAnimParmData.hpp CPASAnimParmData.cpp
|
||||
CEffectComponent.hpp CEffectComponent.cpp
|
||||
CAnimation.hpp CAnimation.cpp
|
||||
CAnimationManager.hpp CAnimationManager.cpp
|
||||
|
|
|
@ -23,16 +23,16 @@ CModelData::CModelData() {}
|
|||
CModelData CModelData::CModelDataNull() {return CModelData();}
|
||||
|
||||
CModelData::CModelData(const CStaticRes& res)
|
||||
: x0_particleScale(res.x4_scale)
|
||||
: x0_particleScale(res.GetScale())
|
||||
{
|
||||
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.x0_cmdlId});
|
||||
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
|
||||
}
|
||||
|
||||
CModelData::CModelData(const CAnimRes& res)
|
||||
: x0_particleScale(res.x8_scale)
|
||||
: x0_particleScale(res.GetScale())
|
||||
{
|
||||
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
|
||||
xc_animData = factory->CreateCharacter(res.x4_charIdx, res.x14_, factory, res.x18_defaultAnim);
|
||||
xc_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim());
|
||||
}
|
||||
|
||||
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a,
|
||||
|
|
|
@ -21,19 +21,44 @@ class CModel;
|
|||
class CSkinnedModel;
|
||||
struct SAdvancementDeltas;
|
||||
|
||||
struct CStaticRes
|
||||
class CStaticRes
|
||||
{
|
||||
ResId x0_cmdlId = 0;
|
||||
zeus::CVector3f x4_scale;
|
||||
public:
|
||||
CStaticRes(ResId id, const zeus::CVector3f& scale)
|
||||
: x0_cmdlId(id),
|
||||
x4_scale(scale)
|
||||
{}
|
||||
|
||||
ResId GetId() const { return x0_cmdlId; }
|
||||
const zeus::CVector3f& GetScale() const { return x4_scale; }
|
||||
};
|
||||
|
||||
struct CAnimRes
|
||||
class CAnimRes
|
||||
{
|
||||
ResId x0_ancsId = 0;
|
||||
s32 x4_charIdx = 0;
|
||||
ResId x0_ancsId = -1;
|
||||
s32 x4_charIdx = -1;
|
||||
zeus::CVector3f x8_scale;
|
||||
bool x14_ = false;
|
||||
s32 x18_defaultAnim = 0;
|
||||
bool x14_canLoop = false;
|
||||
/* NOTE: x18_bodyType - Removed in retail */
|
||||
s32 x18_defaultAnim = -1; /* NOTE: used to be x1c in demo */
|
||||
public:
|
||||
CAnimRes() = default;
|
||||
CAnimRes(ResId ancs, s32 charIdx, const zeus::CVector3f& scale, const s32 defaultAnim, bool loop)
|
||||
: x0_ancsId(ancs),
|
||||
x4_charIdx(charIdx),
|
||||
x8_scale(scale),
|
||||
x14_canLoop(loop),
|
||||
x18_defaultAnim(defaultAnim)
|
||||
{
|
||||
}
|
||||
|
||||
ResId GetId() const { return x0_ancsId; }
|
||||
s32 GetCharacterNodeId() const { return x4_charIdx; }
|
||||
const zeus::CVector3f& GetScale() const { return x8_scale; }
|
||||
bool CanLoop() const { return x14_canLoop; }
|
||||
s32 GetDefaultAnim() const { return x18_defaultAnim; }
|
||||
};
|
||||
|
||||
class CModelData
|
||||
|
|
|
@ -6,4 +6,35 @@ namespace urde
|
|||
CPASAnimInfo::CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms)
|
||||
: x0_id(id), x4_parms(std::move(parms)) {}
|
||||
|
||||
CPASAnimParm::UParmValue CPASAnimInfo::GetAnimParmValue(u32 idx) const
|
||||
{
|
||||
if (idx >= x4_parms.size())
|
||||
return CPASAnimParm::UParmValue{};
|
||||
return x4_parms.at(idx);
|
||||
}
|
||||
|
||||
CPASAnimParm CPASAnimInfo::GetAnimParmData(u32 idx, CPASAnimParm::EParmType type) const
|
||||
{
|
||||
if (idx >= x4_parms.size())
|
||||
return CPASAnimParm::NoParameter();
|
||||
const CPASAnimParm::UParmValue& parm = x4_parms.at(idx);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case CPASAnimParm::EParmType::Int32:
|
||||
return CPASAnimParm::FromInt32(parm.m_int);
|
||||
case CPASAnimParm::EParmType::UInt32:
|
||||
return CPASAnimParm::FromUint32(parm.m_uint);
|
||||
case CPASAnimParm::EParmType::Float:
|
||||
return CPASAnimParm::FromReal32(parm.m_float);
|
||||
case CPASAnimParm::EParmType::Bool:
|
||||
return CPASAnimParm::FromBool(parm.m_bool);
|
||||
case CPASAnimParm::EParmType::Enum:
|
||||
return CPASAnimParm::FromEnum(parm.m_int);
|
||||
default:
|
||||
return CPASAnimParm::NoParameter();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@ class CPASAnimInfo
|
|||
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> x4_parms;
|
||||
public:
|
||||
CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms);
|
||||
u32 GetId() const {return x0_id;}
|
||||
u32 GetAnimId() const {return x0_id;}
|
||||
CPASAnimParm::UParmValue GetAnimParmValue(u32 idx) const;
|
||||
CPASAnimParm GetAnimParmData(u32, CPASAnimParm::EParmType) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include "CPASAnimParmData.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CPASAnimParmData::CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1, const CPASAnimParm& parm2, const CPASAnimParm& parm3,
|
||||
const CPASAnimParm& parm4, const CPASAnimParm& parm5, const CPASAnimParm& parm6,
|
||||
const CPASAnimParm& parm7, const CPASAnimParm& parm8)
|
||||
: x0_stateId(stateId)
|
||||
{
|
||||
x4_parms.push_back(parm1);
|
||||
x4_parms.push_back(parm2);
|
||||
x4_parms.push_back(parm3);
|
||||
x4_parms.push_back(parm4);
|
||||
x4_parms.push_back(parm5);
|
||||
x4_parms.push_back(parm6);
|
||||
x4_parms.push_back(parm7);
|
||||
x4_parms.push_back(parm8);
|
||||
}
|
||||
|
||||
s32 CPASAnimParmData::GetStateId()
|
||||
{
|
||||
return x0_stateId;
|
||||
}
|
||||
|
||||
const std::vector<CPASAnimParm>& CPASAnimParmData::GetAnimParmData() const
|
||||
{
|
||||
return x4_parms;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CPASANIMPARMDATA_HPP
|
||||
#define CPASANIMPARMDATA_HPP
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CPASAnimParm.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CPASAnimParmData
|
||||
{
|
||||
s32 x0_stateId;
|
||||
rstl::reserved_vector<CPASAnimParm,8> x4_parms;
|
||||
public:
|
||||
CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1, const CPASAnimParm& parm2, const CPASAnimParm& parm3,
|
||||
const CPASAnimParm& parm4, const CPASAnimParm& parm5, const CPASAnimParm& parm6, const CPASAnimParm& parm7,
|
||||
const CPASAnimParm& parm8);
|
||||
|
||||
s32 GetStateId();
|
||||
const std::vector<CPASAnimParm>& GetAnimParmData() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CPASANIMPARMDATA_HPP
|
|
@ -18,7 +18,7 @@ CPASAnimState::CPASAnimState(CInputStream& in)
|
|||
|
||||
for (u32 i=0 ; i<animCount ; ++i)
|
||||
{
|
||||
u32 id = in.readUint32Big();
|
||||
s32 id = in.readUint32Big();
|
||||
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> parms;
|
||||
for (const CPASParmInfo& parm : x4_parms)
|
||||
{
|
||||
|
@ -46,9 +46,12 @@ CPASAnimState::CPASAnimState(CInputStream& in)
|
|||
}
|
||||
|
||||
auto search = std::lower_bound(x14_anims.begin(), x14_anims.end(), id,
|
||||
[](const CPASAnimInfo& item, const u32& testId) -> bool {return item.GetId() < testId;});
|
||||
[](const CPASAnimInfo& item, const u32& testId) -> bool {return item.GetAnimId() < testId;});
|
||||
x14_anims.emplace(search, id, std::move(parms));
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vector<CPASAnimParm, 8>&, CRandom16&, s32) const
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,23 @@
|
|||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CRandom16;
|
||||
class CPASAnimParmData;
|
||||
class CPASAnimState
|
||||
{
|
||||
u32 x0_id;
|
||||
s32 x0_id;
|
||||
std::vector<CPASParmInfo> x4_parms;
|
||||
std::vector<CPASAnimInfo> x14_anims;
|
||||
std::vector<u32> x24_;
|
||||
public:
|
||||
CPASAnimState(CInputStream& in);
|
||||
u32 GetId() const {return x0_id;}
|
||||
s32 GetStateId() const {return x0_id;}
|
||||
s32 GetNumAnims() const { return x14_anims.size(); }
|
||||
const CPASAnimParmData& GetAnimParmData(s32, u32) const;
|
||||
std::pair<float,s32> FindBestAnimation(const rstl::reserved_vector<CPASAnimParm,8>&, CRandom16&, s32) const;
|
||||
float ComputeExactMatchWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
|
||||
float ComputePercentErrorWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
|
||||
float ComputeAngularPercentErrorWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace urde
|
|||
void CPASDatabase::AddAnimState(CPASAnimState&& state)
|
||||
{
|
||||
auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state,
|
||||
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetId() < test.GetId();});
|
||||
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetStateId() < test.GetStateId();});
|
||||
x0_states.insert(it, std::move(state));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,44 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
class CRandom16;
|
||||
class CPASAnimParmData;
|
||||
class CPASDatabase
|
||||
{
|
||||
std::vector<CPASAnimState> x0_states;
|
||||
u32 x10_defaultState;
|
||||
s32 x10_defaultState;
|
||||
void AddAnimState(CPASAnimState&& state);
|
||||
void SetDefaultState(u32 state) {x10_defaultState = state;}
|
||||
void SetDefaultState(s32 state) {x10_defaultState = state;}
|
||||
public:
|
||||
CPASDatabase(CInputStream& in);
|
||||
|
||||
void FindBestAnimation(const CPASAnimParmData&, int) const;
|
||||
void FindBestAnimation(const CPASAnimParmData&, CRandom16&, int) const;
|
||||
s32 GetDefaultState() const { return x10_defaultState; }
|
||||
s32 GetNumAnimStates() const { return x0_states.size(); }
|
||||
const CPASAnimState* GetAnimState(s32 id) const
|
||||
{
|
||||
for (const CPASAnimState& state : x0_states)
|
||||
if (id == state.GetStateId())
|
||||
return &state;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
const CPASAnimState* GetAnimStateByIndex(s32 index) const
|
||||
{
|
||||
if (index < 0 || index >= x0_states.size())
|
||||
return nullptr;
|
||||
|
||||
return &x0_states.at(index);
|
||||
}
|
||||
|
||||
bool HasState(s32 id) const
|
||||
{
|
||||
for (const CPASAnimState& state : x0_states)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include "CCollidableOBBTree.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CCollidableOBBTree::CCollidableOBBTree(const COBBTree* tree, const urde::CMaterialList& material)
|
||||
: CCollisionPrimitive(material),
|
||||
x10_tree((COBBTree*)tree)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FourCC CCollidableOBBTree::GetPrimType() const
|
||||
{
|
||||
return SBIG('OBBT');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableOBBTree::CastRayInternal(const CInternalRayCastStructure&) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTree::CalculateAABox(const zeus::CTransform& xf) const
|
||||
{
|
||||
return x10_tree->CalculateAABox(xf);
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTree::CalculateLocalAABox() const
|
||||
{
|
||||
return x10_tree->CalculateLocalAABox();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,27 @@
|
|||
#ifndef __URDE_CCOLLIDABLEOBBTREE_HPP__
|
||||
#define __URDE_CCOLLIDABLEOBBTREE_HPP__
|
||||
|
||||
#include "Collision/CCollisionPrimitive.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CCollidableOBBTree
|
||||
class CCollidableOBBTree : public CCollisionPrimitive
|
||||
{
|
||||
COBBTree* x10_tree = nullptr;
|
||||
u32 x14_ = 0;
|
||||
u32 x18_ = 0;
|
||||
u32 x1c_ = 0;
|
||||
public:
|
||||
CCollidableOBBTree(const COBBTree* tree, const CMaterialList& material);
|
||||
virtual ~CCollidableOBBTree() {}
|
||||
void ResetTestStats() const;
|
||||
void ResetTestStatsRecurse(const COBBTree::CNode&) const;
|
||||
u32 GetTableIndex() const { return -1; }
|
||||
zeus::CAABox CalculateAABox(const zeus::CTransform &) const;
|
||||
zeus::CAABox CalculateLocalAABox() const;
|
||||
virtual FourCC GetPrimType() const;
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include "CCollidableOBBTreeGroup.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
#include "CCollidableOBBTree.hpp"
|
||||
#include "CToken.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CCollisionPrimitive::Type CCollidableOBBTreeGroup::sType(CCollidableOBBTreeGroup::SetStaticTableIndex, "CCollidableOBBTreeGroup");
|
||||
u32 CCollidableOBBTreeGroup::sTableIndex = -1;
|
||||
|
||||
CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in)
|
||||
{
|
||||
|
@ -11,7 +13,54 @@ CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in)
|
|||
x0_trees.reserve(treeCount);
|
||||
|
||||
for (u32 i = 0 ; i < treeCount ; i++)
|
||||
x0_trees.push_back(in);
|
||||
{
|
||||
std::unique_ptr<COBBTree> tree(new COBBTree(in));
|
||||
x0_trees.push_back(std::move(tree));
|
||||
}
|
||||
|
||||
x10_aabbs.reserve(x0_trees.size());
|
||||
|
||||
for (const std::unique_ptr<COBBTree>& tree : x0_trees)
|
||||
x10_aabbs.push_back(CCollidableOBBTree(tree.get(), CMaterialList()).CalculateLocalAABox());
|
||||
}
|
||||
|
||||
void CCollidableOBBTreeGroup::ResetTestStats() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u32 CCollidableOBBTreeGroup::GetTableIndex() const
|
||||
{
|
||||
return sTableIndex;
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTreeGroup::CalculateAABox(const zeus::CTransform& xf) const
|
||||
{
|
||||
return x10_aabbs.front().getTransformedAABox(xf);
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTreeGroup::CalculateLocalAABox() const
|
||||
{
|
||||
return x10_aabbs.front();
|
||||
}
|
||||
|
||||
FourCC CCollidableOBBTreeGroup::GetPrimType() const
|
||||
{
|
||||
return SBIG('OBTG');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableOBBTreeGroup::CastRayInternal(const CInternalRayCastStructure&) const
|
||||
{
|
||||
}
|
||||
|
||||
const CCollisionPrimitive::Type& CCollidableOBBTreeGroup::GetType()
|
||||
{
|
||||
return sType;
|
||||
}
|
||||
|
||||
void CCollidableOBBTreeGroup::SetStaticTableIndex(u32 index)
|
||||
{
|
||||
sTableIndex = index;
|
||||
}
|
||||
|
||||
CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag &tag, CInputStream &in,
|
||||
|
|
|
@ -3,14 +3,31 @@
|
|||
|
||||
#include "IOStreams.hpp"
|
||||
#include "CFactoryMgr.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "CCollisionPrimitive.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class COBBTree;
|
||||
class CCollidableOBBTreeGroup
|
||||
class CCollidableOBBTreeGroup : public CCollisionPrimitive
|
||||
{
|
||||
std::vector<COBBTree> x0_trees;
|
||||
static const CCollisionPrimitive::Type sType;
|
||||
static u32 sTableIndex;
|
||||
std::vector<std::unique_ptr<COBBTree>> x0_trees;
|
||||
std::vector<zeus::CAABox> x10_aabbs;
|
||||
public:
|
||||
CCollidableOBBTreeGroup(CInputStream& in);
|
||||
virtual ~CCollidableOBBTreeGroup() {}
|
||||
|
||||
void ResetTestStats() const;
|
||||
virtual u32 GetTableIndex() const;
|
||||
virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const;
|
||||
virtual zeus::CAABox CalculateLocalAABox() const;
|
||||
virtual FourCC GetPrimType() const;
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
|
||||
static const CCollisionPrimitive::Type& GetType();
|
||||
static void SetStaticTableIndex(u32 index);
|
||||
};
|
||||
|
||||
CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag &tag, CInputStream &in,
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "CCollisionPrimitive.hpp"
|
||||
#include "CInternalRayCastStructure.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list)
|
||||
: x8_material(list)
|
||||
{
|
||||
}
|
||||
|
||||
void CCollisionPrimitive::SetMaterial(const CMaterialList& material)
|
||||
{
|
||||
x8_material = material;
|
||||
}
|
||||
|
||||
const CMaterialList&CCollisionPrimitive::GetMaterial() const
|
||||
{
|
||||
return x8_material;
|
||||
|
||||
}
|
||||
|
||||
CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const zeus::CVector3f& end, float d, const
|
||||
CMaterialFilter& filter, const zeus::CTransform& xf) const
|
||||
{
|
||||
return CastRayInternal(CInternalRayCastStructure(start, end, d, xf, filter));
|
||||
}
|
||||
|
||||
}
|
|
@ -2,11 +2,17 @@
|
|||
#define __URDE_CCOLLISIONPRIMITIVE_HPP__
|
||||
|
||||
#include "Collision/CMaterialList.hpp"
|
||||
#include "CRayCastResult.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class COBBTree;
|
||||
class CInternalRayCastStructure;
|
||||
class CMaterialFilter;
|
||||
class CCollisionPrimitive
|
||||
{
|
||||
CMaterialList x8_material;
|
||||
|
@ -34,6 +40,20 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
CCollisionPrimitive()=default;
|
||||
CCollisionPrimitive(const CMaterialList& list);
|
||||
virtual u32 GetTableIndex() const=0;
|
||||
virtual void SetMaterial(const CMaterialList&);
|
||||
virtual const CMaterialList& GetMaterial() const;
|
||||
virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const=0;
|
||||
virtual zeus::CAABox CalculateLocalAABox() const=0;
|
||||
virtual FourCC GetPrimType() const=0;
|
||||
virtual ~CCollisionPrimitive() {}
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const=0;
|
||||
CRayCastResult CastRay(const zeus::CVector3f&, const zeus::CVector3f&, float, const CMaterialFilter&,
|
||||
const zeus::CTransform&) const;
|
||||
|
||||
|
||||
static void InitBeginTypes();
|
||||
static void InitAddType(const Type& tp);
|
||||
static void InitEndTypes();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "CInternalRayCastStructure.hpp"
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
||||
#define __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
||||
|
||||
#include "zeus/CTransform.hpp"
|
||||
#include "zeus/CMRay.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
namespace urde
|
||||
{
|
||||
class CInternalRayCastStructure
|
||||
{
|
||||
zeus::CMRay x0_ray;
|
||||
float x38_maxTime;
|
||||
zeus::CTransform x3c_xf;
|
||||
CMaterialFilter x6c_filter;
|
||||
public:
|
||||
CInternalRayCastStructure(const zeus::CVector3f& start, const zeus::CVector3f& end, float d, const zeus::CTransform& xf,
|
||||
const CMaterialFilter& filter)
|
||||
: x0_ray(start, end, d),
|
||||
x3c_xf(xf),
|
||||
x6c_filter(filter)
|
||||
{
|
||||
}
|
||||
|
||||
const zeus::CMRay& GetRay() const { return x0_ray; }
|
||||
const zeus::CVector3f& GetStart() const { return x0_ray.start; }
|
||||
const zeus::CVector3f& GetNormal() const { return x0_ray.normal; }
|
||||
float GetMaxTime() const { return 0.f; }
|
||||
const zeus::CTransform& GetTransform() const { return x3c_xf; }
|
||||
const CMaterialFilter& GetFilter() const { return x6c_filter; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
|
@ -5,8 +5,10 @@ set(COLLISION_SOURCES
|
|||
COBBTree.hpp COBBTree.cpp
|
||||
CCollidableOBBTree.hpp CCollidableOBBTree.cpp
|
||||
CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp
|
||||
CCollisionPrimitive.hpp CCollisionPrimitive.cpp
|
||||
CMaterialList.hpp
|
||||
CMaterialFilter.hpp CMaterialFilter.cpp
|
||||
CInternalRayCastStructure.hpp CInternalRayCastStructure.cpp
|
||||
CRayCastResult.hpp CRayCastResult.cpp)
|
||||
|
||||
runtime_add_list(Collision COLLISION_SOURCES)
|
||||
|
|
|
@ -23,10 +23,23 @@ COBBTree::COBBTree(CInputStream& in)
|
|||
: x0_magic(verify_deaf_babe(in)),
|
||||
x4_version(verify_version(in)),
|
||||
x8_memsize(in.readUint32()),
|
||||
x18_indexData(in)
|
||||
x18_indexData(in),
|
||||
x88_root(new CNode(in))
|
||||
{
|
||||
}
|
||||
|
||||
zeus::CAABox COBBTree::CalculateLocalAABox() const
|
||||
{
|
||||
return CalculateAABox(zeus::CTransform::Identity());
|
||||
}
|
||||
|
||||
zeus::CAABox COBBTree::CalculateAABox(const zeus::CTransform& xf) const
|
||||
{
|
||||
if (x88_root)
|
||||
return x88_root->GetOBB().calculateAABox(xf);
|
||||
return zeus::CAABox::skInvertedBox;
|
||||
}
|
||||
|
||||
COBBTree::SIndexData::SIndexData(CInputStream& in)
|
||||
{
|
||||
u32 count = in.readUint32Big();
|
||||
|
@ -57,9 +70,65 @@ COBBTree::SIndexData::SIndexData(CInputStream& in)
|
|||
x60_.push_back(zeus::CVector3f::ReadBig(in));
|
||||
}
|
||||
|
||||
COBBTree::CNode::CNode(const zeus::CTransform& xf, const zeus::CVector3f& point,
|
||||
const COBBTree::CNode* left, const COBBTree::CNode* right,
|
||||
const COBBTree::CLeafData* leaf)
|
||||
: x0_obb(xf, point),
|
||||
x3c_isLeaf(leaf != nullptr)
|
||||
{
|
||||
x40_left.reset((CNode*)left);
|
||||
x44_right.reset((CNode*)right);
|
||||
x48_leaf.reset((CLeafData*)leaf);
|
||||
}
|
||||
|
||||
COBBTree::CNode::CNode(CInputStream& in)
|
||||
{
|
||||
x0_obb = zeus::COBBox::ReadBig(in);
|
||||
x3c_isLeaf = in.readBool();
|
||||
if (x3c_isLeaf)
|
||||
x48_leaf.reset(new CLeafData(in));
|
||||
else
|
||||
{
|
||||
x40_left.reset(new CNode(in));
|
||||
x44_right.reset(new CNode(in));
|
||||
}
|
||||
}
|
||||
|
||||
COBBTree::CNode* COBBTree::CNode::GetLeft() const
|
||||
{
|
||||
return x40_left.get();
|
||||
}
|
||||
|
||||
COBBTree::CNode*COBBTree::CNode::GetRight() const
|
||||
{
|
||||
return x44_right.get();
|
||||
}
|
||||
|
||||
COBBTree::CLeafData*COBBTree::CNode::GetLeafData() const
|
||||
{
|
||||
return x48_leaf.get();
|
||||
}
|
||||
|
||||
const zeus::COBBox& COBBTree::CNode::GetOBB() const
|
||||
{
|
||||
return x0_obb;
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(const std::vector<u16>& surface)
|
||||
: x0_surface(surface)
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<u16>& COBBTree::CLeafData::GetSurfaceVector() const
|
||||
{
|
||||
return x0_surface;
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(CInputStream& in)
|
||||
{
|
||||
u32 edgeCount = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < edgeCount ; i++)
|
||||
x0_surface.push_back(in.readUint16Big());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,20 +23,36 @@ public:
|
|||
SIndexData(CInputStream&);
|
||||
};
|
||||
|
||||
class CNodeLeafData
|
||||
class CLeafData
|
||||
{
|
||||
std::vector<u16> x0_surface;
|
||||
public:
|
||||
CLeafData()=default;
|
||||
CLeafData(const std::vector<u16>&);
|
||||
CLeafData(CInputStream&);
|
||||
|
||||
const std::vector<u16>& GetSurfaceVector() const;
|
||||
};
|
||||
|
||||
class CNode
|
||||
{
|
||||
zeus::COBBox x0_obb;
|
||||
bool x3c_ = false;
|
||||
std::unique_ptr<CNode> x40_;
|
||||
std::unique_ptr<CNode> x44_;
|
||||
std::unique_ptr<CNodeLeafData> x48_;
|
||||
bool x3c_isLeaf = false;
|
||||
std::unique_ptr<CNode> x40_left;
|
||||
std::unique_ptr<CNode> x44_right;
|
||||
std::unique_ptr<CLeafData> x48_leaf;
|
||||
public:
|
||||
CNode() = default;
|
||||
CNode(const CNode&)=default;
|
||||
CNode(const zeus::CTransform&, const zeus::CVector3f&, const CNode*, const CNode*, const CLeafData*);
|
||||
CNode(CInputStream&);
|
||||
|
||||
bool WasHit() const;
|
||||
void SetWasHit(bool) const;
|
||||
CNode* GetLeft() const;
|
||||
CNode* GetRight() const;
|
||||
CLeafData* GetLeafData() const;
|
||||
const zeus::COBBox& GetOBB() const;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -48,10 +64,12 @@ private:
|
|||
SIndexData x18_indexData;
|
||||
std::unique_ptr<CNode> x88_root;
|
||||
public:
|
||||
|
||||
|
||||
COBBTree()=default;
|
||||
COBBTree(const COBBTree::SIndexData&, const CNode*);
|
||||
COBBTree(CInputStream&);
|
||||
|
||||
zeus::CAABox CalculateLocalAABox() const;
|
||||
zeus::CAABox CalculateAABox(const zeus::CTransform&) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,52 @@
|
|||
#include "CRayCastResult.hpp"
|
||||
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
void CRayCastResult::MakeInvalid()
|
||||
{
|
||||
/* NOTE: CRayCastResult: Enable this if it's required, this is a total guess - Phil */
|
||||
#if 0
|
||||
x0_time = 0.f;
|
||||
x4_point.zeroOut();
|
||||
x10_plane.vec.zeroOut();;
|
||||
x10_plane.d = 0.f;
|
||||
x28_material = CMaterialList();
|
||||
#endif
|
||||
x20_invalid = EInvalid::Invalid;
|
||||
}
|
||||
|
||||
bool CRayCastResult::IsInvalid() const
|
||||
{
|
||||
return x20_invalid == EInvalid::Invalid;
|
||||
}
|
||||
|
||||
float CRayCastResult::GetTime() const
|
||||
{
|
||||
return x0_time;
|
||||
}
|
||||
|
||||
const zeus::CVector3f&CRayCastResult::GetPoint() const
|
||||
{
|
||||
return x4_point;
|
||||
}
|
||||
|
||||
const zeus::CPlane&CRayCastResult::GetPlane() const
|
||||
{
|
||||
return x10_plane;
|
||||
}
|
||||
|
||||
const CMaterialList&CRayCastResult::GetMaterial() const
|
||||
{
|
||||
return x28_material;
|
||||
}
|
||||
|
||||
void CRayCastResult::Transform(const zeus::CTransform& xf)
|
||||
{
|
||||
x4_point = xf * x4_point;
|
||||
x10_plane.vec = xf.rotate(x10_plane.vec);
|
||||
x10_plane.d = x10_plane.vec.dot(x4_point);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,21 +9,42 @@ namespace urde
|
|||
class CRayCastResult
|
||||
{
|
||||
public:
|
||||
enum class EInvalid
|
||||
enum class EInvalid : u8
|
||||
{
|
||||
Zero,
|
||||
One
|
||||
Invalid,
|
||||
Valid
|
||||
};
|
||||
private:
|
||||
EInvalid invalid = EInvalid::Zero;
|
||||
zeus::CVector3f x4_;
|
||||
zeus::CVector3f x10_;
|
||||
float x0_time;
|
||||
zeus::CVector3f x4_point;
|
||||
zeus::CPlane x10_plane;
|
||||
EInvalid x20_invalid = EInvalid::Invalid;
|
||||
/*u32 x24_; */
|
||||
CMaterialList x28_material;
|
||||
public:
|
||||
CRayCastResult();
|
||||
CRayCastResult(float, const zeus::CVector3f&, const zeus::CPlane, const CMaterialList& matList)
|
||||
CRayCastResult(const CRayCastResult& other, EInvalid invalid)
|
||||
: x0_time(other.x0_time),
|
||||
x4_point(other.x4_point),
|
||||
x10_plane(other.x10_plane),
|
||||
x20_invalid(invalid),
|
||||
x28_material(other.x28_material)
|
||||
{
|
||||
}
|
||||
|
||||
CRayCastResult(float, const zeus::CVector3f&, const zeus::CPlane& plane, const CMaterialList& matList)
|
||||
: x28_material(matList)
|
||||
{}
|
||||
|
||||
void MakeInvalid();
|
||||
|
||||
bool IsInvalid() const;
|
||||
|
||||
float GetTime() const;
|
||||
const zeus::CVector3f& GetPoint() const;
|
||||
const zeus::CPlane& GetPlane() const;
|
||||
const CMaterialList& GetMaterial() const;
|
||||
void Transform(const zeus::CTransform&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,25 +16,30 @@ class CDecalDescription;
|
|||
|
||||
enum class EWeaponCollisionResponseTypes
|
||||
{
|
||||
Unknown0, Unknown1, Unknown2, Unknown3, Unknown4,
|
||||
Unknown5, Unknown6, Unknown7, Unknown8, Unknown9,
|
||||
Unknown10,Unknown11,Unknown12,Unknown13,Unknown14,
|
||||
Unknown15,Unknown16,Unknown17,Unknown18,Unknown19,
|
||||
Unknown20,Unknown21,Unknown22,Unknown23,Unknown24,
|
||||
Unknown25,Unknown26,Unknown27,Unknown28,Unknown29,
|
||||
Unknown30,Unknown31,Unknown32,Unknown33,Unknown34,
|
||||
Unknown35,Unknown36,Unknown37,Unknown38,Unknown39,
|
||||
Unknown40,Unknown41,Unknown42,Unknown43,Unknown44,
|
||||
Unknown45,Unknown46,Unknown47,Unknown48,Unknown49,
|
||||
Unknown50,Unknown51,Unknown52,Unknown53,Unknown54,
|
||||
Unknown55,Unknown56,Unknown57,Unknown58,Unknown59,
|
||||
Unknown60,Unknown61,Unknown62,Unknown63,Unknown64,
|
||||
Unknown65,Unknown66,Unknown67,Unknown68,Unknown69,
|
||||
Unknown70,Unknown71,Unknown72,Unknown73,Unknown74,
|
||||
Unknown75,Unknown76,Unknown77,Unknown78,Unknown79,
|
||||
Unknown80,Unknown81,Unknown82,Unknown83,Unknown84,
|
||||
Unknown85,Unknown86,Unknown87,Unknown88,Unknown89,
|
||||
Unknown90,Unknown91,Unknown92,Unknown93
|
||||
Unknown0, Unknown1, Metal, Grass,
|
||||
Ice, Goo, Wood, Water,
|
||||
Mud, Lava, Sand,Unknown11,
|
||||
Unknown12,Unknown13,Unknown14,Unknown15,
|
||||
Unknown16,Unknown17,Unknown18,Unknown19,
|
||||
Unknown20,Unknown21,Unknown22,Unknown23,
|
||||
Unknown24,Unknown25,Unknown26,Unknown27,
|
||||
Unknown28,Unknown29,Unknown30,Unknown31,
|
||||
Unknown32,Unknown33,Unknown34,Unknown35,
|
||||
Unknown36,Unknown37,Unknown38,Unknown39,
|
||||
Unknown40,Unknown41,Unknown42,Unknown43,
|
||||
Unknown44,Unknown45,Unknown46,Unknown47,
|
||||
Unknown48,Unknown49,Unknown50,Unknown51,
|
||||
Unknown52,Unknown53,Unknown54,Unknown55,
|
||||
Unknown56,Unknown57,Unknown58,Unknown59,
|
||||
Unknown60,Unknown61,Unknown62,Unknown63,
|
||||
Unknown64,Unknown65,Unknown66,Unknown67,
|
||||
Unknown68,Unknown69,Unknown70,Unknown71,
|
||||
Unknown72,Unknown73,Unknown74,Unknown75,
|
||||
Unknown76,Unknown77,Unknown78,Unknown79,
|
||||
Unknown80,Unknown81,Unknown82,Unknown83,
|
||||
Unknown84,Unknown85,Unknown86,Unknown87,
|
||||
Unknown88,Unknown89,Unknown90,Unknown91,
|
||||
Unknown92
|
||||
};
|
||||
|
||||
class CCollisionResponseData
|
||||
|
|
|
@ -5,15 +5,11 @@
|
|||
#include "zeus/zeus.hpp"
|
||||
#include "Collision/CMaterialFilter.hpp"
|
||||
#include "Character/CModelData.hpp"
|
||||
#include "Particle/CCollisionResponseData.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
enum class ECollisionResponseType
|
||||
{
|
||||
Unknown12 = 0xC,
|
||||
};
|
||||
|
||||
class CActorParameters;
|
||||
class CWeaponMode;
|
||||
class CHealthInfo;
|
||||
|
@ -86,7 +82,7 @@ public:
|
|||
|
||||
virtual const zeus::CAABox* GetTouchBounds() const { return nullptr; }
|
||||
|
||||
virtual ECollisionResponseType GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) { return ECollisionResponseType::Unknown12; }
|
||||
virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) { return EWeaponCollisionResponseTypes::Unknown13; }
|
||||
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
|
||||
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
|
||||
void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&);
|
||||
|
|
|
@ -8,17 +8,21 @@ namespace urde
|
|||
|
||||
class CAnimationParameters
|
||||
{
|
||||
public:
|
||||
ResId x0_ancs = -1;
|
||||
s32 x4_charIdx = -1;
|
||||
u32 x4_charIdx = -1;
|
||||
u32 x8_defaultAnim = -1;
|
||||
public:
|
||||
CAnimationParameters() = default;
|
||||
CAnimationParameters(ResId ancs, s32 charIdx, u32 defaultAnim)
|
||||
CAnimationParameters(ResId ancs, u32 charIdx, u32 defaultAnim)
|
||||
: x0_ancs(ancs), x4_charIdx(charIdx), x8_defaultAnim(defaultAnim) {}
|
||||
CAnimationParameters(CInputStream& in)
|
||||
: x0_ancs(in.readUint32Big()),
|
||||
x4_charIdx(in.readUint32Big()),
|
||||
x8_defaultAnim(in.readUint32Big()) {}
|
||||
|
||||
u32 GetACSFile() const { return x0_ancs; }
|
||||
u32 GetCharacter() const { return x4_charIdx; }
|
||||
u32 GetInitialAnimation() const { return x8_defaultAnim; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ set(WORLD_SOURCES
|
|||
CScriptCoverPoint.hpp CScriptCoverPoint.cpp
|
||||
CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp
|
||||
CScriptCameraHint.hpp CScriptCameraHint.cpp
|
||||
CScriptActorRotate.hpp CScriptActorRotate.cpp
|
||||
CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp
|
||||
CGrappleParameters.hpp
|
||||
CActorParameters.hpp
|
||||
CLightParameters.hpp
|
||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
|||
float xf0_inertialTensor;
|
||||
float xf4_inertialTensorRecip;
|
||||
zeus::CAABox x1a4_baseBoundingBox;
|
||||
CCollisionPrimitive x1c0_collisionPrimitive;
|
||||
std::unique_ptr<CCollisionPrimitive> x1c0_collisionPrimitive;
|
||||
zeus::CVector3f x1e8_primitiveOffset;
|
||||
float x23c_stepUpHeight;
|
||||
float x240_stepDownHeight;
|
||||
|
@ -114,8 +114,8 @@ public:
|
|||
return zeus::CTransform();
|
||||
}
|
||||
|
||||
const CCollisionPrimitive& GetCollisionPrimitive() const
|
||||
{ return x1c0_collisionPrimitive; }
|
||||
const CCollisionPrimitive* GetCollisionPrimitive() const
|
||||
{ return x1c0_collisionPrimitive.get(); }
|
||||
|
||||
void SetInertiaTensorScalar(float tensor)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "CScriptActorRotate.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
CScriptActorRotate::CScriptActorRotate(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
||||
const zeus::CVector3f& rotation, float scale, bool, bool, bool active)
|
||||
: CEntity(uid, info, active, name)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef CSCRIPTACTORROTATE_HPP
|
||||
#define CSCRIPTACTORROTATE_HPP
|
||||
|
||||
#include "CEntity.hpp"
|
||||
#include "zeus/CTransform.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CScriptActorRotate : public CEntity
|
||||
{
|
||||
zeus::CVector3f x34_rotation;
|
||||
float x40_;
|
||||
float x44_;
|
||||
std::map<TUniqueId, zeus::CTransform> x48_actors;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
bool x58_24_ : 1;
|
||||
bool x58_25_ : 1;
|
||||
bool x58_26_ : 1;
|
||||
bool x58_27_ : 1;
|
||||
};
|
||||
u32 dummy = 0;
|
||||
};
|
||||
public:
|
||||
CScriptActorRotate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool, bool, bool);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSCRIPTACTORROTATE_HPP
|
|
@ -0,0 +1,17 @@
|
|||
#include "CScriptSpecialFunction.hpp"
|
||||
#include "Character/CModelData.hpp"
|
||||
#include "CActorParameters.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
||||
const zeus::CTransform& xf, ESpecialFunction,
|
||||
const std::string&, float, float, float, float, const zeus::CVector3f&,
|
||||
const zeus::CColor&, bool active, const CDamageInfo&, u32, u32, u32, u16, u16, u16)
|
||||
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef __URDE_CSCRIPTSPECIALFUNCTION_HPP__
|
||||
#define __URDE_CSCRIPTSPECIALFUNCTION_HPP__
|
||||
|
||||
#include "CActor.hpp"
|
||||
#include "CDamageInfo.hpp"
|
||||
#include "zeus/CTransform.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CScriptSpecialFunction : public CActor
|
||||
{
|
||||
public:
|
||||
enum class ESpecialFunction
|
||||
{
|
||||
What,
|
||||
PlayerFollowLocator,
|
||||
SpinnerController,
|
||||
ObjectFollowLocator,
|
||||
Four,
|
||||
InventoryActivator,
|
||||
MapStation,
|
||||
SaveStation,
|
||||
IntroBossRingController,
|
||||
ViewFrustumTester,
|
||||
ShotSpinnerController,
|
||||
EscapeSequence,
|
||||
BossEnergyBar,
|
||||
EndGame,
|
||||
HUDFadeIn,
|
||||
CinematicSkip,
|
||||
ScriptLayerController,
|
||||
RainSimulator,
|
||||
AreaDamage,
|
||||
ObjectFollowObject,
|
||||
RedundantHintSystem,
|
||||
DropBomb,
|
||||
TwentyTwo,
|
||||
MissileStation,
|
||||
Billboard,
|
||||
PlayerInAreaRelay,
|
||||
HUDTarget,
|
||||
FogFader,
|
||||
EnterLogbook,
|
||||
PowerBombStation,
|
||||
Ending,
|
||||
FusionRelay,
|
||||
WeaponSwitch,
|
||||
FourtySeven = 47,
|
||||
FourtyEight = 48
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
CScriptSpecialFunction(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, ESpecialFunction,
|
||||
const std::string&, float, float, float, float, const zeus::CVector3f&, const zeus::CColor&, bool,
|
||||
const CDamageInfo&, u32, u32, u32, u16, u16, u16);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSCRIPTSPECIALFUNCTION_HPP
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef CWORLDLIGHT_HPP
|
||||
#define CWORLDLIGHT_HPP
|
||||
#ifndef __URDE_CWORLDLIGHT_HPP__
|
||||
#define __URDE_CWORLDLIGHT_HPP__
|
||||
|
||||
#include "Graphics/CLight.hpp"
|
||||
|
||||
|
@ -31,4 +31,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
#endif // CWORLDLIGHT_HPP
|
||||
#endif // __URDE_CWORLDLIGHT_HPP__
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "CScriptCoverPoint.hpp"
|
||||
#include "CScriptSpawnPoint.hpp"
|
||||
#include "CScriptCameraHint.hpp"
|
||||
#include "CScriptActorRotate.hpp"
|
||||
#include "CScriptSpecialFunction.hpp"
|
||||
#include "Camera/CCinematicCamera.hpp"
|
||||
#include "MP1/CNewIntroBoss.hpp"
|
||||
#include "MP1/CWarWasp.hpp"
|
||||
|
@ -44,7 +46,7 @@ namespace urde
|
|||
static logvisor::Module Log("urde::ScriptLoader");
|
||||
|
||||
static SObjectTag MorphballDoorANCS = {};
|
||||
static const SObjectTag& GetMorphballDoorANCS()
|
||||
static const SObjectTag& GetMorphballDoorACS()
|
||||
{
|
||||
if (!MorphballDoorANCS)
|
||||
MorphballDoorANCS = static_cast<ProjectResourceFactoryBase*>(g_ResFactory)->
|
||||
|
@ -361,7 +363,7 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in,
|
|||
bool b8 = in.readBool();
|
||||
bool b9 = in.readBool();
|
||||
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.x0_ancs);
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
|
||||
if (!g_ResFactory->GetResourceTypeById(staticId) && !animType)
|
||||
return nullptr;
|
||||
|
||||
|
@ -383,22 +385,9 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in,
|
|||
|
||||
CModelData data;
|
||||
if (animType == SBIG('ANCS'))
|
||||
{
|
||||
CAnimRes aRes;
|
||||
aRes.x0_ancsId = aParms.x0_ancs;
|
||||
aRes.x4_charIdx = aParms.x4_charIdx;
|
||||
aRes.x8_scale = head.x40_scale;
|
||||
aRes.x14_ = true;
|
||||
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
|
||||
data = aRes;
|
||||
}
|
||||
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
|
||||
else
|
||||
{
|
||||
CStaticRes sRes;
|
||||
sRes.x0_cmdlId = staticId;
|
||||
sRes.x4_scale = head.x40_scale;
|
||||
data = sRes;
|
||||
}
|
||||
data = CStaticRes(staticId, head.x40_scale);
|
||||
|
||||
if (generateExtent || collisionExtent.isZero())
|
||||
aabb = data.GetBounds(head.x10_transform.getRotation());
|
||||
|
@ -455,23 +444,17 @@ CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in,
|
|||
|
||||
zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), collisionExtent, offset);
|
||||
|
||||
if (!g_ResFactory->GetResourceTypeById(aParms.x0_ancs))
|
||||
if (!g_ResFactory->GetResourceTypeById(aParms.GetACSFile()))
|
||||
return nullptr;
|
||||
|
||||
CAnimRes aRes;
|
||||
aRes.x0_ancsId = aParms.x0_ancs;
|
||||
aRes.x4_charIdx = aParms.x4_charIdx;
|
||||
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
|
||||
aRes.x8_scale = head.x40_scale;
|
||||
|
||||
CModelData mData = aRes;
|
||||
CModelData mData = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
|
||||
if (collisionExtent.isZero())
|
||||
aabb = mData.GetBounds(head.x10_transform.getRotation());
|
||||
|
||||
bool isMorphballDoor = false;
|
||||
if (propCount == 13)
|
||||
{
|
||||
if (aParms.x0_ancs == GetMorphballDoorANCS().id)
|
||||
if (aParms.GetACSFile() == GetMorphballDoorACS().id)
|
||||
isMorphballDoor = true;
|
||||
}
|
||||
else if (propCount == 14)
|
||||
|
@ -623,7 +606,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in,
|
|||
u32 w2 = in.readUint32Big();
|
||||
u32 w3 = in.readUint32Big();
|
||||
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.x0_ancs);
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
|
||||
if (!g_ResFactory->GetResourceTypeById(staticId) && !animType)
|
||||
return nullptr;
|
||||
|
||||
|
@ -639,22 +622,9 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in,
|
|||
|
||||
CModelData data;
|
||||
if (animType == SBIG('ANCS'))
|
||||
{
|
||||
CAnimRes aRes;
|
||||
aRes.x0_ancsId = aParms.x0_ancs;
|
||||
aRes.x4_charIdx = aParms.x4_charIdx;
|
||||
aRes.x8_scale = head.x40_scale;
|
||||
aRes.x14_ = true;
|
||||
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
|
||||
data = aRes;
|
||||
}
|
||||
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
|
||||
else
|
||||
{
|
||||
CStaticRes sRes;
|
||||
sRes.x0_cmdlId = staticId;
|
||||
sRes.x4_scale = head.x40_scale;
|
||||
data = sRes;
|
||||
}
|
||||
data = CStaticRes(staticId, head.x40_scale);
|
||||
|
||||
if (extent.isZero())
|
||||
aabb = data.GetBounds(head.x10_transform.getRotation());
|
||||
|
@ -724,7 +694,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in,
|
|||
if (!EnsurePropertyCount(propCount, 7, "Dock"))
|
||||
return nullptr;
|
||||
|
||||
std::string name = *mgr.HashInstanceName(in);
|
||||
const std::string* name = mgr.HashInstanceName(in);
|
||||
bool active = in.readBool();
|
||||
zeus::CVector3f position;
|
||||
position.readBig(in);
|
||||
|
@ -733,7 +703,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in,
|
|||
u32 dock = in.readUint32Big();
|
||||
TAreaId area = in.readUint32Big();
|
||||
bool b1 = in.readBool();
|
||||
return new CScriptDock(mgr.AllocateUniqueId(), name, info, position, scale, dock, area, active, 0, b1);
|
||||
return new CScriptDock(mgr.AllocateUniqueId(), *name, info, position, scale, dock, area, active, 0, b1);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in,
|
||||
|
@ -810,16 +780,13 @@ CEntity* ScriptLoader::LoadNewIntroBoss(CStateManager& mgr, CInputStream& in,
|
|||
u32 w4 = in.readUint32Big();
|
||||
u32 w5 = in.readUint32Big();
|
||||
|
||||
const CAnimationParameters& animParms = pInfo.GetAnimationParameters();
|
||||
if (animParms.x0_ancs < 0)
|
||||
const CAnimationParameters& aParms = pInfo.GetAnimationParameters();
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
|
||||
if (animType != SBIG('ANCS'))
|
||||
return nullptr;
|
||||
|
||||
CAnimRes res;
|
||||
res.x0_ancsId = animParms.x0_ancs;
|
||||
res.x4_charIdx = animParms.x4_charIdx;
|
||||
res.x8_scale = head.x40_scale;
|
||||
res.x14_ = true;
|
||||
res.x18_defaultAnim = animParms.x8_defaultAnim;
|
||||
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
|
||||
|
||||
|
||||
return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info,
|
||||
head.x10_transform, res, pInfo, actParms, f1, w1,
|
||||
|
@ -968,7 +935,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in,
|
|||
if (!EnsurePropertyCount(propCount, 63, "Water"))
|
||||
return nullptr;
|
||||
|
||||
std::string name = *mgr.HashInstanceName(in);
|
||||
const std::string* name = mgr.HashInstanceName(in);
|
||||
zeus::CVector3f position;
|
||||
position.readBig(in);
|
||||
zeus::CVector3f extent;
|
||||
|
@ -1066,7 +1033,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in,
|
|||
if (textureId4 == -1)
|
||||
realTextureId5 = textureId5;
|
||||
|
||||
return new CScriptWater(mgr, mgr.AllocateUniqueId(), name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface,
|
||||
return new CScriptWater(mgr, mgr.AllocateUniqueId(), *name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface,
|
||||
textureId1, textureId2, textureId3, textureId4, realTextureId5, realTextureId6, -1, otherV2, f1, f2,
|
||||
f3, active, fluidType, b4, f4, fluidMotion, f5, f6, f7, f8, f9, f10, f11, f12, c1, c2, enterParticle,
|
||||
partId2, partId3, partId4, partId5, soundId1, soundId2, soundId3, soundId4, soundId5,
|
||||
|
@ -1080,7 +1047,7 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in,
|
|||
if (!EnsurePropertyCount(propCount, 13, "WarWasp"))
|
||||
return nullptr;
|
||||
|
||||
std::string name = *mgr.HashInstanceName(in);
|
||||
const std::string* name = mgr.HashInstanceName(in);
|
||||
CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big());
|
||||
zeus::CTransform xf = LoadEditorTransformPivotOnly(in);
|
||||
zeus::CVector3f scale;
|
||||
|
@ -1099,18 +1066,14 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in,
|
|||
ResId particle = in.readUint32Big();
|
||||
u32 w1 = in.readUint32Big();
|
||||
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(pInfo.GetAnimationParameters().x0_ancs);
|
||||
const CAnimationParameters& aParms = pInfo.GetAnimationParameters();
|
||||
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
|
||||
if (animType != SBIG('ANCS'))
|
||||
return nullptr;
|
||||
|
||||
CAnimRes res;
|
||||
res.x0_ancsId = pInfo.GetAnimationParameters().x0_ancs;
|
||||
res.x4_charIdx = pInfo.GetAnimationParameters().x4_charIdx;
|
||||
res.x8_scale = scale;
|
||||
res.x14_ = true;
|
||||
res.x18_defaultAnim = pInfo.GetAnimationParameters().x8_defaultAnim;
|
||||
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, true, aParms.GetInitialAnimation());
|
||||
CModelData mData(res);
|
||||
return new MP1::CWarWasp(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, flavor, collider, damageInfo1, actorParms, weaponDesc,
|
||||
return new MP1::CWarWasp(mgr.AllocateUniqueId(), *name, info, xf, std::move(mData), pInfo, flavor, collider, damageInfo1, actorParms, weaponDesc,
|
||||
damageInfo2, particle, w1);
|
||||
}
|
||||
|
||||
|
@ -1182,11 +1145,11 @@ CEntity* ScriptLoader::LoadGrapplePoint(CStateManager& mgr, CInputStream& in,
|
|||
if (!EnsurePropertyCount(propCount, 5, "GrapplePoint"))
|
||||
return nullptr;
|
||||
|
||||
std::string name = *mgr.HashInstanceName(in);
|
||||
const std::string* name = mgr.HashInstanceName(in);
|
||||
zeus::CTransform grappleXf = LoadEditorTransform(in);
|
||||
bool active = in.readBool();
|
||||
CGrappleParameters parameters = LoadGrappleParameters(in);
|
||||
return new CScriptGrapplePoint(mgr.AllocateUniqueId(), name, info, grappleXf, active, parameters);
|
||||
return new CScriptGrapplePoint(mgr.AllocateUniqueId(), *name, info, grappleXf, active, parameters);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadPuddleSpore(CStateManager& mgr, CInputStream& in,
|
||||
|
@ -1232,11 +1195,46 @@ CEntity* ScriptLoader::LoadDockAreaChange(CStateManager& mgr, CInputStream& in,
|
|||
CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in,
|
||||
int propCount, const CEntityInfo& info)
|
||||
{
|
||||
if (!EnsurePropertyCount(propCount, 6, "ActorRotate"))
|
||||
return nullptr;
|
||||
|
||||
const std::string* name = mgr.HashInstanceName(in);
|
||||
zeus::CVector3f rotation = zeus::CVector3f::ReadBig(in);
|
||||
float scale = in.readFloatBig();
|
||||
bool b1 = in.readBool();
|
||||
bool b2 = in.readBool();
|
||||
bool active = in.readBool();
|
||||
|
||||
return new CScriptActorRotate(mgr.AllocateUniqueId(), *name, info, rotation, scale, b1, b2, active);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in,
|
||||
int propCount, const CEntityInfo& info)
|
||||
{
|
||||
if (!EnsurePropertyCount(propCount, 15, "SpecialFunction"))
|
||||
return nullptr;
|
||||
|
||||
SActorHead head = LoadActorHead(in, mgr);
|
||||
CScriptSpecialFunction::ESpecialFunction specialFunction = CScriptSpecialFunction::ESpecialFunction(in.readUint32Big());
|
||||
std::string str = in.readString();
|
||||
float f1 = in.readFloatBig();
|
||||
float f2 = in.readFloatBig();
|
||||
float f3 = in.readFloatBig();
|
||||
u32 w2 = in.readUint32Big();
|
||||
u32 w3 = in.readUint32Big();
|
||||
u32 w4 = in.readUint32Big();
|
||||
bool active1 = in.readBool();
|
||||
float f4 = in.readFloatBig();
|
||||
s16 w5 = in.readUint32Big() & 0xFFFF;
|
||||
s16 w6 = in.readUint32Big() & 0xFFFF;
|
||||
s16 w7 = in.readUint32Big() & 0xFFFF;
|
||||
if (specialFunction == CScriptSpecialFunction::ESpecialFunction::FourtySeven ||
|
||||
specialFunction == CScriptSpecialFunction::ESpecialFunction::FourtySeven)
|
||||
return nullptr;
|
||||
|
||||
return new CScriptSpecialFunction(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, specialFunction, str, f1, f2,
|
||||
f3, f4, zeus::CVector3f::skZero, zeus::CColor::skBlack, active1, CDamageInfo(), w2, w3, w4,
|
||||
w5, w6, w7);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadSpankWeed(CStateManager& mgr, CInputStream& in,
|
||||
|
|
2
specter
2
specter
|
@ -1 +1 @@
|
|||
Subproject commit d14a7aed7bd256191ed5bfbbb9a0f9cf4a141796
|
||||
Subproject commit 5352a5842ac0b2b6ba075f2c885fa172a93a54c0
|
Loading…
Reference in New Issue