Mesh

Type aliases

bitfield MeshVisibility : uint16

Specifies the visibility of a mesh in different cameras and shadow casting.

Fields:
  • Camera0 (0x1) - Visible in cameras with layerIdx == 0

  • Camera1 (0x2) - Visible in cameras with layerIdx == 1

  • Camera2 (0x4) - Visible in cameras with layerIdx == 2

  • Camera3 (0x8) - Visible in cameras with layerIdx == 3

  • Camera4 (0x10) - Visible in cameras with layerIdx == 4

  • Camera5 (0x20) - Visible in cameras with layerIdx == 5

  • Camera6 (0x40) - Visible in cameras with layerIdx == 6

  • Camera7 (0x80) - Visible in cameras with layerIdx == 7

  • EditorCamera (0x100) - Visible in the editor camera

  • CastShadowsFromSun (0x200) - Casts shadows from the sun

  • CastShadowsFromLights (0x400) - Casts shadows from lights

  • DisableCulling (0x800) - Culling for this mesh is disabled

  • VisibleInAnyCamera (0x1ff) - Visible in any camera

  • CastAnyShadows (0x600) - Cast shadows from any light source

  • FullVisibility (0x7ff) - Fully visible in any camera and casts shadows from any light source

Classes

Mesh : NativeComponent

This component is used to render meshes with given materials.

To use this component, add the following line to your project file:

require engine.core_components.mesh_component // or require engine.core

Usage example:

var node = create_node(NodeData())
// *creating a cubeMesh using generate_mesh function, and requesting greenMaterial*
add_component(node, new Mesh(meshId = cubeMesh, materialId = greenMaterial))
Mesh.setPerInstanceData(color: float4; uvRect: float4)

Sets per instance color and UV offset rect to the node. Have same behaviour as set_color + set_uv_rect, but has less overhead. Using per instance data improves rendering performance, because the amount of draw calls gets significantly reduced.

Arguments:
  • color : float4 - The color to set

  • uvRect : float4 - The UV rect where .xy is uv offset and .zw is uv scale

Properties:

Mesh.meshId: MeshId
Mesh.meshId =(value: MeshId)

MeshId of the mesh to render. Default is no mesh at all

Arguments:
Mesh.materialId: MaterialId
Mesh.materialId =(value: MaterialId)

MaterialId of the material to render. Default is DefaultMaterial

Arguments:
Mesh.visibility: MeshVisibility
Mesh.visibility =(value: MeshVisibility)

Visibility bits of the mesh. Default is MeshVisibility.FullVisibility. It is used to hide the mesh from some cameras or to disable rendering shadows cast by the mesh.

Usage example:

// Here are some examples of how to set visibility:
let defaultVisibility = MeshVisibility.VisibleInAnyCamera | MeshVisibility.CastAnyShadows // is equal to 'MeshVisibility.FullVisibility'
let visibleOnlyInEditor = MeshVisibility EditorCamera | MeshVisibility.CastAnyShadows
let visibleButWithoutShadows = MeshVisibility.VisibleInAnyCamera
let visibleAndShadowsOnlyFromSun = MeshVisibility.VisibleInAnyCamera | MeshVisibility CastShadowsFromSun
let visibleOnlyInFirstAndEditorCamera = MeshVisibility Camera0 | MeshVisibility EditorCamera | MeshVisibility.CastAnyShadows
Arguments:
Mesh.isStatic: bool
Mesh.isStatic =(value: bool)

Static flag of the mesh. Default is false. If true, the mesh will be rendered as static geometry.

Arguments:
  • value : bool

Mesh.color: float4

Returns per instance color of the node.

Mesh.color =(color: float4)

Sets per instance color to the node. This color will override the material color for an instance.

Using per instance data improves rendering performance, because the amount of draw calls gets significantly reduced.

Arguments:
  • color : float4

Mesh.uvRect: float4

Returns per instance UV rect of the node.

Mesh.uvRect =(rect: float4)

Sets per instance UV rect to the node. Those UV rect will override the material UV rest for an instance.

Using per instance data improves rendering performance, because the amount of draw calls gets significantly reduced.

Arguments:
  • rect : float4