hgePolygon Class Reference

Polygon Class. More...

#include <hgePolygon.h>

Inheritance diagram for hgePolygon:

hgeShape hgeEntity hgeEntityEx

List of all members.

Public Member Functions

void Load (hgeResourceReader *file)
virtual void Render ()
void RenderOutline ()
bool IsPoint ()
bool IsPoly ()
bool IsEntity ()
void Copy (hgePolygon *)
void SetMap (hgePolygonMap *m_Map)
hgeIntersect Intersects (hgeCircle circle, hgeVector offset=hgeVector(0, 0))
hgeIntersect Intersects (hgeCircle *circle, hgeVector offset=hgeVector(0, 0))
hgeIntersect Intersects (hgeLine line, hgeVector offset=hgeVector(0, 0))
hgeIntersect Intersects (hgeLine *line, hgeVector offset=hgeVector(0, 0))
hgeIntersect Intersects (hgePolygon *p, hgeVector offset=hgeVector(0, 0))
hgeIntersect Intersects (hgeEntityEx *p, hgeVector offset=hgeVector(0, 0), float rot=0)
hgeTriangle * TestGetTriangle (hgeVector point)
bool TestPoint (hgeVector point)
hgeSprite * GetSprite ()
hgeRect GetAABB ()
hgeVector GetCenter ()
void SetAABBSize (hgeVector m_size)
void SetAABB (hgeVector m_position, hgeVector m_size)
void SetTexture (HTEXTURE m_texture, int m_blend=-1)
void SetHotSpot (hgeVector m_hotspot)
hgeVector GetHotSpot ()
void Shift (hgeVector amount)
hgeVector GetPosition ()
void SetPosition (hgeVector pos)
hgePVertexAddVertex (hgeVector pos)
void RemoveVertex (hgePVertex *which)
void ClearVertices ()
int VertexCount ()
 hgePolygon (class hgePolygonMap *pmap=NULL)

Public Attributes

std::vector< hgePVertex * > vertices
std::vector< hgeTriangle * > triangles
hgePolyData texture_data
hgeProperties entity_data

Protected Attributes

bool is_entity
hgeRect aabb
hgeVector center
hgeSprite * sprite
HGE * hge
class hgePolygonMapmap


Detailed Description

polygon.jpg

A Polygon.

The polygon class stores all of an individual polygons information.

This includes a hgePVertex array, a hgeTriangle array, arrays of quads & triangles that make up its geometry, the axis aligned bounding box (AABB) that surrounds the shape, and the entity data associated with the polygon.

The class also provides intersection routines for various shapes.

If a polygon has only a single vertex, it is regarded as a point entity, then its AABB determines its size as a box and is used in collision testing against the shape. The functions IsPoint() and IsPoly() can be used to determine the nature of a polygon. Point polygons render a sprite instead of a polygonal shape.


Member Function Documentation

void hgePolygon::Copy ( hgePolygon poly  ) 

Copies another polygon. Used by the map class when registering polygons, end users should rarely need to use this.

hgeRect hgePolygon::GetAABB (  )  [inline]

Returns the AABB surrounding the polygon.

hgeVector hgePolygon::GetCenter (  )  [inline]

Returns the center point of the AABB surrounding the polygon.

hgeVector hgePolygon::GetHotSpot (  )  [inline]

Returns hot spot vector.

hgeVector hgePolygon::GetPosition (  )  [inline]

Fetches the position of a polygon. Usually the top left coordinate of its AABB.

Remarks:
If a hotspot was set, returns the location of the hotspot in world coordinates.
See also:
SetPosition() | SetHotSpot()

Reimplemented in hgeEntityEx.

hgeSprite* hgePolygon::GetSprite (  )  [inline]

Returns the point sprite.

bool hgePolygon::IsEntity (  )  [inline]

Can polygon be cast up to a hgeEntity?

bool hgePolygon::IsPoint (  )  [inline]

Does polygon contain only a single vertex?

bool hgePolygon::IsPoly (  )  [inline]

Is polygon made up of multiple vertices?

void hgePolygon::Render (  )  [virtual]

Renders the polygon.

Reimplemented in hgeEntity.

void hgePolygon::RenderOutline (  ) 

Renders the outline of a polygon, or the AABB if it is a point.

Remarks:
Must be called during Render()

void hgePolygon::SetAABB ( hgeVector  m_position,
hgeVector  m_size 
) [inline]

Sets AABB Position & Size.

Remarks:
Position must be given in world coordinates.

void hgePolygon::SetAABBSize ( hgeVector  m_size  )  [inline]

Sets AABB Size.

void hgePolygon::SetHotSpot ( hgeVector  m_hotspot  )  [inline]

Sets hot spot for transform operations.

Parameters:
m_hotspot Vector describing the offset from the top left hand corner of the AABB
The hot spot is used by translation routines in the polygon, such as SetPosition().
It works in the same way a hotspot does in a hgeSprite - it is an offset from the top left hand corner of the shape.

Reimplemented in hgeEntityEx.

void hgePolygon::SetMap ( hgePolygonMap m_Map  )  [inline]

Sets the polygons internal map reference. Used by the map class when registering polygons, end users should rarely need to use this.

void hgePolygon::SetPosition ( hgeVector  pos  )  [inline]

Sets the position of a polygon. Usually the top left coordinate of its AABB.

Remarks:
If a hotspot was set, the position is offset to match.
See also:
GetPosition() | SetHotSpot()

Reimplemented in hgeEntityEx.

void hgePolygon::SetTexture ( HTEXTURE  m_texture,
int  m_blend = -1 
)

Sets the polygons current texture.

Parameters:
m_texture HTEXTURE handle to use.
m_blend Optional HGEBLEND_ mode.

void hgePolygon::Shift ( hgeVector  amount  ) 

Moves polygon from its current position by a certain amount.

Remarks:
Shifts all of the polygons attributes, including vertices, triangles, quads, triangles & aabb.
See also:
SetPosition

Reimplemented in hgeEntityEx.

hgeTriangle * hgePolygon::TestGetTriangle ( hgeVector  point  ) 

Fetches a triangle from the polygon at given point.

Parameters:
point Point to test.
Returns:
Pointer to hgeTriangle, or NULL.

bool hgePolygon::TestPoint ( hgeVector  point  )  [inline]

Simple boolean collision test at given point.

Returns:
True if a polygon is found at given point.


Member Data Documentation

hgeRect hgePolygon::aabb [protected]

Axis-Aligned Bounding Box (AABB).

hgeVector hgePolygon::center [protected]

Center point of AABB.

hgeProperties hgePolygon::entity_data

Entity Properties data - contains any entity data set in the polygon editor.

HGE* hgePolygon::hge [protected]

HGE Interface.

bool hgePolygon::is_entity [protected]

Determines whether it is safe to cast this to a hgeEntity.

class hgePolygonMap* hgePolygon::map [protected]

Map Reference.

hgeSprite* hgePolygon::sprite [protected]

Point entity sprite.

Texturing + Style data - whether or not its bordered, border heights, texture stretch, etc.

std::vector<hgeTriangle *> hgePolygon::triangles

Array of triangles that make up the polygon.

Array of vertices that make up the polygon, in clockwise order.


Generated on Wed Apr 29 12:56:50 2009 for Opal by  doxygen 1.5.8