#include "orconstraintextraction.h"
#define ORCONSTRAINTEXTRACTION__CLASS ORCONSTRAINTEXTRACTION__CLASSNAME
#define ORCONSTRAINTEXTRACTION__NAME "Extraction override"
#define ORCONSTRAINTEXTRACTION__LABEL "Extraction override"
#define ORCONSTRAINTEXTRACTION__DESC "Extraction override"
ORCONSTRAINTEXTRACTION__CLASS,
ORCONSTRAINTEXTRACTION__LABEL,
ORCONSTRAINTEXTRACTION__DESC,
bool ORConstraintExtraction::FBCreate()
{
Character.SetSingleConnect(true);
Character.SetFilter(FBCharacter::GetInternalClassId());
mReferenceGroup = ReferenceGroupAdd( "Goals", 0 );
HasLayout = true;
return true;
}
void ORConstraintExtraction::FBDestroy()
{
while(mNodes.GetCount())
{
delete mNodes.GetLast();
mNodes.RemoveLast();
}
}
void ORConstraintExtraction::SetupAllAnimationNodes()
{
if(Character.GetSrcCount() > 0)
{
FBCharacter* lCharacter = (FBCharacter*)Character.GetSrc(0);
FBCharacterMarkerSet* lMarkerSet = lCharacter ? lCharacter->GetCharacterMarkerSet() :
NULL;
if(lMarkerSet)
{
for(
int i = 0;
i < mNodes.GetCount();
i++)
{
mNodes[
i]->Setup(lCharacter,
this,
i);
}
}
}
}
void ORConstraintExtraction::RemoveAllAnimationNodes()
{
for(
int i = 0;
i < mNodes.GetCount();
i++)
{
}
}
{
if(
FBIS(pPlug, FBCharacter) )
{
FBCharacter* lCharacter = (FBCharacter*)pPlug;
if(pThis->GetHIObject() == Character.GetHIObject())
{
switch (pAction)
{
return lCharacter->GetCharacterize() && lCharacter->GetCharacterMarkerSet() !=
NULL;
Active = false;
ReferenceRemoveAll();
break;
for(
int i = 0;
i < mNodes.GetCount();
i++)
{
mNodes[
i]->ReferenceAdd(lCharacter,
this, mReferenceGroup);
}
break;
Active = false;
ReferenceRemoveAll();
break;
}
}
}
return true;
}
void ORConstraintExtraction::Node::ReferenceAdd(FBCharacter* pCharacter, FBConstraint* pConstraint, int pGroup)
{
FBModel* lStartGoalModel = pCharacter->GetGoalModel(mStartNode);
FBModel* lEndGoalModel = pCharacter->GetGoalModel(mEndNode);
if(lStartGoalModel && lEndGoalModel)
{
pConstraint->ReferenceAdd(pGroup,lStartGoalModel);
pConstraint->ReferenceAdd(pGroup,lEndGoalModel);
}
}
void ORConstraintExtraction::Node::Setup( FBCharacter* pCharacter, FBConstraint* pConstraint, int pIndex )
{
FBModel* lStartGoalModel = pCharacter->GetGoalModel(mStartNode);
FBModel* lEndGoalModel = pCharacter->GetGoalModel(mEndNode);
if(lStartGoalModel && lEndGoalModel)
{
pCharacter->GetTOffset(mStartNode, &lT_A);
pCharacter->GetTOffset(mEndNode, &lT_B);
mReadT = lEndGoalModel->Translation.GetAnimationNode();
}
}
void ORConstraintExtraction::Node::Solve(FBCharacter* pCharacter, FBConstraint* pConstraint, FBEvaluateInfo* pEvaluateInfo)
{
if(mReadT ==
NULL || mWriteT ==
NULL)
return;
FBModel* lStart = pCharacter->GetGoalModel(mStartNode);
FBModel* lEnd = pCharacter->GetGoalModel(mEndNode);
if(lStart && lEnd)
{
mReadT->ReadData(lT_B.mValue, pEvaluateInfo);
if(lCurrentLength > mLength)
{
FBMult(lV,lV,mLength/lCurrentLength);
mWriteT->WriteData(lT_B.mValue, pEvaluateInfo);
}
}
}
bool ORConstraintExtraction::AnimationNodeNotify(FBAnimationNode* pConnector,FBEvaluateInfo* pEvaluateInfo,FBConstraintInfo* pConstraintInfo)
{
if(Character.GetSrcCount() > 0)
{
FBCharacter* lCharacter = (FBCharacter*)Character.GetSrc(0);
for(
int i = 0;
i < mNodes.GetCount();
i++)
{
mNodes[
i]->Solve(lCharacter,
this, pEvaluateInfo);
}
}
AnimationNodesOutDisableIfNotWritten(pEvaluateInfo);
return true;
}
bool ORConstraintExtraction::FbxStore( FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat )
{
return true;
}
bool ORConstraintExtraction::FbxRetrieve( FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat )
{
return true;
}