The Game Engine  1
CollisionSegment Class Reference

This class is tasked with representing a line segment for uni-directional collision capabilities. More...

#include <CollisionObject.h>

+ Inheritance diagram for CollisionSegment:
+ Collaboration diagram for CollisionSegment:

Public Member Functions

 CollisionSegment (string n)
 
 CollisionSegment (string n, Point2D s, Point2D e)
 
void calcNormal ()
 Calculates the normal direction from start point fist. More...
 
pair< WorldObject
*, CollisionObject * > 
collision (const CollisionRectangle *c, WorldObject *wo, WorldObject *mObj) const
 This does collision between Rectangles and Collision Rectangles. More...
 
pair< WorldObject
*, CollisionObject * > 
collision (const CollisionCircle *c, WorldObject *wo, WorldObject *mObj) const
 This does collision between Rectangles and Collision Cirles. More...
 
virtual pair< WorldObject
*, CollisionObject * > 
collision (const CollisionObject *c, WorldObject *wo, WorldObject *mObj) const
 Check collision with objects implements segment on segment collision. More...
 
virtual void draw (const Point2D &pos)
 Draws the collision data to the screen. More...
 
virtual CollisionObjectType getType () const
 This provides a simple interface to determine types of objects. More...
 
- Public Member Functions inherited from CollisionObject
 CollisionObject (string n)
 
bool checkCollisions (const vector< CollisionObject * > &c, const Point2D cPos, const Point2D pos, vector< string > names=vector< string >())
 Check collision with objects. More...
 

Public Attributes

Point2D end
 Endpoint of the collision segment. More...
 
double distance
 Amount of lookahead to determine a collision. More...
 
Point2D norm
 Normal direction (calculated on construction) More...
 
bool twoWay
 whether or not this is a bi-directional segment. More...
 
- Public Attributes inherited from CollisionObject
Point2D mPos
 The position of the center of the collision data. More...
 

Additional Inherited Members

- Public Types inherited from CollisionObject
enum  CollisionObjectType { COLLISIONRECTANGLE, COLLISIONCIRCLE, COLLISIONSEGMENT }
 This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency. More...
 
- Protected Attributes inherited from CollisionObject
string name
 Name of the collision type. More...
 
Uint32 color
 The collision box color. More...
 

Detailed Description

This class is tasked with representing a line segment for uni-directional collision capabilities.

This class is tasked with the following:

  • Defining a sement of space
    • Providing access to normal direction
    • Providing ability to check for collision against normal and non-normal direction
      Todo:
      make this implement something other than simply axis aligned segments

Definition at line 166 of file CollisionObject.h.

Constructor & Destructor Documentation

CollisionSegment::CollisionSegment ( string  n)
inline

Definition at line 169 of file CollisionObject.h.

CollisionSegment::CollisionSegment ( string  n,
Point2D  s,
Point2D  e 
)
inline

Definition at line 170 of file CollisionObject.h.

+ Here is the call graph for this function:

Member Function Documentation

void CollisionSegment::calcNormal ( )

Calculates the normal direction from start point fist.

+ Here is the caller graph for this function:

pair< WorldObject *, CollisionObject * > CollisionSegment::collision ( const CollisionRectangle c,
WorldObject wo,
WorldObject mObj 
) const

This does collision between Rectangles and Collision Rectangles.

Parameters
ca single collision data for an object
woPointer to Object with checking bound
mObjthe current collision's world object
Returns
Returns true if any of the object's collision datas are colliding .

check rect vs circle

Todo:
test

we need to determine pos and use velocity to determine collision (make collision checks also pass along WorldObject*

Definition at line 177 of file CollisionObject.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

pair< WorldObject *, CollisionObject * > CollisionSegment::collision ( const CollisionCircle c,
WorldObject wo,
WorldObject mObj 
) const

This does collision between Rectangles and Collision Cirles.

Parameters
ca single collision data for an object
woPointer to Object with checking bound
mObjthe current collision's world object
Returns
Returns true if any of the object's collision datas are colliding .

Definition at line 192 of file CollisionObject.cpp.

pair< WorldObject *, CollisionObject * > CollisionSegment::collision ( const CollisionObject c,
WorldObject wo,
WorldObject mObj 
) const
virtual

Check collision with objects implements segment on segment collision.

Parameters
ca single collision data for an object
woPointer to Object with checking bound
mObjthe current collision's world object
Returns
Returns true if any of the object's collision datas are colliding .

call the circle segment fn

call the circle segment fn

Todo:
implement! initially just AA but later any normal

Implements CollisionObject.

Definition at line 198 of file CollisionObject.cpp.

+ Here is the call graph for this function:

virtual void CollisionSegment::draw ( const Point2D pos)
virtual

Draws the collision data to the screen.

Implements CollisionObject.

virtual CollisionObjectType CollisionSegment::getType ( ) const
inlinevirtual

This provides a simple interface to determine types of objects.

Returns the name of the Class and Descendants i.e. Something inheriting from Sprite would look like Sprite:Thing

Implements CollisionObject.

Definition at line 220 of file CollisionObject.h.

Member Data Documentation

double CollisionSegment::distance

Amount of lookahead to determine a collision.

Definition at line 175 of file CollisionObject.h.

Point2D CollisionSegment::end

Endpoint of the collision segment.

Definition at line 172 of file CollisionObject.h.

Point2D CollisionSegment::norm

Normal direction (calculated on construction)

Definition at line 178 of file CollisionObject.h.

bool CollisionSegment::twoWay

whether or not this is a bi-directional segment.

Definition at line 181 of file CollisionObject.h.


The documentation for this class was generated from the following files: