C# Class Buoyancy.BuoyancyBehavior

Inheritance: Behavior
Show file Open project: WaveEngine/Samples Class Usage Examples

Public Properties

Property Type Description
fixturePairs ICollider2D>>.List

Private Properties

Property Type Description
GetIntersect Vector2?
IsClockwise bool
IsInside bool
IsLeftOf bool?
IsNearZero bool
IterateEdgesClockwise IEnumerable
Simulate2D_BeginCollision void
Simulate2D_EndCollision void
b2Cross Vector2

Public Methods

Method Description
ComputeCentroid ( System.Vector2 vs, float &area ) : System.Vector2

Compute polygon centroid

GetIntersectedPolygon ( System.Vector2 subjectPoly, System.Vector2 clipPoly ) : System.Vector2[]

This clips the subject polygon against the clip polygon (gets the intersection of the two polygons)

Based on the psuedocode from: http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman

GetPolygonPoints ( ICollider2D collider ) : System.Vector2[]

Get Polygon points of a physic collider

Protected Methods

Method Description
DefaultValues ( ) : void

Default values

Initialize ( ) : void

Initialize method

Update ( TimeSpan gameTime ) : void

Update method

Private Methods

Method Description
GetIntersect ( System.Vector2 line1From, System.Vector2 line1To, System.Vector2 line2From, System.Vector2 line2To ) : Vector2?

Returns the intersection of the two lines (line segments are passed in, but they are treated like infinite lines)

Got this here: http://stackoverflow.com/questions/14480124/how-do-i-detect-triangle-and-rectangle-intersection

IsClockwise ( System.Vector2 polygon ) : bool
IsInside ( System.Edge edge, System.Vector2 test ) : bool
IsLeftOf ( System.Edge edge, System.Vector2 test ) : bool?

Tells if the test Vector2 lies on the left side of the edge line

IsNearZero ( double testValue ) : bool
IterateEdgesClockwise ( System.Vector2 polygon ) : IEnumerable

This iterates through the edges of the polygon, always clockwise

Simulate2D_BeginCollision ( WaveEngine contact ) : void

Begin collision world event

Simulate2D_EndCollision ( WaveEngine contact ) : void

End collision world event

b2Cross ( float s, Vector2 &a ) : Vector2

Method Details

ComputeCentroid() public static method

Compute polygon centroid
public static ComputeCentroid ( System.Vector2 vs, float &area ) : System.Vector2
vs System.Vector2 polygon vertex
area float polygon area
return System.Vector2

DefaultValues() protected method

Default values
protected DefaultValues ( ) : void
return void

GetIntersectedPolygon() public static method

This clips the subject polygon against the clip polygon (gets the intersection of the two polygons)
Based on the psuedocode from: http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman
public static GetIntersectedPolygon ( System.Vector2 subjectPoly, System.Vector2 clipPoly ) : System.Vector2[]
subjectPoly System.Vector2 Can be concave or convex
clipPoly System.Vector2 Must be convex
return System.Vector2[]

GetPolygonPoints() public static method

Get Polygon points of a physic collider
public static GetPolygonPoints ( ICollider2D collider ) : System.Vector2[]
collider ICollider2D physic collider
return System.Vector2[]

Initialize() protected method

Initialize method
protected Initialize ( ) : void
return void

Update() protected method

Update method
protected Update ( TimeSpan gameTime ) : void
gameTime TimeSpan game time
return void

Property Details

fixturePairs public property

public List> fixturePairs
return ICollider2D>>.List