constraints/CharacterSolver/HIK2016Solver/orcharactersolver_hik_manipulator.h

constraints/CharacterSolver/HIK2016Solver/orcharactersolver_hik_manipulator.h
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2015 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 __ORCHARACTERMANIPULATOR_H__
#define __ORCHARACTERMANIPULATOR_H__
//--- SDK include
#include <fbsdk/fbsdk.h>
#include "hikhostmb.h"
#define ORCHARACTERMANIPULATORCTRLSET__CLASSNAME ORCharacterManipulatorCtrlSet
class ORCharacterSolver_HIK;
class ORCharacterManipulatorCtrlSet : public FBCharacterManipulatorCtrlSet
{
//--- declaration
FBCharacterManipulatorCtrlSetDeclare( ORCharacterManipulatorCtrlSet, FBCharacterManipulatorCtrlSet );
public:
//--- Creation & Destruction
virtual bool FBCreate();
virtual void FBDestroy();
virtual FBManipulationGetResult TranslationIsEditable( bool &pEditable, FBReferencialType pRefType ) override;
// Manipulation Get/Set
virtual FBManipulationSetResult TranslationSet( FBTVector &pT, FBReferencialType pRefType, FBSetType pSetType, FBSetWhat pSetWhat ) override;
virtual FBManipulationGetResult TranslationGet( FBTVector &pT, FBReferencialType pRefType, FBManipPivot pPivot = FBManipPivotObjectTranslation ) override;
// Manipulation
virtual FBManipulationStartResult TranslationStartManipulation( FBReferencialType pRefType, const FBTime* pTime = NULL ) override;
virtual void TranslationStopManipulation () override;
//Rotation
virtual FBManipulationGetResult RotationIsEditable( bool &pEditable, FBReferencialType pRefType ) override;
/* Matrix Get/Set */
virtual FBManipulationSetResult RotationSet( FBMatrix &pRM, FBReferencialType pRefType, FBSetType pSetType, bool pOnlyRoot = false ) override;
virtual FBManipulationGetResult RotationGet( FBMatrix &pRM, FBReferencialType pRefType ) override;
/* Manipulation */
virtual FBManipulationStartResult RotationStartManipulation( FBReferencialType pRefType ) override;
virtual void RotationStopManipulation () override;
//Scaling
virtual FBManipulationGetResult ScalingIsEditable( bool &pEditable ) override;
// Manipulation Get/Set
virtual FBManipulationGetResult ScalingGet( FBSVector &pS, FBReferencialType pRefType ) override;
virtual FBManipulationSetResult ScalingSet( FBSVector &pS, FBReferencialType pRefType, FBSetType pSetType, FBSetWhat pSetWhat ) override;
// Manipulation
virtual FBManipulationStartResult ScalingStartManipulation( FBReferencialType pRefType ) override;
virtual void ScalingStopManipulation ();
// Called to Sync Rig and Character
virtual void SyncCharacter(FBEvaluateInfo *pEvalInfo) override; // Apply Solving and States
protected:
HIKCharacter* mHIKCharacter;
HIKCharacterHost<HIKHostNodeMB,HIKHostPropertyMB> mHIKCharacterHost;
HIKControlRigHost<HIKHostNodeMB> mHIKControlRigHost;
HIKControlRigHostEvaluator<HIKHostNodeMB,HIKHostPropertyMB> mHIKCurrentControlRigHostEvaluator;
HIKControlRigHostEvaluator<HIKHostNodeMB,HIKHostPropertyMB> mHIKInitialControlRigHostEvaluator; // Initial State is used to keep only some part when in BodyPart Manipulation Mode
HIKEvaluationState mCurrentState;
HIKEvaluationState mInitialState;
int mManipulatedEffectorsCount;
int mManipulatedEffectorIdArray[LastEffectorId];
bool mHIKUndoSetup;
void Translation_ApplyPivot( FBEffectorId &pEffectorId, int pHIKId, FBTVector &pGT, const FBQuaternion &pGQ, const FBVector4d &pGS );
void Rotation_ApplyPivot( FBEffectorId &pEffectorId, int pHIKId, FBTVector &pGT, const FBQuaternion &pGQ, const FBVector4d &pGS );
void Translation_LocalToGlobal(FBTVector &pGT, FBModel *pModel, const FBTVector &pLT, FBModelTransformationType pTransformType=kModelTransformation);
FBManipulationSetResult RotationSetEffectorGlobal( FBEffectorId &pEffectorIndex, const FBMatrix &pRM );
FBManipulationSetResult RotationSetEffectorLocal( FBEffectorId &pEffectorIndex, const FBMatrix &pRM );
FBManipulationSetResult RotationSetFKGlobal( FBModel *pModel, FBMatrix &pRM );
FBManipulationSetResult RotationSetFKLocal( FBModel *pModel, FBMatrix &pRM );
virtual void AllocateState(FBCharacter* pCharacter) override;
virtual void DeallocateState() override;
// helpers
int GetManipulationSolvingStep();
void AskSync(bool pForce = false);
void ApplySync(FBEvaluateInfo *pEvalInfo, bool pForce = false );
void RestoreInitialState();
bool IsDescendantPulling(FBEffectorId pEffectorId);
void SetResist(float pResist);
void SetBlendFact(float pFact);
void AddPostRotation(FBModel *pModel, FBMatrix &pMatrix);
void RemovePostRotation(FBModel *pModel, FBMatrix &pMatrix);
void AddPreRotation(FBModel *pModel, FBMatrix &pMatrix);
void RemovePreRotation(FBModel *pModel, FBMatrix &pmatrix);
void ManipulationStart(FBManipMode pManipMode, const FBTime *pTime=NULL);
void PrepareSetForManip(FBManipMode pManipMode, FBEvaluateInfo *pEvalInfo=NULL);
void CleanForManipulation();
bool NeedRotationSync(FBEffectorId pEffectorIndex,double pAngleTol);
void GetNormalizedLocalState( KHIKNodeState pDataSet[LastNodeId] ) const;
void SetNormalizedLocalState( KHIKNodeState pDataSet[LastNodeId] );
ORCharacterSolver_HIK* GetORCharacterSolver_HIK(FBCharacter* pCharacter=NULL);
HIKNodeId GetManipulatedHIKNodeId();
int GetManipulatedNodeExtraFKIndex();
int GetManipulatedNodeExtraBoneIndex();
bool IsManipulated_FK();
bool IsManipulated_IK();
FBEffectorId GetCorrespondingEffector();
};
#endif /* __ORCONSTRAINT_HIKBRIDGE_CONSTRAINT_H__ */