com.threerings.media.util
Class ArcPath

java.lang.Object
  extended by com.threerings.media.util.TimedPath
      extended by com.threerings.media.util.ArcPath
All Implemented Interfaces:
Path

public class ArcPath
extends TimedPath

The line path is used to cause a pathable to go from point A to point B along the arc of an ellipse in a certain number of milliseconds.


Field Summary
protected  Point _center
          The center of our ellipse.
protected  double _delta
          Our starting and delta angles.
protected  int _orient
          The method to be used to orient the pathable.
protected  int _orientOffset
          An orientation offset used when orienting our pathable.
protected  double _sangle
          Our starting and delta angles.
protected  Point _tpos
          A temporary point used when computing our position along the path.
protected  double _xradius
          Our ellipse radii.
protected  double _yradius
          Our ellipse radii.
static int FINE
          An orientation constant indicating that the fine (sixteen) directions should be used to orient the pathable being made to follow this path.
static int NONE
          An orientation indicating that the pathable should not be oriented as it moves along the path.
static int NORMAL
          An orientation constant indicating that the normal (eight) directions should be used to orient the pathable being made to follow this path.
 
Fields inherited from class com.threerings.media.util.TimedPath
_duration, _startStamp
 
Constructor Summary
ArcPath(Point start, double xradius, double yradius, double sangle, double delta, long duration, int orient)
          Creates an arc path that will animate a pathable from the specified starting position along an ellipse defined by the supplied parameters.
 
Method Summary
static void computePosition(Point center, double xradius, double yradius, double angle, Point pos)
          Computes the position of an entity along the path defined by the supplied parameters assuming that it must finish the path in the specified duration (in millis) and has been traveling the path for the specified number of elapsed milliseconds.
 Point getEndPos()
          Returns the position of the end of the path.
 Path getTranslatedInstance(int x, int y)
          Return a copy of the path, translated by the specified amounts.
 void paint(Graphics2D gfx)
          Paint this path on the screen (used for debugging purposes only).
 void setOrientOffset(int offset)
          Sets the offset that is applied to the pathable whenever it is oriented.
 boolean tick(Pathable pable, long timestamp)
          Called to request that this path update the position of the specified pathable based on the supplied timestamp information.
protected  void toString(StringBuilder buf)
          An extensible method for generating a string representation of this instance.
 
Methods inherited from class com.threerings.media.util.TimedPath
fastForward, init, toString, wasRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
An orientation constant indicating that the normal (eight) directions should be used to orient the pathable being made to follow this path.

See Also:
Constant Field Values

FINE

public static final int FINE
An orientation constant indicating that the fine (sixteen) directions should be used to orient the pathable being made to follow this path.

See Also:
Constant Field Values

NONE

public static final int NONE
An orientation indicating that the pathable should not be oriented as it moves along the path.

See Also:
Constant Field Values

_center

protected Point _center
The center of our ellipse.


_xradius

protected double _xradius
Our ellipse radii.


_yradius

protected double _yradius
Our ellipse radii.


_sangle

protected double _sangle
Our starting and delta angles.


_delta

protected double _delta
Our starting and delta angles.


_orient

protected int _orient
The method to be used to orient the pathable.


_orientOffset

protected int _orientOffset
An orientation offset used when orienting our pathable.


_tpos

protected Point _tpos
A temporary point used when computing our position along the path.

Constructor Detail

ArcPath

public ArcPath(Point start,
               double xradius,
               double yradius,
               double sangle,
               double delta,
               long duration,
               int orient)
Creates an arc path that will animate a pathable from the specified starting position along an ellipse defined by the supplied parameters. The pathable will travel the specified number of radians along the arc of that ellipse. A positive number of radians indicates counter-clockwise travel along the circle, a negative number, clockwise rotation.

Parameters:
start - the starting point for the pathable.
xradius - the length of the x radius.
yradius - the length of the y radius.
sangle - the starting angle.
delta - the angle through which the pathable should be moved.
duration - the number of milliseconds during which to effect the animation.
orient - an orientation code indicating how the pathable should be oriented when following the path, either NORMAL, or FINE.
Method Detail

getTranslatedInstance

public Path getTranslatedInstance(int x,
                                  int y)
Return a copy of the path, translated by the specified amounts.


setOrientOffset

public void setOrientOffset(int offset)
Sets the offset that is applied to the pathable whenever it is oriented. This offset is in clockwise units whose granularity is specified by the NORMAL or FINE setting supplied to the path at construct time. The intent here is to allow arc paths to be applied that don't orient the pathable in the direction they are traveling but instead in some fixed offset from that direction.


getEndPos

public Point getEndPos()
Returns the position of the end of the path.


tick

public boolean tick(Pathable pable,
                    long timestamp)
Description copied from interface: Path
Called to request that this path update the position of the specified pathable based on the supplied timestamp information. A path should record its initial timestamp and determine the progress of the pathable along the path based on the time elapsed since the pathable began down the path.

Parameters:
pable - the pathable whose position should be updated.
timestamp - the timestamp associated with this frame.
Returns:
true if the pathable's position was updated, false if the path determined that the pathable should not move at this time.

paint

public void paint(Graphics2D gfx)
Description copied from interface: Path
Paint this path on the screen (used for debugging purposes only).


toString

protected void toString(StringBuilder buf)
Description copied from class: TimedPath
An extensible method for generating a string representation of this instance.

Overrides:
toString in class TimedPath

computePosition

public static void computePosition(Point center,
                                   double xradius,
                                   double yradius,
                                   double angle,
                                   Point pos)
Computes the position of an entity along the path defined by the supplied parameters assuming that it must finish the path in the specified duration (in millis) and has been traveling the path for the specified number of elapsed milliseconds.