[Orxonox-commit 3778] r8458 - in code/trunk: . data/levels src/orxonox/worldentities
smerkli at orxonox.net
smerkli at orxonox.net
Thu May 12 14:23:45 CEST 2011
Author: smerkli
Date: 2011-05-12 14:23:45 +0200 (Thu, 12 May 2011)
New Revision: 8458
Added:
code/trunk/data/levels/myTestLevel.oxw
code/trunk/src/orxonox/worldentities/SpaceBoundaries.cc
code/trunk/src/orxonox/worldentities/SpaceBoundaries.h
Modified:
code/trunk/
code/trunk/src/orxonox/worldentities/CMakeLists.txt
Log:
merged spaceboundaries
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8107
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8107
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Copied: code/trunk/data/levels/myTestLevel.oxw (from rev 8457, code/branches/spaceboundaries/data/levels/myTestLevel.oxw)
===================================================================
--- code/trunk/data/levels/myTestLevel.oxw (rev 0)
+++ code/trunk/data/levels/myTestLevel.oxw 2011-05-12 12:23:45 UTC (rev 8458)
@@ -0,0 +1,38 @@
+<LevelInfo
+ name = "MyTestLevel"
+ description = "A level to test the Class SpaceBoundaries."
+ tags = "test"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff.oxt")
+ include("templates/spaceshipPirate.oxt")
+?>
+
+<Level
+ name = "Sample"
+ description = "Just a few tests"
+>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="0,0,0" lookat="2,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+ <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="100" healthDecrease="0.1" position="0,0,0"/>
+
+ </Scene>
+</Level>
+
Modified: code/trunk/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/worldentities/CMakeLists.txt 2011-05-12 11:51:18 UTC (rev 8457)
+++ code/trunk/src/orxonox/worldentities/CMakeLists.txt 2011-05-12 12:23:45 UTC (rev 8458)
@@ -11,6 +11,7 @@
CameraPosition.cc
SpawnPoint.cc
TeamSpawnPoint.cc
+ SpaceBoundaries.cc
)
ADD_SUBDIRECTORY(pawns)
Copied: code/trunk/src/orxonox/worldentities/SpaceBoundaries.cc (from rev 8457, code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc)
===================================================================
--- code/trunk/src/orxonox/worldentities/SpaceBoundaries.cc (rev 0)
+++ code/trunk/src/orxonox/worldentities/SpaceBoundaries.cc 2011-05-12 12:23:45 UTC (rev 8458)
@@ -0,0 +1,297 @@
+/*
+ * 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:
+ * Maurus Kaufmann
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "SpaceBoundaries.h"
+
+#include "worldentities/MobileEntity.h"
+#include "worldentities/ControllableEntity.h"
+#include "core/ObjectListIterator.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+#include "infos/PlayerInfo.h"
+#include "interfaces/RadarViewable.h"
+#include "graphics/Billboard.h"
+
+namespace orxonox
+{
+ CreateFactory(SpaceBoundaries);
+
+ SpaceBoundaries::SpaceBoundaries(BaseObject* creator) : StaticEntity(creator)
+ {
+ /* Standardwerte, die zum Tragen kommen,
+ * falls im XML-File keine Werte spezifiziert wurden. */
+ this->setMaxDistance(3000);
+ this->setWarnDistance(2000);
+ this->setShowDistance(2500);
+ this->setHealthDecrease(1);
+ this->setReaction(0);
+
+ RegisterObject(SpaceBoundaries);
+
+ // Show Boundaries on the radar.
+ this->centerRadar_ = new RadarViewable(this, this);
+ this->centerRadar_->setRadarObjectShape(RadarViewable::Dot);
+ this->centerRadar_->setRadarVisibility(false);
+ }
+ SpaceBoundaries::~SpaceBoundaries()
+ {
+ delete this->centerRadar_;
+
+ this->pawnsIn_.clear();
+
+ for( std::vector<billboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
+ {
+ if( current->billy != NULL)
+ {
+ delete current->billy;
+ }
+ }
+ this->billboards_.clear();
+ }
+
+ void SpaceBoundaries::checkWhoIsIn()
+ {
+ pawnsIn_.clear();
+ for(ObjectListIterator<Pawn> current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current)
+ {
+ Pawn* currentPawn = *current;
+ float distance = this->computeDistance(currentPawn);
+ if(distance <= this->maxDistance_)
+ {
+ pawnsIn_.push_back(currentPawn);
+ }
+ }
+ }
+
+ void SpaceBoundaries::positionBillboard(const Vector3 position)
+ {
+ std::vector<billboardAdministration>::iterator current;
+ for( current = this->billboards_.begin(); current != this->billboards_.end(); current++)
+ {
+ if(!current->usedYet)
+ {
+ break;
+ }
+ }
+ if( current == this->billboards_.end() )
+ {
+ Billboard *tmp = new Billboard(this);
+ this->setBillboardOptions( tmp );
+ tmp->setPosition(position);
+ billboardAdministration tmp2 = { true, tmp };
+ this->billboards_.push_back( tmp2 );
+
+ } else {
+ current->billy->setPosition(position);
+ current->billy->setVisible(true);
+ current->usedYet = true;
+ }
+ }
+
+ void SpaceBoundaries::setBillboardOptions(Billboard *billy)
+ {
+ if(billy != NULL)
+ {
+ billy->setMaterial("Shield");
+ billy->setVisible(true);
+ }
+ }
+
+ void SpaceBoundaries::removeAllBillboards()
+ {
+ for( std::vector<billboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )
+ {
+ current->usedYet = false;
+ current->billy->setVisible(false);
+ }
+ }
+
+ void SpaceBoundaries::setMaxDistance(float r)
+ {
+ this->maxDistance_ = r;
+ }
+ float SpaceBoundaries::getMaxDistance()
+ {
+ return this->maxDistance_;
+ }
+
+ void SpaceBoundaries::setWarnDistance(float r)
+ {
+ this->warnDistance_ = r;
+ }
+ float SpaceBoundaries::getWarnDistance()
+ {
+ return this->warnDistance_;
+ }
+
+ void SpaceBoundaries::setShowDistance(float r)
+ {
+ this->showDistance_ = r;
+ }
+ float SpaceBoundaries::getShowDistance()
+ {
+ return this->showDistance_;
+ }
+
+ void SpaceBoundaries::setHealthDecrease(float amount)
+ {
+ this->healthDecrease_ = amount/1000;
+ }
+ float SpaceBoundaries::getHealthDecrease()
+ {
+ return this->healthDecrease_;
+ }
+
+ void SpaceBoundaries::setReaction(int mode)
+ {
+ this->reaction_ = mode;
+ }
+ int SpaceBoundaries::getReaction()
+ {
+ return this->reaction_;
+ }
+
+ void SpaceBoundaries::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SpaceBoundaries, XMLPort, xmlelement, mode);
+
+ XMLPortParam(SpaceBoundaries, "maxDistance", setMaxDistance, getMaxDistance, xmlelement, mode);
+ XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode);
+ XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode);
+ XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode);
+ }
+
+ void SpaceBoundaries::tick(float dt)
+ {
+ this->checkWhoIsIn();
+ this->removeAllBillboards();
+ COUT(0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl;
+
+ float distance;
+ bool humanItem;
+ for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
+ {
+ Pawn* currentPawn = current->get();
+ if( currentPawn && currentPawn->getNode() )
+ {
+ distance = this->computeDistance(currentPawn);
+ humanItem = this->isHumanPlayer(currentPawn);
+ COUT(0) << "Distanz:" << distance << std::endl; // message for debugging
+ if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an!
+ {
+ COUT(0) << "You are near by the boundaries!" << std::endl; // message for debugging
+ if(humanItem)
+ {
+ COUT(0) << "humanItem ist true" << std::endl;
+ this->displayWarning("Attention! You are near by the boundaries!");
+ }
+ }
+ if( (this->maxDistance_ - distance) < this->showDistance_ )
+ {
+ this->displayBoundaries(currentPawn); // Zeige Grenze an!
+ }
+ if(distance > this->maxDistance_ && (this->reaction_ == 1) )
+ {
+ if( humanItem )
+ {
+ COUT(0) << "Health should be decreasing!" << std::endl;
+ this->displayWarning("You are out of the area now!");
+ }
+ currentPawn->removeHealth( (distance - this->maxDistance_) * this->healthDecrease_);
+ }
+ if( (this->reaction_ == 0) && (distance + 100 > this->maxDistance_)) // Annahme: Ein Pawn kann von einem Tick bis zum nächsten nicht mehr als 100 Distanzeinheiten zurücklegen.
+ {
+ this->conditionalBounceBack(currentPawn, distance, dt);
+ }
+ }
+ }
+ }
+
+ float SpaceBoundaries::computeDistance(WorldEntity *item)
+ {
+ if(item != NULL)
+ {
+ Vector3 itemPosition = item->getPosition();
+ return (itemPosition.distance(this->getPosition()));
+ } else {
+ return -1;
+ }
+ }
+
+ void SpaceBoundaries::displayWarning(const std::string warnText)
+ {
+
+ }
+
+ void SpaceBoundaries::displayBoundaries(Pawn *item)
+ {
+
+ Vector3 direction = item->getPosition() - this->getPosition();
+ direction.normalise();
+
+ Vector3 boundaryPosition = this->getPosition() + direction * this->maxDistance_;
+
+ this->positionBillboard(boundaryPosition);
+ }
+
+ void SpaceBoundaries::conditionalBounceBack(Pawn *item, float currentDistance, float dt)
+ {
+ Vector3 normal = item->getPosition() - this->getPosition();
+ normal.normalise();
+ Vector3 velocity = item->getVelocity();
+ float normalSpeed = item->getVelocity().dotProduct(normal);
+
+ /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde.
+ Falls ja: Spicke es zurück. */
+ if( currentDistance + normalSpeed * dt > this->maxDistance_ )
+ {
+ float dampingFactor = 0.5;
+ velocity = velocity.reflect(normal);
+ Vector3 acceleration = item->getAcceleration();
+ acceleration = acceleration.reflect(normal);
+
+ item->lookAt( velocity + this->getPosition() );
+
+ item->setAcceleration(acceleration * dampingFactor);
+ item->setVelocity(velocity * dampingFactor);
+ }
+ }
+
+ bool SpaceBoundaries::isHumanPlayer(Pawn *item)
+ {
+ if(item != NULL)
+ {
+ if(item->getPlayer())
+ {
+ return item->getPlayer()->isHumanPlayer();
+ }
+ }
+ return false;
+ }
+
+}
Copied: code/trunk/src/orxonox/worldentities/SpaceBoundaries.h (from rev 8457, code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h)
===================================================================
--- code/trunk/src/orxonox/worldentities/SpaceBoundaries.h (rev 0)
+++ code/trunk/src/orxonox/worldentities/SpaceBoundaries.h 2011-05-12 12:23:45 UTC (rev 8458)
@@ -0,0 +1,129 @@
+/*
+ * 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:
+ * Maurus Kaufmann
+ * Co-authors:
+ * ...
+ *
+ */
+
+ /* TODO: - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers)
+ beachte hierzu folgende statische Funktion: 'static unsigned int Host::getPlayerID()'
+ (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2)
+
+ - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h')
+
+ - Wiki-SpaceBoundaries-Eintrag aktualisieren
+ */
+
+#ifndef _SpaceBoundaries_H__
+#define _SpaceBoundaries_H__
+
+
+#include "core/CoreIncludes.h"
+#include "core/WeakPtr.h"
+#include "tools/interfaces/Tickable.h"
+#include "interfaces/RadarViewable.h"
+#include "worldentities/StaticEntity.h"
+#include "worldentities/WorldEntity.h"
+
+#include <string>
+#include <list>
+#include <map>
+#include <vector>
+
+namespace orxonox
+{
+
+/**
+ at brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
+
+ Five attributes can/should be defined in the XML-File:
+ - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
+ inform the player that he'll soon be leaving the allowed area.
+ - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
+ - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown.
+ - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
+ Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
+ - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries.
+ 0: Reflect the space ship (default).
+ 1: Decrease Health of the space ship after having left the allowed area.
+*/
+
+ class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable
+ {
+ public:
+ SpaceBoundaries(BaseObject* creator);
+ ~SpaceBoundaries();
+
+ void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
+
+ void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.
+ void setBillboardOptions(Billboard *billy);
+ void removeAllBillboards(); //!< Hide all all elements of '*billboard_' and set their attribute 'usedYet' to 0.
+
+ void setMaxDistance(float r);
+ float getMaxDistance();
+
+ void setWarnDistance(float r);
+ float getWarnDistance();
+
+ void setShowDistance(float r);
+ float getShowDistance();
+
+ void setHealthDecrease(float amount);
+ float getHealthDecrease();
+
+ void setReaction(int mode);
+ int getReaction();
+
+ void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ void tick(float dt);
+
+ private:
+ struct billboardAdministration{ bool usedYet; Billboard* billy; };
+
+ std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
+
+ std::vector<billboardAdministration> billboards_;
+
+ int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus.
+ float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'.
+ float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst.
+ float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen.
+
+ float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden.
+ //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung)
+
+ RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar.
+
+ float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen.
+ void displayWarning(const std::string warnText);
+ void displayBoundaries(Pawn *item);
+ void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
+ bool isHumanPlayer(Pawn *item);
+
+ };
+}
+
+#endif /* _SpaceBoundaries_H__ */
More information about the Orxonox-commit
mailing list