Table of Contents

Class ImporterMesh

Namespace
Godot
Assembly
GodotSharp.dll

ImporterMesh is a type of Resource analogous to ArrayMesh. It contains vertex array-based geometry, divided in surfaces. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.

Unlike its runtime counterpart, ImporterMesh contains mesh data before various import steps, such as lod and shadow mesh generation, have taken place. Modify surface data by calling Clear(), followed by AddSurface(PrimitiveType, Array, Array<Array>, Dictionary, Material, string, ulong) for each surface.

public class ImporterMesh : Resource, IDisposable
Inheritance
ImporterMesh
Implements
Inherited Members

Constructors

ImporterMesh()

public ImporterMesh()

Properties

_Data

public Dictionary _Data { get; set; }

Property Value

Dictionary

Methods

AddBlendShape(string)

Adds name for a blend shape that will be added with AddSurface(PrimitiveType, Array, Array<Array>, Dictionary, Material, string, ulong). Must be called before surface is added.

public void AddBlendShape(string name)

Parameters

name string

AddSurface(PrimitiveType, Array, Array<Array>, Dictionary, Material, string, ulong)

Creates a new surface. GetSurfaceCount() will become the surf_idx for this new surface.

Surfaces are created to be rendered using a primitive, which may be any of the values defined in Mesh.PrimitiveType.

The arrays argument is an array of arrays. Each of the Max elements contains an array with some of the mesh data for this surface as described by the corresponding member of Mesh.ArrayType or null if it is not used by the surface. For example, arrays[0] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this surface into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array (or be an exact multiple of the vertex array's length, when multiple elements of a sub-array correspond to a single vertex) or be empty, except for Index if it is used.

The blendShapes argument is an array of vertex data for each blend shape. Each element is an array of the same structure as arrays, but Vertex, Normal, and Tangent are set if and only if they are set in arrays and all other entries are null.

The lods argument is a dictionary with float keys and int[] values. Each entry in the dictionary represents a LOD level of the surface, where the value is the Index array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of a LOD also increases the distance that the objects has to be from the camera before the LOD is used.

The flags argument is the bitwise or of, as required: One value of Mesh.ArrayCustomFormat left shifted by ARRAY_FORMAT_CUSTOMn_SHIFT for each custom channel in use, FlagUseDynamicUpdate, FlagUse8BoneWeights, or FlagUsesEmptyVertexArray.

Note: When using indices, it is recommended to only use points, lines, or triangles.

public void AddSurface(Mesh.PrimitiveType primitive, Array arrays, Array<Array> blendShapes = null, Dictionary lods = null, Material material = null, string name = "", ulong flags = 0)

Parameters

primitive Mesh.PrimitiveType
arrays Array
blendShapes Array<Array>
lods Dictionary
material Material
name string
flags ulong

Clear()

Removes all surfaces and blend shapes from this ImporterMesh.

public void Clear()

GenerateLods(float, float, Array)

Generates all lods for this ImporterMesh.

normalMergeAngle and normalSplitAngle are in degrees and used in the same way as the importer settings in lods. As a good default, use 25 and 60 respectively.

The number of generated lods can be accessed using GetSurfaceLodCount(int), and each LOD is available in GetSurfaceLodSize(int, int) and GetSurfaceLodIndices(int, int).

boneTransformArray is an Array which can be either empty or contain Transform3Ds which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.

public void GenerateLods(float normalMergeAngle, float normalSplitAngle, Array boneTransformArray)

Parameters

normalMergeAngle float
normalSplitAngle float
boneTransformArray Array

GetBlendShapeCount()

Returns the number of blend shapes that the mesh holds.

public int GetBlendShapeCount()

Returns

int

GetBlendShapeMode()

Returns the blend shape mode for this Mesh.

public Mesh.BlendShapeMode GetBlendShapeMode()

Returns

Mesh.BlendShapeMode

GetBlendShapeName(int)

Returns the name of the blend shape at this index.

public string GetBlendShapeName(int blendShapeIdx)

Parameters

blendShapeIdx int

Returns

string

GetLightmapSizeHint()

Returns the size hint of this mesh for lightmap-unwrapping in UV-space.

public Vector2I GetLightmapSizeHint()

Returns

Vector2I

GetMesh(ArrayMesh)

Returns the mesh data represented by this ImporterMesh as a usable ArrayMesh.

This method caches the returned mesh, and subsequent calls will return the cached data until Clear() is called.

If not yet cached and baseMesh is provided, baseMesh will be used and mutated.

public ArrayMesh GetMesh(ArrayMesh baseMesh = null)

Parameters

baseMesh ArrayMesh

Returns

ArrayMesh

GetSurfaceArrays(int)

Returns the arrays for the vertices, normals, UVs, etc. that make up the requested surface. See AddSurface(PrimitiveType, Array, Array<Array>, Dictionary, Material, string, ulong).

public Array GetSurfaceArrays(int surfaceIdx)

Parameters

surfaceIdx int

Returns

Array

GetSurfaceBlendShapeArrays(int, int)

Returns a single set of blend shape arrays for the requested blend shape index for a surface.

public Array GetSurfaceBlendShapeArrays(int surfaceIdx, int blendShapeIdx)

Parameters

surfaceIdx int
blendShapeIdx int

Returns

Array

GetSurfaceCount()

Returns the number of surfaces that the mesh holds.

public int GetSurfaceCount()

Returns

int

GetSurfaceFormat(int)

Returns the format of the surface that the mesh holds.

public ulong GetSurfaceFormat(int surfaceIdx)

Parameters

surfaceIdx int

Returns

ulong

GetSurfaceLodCount(int)

Returns the number of lods that the mesh holds on a given surface.

public int GetSurfaceLodCount(int surfaceIdx)

Parameters

surfaceIdx int

Returns

int

GetSurfaceLodIndices(int, int)

Returns the index buffer of a lod for a surface.

public int[] GetSurfaceLodIndices(int surfaceIdx, int lodIdx)

Parameters

surfaceIdx int
lodIdx int

Returns

int[]

GetSurfaceLodSize(int, int)

Returns the screen ratio which activates a lod for a surface.

public float GetSurfaceLodSize(int surfaceIdx, int lodIdx)

Parameters

surfaceIdx int
lodIdx int

Returns

float

GetSurfaceMaterial(int)

Returns a Material in a given surface. Surface is rendered using this material.

public Material GetSurfaceMaterial(int surfaceIdx)

Parameters

surfaceIdx int

Returns

Material

GetSurfaceName(int)

Gets the name assigned to this surface.

public string GetSurfaceName(int surfaceIdx)

Parameters

surfaceIdx int

Returns

string

GetSurfacePrimitiveType(int)

Returns the primitive type of the requested surface (see AddSurface(PrimitiveType, Array, Array<Array>, Dictionary, Material, string, ulong)).

public Mesh.PrimitiveType GetSurfacePrimitiveType(int surfaceIdx)

Parameters

surfaceIdx int

Returns

Mesh.PrimitiveType

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetBlendShapeMode(BlendShapeMode)

Sets the blend shape mode to one of Mesh.BlendShapeMode.

public void SetBlendShapeMode(Mesh.BlendShapeMode mode)

Parameters

mode Mesh.BlendShapeMode

SetLightmapSizeHint(Vector2I)

Sets the size hint of this mesh for lightmap-unwrapping in UV-space.

public void SetLightmapSizeHint(Vector2I size)

Parameters

size Vector2I

SetSurfaceMaterial(int, Material)

Sets a Material for a given surface. Surface will be rendered using this material.

public void SetSurfaceMaterial(int surfaceIdx, Material material)

Parameters

surfaceIdx int
material Material

SetSurfaceName(int, string)

Sets a name for a given surface.

public void SetSurfaceName(int surfaceIdx, string name)

Parameters

surfaceIdx int
name string