CL_CollisionOutline Class Reference
[clanDisplay Collision]

Collision detection outline. More...

#include <collision_outline.h>

List of all members.

Attributes

const CL_Contourget_object_bounding_box () const
 Returns the contour used as an object bounding box. (an rotated rectangle).
CL_Circlef get_minimum_enclosing_disc () const
 Returns the radius of the outline.
bool get_inside_test () const
 Returns true if completely-inside test is used.
std::vector< CL_Contour > & get_contours ()
 Returns the contours in the outline.
const std::vector< CL_Contour > & get_contours () const
CL_Pointf get_translation () const
 Returns the position of the outline.
CL_Pointf get_scale () const
 Returns the scaling factor.
float get_angle () const
 Returns the rotation angle.
unsigned int get_width () const
 Returns the width of the image this outline was created from.
unsigned int get_height () const
 Returns the height of the image this outline was created from.
void get_alignment (CL_Origin &origin, float &x, float &y) const
 Get the translation origin and hotspot of the outline.
void get_rotation_hotspot (CL_Origin &origin, float &x, float &y) const
 Get the rotation hotspot of the outline.
const std::vector< CL_CollidingContours > & get_collision_info () const
 Return the info about the collisions. (collision points, normals, pointers to contours, and indexes to lines that intersected).
void get_collision_info_state (bool &points, bool &normals, bool &metadata, bool &pendepth) const
 Fetch the state of the collision testing variables.
CL_Resource resource
 Resource owning this outline, if any.

Operations

void load (const CL_StringRef &fullname)
 Load the outline from file replacing the current data.
void load (const CL_StringRef &filename, const CL_VirtualDirectory &directory)
 Load.
void load (CL_IODevice &file)
 Load.
CL_CollisionOutlinecopy (const CL_CollisionOutline &other)
 Copy.
void optimize (unsigned char check_distance=3, float corner_angle=CL_PI/5.0)
 Optimize the outline by removing redundant points.
void draw (float x, float y, const CL_Colorf &color, CL_GraphicContext &gc)
 Draw outline on graphic context.
void draw_sub_circles (float x, float y, const CL_Colorf &color, CL_GraphicContext &gc)
 Draw the subcircles surrounding the linesegments on graphic context.
void draw_smallest_enclosing_disc (float x, float y, const CL_Colorf &color, CL_GraphicContext &gc)
 Draw the disc enclosing the entire outline.
void set_alignment (CL_Origin origin, float x=0, float y=0)
 Set the translation hotspot of the outline.
void set_rotation_hotspot (CL_Origin origin, float x=0, float y=0)
 Set the rotation hotspot of the outline.
void set_translation (float x, float y)
 Set the position of the outline.
void set_scale (float x, float y)
 Set the scale of the outline.
void set_angle (const CL_Angle &angle)
 Set the angle (in degrees) of the outline.
void rotate (const CL_Angle &angle)
 Rotate the outline by angle (in degrees).
void set_inside_test (bool value)
 Set to true if completely-inside test should be done.
void enable_collision_info (bool points=true, bool normals=false, bool metadata=false, bool pen_depth=false)
 Enable collision info gathering.
void set_collision_info (const std::vector< CL_CollidingContours > &colinfo)
 This will set the collision info of the outline.
void clean_collision_info ()
 This will empty the collision-info vector.
void calculate_radius ()
 (Re)calculate the radius of the outline.
void calculate_sub_circles (float radius_multiplier=3.5)
 (Re)calculate the subcircle segmentation of the outline.
void calculate_smallest_enclosing_discs ()
 (Re)calculate the smallest circles enclosing every contour in the outline.
void calculate_convex_hulls ()
 (Re)calculate the convex hull for every contour in the outline
void save (const CL_StringRef &fullname) const
 Write the outline to a file.
void save (const CL_StringRef &filename, CL_VirtualDirectory &directory) const
 Save.
void save (CL_IODevice &file) const
 Save.
bool collide (const CL_CollisionOutline &outline, bool remove_old_collision_info=true)
 Returns true if outlines overlap.
bool point_inside (const CL_Pointf &point) const
 Returns true if a point is inside the outline.
static void calculate_penetration_depth (std::vector< CL_CollidingContours > &collision_info)
 Will calculate the penetration_depth and penetration_normal for all colliding contours.

Public Member Functions

Construction
 CL_CollisionOutline ()
 Construct a collision outline.
 CL_CollisionOutline (const CL_PixelBufferRef &pbuf, int alpha_limit=128, CL_OutlineAccuracy accuracy=accuracy_medium)
 Construct a collision outline.
 CL_CollisionOutline (const CL_StringRef &fullname, int alpha_limit=128, CL_OutlineAccuracy accuracy=accuracy_medium, bool get_insides=true)
 Construct a collision outline.
 CL_CollisionOutline (CL_IODevice &file, const CL_String &file_extension, int alpha_limit=128, CL_OutlineAccuracy accuracy=accuracy_medium, bool get_insides=true)
 Constructs a CollisionOutline.
 CL_CollisionOutline (const CL_StringRef &filename, const CL_VirtualDirectory &directory, int alpha_limit=128, CL_OutlineAccuracy accuracy=accuracy_medium, bool get_insides=true)
 Constructs a CollisionOutline.
 CL_CollisionOutline (const CL_StringRef &resource_id, CL_ResourceManager *manager)
 Construct a collision outline.
 CL_CollisionOutline (std::vector< CL_Contour > contours, int width, int height)
 Construct a collision outline.
 ~CL_CollisionOutline ()


Detailed Description

Collision detection outline.

A collision outline is used in collision detection


Constructor & Destructor Documentation

CL_CollisionOutline::CL_CollisionOutline  ) 
 

Construct a collision outline.

CL_CollisionOutline::CL_CollisionOutline const CL_PixelBufferRef pbuf,
int  alpha_limit = 128,
CL_OutlineAccuracy  accuracy = accuracy_medium
 

Construct a collision outline.

Parameters:
pbuf = Find alpha outline from a pixel buffer
alpha_limit = Alpha limit for pixels considered solid (collidable)
accuracy = Amount of optimization of the outline (default medium)

CL_CollisionOutline::CL_CollisionOutline const CL_StringRef fullname,
int  alpha_limit = 128,
CL_OutlineAccuracy  accuracy = accuracy_medium,
bool  get_insides = true
 

Construct a collision outline.

Parameters:
filename = Load outline from a file. The file can be an image or a precompiled outline.
directory = The virtual directory
file_extension = "out" for a precompiled outline, else a bitmap outline

CL_CollisionOutline::CL_CollisionOutline CL_IODevice file,
const CL_String file_extension,
int  alpha_limit = 128,
CL_OutlineAccuracy  accuracy = accuracy_medium,
bool  get_insides = true
 

Constructs a CollisionOutline.

Parameters:
file = IODevice
file_extension = String
alpha_limit = value
accuracy = Outline Accuracy
get_insides = bool

CL_CollisionOutline::CL_CollisionOutline const CL_StringRef filename,
const CL_VirtualDirectory directory,
int  alpha_limit = 128,
CL_OutlineAccuracy  accuracy = accuracy_medium,
bool  get_insides = true
 

Constructs a CollisionOutline.

Parameters:
filename = String Ref
directory = Virtual Directory
alpha_limit = value
accuracy = Outline Accuracy
get_insides = bool

CL_CollisionOutline::CL_CollisionOutline const CL_StringRef resource_id,
CL_ResourceManager manager
 

Construct a collision outline.

Parameters:
resource_id = The resource id
mananger = The resource manager

CL_CollisionOutline::CL_CollisionOutline std::vector< CL_Contour contours,
int  width,
int  height
 

Construct a collision outline.

Parameters:
contours = The contours
width = The width
height = The height

CL_CollisionOutline::~CL_CollisionOutline  ) 
 


Member Function Documentation

void CL_CollisionOutline::calculate_convex_hulls  ) 
 

(Re)calculate the convex hull for every contour in the outline

static void CL_CollisionOutline::calculate_penetration_depth std::vector< CL_CollidingContours > &  collision_info  )  [static]
 

Will calculate the penetration_depth and penetration_normal for all colliding contours.

void CL_CollisionOutline::calculate_radius  ) 
 

(Re)calculate the radius of the outline.

void CL_CollisionOutline::calculate_smallest_enclosing_discs  ) 
 

(Re)calculate the smallest circles enclosing every contour in the outline.

void CL_CollisionOutline::calculate_sub_circles float  radius_multiplier = 3.5  ) 
 

(Re)calculate the subcircle segmentation of the outline.

void CL_CollisionOutline::clean_collision_info  ) 
 

This will empty the collision-info vector.

bool CL_CollisionOutline::collide const CL_CollisionOutline outline,
bool  remove_old_collision_info = true
 

Returns true if outlines overlap.

Parameters:
outline = Outline to test against.
remove_old_collision_info = set to true to remove old collision info

CL_CollisionOutline& CL_CollisionOutline::copy const CL_CollisionOutline other  ) 
 

Copy.

void CL_CollisionOutline::draw float  x,
float  y,
const CL_Colorf color,
CL_GraphicContext gc
 

Draw outline on graphic context.

Actual rendering position depends on the anchor and the alignment mode.

Parameters:
x = Anchor position of where to render sprite.
y = Anchor y position
color = The color
gc = Graphic context on which to render upon.

void CL_CollisionOutline::draw_smallest_enclosing_disc float  x,
float  y,
const CL_Colorf color,
CL_GraphicContext gc
 

Draw the disc enclosing the entire outline.

Actual rendering position depends on the anchor and the alignment mode.

Parameters:
x = Anchor position of where to render the cirle.
y = Anchor y position
color = The color
gc = Graphic context on which to render upon.

void CL_CollisionOutline::draw_sub_circles float  x,
float  y,
const CL_Colorf color,
CL_GraphicContext gc
 

Draw the subcircles surrounding the linesegments on graphic context.

Actual rendering position depends on the anchor and the alignment mode.

Parameters:
x = Anchor position of where to render cirles.
y = Anchor y position
color = The color
gc = Graphic context on which to render upon.

void CL_CollisionOutline::enable_collision_info bool  points = true,
bool  normals = false,
bool  metadata = false,
bool  pen_depth = false
 

Enable collision info gathering.

void CL_CollisionOutline::get_alignment CL_Origin origin,
float &  x,
float &  y
const
 

Get the translation origin and hotspot of the outline.

float CL_CollisionOutline::get_angle  )  const
 

Returns the rotation angle.

const std::vector<CL_CollidingContours>& CL_CollisionOutline::get_collision_info  )  const
 

Return the info about the collisions. (collision points, normals, pointers to contours, and indexes to lines that intersected).

void CL_CollisionOutline::get_collision_info_state bool &  points,
bool &  normals,
bool &  metadata,
bool &  pendepth
const
 

Fetch the state of the collision testing variables.

const std::vector<CL_Contour>& CL_CollisionOutline::get_contours  )  const
 

std::vector<CL_Contour>& CL_CollisionOutline::get_contours  ) 
 

Returns the contours in the outline.

unsigned int CL_CollisionOutline::get_height  )  const
 

Returns the height of the image this outline was created from.

bool CL_CollisionOutline::get_inside_test  )  const
 

Returns true if completely-inside test is used.

CL_Circlef CL_CollisionOutline::get_minimum_enclosing_disc  )  const
 

Returns the radius of the outline.

float get_radius() const;

const CL_Contour& CL_CollisionOutline::get_object_bounding_box  )  const
 

Returns the contour used as an object bounding box. (an rotated rectangle).

void CL_CollisionOutline::get_rotation_hotspot CL_Origin origin,
float &  x,
float &  y
const
 

Get the rotation hotspot of the outline.

CL_Pointf CL_CollisionOutline::get_scale  )  const
 

Returns the scaling factor.

CL_Pointf CL_CollisionOutline::get_translation  )  const
 

Returns the position of the outline.

unsigned int CL_CollisionOutline::get_width  )  const
 

Returns the width of the image this outline was created from.

void CL_CollisionOutline::load CL_IODevice file  ) 
 

Load.

Parameters:
file = The file

void CL_CollisionOutline::load const CL_StringRef filename,
const CL_VirtualDirectory directory
 

Load.

Parameters:
filename = The filename
directory = Virtual Directory

void CL_CollisionOutline::load const CL_StringRef fullname  ) 
 

Load the outline from file replacing the current data.

Loads precompiled outlines

void CL_CollisionOutline::optimize unsigned char  check_distance = 3,
float  corner_angle = CL_PI/5.0
 

Optimize the outline by removing redundant points.

Parameters:
check_distance = the distance of points compared on the outline
corner_angle = angle for a corner

bool CL_CollisionOutline::point_inside const CL_Pointf point  )  const
 

Returns true if a point is inside the outline.

Parameters:
point = the point to test.

void CL_CollisionOutline::rotate const CL_Angle angle  ) 
 

Rotate the outline by angle (in degrees).

void CL_CollisionOutline::save CL_IODevice file  )  const
 

Save.

Parameters:
file = The file

void CL_CollisionOutline::save const CL_StringRef filename,
CL_VirtualDirectory directory
const
 

Save.

Parameters:
filename = The filename
directory = Virtual Directory

void CL_CollisionOutline::save const CL_StringRef fullname  )  const
 

Write the outline to a file.

Parameters:
filename = Name of file.
directory = Visual Directory to use

void CL_CollisionOutline::set_alignment CL_Origin  origin,
float  x = 0,
float  y = 0
 

Set the translation hotspot of the outline.

void CL_CollisionOutline::set_angle const CL_Angle angle  ) 
 

Set the angle (in degrees) of the outline.

void CL_CollisionOutline::set_collision_info const std::vector< CL_CollidingContours > &  colinfo  ) 
 

This will set the collision info of the outline.

void CL_CollisionOutline::set_inside_test bool  value  ) 
 

Set to true if completely-inside test should be done.

void CL_CollisionOutline::set_rotation_hotspot CL_Origin  origin,
float  x = 0,
float  y = 0
 

Set the rotation hotspot of the outline.

void CL_CollisionOutline::set_scale float  x,
float  y
 

Set the scale of the outline.

void CL_CollisionOutline::set_translation float  x,
float  y
 

Set the position of the outline.


Member Data Documentation

CL_Resource CL_CollisionOutline::resource
 

Resource owning this outline, if any.


The documentation for this class was generated from the following file:
Generated on Thu Dec 3 02:39:35 2009 for ClanLib by  doxygen 1.4.6