class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS ObjectRefCounted MeshDataTool
Helper tool to access and edit Mesh data.

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 create_from_surface(). When you are finished editing the data commit the data to a mesh with commit_to_surface().

Below is an example of how MeshDataTool may be used.

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)

See also ArrayMesh, ImmediateMesh and SurfaceTool for procedural geometry generation.

void clear<>():void

Clears all data currently in MeshDataTool.

Error commit_to_surface<>( ArrayMesh mesh=, mesh:ArrayMesh=, int compression_flags=0, compression_flags:int=0, ):Error

Adds a new surface to specified Mesh with edited data.

Error create_from_surface<>( ArrayMesh mesh=, mesh:ArrayMesh=, int surface=, surface:int=, ):Error

Uses specified surface of given Mesh to populate data for MeshDataTool.

Requires Mesh with primitive type Mesh.PRIMITIVE_TRIANGLES.

int get_edge_count<>():int

Returns the number of edges in this Mesh.

PackedInt32Array get_edge_faces<>( int idx=, idx:int=, ):PackedInt32Array

Returns array of faces that touch given edge.

Variant get_edge_meta<>( int idx=, idx:int=, ):Variant

Returns meta information assigned to given edge.

int get_edge_vertex<>( int idx=, idx:int=, int vertex=, 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.

int get_face_count<>():int

Returns the number of faces in this Mesh.

int get_face_edge<>( int idx=, idx:int=, int edge=, 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.

Variant get_face_meta<>( int idx=, idx:int=, ):Variant

Returns the metadata associated with the given face.

Vector3 get_face_normal<>( int idx=, idx:int=, ):Vector3

Calculates and returns the face normal of the given face.

int get_face_vertex<>( int idx=, idx:int=, int vertex=, vertex:int=, ):int

Returns the specified vertex index of the given face.

vertex must be either 0, 1, or 2 because faces contain three vertices.

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)
int get_format<>():int

Returns the Mesh's format as a combination of the ArrayFormat flags. For example, a mesh containing both vertices and normals would return a format of 3 because Mesh.ARRAY_FORMAT_VERTEX is 1 and Mesh.ARRAY_FORMAT_NORMAL is 2.

Material get_material<>():Material

Returns the material assigned to the Mesh.

Vector3 get_vertex<>( int idx=, idx:int=, ):Vector3

Returns the position of the given vertex.

PackedInt32Array get_vertex_bones<>( int idx=, idx:int=, ):PackedInt32Array

Returns the bones of the given vertex.

Color get_vertex_color<>( int idx=, idx:int=, ):Color

Returns the color of the given vertex.

int get_vertex_count<>():int

Returns the total number of vertices in Mesh.

PackedInt32Array get_vertex_edges<>( int idx=, idx:int=, ):PackedInt32Array

Returns an array of edges that share the given vertex.

PackedInt32Array get_vertex_faces<>( int idx=, idx:int=, ):PackedInt32Array

Returns an array of faces that share the given vertex.

Variant get_vertex_meta<>( int idx=, idx:int=, ):Variant

Returns the metadata associated with the given vertex.

Vector3 get_vertex_normal<>( int idx=, idx:int=, ):Vector3

Returns the normal of the given vertex.

Plane get_vertex_tangent<>( int idx=, idx:int=, ):Plane

Returns the tangent of the given vertex.

Vector2 get_vertex_uv<>( int idx=, idx:int=, ):Vector2

Returns the UV of the given vertex.

Vector2 get_vertex_uv2<>( int idx=, idx:int=, ):Vector2

Returns the UV2 of the given vertex.

PackedFloat32Array get_vertex_weights<>( int idx=, idx:int=, ):PackedFloat32Array

Returns bone weights of the given vertex.

void set_edge_meta<>( int idx=, idx:int=, Variant meta=, meta:Variant=, ):void

Sets the metadata of the given edge.

void set_face_meta<>( int idx=, idx:int=, Variant meta=, meta:Variant=, ):void

Sets the metadata of the given face.

void set_material<>( Material material=, material:Material=, ):void

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

void set_vertex<>( int idx=, idx:int=, Vector3 vertex=, vertex:Vector3=, ):void

Sets the position of the given vertex.

void set_vertex_bones<>( int idx=, idx:int=, PackedInt32Array bones=, bones:PackedInt32Array=, ):void

Sets the bones of the given vertex.

void set_vertex_color<>( int idx=, idx:int=, Color color=, color:Color=, ):void

Sets the color of the given vertex.

void set_vertex_meta<>( int idx=, idx:int=, Variant meta=, meta:Variant=, ):void

Sets the metadata associated with the given vertex.

void set_vertex_normal<>( int idx=, idx:int=, Vector3 normal=, normal:Vector3=, ):void

Sets the normal of the given vertex.

void set_vertex_tangent<>( int idx=, idx:int=, Plane tangent=, tangent:Plane=, ):void

Sets the tangent of the given vertex.

void set_vertex_uv<>( int idx=, idx:int=, Vector2 uv=, uv:Vector2=, ):void

Sets the UV of the given vertex.

void set_vertex_uv2<>( int idx=, idx:int=, Vector2 uv2=, uv2:Vector2=, ):void

Sets the UV2 of the given vertex.

void set_vertex_weights<>( int idx=, idx:int=, PackedFloat32Array weights=, weights:PackedFloat32Array=, ):void

Sets the bone weights of the given vertex.




All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...