~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/widgets/MovableObjectRenderer.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// C++ Interface: MovableObjectRenderer
 
3
//
 
4
// Description: 
 
5
//
 
6
//
 
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2006
 
8
//
 
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.
 
13
// 
 
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.
 
18
// 
 
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.//
 
22
//
 
23
#ifndef EMBEROGREMOVABLEOBJECTRENDERER_H
 
24
#define EMBEROGREMOVABLEOBJECTRENDERER_H
 
25
 
 
26
#include <CEGUIEvent.h> 
 
27
 
 
28
#include "components/ogre/EmberOgrePrerequisites.h"
 
29
#include "services/input/IInputAdapter.h"
 
30
#include "../SimpleRenderContext.h"
 
31
 
 
32
namespace CEGUI
 
33
{
 
34
class GUISheet;
 
35
}
 
36
 
 
37
namespace EmberOgre {
 
38
namespace Gui {
 
39
 
 
40
class EntityCEGUITexture;
 
41
 
 
42
/**
 
43
Class used for rendering a single Ogre::MovableObject to a EntityCEGUITexture
 
44
 
 
45
@author Erik Hjortsberg
 
46
*/
 
47
class MovableObjectRenderer : public Ember::IInputAdapter, public Ogre::FrameListener
 
48
{
 
49
public:
 
50
    MovableObjectRenderer(CEGUI::Window* image);
 
51
 
 
52
    virtual ~MovableObjectRenderer();
 
53
    
 
54
    /**
 
55
     * Adapts the position of the camera so that the whole scene is shown.
 
56
     */
 
57
    void showFull();
 
58
    
 
59
    /**
 
60
     * Sets the distance of the camera from the Model.
 
61
     * @param distance 
 
62
     */
 
63
    void setCameraDistance(float distance);
 
64
    
 
65
    /**
 
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.
 
67
     * @return 
 
68
     */
 
69
    float getCameraDistance();
 
70
    
 
71
        /**
 
72
         *    Gets the distance of the camera from the model in world units.
 
73
         * @return 
 
74
         */
 
75
        float getAbsoluteCameraDistance();
 
76
        
 
77
   
 
78
    
 
79
    
 
80
    /**
 
81
     * Returns whether input catching (and also rotation of the model) is allowed.
 
82
     * Defaults to true.
 
83
     * @return 
 
84
     */
 
85
    bool getIsInputCatchingAllowed() const;
 
86
    
 
87
    /**
 
88
     * Sets whether input catching (and also rotation of the model) is allowed.
 
89
     * @param allowed 
 
90
     */
 
91
    void setIsInputCatchingAllowed(bool allowed);
 
92
    
 
93
    /**
 
94
     * Gets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
 
95
     * Defaults to true.
 
96
     * @return 
 
97
     */
 
98
    void setAutoShowFull(bool showFull);
 
99
    
 
100
    /**
 
101
     * Sets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
 
102
     * @return 
 
103
     */
 
104
    bool getAutoShowFull() const;
 
105
    
 
106
    bool getActive() const {return mActive;}
 
107
    void setActive(bool isActive) {mActive = isActive;}
 
108
 
 
109
/**
 
110
---------Methods implemented from IInputAdapter
 
111
@see IInputAdapter
 
112
*/
 
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);
 
119
 
 
120
 
 
121
        /**
 
122
         * Methods from Ogre::FrameListener
 
123
         */
 
124
        virtual bool frameStarted(const Ogre::FrameEvent& event);
 
125
 
 
126
 
 
127
        /**
 
128
         *    Gets the rotation of the entity.
 
129
         * @return 
 
130
         */
 
131
        Ogre::Quaternion getEntityRotation();
 
132
        
 
133
        
 
134
        /**
 
135
         *    Resets the orientation of the camera.
 
136
         */
 
137
        void resetCameraOrientation();
 
138
        
 
139
        /**
 
140
         *    Pitches the camera.
 
141
         * @param degrees The amount of degrees to pitch.
 
142
         */
 
143
        void pitch(Ogre::Degree degrees);
 
144
        
 
145
        /**
 
146
         *    Yaws the camera.
 
147
         * @param degrees The amount of degree to yaw.
 
148
         */
 
149
        void yaw(Ogre::Degree degrees);
 
150
    
 
151
        /**
 
152
         *    Rolls the camera.
 
153
         * @param degrees The amount of degree to roll.
 
154
         */
 
155
    void roll(Ogre::Degree degrees);
 
156
    
 
157
    /**
 
158
     * Updates the texture by rendering one frame manually.
 
159
     */
 
160
    void updateRender();
 
161
    
 
162
    /**
 
163
     * Sets the background colour.
 
164
     * @param colour 
 
165
     */
 
166
    void setBackgroundColour(const Ogre::ColourValue& colour);
 
167
    /**
 
168
     * Sets the background colour.
 
169
     * @param red 
 
170
     * @param green 
 
171
     * @param blue 
 
172
     * @param  
 
173
     */
 
174
    void setBackgroundColour(float red, float green, float blue, float alpha);
 
175
    
 
176
    /**
 
177
     * Shows an axis mesh in the middle of the scene. Useful for authoring.
 
178
     */
 
179
    void showAxis();    
 
180
    
 
181
    /**
 
182
     * Hides the axis mesh.
 
183
     */
 
184
    void hideAxis();      
 
185
    
 
186
        /**
 
187
         *    Gets the current camera positioning mode. The default is CPM_OBJECTCENTER which centers the camera on the current displayed object.
 
188
         * @return 
 
189
         */
 
190
        SimpleRenderContext::CameraPositioningMode getCameraPositionMode() const;
 
191
    
 
192
        /**
 
193
         *    Sets the camera positioning mode. This determines how the camera behaves.
 
194
         * @param mode 
 
195
         */
 
196
        void setCameraPositionMode(SimpleRenderContext::CameraPositioningMode mode);
 
197
                
 
198
protected:
 
199
 
 
200
        /**
 
201
         *    Catches input and allows for rotation of the Model
 
202
         *    @see releaseInput
 
203
         */
 
204
        void catchInput();
 
205
        
 
206
        /**
 
207
         *    Releases input caught with catchInput
 
208
         *    @see catchInput
 
209
         */
 
210
        void releaseInput();
 
211
        
 
212
        
 
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.
 
215
         * @param args 
 
216
         * @return 
 
217
         */
 
218
        bool image_MouseButtonDown(const CEGUI::EventArgs& args);
 
219
        
 
220
        
 
221
        /**
 
222
         *    Mouse wheel movements will zoom in and out.
 
223
         * @param args 
 
224
         * @return 
 
225
         */
 
226
        bool image_MouseWheel(const CEGUI::EventArgs& args);
 
227
        
 
228
    EntityCEGUITexture* mTexture;
 
229
    /**
 
230
    If true, the input will be caught when the user clicks on the image, allowing for rotation of the model.
 
231
    */
 
232
    bool mIsInputCatchingAllowed;
 
233
 
 
234
        /**
 
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
 
236
        */
 
237
        bool mAutoShowFull;
 
238
        
 
239
        CEGUI::Window* mImage;
 
240
        
 
241
        virtual Ogre::MovableObject* getMovableObject() = 0;
 
242
        
 
243
        bool mActive;
 
244
        
 
245
        Ogre::Entity* mAxisEntity;
 
246
        Ogre::SceneNode* mAxesNode;
 
247
 
 
248
};
 
249
}
 
250
}
 
251
 
 
252
#endif