fbsdk/fbconstraint.h Source File

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
47 
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 
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
108 FB_FORWARD( FBConstraintInfo );
109 
115 {
116 public:
120  bool GetSnapRequested();
121 
125  bool GetZeroRequested();
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(K_IMPLEMENTATION); // 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 
223  int ReferenceGroupGetCount();
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 
275  void ReferenceRemoveAll();
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 );
332  virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
334 
338 
343 };
344 
346 // FBPropertyListConstraint
350 {
351 public:
357  FBConstraint* operator[](int pIndex);
358 };
359 
361 // FBPropertyListBox
363 __FB_FORWARD( FBBox );
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 
419 };
420 
422 // FBModelPlaceHolder
426 
434 public:
438  FBModelPlaceHolder(HIObject pObject);
439 
442 };
443 
445 // FBConstraintRelation
448 
455 public:
460  FBConstraintRelation(const char* pName, HIObject pObject=NULL);
461 
462  IObject_Declare(K_IMPLEMENTATION); // 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 
556 __FB_FORWARD( FBConstraintSolver );
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 
668 __FB_FORWARD( FBPhysicalProperties );
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:
696  FBPhysicalProperties* operator[](int pIndex);
697 };
698 
700 // FBConstraintManager
703 
706 {
708 public:
713 
717  static FBConstraintManager& TheOne();
718 
725  const char* TypeGetName ( int pTypeIndex ) const;
726 
730  int TypeGetCount () const;
731 
739  FBConstraint* TypeCreateConstraint( int pTypeIndex );
740 
748  FBConstraint* TypeCreateConstraint( const char* pName );
749 };
750 
751 
752 #ifdef FBSDKUseNamespace
753  }
754 #endif
755 #endif
Model class.
Definition: fbmodel.h:273
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:132
FBPropertyAction Snap
Function Property: Snap constraint.
Definition: fbconstraint.h:341
Constraint manager.
Definition: fbconstraint.h:705
#define FB_DEFINE_COMPONENT(DllTag, Type)
Define a component and give it the ability to be a property.
Definition: fbproperties.h:139
#define FB_DEFINE_LIST(DllTag, Type)
Define a component list.
Definition: fbproperties.h:161
Base class for constraints.
Definition: fbconstraint.h:134
FBPropertyBool Deformer
Read Write Property: Is a deformer constraint?
Definition: fbconstraint.h:335
class FBPropertyBaseAnimatable< double, kFBPT_double > FBPropertyAnimatableDouble
FBPropertyBaseAnimatableDouble type definition.
FBPropertyBool UseGlobalTransforms
Read Write Property: Indicate if the translations are expressed in local or global mode...
Definition: fbconstraint.h:441
#define NULL
Definition: kaydara.h:169
PropertyList: Physical properties
Definition: fbconstraint.h:688
FBPropertyBox Box
Read Only Property: Underlying box object.
Definition: fbconstraint.h:418
#define K_IMPLEMENTATION
Definition: iobject.h:53
AnimationNodeNotify evaluation information.
Contains definitions for devices, boxes and models.
Constraint information class.
Definition: fbconstraint.h:114
#define IObject_Declare(IsPure)
Definition: iobject.h:75
Property class: const char * (String).
FBPropertyBool SyncAnimationPlay
Read Write Property: Sync animation play speed with solver? (for computation expensive scenes this wi...
Definition: fbconstraint.h:599
FBX file interface.
Definition: fbfbx.h:80
MotionBuilder SDK base class.
Definition: fbcomponent.h:668
FBPropertyModel Model
Read Only Property: Underlying model object.
Definition: fbconstraint.h:440
class FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
Base class for constraint solver.
Definition: fbconstraint.h:559
PropertyList: Component.
Definition: fbcomponent.h:494
Property: Action Action property to trigger function.
FBPropertyListBox Boxes
List: Boxes used in this constraint.
Definition: fbconstraint.h:505
Definition: Python-ast.h:18
PropertyList: Concrete class for PropertyList of component
Definition: fbcomponent.h:553
class FBVector4< float > FBVertex
Vertex.
Definition: fbtypes.h:597
List: Box informations for constraint relation.
Definition: fbconstraint.h:368
ConstraintRelation class.
Definition: fbconstraint.h:453
void(* kBackgroundEvaluationCallback)(const FBAnimationNode *pDst, const FBAnimationNode *pSrc, void *pCustomData)
Background Notification Function.
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
FBPropertyAnimatableDouble Weight
Read Write Property: Weight of constraint.
Definition: fbconstraint.h:342
Property: Base property class.
Definition: fbproperties.h:192
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbconstraint.h:50
class FBVector3< double > FBVector3d
3D vector.
Definition: fbtypes.h:438
FBPropertyString Description
Read Write Property: Long description of constraint.
Definition: fbconstraint.h:337
Wrapper around a specific instance of a FBModel object.
Definition: fbconstraint.h:432
class FBPropertyBaseComponent< FBModel * > FBPropertyModel
Definition: fbcore.h:70
#define FBSDKNamespace
FBSDKNamespace define.
Definition: fbversion.h:64
Basic class definitions.
Time data structure.
Definition: fbtime.h:86
FBPropertyBool Lock
Read Write Property: Lock state.
Definition: fbconstraint.h:340
Base class for physical properties attach to a model.
Definition: fbconstraint.h:673
PropertyList: Constraint solver
Definition: fbconstraint.h:610
A box is a fundamental building block in the application architecture.
Definition: fbcore.h:218
#define K_DEPRECATED_2014
Definition: kaydara.h:412
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
Wrapper around a specific instance of a FBBox object.
Definition: fbconstraint.h:410
class FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
kFbxObjectStore
Description of the different store/retrieve passes of the FBX format.
Definition: fbtypes.h:74
FBPropertyInt SampleRecordingPrecision
Read Write Property: Sample Recording Precision?
Definition: fbconstraint.h:598
FBPropertyBool Active
Read Write Property: Active state.
Definition: fbconstraint.h:339
PropertyList: Contraint
Definition: fbconstraint.h:349
FBPropertyBool HasLayout
Read Write Property: Does the constraint have a layout?
Definition: fbconstraint.h:336
class FBPropertyBaseComponent< FBBox * > FBPropertyBox
Definition: fbconstraint.h:401