qaf::CollisionStruct::Polygon Class Reference

#include <qafCollisionStruct.h>

Inheritance diagram for qaf::CollisionStruct::Polygon:

qaf::CollisionStruct List of all members.

Detailed Description

Represents a polygonal collision boundary.

The polygon may be concave and its edges may intersect. You could hardly ask for anything more generic than this, although it is much less efficient than other collision structures.

The polygon defined by points is assumed to be the "untranslated" version of the collision boundary. If this were an hgeSprite, think of the point (0, 0) as the polygon's hot spot.

Typically, you would specify the object's polygon points relative to its sprite's hot spot, and then update the polygon's position to the object's position once per frame.


Public Member Functions

 Polygon (const hgeSprite *pSprite)
 This constructor will create a polygon based on a sprite's width, height, and hotspot.
 Polygon ()
 Default constructor, that creates an "empty" polygon.
void getTransformedPoints (Container< Vector2D > *points)
 Returns the polygon points with scaling/translation applied.
void setPosition (float x, float y)
 Sets the object's displacement relative to (0, 0).
void getPosition (float *x, float *py)
 Gets the object displacement relative to (0, 0).
void setRotation (float radians)
 Sets the object's rotation around its hot spot.
float getRotation ()
 Gets the object's rotation around its hot spot.
void setScale (float s)
 Sets the object's scale.
void getScale ()
 Gets the object's current scale.
void render (float scrollX, float scrollY, unsigned long color)
bool collidesWith (CollisionStruct *otherStruct)
bool hasPoint (float x, float y)
bool pointIntersection (float x1, float y1, float x2, float y2, Vector2D *pContact, Vector2D *pNormal)
void move (float dx, float dy)
void setPoints (const Vector2D *points, int nPoints)
 Redefines the points that represent the polygon's outline.
void setPoints (const Container< Vector2D > &points)
 Redefines the points that represent the polygon's outline.


Constructor & Destructor Documentation

qaf::CollisionStruct::Polygon::Polygon ( const Vector2D points,
int  nPoints 
)

The constructor receives a series of points that represent the polygon's outline.

The polygon is always assumed to be closed (i.e., the last point will be "linked" with the first point).

qaf::CollisionStruct::Polygon::Polygon ( const Container< Vector2D > &  points  ) 

The constructor receives a series of points that represent the polygon's outline.

The polygon is always assumed to be closed (i.e., the last point will be "linked" with the first point).

qaf::CollisionStruct::Polygon::Polygon ( const hgeSprite *  pSprite  ) 

This constructor will create a polygon based on a sprite's width, height, and hotspot.

You can then use it as the bounding box to represent the sprite, even when it's rotated/scaled.

qaf::CollisionStruct::Polygon::Polygon ( const Vector2D points,
int  nPoints 
)

The constructor receives a series of points that represent the polygon's outline.

The polygon is always assumed to be closed (i.e., the last point will be "linked" with the first point).

qaf::CollisionStruct::Polygon::Polygon ( const Container< Vector2D > &  points  ) 

The constructor receives a series of points that represent the polygon's outline.

The polygon is always assumed to be closed (i.e., the last point will be "linked" with the first point).


Member Function Documentation

void qaf::CollisionStruct::Polygon::getTransformedPoints ( Container< Vector2D > *  points  )  [inline]

Returns the polygon points with scaling/translation applied.

See also:
setPoints(), setScale(), setPosition()


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:13 2007 for Qaf Framework by  doxygen 1.5.1-p1