kfcurvenode.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_COMPONENTS_KFCURVE_KFCURVENODE_H
00005 #define FBXFILESDK_COMPONENTS_KFCURVE_KFCURVENODE_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2010 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00044 #include <fbxfilesdk/components/kbaselib/klib/kerror.h>
00045 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00046 
00047 #include <fbxfilesdk/components/kfcurve/kfcurve.h>
00048 
00049 KFBX_FORWARD (IConnector) 
00050 KFBX_FORWARD (IData) 
00051 
00052 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00053 
00054     enum 
00055     {   
00056         KFCN_IN = 0, 
00057         KFCN_OUT = 1, 
00058         KFCN_INOUT_MASK = 1, 
00059 
00060         KFCN_HIDDEN = 0, 
00061         KFCN_SHOWN = 2, 
00062 
00063         KFCN_CONTAINER_NODE = 0, 
00064         KFCN_REFERENCER_NODE = 8, 
00065         KFCN_REFERENCER_MASK = 8, 
00066 
00067         KFCN_TAKE_NODE = 16, 
00068         KFCN_FIXED_NODE = 0, 
00069         KFCN_TAKE_MASK = 16,
00070 
00071         KFCN_EXPENDED_NODE = 32, 
00072         KFCN_NOTEXPENDED_NODE = 0, 
00073         KFCN_EXPENDED_MASK = 32,
00074 
00075         KFCN_MULTILAYER = 64,
00076         KFCN_MONOLAYER  = 0,
00077         KFCN_MULTILAYER_MASK = 64,
00078 
00079         KFCN_ALWAYS_CANDIDATE = 128,
00080         KFCN_ALWAYS_CANDIDATE_TESTED = 256
00081     };
00082 
00083     //
00084     // Picking Types define
00085     //
00086     enum 
00087     {
00088         KCP_KEY = 1, 
00089         KCP_LTANGENT, 
00090         KCP_RTANGENT
00091     };
00092 
00093     //
00094     //  Node/Layer info
00095     //
00096     enum
00097     {
00098         KFCL_NOLAYER,
00099         KFCL_ADD,       // For translation and standard others
00100         KFCL_EULER_XYZ, // For rotation
00101         KFCL_MULT,      // For scaling, mainly
00102         KFCL_QUAT       // For quaternion rotation
00103     };
00104 
00105     #define KFCURVENODE_TRANSFORM               "Transform"
00106         #define KFCURVENODE_T                       "T"
00107             #define KFCURVENODE_T_X                     "X"
00108             #define KFCURVENODE_T_Y                     "Y"
00109             #define KFCURVENODE_T_Z                     "Z"
00110         #define KFCURVENODE_R                       "R"
00111             #define KFCURVENODE_R_X                     "X"
00112             #define KFCURVENODE_R_Y                     "Y"
00113             #define KFCURVENODE_R_Z                     "Z"
00114             #define KFCURVENODE_R_W                     "W"
00115         #define KFCURVENODE_S                       "S"
00116             #define KFCURVENODE_S_X                     "X"
00117             #define KFCURVENODE_S_Y                     "Y"
00118             #define KFCURVENODE_S_Z                     "Z"
00119     #define KFCURVENODE_LCL_T                   "Lcl Translation"
00120     #define KFCURVENODE_LCL_R                   "Lcl Rotation"
00121     #define KFCURVENODE_LCL_S                   "Lcl Scaling"
00122     #define KFCURVENODE_VISIBILITY              "Visibility"
00123 
00124     // Addition for the optical marker node attribute.
00125     #define KFCURVENODE_OCCLUSION               "Occlusion"
00126 
00127     // Addition for the IK effector marker node attribute.
00128     #define KFCURVENODE_IK_REACH_TRANSLATION    "IK Reach Translation"
00129     #define KFCURVENODE_IK_REACH_ROTATION       "IK Reach Rotation"
00130 
00131     // Addition for the light node attribute.
00132     #define KFCURVENODE_LIGHT_CONEANGLE         "Cone angle"
00133     #define KFCURVENODE_LIGHT_FOG               "Fog"
00134     #define KFCURVENODE_LIGHT_INTENSITY         "Intensity"
00135     #define KFCURVENODE_COLOR                   "Color"
00136     #define KFCURVENODE_COLOR_RED                   "X"
00137     #define KFCURVENODE_COLOR_GREEN                 "Y"
00138     #define KFCURVENODE_COLOR_BLUE                  "Z"
00139 
00140     // Addition for the camera node attribute.
00141     #define KFCURVENODE_CAMERA_FIELDOFVIEW      "FieldOfView"
00142     #define KFCURVENODE_CAMERA_FIELDOFVIEWX     "FieldOfViewX"
00143     #define KFCURVENODE_CAMERA_FIELDOFVIEWY     "FieldOfViewY"
00144     #define KFCURVENODE_CAMERA_FOCALLENGTH      "FocalLength"
00145     #define KFCURVENODE_CAMERA_OPTICALCENTERX   "OpticalCenterX"
00146     #define KFCURVENODE_CAMERA_OPTICALCENTERY   "OpticalCenterY"
00147     #define KFCURVENODE_CAMERA_ROLL             "Roll"
00148     #define KFCURVENODE_CAMERA_TURNTABLE        "TurnTable"
00149     #define KFCURVENODE_BACKGROUND_COLOR        "BackgroundColor"
00150     #define KFCURVENODE_BACKGROUND_COLOR_RED        "X"
00151     #define KFCURVENODE_BACKGROUND_COLOR_GREEN      "Y"
00152     #define KFCURVENODE_BACKGROUND_COLOR_BLUE       "Z"
00153 
00154     // Addition for the camera switcher node attribute.
00155     #define KFCURVENODE_CAMERA_INDEX            "Camera Index"
00156 
00157     // Addition for the texture.
00158     #define KFCURVENODE_TEXTURE_TRANSLATION     "Translation"
00159     #define KFCURVENODE_TEXTURE_TRANSLATION_X   "X"
00160     #define KFCURVENODE_TEXTURE_TRANSLATION_Y   "Y"
00161     #define KFCURVENODE_TEXTURE_TRANSLATION_Z   "Z"
00162     #define KFCURVENODE_TEXTURE_ROTATION        "Rotation"
00163     #define KFCURVENODE_TEXTURE_ROTATION_X      "X"
00164     #define KFCURVENODE_TEXTURE_ROTATION_Y      "Y"
00165     #define KFCURVENODE_TEXTURE_ROTATION_Z      "Z"
00166     #define KFCURVENODE_TEXTURE_SCALING         "Scaling"
00167     #define KFCURVENODE_TEXTURE_SCALING_X       "X"
00168     #define KFCURVENODE_TEXTURE_SCALING_Y       "Y"
00169     #define KFCURVENODE_TEXTURE_SCALING_Z       "Z"
00170     #define KFCURVENODE_TEXTURE_ALPHA           "Alpha"
00171 
00172     // Addition for the material.
00173     #define KFCURVENODE_MATERIAL_EMISSIVE       "Emissive"
00174     #define KFCURVENODE_MATERIAL_EMISSIVE_R     "X"
00175     #define KFCURVENODE_MATERIAL_EMISSIVE_G     "Y"
00176     #define KFCURVENODE_MATERIAL_EMISSIVE_B     "Z"
00177     #define KFCURVENODE_MATERIAL_AMBIENT        "Ambient"
00178     #define KFCURVENODE_MATERIAL_AMBIENT_R      "X"
00179     #define KFCURVENODE_MATERIAL_AMBIENT_G      "Y"
00180     #define KFCURVENODE_MATERIAL_AMBIENT_B      "Z"
00181     #define KFCURVENODE_MATERIAL_DIFFUSE        "Diffuse"
00182     #define KFCURVENODE_MATERIAL_DIFFUSE_R      "X"
00183     #define KFCURVENODE_MATERIAL_DIFFUSE_G      "Y"
00184     #define KFCURVENODE_MATERIAL_DIFFUSE_B      "Z"
00185     #define KFCURVENODE_MATERIAL_SPECULAR       "Specular"
00186     #define KFCURVENODE_MATERIAL_SPECULAR_R     "X"
00187     #define KFCURVENODE_MATERIAL_SPECULAR_G     "Y"
00188     #define KFCURVENODE_MATERIAL_SPECULAR_B     "Z"
00189     #define KFCURVENODE_MATERIAL_OPACITY        "Opacity"
00190     #define KFCURVENODE_MATERIAL_REFLECTIVITY   "Reflectivity"
00191     #define KFCURVENODE_MATERIAL_SHININESS      "Shininess"
00192 
00193     // Addition for the generic vector property.
00194     #define KFCURVENODE_USER_PROPERTY_VECTOR_X  "X"
00195     #define KFCURVENODE_USER_PROPERTY_VECTOR_Y  "Y"
00196     #define KFCURVENODE_USER_PROPERTY_VECTOR_Z  "Z"
00197     #define KFCURVENODE_USER_PROPERTY_VECTOR_W  "W"
00198 
00199     // Addition for the generic color property.
00200     #define KFCURVENODE_USER_PROPERTY_COLOR_R  "X"
00201     #define KFCURVENODE_USER_PROPERTY_COLOR_G  "Y"
00202     #define KFCURVENODE_USER_PROPERTY_COLOR_B  "Z"
00203     #define KFCURVENODE_USER_PROPERTY_COLOR_A  "W"
00204 
00205     // Addition of generic matrix
00206     #define KFCURVENODE_USER_PROPERTY_MATRIX "Matrix"
00207     #define KFCURVENODE_USER_PROPERTY_MATRIX_0 "0"
00208     #define KFCURVENODE_USER_PROPERTY_MATRIX_1 "1"
00209     #define KFCURVENODE_USER_PROPERTY_MATRIX_2 "2"
00210     #define KFCURVENODE_USER_PROPERTY_MATRIX_3 "3"
00211     #define KFCURVENODE_USER_PROPERTY_MATRIX_4 "4"
00212     #define KFCURVENODE_USER_PROPERTY_MATRIX_5 "5"
00213     #define KFCURVENODE_USER_PROPERTY_MATRIX_6 "6"
00214     #define KFCURVENODE_USER_PROPERTY_MATRIX_7 "7" 
00215     #define KFCURVENODE_USER_PROPERTY_MATRIX_8 "8"
00216     #define KFCURVENODE_USER_PROPERTY_MATRIX_9 "9"
00217     #define KFCURVENODE_USER_PROPERTY_MATRIX_A "A"
00218     #define KFCURVENODE_USER_PROPERTY_MATRIX_B "B"
00219     #define KFCURVENODE_USER_PROPERTY_MATRIX_C "C"
00220     #define KFCURVENODE_USER_PROPERTY_MATRIX_D "D"
00221     #define KFCURVENODE_USER_PROPERTY_MATRIX_E "E"
00222     #define KFCURVENODE_USER_PROPERTY_MATRIX_F "F"
00223 
00224     // Default array size for 1 minute of animation (30fps) 
00225     #define SELECTION_ARRAY_SIZE    30*60+1
00226     //#define SELECTION_ARRAY_SIZE 1024*1024
00227 
00228     #define KFCURVENODE_CANDIDATE_MAX_COUNT 4
00229 
00230 
00231     typedef int  kFCurveNodeType;
00232 
00233     KFBX_FORWARD (KFCurveNode);
00234     typedef HKFCurveNode HIKFCurveNode;
00235     typedef KFCurveNode IKFCurveNode;
00236 
00237     #define IKFCurveNodeID 43763634
00238 
00239     enum EKFCurveNodeEventType
00240     {
00241         KFCURVENODEEVENT_NONE = 0, 
00242         KFCURVENODEEVENT_SELECTION = 1, 
00243         KFCURVENODEEVENT_DESTROY = 2, 
00244         KFCURVENODEEVENT_FCURVE = 4, 
00245         KFCURVENODEEVENT_TIMEWARP = 8, 
00246         KFCURVENODEEVENT_CTRLCURVE = 16, 
00247         KFCURVENODEEVENT_DATAUPDATED = 32
00248     };
00249 
00250     struct KExternalTimingInformation
00251     {
00252         KTime mLclOffset;
00253         KTime mDuration;
00254     };
00255 
00256 
00259     class KFBX_DLL KFCurveNodeEvent : public KEventBase
00260     {
00261     public:
00267 
00268         int mEventCount;
00269 
00271         void* mData;
00272 
00274         inline void Clear () 
00275         {
00276             mType=KFCURVENODEEVENT_NONE; 
00277             mEventCount = 0; 
00278             mData = NULL; 
00279         }
00280 
00284         inline void Add (int pWhat) 
00285         {
00286             mType |= pWhat;
00287             mEventCount++;
00288         }
00289 
00290         // Set the data contained by the node event.
00291         inline void SetData (void* pData) {mData = pData;}
00292     };
00293 
00294 
00295     struct KFCurveNodeCallback 
00296     {
00297         KFCurveNodeEvent mEvent;
00298         KArrayUL mCallbackFunctions;   // no delete on object must use array ul
00299         KArrayUL mCallbackObjects;     // no delete on object must use array ul
00300         bool mCallbackEnable;
00301     };
00302 
00303     typedef void (*kFCurveNodeCallback) (KFCurveNode* pFCurve, KFCurveNodeEvent* FCurveNodeEvent, void* pObject) ;
00304 
00305     typedef class KArrayTemplate< HKFCurveNode > KArrayTemplateFCurveNode;  
00306 
00307     // Return codes for function KFCurveNode::IsKey().
00308     enum 
00309     { 
00310         ISKEY_NONE,
00311         ISKEY_SOME, 
00312         ISKEY_ALL 
00313     };
00314 
00315 
00316     class KFBX_DLL KFCurveNodeCandidateState
00317     {
00318     public:
00319         KFCurveNodeCandidateState();
00320         ~KFCurveNodeCandidateState();
00321 
00322         void Dump(int pLevel = 0);
00323 
00324         void SetCandidateTotalTime      ( KTime &pCandidateTime ) { mCandidateTotalTime = pCandidateTime; };
00325         void SetCandidateSpecificTime   ( KTime &pCandidateTime ) { mCandidateSpecificTime = pCandidateTime; };
00326 
00327     protected:
00328         friend class KFCurveNode;
00329         
00330         int mSpecificCandidateMethod;
00331         int mTotalCandidateMethod;
00332 
00333         double mCandidateTotalValue[KFCURVENODE_CANDIDATE_MAX_COUNT];
00334         KTime   mCandidateTotalTime;
00335 
00336         double mCandidateSpecificValue;
00337         double mFCurveValue;
00338         KTime mCandidateSpecificTime;
00339 
00340         KFCurveNodeCandidateState *mSubStates[KFCURVENODE_CANDIDATE_MAX_COUNT];
00341         KFCurveNodeCandidateState *mLayerState;
00342         int                        mLayerID;
00343 
00344     };
00345 
00346 
00359     class KFBX_DLL KFCurveNode
00360     {
00361 
00362     public:
00363 
00368 
00377         KFCurveNode 
00378         (
00379             char* pNodeName, 
00380             char* pTimeWarpName, 
00381             HKDataType pDataType, 
00382             int  pLayerType = KFCL_NOLAYER,
00383             int  pLayerID = 0
00384         ) ;
00385 
00393         KFCurveNode(HKFCurveNode pTemplateCurveNode);
00394 
00396         virtual ~KFCurveNode () ;
00397 
00398     private:
00399         // Disabling copy constructor, since this class maintains pointers with ref counts on them
00400         KFCurveNode& operator = (const KFCurveNode&);
00401         KFCurveNode(const KFCurveNode& );
00402          
00403     public:
00404 
00405 
00406 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00407         void Destroy (int Local=0) ;
00408 #endif
00409 
00411 
00416 
00420         void CreateFCurve( );
00421 
00426         bool FCurveCreated( );
00427 
00429 
00434 
00445         HKFCurveNode Clone(bool pKeepAttached);
00446 
00460         HKFCurveNode CloneTemplate(bool pKeepAttached=false, bool pCloneFCurves=false, bool pCreateCurves=false, int pLayerID = -1);
00461 
00469         void CopyFrom(HKFCurveNode pSource, bool pTransferCurve = false);
00470 
00479         HKFCurveNode Copy(KTime pStart=KTIME_MINUS_INFINITE, KTime pStop=KTIME_INFINITE);
00480 
00482 
00487 
00489         char* GetName () const;
00490 
00492         char* GetTimeWarpName() const;
00493 
00495         char* GetTypeName() const;
00496 
00498 
00503 
00507         HKFCurve FCurveGet() const;
00508 
00517         KFCurve* FCurveSet (KFCurve* pCurve, bool pDestroyOldCurve = false) ;
00518 
00525         void FCurveReplace (KFCurve* pCurve) ;
00526 
00535         bool GetTransformCurves (KFCurve* pT[3], KFCurve* pR[3], KFCurve* pS[3]) ;
00536 
00538 
00543 
00547         virtual void Clear () ;
00548 
00553         virtual int Add(HKFCurveNode pCurveNode);
00554         
00558         virtual void Remove (int pIndex) ;
00559         
00563         virtual void Delete (int pIndex) ;
00564         
00566         virtual int GetCount () const;
00567         
00572         virtual HKFCurveNode Get(int pIndex) const;
00573         
00580         virtual bool IsChild(KFCurveNode* pCurveNode, bool pRecursive = false) const;
00581 
00587         virtual int Find (char* pName) const;
00588 
00594         virtual int Find(HKFCurveNode pNode) const;
00595 
00600         HKFCurveNode FindRecursive(char* pName) const;
00601 
00608         HKFCurveNode FindOrCreate(char* pName, bool pFindOrCreateCurve = true) ;
00609         
00613         virtual void SetParent(HKFCurveNode pParent) {mParent = pParent;}
00614         
00618         virtual HKFCurveNode GetParent() const {return mParent;}
00619 
00621 
00626 
00632         int KeyGetCount(bool pRecursiveInLayers = false) const;
00633 
00640         void KeyGetCount(int& pCurveCount, int& pTotalCount, int& pMinCount, int& pMaxCount) const;
00641 
00649         void GetCurveWithFirstKey(KFCurve*& lCurveWithFirstKey, bool *pCurveMask /* = NULL */, bool pRecursiveInLayers) const;
00650 
00657         void GetCurveWithLastKey(KFCurve*& lCurveWithLastKey, bool *pCurveMask /* = NULL */, bool pRecursiveInLayers) const;
00658 
00665         KTime GetFirstKeyTime(bool *pCurveMask = NULL, bool pRecursiveInLayers = false) const;
00666 
00673         KTime GetLastKeyTime(bool *pCurveMask = NULL, bool pRecursiveInLayers = false) const;
00674 
00685         double* KeyAdd (KTime pTime, double* pValue) ;
00686 
00700         double* KeyAppend (KTime pTime, double* pValue, bool pCheckForContinuousRotation = false) ;
00701 
00712         bool GetAnimationInterval (KTime& pStart, KTime& pStop) const;
00713 
00718         void GetTimeSpan          (KTime& pStart, KTime& pStop) const;  
00719 
00735         int IsKey (KTime& pTime, int *pLast, bool* pCurveMask = NULL, double pKeyIndexTolerance = 0.0, double pMin = -K_DOUBLE_MAX,  double pMax = K_DOUBLE_MAX ) const;
00736 
00746         bool DeleteKey (KTime& pTime, bool* pCurveMask = NULL, double pKeyIndexTolerance = 0.0 );
00747 
00758         KTime GetNextKeyTime (KTime pTime, bool* pCurveMask = NULL, bool pRecursiveInLayers = false) const;
00759 
00769         KTime GetPrevKeyTime (KTime pTime, bool* pCurveMask = NULL ) const;
00770 
00785         double* Evaluate (double* pValue, KTime pTime, kFCurveIndex* pLast=NULL) ;
00786         
00797         double* GetValue (double* pValue) const;
00798         
00808         double* SetValue (double* pValue) ;
00809 
00816         void Delete(KTime pStart=KTIME_MINUS_INFINITE, KTime pStop=KTIME_INFINITE);
00817 
00830     void Replace(HKFCurveNode pSource, KTime pStart = KTIME_MINUS_INFINITE, KTime pStop = KTIME_INFINITE, bool pUseGivenSpan = false, bool pKeyStartEndOnNoKey = true, KTime pTimeSpanOffset = KTIME_ZERO );
00831 
00833 
00835     //
00836     //  WARNING!
00837     //
00838     //  Anything beyond these lines may not be documented accurately and is 
00839     //  subject to change without notice.
00840     //
00842 
00843     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00844 
00849 
00851         float* GetColor();
00852 
00854         void SetColor (float pColor[3]) ;
00855 
00857 
00862 
00864         inline int IncReferenceCount () {return ++mReferenceCount;}
00865 
00867         inline int DecReferenceCount () {mReferenceCount--; return mReferenceCount;}
00868 
00870         inline int GetReferenceCount () const {return mReferenceCount;}
00871 
00873 
00878 
00880         int GetTakeType () const;
00881 
00883         void SetTakeType (int pType) ;
00884 
00886 
00891 
00893         bool GetVisibility () const;
00894 
00896         void SetVisibility (bool pVisible, bool pRecursive=false, bool pRecurseLayer = false, int lChildIndex = -1) ;
00897 
00899 
00904 
00909         void DataNodeSet (HKFCurveNode pDataNode, bool pRecursive=true) ;
00910 
00914         HKFCurveNode DataNodeGet ();
00915 
00919         bool SetPreExtrapolation(kUInt pNewPreExtrapolation, bool pRespectUserLock=true );
00920         bool SetPreExtrapolationCount(kUInt pNewPreExtrapolationCount, bool pRespectUserLock=true);
00921         bool SetPostExtrapolation(kUInt pNewPreExtrapolation, bool pRespectUserLock=true);
00922         bool SetPostExtrapolationCount(kUInt pNewPreExtrapolationCount, bool pRespectUserLock=true);
00923 
00925 
00930 
00932         int GetContainerType () const;
00933 
00935         void SetContainerType (int pInOutType) ;
00936 
00938 
00943 
00945         int GetIOType () const;
00946 
00948         void SetIOType (int pInOutType) ;
00949 
00951 
00956 
00958         int IsExpended () const;
00959 
00961         void SetExpended (bool pExpended) ;
00962 
00964 
00969 
00971         int IsMultiLayer() const;
00972 
00974         void SetMultiLayer (bool pMultiLayer) ;
00975 
00977         HKFCurveNode GetLayerNode(int pLayerID);
00978 
00980 
00985 
00989         bool LookLikeSampledData(KTime pThresholdPeriod) const;
00990 
00992 
00997 
00999         int GetUpdateId () const;
01000 
01002         int GetValuesUpdateId () const;
01003 
01005         int GetNodeUpdateId () const;
01006 
01007 
01009 
01014         
01016         bool CallbackEnable (bool pEnable) ;
01017         
01019         bool CallbackIsEnable () const;
01020         
01022         void CallbackClear () ;
01023         
01025         void CallbackAddEvent (int pWhat) ;
01026         
01028         void CallbackRegister (kFCurveNodeCallback, void* pObject) ;
01029         
01031         void CallbackUnregister (kFCurveNodeCallback, void* pObject) ;
01032 
01034 
01035         bool    FbxStore (KFbx* pFbx, bool pOnlyDefaults = false, bool pReplaceLclTRSName = false, bool pSkipTimeWarpName = false, char* pFieldName = "Channel", bool pColor = true, KFCurve::FbxStoreVersionID pIsVersionID = KFCurve::V7 ) ;
01036         bool    FbxRetrieve (KFbx* pFbx, bool pOnlyDefaults = false, bool pCreateIfNotFound = true,bool pColor = false);
01037         bool    FbxInternalRetrieve (KFbx* pFbx, bool pOnlyDefaults = false, bool pCreateIfNotFound = true,bool pColor = false) ;
01038         bool    FbxTimeWarpNameRetrieve(KFbx* pFbx);
01039         bool    FbxLayerAndTimeWarpRetrieve(KFbx* pFbx, bool pOnlyDefaults = false, bool pCreateIfNotFound = true,bool pColor = false) ;
01040 
01042 
01046         unsigned short mUseQuaternion;
01047         inline unsigned short GetUseQuaternion()const {return mUseQuaternion;}; 
01048         void SetUseQuaternion(unsigned short pVal); 
01049         private:
01050             void RotationNodeEvaluate(double* pValue, KTime pTime, kFCurveIndex* pLast,bool pEvaluateCandidate,bool pInternalCall = false);
01051             void Make4Quaternions(int lIndexLeft, int lIndexRight,
01052                                  KTime lTM2, KTime lTM1, KTime lTP1, KTime lTP2,
01053                                  KgeQuaternion& lQM2, KgeQuaternion& lQM1, KgeQuaternion& lQP1, KgeQuaternion& lQP2, KgeRMatrix& lRMRef);
01054 
01055             void QuatEvaluateClassic(double* pValue, KTime pTime, kFCurveIndex* pLast,bool pEvaluateCandidate,
01056                                           double lIndex, int lIndexLeft, int lIndexRight,
01057                                           double lIndexY, int lIndexLeftY, int lIndexRightY,
01058                                           double lIndexZ, int lIndexLeftZ, int lIndexRightZ,
01059                                           bool lKeyP2Exists, bool lKeyM2Exists,
01060                                           HKFCurveNode lFCurveNodeX, HKFCurveNode lFCurveNodeY, HKFCurveNode lFCurveNodeZ);
01061             void QuatEvaluateSlerp(double* pValue, 
01062                                           double lIndex, int lIndexLeft, int lIndexRight,
01063                                           KTime lTM2, KTime lTM1, KTime lTP1, KTime lTP2,
01064                                           bool lKeyP2Exists, bool lKeyM2Exists);
01065             void QuatEvaluateCubic(double* pValue, 
01066                                           double lIndex, int lIndexLeft, int lIndexRight,
01067                                           KTime lTM2, KTime lTM1, KTime lTP1, KTime lTP2,
01068                                           bool lKeyP2Exists, bool lKeyM2Exists);
01069             void QuatEvaluateTangentDependent(double* pValue, KTime pTime, kFCurveIndex* pLast,bool pEvaluateCandidate,
01070                                           double lIndex, int lIndexLeft, int lIndexRight,
01071                                           double lIndexY, int lIndexLeftY, int lIndexRightY,
01072                                           double lIndexZ, int lIndexLeftZ, int lIndexRightZ,
01073                                           bool lKeyP2Exists, bool lKeyM2Exists,
01074                                           HKFCurveNode lFCurveNodeX, HKFCurveNode lFCurveNodeY, HKFCurveNode lFCurveNodeZ);
01075 
01077 
01078     public:
01080 
01084         void GetCandidateState(KFCurveNodeCandidateState& pState) const;
01085         void SetCandidateState(const KFCurveNodeCandidateState& pState, bool pDestroyMissingLayers = false );
01086 
01087         int     GetCandidateSpecificMethod() const;
01088         int     GetCandidateTotalMethod() const;
01089         KTime   GetCandidateTotalTime() const;
01090         double* GetCandidateTotalValue();
01091         int     GetCandidateTotalValueSize() const;
01092 
01093         void    SetCandidateSpecificMethod(int pMethod);
01094         void    SetCandidateTotalMethod(int pMethod);
01095         void    SetCandidateTotalTime(KTime pTime);
01096         void    SetCandidateTotalValue(double* pValue);
01097 
01099 
01100     void GetQuaternionInterpolationBezierPoints(KTime pCurrentTime, KgeQuaternion &pQ0, KgeQuaternion &lQ1, KgeQuaternion &lQ2, KgeQuaternion &lQ3);
01101 
01102     private:
01103         struct NameInfo 
01104         {
01105             KString     mName;
01106             KString     mTimeWarpName;
01107             HKDataType  mDataType;
01108             int     mRefCount;
01109         }*mNameInfo;
01110 
01111         void    SetNameInfo( NameInfo* pNameInfo );
01112 
01113     protected:
01114 
01115         int mType;
01116 
01117         int mReferenceCount;
01118         KArrayTemplate<HKFCurveNode> mNodes;
01119 
01120         HIKFCurve    mFCurve;
01121         HKFCurveNode mTimeWarp;
01122         HKFCurveNode mLayer;        // Ctrl Curve (Animation layering) 
01123         HKFCurveNode mObjectLayer;  // Pointer to Layer 0
01124         HKFCurveNode mTemplate;
01125         HKFCurveNode mDataNode;
01126         HKFCurveNode mParent;
01127 
01128         int mLayerType;
01129         int mLayerID;
01130 
01131         int mUpdateId;
01132 
01133         public:
01134         int mMBRotationOrder;
01135         inline int GetRotationOrder() const {return mMBRotationOrder;}; 
01136         void SetRotationOrder(int pRotationOrder);
01137 
01139         int GetLayerType() const { return mLayerType; }
01140 
01141         protected:
01142         //
01143         //  Candidates in nodes (Max is KFCURVENODE_CANDIDATE_MAX_COUNT)
01144         //
01145         
01146         void FromTotalCandidateToSpecificCandidate(int pLayerID);
01147 
01148         enum {eUseFCurve = 1, eUseTotal = 2};
01149         int mSpecificCandidateMethod;  // Used as a bit field
01150         int mTotalCandidateMethod;     // Used as an enum
01151                                         // To my knowledge the possible state are       
01152                                         // No validcandidate                            mCandidateTotalTime == INFINITE and no FCurve candidate for the current time
01153                                         // Total candidate is valid and fcuve invalid   mTotalCandidateMethod ==  eUseTotal and mSpecificCandidateMethod == eUseTotal
01154                                         // FCurve is valid and Total invalid            mTotalCandidateMethod ==  eUseFCurve and mSpecificCandidateMethod == eUseFCurve
01155                                         // Total valid and FCurve computed              mTotalCandidateMethod ==  eUseTotal and mSpecificCandidateMethod == eUseTotal | eUseFCurve
01156 
01157                                         // FCurve valid and total computed              mTotalCandidateMethod ==  eUseTotal and mSpecificCandidateMethod == eUseFCurve
01158                                         // FCurve valid (and computed from total) and total computed    mTotalCandidateMethod ==  eUseTotal and mSpecificCandidateMethod == eUseTotal | eUseFCurve
01159                         
01160                     
01161                                         
01162 
01163         double mCandidateTotalValue[KFCURVENODE_CANDIDATE_MAX_COUNT];   // For all layers at once (only meaningful on ObjectLayer )
01164         KTime   mCandidateTotalTime;
01165 
01166         //
01167         //  Callbacks
01168         //
01169         
01170         KFCurveNodeCallback* mCallback;
01171         int mUserLock;
01172 
01173     private:
01174         void KeyGetCountRecursive(int& pCurveCount, int& pTotalCount, int& pMinCount, int& pMaxCount) const;
01175         bool GetAnimationIntervalRecursive (KTime& pStart, KTime& pStop) const;
01176         void IsKeyRecursive( KTime& pTime, int &pKeyCount, int &pKeyFound, int *pLast, bool *pCurveMask, double pKeyIndexTolerance = 0.0, double pMin = -K_DOUBLE_MAX,  double pMax = K_DOUBLE_MAX ) const;
01177 
01178         friend KFBX_DLL HKFCurveNode KFCurveNodeCreate (KFbx* pFbx, HKFCurveNode pParent, bool pOnlyDefaults, bool pCreateIfNotFound, bool pColor );
01179 
01180     public:
01181         //
01182         // TimeWarp
01183         //
01184 
01186         void TimeWarpSet (HKFCurveNode pLayer);
01187 
01191         HKFCurveNode TimeWarpGet () const;
01192 
01193         //
01194         // Layers
01195         //
01196 
01198         void LayerSet(HKFCurveNode pLayer, bool pDeleteCurrentAndSubLayers ); // No default value to make sure you know what you are doing
01199 
01203         HKFCurveNode LayerGet () const;
01204 
01208         HKFCurveNode LayerGet( int pLayerID );
01209 
01211         void CreateLayerAt( int pLayerID );
01212     private:
01214         HKFCurveNode LayerCreate ( int pLayerID, bool pDeleteCurrentLayer );    // No default value to make sure you know what you are doing
01215     public:
01217         virtual HKFCurveNode Find(HKDataType pDataType) const;
01218         
01223         HKFCurveNode FindRecursive(HKDataType pDataType) const;
01224 
01226         HKDataType GetDataType() const;
01227             
01231         void Delete(HKFCurveNode pNode);
01232 
01234         HKFCurveNode ObjectLayerGet() const;
01235 
01237         void ObjectLayerSet( HKFCurveNode pNode );
01238 
01240         inline int GetLayerID() const { return mLayerID; };
01241 
01243         inline void SetLayerID( int pLayerID ) { mLayerID = pLayerID; };
01244 
01246         void SetLayerType( int pLayerType, HKFCurveNode pObjectLayerNode = NULL );
01247 
01249         HKFCurveNode GetPreviousLayer( int pLayerID );
01250 
01252         HKFCurveNode RemoveLayer( int pLayerID, bool pDestroy = true );
01253 
01254         // Copy a specific anyer or create one if none exist 
01255         HKFCurveNode InsertOrCopyLayer( int pLayerId, HKFCurveNode pLayerNode );
01256 
01257         void SingleLayerCopyFrom(HKFCurveNode pSource, bool pTransferCurve = false );
01258 
01259         HKFCurveNode SingleLayerCopy(KTime pStart=KTIME_MINUS_INFINITE, KTime pStop=KTIME_INFINITE ); 
01260 
01261         //
01262         // Templates
01263         //
01264 
01266         void TemplateSet (HKFCurveNode pTemplate);
01267 
01271         HKFCurveNode TemplateGet () const;
01272 
01273         //
01274         // Copy/paste
01275         //
01276 
01278         void LayerCopyFromRecursive( HKFCurveNode pSource, bool pTransferCurve = false );
01279 
01280         //
01281         //  Candidates
01282         //
01283 
01285         bool    CandidateClear ( int pLayerID = 0, bool pClearAllSubLayersToo = true );
01286 
01288         void    CandidateClearSubLayers ();
01289         
01291         double* CandidateSet (KTime pTime, double* pValue, int pLayerID = 0, int pChildIndexInParent = -1 );
01292 
01294         double *CandidateSetSpecificLayer (KTime pTime,double *pValue, int pLayerID = 0 );
01295 
01297         double* CandidateGet (double* pValue, int pLayerID = 0 ) const;
01298         
01300         double* CandidateGetSpecificLayer( double* pValue, KTime &pCandidateTime, int pLayerID = 0 );
01301         
01303         void CandidateGetTotalCandidate( double* pValue, KTime &pCandidateTime ) const;
01304         
01306         bool IsCandidate              () const;
01307         
01309         bool    CandidateKey 
01310         (
01311             kFCurveIndex*   pLast           = NULL, 
01312             int             pLayerID        = 0, 
01313             bool*           pCurveMask      = NULL, 
01314             bool            pZeroKey        = false , 
01315             int         pInterpolation  = KFCURVE_INTERPOLATION_CUBIC, 
01316             int         pTangeantMode   = KFCURVE_TANGEANT_USER, 
01317             int         pContinuity     = KFCURVE_CONTINUITY,
01318             bool            pTanOverride    = true,
01319             KTime           pCandidateTime  = KTIME_INFINITE,
01320             double          pKeyIndexTolerance = 0.0
01321         );
01322 
01324         bool    CandidateKeySpecificLayer 
01325         (
01326             kFCurveIndex*   pLast           = NULL, 
01327             int             pLayerID        = 0, 
01328             bool*           pCurveMask      = NULL,
01329             int         pInterpolation  = KFCURVE_INTERPOLATION_CUBIC, 
01330             int         pTangeantMode   = KFCURVE_TANGEANT_USER, 
01331             int         pContinuity     = KFCURVE_CONTINUITY,
01332             bool            pTanOverride    = true,
01333             KTime           pCandidateTime  = KTIME_INFINITE,
01334             double          pKeyIndexTolerance = 0.0
01335         );
01336 
01337         // !    If CurveNode is MonoLayer it will return 0
01338         int         GetCorrectLayerID( int pLayerID ) const;
01339         HKFCurveNode    GetCorrectLayer  ( int pLayerID, bool pCreateLayerIfNesseary = false );
01340 
01342         void    ComputeCandidateForLayer( double *pDestLayerValue, double *pCandidateValue, KTime pTime, int pLayerID, kFCurveIndex *pLast );
01343 
01345         void    EvaluateCurvesExceptLayerRecursiveAdd ( double *pValue, KTime pTime, int pExceptLayerID, kFCurveIndex* pLast=NULL);
01346         
01348         void    EvaluateCurvesExceptLayerRecursiveMult ( double *pValue, KTime pTime, int pExceptLayerID, kFCurveIndex* pLast=NULL);
01349 
01351         void    EvaluateCurvesBeforeLayerRecursiveEulerXYZ ( KgeRMatrix &pBefore, KTime lCandidateTime, int pLayerID, kFCurveIndex* pLast );
01352 
01354         void    EvaluateCurvesAfterLayerRecursiveEulerXYZ  ( KgeRMatrix &pAfter, KTime lCandidateTime, int pAfterLayerID, kFCurveIndex* pLast );
01355 
01357         void    EvaluateCurvesBeforeLayerRecursiveQuat( KgeQuaternion &pBefore, KTime pTime, int pBeforeLayerID, kFCurveIndex* pLast );
01358 
01360         void    EvaluateCurvesAfterLayerRecursiveQuat ( KgeQuaternion &pAfter , KTime pTime, int pBeforeLayerID, kFCurveIndex* pLast );
01361 
01363         double* CandidateGetWithTime ( double *pValue, KTime &pCandidateTime );
01364 
01365 
01366         //
01367         // Helpers
01368         //
01369 
01371         double* EvaluateSpecificLayer( double *pValue, KTime pTime, int pLayerID, kFCurveIndex* pLast=NULL);
01372 
01374         double *CandidateEvaluateSpecificLayer( double *pValue, KTime pTime, int pLayerID, kFCurveIndex *pLast=NULL);
01375 
01377         double* GeneralEvaluate (double* pValue, KTime pTime, kFCurveIndex* pLast=NULL,bool pEvaluateCandidate=true);
01378 
01380         double* CandidateEvaluate (double* pValue, KTime pTime, kFCurveIndex* pLast=NULL);
01381 
01383         bool IsEditable ();
01384 
01386         void GetZeroValues( double *pValues ) const;
01387 
01388         // ! Content replacement for quaternions ( = with scaling of the quaternion )
01389         void ReplaceForQuaternion( HKFCurveNode pSource, KTime pStart, KTime pStop, double pScaleStart, double pScaleStop, bool pUseExactGivenSpan /*= false*/, bool pKeyStartEndOnNoKey /*= true*/, KTime pTimeSpanOffset /*= KTIME_ZERO*/ );
01390 
01391         // ! Calculates the offset between to euler rotations
01392         bool GetContinuousOffset( double pOffset[3], double pNew[3], double pOld[3] ) const;
01393 
01394         // ! Unrolls a rotation at a given time, using the previous key.
01395         void GetContinuousRotation( double pResultKeyValue[3], double pCurrentKeyValue[3], KTime pCurrentKeyTime );
01396 
01397         // ! Sets the user name
01398         void SetTimeWarpName( char* pName );
01399 
01400         // ! Returns the total key count for all child (pChildIndex) in every layer.
01401         int KeyGetCountOnChild( int pChildIndex ) const;
01402 
01403         //
01404         //  User lock
01405         //
01406 
01408         void    UserLockAdd();
01409 
01411         void    UserLockRemove();
01412 
01414         bool    IsUserLocked() const;
01415 
01416     public:
01421         virtual int SortedAdd (HKFCurveNode pNode) ;
01422 
01424     public:
01425 
01426         // For Backward compatibility reasons must be revisited please ...
01427         HIConnector mConnector; // Do not set this member because if the Connector is set, it means that it is a Connector FCurveNode. So watchout!!!
01428 
01429 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01430 
01431     };
01432 
01433 
01443     KFBX_DLL HKFCurveNode KFCurveNodeCreate(char* pNodeName, char* pTimeWarpName, char* pTypeName, int pLayerType = KFCL_NOLAYER, int pLayerID = 0);
01444     KFBX_DLL HKFCurveNode KFCurveNodeCreate(char* pNodeName, HKDataType pDataType=NULL, int pLayerType = KFCL_NOLAYER, int pLayerID = 0);
01445 
01446 
01454     KFBX_DLL HKFCurveNode KFCurveNodeCreate(HKFCurveNode pTemplateCurveNode);
01455 
01456     // Create a curve node, FBX SDK internal use only.
01457     KFBX_DLL HKFCurveNode KFCurveNodeCreate(KFbx* pFbx, bool pOnlyDefaults = false, bool pColor = false);
01458 
01459     // Create a curve node, FBX SDK internal use only.
01460     KFBX_DLL HKFCurveNode KFCurveNodeCreate(KFbx* pFbx, HKFCurveNode pParent, bool pOnlyDefaults = false, bool pCreateIfNotFound = true, bool pColor = false);
01461 
01462     // Create a layer node, FBX SDK internal use only.
01463     KFBX_DLL HKFCurveNode KFCurveNodeLayerCreate (KFbx* pFbx,HKFCurveNode pParent, bool pOnlyDefaults = false );
01464 
01465     // Create a curve node from a datatype, FBX SDK internal use only.
01466     KFBX_DLL HKFCurveNode FCurveNodeCreateFromDataType( HKDataType pDataType,char* pNodeName);
01467 
01468 #include <fbxfilesdk/fbxfilesdk_nsend.h>
01469 
01470 #endif // FBXFILESDK_COMPONENTS_KFCURVE_KFCURVENODE_H
01471