PixelLightAPI  .
MorphTargetAni.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: MorphTargetAni.h                               *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLMESH_MORPHTARGETANI_H__
00024 #define __PLMESH_MORPHTARGETANI_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Container/Element.h>
00032 #include <PLCore/Container/ElementManager.h>
00033 #include <PLCore/Container/ElementHandler.h>
00034 #include <PLRenderer/Animation/AnimationBase.h>
00035 #include "PLMesh/PLMesh.h"
00036 
00037 
00038 //[-------------------------------------------------------]
00039 //[ Namespace                                             ]
00040 //[-------------------------------------------------------]
00041 namespace PLMesh {
00042 
00043 
00044 //[-------------------------------------------------------]
00045 //[ Forward declarations                                  ]
00046 //[-------------------------------------------------------]
00047 class Mesh;
00048 
00049 
00050 //[-------------------------------------------------------]
00051 //[ Classes                                               ]
00052 //[-------------------------------------------------------]
00053 /**
00054 *  @brief
00055 *    Morph target animation class
00056 */
00057 class MorphTargetAni : public PLRenderer::AnimationBase, public PLCore::Element<MorphTargetAni> {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ Public structures                                     ]
00062     //[-------------------------------------------------------]
00063     public:
00064         /**
00065         *  @brief
00066         *    Animation morph target
00067         */
00068         class AniMorphTarget {
00069 
00070 
00071             //[-------------------------------------------------------]
00072             //[ Public data                                           ]
00073             //[-------------------------------------------------------]
00074             public:
00075                 PLCore::String sName; /**< Morph target name */
00076 
00077 
00078             //[-------------------------------------------------------]
00079             //[ Public functions                                      ]
00080             //[-------------------------------------------------------]
00081             public:
00082                 PLMESH_API AniMorphTarget()
00083                 {
00084                 }
00085 
00086                 PLMESH_API ~AniMorphTarget()
00087                 {
00088                 }
00089 
00090                 PLMESH_API bool operator ==(const AniMorphTarget &cAniMorphTarget) const
00091                 {
00092                     return sName == cAniMorphTarget.sName;
00093                 }
00094 
00095 
00096         };
00097 
00098 
00099     //[-------------------------------------------------------]
00100     //[ Public functions                                      ]
00101     //[-------------------------------------------------------]
00102     public:
00103         /**
00104         *  @brief
00105         *    Constructor
00106         *
00107         *  @param[in] sName
00108         *    Name
00109         *  @param[in] pManager
00110         *    Element manager using this element, can be a null pointer
00111         *
00112         *  @note
00113         *    - If you provide the pointer to the owner manager the morph target animation
00114         *      will check in the owner morph target animation manager name list
00115         *    - If the desired name is already in use inside the owner manager an alternative
00116         *      name is set
00117         */
00118         PLMESH_API MorphTargetAni(const PLCore::String &sName, PLCore::ElementManager<MorphTargetAni> *pManager = nullptr);
00119 
00120         /**
00121         *  @brief
00122         *    Destructor
00123         */
00124         PLMESH_API virtual ~MorphTargetAni();
00125 
00126         /**
00127         *  @brief
00128         *    Returns the morph target animation morph targets
00129         *
00130         *  @return
00131         *    Morph target animation morph targets
00132         */
00133         PLMESH_API PLCore::Array<AniMorphTarget> &GetMorphTargets();
00134 
00135         /**
00136         *  @brief
00137         *    Applies the morph target weight from the given morph target frame
00138         *    to the given morph target weights
00139         *
00140         *  @param[out] lstMorphTargetWeights
00141         *    Morph target weights to manipulate
00142         *  @param[in]  nFrame
00143         *    Morph target animation frame
00144         *  @param[in]  fWeight
00145         *    Weight (0.0-1.0)
00146         *  @param[in]  pMesh
00147         *    Mesh of the given morph target weights array, can be a null pointer
00148         *
00149         *  @return
00150         *    'true' if all went fine, else 'false'
00151         *
00152         *  @note
00153         *    - If pMesh is not a null pointer lstMorphTargetWeights is a list of ALL morph target influences
00154         *      of the given mesh, else lstMorphTargetWeights is only a list of the morph target
00155         *      weights of THIS animation!
00156         */
00157         PLMESH_API bool ApplyMorphTargetWeight(PLCore::Array<float> &lstMorphTargetWeights,
00158                                                PLCore::uint32 nFrame, float fWeight = 1.0f, const Mesh *pMesh = nullptr) const;
00159 
00160         /**
00161         *  @brief
00162         *    Applies the blended morph target weight from the given morph target frames
00163         *    to the given morph target weights
00164         *
00165         *  @param[out] lstMorphTargetWeights
00166         *    Morph target weights to manipulate
00167         *  @param[in]  nFrame1
00168         *    Morph target animation frame 1
00169         *  @param[in]  nFrame2
00170         *    Morph target animation frame 2
00171         *  @param[in]  fTime
00172         *    Morph target animation time (0.0-1.0)
00173         *  @param[in]  fWeight
00174         *    Weight (0.0-1.0)
00175         *  @param[in]  pMesh
00176         *    Mesh of the given morph target weights array, can be a null pointer
00177         *
00178         *  @return
00179         *    'true' if all went fine, else 'false'
00180         *
00181         *  @see
00182         *    - ApplyMorphTargetWeight() above
00183         */
00184         PLMESH_API bool ApplyMorphTargetWeight(PLCore::Array<float> &lstMorphTargetWeights,
00185                                                PLCore::uint32 nFrame1, PLCore::uint32 nFrame2, float fTime,
00186                                                float fWeight = 1.0f, const Mesh *pMesh = nullptr) const;
00187 
00188 
00189     //[-------------------------------------------------------]
00190     //[ Private data                                          ]
00191     //[-------------------------------------------------------]
00192     private:
00193         PLCore::Array<AniMorphTarget> m_lstAniMorphTargets;
00194 
00195 
00196     //[-------------------------------------------------------]
00197     //[ Public virtual AnimationInfo functions                ]
00198     //[-------------------------------------------------------]
00199     public:
00200         PLMESH_API virtual MorphTargetAni &operator =(const MorphTargetAni &cSource);
00201         PLMESH_API virtual PLCore::String GetSourceName() const override;
00202 
00203 
00204 };
00205 
00206 
00207 /**
00208 *  @brief
00209 *    Morph target animation manager
00210 */
00211 class MorphTargetAniManager : public PLCore::ElementManager<MorphTargetAni> {
00212 
00213 
00214     //[-------------------------------------------------------]
00215     //[ Public functions                                      ]
00216     //[-------------------------------------------------------]
00217     public:
00218         /**
00219         *  @brief
00220         *    Constructor
00221         */
00222         PLMESH_API MorphTargetAniManager();
00223 
00224         /**
00225         *  @brief
00226         *    Destructor
00227         */
00228         PLMESH_API virtual ~MorphTargetAniManager();
00229 
00230 
00231     //[-------------------------------------------------------]
00232     //[ Private virtual PLCore::ElementManager functions      ]
00233     //[-------------------------------------------------------]
00234     private:
00235         virtual MorphTargetAni *CreateElement(const PLCore::String &sName) override;
00236 
00237 
00238 };
00239 
00240 
00241 //[-------------------------------------------------------]
00242 //[ Namespace                                             ]
00243 //[-------------------------------------------------------]
00244 } // PLMesh
00245 
00246 
00247 #endif // __PLMESH_MORPHTARGETANI_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:58
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported