[Orxonox-commit 5349] r10012 - in code/branches/ScriptableController: data/levels src/orxonox/controllers
mkronig at orxonox.net
mkronig at orxonox.net
Thu Apr 3 13:21:01 CEST 2014
Author: mkronig
Date: 2014-04-03 13:21:01 +0200 (Thu, 03 Apr 2014)
New Revision: 10012
Added:
code/branches/ScriptableController/data/levels/scriptController.oxw
code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc
code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h
Modified:
code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
Log:
commit 3.4.2014
Added: code/branches/ScriptableController/data/levels/scriptController.oxw
===================================================================
--- code/branches/ScriptableController/data/levels/scriptController.oxw (rev 0)
+++ code/branches/ScriptableController/data/levels/scriptController.oxw 2014-04-03 11:21:01 UTC (rev 10012)
@@ -0,0 +1,198 @@
+<!-- First levelFile of mkronig and samuezu. It was copied from dockingToASpaceStation.oxw and modified a little bit -->
+<LevelInfo
+ name = "Fancy orxout tests"
+ description = "Docking into a spacestation."
+ tags = "showcase"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+ include("templates/pickupRepresentationTemplates.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipEscort.oxt")
+ include("templates/bigship.oxt")
+ include("templates/spaceshipTurret.oxt")
+ include("templates/spaceshipCollateralDamage.oxt")
+ include("templates/FPS.oxt")
+?>
+
+<Level
+ gametype = Deathmatch
+>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+
+ <Scene
+ ambientlight = "0.5, 0.5, 0.5"
+ skybox = "Orxonox/Starbox"
+ negativeWorldRange = "-100000, -100000, -100000"
+ positiveWorldRange = " 100000, 100000, 100000"
+ gravity = "0,0,0"
+ hasPhysics = true
+ >
+
+ <?lua
+ include("includes/pickups.oxi")
+ ?>
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0,1.0,1.0,0.5" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="3200,0,0" lookat="2800,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+ <StaticEntity position = "2800,0,0" mass=10000 collisionType=static >
+ <attached>
+ <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=50 />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="-560,0,0" halfExtents="115,100,245" /><!-- Three lower boxes -->
+ <BoxCollisionShape position="290,0,-480" halfExtents="115,100,245" yaw=-120 />
+ <BoxCollisionShape position="290,0,480" halfExtents="115,100,245" yaw=-240 />
+ <BoxCollisionShape position="-280,0,0" halfExtents="163,50,50" /><!-- Three lower connections -->
+ <BoxCollisionShape position="140,0,-240" halfExtents="163,50,50" yaw=-120 />
+ <BoxCollisionShape position="140,0,240" halfExtents="163,50,50" yaw=-240 />
+ <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" /><!-- Upper Tower -->
+ <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-120 />
+ <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-240 />
+ <BoxCollisionShape position="0,400,0" halfExtents="43,110,26" yaw=-30 /><!-- Middle one-->
+ <BoxCollisionShape position="-200,100,0" halfExtents="26,50,43" /><!--Three lower legs -->
+ <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=-30 />
+ <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=30 />
+ <BoxCollisionShape position="-100,264,0" halfExtents="26,105,43" roll=-49 /><!--Three upper legs -->
+ <BoxCollisionShape position="50,264,-87" halfExtents="26,105,43" roll=-49 yaw=-120 />
+ <BoxCollisionShape position="50,264,87" halfExtents="26,105,43" roll=-49 yaw=-240 />
+ </collisionShapes>
+ </StaticEntity>
+
+<!-- Docking -->
+ <Dock position="2830,20,50" roll=0 yaw=0 >
+ <animations>
+ <MoveToDockingTarget target="destroyer" />
+ </animations>
+ <effects>
+ <DockToShip target="spaceShip" />
+ </effects>
+ <events>
+ <execute>
+ <EventListener event="dockMe" />
+ </execute>
+
+ <undocking>
+ <EventListener event="undockMe" />
+ </undocking>
+
+ <activity>
+ <EventListener event=notGameEnd />
+ </activity>
+ </events>
+ <attached>
+ <!-- Trigger for docking with billboard -->
+
+ <!-- removed -->
+
+ <!-- Trigger for undocking with billboard -->
+ <!-- <Billboard position="-2630,-19970,150" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 /> -->
+ <DistanceTrigger position="-2630,-19970,150" distance="50" target="Pawn"
+ beaconMode="identify" targetname="bcnDestroyer" name="undockMe"
+ />
+ </attached>
+ </Dock>
+
+ <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=100 />
+ <DistanceTrigger position="0,0,0" distance="200" target="Pawn"
+ beaconMode="exclude" targetname="bcnDestroyer" name="dockMe"
+ />
+
+
+<!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING -->
+ <ScriptController position="0,0,0">
+ <events>
+ <party>
+ <EventListener event="dockMe" />
+ </party>
+
+ </events>
+
+ </ScriptController>
+
+
+<!-- FPS Player as destination of the dock -->
+<FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-19900,0" >
+ <attached>
+ <DockingTarget name="spaceShip" />
+ <DistanceTriggerBeacon name="bcnDestroyer" />
+ <DockingTarget name="destroyer" />
+ </attached>
+</FpsPlayer>
+
+
+<!-- Cube as test SpaceStation
+
+The station can either be hidden outside of the skybox, within the hull of the space station if it is big enough or within a planet.
+Complex spacestations can be placed very far away from the spaceship so it is rendered at low resolution while the player uses the space ship.
+
+-->
+ <StaticEntity position="0,-20000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="80,80,5" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="400,400,25" />
+ </collisionShapes>
+ </StaticEntity>
+
+<!-- Homogenous gravitationfield to simulate local gravity (activating the normal gravity will affect the spaceship terribly) -->
+<ForceField position="0,-20000,0" mode="homogen" diameter="2000" forcedirection = "0,-500,0" />
+
+
+<!-- Some more stuff -->
+
+ <!-- triple large belt around the planet -->
+ <?lua
+ dofile("includes/asteroidField.lua")
+ asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 7190, 7800, 250, 1)
+ ?>
+ <?lua
+ dofile("includes/asteroidField.lua")
+ asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 10000, 11000, 300, 1)
+ ?>
+ <?lua
+ dofile("includes/asteroidField.lua")
+ asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 14000, 15000, 350, 1)
+ ?>
+
+ <Planet
+ position="15000,0,-1000"
+ scale="5000"
+ collisionType="dynamic"
+ linearDamping="0.8"
+ angularDamping="0"
+ mass="10000000"
+ pitch="0"
+ mesh="planets/ganymede.mesh"
+ atmosphere="atmosphere1"
+ rotationaxis="1,0,0"
+ rotationrate="1.0"
+ atmospheresize="80.0f"
+ imagesize="1024.0f"
+ collisiondamage = 2
+ enablecollisiondamage = true
+ >
+ <attached>
+ <ForceField position="5000,0,0" mode="sphere" diameter="10000" velocity="-50" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="5000" position="0,0,0" />
+ </collisionShapes>
+ </Planet>
+
+ </Scene>
+
+</Level>
+
Added: code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc (rev 0)
+++ code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc 2014-04-03 11:21:01 UTC (rev 10012)
@@ -0,0 +1,26 @@
+#include "ControllerDirector.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "worldentities/ControllableEntity.h"
+
+
+
+
+namespace orxonox
+{
+
+
+RegisterClass(ControllerDirector);
+
+ ControllerDirector::ControllerDirector(Context* context) : BaseObject(context)
+ {
+ RegisterObject(ControllerDirector);
+
+
+ }
+ ControllerDirector::~ControllerDirector(){}
+
+
+
+
+}
Added: code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h (rev 0)
+++ code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h 2014-04-03 11:21:01 UTC (rev 10012)
@@ -0,0 +1,22 @@
+#ifndef _ControllerDirector_H__
+#define _ControllerDirector_H__
+
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "core/class/Super.h"
+
+
+namespace orxonox
+{
+
+
+ class _OrxonoxExport ControllerDirector : public BaseObject
+ {
+ public:
+ ControllerDirector(Context* context);
+ virtual ~ControllerDirector();
+
+};
+}
+#endif
Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc 2014-04-02 18:38:07 UTC (rev 10011)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc 2014-04-03 11:21:01 UTC (rev 10012)
@@ -1,29 +1,5 @@
/*
- * 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:
- * ...
- *
+First try of a scriptController. Target: An event occurs in the levelTry.oxw file, which is "heard" by an object of the type of this class. It then SHOULD (because it is not working) execute the party function.
*/
#include "ScriptController.h"
@@ -35,6 +11,126 @@
ScriptController::ScriptController(Context* context) : ArtificialController(context)
{
+ //Working
RegisterObject(ScriptController);
+ orxout()<<"hello universe constructor"<< endl;
+
+ this->player_=NULL;
+ this->entity_=NULL;
+ this->pTrigger_=NULL;
}
+
+ bool ScriptController::party(bool bTriggered, BaseObject* trigger)
+ {
+ //XMLPortEventSink seems not to execute the party function
+ orxout()<<"hello universe party"<< endl;
+ return true;
+ }
+
+
+ void ScriptController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(ScriptController, XMLPort, xmlelement, mode);
+
+
+ XMLPortEventSink(ScriptController, BaseObject, "party", party, xmlelement, mode);
+ // Working
+ orxout()<<"hello universe xmlport"<< endl;
+ }
+
+ void ScriptController::tick(float dt)
+ {
+
+ //Get controllable entity which is attached to this controller in the XML file.
+ ControllableEntity* entity = this->getControllableEntity();
+ if (!entity)
+ orxout()<<"No controllable entity found"<<endl;
+ return;
+
+
+
+ SUPER(ScriptController, tick, dt);
+ }
+
+ void ScriptController::takeControl(Controller * controller, BaseObject * trigger) {
+
+ preparationToTakeControl(trigger);
+ setNewController(controller);
+
+ }
+
+
+ bool ScriptController::preparationToTakeControl(BaseObject * trigger) {
+
+ this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);
+ this->player_ = NULL;
+
+ // Check whether it is a player trigger and extract pawn from it
+ if(pTrigger != NULL)
+ {
+ if(!pTrigger->isForPlayer()) { // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
+ orxout(verbose, context::docking) << "Docking:execute PlayerTrigger was not triggered by a player.." << endl;
+ return false;
+ }
+ player_ = pTrigger->getTriggeringPlayer(); //Get the object which triggered the event.
+ }
+ else
+ {
+ orxout(verbose, context::docking) << "Docking::execute Not a player trigger, can't extract pawn from it.." << endl;
+ return false;
+ }
+
+
+ this->entity_ = this->player_->getControllableEntity();
+ assert(this->entity_);
+
+ }
+
+ void ScriptController::setNewController(Controller * controller) {
+
+
+ orxout(verbose) << "New Controller is going to be set!" << endl;
+
+ this->entity_->setDestroyWhenPlayerLeft(false);
+ this->player_->pauseControl();
+ this->entity_->setController(controller);
+ this->setControllableEntity(this->entity_);
+
+
+
+ }
+
+
+
+
+/* Detaillierte Planung
+Director nimmt event auf und hängt dann einen controller (momentan als erstellt zu betrachten) an objekt, welches event ausgelöst hat.
+
+
+
+ Klassenvariablen
+
+ ...? brauchts überhaupt?
+
+ Variablen (in Funktionen auftretend):
+
+ Playerinfo * player enthält infos über objekt, welches event ausgelöst hat.Relevant für Inputseite des Directors
+
+ Funktion:
+
+ Auf Seite des Inputs des Directors:
+
+ preparationForControlTakeOver(...) Vorbereitende Massnahmen um neuen Controller anzuhängen, z.B. player = pTrigger->getTriggeringPlayer();
+ Orientierung an execute Funktion von Dock.cc
+
+ Auf Outputseite des Directors:
+
+ takeControl(...) Orientierung an DockingController.cc
+
+ tick() Soll von Event ausgelöst werden, wenn z.B. Kamera an Endposition angelangt ist. Danach soll wieder ein
+ menschlicher Spieler die Kontrolle übernehmen (wie? new human controller? Klasse noch angucken!).
+*/
+
+
+
}
Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h 2014-04-02 18:38:07 UTC (rev 10011)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h 2014-04-03 11:21:01 UTC (rev 10012)
@@ -31,7 +31,9 @@
#include "OrxonoxPrereqs.h"
#include "ArtificialController.h"
+#include "core/EventIncludes.h"
+
namespace orxonox
{
class _OrxonoxExport ScriptController : public ArtificialController
@@ -40,7 +42,23 @@
ScriptController(Context* context);
virtual ~ScriptController() { }
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ bool party(bool bTriggered, BaseObject* trigger);
+ void tick(float dt);
+ void takeControl(Controller * controller, BaseObject * trigger);
+ bool preparationToTakeControl(BaseObject * trigger);
+ void setNewController(Controller * controller);
+
+
private:
+
+ PlayerInfo* player_;
+
+ ControllableEntity* entity_;
+
+ PlayerTrigger * pTrigger_;
+
+
};
}
More information about the Orxonox-commit
mailing list