2
Copyright (C) 2004 Erik Hjortsberg
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
#ifndef AVATARCONTROLLER_H
20
#define AVATARCONTROLLER_H
22
#include "EmberOgrePrerequisites.h"
26
#include <sigc++/trackable.h>
28
#include "services/input/Input.h"
29
#include "services/input/InputCommandMapper.h"
30
#include "framework/ConsoleObject.h"
31
#include "EntityWorldPickListener.h"
43
class AvatarController;
46
The movement mode of the avatar, run or walk.
48
class AvatarMovementMode {
59
Used for sending the current desired movement to the actual avatar.
61
struct AvatarControllerMovement
63
AvatarControllerMovement();
65
float rotationDegHoriz;
66
float rotationDegVert;
68
Ogre::Vector3 movementDirection;
69
AvatarMovementMode::Mode mode;
71
Ogre::Quaternion cameraOrientation;
75
Listens for left mouse button pressed in movement mode and moves the character forward.
77
class AvatarControllerInputListener
80
AvatarControllerInputListener(AvatarController& controller);
84
void input_MouseButtonPressed(Ember::Input::MouseButton button, Ember::Input::InputMode mode);
85
void input_MouseButtonReleased(Ember::Input::MouseButton button, Ember::Input::InputMode mode);
86
AvatarController& mController;
90
Controls the avatar. All avatar movement is handled by an instance of this class.
92
class AvatarController
93
: public Ogre::FrameListener,
94
public sigc::trackable,
95
public Ember::ConsoleObject
98
friend class AvatarControllerInputListener;
100
AvatarController(Avatar& avatar, Ogre::RenderWindow& window, GUIManager& guiManager, Ogre::Camera& camera);
102
virtual ~AvatarController();
105
Each frame we check if we should update the avatar.
107
virtual bool frameStarted(const Ogre::FrameEvent & event);
111
Emitted when the movement mode changes between run and walk.
113
sigc::signal<void, AvatarMovementMode::Mode> EventMovementModeChanged;
117
void createAvatarCameras(Ogre::SceneNode* avatarSceneNode);
120
* Gets the AvatarCamera.
123
AvatarCamera* getAvatarCamera() const;
126
* Detaches the camera from the avatar and attaches it to the free flying node.
131
* Attaches the camera to the avatar.
136
* Gets the current movement for this frame.
139
const AvatarControllerMovement& getCurrentMovement() const;
141
const Ember::ConsoleCommandWrapper RunToggle;
142
const Ember::ConsoleCommandWrapper ToggleCameraAttached;
144
const Ember::ConsoleCommandWrapper CharacterMoveForward;
145
const Ember::ConsoleCommandWrapper CharacterMoveBackward;
146
const Ember::ConsoleCommandWrapper CharacterMoveDownwards;
147
const Ember::ConsoleCommandWrapper CharacterMoveUpwards;
148
const Ember::ConsoleCommandWrapper CharacterStrafeLeft;
149
const Ember::ConsoleCommandWrapper CharacterStrafeRight;
150
/* const Ember::ConsoleCommandWrapper CharacterRotateLeft;
151
const Ember::ConsoleCommandWrapper CharacterRotateRight;*/
153
const Ember::ConsoleCommandWrapper MoveCameraTo;
157
* Reimplements the ConsoleObject::runCommand method
161
virtual void runCommand(const std::string &command, const std::string &args);
164
Moves the avatar to the specified point.
165
A terrain decal will be shown.
167
void moveToPoint(const Ogre::Vector3& point);
170
* Teleports the avatar to the specified point.
172
* @param locationEntity
174
void teleportTo(const Ogre::Vector3& point, EmberEntity* locationEntity);
178
Ember::InputCommandMapper mMovementCommandMapper;
180
Ogre::RenderWindow& mWindow;
182
GUIManager& mGUIManager;
185
// void checkMovementKeys(const Ogre::FrameEvent & event, const Input& input);
188
AvatarCamera* mAvatarCamera;
189
Ogre::Camera& mCamera;
197
EmberEntity* mEntityUnderCursor;
198
EmberEntity* mSelectedEntity;
200
AvatarControllerMovement movementForFrame, mPreviousMovementForFrame;
202
Ogre::SceneNode* mFreeFlyingCameraNode;
205
True if we're in running mode.
209
Ogre::Vector3 mMovementDirection;
212
Listen for double clicks and send the avatar to the double clicked position.
214
void entityPicker_PickedEntity(const EntityPickResult& result, const MousePickerArgs& args);
217
Creates the terrain decal needed for displaying where the avatar is heading.
219
void createDecal(Ogre::Vector3 position);
222
A decal object for showing a decal on the terrain when the user uses the "move to here" functionality.
223
The decal will be shown at the destination, and removed when the user either gets close to it, or aborts the "move to here" movement (for example by moving manually).
225
Ogre::MovableObject* mDecalObject;
228
The scene node to which the decal object for showing the destination of a "move to here" movement operation is attached.
230
Ogre::SceneNode* mDecalNode;
233
Controller for making the decal pulsate a little.
234
@note Not used currently.
236
// Ogre::WaveformControllerFunction* mPulsatingController;
238
AvatarControllerInputListener mControllerInputListener;
245
#endif // AvatarController_H