virtualx-engine/doc/classes/SurfaceTool.xml

246 lines
8.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" ?>
2019-04-01 12:33:56 +02:00
<class name="SurfaceTool" inherits="Reference" category="Core" version="3.2">
<brief_description>
Helper tool to create geometry.
</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]
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 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 add_uv] or [method add_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.
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_bones">
<return type="void">
</return>
<argument index="0" name="bones" type="PoolIntArray">
</argument>
<description>
Adds an array of bones for the next vertex to use. [code]bones[/code] must contain 4 integers.
</description>
</method>
<method name="add_color">
<return type="void">
</return>
<argument index="0" name="color" type="Color">
</argument>
<description>
Specifies 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 vertices.
</description>
</method>
<method name="add_normal">
<return type="void">
</return>
<argument index="0" name="normal" type="Vector3">
</argument>
<description>
Specifies 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>
Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
</description>
</method>
<method name="add_tangent">
<return type="void">
</return>
<argument index="0" name="tangent" type="Plane">
</argument>
<description>
Specifies a tangent for the next vertex to use.
</description>
</method>
<method name="add_triangle_fan">
<return type="void">
</return>
<argument index="0" name="vertices" 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>
Inserts a triangle fan made of array data into [Mesh] being constructed.
Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES].
</description>
</method>
<method name="add_uv">
<return type="void">
</return>
<argument index="0" name="uv" type="Vector2">
</argument>
<description>
Specifies a set of UV coordinates to use for the next vertex.
</description>
</method>
<method name="add_uv2">
<return type="void">
</return>
<argument index="0" name="uv2" type="Vector2">
</argument>
<description>
Specifies an optional second set of UV coordinates to use for the next vertex.
</description>
</method>
<method name="add_vertex">
<return type="void">
</return>
<argument index="0" name="vertex" type="Vector3">
</argument>
<description>
Specifies the 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>
Specifies weight values for next vertex to use. [code]weights[/code] must contain 4 values.
</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>
2018-10-25 15:14:36 +02:00
Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform].
</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. [constant 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>
<argument index="1" name="flags" type="int" default="97280">
2017-12-10 00:43:30 +01:00
</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].
Default flag is [constant Mesh.ARRAY_COMPRESS_DEFAULT]. See [code]Mesh.ARRAY_COMPRESS_*[/code] constants for other flags.
</description>
</method>
2019-05-28 18:08:13 +02:00
<method name="commit_to_arrays">
<return type="Array">
</return>
<description>
</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>
2018-10-25 15:14:36 +02:00
Creates a vertex array from an existing [Mesh].
</description>
</method>
2019-05-28 18:08:13 +02:00
<method name="create_from_blend_shape">
<return type="void">
</return>
<argument index="0" name="existing" type="Mesh">
</argument>
<argument index="1" name="surface" type="int">
</argument>
<argument index="2" name="blend_shape" type="String">
</argument>
<description>
</description>
</method>
<method name="deindex">
<return type="void">
</return>
<description>
Removes the index array by expanding the vertex array.
</description>
</method>
<method name="generate_normals">
<return type="void">
</return>
2018-02-14 20:14:23 +01:00
<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].
</description>
</method>
<method name="generate_tangents">
<return type="void">
</return>
<description>
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already.
</description>
</method>
<method name="index">
<return type="void">
</return>
<description>
Shrinks the 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>