[Orxonox-commit 6508] r11152 - in code/branches/plehmannFS16: data/gui/scripts data/levels src/orxonox/controllers

plehmann at orxonox.net plehmann at orxonox.net
Thu Mar 24 15:54:06 CET 2016


Author: plehmann
Date: 2016-03-24 15:54:06 +0100 (Thu, 24 Mar 2016)
New Revision: 11152

Modified:
   code/branches/plehmannFS16/data/gui/scripts/testscript.lua
   code/branches/plehmannFS16/data/levels/scriptController.oxw
   code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.cc
   code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h
Log:
took the event functions out of the tick function

Modified: code/branches/plehmannFS16/data/gui/scripts/testscript.lua
===================================================================
--- code/branches/plehmannFS16/data/gui/scripts/testscript.lua	2016-03-24 14:53:28 UTC (rev 11151)
+++ code/branches/plehmannFS16/data/gui/scripts/testscript.lua	2016-03-24 14:54:06 UTC (rev 11152)
@@ -22,19 +22,18 @@
 -- If it worked, call its "movetoposition" function
 if ctrl ~= nil then
 
-  ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 2)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("ral", xl, yl, zl, 3, 3000, 0, math.pi)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3)
-  ctrl:eventScheduler("idle", 1)
-  ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4)
-  ctrl:eventScheduler("idle", 1)
+  ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 10)
+  -- ctrl:eventScheduler("ral", xl, yl, zl, 3, 3000, 0, math.pi)
+  -- ctrl:eventScheduler("idle", 1)
+  -- ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3)
+  -- ctrl:eventScheduler("idle", 1)
+  -- ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2)
+  -- ctrl:eventScheduler("idle", 1)
+  -- ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4)
+  -- ctrl:eventScheduler("idle", 1)
+  -- ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3)
+  -- ctrl:eventScheduler("idle", 1)
+  -- ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4)
+  -- ctrl:eventScheduler("idle", 1)
 
 end
\ No newline at end of file

Modified: code/branches/plehmannFS16/data/levels/scriptController.oxw
===================================================================
--- code/branches/plehmannFS16/data/levels/scriptController.oxw	2016-03-24 14:53:28 UTC (rev 11151)
+++ code/branches/plehmannFS16/data/levels/scriptController.oxw	2016-03-24 14:54:06 UTC (rev 11152)
@@ -53,8 +53,27 @@
       </attached>
     </StaticEntity>
 
+
+    <StaticEntity position  = "3000,0,0" mass=10000 collisionType=static >
+      <attached>
+        <Model mesh="cube_green.mesh" mass=10 position="0,0,0" scale=10 />
+      </attached>
+    </StaticEntity>
+
+    <StaticEntity position  = "2000,0,0" mass=10000 collisionType=static >
+      <attached>
+        <Model mesh="cube_green.mesh" mass=10 position="0,0,0" scale=10 />
+      </attached>
+    </StaticEntity>
+
+    <StaticEntity position  = "2500,500,0" mass=10000 collisionType=static >
+      <attached>
+        <Model mesh="cube_green.mesh" mass=10 position="0,0,0" scale=10 />
+      </attached>
+    </StaticEntity>
+
 <!-- ControllerDirector waits for the event takeControl to attach a new Controller -->
-    <ControllerDirector position="0,0,0" scriptname="presentation">
+    <ControllerDirector position="0,0,0" scriptname="testscript">
         <events>
             <takeControl>
                 <EventListener event="takeControl" />

Modified: code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.cc	2016-03-24 14:53:28 UTC (rev 11151)
+++ code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.cc	2016-03-24 14:54:06 UTC (rev 11152)
@@ -33,10 +33,11 @@
   *
   * Command             | Abbreviation | Parameter 1          | '' 2     | '' 3    | '' 4                 | '' 5     | '' 6     | '' 7
   *
-  * "Move And Look"     | mal          | GoTo X Coordinate    | '' Y ''  | '' Z '' | LookAt X Coordinate  |  '' Y '' |  '' Y '' | Duration
-  * "Rotate And Look"   | ral          | GoTo X Coordinate    | '' Y ''  | '' Z '' | Axis (1=x, 2=z, 3=z) |     -    |     -    | Duration
-  * "Spiral"            | spi          | GoTo X Coordinate    | '' Y ''  | '' Z '' |          -           |     -    |     -    | Duration
-  * "Transition Look"   | chl          | From X Coordinate    | '' Y ''  | '' Z '' | To X Coordinate      |  '' Y '' |  '' Y '' | Duration
+  * "Move And Look"     | mal          | GoTo X Coordinate    |  '' Y ''  | '' Z '' | LookAt X Coordinate  |  '' Y '' |  '' Y '' | Duration
+  * "Rotate And Look"   | ral          | GoTo X Coordinate    |  '' Y ''  | '' Z '' | Axis (1=x, 2=y, 3=z) |     -    |     -    | Duration
+  * "Spiral"            | spi          | GoTo X Coordinate    |  '' Y ''  | '' Z '' |          -           |     -    |     -    | Duration
+  * "Transition Look"   | chl          | From X Coordinate    |  '' Y ''  | '' Z '' | To X Coordinate      |  '' Y '' |  '' Y '' | Duration
+  * "rotate round X crd"| rotX         | anchor coordinate    | angle(rad)|    -    |                      |          |          | Duration
   * "Idle (Do nothing)" | idle         | Duration
   */
 
@@ -89,7 +90,7 @@
     {
         /* Output some debugging information */
         orxout(verbose) << "ScriptController: Taking control" << endl;
-        orxout(verbose) << "This-pointer: " << this << endl;
+        orxout(verbose) << "This-pointer: " << this << endl; 
 
         /* Set the controller ID (the argument here should be nonzero) */
         this->ctrlid_ = ctrlid;
@@ -102,12 +103,11 @@
          * any preexisting human controllers in place. 
          */
         this->entity_->setDestroyWhenPlayerLeft(false);
-        // uncomment the next line because i just did that for debug
-        //this->player_->pauseControl();
+        this->player_->stopTemporaryControl();
         this->entity_->setController(this);
         this->setControllableEntity(this->entity_);
-        this->entity_->mouseLook();
-        this->entity_->setVisible(false);
+        //this->entity_->mouseLook();
+        //this->entity_->setVisible(false);
         
         // TODO take the human Controllers control  dont forget to give it back in the destructor
     }
@@ -203,69 +203,23 @@
         if( this->processing )
         {
           // Abbreviation for "spiral" (rotation + translation)
-          if (this->currentEvent.fctName == "spi") {
-
-            // Need to know a perpendicular basis to the translation vector:
-            // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm
-            // Currently we set a fix rotational radius of 400
-            // TODO: Add an option to adjust radius of spiral movement
-            Vector3 direction = this->currentEvent.v1 - startpos;
-
-            Vector3* ortho1 = new Vector3(direction.y, -direction.x, 0);
-            float absOrtho1 = sqrt(direction.y * direction.y + direction.x * direction.x);
-            *ortho1 = 400 * cos(2 * math::pi * dl) * (*ortho1)/absOrtho1;
-
-            Vector3* ortho2 = new Vector3(0, direction.z, -direction.y);
-            float absOrtho2 = sqrt(direction.y * direction.y + direction.z * direction.z);
-            *ortho2 = 400 * sin(2 * math::pi * dl) * (*ortho2)/absOrtho2;
-
-            this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1 + *ortho1 + *ortho2);
-
-            delete ortho1;
-            delete ortho2;
+          if (this->currentEvent.fctName == "spi") 
+          {
+              spi(dl); // call the external function
           }
 
           // Abbreviation for "rotate and look"
-          if (this->currentEvent.fctName == "ral")
+          else if (this->currentEvent.fctName == "ral")
           { 
-            // Specify the axis
-            Vector3 a;
-              switch ((int) currentEvent.d) {
-                case 3:
-                  a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl),
-                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
-                                  this->currentEvent.v1.z);
-                break;
-                case 2:
-                  a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl),
-                                  this->currentEvent.v1.y,
-                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
-                break;
-                case 1:
-                  a = Vector3(this->currentEvent.v1.x,
-                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
-                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
-                break;
-              }
-
-            this->entity_->setPosition(a);
-
-            /* Look at the specified position */
-            this->entity_->lookAt(this->currentEvent.v1);
+              ral(dl);  
           }
           else if( this->currentEvent.fctName == "mal" )
           {
-            /* Set the position to the correct place in the trajectory */
-            this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1);
-
-            /* Look at the specified position */
-            this->entity_->lookAt(this->currentEvent.v2);
+              mal(dl);
           }
           else if( this->currentEvent.fctName == "chl" )
           {
-            /* Sweep the look from v1 to v2 */
-            this->entity_->lookAt( (1-dl)*this->currentEvent.v1 + 
-              dl * this->currentEvent.v2 );
+              chl(dl);
           }
 
 
@@ -343,4 +297,83 @@
       this->eventno += 1;
 
     }
+
+    // Event Functions
+
+    void ScriptController::spi(float dl) 
+    {
+    
+                // Need to know a perpendicular basis to the translation vector:
+            // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm
+            // Currently we set a fix rotational radius of 400
+            // TODO: Add an option to adjust radius of spiral movement
+            Vector3 direction = this->currentEvent.v1 - startpos;
+
+            Vector3* ortho1 = new Vector3(direction.y, -direction.x, 0);
+            float absOrtho1 = sqrt(direction.y * direction.y + direction.x * direction.x);
+            *ortho1 = 400 * cos(2 * math::pi * dl) * (*ortho1)/absOrtho1;
+
+            Vector3* ortho2 = new Vector3(0, direction.z, -direction.y);
+            float absOrtho2 = sqrt(direction.y * direction.y + direction.z * direction.z);
+            *ortho2 = 400 * sin(2 * math::pi * dl) * (*ortho2)/absOrtho2;
+
+            this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1 + *ortho1 + *ortho2);
+
+            delete ortho1;
+            delete ortho2;
+
+    }
+
+    void ScriptController::ral(float dl)
+    {
+            // Specify the axis
+            Vector3 a;
+              switch ((int) currentEvent.d) {
+                case 3:
+                  a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl),
+                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
+                                  this->currentEvent.v1.z);
+                break;
+                case 2:
+                  a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl),
+                                  this->currentEvent.v1.y,
+                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
+                break;
+                case 1:
+                  a = Vector3(this->currentEvent.v1.x,
+                                  this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
+                                  this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
+                break;
+              }
+
+            this->entity_->setPosition(a);
+
+            /* Look at the specified position */
+            this->entity_->lookAt(this->currentEvent.v1);
+      
+    }
+
+    void ScriptController::mal(float dl)
+    {
+            /* Set the position to the correct place in the trajectory */
+            this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1);
+
+            /* Look at the specified position */
+            this->entity_->lookAt(this->currentEvent.v2);
+
+    }
+
+    void ScriptController::chl(float dl)
+    {
+            /* Sweep the look from v1 to v2 */
+            this->entity_->lookAt( (1-dl)*this->currentEvent.v1 + 
+              dl * this->currentEvent.v2 );
+
+    }
+
+    void ScriptController::rotX(float dl)
+    {
+
+
+    }
 }

Modified: code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h	2016-03-24 14:53:28 UTC (rev 11151)
+++ code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h	2016-03-24 14:54:06 UTC (rev 11152)
@@ -127,6 +127,24 @@
             /* - Position to look at during that transition */
             //Vector3 lookAtPosition;
 
+
+            /* private member functions */
+
+            /*spiral event*/
+            void spi(float dl);
+
+            /* rotate and look event */
+            void ral(float dl);
+
+            /* move and look event */
+            void mal(float dl);
+
+            /* transition look event */
+            void chl(float dl);
+
+            /* rotate around x-coordinate event */
+            void rotX(float dl);
+
     };// tolua_export
 } // tolua_export
 




More information about the Orxonox-commit mailing list