@@ -21,6 +21,14 @@ Attributes are added before each vertex is added:
2121 st.add_vertex() # Captures normal and color above.
2222 st.set_normal() # Normal never added to a vertex.
2323
24+ .. code-tab :: csharp
25+
26+ st.SetNormal(); // Overwritten by normal below.
27+ st.SetNormal(); // Added to next vertex.
28+ st.SetColor(); // Added to next vertex.
29+ st.AddVertex(); // Captures normal and color above.
30+ st.SetNormal(); // Normal never added to a vertex.
31+
2432When finished generating your geometry with the :ref: `SurfaceTool <class_surfacetool >`
2533call ``commit() `` to finish generating the mesh. If an :ref: `ArrayMesh <class_ArrayMesh >` is passed
2634to ``commit() `` then it appends a new surface to the end of the ArrayMesh. While if nothing is passed
@@ -33,6 +41,12 @@ in, ``commit()`` returns an ArrayMesh.
3341 # Or:
3442 var mesh = st.commit()
3543
44+ .. code-tab :: csharp
45+
46+ st.Commit(mesh);
47+ // Or:
48+ var mesh = st.Commit();
49+
3650Code creates a triangle with indices
3751
3852.. tabs ::
@@ -59,6 +73,29 @@ Code creates a triangle with indices
5973 # Commit to a mesh.
6074 var mesh = st.commit()
6175
76+ .. code-tab :: csharp
77+
78+ var st = new SurfaceTool();
79+
80+ st.Begin(Mesh.PrimitiveType.Triangles);
81+
82+ // Prepare attributes for AddVertex.
83+ st.SetNormal(new Vector3(0, 0, 1));
84+ st.SetUV(new Vector2(0, 0));
85+ // Call last for each vertex, adds the above attributes.
86+ st.AddVertex(new Vector3(-1, -1, 0));
87+
88+ st.SetNormal(new Vector3(0, 0, 1));
89+ st.SetUV(new Vector2(0, 1));
90+ st.AddVertex(new Vector3(-1, 1, 0));
91+
92+ st.SetNormal(new Vector3(0, 0, 1));
93+ st.SetUV(new Vector2(1, 1));
94+ st.AddVertex(new Vector3(1, 1, 0));
95+
96+ // Commit to a mesh.
97+ var mesh = st.Commit();
98+
6299You can optionally add an index array, either by calling ``add_index() `` and adding
63100vertices to the index array or by calling ``index() `` which shrinks the vertex array
64101to remove duplicate vertices.
@@ -67,7 +104,7 @@ to remove duplicate vertices.
67104 .. code-tab :: gdscript GDScript
68105
69106 # Creates a quad from four corner vertices.
70- # Add_index does not need to be called before add_vertex.
107+ # add_index does not need to be called before add_vertex.
71108 st.add_index(0)
72109 st.add_index(1)
73110 st.add_index(2)
@@ -79,6 +116,21 @@ to remove duplicate vertices.
79116 # Alternatively:
80117 st.index()
81118
119+ .. code-tab :: csharp
120+
121+ // Creates a quad from four corner vertices.
122+ // AddIndex does not need to be called before AddVertex.
123+ st.AddIndex(0);
124+ st.AddIndex(1);
125+ st.AddIndex(2);
126+
127+ st.AddIndex(1);
128+ st.AddIndex(3);
129+ st.AddIndex(2);
130+
131+ // Alternatively:
132+ st.Index();
133+
82134Similarly, if you have an index array, but you want each vertex to be unique (e.g. because
83135you want to use unique normals or colors per face instead of per-vertex), you can call ``deindex() ``.
84136
@@ -87,6 +139,10 @@ you want to use unique normals or colors per face instead of per-vertex), you ca
87139
88140 st.deindex()
89141
142+ .. code-tab :: csharp
143+
144+ st.Deindex();
145+
90146If you don't add custom normals yourself, you can add them using ``generate_normals() ``, which should
91147be called after generating geometry and before committing the mesh using ``commit() `` or
92148``commit_to_arrays() ``. Calling ``generate_normals(true) `` will flip the resulting normals. As a side
@@ -105,6 +161,11 @@ normals set already.
105161 st.generate_normals()
106162 st.generate_tangents()
107163
164+ .. code-tab :: csharp
165+
166+ st.GenerateNormals();
167+ st.GenerateTangents();
168+
108169By default, when generating normals, they will be calculated on a per-face basis. If you want
109170smooth vertex normals, when adding vertices, call ``add_smooth_group() ``. ``add_smooth_group() ``
110171needs to be called while building the geometry, e.g. before the call to ``add_vertex() ``
0 commit comments