Changeset 7674
- Timestamp:
- Nov 26, 2010, 12:01:53 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/data/levels/The Time Machine.oxw
r7673 r7674 173 173 174 174 <!--Creating Spaceships_____________________________________________________________________________________________________________________________________________________________________--> 175 176 <?lua for i=0,5,1 do177 y=math.random(-500,500)178 z=math.random(-1000,1000)179 y2=math.random(-500,500)180 z2=math.random(-1000,1000)181 health=230182 addh=100183 ?>184 185 <EventTrigger name="BotDied" >186 <events>187 <trigger>188 <SpaceShip position="-4000,<?lua print(y) ?>,<?lua print(z) ?>" lookat="1000,<?lua print(y) ?>,<?lua print(z) ?>" health=<?lua print(health) ?> maxhealth=<?lua print(health) ?> initialhealth=<?lua print(health) ?> >189 <templates>190 <Template link=spaceshipassff />191 </templates>192 <controller>193 <WaypointPatrolController alertnessradius=1000 team=0 active=1 >194 <waypoints>195 <Model mesh="cube.mesh" scale=0 position="1000,<?lua print(math.random(-1000,1000)) ?>,<?lua print(math.random(-1000,1000)) ?>" />196 </waypoints>197 <events>198 <activity>199 <Trigger mode=or>200 <EventTrigger invert=true>201 <events>202 <trigger>203 <EventListener event=EnterTimeMachine />204 </trigger>205 </events>206 </EventTrigger>207 <EventTrigger>208 <events>209 <trigger>210 <EventListener event=trigger2 />211 </trigger>212 </events>213 </EventTrigger>214 </Trigger>215 </activity>216 </events>217 </WaypointPatrolController>218 </controller>219 </SpaceShip>220 </trigger>221 </events>222 </EventTrigger>223 224 <EventTrigger name="BotDied" >225 <events>226 <trigger>227 <SpaceShip position="4000,<?lua print(y2) ?>,<?lua print(z2) ?>" lookat="-1000,<?lua print(y2) ?>, <?lua print(z2) ?>" health=<?lua print(health+addh) ?> maxhealth=<?lua print(health+addh) ?> initialhealth=<?lua print(health+addh) ?> >228 <templates>229 <Template link=spaceshippirate />230 </templates>231 <controller>232 <WaypointPatrolController alertnessradius=1000 team=1 active=1 >233 <waypoints>234 <Model mesh="cube.mesh" scale=0 position="-1000,<?lua print(math.random(-1000,1000)) ?>, <?lua print(math.random(-1000,1000)) ?>" />235 </waypoints>236 <events>237 <activity>238 <Trigger mode=or>239 <EventTrigger invert=true>240 <events>241 <trigger>242 <EventListener event=EnterTimeMachine />243 </trigger>244 </events>245 </EventTrigger>246 <EventTrigger>247 <events>248 <trigger>249 <EventListener event=trigger2 />250 </trigger>251 </events>252 </EventTrigger>253 </Trigger>254 </activity>255 </events>256 </WaypointPatrolController>257 </controller>258 </SpaceShip>259 </trigger>260 </events>261 </EventTrigger>262 <?lua end ?>263 175 264 176 <!--Creating Spaceships_____END_____________________________________________________________________________________________________________________________________________________________--> -
code/trunk/src/modules/objects/ForceField.cc
r7673 r7674 42 42 CreateFactory(ForceField); 43 43 44 /*static*/ const std::string modeStringNormal_s = "tube";45 /*static*/ const std::string modeStringSphere_s = "sphere";44 /*static*/ const std::string ForceField::modeTube_s = "tube"; 45 /*static*/ const std::string ForceField::modeSphere_s = "sphere"; 46 46 47 47 ForceField::ForceField(BaseObject* creator) : StaticEntity(creator) … … 54 54 this->diameter_ = 500; 55 55 this->length_ = 5000; 56 this->mode_ = ForceFieldMode::tube;56 this->mode_ = forceFieldMode::tube; 57 57 } 58 58 … … 70 70 XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000); 71 71 XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode); 72 COUT(0) << "ForceField created " << this->velocity_ << " " << this->diameter_ << " " << this->radius_ << " " << this->length_ << " " << this->halfLength_ << " " << this->getMode() << std::endl; 72 73 } 73 74 74 75 void ForceField::tick(float dt) 75 76 { 76 // Iterate over all objects that could possibly be affected by the ForceField. 77 for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it) 77 if(this->mode_ == forceFieldMode::tube) 78 78 { 79 if(this->mode_ == ForceFieldMode::tube) 79 // Iterate over all objects that could possibly be affected by the ForceField. 80 for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it) 80 81 { 81 82 // The direction of the orientation of the force field. … … 89 90 // The object is outside of the length of the ForceField. 90 91 if(distanceVector.length() > this->halfLength_) 91 return;92 continue; 92 93 93 94 // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector) … … 96 97 // If the object in a tube of radius diameter/2 around the direction of orientation. 97 98 if(distanceFromDirectionVector >= this->radius_) 98 return;99 continue; 99 100 100 101 // Apply a force to the object in the direction of the orientation. 101 102 // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius. 102 it->applyCentralForce(( (this->radius_ - distanceFromDirectionVector)/(this->radius_))* this->velocity_ * direction);103 it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction); 103 104 } 104 else if(this->mode_ == ForceFieldMode::sphere) 105 } 106 else if(this->mode_ == forceFieldMode::sphere) 107 { 108 // Iterate over all objects that could possibly be affected by the ForceField. 109 for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it) 105 110 { 106 111 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition(); … … 117 122 void ForceField::setMode(const std::string& mode) 118 123 { 119 if(mode == ForceField::mode StringTube_s)120 this->mode_ = ForceFieldMode::tube;121 else if(mode == ForceField::modeS tringSphere_s)122 this->mode_ = ForceFieldMode::sphere;124 if(mode == ForceField::modeTube_s) 125 this->mode_ = forceFieldMode::tube; 126 else if(mode == ForceField::modeSphere_s) 127 this->mode_ = forceFieldMode::sphere; 123 128 else 124 129 { 125 130 COUT(2) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << std::endl; 126 this->mode_ = ForceFieldMode::tube;131 this->mode_ = forceFieldMode::tube; 127 132 } 128 133 } … … 132 137 switch(this->mode_) 133 138 { 134 case ForceFieldMode::tube:135 return ForceField::mode StringTube_s;136 case ForceFieldMode::sphere:137 return ForceField::modeS tringSphere_s;139 case forceFieldMode::tube: 140 return ForceField::modeTube_s; 141 case forceFieldMode::sphere: 142 return ForceField::modeSphere_s; 138 143 default: 139 return ForceField::mode StringTube_s;144 return ForceField::modeTube_s; 140 145 } 141 146 } -
code/trunk/src/modules/objects/ForceField.h
r7673 r7674 56 56 @inGroup Objects 57 57 */ 58 namespace ForceFieldMode58 namespace forceFieldMode 59 59 { 60 60 enum Value { … … 116 116 117 117 private: 118 static const std::string mode StringTube_s;119 static const std::string modeS tringSphere_s;118 static const std::string modeTube_s; 119 static const std::string modeSphere_s; 120 120 121 121 float velocity_; … … 124 124 float length_; 125 125 float halfLength_; 126 ForceFieldMode::Value mode_;126 forceFieldMode::Value mode_; 127 127 }; 128 128 }
Note: See TracChangeset
for help on using the changeset viewer.