| 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 fbxblendshapechannel.h |
| 13 | #ifndef _FBXSDK_SCENE_GEOMETRY_BLEND_SHAPE_CHANNEL_H_ |
| 14 | #define _FBXSDK_SCENE_GEOMETRY_BLEND_SHAPE_CHANNEL_H_ |
| 15 | |
| 16 | #include <fbxsdk/fbxsdk_def.h> |
| 17 | |
| 18 | #include <fbxsdk/scene/geometry/fbxsubdeformer.h> |
| 19 | |
| 20 | #include <fbxsdk/fbxsdk_nsbegin.h> |
| 21 | |
| 22 | class FbxShape; |
| 23 | class FbxBlendShape; |
| 24 | |
| 25 | /** Class for blend shape channels. |
| 26 | * A blend shape channel is a sub-deformer to help blend shape deformer to organize the target shapes. |
| 27 | * One blend shape deformer can have multiple blend shape channels in parallel, and each of them can |
| 28 | * control one or multiple target shapes. If there are multiple target shapes connected to one channel, |
| 29 | * each target shape could have its own full deformation percentage. For example, given a channel that |
| 30 | * has 3 target shapes, whose full deform percentage are 30, to 80 to 100 separately, then when the percent |
| 31 | * changes from 0 to 100, the base geometry will deform from the first target shape to the last one. |
| 32 | * This is called in-between blend shapes or progressive morph. |
| 33 | * The property DeformPercent of blend shape channel will control the deform level of each target shape or |
| 34 | * in-between blend shape on it. |
| 35 | *\nosubgrouping |
| 36 | */ |
| 37 | class FBXSDK_DLL FbxBlendShapeChannel : public FbxSubDeformer |
| 38 | { |
| 39 | FBXSDK_OBJECT_DECLARE(FbxBlendShapeChannel, FbxSubDeformer); |
| 40 | |
| 41 | public: |
| 42 | /** This property stores deform percent of this channel. |
| 43 | * The default value of this property is 0.0. |
| 44 | * |
| 45 | * \remark Although not enforced, it is strongly suggested to limit the value of this property |
| 46 | * in the range from 0.0 to 100.0 because graphic applications may handle values outside of this |
| 47 | * interval differently, therefore producing unexpected results. |
| 48 | */ |
| 49 | FbxPropertyT<FbxDouble> DeformPercent; |
| 50 | |
| 51 | /** Set the blend shape deformer that contains this blend shape channel. |
| 52 | * \param pBlendShape Pointer to the blend shape deformer to set. |
| 53 | * \return \c true on success, \c false otherwise. |
| 54 | */ |
| 55 | bool SetBlendShapeDeformer(FbxBlendShape* pBlendShape); |
| 56 | |
| 57 | /** Get the blend shape deformer that contains this blend shape channel. |
| 58 | * \return A pointer to the blend shape deformer if set or NULL. |
| 59 | */ |
| 60 | FbxBlendShape* GetBlendShapeDeformer(); |
| 61 | |
| 62 | /** Add a target shape. |
| 63 | * \param pShape Pointer to the target shape to add. |
| 64 | * \param pFullDeformPercent The full deform percentage for the target shape. |
| 65 | * \return \c true on success, \c false otherwise. |
| 66 | */ |
| 67 | bool AddTargetShape(FbxShape* pShape, double pFullDeformPercent = 100); |
| 68 | |
| 69 | /** Remove the given target shape. |
| 70 | * \param pShape Pointer to the target shape to remove from this blend shape channel. |
| 71 | * \return Pointer to the target shape or \c NULL if pShape is not owned by this blend shape channel. |
| 72 | */ |
| 73 | FbxShape* RemoveTargetShape(FbxShape* pShape); |
| 74 | |
| 75 | /** Get the number of target shapes. |
| 76 | * \return Number of target shapes that have been added to this blend shape channel. |
| 77 | */ |
| 78 | int GetTargetShapeCount() const; |
| 79 | |
| 80 | /** Get the target shape at given index. |
| 81 | * \param pIndex Index of the target shape. |
| 82 | * \return Pointer to the target shape or \c NULL if index is out of range. |
| 83 | */ |
| 84 | FbxShape* GetTargetShape(int pIndex); |
| 85 | |
| 86 | /** Get the target shape at given index. |
| 87 | * \param pIndex Index of the target shape. |
| 88 | * \return Pointer to the target shape or \c NULL if index is out of range. |
| 89 | */ |
| 90 | const FbxShape* GetTargetShape(int pIndex) const; |
| 91 | |
| 92 | /** Get the index of the given target shape. |
| 93 | * \param pShape The given target shape to find index. |
| 94 | * \return The index of the target shape. |
| 95 | */ |
| 96 | int GetTargetShapeIndex( FbxShape* pShape); |
| 97 | |
| 98 | /** Get the full weight values of target shape. |
| 99 | * To access each value iterate in the array up to GetTargetShapeCount(). |
| 100 | * \return The array of full weight values of target shape. |
| 101 | */ |
| 102 | double* GetTargetShapeFullWeights(); |
| 103 | |
| 104 | /** Set the array size for the fully deform weights. |
| 105 | * This functions pre-allocate the array to pCount size. |
| 106 | * \param pCount The new array size to set. |
| 107 | */ |
| 108 | void SetFullWeightsCount(int pCount); |
| 109 | |
| 110 | /** |
| 111 | * \name General Functions |
| 112 | */ |
| 113 | //@{ |
| 114 | /** Get the type of the sub deformer. |
| 115 | * \return The sub deformer type identifier of blend shape channel. |
| 116 | */ |
| 117 | EType GetSubDeformerType() const {return eBlendShapeChannel; }; |
| 118 | |
| 119 | /** Restore the blend shape channel to the initial state. |
| 120 | * Calling this function will do the following: |
| 121 | * \li Set the DeformPercent to 0. |
| 122 | * \li Remove all target shapes. |
| 123 | * \li Clear the array for fully deform weights of in-between target shapes. |
| 124 | */ |
| 125 | void Reset(); |
| 126 | |
| 127 | |
| 128 | /***************************************************************************************************************************** |
| 129 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
| 130 | *****************************************************************************************************************************/ |
| 131 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 132 | virtual FbxObject& Copy(const FbxObject& pObject); |
| 133 | virtual FbxObject* Clone(FbxObject::ECloneType pCloneType=eDeepClone, FbxObject* pContainer=NULL, void* pSet = NULL) const; |
| 134 | |
| 135 | protected: |
| 136 | virtual void Construct(const FbxObject* pFrom); |
| 137 | virtual void ConstructProperties(bool pForceSet); |
| 138 | |
| 139 | virtual FbxStringList GetTypeFlags() const; |
| 140 | |
| 141 | //The full weights array of each shapes on this blend shape channel |
| 142 | FbxArray<double> mShapeFullWeightArray; |
| 143 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
| 144 | }; |
| 145 | |
| 146 | #include <fbxsdk/fbxsdk_nsend.h> |
| 147 | |
| 148 | #endif /* _FBXSDK_SCENE_GEOMETRY_BLEND_SHAPE_CHANNEL_H_ */ |
| 149 | |