FlatRedBall.Math.Geometry.Line Introduction The LastCollisionPoint is a property which can tell you the last location where collision occurred. This can be used if you would like to play effects or perform custom physics where collision has occurred. Code Example The following example creates two Lines and calls CollideAgainst between them. It then uses the LastCollisionPoint (if[…]


Introduction The RelativePoint1 and RelativePoint2 values define the shape of a line relative to its absolute position. These values can be set to modify how a line will draw – specifically its angle and length. For simplicity the RelativePoint1 can be set to (0,0), so simply modifying the second point will adjust the line. Examples[…]


Introduction The SetFromAbsoluteEndpoints method can be used to set a line so that its endpoints are located at the argument locations. This method assigns: RelativePoint1 RelativePoint2 Position RotationZ Conceptual Example Consider the following code: Vector3 firstPoint = new Vector3(0, 0, 0); Vector3 secondPoint = new Vector3(100, 0, 0) line.SetFromAbsoluteEndpoints(firstPoint, secondPoint); The code above shows how[…]


Introduction The ClosestPointTo returns the closest point on the calling Segment to the argument position. The closest point may be anywhere on the segment including the endpoints. Code Example The following creates a Segment and a Line as a visible representation of the Segment. The update method finds the closest point on the Segment to[…]


Introduction The ShapeDrawingOrder controls whether all Shapes are drawn under or over other FlatRedBall-drawn objects (for example Sprites, Models, and Texts). Currently shape drawing order cannot be controlled by the shape’s Z value; however, as of the June 2009 release of FlatRedBall, most shapes can be placed on layers which provides some control over ordering.[…]

Shapes and 2D Collision

Introduction The 2D shapes in the FlatRedBall.Math.Geometry namespace provide useful methods for detecting and reacting to collisions. The following lists the 2D shapes: AxisAlignedRectangle Capsule2D Circle Line Polygon These objects provide methods for performing collision against one another. While these objects can be positioned and in some case rotated in 3D space, the collisions they[…]


Introduction The ShapeManager is responsible for managing “Shapes”. Shapes are most often used for collision between objects. Objects which belong to the Shape categorization are: AxisAlignedCube AxisAlignedRectangle Capsule2D Circle Line Polygon Sphere All of these objects share the PositionedObject base class. These are the only objects which the ShapeManager manages. Although there is no “Shape”[…]


Introduction The AxisAlignedCube is a geometric shape from the FlatRedBall.Math.Geometry class. As a 3D shape, it can be used for detecting collisions with 3D or 2D shapes. The AxisAlignedCube class shares many similarities with other shape classes (Circle, Line, AxisAlignedRectangle, Polygon, etc). For general information about shapes, see the ShapeManager wiki entry. Creating an AxisAlignedCube[…]


Introduction A segment is a object defined by two Points. It is not a PositionedObject and its points are absolute, which differentiates it from the Line class. Segment Intersection The following code creates two Lines. One line rotates automatically while the other is controlled by input from the Keyboard. The two Lines call the AsSegment[…]


Introduction A line is defined by two endpoints, so in mathematical terms it is actually a segment. Lines can be used to perform 2D collisions against any other shapes. Line Sample The following sample creates a line, a Circle, and an AxisAlignedRectangle. The line is controlled with the keyboard and it changes colors when it[…]