PixelLightAPI  .
SNMAnchor.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMAnchor.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_ANCHOR_H__
00024 #define __PLSCENE_SCENENODEMODIFIER_ANCHOR_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLMath/Vector3.h>
00032 #include "PLScene/Scene/SceneNodeHandler.h"
00033 #include "PLScene/Scene/SceneNodeModifier.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLScene {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Classes                                               ]
00044 //[-------------------------------------------------------]
00045 /**
00046 *  @brief
00047 *    Scene node anchor modifier class
00048 *
00049 *  @remarks
00050 *    By using this modifier, you can link together scene nodes in multiple ways.
00051 */
00052 class SNMAnchor : public SceneNodeModifier {
00053 
00054 
00055     //[-------------------------------------------------------]
00056     //[ Public definitions                                    ]
00057     //[-------------------------------------------------------]
00058     public:
00059         /**
00060         *  @brief
00061         *    Flags (SceneNodeModifier flags extension)
00062         */
00063         enum EFlags {
00064             NoPosition        = 1<<2,   /**< Do NOT manipulate the position */
00065             NoRotation        = 1<<3,   /**< Do NOT manipulate the rotation */
00066             NoContainerUpdate = 1<<4    /**< Do NOT change the container the attached node is in */
00067         };
00068         pl_enum(EFlags)
00069             pl_enum_base(SceneNodeModifier::EFlags)
00070             pl_enum_value(NoPosition,           "Do NOT manipulate the position")
00071             pl_enum_value(NoRotation,           "Do NOT manipulate the rotation")
00072             pl_enum_value(NoContainerUpdate,    "Do NOT change the container the attached node is in")
00073         pl_enum_end
00074 
00075 
00076     //[-------------------------------------------------------]
00077     //[ RTTI interface                                        ]
00078     //[-------------------------------------------------------]
00079     pl_class(PLS_RTTI_EXPORT, SNMAnchor, "PLScene", PLScene::SceneNodeModifier, "Scene node anchor modifier class")
00080         // Attributes
00081         pl_attribute(AttachedNode,          PLCore::String,         "",                                 ReadWrite,  GetSet,         "Name of the attached scene node",                                                                              "")
00082         pl_attribute(PositionOffset,        PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Position offset (node space)",                                                                                 "")
00083         pl_attribute(RotationOffset,        PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Rotation offset in degree (node space)",                                                                       "")
00084         pl_attribute(SkeletonJoint,         PLCore::String,         "",                                 ReadWrite,  DirectValue,    "If not empty, the attached node is relative to this skeleton joint (there must be a mesh handler + skeleton)", "")
00085         pl_attribute(JointPositionOffset,   PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Joint position offset (joint space)",                                                                          "")
00086         pl_attribute(JointRotationOffset,   PLMath::Vector3,        PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Joint rotation offset in degree (joint space)",                                                                "")
00087             // Overwritten SceneNodeModifier attributes
00088         pl_attribute(Flags,                 pl_flag_type(EFlags),   0,                                  ReadWrite,  GetSet,         "Flags",                                                                                                        "")
00089         // Constructors
00090         pl_constructor_1(ParameterConstructor,  SceneNode&, "Parameter constructor",    "")
00091         // Slots
00092         pl_slot_0(OnContainer,              "Called when the scene node container changed",                                 "")
00093         pl_slot_0(OnPositionRotationUpdate, "Called when the scene node position or rotation changed or on update request", "")
00094     pl_class_end
00095 
00096 
00097     //[-------------------------------------------------------]
00098     //[ Public RTTI get/set functions                         ]
00099     //[-------------------------------------------------------]
00100     public:
00101         PLS_API PLCore::String GetAttachedNode() const;
00102         PLS_API void SetAttachedNode(const PLCore::String &sValue);
00103 
00104 
00105     //[-------------------------------------------------------]
00106     //[ Public functions                                      ]
00107     //[-------------------------------------------------------]
00108     public:
00109         /**
00110         *  @brief
00111         *    Constructor
00112         *
00113         *  @param[in] cSceneNode
00114         *    Owner scene node
00115         */
00116         PLS_API SNMAnchor(SceneNode &cSceneNode);
00117 
00118         /**
00119         *  @brief
00120         *    Destructor
00121         */
00122         PLS_API virtual ~SNMAnchor();
00123 
00124 
00125     //[-------------------------------------------------------]
00126     //[ Protected virtual SceneNodeModifier functions         ]
00127     //[-------------------------------------------------------]
00128     protected:
00129         PLS_API virtual void OnActivate(bool bActivate) override;
00130 
00131 
00132     //[-------------------------------------------------------]
00133     //[ Private functions                                     ]
00134     //[-------------------------------------------------------]
00135     private:
00136         /**
00137         *  @brief
00138         *    Called when the scene node container changed
00139         */
00140         void OnContainer();
00141 
00142         /**
00143         *  @brief
00144         *    Called when the scene node position or rotation changed or on update request
00145         */
00146         void OnPositionRotationUpdate();
00147 
00148 
00149     //[-------------------------------------------------------]
00150     //[ Private data                                          ]
00151     //[-------------------------------------------------------]
00152     private:
00153         PLCore::String m_sAttachedNode;
00154         SceneNodeHandler  m_cAttachedNodeHandler;
00155 
00156 
00157 };
00158 
00159 
00160 //[-------------------------------------------------------]
00161 //[ Namespace                                             ]
00162 //[-------------------------------------------------------]
00163 } // PLScene
00164 
00165 
00166 #endif // __PLSCENE_SCENENODEMODIFIER_ANCHOR_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