Skip to content

Commit

Permalink
Clarify how to convert PrimitiveMesh to ArrayMesh.
Browse files Browse the repository at this point in the history
It took me a bit to figure this out, as I was initially doing something
more complicated like this before I realized I just had to pass
get_mesh_arrays directly to add_surface_from_arrays.

```
var arr_mesh = ArrayMesh.new()
var arrays = []
arrays.resize(ArrayMesh.ARRAY_MAX)
arrays[ArrayMesh.ARRAY_VERTEX] = c.get_mesh_arrays()
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
```
  • Loading branch information
rcorre committed Jul 15, 2020
1 parent 08dda79 commit 933bf96
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion doc/classes/PrimitiveMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
<return type="Array">
</return>
<description>
Returns mesh arrays used to constitute surface of [Mesh]. Mesh arrays can be used with [ArrayMesh] to create new surfaces.
Returns mesh arrays used to constitute surface of [Mesh]. The result can be passed to [method ArrayMesh.add_surface_from_arrays] to create a new surface. For example:
[codeblock]
var c := CylinderMesh.new()
var arr_mesh := ArrayMesh.new()
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, c.get_mesh_arrays())
[/codeblock]
</description>
</method>
</methods>
Expand Down

0 comments on commit 933bf96

Please sign in to comment.