Flight Club


flightclub.client
Class Glider

java.lang.Object
  |
  +--flightclub.client.Particle
        |
        +--flightclub.client.MovingBody
              |
              +--flightclub.client.Glider
All Implemented Interfaces:
CameraSubject, ClockObserver
Direct Known Subclasses:
GliderAI, GliderUser

public class Glider
extends flightclub.client.MovingBody

This class implements a glider. The class is abstract because any actual glider must have a controller. The possible controllers are AI, Network and User.


Field Summary
protected  ModelViewer modelViewer
           
 
Constructor Summary
Glider(ModelViewer modelViewer, GliderType gliderType)
          Creates a glider using the spec given in the GliderType object.
 
Method Summary
protected  void createTail()
           
 void destroyMe()
           
 float[] getEye()
           
 float[] getFocus()
           
 void goFaster()
           
 void goSlower()
           
 void setGround(float g)
           
 void setTurn(float dir)
          Makes me turn to left (-ve) or right (+ve).
 void takeOff(float[] p, float[] v)
          Takes off starting at point p and heading in the direction given by the v[0] and v[1].
 void tick(float t, float dt)
          Updates the particle's position, velocity and tail.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modelViewer

protected ModelViewer modelViewer
Constructor Detail

Glider

public Glider(ModelViewer modelViewer,
              GliderType gliderType)
Creates a glider using the spec given in the GliderType object. We create our own copy of the 3d object because it will have changing *state*. The other data is static so we may simply assign references.

Method Detail

goFaster

public void goFaster()

goSlower

public void goSlower()

takeOff

public void takeOff(float[] p,
                    float[] v)
Takes off starting at point p and heading in the direction given by the v[0] and v[1]. Note that v[2], the vertical component of v, is not used. The glide angle and speed are determined by the first point on the polar curve.


tick

public void tick(float t,
                 float dt)
Description copied from class: flightclub.client.Particle
Updates the particle's position, velocity and tail. The only change to v (if any) will be a rotation of v about the z axis.

Specified by:
tick in interface ClockObserver
Overrides:
tick in class flightclub.client.MovingBody

setGround

public final void setGround(float g)

destroyMe

public void destroyMe()
Overrides:
destroyMe in class flightclub.client.Particle

createTail

protected void createTail()

setTurn

public void setTurn(float dir)
Makes me turn to left (-ve) or right (+ve). We ignore the vertical component of the motion and simply work in the xy plane. This seperation of xy from z works pretty well for Flight Club where we use Particle to build, for example, gliders, jets, roads, balloons...

The argument

works as follows. The further from zero the tighter the turn. > 0 turn right, < 0 turn left, 1 - my turn radius 2 - halve my turn radius etc... All the work is actually done in another private method, makeTurn, which gets called each tick.


getFocus

public float[] getFocus()
Specified by:
getFocus in interface CameraSubject

getEye

public float[] getEye()
Specified by:
getEye in interface CameraSubject

Dan Burton <danb@dircon.co.uk> | latest update: 20 Sep 2002;