CUGL 2.3
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cugl::scene2::WireNode Class Reference

#include <CUWireNode.h>

Inheritance diagram for cugl::scene2::WireNode:
cugl::scene2::TexturedNode cugl::scene2::SceneNode

Public Member Functions

 WireNode ()
 
 ~WireNode ()
 
bool initWithPoly (const Poly2 &poly)
 
bool initWithPoly (const Rect rect)
 
bool initWithPath (const Path2 &path)
 
bool initWithPath (const Rect rect)
 
bool initWithPath (const std::vector< Vec2 > &vertices)
 
bool initWithTraversal (const Poly2 &poly, poly2::Traversal traversal)
 
bool initWithTraversal (const std::vector< Vec2 > &vertices, const std::vector< Uint32 > &indices)
 
bool initWithTraversal (Vec2 *vertices, size_t vsize, Uint32 *indices, size_t isize)
 
bool initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) override
 
virtual std::shared_ptr< SceneNodecopy (const std::shared_ptr< SceneNode > &dst) const override
 
void setPolygon (const Poly2 &poly)
 
const Poly2getPolygon () const
 
void setPolygon (const Rect rect)
 
void setPath (const Path2 &path)
 
void setPath (const Rect rect)
 
void setPath (const std::vector< Vec2 > &vertices)
 
void setTraversal (poly2::Traversal traversal)
 
void setTraversal (const std::vector< Uint32 > &indices)
 
void setTraversal (Uint32 *indices, size_t isize)
 
poly2::Traversal getTraversal () const
 
const std::vector< Vec2 > & getVertices () const
 
const std::vector< Uint32 > & getIndices () const
 
virtual void draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override
 
- Public Member Functions inherited from cugl::scene2::TexturedNode
 TexturedNode ()
 
 ~TexturedNode ()
 
virtual void dispose () override
 
virtual bool init () override
 
virtual bool initWithFile (const std::string filename)
 
virtual bool initWithTexture (const std::shared_ptr< Texture > &texture)
 
virtual bool initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) override
 
virtual std::shared_ptr< SceneNodecopy (const std::shared_ptr< SceneNode > &dst) const override
 
void setTexture (const std::string &filename)
 
void setTexture (const std::shared_ptr< Texture > &texture)
 
std::shared_ptr< Texture > & getTexture ()
 
const std::shared_ptr< Texture > & getTexture () const
 
const std::shared_ptr< Gradient > & getGradient () const
 
void setGradient (const std::shared_ptr< Gradient > &gradient)
 
void shiftTexture (float dx, float dy)
 
void setBlendFunc (GLenum srcFactor, GLenum dstFactor)
 
GLenum getSourceBlendFactor () const
 
GLenum getDestinationBlendFactor () const
 
void setBlendEquation (GLenum equation)
 
GLenum getBlendEquation () const
 
void flipHorizontal (bool flag)
 
bool isFlipHorizontal () const
 
void flipVertical (bool flag)
 
bool isFlipVertical () const
 
virtual std::string toString (bool verbose=false) const override
 
bool isAbsolute () const
 
void setAbsolute (bool flag)
 
virtual void setAnchor (const Vec2 anchor) override
 
virtual void setAnchor (float x, float y) override
 
virtual void setContentSize (const Size size) override
 
virtual void setContentSize (float width, float height) override
 
virtual void draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override=0
 
void refresh ()
 
- Public Member Functions inherited from cugl::scene2::SceneNode
 SceneNode ()
 
 ~SceneNode ()
 
virtual void dispose ()
 
virtual bool init ()
 
virtual bool initWithPosition (const Vec2 pos)
 
bool initWithPosition (float x, float y)
 
virtual bool initWithBounds (const Size size)
 
virtual bool initWithBounds (float width, float height)
 
virtual bool initWithBounds (const Rect rect)
 
virtual bool initWithBounds (float x, float y, float width, float height)
 
virtual bool initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 
virtual std::shared_ptr< SceneNodecopy (const std::shared_ptr< SceneNode > &dst) const
 
unsigned int getTag () const
 
void setTag (unsigned int tag)
 
const std::string getName () const
 
void setName (const std::string name)
 
const std::string getClassName () const
 
virtual std::string toString (bool verbose=false) const
 
 operator std::string () const
 
const Vec2 getPosition () const
 
void setPosition (const Vec2 &position)
 
void setPosition (float x, float y)
 
float getPositionX (void) const
 
void setPositionX (float x)
 
float getPositionY (void) const
 
void setPositionY (float y)
 
Vec2 getWorldPosition () const
 
const Size getContentSize () const
 
virtual void setContentSize (const Size size)
 
virtual void setContentSize (float width, float height)
 
float getContentWidth () const
 
void setContentWidth (float width)
 
float getContentHeight () const
 
void setContentHeight (float height)
 
virtual Rect getLayoutBounds () const
 
Size getSize () const
 
float getWidth () const
 
float getHeight () const
 
Rect getBoundingBox () const
 
virtual void setAnchor (const Vec2 anchor)
 
virtual void setAnchor (float x, float y)
 
const Vec2 getAnchor () const
 
Vec2 getAnchorInPixels ()
 
Color4 getColor () const
 
virtual void setColor (Color4 color)
 
Color4 getAbsoluteColor ()
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool hasRelativeColor () const
 
void setRelativeColor (bool flag)
 
std::shared_ptr< ScissorgetScissor () const
 
void setScissor (const std::shared_ptr< Scissor > &scissor)
 
void setScissor ()
 
const Vec2 getScale () const
 
float getScaleX () const
 
float getScaleY () const
 
void setScale (float scale)
 
void setScale (const Vec2 vec)
 
void setScale (float sx, float sy)
 
float getAngle ()
 
void setAngle (float angle)
 
const Affine2getTransform () const
 
const Affine2getAlternateTransform () const
 
void setAlternateTransform (const Affine2 &transform)
 
bool withAlternateTransform ()
 
void chooseAlternateTransform (bool active)
 
const Affine2getNodeToParentTransform () const
 
Affine2 getParentToNodeTransform () const
 
Affine2 getNodeToWorldTransform () const
 
Affine2 getWorldToNodeTransform () const
 
Vec2 screenToNodeCoords (const Vec2 screenPoint) const
 
Vec2 worldToNodeCoords (const Vec2 worldPoint) const
 
Vec2 nodeToScreenCoords (const Vec2 nodePoint) const
 
Vec2 nodeToWorldCoords (const Vec2 nodePoint) const
 
Vec2 parentToNodeCoords (const Vec2 parentPoint) const
 
Vec2 nodeToParentCoords (const Vec2 nodePoint) const
 
size_t getChildCount () const
 
std::shared_ptr< SceneNodegetChild (unsigned int pos)
 
const std::shared_ptr< SceneNode > & getChild (unsigned int pos) const
 
template<typename T >
std::shared_ptr< TgetChild (unsigned int pos) const
 
std::shared_ptr< SceneNodegetChildByTag (unsigned int tag) const
 
template<typename T >
std::shared_ptr< TgetChildByTag (unsigned int tag) const
 
std::shared_ptr< SceneNodegetChildByName (const std::string name) const
 
template<typename T >
std::shared_ptr< TgetChildByName (const std::string name) const
 
std::vector< std::shared_ptr< SceneNode > > getChildren ()
 
const std::vector< std::shared_ptr< SceneNode > > & getChildren () const
 
void addChild (const std::shared_ptr< SceneNode > &child)
 
void addChildWithTag (const std::shared_ptr< SceneNode > &child, unsigned int tag)
 
void addChildWithName (const std::shared_ptr< SceneNode > &child, const std::string name)
 
void swapChild (const std::shared_ptr< SceneNode > &child1, const std::shared_ptr< SceneNode > &child2, bool inherit=false)
 
SceneNodegetParent ()
 
const SceneNodegetParent () const
 
Scene2getScene ()
 
const Scene2getScene () const
 
void removeFromParent ()
 
virtual void removeChild (unsigned int pos)
 
void removeChild (const std::shared_ptr< SceneNode > &child)
 
void removeChildByTag (unsigned int tag)
 
void removeChildByName (const std::string name)
 
virtual void removeAllChildren ()
 
void setPriority (float priority)
 
float getPriority ()
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint)
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch)
 
virtual void draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint)
 
const std::shared_ptr< Layout > & getLayout () const
 
void setLayout (const std::shared_ptr< Layout > &layout)
 
virtual void doLayout ()
 

Static Public Member Functions

static std::shared_ptr< WireNodealloc ()
 
static std::shared_ptr< WireNodeallocWithPoly (const Poly2 &poly)
 
static std::shared_ptr< WireNodeallocWithPoly (const Rect rect)
 
static std::shared_ptr< WireNodeallocWithPath (const Path2 &path)
 
static std::shared_ptr< WireNodeallocWithPath (const Rect rect)
 
static std::shared_ptr< WireNodeallocWithPath (const std::vector< Vec2 > &vertices)
 
static std::shared_ptr< WireNodeallocWithTraversal (const Poly2 &poly, poly2::Traversal traversal)
 
static std::shared_ptr< WireNodeallocWithTraversal (const std::vector< Vec2 > &vertices, const std::vector< Uint32 > &indices)
 
static std::shared_ptr< WireNodeallocWithTraversal (Vec2 *vertices, size_t vsize, Uint32 *indices, size_t isize)
 
static std::shared_ptr< SceneNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 
- Static Public Member Functions inherited from cugl::scene2::SceneNode
static std::shared_ptr< SceneNodealloc ()
 
static std::shared_ptr< SceneNodeallocWithPosition (const Vec2 pos)
 
static std::shared_ptr< SceneNodeallocWithPosition (float x, float y)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Size size)
 
static std::shared_ptr< SceneNodeallocWithBounds (float width, float height)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Rect rect)
 
static std::shared_ptr< SceneNodeallocWithBounds (float x, float y, float width, float height)
 
static std::shared_ptr< SceneNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 

Protected Attributes

Poly2 _polygon
 
std::vector< Uint32 > _indices
 
poly2::Traversal _traversal
 
- Protected Attributes inherited from cugl::scene2::TexturedNode
std::shared_ptr< Texture_texture
 
std::shared_ptr< Gradient_gradient
 
bool _absolute
 
Vec2 _offset
 
bool _rendered
 
Mesh< SpriteVertex2_mesh
 
GLenum _blendEquation
 
GLenum _srcFactor
 
GLenum _dstFactor
 
bool _flipHorizontal
 
bool _flipVertical
 
- Protected Attributes inherited from cugl::scene2::SceneNode
Vec2 _position
 
Vec2 _anchor
 
Size _contentSize
 
Color4 _tintColor
 
bool _hasParentColor
 
bool _isVisible
 
std::shared_ptr< Scissor_scissor
 
Vec2 _scale
 
float _angle
 
Affine2 _transform
 
bool _useTransform
 
Affine2 _combined
 
std::vector< std::shared_ptr< SceneNode > > _children
 
SceneNode_parent
 
Scene2_graph
 
std::shared_ptr< Layout_layout
 
int _childOffset
 
unsigned int _tag
 
std::string _name
 
size_t _hashOfName
 
std::string _classname
 
float _priority
 
std::shared_ptr< JsonValue_json
 

Additional Inherited Members

- Protected Member Functions inherited from cugl::scene2::TexturedNode
virtual void generateRenderData ()=0
 
virtual void updateTextureCoords ()=0
 
void clearRenderData ()
 
 CU_DISALLOW_COPY_AND_ASSIGN (TexturedNode)
 

Detailed Description

This is a scene graph node to represent a wireframe

The wireframes are lines, but they can still be textured. However, generally you will only want to create a wireframe with the degenerate texture (to draw a solid, colored line). Hence, none of the static constructors take a texture. You are free to update the texture after creation, if you wish.

The node shape is stored as polygon. The wireframe shape is determined by the polygon traversal. There are three options, defined in poly2::Traversal.

OPEN:     The traversal is in order, but does not close the ends.

CLOSED:   The traversal is in order, and closes the ends.

INTERIOR: The traverse will outline the default triangulation.

The default is traversal is CLOSED.

The wireframe can be textured (as lines can be textured). The wireframe is specified in image coordinates. Image coordinates are different from texture coordinates. Their origin is at the bottom-left corner of the file, and each pixel is one unit. This makes specifying to polygon more natural for irregular shapes.

This means that a wireframe with vertices (0,0), (width,0), (width,height), and (0,height) would be the border of a sprite node. However, a wireframe with vertices (0,0), (2*width,0), (2*width,2*height), and (0,2*height) would tile the sprite texture (given the wrap settings) twice both horizontally and vertically.

The content size of this node is defined by the size (but not the offset) of the bounding box. The anchor point is relative to this content size. The default anchor point in a TexturedNode is (0.5, 0.5). This means that a uniform translation of the polygon (in contrast to the node itself) will not move the shape on the the screen. Instead, it will just change the part of the texture it uses.

For example, suppose the texture has given width and height. We have one polygon with vertices (0,0), (width/2,0), (width/2,height/2), and (0,height/2). We have another polygon with vertices (width/2,height/2), (width,height/2), (width,height), and (width/2,height). Both polygons would create a rectangle of size (width/2,height/2). centered at the node position. However, the first would use the bottom left part of the texture, while the second would use the top right.

You can disable these features at any time by setting the attribute absolute to true. Do this will place the polygon vertices in their absolute positions in Node space. This will also disable anchor functions (setting the anchor as the bottom left corner), since anchors do not make sense when we are drawing vertices directly into the coordinate space.

Constructor & Destructor Documentation

◆ WireNode()

cugl::scene2::WireNode::WireNode ( )
inline

Creates an empty wire frame with the degenerate texture.

You must initialize this WireNode before use.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.

◆ ~WireNode()

cugl::scene2::WireNode::~WireNode ( )
inline

Releases all resources allocated with this node.

This will release, but not necessarily delete the associated texture. However, the polygon and drawing commands will be deleted and no longer safe to use.

Member Function Documentation

◆ alloc()

static std::shared_ptr< WireNode > cugl::scene2::WireNode::alloc ( )
inlinestatic

Returns an empty wire frame.

The underlying polygon is empty, and must be set via setPolygon.

Returns
an empty wire frame.

◆ allocWithData()

static std::shared_ptr< SceneNode > cugl::scene2::WireNode::allocWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
inlinestatic

Returns a newly allocated wire frame with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:

 "traversal": One of 'none', 'open', 'closed', or 'interior'
 "polygon":   A JSON object defining a polygon. See {@link Poly2}.
 "wireframe": An even array of numbers defining the wireframe indices.

All attributes are optional. If the polygon is not specified, the node will use a rectangle with the dimensions of the texture. For more information, see TexturedNode#initWithData.

If you do specify the wire frame, the traversal algorithm will be ignored. If both the wireframe and the traversal algorithm are omitted, this will perform an INTERIOR traversal on the polygon.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
a newly allocated wire frame with the given JSON specificaton.

◆ allocWithPath() [1/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithPath ( const Path2 path)
inlinestatic

Returns a newly allocated wire frame with the given path.

This wireframe will perform a traversal of the path. The traversal will either be OPEN or CLOSED depending upon the properties of the path.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
pathThe path to traverse
Returns
a newly allocated wire frame with the given path.

◆ allocWithPath() [2/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithPath ( const Rect  rect)
inlinestatic

Returns a newly allocated wire frame with the given rectangle (outline).

This wireframe will perform a CLOSED traversal of the rectangle.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
rectThe rectangle to traverse
Returns
a newly allocated wire frame with the given rectangle (outline).

◆ allocWithPath() [3/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithPath ( const std::vector< Vec2 > &  vertices)
inlinestatic

Returns a newly allocated wire frame with the given path.

This wireframe will perform a CLOSED traversal of the given path.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe path to traverse
Returns
a newly allocated wire frame with the given path.

◆ allocWithPoly() [1/2]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithPoly ( const Poly2 poly)
inlinestatic

Returns a newly allocated wire frame with the given polygon.

This wireframe will perform an INTERIOR traversal of the given polygon. This assumes that the polygon has been triangulated previously.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
polyThe polygon to traverse
Returns
a newly allocated wire frame with the given polygon.

◆ allocWithPoly() [2/2]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithPoly ( const Rect  rect)
inlinestatic

Returns a newly allocated wire frame with the given (solid) rectangle.

This wireframe will perform an INTERIOR traversal of the standard triangulation of this rectangle.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
rectThe rectangle to traverse
Returns
a newly allocatedwire frame with the given (solid) rectangle.

◆ allocWithTraversal() [1/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithTraversal ( const Poly2 poly,
poly2::Traversal  traversal 
)
inlinestatic

Returns a newly allocated wire frame with the given polygon and traversal.

The provided polygon will be used as the source for the traversal. The traversal will be defined exactly as the one provided by PathFactory#makeTraversal.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
polyThe triangulated polygon
traversalThe path traversal for index generation
Returns
a newly allocated wire frame with the given polygon and traversal.

◆ allocWithTraversal() [2/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithTraversal ( const std::vector< Vec2 > &  vertices,
const std::vector< Uint32 > &  indices 
)
inlinestatic

Returns a newly allocated wire frame with the given vertices and indices

This initializer will set the given vertices to of the polygon to be the one specified. However, it will not triangulate the polygon, or attempt to traverse it. Instead, it will use the provided indices as the final traversal. Hence this is a way of creating a custom traversal. To work properly, the indices should have an even number of elements and define a sequence of line segments.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe vertices to texture (expressed in image space)
indicesThe traversal indices
Returns
a newly allocated wire frame with the given vertices and indices

◆ allocWithTraversal() [3/3]

static std::shared_ptr< WireNode > cugl::scene2::WireNode::allocWithTraversal ( Vec2 vertices,
size_t  vsize,
Uint32 *  indices,
size_t  isize 
)
inlinestatic

Returns a newly allocated wire frame with the given vertices and indices

This initializer will set the given vertices to of the polygon to be the one specified. However, it will not triangulate the polygon, or attempt to traverse it. Instead, it will use the provided indices as the final traversal. Hence this is a way of creating a custom traversal. To work properly, the indices should have an even number of elements and define a sequence of line segments.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe vertices to texture (expressed in image space)
vsizeThe number of vertices
indicesThe traversal indices
isizeThe number of indices
Returns
a newly allocated wire frame with the given vertices and indices

◆ copy()

virtual std::shared_ptr< SceneNode > cugl::scene2::WireNode::copy ( const std::shared_ptr< SceneNode > &  dst) const
overridevirtual

Performs a shallow copy of this Node into dst.

No children from this node are copied, and no children of dst are modified. In addition, the parents of both Nodes are unchanged. However, all other attributes of this node are copied.

Parameters
dstThe Node to copy into
Returns
A reference to dst for chaining.

Reimplemented from cugl::scene2::TexturedNode.

◆ draw()

virtual void cugl::scene2::WireNode::draw ( const std::shared_ptr< SpriteBatch > &  batch,
const Affine2 transform,
Color4  tint 
)
overridevirtual

Draws this wireframe via the given SpriteBatch.

This method only worries about drawing the current node. It does not attempt to render the children.

Parameters
batchThe SpriteBatch to draw with.
transformThe global transformation matrix.
tintThe tint to blend with the Node color.

Implements cugl::scene2::TexturedNode.

◆ getIndices()

const std::vector< Uint32 > & cugl::scene2::WireNode::getIndices ( ) const
inline

Returns the traversal indices of this wire frame.

Returns
the traversal indices of this wire frame.

◆ getPolygon()

const Poly2 & cugl::scene2::WireNode::getPolygon ( ) const
inline

Returns the wire frame polygon.

The provided polygon will be used as the source for the traversal. The polygon itself may or may not have any indices, as the polygon indices are not the same as the traversal indices.

The polygon is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

Returns
the wire frame polygon

◆ getTraversal()

poly2::Traversal cugl::scene2::WireNode::getTraversal ( ) const
inline

Returns the current traversal algorithm of this path.

If the traversal was defined by a custom set of indices, this method returns NONE.

Returns
the current traversal algorithm of this path.

◆ getVertices()

const std::vector< Vec2 > & cugl::scene2::WireNode::getVertices ( ) const
inline

Returns the current vertices of this wire frame.

Returns
the current vertices of this wire frame.

◆ initWithData()

bool cugl::scene2::WireNode::initWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
overridevirtual

Initializes a wire frame with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:

 "traversal": One of 'none', 'open', 'closed', or 'interior'
 "polygon":   A JSON object defining a polygon. See {@link Poly2}.
 "wireframe": An even array of numbers defining the wireframe indices.

All attributes are optional. If the polygon is not specified, the node will use a rectangle with the dimensions of the texture. For more information, see TexturedNode#initWithData.

If you do specify the wire frame, the traversal algorithm will be ignored. If both the wireframe and the traversal algorithm are omitted, this will perform an INTERIOR traversal on the polygon.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::TexturedNode.

◆ initWithPath() [1/3]

bool cugl::scene2::WireNode::initWithPath ( const Path2 path)

Initializes a wire frame with the given path.

This wireframe will perform a traversal of the path. The traversal will either be OPEN or CLOSED depending upon the properties of the path.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
pathThe path to traverse
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithPath() [2/3]

bool cugl::scene2::WireNode::initWithPath ( const Rect  rect)

Initializes a wire frame with the given rectangle (outline).

This wireframe will perform a CLOSED traversal of the rectangle.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
rectThe rectangle to traverse
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithPath() [3/3]

bool cugl::scene2::WireNode::initWithPath ( const std::vector< Vec2 > &  vertices)

Initializes a wire frame with the given path.

This wireframe will perform a CLOSED traversal of the given path.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe path to traverse
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithPoly() [1/2]

bool cugl::scene2::WireNode::initWithPoly ( const Poly2 poly)

Initializes a wire frame with the given polygon.

This wireframe will perform an INTERIOR traversal of the given polygon. This assumes that the polygon has been triangulated previously.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
polyThe polygon to traverse
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithPoly() [2/2]

bool cugl::scene2::WireNode::initWithPoly ( const Rect  rect)

Initializes a wire frame with the given (solid) rectangle.

This wireframe will perform an INTERIOR traversal of the standard triangulation of this rectangle.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
rectThe rectangle to traverse
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithTraversal() [1/3]

bool cugl::scene2::WireNode::initWithTraversal ( const Poly2 poly,
poly2::Traversal  traversal 
)

Intializes a wire frame with the given polygon and traversal

The provided polygon will be used as the source for the traversal. The traversal will be applied to the vertices (and potentially indices) of thei polygon.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
polyThe triangulated polygon
traversalThe path traversal for index generation
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithTraversal() [2/3]

bool cugl::scene2::WireNode::initWithTraversal ( const std::vector< Vec2 > &  vertices,
const std::vector< Uint32 > &  indices 
)

Intializes a wire frame with the given vertices and indices

This initializer will set the given vertices to of the polygon to be the one specified. However, it will not triangulate the polygon, or attempt to traverse it. Instead, it will use the provided indices as the final traversal. Hence this is a way of creating a custom traversal. To work properly, the indices should have an even number of elements and define a sequence of line segments.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe vertices to texture (expressed in image space)
indicesThe traversal indices
Returns
true if the wireframe is initialized properly, false otherwise.

◆ initWithTraversal() [3/3]

bool cugl::scene2::WireNode::initWithTraversal ( Vec2 vertices,
size_t  vsize,
Uint32 *  indices,
size_t  isize 
)

Intializes a wire frame with the given vertices and indices

This initializer will set the given vertices to of the polygon to be the one specified. However, it will not triangulate the polygon, or attempt to traverse it. Instead, it will use the provided indices as the final traversal. Hence this is a way of creating a custom traversal. To work properly, the indices should have an even number of elements and define a sequence of line segments.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. Hence the wireframe will have a solid color.

Parameters
verticesThe vertices to texture (expressed in image space)
vsizeThe number of vertices
indicesThe traversal indices
isizeThe number of indices
Returns
true if the wireframe is initialized properly, false otherwise.

◆ setPath() [1/3]

void cugl::scene2::WireNode::setPath ( const Path2 path)

Sets the wire frame polygon to the given path.

The resulting polygon will not have an triangulation vertices, so any INTERIOR travesal will fail (generate no indices). However, any other traversal will work normally. In addition, setting this value will change the traversal algorithm to either OPEN or CLOSED, depending on the nature of the path.

The path is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

Parameters
pathThe wire frame path

◆ setPath() [2/3]

void cugl::scene2::WireNode::setPath ( const Rect  rect)

Sets the wire frame polygon to the given rect (outline).

The resulting polygon will not have an triangulation vertices, so any INTERIOR travesal will fail (generate no indices). However, any other traversal will work normally. In addition, setting this value will change the traversal algorithm to CLOSED.

The rectangle is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

Parameters
rectThe wire frame rectangle

◆ setPath() [3/3]

void cugl::scene2::WireNode::setPath ( const std::vector< Vec2 > &  vertices)

Sets the wire frame polygon to the given path.

The resulting polygon will not have an triangulation vertices, so any INTERIOR travesal will fail (generate no indices). However, any other traversal will work normally.

The path is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

Parameters
verticesThe wire frame path

◆ setPolygon() [1/2]

void cugl::scene2::WireNode::setPolygon ( const Poly2 poly)

Sets the wire frame polygon to the given one.

The provided polygon will be used as the source for the traversal. If the traversal algorithm is not NONE, setting this value will generate a new set of traversal indices.

The polygon is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

It is not necessary for this polygon to be triangulated (e.g. have indices). A triangulation is only necessary for an INTERIOR traversal.

Parameters
polyThe wire frame polygon

◆ setPolygon() [2/2]

void cugl::scene2::WireNode::setPolygon ( const Rect  rect)

Sets the wire frame polygon to the given (solid) rect.

The rectangle will be converted into a Poly2, with the traditional two-element triagulation. If the traversal algorithm is not NONE, setting this value will generate a new set of traversal indices. traversal method.

The rectangle is specified in image coordinates. The origin is at the bottom-left corner of the image, and each pixel is one unit. If no texture is specified, this node will draw the wire frame with a solid color.

Parameters
rectThe wire frame rectangle

◆ setTraversal() [1/3]

void cugl::scene2::WireNode::setTraversal ( const std::vector< Uint32 > &  indices)

Sets the traversal indices of this path.

The indices are a manual traversal of the underlying polygon. The argument should contain an even number of indices, defining a sequence of line segments. In addition, the indices should all represent valid vertices in the polygon. However, this method provides no validation, so violating these requirements causes undefined behavior.

Setting indices manually will cause the underlying traveral algorithm to be NONE.

Parameters
indicesA custom traversal of the polygon.

◆ setTraversal() [2/3]

void cugl::scene2::WireNode::setTraversal ( poly2::Traversal  traversal)

Sets the traversal algorithm of this wire frame.

If the traversal algorithm is different from the current one, it will recompute the traversal indices.

Parameters
traversalThe new traversal algorithm

◆ setTraversal() [3/3]

void cugl::scene2::WireNode::setTraversal ( Uint32 *  indices,
size_t  isize 
)

Sets the traversal indices of this path.

The indices are a manual traversal of the underlying polygon. The argument should contain an even number of indices, defining a sequence of line segments. In addition, the indices should all represent valid vertices in the polygon. However, this method provides no validation, so violating these requirements causes undefined behavior.

Setting indices manually will cause the underlying traveral algorithm to be NONE.

Parameters
indicesA custom traversal of the polygon.
isizeThe number of indices

Member Data Documentation

◆ _indices

std::vector<Uint32> cugl::scene2::WireNode::_indices
protected

The wireframe indices

◆ _polygon

Poly2 cugl::scene2::WireNode::_polygon
protected

The wireframe vertices

◆ _traversal

poly2::Traversal cugl::scene2::WireNode::_traversal
protected

The current (known) traversal of this wireframe


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