Table of Contents

Mesh

Inherits: Sprite

Supported platforms:

Available since version: Gideros 2012.09

Description:

Mesh class is used to create and display custom constructed set of triangles (triangle meshes). It basically consists of
4 arrays: vertex, index, color (optional), textureCoordinate (optional) and a texture (optional) and it provides more than
one way to set/modify these arrays.
Mesh can be 2D or 3D, the latter expects an additionnal Z coordinate in its vertices. Additionnally, 3D meshes and their children are rendered with depth testing enabled, which prevents far objects to be drawn above nearest ones, irrespective of actual drawing order.
Note 1: Mesh class doesn't do bounds check. If an element at index array points to an non-existent vertex, the application may crash.

Common uses and examples:

Mesh usage

local mesh = Mesh.new()
stage:addChild(mesh)
-- 1. vertex (0, 0)
-- 2. vertex (100, 0)
-- 3. vertex (100, 150)
-- 4. vertex (0, 150)
mesh:setVertexArray(0, 0,   100, 0,   100, 150,   0, 150)

-- 1. triangle from 1, 2 and 3 vertex
-- 2. triangle from 1, 3 and 4 vertex
mesh:setIndexArray(1, 2, 3,     1, 3, 4)

-- 1. vertex 0xff0000 color with 0.5 alpha
-- 2. vertex 0x00ff00 color with 0.7 alpha
-- 3. vertex 0x0000ff color with 1 alpha
-- 4. vertex 0xffff00 color with 0 alpha
mesh:setColorArray(0xff0000, 0.5, 0x00ff00, 0.7, 0x0000ff, 1.0, 0xffff00, 0)

Methods, events and properties:

Inherited Methods
EventDispatcher.new
EventDispatcher:addEventListener
EventDispatcher:dispatchEvent
EventDispatcher:hasEventListener
EventDispatcher:removeAllListeners
EventDispatcher:removeEventListener
Sprite.new
Sprite:addChild
Sprite:addChildAt
Sprite:clearBlendMode
Sprite:contains
Sprite:get
Sprite:getAlpha
Sprite:getAnchorPosition
Sprite:getBounds
Sprite:getChildAt
Sprite:getChildIndex
Sprite:getClip
Sprite:getColorTransform
Sprite:getHeight
Sprite:getLayoutConstraints
Sprite:getLayoutInfo
Sprite:getLayoutParameters
Sprite:getMatrix
Sprite:getNumChildren
Sprite:getParent
Sprite:getPosition
Sprite:getRotation
Sprite:getRotationX
Sprite:getRotationY
Sprite:getScale
Sprite:getScaleX
Sprite:getScaleY
Sprite:getScaleZ
Sprite:getSkew
Sprite:getSkewX
Sprite:getSkewY
Sprite:getWidth
Sprite:getX
Sprite:getY
Sprite:getZ
Sprite:globalToLocal
Sprite:hitTestPoint
Sprite:isVisible
Sprite:localToGlobal
Sprite:removeChild
Sprite:removeChildAt
Sprite:removeFromParent
Sprite:set
Sprite:setAlpha
Sprite:setAnchorPosition
Sprite:setBlendMode
Sprite:setClip
Sprite:setColorTransform
Sprite:setLayoutConstraints
Sprite:setLayoutParameters
Sprite:setMatrix
Sprite:setPosition
Sprite:setRotation
Sprite:setRotationX
Sprite:setRotationY
Sprite:setScale
Sprite:setScaleX
Sprite:setScaleY
Sprite:setScaleZ
Sprite:setShader
Sprite:setShaderConstant
Sprite:setSkew
Sprite:setSkewX
Sprite:setSkewY
Sprite:setStencilOperation
Sprite:setVisible
Sprite:setX
Sprite:setY
Sprite:setZ
Sprite:swapChildren
Sprite:swapChildrenAt
Object:getBaseClass
Object:getClass
Object:isInstanceOf