![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUMeshNode.h>
Public Member Functions | |
MeshNode () | |
~MeshNode () | |
virtual void | dispose () override |
virtual bool | init () override |
bool | initWithMesh (const graphics::Mesh< graphics::SpriteVertex > &mesh) |
bool | initWithPoly (const Poly2 &poly) |
bool | initWithPoly (const Poly2 &poly, const std::vector< Color4 > &colors) |
virtual bool | initWithFile (const std::string filename) override |
bool | initWithFileMesh (const std::string filename, const graphics::Mesh< graphics::SpriteVertex > &mesh) |
bool | initWithFilePoly (const std::string filename, const Poly2 &poly) |
bool | initWithFilePoly (const std::string filename, const Poly2 &poly, const std::vector< Color4 > &colors) |
virtual bool | initWithTexture (const std::shared_ptr< graphics::Texture > &texture) override |
bool | initWithTextureMesh (const std::shared_ptr< graphics::Texture > &texture, const graphics::Mesh< graphics::SpriteVertex > &mesh) |
bool | initWithTexturePoly (const std::shared_ptr< graphics::Texture > &texture, const Poly2 &poly) |
bool | initWithTexturePoly (const std::shared_ptr< graphics::Texture > &texture, const Poly2 &poly, const std::vector< Color4 > &colors) |
virtual bool | initWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &data) override |
virtual std::shared_ptr< SceneNode > | copy (const std::shared_ptr< SceneNode > &dst) const override |
void | setMesh (const graphics::Mesh< graphics::SpriteVertex > &mesh) |
void | setMesh (graphics::Mesh< graphics::SpriteVertex > &&mesh) |
const graphics::Mesh< graphics::SpriteVertex > & | getMesh () const |
graphics::Mesh< graphics::SpriteVertex > & | getMesh () |
const graphics::SpriteVertex * | getVertex (size_t index) const |
graphics::SpriteVertex * | getVertex (size_t index) |
void | setVertexColors (const std::vector< Color4 > &colors) |
void | setVertexTexCoords (const std::vector< Vec2 > &coords) |
void | setVertexGradCoords (const std::vector< Vec2 > &coords) |
const Rect | getBoundingRect () const |
void | setPolygon (const Poly2 &poly) |
virtual void | draw (const std::shared_ptr< graphics::SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override |
![]() | |
TexturedNode () | |
~TexturedNode () | |
virtual void | dispose () override |
virtual bool | init () override |
virtual bool | initWithFile (const std::string filename) |
virtual bool | initWithTexture (const std::shared_ptr< graphics::Texture > &texture) |
virtual bool | initWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &data) override |
virtual std::shared_ptr< SceneNode > | copy (const std::shared_ptr< SceneNode > &dst) const override |
void | setTexture (const std::string &filename) |
void | setTexture (const std::shared_ptr< graphics::Texture > &texture) |
std::shared_ptr< graphics::Texture > | getTexture () |
const std::shared_ptr< graphics::Texture > | getTexture () const |
const std::shared_ptr< graphics::Gradient > | getGradient () const |
void | setGradient (const std::shared_ptr< graphics::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< graphics::SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override=0 |
void | refresh () |
![]() | |
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 AssetManager *manager, const std::shared_ptr< JsonValue > &data) |
virtual std::shared_ptr< SceneNode > | copy (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 std::shared_ptr< cugl::JsonValue > & | getJSON () 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 bool | inContentBounds (const Vec2 point) |
bool | inContentBounds (float x, float y) |
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< graphics::Scissor > | getScissor () const |
void | setScissor (const std::shared_ptr< graphics::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 Affine2 & | getTransform () const |
const Affine2 & | getAlternateTransform () const |
void | setAlternateTransform (const Affine2 &transform) |
bool | withAlternateTransform () |
void | chooseAlternateTransform (bool active) |
const Affine2 & | getNodeToParentTransform () const |
Affine2 | getParentToNodeTransform () const |
virtual 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< SceneNode > | getChild (unsigned int pos) |
const std::shared_ptr< SceneNode > & | getChild (unsigned int pos) const |
template<typename T > | |
std::shared_ptr< T > | getChild (unsigned int pos) const |
std::shared_ptr< SceneNode > | getChildByTag (unsigned int tag) const |
template<typename T > | |
std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
std::shared_ptr< SceneNode > | getChildByName (const std::string name) const |
template<typename T > | |
std::shared_ptr< T > | getChildByName (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) |
SceneNode * | getParent () |
const SceneNode * | getParent () const |
Scene2 * | getScene () |
const Scene2 * | getScene () 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< graphics::SpriteBatch > &batch, const Affine2 &transform, Color4 tint) |
virtual void | render (const std::shared_ptr< graphics::SpriteBatch > &batch) |
virtual void | draw (const std::shared_ptr< graphics::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< MeshNode > | alloc () |
static std::shared_ptr< SceneNode > | allocWithMesh (const graphics::Mesh< graphics::SpriteVertex > &mesh) |
static std::shared_ptr< SceneNode > | allocWithPoly (const Poly2 &poly, const std::vector< Color4 > colors) |
static std::shared_ptr< SceneNode > | allocWithFile (const std::string filename) |
static std::shared_ptr< SceneNode > | allocWithFileMesh (const std::string filename, const graphics::Mesh< graphics::SpriteVertex > &mesh) |
static std::shared_ptr< SceneNode > | allocWithFilePoly (const std::string filename, const Poly2 &poly) |
static std::shared_ptr< SceneNode > | allocWithFilePoly (const std::string filename, const Poly2 &poly, std::vector< Color4 > colors) |
static std::shared_ptr< SceneNode > | allocWithTexture (const std::shared_ptr< graphics::Texture > &texture) |
static std::shared_ptr< SceneNode > | allocWithTextureMesh (const std::shared_ptr< graphics::Texture > &texture, const graphics::Mesh< graphics::SpriteVertex > &mesh) |
static std::shared_ptr< SceneNode > | allocWithTexturePoly (const std::shared_ptr< graphics::Texture > &texture, const Poly2 &poly) |
static std::shared_ptr< SceneNode > | allocWithTexturePoly (const std::shared_ptr< graphics::Texture > &texture, const Poly2 &poly, std::vector< Color4 > colors) |
static std::shared_ptr< SceneNode > | allocWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &data) |
![]() | |
static std::shared_ptr< SceneNode > | alloc () |
static std::shared_ptr< SceneNode > | allocWithPosition (const Vec2 pos) |
static std::shared_ptr< SceneNode > | allocWithPosition (float x, float y) |
static std::shared_ptr< SceneNode > | allocWithBounds (const Size size) |
static std::shared_ptr< SceneNode > | allocWithBounds (float width, float height) |
static std::shared_ptr< SceneNode > | allocWithBounds (const Rect rect) |
static std::shared_ptr< SceneNode > | allocWithBounds (float x, float y, float width, float height) |
static std::shared_ptr< SceneNode > | allocWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &data) |
Protected Attributes | |
int | _flipFlags |
![]() | |
std::shared_ptr< graphics::Texture > | _texture |
std::shared_ptr< graphics::Gradient > | _gradient |
bool | _absolute |
Vec2 | _offset |
bool | _rendered |
graphics::Mesh< graphics::SpriteVertex > | _mesh |
GLenum | _blendEquation |
GLenum | _srcFactor |
GLenum | _dstFactor |
bool | _flipHorizontal |
bool | _flipVertical |
![]() | |
Vec2 | _position |
Vec2 | _anchor |
Size | _contentSize |
Color4 | _tintColor |
bool | _hasParentColor |
bool | _isVisible |
std::shared_ptr< graphics::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 | |
![]() | |
virtual void | generateRenderData ()=0 |
virtual void | updateTextureCoords ()=0 |
virtual void | clearRenderData () |
CU_DISALLOW_COPY_AND_ASSIGN (TexturedNode) | |
This is a scene graph node to support mesh manipulation
The API for this class is very similar to PolygonNode
, except that the use specifies a mesh directly (instead of inferring it from the shape). This allows the user direct control over the interior vertices, and the individual vertex colors.
Unlike polgon nodes, all mesh nodes use absolute positioning by default.
|
inline |
Creates an empty mesh with the degenerate texture.
You must initialize this MeshNode 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.
|
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.
|
inlinestatic |
Returns a default mesh node.
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes. The vertex colors will be blue, red, and yellow.
|
inlinestatic |
Returns a newly allocated mesh node with the given JSON specification.
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:
"mesh": A JSON object defining a mesh of SpriteVertex
This JSON object for mesh is required. The mesh can be represented as either an array or JSON object. If it is an array, it contain JSON values compatible with the graphics::SpriteVertex
constructor. If it is a JSON object, then it supports the following attributes:
"vertices": An array {@link SpriteVertex} descriptions "indices": An intenger list of triangle indices (in multiples of 3) "triangulator": One of 'monotone', 'earclip', 'delaunay', 'fan', or 'strip'
All attributes are optional. If "vertices" are missing, the mesh will be empty. If both "indices" and "triangulator" are missing, the mesh will use a triangle fan. The "triangulator" choice will only be applied if the "indices" are missing.
manager | The asset manager handling this asset |
data | The JSON object specifying the node |
|
inlinestatic |
Returns a newly allocated mesh node from the image filename.
After creation, the mesh will be a rectangle. The vertices of this mesh will be the corners of the image. The rectangle will be triangulated with the standard two triangles. The colors of all the vertices will be white.
filename | A path to image file, e.g., "scene1/earthtile.png" |
|
inlinestatic |
Returns a newly allocated mesh node from the image filename and mesh
The texture coordinates in the mesh will determine how to interpret the texture.
filename | A path to image file, e.g., "scene1/earthtile.png" |
mesh | The mesh data |
|
inlinestatic |
Returns a newly allocated mesh node from the image filename and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices will all have color white
filename | A path to image file, e.g., "scene1/earthtile.png" |
poly | The polygon to define the mesh |
|
inlinestatic |
Returns a newly allocated mesh node from the image filename and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
filename | A path to image file, e.g., "scene1/earthtile.png" |
poly | The polygon to define the mesh |
colors | The vertex colors |
|
inlinestatic |
Intializes a mesh node from the current mesh
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes.
mesh | The mesh data |
|
inlinestatic |
Returns a newly allocated mesh node using from a polygon and set of colors.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes.
poly | The polygon to define the mesh |
colors | The vertex colors |
|
inlinestatic |
Returns a newly allocated mesh node from a Texture object.
After creation, the mesh will be a rectangle. The vertices of this mesh will be the corners of the image. The rectangle will be triangulated with the standard two triangles. The colors of all the vertices will be white.
texture | A shared pointer to a Texture object. |
|
inlinestatic |
Returns a newly allocated mesh node from the Texture object and mesh
The texture coordinates in the mesh will determine how to interpret the texture.
texture | A shared pointer to a Texture object. |
mesh | The mesh data |
|
inlinestatic |
Returns a newly allocated mesh node from the Texture object and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices will all have color white
texture | A shared pointer to a Texture object. |
poly | The polygon to define the mesh |
|
inlinestatic |
Returns a newly allocated mesh node from the Texture object and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
texture | A shared pointer to a Texture object. |
poly | The polygon to define the mesh |
colors | The vertex colors |
|
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.
dst | The Node to copy into |
Reimplemented from cugl::scene2::TexturedNode.
|
overridevirtual |
Disposes all of the resources used by this node.
A disposed Node can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them.
It is unsafe to call this on a Node that is still currently inside of a scene graph.
Reimplemented from cugl::scene2::TexturedNode.
|
overridevirtual |
Draws this mesh node via the given SpriteBatch.
This method only worries about drawing the current node. It does not attempt to render the children.
batch | The SpriteBatch to draw with. |
transform | The global transformation matrix. |
tint | The tint to blend with the Node color. |
Implements cugl::scene2::TexturedNode.
const Rect cugl::scene2::MeshNode::getBoundingRect | ( | ) | const |
Returns the rect of the mesh node in points
The bounding rect is the smallest rectangle containing all of the points in the mesh.
This value also defines the content size of the node. The mesh will be shifted so that its bounding rect is centered at the node center.
|
inline |
Returns a reference to the underlying mesh.
|
inline |
Returns a reference to the underlying mesh.
graphics::SpriteVertex * cugl::scene2::MeshNode::getVertex | ( | size_t | index | ) |
Returns a pointer to the sprite vertex as the given index
This sprite vertex can be updated to change the vertex position, color, texture coordinates, or gradient coordinates. If there is not vertex as that index, this method returns nullptr.
index | The sprite index |
const graphics::SpriteVertex * cugl::scene2::MeshNode::getVertex | ( | size_t | index | ) | const |
Returns a pointer to the sprite vertex as the given index
This sprite vertex can be updated to change the vertex position, color, texture coordinates, or gradient coordinates. If there is not vertex as that index, this method returns nullptr.
index | The sprite index |
|
overridevirtual |
Initializes a mesh node as a default equilateral triangle mesh.
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes. The vertex colors will be blue, red, and yellow.
Reimplemented from cugl::scene2::TexturedNode.
|
overridevirtual |
Initializes a mesh node with the given JSON specification.
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:
"mesh": A JSON object defining a mesh of SpriteVertex
This JSON object for mesh is required. The mesh can be represented as either an array or JSON object. If it is an array, it contains JSON values compatible with the graphics::SpriteVertex
constructor. If it is a JSON object, then it supports the following attributes:
"vertices": An array {@link SpriteVertex} descriptions "indices": An intenger list of triangle indices (in multiples of 3) "triangulator": One of 'monotone', 'earclip', 'delaunay', 'fan', or 'strip'
All attributes are optional. If "vertices" are missing, the mesh will be empty. If both "indices" and "triangulator" are missing, the mesh will use a triangle fan. The "triangulator" choice will only be applied if the "indices" are missing.
manager | The asset manager handling this asset |
data | The JSON object specifying the node |
Reimplemented from cugl::scene2::TexturedNode.
|
overridevirtual |
Initializes a mesh node from the image filename.
After creation, the mesh will be a rectangle. The vertices of this mesh will be the corners of the image. The rectangle will be triangulated with the standard two triangles. The colors of all the vertices will be white.
filename | A path to image file, e.g., "scene1/earthtile.png" |
Reimplemented from cugl::scene2::TexturedNode.
bool cugl::scene2::MeshNode::initWithFileMesh | ( | const std::string | filename, |
const graphics::Mesh< graphics::SpriteVertex > & | mesh | ||
) |
Initializes a mesh node from the image filename and mesh
The texture coordinates in the mesh will determine how to interpret the texture.
filename | A path to image file, e.g., "scene1/earthtile.png" |
mesh | The mesh data |
bool cugl::scene2::MeshNode::initWithFilePoly | ( | const std::string | filename, |
const Poly2 & | poly | ||
) |
Initializes a mesh node from the image filename and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices will all have color white
filename | A path to image file, e.g., "scene1/earthtile.png" |
poly | The polygon to define the mesh |
bool cugl::scene2::MeshNode::initWithFilePoly | ( | const std::string | filename, |
const Poly2 & | poly, | ||
const std::vector< Color4 > & | colors | ||
) |
Initializes a mesh node from the image filename and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
filename | A path to image file, e.g., "scene1/earthtile.png" |
poly | The polygon to define the mesh |
colors | The vertex colors |
|
inline |
Initializes a mesh node from the current mesh
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes.
mesh | The mesh data |
|
inline |
Initializes a mesh node using from a polygon.
This method uses the polygon to construct a mesh for the mesh node. The colors of all the vertices will be white.
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes.
poly | The polygon to define the mesh |
|
inline |
Initializes a mesh node using from a polygon and set of colors.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
The mesh will use the texture graphics::Texture#getBlank
, which is suitable for drawing solid shapes.
poly | The polygon to define the mesh |
colors | The vertex colors |
|
overridevirtual |
Initializes a mesh node from a Texture object.
After creation, the mesh will be a rectangle. The vertices of this mesh will be the corners of the image. The rectangle will be triangulated with the standard two triangles. The colors of all the vertices will be white.
texture | A shared pointer to a Texture object. |
Reimplemented from cugl::scene2::TexturedNode.
bool cugl::scene2::MeshNode::initWithTextureMesh | ( | const std::shared_ptr< graphics::Texture > & | texture, |
const graphics::Mesh< graphics::SpriteVertex > & | mesh | ||
) |
Initializes a mesh node from the Texture object and mesh
The texture coordinates in the mesh will determine how to interpret the texture.
texture | A shared pointer to a Texture object. |
mesh | The mesh data |
bool cugl::scene2::MeshNode::initWithTexturePoly | ( | const std::shared_ptr< graphics::Texture > & | texture, |
const Poly2 & | poly | ||
) |
Initializes a mesh node from the Texture object and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices will all have color white
texture | A shared pointer to a Texture object. |
poly | The polygon to define the mesh |
bool cugl::scene2::MeshNode::initWithTexturePoly | ( | const std::shared_ptr< graphics::Texture > & | texture, |
const Poly2 & | poly, | ||
const std::vector< Color4 > & | colors | ||
) |
Initializes a mesh node from the Texture object and the given polygon.
This method uses the polygon to construct a mesh for the mesh node. The vertices are assigned the respective colors from the colors vector, in the order that they are specified in the polygon.
texture | A shared pointer to a Texture object. |
poly | The polygon to define the mesh |
colors | The vertex colors |
void cugl::scene2::MeshNode::setMesh | ( | const graphics::Mesh< graphics::SpriteVertex > & | mesh | ) |
Sets the mesh for the mesh node.
mesh | The updated mesh. |
void cugl::scene2::MeshNode::setMesh | ( | graphics::Mesh< graphics::SpriteVertex > && | mesh | ) |
Sets the mesh for the mesh node.
mesh | The updated mesh. |
void cugl::scene2::MeshNode::setPolygon | ( | const Poly2 & | poly | ) |
Sets the mesh to match the given polygon.
The mesh textures and colors will be recomputed as if this were a PolygonNode
.
poly | The new poly2 object. |
void cugl::scene2::MeshNode::setVertexColors | ( | const std::vector< Color4 > & | colors | ) |
Sets the colors of the mesh vertices.
The parameter vector should have a size equal to the number of vertices. If it is too long, extra colors are ignored. If it is too short, the the final color will be used for all remaining vertices.
colors | The vertex colors |
void cugl::scene2::MeshNode::setVertexGradCoords | ( | const std::vector< Vec2 > & | coords | ) |
Sets the gradient coordinates of the mesh vertices.
The parameter vector should have a size equal to the number of vertices. If it is too long, extra coordinates are ignored. If it is too short, the the final texture coordinate will be used for all remaining vertices.
coords | The gradient coordinates |
void cugl::scene2::MeshNode::setVertexTexCoords | ( | const std::vector< Vec2 > & | coords | ) |
Sets the texture coordinates of the mesh vertices.
The parameter vector should have a size equal to the number of vertices. If it is too long, extra coordinates are ignored. If it is too short, the the final texture coordinate will be used for all remaining vertices.
coords | The texture coordinates |
|
protected |
Used to keep track of the current flip state