2
// C++ Interface: MovableObjectRenderer
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2006
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 EMBEROGREMOVABLEOBJECTRENDERER_H
24
#define EMBEROGREMOVABLEOBJECTRENDERER_H
26
#include <CEGUIEvent.h>
28
#include "components/ogre/EmberOgrePrerequisites.h"
29
#include "services/input/IInputAdapter.h"
30
#include "../SimpleRenderContext.h"
40
class EntityCEGUITexture;
43
Class used for rendering a single Ogre::MovableObject to a EntityCEGUITexture
45
@author Erik Hjortsberg
47
class MovableObjectRenderer : public Ember::IInputAdapter, public Ogre::FrameListener
50
MovableObjectRenderer(CEGUI::Window* image);
52
virtual ~MovableObjectRenderer();
55
* Adapts the position of the camera so that the whole scene is shown.
60
* Sets the distance of the camera from the Model.
63
void setCameraDistance(float distance);
66
* Gets the distance of the camera from the Model in reltive terms with 1.0 being the optimal distance to show the full model.
69
float getCameraDistance();
72
* Gets the distance of the camera from the model in world units.
75
float getAbsoluteCameraDistance();
81
* Returns whether input catching (and also rotation of the model) is allowed.
85
bool getIsInputCatchingAllowed() const;
88
* Sets whether input catching (and also rotation of the model) is allowed.
91
void setIsInputCatchingAllowed(bool allowed);
94
* Gets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
98
void setAutoShowFull(bool showFull);
101
* Sets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
104
bool getAutoShowFull() const;
106
bool getActive() const {return mActive;}
107
void setActive(bool isActive) {mActive = isActive;}
110
---------Methods implemented from IInputAdapter
113
virtual bool injectMouseMove(const Ember::MouseMotion& motion, bool& freezeMouse);
114
virtual bool injectMouseButtonUp(const Ember::Input::MouseButton& button);
115
virtual bool injectMouseButtonDown(const Ember::Input::MouseButton& button);
116
virtual bool injectChar(char character);
117
virtual bool injectKeyDown(const SDLKey& key);
118
virtual bool injectKeyUp(const SDLKey& key);
122
* Methods from Ogre::FrameListener
124
virtual bool frameStarted(const Ogre::FrameEvent& event);
128
* Gets the rotation of the entity.
131
Ogre::Quaternion getEntityRotation();
135
* Resets the orientation of the camera.
137
void resetCameraOrientation();
140
* Pitches the camera.
141
* @param degrees The amount of degrees to pitch.
143
void pitch(Ogre::Degree degrees);
147
* @param degrees The amount of degree to yaw.
149
void yaw(Ogre::Degree degrees);
153
* @param degrees The amount of degree to roll.
155
void roll(Ogre::Degree degrees);
158
* Updates the texture by rendering one frame manually.
163
* Sets the background colour.
166
void setBackgroundColour(const Ogre::ColourValue& colour);
168
* Sets the background colour.
174
void setBackgroundColour(float red, float green, float blue, float alpha);
177
* Shows an axis mesh in the middle of the scene. Useful for authoring.
182
* Hides the axis mesh.
187
* Gets the current camera positioning mode. The default is CPM_OBJECTCENTER which centers the camera on the current displayed object.
190
SimpleRenderContext::CameraPositioningMode getCameraPositionMode() const;
193
* Sets the camera positioning mode. This determines how the camera behaves.
196
void setCameraPositionMode(SimpleRenderContext::CameraPositioningMode mode);
201
* Catches input and allows for rotation of the Model
207
* Releases input caught with catchInput
213
/**CEGUI::StaticImage* image
214
* When the mouse button is pressed over the image, catch input and allow for rotation of the model. When the mouse button is releases, also release input.
218
bool image_MouseButtonDown(const CEGUI::EventArgs& args);
222
* Mouse wheel movements will zoom in and out.
226
bool image_MouseWheel(const CEGUI::EventArgs& args);
228
EntityCEGUITexture* mTexture;
230
If true, the input will be caught when the user clicks on the image, allowing for rotation of the model.
232
bool mIsInputCatchingAllowed;
235
used to decide if the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
239
CEGUI::Window* mImage;
241
virtual Ogre::MovableObject* getMovableObject() = 0;
245
Ogre::Entity* mAxisEntity;
246
Ogre::SceneNode* mAxesNode;