Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AESContext
- AStar2D
- AStar3D
- AStarGrid2D
- AudioEffectInstance (1)
- AudioSample
- AudioSamplePlayback
- AudioStreamPlayback (5)
- CameraFeed
- CharFXTransform
- ConfigFile
- Crypto
- DTLSServer
- DirAccess
- ENetConnection
- EditorContextMenuPlugin
- EditorDebuggerPlugin
- EditorDebuggerSession
- EditorExportPlatform (6)
- EditorExportPlugin
- EditorExportPreset
- EditorFeatureProfile
- EditorFileSystemImportFormatSupportQuery
- EditorInspectorPlugin
- EditorResourceConversionPlugin
- EditorResourcePreviewGenerator
- EditorResourceTooltipPlugin
- EditorSceneFormatImporter (4)
- EditorScenePostImport
- EditorScenePostImportPlugin
- EditorScript
- EditorTranslationParserPlugin
- EncodedObjectAsID
- EngineProfiler
- Expression
- FileAccess
- GLTFObjectModelProperty
- HMACContext
- HTTPClient
- HashingContext
- ImageFormatLoader (1)
- JavaClass
- JavaObject
- JavaScriptObject
- KinematicCollision2D
- KinematicCollision3D
- Lightmapper (1)
- MeshConvexDecompositionSettings
- MeshDataTool
- MultiplayerAPI (2)
- Mutex
- NavigationPathQueryParameters2D
- NavigationPathQueryParameters3D
- NavigationPathQueryResult2D
- NavigationPathQueryResult3D
- Node3DGizmo (1)
- OggPacketSequencePlayback
- OpenXRAPIExtension
- PCKPacker
- PackedDataContainerRef
- PacketPeer (8)
- PhysicsPointQueryParameters2D
- PhysicsPointQueryParameters3D
- PhysicsRayQueryParameters2D
- PhysicsRayQueryParameters3D
- PhysicsShapeQueryParameters2D
- PhysicsShapeQueryParameters3D
- PhysicsTestMotionParameters2D
- PhysicsTestMotionParameters3D
- PhysicsTestMotionResult2D
- PhysicsTestMotionResult3D
- RDAttachmentFormat
- RDFramebufferPass
- RDPipelineColorBlendState
- RDPipelineColorBlendStateAttachment
- RDPipelineDepthStencilState
- RDPipelineMultisampleState
- RDPipelineRasterizationState
- RDPipelineSpecializationConstant
- RDSamplerState
- RDShaderSource
- RDTextureFormat
- RDTextureView
- RDUniform
- RDVertexAttribute
- RandomNumberGenerator
- RegEx
- RegExMatch
- RenderSceneBuffers (2)
- RenderSceneBuffersConfiguration
- Resource (103)
- ResourceFormatLoader
- ResourceFormatSaver
- ResourceImporter (16)
- SceneState
- SceneTreeTimer
- Semaphore
- SkinReference
- StreamPeer (5)
- SurfaceTool
- TCPServer
- TLSOptions
- TextLine
- TextParagraph
- TextServer (1)
- Thread
- TranslationDomain
- TriangleMesh
- Tween
- Tweener (5)
- UDPServer
- UPNP
- UPNPDevice
- WeakRef
- WebRTCPeerConnection (1)
- XMLParser
- XRInterface (4)
- XRPose
- XRTracker (2)
- ZIPPacker
- ZIPReader
Table of contents
-
func clear() -> void -
func commit_to_surface(compression_flags: int = 0) -> intError -
func create_from_surface(surface: int) -> intError -
const func get_edge_count() -> int -
const func get_edge_faces(idx: int) -> PackedInt32Array -
const func get_edge_meta(idx: int) -> Variant -
const func get_edge_vertex(vertex: int) -> int -
const func get_face_count() -> int -
const func get_face_edge(edge: int) -> int -
const func get_face_meta(idx: int) -> Variant -
const func get_face_normal(idx: int) -> Vector3 -
const func get_face_vertex(vertex: int) -> int -
const func get_format() -> int -
const func get_material() -> Material -
const func get_vertex(idx: int) -> Vector3 -
const func get_vertex_bones(idx: int) -> PackedInt32Array -
const func get_vertex_color(idx: int) -> Color -
const func get_vertex_count() -> int -
const func get_vertex_edges(idx: int) -> PackedInt32Array -
const func get_vertex_faces(idx: int) -> PackedInt32Array -
const func get_vertex_meta(idx: int) -> Variant -
const func get_vertex_normal(idx: int) -> Vector3 -
const func get_vertex_tangent(idx: int) -> Plane -
const func get_vertex_uv(idx: int) -> Vector2 -
const func get_vertex_uv2(idx: int) -> Vector2 -
const func get_vertex_weights(idx: int) -> PackedFloat32Array -
func set_edge_meta(meta: Variant) -> void -
func set_face_meta(meta: Variant) -> void -
func set_material(material: Material) -> void -
func set_vertex(vertex: Vector3) -> void -
func set_vertex_bones(bones: PackedInt32Array) -> void -
func set_vertex_color(color: Color) -> void -
func set_vertex_meta(meta: Variant) -> void -
func set_vertex_normal(normal: Vector3) -> void -
func set_vertex_tangent(tangent: Plane) -> void -
func set_vertex_uv(uv: Vector2) -> void -
func set_vertex_uv2(uv2: Vector2) -> void -
func set_vertex_weights(weights: PackedFloat32Array) -> void
MeshDataTool #
is_refcounted, is_instantiable, core, not_builtin_classes
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.
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)C#
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);See also ArrayMesh, ImmediateMesh and SurfaceTool for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Members #
Methods #
func clear() -> void#
Clears all data currently in MeshDataTool.
func commit_to_surface(compression_flags: int = 0) -> intError#
Adds a new surface to specified Mesh with edited data.
func create_from_surface(surface: int) -> intError#
Uses specified surface of given Mesh to populate data for MeshDataTool.
Requires Mesh with primitive type Mesh.PRIMITIVE_TRIANGLES.
const func get_edge_faces(idx: int) -> PackedInt32Array#
Returns array of faces that touch given edge.
const func get_edge_meta(idx: int) -> Variant#
Returns meta information assigned to given edge.
const func get_edge_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.
const func get_face_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.
const func get_face_meta(idx: int) -> Variant#
Returns the metadata associated with the given face.
const func get_face_normal(idx: int) -> Vector3#
Calculates and returns the face normal of the given face.
const func get_face_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.
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)C#
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);const func get_format() -> int#
Returns the Mesh's format as a combination of the Mesh.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.
const func get_vertex(idx: int) -> Vector3#
Returns the position of the given vertex.
const func get_vertex_bones(idx: int) -> PackedInt32Array#
Returns the bones of the given vertex.
const func get_vertex_color(idx: int) -> Color#
Returns the color of the given vertex.
const func get_vertex_edges(idx: int) -> PackedInt32Array#
Returns an array of edges that share the given vertex.
const func get_vertex_faces(idx: int) -> PackedInt32Array#
Returns an array of faces that share the given vertex.
const func get_vertex_meta(idx: int) -> Variant#
Returns the metadata associated with the given vertex.
const func get_vertex_normal(idx: int) -> Vector3#
Returns the normal of the given vertex.
const func get_vertex_tangent(idx: int) -> Plane#
Returns the tangent of the given vertex.
const func get_vertex_uv(idx: int) -> Vector2#
Returns the UV of the given vertex.
const func get_vertex_uv2(idx: int) -> Vector2#
Returns the UV2 of the given vertex.
const func get_vertex_weights(idx: int) -> PackedFloat32Array#
Returns bone weights of the given vertex.
func set_edge_meta(meta: Variant) -> void#
Sets the metadata of the given edge.
func set_face_meta(meta: Variant) -> void#
Sets the metadata of the given face.
func set_material(material: Material) -> void#
Sets the material to be used by newly-constructed Mesh.
func set_vertex(vertex: Vector3) -> void#
Sets the position of the given vertex.
func set_vertex_bones(bones: PackedInt32Array) -> void#
Sets the bones of the given vertex.
func set_vertex_color(color: Color) -> void#
Sets the color of the given vertex.
func set_vertex_meta(meta: Variant) -> void#
Sets the metadata associated with the given vertex.
func set_vertex_normal(normal: Vector3) -> void#
Sets the normal of the given vertex.
func set_vertex_tangent(tangent: Plane) -> void#
Sets the tangent of the given vertex.
func set_vertex_uv(uv: Vector2) -> void#
Sets the UV of the given vertex.
func set_vertex_uv2(uv2: Vector2) -> void#
Sets the UV2 of the given vertex.
func set_vertex_weights(weights: PackedFloat32Array) -> void#
Sets the bone weights of the given vertex.