summaryrefslogtreecommitdiff
path: root/doc/classes/SurfaceTool.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/SurfaceTool.xml')
-rw-r--r--doc/classes/SurfaceTool.xml39
1 files changed, 27 insertions, 12 deletions
diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml
index e10b65e309..1195e4aa2b 100644
--- a/doc/classes/SurfaceTool.xml
+++ b/doc/classes/SurfaceTool.xml
@@ -5,13 +5,22 @@
</brief_description>
<description>
The [SurfaceTool] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from a script. All properties except indices need to be added before calling [method add_vertex]. For example, to add vertex colors and UVs:
- [codeblock]
+ [codeblocks]
+ [gdscript]
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_color(Color(1, 0, 0))
st.set_uv(Vector2(0, 0))
st.set_vertex(Vector3(0, 0, 0))
- [/codeblock]
+ [/gdscript]
+ [csharp]
+ var st = new SurfaceTool();
+ st.Begin(Mesh.PrimitiveType.Triangles);
+ st.SetColor(new Color(1, 0, 0));
+ st.SetUv(new Vector2(0, 0));
+ st.SetVertex(new Vector3(0, 0, 0));
+ [/csharp]
+ [/codeblocks]
The above [SurfaceTool] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calling [method set_uv] or [method set_color], then the last values would be used.
Vertex attributes must be passed [b]before[/b] calling [method add_vertex]. Failure to do so will result in an error when committing the vertex information to a mesh.
Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.
@@ -155,8 +164,8 @@
<argument index="0" name="flip" type="bool" default="false">
</argument>
<description>
- Generates normals from vertices so you do not have to do it manually. If [code]flip[/code] is [code]true[/code], the resulting normals will be inverted.
- Requires the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES].
+ Generates normals from vertices so you do not have to do it manually. If [code]flip[/code] is [code]true[/code], the resulting normals will be inverted. [method generate_normals] should be called [i]after[/i] generating geometry and [i]before[/i] committing the mesh using [method commit] or [method commit_to_arrays].
+ [b]Note:[/b] [method generate_normals] only works if the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES].
</description>
</method>
<method name="generate_tangents">
@@ -180,6 +189,12 @@
<description>
</description>
</method>
+ <method name="get_primitive" qualifiers="const">
+ <return type="int" enum="Mesh.PrimitiveType">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_skin_weight_count" qualifiers="const">
<return type="int" enum="SurfaceTool.SkinWeightCount">
</return>
@@ -190,7 +205,7 @@
<return type="void">
</return>
<description>
- Shrinks the vertex array by creating an index array (avoids reusing vertices).
+ Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
</description>
</method>
<method name="optimize_indices_for_cache">
@@ -205,7 +220,7 @@
<argument index="0" name="bones" type="PackedInt32Array">
</argument>
<description>
- Specifies an array of bones for the next vertex to use. [code]bones[/code] must contain 4 integers.
+ Specifies an array of bones to use for the [i]next[/i] vertex. [code]bones[/code] must contain 4 integers.
</description>
</method>
<method name="set_color">
@@ -214,7 +229,7 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
- Specifies a [Color] for the next vertex to use.
+ Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
[b]Note:[/b] The material must have [member BaseMaterial3D.vertex_color_use_as_albedo] enabled for the vertex color to be visible.
</description>
</method>
@@ -253,7 +268,7 @@
<argument index="0" name="normal" type="Vector3">
</argument>
<description>
- Specifies a normal for the next vertex to use.
+ Specifies a normal to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
</description>
</method>
<method name="set_skin_weight_count">
@@ -279,7 +294,7 @@
<argument index="0" name="tangent" type="Plane">
</argument>
<description>
- Specifies a tangent for the next vertex to use.
+ Specifies a tangent to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
</description>
</method>
<method name="set_uv">
@@ -288,7 +303,7 @@
<argument index="0" name="uv" type="Vector2">
</argument>
<description>
- Specifies a set of UV coordinates to use for the next vertex.
+ Specifies a set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
</description>
</method>
<method name="set_uv2">
@@ -297,7 +312,7 @@
<argument index="0" name="uv2" type="Vector2">
</argument>
<description>
- Specifies an optional second set of UV coordinates to use for the next vertex.
+ Specifies an optional second set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
</description>
</method>
<method name="set_weights">
@@ -306,7 +321,7 @@
<argument index="0" name="weights" type="PackedFloat32Array">
</argument>
<description>
- Specifies weight values for next vertex to use. [code]weights[/code] must contain 4 values.
+ Specifies weight values to use for the [i]next[/i] vertex. [code]weights[/code] must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
</description>
</method>
</methods>