MeshDataTool

package
v0.0.0-...-5fa07e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package MeshDataTool provides methods for working with MeshDataTool object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsMeshDataTool() Instance
}

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 New

func New() Instance

func (Instance) AsMeshDataTool

func (self Instance) AsMeshDataTool() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) Clear

func (self Instance) Clear()

Clears all data currently in MeshDataTool.

func (Instance) CommitToSurface

func (self Instance) CommitToSurface(mesh [1]gdclass.ArrayMesh) error

Adds a new surface to specified [Mesh] with edited data.

func (Instance) CreateFromSurface

func (self Instance) CreateFromSurface(mesh [1]gdclass.ArrayMesh, surface int) error

Uses specified surface of given [Mesh] to populate data for MeshDataTool. Requires [Mesh] with primitive type [constant Mesh.PRIMITIVE_TRIANGLES].

func (Instance) GetEdgeCount

func (self Instance) GetEdgeCount() int

Returns the number of edges in this [Mesh].

func (Instance) GetEdgeFaces

func (self Instance) GetEdgeFaces(idx int) []int32

Returns array of faces that touch given edge.

func (Instance) GetEdgeMeta

func (self Instance) GetEdgeMeta(idx int) any

Returns meta information assigned to given edge.

func (Instance) GetEdgeVertex

func (self Instance) GetEdgeVertex(idx int, vertex int) int

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

func (self Instance) GetFaceCount() int

Returns the number of faces in this [Mesh].

func (Instance) GetFaceEdge

func (self Instance) GetFaceEdge(idx int, edge int) int

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

func (self Instance) GetFaceMeta(idx int) any

Returns the metadata associated with the given face.

func (Instance) GetFaceNormal

func (self Instance) GetFaceNormal(idx int) Vector3.XYZ

Calculates and returns the face normal of the given face.

func (Instance) GetFaceVertex

func (self Instance) GetFaceVertex(idx int, vertex int) int

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

func (self Instance) GetFormat() int

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

func (self Instance) GetMaterial() [1]gdclass.Material

Returns the material assigned to the [Mesh].

func (Instance) GetVertex

func (self Instance) GetVertex(idx int) Vector3.XYZ

Returns the position of the given vertex.

func (Instance) GetVertexBones

func (self Instance) GetVertexBones(idx int) []int32

Returns the bones of the given vertex.

func (Instance) GetVertexColor

func (self Instance) GetVertexColor(idx int) Color.RGBA

Returns the color of the given vertex.

func (Instance) GetVertexCount

func (self Instance) GetVertexCount() int

Returns the total number of vertices in [Mesh].

func (Instance) GetVertexEdges

func (self Instance) GetVertexEdges(idx int) []int32

Returns an array of edges that share the given vertex.

func (Instance) GetVertexFaces

func (self Instance) GetVertexFaces(idx int) []int32

Returns an array of faces that share the given vertex.

func (Instance) GetVertexMeta

func (self Instance) GetVertexMeta(idx int) any

Returns the metadata associated with the given vertex.

func (Instance) GetVertexNormal

func (self Instance) GetVertexNormal(idx int) Vector3.XYZ

Returns the normal of the given vertex.

func (Instance) GetVertexTangent

func (self Instance) GetVertexTangent(idx int) Plane.NormalD

Returns the tangent of the given vertex.

func (Instance) GetVertexUv

func (self Instance) GetVertexUv(idx int) Vector2.XY

Returns the UV of the given vertex.

func (Instance) GetVertexUv2

func (self Instance) GetVertexUv2(idx int) Vector2.XY

Returns the UV2 of the given vertex.

func (Instance) GetVertexWeights

func (self Instance) GetVertexWeights(idx int) []float32

Returns bone weights of the given vertex.

func (Instance) SetEdgeMeta

func (self Instance) SetEdgeMeta(idx int, meta any)

Sets the metadata of the given edge.

func (Instance) SetFaceMeta

func (self Instance) SetFaceMeta(idx int, meta any)

Sets the metadata of the given face.

func (Instance) SetMaterial

func (self Instance) SetMaterial(material [1]gdclass.Material)

Sets the material to be used by newly-constructed [Mesh].

func (Instance) SetVertex

func (self Instance) SetVertex(idx int, vertex Vector3.XYZ)

Sets the position of the given vertex.

func (Instance) SetVertexBones

func (self Instance) SetVertexBones(idx int, bones []int32)

Sets the bones of the given vertex.

func (Instance) SetVertexColor

func (self Instance) SetVertexColor(idx int, color Color.RGBA)

Sets the color of the given vertex.

func (Instance) SetVertexMeta

func (self Instance) SetVertexMeta(idx int, meta any)

Sets the metadata associated with the given vertex.

func (Instance) SetVertexNormal

func (self Instance) SetVertexNormal(idx int, normal Vector3.XYZ)

Sets the normal of the given vertex.

func (Instance) SetVertexTangent

func (self Instance) SetVertexTangent(idx int, tangent Plane.NormalD)

Sets the tangent of the given vertex.

func (Instance) SetVertexUv

func (self Instance) SetVertexUv(idx int, uv Vector2.XY)

Sets the UV of the given vertex.

func (Instance) SetVertexUv2

func (self Instance) SetVertexUv2(idx int, uv2 Vector2.XY)

Sets the UV2 of the given vertex.

func (Instance) SetVertexWeights

func (self Instance) SetVertexWeights(idx int, weights []float32)

Sets the bone weights of the given vertex.

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL