cs5643.rigidbody
Class RigidImageSimulation

java.lang.Object
  extended by cs5643.rigidbody.RigidImageSimulation
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.media.opengl.GLEventListener

public class RigidImageSimulation
extends java.lang.Object
implements javax.media.opengl.GLEventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

CS5643: Assignment #3 "Rigid Body Contact" main class. RigidImageSimulation simulates rigid bodies derived from an image's connected nonwhite components.


Field Summary
(package private)  boolean drawBounds
          Draws object bounds (Disk) if true.
(package private)  boolean drawWireframe
          Draws wireframe if true, and pixel blocks if false.
static double DT
          Size of symplectic Euler time step (in seconds).
(package private)  javax.swing.JFrame frame
          Main window frame.
(package private)  cs5643.rigidbody.RigidImageSimulation.FrameExporter frameExporter
          Reference to current FrameExporter, or null if no frames being dumped.
(package private)  JellyBeanFactory jellyBeanFactory
          Non-null reference when simulating the "Jelly Bean Factory" images.
(package private)  boolean largeStep
          If true, instead of one step per frame, simulator takes N_STEPS_PER_FRAME.
(package private) static int N_STEPS_PER_FRAME
          Number of time steps per large step size.
(package private)  RigidBodySystem RBS
          The single RigidBodySystem reference.
(package private)  boolean simulate
          Toggle to advance simulation.
 
Constructor Summary
RigidImageSimulation(java.lang.String imageFilename, boolean processCollisions)
          Main constructor.
 
Method Summary
(package private)  void advanceTime(double dt)
           
 void dispatchKey(char key, java.awt.event.KeyEvent e)
          Handles keyboard events, e.g., spacebar toggles simulation/pausing, and escape resets the current Task.
 void display(javax.media.opengl.GLAutoDrawable drawable)
          Main event loop: OpenGL display + simulation advance.
 void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          GLEventListener implementation
 javax.vecmath.Point2d getPoint2d(java.awt.event.MouseEvent e)
          Maps mouse event into computational cell using OrthoMap.
 void init(javax.media.opengl.GLAutoDrawable drawable)
          GLEventListener implementation: Initializes JOGL renderer.
static void main(java.lang.String[] args)
          ### Runs the RigidImageSimulation.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
          GLEventListener implementation
(package private)  void simulateAndDisplayScene(javax.media.opengl.GL gl)
          Simulate then display particle system and any builder adornments.
 void start()
          Builds and shows window, and starts simulator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frameExporter

cs5643.rigidbody.RigidImageSimulation.FrameExporter frameExporter
Reference to current FrameExporter, or null if no frames being dumped.


N_STEPS_PER_FRAME

static int N_STEPS_PER_FRAME
Number of time steps per large step size.


DT

public static double DT
Size of symplectic Euler time step (in seconds). You may want to change this, but watch out for interpenetrations at high linear/angular speeds!


frame

javax.swing.JFrame frame
Main window frame.


RBS

RigidBodySystem RBS
The single RigidBodySystem reference.


simulate

boolean simulate
Toggle to advance simulation.


drawWireframe

boolean drawWireframe
Draws wireframe if true, and pixel blocks if false.


drawBounds

boolean drawBounds
Draws object bounds (Disk) if true.


largeStep

boolean largeStep
If true, instead of one step per frame, simulator takes N_STEPS_PER_FRAME.


jellyBeanFactory

JellyBeanFactory jellyBeanFactory
Non-null reference when simulating the "Jelly Bean Factory" images.

Constructor Detail

RigidImageSimulation

RigidImageSimulation(java.lang.String imageFilename,
                     boolean processCollisions)
               throws java.io.IOException
Main constructor. Call start() to begin simulation.

Parameters:
imageFilename - Image to simulate.
processCollisions - Enables collisions if true.
Throws:
java.io.IOException
Method Detail

start

public void start()
Builds and shows window, and starts simulator.


getPoint2d

public javax.vecmath.Point2d getPoint2d(java.awt.event.MouseEvent e)
Maps mouse event into computational cell using OrthoMap.


init

public void init(javax.media.opengl.GLAutoDrawable drawable)
GLEventListener implementation: Initializes JOGL renderer.

Specified by:
init in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
GLEventListener implementation

Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

reshape

public void reshape(javax.media.opengl.GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
GLEventListener implementation

Specified by:
reshape in interface javax.media.opengl.GLEventListener

display

public void display(javax.media.opengl.GLAutoDrawable drawable)
Main event loop: OpenGL display + simulation advance. GLEventListener implementation.

Specified by:
display in interface javax.media.opengl.GLEventListener

simulateAndDisplayScene

void simulateAndDisplayScene(javax.media.opengl.GL gl)
Simulate then display particle system and any builder adornments.


advanceTime

void advanceTime(double dt)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

dispatchKey

public void dispatchKey(char key,
                        java.awt.event.KeyEvent e)
Handles keyboard events, e.g., spacebar toggles simulation/pausing, and escape resets the current Task.


main

public static void main(java.lang.String[] args)
### Runs the RigidImageSimulation. ###