constraints/CharacterSolver/HIK2013Solver/orcharactersolver_hik.h

constraints/CharacterSolver/HIK2013Solver/orcharactersolver_hik.h
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2012 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
#ifndef __ORCONSTRAINT_HIKBRIDGE_CONSTRAINT_H__
#define __ORCONSTRAINT_HIKBRIDGE_CONSTRAINT_H__
//--- SDK include
#include <fbsdk/fbsdk.h>
#include "hikhostmb.h"
#include "orcharactersolver_hik_manipulator.h"
#include "charactersolverdefinition.h"
/*
Character Constraint
what is not supported yet:
- No support for Align Control Rig
- No Support for Double Evaluation
- No Support for Output Control Rig
- Character Poses still use internal Evaluation
- Story still doing an Internal Retargeting on the Character
what will not be supported:
- MB 5.5 Old Limits.
*/
#define ORCONSTRAINTHIK__CLASS ORCharacterSolver_HIK
class ORCharacterSolver_HIK : public FBCharacterSolver, public MultiState
{
//--- declaration
FBCharacterSolverDeclare( ORCharacterSolver_HIK, FBCharacterSolver );
public:
//--- Creation & Destruction
virtual bool FBCreate();
virtual void FBDestroy();
// callback
//void EventConnectionNotify(HISender pSender,HKEvent pEvent);
//--- Animation node management
virtual void RemoveAllAnimationNodes();
virtual void SetupAllAnimationNodes();
virtual void FreezeSuggested ();
virtual bool AnimationNodeNotify ( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo, FBConstraintInfo* pConstraintInfo );
//--- FBX Interface
virtual bool FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
virtual bool FbxRetrieve ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
virtual double GetCharacterSolverVersion() override { return 4.5; };
HIKEvaluationState* EvaluationStateCreator();
bool mAlreadyConnected;
void EventListen( HISender pSender, HKEvent pEvent );
void EventSuspend( HISender pSender, HKEvent pEvent );
void ConnectionNotify(HISender /*pSender*/, HKEvent pEvent);
int SolvingStepFilter;
FBSystem mSystem;
FBApplication mApplication;
FBPropertyAnimatableDouble ExtraCollarRatio;
FBPropertyAnimatableDouble CollarStiffnessX;
FBPropertyAnimatableDouble CollarStiffnessY;
FBPropertyAnimatableDouble CollarStiffnessZ;
FBPropertyAnimatableDouble ReachLeftShoulder;
FBPropertyAnimatableDouble ReachRightShoulder;
// new in 4.0
FBPropertyBool FingerSolvingPropagation;
FBPropertyAnimatableDouble RealisticLeftKneeSolving;
FBPropertyAnimatableDouble RealisticRightKneeSolving;
// SnS
FBPropertyAnimatableDouble StretchStartArmsAndLegs;
FBPropertyAnimatableDouble StretchStopArmsAndLegs;
FBPropertyAnimatableDouble SnSScaleArmsAndLegs;
FBPropertyAnimatableDouble SnSReachLeftWrist;
FBPropertyAnimatableDouble SnSReachRightWrist;
FBPropertyAnimatableDouble SnSReachLeftAnkle;
FBPropertyAnimatableDouble SnSReachRightAnkle;
FBPropertyAnimatableDouble SnSScaleSpineChildren;
FBPropertyAnimatableDouble SnSSpineFreedom;
FBPropertyAnimatableDouble SnSReachChestEnd;
FBPropertyAnimatableDouble SnSNeckFreedom;
//HIK
HIKCharacter* mHIKCharacter;
HIKCharacterHost<HIKHostNodeMB,HIKHostPropertyMB> mHIKCharacterHost;
HIKCharacter* mHIKCharacterSrc;
HIKCharacterHost<HIKHostNodeMB,HIKHostPropertyMB> mHIKCharacterHostSrc;
HIKControlRigHost<HIKHostNodeMB> mHIKControlRigHost;
HIKCharacter* mHIKActorSrc;
FBActor* mActorSrc;
HIKEffectorSetState* mHIKEffectorSetStatePlot;
HIKCharacterState* mHIKCharacterStateStance;
HIKCharacter* mHIKCharacterDebug;
HIKCharacterHost<HIKHostNodeMB,HIKHostPropertyMB> mHIKCharacterHostDebug;
HIKCharacterState* mHIKCharacterStateDebug;
HIKCharacterState* mHIKCharacterStateOutDebug;
HIKEffectorSetState* mHIKEffectorSetStateDebug;
HIKPropertySetState* mHIKPropertySetStateDebug;
HIKControlRigHostEvaluator<HIKHostNodeMB,HIKHostPropertyMB> mHIKControlRigHostEvaluator;
HIKCharacterHostEvaluator<HIKHostNodeMB,HIKHostPropertyMB> mHIKCharacterHostEvaluator;
void SetupTargetCharacter(FBCharacter* pCharacter);
void SetupInputControlRig(FBControlSet* pControlRig, bool pConstraintRig = false );
void SetupExtraFK(FBCharacter* pCharacter, int pExtraBoneId, FBModelMarker** pExtraMarker);
void SetupAutoProperties(FBCharacter* pCharacter);
FBArrayTemplate<FBAnimationNode*> mAutoPropertyConnArray;
//Manipulator
virtual FBCharacterManipulatorCtrlSet* CreateCharacterManipulatorCtrlSet(const char* pName);
FBCharacterManipulatorCtrlSet * mControlSetManipulator;
//Pivot
void SyncPivot(FBControlSet* pControlSet);
// Exposing Extra FK and Skeleton
virtual int GetExtraFKCount();
virtual const char* GetExtraFKNameAt(int pIndex);
virtual FBBodyPartId GetExtraFKBodyPartAt(int pIndex);
virtual int GetExtraBoneCount();
virtual const char* GetExtraBoneNameAt(int pIndex);
virtual FBBodyPartId GetExtraBoneBodyPartAt(int pIndex);
// Pose support
virtual void CharacterPasteState( FBCharacter* pFromCharacter, FBCharacterPose* pPose, FBCharacterPoseOptions& pCharacterPoseOptions );
void DoPasteCharacter(HIKCharacter* pHIKFromCharacter, HIKCharacterState* pFromCharacterState, HIKPropertySetState* pFromPropertySetState, HIKEvaluationState* pCurrentState, FBCharacterPoseKeyingMode pKeyingMode, FBMatrix* pHipsOffsetGX);
void DoPasteCharacterExtension(FBCharacterPose* pPose, FBCharacterPoseOptions& pCharacterPoseOptions, HIKEvaluationState* pCurrentState);
void DoPasteForBodyPart(HIKEvaluationState* pCurrentState, HIKCharacterState* pPoseState);
void RegisterExtraProperties(HIKCharacterHost<HIKHostNodeMB,HIKHostPropertyMB> &pHIKCharacterHost);
// Reset solver extra properties
virtual void ResetExtraProperties() override;
private:
static int mInternalPropertiesCount; //Used to determine the properties defined specifically in this class(not inherited from parent classes) upon creation,
static int mSolverPropertiesCount; //i.e., number of 'solver-specific' properties = mSolverPropertiesCount - mInternalPropertiesCount
// Pose support
void PastePoseToTempHikCharacter( FBCharacter* pFromCharacter, FBCharacterPose* pPose, FBCharacterPoseOptions& pCharacterPoseOptions, HIKEvaluationState* pCurrentState, // inputs
HIKCharacter*& pHIKFromCharacter, HIKCharacterState*& pFromCharacterState, HIKPropertySetState*& pFromPropertySetState); // outputs
void GetTRSForMatchModel_Body(FBCharacterPoseOptions& pCharacterPoseOptions, HIKCharacter* pHIKFromCharacter, HIKCharacterState* pFromCharacterState, HIKPropertySetState* pFromPropertySetState, HIKEvaluationState* pCurrentState,
FBMatrix* pHipsOffsetGX, int pHIKNodeId, int pHIKEffectorId, FBEffectorId pEffectorId, int pPivotIndex, FBMatrix* pValue);
void GetTRSForMatchModel_Extension( FBCharacterPose* pPose, FBModel* pMatchModel, FBMatrix& pExtensionTRS );
void GetNodeEffectIds( FBModel* pModelToMatch, int& pHIKNodeId, int& pHIKEffectorId, FBEffectorId& pEffectorId, FBEffectorSetID& pPivotIndex );
void GetRotationOffset( const FBMatrix& pMatchModel_CurrentGRM, const FBMatrix& pMatchMode_PoseTRSM, const bool pGravity, FBMatrix& pHipsOffsetGX );
void GetTranslationOffset( const FBVector3d& pMatchModel_CurrentGT, const FBMatrix& pMatchMode_PoseTRSM, bool pMatchX, bool pMatchY, bool pMatchZ, bool pGravity, FBMatrix& pHipsOffsetGX );
//Initialize properties with default values
void ResetPropertiesToDefault();
//Clears animation for the properties defined in this class(excludes those defined in the parent classes)
void RemoveAnimations();
// Leave it here for testing purpose
//void PrintTargetCharacter( const char* pName );
//void PrintState( const char* pName, HIKCharacter* pCharacter, HIKCharacterState* pState );
};
#endif /* __ORCONSTRAINT_HIKBRIDGE_CONSTRAINT_H__ */