Fixed animation loader bug, added CBoneTransformData to separate animation transforms away from CSkeleton, added skeleton raycasting, added a bunch of animation playback controls to the character editor

This commit is contained in:
parax0
2016-04-10 06:49:42 -06:00
parent dfdbed24c4
commit feace9e38c
23 changed files with 508 additions and 98 deletions

View File

@@ -4,8 +4,9 @@
CCharacterNode::CCharacterNode(CScene *pScene, u32 NodeID, CAnimSet *pChar /*= 0*/, CSceneNode *pParent /*= 0*/)
: CSceneNode(pScene, NodeID, pParent)
, mAnimTime(0.f)
{
SetCharacter(pChar);
SetCharSet(pChar);
}
ENodeType CCharacterNode::NodeType()
@@ -36,31 +37,53 @@ void CCharacterNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, const
{
CSkeleton *pSkel = mpCharacter->NodeSkeleton(mActiveCharSet);
CAnimation *pAnim = mpCharacter->Animation(mActiveAnim);
pSkel->UpdateTransform(pAnim, (float) CTimer::GlobalTime(), false);
pSkel->Draw(Options);
pSkel->UpdateTransform(mTransformData, pAnim, mAnimTime, false);
pSkel->Draw(Options, mTransformData);
}
SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)
SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)
{
// Not currently doing any ray checks on character nodes so don't care about this right now.
// Check for bone under ray. Doesn't check for model intersections atm
if (mpCharacter)
{
CSkeleton *pSkel = mpCharacter->NodeSkeleton(mActiveCharSet);
if (pSkel)
{
std::pair<s32,float> Hit = pSkel->RayIntersect(rkRay, mTransformData);
if (Hit.first != -1)
{
SRayIntersection Intersect;
Intersect.Hit = true;
Intersect.ComponentIndex = Hit.first;
Intersect.Distance = Hit.second;
Intersect.HitPoint = rkRay.PointOnRay(Hit.second);
Intersect.pNode = this;
return Intersect;
}
}
}
return SRayIntersection();
}
void CCharacterNode::SetCharacter(CAnimSet *pChar)
void CCharacterNode::SetCharSet(CAnimSet *pChar)
{
mpCharacter = pChar;
SetActiveCharSet(0);
SetActiveChar(0);
if (!mpCharacter)
mLocalAABox = CAABox::skOne;
}
void CCharacterNode::SetActiveCharSet(u32 CharIndex)
void CCharacterNode::SetActiveChar(u32 CharIndex)
{
mActiveCharSet = CharIndex;
if (mpCharacter)
{
mTransformData.ResizeToSkeleton(mpCharacter->NodeSkeleton(CharIndex));
mLocalAABox = mpCharacter->NodeModel(CharIndex)->AABox();
MarkTransformChanged();
}
@@ -70,3 +93,8 @@ void CCharacterNode::SetActiveAnim(u32 AnimIndex)
{
mActiveAnim = AnimIndex;
}
void CCharacterNode::SetAnimTime(float Time)
{
mAnimTime = Time;
}