org.starhope.appius.physica
Class CollisionObject

java.lang.Object
  extended by org.starhope.appius.physica.CollisionObject
All Implemented Interfaces:
Collidable

public final class CollisionObject
extends Object
implements Collidable

A generic collision object. Used primarily for 'rewinding' objects when they collide so that the true point of collision can be found

Author:
ewinkelman

Field Summary
private  Coord2D centerofMass
          Object's center of mass
private  boolean changed
          Determines if this object has changed since the last reset
private  PolygonPrimitive<?> collisionBounds
          Object's collision boundaries
private  double mass
          Object's mass
private  long moveEndTime
          The time the object will stop moving
private  long moveStartTime
          The time the object started moving
private  long referenceTime
          The current time index for this snapshot
private  Vector2D velocity
          Object's velocity
 
Constructor Summary
CollisionObject(Collidable obj, long currentTime)
          WRITEME: Document this constructor
 
Method Summary
 boolean changed()
          Gets the current moved status
 Coord2D getCenterOfMass()
          Gets the object's current center of mass in world coordinates
 PolygonPrimitive<?> getCollisionBounds()
          Gets the collision boundaries for the object
 long getEndMovementTime(long currentTime)
           
 double getMass()
          Gets the mass of the collidable object
 long getStartMovementTime()
           
 Vector2D getVelocity()
          Gets the object's current velocity
 void move(long milliseconds)
          Moves the object forward/backwards by x milliseconds Also watches for objects that start/stop
 void reset()
          Resets the moved flag
 void setCenterOfMass(Coord2D com)
          Sets the center of mass
 void setVelocity(Vector2D newVelocity)
          Sets the object's new velocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

centerofMass

private Coord2D centerofMass
Object's center of mass


collisionBounds

private PolygonPrimitive<?> collisionBounds
Object's collision boundaries


mass

private final double mass
Object's mass


moveStartTime

private final long moveStartTime
The time the object started moving


moveEndTime

private final long moveEndTime
The time the object will stop moving


referenceTime

private long referenceTime
The current time index for this snapshot


velocity

private Vector2D velocity
Object's velocity


changed

private boolean changed
Determines if this object has changed since the last reset

Constructor Detail

CollisionObject

public CollisionObject(Collidable obj,
                       long currentTime)
WRITEME: Document this constructor

Parameters:
obj - WRITEME
currentTime - WRITEME
Method Detail

changed

public boolean changed()
Gets the current moved status

Returns:
WRITEME

getCenterOfMass

public Coord2D getCenterOfMass()
Description copied from interface: Collidable
Gets the object's current center of mass in world coordinates

Specified by:
getCenterOfMass in interface Collidable
Returns:
A 2D point representing the center of mass
See Also:
Collidable.getCenterOfMass()

getCollisionBounds

public PolygonPrimitive<?> getCollisionBounds()
Description copied from interface: Collidable
Gets the collision boundaries for the object

Specified by:
getCollisionBounds in interface Collidable
Returns:
A polygon outlining the boundaries of the object
See Also:
Collidable.getCollisionBounds()

getEndMovementTime

public long getEndMovementTime(long currentTime)
Specified by:
getEndMovementTime in interface Collidable
Parameters:
currentTime - The current time
Returns:
the time the object will stop moving
See Also:
Collidable.getEndMovementTime(long)

getMass

public double getMass()
Description copied from interface: Collidable
Gets the mass of the collidable object

Specified by:
getMass in interface Collidable
Returns:
Mass
See Also:
Collidable.getMass()

getStartMovementTime

public long getStartMovementTime()
Specified by:
getStartMovementTime in interface Collidable
Returns:
the time the object started moving
See Also:
Collidable.getStartMovementTime()

getVelocity

public Vector2D getVelocity()
Description copied from interface: Collidable
Gets the object's current velocity

Specified by:
getVelocity in interface Collidable
Returns:
A 2D velocity vector
See Also:
Collidable.getVelocity()

move

public void move(long milliseconds)
Moves the object forward/backwards by x milliseconds Also watches for objects that start/stop

Parameters:
milliseconds - WRITEME

reset

public void reset()
Resets the moved flag


setCenterOfMass

public void setCenterOfMass(Coord2D com)
Sets the center of mass

Specified by:
setCenterOfMass in interface Collidable
Parameters:
com - New center of mass in world coordinates
See Also:
Collidable.setCenterOfMass(Coord2D)

setVelocity

public void setVelocity(Vector2D newVelocity)
Description copied from interface: Collidable
Sets the object's new velocity

Specified by:
setVelocity in interface Collidable
Parameters:
newVelocity - WRITEME
See Also:
Collidable.setVelocity(Vector2D)