Mesh: Difference between revisions
No edit summary |
wip |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
<!-- GIDEROSOBJ:Mesh --> | <!-- GIDEROSOBJ:Mesh --> | ||
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]][[File:Platform linux.png]]<br/> | ||
'''Available since:''' Gideros 2012.09<br/> | '''Available since:''' Gideros 2012.09<br/> | ||
'''Inherits from:''' [[Sprite]]<br/> | '''Inherits from:''' [[Sprite]]<br/> | ||
| Line 64: | Line 64: | ||
[[Mesh:resizeTextureCoordinateArray]] ''resizes the texture coordinates array''<br/><!--GIDEROSMTD:Mesh:resizeTextureCoordinateArray(size) resizes the texture coordinates array--> | [[Mesh:resizeTextureCoordinateArray]] ''resizes the texture coordinates array''<br/><!--GIDEROSMTD:Mesh:resizeTextureCoordinateArray(size) resizes the texture coordinates array--> | ||
[[Mesh:resizeVertexArray]] ''resizes the vertex array''<br/><!--GIDEROSMTD:Mesh:resizeVertexArray(size) resizes the vertex array--> | [[Mesh:resizeVertexArray]] ''resizes the vertex array''<br/><!--GIDEROSMTD:Mesh:resizeVertexArray(size) resizes the vertex array--> | ||
[[Mesh:setColor]] ''sets a color in the color array''<br/><!--GIDEROSMTD:Mesh:setColor(i,color,alpha) sets a color in the color array--> | [[Mesh:setColor]] ''sets a color in the color array''<br/><!--GIDEROSMTD:Mesh:setColor(i,color,alpha) sets a color in the color array--> | ||
[[Mesh:setColorArray]] ''sets or replace the whole color array''<br/><!--GIDEROSMTD:Mesh:setColorArray(colors) sets or replace the whole color array--> | [[Mesh:setColorArray]] ''sets or replace the whole color array''<br/><!--GIDEROSMTD:Mesh:setColorArray(colors) sets or replace the whole color array--> | ||
| Line 82: | Line 81: | ||
[[Mesh:setVertexArray]] ''sets or replace the whole vertex array''<br/><!--GIDEROSMTD:Mesh:setVertexArray(vertices) sets or replace the whole vertex array--> | [[Mesh:setVertexArray]] ''sets or replace the whole vertex array''<br/><!--GIDEROSMTD:Mesh:setVertexArray(vertices) sets or replace the whole vertex array--> | ||
[[Mesh:setVertices]] ''sets several vertices at once''<br/><!--GIDEROSMTD:Mesh:setVertices(vertices) sets several vertices at once--> | [[Mesh:setVertices]] ''sets several vertices at once''<br/><!--GIDEROSMTD:Mesh:setVertices(vertices) sets several vertices at once--> | ||
[[Mesh:updateBones]] ''updates bones for animation''<br/><!--GIDEROSMTD:Mesh:updateBones(bonestable) updates bones for animation--> | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
Latest revision as of 14:18, 3 September 2026
Supported platforms: ![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Available since: Gideros 2012.09
Inherits from: Sprite
Description
The 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). The Mesh class provides more than one way to set/modify these arrays.
The Mesh can be 2D or 3D, the latter expects an additional Z coordinate in its vertices. Additionally, 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.
the Mesh class doesn't do bounds check: if an element at index array points to an non-existent vertex, the application may crash
Example
Drawing a colored Mesh rectangle
application:configureFrustum(45, -2*128)
--application:configureFrustum(0, 2*128)
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)
MethodsMesh.new creates a new Mesh instance |
EventsConstants |