Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 3:45:56 PM (9 years ago)
Author:
landauf
Message:

merged branch presentationFS15merge back to trunk

Location:
code/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/controllers/ControllerDirector.cc

    r10262 r10622  
    4141    {
    4242        SUPER(ControllerDirector, XMLPort, xmlelement, mode);
     43        XMLPortParam(ControllerDirector, "scriptname", setScriptName, getScriptName, xmlelement, mode).defaultValues("testscript");
    4344
    4445        orxout(verbose)<< "ControllerDirector::XMLPort "
     
    8384       else
    8485         return;
    85        
     86
    8687       /* Set up a luastate to use for running the scripts */
    8788       LuaState * ls = new LuaState();
     
    9899        * variable "newctrlid" defined, which means it can make use of it.
    99100        */
    100 
    101        ls->doFile("testscript.lua");
     101       std::string scr = this->scriptname_ + ".lua";
     102       ls->doFile(scr);
    102103
    103104       /* Increase the controller ID so we have a different one for
  • code/trunk/src/orxonox/controllers/ControllerDirector.h

    r10262 r10622  
    4747            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    4848
     49            inline void setScriptName(const std::string& name) { this->scriptname_ = name; }
     50            inline const std::string& getScriptName() const { return this->scriptname_; }
     51
    4952
    5053            /* Take over control of a given object */
     
    5558            //void setNewController(Controller * controller);
    5659
    57         private:
     60        protected:
     61            std::string scriptname_;   
    5862            PlayerInfo* player_;
    5963            ControllableEntity* entity_;
  • code/trunk/src/orxonox/controllers/FormationController.cc

    r10290 r10622  
    955955    bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    956956    {
     957
     958
    957959        if (entity1 == entity2)
    958960            return true;
     
    984986        }
    985987
    986         TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
     988        TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype);
    987989        if (tdm)
    988990        {
     
    992994            if (entity2->getPlayer())
    993995                team2 = tdm->getTeam(entity2->getPlayer());
    994         }
    995 
    996         Mission* miss = orxonox_cast<Mission*>(gametype);
    997         if (miss)
    998         {
    999             if (entity1->getPlayer())
    1000                 team1 = miss->getTeam(entity1->getPlayer());
    1001 
    1002             if (entity2->getPlayer())
    1003                 team2 = miss->getTeam(entity2->getPlayer());
    1004996        }
    1005997
  • code/trunk/src/orxonox/controllers/ScriptController.cc

    r10262 r10622  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      ...
    2424 *   Co-authors:
    2525 *      ...
    2626 *
    2727 */
     28
     29 /*
     30  * Currently available lua commands:
     31  *
     32  * IMPORTANT: ALL COMMANDS DO REQUIRE 7 PARAMETERS TO BE PROVIDED. FILL UP WITH ZEROES IN UNIMPORTANT PLACES.
     33  *
     34  * Command             | Abbreviation | Parameter 1          | '' 2     | '' 3    | '' 4                 | '' 5     | '' 6     | '' 7
     35  *
     36  * "Move And Look"     | mal          | GoTo X Coordinate    | '' Y ''  | '' Z '' | LookAt X Coordinate  |  '' Y '' |  '' Y '' | Duration
     37  * "Rotate And Look"   | ral          | GoTo X Coordinate    | '' Y ''  | '' Z '' | Axis (1=x, 2=z, 3=z) |     -    |     -    | Duration
     38  * "Spiral"            | spi          | GoTo X Coordinate    | '' Y ''  | '' Z '' |          -           |     -    |     -    | Duration
     39  * "Transition Look"   | chl          | From X Coordinate    | '' Y ''  | '' Z '' | To X Coordinate      |  '' Y '' |  '' Y '' | Duration
     40  * "Idle (Do nothing)" | idle         | Duration
     41  */
    2842
    2943#include "ScriptController.h"
     
    3246#include "worldentities/ControllableEntity.h"
    3347#include "core/LuaState.h"
    34 #include <cmath>
     48#include "core/LuaState.h"
     49#include "util/Math.h"
    3550
    3651namespace orxonox
     
    6681        this->eventno = 0;
    6782
     83        /* - First "previous event" scheduled at t=0 */
     84        /* - Needed for automatically updating event times */
     85        this->prevEventTime = 0;
    6886    }
    6987
     
    178196
    179197        /* Get a variable that specifies how far along the trajectory
    180          * we are
     198         * we are currently.
    181199         */
    182200        float dl = eventTime / currentEvent.duration;
    183201
    184         /* Depending */
     202        /* Depending on command */
    185203        /* Do some moving */
    186204        if( this->processing )
    187         {
    188           if( this->currentEvent.fctName == "mal" )
     205        {
     206          // Abbreviation for "spiral" (rotation + translation)
     207          if (this->currentEvent.fctName == "spi") {
     208
     209            // Need to know a perpendicular basis to the translation vector:
     210            // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm
     211            // Currently we set a fix rotational radius of 400
     212            // TODO: Add an option to adjust radius of spiral movement
     213            Vector3 direction = this->currentEvent.v1 - startpos;
     214
     215            Vector3* ortho1 = new Vector3(direction.y, -direction.x, 0);
     216            float absOrtho1 = sqrt(direction.y * direction.y + direction.x * direction.x);
     217            *ortho1 = 400 * cos(2 * math::pi * dl) * (*ortho1)/absOrtho1;
     218
     219            Vector3* ortho2 = new Vector3(0, direction.z, -direction.y);
     220            float absOrtho2 = sqrt(direction.y * direction.y + direction.z * direction.z);
     221            *ortho2 = 400 * sin(2 * math::pi * dl) * (*ortho2)/absOrtho2;
     222
     223            this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1 + *ortho1 + *ortho2);
     224
     225            delete ortho1;
     226            delete ortho2;
     227          }
     228
     229          // Abbreviation for "rotate and look"
     230          if (this->currentEvent.fctName == "ral")
     231          {
     232            // Specify the axis
     233            Vector3* a;
     234              switch ((int) currentEvent.d) {
     235                case 3:
     236                  a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl),
     237                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
     238                                  this->currentEvent.v1.z);
     239                break;
     240                case 2:
     241                  a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl),
     242                                  this->currentEvent.v1.y,
     243                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
     244                break;
     245                case 1:
     246                  a = new Vector3(this->currentEvent.v1.x,
     247                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
     248                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
     249                break;
     250              }
     251
     252            this->entity_->setPosition(*a);
     253
     254            /* Look at the specified position */
     255            this->entity_->lookAt(this->currentEvent.v1);
     256          }
     257          else if( this->currentEvent.fctName == "mal" )
    189258          {
    190259            /* Set the position to the correct place in the trajectory */
     
    193262            /* Look at the specified position */
    194263            this->entity_->lookAt(this->currentEvent.v2);
    195 
    196             /* Update look at position */
    197             //this->lookAtPosition = this->currentEvent.v2;
    198264          }
    199265          else if( this->currentEvent.fctName == "chl" )
     
    224290      /* Fill the structure with all the provided information */
    225291      tmp.fctName = instruction;
     292
    226293      //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1;
    227294      //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2;
    228295      tmp.v1 = Vector3(x1,y1,z1);
    229296      tmp.v2 = Vector3(x2,y2,z2);
     297
     298      // the parameters are not required to be vector coordinates!
     299      // for convenience they are however stored twice if they have some kind of different meaning
     300      tmp.a = x1;
     301      tmp.b = y1;
     302      tmp.c = z1;
     303      tmp.d = x2;
     304      tmp.e = y2;
     305      tmp.f = z2;
     306
    230307      tmp.duration = duration;
    231       tmp.eventTime = executionTime;
    232 
    233       orxout(verbose) << tmp.fctName << endl;
     308
     309      /* This is kind of a hack. If we hit the function idle all we want to do is
     310         advance event execution time, not schedule anything */
     311      if (instruction == "idle") {
     312        tmp.eventTime = this->prevEventTime;
     313        this->prevEventTime += x1;
     314        return;
     315      } else {
     316        tmp.eventTime = this->prevEventTime;
     317        this->prevEventTime += duration;
     318      }
    234319
    235320      /* Add the created event to the event list */
  • code/trunk/src/orxonox/controllers/ScriptController.h

    r10262 r10622  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      ...
    2424 *   Co-authors:
    2525 *      ...
     
    4545        std::string fctName;
    4646
     47        /** Final position we want to be at **/
    4748        Vector3 v1;
     49
     50        /** Where we are looking **/
    4851        Vector3 v2;
     52
     53        /** The parameters are additionally stored as a set of 6 numerical values **/
     54        float a, b, c, d, e, f;
    4955
    5056        /** Time span of the event */
     
    6975            // LUA interface
    7076            // tolua_begin
    71             void eventScheduler(std::string instruction,
    72               float x1, float y1, float z1,
    73               float x2, float y2, float z2,
    74               float duration, float executionTime);
     77            void eventScheduler(std::string instruction = "",
     78              float x1 = 0, float y1 = 0, float z1 = 0,
     79              float x2 = 0, float y2 = 0, float z2 = 0,
     80              float duration = 0, float executionTime = 0);
    7581
    7682            static ScriptController* getScriptController();
     
    116122            Vector3 startpos;
    117123
     124            /* Time of the previously scheduled event */
     125            float prevEventTime;
     126
    118127            /* - Position to look at during that transition */
    119128            //Vector3 lookAtPosition;
  • code/trunk/src/orxonox/controllers/testscript.lua

    r10262 r10622  
    1 print   ('1: Hello World')
     1print ('1: Hello World')
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r10216 r10622  
    367367            if (GameMode::isMaster())
    368368            {
    369 //                this->deathEffect();
     369                this->deatheffect();
    370370                this->goWithStyle();
    371371            }
     
    387387    {
    388388        // play death effect
    389         {
     389        /*{
    390390            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    391391            effect->setPosition(this->getPosition());
     
    410410            effect->setSource("Orxonox/sparks");
    411411            effect->setLifetime(4.0f);
    412         }
     412        }*/
     413       
     414       
     415        {
     416            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     417            effect->setPosition(this->getPosition());
     418            effect->setOrientation(this->getOrientation());
     419            effect->setDestroyAfterLife(true);
     420            effect->setSource("orxonox/explosion_flash2");
     421            effect->setLifetime(5.0f);
     422        }
     423        {
     424            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     425            effect->setPosition(this->getPosition());
     426            effect->setOrientation(this->getOrientation());
     427            effect->setDestroyAfterLife(true);
     428            effect->setSource("orxonox/explosion_flame2");
     429            effect->setLifetime(5.0f);
     430        }
     431        {
     432            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     433            effect->setPosition(this->getPosition());
     434            effect->setOrientation(this->getOrientation());
     435            effect->setDestroyAfterLife(true);
     436            effect->setSource("orxonox/explosion_shockwave2");
     437            effect->scale(20);
     438            effect->setLifetime(5.0f);
     439        }{
     440            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     441            effect->setPosition(this->getPosition());
     442            effect->setOrientation(this->getOrientation());
     443            effect->setDestroyAfterLife(true);
     444            effect->setSource("orxonox/explosion_sparks2");
     445            effect->setLifetime(5.0f);
     446        }
     447        {
     448            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     449            effect->setPosition(this->getPosition());
     450            effect->setOrientation(this->getOrientation());
     451            effect->setDestroyAfterLife(true);
     452            effect->setSource("orxonox/explosion_streak2");
     453            effect->setLifetime(5.0f);
     454        }
     455        {
     456            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     457            effect->setPosition(this->getPosition());
     458            effect->setOrientation(this->getOrientation());
     459            effect->setDestroyAfterLife(true);
     460            effect->setSource("orxonox/explosion_afterglow");
     461            effect->scale(20);
     462            effect->setLifetime(5.0f);
     463        }
     464       
     465       
    413466        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
    414467        {
Note: See TracChangeset for help on using the changeset viewer.