Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.j3d.physics
Class Simulation

    java.lang.Object
      net.sf.j3d.threeD.raytracer.engine.Scene
          net.sf.j3d.physics.Simulation

All Implemented Interfaces:
  Cloneable, Runnable

    public class Simulation

extends Scene
implements Runnable

Author:
  Mike Murray

Nested Class Summary
`static interface` | `Simulation.Force`

Field Summary
`static double` | `G`

Constructor Summary
`Simulation()`
`Simulation(int width, int height)`
`Simulation(int width, int height, double ox, double oy, double scale, RigidBody[] bodies, double dt, int itr, UpdateListener l, String outputDir)` Constructs a new Simulation object using the specified parameters.
`Simulation(int width, int height, RigidBody[] bodies, double dt, int itr)`
`Simulation(int width, int height, RigidBody[] bodies, double dt, int itr, UpdateListener l)`
`Simulation(int width, int height, RigidBody[] bodies, double dt, int itr, UpdateListener l, String outputDir)`

Method Summary
`void` | `addForce(Simulation.Force f)` Adds a Force object to the set of forces that will be evaluated each iteration.
`void` | `addGravity()` Adds the force of (newtonian) gravity to the simulation.
`void` | `addSurface(Surface s)` Adds the specified Surface object to the surfaces stored by this Simulation object.
`Properties` | `generateProperties()`
`double` | `getAverageLinearVelocity()`
`Image` | `getImage()`
`boolean` | `getLogEachFrame()`
`boolean` | `getRenderEachFrame()`
`Scene` | `getScene()`
`double` | `getTime()`
`void` | `jitter(double t)` Moves all of the rigid bodies stored by this Simulation object by a random amount in the range [-t, t].
`List` | `loadProperties(Properties p)`
`static void` | `main(String[] args)`
`void` | `removeSurface(int index)` Removes the Surface object stored at the specified index from this Simulation object.
`void` | `run()` Runs the simulation.
`void` | `setEditPanel(RigidBodyEditPanel editPanel)` Sets edit RigidBodyEditPanel object stored by this Simulation.
`void` | `setFPS(double fps)` Sets the number of frames to render per second.
`void` | `setLogEachFrame(boolean log)`
`void` | `setRenderEachFrame(boolean render)`
`void` | `setSleepEachFrame(boolean sleep)` Sets the sleep each frame flag.
`void` | `setSurfaces(Surface[] s)` Sets the surfaces stored by this Simulation object.
`void` | `setVDT(double vdt)` If the value of vdt is set to anything greater than 0.0, the time interval for each iteration will be set so that it is the value of vdt divided by the average velocity of the objects in the screen.
`void` | `start()` Calls the run method on this Simulation object.
`void` | `writeEncodeScript(String instance)` Write a sript to be used to compose the output image to form an animation.
`void` | `writeImage(int i, String instance)` Writes the current image to a file that is labeled using the specified values.

Methods inherited from class net.sf.j3d.threeD.raytracer.engine.Scene
`addLight, clone, getCamera, getLight, getLights, getSurface, getSurfaces, removeLight, setCamera, setLights`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### G

    public static final double G

Constructor Detail

### Simulation

    public Simulation()

### Simulation

    public Simulation(int width,
                      int height)

### Simulation

    public Simulation(int width,
                      int height,
                      RigidBody[] bodies,
                      double dt,
                      int itr)

### Simulation

    public Simulation(int width,
                      int height,
                      RigidBody[] bodies,
                      double dt,
                      int itr,
                      UpdateListener l)

### Simulation

    public Simulation(int width,
                      int height,
                      RigidBody[] bodies,
                      double dt,
                      int itr,
                      UpdateListener l,
                      String outputDir)

### Simulation

    public Simulation(int width,
                      int height,
                      double ox,
                      double oy,
                      double scale,
                      RigidBody[] bodies,
                      double dt,
                      int itr,
                      UpdateListener l,
                      String outputDir)

  Constructs a new Simulation object using the specified parameters.

  Parameters:
    `width` - Width of image produced.
    `height` - Height of image produced.
    `ox` - X coordinate of origin.
    `oy` - Y coordinate of origin.
    `scale` - Scale factor.
    `bodies` - Array containing RigidBody objects to use in simulation.
    `dt` - Time interval to use for each iteration of simulation.
    `itr` - Number of iterations to run.
    `l` - UpdateListener instance to update after each iteration (null accepted).
    `outputDir` - Path to directory to write images (null accepted).

Method Detail

### main

    public static void main(String[] args)

### setFPS

    public void setFPS(double fps)

  Sets the number of frames to render per second.

  Parameters:
    `fps` - The number of frames per second.

### setVDT

    public void setVDT(double vdt)

  If the value of vdt is set to anything greater than 0.0, the time interval for each iteration will be set so that it is the value of vdt divided by the average velocity of the objects in the screen.

### getImage

    public Image getImage()

  Returns:
    An AWT Image object storing the most recent image data for this Simulation object.

### getTime

    public double getTime()

  Returns:
    The total time in seconds since the start of the simulation.

### getScene

    public Scene getScene()

  Returns:
    A clone of the superclass of this Simulation object.

### setEditPanel

    public void setEditPanel(RigidBodyEditPanel editPanel)

  Sets edit RigidBodyEditPanel object stored by this Simulation.

  Parameters:
    `editPanel` - RigidBodyEditPanel object to use.

### setSleepEachFrame

    public void setSleepEachFrame(boolean sleep)

  Sets the sleep each frame flag.

  Parameters:
    `sleep` - True if the simulation thread should wait the actual time between frames, false otherwise.

### getRenderEachFrame

    public boolean getRenderEachFrame()

  Returns:
    True if the simulation will render an image for each frame, false otherwise.

### setRenderEachFrame

    public void setRenderEachFrame(boolean render)

  Parameters:
    `render` - True if the simulation should render an image for each frame, false otherwise.

### getLogEachFrame

    public boolean getLogEachFrame()

  Returns:
    True if the simulation will output a properties file for each frame, false otherwise.

### setLogEachFrame

    public void setLogEachFrame(boolean log)

  Parameters:
    `log` - True if the simulation should output a properties file for each frame, false otherwise.

### addForce

    public void addForce(Simulation.Force f)

  Adds a Force object to the set of forces that will be evaluated each iteration.

  Parameters:
    `f` - The Force object to add.

### addGravity

    public void addGravity()

  Adds the force of (newtonian) gravity to the simulation.

### setSurfaces

    public void setSurfaces(Surface[] s)

  Sets the surfaces stored by this Simulation object.

  Overrides:
    `setSurfaces` in class `Scene`
  Throws:
    `IllegalArgumentException` - If any of the Surface objects in the specified array are not instances of RigidBody.

### addSurface

    public void addSurface(Surface s)

  Adds the specified Surface object to the surfaces stored by this Simulation object.

  Overrides:
    `addSurface` in class `Scene`
  Throws:
    `IllegalArgumentException` - If the Surface object specified is not an instance of RigidBody.

### removeSurface

    public void removeSurface(int index)

  Removes the Surface object stored at the specified index from this Simulation object.

  Overrides:
    `removeSurface` in class `Scene`

### jitter

    public void jitter(double t)

  Moves all of the rigid bodies stored by this Simulation object by a random amount in the range [-t, t].

  Parameters:
    `t` - Bounds for jittering.

### getAverageLinearVelocity

    public double getAverageLinearVelocity()

### start

    public void start()

  Calls the run method on this Simulation object.

### run

    public void run()

  Runs the simulation.

  Specified by:
    `run` in interface `Runnable`

### generateProperties

    public Properties generateProperties()

  Returns:
    A Properties object containing all of the data required to reconstruct the current state of the RigidBody objects stored by this Simulation object.

### loadProperties

    public List loadProperties(Properties p)

### writeImage

    public void writeImage(int i,
                           String instance)

  Writes the current image to a file that is labeled using the specified values.

  Parameters:
    `i` - The iteration number of the image.
    `instance` - The instance string for the animation.

### writeEncodeScript

    public void writeEncodeScript(String instance)

  Write a sript to be used to compose the output image to form an animation.

  Parameters:
    `instance` - The instance string for the animation.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD