MeshLibrary
Inherits: Resource < RefCounted < Object
Description
Section titled “Description”Library of meshes.
A library of meshes. Contains a list of Mesh resources, each with a name and ID. Each item can also include collision and navigation shapes. This resource is used in GridMap.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| String | item/{index}/category |
&"" |
| Mesh | item/{index}/mesh |
|
| int | item/{index}/mesh_cast_shadow |
1 |
| Transform3D | item/{index}/mesh_transform |
Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) |
| String | item/{index}/name |
"" |
| int | item/{index}/navigation_layers |
1 |
| NavigationMesh | item/{index}/navigation_mesh |
|
| Transform3D | item/{index}/navigation_mesh_transform |
Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) |
| Texture2D | item/{index}/preview |
|
| Array | item/{index}/shapes |
[] |
Methods
Section titled “Methods”Property descriptions
Section titled “Property descriptions”item/{index}/category
String item/{index}/category = &""
The item’s category. Used to organize meshes in the GridMap editor. A category can include / as a delimiter to create subcategories.
item/{index}/mesh
Mesh item/{index}/mesh
The item’s mesh. Used by other parts of the engine (e.g. GridMap, which displays them in a 3D tile).
item/{index}/mesh_cast_shadow
int item/{index}/mesh_cast_shadow = 1
The shadow casting mode used by the item’s mesh. See RenderingSystem.ShadowCastingSetting.
item/{index}/mesh_transform
Transform3D item/{index}/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
The transform to apply to the item’s mesh.
item/{index}/name
String item/{index}/name = ""
The item’s name, shown in the editor. It can also be used to look up the item later using find_item_by_name().
item/{index}/navigation_layers
int item/{index}/navigation_layers = 1
The item’s navigation layers bitmask.
item/{index}/navigation_mesh
NavigationMesh item/{index}/navigation_mesh
The item’s navigation mesh.
item/{index}/navigation_mesh_transform
Transform3D item/{index}/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
The transform to apply to the item’s navigation mesh.
item/{index}/preview
Texture2D item/{index}/preview
The texture to use as the item’s preview icon in the editor.
item/{index}/shapes
Array item/{index}/shapes = []
The item’s collision shapes. The array should consist of Shape3D objects, each followed by a Transform3D that will be applied to it. For shapes that should not have a transform, use Transform3D.IDENTITY.
Method descriptions
Section titled “Method descriptions”clear
void clear()
Clears the library.
create_item
void create_item(id: int)
Creates a new item in the library with the given ID.
You can get an unused ID from get_last_unused_item_id().
find_item_by_name
int find_item_by_name(name: String) const
Returns the first item with the given name, or -1 if no item is found.
get_item_category
StringName get_item_category(id: int) const
Returns the category for a specific item id. See also set_item_category().
get_item_count
int get_item_count() const
Returns the number of items present in the library.
get_item_list
PackedInt32Array get_item_list() const
Returns the list of item IDs in use.
get_item_mesh
Mesh get_item_mesh(id: int) const
Returns the item’s mesh.
get_item_mesh_cast_shadow
RenderingSystem.ShadowCastingSetting get_item_mesh_cast_shadow(id: int) const
Returns the item’s shadow casting mode.
get_item_mesh_transform
Transform3D get_item_mesh_transform(id: int) const
Returns the transform applied to the item’s mesh.
get_item_name
String get_item_name(id: int) const
Returns the item’s name.
get_item_navigation_layers
int get_item_navigation_layers(id: int) const
Returns the item’s navigation layers bitmask.
get_item_navigation_mesh
NavigationMesh get_item_navigation_mesh(id: int) const
Returns the item’s navigation mesh.
get_item_navigation_mesh_transform
Transform3D get_item_navigation_mesh_transform(id: int) const
Returns the transform applied to the item’s navigation mesh.
get_item_preview
Texture2D get_item_preview(id: int) const
When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using set_item_preview(). Returns an empty Texture2D if no preview was manually set in a running project.
get_item_shapes
Array get_item_shapes(id: int) const
Returns an item’s collision shapes.
The array consists of each Shape3D followed by its Transform3D.
get_last_unused_item_id
int get_last_unused_item_id() const
Gets an unused ID for a new item.
remove_item
void remove_item(id: int)
Removes the item.
set_item_category
void set_item_category(id: int, category: StringName)
Sets the category for a specific item id for organization in the GridMap editor. A category can include / as a delimiter to create subcategories.
set_item_mesh
void set_item_mesh(id: int, mesh: Mesh)
Sets the item’s mesh.
set_item_mesh_cast_shadow
void set_item_mesh_cast_shadow(id: int, shadow_casting_setting: RenderingSystem.ShadowCastingSetting)
Sets the item’s shadow casting mode to shadow_casting_setting.
set_item_mesh_transform
void set_item_mesh_transform(id: int, mesh_transform: Transform3D)
Sets the transform to apply to the item’s mesh.
set_item_name
void set_item_name(id: int, name: String)
Sets the item’s name.
This name is shown in the editor. It can also be used to look up the item later using find_item_by_name().
set_item_navigation_layers
void set_item_navigation_layers(id: int, navigation_layers: int)
Sets the item’s navigation layers bitmask.
set_item_navigation_mesh
void set_item_navigation_mesh(id: int, navigation_mesh: NavigationMesh)
Sets the item’s navigation mesh.
set_item_navigation_mesh_transform
void set_item_navigation_mesh_transform(id: int, navigation_mesh: Transform3D)
Sets the transform to apply to the item’s navigation mesh.
set_item_preview
void set_item_preview(id: int, texture: Texture2D)
Sets a texture to use as the item’s preview icon in the editor.
set_item_shapes
void set_item_shapes(id: int, shapes: Array)
Sets an item’s collision shapes.
The array should consist of Shape3D objects, each followed by a Transform3D that will be applied to it. For shapes that should not have a transform, use Transform3D.IDENTITY.
