Various character imps

This commit is contained in:
Jack Andersen 2016-04-10 17:59:54 -10:00
parent fc6cb2ec33
commit 8242c3edda
41 changed files with 826 additions and 215 deletions

View File

@ -6,7 +6,7 @@ namespace urde
{ {
static logvisor::Module Log("URDE::ProjectManager"); static logvisor::Module Log("URDE::ProjectManager");
CToken ProjectResourcePool::GetObj(char const* name) CToken ProjectResourcePool::GetObj(const char* name)
{ {
CToken ret = CSimplePool::GetObj(name); CToken ret = CSimplePool::GetObj(name);
if (ret) if (ret)
@ -21,7 +21,7 @@ CToken ProjectResourcePool::GetObj(char const* name)
return {}; return {};
} }
CToken ProjectResourcePool::GetObj(char const* name, const CVParamTransfer& pvxfer) CToken ProjectResourcePool::GetObj(const char* name, const CVParamTransfer& pvxfer)
{ {
CToken ret = CSimplePool::GetObj(name, pvxfer); CToken ret = CSimplePool::GetObj(name, pvxfer);
if (ret) if (ret)

View File

@ -20,8 +20,8 @@ class ProjectResourcePool : public CSimplePool
public: public:
ProjectResourcePool(IFactory& factory, ProjectManager& parent) ProjectResourcePool(IFactory& factory, ProjectManager& parent)
: CSimplePool(factory), m_parent(parent) {} : CSimplePool(factory), m_parent(parent) {}
CToken GetObj(char const*); CToken GetObj(const char*);
CToken GetObj(char const*, const CVParamTransfer&); CToken GetObj(const char*, const CVParamTransfer&);
}; };
class ProjectManager class ProjectManager

View File

@ -9,7 +9,7 @@ class CCallStack
const char* x0_fileAndLineStr; const char* x0_fileAndLineStr;
const char* x4_typeStr; const char* x4_typeStr;
public: public:
CCallStack(char const* fileAndLineStr, char const* typeStr) CCallStack(const char* fileAndLineStr, const char* typeStr)
: x0_fileAndLineStr(fileAndLineStr), x4_typeStr(typeStr) {} : x0_fileAndLineStr(fileAndLineStr), x4_typeStr(typeStr) {}
const char* GetFileAndLineText() const {return x0_fileAndLineStr;} const char* GetFileAndLineText() const {return x0_fileAndLineStr;}
const char* GetTypeText() const {return x4_typeStr;} const char* GetTypeText() const {return x4_typeStr;}

View File

@ -30,12 +30,12 @@ CToken CSimplePool::GetObj(const SObjectTag& tag)
return GetObj(tag, x34_paramXfer); return GetObj(tag, x34_paramXfer);
} }
CToken CSimplePool::GetObj(char const* resourceName) CToken CSimplePool::GetObj(const char* resourceName)
{ {
return GetObj(resourceName, x34_paramXfer); return GetObj(resourceName, x34_paramXfer);
} }
CToken CSimplePool::GetObj(char const* resourceName, const CVParamTransfer& paramXfer) CToken CSimplePool::GetObj(const char* resourceName, const CVParamTransfer& paramXfer)
{ {
const SObjectTag* tag = x30_factory.GetResourceIdByName(resourceName); const SObjectTag* tag = x30_factory.GetResourceIdByName(resourceName);
if (!tag) if (!tag)

View File

@ -22,8 +22,8 @@ public:
CSimplePool(IFactory& factory); CSimplePool(IFactory& factory);
CToken GetObj(const SObjectTag&, const CVParamTransfer&); CToken GetObj(const SObjectTag&, const CVParamTransfer&);
CToken GetObj(const SObjectTag&); CToken GetObj(const SObjectTag&);
CToken GetObj(char const*); CToken GetObj(const char*);
CToken GetObj(char const*, const CVParamTransfer&); CToken GetObj(const char*, const CVParamTransfer&);
bool HasObject(const SObjectTag&) const; bool HasObject(const SObjectTag&) const;
bool ObjectIsLive(const SObjectTag&) const; bool ObjectIsLive(const SObjectTag&) const;
IFactory& GetFactory() const {return x30_factory;} IFactory& GetFactory() const {return x30_factory;}

View File

@ -1,11 +1,28 @@
#ifndef __PSHAG_CANIMTREEDOUBLECHILD_HPP__ #ifndef __PSHAG_CANIMTREEDOUBLECHILD_HPP__
#define __PSHAG_CANIMTREEDOUBLECHILD_HPP__ #define __PSHAG_CANIMTREEDOUBLECHILD_HPP__
#include "CAnimTreeNode.hpp"
namespace urde namespace urde
{ {
class CAnimTreeDoubleChild class CAnimTreeDoubleChild : public CAnimTreeNode
{ {
public:
void VAdvanceView(const CCharAnimTime& a);
void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const;
void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const;
void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const;
void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const;
void VGetBoolPOIState(const char*) const;
void VGetInt32POIState(const char*) const;
void VGetParticlePOIState(const char*) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
void VGetContributionOfHighestInfluence() const;
void VGetNumChildren() const;
void VGetBestUnblendedChild() const;
}; };
} }

View File

@ -8,6 +8,10 @@ namespace urde
class CAnimTreeNode : public IAnimReader class CAnimTreeNode : public IAnimReader
{ {
std::string x4_name;
public:
CAnimTreeNode(const std::string& name) : x4_name(name) {}
bool IsCAnimTreeNode() const {return true;}
}; };
} }

View File

@ -0,0 +1,97 @@
#include "CAnimTreeSingleChild.hpp"
namespace urde
{
CAnimTreeSingleChild::CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name)
: CAnimTreeNode(name)
{
}
void CAnimTreeSingleChild::VAdvanceView(const CCharAnimTime& a)
{
}
void CAnimTreeSingleChild::VGetTimeRemaining() const
{
}
bool CAnimTreeSingleChild::VHasOffset(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetOffset(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetRotation(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetBoolPOIList(const CCharAnimTime& time,
CBoolPOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetInt32POIList(const CCharAnimTime& time,
CInt32POINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetParticlePOIList(const CCharAnimTime& time,
CParticlePOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetSoundPOIList(const CCharAnimTime& time,
CSoundPOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetBoolPOIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetInt32POIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetParticlePOIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetSegStatementSet(const CSegIdList& list,
CSegStatementSet& setOut) const
{
}
void CAnimTreeSingleChild::VGetSegStatementSet(const CSegIdList& list,
CSegStatementSet& setOut,
const CCharAnimTime& time) const
{
}
void CAnimTreeSingleChild::VSetPhase(float)
{
}
SAdvancementResults
CAnimTreeSingleChild::VGetAdvancementResults(const CCharAnimTime& a,
const CCharAnimTime& b) const
{
}
void CAnimTreeSingleChild::Depth() const
{
}
void CAnimTreeSingleChild::VGetNumChildren() const
{
}
}

View File

@ -1,11 +1,35 @@
#ifndef __PSHAG_CANIMTREESINGLECHILD_HPP__ #ifndef __PSHAG_CANIMTREESINGLECHILD_HPP__
#define __PSHAG_CANIMTREESINGLECHILD_HPP__ #define __PSHAG_CANIMTREESINGLECHILD_HPP__
#include "CAnimTreeNode.hpp"
namespace urde namespace urde
{ {
class CAnimTreeSingleChild class CAnimTreeSingleChild : public CAnimTreeNode
{ {
std::shared_ptr<CAnimTreeNode> x14_child;
public:
CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name);
void VAdvanceView(const CCharAnimTime& a);
void VGetTimeRemaining() const;
bool VHasOffset(const CSegId& seg) const;
void VGetOffset(const CSegId& seg) const;
void VGetRotation(const CSegId& seg) const;
void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const;
void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const;
void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const;
void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const;
void VGetBoolPOIState(const char*) const;
void VGetInt32POIState(const char*) const;
void VGetParticlePOIState(const char*) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
void VGetNumChildren() const;
}; };
} }

View File

@ -1,11 +1,16 @@
#ifndef __PSHAG_CANIMTREETRANSITION_HPP__ #ifndef __PSHAG_CANIMTREETRANSITION_HPP__
#define __PSHAG_CANIMTREETRANSITION_HPP__ #define __PSHAG_CANIMTREETRANSITION_HPP__
#include "RetroTypes.hpp"
#include "CAnimTreeTweenBase.hpp"
namespace urde namespace urde
{ {
class CAnimTreeTransition class CAnimTreeTransition : public CAnimTreeTweenBase
{ {
public:
static std::string CreatePrimitiveName();
}; };
} }

View File

@ -1,10 +1,12 @@
#ifndef __PSHAG_CANIMTREETWEENBASE_HPP__ #ifndef __PSHAG_CANIMTREETWEENBASE_HPP__
#define __PSHAG_CANIMTREETWEENBASE_HPP__ #define __PSHAG_CANIMTREETWEENBASE_HPP__
#include "CAnimTreeDoubleChild.hpp"
namespace urde namespace urde
{ {
class CAnimTreeTweenBase class CAnimTreeTweenBase : public CAnimTreeDoubleChild
{ {
}; };

View File

@ -3,4 +3,332 @@
namespace urde namespace urde
{ {
CCharAnimTime CCharAnimTime::Infinity()
{
CCharAnimTime ret(1.f);
ret.m_type = Type::Infinity;
return ret;
}
bool CCharAnimTime::EqualsZero() const
{
if (m_type == Type::ZeroIncreasing || m_type == Type::ZeroSteady || m_type == Type::ZeroDecreasing)
return false;
return (m_time == 0.f);
}
bool CCharAnimTime::GreaterThanZero() const
{
if (EqualsZero())
return false;
return (m_time > 0.f);
}
bool CCharAnimTime::operator ==(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time == other.m_time;
return !other.EqualsZero();
}
if (EqualsZero())
{
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
return type == otherType;
}
return false;
}
if (other.m_type == Type::Infinity)
return m_time * other.m_time < 0.f;
return false;
}
bool CCharAnimTime::operator !=(const CCharAnimTime& other) const
{
return !(*this == other);
}
bool CCharAnimTime::operator>=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this > other);
}
bool CCharAnimTime::operator<=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this < other);
}
bool CCharAnimTime::operator >(const CCharAnimTime& other) const
{
return (!(*this == other) && !(*this < other));
}
bool CCharAnimTime::operator <(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time < other.m_time;
if (other.EqualsZero())
return m_time < 0.f;
else
return other.m_time > 0.f;
}
if (EqualsZero())
{
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
return type < otherType;
}
if (other.m_type == Type::NonZero)
return other.m_time > 0.f;
return other.m_time < 0.f;
}
else
{
if (m_type == Type::Infinity)
return m_time < 0.f && other.m_time > 0.f;
return m_time < 0.f;
}
}
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other)
{
*this = *this * other;
return *this;
}
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other)
{
*this = *this + other;
return *this;
}
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time + other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
type += otherType;
otherType = std::max(-1, std::min(type, 1));
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other)
{
*this = *this - other;
return *this;
}
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time == m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
{
CCharAnimTime ret(-other.m_time);
ret.m_type = Type::Infinity;
return ret;
}
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time - other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
CCharAnimTime ret;
type -= otherType;
if (type == -1)
ret.m_type = Type::ZeroDecreasing;
else if (type == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time * other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
type += otherType;
otherType = std::max(-1, std::min(type, 1));
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime CCharAnimTime::operator*(const float& other)
{
CCharAnimTime ret;
if (other == 0.f)
return ret;
if (!EqualsZero())
return CCharAnimTime(m_time * other);
if (other > 0.f)
return *this;
else if (other == 0.f)
return ret;
ret.m_type = m_type;
return ret;
}
float CCharAnimTime::operator/(const CCharAnimTime& other)
{
if (other.EqualsZero())
return 0.f;
return m_time / other.m_time;
}
} }

View File

@ -1,205 +1,47 @@
#ifndef __PSHAG_CCHARANIMTIME_HPP__ #ifndef __PSHAG_CCHARANIMTIME_HPP__
#define __PSHAG_CCHARANIMTIME_HPP__ #define __PSHAG_CCHARANIMTIME_HPP__
#include <algorithm>
namespace urde namespace urde
{ {
class CCharAnimTime class CCharAnimTime
{ {
float m_time = 0.f; float m_time = 0.f;
int m_unk = 2; // enum? enum class Type
{
NonZero,
ZeroIncreasing,
ZeroSteady,
ZeroDecreasing,
Infinity
} m_type = Type::ZeroSteady;
public: public:
CCharAnimTime() = default; CCharAnimTime() = default;
CCharAnimTime(float time) CCharAnimTime(float time)
: m_time(time), : m_time(time),
m_unk(m_time != 0.f ? 0 : 2) m_type(m_time != 0.f ? Type::NonZero : Type::ZeroSteady) {}
{
}
bool EqualsZero() const static CCharAnimTime Infinity();
{ operator float() const {return m_time;}
if (m_unk == 1 || m_unk == 2 || m_unk == 3)
return false;
return (m_time == 0.f); bool EqualsZero() const;
} bool GreaterThanZero() const;
bool operator ==(const CCharAnimTime& other) const;
bool GreaterThanZero() const bool operator !=(const CCharAnimTime& other) const;
{ bool operator>=(const CCharAnimTime& other);
if (EqualsZero()) bool operator<=(const CCharAnimTime& other);
return false; bool operator >(const CCharAnimTime& other) const;
return (m_time > 0.f); bool operator <(const CCharAnimTime& other) const;
} CCharAnimTime& operator*=(const CCharAnimTime& other);
#if 1 CCharAnimTime& operator+=(const CCharAnimTime& other);
bool operator ==(const CCharAnimTime& other) const CCharAnimTime operator+(const CCharAnimTime& other);
{ CCharAnimTime& operator-=(const CCharAnimTime& other);
return false; CCharAnimTime operator-(const CCharAnimTime& other);
} CCharAnimTime operator*(const CCharAnimTime& other);
CCharAnimTime operator*(const float& other);
bool operator !=(const CCharAnimTime& other) const float operator/(const CCharAnimTime& other);
{
return !(*this == other);
}
bool operator>=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this > other);
}
bool operator<=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this < other);
}
bool operator >(const CCharAnimTime& other) const
{
return false;
}
bool operator <(const CCharAnimTime& other) const
{
return false;
}
CCharAnimTime& operator*=(const CCharAnimTime& other)
{
*this = *this * other;
return *this;
}
CCharAnimTime& operator+=(const CCharAnimTime& other)
{
*this = *this + other;
return *this;
}
CCharAnimTime operator+(const CCharAnimTime& other)
{
if (m_unk == 4 && other.m_unk == 4)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_unk == 4)
return *this;
else if (other.m_unk == 4)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time + other.m_time);
int type = -1;
if (m_unk != 3)
{
if (m_unk != 2)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_unk != 3)
{
if (other.m_unk != 2)
otherType = 1;
else
otherType = 0;
}
type += otherType;
if (type < 1)
otherType = 1;
else
otherType = type;
if (otherType < -1)
otherType = -1;
CCharAnimTime ret;
if (otherType == -1)
ret.m_unk = 3;
else if (otherType == 0)
ret.m_unk = 2;
else
ret.m_unk = 1;
return ret;
}
CCharAnimTime operator*(const CCharAnimTime& other)
{
if (m_unk == 4 && other.m_unk == 4)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_unk == 4)
return *this;
else if (other.m_unk == 4)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time * other.m_time);
int type = -1;
if (m_unk != 3)
{
if (m_unk != 2)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_unk != 3)
{
if (other.m_unk != 2)
otherType = 1;
else
otherType = 0;
}
type += otherType;
if (type < 1)
otherType = 1;
else
otherType = type;
if (otherType < -1)
otherType = -1;
CCharAnimTime ret;
if (otherType == -1)
ret.m_unk = 3;
else if (otherType == 0)
ret.m_unk = 2;
else
ret.m_unk = 1;
return ret;
}
CCharAnimTime operator*(const float& other)
{
return CCharAnimTime();
}
float operator/(const CCharAnimTime& other)
{
if (other.EqualsZero())
return 0.f;
return m_time / other.m_time;
}
#endif
}; };
} }

View File

@ -53,4 +53,5 @@ add_library(RuntimeCommonCharacter
IAnimReader.hpp IAnimReader.cpp IAnimReader.hpp IAnimReader.cpp
CPrimitive.hpp CPrimitive.cpp CPrimitive.hpp CPrimitive.cpp
CHalfTransition.hpp CHalfTransition.cpp CHalfTransition.hpp CHalfTransition.cpp
CTimeScaleFunctions.hpp CTimeScaleFunctions.cpp
CBodyState.hpp) CBodyState.hpp)

View File

@ -1,10 +1,15 @@
#include "CMetaAnimBlend.hpp" #include "CMetaAnimBlend.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde namespace urde
{ {
CMetaAnimBlend::CMetaAnimBlend(CInputStream& in) CMetaAnimBlend::CMetaAnimBlend(CInputStream& in)
{ {
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
xc_blend = in.readFloatBig();
x10_ = in.readBool();
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>

View File

@ -9,6 +9,10 @@ namespace urde
class CMetaAnimBlend : public IMetaAnim class CMetaAnimBlend : public IMetaAnim
{ {
std::shared_ptr<IMetaAnim> x4_animA;
std::shared_ptr<IMetaAnim> x8_animB;
float xc_blend;
bool x10_;
public: public:
CMetaAnimBlend(CInputStream& in); CMetaAnimBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Blend;} EMetaAnimType GetType() const {return EMetaAnimType::Blend;}

View File

@ -1,10 +1,15 @@
#include "CMetaAnimPhaseBlend.hpp" #include "CMetaAnimPhaseBlend.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde namespace urde
{ {
CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in) CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in)
{ {
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
xc_blend = in.readFloatBig();
x10_ = in.readBool();
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>

View File

@ -9,6 +9,10 @@ namespace urde
class CMetaAnimPhaseBlend : public IMetaAnim class CMetaAnimPhaseBlend : public IMetaAnim
{ {
std::shared_ptr<IMetaAnim> x4_animA;
std::shared_ptr<IMetaAnim> x8_animB;
float xc_blend;
bool x10_;
public: public:
CMetaAnimPhaseBlend(CInputStream& in); CMetaAnimPhaseBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::PhaseBlend;} EMetaAnimType GetType() const {return EMetaAnimType::PhaseBlend;}

View File

@ -4,8 +4,7 @@ namespace urde
{ {
CMetaAnimPlay::CMetaAnimPlay(CInputStream& in) CMetaAnimPlay::CMetaAnimPlay(CInputStream& in)
{ : x4_primitive(in), x1c_(in.readFloatBig()), x20_(in.readUint32Big()) {}
}
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::GetAnimationTree(const CAnimSysContext& animSys, CMetaAnimPlay::GetAnimationTree(const CAnimSysContext& animSys,

View File

@ -2,6 +2,7 @@
#define __PSHAG_CMETAANIMPLAY_HPP__ #define __PSHAG_CMETAANIMPLAY_HPP__
#include "IMetaAnim.hpp" #include "IMetaAnim.hpp"
#include "CPrimitive.hpp"
#include "IOStreams.hpp" #include "IOStreams.hpp"
namespace urde namespace urde
@ -9,6 +10,9 @@ namespace urde
class CMetaAnimPlay : public IMetaAnim class CMetaAnimPlay : public IMetaAnim
{ {
CPrimitive x4_primitive;
float x1c_;
u32 x20_;
public: public:
CMetaAnimPlay(CInputStream& in); CMetaAnimPlay(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Primitive;} EMetaAnimType GetType() const {return EMetaAnimType::Primitive;}

View File

@ -1,12 +1,27 @@
#include "CMetaAnimRandom.hpp" #include "CMetaAnimRandom.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde namespace urde
{ {
CMetaAnimRandom::CMetaAnimRandom(CInputStream& in) CMetaAnimRandom::RandomData CMetaAnimRandom::CreateRandomData(CInputStream& in)
{ {
CMetaAnimRandom::RandomData ret;
u32 randCount = in.readUint32Big();
ret.reserve(randCount);
for (u32 i=0 ; i<randCount ; ++i)
{
std::shared_ptr<IMetaAnim> metaAnim = CMetaAnimFactory::CreateMetaAnim(in);
ret.emplace_back(std::move(metaAnim), in.readUint32Big());
}
return ret;
} }
CMetaAnimRandom::CMetaAnimRandom(CInputStream& in)
: x4_randomData(CreateRandomData(in)) {}
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaAnimRandom::GetAnimationTree(const CAnimSysContext& animSys, CMetaAnimRandom::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const

View File

@ -9,6 +9,9 @@ namespace urde
class CMetaAnimRandom : public IMetaAnim class CMetaAnimRandom : public IMetaAnim
{ {
using RandomData = std::vector<std::pair<std::shared_ptr<IMetaAnim>, u32>>;
RandomData x4_randomData;
static RandomData CreateRandomData(CInputStream& in);
public: public:
CMetaAnimRandom(CInputStream& in); CMetaAnimRandom(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Random;} EMetaAnimType GetType() const {return EMetaAnimType::Random;}

View File

@ -1,12 +1,24 @@
#include "CMetaAnimSequence.hpp" #include "CMetaAnimSequence.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde namespace urde
{ {
CMetaAnimSequence::CMetaAnimSequence(CInputStream& in) std::vector<std::shared_ptr<IMetaAnim>> CMetaAnimSequence::CreateSequence(CInputStream& in)
{ {
std::vector<std::shared_ptr<IMetaAnim>> ret;
u32 seqCount = in.readUint32Big();
ret.reserve(seqCount);
for (u32 i=0 ; i<seqCount ; ++i)
ret.push_back(std::move(CMetaAnimFactory::CreateMetaAnim(in)));
return ret;
} }
CMetaAnimSequence::CMetaAnimSequence(CInputStream& in)
: x4_sequence(CreateSequence(in)) {}
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::GetAnimationTree(const CAnimSysContext& animSys, CMetaAnimSequence::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const

View File

@ -9,6 +9,8 @@ namespace urde
class CMetaAnimSequence : public IMetaAnim class CMetaAnimSequence : public IMetaAnim
{ {
std::vector<std::shared_ptr<IMetaAnim>> x4_sequence;
std::vector<std::shared_ptr<IMetaAnim>> CreateSequence(CInputStream& in);
public: public:
CMetaAnimSequence(CInputStream& in); CMetaAnimSequence(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Sequence;} EMetaAnimType GetType() const {return EMetaAnimType::Sequence;}

View File

@ -20,7 +20,7 @@ std::shared_ptr<IMetaTrans> CMetaTransFactory::CreateMetaTrans(CInputStream& in)
case EMetaTransType::PhaseTrans: case EMetaTransType::PhaseTrans:
return std::make_shared<CMetaTransPhaseTrans>(in); return std::make_shared<CMetaTransPhaseTrans>(in);
case EMetaTransType::Snap: case EMetaTransType::Snap:
return std::make_shared<CMetaTransSnap>(in); return std::make_shared<CMetaTransSnap>();
default: break; default: break;
} }

View File

@ -1,11 +1,11 @@
#include "CMetaTransMetaAnim.hpp" #include "CMetaTransMetaAnim.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde namespace urde
{ {
CMetaTransMetaAnim::CMetaTransMetaAnim(CInputStream& in) CMetaTransMetaAnim::CMetaTransMetaAnim(CInputStream& in)
{ : x4_metaAnim(CMetaAnimFactory::CreateMetaAnim(in)) {}
}
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaTransMetaAnim::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a, CMetaTransMetaAnim::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,

View File

@ -2,6 +2,7 @@
#define __PSHAG_CMETATRANSMETAANIM_HPP__ #define __PSHAG_CMETATRANSMETAANIM_HPP__
#include "IMetaTrans.hpp" #include "IMetaTrans.hpp"
#include "IMetaAnim.hpp"
#include "IOStreams.hpp" #include "IOStreams.hpp"
namespace urde namespace urde
@ -9,6 +10,7 @@ namespace urde
class CMetaTransMetaAnim : public IMetaTrans class CMetaTransMetaAnim : public IMetaTrans
{ {
std::shared_ptr<IMetaAnim> x4_metaAnim;
public: public:
CMetaTransMetaAnim(CInputStream& in); CMetaTransMetaAnim(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::MetaAnim;} EMetaTransType GetType() const {return EMetaTransType::MetaAnim;}

View File

@ -5,6 +5,11 @@ namespace urde
CMetaTransPhaseTrans::CMetaTransPhaseTrans(CInputStream& in) CMetaTransPhaseTrans::CMetaTransPhaseTrans(CInputStream& in)
{ {
x4_ = in.readFloatBig();
x8_ = in.readUint32Big();
xc_ = in.readBool();
xd_ = in.readBool();
x10_ = in.readUint32Big();
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>

View File

@ -9,6 +9,11 @@ namespace urde
class CMetaTransPhaseTrans : public IMetaTrans class CMetaTransPhaseTrans : public IMetaTrans
{ {
float x4_;
u32 x8_;
bool xc_;
bool xd_;
u32 x10_;
public: public:
CMetaTransPhaseTrans(CInputStream& in); CMetaTransPhaseTrans(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::PhaseTrans;} EMetaTransType GetType() const {return EMetaTransType::PhaseTrans;}

View File

@ -3,15 +3,12 @@
namespace urde namespace urde
{ {
CMetaTransSnap::CMetaTransSnap(CInputStream& in)
{
}
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaTransSnap::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a, CMetaTransSnap::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const const CAnimSysContext& animSys) const
{ {
return b.lock();
} }
} }

View File

@ -10,7 +10,6 @@ namespace urde
class CMetaTransSnap : public IMetaTrans class CMetaTransSnap : public IMetaTrans
{ {
public: public:
CMetaTransSnap(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::Snap;} EMetaTransType GetType() const {return EMetaTransType::Snap;}
std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a, std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,

View File

@ -1,10 +1,16 @@
#include "CMetaTransTrans.hpp" #include "CMetaTransTrans.hpp"
#include "CAnimTreeTransition.hpp"
namespace urde namespace urde
{ {
CMetaTransTrans::CMetaTransTrans(CInputStream& in) CMetaTransTrans::CMetaTransTrans(CInputStream& in)
{ {
x4_ = in.readFloatBig();
x8_ = in.readUint32Big();
xc_ = in.readBool();
xd_ = in.readBool();
x10_ = in.readUint32Big();
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
@ -12,6 +18,7 @@ CMetaTransTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const const CAnimSysContext& animSys) const
{ {
} }
} }

View File

@ -9,6 +9,11 @@ namespace urde
class CMetaTransTrans : public IMetaTrans class CMetaTransTrans : public IMetaTrans
{ {
float x4_;
u32 x8_;
bool xc_;
bool xd_;
u32 x10_;
public: public:
CMetaTransTrans(CInputStream& in); CMetaTransTrans(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::Trans;} EMetaTransType GetType() const {return EMetaTransType::Trans;}

View File

@ -0,0 +1,13 @@
#include "CPrimitive.hpp"
namespace urde
{
CPrimitive::CPrimitive(CInputStream& in)
{
x0_animId = in.readUint32Big();
x4_animIdx = in.readUint32Big();
x8_animName = in.readString();
}
}

View File

@ -1,11 +1,18 @@
#ifndef __PSHAG_CPRIMITIVE_HPP__ #ifndef __PSHAG_CPRIMITIVE_HPP__
#define __PSHAG_CPRIMITIVE_HPP__ #define __PSHAG_CPRIMITIVE_HPP__
#include "IOStreams.hpp"
namespace urde namespace urde
{ {
class CPrimitive class CPrimitive
{ {
TResId x0_animId;
u32 x4_animIdx;
std::string x8_animName;
public:
CPrimitive(CInputStream& in);
}; };
} }

View File

@ -0,0 +1,80 @@
#include "CTimeScaleFunctions.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
std::shared_ptr<IVaryingAnimationTimeScale> IVaryingAnimationTimeScale::Clone() const
{
return VClone();
}
void CConstantAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
}
void CConstantAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
}
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
}
std::shared_ptr<IVaryingAnimationTimeScale>
CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
{
}
void CLinearAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
}
void CLinearAnimationTimeScale::TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
const float&, const float&)
{
}
void CLinearAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
}
void CLinearAnimationTimeScale::FindUpperLimitFromRoot(const CFunctionDescription& desc,
const float&, const float&)
{
}
std::shared_ptr<IVaryingAnimationTimeScale> CLinearAnimationTimeScale::VClone() const
{
CCharAnimTime timeA(x10_);
CCharAnimTime timeB(xc_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
float f30 = x4_ * xc_ + x8_;
ret->x4_ = (x4_ * x10_ + x8_ - f30) / timeB;
ret->x8_ = -((x4_ * x10_ + x8_ - f30) / (timeA - timeB) * timeB - f30);
ret->xc_ = timeB;
ret->x10_ = timeA;
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
std::shared_ptr<IVaryingAnimationTimeScale>
CLinearAnimationTimeScale::VGetFunctionMirrored(const float& parm) const
{
float f27 = -(x4_ * parm * 2.f - x8_);
float f31 = -x4_ * parm * 2.f - x10_ + f27;
CCharAnimTime timeA(2.f * parm - xc_);
CCharAnimTime timeB(2.f * parm - x10_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
ret->x4_ = (-x4_ * 2.f * parm - xc_ + f27 - f31) / (timeA - timeB);
ret->x8_ = -(((-x4_ * 2.f * parm - xc_ + f27 - f31) / (timeA - timeB)) * timeB - f31);
ret->xc_ = timeB;
ret->x10_ = timeA;
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
}

View File

@ -0,0 +1,59 @@
#ifndef __PSHAG_CTIMESCALEFUNCTIONS_HPP__
#define __PSHAG_CTIMESCALEFUNCTIONS_HPP__
#include "RetroTypes.hpp"
namespace urde
{
enum class EVaryingAnimationTimeScaleType
{
Constant,
Linear
};
class IVaryingAnimationTimeScale
{
public:
virtual ~IVaryingAnimationTimeScale() = default;
virtual EVaryingAnimationTimeScaleType GetType() const=0;
virtual void VTimeScaleIntegral(const float&, const float&) const=0;
virtual void VFindUpperLimit(const float&, const float&) const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VClone() const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const=0;
std::shared_ptr<IVaryingAnimationTimeScale> Clone() const;
};
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
{
public:
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Constant;}
void VTimeScaleIntegral(const float&, const float&) const;
void VFindUpperLimit(const float&, const float&) const;
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
};
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
{
float x4_;
float x8_;
float xc_;
float x10_;
public:
struct CFunctionDescription
{
};
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Linear;}
void VTimeScaleIntegral(const float&, const float&) const;
void TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc, const float&, const float&);
void VFindUpperLimit(const float&, const float&) const;
void FindUpperLimitFromRoot(const CFunctionDescription& desc, const float&, const float&);
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
};
}
#endif // __PSHAG_CTIMESCALEFUNCTIONS_HPP__

View File

@ -0,0 +1,14 @@
#include "IAnimReader.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
SAdvancementResults IAnimReader::VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const
{
SAdvancementResults ret;
ret.x0_animTime = a;
return ret;
}
}

View File

@ -1,11 +1,56 @@
#ifndef __PSHAG_IANIMREADER_HPP__ #ifndef __PSHAG_IANIMREADER_HPP__
#define __PSHAG_IANIMREADER_HPP__ #define __PSHAG_IANIMREADER_HPP__
#include "RetroTypes.hpp"
#include "CCharAnimTime.hpp"
#include "zeus/CVector3f.hpp"
#include "zeus/CQuaternion.hpp"
namespace urde namespace urde
{ {
class CSegId;
class CBoolPOINode;
class CInt32POINode;
class CParticlePOINode;
class CSoundPOINode;
class CSegIdList;
class CSegStatementSet;
struct SAdvancementResults
{
CCharAnimTime x0_animTime;
zeus::CVector3f x8_posDelta;
zeus::CQuaternion x14_rotDelta;
};
class IAnimReader class IAnimReader
{ {
public:
virtual ~IAnimReader() = default;
virtual bool IsCAnimTreeNode() const {return false;}
virtual void VAdvanceView(const CCharAnimTime& a)=0;
virtual void VGetTimeRemaining() const=0;
virtual void VGetSteadyStateAnimInfo() const=0;
virtual bool VHasOffset(const CSegId& seg) const=0;
virtual void VGetOffset(const CSegId& seg) const=0;
virtual void VGetRotation(const CSegId& seg) const=0;
virtual void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const=0;
virtual void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const=0;
virtual void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const=0;
virtual void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const=0;
virtual void VGetBoolPOIState(const char*) const=0;
virtual void VGetInt32POIState(const char*) const=0;
virtual void VGetParticlePOIState(const char*) const=0;
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const=0;
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const=0;
virtual void VClone() const=0;
virtual std::unique_ptr<IAnimReader> VSimplified() {return {};}
virtual void VSetPhase(float)=0;
virtual SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
virtual void Depth() const=0;
virtual void VGetContributionOfHighestInfluence() const=0;
virtual void VGetNumChildren() const=0;
virtual void VGetBestUnblendedChild() const=0;
}; };
} }

View File

@ -13,7 +13,7 @@ enum class EMetaTransType
MetaAnim, MetaAnim,
Trans, Trans,
PhaseTrans, PhaseTrans,
Snap, Snap
}; };
class IMetaTrans class IMetaTrans

View File

@ -13,8 +13,8 @@ class IObjectStore
public: public:
virtual CToken GetObj(const SObjectTag&, const CVParamTransfer&)=0; virtual CToken GetObj(const SObjectTag&, const CVParamTransfer&)=0;
virtual CToken GetObj(const SObjectTag&)=0; virtual CToken GetObj(const SObjectTag&)=0;
virtual CToken GetObj(char const*)=0; virtual CToken GetObj(const char*)=0;
virtual CToken GetObj(char const*, const CVParamTransfer&)=0; virtual CToken GetObj(const char*, const CVParamTransfer&)=0;
virtual bool HasObject(const SObjectTag&) const=0; virtual bool HasObject(const SObjectTag&) const=0;
virtual bool ObjectIsLive(const SObjectTag&) const=0; virtual bool ObjectIsLive(const SObjectTag&) const=0;
virtual IFactory& GetFactory() const=0; virtual IFactory& GetFactory() const=0;