Add code example to ArrayMesh class docs
(cherry picked from commit 9b85866c07
)
This commit is contained in:
parent
f7bd6c1948
commit
8cdcd45561
|
@ -3,6 +3,23 @@
|
||||||
<brief_description>
|
<brief_description>
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
|
The [code]ArrayMesh[/code] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle
|
||||||
|
[codeblock]
|
||||||
|
var vertices = PoolVector3Array()
|
||||||
|
vertices.push_back(Vector3(0,1,0))
|
||||||
|
vertices.push_back(Vector3(1,0,0))
|
||||||
|
vertices.push_back(Vector3(0,0,1))
|
||||||
|
# Initialize the ArrayMesh.
|
||||||
|
var arr_mesh = ArrayMesh.new()
|
||||||
|
var arrays = []
|
||||||
|
arrays.resize(ArrayMesh.ARRAY_MAX)
|
||||||
|
arrays[ArrayMesh.ARRAY_VERTEX] = vertices
|
||||||
|
# Create the Mesh.
|
||||||
|
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
|
||||||
|
var m = MeshInstance.new()
|
||||||
|
m.mesh = arr_mesh
|
||||||
|
[/codeblock]
|
||||||
|
The [code]MeshInstance[/code] is ready to be added to the SceneTree to be shown.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
|
|
Loading…
Reference in New Issue