TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Graphics::PolygonShape Class Reference

#include <tb_basic_shapes.h>

Inheritance diagram for TurtleBrains::Graphics::PolygonShape:
TurtleBrains::Graphics::Graphic TurtleBrains::Graphics::BoxShape TurtleBrains::Graphics::CircleShape TurtleBrains::Graphics::OutlinedPolygonShape TurtleBrains::Graphics::FullScreenQuad TurtleBrains::Graphics::OutlinedBoxShape TurtleBrains::Graphics::OutlinedCircleShape

Public Member Functions

 PolygonShape (void)
 
 PolygonShape (const PolygonShape &other)
 
virtual ~PolygonShape (void)
 
virtual void SetColor (const tbGraphics::Color &newColor) override
 
- Public Member Functions inherited from TurtleBrains::Graphics::Graphic
 Graphic (void)
 
 Graphic (const Graphic &other)
 
virtual ~Graphic (void)
 
bool IsActive (void) const
 
void SetActive (const bool isActive)
 
void Update (const float deltaTime)
 
bool IsVisible (void) const
 
void SetVisible (const bool isVisible)
 
void Render (void) const
 
const tbMath::Vector2GetPosition (void) const
 
void SetPosition (const float x, const float y)
 
void SetPosition (const tbMath::Vector2 &position)
 
void SetOrigin (const AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero())
 
void SetOrigin (const float originX, const float originY)
 
void SetOrigin (const tbMath::Vector2 &origin)
 
float GetDepth (void) const
 
void SetDepth (const float newDepth)
 
const tbMath::Vector2GetScale (void) const
 
void SetScale (const float scale)
 
void SetScale (const float scaleX, const float scaleY)
 
float GetRotation (void) const
 
void SetRotation (const float rotation)
 
void SetScroll (const float scroll)
 
void SetScroll (const float scrollX, const float scrollY)
 
bool IsRelative (void) const
 
const ColorGetColor (void) const
 
float GetWidth (void) const
 
float GetHeight (void) const
 

Protected Member Functions

virtual void OnRender (void) const override
 
virtual void ClearVertices (void)
 
virtual void AddVertex (const tbMath::Vector2 &position)
 
virtual PixelSpace GetPixelWidth (void) const override
 
virtual PixelSpace GetPixelHeight (void) const override
 
void SetAsTriangles (void)
 
void SetAsTriangleFan (void)
 
void SetAsTriangleStrip (void)
 
void SetAsLines (void)
 
void SetAsLineStrip (void)
 
void SetAsLineLoop (void)
 
- Protected Member Functions inherited from TurtleBrains::Graphics::Graphic
virtual void OnUpdate (const float deltaTime)
 
virtual void ApplyTransform (void) const
 
virtual void PopTransform (void) const
 

Friends

class OutlinedPolygonShape
 

Detailed Description

Allow creation of simple and complex shapes by supplying several points that get shaped into triangles.

Constructor & Destructor Documentation

TurtleBrains::Graphics::PolygonShape::PolygonShape ( void  )

Constructs an empty PolygonShape object that contains no vertices.

TurtleBrains::Graphics::PolygonShape::PolygonShape ( const PolygonShape other)

Constructs a PolygonShape object with the same properties as the other object being copied.

virtual TurtleBrains::Graphics::PolygonShape::~PolygonShape ( void  )
virtual

Cleans up after a PolygonShape, clearing the vertex container in the process.

Member Function Documentation

virtual void TurtleBrains::Graphics::PolygonShape::AddVertex ( const tbMath::Vector2 position)
protectedvirtual

Adds a vertex to a container of vertices for the PolygonShape. How it will be rendered depends on how the PolygonShape object is configured.

virtual void TurtleBrains::Graphics::PolygonShape::ClearVertices ( void  )
protectedvirtual

Clears all the vertices in the PolygonShape.

Reimplemented in TurtleBrains::Graphics::OutlinedPolygonShape.

virtual PixelSpace TurtleBrains::Graphics::PolygonShape::GetPixelHeight ( void  ) const
overrideprotectedvirtual

Computes and returns the height of the PolygonShape in pixels.

Reimplemented from TurtleBrains::Graphics::Graphic.

virtual PixelSpace TurtleBrains::Graphics::PolygonShape::GetPixelWidth ( void  ) const
overrideprotectedvirtual

Computes and returns the width of the PolygonShape in pixels.

Reimplemented from TurtleBrains::Graphics::Graphic.

virtual void TurtleBrains::Graphics::PolygonShape::OnRender ( void  ) const
overrideprotectedvirtual

Renders the PolygonShape object vertices as Triangles, TriangleStrip, TriangleFan, Lines, LineStrip or LineLoop depending on how the object is configured to treat the vertices. Depending on the configuration this may trigger an error condition based on number of vertices.

Implements TurtleBrains::Graphics::Graphic.

Reimplemented in TurtleBrains::Graphics::OutlinedPolygonShape.

void TurtleBrains::Graphics::PolygonShape::SetAsLineLoop ( void  )
inlineprotected

Configures the object to treat the vertices as a line loop, which is identical in behavior to a line strip in that at least 2 vertices must be added, (really 3 for a visible loop). Each vertex added after the first will create a line segment to the vertex added previously. A final line segment will be created automatically from the last added vertex to the very first vertex which will complete the loop.

void TurtleBrains::Graphics::PolygonShape::SetAsLines ( void  )
inlineprotected

Configures the object to treat the vertices as a list of lines. In this mode the number of vertices must be equal-to or greater-than 2, and must also be divisible by 2. Each pair of vertices added will form a line segment.

void TurtleBrains::Graphics::PolygonShape::SetAsLineStrip ( void  )
inlineprotected

Configures the object to treat the vertices as a line strip. In this mode the number of vertices must be at least 2. Each vertex added after the first will create a line segment to the vertex added previously.

void TurtleBrains::Graphics::PolygonShape::SetAsTriangleFan ( void  )
inlineprotected

Configures the object to treat the vertices as a fan of Triangles. In this mode the number of vertices must be equal-to or greater-than 3. The first vertex added will be the center of the fan and used for each of the triangles.

void TurtleBrains::Graphics::PolygonShape::SetAsTriangles ( void  )
inlineprotected

Configures the object to treat the vertices as a list of Triangles. In this mode the number of vertices must be equal-to or greater-than 3, and must also be divisible by 3.

void TurtleBrains::Graphics::PolygonShape::SetAsTriangleStrip ( void  )
inlineprotected

Configures the object to treat the vertices as a strip of Triangles. In this mode the number of vertices must be at least 3. Each vertex after the third will create a triangle using the two vertices added immediately before it.

virtual void TurtleBrains::Graphics::PolygonShape::SetColor ( const tbGraphics::Color newColor)
overridevirtual

Sets the color of all the vertices in the PolygonShape.

Reimplemented from TurtleBrains::Graphics::Graphic.