| 149 | == WaypointController == |
| 150 | So far we used only the classes StaticEntity and MovableEntity. There is another important WorldEntity derivative you should know: the ControllableEntity. A ControllableEntity is controlled by a controller (an instance of the class Controller). This controller executes steering commands on the ControllableEntity. |
| 151 | By using Controller and ControllableEntity you can create objects that move in the space along any path you like. |
| 152 | The simplest case of a Controller is the WaypointController: |
| 153 | {{{ |
| 154 | #!xml |
| 155 | <SpaceShip position="300,0,0" lookat="0,0,0" team=3> |
| 156 | <templates> |
| 157 | <Template link=spaceshipescort /> |
| 158 | </templates> |
| 159 | <controller> |
| 160 | <WaypointPatrolController accuracy=10 team=3> |
| 161 | <waypoints> |
| 162 | <Model mesh="cube.mesh" scale=8 position="300,0,0" /> |
| 163 | <Model mesh="cube.mesh" scale=8 position="300,500,0" /> |
| 164 | <Model mesh="cube.mesh" scale=8 position="0,500,0" /> |
| 165 | <StaticEntity position="0,0,0" /> |
| 166 | </waypoints> |
| 167 | </WaypointPatrolController> |
| 168 | </controller> |
| 169 | </SpaceShip> |
| 170 | }}} |
| 171 | In this example the SpaceShip (The SpaceShip class is a derivative of the ControllableEntity class) is controlled by a WaypointController. The ship will fly from its starting position to the first cube. There it will change its direction and fly to the second cube ... When the SpaceShip arrived at the last waypoint in the list it will continue at the top of the list again. |
| 172 | If you want the waypoints to be invisible just replace Model by StaticEntity as done for the last waypoint in the list above. |
| 173 | |
| 174 | Take a look at the "waypoints.oxw" level to learn more about the WaypointController. |
| 175 | |
| 246 | |
| 247 | == Planets == |
| 248 | Planets are a nice addition to many levels. Use the Planet class to add a planet to a level. |
| 249 | {{{ |
| 250 | #!xml |
| 251 | <Planet |
| 252 | position="10000,0,0" |
| 253 | scale="100" |
| 254 | collisionType="dynamic" |
| 255 | linearDamping="0.8" |
| 256 | angularDamping="0" |
| 257 | mass="5000000" |
| 258 | pitch="0" |
| 259 | mesh="planets/muunilinst.mesh" |
| 260 | atmosphere="atmosphere1" |
| 261 | rotationaxis="1,0,0" |
| 262 | rotationrate="1.0" |
| 263 | atmospheresize="80.0f" |
| 264 | imagesize="1024.0f" |
| 265 | collisiondamage = 2 |
| 266 | enablecollisiondamage = true |
| 267 | > |
| 268 | <attached> |
| 269 | <ForceField position="0,0,0" mode="sphere" diameter="1000" velocity="-500" /> |
| 270 | </attached> |
| 271 | <collisionShapes> |
| 272 | <SphereCollisionShape radius="100" position="0,0,0" /> |
| 273 | </collisionShapes> |
| 274 | </Planet> |
| 275 | }}} |
| 276 | |
| 277 | Notice that in this example there is a force field attached to the planet to simulate gravitation. The planet also has a collision shape. |
| 278 | Have a look at "planets.oxw" and "Planet.h", to see how planets work in detail. |