Documentation
¶
Overview ¶
Package MeshDataTool provides methods for working with MeshDataTool object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AsMeshDataTool() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) Clear()
- func (self Instance) CommitToSurface(mesh [1]gdclass.ArrayMesh) error
- func (self Instance) CreateFromSurface(mesh [1]gdclass.ArrayMesh, surface int) error
- func (self Instance) GetEdgeCount() int
- func (self Instance) GetEdgeFaces(idx int) []int32
- func (self Instance) GetEdgeMeta(idx int) any
- func (self Instance) GetEdgeVertex(idx int, vertex int) int
- func (self Instance) GetFaceCount() int
- func (self Instance) GetFaceEdge(idx int, edge int) int
- func (self Instance) GetFaceMeta(idx int) any
- func (self Instance) GetFaceNormal(idx int) Vector3.XYZ
- func (self Instance) GetFaceVertex(idx int, vertex int) int
- func (self Instance) GetFormat() int
- func (self Instance) GetMaterial() [1]gdclass.Material
- func (self Instance) GetVertex(idx int) Vector3.XYZ
- func (self Instance) GetVertexBones(idx int) []int32
- func (self Instance) GetVertexColor(idx int) Color.RGBA
- func (self Instance) GetVertexCount() int
- func (self Instance) GetVertexEdges(idx int) []int32
- func (self Instance) GetVertexFaces(idx int) []int32
- func (self Instance) GetVertexMeta(idx int) any
- func (self Instance) GetVertexNormal(idx int) Vector3.XYZ
- func (self Instance) GetVertexTangent(idx int) Plane.NormalD
- func (self Instance) GetVertexUv(idx int) Vector2.XY
- func (self Instance) GetVertexUv2(idx int) Vector2.XY
- func (self Instance) GetVertexWeights(idx int) []float32
- func (self Instance) SetEdgeMeta(idx int, meta any)
- func (self Instance) SetFaceMeta(idx int, meta any)
- func (self Instance) SetMaterial(material [1]gdclass.Material)
- func (self Instance) SetVertex(idx int, vertex Vector3.XYZ)
- func (self Instance) SetVertexBones(idx int, bones []int32)
- func (self Instance) SetVertexColor(idx int, color Color.RGBA)
- func (self Instance) SetVertexMeta(idx int, meta any)
- func (self Instance) SetVertexNormal(idx int, normal Vector3.XYZ)
- func (self Instance) SetVertexTangent(idx int, tangent Plane.NormalD)
- func (self Instance) SetVertexUv(idx int, uv Vector2.XY)
- func (self Instance) SetVertexUv2(idx int, uv2 Vector2.XY)
- func (self Instance) SetVertexWeights(idx int, weights []float32)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Instance ¶
type Instance [1]gdclass.MeshDataTool
MeshDataTool provides access to individual vertices in a [Mesh]. It allows users to read and edit vertex data of meshes. It also creates an array of faces and edges. To use MeshDataTool, load a mesh with [method create_from_surface]. When you are finished editing the data commit the data to a mesh with [method commit_to_surface]. Below is an example of how MeshDataTool may be used. [codeblocks] [gdscript] var mesh = ArrayMesh.new() mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, BoxMesh.new().get_mesh_arrays()) var mdt = MeshDataTool.new() mdt.create_from_surface(mesh, 0) for i in range(mdt.get_vertex_count()):
var vertex = mdt.get_vertex(i) # In this example we extend the mesh by one unit, which results in separated faces as it is flat shaded. vertex += mdt.get_vertex_normal(i) # Save your change. mdt.set_vertex(i, vertex)
mesh.clear_surfaces() mdt.commit_to_surface(mesh) var mi = MeshInstance.new() mi.mesh = mesh add_child(mi) [/gdscript] [csharp] var mesh = new ArrayMesh(); mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, new BoxMesh().GetMeshArrays()); var mdt = new MeshDataTool(); mdt.CreateFromSurface(mesh, 0); for (var i = 0; i < mdt.GetVertexCount(); i++)
{ Vector3 vertex = mdt.GetVertex(i); // In this example we extend the mesh by one unit, which results in separated faces as it is flat shaded. vertex += mdt.GetVertexNormal(i); // Save your change. mdt.SetVertex(i, vertex); }
mesh.ClearSurfaces(); mdt.CommitToSurface(mesh); var mi = new MeshInstance(); mi.Mesh = mesh; AddChild(mi); [/csharp] [/codeblocks] See also [ArrayMesh], [ImmediateMesh] and [SurfaceTool] for procedural geometry generation. [b]Note:[/b] Godot uses clockwise [url=https://learnopengl.com/Advanced-OpenGL/Face-culling]winding order[/url] for front faces of triangle primitive modes.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsMeshDataTool ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) CommitToSurface ¶
Adds a new surface to specified [Mesh] with edited data.
func (Instance) CreateFromSurface ¶
Uses specified surface of given [Mesh] to populate data for MeshDataTool. Requires [Mesh] with primitive type [constant Mesh.PRIMITIVE_TRIANGLES].
func (Instance) GetEdgeCount ¶
Returns the number of edges in this [Mesh].
func (Instance) GetEdgeFaces ¶
Returns array of faces that touch given edge.
func (Instance) GetEdgeMeta ¶
Returns meta information assigned to given edge.
func (Instance) GetEdgeVertex ¶
Returns index of specified vertex connected to given edge. Vertex argument can only be 0 or 1 because edges are comprised of two vertices.
func (Instance) GetFaceCount ¶
Returns the number of faces in this [Mesh].
func (Instance) GetFaceEdge ¶
Returns specified edge associated with given face. Edge argument must be either 0, 1, or 2 because a face only has three edges.
func (Instance) GetFaceMeta ¶
Returns the metadata associated with the given face.
func (Instance) GetFaceNormal ¶
Calculates and returns the face normal of the given face.
func (Instance) GetFaceVertex ¶
Returns the specified vertex index of the given face. Vertex argument must be either 0, 1, or 2 because faces contain three vertices. [b]Example:[/b] [codeblocks] [gdscript] var index = mesh_data_tool.get_face_vertex(0, 1) # Gets the index of the second vertex of the first face. var position = mesh_data_tool.get_vertex(index) var normal = mesh_data_tool.get_vertex_normal(index) [/gdscript] [csharp] int index = meshDataTool.GetFaceVertex(0, 1); // Gets the index of the second vertex of the first face. Vector3 position = meshDataTool.GetVertex(index); Vector3 normal = meshDataTool.GetVertexNormal(index); [/csharp] [/codeblocks]
func (Instance) GetFormat ¶
Returns the [Mesh]'s format as a combination of the [enum Mesh.ArrayFormat] flags. For example, a mesh containing both vertices and normals would return a format of [code]3[/code] because [constant Mesh.ARRAY_FORMAT_VERTEX] is [code]1[/code] and [constant Mesh.ARRAY_FORMAT_NORMAL] is [code]2[/code].
func (Instance) GetMaterial ¶
Returns the material assigned to the [Mesh].
func (Instance) GetVertexBones ¶
Returns the bones of the given vertex.
func (Instance) GetVertexColor ¶
Returns the color of the given vertex.
func (Instance) GetVertexCount ¶
Returns the total number of vertices in [Mesh].
func (Instance) GetVertexEdges ¶
Returns an array of edges that share the given vertex.
func (Instance) GetVertexFaces ¶
Returns an array of faces that share the given vertex.
func (Instance) GetVertexMeta ¶
Returns the metadata associated with the given vertex.
func (Instance) GetVertexNormal ¶
Returns the normal of the given vertex.
func (Instance) GetVertexTangent ¶
Returns the tangent of the given vertex.
func (Instance) GetVertexUv ¶
Returns the UV of the given vertex.
func (Instance) GetVertexUv2 ¶
Returns the UV2 of the given vertex.
func (Instance) GetVertexWeights ¶
Returns bone weights of the given vertex.
func (Instance) SetEdgeMeta ¶
Sets the metadata of the given edge.
func (Instance) SetFaceMeta ¶
Sets the metadata of the given face.
func (Instance) SetMaterial ¶
Sets the material to be used by newly-constructed [Mesh].
func (Instance) SetVertexBones ¶
Sets the bones of the given vertex.
func (Instance) SetVertexColor ¶
Sets the color of the given vertex.
func (Instance) SetVertexMeta ¶
Sets the metadata associated with the given vertex.
func (Instance) SetVertexNormal ¶
Sets the normal of the given vertex.
func (Instance) SetVertexTangent ¶
Sets the tangent of the given vertex.
func (Instance) SetVertexUv ¶
Sets the UV of the given vertex.
func (Instance) SetVertexUv2 ¶
Sets the UV2 of the given vertex.
func (Instance) SetVertexWeights ¶
Sets the bone weights of the given vertex.