Difference between revisions of "Mesh"

From GiderosMobile
Line 11: Line 11:
 
<br />
 
<br />
 
<ul><br />
 
<ul><br />
<li>[[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.</li><br />
+
<li>[[Special:MyLanguage/Note 1:|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.</li><br />
 
</ul><br />
 
</ul><br />
 
<br /></translate>
 
<br /></translate>
Line 36: Line 36:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Mesh.new]] <br/>
+
[[Special:MyLanguage/Mesh.new|Mesh.new]] <br/>
[[Mesh:clearColorArray]] <br/>
+
[[Special:MyLanguage/Mesh:clearColorArray|Mesh:clearColorArray]] <br/>
[[Mesh:clearIndexArray]] <br/>
+
[[Special:MyLanguage/Mesh:clearIndexArray|Mesh:clearIndexArray]] <br/>
[[Mesh:clearTexture]] <br/>
+
[[Special:MyLanguage/Mesh:clearTexture|Mesh:clearTexture]] <br/>
[[Mesh:clearTextureCoordinateArray]] <br/>
+
[[Special:MyLanguage/Mesh:clearTextureCoordinateArray|Mesh:clearTextureCoordinateArray]] <br/>
[[Mesh:clearVertexArray]] <br/>
+
[[Special:MyLanguage/Mesh:clearVertexArray|Mesh:clearVertexArray]] <br/>
[[Mesh:getColor]] ''<translate>Returns color and alpha of the i-th element from color array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getColor|Mesh:getColor]] ''<translate>Returns color and alpha of the i-th element from color array</translate>''<br/>
[[Mesh:getColorArraySize]] ''<translate>Get size of the Color array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getColorArraySize|Mesh:getColorArraySize]] ''<translate>Get size of the Color array</translate>''<br/>
[[Mesh:getIndex]] ''<translate>Returns the i-th element from index array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getIndex|Mesh:getIndex]] ''<translate>Returns the i-th element from index array</translate>''<br/>
[[Mesh:getIndexArraySize]] ''<translate>Get size of the Index array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getIndexArraySize|Mesh:getIndexArraySize]] ''<translate>Get size of the Index array</translate>''<br/>
[[Mesh:getTextureCoordinate]] ''<translate>Returns u and v coordinate of the i-th element from texture coordinate array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getTextureCoordinate|Mesh:getTextureCoordinate]] ''<translate>Returns u and v coordinate of the i-th element from texture coordinate array</translate>''<br/>
[[Mesh:getTextureCoordinateArraySize]] ''<translate>Get size of the Texture Coordinate array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getTextureCoordinateArraySize|Mesh:getTextureCoordinateArraySize]] ''<translate>Get size of the Texture Coordinate array</translate>''<br/>
[[Mesh:getVertex]] ''<translate>Returns x and y coordinate of the i-th element from vertex array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getVertex|Mesh:getVertex]] ''<translate>Returns x and y coordinate of the i-th element from vertex array</translate>''<br/>
[[Mesh:getVertexArraySize]] ''<translate>Get size of the Vertices array</translate>''<br/>
+
[[Special:MyLanguage/Mesh:getVertexArraySize|Mesh:getVertexArraySize]] ''<translate>Get size of the Vertices array</translate>''<br/>
[[Mesh:resizeColorArray]] <br/>
+
[[Special:MyLanguage/Mesh:resizeColorArray|Mesh:resizeColorArray]] <br/>
[[Mesh:resizeIndexArray]] <br/>
+
[[Special:MyLanguage/Mesh:resizeIndexArray|Mesh:resizeIndexArray]] <br/>
[[Mesh:resizeTextureCoordinateArray]] <br/>
+
[[Special:MyLanguage/Mesh:resizeTextureCoordinateArray|Mesh:resizeTextureCoordinateArray]] <br/>
[[Mesh:resizeVertexArray]] <br/>
+
[[Special:MyLanguage/Mesh:resizeVertexArray|Mesh:resizeVertexArray]] <br/>
[[Mesh:setColor]] <br/>
+
[[Special:MyLanguage/Mesh:setColor|Mesh:setColor]] <br/>
[[Mesh:setColorArray]] <br/>
+
[[Special:MyLanguage/Mesh:setColorArray|Mesh:setColorArray]] <br/>
[[Mesh:setColors]] <br/>
+
[[Special:MyLanguage/Mesh:setColors|Mesh:setColors]] <br/>
[[Mesh:setGenericArray]] <br/>
+
[[Special:MyLanguage/Mesh:setGenericArray|Mesh:setGenericArray]] <br/>
[[Mesh:setIndex]] <br/>
+
[[Special:MyLanguage/Mesh:setIndex|Mesh:setIndex]] <br/>
[[Mesh:setIndexArray]] <br/>
+
[[Special:MyLanguage/Mesh:setIndexArray|Mesh:setIndexArray]] <br/>
[[Mesh:setIndices]] <br/>
+
[[Special:MyLanguage/Mesh:setIndices|Mesh:setIndices]] <br/>
[[Mesh:setTexture]] <br/>
+
[[Special:MyLanguage/Mesh:setTexture|Mesh:setTexture]] <br/>
[[Mesh:setTextureCoordinate]] <br/>
+
[[Special:MyLanguage/Mesh:setTextureCoordinate|Mesh:setTextureCoordinate]] <br/>
[[Mesh:setTextureCoordinateArray]] <br/>
+
[[Special:MyLanguage/Mesh:setTextureCoordinateArray|Mesh:setTextureCoordinateArray]] <br/>
[[Mesh:setTextureCoordinates]] <br/>
+
[[Special:MyLanguage/Mesh:setTextureCoordinates|Mesh:setTextureCoordinates]] <br/>
[[Mesh:setVertex]] <br/>
+
[[Special:MyLanguage/Mesh:setVertex|Mesh:setVertex]] <br/>
[[Mesh:setVertexArray]] <br/>
+
[[Special:MyLanguage/Mesh:setVertexArray|Mesh:setVertexArray]] <br/>
[[Mesh:setVertices]] <br/>
+
[[Special:MyLanguage/Mesh:setVertices|Mesh:setVertices]] <br/>
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}

Revision as of 16:35, 23 August 2018

Supported platforms: android, ios, mac, pc
Available since: 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.



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

Mesh.new
Mesh:clearColorArray
Mesh:clearIndexArray
Mesh:clearTexture
Mesh:clearTextureCoordinateArray
Mesh:clearVertexArray
Mesh:getColor Returns color and alpha of the i-th element from color array
Mesh:getColorArraySize Get size of the Color array
Mesh:getIndex Returns the i-th element from index array
Mesh:getIndexArraySize Get size of the Index array
Mesh:getTextureCoordinate Returns u and v coordinate of the i-th element from texture coordinate array
Mesh:getTextureCoordinateArraySize Get size of the Texture Coordinate array
Mesh:getVertex Returns x and y coordinate of the i-th element from vertex array
Mesh:getVertexArraySize Get size of the Vertices array
Mesh:resizeColorArray
Mesh:resizeIndexArray
Mesh:resizeTextureCoordinateArray
Mesh:resizeVertexArray
Mesh:setColor
Mesh:setColorArray
Mesh:setColors
Mesh:setGenericArray
Mesh:setIndex
Mesh:setIndexArray
Mesh:setIndices
Mesh:setTexture
Mesh:setTextureCoordinate
Mesh:setTextureCoordinateArray
Mesh:setTextureCoordinates
Mesh:setVertex
Mesh:setVertexArray
Mesh:setVertices

Events

Constants