|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.util.LineSegmentPath
public class LineSegmentPath
The line segment path is used to cause a pathable to follow a path that is made up of a sequence of line segments. There must be at least two nodes in any worthwhile path. The direction of the first node in the path is meaningless since the pathable begins at that node and will therefore never be heading towards it.
| Field Summary | |
|---|---|
protected PathNode |
_dest
When moving, the pathable's destination path node. |
protected float |
_fracx
The distance to move on the straight path line per tick. |
protected float |
_fracy
The distance to move on the straight path line per tick. |
protected float |
_incx
When moving, the distance to move on each axis per tick. |
protected float |
_incy
When moving, the distance to move on each axis per tick. |
protected float |
_movex
When moving, the pathable position including fractional pixels. |
protected float |
_movey
When moving, the pathable position including fractional pixels. |
protected Iterator<PathNode> |
_niter
We use this when moving along this path. |
protected ArrayList<PathNode> |
_nodes
The nodes that make up the path. |
protected long |
_nodestamp
The time at which we started traversing the current node. |
protected float |
_seglength
The length in pixels of the current path segment. |
protected PathNode |
_src
When moving, the pathable's source path node. |
protected float |
_vel
The path velocity in pixels per millisecond. |
protected static float |
DEFAULT_VELOCITY
Default pathable velocity. |
| Fields inherited from interface com.threerings.util.DirectionCodes |
|---|
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST |
| Constructor Summary | |
|---|---|
LineSegmentPath()
Constructs an empty line segment path. |
|
LineSegmentPath(int x1,
int y1,
int x2,
int y2)
Constructs a line segment path that consists of a single segment connecting the point (x1, y1) with (x2, y2). |
|
LineSegmentPath(List<Point> points)
Constructs a line segment path with the specified list of points. |
|
LineSegmentPath(Point p1,
Point p2,
int dir)
Construct a line segment path between the two nodes with the specified direction. |
|
| Method Summary | |
|---|---|
void |
addNode(int x,
int y,
int dir)
Add a node to the path with the specified destination point and facing direction. |
protected void |
createPath(List<Point> points)
Populate the path with the path nodes that lead the pathable from its starting position to the given destination coordinates following the given list of screen coordinates. |
void |
fastForward(long timeDelta)
This is called if the pathable is paused for some length of time and then unpaused. |
int |
getFinalOrientation()
Returns the orientation the sprite will face at the end of the path. |
protected PathNode |
getNextNode()
Gets the next node in the path. |
PathNode |
getNode(int idx)
Return the requested node index in the path, or null if no such index exists. |
protected boolean |
headToNextNode(Pathable pable,
long startstamp,
long now)
Place the pathable moving along the path at the end of the previous path node, face it appropriately for the next node, and start it on its way. |
void |
init(Pathable pable,
long timestamp)
Called once to let the path prepare itself for the process of animating the supplied pathable. |
void |
paint(Graphics2D gfx)
Paint this path on the screen (used for debugging purposes only). |
void |
setDuration(long millis)
Computes the velocity at which the pathable will need to travel along this path such that it will arrive at the destination in approximately the specified number of milliseconds. |
void |
setVelocity(float velocity)
Sets the velocity of this pathable in pixels per millisecond. |
int |
size()
Return the number of nodes in the path. |
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. |
String |
toString()
|
void |
wasRemoved(Pathable pable)
When a path is removed from a pathable, whether that is because the path was completed or because it was replaced by another path, this method will be called to let the path know that it is no longer associated with this pathable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ArrayList<PathNode> _nodes
protected Iterator<PathNode> _niter
protected PathNode _src
protected PathNode _dest
protected long _nodestamp
protected float _seglength
protected float _vel
protected float _movex
protected float _movey
protected float _incx
protected float _incy
protected float _fracx
protected float _fracy
protected static final float DEFAULT_VELOCITY
| Constructor Detail |
|---|
public LineSegmentPath()
public LineSegmentPath(int x1,
int y1,
int x2,
int y2)
(x1, y1) with (x2, y2). The orientation for the first node is set
arbitrarily and the second node is oriented based on the vector between the two nodes (in
top-down coordinates).
public LineSegmentPath(Point p1,
Point p2,
int dir)
public LineSegmentPath(List<Point> points)
| Method Detail |
|---|
public int getFinalOrientation()
public void addNode(int x,
int y,
int dir)
x - the x-position.y - the y-position.dir - the facing direction.public PathNode getNode(int idx)
idx - the node index.
public int size()
public void setVelocity(float velocity)
velocity - the pathable velocity in pixels per millisecond.public void setDuration(long millis)
public void init(Pathable pable,
long timestamp)
PathPath.tick(com.threerings.media.util.Pathable, long) after Path.init(com.threerings.media.util.Pathable, long) with the same
initialization timestamp.
init in interface Path
public boolean tick(Pathable pable,
long timestamp)
Path
tick in interface Pathpable - the pathable whose position should be updated.timestamp - the timestamp associated with this frame.
public void fastForward(long timeDelta)
Path
fastForward in interface Pathpublic void wasRemoved(Pathable pable)
Path
wasRemoved in interface Path
protected boolean headToNextNode(Pathable pable,
long startstamp,
long now)
public void paint(Graphics2D gfx)
Path
paint in interface Pathpublic String toString()
toString in class Objectprotected void createPath(List<Point> points)
protected PathNode getNextNode()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||