com.threerings.tudey.shape
Class Shape

java.lang.Object
  extended by com.threerings.tudey.shape.Shape
Direct Known Subclasses:
Capsule, Circle, Compound, Global, None, Point, Polygon, Segment

public abstract class Shape
extends Object

A Tudey shape.


Nested Class Summary
static class Shape.IntersectionType
          Intersection types indicating that the shape does not intersect, intersects, or fully contains, respectively, the parameter.
 
Constructor Summary
Shape()
           
 
Method Summary
abstract  ShapeConfig createConfig()
          Creates a config corresponding to this shape.
abstract  void draw(boolean outline)
          Draws this shape in immediate mode.
 Shape expand(float amount)
          Expands this shape by the specified amount.
abstract  Shape expand(float amount, Shape result)
          Expands this shape, placing the result in the provided object if possible.
 Shape expandLocal(float amount)
          Expands this shape in-place by the specified amount.
 Rect getBounds()
          Returns a reference to the bounds of the shape.
 Vector2f getCenter()
          Retrieves the center of the shape.
abstract  Vector2f getCenter(Vector2f result)
          Retrieves the center of the shape and places it in the supplied vector.
abstract  boolean getIntersection(Ray2D ray, Vector2f result)
          Finds the intersection of a ray with this shape and places it in the supplied vector (if it exists).
abstract  Shape.IntersectionType getIntersectionType(Rect rect)
          Checks whether the intersector intersects the specified rect.
abstract  void getNearestPoint(Vector2f point, Vector2f result)
          Fins the nearest point of this element to the supplied point and places it in the supplied vector.
abstract  Vector2f getPenetration(Capsule capsule, Vector2f result)
          Finds the penetration of the specified capsule into this shape.
abstract  Vector2f getPenetration(Circle circle, Vector2f result)
          Finds the penetration of the specified circle into this shape.
abstract  Vector2f getPenetration(Compound compound, Vector2f result)
          Finds the penetration of the specified compound into this shape.
 Vector2f getPenetration(None none, Vector2f result)
          Shapes never penetrate none.
abstract  Vector2f getPenetration(Point point, Vector2f result)
          Finds the penetration of the specified point into this shape.
abstract  Vector2f getPenetration(Polygon polygon, Vector2f result)
          Finds the penetration of the specified polygon into this shape.
abstract  Vector2f getPenetration(Segment segment, Vector2f result)
          Finds the penetration of the specified segment into this shape.
abstract  Vector2f getPenetration(Shape shape, Vector2f result)
          Finds the penetration of the specified shape into this one, assuming that they intersect.
 Vector2f[] getPerimeterPath()
          Returns a perimeter path for this shape.
abstract  boolean intersects(Capsule capsule)
          Checks for an intersection with this shape and the specified capsule.
abstract  boolean intersects(Circle circle)
          Checks for an intersection with this shape and the specified circle.
abstract  boolean intersects(Compound compound)
          Checks for an intersection with this shape and the specified compound.
 boolean intersects(None none)
          Shapes can never intserct none.
abstract  boolean intersects(Point point)
          Checks for an intersection with this shape and the specified point.
abstract  boolean intersects(Polygon polygon)
          Checks for an intersection with this shape and the specified polygon.
abstract  boolean intersects(Segment segment)
          Checks for an intersection with this shape and the specified segment.
abstract  boolean intersects(Shape shape)
          Determines whether this shape intersects the specified shape.
abstract  boolean intersects(SpaceElement element)
          Determines whether this shape intersects the specified element.
 Shape sweep(Vector2f translation)
          Computes the shape created by sweeping this shape along the specified translation vector.
abstract  Shape sweep(Vector2f translation, Shape result)
          Computes the shape created by sweeping this shape along the specified translation vector, placing the result in the provided object if possible.
 Shape transform(Transform2D transform)
          Transforms this shape.
abstract  Shape transform(Transform2D transform, Shape result)
          Transforms this shape, placing the result in the provided object if possible.
 Shape transformLocal(Transform2D transform)
          Transforms this shape in-place.
abstract  void updateBounds()
          Updates the bounds of the shape.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shape

public Shape()
Method Detail

getBounds

public Rect getBounds()
Returns a reference to the bounds of the shape.


updateBounds

public abstract void updateBounds()
Updates the bounds of the shape.


getCenter

public Vector2f getCenter()
Retrieves the center of the shape.

Returns:
a new vector containing the result.

getCenter

public abstract Vector2f getCenter(Vector2f result)
Retrieves the center of the shape and places it in the supplied vector.

Returns:
a reference to the result vector, for chaining.

transformLocal

public Shape transformLocal(Transform2D transform)
Transforms this shape in-place.

Returns:
a reference to this shape, for chaining.

transform

public Shape transform(Transform2D transform)
Transforms this shape.

Returns:
a new shape containing the result.

transform

public abstract Shape transform(Transform2D transform,
                                Shape result)
Transforms this shape, placing the result in the provided object if possible.

Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

expandLocal

public Shape expandLocal(float amount)
Expands this shape in-place by the specified amount.

Returns:
a reference to this shape, for chaining.

expand

public Shape expand(float amount)
Expands this shape by the specified amount.

Returns:
a new shape containing the result.

expand

public abstract Shape expand(float amount,
                             Shape result)
Expands this shape, placing the result in the provided object if possible.

Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

sweep

public Shape sweep(Vector2f translation)
Computes the shape created by sweeping this shape along the specified translation vector.

Returns:
a new shape containing the result.

sweep

public abstract Shape sweep(Vector2f translation,
                            Shape result)
Computes the shape created by sweeping this shape along the specified translation vector, placing the result in the provided object if possible.

Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

getPerimeterPath

public Vector2f[] getPerimeterPath()
Returns a perimeter path for this shape.


getIntersection

public abstract boolean getIntersection(Ray2D ray,
                                        Vector2f result)
Finds the intersection of a ray with this shape and places it in the supplied vector (if it exists).

Returns:
true if the ray intersected the shape (in which case the result will contain the point of intersection), false otherwise.

getNearestPoint

public abstract void getNearestPoint(Vector2f point,
                                     Vector2f result)
Fins the nearest point of this element to the supplied point and places it in the supplied vector.


getIntersectionType

public abstract Shape.IntersectionType getIntersectionType(Rect rect)
Checks whether the intersector intersects the specified rect.


intersects

public abstract boolean intersects(SpaceElement element)
Determines whether this shape intersects the specified element. Uses double-dispatch to invoke the appropriate specialization of SpaceElement.intersects(com.threerings.tudey.shape.Point).


intersects

public abstract boolean intersects(Shape shape)
Determines whether this shape intersects the specified shape. Uses double-dispatch to invoke the appropriate method specialization.


intersects

public abstract boolean intersects(Point point)
Checks for an intersection with this shape and the specified point.


intersects

public abstract boolean intersects(Segment segment)
Checks for an intersection with this shape and the specified segment.


intersects

public abstract boolean intersects(Circle circle)
Checks for an intersection with this shape and the specified circle.


intersects

public abstract boolean intersects(Capsule capsule)
Checks for an intersection with this shape and the specified capsule.


intersects

public abstract boolean intersects(Polygon polygon)
Checks for an intersection with this shape and the specified polygon.


intersects

public abstract boolean intersects(Compound compound)
Checks for an intersection with this shape and the specified compound.


intersects

public boolean intersects(None none)
Shapes can never intserct none.


getPenetration

public abstract Vector2f getPenetration(Shape shape,
                                        Vector2f result)
Finds the penetration of the specified shape into this one, assuming that they intersect. The penetration vector represents the minimum translation required to separate the two shapes. Uses double-dispatch to invoke the appropriate method specialization.

Returns:
a reference to the result vector, for chaining.

getPenetration

public abstract Vector2f getPenetration(Point point,
                                        Vector2f result)
Finds the penetration of the specified point into this shape.


getPenetration

public abstract Vector2f getPenetration(Segment segment,
                                        Vector2f result)
Finds the penetration of the specified segment into this shape.


getPenetration

public abstract Vector2f getPenetration(Circle circle,
                                        Vector2f result)
Finds the penetration of the specified circle into this shape.


getPenetration

public abstract Vector2f getPenetration(Capsule capsule,
                                        Vector2f result)
Finds the penetration of the specified capsule into this shape.


getPenetration

public abstract Vector2f getPenetration(Polygon polygon,
                                        Vector2f result)
Finds the penetration of the specified polygon into this shape.


getPenetration

public abstract Vector2f getPenetration(Compound compound,
                                        Vector2f result)
Finds the penetration of the specified compound into this shape.


getPenetration

public Vector2f getPenetration(None none,
                               Vector2f result)
Shapes never penetrate none.


draw

public abstract void draw(boolean outline)
Draws this shape in immediate mode.

Parameters:
outline - if true, draw the outline of the shape; otherwise, the solid form.

createConfig

public abstract ShapeConfig createConfig()
Creates a config corresponding to this shape.



Copyright © 2011. All Rights Reserved.