PixelLightAPI  .
SNMMeshJoint.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMMeshJoint.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 __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__
00024 #define __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLMath/Vector3.h>
00032 #include "PLScene/Scene/SceneNodeModifiers/SNMMesh.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039     class Renderer;
00040 }
00041 namespace PLScene {
00042     class VisNode;
00043 }
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Namespace                                             ]
00048 //[-------------------------------------------------------]
00049 namespace PLScene {
00050 
00051 
00052 //[-------------------------------------------------------]
00053 //[ Classes                                               ]
00054 //[-------------------------------------------------------]
00055 /**
00056 *  @brief
00057 *    Mesh scene node joint modifier class
00058 *
00059 *  @note
00060 *    - Adds automatically a "PLScene::SNMMeshUpdate" scene node modifier (if there's not yet one) in order to frequently update the mesh
00061 *    - If the node has no mesh with a skeleton, this modifier will have no effect
00062 */
00063 class SNMMeshJoint : public SNMMesh {
00064 
00065 
00066     //[-------------------------------------------------------]
00067     //[ Public definitions                                    ]
00068     //[-------------------------------------------------------]
00069     public:
00070         /**
00071         *  @brief
00072         *    Flags (SceneNodeModifier flags extension)
00073         */
00074         enum EFlags {
00075             UseFallbackRotation = 1<<2  /**< Use fallback rotation if the target is 'out of rotation range' */
00076         };
00077         pl_enum(EFlags)
00078             pl_enum_base(SNMMesh::EFlags)
00079             pl_enum_value(UseFallbackRotation, "Use fallback rotation if the target is 'out of rotation range'")
00080         pl_enum_end
00081 
00082 
00083     //[-------------------------------------------------------]
00084     //[ RTTI interface                                        ]
00085     //[-------------------------------------------------------]
00086     pl_class(PLS_RTTI_EXPORT, SNMMeshJoint, "PLScene", PLScene::SNMMesh, "Mesh scene node joint modifier class")
00087         // Attributes
00088         pl_attribute(Name,              PLCore::String,         "",                                 ReadWrite,  GetSet,         "Name of the joint to modify",                                                          "")
00089         pl_attribute(Rotation,          PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  GetSet,         "Joint rotation in degree (joint space)",                                               "")
00090         pl_attribute(RotationFrom,      PLCore::String,         "",                                 ReadWrite,  DirectValue,    "Name of the scene node to take the rotation from (transformed into joint space)",      "")
00091         pl_attribute(Min,               PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  GetSet,         "Minimum joint rotation in in degree, if min = max -> no limitation, per component",    "")
00092         pl_attribute(Max,               PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  GetSet,         "Maximum joint rotation in in degree, if min = max -> no limitation, per component",    "")
00093         pl_attribute(Speed,             float,                  5.0f,                               ReadWrite,  DirectValue,    "Rotation speed",                                                                       "")
00094         pl_attribute(MaxDifference,     float,                  50.0f,                              ReadWrite,  DirectValue,    "Maximum rotation difference in degree, use it to void TO fast rotations",              "")
00095         pl_attribute(FallbackRotation,  PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Rotation that is used if the target is 'out of rotation range'",                       "")
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         // Slots
00101         pl_slot_0(OnUpdate,                                             "Called when the scene node modifier needs to be updated",                                                                                                              "")
00102         pl_slot_2(OnDrawDebug,  PLRenderer::Renderer&,  const VisNode*, "Called on scene node debug draw, the used renderer as first parameter, the current visibility node of this scene node (can be a null pointer) as second parameter",    "")
00103     pl_class_end
00104 
00105 
00106     //[-------------------------------------------------------]
00107     //[ Public RTTI get/set functions                         ]
00108     //[-------------------------------------------------------]
00109     public:
00110         PLS_API PLCore::String GetName() const;
00111         PLS_API void SetName(const PLCore::String &sValue);
00112         PLS_API const PLMath::Vector3 &GetRotation() const;
00113         PLS_API void SetRotation(const PLMath::Vector3 &vValue);
00114         PLS_API const PLMath::Vector3 &GetMin() const;
00115         PLS_API void SetMin(const PLMath::Vector3 &vValue);
00116         PLS_API const PLMath::Vector3 &GetMax() const;
00117         PLS_API void SetMax(const PLMath::Vector3 &vValue);
00118 
00119 
00120     //[-------------------------------------------------------]
00121     //[ Public functions                                      ]
00122     //[-------------------------------------------------------]
00123     public:
00124         /**
00125         *  @brief
00126         *    Constructor
00127         *
00128         *  @param[in] cSceneNode
00129         *    Owner scene node
00130         */
00131         PLS_API SNMMeshJoint(SceneNode &cSceneNode);
00132 
00133         /**
00134         *  @brief
00135         *    Destructor
00136         */
00137         PLS_API virtual ~SNMMeshJoint();
00138 
00139 
00140     //[-------------------------------------------------------]
00141     //[ Protected virtual SceneNodeModifier functions         ]
00142     //[-------------------------------------------------------]
00143     protected:
00144         PLS_API virtual void OnActivate(bool bActivate) override;
00145 
00146 
00147     //[-------------------------------------------------------]
00148     //[ Private functions                                     ]
00149     //[-------------------------------------------------------]
00150     private:
00151         /**
00152         *  @brief
00153         *    Returns the target rotation within the container space of the owner node
00154         *
00155         *  @param[out] qRot
00156         *    Will receive the rotation of the target scene node
00157         *
00158         *  @return
00159         *    'true' if all went fine, else 'false' (invalid target?)
00160         */
00161         bool GetTargetRotation(PLMath::Quaternion &qRot) const;
00162 
00163         /**
00164         *  @brief
00165         *    Updates the joint
00166         */
00167         void UpdateJoint();
00168 
00169         /**
00170         *  @brief
00171         *    Called when the scene node modifier needs to be updated
00172         */
00173         void OnUpdate();
00174 
00175         /**
00176         *  @brief
00177         *    Called on scene node debug draw
00178         *
00179         *  @param[in] cRenderer
00180         *    The used renderer
00181         *  @param[in] pVisNode
00182         *    The current visibility node of this scene node, can be a null pointer
00183         */
00184         void OnDrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode);
00185 
00186 
00187     //[-------------------------------------------------------]
00188     //[ Private data                                          ]
00189     //[-------------------------------------------------------]
00190     private:
00191         PLCore::String  m_sName;        /**< Name of the joint to modify */
00192         PLMath::Vector3 m_vRotation;    /**< Joint rotation in degree (joint space) */
00193         PLMath::Vector3 m_vMin;         /**< Minimum joint rotation in in degree, if min = max -> no limitation, per component */
00194         PLMath::Vector3 m_vMax;         /**< Maximum joint rotation in in degree, if min = max -> no limitation, per component */
00195 
00196 
00197 };
00198 
00199 
00200 //[-------------------------------------------------------]
00201 //[ Namespace                                             ]
00202 //[-------------------------------------------------------]
00203 } // PLScene
00204 
00205 
00206 #endif // __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__


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