From: <eg...@us...> - 2006-04-16 16:35:59
|
Revision: 54 Author: egore Date: 2006-04-16 09:35:29 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/opengate/?rev=54&view=rev Log Message: ----------- split the game even further into more object oriented stuff, breaks pretty much everything Modified Paths: -------------- include/Makefile.am include/Makefile.in include/application.h include/avatar.h include/framelistener.h Added Paths: ----------- include/camera.h include/gamestate.h include/keyboard.h include/mouse.h include/movable_object.h Modified: include/Makefile.am =================================================================== --- include/Makefile.am 2006-04-14 14:29:31 UTC (rev 53) +++ include/Makefile.am 2006-04-16 16:35:29 UTC (rev 54) @@ -10,7 +10,11 @@ application.h\ framelistener.h\ constants.h\ - optimize.h\ - avatar.h + avatar.h\ + keyboard.h\ + mouse.h\ + camera.h\ + gamestate.h\ + movable_object.h EXTRA_DIST = $(opengate_include_DATA) Modified: include/Makefile.in =================================================================== --- include/Makefile.in 2006-04-14 14:29:31 UTC (rev 53) +++ include/Makefile.in 2006-04-16 16:35:29 UTC (rev 54) @@ -187,7 +187,13 @@ opengate_include_DATA = \ application.h\ framelistener.h\ - constants.h + constants.h\ + avatar.h\ + keyboard.h\ + mouse.h\ + camera.h\ + gamestate.h\ + movable_object.h EXTRA_DIST = $(opengate_include_DATA) all: all-am Modified: include/application.h =================================================================== --- include/application.h 2006-04-14 14:29:31 UTC (rev 53) +++ include/application.h 2006-04-16 16:35:29 UTC (rev 54) @@ -25,10 +25,13 @@ #ifndef _APPLICATION_H #define _APPLICATION_H -#include <Ogre.h> #include <OgreConfigFile.h> +#include <OgreRoot.h> +#include <OgreCamera.h> +#include <OgreRenderWindow.h> #include "framelistener.h" #include "avatar.h" +#include "camera.h" #ifdef __cplusplus extern "C" @@ -60,15 +63,22 @@ protected: + CEGUI::OgreCEGUIRenderer* mGUIRenderer; + CEGUI::System* mGUISystem; + CEGUI::Window* mEditorGuiSheet; + Avatar* mAvatar; - SceneNode* mAvatarNode; + Ogre::SceneNode* mAvatarNode; - Root* mRoot; - Camera* mCamera; - SceneManager* mSceneMgr; - MyListener* mFrameListener; - RenderWindow* mWindow; + Ogre::Root* mRoot; + Camera* mCamera; + Ogre::SceneManager* mSceneMgr; + OpengateListener* mFrameListener; + Ogre::RenderWindow* mWindow; + + Ogre::SceneManager* mGuiSceneMgr; + /** Sets up the application - returns false if the user chooses to abandon configuration. */ bool setup(void); @@ -86,14 +96,6 @@ */ void createCamera(); - /*! \brief Creates a viewport with the given cameras for the scene - * - * This method creates the viewport to the scene. This is what the user will - * actually see when playing the game. The viewport uses the given cameras - * to get its picture. - */ - virtual void createViewports(void); - /*! \brief Define what is in the scene * * This method created an initial scene. So here some common things will be @@ -120,6 +122,9 @@ /// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); virtual void loadResources(void); + void setupEventHandlers(void); + + bool handleQuit(const CEGUI::EventArgs& e); }; #ifdef __cplusplus Modified: include/avatar.h =================================================================== --- include/avatar.h 2006-04-14 14:29:31 UTC (rev 53) +++ include/avatar.h 2006-04-16 16:35:29 UTC (rev 54) @@ -26,23 +26,24 @@ #define _AVATAR_H #include <OgreSceneNode.h> +#include "movable_object.h" #ifdef __cplusplus extern "C" { #endif -using namespace Ogre; - -class Avatar { +class Avatar : public MovableObject { public: /*! \brief Creates the avatar (not the graphical representation, the real - * one + * one) */ - Avatar(SceneNode* node); + Avatar(Ogre::SceneNode* node); + /*! \brief Destroys the avatar */ ~Avatar(); + /*! \brief Moves the avatar * * \param direction The direction the avatar is moving (i.e. Avatar::LEFT) @@ -51,39 +52,29 @@ * * This method moves the avatar in a given direction with a given scale */ - bool move(const int direction, float scale); + virtual bool move(const int direction, float scale); - /*! Direction: left */ - static const int LEFT = 1; - /*! Direction: left */ - static const int RIGHT = 2; - /*! Direction: left */ - static const int FRONT = 3; - /*! Direction: left */ - static const int BACK = 4; - /*! Direction: left */ - static const int UP = 5; - /*! Direction: left */ - static const int DOWN = 6; - - static const int YAW_LEFT = 7; - static const int YAW_RIGHT = 8; - static const int ROLL_LEFT = 9; - static const int ROLL_RIGHT = 10; - static const int PITCH_UP = 11; - static const int PITCH_DOWN = 12; - -private: - /*! Handle to the node the avatar is attached to + /*! \brief Rotates the avatar + * + * This method rotates the avatar in a given direction with a given scale + * + * \param direction The direction the avatar is rotating (i.e. + * Avatar::YAW_LEFT) + * \param scale The degree the avatar is direction (based on the time + * elapsed since the last frame) */ - SceneNode* mNode; + virtual bool rotate(int direction, Ogre::Degree scale); - /*! Value that the players avatar can pitch */ - Radian pitch; - /*! Value that the players avatar can yaw */ - Radian yaw; - /*! Value that the players avatar can roll */ - Radian roll; + virtual void performMove() {}; +private: + /*! Handle to the node the avatar is attached to */ + Ogre::SceneNode* mNode; + /*! Value that the players avatar can pitch in one frame */ + Ogre::Radian pitch; + /*! Value that the players avatar can yaw in one frame */ + Ogre::Radian yaw; + /*! Value that the players avatar can roll in one frame */ + Ogre::Radian roll; }; #ifdef __cplusplus Added: include/camera.h =================================================================== --- include/camera.h (rev 0) +++ include/camera.h 2006-04-16 16:35:29 UTC (rev 54) @@ -0,0 +1,103 @@ +/*************************************************************************** + * camera.h + * + * Sat Apr 15 17:51:35 2006 + * Copyright 2006 User + * Email + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _CAMERA_H +#define _CAMERA_H + +#include <OgreMath.h> +#include <OgreSceneManager.h> +#include <OgreCamera.h> +#include <OgreVector3.h> +#include <OgreRenderWindow.h> +#include "movable_object.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Camera : public MovableObject { +public: + Camera(Ogre::SceneManager* sceneManager, Ogre::RenderWindow* window, Ogre::SceneNode* avatarNode, bool moveEndOfFrame); + + /*! \brief Moves the avatar + * + * \param direction The direction the avatar is moving (i.e. Avatar::LEFT) + * \param scale The distance the avatar is moving (based on the time elapsed + * since the last frame + * + * This method moves the avatar in a given direction with a given scale + */ + virtual bool move(const int direction, float scale); + + /*! \brief Rotates the avatar + * + * This method rotates the avatar in a given direction with a given scale + * + * \param direction The direction the avatar is rotating (i.e. + * Avatar::YAW_LEFT) + * \param scale The degree the avatar is direction (based on the time + * elapsed since the last frame) + */ + virtual bool rotate(int direction, Ogre::Degree scale); + + virtual void performMove(); + +private: + /*! Handle to the players camera so we can move it on mouse or keyboard + * input + */ + Ogre::Camera* mCamera; + + /*! Value to rotate the camera by X (=yaw) + */ + Ogre::Radian mRotX; + + /*! Value to rotate the camera by Y (=pitch) + */ + Ogre::Radian mRotY; + + /*! \brief Creates a camera for the scene + * + * This method creates the necessary cameras for the game. Since we have a + * first person camera and a third person camera, we will use 2 cameras to + * do that. It would be possible to do that with one camera, but the concept + * in OGRE3D is to use 2 cameras. + */ + void createCamera(Ogre::SceneManager* sceneManager, Ogre::SceneNode* avatarNode); + + /*! \brief Creates a viewport with the given cameras for the scene + * + * This method creates the viewport to the scene. This is what the user will + * actually see when playing the game. The viewport uses the given cameras + * to get its picture. + */ + void createViewports(Ogre::RenderWindow* window); +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _CAMERA_H */ Property changes on: include/camera.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Modified: include/framelistener.h =================================================================== --- include/framelistener.h 2006-04-14 14:29:31 UTC (rev 53) +++ include/framelistener.h 2006-04-16 16:35:29 UTC (rev 54) @@ -25,22 +25,41 @@ #ifndef _FRAMELISTENER_H #define _FRAMELISTENER_H -#include <Ogre.h> +//Work around for memory manager problems between CEGUI and Ogre +#include <OgreNoMemoryMacros.h> +#include <CEGUI/CEGUIImageset.h> +#include <CEGUI/CEGUISystem.h> +#include <CEGUI/CEGUILogger.h> +#include <CEGUI/CEGUISchemeManager.h> +#include <CEGUI/CEGUIWindowManager.h> +#include <CEGUI/CEGUIWindow.h> +#include <OgreCEGUIRenderer.h> +#include <OgreCEGUIResourceProvider.h> +//regular mem handler +#include <OgreMemoryMacros.h> +//End of workaround +#include <OgreFrameListener.h> +#include <OgreEventProcessor.h> +#include <OgrePlatformManager.h> +#include <OgreCamera.h> +#include <OgreInput.h> +#include <OgreOverlayManager.h> #include <OgreKeyEvent.h> #include <OgreEventListeners.h> #include <OgreStringConverter.h> #include <OgreException.h> #include "avatar.h" +#include "keyboard.h" +#include "camera.h" +#include "mouse.h" #ifdef __cplusplus extern "C" { #endif -using namespace Ogre; - // Declare a subclass of the ExampleFrameListener class -class MyListener : public FrameListener, public KeyListener { +class OpengateListener : public Ogre::FrameListener { public: /*! \brief The constructor that creates the object that reacts to user input @@ -54,15 +73,14 @@ * \param useBufferedInputMouse Flag to set if the mouse input should be * buffered or not */ - MyListener(RenderWindow* win, Camera* cam, Avatar* avatar, - bool useBufferedInputKeys, bool useBufferedInputMouse); + OpengateListener(Ogre::RenderWindow* win, Camera* cam, Avatar* avatar, CEGUI::Renderer* renderer); /*! \brief The destructor to free the input readers * * It will destroy either the reader for buffered or unbuffered input, * depending on what was chosen in the constructor */ - ~MyListener(); + ~OpengateListener(); /*! \brief This method processes the keyboard events * @@ -72,7 +90,7 @@ * * \param evt The frame event from frameStarted() */ - bool processUnbufferedKeyInput(const FrameEvent& evt); + bool processUnbufferedKeyInput(const Ogre::FrameEvent& evt); /*! \brief This method processes the mouse events * @@ -82,15 +100,8 @@ * * \param evt The frame event from frameStarted() */ - bool processUnbufferedMouseInput(const FrameEvent& evt); + bool processUnbufferedMouseInput(const Ogre::FrameEvent& evt); - /*! \brief Make all the camera movement - * - * This method is called after the unbuffered input events are processed - * and have modified the translation vector, yaw and pitch - */ - void moveCamera(); - /*! \brief Enable or disbale the debug overlay * * This method changes the visibility status of the debug overlay which was @@ -104,14 +115,14 @@ * keyboard and mouse events). It is called before the actual rendering * happens. */ - bool frameStarted(const FrameEvent& evt); + bool frameStarted(const Ogre::FrameEvent& evt); /*! \brief Update statistics * * This method is called after the frame is rendered and refreshes the * statistics. */ - bool frameEnded(const FrameEvent& evt); + bool frameEnded(const Ogre::FrameEvent& evt); /*! \brief Switch mousemode from buffered<->immediate */ @@ -121,33 +132,14 @@ */ void switchKeyMode(); - /*! \brief Performes updates when a key was pressed AND released - * - * This method is part of the KeyListener interface of OGRE - * - * It is called by the buffered KeyListener when a key was klicked (pressed - * and afterwards released + /*! Tell the frame listener to exit at the end of the next frame */ - void keyClicked(KeyEvent* e); + void requestShutdown(); - /*! \brief Performes updates when a key was released - * - * This method is part of the KeyListener interface of OGRE - * - * It is called by the buffered KeyListener when a key was released - */ - void keyPressed(KeyEvent* e); +protected: - /*! \brief Performes updates when a key was pressed - * - * This method is part of the KeyListener interface of OGRE - * - * It is called by the buffered KeyListener when a key was pressed - */ - void keyReleased(KeyEvent* e); + bool mShutdownRequested; -protected: - /*! \brief This method updates the status (FPS,Triangles,etc.) * * This method is called at the end of every frame to update the statistics @@ -158,74 +150,84 @@ */ void updateStats(); - /*! Value used to cycle thorugh the scene details */ int mSceneDetailIndex; + /*! Movement speed of the camera */ - Real mMoveSpeed; + Ogre::Real mMoveSpeed; + /*! Rotation speed of the camera */ - Degree mRotateSpeed; + Ogre::Degree mRotateSpeed; + /*! Handle to the debug overlay (which displays the OGRE logo and stats */ - Overlay* mDebugOverlay; + Ogre::Overlay* mDebugOverlay; + /*! An event processor used, if the mouse or the keyboard input is buffered */ - EventProcessor* mEventProcessor; - /*! An input reader for unbuffered mouse and keyboard input */ - InputReader* mInputDevice; - /*! Handle to the players camera so we can move it on mouse or keyboard - * input + Ogre::EventProcessor* mEventProcessor; + + /*! An input reader for unbuffered mouse and keyboard input */ - Camera* mCamera; + Ogre::InputReader* mInputDevice; + /*! Vector used to modify the movement of the camera */ - Vector3 mTranslateVector; + Ogre::Vector3 mTranslateVector; + /*! Handle to the window where the contents is shown (used for statistics * updates */ - RenderWindow* mWindow; + Ogre::RenderWindow* mWindow; + /*! Flag to determine whether the stats should be displayed or not */ bool mStatsOn; + /*! Flag to determine if the input of the keyboard is buffered or * unbuffered */ bool mUseBufferedInputKeys; + /*! Flag to determine if the input of the mouse is buffered or unbuffered */ bool mUseBufferedInputMouse; + /*! Flag to determine if the input can be switched from buffered to * unbuffered. This is only possible if we created an instance of this * class with at least one buffered input */ bool mInputTypeSwitchingOn; + /*! Variable holding the current number of screenshots made (used to create * the filename of the screenshot */ unsigned int mNumScreenShots; - /*! Value to move the camera */ - float mMoveScale; - /*! Value to rotate the camera */ - Degree mRotScale; + /*! Value to stop flickering of toggles */ - Real mTimeUntilNextToggle; - /*! Value to rotate the camera by X (=yaw) - */ - Radian mRotX; - /*! Value to rotate the camera by Y (=pitch) - */ - Radian mRotY; + Ogre::Real mTimeUntilNextToggle; + /*! Filtering method for the scene */ - TextureFilterOptions mFiltering; + Ogre::TextureFilterOptions mFiltering; + /*! Number of anisotropic filtering processes */ int mAniso; + /*! Handle to the avatar */ Avatar* mAvatar; + + /*! Handle to a CEGUI Renderer */ + CEGUI::Renderer* mGUIRenderer; + + + Keyboard* mKeyboard; + Camera* mCamera; + Mouse* mMouse; }; #ifdef __cplusplus Added: include/gamestate.h =================================================================== --- include/gamestate.h (rev 0) +++ include/gamestate.h 2006-04-16 16:35:29 UTC (rev 54) @@ -0,0 +1,56 @@ +/*************************************************************************** + * gamestate.h + * + * Sat Apr 15 18:17:42 2006 + * Copyright 2006 User + * Email + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _GAMESTATE_H +#define _GAMESTATE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Gamestate { +public: + Gamestate(); + + bool setGamestate(int state); + + int getGamestate(); + + + static const int GAME = 0; + static const int MENU = 1; + static const int MIN = GAME; + static const int MAX = MENU; + +private: + + int mActivestate; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _GAMESTATE_H */ Property changes on: include/gamestate.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Added: include/keyboard.h =================================================================== --- include/keyboard.h (rev 0) +++ include/keyboard.h 2006-04-16 16:35:29 UTC (rev 54) @@ -0,0 +1,60 @@ +/*************************************************************************** + * keyboard.h + * + * Sat Apr 15 16:31:36 2006 + * Copyright 2006 User + * Email + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _KEYBOARD_H +#define _KEYBOARD_H + +#include <OgreInput.h> +#include <OgreFrameListener.h> +#include "avatar.h" +#include "camera.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Keyboard { +public: + Keyboard(Ogre::InputReader* mInputDevice, Avatar* avatar, Camera* camera); + bool processKeyInput(const Ogre::FrameEvent& evt); + void setScale(float moveScale); +private: + /*! Handle to the input device, which will give us keyboard states */ + Ogre::InputReader* mInputDevice; + /*! Handle to the players avatar */ + Avatar* mAvatar; + /*! Value to move the camera */ + float mMoveScale; + /*! Handle to the camera chasing the avatar (will be removed once the movement + * is completed) + */ + Camera* mCamera; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _KEYBOARD_H */ Property changes on: include/keyboard.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Added: include/mouse.h =================================================================== --- include/mouse.h (rev 0) +++ include/mouse.h 2006-04-16 16:35:29 UTC (rev 54) @@ -0,0 +1,89 @@ +/*************************************************************************** + * mouse.h + * + * Sat Apr 15 16:55:15 2006 + * Copyright 2006 User + * Email + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _MOUSE_H +#define _MOUSE_H + +#include <OgreInput.h> +#include <OgreFrameListener.h> +#include <OgreMath.h> +#include "avatar.h" +#include "camera.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Mouse { +public: + /*! \brief Creates a new camera to chase the players avatar + * + * This constructor saves the given avatar and the input device to translate + * mouse movement and button clicks into actions on the player. So if the + * mouse was moved the players avatar will move accordingly. + * \param mInputDevice an inputdevice to get the current mousestates from + * \param avatar the players avatar + */ + Mouse(Ogre::InputReader* mInputDevice, Avatar* avatar); + + /*! \brief This method performs actions depending on the mousestate + * + * This method reads the state from the input device (which were set at the + * begin of the current frame) and depending on the states it performs + * actions. + * \param evt the FrameEvent that happened (i.e. for getting the time since + * the last frame + */ + bool processMouseInput(const Ogre::FrameEvent& evt); + + /*! \brief Sets the amount the players avatar can rotate in this frame + * + * This method is called at the begin of the frame. Depending on the time + * passed since the last frame, the players avatar can rotate for a specific + * degree. This degree also depends on the ships details. + * \param rotScale the degree the ship can rotate + */ + void setScale(Ogre::Degree rotScale); + +private: + + /*! Handle to the players avatar so we can perform rotation actions to it */ + Avatar* mAvatar; + /*! Handle to the input device, which will give us mouse states */ + Ogre::InputReader* mInputDevice; + /*! Value to rotate the camera */ + Ogre::Degree mRotScale; + + Camera* mCamera; + Ogre::Vector3 mTranslateVector; + Ogre::Degree mRotX; + Ogre::Degree mRotY; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _MOUSE_H */ Property changes on: include/mouse.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Added: include/movable_object.h =================================================================== --- include/movable_object.h (rev 0) +++ include/movable_object.h 2006-04-16 16:35:29 UTC (rev 54) @@ -0,0 +1,104 @@ +/*************************************************************************** + * movable_object.h + * + * Sun Apr 16 15:30:28 2006 + * Copyright 2006 Christoph Brill <eg...@us...> + * Email + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _MOVABLE_OBJECT_H +#define _MOVABLE_OBJECT_H + +#include <OgreVector3.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! \brief interface for objects that can be moved by player input + * \author Christoph Brill + */ +class MovableObject { +public: + + virtual ~MovableObject() {}; + + /*! \brief Moves the object + * + * This method moves the object in a given direction with a given scale + * + * \param direction The direction the object is moving (i.e. + * MovableObject::LEFT) + * \param scale The distance the object is moving (based on the time elapsed + * since the last frame) + */ + virtual bool move(const int direction, float scale) = 0; + + /*! \brief Rotates the object + * + * This method rotates the object in a given direction with a given scale + * + * \param direction The direction the object is rotating (i.e. + * MovableObject::YAW_LEFT) + * \param scale The degree the object is direction (based on the time + * elapsed since the last frame) + */ + virtual bool rotate(int direction, Ogre::Degree scale) = 0; + + void reset(); + + virtual void performMove() = 0; + + /*! Direction: left */ + static const int LEFT = 1; + /*! Direction: right */ + static const int RIGHT = 2; + /*! Direction: forward */ + static const int FRONT = 3; + /*! Direction: backward */ + static const int BACK = 4; + /*! Direction: up */ + static const int UP = 5; + /*! Direction: down */ + static const int DOWN = 6; + /*! Yaw: left */ + static const int YAW_LEFT = 7; + /*! Yaw: right */ + static const int YAW_RIGHT = 8; + /*! Roll: left */ + static const int ROLL_LEFT = 9; + /*! Roll: right */ + static const int ROLL_RIGHT = 10; + /*! Pitch: up */ + static const int PITCH_UP = 11; + /*! Pitch: down */ + static const int PITCH_DOWN = 12; + +protected: + bool mMoveEndOfFrame; + Ogre::Vector3 mTranslateVector; + Ogre::Quaternion mNewOrientation; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _MOVABLE_OBJECT_H */ Property changes on: include/movable_object.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eg...@us...> - 2006-04-16 16:44:05
|
Revision: 55 Author: egore Date: 2006-04-16 09:43:53 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/opengate/?rev=55&view=rev Log Message: ----------- reclaim copyrights Modified Paths: -------------- include/avatar.h include/camera.h include/gamestate.h include/keyboard.h include/mouse.h include/movable_object.h Modified: include/avatar.h =================================================================== --- include/avatar.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/avatar.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * avatar.h * * Sun Apr 9 14:58:04 2006 - * Copyright 2006 User - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* Modified: include/camera.h =================================================================== --- include/camera.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/camera.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * camera.h * * Sat Apr 15 17:51:35 2006 - * Copyright 2006 User - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* Modified: include/gamestate.h =================================================================== --- include/gamestate.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/gamestate.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * gamestate.h * * Sat Apr 15 18:17:42 2006 - * Copyright 2006 User - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* Modified: include/keyboard.h =================================================================== --- include/keyboard.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/keyboard.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * keyboard.h * * Sat Apr 15 16:31:36 2006 - * Copyright 2006 User - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* Modified: include/mouse.h =================================================================== --- include/mouse.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/mouse.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * mouse.h * * Sat Apr 15 16:55:15 2006 - * Copyright 2006 User - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* Modified: include/movable_object.h =================================================================== --- include/movable_object.h 2006-04-16 16:35:29 UTC (rev 54) +++ include/movable_object.h 2006-04-16 16:43:53 UTC (rev 55) @@ -2,8 +2,8 @@ * movable_object.h * * Sun Apr 16 15:30:28 2006 - * Copyright 2006 Christoph Brill <eg...@us...> - * Email + * Copyright 2006 Christoph Brill + * Email <eg...@us...> ****************************************************************************/ /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eg...@us...> - 2006-07-16 16:20:48
|
Revision: 79 Author: egore Date: 2006-07-16 09:20:30 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/opengate/?rev=79&view=rev Log Message: ----------- synchronize headers with sourcefiles Modified Paths: -------------- include/Makefile.am include/Makefile.in include/application.h include/avatar.h include/camera.h include/framelistener.h include/gamestate.h include/keyboard.h include/mouse.h include/movable_object.h Added Paths: ----------- include/input.h Modified: include/Makefile.am =================================================================== --- include/Makefile.am 2006-07-16 16:18:51 UTC (rev 78) +++ include/Makefile.am 2006-07-16 16:20:30 UTC (rev 79) @@ -15,6 +15,9 @@ mouse.h\ camera.h\ gamestate.h\ - movable_object.h + movable_object.h\ + input.h\ + xml_parser.h\ + object.h EXTRA_DIST = $(opengate_include_DATA) Modified: include/Makefile.in =================================================================== --- include/Makefile.in 2006-07-16 16:18:51 UTC (rev 78) +++ include/Makefile.in 2006-07-16 16:20:30 UTC (rev 79) @@ -67,8 +67,6 @@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -79,7 +77,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO = @ECHO@ @@ -90,15 +87,11 @@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GMOFILES = @GMOFILES@ -GMSGFMT = @GMSGFMT@ +GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLLIBS = @INTLLIBS@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ @@ -109,8 +102,6 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MSGFMT = @MSGFMT@ NO_PREFIX_PACKAGE_DATA_DIR = @NO_PREFIX_PACKAGE_DATA_DIR@ NO_PREFIX_PACKAGE_DOC_DIR = @NO_PREFIX_PACKAGE_DOC_DIR@ NO_PREFIX_PACKAGE_HELP_DIR = @NO_PREFIX_PACKAGE_HELP_DIR@ @@ -129,23 +120,14 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -POFILES = @POFILES@ -POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ -USE_NLS = @USE_NLS@ VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ @@ -162,23 +144,30 @@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ +htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ +psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ @@ -193,7 +182,10 @@ mouse.h\ camera.h\ gamestate.h\ - movable_object.h + movable_object.h\ + input.h\ + xml_parser.h\ + object.h EXTRA_DIST = $(opengate_include_DATA) all: all-am Modified: include/application.h =================================================================== --- include/application.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/application.h 2006-07-16 16:20:30 UTC (rev 79) @@ -32,6 +32,7 @@ #include "framelistener.h" #include "avatar.h" #include "camera.h" +#include "gamestate.h" #ifdef __cplusplus extern "C" @@ -57,15 +58,21 @@ * * When this destructor is called, the game is done and will quit. */ - virtual ~OpengateApp(); + ~OpengateApp(); - virtual void go(void); + /*! \brief The main "loop" of the game + * + * This method is running while the game is running. When this method is + * done, we are completely done. + */ + void go(); protected: CEGUI::OgreCEGUIRenderer* mGUIRenderer; CEGUI::System* mGUISystem; CEGUI::Window* mEditorGuiSheet; + Gamestate* mGamestate; Avatar* mAvatar; Ogre::SceneNode* mAvatarNode; @@ -102,9 +109,9 @@ * loaded, like the space background, or jumpgates (which can be found in * every sector) etc. */ - virtual void createScene(void); + void createScene(void); - virtual void destroyScene(void); + void destroyScene(void); /*! \biref Create the frame listener for the game * @@ -113,14 +120,14 @@ void createFrameListener(void); /// Method which will define the source of resources (other than current folder) - virtual void setupResources(void); + void setupResources(void); /// Optional override method where you can create resource listeners (e.g. for loading screens) - virtual void createResourceListener(void); + void createResourceListener(void); /// Optional override method where you can perform resource group loading /// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - virtual void loadResources(void); + void loadResources(void); void setupEventHandlers(void); Modified: include/avatar.h =================================================================== --- include/avatar.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/avatar.h 2006-07-16 16:20:30 UTC (rev 79) @@ -33,10 +33,17 @@ { #endif +/*! \brief Class for the players avatar (the ship flying through space) + * \author Christoph Brill + * + * This class defines the players avatar. It is not only the graphical + * representation but also the technical. So it will contain ship-specific stuff, + * any maybe also weaponspecific, but that will follow later + */ class Avatar : public MovableObject { public: - /*! \brief Creates the avatar (not the graphical representation, the real - * one) + /*! \brief Creates the avatar (not only the graphical representation, the + * real one) */ Avatar(Ogre::SceneNode* node); @@ -46,26 +53,41 @@ /*! \brief Moves the avatar * + * This method moves the avatar in a given direction with a given scale. If + * "mMoveEndOfFrame" is true, it will only save the movement operation and + * perform the movement at the end of the frame (when performMove() is + * called). + * * \param direction The direction the avatar is moving (i.e. Avatar::LEFT) * \param scale The distance the avatar is moving (based on the time elapsed * since the last frame - * - * This method moves the avatar in a given direction with a given scale + * \return Returns false, if an unkown direction was given */ virtual bool move(const int direction, float scale); /*! \brief Rotates the avatar * - * This method rotates the avatar in a given direction with a given scale + * This method rotates the avatar in a given direction with a given scale. + * If "mMoveEndOfFrame" is true, it will only save the rotation operation + * and perform the movement at the end of the frame (when performMove() is + * called). * * \param direction The direction the avatar is rotating (i.e. * Avatar::YAW_LEFT) * \param scale The degree the avatar is direction (based on the time * elapsed since the last frame) + * \return Returns false, if an unkown rotation was given */ virtual bool rotate(int direction, Ogre::Degree scale); + /*! \brief Performs movement at the end of the frame + * + * This method is called at the and of the frame to perform stored movement + * from the methods rotate() and move(). This movement is only stored if + * mMoveEndOfFrame is true, so otherwise nothing will happen in this method + */ virtual void performMove() {}; + private: /*! Handle to the node the avatar is attached to */ Ogre::SceneNode* mNode; Modified: include/camera.h =================================================================== --- include/camera.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/camera.h 2006-07-16 16:20:30 UTC (rev 79) @@ -39,29 +39,53 @@ class Camera : public MovableObject { public: + /*! \brief creates a new camera + * + * This method creates a new camera by invoking createCamera() and + * createViewports(). + * \param sceneManager The handle to the scenemanager of the game (used in + * createCamera()). + * \param window The handle to the window of the game (used in + * createViewports()). + * \param avatarNode The handle to the scenenode of the players avatar (used + * in createCamera()). + * \param moveEndOfFrame If true, the movement will be done at once at the + * end of the frame. + */ Camera(Ogre::SceneManager* sceneManager, Ogre::RenderWindow* window, Ogre::SceneNode* avatarNode, bool moveEndOfFrame); - /*! \brief Moves the avatar + /*! \brief Moves the camera * - * \param direction The direction the avatar is moving (i.e. Avatar::LEFT) - * \param scale The distance the avatar is moving (based on the time elapsed - * since the last frame + * This method moves the camera in a given direction with a given scale. If + * "mMoveEndOfFrame" is true, it will only save the movement operation and + * perform the movement at the end of the frame (when performMove() is + * called). * - * This method moves the avatar in a given direction with a given scale + * \param direction The direction the camera is moving (i.e. Camera::LEFT). + * \param scale The distance the camera is moving (based on the time elapsed + * since the last frame. + * \return Returns false, if an unkown direction was given. */ virtual bool move(const int direction, float scale); - /*! \brief Rotates the avatar + /*! \brief Rotates the camera * - * This method rotates the avatar in a given direction with a given scale + * This method rotates the camera in a given direction with a given scale. * - * \param direction The direction the avatar is rotating (i.e. - * Avatar::YAW_LEFT) - * \param scale The degree the avatar is direction (based on the time - * elapsed since the last frame) + * \param direction The direction the camera is rotating (i.e. + * Camera::YAW_LEFT). + * \param scale The degree the camera is direction (based on the time + * elapsed since the last frame). + * \return Returns false, if an unkown rotation was given. */ virtual bool rotate(int direction, Ogre::Degree scale); + /*! \brief Performs movement at the end of the frame + * + * This method is called at the and of the frame to perform stored movement + * from the methods rotate() and move(). This movement is only stored if + * mMoveEndOfFrame is true, so otherwise nothing will happen in this method + */ virtual void performMove(); private: Modified: include/framelistener.h =================================================================== --- include/framelistener.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/framelistener.h 2006-07-16 16:20:30 UTC (rev 79) @@ -73,7 +73,7 @@ * \param useBufferedInputMouse Flag to set if the mouse input should be * buffered or not */ - OpengateListener(Ogre::RenderWindow* win, Camera* cam, Avatar* avatar, CEGUI::Renderer* renderer); + OpengateListener(Ogre::RenderWindow* win, Camera* cam, Avatar* avatar, CEGUI::Renderer* renderer, Gamestate* gamestate); /*! \brief The destructor to free the input readers * Modified: include/gamestate.h =================================================================== --- include/gamestate.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/gamestate.h 2006-07-16 16:20:30 UTC (rev 79) @@ -30,22 +30,51 @@ { #endif +/*! \brief This class defines the gamestate + * \author Christoph Brill + * + * This class represents the current gamestate. This can be for example the + * player is in the game, the player is in the menu, the player is in the + * console, etc. All these states are defined and used here. + */ class Gamestate { public: + /*! \brief creates a gamestatehandler + * + * This creates a gamestatehandler and will default to "in game" + */ Gamestate(); + /*! \brief set the state + * + * This class sets a given state. It a user switches to menu it will be + * Gamestate::MENU for example. + * \param state the new gamestate. + * \return Returns true if the gamestate was switched, otherwise (if the + * state was unkown) it returns false. + */ bool setGamestate(int state); + /*! \brief get the current state + * + * This return the current state + * \return returns the current state + */ int getGamestate(); - + /*! Gamestate: in game */ static const int GAME = 0; + /*! Gamestate: in menu */ static const int MENU = 1; - static const int MIN = GAME; - static const int MAX = MENU; + /*! Gamestate: quitting */ + static const int QUIT = 2; private: - + /*! smallest known gamestate */ + static const int MIN = GAME; + /*! biggest known gamestate */ + static const int MAX = QUIT; + /*! active gamestate */ int mActivestate; }; Added: include/input.h =================================================================== --- include/input.h (rev 0) +++ include/input.h 2006-07-16 16:20:30 UTC (rev 79) @@ -0,0 +1,109 @@ +/*************************************************************************** + * input.h + * + * Mon Apr 17 11:32:17 2006 + * Copyright 2006 Christoph Brill + * Email <eg...@us...> + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _INPUT_H +#define _INPUT_H + +#include <OgreInput.h> +#include <OgreFrameListener.h> +#include <CEGUIRenderer.h> +#include "movable_object.h" +#include "gamestate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*! \brief An abstract class for input devices + * \author Christoph Brill + * + * This class is an interface for all types of input devices (keyboard, mouse, + * joystick, gamepad, etc.). Every type of input device has to use this + * and implement its own processInput method. The idea of this class is to + * translate user input into reactions of an object (most likely the players + * avatar) in the game. + */ +class Input { +public: + /*! \brief Constructor to save the input device and the target + * + * This constructor will save the given input device and the given target + * for the input to perform movement based on the input states in the game. + * If (for example) we have a mouse as input device and the players avatar + * as target, we can rotate the players avatar based on mouse movement, or + * fire its weapons on mouseclicks + */ + Input(Ogre::InputReader* inputDevice, MovableObject* object, CEGUI::Renderer* guiRenderer, Gamestate* gamestate); + + /*! \brief Destructor + * + * This is a currently empty destructor, since we don't need to free + * anything + */ + virtual ~Input(); + + /*! \brief perform movement on input states + * + * This is the main method of this class. It will be called once in a frame + * to read the input states and react to them. If a player move the mouse + * the avatar will be moved to represent this change. + * + * \param evt the FrameEvent that happened (i.e. for getting the time since + * the last frame + * \return returns the time to the next "toggle-event" (to remove flickering + * when toggling to often) or a negative value on special states + */ + virtual Ogre::Real processInput(const Ogre::FrameEvent& evt) = 0; + + /*! Returned by processInput if the game should be quit */ + static const int GAME_QUIT = -1; + +protected: + + /*! Handle to the input device, which will give us the keyboard, mouse or + * joysick states + */ + Ogre::InputReader* mInputDevice; + + /*! Handle to the object that can be moved by the input device (i.e. the + * players avatar or a free camera) + */ + MovableObject* mTarget; + + /*! Handle to the GUI renderer when we are in the menu and want to react to + * events + */ + CEGUI::Renderer* mGuiRenderer; + + /*! Handle to the gamestate manager + */ + Gamestate* mGamestate; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _INPUT_H */ Property changes on: include/input.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Modified: include/keyboard.h =================================================================== --- include/keyboard.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/keyboard.h 2006-07-16 16:20:30 UTC (rev 79) @@ -27,30 +27,28 @@ #include <OgreInput.h> #include <OgreFrameListener.h> +#include <OgreMath.h> #include "avatar.h" -#include "camera.h" +#include "input.h" #ifdef __cplusplus extern "C" { #endif -class Keyboard { +class Keyboard : public Input { public: - Keyboard(Ogre::InputReader* mInputDevice, Avatar* avatar, Camera* camera); - bool processKeyInput(const Ogre::FrameEvent& evt); + Keyboard(Ogre::InputReader* mInputDevice, Avatar* avatar, CEGUI::Renderer* guiRenderer, Gamestate* gamestate); + virtual ~Keyboard(); + virtual Ogre::Real processInput(const Ogre::FrameEvent& evt); void setScale(float moveScale); private: - /*! Handle to the input device, which will give us keyboard states */ - Ogre::InputReader* mInputDevice; - /*! Handle to the players avatar */ - Avatar* mAvatar; + /*! Value to move the camera */ float mMoveScale; - /*! Handle to the camera chasing the avatar (will be removed once the movement - * is completed) - */ - Camera* mCamera; + + /*! */ + Ogre::Real mTimeUntilNextToggle; }; #ifdef __cplusplus Modified: include/mouse.h =================================================================== --- include/mouse.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/mouse.h 2006-07-16 16:20:30 UTC (rev 79) @@ -29,14 +29,14 @@ #include <OgreFrameListener.h> #include <OgreMath.h> #include "avatar.h" -#include "camera.h" +#include "input.h" #ifdef __cplusplus extern "C" { #endif -class Mouse { +class Mouse : public Input { public: /*! \brief Creates a new camera to chase the players avatar * @@ -46,7 +46,7 @@ * \param mInputDevice an inputdevice to get the current mousestates from * \param avatar the players avatar */ - Mouse(Ogre::InputReader* mInputDevice, Avatar* avatar); + Mouse(Ogre::InputReader* mInputDevice, Avatar* avatar, CEGUI::Renderer* guiRenderer, Gamestate* gamestate); /*! \brief This method performs actions depending on the mousestate * @@ -56,7 +56,7 @@ * \param evt the FrameEvent that happened (i.e. for getting the time since * the last frame */ - bool processMouseInput(const Ogre::FrameEvent& evt); + virtual Ogre::Real processInput(const Ogre::FrameEvent& evt); /*! \brief Sets the amount the players avatar can rotate in this frame * @@ -68,18 +68,11 @@ void setScale(Ogre::Degree rotScale); private: - - /*! Handle to the players avatar so we can perform rotation actions to it */ - Avatar* mAvatar; - /*! Handle to the input device, which will give us mouse states */ - Ogre::InputReader* mInputDevice; /*! Value to rotate the camera */ Ogre::Degree mRotScale; - Camera* mCamera; - Ogre::Vector3 mTranslateVector; - Ogre::Degree mRotX; - Ogre::Degree mRotY; + /*! */ + bool mPressed; }; #ifdef __cplusplus Modified: include/movable_object.h =================================================================== --- include/movable_object.h 2006-07-16 16:18:51 UTC (rev 78) +++ include/movable_object.h 2006-07-16 16:20:30 UTC (rev 79) @@ -26,6 +26,7 @@ #define _MOVABLE_OBJECT_H #include <OgreVector3.h> +#include "object.h" #ifdef __cplusplus extern "C" @@ -35,35 +36,56 @@ /*! \brief interface for objects that can be moved by player input * \author Christoph Brill */ -class MovableObject { +class MovableObject : public Object { public: - + /*! \brief empty destructor + */ virtual ~MovableObject() {}; /*! \brief Moves the object * - * This method moves the object in a given direction with a given scale + * This method moves the object in a given direction with a given scale. If + * "mMoveEndOfFrame" is true, it will only save the movement operation and + * perform the movement at the end of the frame (when performMove() is + * called). * - * \param direction The direction the object is moving (i.e. - * MovableObject::LEFT) + * \param direction The direction the camera is moving (i.e. + * MovableObject::LEFT). * \param scale The distance the object is moving (based on the time elapsed - * since the last frame) + * since the last frame. + * \return Returns false, if an unkown direction was given. */ virtual bool move(const int direction, float scale) = 0; /*! \brief Rotates the object * - * This method rotates the object in a given direction with a given scale + * This method rotates the object in a given direction with a given scale. + * If "mMoveEndOfFrame" is true, it will only save the rotation operation + * and perform the movement at the end of the frame (when performMove() is + * called). * * \param direction The direction the object is rotating (i.e. - * MovableObject::YAW_LEFT) + * MovableObject::YAW_LEFT). * \param scale The degree the object is direction (based on the time - * elapsed since the last frame) + * elapsed since the last frame). + * \return Returns false, if an unkown rotation was given. */ virtual bool rotate(int direction, Ogre::Degree scale) = 0; + /*! \brief resets the movement and rotation stored in the last frame. + * + * This method is called at the begin of a frame to clear stored movement + * and rotation from the last frame. This is only necessary if + * mMoveEndOfFrame is true. + */ void reset(); + /*! \brief Performs movement at the end of the frame. + * + * This method is called at the and of the frame to perform stored movement + * from the methods rotate() and move(). This movement is only stored if + * mMoveEndOfFrame is true, so otherwise nothing will happen in this method. + */ virtual void performMove() = 0; /*! Direction: left */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |