PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SNMPositionKeyframeAnimation.h * 00003 * 00004 * Copyright (C) 2002-2012 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 __PLSCENE_SCENENODEMODIFIER_POSITIONKEYFRAMEANIMATION_H__ 00024 #define __PLSCENE_SCENENODEMODIFIER_POSITIONKEYFRAMEANIMATION_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Event/EventHandler.h> 00032 #include "PLScene/Scene/SceneNodeModifiers/SNMTransform.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLCore { 00039 class Chunk; 00040 } 00041 namespace PLRenderer { 00042 class Animation; 00043 } 00044 00045 00046 //[-------------------------------------------------------] 00047 //[ Namespace ] 00048 //[-------------------------------------------------------] 00049 namespace PLScene { 00050 00051 00052 //[-------------------------------------------------------] 00053 //[ Classes ] 00054 //[-------------------------------------------------------] 00055 /** 00056 * @brief 00057 * Keyframe position animation scene node modifier class 00058 * 00059 * @remarks 00060 * Animates the position of the scene nodes over time using keyframes. 00061 * 00062 * @note 00063 * - The "CoordinateSystem" attribute can be quite useful if the scene contains portals 00064 */ 00065 class SNMPositionKeyframeAnimation : public SNMTransform { 00066 00067 00068 //[-------------------------------------------------------] 00069 //[ Public definition ] 00070 //[-------------------------------------------------------] 00071 public: 00072 /** 00073 * @brief 00074 * Scene node modifier flags (SceneNodeModifier flags extension) 00075 */ 00076 enum EFlags { 00077 PlaybackNoLoop = 1<<2, /**< No loop animation */ 00078 PlaybackPingPong = 1<<3 /**< Ping pong animation */ 00079 }; 00080 pl_enum(EFlags) 00081 pl_enum_base(SNMTransform::EFlags) 00082 pl_enum_value(PlaybackNoLoop, "No loop animation") 00083 pl_enum_value(PlaybackPingPong, "Ping pong animation") 00084 pl_enum_end 00085 00086 00087 //[-------------------------------------------------------] 00088 //[ RTTI interface ] 00089 //[-------------------------------------------------------] 00090 pl_class(PLS_RTTI_EXPORT, SNMPositionKeyframeAnimation, "PLScene", PLScene::SNMTransform, "Keyframe position animation scene node modifier class") 00091 // Attributes 00092 pl_attribute(Speed, float, 1.0f, ReadWrite, DirectValue, "Animation playback speed", "") 00093 pl_attribute(FramesPerSecond, PLCore::uint32, 24, ReadWrite, DirectValue, "Frames per second", "") 00094 pl_attribute(Keys, PLCore::String, "", ReadWrite, GetSet, "Position keys (x, y and z) chunk filename", "") 00095 pl_attribute(CoordinateSystem, PLCore::String, "", ReadWrite, DirectValue, "Name of the scene container the position keys are in, empty string means scene container of the modifiers owner scene node", "") 00096 // Overwritten SceneNodeModifier attributes 00097 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "") 00098 // Constructors 00099 pl_constructor_1(ParameterConstructor, SceneNode&, "Parameter constructor", "") 00100 pl_class_end 00101 00102 00103 //[-------------------------------------------------------] 00104 //[ Public RTTI get/set functions ] 00105 //[-------------------------------------------------------] 00106 public: 00107 PLS_API PLCore::String GetKeys() const; 00108 PLS_API void SetKeys(const PLCore::String &sValue); 00109 00110 00111 //[-------------------------------------------------------] 00112 //[ Public functions ] 00113 //[-------------------------------------------------------] 00114 public: 00115 /** 00116 * @brief 00117 * Constructor 00118 * 00119 * @param[in] cSceneNode 00120 * Owner scene node 00121 */ 00122 PLS_API SNMPositionKeyframeAnimation(SceneNode &cSceneNode); 00123 00124 /** 00125 * @brief 00126 * Destructor 00127 */ 00128 PLS_API virtual ~SNMPositionKeyframeAnimation(); 00129 00130 /** 00131 * @brief 00132 * Returns the chunk holding the keyframe data 00133 * 00134 * @return 00135 * The chunk holding the keyframe data 00136 */ 00137 PLS_API PLCore::Chunk &GetChunk(); 00138 00139 /** 00140 * @brief 00141 * Returns the animation controller 00142 * 00143 * @return 00144 * The animation controller 00145 */ 00146 PLS_API PLRenderer::Animation &GetAnimation(); 00147 00148 00149 //[-------------------------------------------------------] 00150 //[ Protected virtual SceneNodeModifier functions ] 00151 //[-------------------------------------------------------] 00152 protected: 00153 PLS_API virtual void OnActivate(bool bActivate) override; 00154 00155 00156 //[-------------------------------------------------------] 00157 //[ Private functions ] 00158 //[-------------------------------------------------------] 00159 private: 00160 /** 00161 * @brief 00162 * Called when the scene node modifier needs to be updated 00163 */ 00164 void OnUpdate(); 00165 00166 00167 //[-------------------------------------------------------] 00168 //[ Private event handlers ] 00169 //[-------------------------------------------------------] 00170 private: 00171 PLCore::EventHandler<> EventHandlerUpdate; 00172 00173 00174 //[-------------------------------------------------------] 00175 //[ Private data ] 00176 //[-------------------------------------------------------] 00177 private: 00178 PLCore::String m_sKeys; /**< Position keys (x, y and z) chunk filename */ 00179 PLCore::Chunk *m_pChunk; /**< Chunk holding the keyframe data, always valid! */ 00180 PLRenderer::Animation *m_pAnimation; /**< Animation */ 00181 00182 00183 }; 00184 00185 00186 //[-------------------------------------------------------] 00187 //[ Namespace ] 00188 //[-------------------------------------------------------] 00189 } // PLScene 00190 00191 00192 #endif // __PLSCENE_SCENENODEMODIFIER_POSITIONKEYFRAMEANIMATION_H__
|