Changeset 1495 for code/branches/network/src/orxonox
- Timestamp:
- Jun 1, 2008, 1:10:46 AM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/CMakeLists.txt
r1494 r1495 1 SET( ORXONOX_SRC_FILES GraphicsEngine.cc Main.cc Orxonox.cc console/InGameConsole.cc hud/HUD.cc hud/BarOverlayElement.cc hud/RadarOverlayElement.cc 1 SET( ORXONOX_SRC_FILES 2 GraphicsEngine.cc 3 Main.cc 4 Orxonox.cc 5 6 console/InGameConsole.cc 7 hud/HUD.cc 8 hud/BarOverlayElement.cc 9 hud/RadarOverlayElement.cc 2 10 hud/RadarObject.cc 3 hud/Navigation.cc particle/ParticleInterface.cc tolua/tolua_bind.cc tools/BillboardSet.cc tools/Light.cc tools/Mesh.cc tools/Timer.cc objects/Ambient.cc objects/Camera.cc objects/CameraHandler.cc objects/Explosion.cc objects/Model.cc objects/NPC.cc objects/Projectile.cc objects/RotatingProjectile.cc objects/Skybox.cc objects/SpaceShip.cc objects/SpaceShipAI.cc objects/WorldEntity.cc# objects/weapon/AmmunitionDump.cc# objects/weapon/BarrelGun.cc# objects/weapon/BaseWeapon.cc# objects/weapon/Bullet.cc# objects/weapon/BulletManager.cc# objects/weapon/WeaponStation.cc)GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)ADD_CUSTOM_COMMAND( OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg DEPENDS tolua WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib) ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )IF(NETWORKTRAFFIC_TESTING_ENABLED) SET( ORXONOXS_SRC_FILES GraphicsEngine.cc objects/Ambient.cc objects/Camera.cc objects/CameraHandler.cc objects/Explosion.cc objects/Model.cc objects/NPC.cc objects/Projectile.cc objects/Skybox.cc objects/SpaceShip.cc objects/WorldEntity.cc ) ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES})ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)TARGET_LINK_LIBRARIES( orxonox ${OGRE_LIBRARIES} ${Lua_LIBRARIES} tinyxml tolualib ois util core audio network) 11 hud/Navigation.cc 12 particle/ParticleInterface.cc 13 tolua/tolua_bind.cc 14 15 tools/BillboardSet.cc 16 tools/Light.cc 17 tools/Mesh.cc 18 tools/Timer.cc 19 20 objects/Ambient.cc 21 objects/Camera.cc 22 objects/CameraHandler.cc 23 objects/Explosion.cc 24 objects/Model.cc 25 objects/NPC.cc 26 objects/Projectile.cc 27 objects/RotatingProjectile.cc 28 objects/Skybox.cc 29 objects/SpaceShip.cc 30 objects/SpaceShipAI.cc 31 objects/WorldEntity.cc 32 33 # objects/weapon/AmmunitionDump.cc 34 # objects/weapon/BarrelGun.cc 35 # objects/weapon/BaseWeapon.cc 36 # objects/weapon/Bullet.cc 37 # objects/weapon/BulletManager.cc 38 # objects/weapon/WeaponStation.cc 39 ) 40 41 GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION) 42 ADD_CUSTOM_COMMAND( 43 OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h 44 COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg 45 DEPENDS tolua 46 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib 47 ) 48 49 ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} ) 50 51 IF(NETWORKTRAFFIC_TESTING_ENABLED) 52 53 SET( ORXONOXS_SRC_FILES 54 GraphicsEngine.cc 55 objects/Ambient.cc 56 objects/Camera.cc 57 objects/CameraHandler.cc 58 objects/Explosion.cc 59 objects/Model.cc 60 objects/NPC.cc 61 objects/Projectile.cc 62 objects/Skybox.cc 63 objects/SpaceShip.cc 64 objects/WorldEntity.cc 65 ) 66 67 ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES}) 68 ENDIF(NETWORKTRAFFIC_TESTING_ENABLED) 69 70 TARGET_LINK_LIBRARIES( orxonox 71 ${OGRE_LIBRARIES} 72 ${Lua_LIBRARIES} 73 tinyxml 74 tolualib 75 ois 76 util 77 core 78 audio 79 network 80 ) 81 -
code/branches/network/src/orxonox/GraphicsEngine.cc
r1494 r1495 44 44 #include "core/ConfigValueIncludes.h" 45 45 #include "core/Debug.h" 46 #include "core/CommandExecutor.h"#include "core/TclBind.h" 46 #include "core/CommandExecutor.h" 47 #include "core/TclBind.h" 47 48 #include "console/InGameConsole.h" 48 49 … … 86 87 SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial"); 87 88 SetConfigValue(ogreLogLevelNormal_ , 4).description("Corresponding orxonox debug level for ogre Normal"); 88 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); TclBind::getInstance().setDataPath(this->dataPath_); 89 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); 90 91 TclBind::getInstance().setDataPath(this->dataPath_); 89 92 } 90 93 … … 309 312 return 0; 310 313 } 311 /** @brief Returns the window aspect ratio height/width. @return The ratio */ float GraphicsEngine::getWindowAspectRatio() const { if (this->renderWindow_) return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth(); else return 1.0f; } 314 315 /** 316 @brief Returns the window aspect ratio height/width. 317 @return The ratio 318 */ 319 float GraphicsEngine::getWindowAspectRatio() const 320 { 321 if (this->renderWindow_) 322 return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth(); 323 else 324 return 1.0f; 325 } 326 312 327 /** 313 328 @brief Method called by the LogListener interface from Ogre. … … 356 371 * as rw. But we have to be careful when using multiple render windows! 357 372 */ 358 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) { // change the mouse clipping size for absolute mouse movements 373 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) 374 { 375 // change the mouse clipping size for absolute mouse movements 359 376 int w = rw->getWidth(); 360 377 int h = rw->getHeight(); -
code/branches/network/src/orxonox/GraphicsEngine.h
r1494 r1495 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < * 3 * > www.orxonox.net < 4 * 4 5 * 5 6 * License notice: … … 70 71 size_t getWindowHandle(); 71 72 int getWindowWidth() const; 72 int getWindowHeight() const; float getWindowAspectRatio() const; 73 int getWindowHeight() const; 74 float getWindowAspectRatio() const; 73 75 float getAverageFPS() const 74 76 { if (renderWindow_) return this->renderWindow_->getAverageFPS(); else return 0.0f; } -
code/branches/network/src/orxonox/Orxonox.cc
r1494 r1495 84 84 SetConsoleCommandShortcut(Orxonox, slomo).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false); 85 85 SetConsoleCommandShortcut(Orxonox, setTimeFactor).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0); 86 86 87 /** 87 88 @brief Reference to the only instance of the class. -
code/branches/network/src/orxonox/Orxonox.h
r1494 r1495 71 71 static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; } 72 72 static inline void exit() { Orxonox::getSingleton()->abortRequest(); } 73 73 74 private: 74 75 // don't mess with singletons -
code/branches/network/src/orxonox/OrxonoxPrereqs.h
r1494 r1495 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < * 3 * > www.orxonox.net < 4 * 4 5 * 5 6 * License notice: … … 72 73 class Projectile; 73 74 class Skybox; 74 class SpaceShip; class SpaceShipAI; 75 class SpaceShip; 76 class SpaceShipAI; 75 77 class WorldEntity; 76 78 … … 94 96 95 97 // hud 96 class BarOverlayElement; class HUD; class Navigation; class RadarObject; class RadarOverlayElement; 98 class BarOverlayElement; 99 class HUD; 100 class Navigation; 101 class RadarObject; 102 class RadarOverlayElement; 97 103 98 104 //console -
code/branches/network/src/orxonox/OrxonoxStableHeaders.h
r1494 r1495 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < * 3 * > www.orxonox.net < 4 * 4 5 * 5 6 * License notice: … … 30 31 @brief Contains the bigger (or smaller) header files in order to precompile them with MSVC 31 32 */ 32 #ifndef _OrxonoxStableHeaders_H__#define _OrxonoxStableHeaders_H__#include "util/OrxonoxPlatform.h"#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC// including std headers here is useless since they're already precompiled#ifndef WIN32_LEAN_AND_MEAN// prevent Ogre from including winsock.h that messes with winsock2.h from enet# define WIN32_LEAN_AND_MEAN#endif// not including the entire Ogre.h doesn't exceed the default heap size for pch//#include <Ogre.h>#include <OgreBillboardSet.h>#include <OgreCamera.h>#include <OgreColourValue.h>#include <OgreConfigFile.h>#include <OgreEntity.h>#include <OgreException.h>#include <OgreFrameListener.h>#include <OgreLight.h>#include <OgreLog.h>#include <OgreLogManager.h>#include <OgreMath.h>#include <OgreMatrix3.h>#include <OgreOverlay.h>#include <OgreOverlayElement.h>#include <OgreOverlayManager.h>#include <OgreParticleEmitter.h>#include <OgreParticleSystem.h>#include <OgreQuaternion.h>#include <OgreResourceGroupManager.h>#include <OgreRenderWindow.h>#include <OgreRoot.h>#include <OgreSceneManager.h>#include <OgreSceneNode.h>#include <OgreStringConverter.h>#include <OgreTextureManager.h>#include <OgreTimer.h>#include <OgreVector2.h>#include <OgreVector3.h>#include <OgreVector3.h>#include <OgreViewport.h>#include <OgreWindowEventUtilities.h>//----------------------------------------------------------------------- 33 34 #ifndef _OrxonoxStableHeaders_H__ 35 #define _OrxonoxStableHeaders_H__ 36 37 #include "util/OrxonoxPlatform.h" 38 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 40 41 // including std headers here is useless since they're already precompiled 42 43 #ifndef WIN32_LEAN_AND_MEAN 44 // prevent Ogre from including winsock.h that messes with winsock2.h from enet 45 # define WIN32_LEAN_AND_MEAN 46 #endif 47 // not including the entire Ogre.h doesn't exceed the default heap size for pch 48 //#include <Ogre.h> 49 #include <OgreBillboardSet.h> 50 #include <OgreCamera.h> 51 #include <OgreColourValue.h> 52 #include <OgreConfigFile.h> 53 #include <OgreEntity.h> 54 #include <OgreException.h> 55 #include <OgreFrameListener.h> 56 #include <OgreLight.h> 57 #include <OgreLog.h> 58 #include <OgreLogManager.h> 59 #include <OgreMath.h> 60 #include <OgreMatrix3.h> 61 #include <OgreOverlay.h> 62 #include <OgreOverlayElement.h> 63 #include <OgreOverlayManager.h> 64 #include <OgreParticleEmitter.h> 65 #include <OgreParticleSystem.h> 66 #include <OgreQuaternion.h> 67 #include <OgreResourceGroupManager.h> 68 #include <OgreRenderWindow.h> 69 #include <OgreRoot.h> 70 #include <OgreSceneManager.h> 71 #include <OgreSceneNode.h> 72 #include <OgreStringConverter.h> 73 #include <OgreTextureManager.h> 74 #include <OgreTimer.h> 75 #include <OgreVector2.h> 76 #include <OgreVector3.h> 77 #include <OgreVector3.h> 78 #include <OgreViewport.h> 79 #include <OgreWindowEventUtilities.h> 80 81 //----------------------------------------------------------------------- 33 82 // ORXONOX HEADERS 34 83 //----------------------------------------------------------------------- 35 84 36 85 #include "ois/OIS.h" 86 37 87 //#include "util/Convert.h" 38 #include "util/Math.h"//#include "util/Multitype.h"//#include "util/MultiTypeMath.h"//#include "util/MultiTypePrimitive.h"//#include "util/MultiTypeString.h"#include "util/Sleep.h"#include "util/String.h"#include "util/SubString.h"//#include "util/XMLIncludes.h"#include "tinyxml/ticpp.h"#include "tinyxml/tinyxml.h"#include "core/BaseObject.h"//#include "core/CommandExecutor.h"//#include "core/CoreIncludes.h"//#include "core/ConfigValueIncludes.h"#include "core/Debug.h"//#include "core/Executor.h"#include "core/Tickable.h"//#include "core/XMLPort.h"#include "network/Synchronisable.h"#include "OrxonoxPrereqs.h"#include "tools/Timer.h"#include "objects/Model.h"#include "objects/WorldEntity.h"#endif /* Compiler MSVC */#endif /* _OrxonoxStableHeaders_H__ */ 88 #include "util/Math.h" 89 //#include "util/Multitype.h" 90 //#include "util/MultiTypeMath.h" 91 //#include "util/MultiTypePrimitive.h" 92 //#include "util/MultiTypeString.h" 93 #include "util/Sleep.h" 94 #include "util/String.h" 95 #include "util/SubString.h" 96 //#include "util/XMLIncludes.h" 97 #include "tinyxml/ticpp.h" 98 #include "tinyxml/tinyxml.h" 99 100 #include "core/BaseObject.h" 101 //#include "core/CommandExecutor.h" 102 //#include "core/CoreIncludes.h" 103 //#include "core/ConfigValueIncludes.h" 104 #include "core/Debug.h" 105 //#include "core/Executor.h" 106 #include "core/Tickable.h" 107 //#include "core/XMLPort.h" 108 109 #include "network/Synchronisable.h" 110 111 #include "OrxonoxPrereqs.h" 112 #include "tools/Timer.h" 113 #include "objects/Model.h" 114 #include "objects/WorldEntity.h" 115 116 #endif /* Compiler MSVC */ 117 118 #endif /* _OrxonoxStableHeaders_H__ */ -
code/branches/network/src/orxonox/PrecompiledHeaderFiles.cc
r1494 r1495 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < * 3 * > www.orxonox.net < 4 * 4 5 * 5 6 * License notice: -
code/branches/network/src/orxonox/console/InGameConsole.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Felix Schulthess * Co-authors: * Fabian 'x3n' Landau * */#ifndef _InGameConsole_H__#define _InGameConsole_H__ 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Felix Schulthess 24 * Co-authors: 25 * Fabian 'x3n' Landau 26 * 27 */ 28 29 #ifndef _InGameConsole_H__ 30 #define _InGameConsole_H__ 31 2 32 3 33 #include "OrxonoxPrereqs.h" … … 8 38 #include "core/Tickable.h" 9 39 #include "core/Shell.h" 10 namespace orxonox{ 40 41 42 namespace orxonox 43 { 11 44 class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener 12 45 { 13 public: static InGameConsole& getInstance(); void setConfigValues(); void tick(float dt); 46 public: 47 static InGameConsole& getInstance(); 48 49 void setConfigValues(); 50 void tick(float dt); 51 14 52 void activate(); 15 void deactivate(); void resize(); static void openConsole(); static void closeConsole(); 53 void deactivate(); 54 void resize(); 55 56 static void openConsole(); 57 static void closeConsole(); 16 58 17 59 private: 18 InGameConsole(); InGameConsole(const InGameConsole& other); ~InGameConsole(); virtual void linesChanged(); virtual void onlyLastLineChanged(); virtual void lineAdded(); virtual void inputChanged(); virtual void cursorChanged(); virtual void exit(); void init(); void shiftLines(); void colourLine(int colourcode, int index); 60 InGameConsole(); 61 InGameConsole(const InGameConsole& other); 62 ~InGameConsole(); 63 64 virtual void linesChanged(); 65 virtual void onlyLastLineChanged(); 66 virtual void lineAdded(); 67 virtual void inputChanged(); 68 virtual void cursorChanged(); 69 virtual void exit(); 70 71 void init(); 72 void shiftLines(); 73 void colourLine(int colourcode, int index); 19 74 void setCursorPosition(int pos); 20 75 void print(const std::string& text, int index, bool alwaysShift = false); 21 76 static Ogre::UTFString convert2UTF(std::string s); 22 static float REL_WIDTH; static float REL_HEIGHT; static float BLINK; int windowW_; 23 int windowH_; int desiredTextWidth_; unsigned int maxCharsPerLine_; unsigned int numLinesShifted_; 77 78 static float REL_WIDTH; 79 static float REL_HEIGHT; 80 static float BLINK; 81 82 int windowW_; 83 int windowH_; 84 int desiredTextWidth_; 85 unsigned int maxCharsPerLine_; 86 unsigned int numLinesShifted_; 24 87 int scroll_; 25 88 float scrollTimer_; 26 float cursor_; unsigned int inputWindowStart_; char cursorSymbol_; 89 float cursor_; 90 unsigned int inputWindowStart_; 91 char cursorSymbol_; 27 92 bool active_; 28 93 bool bShowCursor_; … … 35 100 Ogre::BorderPanelOverlayElement* consoleOverlayBorder_; 36 101 Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_; 37 };}#endif /* _InGameConsole_H__ */ 102 }; 103 } 104 105 #endif /* _InGameConsole_H__ */ -
code/branches/network/src/orxonox/hud/BarOverlayElement.cc
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/hud/BarOverlayElement.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/hud/HUD.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/hud/Navigation.cc
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Felix Schulthess -
code/branches/network/src/orxonox/hud/Navigation.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Felix Schulthess -
code/branches/network/src/orxonox/hud/OverlayElementFactories.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/hud/RadarObject.cc
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Felix Schulthess -
code/branches/network/src/orxonox/hud/RadarObject.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Felix Schulthess -
code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/hud/RadarOverlayElement.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 2 22 * Author: 3 23 * Yuning Chai -
code/branches/network/src/orxonox/objects/Camera.h
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Fabian 'x3n' Landau * Co-authors: * Benjamin Knecht * */#ifndef _Camera_H__#define _Camera_H__#include <OgrePrerequisites.h>#include <OgreSceneNode.h>#include <OgreCamera.h>#include "OrxonoxPrereqs.h"namespace orxonox{ class _OrxonoxExport Camera { friend class CameraHandler; public: Camera(Ogre::SceneNode* node = NULL); virtual ~Camera(); void setPositionNode(Ogre::SceneNode* node); inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; } // maybe also BaseObject void setTargetNode(Ogre::SceneNode* obj); 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Fabian 'x3n' Landau 24 * Co-authors: 25 * Benjamin Knecht 26 * 27 */ 28 29 #ifndef _Camera_H__ 30 #define _Camera_H__ 31 32 #include <OgrePrerequisites.h> 33 #include <OgreSceneNode.h> 34 #include <OgreCamera.h> 35 36 #include "OrxonoxPrereqs.h" 37 38 namespace orxonox 39 { 40 class _OrxonoxExport Camera 41 { 42 friend class CameraHandler; 43 public: 44 Camera(Ogre::SceneNode* node = NULL); 45 virtual ~Camera(); 46 47 void setPositionNode(Ogre::SceneNode* node); 48 inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; } 49 // maybe also BaseObject 50 void setTargetNode(Ogre::SceneNode* obj); 51 2 52 Ogre::Camera* cam_; 3 void tick(float dt); void update(); inline bool hasFocus() { return this->bHasFocus_; } private: void removeFocus(); void setFocus(Ogre::Camera* ogreCam); private: Ogre::SceneNode* targetNode_; Ogre::SceneNode* positionNode_; Ogre::SceneNode* cameraNode_; Ogre::Vector3 oldPos; bool bHasFocus_; };}#endif /* _Camera_H__ */ 53 54 void tick(float dt); 55 void update(); 56 inline bool hasFocus() { return this->bHasFocus_; } 57 58 private: 59 void removeFocus(); 60 void setFocus(Ogre::Camera* ogreCam); 61 62 private: 63 Ogre::SceneNode* targetNode_; 64 Ogre::SceneNode* positionNode_; 65 Ogre::SceneNode* cameraNode_; 66 Ogre::Vector3 oldPos; 67 bool bHasFocus_; 68 }; 69 } 70 71 #endif /* _Camera_H__ */ -
code/branches/network/src/orxonox/objects/SpaceShipAI.cc
r1494 r1495 1 /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Fabian 'x3n' Landau * Co-authors: * ... * */#include "OrxonoxStableHeaders.h" 2 #include "SpaceShipAI.h"#include <OgreMath.h>#include "Projectile.h"#include "core/CoreIncludes.h"#include "core/Iterator.h"#include "core/Executor.h"#include "core/ConsoleCommand.h"#include "core/XMLPort.h"#define ACTION_INTERVAL 1.0fnamespace orxonox{ SetConsoleCommand(SpaceShipAI, createEnemy, true).setDefaultValue(0, 1); SetConsoleCommand(SpaceShipAI, killEnemies, true).setDefaultValue(0, 0); CreateFactory(SpaceShipAI); SpaceShipAI::SpaceShipAI() { RegisterObject(SpaceShipAI); this->alive_ = true; this->setPosition(Vector3(rnd(-1000, 1000), rnd(-1000, 1000), rnd(-1000, 0000))); this->target_ = 0; this->bShooting_ = 0; this->bHasTargetPosition_ = false; this->setTeamNr((int)rnd(NUM_AI_TEAMS) % NUM_AI_TEAMS + 1); if (NUM_AI_TEAMS > 0) this->teamColours_[1] = ColourValue(1, 0, 0, 1); if (NUM_AI_TEAMS > 1) this->teamColours_[2] = ColourValue(0, 1, 0, 1); if (NUM_AI_TEAMS > 2) this->teamColours_[3] = ColourValue(0, 0, 1, 1); for (int i = 4; i <= NUM_AI_TEAMS; ++i) this->teamColours_[i] = ColourValue(rnd(), rnd(), rnd(), 1); } void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SpaceShip::XMLPort(xmlelement, mode); myShip_=true; this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action))); } void SpaceShipAI::createEnemy(int num) { for (int i = 0; i < num; ++i) { SpaceShipAI* newenemy = new SpaceShipAI(); newenemy->setMesh("assff.mesh");// newenemy->setPosition(0, 0, 0); newenemy->setScale(10); newenemy->setMaxSpeed(500); newenemy->setMaxSideAndBackSpeed(50); newenemy->setMaxRotation(1.0); newenemy->setTransAcc(200); newenemy->setRotAcc(3.0); newenemy->setTransDamp(75); newenemy->setRotDamp(1.0); Element xmlelement; newenemy->XMLPort(xmlelement, XMLPort::LoadObject); } } void SpaceShipAI::killEnemies(int num) { int i = 0; for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ) { delete *(it++); ++i; if (num && i >= num) break; } } ColourValue SpaceShipAI::getProjectileColour() const { return this->teamColours_[this->getTeamNr()]; } void SpaceShipAI::action() { float random; float maxrand = 100.0f / ACTION_INTERVAL; // search enemy random = rnd(maxrand);//std::cout << "search enemy: " << random << std::endl; if (random < 20 && (!this->target_)) { this->searchNewTarget(); } // forget enemy random = rnd(maxrand);//std::cout << "forget enemy: " << random << std::endl; if (random < 5 && (this->target_)) { this->forgetTarget(); } // next enemy random = rnd(maxrand);//std::cout << "next enemy: " << random << std::endl; if (random < 10 && (this->target_)) { this->searchNewTarget(); } // fly somewhere random = rnd(maxrand);//std::cout << "fly somewhere: " << random << std::endl; if (random < 40 && (!this->bHasTargetPosition_ && !this->target_)) { this->searchNewTargetPosition(); } // stop flying random = rnd(maxrand);//std::cout << "stop flying: " << random << std::endl; if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) { this->bHasTargetPosition_ = false; } // fly somewhere else random = rnd(maxrand);//std::cout << "fly somewhere else: " << random << std::endl; if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) { this->searchNewTargetPosition(); } // shoot random = rnd(maxrand);//std::cout << "shoot: " << random << std::endl; if (random < 75 && (this->target_ && !this->bShooting_)) { this->bShooting_ = true; } // stop shooting random = rnd(maxrand);//std::cout << "stop shooting: " << random << std::endl; if (random < 25 && (this->bShooting_)) { this->bShooting_ = false; } } void SpaceShipAI::tick(float dt) { if (this->target_) this->aimAtTarget(); if (this->bHasTargetPosition_) this->moveToTargetPosition(dt); if (this->bShooting_ && this->isCloseAtTarget(2000) && this->isLookingAtTarget(Ogre::Math::PI / 10.0f)) this->doFire(); SpaceShip::tick(dt); } void SpaceShipAI::moveToTargetPosition(float dt) { static Radian RadianZERO(0);// float dotprod = (this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(this->targetPosition_ - this->getPosition()); Quaternion rotation = (this->getOrientation() * Ogre::Vector3::UNIT_X).getRotationTo(this->targetPosition_ - this->getPosition());/*std::cout << "scalprod: " << dotprod << std::endl;std::cout << "dist: " << this->targetPosition_ - this->getPosition() << std::endl;std::cout << "yaw: " << rotation.getYaw().valueRadians() << std::endl;std::cout << "pitch: " << rotation.getPitch().valueRadians() << std::endl;std::cout << "roll: " << rotation.getRoll().valueRadians() << std::endl;*/ this->setMoveYaw(-rotation.getRoll().valueRadians()); this->setMovePitch(rotation.getYaw().valueRadians()); if ((this->targetPosition_ - this->getPosition()).length() > 100) { this->setMoveLongitudinal(1); } } void SpaceShipAI::searchNewTargetPosition() { this->targetPosition_ = Vector3(rnd(-5000,5000), rnd(-5000,5000), rnd(-5000,5000)); this->bHasTargetPosition_ = true; } void SpaceShipAI::searchNewTarget() { this->targetPosition_ = this->getPosition(); this->forgetTarget(); for (Iterator<SpaceShip> it = ObjectList<SpaceShip>::begin(); it; ++it) { if (it->getTeamNr() != this->getTeamNr()) { float speed = this->getVelocity().length(); Vector3 distanceCurrent = this->targetPosition_ - this->getPosition(); Vector3 distanceNew = it->getPosition() - this->getPosition(); if (!this->target_ || it->getPosition().squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceNew) / speed / distanceNew.length()) / (2 * Ogre::Math::PI)) < this->targetPosition_.squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::Math::PI))) { this->target_ = (*it); this->targetPosition_ = it->getPosition(); } } } } void SpaceShipAI::forgetTarget() { this->target_ = 0; this->bShooting_ = false; } void SpaceShipAI::aimAtTarget() { if (!this->target_) return;/* Vector3 enemymovement = this->target_->getVelocity(); Vector3 distance_normalised = this->target_->getPosition() - this->getPosition(); distance_normalised.normalise(); float scalarprod = enemymovement.dotProduct(distance_normalised); float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength(); if (aimoffset < 0) { this->bHasTargetPosition_ = false; return; } aimoffset = -scalarprod + sqrt(aimoffset); this->targetPosition_ = enemymovement + distance_normalised * aimoffset; this->bHasTargetPosition_ = true; std::cout << "targetpos: " << this->targetPosition_ << std::endl;*/ this->targetPosition_ = this->target_->getPosition(); this->bHasTargetPosition_ = true; } bool SpaceShipAI::isCloseAtTarget(float distance) { return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance); } bool SpaceShipAI::isLookingAtTarget(float angle) { return (this->getOrientation() * Ogre::Vector3::UNIT_X).directionEquals(this->targetPosition_ - this->getPosition(), Radian(angle)); }} 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Fabian 'x3n' Landau 24 * Co-authors: 25 * ... 26 * 27 */ 28 29 #include "OrxonoxStableHeaders.h" 30 #include "SpaceShipAI.h" 31 32 #include <OgreMath.h> 33 #include "Projectile.h" 34 #include "core/CoreIncludes.h" 35 #include "core/Iterator.h" 36 #include "core/Executor.h" 37 #include "core/ConsoleCommand.h" 38 #include "core/XMLPort.h" 39 40 #define ACTION_INTERVAL 1.0f 41 42 namespace orxonox 43 { 44 SetConsoleCommand(SpaceShipAI, createEnemy, true).setDefaultValue(0, 1); 45 SetConsoleCommand(SpaceShipAI, killEnemies, true).setDefaultValue(0, 0); 46 47 CreateFactory(SpaceShipAI); 48 49 SpaceShipAI::SpaceShipAI() 50 { 51 RegisterObject(SpaceShipAI); 52 53 this->alive_ = true; 54 this->setPosition(Vector3(rnd(-1000, 1000), rnd(-1000, 1000), rnd(-1000, 0000))); 55 this->target_ = 0; 56 this->bShooting_ = 0; 57 this->bHasTargetPosition_ = false; 58 59 this->setTeamNr((int)rnd(NUM_AI_TEAMS) % NUM_AI_TEAMS + 1); 60 61 if (NUM_AI_TEAMS > 0) 62 this->teamColours_[1] = ColourValue(1, 0, 0, 1); 63 if (NUM_AI_TEAMS > 1) 64 this->teamColours_[2] = ColourValue(0, 1, 0, 1); 65 if (NUM_AI_TEAMS > 2) 66 this->teamColours_[3] = ColourValue(0, 0, 1, 1); 67 68 for (int i = 4; i <= NUM_AI_TEAMS; ++i) 69 this->teamColours_[i] = ColourValue(rnd(), rnd(), rnd(), 1); 70 } 71 72 void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode) 73 { 74 SpaceShip::XMLPort(xmlelement, mode); 75 myShip_=true; 76 77 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action))); 78 } 79 80 void SpaceShipAI::createEnemy(int num) 81 { 82 for (int i = 0; i < num; ++i) 83 { 84 SpaceShipAI* newenemy = new SpaceShipAI(); 85 newenemy->setMesh("assff.mesh"); 86 // newenemy->setPosition(0, 0, 0); 87 newenemy->setScale(10); 88 newenemy->setMaxSpeed(500); 89 newenemy->setMaxSideAndBackSpeed(50); 90 newenemy->setMaxRotation(1.0); 91 newenemy->setTransAcc(200); 92 newenemy->setRotAcc(3.0); 93 newenemy->setTransDamp(75); 94 newenemy->setRotDamp(1.0); 95 Element xmlelement; 96 newenemy->XMLPort(xmlelement, XMLPort::LoadObject); 97 } 98 } 99 100 void SpaceShipAI::killEnemies(int num) 101 { 102 int i = 0; 103 for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ) 104 { 105 delete *(it++); 106 ++i; 107 if (num && i >= num) 108 break; 109 } 110 } 111 112 ColourValue SpaceShipAI::getProjectileColour() const 113 { 114 return this->teamColours_[this->getTeamNr()]; 115 } 116 117 void SpaceShipAI::action() 118 { 119 float random; 120 float maxrand = 100.0f / ACTION_INTERVAL; 121 122 // search enemy 123 random = rnd(maxrand); 124 //std::cout << "search enemy: " << random << std::endl; 125 if (random < 20 && (!this->target_)) 126 { 127 this->searchNewTarget(); 128 } 129 130 // forget enemy 131 random = rnd(maxrand); 132 //std::cout << "forget enemy: " << random << std::endl; 133 if (random < 5 && (this->target_)) 134 { 135 this->forgetTarget(); 136 } 137 138 // next enemy 139 random = rnd(maxrand); 140 //std::cout << "next enemy: " << random << std::endl; 141 if (random < 10 && (this->target_)) 142 { 143 this->searchNewTarget(); 144 } 145 146 // fly somewhere 147 random = rnd(maxrand); 148 //std::cout << "fly somewhere: " << random << std::endl; 149 if (random < 40 && (!this->bHasTargetPosition_ && !this->target_)) 150 { 151 this->searchNewTargetPosition(); 152 } 153 154 // stop flying 155 random = rnd(maxrand); 156 //std::cout << "stop flying: " << random << std::endl; 157 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 158 { 159 this->bHasTargetPosition_ = false; 160 } 161 162 // fly somewhere else 163 random = rnd(maxrand); 164 //std::cout << "fly somewhere else: " << random << std::endl; 165 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 166 { 167 this->searchNewTargetPosition(); 168 } 169 170 // shoot 171 random = rnd(maxrand); 172 //std::cout << "shoot: " << random << std::endl; 173 if (random < 75 && (this->target_ && !this->bShooting_)) 174 { 175 this->bShooting_ = true; 176 } 177 178 // stop shooting 179 random = rnd(maxrand); 180 //std::cout << "stop shooting: " << random << std::endl; 181 if (random < 25 && (this->bShooting_)) 182 { 183 this->bShooting_ = false; 184 } 185 } 186 187 void SpaceShipAI::tick(float dt) 188 { 189 if (this->target_) 190 this->aimAtTarget(); 191 192 if (this->bHasTargetPosition_) 193 this->moveToTargetPosition(dt); 194 195 if (this->bShooting_ && this->isCloseAtTarget(2000) && this->isLookingAtTarget(Ogre::Math::PI / 10.0f)) 196 this->doFire(); 197 198 SpaceShip::tick(dt); 199 } 200 201 void SpaceShipAI::moveToTargetPosition(float dt) 202 { 203 static Radian RadianZERO(0); 204 205 // float dotprod = (this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(this->targetPosition_ - this->getPosition()); 206 Quaternion rotation = (this->getOrientation() * Ogre::Vector3::UNIT_X).getRotationTo(this->targetPosition_ - this->getPosition()); 207 /* 208 std::cout << "scalprod: " << dotprod << std::endl; 209 std::cout << "dist: " << this->targetPosition_ - this->getPosition() << std::endl; 210 std::cout << "yaw: " << rotation.getYaw().valueRadians() << std::endl; 211 std::cout << "pitch: " << rotation.getPitch().valueRadians() << std::endl; 212 std::cout << "roll: " << rotation.getRoll().valueRadians() << std::endl; 213 */ 214 this->setMoveYaw(-rotation.getRoll().valueRadians()); 215 this->setMovePitch(rotation.getYaw().valueRadians()); 216 217 if ((this->targetPosition_ - this->getPosition()).length() > 100) 218 { 219 this->setMoveLongitudinal(1); 220 } 221 222 } 223 224 void SpaceShipAI::searchNewTargetPosition() 225 { 226 this->targetPosition_ = Vector3(rnd(-5000,5000), rnd(-5000,5000), rnd(-5000,5000)); 227 this->bHasTargetPosition_ = true; 228 } 229 230 void SpaceShipAI::searchNewTarget() 231 { 232 this->targetPosition_ = this->getPosition(); 233 this->forgetTarget(); 234 235 for (Iterator<SpaceShip> it = ObjectList<SpaceShip>::begin(); it; ++it) 236 { 237 if (it->getTeamNr() != this->getTeamNr()) 238 { 239 float speed = this->getVelocity().length(); 240 Vector3 distanceCurrent = this->targetPosition_ - this->getPosition(); 241 Vector3 distanceNew = it->getPosition() - this->getPosition(); 242 if (!this->target_ || it->getPosition().squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceNew) / speed / distanceNew.length()) / (2 * Ogre::Math::PI)) 243 < this->targetPosition_.squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::Math::PI))) 244 { 245 this->target_ = (*it); 246 this->targetPosition_ = it->getPosition(); 247 } 248 } 249 } 250 } 251 252 void SpaceShipAI::forgetTarget() 253 { 254 this->target_ = 0; 255 this->bShooting_ = false; 256 } 257 258 void SpaceShipAI::aimAtTarget() 259 { 260 if (!this->target_) 261 return; 262 /* 263 Vector3 enemymovement = this->target_->getVelocity(); 264 Vector3 distance_normalised = this->target_->getPosition() - this->getPosition(); 265 distance_normalised.normalise(); 266 267 float scalarprod = enemymovement.dotProduct(distance_normalised); 268 float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength(); 269 if (aimoffset < 0) 270 { 271 this->bHasTargetPosition_ = false; 272 return; 273 } 274 aimoffset = -scalarprod + sqrt(aimoffset); 275 this->targetPosition_ = enemymovement + distance_normalised * aimoffset; 276 this->bHasTargetPosition_ = true; 277 278 std::cout << "targetpos: " << this->targetPosition_ << std::endl; 279 */ 280 this->targetPosition_ = this->target_->getPosition(); 281 this->bHasTargetPosition_ = true; 282 } 283 284 bool SpaceShipAI::isCloseAtTarget(float distance) 285 { 286 return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance); 287 } 288 289 bool SpaceShipAI::isLookingAtTarget(float angle) 290 { 291 return (this->getOrientation() * Ogre::Vector3::UNIT_X).directionEquals(this->targetPosition_ - this->getPosition(), Radian(angle)); 292 } 293 } -
code/branches/network/src/orxonox/objects/weapon/BaseWeapon.h
r1494 r1495 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < * 3 * > www.orxonox.net < 4 * 4 5 * 5 6 * License notice: … … 25 26 * 26 27 */ 27 #ifndef _BaseWeapon_H__#define _BaseWeapon_H__#include "OrxonoxPrereqs.h"#include <OgrePrerequisites.h>#include "../Model.h"namespace orxonox { class _OrxonoxExport BaseWeapon : public Model { public: enum Action { NOTHING = 0, RELOAD = 1, CHANGE_AMMO = 2, SPECIAL = 3 }; protected: enum State { IDLE = 0, PRIMARY_FIRE = 1, SECONDARY_FIRE = 2, RELOADING = 3, CHANGING_AMMO = 4, }; public: BaseWeapon(); virtual ~BaseWeapon(); bool addAction(const Action); void primaryFireRequest(); void secondaryFireRequest(); int getAmmoState(); void setAmmoDump(AmmunitionDump*); inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); }; virtual void tick(float dt); protected: virtual void primaryFire() = 0; virtual void primaryFiring(float) = 0; virtual void secondaryFire() = 0; virtual void secondaryFiring(float) = 0; virtual void registerAllVariables() { }; public: protected: Ogre::SceneManager *sceneMgr_; int bulletCounter_; BulletManager *bulletManager_; AmmunitionDump *ammoDump_; bool primaryFireRequest_; bool secondaryFireRequest_; float totalTime_; float actionStartTime_; State currentState_; bool secondaryFired_; Action nextAction_; bool actionAdded_; float timeSinceNextActionAdded_; static float nextActionValidityPeriod_s; // weapon properties int leftAmmo_; float primaryFirePower_; float secondaryFirePower_; float primaryFiringRate_; float secondaryFiringRate_; Real primaryBulletSpeed_; Real secondaryBulletSpeed_; int magazineSize_; };}#endif /* _BaseWeapon_H__ */ 28 29 30 #ifndef _BaseWeapon_H__ 31 #define _BaseWeapon_H__ 32 33 #include "OrxonoxPrereqs.h" 34 35 #include <OgrePrerequisites.h> 36 37 #include "../Model.h" 38 39 40 namespace orxonox { 41 class _OrxonoxExport BaseWeapon : public Model 42 { 43 public: 44 enum Action { 45 NOTHING = 0, 46 RELOAD = 1, 47 CHANGE_AMMO = 2, 48 SPECIAL = 3 49 }; 50 51 protected: 52 enum State { 53 IDLE = 0, 54 PRIMARY_FIRE = 1, 55 SECONDARY_FIRE = 2, 56 RELOADING = 3, 57 CHANGING_AMMO = 4, 58 }; 59 60 public: 61 BaseWeapon(); 62 virtual ~BaseWeapon(); 63 64 bool addAction(const Action); 65 66 void primaryFireRequest(); 67 68 void secondaryFireRequest(); 69 70 int getAmmoState(); 71 72 void setAmmoDump(AmmunitionDump*); 73 74 inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); }; 75 76 virtual void tick(float dt); 77 78 protected: 79 virtual void primaryFire() = 0; 80 81 virtual void primaryFiring(float) = 0; 82 83 virtual void secondaryFire() = 0; 84 85 virtual void secondaryFiring(float) = 0; 86 87 virtual void registerAllVariables() { }; 88 89 public: 90 91 protected: 92 Ogre::SceneManager *sceneMgr_; 93 94 int bulletCounter_; 95 BulletManager *bulletManager_; 96 97 AmmunitionDump *ammoDump_; 98 99 bool primaryFireRequest_; 100 bool secondaryFireRequest_; 101 102 float totalTime_; 103 float actionStartTime_; 104 105 State currentState_; 106 bool secondaryFired_; 107 108 Action nextAction_; 109 bool actionAdded_; 110 float timeSinceNextActionAdded_; 111 static float nextActionValidityPeriod_s; 112 113 // weapon properties 114 int leftAmmo_; 115 float primaryFirePower_; 116 float secondaryFirePower_; 117 float primaryFiringRate_; 118 float secondaryFiringRate_; 119 Real primaryBulletSpeed_; 120 Real secondaryBulletSpeed_; 121 122 int magazineSize_; 123 124 }; 125 } 126 127 #endif /* _BaseWeapon_H__ */
Note: See TracChangeset
for help on using the changeset viewer.