From: <eg...@us...> - 2006-07-16 20:49:27
|
Revision: 90 Author: egore Date: 2006-07-16 13:48:05 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/opengate/?rev=90&view=rev Log Message: ----------- continue merge Modified Paths: -------------- src/Makefile.in src/client/Makefile.am src/client/Makefile.in src/common/Makefile.am src/common/Makefile.in src/common/components/Makefile.in src/common/components/component.cpp src/common/equipment/Makefile.in src/common/equipment/ecms/Makefile.in src/common/equipment/engines/Makefile.in src/common/objects/Makefile.in src/common/objects/movable_object.cpp src/common/objects/movable_object.h src/common/objects/object.h src/common/objects/ships/Makefile.in src/opengate_client.cpp src/server/Makefile.in Added Paths: ----------- src/client/input/ src/client/input/Makefile.am src/client/input/input.cpp src/client/input/input.h src/client/input/keyboard.cpp src/client/input/keyboard.h src/client/input/mouse.cpp src/client/input/mouse.h src/client/ui/ src/client/ui/Makefile.am src/client/ui/application.cpp src/client/ui/application.h src/client/ui/avatar.cpp src/client/ui/avatar.h src/client/ui/camera.cpp src/client/ui/camera.h src/client/ui/framelistener.cpp src/client/ui/framelistener.h src/common/gamestate.cpp src/common/gamestate.h Removed Paths: ------------- src/application.cpp src/application.h src/avatar.cpp src/avatar.h src/camera.cpp src/camera.h src/constants.h src/framelistener.cpp src/framelistener.h src/gamestate.cpp src/gamestate.h src/input.cpp src/input.h src/keyboard.cpp src/keyboard.h src/main.cpp src/mouse.cpp src/mouse.h src/movable_object.cpp src/movable_object.h Modified: src/Makefile.in =================================================================== --- src/Makefile.in 2006-07-16 20:36:10 UTC (rev 89) +++ src/Makefile.in 2006-07-16 20:48:05 UTC (rev 90) @@ -86,6 +86,8 @@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -93,6 +95,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ +CEGUI_CFLAGS = @CEGUI_CFLAGS@ +CEGUI_LIBS = @CEGUI_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ @@ -124,6 +128,8 @@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ +OGRE_CFLAGS = @OGRE_CFLAGS@ +OGRE_LIBS = @OGRE_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -131,6 +137,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -210,9 +217,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile + $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ Deleted: src/application.cpp =================================================================== --- src/application.cpp 2006-07-16 20:36:10 UTC (rev 89) +++ src/application.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -1,211 +0,0 @@ -/*************************************************************************** - * application.cpp - * - * Sat Apr 8 10:24:00 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. - */ - -#include <OgreNode.h> -#include <OgreEntity.h> -#include <OgreTextureManager.h> -#include <OgreViewport.h> -#include <CEGUI/elements/CEGUIPushButton.h> -#include "application.h" -#include "constants.h" - -OpengateApp::OpengateApp() : mGUIRenderer(NULL), - mGUISystem(NULL), - mEditorGuiSheet(NULL){ - mFrameListener = NULL; - mRoot = NULL; -} - -OpengateApp::~OpengateApp() { - if (mGamestate) { - delete mGamestate; - } - if (mEditorGuiSheet) { - CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet); - } - if (mGUISystem) { - delete mGUISystem; - } - if (mGUIRenderer) { - delete mGUIRenderer; - } - if (mFrameListener) { - delete mFrameListener; - } - if (mCamera) { - delete mCamera; - } - if (mRoot) { - delete mRoot; - } -} - -void OpengateApp::go(void) { - if (!setup()) - return; - - mRoot->startRendering(); - - // clean up - destroyScene(); -} - -bool OpengateApp::setup(void) { - mRoot = new Ogre::Root(); - - setupResources(); - - if (!configure()) - return false; - - chooseSceneManager(); - - // Set default mipmap level (NB some APIs ignore this) - Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); - - // Create any resource listeners (for loading screens) - createResourceListener(); - // Load resources - loadResources(); - - // Create the scene - createScene(); - - mCamera = new Camera(mSceneMgr, mWindow, mAvatarNode, true); - mGamestate = new Gamestate(); - setupEventHandlers(); - - createFrameListener(); - setupEventHandlers(); - - return true; - -} - -bool OpengateApp::configure(void) { - // Show the configuration dialog and initialise the system - // You can skip this and use root.restoreConfig() to load configuration - // settings if you were sure there are valid ones saved in ogre.cfg - if(mRoot->restoreConfig()) { - // If returned true, user clicked OK so initialise - // Here we choose to let the system create a default rendering window by passing 'true' - mWindow = mRoot->initialise(true); - return true; - } else { - return false; - } -} - -void OpengateApp::chooseSceneManager(void) { - // Get the SceneManager, in this case a generic one - mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "ExampleSMInstance"); -} - -void OpengateApp::createScene() { - // create an ambient light for the scene - mSceneMgr->setAmbientLight(Ogre::ColourValue( 1, 1, 1 )); - mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); - mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); - - // setup GUI system - mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr); - mGUISystem = new CEGUI::System(mGUIRenderer); - CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme"); - mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); - mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-12"); - mEditorGuiSheet= CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"Sheet"); - mGUISystem->setGUISheet(mEditorGuiSheet); CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative); - - CEGUI::PushButton* quitButton = (CEGUI::PushButton*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button", (CEGUI::utf8*)"Quit"); - mEditorGuiSheet->addChildWindow(quitButton); - quitButton->setPosition(CEGUI::Point(0.35f, 0.45f)); - quitButton->setSize(CEGUI::Size(0.3f, 0.1f)); - quitButton->setText("Quit"); - - // Create an entity - Ogre::Entity* ent = mSceneMgr->createEntity( "Octavius Apteryx", "Ships/Octavius/Apteryx/octavius_apteryx.mesh" ); - mAvatarNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - mAvatarNode->attachObject(ent); - mAvatarNode->setPosition(Ogre::Vector3(0,0,30)); - mAvatarNode->rotate(Ogre::Vector3(0.,1.,0.), Ogre::Degree(-90)); - mAvatar = new Avatar(mAvatarNode); - - //ent = mSceneMgr->createEntity( "Quantar Storm", "Ships/Quantar/Storm/quantar_storm.mesh" ); - //Ogre::SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - //node2->attachObject(ent); -} - -void OpengateApp::destroyScene(void) { - -} - -void OpengateApp::createFrameListener(void) { - mFrameListener = new OpengateListener(mWindow, mCamera, mAvatar, mGUIRenderer, mGamestate); - mFrameListener->showDebugOverlay(true); - mRoot->addFrameListener(mFrameListener); -} - -void OpengateApp::setupResources(void) { - // Load resource paths from config file - Ogre::ConfigFile cf; - cf.load("resources.cfg"); - - // Go through all sections & settings in the file - Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); - - Ogre::String secName, typeName, archName; - while (seci.hasMoreElements()) - { - secName = seci.peekNextKey(); - Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); - Ogre::ConfigFile::SettingsMultiMap::iterator i; - for (i = settings->begin(); i != settings->end(); ++i) - { - typeName = i->first; - archName = i->second; - Ogre::ResourceGroupManager::getSingleton().addResourceLocation( - archName, typeName, secName); - } - } -} - -void OpengateApp::createResourceListener(void) -{ - -} - -void OpengateApp::loadResources(void) { - // Initialise, parse scripts etc - Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); -} - -void OpengateApp::setupEventHandlers(void) { - CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); - wmgr.getWindow((CEGUI::utf8*)"Quit")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&OpengateApp::handleQuit, this)); -} - -bool OpengateApp::handleQuit(const CEGUI::EventArgs& e) { - static_cast<OpengateListener*>(mFrameListener)->requestShutdown(); - return true; -} Deleted: src/application.h =================================================================== --- src/application.h 2006-07-16 20:36:10 UTC (rev 89) +++ src/application.h 2006-07-16 20:48:05 UTC (rev 90) @@ -1,141 +0,0 @@ -/*************************************************************************** - * application.h - * - * Sat Apr 8 10:26:58 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 _APPLICATION_H -#define _APPLICATION_H - -#include <OgreConfigFile.h> -#include <OgreRoot.h> -#include <OgreCamera.h> -#include <OgreRenderWindow.h> -#include "framelistener.h" -#include "avatar.h" -#include "camera.h" -#include "gamestate.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! - * - */ -class OpengateApp { -public: - - /*! \brief This default constructor instantiates an Application - * - * The default constructor is used to instantiates the Application. The - * Application can be considered as the object, that holds references to - * everything within the game. So here you can find the Scene, the Viewport - * to the scene, the camera(s) and the FrameListener. - */ - OpengateApp(); - - /*! \brief This destructor closes the application - * - * When this destructor is called, the game is done and will quit. - */ - ~OpengateApp(); - - /*! \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; - - 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); - - /** Configures the application - returns false if the user chooses to abandon configuration. */ - bool configure(void); - - void chooseSceneManager(void); - - /*! \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(); - - /*! \brief Define what is in the scene - * - * This method created an initial scene. So here some common things will be - * loaded, like the space background, or jumpgates (which can be found in - * every sector) etc. - */ - void createScene(void); - - void destroyScene(void); - - /*! \biref Create the frame listener for the game - * - * This method creates the framelistener necessary to render a scene - */ - void createFrameListener(void); - - /// Method which will define the source of resources (other than current folder) - void setupResources(void); - - /// Optional override method where you can create resource listeners (e.g. for loading screens) - void createResourceListener(void); - - /// Optional override method where you can perform resource group loading - /// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - void loadResources(void); - - void setupEventHandlers(void); - - bool handleQuit(const CEGUI::EventArgs& e); -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _APPLICATION_H */ Deleted: src/avatar.cpp =================================================================== --- src/avatar.cpp 2006-07-16 20:36:10 UTC (rev 89) +++ src/avatar.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -1,98 +0,0 @@ -/*************************************************************************** - * avatar.cpp - * - * Sun Apr 9 14:58:35 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. - */ - -#include "avatar.h" - -Avatar::Avatar(Ogre::SceneNode* node) { - mNode = node; - pitch = Ogre::Radian(0.001396)*100; - roll = Ogre::Radian(0.001222)*100; - yaw = Ogre::Radian(0.001396)*100; - mMoveEndOfFrame = false; //TODO -} - -Avatar::~Avatar() { - -} - -bool Avatar::move(const int direction, float scale) { - mTranslateVector = mNode->getPosition(); - switch(direction) { - case Avatar::LEFT: - mTranslateVector += mNode->getOrientation () * Ogre::Vector3 (0, 0, .1 * scale); - break; - case Avatar::RIGHT: - mTranslateVector -= mNode->getOrientation () * Ogre::Vector3 (0, 0, .1 * scale); - break; - case Avatar::UP: - mTranslateVector += mNode->getOrientation () * Ogre::Vector3 (0, .1 * scale, 0); - break; - case Avatar::DOWN: - mTranslateVector -= mNode->getOrientation () * Ogre::Vector3 (0, .1 * scale, 0); - break; - case Avatar::FRONT: - mTranslateVector -= mNode->getOrientation () * Ogre::Vector3 (1 * scale, 0, 0 ); - break; - case Avatar::BACK: - mTranslateVector += mNode->getOrientation () * Ogre::Vector3 (.5 * scale, 0, 0 ); - break; - default: - return false; - break; - } - if (!mMoveEndOfFrame) { - mNode->setPosition(mTranslateVector); - } - return true; -} - -bool Avatar::rotate(int direction, Ogre::Degree scale) { - switch(direction) { - case Avatar::YAW_LEFT: - mNewOrientation = Ogre::Quaternion(yaw*scale, Ogre::Vector3::UNIT_Y); - break; - case Avatar::YAW_RIGHT: - mNewOrientation = Ogre::Quaternion(-yaw*scale, Ogre::Vector3::UNIT_Y); - break; - case Avatar::ROLL_LEFT: - mNewOrientation = Ogre::Quaternion(roll*scale, Ogre::Vector3::UNIT_X); - break; - case Avatar::ROLL_RIGHT: - mNewOrientation = Ogre::Quaternion(-roll*scale, Ogre::Vector3::UNIT_X); - break; - case Avatar::PITCH_DOWN: - mNewOrientation = Ogre::Quaternion(pitch*scale, Ogre::Vector3::UNIT_Z); - break; - case Avatar::PITCH_UP: - mNewOrientation = Ogre::Quaternion(-pitch*scale, Ogre::Vector3::UNIT_Z); - break; - default: - mNewOrientation = Ogre::Quaternion(Ogre::Degree(0), Ogre::Vector3::UNIT_X); - break; - } - if (!mMoveEndOfFrame) { - mNode->rotate(mNewOrientation); - } - return true; -} Deleted: src/avatar.h =================================================================== --- src/avatar.h 2006-07-16 20:36:10 UTC (rev 89) +++ src/avatar.h 2006-07-16 20:48:05 UTC (rev 90) @@ -1,106 +0,0 @@ -/*************************************************************************** - * avatar.h - * - * Sun Apr 9 14:58:04 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 _AVATAR_H -#define _AVATAR_H - -#include <OgreSceneNode.h> -#include "movable_object.h" - -#ifdef __cplusplus -extern "C" -{ -#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 only the graphical representation, the - * real one) - */ - Avatar(Ogre::SceneNode* node); - - /*! \brief Destroys the avatar - */ - ~Avatar(); - - /*! \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 - * \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. - * 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; - /*! 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 -} -#endif - -#endif /* _AVATAR_H */ Deleted: src/camera.cpp =================================================================== --- src/camera.cpp 2006-07-16 20:36:10 UTC (rev 89) +++ src/camera.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -1,134 +0,0 @@ -/*************************************************************************** - * camera.cpp - * - * Sat Apr 15 17:51:12 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. - */ - -#include <OgreViewport.h> -#include <OgreMath.h> -#include "camera.h" - -Camera::Camera(Ogre::SceneManager* sceneManager, Ogre::RenderWindow* window, Ogre::SceneNode* avatarNode, bool moveEndOfFrame) { - this->mMoveEndOfFrame = moveEndOfFrame; - - mCamera = NULL; - mRotX = 0; - mRotY = 0; - mTranslateVector = Ogre::Vector3::ZERO; - - createCamera(sceneManager, avatarNode); - createViewports(window); -} - -void Camera::createCamera(Ogre::SceneManager* sceneManager, Ogre::SceneNode* avatarNode) { - // create the camera - mCamera = sceneManager->createCamera("PlayerCam"); - - // set its position, direction - mCamera->setPosition(Ogre::Vector3(0,10,50)); - mCamera->lookAt(Ogre::Vector3(0,0,0)); - mCamera->setAutoTracking (true, avatarNode); // The camera will always look at the camera target - mCamera->setFixedYawAxis (true); // Needed because of auto tracking - mCamera->setNearClipDistance(5); -} - -void Camera::createViewports(Ogre::RenderWindow* window) { - // Create one viewport, entire window - Ogre::Viewport* vp = window->addViewport(mCamera); - vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); - - // Alter the camera aspect ratio to match the viewport - mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); -} - -void Camera::performMove() { - // Movement does not happen at once, so don't do it again at the end of the - // frame - if (!mMoveEndOfFrame) - return; - // Make all the changes to the camera - // Note that YAW direction is around a fixed axis (freelook style) rather - // than a natural YAW (e.g. airplane) - mCamera->rotate(mNewOrientation); - mCamera->moveRelative(mTranslateVector); -} - -bool Camera::move(const int direction, float scale) { - if (!mMoveEndOfFrame) { - reset(); - } - switch(direction) { - case Camera::LEFT: - mTranslateVector += Ogre::Vector3 (0, 0, .1 * scale); - break; - case Camera::RIGHT: - mTranslateVector -= Ogre::Vector3 (0, 0, .1 * scale); - break; - case Camera::UP: - mTranslateVector += Ogre::Vector3 (0, .1 * scale, 0); - break; - case Camera::DOWN: - mTranslateVector -= Ogre::Vector3 (0, .1 * scale, 0); - break; - case Camera::FRONT: - mTranslateVector -= Ogre::Vector3 (1 * scale, 0, 0 ); - break; - case Camera::BACK: - mTranslateVector += Ogre::Vector3 (.5 * scale, 0, 0 ); - break; - default: - return false; - } - if (!mMoveEndOfFrame) { - mCamera->moveRelative(mTranslateVector); - } - return true; -} - -bool Camera::rotate(int direction, Ogre::Degree scale) { - switch(direction) { - case Camera::YAW_LEFT: - mNewOrientation = Ogre::Quaternion(scale, Ogre::Vector3::UNIT_Y); - break; - case Camera::YAW_RIGHT: - mNewOrientation = Ogre::Quaternion(-scale, Ogre::Vector3::UNIT_Y); - break; - case Camera::ROLL_LEFT: - mNewOrientation = Ogre::Quaternion(scale, Ogre::Vector3::UNIT_X); - break; - case Camera::ROLL_RIGHT: - mNewOrientation = Ogre::Quaternion(-scale, Ogre::Vector3::UNIT_X); - break; - case Camera::PITCH_DOWN: - mNewOrientation = Ogre::Quaternion(scale, Ogre::Vector3::UNIT_Z); - break; - case Camera::PITCH_UP: - mNewOrientation = Ogre::Quaternion(-scale, Ogre::Vector3::UNIT_Z); - break; - default: - mNewOrientation = Ogre::Quaternion(Ogre::Degree(0), Ogre::Vector3::UNIT_X); - break; - } - if (!mMoveEndOfFrame) { - mCamera->rotate(mNewOrientation); - } - return true; -} Deleted: src/camera.h =================================================================== --- src/camera.h 2006-07-16 20:36:10 UTC (rev 89) +++ src/camera.h 2006-07-16 20:48:05 UTC (rev 90) @@ -1,127 +0,0 @@ -/*************************************************************************** - * camera.h - * - * Sat Apr 15 17:51:35 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 _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: - /*! \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 camera - * - * 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). - * - * \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 camera - * - * This method rotates the camera in a given direction with a given scale. - * - * \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: - /*! 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 */ Modified: src/client/Makefile.am =================================================================== --- src/client/Makefile.am 2006-07-16 20:36:10 UTC (rev 89) +++ src/client/Makefile.am 2006-07-16 20:48:05 UTC (rev 90) @@ -3,3 +3,6 @@ noinst_LTLIBRARIES = libopengate-client.la noinst_HEADERS = network.h libopengate_client_la_SOURCES = network.cpp +SUBDIRS = input ui +libopengate_client_la_LIBADD = $(top_builddir)/src/client/ui/libopengate-ui.la\ + $(top_builddir)/src/client/input/libopengate-input.la Modified: src/client/Makefile.in =================================================================== --- src/client/Makefile.in 2006-07-16 20:36:10 UTC (rev 89) +++ src/client/Makefile.in 2006-07-16 20:48:05 UTC (rev 90) @@ -48,7 +48,9 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) -libopengate_client_la_LIBADD = +libopengate_client_la_DEPENDENCIES = \ + $(top_builddir)/src/client/ui/libopengate-ui.la \ + $(top_builddir)/src/client/input/libopengate-input.la am_libopengate_client_la_OBJECTS = network.lo libopengate_client_la_OBJECTS = $(am_libopengate_client_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) @@ -64,14 +66,23 @@ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libopengate_client_la_SOURCES) DIST_SOURCES = $(libopengate_client_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -79,6 +90,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ +CEGUI_CFLAGS = @CEGUI_CFLAGS@ +CEGUI_LIBS = @CEGUI_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ @@ -110,6 +123,8 @@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ +OGRE_CFLAGS = @OGRE_CFLAGS@ +OGRE_LIBS = @OGRE_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -117,6 +132,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -174,8 +190,12 @@ noinst_LTLIBRARIES = libopengate-client.la noinst_HEADERS = network.h libopengate_client_la_SOURCES = network.cpp -all: all-am +SUBDIRS = input ui +libopengate_client_la_LIBADD = $(top_builddir)/src/client/ui/libopengate-ui.la\ + $(top_builddir)/src/client/input/libopengate-input.la +all: all-recursive + .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @@ -187,9 +207,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/client/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/client/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/client/Makefile + $(AUTOMAKE) --foreign src/client/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -258,6 +278,77 @@ -rm -f libtool uninstall-info-am: +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -268,10 +359,23 @@ mkid -fID $$unique tags: TAGS -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ @@ -284,7 +388,7 @@ $$tags $$unique; \ fi ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ @@ -333,19 +437,35 @@ || exit 1; \ fi; \ done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am -check: check-am +check: check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ @@ -361,24 +481,24 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am +clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive -info: info-am +info: info-recursive info-am: @@ -386,43 +506,47 @@ install-exec-am: -install-info: install-info-am +install-info: install-info-recursive install-man: installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: uninstall-info-am -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES ctags distclean \ +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean-recursive ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-info-am + distclean-recursive distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. Added: src/client/input/Makefile.am =================================================================== --- src/client/input/Makefile.am (rev 0) +++ src/client/input/Makefile.am 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,6 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO +noinst_LTLIBRARIES = libopengate-input.la +noinst_HEADERS = input.h keyboard.h mouse.h +libopengate_input_la_SOURCES = input.cpp keyboard.cpp mouse.cpp +libopengate_input_la_LIBADD = $(top_builddir)/src/common/libopengate-common.la Property changes on: src/client/input/Makefile.am ___________________________________________________________________ Name: svn:svn:eol-style + native Name: svn:mime-type + text/plain Name: svn:eol-style + native Copied: src/client/input/input.cpp (from rev 84, src/input.cpp) =================================================================== --- src/client/input/input.cpp (rev 0) +++ src/client/input/input.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,35 @@ +/*************************************************************************** + * input.cpp + * + * Mon Apr 17 11:36:04 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. + */ + +#include "input.h" + +Input::Input(Ogre::InputReader* inputDevice, MovableObject* object, CEGUI::Renderer* guiRenderer, Gamestate* gamestate) { + this->mInputDevice = inputDevice; + this->mTarget = object; + this->mGuiRenderer = guiRenderer; + this->mGamestate = gamestate; +} + +Input::~Input() { +} Copied: src/client/input/input.h (from rev 84, src/input.h) =================================================================== --- src/client/input/input.h (rev 0) +++ src/client/input/input.h 2006-07-16 20:48:05 UTC (rev 90) @@ -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 <OGRE/OgreInput.h> +#include <OGRE/OgreFrameListener.h> +#include <CEGUIRenderer.h> +#include "../../common/objects/movable_object.h" +#include "../../common/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 */ Copied: src/client/input/keyboard.cpp (from rev 84, src/keyboard.cpp) =================================================================== --- src/client/input/keyboard.cpp (rev 0) +++ src/client/input/keyboard.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,163 @@ +/*************************************************************************** + * keyboard.cpp + * + * Sat Apr 15 16:31:18 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. + */ + +#include "keyboard.h" + +Keyboard::Keyboard(Ogre::InputReader* inputDevice, Avatar* avatar, CEGUI::Renderer* guiRenderer, Gamestate* gamestate) + : Input (inputDevice, avatar, guiRenderer, gamestate) { + mTimeUntilNextToggle = 0; +} + +Keyboard::~Keyboard() { +} + +Ogre::Real Keyboard::processInput(const Ogre::FrameEvent& evt) { + + switch (mGamestate->getGamestate()) { + case Gamestate::GAME: + mTimeUntilNextToggle = 0; + + // Move avatar forwards + if (mInputDevice->isKeyDown(Ogre::KC_U)) { + mTarget->move(Avatar::FRONT, mMoveScale); + } + + // Move avatar backwards + if (mInputDevice->isKeyDown(Ogre::KC_N)) { + mTarget->move(Avatar::BACK, mMoveScale); + } + + // Move avatar forwards + if (mInputDevice->isKeyDown(Ogre::KC_I)) { + mTarget->move(Avatar::PITCH_DOWN, mMoveScale); + } + + // Move avatar backwards + if (mInputDevice->isKeyDown(Ogre::KC_K)) { + mTarget->move(Avatar::PITCH_UP, mMoveScale); + } + + // Move avatar left + if (mInputDevice->isKeyDown(Ogre::KC_J)) { + mTarget->move(Avatar::YAW_LEFT, mMoveScale); + } + + // Move avatar right + if (mInputDevice->isKeyDown(Ogre::KC_L)) { + mTarget->move(Avatar::YAW_RIGHT, mMoveScale); + } + + // Move avatar up + if (mInputDevice->isKeyDown(Ogre::KC_PERIOD)) { + mTarget->move(Avatar::ROLL_RIGHT, mMoveScale); + } + + // Move avatar down + if (mInputDevice->isKeyDown(Ogre::KC_COMMA)) { + mTarget->move(Avatar::ROLL_LEFT, mMoveScale); + } + + // switch to menu + if( mInputDevice->isKeyDown(Ogre::KC_ESCAPE)) { + mGamestate->setGamestate(Gamestate::MENU); + } + + /*// switch filtering + if (mInputDevice->isKeyDown(Ogre::KC_T) && mTimeUntilNextToggle <= 0) { + switch(mFiltering) { + case TFO_BILINEAR: + mFiltering = TFO_TRILINEAR; + mAniso = 1; + break; + case TFO_TRILINEAR: + mFiltering = TFO_ANISOTROPIC; + mAniso = 8; + break; + case TFO_ANISOTROPIC: + mFiltering = TFO_BILINEAR; + mAniso = 1; + break; + default: + break; + } + MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); + MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); + + showDebugOverlay(mStatsOn); + + mTimeUntilNextToggle = 1; + } + + // create screenshot + if (mInputDevice->isKeyDown(Ogre::KC_SYSRQ) && mTimeUntilNextToggle <= 0) { + char tmp[20]; + sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots); + mWindow->writeContentsToFile(tmp); + mTimeUntilNextToggle = 0.5; + mWindow->setDebugText(String("Wrote ") + tmp); + } + + // switch rendermode + if (mInputDevice->isKeyDown(Ogre::KC_R) && mTimeUntilNextToggle <=0) { + mSceneDetailIndex = (mSceneDetailIndex+1)%3; + switch(mSceneDetailIndex) { + case 0 : mCamera->setDetailLevel(Ogre::SDL_SOLID) ; break ; + case 1 : mCamera->setDetailLevel(Ogre::SDL_WIREFRAME) ; break ; + case 2 : mCamera->setDetailLevel(Ogre::SDL_POINTS) ; break ; + } + mTimeUntilNextToggle = 1; + } + + static bool displayCameraDetails = false; + if (mInputDevice->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0) + { + + displayCameraDetails = !displayCameraDetails; + mTimeUntilNextToggle = 1; + if (!displayCameraDetails) + mWindow->setDebugText(""); + } + if (displayCameraDetails) + { + // Print camera details + mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + " " + + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); + }*/ + + // Return true to continue rendering + return mTimeUntilNextToggle; + case Gamestate::MENU: + // quit game + if( mInputDevice->isKeyDown(Ogre::KC_ESCAPE)) { + return Input::GAME_QUIT; + } + return 0; + default: + return 0; + } +} + +void Keyboard::setScale(float moveScale) { + mMoveScale = moveScale; +} Copied: src/client/input/keyboard.h (from rev 84, src/keyboard.h) =================================================================== --- src/client/input/keyboard.h (rev 0) +++ src/client/input/keyboard.h 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,58 @@ +/*************************************************************************** + * keyboard.h + * + * Sat Apr 15 16:31:36 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 _KEYBOARD_H +#define _KEYBOARD_H + +#include <OgreInput.h> +#include <OgreFrameListener.h> +#include <OgreMath.h> +#include "../ui/avatar.h" +#include "input.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Keyboard : public Input { +public: + 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: + + /*! Value to move the camera */ + float mMoveScale; + + /*! */ + Ogre::Real mTimeUntilNextToggle; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _KEYBOARD_H */ Copied: src/client/input/mouse.cpp (from rev 84, src/mouse.cpp) =================================================================== --- src/client/input/mouse.cpp (rev 0) +++ src/client/input/mouse.cpp 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,66 @@ +/*************************************************************************** + * mouse.cpp + * + * Sat Apr 15 16:55:56 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. + */ + +#include <CEGUISystem.h> +#include "mouse.h" + +Mouse::Mouse(Ogre::InputReader* inputDevice, Avatar* avatar, CEGUI::Renderer* guiRenderer, Gamestate* gamestate) + : Input (inputDevice, avatar, guiRenderer, gamestate) { + mPressed = false; +} + +Ogre::Real Mouse::processInput(const Ogre::FrameEvent& evt) { + + switch (mGamestate->getGamestate()) { + case Gamestate::GAME: + /* If the second mouse button is pressed, then the mouse movement results in + sliding the camera, otherwise we rotate. */ + if (mInputDevice->getMouseButton(1)) { + mTarget->move(Avatar::LEFT, (mInputDevice->getMouseRelativeX() * 0.13)); + mTarget->move(Avatar::DOWN, (mInputDevice->getMouseRelativeY() * 0.13)); + } else { + mTarget->rotate(Avatar::YAW_RIGHT, Ogre::Degree(mInputDevice->getMouseRelativeX() * 0.13)); + mTarget->rotate(Avatar::PITCH_DOWN, Ogre::Degree(mInputDevice->getMouseRelativeY() * 0.13)); + } + return 0; + case Gamestate::MENU: + CEGUI::System::getSingleton().injectMouseMove( + (mInputDevice->getMouseRelativeX() * 0.13) * mGuiRenderer->getWidth(), + (mInputDevice->getMouseRelativeY() * 0.13) * mGuiRenderer->getHeight()); + if (mInputDevice->getMouseButton(0)) { + CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton); + mPressed = true; + } else if (mPressed && !mInputDevice->getMouseButton(0)) { + CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton); + } + return 0; + default: + break; + } + return 0; +} + +void Mouse::setScale(Ogre::Degree rotScale) { + mRotScale = rotScale; +} Copied: src/client/input/mouse.h (from rev 84, src/mouse.h) =================================================================== --- src/client/input/mouse.h (rev 0) +++ src/client/input/mouse.h 2006-07-16 20:48:05 UTC (rev 90) @@ -0,0 +1,82 @@ +/*************************************************************************** + * mouse.h + * + * Sat Apr 15 16:55:15 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 _MOUSE_H +#define _MOUSE_H + +#include <OgreInput.h> +#include <OgreFrameListener.h> +#include <OgreMath.h> +#include "../ui/avatar.h" +#include "input.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +class Mouse : public Input { +public: + /*! \brief Creates a new camera to chase the players avatar + * + * This constructor saves the given avatar an... [truncated message content] |