Open Reality Reference Guide
fbconstraint.h
Go to the documentation of this file.
1 #ifndef __FBCONSTRAINT_H__
2 #define __FBCONSTRAINT_H__
3 /**************************************************************************
4  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5  All Rights Reserved.
6 
7  The coded instructions, statements, computer programs, and/or related
8  material (collectively the "Data") in these files contain unpublished
9  information proprietary to Autodesk, Inc. and/or its licensors, which is
10  protected by Canada and United States of America federal copyright law
11  and by international treaties.
12 
13  The Data may not be disclosed or distributed to third parties, in whole
14  or in part, without the prior written consent of Autodesk, Inc.
15  ("Autodesk").
16 
17  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24  FREE.
25 
26  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
45 #include <kaydaradef.h>
46 #ifndef FBSDK_DLL
50  #define FBSDK_DLL K_DLLIMPORT
51 #endif
52 
53 #include <fbsdk/fbcomponent.h>
54 #include <fbsdk/fbcore.h>
55 
56 #ifdef FBSDKUseNamespace
57  namespace FBSDKNamespace {
58 #endif
59 
60 FB_DEFINE_COMPONENT( FBSDK_DLL, Constraint );
61 
69 #define FBRegisterConstraint( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
70  HIObject RegisterConstraint##ClassName##Create( HIObject /*pOwner*/,const char* pName,void * /*pData*/) \
71  { \
72  ClassName *Class = new ClassName(pName); \
73  Class->UniqueName = UniqueNameStr; \
74  if (Class->FBCreate()) { \
75  return Class->GetHIObject(); \
76  } else { \
77  delete Class; \
78  return NULL; \
79  } \
80  } \
81 \
82  FBLibraryModule( ClassName ) \
83  { \
84  FBRegisterObject( ClassName##R1,"Constraints",Label,Description,RegisterConstraint##ClassName##Create,true, IconFilename ); \
85  FBRegisterObject( ClassName##R2,"FbxStorable/Constraint",UniqueNameStr,Description,RegisterConstraint##ClassName##Create,true, IconFilename ); \
86  }
87 
93 #define FBConstraintDeclare( ClassName, Parent ) \
94  FBClassDeclare( ClassName, Parent ); \
95  public: \
96  ClassName(const char* pName):Parent(pName) { FBClassInit; } \
97  private:
98 
102 #define FBConstraintImplementation( ThisComponent ) \
103  FBClassImplementation( ThisComponent )
104 
106 // FBConstraintInfo
109 
115 {
116 public:
121 
126 };
127 
129 // FBConstraint
132 
134 class FBSDK_DLL FBConstraint : public FBBox {
136 public:
141  FBConstraint(const char* pName, HIObject pObject=NULL);
142 
143  IObject_Declare(override); // Interface to IObject
144 
145  virtual void ActiveChanged();
146 
147  virtual void RemoveAllAnimationNodes();
148  virtual void SetupAllAnimationNodes();
149 
150  virtual void SnapSuggested();
151  virtual void FreezeSuggested();
152 
157  virtual bool Disable( FBModel* pModel );
158 
163  virtual bool Enable( FBModel* pModel );
164 
171  virtual bool AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo, FBConstraintInfo* pConstraintInfo );
172 
174 
182  FBAnimationNode* AnimationNodeOutCreate ( kReference pUserId, FBModel* pModel, const char* pAttribute );
183  FBAnimationNode* AnimationNodeInCreate ( kReference pUserId, FBModel* pModel, const char* pAttribute );
191  FBAnimationNode* AnimationNodeInCreate ( kReference pUserId, FBProperty* pProperty );
193 
200  virtual void SaveModelState( FBModel* pModel, bool pS, bool pR, bool pT );
201 
205  virtual void RestoreModelState( FBModel* pModel );
206 
213  virtual void FreezeSRT( FBModel* pModel, bool pS, bool pR, bool pT );
214 
218  virtual FBConstraint* Clone();
219 
224 
230  int ReferenceGroupAdd( const char* pGroupName, int pMaxItemCount );
231 
236  const char* ReferenceGroupGetName( int pGroupIndex );
237 
243  int ReferenceGroupGetMaxCount( int pGroupIndex );
244 
250  FBModel* ReferenceGet( int pGroupIndex, int pItemIndex=0 );
251 
256  int ReferenceGetCount( int pGroupIndex );
257 
265  bool ReferenceAdd( int pGroupIndex, FBModel* pModel );
266 
272  bool ReferenceRemove( int pGroupIndex, FBModel* pModel );
273 
276 
278 
283  virtual bool ReferenceAddNotify ( int pGroupIndex, FBModel* pModel );
284  virtual bool ReferenceRemoveNotify ( int pGroupIndex, FBModel* pModel );
286 
299  virtual bool DeformerPreNotify( FBModel* pModel, FBEvaluateInfo* pEvaluateInfo, FBVertex* pBBoxMin,FBVertex* pBBoxMax);
300 
310  virtual bool DeformerNotify( FBModel* pModel, const FBVertex* pSrcVertex, const FBVertex* pSrcNormal,
311  int pCount,
312  FBVertex* pDstVertex,FBVertex* pDstNormal);
313 
315 
321  virtual bool DeformerBind ( FBModel* pModel );
322  virtual bool DeformerUnBind ( FBModel* pModel );
324 
326 
331  virtual bool FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
332  virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
334 
338 
343 };
344 
346 // FBPropertyListConstraint
350 {
351 public:
357  FBConstraint* operator[](int pIndex);
358 };
359 
361 // FBPropertyListBox
363 __FB_FORWARD( FBBox );
365 FB_DEFINE_LIST( FBSDK_DLL, Box );
366 
369 {
370 public:
376  int Add( FBBox* pItem );
380  virtual void RemoveAt( int pIndex );
385  virtual FBBox* operator[](int pIndex);
389  virtual int GetCount();
390 
391 #ifndef DOXYGEN_SHOULD_SKIP_THIS
392  inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
393 private:
394  inline virtual int Add ( FBComponent* pItem ) { return Add((FBBox*)pItem); }
395 #endif
396 };
397 
399 // FBBoxPlaceHolder
403 
412 public:
416  FBBoxPlaceHolder(HIObject pObject);
417 
418  FBPropertyBox Box;
419 };
420 
422 // FBModelPlaceHolder
426 
434 public:
438  FBModelPlaceHolder(HIObject pObject);
439 
440  FBPropertyModel Model;
442 };
443 
445 // FBConstraintRelation
448 
455 public:
460  FBConstraintRelation(const char* pName, HIObject pObject=NULL);
461 
462  IObject_Declare(override); // Interface to IObject
463 
469  FBBox* SetAsSource ( FBBox* pSource );
470 
476  FBBox* ConstrainObject( FBBox* pConstrainedObject ); // Receiver
477 
484  FBBox* CreateFunctionBox( const char* pGroup, const char* pName );
485 
494  bool GetBoxPosition( FBBox* pBox, int& pX, int& pY );
495 
503  bool SetBoxPosition( FBBox* pBox, int pX, int pY );
504 
506 };
507 
509 // FBConstraintSolver
511 FB_DEFINE_COMPONENT( FBSDK_DLL, ConstraintSolver );
512 
520 #define FBRegisterConstraintSolver( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
521  HIObject RegisterConstraintSolver##ClassName##Create( HIObject /*pOwner*/,const char* pName,void * /*pData*/) \
522  { \
523  ClassName *Class = new ClassName(pName); \
524  Class->UniqueName = UniqueNameStr; \
525  if (Class->FBCreate()) { \
526  return Class->GetHIObject(); \
527  } else { \
528  delete Class; \
529  return NULL; \
530  } \
531  } \
532 \
533  FBLibraryModule( ClassName ) \
534  { \
535  FBRegisterObject( ClassName##R1,"Browsing/Templates/Solvers",Label,Description,RegisterConstraintSolver##ClassName##Create,true, IconFilename ); \
536  FBRegisterObject( ClassName##R2,"FbxStorable/Constraint",UniqueNameStr,Description,RegisterConstraintSolver##ClassName##Create,true, IconFilename ); \
537  }
538 
544 #define FBConstraintSolverDeclare( ClassName, Parent ) \
545  FBClassDeclare( ClassName, Parent ); \
546  public: \
547  ClassName(const char* pName):Parent(pName) { FBClassInit; } \
548  private:
549 
553 #define FBConstraintSolverImplementation( ThisComponent ) \
554  FBClassImplementation( ThisComponent )
555 
557 
561 public:
562 
563  FBConstraintSolver(const char* pName, HIObject pObject=NULL);
564 
565  static bool BackgroundEvaluate( FBModel* pModel, FBComponent* pTrackOrTake, FBTime pTime, FBVector3d& pT, FBVector3d& pR, FBVector3d& pS, FBEvaluateInfo* pEvaluateInfo = NULL, bool pGlobal = true );
566 
573  FBEvaluateInfo* BackgroundEvaluateInfoBegin(FBEvaluateInfo* pSourceEvaluateInfo, bool pEvaluateCandidates=false);
574 
581  FBEvaluateInfo* BackgroundEvaluateInfoRecursiveBegin(FBEvaluateInfo* pSourceEvaluateInfo, bool pForceUpdateLocals=false);
582 
584  void BackgroundEvaluateInfoEnd(FBEvaluateInfo* pBackgroundEvaluateInfo);
585 
593  bool BackgroundEvaluateInfoNotify(FBEvaluateInfo* pBackgroundEvaluateInfo, kBackgroundEvaluationCallback pFunction, void* pCustomData=NULL);
594 
595  void MultiThreaded( bool pActive );
596  bool IsMultiThreaded();
597 
600 
601  virtual void LiveChanged();
602 };
603 
605 // FBPropertyListConstraintSolver
608 
611 {
612 public:
618  FBConstraint* operator[](int pIndex);
619 };
620 
622 // FBPhysicalProperties
624 FB_DEFINE_COMPONENT( FBSDK_DLL, PhysicalProperties );
625 
633 #define FBRegisterPhysicalProperties( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
634  HIObject RegisterPhysicalProperties##ClassName##Create( HIObject /*pOwner*/,const char* pName,void * /*pData*/) \
635  { \
636  ClassName *Class = new ClassName(pName); \
637  if (Class->FBCreate()) { \
638  return Class->GetHIObject(); \
639  } else { \
640  delete Class; \
641  return NULL; \
642  } \
643  } \
644 \
645  FBLibraryModule( ClassName ) \
646  { \
647  FBRegisterObject( ClassName##R1,"Browsing/Templates/Physical Properties",Label,Description,RegisterPhysicalProperties##ClassName##Create,true, IconFilename ); \
648  FBRegisterObject( ClassName##R2,"FbxStorable/Physical Properties",UniqueNameStr,Description,RegisterPhysicalProperties##ClassName##Create,true, IconFilename ); \
649  }
650 
656 #define FBPhysicalPropertiesDeclare( ClassName, Parent ) \
657  FBClassDeclare( ClassName, Parent ); \
658  public: \
659  ClassName(const char* pName):Parent(pName) { FBClassInit; } \
660  private:
661 
665 #define FBPhysicalPropertiesImplementation( ThisComponent ) \
666  FBClassImplementation( ThisComponent )
667 
669 
675 public:
676 
677  FBPhysicalProperties(const char* pName, HIObject pObject=NULL);
678 
679 };
680 
682 // FBPropertyListPhysicalProperties
684 FB_DEFINE_LIST( FBSDK_DLL, PhysicalProperties );
686 
689 {
690 public:
697 };
698 
700 // FBConstraintManager
703 
706 {
708 public:
713 
720  const char* TypeGetName ( int pTypeIndex ) const;
721 
725  int TypeGetCount () const;
726 
734  FBConstraint* TypeCreateConstraint( int pTypeIndex );
735 
743  FBConstraint* TypeCreateConstraint( const char* pName );
744 protected:
748 };
749 
750 
751 #ifdef FBSDKUseNamespace
752  }
753 #endif
754 #endif
A box is a fundamental building block in the application architecture.
Definition: fbcore.h:218
Wrapper around a specific instance of a FBBox object.
Definition: fbconstraint.h:410
FBBoxPlaceHolder(HIObject pObject)
Constructor.
FBPropertyBox Box
Read Only Property: Underlying box object.
Definition: fbconstraint.h:418
MotionBuilder SDK base class.
Definition: fbcomponent.h:651
Base class for constraints.
Definition: fbconstraint.h:134
virtual void SaveModelState(FBModel *pModel, bool pS, bool pR, bool pT)
Save current state of pModel.
virtual void SnapSuggested()
Suggest 'snap'.
FBPropertyBool Lock
Read Write Property: Lock state.
Definition: fbconstraint.h:340
FBAnimationNode * AnimationNodeInCreate(kReference pUserId, FBProperty *pProperty)
Animation Node Creations (IN).
virtual void SetupAllAnimationNodes()
Setup animation nodes.
bool ReferenceRemove(int pGroupIndex, FBModel *pModel)
Remove a reference to pModel from the group at pGroupIndex.
void ReferenceRemoveAll()
Remove All References.
FBAnimationNode * AnimationNodeOutCreate(kReference pUserId, FBModel *pModel, const char *pAttribute)
Animation Node Creations (IN/OUT).
virtual bool DeformerPreNotify(FBModel *pModel, FBEvaluateInfo *pEvaluateInfo, FBVertex *pBBoxMin, FBVertex *pBBoxMax)
Deformation pre-notification function This function pass the evaluation information for deformation (...
bool ReferenceAdd(int pGroupIndex, FBModel *pModel)
Add a reference to a specified group.
int ReferenceGroupGetMaxCount(int pGroupIndex)
Get the maximum number of items that can exist in the reference group in question.
FBModel * ReferenceGet(int pGroupIndex, int pItemIndex=0)
Get a reference.
FBPropertyString Description
Read Write Property: Long description of constraint.
Definition: fbconstraint.h:337
FBConstraint(const char *pName, HIObject pObject=NULL)
Constructor.
const char * ReferenceGroupGetName(int pGroupIndex)
Get the name of the reference group.
virtual bool Enable(FBModel *pModel)
Enable constraint on pModel.
virtual bool FbxStore(FBFbxObject *pFbxObject, kFbxObjectStore pStoreWhat) override
Store/Retrieve data to/from FBX files.
virtual bool AnimationNodeNotify(FBAnimationNode *pAnimationNode, FBEvaluateInfo *pEvaluateInfo, FBConstraintInfo *pConstraintInfo)
Notification callback for connectors.
FBPropertyBool HasLayout
Read Write Property: Does the constraint have a layout?
Definition: fbconstraint.h:336
virtual bool DeformerBind(FBModel *pModel)
Bind/Unbind pModel to deformation constraint.
virtual void FreezeSRT(FBModel *pModel, bool pS, bool pR, bool pT)
Freeze current model state.
virtual bool DeformerNotify(FBModel *pModel, const FBVertex *pSrcVertex, const FBVertex *pSrcNormal, int pCount, FBVertex *pDstVertex, FBVertex *pDstNormal)
Deformation notification function.
virtual void ActiveChanged()
Notification for Activation Status Change.
FBPropertyAction Snap
Function Property: Snap constraint.
Definition: fbconstraint.h:341
int ReferenceGroupGetCount()
Return the number of reference groups.
virtual FBConstraint * Clone()
Clone the constraint.
FBPropertyBool Deformer
Read Write Property: Is a deformer constraint?
Definition: fbconstraint.h:335
int ReferenceGetCount(int pGroupIndex)
Get number of references in a specified group.
FBPropertyBool Active
Read Write Property: Active state.
Definition: fbconstraint.h:339
virtual void RemoveAllAnimationNodes()
Remove animation nodes.
virtual bool ReferenceAddNotify(int pGroupIndex, FBModel *pModel)
Notification callbacks for when a reference is added or removed.
FBPropertyAnimatableDouble Weight
Read Write Property: Weight of constraint.
Definition: fbconstraint.h:342
virtual bool Disable(FBModel *pModel)
Disable constraint on pModel.
virtual void RestoreModelState(FBModel *pModel)
Restore the saved model state onto pModel.
int ReferenceGroupAdd(const char *pGroupName, int pMaxItemCount)
Add a group of references.
virtual void FreezeSuggested()
Suggest 'freeze'.
Constraint information class.
Definition: fbconstraint.h:115
bool GetZeroRequested()
Was a 'zero' requested?
bool GetSnapRequested()
Was a 'snap' requested?
Constraint manager.
Definition: fbconstraint.h:706
FBConstraint * TypeCreateConstraint(const char *pName)
Create a constraint by name.
static FBConstraintManager & TheOne()
Get the global FBConstraintManager object.
FBConstraint * TypeCreateConstraint(int pTypeIndex)
Create a constraint by index.
FBConstraintManager()
Constructor.
int TypeGetCount() const
Get the number of registered constraint types.
const char * TypeGetName(int pTypeIndex) const
Get the name of a registered type of constraint.
ConstraintRelation class.
Definition: fbconstraint.h:453
bool GetBoxPosition(FBBox *pBox, int &pX, int &pY)
Get a box position in the GUI.
FBBox * SetAsSource(FBBox *pSource)
Create a sender box.
bool SetBoxPosition(FBBox *pBox, int pX, int pY)
Set a box position in the GUI.
FBPropertyListBox Boxes
List: Boxes used in this constraint.
Definition: fbconstraint.h:505
FBBox * CreateFunctionBox(const char *pGroup, const char *pName)
Create a function box.
FBBox * ConstrainObject(FBBox *pConstrainedObject)
Create a receiver box.
FBConstraintRelation(const char *pName, HIObject pObject=NULL)
Constructor.
Base class for constraint solver.
Definition: fbconstraint.h:559
bool BackgroundEvaluateInfoNotify(FBEvaluateInfo *pBackgroundEvaluateInfo, kBackgroundEvaluationCallback pFunction, void *pCustomData=NULL)
Enable evaluation notification.
void BackgroundEvaluateInfoEnd(FBEvaluateInfo *pBackgroundEvaluateInfo)
Release background evaluation info - very important.
FBPropertyInt SampleRecordingPrecision
Read Write Property: Sample Recording Precision?
Definition: fbconstraint.h:598
FBEvaluateInfo * BackgroundEvaluateInfoBegin(FBEvaluateInfo *pSourceEvaluateInfo, bool pEvaluateCandidates=false)
Start background evaluation.
FBEvaluateInfo * BackgroundEvaluateInfoRecursiveBegin(FBEvaluateInfo *pSourceEvaluateInfo, bool pForceUpdateLocals=false)
Start recursive background evaluation.
FBPropertyBool SyncAnimationPlay
Read Write Property: Sync animation play speed with solver? (for computation expensive scenes this wi...
Definition: fbconstraint.h:599
AnimationNodeNotify evaluation information.
FBX file interface.
Definition: fbfbx.h:80
Model class.
Definition: fbmodel.h:274
Wrapper around a specific instance of a FBModel object.
Definition: fbconstraint.h:432
FBPropertyBool UseGlobalTransforms
Read Write Property: Indicate if the translations are expressed in local or global mode.
Definition: fbconstraint.h:441
FBModelPlaceHolder(HIObject pObject)
Constructor.
FBPropertyModel Model
Read Only Property: Underlying model object.
Definition: fbconstraint.h:440
Base class for physical properties attach to a model.
Definition: fbconstraint.h:673
Property: Action Action property to trigger function.
Property: Base property class.
Definition: fbproperties.h:195
List: Box informations for constraint relation.
Definition: fbconstraint.h:369
virtual void RemoveAt(int pIndex)
Remove FBBox object from property list.
virtual int GetCount()
Get the number of objects.
virtual FBBox * operator[](int pIndex)
Get the FBBox object at pIndex.
int Add(FBBox *pItem)
Add a FBBox object to the property list.
PropertyList: Component.
Definition: fbcomponent.h:477
PropertyList: Concrete class for PropertyList of component
Definition: fbcomponent.h:536
PropertyList: Contraint
Definition: fbconstraint.h:350
FBConstraint * operator[](int pIndex)
Get the constraint at pIndex.
PropertyList: Constraint solver
Definition: fbconstraint.h:611
FBConstraint * operator[](int pIndex)
Get the model template at pIndex.
PropertyList: Physical properties
Definition: fbconstraint.h:689
FBPhysicalProperties * operator[](int pIndex)
Get the model template at pIndex.
Property class: const char * (String).
Time data structure.
Definition: fbtime.h:88
Basic class definitions.
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:131
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbconstraint.h:50
Contains definitions for devices, boxes and models.
FB_DEFINE_COMPONENT(K_DLLIMPORT, AnimationNode)
Animation node class.
class K_DLLIMPORT FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
class K_DLLIMPORT FBPropertyBaseAnimatable< double, kFBPT_double > FBPropertyAnimatableDouble
FBPropertyBaseAnimatableDouble type definition.
class K_DLLIMPORT FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
#define FB_DEFINE_LIST(DllTag, Type)
Define a component list.
Definition: fbproperties.h:163
class K_DLLIMPORT FBVector4< float > FBVertex
Vertex.
Definition: fbtypes.h:597
kFbxObjectStore
Description of the different store/retrieve passes of the FBX format.
Definition: fbtypes.h:74
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
class K_DLLIMPORT FBVector3< double > FBVector3d
3D vector.
Definition: fbtypes.h:438