[Orxonox-commit 1013] r5734 - in code/branches/libraries2/src/orxonox: . collisionshapes controllers worldentities
landauf at orxonox.net
landauf at orxonox.net
Tue Sep 1 00:14:44 CEST 2009
Author: landauf
Date: 2009-09-01 00:14:43 +0200 (Tue, 01 Sep 2009)
New Revision: 5734
Added:
code/branches/libraries2/src/orxonox/GlobalShader.cc
code/branches/libraries2/src/orxonox/GlobalShader.h
code/branches/libraries2/src/orxonox/Level.cc
code/branches/libraries2/src/orxonox/Level.h
code/branches/libraries2/src/orxonox/Radar.cc
code/branches/libraries2/src/orxonox/Radar.h
code/branches/libraries2/src/orxonox/Scene.cc
code/branches/libraries2/src/orxonox/Scene.h
code/branches/libraries2/src/orxonox/Test.cc
code/branches/libraries2/src/orxonox/Test.h
code/branches/libraries2/src/orxonox/collisionshapes/
code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt
code/branches/libraries2/src/orxonox/controllers/
code/branches/libraries2/src/orxonox/controllers/HumanController.cc
code/branches/libraries2/src/orxonox/gametypes/
code/branches/libraries2/src/orxonox/infos/
code/branches/libraries2/src/orxonox/items/
code/branches/libraries2/src/orxonox/pickup/
code/branches/libraries2/src/orxonox/weaponsystem/
code/branches/libraries2/src/orxonox/worldentities/
code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt
Removed:
code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.cc
code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.h
code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt
code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.cc
code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.h
code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.cc
code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.h
code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.cc
code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.h
code/branches/libraries2/src/orxonox/controllers/HumanController.cc
code/branches/libraries2/src/orxonox/objects/
code/branches/libraries2/src/orxonox/worldentities/Attacher.cc
code/branches/libraries2/src/orxonox/worldentities/Attacher.h
code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt
code/branches/libraries2/src/orxonox/worldentities/ForceField.cc
code/branches/libraries2/src/orxonox/worldentities/ForceField.h
code/branches/libraries2/src/orxonox/worldentities/Planet.cc
code/branches/libraries2/src/orxonox/worldentities/Planet.h
code/branches/libraries2/src/orxonox/worldentities/triggers/
Modified:
code/branches/libraries2/src/orxonox/CMakeLists.txt
Log:
Moved all files and subdirectories from orxonox/objects to orxonox directly. Deleted the objects directory.
Doesn't compile at the moment because all paths to objects are wrong
Modified: code/branches/libraries2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/libraries2/src/orxonox/CMakeLists.txt 2009-08-31 22:04:50 UTC (rev 5733)
+++ code/branches/libraries2/src/orxonox/CMakeLists.txt 2009-08-31 22:14:43 UTC (rev 5734)
@@ -24,11 +24,24 @@
LevelManager.cc
PawnManager.cc
PlayerManager.cc
+
+ GlobalShader.cc
+ Level.cc
+ Radar.cc
+ Scene.cc
)
+
+ADD_SUBDIRECTORY(collisionshapes)
+ADD_SUBDIRECTORY(controllers)
+ADD_SUBDIRECTORY(gametypes)
+ADD_SUBDIRECTORY(infos)
ADD_SUBDIRECTORY(interfaces)
+ADD_SUBDIRECTORY(items)
ADD_SUBDIRECTORY(overlays)
-ADD_SUBDIRECTORY(objects)
+ADD_SUBDIRECTORY(pickup)
ADD_SUBDIRECTORY(sound)
+ADD_SUBDIRECTORY(weaponsystem)
+ADD_SUBDIRECTORY(worldentities)
ORXONOX_ADD_LIBRARY(orxonox
FIND_HEADER_FILES
Copied: code/branches/libraries2/src/orxonox/GlobalShader.cc (from rev 5727, code/branches/libraries2/src/orxonox/objects/GlobalShader.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/GlobalShader.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/GlobalShader.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,78 @@
+/*
+ * 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 "GlobalShader.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+ CreateFactory(GlobalShader);
+
+ GlobalShader::GlobalShader(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
+ {
+ RegisterObject(GlobalShader);
+
+ if (!this->getScene())
+ ThrowException(AbortLoading, "Can't create GlobalShader, no scene given.");
+// if (!this->getScene()->getSceneManager())
+// ThrowException(AbortLoading, "Can't create GlobalShader, no scene manager given.");
+
+ if (this->getScene()->getSceneManager())
+ this->shader_.setSceneManager(this->getScene()->getSceneManager());
+
+ this->registerVariables();
+ }
+
+ GlobalShader::~GlobalShader()
+ {
+ }
+
+ void GlobalShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(GlobalShader, XMLPort, xmlelement, mode);
+
+ XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositor, getCompositor, xmlelement, mode);
+ }
+
+ void GlobalShader::registerVariables()
+ {
+ registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
+ registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
+ }
+
+ void GlobalShader::changedVisibility()
+ {
+ SUPER(GlobalShader, changedVisibility);
+
+ this->shader_.setVisible(this->isVisible());
+ }
+}
Copied: code/branches/libraries2/src/orxonox/GlobalShader.h (from rev 5727, code/branches/libraries2/src/orxonox/objects/GlobalShader.h)
===================================================================
--- code/branches/libraries2/src/orxonox/GlobalShader.h (rev 0)
+++ code/branches/libraries2/src/orxonox/GlobalShader.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,61 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _GlobalShader_H__
+#define _GlobalShader_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "network/synchronisable/Synchronisable.h"
+#include "tools/Shader.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport GlobalShader : public BaseObject, public Synchronisable
+ {
+ public:
+ GlobalShader(BaseObject* creator);
+ virtual ~GlobalShader();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void registerVariables();
+
+ virtual void changedVisibility();
+
+ inline const Shader& getShader() const
+ { return this->shader_; }
+
+ private:
+ void changedCompositor();
+
+ Shader shader_;
+ };
+}
+
+#endif /* _GlobalShader_H__ */
Copied: code/branches/libraries2/src/orxonox/Level.cc (from rev 5727, code/branches/libraries2/src/orxonox/objects/Level.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/Level.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/Level.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,177 @@
+/*
+ * 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 "Level.h"
+
+#include "util/Math.h"
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/Loader.h"
+#include "core/Template.h"
+#include "core/XMLFile.h"
+#include "core/XMLPort.h"
+
+#include "objects/infos/PlayerInfo.h"
+#include "objects/gametypes/Gametype.h"
+#include "overlays/OverlayGroup.h"
+#include "sound/SoundBase.h"
+#include "LevelManager.h"
+
+namespace orxonox
+{
+ CreateFactory(Level);
+
+ Level::Level(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
+ {
+ RegisterObject(Level);
+
+ this->registerVariables();
+ this->xmlfilename_ = this->getFilename();
+ }
+
+ Level::~Level()
+ {
+ if (this->isInitialized())
+ {
+ if (LevelManager::getInstancePtr())
+ LevelManager::getInstance().releaseActivity(this);
+
+ if (this->xmlfile_)
+ Loader::unload(this->xmlfile_);
+
+ if(this->ambientsound_ != NULL)
+ delete this->ambientsound_;
+ }
+ }
+
+ void Level::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Level, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
+ XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
+
+ XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
+
+ XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+ }
+
+ void Level::registerVariables()
+ {
+ registerVariable(this->xmlfilename_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
+ registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::changedName));
+ registerVariable(this->description_, VariableDirection::ToClient);
+ }
+
+ void Level::networkcallback_applyXMLFile()
+ {
+ COUT(0) << "Loading level \"" << this->xmlfilename_ << "\"..." << std::endl;
+
+ ClassTreeMask mask;
+ mask.exclude(Class(BaseObject));
+ mask.include(Class(Template));
+ mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay
+
+ this->xmlfile_ = new XMLFile(mask, this->xmlfilename_);
+
+ Loader::open(this->xmlfile_);
+ }
+
+ void Level::setGametypeString(const std::string& gametype)
+ {
+ Identifier* identifier = ClassByString(gametype);
+
+ if (!identifier || !identifier->isA(Class(Gametype)))
+ {
+ COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
+ identifier = Class(Gametype);
+ this->gametype_ = "Gametype";
+ }
+ else
+ this->gametype_ = gametype;
+
+std::cout << "Load Gametype: " << this->gametype_ << std::endl;
+
+ Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
+ this->setGametype(rootgametype);
+
+std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;
+
+ for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ (*it)->setGametype(rootgametype);
+
+ if (LevelManager::getInstancePtr())
+ LevelManager::getInstance().requestActivity(this);
+ }
+
+
+ void Level::addObject(BaseObject* object)
+ {
+ this->objects_.push_back(object);
+ object->setGametype(this->getGametype());
+ }
+
+ BaseObject* Level::getObject(unsigned int index) const
+ {
+ unsigned int i = 0;
+ for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ {
+ if (i == index)
+ return (*it);
+ ++i;
+ }
+ return 0;
+ }
+
+ void Level::loadAmbientSound(const std::string& filename)
+ {
+ if(filename == "") return;
+ else
+ {
+ if(this->ambientsound_ == NULL)
+ {
+ this->ambientsound_ = new SoundBase();
+ }
+
+ this->ambientsound_->loadFile(filename);
+ this->ambientsound_->play(true);
+ }
+ }
+
+ void Level::playerEntered(PlayerInfo* player)
+ {
+ COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
+ player->setGametype(this->getGametype());
+ }
+
+ void Level::playerLeft(PlayerInfo* player)
+ {
+ COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
+ player->setGametype(0);
+ }
+}
Copied: code/branches/libraries2/src/orxonox/Level.h (from rev 5727, code/branches/libraries2/src/orxonox/objects/Level.h)
===================================================================
--- code/branches/libraries2/src/orxonox/Level.h (rev 0)
+++ code/branches/libraries2/src/orxonox/Level.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,80 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _Level_H__
+#define _Level_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <string>
+#include "core/BaseObject.h"
+#include "network/synchronisable/Synchronisable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Level : public BaseObject, public Synchronisable
+ {
+ public:
+ Level(BaseObject* creator);
+ virtual ~Level();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void registerVariables();
+
+ inline void setDescription(const std::string& description)
+ { this->description_ = description; }
+ inline const std::string& getDescription() const
+ { return this->description_; }
+
+ void loadAmbientSound(const std::string& filename);
+
+ void playerEntered(PlayerInfo* player);
+ void playerLeft(PlayerInfo* player);
+
+ private:
+ void addObject(BaseObject* object);
+ BaseObject* getObject(unsigned int index) const;
+
+ void setGametypeString(const std::string& gametype);
+ inline const std::string& getGametypeString() const
+ { return this->gametype_; }
+
+ void networkcallback_applyXMLFile();
+
+ std::string description_;
+ std::string gametype_;
+ std::string xmlfilename_;
+ XMLFile* xmlfile_;
+ std::list<BaseObject*> objects_;
+
+ SoundBase* ambientsound_;
+ };
+}
+
+#endif /* _Level_H__ */
Copied: code/branches/libraries2/src/orxonox/Radar.cc (from rev 5727, code/branches/libraries2/src/orxonox/objects/Radar.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/Radar.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/Radar.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,216 @@
+/*
+ * 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:
+ * Reto Grieder
+ * Co-authors:
+ * Felix Schulthess
+ *
+ */
+
+/**
+ at file
+ at brief
+*/
+
+#include "Radar.h"
+
+#include <cassert>
+
+//#include "util/Math.h"
+#include "core/ConsoleCommand.h"
+#include "core/ObjectList.h"
+#include "interfaces/RadarListener.h"
+
+namespace orxonox
+{
+ SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
+
+ Radar* Radar::instance_s = 0;
+
+ Radar::Radar()
+ : focus_(0)
+ , objectTypeCounter_(0)
+ {
+ assert(instance_s == 0);
+ instance_s = this;
+
+ // TODO: make this mapping configurable. Maybe there's a possibility with self configured
+ // configValues..
+ this->objectTypes_["Asteroid"] = RadarViewable::Dot;
+ this->objectTypes_["SpaceShip"] = RadarViewable::Square;
+ this->objectTypes_["AsdfQwerty"] = RadarViewable::Triangle;
+
+ /*WorldEntity* object;
+ object = new WorldEntity();
+ object->setPosition(2000.0, 0.0, 0.0);
+ addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+ object = new WorldEntity();
+ object->setPosition(0.0, 2000.0, 0.0);
+ addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+ object = new WorldEntity();
+ object->setPosition(0.0, 0.0, 2000.0);
+ addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+ object = new WorldEntity();
+ object->setPosition(10000.0,16000.0,0.0);
+ addRadarObject(object);*/
+
+ }
+
+ Radar::~Radar()
+ {
+ instance_s = 0;
+ }
+
+ const RadarViewable* Radar::getFocus()
+ {
+ return *(this->itFocus_);
+ }
+
+ RadarViewable::Shape Radar::addObjectDescription(const std::string name)
+ {
+ std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name);
+ if (it == this->objectTypes_.end())
+ return this->objectTypes_[name] = RadarViewable::Square; // default, configure!!
+ else
+ return this->objectTypes_[name];
+ }
+
+
+ void Radar::tick(float dt)
+ {
+ SUPER(Radar, tick, dt);
+
+ if (this->focus_ != *(this->itFocus_))
+ {
+ // focus object was deleted, release focus
+ this->focus_ = 0;
+ this->itFocus_ = 0;
+ }
+
+ for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+ {
+ (*itListener)->radarTick(dt);
+
+ for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
+ {
+ if ((*itElement)->getRadarVisibility())
+ if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
+ (*itListener)->displayObject(*itElement, *itElement == this->focus_);
+ }
+ }
+ }
+
+ void Radar::cycleFocus()
+ {
+ if (ObjectList<RadarViewable>::begin() == 0)
+ {
+ // list is empty
+ this->itFocus_ = 0;
+ this->focus_ = 0;
+ }
+/*
+ else if (this->owner_)
+ {
+ Vector3 localPosition = this->owner_->getPosition();
+ Vector3 targetPosition = localPosition;
+ if (*(this->itFocus_))
+ targetPosition = this->itFocus_->getRVWorldPosition();
+
+ // find the closed object further away than targetPosition
+ float currentDistance = localPosition.squaredDistance(targetPosition);
+ float nextDistance = FLT_MAX;
+ float minimumDistance = FLT_MAX;
+ ObjectList<RadarViewable>::iterator itFallback = 0;
+
+ for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
+ {
+ if (*it == static_cast<RadarViewable*>(this)->owner_)
+ continue;
+
+ float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition());
+ if (targetDistance > currentDistance && targetDistance < nextDistance)
+ {
+ this->itFocus_ = it;
+ nextDistance = targetDistance;
+ }
+ if (targetDistance < minimumDistance)
+ {
+ itFallback = it;
+ minimumDistance = targetDistance;
+ }
+ }
+
+ if (nextDistance == FLT_MAX)
+ {
+ // we already had the furthest object
+ this->itFocus_ = itFallback;
+ this->focus_ = *itFallback;
+ }
+ else
+ {
+ this->focus_ = *(this->itFocus_);
+ }
+ }
+*/
+ }
+
+ void Radar::releaseFocus()
+ {
+ this->itFocus_ = 0;
+ this->focus_ = 0;
+ }
+
+ void Radar::listObjects() const
+ {
+ COUT(3) << "List of RadarObjects:\n";
+ // iterate through all Radar Objects
+ unsigned int i = 0;
+ for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
+ {
+ COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
+ }
+ }
+
+
+ /*static*/ Radar& Radar::getInstance()
+ {
+ assert(instance_s);
+ return *instance_s;
+ }
+
+ /*static*/ void Radar::cycleNavigationFocus()
+ {
+ // avoid using getInstance because of the assert().
+ // User might call this fuction even if HUDNavigation doesn't exist.
+ if (instance_s)
+ instance_s->cycleFocus();
+ }
+
+ /*static*/ void Radar::releaseNavigationFocus()
+ {
+ // avoid using getInstance because of the assert().
+ // User might call this fuction even if HUDNavigation doesn't exist.
+ if (instance_s)
+ instance_s->releaseFocus();
+ }
+}
Copied: code/branches/libraries2/src/orxonox/Radar.h (from rev 5727, code/branches/libraries2/src/orxonox/objects/Radar.h)
===================================================================
--- code/branches/libraries2/src/orxonox/Radar.h (rev 0)
+++ code/branches/libraries2/src/orxonox/Radar.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,92 @@
+/*
+ * 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:
+ * Reto Grieder
+ * Co-authors:
+ * Felix Schulthess
+ *
+ */
+
+/**
+ at file
+ at brief
+*/
+
+#ifndef _Radar_H__
+#define _Radar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+
+#include "core/ObjectListIterator.h"
+#include "interfaces/RadarViewable.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+ /**
+ @brief This class merely ensures that no one can inherit from Radar.
+ */
+ class _OrxonoxExport RadarBase
+ {
+ private:
+ friend class Radar;
+ RadarBase() { }
+ };
+
+ class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
+ {
+ public:
+ Radar();
+ ~Radar();
+
+ virtual void tick(float dt);
+
+ const RadarViewable* getFocus();
+ RadarViewable::Shape addObjectDescription(const std::string name);
+
+ void listObjects() const;
+
+ static Radar& getInstance();
+ static Radar* getInstancePtr() { return instance_s; }
+
+ static void cycleNavigationFocus();
+ static void releaseNavigationFocus();
+
+ private:
+ Radar(Radar& instance);
+
+ void releaseFocus();
+ void updateFocus();
+ void cycleFocus();
+
+ ObjectListIterator<RadarViewable> itFocus_;
+ RadarViewable* focus_;
+ std::map<std::string, RadarViewable::Shape> objectTypes_;
+ int objectTypeCounter_;
+
+ static Radar* instance_s;
+ };
+}
+#endif /* _Radar_H__ */
Copied: code/branches/libraries2/src/orxonox/Scene.cc (from rev 5727, code/branches/libraries2/src/orxonox/objects/Scene.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/Scene.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/Scene.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,345 @@
+/*
+ * 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
+ * Reto Grieder (physics)
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "Scene.h"
+
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneManagerEnumerator.h>
+#include <OgreSceneNode.h>
+
+#include <BulletCollision/BroadphaseCollision/btAxisSweep3.h>
+#include <BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h>
+#include <BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h>
+#include <BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/XMLPort.h"
+#include "tools/BulletConversions.h"
+#include "objects/worldentities/WorldEntity.h"
+
+namespace orxonox
+{
+ CreateFactory(Scene);
+
+ Scene::Scene(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
+ {
+ RegisterObject(Scene);
+
+ this->setScene(this);
+ this->bShadows_ = true;
+
+ if (GameMode::showsGraphics())
+ {
+ assert(Ogre::Root::getSingletonPtr());
+ this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
+ this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+ }
+ else
+ {
+ // create a dummy SceneManager of our own since we don't have Ogre::Root.
+ this->sceneManager_ = new Ogre::DefaultSceneManager("");
+ this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+ }
+
+ // No physics yet, XMLPort will do that.
+ const int defaultMaxWorldSize = 100000;
+ this->negativeWorldRange_ = Vector3::UNIT_SCALE * -defaultMaxWorldSize;
+ this->positiveWorldRange_ = Vector3::UNIT_SCALE * defaultMaxWorldSize;
+ this->gravity_ = Vector3::ZERO;
+ this->physicalWorld_ = 0;
+ this->solver_ = 0;
+ this->dispatcher_ = 0;
+ this->collisionConfig_ = 0;
+ this->broadphase_ = 0;
+
+ this->registerVariables();
+ }
+
+ Scene::~Scene()
+ {
+ if (this->isInitialized())
+ {
+ if (GameMode::showsGraphics())
+ Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
+ else
+ delete this->sceneManager_;
+
+ this->setPhysicalWorld(false);
+ }
+ }
+
+ void Scene::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Scene, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Scene, "skybox", setSkybox, getSkybox, xmlelement, mode);
+ XMLPortParam(Scene, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2f, 0.2f, 0.2f, 1.0f));
+ XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
+
+ XMLPortParam(Scene, "gravity", setGravity, getGravity, xmlelement, mode);
+ XMLPortParam(Scene, "negativeWorldRange", setNegativeWorldRange, getNegativeWorldRange, xmlelement, mode);
+ XMLPortParam(Scene, "positiveWorldRange", setPositiveWorldRange, getPositiveWorldRange, xmlelement, mode);
+ XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValues(true);
+
+ XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+ }
+
+ void Scene::registerVariables()
+ {
+ registerVariable(this->skybox_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
+ registerVariable(this->ambientLight_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
+ registerVariable(this->negativeWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
+ registerVariable(this->positiveWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
+ registerVariable(this->gravity_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
+ registerVariable(this->bHasPhysics_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
+ registerVariable(this->bShadows_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
+ }
+
+ void Scene::setNegativeWorldRange(const Vector3& range)
+ {
+ if (range.length() < 10.0f)
+ {
+ CCOUT(2) << "Warning: Setting the negative world range to a very small value: "
+ << multi_cast<std::string>(range) << std::endl;
+ }
+ if (this->hasPhysics())
+ {
+ CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
+ << "This causes a complete physical reload which might take some time." << std::endl;
+ this->setPhysicalWorld(false);
+ this->negativeWorldRange_ = range;
+ this->setPhysicalWorld(true);
+ }
+ else
+ this->negativeWorldRange_ = range;
+ }
+
+ void Scene::setPositiveWorldRange(const Vector3& range)
+ {
+ if (range.length() < 10.0f)
+ {
+ CCOUT(2) << "Warning: Setting the positive world range to a very small value: "
+ << multi_cast<std::string>(range) << std::endl;
+ }
+ if (this->hasPhysics())
+ {
+ CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
+ << "This causes a complete physical reload which might take some time." << std::endl;
+ this->setPhysicalWorld(false);
+ this->positiveWorldRange_ = range;
+ this->setPhysicalWorld(true);
+ }
+ else
+ this->positiveWorldRange_ = range;
+ }
+
+ void Scene::setGravity(const Vector3& gravity)
+ {
+ this->gravity_ = gravity;
+ if (this->hasPhysics())
+ this->physicalWorld_->setGravity(multi_cast<btVector3>(this->gravity_));
+ }
+
+ void Scene::setPhysicalWorld(bool wantPhysics)
+ {
+ this->bHasPhysics_ = wantPhysics;
+ if (wantPhysics && !hasPhysics())
+ {
+ // Note: These are all little known default classes and values.
+ // It would require further investigation to properly dertermine the right choices.
+ this->broadphase_ = new bt32BitAxisSweep3(
+ multi_cast<btVector3>(this->negativeWorldRange_), multi_cast<btVector3>(this->positiveWorldRange_));
+ this->collisionConfig_ = new btDefaultCollisionConfiguration();
+ this->dispatcher_ = new btCollisionDispatcher(this->collisionConfig_);
+ this->solver_ = new btSequentialImpulseConstraintSolver();
+
+ this->physicalWorld_ = new btDiscreteDynamicsWorld(this->dispatcher_, this->broadphase_, this->solver_, this->collisionConfig_);
+ this->physicalWorld_->setGravity(multi_cast<btVector3>(this->gravity_));
+
+ // also set the collision callback variable.
+ // Note: This is a global variable which we assign a static function.
+ // TODO: Check whether this (or anything about Bullet) works with multiple physics engine instances.
+ gContactAddedCallback = &Scene::collisionCallback;
+ }
+ else if (!wantPhysics && hasPhysics())
+ {
+ // Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world.
+ for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin();
+ it != this->physicalObjects_.end(); ++it)
+ {
+ this->physicalWorld_->removeRigidBody((*it)->physicalBody_);
+ this->physicalObjectQueue_.insert(*it);
+ }
+ this->physicalObjects_.clear();
+
+ delete this->physicalWorld_;
+ delete this->solver_;
+ delete this->dispatcher_;
+ delete this->collisionConfig_;
+ delete this->broadphase_;
+ this->physicalWorld_ = 0;
+ this->solver_ = 0;
+ this->dispatcher_ = 0;
+ this->collisionConfig_ = 0;
+ this->broadphase_ = 0;
+ }
+ }
+
+ void Scene::tick(float dt)
+ {
+ if (!GameMode::showsGraphics())
+ {
+ // We need to update the scene nodes if we don't render
+ this->rootSceneNode_->_update(true, false);
+ }
+ if (this->hasPhysics())
+ {
+ // TODO: This here is bad practice! It will slow down the first tick() by ages.
+ // Rather have an initialise() method as well, called by the Level after everything has been loaded.
+ if (this->physicalObjectQueue_.size() > 0)
+ {
+ // Add all scheduled WorldEntities
+ for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin();
+ it != this->physicalObjectQueue_.end(); ++it)
+ {
+ this->physicalWorld_->addRigidBody((*it)->physicalBody_);
+ this->physicalObjects_.insert(*it);
+ }
+ this->physicalObjectQueue_.clear();
+ }
+
+ // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds.
+ // Under that mark, the simulation will "loose time" and get unusable.
+ physicalWorld_->stepSimulation(dt, 60);
+ }
+ }
+
+ void Scene::setSkybox(const std::string& skybox)
+ {
+ if (GameMode::showsGraphics() && this->sceneManager_)
+ this->sceneManager_->setSkyBox(true, skybox);
+
+ this->skybox_ = skybox;
+ }
+
+ void Scene::setAmbientLight(const ColourValue& colour)
+ {
+ if (GameMode::showsGraphics() && this->sceneManager_)
+ this->sceneManager_->setAmbientLight(colour);
+
+ this->ambientLight_ = colour;
+ }
+
+ void Scene::setShadow(bool bShadow)
+ {
+ if (GameMode::showsGraphics() && this->sceneManager_)
+ {
+ if (bShadow)
+ this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
+ else
+ this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
+ }
+
+ this->bShadows_ = bShadow;
+ }
+
+ void Scene::addObject(BaseObject* object)
+ {
+ this->objects_.push_back(object);
+ object->setScene(this);
+ }
+
+ BaseObject* Scene::getObject(unsigned int index) const
+ {
+ unsigned int i = 0;
+ for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+ {
+ if (i == index)
+ return (*it);
+ ++i;
+ }
+ return 0;
+ }
+
+ void Scene::addPhysicalObject(WorldEntity* object)
+ {
+ if (object)
+ {
+ std::set<WorldEntity*>::iterator it = this->physicalObjects_.find(object);
+ if (it != this->physicalObjects_.end())
+ return;
+
+ this->physicalObjectQueue_.insert(object);
+ }
+ }
+
+ void Scene::removePhysicalObject(WorldEntity* object)
+ {
+ // check queue first
+ std::set<WorldEntity*>::iterator it = this->physicalObjectQueue_.find(object);
+ if (it != this->physicalObjectQueue_.end())
+ {
+ this->physicalObjectQueue_.erase(it);
+ return;
+ }
+
+ it = this->physicalObjects_.find(object);
+ if (it == this->physicalObjects_.end())
+ return;
+ this->physicalObjects_.erase(it);
+
+ if (this->hasPhysics())
+ this->physicalWorld_->removeRigidBody(object->physicalBody_);
+ }
+
+ /*static*/ bool Scene::collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
+ int index0, const btCollisionObject* colObj1, int partId1, int index1)
+ {
+ // get the WorldEntity pointers
+ WorldEntity* object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
+ assert(orxonox_cast<WorldEntity*>(object0));
+ WorldEntity* object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
+ assert(orxonox_cast<WorldEntity*>(object1));
+
+ // false means that bullet will assume we didn't modify the contact
+ bool modified = false;
+ if (object0->isCollisionCallbackActive())
+ {
+ modified |= object0->collidesAgainst(object1, cp);
+ if (object1->isCollisionCallbackActive())
+ modified |= object1->collidesAgainst(object0, cp);
+ }
+ else
+ modified |= object1->collidesAgainst(object0, cp);
+
+ return modified;
+ }
+}
Copied: code/branches/libraries2/src/orxonox/Scene.h (from rev 5727, code/branches/libraries2/src/orxonox/objects/Scene.h)
===================================================================
--- code/branches/libraries2/src/orxonox/Scene.h (rev 0)
+++ code/branches/libraries2/src/orxonox/Scene.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,149 @@
+/*
+ * 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
+ * Reto Grieder (physics)
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Scene_H__
+#define _Scene_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <set>
+#include <string>
+
+#include "util/Math.h"
+#include "util/OgreForwardRefs.h"
+#include "core/BaseObject.h"
+#include "network/synchronisable/Synchronisable.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable
+ {
+ public:
+ Scene(BaseObject* creator);
+ virtual ~Scene();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void registerVariables();
+
+ inline Ogre::SceneManager* getSceneManager() const
+ { return this->sceneManager_; }
+ inline Ogre::SceneNode* getRootSceneNode() const
+ { return this->rootSceneNode_; }
+
+ void setSkybox(const std::string& skybox);
+ inline const std::string& getSkybox() const
+ { return this->skybox_; }
+
+ void setAmbientLight(const ColourValue& colour);
+ inline const ColourValue& getAmbientLight() const
+ { return this->ambientLight_; }
+
+ void setShadow(bool bShadow);
+ inline bool getShadow() const
+ { return this->bShadows_; }
+
+ virtual void tick(float dt);
+
+ private:
+ void addObject(BaseObject* object);
+ BaseObject* getObject(unsigned int index) const;
+
+ void networkcallback_applySkybox()
+ { this->setSkybox(this->skybox_); }
+ void networkcallback_applyAmbientLight()
+ { this->setAmbientLight(this->ambientLight_); }
+ void networkcallback_applyShadows()
+ { this->setShadow(this->bShadows_); }
+
+ Ogre::SceneManager* sceneManager_;
+ Ogre::SceneNode* rootSceneNode_;
+
+ std::string skybox_;
+ ColourValue ambientLight_;
+ std::list<BaseObject*> objects_;
+ bool bShadows_;
+
+
+ /////////////
+ // Physics //
+ /////////////
+
+ public:
+ inline bool hasPhysics()
+ { return this->physicalWorld_ != 0; }
+ void setPhysicalWorld(bool wantsPhysics);
+
+ void setNegativeWorldRange(const Vector3& range);
+ inline const Vector3& getNegativeWorldRange() const
+ { return this->negativeWorldRange_; }
+
+ void setPositiveWorldRange(const Vector3& range);
+ inline const Vector3& getPositiveWorldRange() const
+ { return this->positiveWorldRange_; }
+
+ void setGravity(const Vector3& gravity);
+ inline const Vector3& getGravity() const
+ { return this->gravity_; }
+
+ void addPhysicalObject(WorldEntity* object);
+ void removePhysicalObject(WorldEntity* object);
+
+ private:
+ inline void networkcallback_hasPhysics()
+ { this->setPhysicalWorld(this->bHasPhysics_); }
+ inline void networkcallback_negativeWorldRange()
+ { this->setNegativeWorldRange(this->negativeWorldRange_); }
+ inline void networkcallback_positiveWorldRange()
+ { this->setPositiveWorldRange(this->positiveWorldRange_); }
+ inline void networkcallback_gravity()
+ { this->setGravity(this->gravity_); }
+
+ // collision callback from bullet
+ static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
+ int index0, const btCollisionObject* colObj1, int partId1, int index1);
+
+ // Bullet objects
+ btDiscreteDynamicsWorld* physicalWorld_;
+ bt32BitAxisSweep3* broadphase_;
+ btDefaultCollisionConfiguration* collisionConfig_;
+ btCollisionDispatcher* dispatcher_;
+ btSequentialImpulseConstraintSolver* solver_;
+
+ std::set<WorldEntity*> physicalObjectQueue_;
+ std::set<WorldEntity*> physicalObjects_;
+ bool bHasPhysics_;
+ Vector3 negativeWorldRange_;
+ Vector3 positiveWorldRange_;
+ Vector3 gravity_;
+ };
+}
+
+#endif /* _Scene_H__ */
Copied: code/branches/libraries2/src/orxonox/Test.cc (from rev 5727, code/branches/libraries2/src/orxonox/objects/Test.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/Test.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/Test.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,145 @@
+/*
+ * 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:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "network/NetworkFunction.h"
+#include "Test.h"
+#include "util/MultiType.h"
+
+namespace orxonox
+{
+ CreateFactory ( Test );
+
+ SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
+
+
+ //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
+ //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
+// NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
+
+ registerStaticNetworkFunction( &Test::printV1 );
+ registerMemberNetworkFunction( Test, checkU1 );
+ registerMemberNetworkFunction( Test, printBlaBla );
+
+ Test* Test::instance_ = 0;
+
+ Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
+ {
+ assert(instance_==0);
+ instance_=this;
+ RegisterObject ( Test );
+ setConfigValues();
+ registerVariables();
+ setObjectMode(0x3);
+ }
+
+ Test::~Test()
+ {
+ instance_=0;
+ }
+
+ void Test::setConfigValues()
+ {
+ SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/;
+ SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+ SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+ SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+
+ SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
+ SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+ SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+ SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+ }
+
+
+ void Test::registerVariables()
+ {
+ registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
+ registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
+ registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
+ registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
+
+ registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
+ registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
+ registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
+ registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
+ }
+
+ void Test::call(unsigned int clientID)
+ {
+ callStaticNetworkFunction( &Test::printV1, clientID );
+ callStaticNetworkFunction( &Test::printV1, clientID );
+ }
+
+ void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
+ {
+ callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+ }
+
+ void Test::tick(float dt)
+ {
+// std::string str1 = "blub";
+// //MultiType mt1(std::string("blub"));
+// MultiType mt1(str1);
+// uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
+// uint8_t* temp = mem;
+// mt1.exportData( temp );
+// assert( temp-mem == mt1.getNetworkSize() );
+// MultiType mt2;
+// temp = mem;
+// mt2.importData( temp );
+// assert( temp-mem == mt1.getNetworkSize() );
+// COUT(0) << mt2 << endl;
+ if(!Core::isMaster())
+ call2(0, "bal", "a", "n", "ce");
+// callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+ }
+
+ void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
+ {
+ COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+ }
+
+ void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
+ void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
+ void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
+ void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
+
+ void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
+ void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
+ void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
+ void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
+
+}
Copied: code/branches/libraries2/src/orxonox/Test.h (from rev 5727, code/branches/libraries2/src/orxonox/objects/Test.h)
===================================================================
--- code/branches/libraries2/src/orxonox/Test.h (rev 0)
+++ code/branches/libraries2/src/orxonox/Test.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,100 @@
+/*
+ * 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:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Test_H__
+#define _Test_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "network/synchronisable/Synchronisable.h"
+#include "tools/interfaces/Tickable.h"
+
+
+typedef int TYPE;
+typedef unsigned int UTYPE;
+
+
+namespace orxonox
+{
+ class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
+ {
+ public:
+ Test(BaseObject* creator);
+ virtual ~Test();
+
+ void setConfigValues();
+ void registerVariables();
+
+ static void call(unsigned int clientID);
+ void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
+ virtual void tick(float dt);
+
+
+ //unsigned functions
+ void setU1(UTYPE value){ u1 = value; }
+ void setU2(UTYPE value){ u2 = value; }
+ void setU3(UTYPE value){ u3 = value; }
+ void setU4(UTYPE value){ u4 = value; }
+ void checkU1();
+ void checkU2();
+ void checkU3();
+ void checkU4();
+
+ //signed functions
+ void setS1(TYPE value){ s1 = value; }
+ void setS2(TYPE value){ s2 = value; }
+ void setS3(TYPE value){ s3 = value; }
+ void setS4(TYPE value){ s4 = value; }
+ void checkS1();
+ void checkS2();
+ void checkS3();
+ void checkS4();
+
+ static void printV1(){ instance_->checkU1(); }
+ static void printV2(){ instance_->checkU2(); }
+ static void printV3(){ instance_->checkU3(); }
+ static void printV4(){ instance_->checkU4(); }
+
+ void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
+
+ private:
+ UTYPE u1;
+ UTYPE u2;
+ UTYPE u3;
+ UTYPE u4;
+
+ TYPE s1;
+ TYPE s2;
+ TYPE s3;
+ TYPE s4;
+
+ static Test* instance_;
+ };
+}
+
+#endif /* _Test_H__ */
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,76 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#include "BoxCollisionShape.h"
-
-#include <BulletCollision/CollisionShapes/btBoxShape.h>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "tools/BulletConversions.h"
-
-namespace orxonox
-{
- CreateFactory(BoxCollisionShape);
-
- BoxCollisionShape::BoxCollisionShape(BaseObject* creator) : CollisionShape(creator)
- {
- RegisterObject(BoxCollisionShape);
-
- this->halfExtents_ = Vector3(1, 1, 1);
- updateShape();
-
- this->registerVariables();
- }
-
- BoxCollisionShape::~BoxCollisionShape()
- {
- if (this->isInitialized())
- delete this->collisionShape_;
- }
-
- void BoxCollisionShape::registerVariables()
- {
- registerVariable(this->halfExtents_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- }
-
- void BoxCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(BoxCollisionShape, XMLPort, xmlelement, mode);
-
- XMLPortParam(BoxCollisionShape, "halfExtents", setHalfExtents, getHalfExtents, xmlelement, mode);
- XMLPortParamLoadOnly(BoxCollisionShape, "width", setWidth, xmlelement, mode);
- XMLPortParamLoadOnly(BoxCollisionShape, "height", setHeight, xmlelement, mode);
- XMLPortParamLoadOnly(BoxCollisionShape, "length", setLength, xmlelement, mode);
- }
-
- btCollisionShape* BoxCollisionShape::createNewShape() const
- {
- return new btBoxShape(multi_cast<btVector3>(this->halfExtents_));
- }
-}
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/BoxCollisionShape.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/BoxCollisionShape.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,75 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _BoxCollisionShape_H__
-#define _BoxCollisionShape_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Math.h"
-#include "CollisionShape.h"
-
-namespace orxonox
-{
- class _OrxonoxExport BoxCollisionShape : public CollisionShape
- {
- public:
- BoxCollisionShape(BaseObject* creator);
- virtual ~BoxCollisionShape();
-
- void registerVariables();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- inline void setHalfExtents(const Vector3& extents)
- { this->halfExtents_ = extents; updateShape(); }
- inline const Vector3& getHalfExtents() const
- { return halfExtents_;}
-
- inline void setWidth(float value)
- { this->halfExtents_.z = value / 2; updateShape(); }
- inline float getWidth() const
- { return this->halfExtents_.z * 2; }
-
- inline void setHeight(float value)
- { this->halfExtents_.y = value / 2; updateShape(); }
- inline float getHeight() const
- { return this->halfExtents_.y * 2; }
-
- inline void setLength(float value)
- { this->halfExtents_.x = value / 2; updateShape(); }
- inline float getLength() const
- { return this->halfExtents_.x * 2; }
-
- private:
- btCollisionShape* createNewShape() const;
-
- Vector3 halfExtents_;
- };
-}
-
-#endif /* _BoxCollisionShape_H__ */
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/CMakeLists.txt 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,9 +0,0 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- BoxCollisionShape.cc
- CollisionShape.cc
- CompoundCollisionShape.cc
- ConeCollisionShape.cc
- PlaneCollisionShape.cc
- SphereCollisionShape.cc
- WorldEntityCollisionShape.cc
-)
Copied: code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt (from rev 5728, code/branches/libraries2/src/orxonox/objects/collisionshapes/CMakeLists.txt)
===================================================================
--- code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt (rev 0)
+++ code/branches/libraries2/src/orxonox/collisionshapes/CMakeLists.txt 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,5 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ CollisionShape.cc
+ CompoundCollisionShape.cc
+ WorldEntityCollisionShape.cc
+)
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,75 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#include "ConeCollisionShape.h"
-
-#include <BulletCollision/CollisionShapes/btConeShape.h>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- CreateFactory(ConeCollisionShape);
-
- ConeCollisionShape::ConeCollisionShape(BaseObject* creator) : CollisionShape(creator)
- {
- RegisterObject(ConeCollisionShape);
-
- this->radius_ = 1.0f;
- this->height_ = 1.0f;
- updateShape();
-
- this->registerVariables();
- }
-
- ConeCollisionShape::~ConeCollisionShape()
- {
- if (this->isInitialized())
- delete this->collisionShape_;
- }
-
- void ConeCollisionShape::registerVariables()
- {
- registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- registerVariable(this->height_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- }
-
- void ConeCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(ConeCollisionShape, XMLPort, xmlelement, mode);
-
- XMLPortParam(ConeCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);
- XMLPortParam(ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);
- }
-
- btCollisionShape* ConeCollisionShape::createNewShape() const
- {
- return new btConeShape(this->radius_, this->height_);
- }
-}
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/ConeCollisionShape.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/ConeCollisionShape.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,64 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _ConeCollisionShape_H__
-#define _ConeCollisionShape_H__
-
-#include "OrxonoxPrereqs.h"
-#include "CollisionShape.h"
-
-namespace orxonox
-{
- class _OrxonoxExport ConeCollisionShape : public CollisionShape
- {
- public:
- ConeCollisionShape(BaseObject* creator);
- virtual ~ConeCollisionShape();
-
- void registerVariables();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- inline void setRadius(float value)
- { this->radius_ = value; updateShape(); }
- inline float getRadius() const
- { return radius_; }
-
- inline void setHeight(float value)
- { this->height_ = value; updateShape(); }
- inline float getHeight() const
- { return this->height_; }
-
- private:
- btCollisionShape* createNewShape() const;
-
- float radius_;
- float height_;
- };
-}
-
-#endif /* _ConeCollisionShape_H__ */
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,76 +0,0 @@
-/*
- * 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:
- * Martin Stypinski
- * Co-authors:
- * ...
- *
- */
-
-#include "PlaneCollisionShape.h"
-
-#include <BulletCollision/CollisionShapes/btStaticPlaneShape.h>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "tools/BulletConversions.h"
-
-namespace orxonox
-{
- CreateFactory(PlaneCollisionShape);
-
- PlaneCollisionShape::PlaneCollisionShape(BaseObject* creator) : CollisionShape(creator)
- {
- RegisterObject(PlaneCollisionShape);
-
- this->normal_ = Vector3(0, 1, 0);
- this->offset_ = 0.0f;
- updateShape();
-
- this->registerVariables();
- }
-
- PlaneCollisionShape::~PlaneCollisionShape()
- {
- if (this->isInitialized())
- delete this->collisionShape_;
- }
-
- void PlaneCollisionShape::registerVariables()
- {
- registerVariable(this->normal_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- registerVariable(this->offset_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- }
-
- void PlaneCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(PlaneCollisionShape, XMLPort, xmlelement, mode);
-
- XMLPortParam(PlaneCollisionShape, "normal", setNormal, getNormal, xmlelement, mode);
- XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);
- }
-
- btCollisionShape* PlaneCollisionShape::createNewShape() const
- {
- return new btStaticPlaneShape(multi_cast<btVector3>(this->normal_), this->offset_);
- }
-}
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/PlaneCollisionShape.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/PlaneCollisionShape.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,66 +0,0 @@
-/*
- * 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:
- * Martin Stypinski
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _PlaneCollisionShape_H__
-#define _PlaneCollisionShape_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Math.h"
-#include "CollisionShape.h"
-
-namespace orxonox
-{
- class _OrxonoxExport PlaneCollisionShape : public CollisionShape
- {
- public:
- PlaneCollisionShape(BaseObject* creator);
- virtual ~PlaneCollisionShape();
-
- void registerVariables();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- inline void setNormal(const Vector3& normal)
- { this->normal_ = normal; updateShape(); }
- inline const Vector3& getNormal()
- { return normal_;}
-
- inline void setOffset(float offset)
- { this->offset_ = offset; updateShape(); }
- inline float getOffset()
- { return this->offset_;}
-
- private:
- btCollisionShape* createNewShape()const;
-
- Vector3 normal_;
- float offset_;
- };
-}
-
-#endif /* _PlaneCollisionShape_H__ */
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,72 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#include "SphereCollisionShape.h"
-
-#include <BulletCollision/CollisionShapes/btSphereShape.h>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- CreateFactory(SphereCollisionShape);
-
- SphereCollisionShape::SphereCollisionShape(BaseObject* creator) : CollisionShape(creator)
- {
- RegisterObject(SphereCollisionShape);
-
- this->radius_ = 1.0f;
- updateShape();
-
- this->registerVariables();
- }
-
- SphereCollisionShape::~SphereCollisionShape()
- {
- if (this->isInitialized())
- delete this->collisionShape_;
- }
-
- void SphereCollisionShape::registerVariables()
- {
- registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- }
-
- void SphereCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(SphereCollisionShape, XMLPort, xmlelement, mode);
-
- XMLPortParam(SphereCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);
- }
-
- btCollisionShape* SphereCollisionShape::createNewShape() const
- {
- return new btSphereShape(this->radius_);
- }
-}
Deleted: code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/collisionshapes/SphereCollisionShape.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/collisionshapes/SphereCollisionShape.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,58 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _SphereCollisionShape_H__
-#define _SphereCollisionShape_H__
-
-#include "OrxonoxPrereqs.h"
-#include "CollisionShape.h"
-
-namespace orxonox
-{
- class _OrxonoxExport SphereCollisionShape : public CollisionShape
- {
- public:
- SphereCollisionShape(BaseObject* creator);
- virtual ~SphereCollisionShape();
-
- void registerVariables();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- inline void setRadius(float radius)
- { this->radius_ = radius; updateShape(); }
- inline float getRadius() const
- { return this->radius_; }
-
- private:
- btCollisionShape* createNewShape() const;
-
- float radius_;
- };
-}
-
-#endif /* _SphereCollisionShape_H__ */
Deleted: code/branches/libraries2/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/controllers/HumanController.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,202 +0,0 @@
-/*
- * 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 "HumanController.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "objects/worldentities/ControllableEntity.h"
-#include "objects/worldentities/pawns/Pawn.h"
-#include "objects/gametypes/Gametype.h"
-#include "objects/infos/PlayerInfo.h"
-#include "Map.h"
-
-namespace orxonox
-{
- SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
- SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
- SetConsoleCommand(HumanController, moveUpDown, true).setAsInputCommand();
- SetConsoleCommand(HumanController, rotateYaw, true).setAsInputCommand();
- SetConsoleCommand(HumanController, rotatePitch, true).setAsInputCommand();
- SetConsoleCommand(HumanController, rotateRoll, true).setAsInputCommand();
- SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold);
- SetConsoleCommand(HumanController, reload, true);
- SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold);
- SetConsoleCommand(HumanController, greet, true);
- SetConsoleCommand(HumanController, switchCamera, true);
- SetConsoleCommand(HumanController, mouseLook, true);
- SetConsoleCommand(HumanController, suicide, true);
- SetConsoleCommand(HumanController, addBots, true).defaultValues(1);
- SetConsoleCommand(HumanController, killBots, true).defaultValues(0);
- SetConsoleCommand(HumanController, dropItems, true);
- SetConsoleCommand(HumanController, useItem, true);
-
- CreateUnloadableFactory(HumanController);
-
- HumanController* HumanController::localController_s = 0;
-
- HumanController::HumanController(BaseObject* creator) : Controller(creator)
- {
- RegisterObject(HumanController);
-
- HumanController::localController_s = this;
- }
-
- HumanController::~HumanController()
- {
- HumanController::localController_s = 0;
- }
-
- void HumanController::moveFrontBack(const Vector2& value)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->moveFrontBack(value);
- }
-
- void HumanController::moveRightLeft(const Vector2& value)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->moveRightLeft(value);
- }
-
- void HumanController::moveUpDown(const Vector2& value)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->moveUpDown(value);
- }
-
- void HumanController::rotateYaw(const Vector2& value)
- {
- //Hack to enable mouselook in map
- if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
- {
- Map::getSingletonPtr()->rotateYaw(value);
- return;
- }
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->rotateYaw(value);
- }
-
- void HumanController::rotatePitch(const Vector2& value)
- {
- //Hack to enable mouselook in map
- if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
- {
- Map::getSingletonPtr()->rotatePitch(value);
- return;
- }
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->rotatePitch(value);
- }
-
- void HumanController::rotateRoll(const Vector2& value)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->rotateRoll(value);
- }
-
- void HumanController::fire(unsigned int firemode)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->fire(firemode);
- }
-
- void HumanController::reload()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->reload();
- }
-
- void HumanController::boost()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->boost();
- }
-
- void HumanController::greet()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->greet();
- }
-
- void HumanController::switchCamera()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->switchCamera();
- }
-
- void HumanController::mouseLook()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->mouseLook();
- }
-
- void HumanController::suicide()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- {
- Pawn* pawn = orxonox_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
- if (pawn)
- pawn->kill();
- else if (HumanController::localController_s->player_)
- HumanController::localController_s->player_->stopControl();
- }
- }
-
- void HumanController::useItem()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->useItem();
- }
-
- void HumanController::addBots(unsigned int amount)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
- HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
- }
-
- void HumanController::killBots(unsigned int amount)
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
- HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
- }
-
- void HumanController::dropItems()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->dropItems();
- }
-
- Pawn* HumanController::getLocalControllerEntityAsPawn()
- {
- if (HumanController::localController_s)
- return orxonox_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
- else
- return NULL;
- }
-}
Copied: code/branches/libraries2/src/orxonox/controllers/HumanController.cc (from rev 5732, code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/controllers/HumanController.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/controllers/HumanController.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,202 @@
+/*
+ * 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 "HumanController.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "objects/worldentities/ControllableEntity.h"
+#include "objects/worldentities/pawns/Pawn.h"
+#include "objects/gametypes/Gametype.h"
+#include "objects/infos/PlayerInfo.h"
+#include "overlays/Map.h"
+
+namespace orxonox
+{
+ SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, moveUpDown, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, rotateYaw, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, rotatePitch, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, rotateRoll, true).setAsInputCommand();
+ SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold);
+ SetConsoleCommand(HumanController, reload, true);
+ SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold);
+ SetConsoleCommand(HumanController, greet, true);
+ SetConsoleCommand(HumanController, switchCamera, true);
+ SetConsoleCommand(HumanController, mouseLook, true);
+ SetConsoleCommand(HumanController, suicide, true);
+ SetConsoleCommand(HumanController, addBots, true).defaultValues(1);
+ SetConsoleCommand(HumanController, killBots, true).defaultValues(0);
+ SetConsoleCommand(HumanController, dropItems, true);
+ SetConsoleCommand(HumanController, useItem, true);
+
+ CreateUnloadableFactory(HumanController);
+
+ HumanController* HumanController::localController_s = 0;
+
+ HumanController::HumanController(BaseObject* creator) : Controller(creator)
+ {
+ RegisterObject(HumanController);
+
+ HumanController::localController_s = this;
+ }
+
+ HumanController::~HumanController()
+ {
+ HumanController::localController_s = 0;
+ }
+
+ void HumanController::moveFrontBack(const Vector2& value)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->moveFrontBack(value);
+ }
+
+ void HumanController::moveRightLeft(const Vector2& value)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->moveRightLeft(value);
+ }
+
+ void HumanController::moveUpDown(const Vector2& value)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->moveUpDown(value);
+ }
+
+ void HumanController::rotateYaw(const Vector2& value)
+ {
+ //Hack to enable mouselook in map
+ if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
+ {
+ Map::getSingletonPtr()->rotateYaw(value);
+ return;
+ }
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->rotateYaw(value);
+ }
+
+ void HumanController::rotatePitch(const Vector2& value)
+ {
+ //Hack to enable mouselook in map
+ if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
+ {
+ Map::getSingletonPtr()->rotatePitch(value);
+ return;
+ }
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->rotatePitch(value);
+ }
+
+ void HumanController::rotateRoll(const Vector2& value)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->rotateRoll(value);
+ }
+
+ void HumanController::fire(unsigned int firemode)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->fire(firemode);
+ }
+
+ void HumanController::reload()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->reload();
+ }
+
+ void HumanController::boost()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->boost();
+ }
+
+ void HumanController::greet()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->greet();
+ }
+
+ void HumanController::switchCamera()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->switchCamera();
+ }
+
+ void HumanController::mouseLook()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->mouseLook();
+ }
+
+ void HumanController::suicide()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ {
+ Pawn* pawn = orxonox_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
+ if (pawn)
+ pawn->kill();
+ else if (HumanController::localController_s->player_)
+ HumanController::localController_s->player_->stopControl();
+ }
+ }
+
+ void HumanController::useItem()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->useItem();
+ }
+
+ void HumanController::addBots(unsigned int amount)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
+ HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
+ }
+
+ void HumanController::killBots(unsigned int amount)
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
+ HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
+ }
+
+ void HumanController::dropItems()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->dropItems();
+ }
+
+ Pawn* HumanController::getLocalControllerEntityAsPawn()
+ {
+ if (HumanController::localController_s)
+ return orxonox_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
+ else
+ return NULL;
+ }
+}
Deleted: code/branches/libraries2/src/orxonox/worldentities/Attacher.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/Attacher.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/Attacher.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,120 +0,0 @@
-/*
- * 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 "Attacher.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- CreateFactory(Attacher);
-
- Attacher::Attacher(BaseObject* creator) : StaticEntity(creator)
- {
- RegisterObject(Attacher);
-
- this->target_ = 0;
- }
-
- void Attacher::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(Attacher, XMLPort, xmlelement, mode);
-
- XMLPortParam(Attacher, "target", setTarget, getTarget, xmlelement, mode);
- XMLPortObject(Attacher, WorldEntity, "", addObject, getObject, xmlelement, mode);
- }
-
- void Attacher::processEvent(Event& event)
- {
- for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- (*it)->fireEvent(event);
- }
-
- void Attacher::changedActivity()
- {
- SUPER(Attacher, changedActivity);
-
- for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- (*it)->setActive(this->isActive());
- }
-
- void Attacher::changedVisibility()
- {
- SUPER(Attacher, changedVisibility);
-
- for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- (*it)->setVisible(this->isVisible());
- }
-
- void Attacher::addObject(WorldEntity* object)
- {
- this->objects_.push_back(object);
-
- this->attach(object);
- }
-
- WorldEntity* Attacher::getObject(unsigned int index) const
- {
- unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
- {
- if (i == index)
- return (*it);
-
- ++i;
- }
- return 0;
- }
-
- void Attacher::setTarget(const std::string& target)
- {
- this->targetname_ = target;
- this->target_ = 0;
-
- if (this->targetname_ == "")
- return;
-
- for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
- if (it->getName() == this->targetname_)
- this->attachToParent(*it);
- }
-
- void Attacher::loadedNewXMLName(BaseObject* object)
- {
- if (this->target_ || this->targetname_ == "")
- return;
-
- WorldEntity* entity = orxonox_cast<WorldEntity*>(object);
- if (entity && entity->getName() == this->targetname_)
- {
- this->target_ = entity;
- this->attachToParent(entity);
- }
- }
-}
Deleted: code/branches/libraries2/src/orxonox/worldentities/Attacher.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/Attacher.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/Attacher.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,69 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#ifndef _Attacher_H__
-#define _Attacher_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <list>
-#include <string>
-#include "core/XMLNameListener.h"
-#include "objects/worldentities/StaticEntity.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Attacher : public StaticEntity, public XMLNameListener
- {
- public:
- Attacher(BaseObject* creator);
- virtual ~Attacher() {}
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- virtual void processEvent(Event& event);
- virtual void changedActivity();
- virtual void changedVisibility();
-
- void addObject(WorldEntity* object);
- WorldEntity* getObject(unsigned int index) const;
-
- void setTarget(const std::string& target);
- inline const std::string& getTarget() const
- { return this->targetname_; }
-
- void loadedNewXMLName(BaseObject* object);
-
- private:
- WorldEntity* target_;
- std::string targetname_;
- std::list<WorldEntity*> objects_;
- };
-}
-
-#endif /* _Attacher_H__ */
Deleted: code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/CMakeLists.txt 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,28 +0,0 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- WorldEntity.cc
- StaticEntity.cc
- MovableEntity.cc
- MobileEntity.cc
- ControllableEntity.cc
-
- Attacher.cc
- Backlight.cc
- Billboard.cc
- BlinkingBillboard.cc
- BigExplosion.cc
- ExplosionChunk.cc
- FadingBillboard.cc
- Light.cc
- Camera.cc
- CameraPosition.cc
- Model.cc
- ParticleEmitter.cc
- ParticleSpawner.cc
- Planet.cc
- SpawnPoint.cc
- TeamSpawnPoint.cc
- ForceField.cc
-)
-
-ADD_SUBDIRECTORY(pawns)
-ADD_SUBDIRECTORY(triggers)
Copied: code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt (from rev 5728, code/branches/libraries2/src/orxonox/objects/worldentities/CMakeLists.txt)
===================================================================
--- code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt (rev 0)
+++ code/branches/libraries2/src/orxonox/worldentities/CMakeLists.txt 2009-08-31 22:14:43 UTC (rev 5734)
@@ -0,0 +1,24 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ WorldEntity.cc
+ StaticEntity.cc
+ MovableEntity.cc
+ MobileEntity.cc
+ ControllableEntity.cc
+
+ Backlight.cc
+ Billboard.cc
+ BlinkingBillboard.cc
+ BigExplosion.cc
+ ExplosionChunk.cc
+ FadingBillboard.cc
+ Light.cc
+ Camera.cc
+ CameraPosition.cc
+ Model.cc
+ ParticleEmitter.cc
+ ParticleSpawner.cc
+ SpawnPoint.cc
+ TeamSpawnPoint.cc
+)
+
+ADD_SUBDIRECTORY(pawns)
Deleted: code/branches/libraries2/src/orxonox/worldentities/ForceField.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/ForceField.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/ForceField.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,87 +0,0 @@
-/*
- * 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:
- * Aurelian Jaggi
- * Co-authors:
- * ...
- *
- */
-
-#include "ForceField.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "objects/worldentities/MobileEntity.h"
-
-namespace orxonox
-{
- CreateFactory(ForceField);
-
- ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
- {
- RegisterObject(ForceField);
-
- //Standard Values
- this->setDirection(Vector3::ZERO);
- velocity_ = 100;
- diameter_ = 500;
- length_ = 5000;
- }
-
- ForceField::~ForceField() {}
-
- void ForceField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(ForceField, XMLPort, xmlelement, mode);
-
- //For correct xml import use: position, direction, velocity, scale
- XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
- XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
- XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000);
- }
-
- void ForceField::tick(float dt)
- {
- for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
- {
- //calculate from
- Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
- directionVec.normalise();
-
- Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
-
- //distance from centervector of the field (
- float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
-
- if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
- {
- //normalize distance from center
- it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
- }
- }
- }
-}
-
-
-
-
-
Deleted: code/branches/libraries2/src/orxonox/worldentities/ForceField.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/ForceField.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/ForceField.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,74 +0,0 @@
-/*
- * 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:
- * Aurelian Jaggi
- * Co-authors:
- * ...
- *
- */
-
-
-#ifndef _ForceField_H__
-#define _ForceField_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "StaticEntity.h"
-
-namespace orxonox
-{
- class _OrxonoxExport ForceField : public StaticEntity, public Tickable
- {
- public:
- ForceField(BaseObject* creator);
- virtual ~ForceField();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void tick(float dt);
-
- inline void setVelocity(float vel)
- { this->velocity_ = vel; }
-
- inline float getVelocity()
- { return velocity_; }
-
- inline void setDiameter(float diam)
- { this->diameter_ = diam; }
-
- inline float getDiameter()
- { return diameter_; }
-
- inline void setLength(float l)
- { this->length_ = l; }
-
- inline float getLength()
- { return length_; }
-
- private:
- float velocity_;
- float diameter_;
- float length_;
- };
-}
-
-#endif
-
Deleted: code/branches/libraries2/src/orxonox/worldentities/Planet.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/Planet.cc 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/Planet.cc 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,175 +0,0 @@
-/*
- * 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:
- * Marian Runo
- * Co-authors:
- * ...
- *
- */
-
-#include "Planet.h"
-
-#include <OgreEntity.h>
-#include <OgreBillboardSet.h>
-#include <OgreProgressiveMesh.h>
-
-#include "core/CoreIncludes.h"
-#include "core/GameMode.h"
-#include "core/XMLPort.h"
-#include "objects/Scene.h"
-#include "Camera.h"
-#include "CameraManager.h"
-
-namespace orxonox
-{
- CreateFactory(Planet);
-
- /**
- * @brief Constructor
- */
- Planet::Planet(BaseObject* creator): MovableEntity(creator)
- {
- RegisterObject(Planet);
- this->registerVariables();
- }
-
- /**
- * @brief Destructor
- */
- Planet::~Planet()
- {
- if (this->isInitialized() && this->mesh_.getEntity())
- this->detachOgreObject(this->mesh_.getEntity());
- }
-
- void Planet::tick(float dt)
- {
- if(!this->isVisible())
- return;
-
- if (GameMode::showsGraphics())
- {
- Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
- if(activeCamera)
- {
- float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
- // COUT(2) << distance << std::endl;
- float planetRadius = this->getScale();
-
- float newScale = 2 * distance / sqrt(distance*distance - planetRadius*planetRadius);
- float tempTest = newScale*(1+float(this->atmosphereSize)/float(this->imageSize));
- newScale = tempTest;
-
- this->billboard_.getBillboardSet()->setDefaultDimensions(newScale, newScale);
- }
- }
-
- SUPER(Planet, tick, dt);
- }
-
- void Planet::init()
- {
- float scaleFactor = this->getScale();
-
- this->distList.push_back(10.0f*scaleFactor);
- this->distList.push_back(19.0f*scaleFactor);
- this->distList.push_back(27.0f*scaleFactor);
- this->distList.push_back(34.0f*scaleFactor);
- this->distList.push_back(40.0f*scaleFactor);
- this->distList.push_back(45.0f*scaleFactor);
- this->distList.push_back(49.0f*scaleFactor);
- this->distList.push_back(52.0f*scaleFactor);
- this->distList.push_back(54.0f*scaleFactor);
- this->distList.push_back(55.0f*scaleFactor);
-
- float reductionValue = 0.2f;
-
- this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
- billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
-
- this->attachOgreObject(this->billboard_.getBillboardSet());
- this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
- this->setCastShadows(true);
- this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());
- this->mesh_.setCastShadows(true);
- }
-
- void Planet::changedMesh()
- {
- if (this->mesh_.getEntity())
- this->detachOgreObject(this->mesh_.getEntity());
-
- this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
-
- if (this->mesh_.getEntity())
- {
- this->attachOgreObject(this->mesh_.getEntity());
- this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
- this->mesh_.setVisible(this->isVisible());
- }
- this->init();
- }
-
- void Planet::changedShadows()
- {
- this->mesh_.setCastShadows(this->bCastShadows_);
- }
-
- /**
- @brief XML loading and saving.
- @param xmlelement The XML-element
- @param loading Loading (true) or saving (false)
- @return The XML-element
- */
- void Planet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(Planet, XMLPort, xmlelement, mode);
-
- if (GameMode::showsGraphics())
- {
- XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere");
- XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode);
- XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode);
- XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
- XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
- }
- }
-
- void Planet::registerVariables()
- {
- registerVariable(this->atmosphere_, VariableDirection::ToClient);
- registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
- registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
- registerVariable(this->atmosphereSize, VariableDirection::ToClient);
- registerVariable(this->imageSize, VariableDirection::ToClient);
- }
-
- void Planet::changedVisibility()
- {
- SUPER(Planet, changedVisibility);
- if (this->isInitialized())
- {
- this->mesh_.setVisible(this->isVisible());
- this->billboard_.setVisible(this->isVisible());
- }
- }
-}
Deleted: code/branches/libraries2/src/orxonox/worldentities/Planet.h
===================================================================
--- code/branches/libraries2/src/orxonox/objects/worldentities/Planet.h 2009-08-31 19:18:17 UTC (rev 5727)
+++ code/branches/libraries2/src/orxonox/worldentities/Planet.h 2009-08-31 22:14:43 UTC (rev 5734)
@@ -1,116 +0,0 @@
-/*
- * 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:
- * Marian Runo
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _Planet_H__
-#define _Planet_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#include "tools/BillboardSet.h"
-#include "tools/Mesh.h"
-#include "MovableEntity.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Planet : public MovableEntity
- {
- public:
- Planet(BaseObject* creator);
-
- virtual ~Planet();
-
- void init();
- virtual void tick(float dt);
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- virtual void changedVisibility();
-
- inline void setMeshSource(const std::string& meshname)
- { this->meshSrc_ = meshname; this->changedMesh(); }
-
- inline const std::string& getMeshSource() const
- { return this->meshSrc_; }
-
- inline void setCastShadows(bool bCastShadows)
- { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
-
- inline bool getCastShadows() const
- { return this->bCastShadows_; }
-
- inline const std::string& getMesh() const{
- return this->meshSrc_;
- }
-
- inline void setAtmosphereSize(float size){
- this->atmosphereSize = size;
- }
-
- inline float getAtmosphereSize(){
- return this->atmosphereSize;
- }
-
- inline void setAtmosphere(const std::string& atmosphere){
- this->atmosphere_ = atmosphere;
- }
-
- inline const std::string& getAtmosphere(){
- return this->atmosphere_;
- }
-
- inline void setImageSize(float size){
- this->imageSize = size;
- }
-
- inline float getImageSize(){
- return this->imageSize;
- }
-
- protected:
- void registerVariables();
-
- private:
-
- void changedMesh();
- void changedShadows();
-
- std::string meshSrc_;
- std::string atmosphere_;
- Mesh mesh_;
- float atmosphereSize;
- float imageSize;
- std::vector<float> distList;
- BillboardSet billboard_;
- bool bCastShadows_;
-
- };
-}
-
-#endif
-
More information about the Orxonox-commit
mailing list