Changeset 10614 for code/branches/presentationFS15merge
- Timestamp:
- Oct 4, 2015, 12:16:42 PM (9 years ago)
- Location:
- code/branches/presentationFS15merge
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationFS15merge
- Property svn:mergeinfo changed
/code/branches/SciptableControllerFS15 (added) merged: 10308,10315,10448,10600,10605,10609 /code/branches/presentationFS15 (added) merged: 10499
- Property svn:mergeinfo changed
-
code/branches/presentationFS15merge/data/gui/scripts/testscript.lua
r10262 r10614 22 22 -- If it worked, call its "movetoposition" function 23 23 if ctrl ~= nil then 24 -- Move to the starting point at (xl+3000,yl,zl) while looking25 -- at xl,yl,zl over the time span of 3 seconds26 ctrl:eventScheduler("mal", xl+3000,yl,zl, xl,yl,zl, 1, 0)27 24 28 -- From there, perform a rotation around the harvester placed there 29 -- in 100 steps 30 dt = math.pi/100 31 for t = 0,math.pi,dt do 32 xt = math.cos(t) 33 yt = math.sin(t) 34 35 ctrl:eventScheduler("mal", xl+3000*xt, yl+3000*yt, zl, xl, yl, zl, dt, t+0.9) 36 end 37 38 39 -- Update absolute time 40 Tabs = math.pi + 0.9 41 42 43 44 -- Move away again, still looking at the station 45 ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3, Tabs+0.4) 46 47 48 49 -- Update absolute time 50 Tabs = Tabs + 0.4 + 3 51 52 53 54 55 56 -- Transition the look from (xl,yl,zl) to (3500,0,0) in 3 seconds 57 ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2, Tabs+0.2) 58 59 Tabs = Tabs + 2 + 0.2 60 61 ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4, Tabs+0) 62 63 Tabs = Tabs + 4 64 65 for t = 0,math.pi,dt do 66 xt = math.cos(t) 67 zt = math.sin(t) 68 69 ctrl:eventScheduler("mal", xr+600*xt, yr, zr+600*zt, xr, yr, zr, dt, Tabs+t) 70 end 71 72 Tabs = Tabs + math.pi 73 74 ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3, Tabs+0.2) 75 76 Tabs = Tabs + 3 + 0.2 77 78 ctrl:eventScheduler("mal", xm,ym,zm, xl,yl,zl, 4, Tabs+2.5) 79 25 ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 2) 26 ctrl:eventScheduler("idle", 1) 27 ctrl:eventScheduler("ral", xl, yl, zl, 3, 0, 0, math.pi) 28 ctrl:eventScheduler("idle", 1) 29 ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3) 30 ctrl:eventScheduler("idle", 1) 31 ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2) 32 ctrl:eventScheduler("idle", 1) 33 ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4) 34 ctrl:eventScheduler("idle", 1) 35 ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3) 36 ctrl:eventScheduler("idle", 1) 37 ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4) 38 ctrl:eventScheduler("idle", 600) 80 39 81 40 end 82 83 84 85 -- Output the newctrlid variable we set from the C++ code86 if newctrlid ~= nil then87 orxonox.execute("orxout message test " .. newctrlid)88 end89 90 --orxonox.execute("setPause 1")91 92 -
code/branches/presentationFS15merge/data/levels/scriptController.oxw
r10262 r10614 1 1 <!-- First levelFile of mkronig and samuezu. It was copied from dockingToASpaceStation.oxw and modified a little bit --> 2 2 <LevelInfo 3 name = " Fancy orxout tests"4 description = " Docking into a spacestation."3 name = "Scriptable Controller" 4 description = "Showcase for Scriptable Controller" 5 5 tags = "showcase" 6 6 screenshot = "emptylevel.png" … … 11 11 include("HUDTemplates3.oxo") 12 12 include("templates/lodInformation.oxt") 13 include("templates/pickupRepresentationTemplates.oxt")14 13 ?> 15 14 16 15 <?lua 17 include("templates/spaceshipAssff.oxt")18 include("templates/spaceshipPirate.oxt")19 16 include("templates/spaceshipEscort.oxt") 20 include("templates/bigship.oxt")21 include("templates/spaceshipTurret.oxt")22 include("templates/spaceshipCollateralDamage.oxt")23 include("templates/FPS.oxt")24 17 ?> 25 18 … … 40 33 > 41 34 42 <?lua 43 include("includes/pickups.oxi") 44 ?> 35 <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"/> 45 36 46 <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"/>47 37 <SpawnPoint team=0 position="3200,0,0" lookat="2800,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort /> 48 38 49 <StaticEntity position = "2800,0,0" mass=10000 collisionType=static > 39 <Billboard position="2500,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=10 /> 40 <DistanceTrigger position="2500,0,0" distance="200" target="Pawn" 41 beaconMode="exclude" targetname="bcnDestroyer" name="takeControl" 42 /> 43 44 <StaticEntity position = "2000,500,2000" mass=10000 collisionType=static > 50 45 <attached> 51 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale= 50 />46 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=10 /> 52 47 </attached> 53 <collisionShapes>54 <BoxCollisionShape position="-560,0,0" halfExtents="115,100,245" /><!-- Three lower boxes -->55 <BoxCollisionShape position="290,0,-480" halfExtents="115,100,245" yaw=-120 />56 <BoxCollisionShape position="290,0,480" halfExtents="115,100,245" yaw=-240 />57 <BoxCollisionShape position="-280,0,0" halfExtents="163,50,50" /><!-- Three lower connections -->58 <BoxCollisionShape position="140,0,-240" halfExtents="163,50,50" yaw=-120 />59 <BoxCollisionShape position="140,0,240" halfExtents="163,50,50" yaw=-240 />60 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" /><!-- Upper Tower -->61 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-120 />62 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-240 />63 <BoxCollisionShape position="0,400,0" halfExtents="43,110,26" yaw=-30 /><!-- Middle one-->64 <BoxCollisionShape position="-200,100,0" halfExtents="26,50,43" /><!--Three lower legs -->65 <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=-30 />66 <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=30 />67 <BoxCollisionShape position="-100,264,0" halfExtents="26,105,43" roll=-49 /><!--Three upper legs -->68 <BoxCollisionShape position="50,264,-87" halfExtents="26,105,43" roll=-49 yaw=-120 />69 <BoxCollisionShape position="50,264,87" halfExtents="26,105,43" roll=-49 yaw=-240 />70 </collisionShapes>71 48 </StaticEntity> 72 49 73 <!-- Docking -->74 <Dock position="2830,20,50" roll=0 yaw=0>75 < animations>76 <MoveToDockingTarget target="destroyer" />77 </animations>78 <effects> 79 <DockToShip target="spaceShip" />80 </effects>50 <StaticEntity position = "-1000,3000,-1000" mass=10000 collisionType=static > 51 <attached> 52 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=80 /> 53 </attached> 54 </StaticEntity> 55 56 <!-- ControllerDirector waits for the event takeControl to attach a new Controller --> 57 <ControllerDirector position="0,0,0" scriptname="presentation"> 81 58 <events> 82 <execute> 83 <EventListener event="dockMe" /> 84 </execute> 85 86 <undocking> 87 <EventListener event="undockMe" /> 88 </undocking> 89 90 <activity> 91 <EventListener event=notGameEnd /> 92 </activity> 59 <takeControl> 60 <EventListener event="takeControl" /> 61 </takeControl> 93 62 </events> 94 <attached> 95 <!-- Trigger for docking with billboard --> 96 97 <!-- removed --> 98 99 <!-- Trigger for undocking with billboard --> 100 <!-- <Billboard position="-2630,-19970,150" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 /> --> 101 <DistanceTrigger position="-2630,-19970,150" distance="50" target="Pawn" 102 beaconMode="identify" targetname="bcnDestroyer" name="undockMe" 103 /> 104 </attached> 105 </Dock> 106 107 <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=100 /> 108 <DistanceTrigger position="0,0,0" distance="200" target="Pawn" 109 beaconMode="exclude" targetname="bcnDestroyer" name="dockMe" 110 /> 111 112 113 <!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING --> 114 <ScriptController position="0,0,0"> 115 <events> 116 <party> 117 <EventListener event="dockMe" /> 118 </party> 119 120 </events> 121 122 </ScriptController> 123 124 125 <!-- FPS Player as destination of the dock --> 126 <FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-19900,0" > 127 <attached> 128 <DockingTarget name="spaceShip" /> 129 <DistanceTriggerBeacon name="bcnDestroyer" /> 130 <DockingTarget name="destroyer" /> 131 </attached> 132 </FpsPlayer> 133 134 135 <!-- Cube as test SpaceStation 136 137 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. 138 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. 139 140 --> 141 <StaticEntity position="0,-20000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 > 142 <attached> 143 <Model position="0,0,0" mesh="crate.mesh" scale3D="80,80,5" /> 144 </attached> 145 <collisionShapes> 146 <BoxCollisionShape position="0,0,0" halfExtents="400,400,25" /> 147 </collisionShapes> 148 </StaticEntity> 149 150 <!-- Homogenous gravitationfield to simulate local gravity (activating the normal gravity will affect the spaceship terribly) --> 151 <ForceField position="0,-20000,0" mode="homogen" diameter="2000" forcedirection = "0,-500,0" /> 152 153 154 <!-- Some more stuff --> 155 156 <!-- triple large belt around the planet --> 157 <?lua 158 dofile("includes/asteroidField.lua") 159 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 7190, 7800, 250, 1) 160 ?> 161 <?lua 162 dofile("includes/asteroidField.lua") 163 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 10000, 11000, 300, 1) 164 ?> 165 <?lua 166 dofile("includes/asteroidField.lua") 167 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 14000, 15000, 350, 1) 168 ?> 169 170 <Planet 171 position="15000,0,-1000" 172 scale="5000" 173 collisionType="dynamic" 174 linearDamping="0.8" 175 angularDamping="0" 176 mass="10000000" 177 pitch="0" 178 mesh="planets/ganymede.mesh" 179 atmosphere="atmosphere1" 180 rotationaxis="1,0,0" 181 rotationrate="1.0" 182 atmospheresize="80.0f" 183 imagesize="1024.0f" 184 collisiondamage = 2 185 enablecollisiondamage = true 186 > 187 <attached> 188 <ForceField position="5000,0,0" mode="sphere" diameter="10000" velocity="-50" /> 189 </attached> 190 <collisionShapes> 191 <SphereCollisionShape radius="5000" position="0,0,0" /> 192 </collisionShapes> 193 </Planet> 63 </ControllerDirector> 194 64 195 65 </Scene> 196 197 66 </Level> 198 67 -
code/branches/presentationFS15merge/src/orxonox/controllers/ControllerDirector.cc
r10262 r10614 41 41 { 42 42 SUPER(ControllerDirector, XMLPort, xmlelement, mode); 43 XMLPortParam(ControllerDirector, "scriptname", setScriptName, getScriptName, xmlelement, mode).defaultValues("testscript"); 43 44 44 45 orxout(verbose)<< "ControllerDirector::XMLPort " … … 83 84 else 84 85 return; 85 86 86 87 /* Set up a luastate to use for running the scripts */ 87 88 LuaState * ls = new LuaState(); … … 98 99 * variable "newctrlid" defined, which means it can make use of it. 99 100 */ 100 101 ls->doFile( "testscript.lua");101 std::string scr = this->scriptname_ + ".lua"; 102 ls->doFile(scr); 102 103 103 104 /* Increase the controller ID so we have a different one for -
code/branches/presentationFS15merge/src/orxonox/controllers/ControllerDirector.h
r10262 r10614 47 47 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 48 48 49 inline void setScriptName(const std::string& name) { this->scriptname_ = name; } 50 inline const std::string& getScriptName() const { return this->scriptname_; } 51 49 52 50 53 /* Take over control of a given object */ … … 55 58 //void setNewController(Controller * controller); 56 59 57 private: 60 protected: 61 std::string scriptname_; 58 62 PlayerInfo* player_; 59 63 ControllableEntity* entity_; -
code/branches/presentationFS15merge/src/orxonox/controllers/ScriptController.cc
r10262 r10614 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... 26 26 * 27 27 */ 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 */ 28 42 29 43 #include "ScriptController.h" … … 32 46 #include "worldentities/ControllableEntity.h" 33 47 #include "core/LuaState.h" 48 #include "core/LuaState.h" 34 49 #include <cmath> 50 35 51 36 52 namespace orxonox … … 66 82 this->eventno = 0; 67 83 84 /* - First "previous event" scheduled at t=0 */ 85 /* - Needed for automatically updating event times */ 86 this->prevEventTime = 0; 68 87 } 69 88 … … 178 197 179 198 /* Get a variable that specifies how far along the trajectory 180 * we are 199 * we are currently. 181 200 */ 182 201 float dl = eventTime / currentEvent.duration; 183 202 184 /* Depending */203 /* Depending on command */ 185 204 /* Do some moving */ 186 205 if( this->processing ) 187 { 188 if( this->currentEvent.fctName == "mal" ) 206 { 207 // Abbreviation for "spiral" (rotation + translation) 208 if (this->currentEvent.fctName == "spi") { 209 210 // Need to know a perpendicular basis to the translation vector: 211 // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm 212 // Currently we set a fix rotational radius of 400 213 // TODO: Add an option to adjust radius of spiral movement 214 Vector3 direction = this->currentEvent.v1 - startpos; 215 216 Vector3* ortho1 = new Vector3(direction.y, -direction.x, 0); 217 float absOrtho1 = sqrt(direction.y * direction.y + direction.x * direction.x); 218 *ortho1 = 400 * cos(2 * M_PI * dl) * (*ortho1)/absOrtho1; 219 220 Vector3* ortho2 = new Vector3(0, direction.z, -direction.y); 221 float absOrtho2 = sqrt(direction.y * direction.y + direction.z * direction.z); 222 *ortho2 = 400 * sin(2 * M_PI * dl) * (*ortho2)/absOrtho2; 223 224 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1 + *ortho1 + *ortho2); 225 226 delete ortho1; 227 delete ortho2; 228 } 229 230 // Abbreviation for "rotate and look" 231 if (this->currentEvent.fctName == "ral") 232 { 233 // Specify the axis 234 Vector3* a; 235 switch ((int) currentEvent.d) { 236 case 3: 237 a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*M_PI*dl), 238 this->currentEvent.v1.y + this->currentEvent.e*sin(2*M_PI*dl), 239 this->currentEvent.v1.z); 240 break; 241 case 2: 242 a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*M_PI*dl), 243 this->currentEvent.v1.y, 244 this->currentEvent.v1.z + this->currentEvent.e*cos(2*M_PI*dl)); 245 break; 246 case 1: 247 a = new Vector3(this->currentEvent.v1.x, 248 this->currentEvent.v1.y + this->currentEvent.e*sin(2*M_PI*dl), 249 this->currentEvent.v1.z + this->currentEvent.e*cos(2*M_PI*dl)); 250 break; 251 } 252 253 this->entity_->setPosition(*a); 254 255 /* Look at the specified position */ 256 this->entity_->lookAt(this->currentEvent.v1); 257 } 258 else if( this->currentEvent.fctName == "mal" ) 189 259 { 190 260 /* Set the position to the correct place in the trajectory */ … … 193 263 /* Look at the specified position */ 194 264 this->entity_->lookAt(this->currentEvent.v2); 195 196 /* Update look at position */197 //this->lookAtPosition = this->currentEvent.v2;198 265 } 199 266 else if( this->currentEvent.fctName == "chl" ) … … 224 291 /* Fill the structure with all the provided information */ 225 292 tmp.fctName = instruction; 293 226 294 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 227 295 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 228 296 tmp.v1 = Vector3(x1,y1,z1); 229 297 tmp.v2 = Vector3(x2,y2,z2); 298 299 // the parameters are not required to be vector coordinates! 300 // for convenience they are however stored twice if they have some kind of different meaning 301 tmp.a = x1; 302 tmp.b = y1; 303 tmp.c = z1; 304 tmp.d = x2; 305 tmp.e = y2; 306 tmp.f = z2; 307 230 308 tmp.duration = duration; 231 tmp.eventTime = executionTime; 232 233 orxout(verbose) << tmp.fctName << endl; 309 310 /* This is kind of a hack. If we hit the function idle all we want to do is 311 advance event execution time, not schedule anything */ 312 if (instruction == "idle") { 313 tmp.eventTime = this->prevEventTime; 314 this->prevEventTime += x1; 315 return; 316 } else { 317 tmp.eventTime = this->prevEventTime; 318 this->prevEventTime += duration; 319 } 234 320 235 321 /* Add the created event to the event list */ -
code/branches/presentationFS15merge/src/orxonox/controllers/ScriptController.h
r10262 r10614 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... … … 45 45 std::string fctName; 46 46 47 /** Final position we want to be at **/ 47 48 Vector3 v1; 49 50 /** Where we are looking **/ 48 51 Vector3 v2; 52 53 /** The parameters are additionally stored as a set of 6 numerical values **/ 54 float a, b, c, d, e, f; 49 55 50 56 /** Time span of the event */ … … 69 75 // LUA interface 70 76 // 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); 75 81 76 82 static ScriptController* getScriptController(); … … 116 122 Vector3 startpos; 117 123 124 /* Time of the previously scheduled event */ 125 float prevEventTime; 126 118 127 /* - Position to look at during that transition */ 119 128 //Vector3 lookAtPosition;
Note: See TracChangeset
for help on using the changeset viewer.