| 1 | /**************************************************************************************** |
| 2 | |
| 3 | Copyright (C) 2015 Autodesk, Inc. |
| 4 | All rights reserved. |
| 5 | |
| 6 | Use of this software is subject to the terms of the Autodesk license agreement |
| 7 | provided at the time of installation or download, or which otherwise accompanies |
| 8 | this software in either electronic or hard copy form. |
| 9 | |
| 10 | ****************************************************************************************/ |
| 11 | |
| 12 | //! \file fbxtransforms.h |
| 13 | #ifndef _FBXSDK_CORE_MATH_TRANSFORMS_H_ |
| 14 | #define _FBXSDK_CORE_MATH_TRANSFORMS_H_ |
| 15 | |
| 16 | #include <fbxsdk/fbxsdk_def.h> |
| 17 | |
| 18 | #include <fbxsdk/core/math/fbxmath.h> |
| 19 | #include <fbxsdk/core/math/fbxquaternion.h> |
| 20 | |
| 21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
| 22 | |
| 23 | /** FbxLimits defines a limit range for one transform component, either translation, rotation or scaling. |
| 24 | * One transform component limit contains two part: a min value and a max value limit, which means |
| 25 | * that each value of the corresponding transform component cannot go beyond the range set by the |
| 26 | * min and max values. Although the members are identified as X, Y and Z (the W component is ignored) |
| 27 | * at this level, they are unitless values and will only have meaning within the context they are queried. |
| 28 | * |
| 29 | * For each limit, there is one flag to indicate if the limit is active or not. Before accessing the |
| 30 | * limit info, the caller need to query the flag first to make sure that the retrieved values will be |
| 31 | * meaningful. |
| 32 | * \nosubgrouping |
| 33 | */ |
| 34 | class FBXSDK_DLL FbxLimits |
| 35 | { |
| 36 | public: |
| 37 | //! Constructor |
| 38 | FbxLimits(); |
| 39 | |
| 40 | //! Assignment Operator |
| 41 | FbxLimits& operator=(const FbxLimits& pLimits); |
| 42 | |
| 43 | /** Retrieve the active state of this limit. |
| 44 | * \return True if the limit is active. |
| 45 | */ |
| 46 | bool GetActive() const; |
| 47 | |
| 48 | /** Set the active state of this limit. |
| 49 | * \param pActive If true, this limit will become globally active. |
| 50 | */ |
| 51 | void SetActive(const bool pActive); |
| 52 | |
| 53 | /** Get the active state of the minimum X component. |
| 54 | * \return True if the X component minimum limit is active. |
| 55 | */ |
| 56 | bool GetMinXActive() const; |
| 57 | |
| 58 | /** Get the active state of the minimum Y component. |
| 59 | * \return True if the Y component minimum limit is active. |
| 60 | */ |
| 61 | bool GetMinYActive() const; |
| 62 | |
| 63 | /** Get the active state of the minimum Z component. |
| 64 | * \return True if the Z component minimum limit is active. |
| 65 | */ |
| 66 | bool GetMinZActive() const; |
| 67 | |
| 68 | /** Get the active states of the three components of the minimum limit. |
| 69 | * \param pXActive \c True if the X component minimum limit is active. |
| 70 | * \param pYActive \c True if the Y component minimum limit is active. |
| 71 | * \param pZActive \c True if the Z component minimum limit is active. |
| 72 | */ |
| 73 | void GetMinActive(bool& pXActive, bool& pYActive, bool& pZActive) const; |
| 74 | |
| 75 | /** Get the minimum limits. |
| 76 | * \return The current X, Y and Z values for the minimum limits. |
| 77 | */ |
| 78 | FbxDouble3 GetMin() const; |
| 79 | |
| 80 | /** Set the active state of the minimum X component. |
| 81 | * \param pActive If true, the X component minimum limit will be active. |
| 82 | */ |
| 83 | void SetMinXActive(bool pActive); |
| 84 | |
| 85 | /** Set the active state of the minimum Y component. |
| 86 | * \param pActive If true, the Y component minimum limit will be active. |
| 87 | */ |
| 88 | void SetMinYActive(bool pActive); |
| 89 | |
| 90 | /** Set the active state of the minimum Z component. |
| 91 | * \param pActive If true, the Z component minimum limit will be active. |
| 92 | */ |
| 93 | void SetMinZActive(bool pActive); |
| 94 | |
| 95 | /** Set the active states of the three components of the minimum limits. |
| 96 | * \param pXActive If true, the X component minimum limit will be active. |
| 97 | * \param pYActive If true, the Y component minimum limit will be active. |
| 98 | * \param pZActive If true, the Z component minimum limit will be active. |
| 99 | */ |
| 100 | void SetMinActive(bool pXActive, bool pYActive, bool pZActive); |
| 101 | |
| 102 | /** Set the minimum limits. |
| 103 | * \param pMin The X, Y and Z values for the minimum limits. |
| 104 | */ |
| 105 | void SetMin(const FbxDouble3& pMin); |
| 106 | |
| 107 | /** Get the active state of the maximum X component. |
| 108 | * \return True if the X component maximum limit is active. |
| 109 | */ |
| 110 | bool GetMaxXActive() const; |
| 111 | |
| 112 | /** Get the active state of the maximum Y component. |
| 113 | * \return True if the Y component maximum limit is active. |
| 114 | */ |
| 115 | bool GetMaxYActive() const; |
| 116 | |
| 117 | /** Get the active state of the maximum Z component. |
| 118 | * \return True if the Z component maximum limit is active. |
| 119 | */ |
| 120 | bool GetMaxZActive() const; |
| 121 | |
| 122 | /** Get the active states of the three components of the maximum limit. |
| 123 | * \param pXActive \c True if the X component maximum limit is active. |
| 124 | * \param pYActive \c True if the Y component maximum limit is active. |
| 125 | * \param pZActive \c True if the Z component maximum limit is active. |
| 126 | */ |
| 127 | void GetMaxActive(bool& pXActive, bool& pYActive, bool& pZActive) const; |
| 128 | |
| 129 | /** Get the maximum limits. |
| 130 | * \return The current X, Y and Z values for the maximum limits. |
| 131 | */ |
| 132 | FbxDouble3 GetMax() const; |
| 133 | |
| 134 | /** Set the active state of the maximum X component. |
| 135 | * \param pActive If true, the X component maximum limit will be active. |
| 136 | */ |
| 137 | void SetMaxXActive(bool pActive); |
| 138 | |
| 139 | /** Set the active state of the maximum Y component. |
| 140 | * \param pActive If true, the Y component maximum limit will be active. |
| 141 | */ |
| 142 | void SetMaxYActive(bool pActive); |
| 143 | |
| 144 | /** Set the active state of the maximum Z component. |
| 145 | * \param pActive If true, the Z component maximum limit will be active. |
| 146 | */ |
| 147 | void SetMaxZActive(bool pActive); |
| 148 | |
| 149 | /** Set the active states of the three components of the maximum limits. |
| 150 | * \param pXActive If true, the X component maximum limit will be active. |
| 151 | * \param pYActive If true, the Y component maximum limit will be active. |
| 152 | * \param pZActive If true, the Z component maximum limit will be active. |
| 153 | */ |
| 154 | void SetMaxActive(bool pXActive, bool pYActive, bool pZActive); |
| 155 | |
| 156 | /** Set the maximum limits. |
| 157 | * \param pMax The X, Y and Z values for the maximum limits. |
| 158 | */ |
| 159 | void SetMax(const FbxDouble3& pMax); |
| 160 | |
| 161 | /** Find if any of the minimum or maximum active state are set. |
| 162 | * \return If any component of the minimum or maximum active state are set, true is returned. |
| 163 | * \remarks The global active state will not count when resolving this. |
| 164 | */ |
| 165 | bool GetAnyMinMaxActive() const; |
| 166 | |
| 167 | /** Apply the active limits to the components of the vector provided. |
| 168 | * \return The new vector clamped by active limits. |
| 169 | */ |
| 170 | FbxDouble3 Apply(const FbxDouble3& pVector); |
| 171 | |
| 172 | /***************************************************************************************************************************** |
| 173 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
| 174 | *****************************************************************************************************************************/ |
| 175 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 176 | private: |
| 177 | enum EMask {eActive=1<<0, eMinX=1<<1, eMinY=1<<2, eMinZ=1<<3, eMaxX=1<<4, eMaxY=1<<5, eMaxZ=1<<6, eAll=eMinX|eMinY|eMinZ|eMaxX|eMaxY|eMaxZ}; |
| 178 | |
| 179 | FbxUInt8 mMask; |
| 180 | FbxDouble3 mMin; |
| 181 | FbxDouble3 mMax; |
| 182 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
| 183 | }; |
| 184 | |
| 185 | class FBXSDK_DLL FbxRotationOrder |
| 186 | { |
| 187 | public: |
| 188 | FbxRotationOrder(FbxEuler::EOrder pOrder=FbxEuler::eOrderXYZ); |
| 189 | |
| 190 | FbxEuler::EOrder GetOrder() const; |
| 191 | void SetOrder(FbxEuler::EOrder pOrder); |
| 192 | void V2M(FbxAMatrix& pRM, const FbxVector4& pV); |
| 193 | void M2V(FbxVector4& pV, const FbxAMatrix& pRM); |
| 194 | bool V2VRef(FbxVector4& pVOut, const FbxVector4& pVIn, const FbxVector4& pVRef); |
| 195 | |
| 196 | private: |
| 197 | FbxEuler::EOrder mOrder; |
| 198 | }; |
| 199 | |
| 200 | /** Handle transform behaviors such as pivots, limits and offets, etc. |
| 201 | */ |
| 202 | class FBXSDK_DLL FbxTransform |
| 203 | { |
| 204 | public: |
| 205 | enum EInheritType {, eInheritRSrs, eInheritRrs}; |
| 206 | |
| 207 | FbxTransform(); |
| 208 | |
| 209 | EInheritType GetInheritType() const; |
| 210 | void SetInheritType(EInheritType pType); |
| 211 | FbxLimits& GetTranslationLimits(); |
| 212 | FbxLimits& GetRotationLimits(); |
| 213 | FbxLimits& GetScalingLimits(); |
| 214 | FbxRotationOrder& GetRotationOrder(); |
| 215 | bool HasROffset() const; |
| 216 | bool HasRPivot() const; |
| 217 | bool HasSOffset() const; |
| 218 | bool HasSPivot() const; |
| 219 | bool HasPreRM() const; |
| 220 | bool HasPostRM() const; |
| 221 | void SetROffset(const FbxVector4& pROffset); |
| 222 | void SetRPivot(const FbxVector4& pRPivot); |
| 223 | void SetSOffset(const FbxVector4& pSOffset); |
| 224 | void SetSPivot(const FbxVector4& pSPivot); |
| 225 | void SetPreRM(const FbxVector4& pPreR); |
| 226 | void SetPostRM(const FbxVector4& pPostR); |
| 227 | bool GetRotationSpaceForLimitOnly() const; |
| 228 | void SetRotationSpaceForLimitOnly(bool pRotationSpaceForLimitOnly); |
| 229 | |
| 230 | void DoF2LT(FbxVector4& pLT, const FbxVector4& pDoF, const FbxAMatrix& pLRM, const FbxAMatrix& pLSM); |
| 231 | void LT2DoF(FbxVector4& pDoF, const FbxVector4& pLT, const FbxAMatrix& pLRM, const FbxAMatrix& pLSM); |
| 232 | void DoF2LRM(FbxAMatrix& pLRM, const FbxVector4& pRDoF, bool pForLimit=false); |
| 233 | void LRM2DoF(FbxVector4& pRDoF, const FbxAMatrix& pLRM, bool pForLimit=false); |
| 234 | void LSM2GSM(FbxAMatrix& pGSM, const FbxAMatrix& pPGSM, const FbxAMatrix& pLSM, const FbxAMatrix& pLRM, const FbxVector4& pPLS); |
| 235 | void GTRSM2GX(FbxAMatrix& pGX, const FbxVector4& pGT, const FbxAMatrix& pGRM, const FbxAMatrix& pGSM); |
| 236 | |
| 237 | private: |
| 238 | void SumPivots(FbxVector4& pSum, const FbxAMatrix& pLRM, const FbxAMatrix& pLSM); |
| 239 | |
| 240 | class RotationSpace |
| 241 | { |
| 242 | public: |
| 243 | enum EMask {eHasNothing=0, eHasPreRotM=1<<0, eHasPostRotM=1<<1}; |
| 244 | |
| 245 | RotationSpace(); |
| 246 | |
| 247 | bool HasPreRM() const; |
| 248 | bool HasPostRM() const; |
| 249 | void GetPreRM(FbxAMatrix& pPreRM) const; |
| 250 | void GetPostRM(FbxAMatrix& pPostRM) const; |
| 251 | void SetPreRM(const FbxVector4& pPreR); |
| 252 | void SetPostRM(const FbxVector4& pPostR); |
| 253 | void DoF2LRM(FbxAMatrix& pLRM, const FbxVector4& pRDoF); |
| 254 | void LRM2DoF(FbxVector4& pRDoF, const FbxAMatrix& pLRM); |
| 255 | |
| 256 | FbxUInt8 mMask; |
| 257 | FbxAMatrix mPreRM; |
| 258 | FbxAMatrix mPostRM; |
| 259 | FbxRotationOrder mRotationOrder; |
| 260 | }; |
| 261 | |
| 262 | enum EMask {eHasNothing=0, eHasRotOffset=1<<0, eHasRotPivot=1<<1, eHasScaleOffset=1<<2, eHasScalePivot=1<<3}; |
| 263 | |
| 264 | FbxUInt8 mMask; |
| 265 | EInheritType mInheritType; |
| 266 | FbxVector4 mROffset; |
| 267 | FbxVector4 mRPivot; |
| 268 | FbxVector4 mSOffset; |
| 269 | FbxVector4 mSPivot; |
| 270 | FbxLimits mTranslationLimits; |
| 271 | FbxLimits mRotationLimits; |
| 272 | FbxLimits mScalingLimits; |
| 273 | bool mRotationSpaceForLimitOnly; |
| 274 | RotationSpace mRotationSpace; |
| 275 | }; |
| 276 | |
| 277 | FBXSDK_DLL bool FbxGetContinuousRotation(FbxVector4& pRes, const FbxVector4& pRot, const FbxVector4& pRef, const int* pOrder); |
| 278 | FBXSDK_DLL void FbxGetContinuousRotation(FbxVector4& pRes, const FbxVector4& pRot, const FbxVector4& pRef); |
| 279 | |
| 280 | #include <fbxsdk/fbxsdk_nsend.h> |
| 281 | |
| 282 | #endif /* _FBXSDK_CORE_MATH_TRANSFORMS_H_ */ |
| 283 | |