PixelLightAPI  .
SNMRotationTarget.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMRotationTarget.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_ROTATIONTARGET_H__
00024 #define __PLSCENE_SCENENODEMODIFIER_ROTATIONTARGET_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Event/EventHandler.h>
00032 #include <PLMath/Vector3.h>
00033 #include "PLScene/Scene/SceneNodeModifiers/SNMTransform.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Forward declarations                                  ]
00038 //[-------------------------------------------------------]
00039 namespace PLRenderer {
00040     class Renderer;
00041 }
00042 namespace PLScene {
00043     class VisNode;
00044 }
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Namespace                                             ]
00049 //[-------------------------------------------------------]
00050 namespace PLScene {
00051 
00052 
00053 //[-------------------------------------------------------]
00054 //[ Classes                                               ]
00055 //[-------------------------------------------------------]
00056 /**
00057 *  @brief
00058 *    Scene node modifier class rotating a scene node towards a target scene node
00059 *
00060 *  @remarks
00061 *    Rotates the scene node so it's always 'looking at' a given target scene node. This modifier doesn't
00062 *    offer 'target offsets' because they can be easy and universal constructed by using for instance a 'SNMAnchor'
00063 *    scene node modifier in combination with a 'SNHelper' scene node.
00064 */
00065 class SNMRotationTarget : public SNMTransform {
00066 
00067 
00068     //[-------------------------------------------------------]
00069     //[ RTTI interface                                        ]
00070     //[-------------------------------------------------------]
00071     pl_class(PLS_RTTI_EXPORT, SNMRotationTarget, "PLScene", PLScene::SNMTransform, "Scene node modifier class rotating a scene node towards a target scene node")
00072         // Attributes
00073         pl_attribute(Target,    PLCore::String,     "",                                 ReadWrite,  DirectValue,    "Target scene node to 'look at', if empty nothing happens", "")
00074         pl_attribute(Offset,    PLMath::Vector3,    PLMath::Vector3(0.0f, 0.0f, 0.0f),  ReadWrite,  DirectValue,    "Rotation offset to add in degree, [0, 360]",               "")
00075         pl_attribute(UpVector,  PLMath::Vector3,    PLMath::Vector3(0.0f, 1.0f, 0.0f),  ReadWrite,  DirectValue,    "Up vector",                                                "")
00076         // Constructors
00077         pl_constructor_1(ParameterConstructor,  SceneNode&, "Parameter constructor",    "")
00078     pl_class_end
00079 
00080 
00081     //[-------------------------------------------------------]
00082     //[ Public functions                                      ]
00083     //[-------------------------------------------------------]
00084     public:
00085         /**
00086         *  @brief
00087         *    Constructor
00088         *
00089         *  @param[in] cSceneNode
00090         *    Owner scene node
00091         */
00092         PLS_API SNMRotationTarget(SceneNode &cSceneNode);
00093 
00094         /**
00095         *  @brief
00096         *    Destructor
00097         */
00098         PLS_API virtual ~SNMRotationTarget();
00099 
00100 
00101     //[-------------------------------------------------------]
00102     //[ Protected virtual SceneNodeModifier functions         ]
00103     //[-------------------------------------------------------]
00104     protected:
00105         PLS_API virtual void OnActivate(bool bActivate) override;
00106 
00107 
00108     //[-------------------------------------------------------]
00109     //[ Private functions                                     ]
00110     //[-------------------------------------------------------]
00111     private:
00112         /**
00113         *  @brief
00114         *    Returns the target position within the container space of the owner node
00115         *
00116         *  @param[out] vPos
00117         *    Will receive the position of the target scene node, not manipulated on error
00118         *
00119         *  @return
00120         *    'true' if all went fine, else 'false' (invalid target?)
00121         */
00122         bool GetTargetPosition(PLMath::Vector3 &vPos) const;
00123 
00124         /**
00125         *  @brief
00126         *    Called on scene node debug draw
00127         *
00128         *  @param[in] cRenderer
00129         *    The used renderer
00130         *  @param[in] pVisNode
00131         *    The current visibility node of this scene node, can be a null pointer
00132         */
00133         void OnDrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode);
00134 
00135         /**
00136         *  @brief
00137         *    Called on scene node position change or update request
00138         */
00139         void OnPositionUpdate();
00140 
00141 
00142     //[-------------------------------------------------------]
00143     //[ Private event handlers                                ]
00144     //[-------------------------------------------------------]
00145     private:
00146         PLCore::EventHandler<>                                        EventHandlerPositionUpdate;
00147         PLCore::EventHandler<PLRenderer::Renderer &, const VisNode *> EventHandlerDrawDebug;
00148 
00149 
00150 };
00151 
00152 
00153 //[-------------------------------------------------------]
00154 //[ Namespace                                             ]
00155 //[-------------------------------------------------------]
00156 } // PLScene
00157 
00158 
00159 #endif // __PLSCENE_SCENENODEMODIFIER_ROTATIONTARGET_H__


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