summaryrefslogtreecommitdiff
path: root/doc/classes/SurfaceTool.xml
blob: 93090d9d2e179d81b855252018c71b2911fc9315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SurfaceTool" inherits="Reference" category="Core" version="3.0-alpha">
	<brief_description>
		Helper tool to create geometry.
	</brief_description>
	<description>
		The [code]SurfaceTool[/code] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from script. All properties except index need to be added before a call to [method add_vertex]. For example adding vertex colors and UVs looks like
		[codeblock]
		var st = SurfaceTool.new()
		st.begin(Mesh.PRIMITIVE_TRIANGLES)
		st.add_color(Color(1, 0, 0))
		st.add_uv(Vector2(0, 0))
		st.add_vertex(Vector3(0, 0, 0))
		[/codeblock]
		The [code]SurfaceTool[/code] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calls to [method add_uv] or [method add_color] then the last values would be used.
		It is very important that vertex attributes are passed [b]before[/b] the call to [method add_vertex], failure to do this will result in an error when committing the vertex information to a mesh.
	</description>
	<tutorials>
	</tutorials>
	<demos>
	</demos>
	<methods>
		<method name="add_bones">
			<return type="void">
			</return>
			<argument index="0" name="bones" type="PoolIntArray">
			</argument>
			<description>
				Add an array of bones for the next Vertex to use.
			</description>
		</method>
		<method name="add_color">
			<return type="void">
			</return>
			<argument index="0" name="color" type="Color">
			</argument>
			<description>
				Specify a [Color] for the next Vertex to use.
			</description>
		</method>
		<method name="add_index">
			<return type="void">
			</return>
			<argument index="0" name="index" type="int">
			</argument>
			<description>
				Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.
			</description>
		</method>
		<method name="add_normal">
			<return type="void">
			</return>
			<argument index="0" name="normal" type="Vector3">
			</argument>
			<description>
				Specify a normal for the next Vertex to use.
			</description>
		</method>
		<method name="add_smooth_group">
			<return type="void">
			</return>
			<argument index="0" name="smooth" type="bool">
			</argument>
			<description>
				Specify whether current Vertex (if using only Vertex arrays) or current index (if also using index arrays) should utilize smooth normals for normal calculation.
			</description>
		</method>
		<method name="add_tangent">
			<return type="void">
			</return>
			<argument index="0" name="tangent" type="Plane">
			</argument>
			<description>
				Specify a Tangent for the next Vertex to use.
			</description>
		</method>
		<method name="add_to_format">
			<return type="void">
			</return>
			<argument index="0" name="flags" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="add_triangle_fan">
			<return type="void">
			</return>
			<argument index="0" name="vertexes" type="PoolVector3Array">
			</argument>
			<argument index="1" name="uvs" type="PoolVector2Array" default="PoolVector2Array(  )">
			</argument>
			<argument index="2" name="colors" type="PoolColorArray" default="PoolColorArray(  )">
			</argument>
			<argument index="3" name="uv2s" type="PoolVector2Array" default="PoolVector2Array(  )">
			</argument>
			<argument index="4" name="normals" type="PoolVector3Array" default="PoolVector3Array(  )">
			</argument>
			<argument index="5" name="tangents" type="Array" default="[  ]">
			</argument>
			<description>
				Insert a triangle fan made of array data into [Mesh] being constructed.
			</description>
		</method>
		<method name="add_uv">
			<return type="void">
			</return>
			<argument index="0" name="uv" type="Vector2">
			</argument>
			<description>
				Specify UV Coordinate for next Vertex to use.
			</description>
		</method>
		<method name="add_uv2">
			<return type="void">
			</return>
			<argument index="0" name="uv2" type="Vector2">
			</argument>
			<description>
				Specify an optional second set of UV coordinates for next Vertex to use.
			</description>
		</method>
		<method name="add_vertex">
			<return type="void">
			</return>
			<argument index="0" name="vertex" type="Vector3">
			</argument>
			<description>
				Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
			</description>
		</method>
		<method name="add_weights">
			<return type="void">
			</return>
			<argument index="0" name="weights" type="PoolRealArray">
			</argument>
			<description>
				Specify weight value for next Vertex to use.
			</description>
		</method>
		<method name="append_from">
			<return type="void">
			</return>
			<argument index="0" name="existing" type="Mesh">
			</argument>
			<argument index="1" name="surface" type="int">
			</argument>
			<argument index="2" name="transform" type="Transform">
			</argument>
			<description>
			</description>
		</method>
		<method name="begin">
			<return type="void">
			</return>
			<argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType">
			</argument>
			<description>
				Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).
			</description>
		</method>
		<method name="clear">
			<return type="void">
			</return>
			<description>
				Clear all information passed into the surface tool so far.
			</description>
		</method>
		<method name="commit">
			<return type="ArrayMesh">
			</return>
			<argument index="0" name="existing" type="ArrayMesh" default="null">
			</argument>
			<description>
				Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh].
			</description>
		</method>
		<method name="create_from">
			<return type="void">
			</return>
			<argument index="0" name="existing" type="Mesh">
			</argument>
			<argument index="1" name="surface" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="deindex">
			<return type="void">
			</return>
			<description>
				Removes index array by expanding Vertex array.
			</description>
		</method>
		<method name="generate_normals">
			<return type="void">
			</return>
			<description>
				Generates normals from Vertices so you do not have to do it manually.
			</description>
		</method>
		<method name="generate_tangents">
			<return type="void">
			</return>
			<description>
			</description>
		</method>
		<method name="index">
			<return type="void">
			</return>
			<description>
				Shrinks Vertex array by creating an index array. Avoids reusing Vertices.
			</description>
		</method>
		<method name="set_material">
			<return type="void">
			</return>
			<argument index="0" name="material" type="Material">
			</argument>
			<description>
				Sets [Material] to be used by the [Mesh] you are constructing.
			</description>
		</method>
	</methods>
	<constants>
	</constants>
</class>