2
// C++ Interface: ModelMount
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2008
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
23
#ifndef EMBEROGREMODELMOUNT_H
24
#define EMBEROGREMODELMOUNT_H
26
#include <wfmath/axisbox.h>
40
@brief Acts as a mount for a model, connecting it to two scene nodes.
41
A model can contain internal orientation and offset data. This requires us to use two different scene nodes for each model instance. The inner most scene node, called the "scale node", is the one which the Model is attached to. This is then offset and oriented in relation to the outer scene node. Whenever we move the Model, we move only the outer scene node, leaving the inner scene node completely in the hands of the Model.
42
The scale node will be owned by this class.
43
@author Erik Hjortsberg <erik.hjortsberg@gmail.com>
50
* @param model The model which we need a mount for.
51
* @param mainNode The main node. A scale node will be created as a child, to which the model then will be attached. Ownership of the main node isn't transferred to this class, but the scale node that's created will be owned, and destroyed, by this class.
53
ModelMount(::EmberOgre::Model::Model& model, Ogre::SceneNode* mainNode);
57
* The scale node will be destroyed here.
59
virtual ~ModelMount();
62
* @brief Gets the main node. This is the node to use when positioning or rotating the Model.
63
* @return The main node.
65
Ogre::SceneNode* getMainNode() const;
68
* @brief Gets the scale node. This is the node to which the Model is directly attached to. It should normally never be altered outside of this class.
69
* Under normal circumstances the scale node is handed solely by this class and should never be modified from outside functionality. Accessing through this method is mainly for lookup purposes, when you need to read the orientation or scale of the bounding box.
70
* @return The scale node, to which the Model is attached.
72
Ogre::SceneNode* getScaleNode() const;
75
* @brief Gets the Model instance to which this mount is attached.
76
* @return The model instance.
78
::EmberOgre::Model::Model& getModel() const;
81
* @brief Rescales the model according to the bounding box.
82
* @param wfBbox The bounding box to the model should be scaled. If you don't have an axis box available, just send null.
84
void rescale(const WFMath::AxisBox<3>* wfBbox);
86
// const Ogre::Vector3 calculateScaling(::EmberOgre::Model::Model& model, const WFMath::AxisBox<3>* wfBbox);
91
*@brief The Model which this mount is attached to.
93
::EmberOgre::Model::Model& mModel;
96
* @brief The inner scale node, to which the model is attached to.
97
* It's this node that we'll change the orientation and position of. This node should never be touched by outside functionality.
99
Ogre::SceneNode* mScaleNode;
102
* @brief The main node, to which the scale node is attached.
103
* This node is the external node, used for positioning the Model.
105
Ogre::SceneNode* mMainNode;
109
* @brief Resets all scaling and rotation
114
* @brief Scales the scale node accoring to the submitted bounding box.
115
* @note You should in almost all cases call reset() before calling this method.
116
* @param wfBbox The bounding box, in WF space, for which we should scale the node, or null if there's no bbox available.
118
void scaleNode(const WFMath::AxisBox<3>* wfBbox);
121
* @brief Gets the active scaling node. If the model is attached to a node already, this will be used, else the mScaleNode will be used.
122
* @return The active scaling node.
124
Ogre::Node* getActiveScaleNode() const;
128
inline Ogre::SceneNode* ModelMount::getMainNode() const
134
inline ::EmberOgre::Model::Model& ModelMount::getModel() const