PixelLightAPI  .
AnchorPoint.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: AnchorPoint.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_ANCHORPOINT_H__
00024 #define __PLMESH_ANCHORPOINT_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 "PLMesh/PLMesh.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Namespace                                             ]
00039 //[-------------------------------------------------------]
00040 namespace PLMesh {
00041 
00042 
00043 //[-------------------------------------------------------]
00044 //[ Forward declarations                                  ]
00045 //[-------------------------------------------------------]
00046 class AnchorPointManager;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    An anchor points holds the index to a vertex or bone
00055 *
00056 *  @remarks
00057 *    SceneNode is the best example for it's usage. You can create anchor points for a mesh in
00058 *    the PixelLight mesh editor and if you want to get it's position in the world you just have
00059 *    to call the function GetAnchorPoint("MyAnchorPoint"). With this anchor points you are able
00060 *    to connect e.g. particle effects etc. to mesh vertices without to much effort.
00061 *    Bone anchor points have the advantage that you will also receive the current bone rotation.
00062 */
00063 class AnchorPoint : public PLCore::Element<AnchorPoint> {
00064 
00065 
00066     //[-------------------------------------------------------]
00067     //[ Public functions                                      ]
00068     //[-------------------------------------------------------]
00069     public:
00070         /**
00071         *  @brief
00072         *    Constructor
00073         *
00074         *  @param[in] sName
00075         *    Name of the anchor point
00076         *  @param[in] bType
00077         *    Anchor type (0=vertex  1=bone)
00078         *  @param[in] nID
00079         *    ID of the vertex/bone the anchor is attached to
00080         *  @param[in] pManager
00081         *    Anchor point manager using this element, can be a null pointer
00082         *
00083         *  @note
00084         *    - If you provide the pointer to the owner manager the anchor point
00085         *      will check in the anchor point manager name list
00086         */
00087         PLMESH_API AnchorPoint(const PLCore::String &sName = "", bool bType = 0, PLCore::uint32 nID = 0, AnchorPointManager *pManager = nullptr);
00088 
00089         /**
00090         *  @brief
00091         *    Destructor
00092         */
00093         PLMESH_API virtual ~AnchorPoint();
00094 
00095         /**
00096         *  @brief
00097         *    Returns the anchor type
00098         *
00099         *  @return
00100         *    Anchor type (0=vertex  1=bone)
00101         */
00102         PLMESH_API bool GetType() const;
00103 
00104         /**
00105         *  @brief
00106         *    Sets the anchor type
00107         *
00108         *  @param[in] bType
00109         *    Anchor type (0=vertex  1=bone)
00110         */
00111         PLMESH_API void SetType(bool bType = 0);
00112 
00113         /**
00114         *  @brief
00115         *    Returns the anchors vertex/bone ID
00116         *
00117         *  @return
00118         *    ID of the vertex/bone the anchor is attached to
00119         */
00120         PLMESH_API PLCore::uint32 GetID() const;
00121 
00122         /**
00123         *  @brief
00124         *    Sets the anchors vertex/bone ID
00125         *
00126         *  @param[in] nID
00127         *    ID of the vertex/bone the anchor is attached to
00128         */
00129         PLMESH_API void SetID(PLCore::uint32 nID = 0);
00130 
00131 
00132     //[-------------------------------------------------------]
00133     //[ Private data                                          ]
00134     //[-------------------------------------------------------]
00135     private:
00136         bool           m_bType; /**< Anchor point type (0=vertex  1=joint) */
00137         PLCore::uint32 m_nID;   /**< Vertex/bone ID the anchor is attached to */
00138 
00139 
00140     //[-------------------------------------------------------]
00141     //[ Public virtual PLCore::Element functions              ]
00142     //[-------------------------------------------------------]
00143     public:
00144         PLMESH_API virtual AnchorPoint &operator =(const AnchorPoint &cSource);
00145 
00146 
00147 };
00148 
00149 /**
00150 *  @brief
00151 *    Anchor point manager
00152 */
00153 class AnchorPointManager : public PLCore::ElementManager<AnchorPoint> {
00154 
00155 
00156     //[-------------------------------------------------------]
00157     //[ Public functions                                      ]
00158     //[-------------------------------------------------------]
00159     public:
00160         /**
00161         *  @brief
00162         *    Constructor
00163         */
00164         PLMESH_API AnchorPointManager();
00165 
00166         /**
00167         *  @brief
00168         *    Destructor
00169         */
00170         PLMESH_API virtual ~AnchorPointManager();
00171 
00172 
00173     //[-------------------------------------------------------]
00174     //[ Private virtual PLCore::ElementManager functions      ]
00175     //[-------------------------------------------------------]
00176     private:
00177         virtual AnchorPoint *CreateElement(const PLCore::String &sName) override;
00178 
00179 
00180 };
00181 
00182 
00183 //[-------------------------------------------------------]
00184 //[ Namespace                                             ]
00185 //[-------------------------------------------------------]
00186 } // PLMesh
00187 
00188 
00189 #endif // __PLMESH_ANCHORPOINT_H__


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