Fixes in preparation for rigged model rendering

This commit is contained in:
Jack Andersen 2016-09-04 12:47:48 -10:00
parent 03225d3616
commit 668c4f7eee
12 changed files with 89 additions and 46 deletions

View File

@ -1274,16 +1274,16 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
{
EVNT evnt;
evnt.fromYAMLStream(reader);
anim.m_anim->evnt = evntYamlPath;
hecl::ProjectPath evntYamlOut = cookedOut.getWithExtension(_S(".evnt"));
athena::io::FileWriter w(evntYamlOut.getAbsolutePath(), true, false);
hecl::ProjectPath evntCookedOut = evntYamlPath.getCookedPath(SpecEntMP1);
athena::io::FileWriter w(evntCookedOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
evntYamlOut.getRelativePath().c_str());
evntCookedOut.getRelativePath().c_str());
evnt.write(w);
ancs.animationSet.animResources.back().evntId = evntYamlPath;
anim.m_anim->evnt = evntYamlPath;
}
}

View File

@ -156,7 +156,8 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
return nullptr;
if (hecl::IsPathBlend(path))
{
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CSKR")))
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CSKR")) ||
hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".ANIM")))
return oldEntry;
hecl::BlenderConnection& conn = btok.getBlenderConnection();

View File

@ -26,7 +26,7 @@ class CAnimFormatUnion
union
{
EAnimFormat x0_format;
intptr_t _align = 0;
u8 _align[16];
};
u8 x4_storage[std::max(sizeof(CAnimSource), sizeof(CFBStreamedCompression))];
static void SubConstruct(u8* storage, EAnimFormat fmt,

View File

@ -57,10 +57,11 @@ CAnimData::CAnimData(ResId id,
x1fc_transMgr(transMgr),
x204_charIdx(charIdx),
x208_defaultAnim(defaultAnim),
x220_25_loop(loop),
x224_pose(layout->GetSegIdList().GetList().size()),
x2fc_poseBuilder(layout)
{
x220_25_loop = loop;
if (iceModel)
xe4_iceModelData = *iceModel;
@ -391,13 +392,13 @@ void CAnimData::PrimitiveSetToTokenVector(const std::set<CPrimitive>& primSet,
void CAnimData::GetAnimationPrimitives(const CAnimPlaybackParms& parms, std::set<CPrimitive>& primsOut) const
{
std::shared_ptr<IMetaAnim> animA =
GetAnimationManager()->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.x0_animA));
x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.x0_animA));
animA->GetUniquePrimitives(primsOut);
if (parms.x4_animB != -1)
{
std::shared_ptr<IMetaAnim> animB =
GetAnimationManager()->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.x4_animB));
x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.x4_animB));
animB->GetUniquePrimitives(primsOut);
}
}
@ -405,12 +406,12 @@ void CAnimData::GetAnimationPrimitives(const CAnimPlaybackParms& parms, std::set
void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
{
if (parms.x0_animA == x40c_playbackParms.x0_animA ||
(parms.x4_animB != x40c_playbackParms.x4_animB &&
(parms.x4_animB == x40c_playbackParms.x4_animB &&
parms.x8_blendWeight == x40c_playbackParms.x8_blendWeight &&
parms.x8_blendWeight != 1.f) ||
parms.x4_animB == -1)
{
if (x220_29_)
if (x220_29_animationJustStarted)
return;
}
@ -430,9 +431,9 @@ void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
u32 animIdxB = xc_charInfo.GetAnimationIndex(parms.x4_animB);
std::shared_ptr<CAnimTreeNode> treeA =
GetAnimationManager()->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
x100_animMgr->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
std::shared_ptr<CAnimTreeNode> treeB =
GetAnimationManager()->GetAnimationTree(animIdxB, CMetaAnimTreeBuildOrders::NoSpecialOrders());
x100_animMgr->GetAnimationTree(animIdxB, CMetaAnimTreeBuildOrders::NoSpecialOrders());
blendNode = std::make_shared<CAnimTreeBlend>(false, treeA, treeB, parms.x8_blendWeight,
CAnimTreeBlend::CreatePrimitiveName(treeA, treeB,
@ -440,10 +441,10 @@ void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
}
else
{
blendNode = GetAnimationManager()->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
blendNode = x100_animMgr->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
}
if (!noTrans)
if (!noTrans && x1f8_animRoot)
x1f8_animRoot = x1fc_transMgr->GetTransitionTree(x1f8_animRoot, blendNode);
else
x1f8_animRoot = blendNode;
@ -451,7 +452,7 @@ void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
x220_24_animating = parms.xc_animating;
CalcPlaybackAlignmentParms(parms, blendNode);
ResetPOILists();
x220_29_ = true;
x220_29_animationJustStarted = true;
}
SAdvancementDeltas CAnimData::DoAdvance(float dt, bool& b1, CRandom16& random, bool advTree)
@ -476,9 +477,9 @@ SAdvancementDeltas CAnimData::DoAdvance(float dt, bool& b1, CRandom16& random, b
return {};
}
if (x220_29_)
if (x220_29_animationJustStarted)
{
x220_29_ = false;
x220_29_animationJustStarted = false;
b1 = true;
}
@ -512,7 +513,7 @@ SAdvancementDeltas CAnimData::DoAdvance(float dt, bool& b1, CRandom16& random, b
if (remTime.EpsilonZero())
{
x220_24_animating = false;
x1dc_ = zeus::CVector3f::skZero;
x1dc_alignPos = zeus::CVector3f::skZero;
x220_28_ = false;
x220_26_ = false;
}
@ -555,7 +556,7 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
SAdvancementResults results;
std::shared_ptr<IAnimReader> simplified;
if (x104_)
if (!x104_)
{
results = x1f8_animRoot->VAdvanceView(time);
simplified = x1f8_animRoot->VSimplified();
@ -587,14 +588,14 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
}
case EUserEventType::AlignTargetPos:
{
x1dc_ = zeus::CVector3f::skZero;
x1dc_alignPos = zeus::CVector3f::skZero;
x220_28_ = false;
x220_26_ = false;
break;
}
case EUserEventType::AlignTargetRot:
{
x1e8_ = zeus::CQuaternion::skNoRotation;
x1e8_alignRot = zeus::CQuaternion::skNoRotation;
x220_27_ = false;
break;
}
@ -606,11 +607,11 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
offset += results.x8_deltas.x0_posDelta;
if (x220_26_)
offset += x1dc_ * time;
offset += x1dc_alignPos * time;
zeus::CQuaternion rot = results.x8_deltas.xc_rotDelta * x1e8_;
zeus::CQuaternion rot = results.x8_deltas.xc_rotDelta * x1e8_alignRot;
quat = quat * rot;
x1dc_ = rot.transform(x1dc_);
x1dc_alignPos = rot.transform(x1dc_alignPos);
time = results.x0_remTime;
}

View File

@ -95,8 +95,8 @@ class CAnimData
zeus::CAABox x108_aabb;
CParticleDatabase x120_particleDB;
ResId x1d8_selfId;
zeus::CVector3f x1dc_;
zeus::CQuaternion x1e8_;
zeus::CVector3f x1dc_alignPos;
zeus::CQuaternion x1e8_alignRot;
std::shared_ptr<CAnimTreeNode> x1f8_animRoot;
std::shared_ptr<CTransitionManager> x1fc_transMgr;
@ -119,7 +119,7 @@ class CAnimData
bool x220_26_ : 1;
bool x220_27_ : 1;
bool x220_28_ : 1;
bool x220_29_ : 1;
bool x220_29_animationJustStarted : 1;
bool x220_30_poseBuilt : 1;
bool x220_31_poseCached : 1;
};

View File

@ -146,7 +146,7 @@ bool CCharAnimTime::operator <(const CCharAnimTime& other) const
{
if (m_type == Type::Infinity)
return m_time < 0.f && other.m_time > 0.f;
return m_time < 0.f;
return m_time < other.m_time;
}
}

View File

@ -350,6 +350,7 @@ CFBStreamedAnimReader::CFBStreamedAnimReader(const TSubAnimTypeToken<CFBStreamed
x7c_totals(source), x104_bitstreamData(source->GetBitstreamPointer()), x108_bitLoader(x104_bitstreamData),
x114_segIdToIndex(x7c_totals.x10_nextSel ? x7c_totals.x14_a : x7c_totals.x3c_b)
{
x7c_totals.SetTime(x108_bitLoader, CCharAnimTime());
PostConstruct(time);
}

View File

@ -7,6 +7,7 @@
#include "zeus/CQuaternion.hpp"
#include "CParticleData.hpp"
#include "CToken.hpp"
#include "CAllFormatsAnimSource.hpp"
namespace urde
{
@ -66,7 +67,41 @@ public:
};
template <class T>
using TSubAnimTypeToken = TLockedToken<T>;
class TSubAnimTypeToken : public TLockedToken<CAllFormatsAnimSource>
{
};
template <>
class TSubAnimTypeToken<CAnimSource> : public TLockedToken<CAllFormatsAnimSource>
{
public:
TSubAnimTypeToken<CAnimSource>(const TLockedToken<CAllFormatsAnimSource>& token)
: TLockedToken<CAllFormatsAnimSource>(token) {}
const CAnimSource* GetObj() const
{
const CAllFormatsAnimSource* source = TLockedToken<CAllFormatsAnimSource>::GetObj();
return &source->GetAsCAnimSource();
}
const CAnimSource* operator->() const {return GetObj();}
const CAnimSource& operator*() const {return *GetObj();}
};
template <>
class TSubAnimTypeToken<CFBStreamedCompression> : public TLockedToken<CAllFormatsAnimSource>
{
public:
TSubAnimTypeToken<CFBStreamedCompression>(const TLockedToken<CAllFormatsAnimSource>& token)
: TLockedToken<CAllFormatsAnimSource>(token) {}
const CFBStreamedCompression* GetObj() const
{
const CAllFormatsAnimSource* source = TLockedToken<CAllFormatsAnimSource>::GetObj();
return &source->GetAsCFBStreamedCompression();
}
const CFBStreamedCompression* operator->() const {return GetObj();}
const CFBStreamedCompression& operator*() const {return *GetObj();}
};
class IAnimReader
{

View File

@ -177,6 +177,9 @@ class CModel
boo::IGraphicsBufferS* m_ibo;
boo::IVertexFormat* m_vtxFmt;
u32 m_weightVecCount;
u32 m_skinBankCount;
public:
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;

View File

@ -619,7 +619,7 @@ std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx)
if (shaderIdx >= x18_matSets.size())
shaderIdx = 0;
return std::make_unique<CBooModel>(m_selfToken, &x8_surfaces, x18_matSets[shaderIdx],
m_vtxFmt, m_vbo, m_ibo, 0, 0, m_aabb);
m_vtxFmt, m_vbo, m_ibo, m_weightVecCount, m_skinBankCount, m_aabb);
}
CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* store, CObjectReference* selfRef)
@ -655,6 +655,8 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
athena::io::MemoryReader r(hmdlMetadata, hmdlSz);
hmdlMeta.read(r);
}
m_weightVecCount = hmdlMeta.weightCount;
m_skinBankCount = hmdlMeta.bankCount;
const u8* vboData = MemoryFromPartData(dataCur, secSizeCur);
const u8* iboData = MemoryFromPartData(dataCur, secSizeCur);

View File

@ -61,12 +61,12 @@ enum class EGameplayResult
class CGameGlobalObjects
{
CMemoryCardSys x0_memoryCardSys;
IFactory& x20_resFactory;
CSimplePool& x114_simplePool;
CCharacterFactoryBuilder x14c_charFactoryBuilder;
CAiFuncMap x188_aiFuncMap;
CGameState x1a8_gameState;
CInGameTweakManager x1c0_tweakManager;
IFactory& x4_resFactory;
CSimplePool& xcc_simplePool;
CCharacterFactoryBuilder xec_charFactoryBuilder;
CAiFuncMap x110_aiFuncMap;
CGameState x134_gameState;
CInGameTweakManager x150_tweakManager;
std::unique_ptr<CBooRenderer> m_renderer;
void LoadStringTable()
@ -82,21 +82,21 @@ class CGameGlobalObjects
public:
CGameGlobalObjects(IFactory& resFactory,
CSimplePool& objStore)
: x20_resFactory(resFactory), x114_simplePool(objStore)
: x4_resFactory(resFactory), xcc_simplePool(objStore)
{
g_MemoryCardSys = &x0_memoryCardSys;
g_ResFactory = &x20_resFactory;
g_SimplePool = &x114_simplePool;
g_CharFactoryBuilder = &x14c_charFactoryBuilder;
g_AiFuncMap = &x188_aiFuncMap;
g_GameState = &x1a8_gameState;
g_TweakManager = &x1c0_tweakManager;
g_ResFactory = &x4_resFactory;
g_SimplePool = &xcc_simplePool;
g_CharFactoryBuilder = &xec_charFactoryBuilder;
g_AiFuncMap = &x110_aiFuncMap;
g_GameState = &x134_gameState;
g_TweakManager = &x150_tweakManager;
}
void PostInitialize()
{
LoadStringTable();
m_renderer.reset(AllocateRenderer(x114_simplePool, x20_resFactory));
m_renderer.reset(AllocateRenderer(xcc_simplePool, x4_resFactory));
}
};

2
hecl

@ -1 +1 @@
Subproject commit 42679f2a3ae651a7c070688969a8a8430791256e
Subproject commit 29c77ef93ca9c5102c01e4f81ef3b5b7675150dd