diff options
Diffstat (limited to 'doc/classes/ArrayMesh.xml')
-rw-r--r-- | doc/classes/ArrayMesh.xml | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index b45716544a..dc834474ad 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -6,27 +6,48 @@ <description> The [ArrayMesh] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle: - [codeblock] + [codeblocks] + [gdscript] var vertices = PackedVector3Array() 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 = MeshInstance3D.new() m.mesh = arr_mesh - [/codeblock] + [/gdscript] + [csharp] + var vertices = new Godot.Collections.Array<Vector3>(); + vertices.Add(new Vector3(0, 1, 0)); + vertices.Add(new Vector3(1, 0, 0)); + vertices.Add(new Vector3(0, 0, 1)); + + // Initialize the ArrayMesh. + var arrMesh = new ArrayMesh(); + var arrays = new Godot.Collections.Array(); + arrays.Resize((int)ArrayMesh.ArrayType.Max); + arrays[(int)ArrayMesh.ArrayType.Vertex] = vertices; + + // Create the Mesh. + arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays); + var m = new MeshInstance(); + m.Mesh = arrMesh; + [/csharp] + [/codeblocks] The [MeshInstance3D] is ready to be added to the [SceneTree] to be shown. See also [ImmediateGeometry3D], [MeshDataTool] and [SurfaceTool] for procedural geometry generation. [b]Note:[/b] Godot uses clockwise [url=https://learnopengl.com/Advanced-OpenGL/Face-culling]winding order[/url] for front faces of triangle primitive modes. </description> <tutorials> - <link>https://docs.godotengine.org/en/latest/tutorials/content/procedural_geometry/arraymesh.html</link> + <link title="Procedural geometry using the ArrayMesh">https://docs.godotengine.org/en/latest/tutorials/content/procedural_geometry/arraymesh.html</link> </tutorials> <methods> <method name="add_blend_shape"> @@ -48,7 +69,6 @@ <argument index="2" name="blend_shapes" type="Array" default="[ ]"> </argument> <argument index="3" name="lods" type="Dictionary" default="{ - }"> </argument> <argument index="4" name="compress_flags" type="int" default="31744"> |