.. _stdlib_mesh_component: ==== Mesh ==== ++++++++++++ Type aliases ++++++++++++ .. _alias-MeshVisibility: .. das:attribute:: bitfield MeshVisibility : uint16 Specifies the visibility of a mesh in different cameras and shadow casting. :Fields: * **Camera0** (0x1) - Visible in cameras with :ref:`layerIdx ` == 0 * **Camera1** (0x2) - Visible in cameras with :ref:`layerIdx ` == 1 * **Camera2** (0x4) - Visible in cameras with :ref:`layerIdx ` == 2 * **Camera3** (0x8) - Visible in cameras with :ref:`layerIdx ` == 3 * **Camera4** (0x10) - Visible in cameras with :ref:`layerIdx ` == 4 * **Camera5** (0x20) - Visible in cameras with :ref:`layerIdx ` == 5 * **Camera6** (0x40) - Visible in cameras with :ref:`layerIdx ` == 6 * **Camera7** (0x80) - Visible in cameras with :ref:`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 +++++++ .. _struct-mesh_component-Mesh: .. das:attribute:: 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)) .. _function-mesh_component_Mesh_rq_setPerInstanceData_Mesh_float4_float4: .. das:function:: 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: .. _function-mesh_component__dot__rq_meshId_Mesh: .. das:operator:: Mesh.meshId() : MeshId .. _function-mesh_component__dot__rq_meshId_rq_clone_Mesh_MeshId: .. das:operator:: Mesh.meshId =(value: MeshId) MeshId of the mesh to render. Default is no mesh at all :Arguments: * **value** : :ref:`MeshId ` .. _function-mesh_component__dot__rq_materialId_Mesh: .. das:operator:: Mesh.materialId() : MaterialId .. _function-mesh_component__dot__rq_materialId_rq_clone_Mesh_MaterialId: .. das:operator:: Mesh.materialId =(value: MaterialId) MaterialId of the material to render. Default is DefaultMaterial :Arguments: * **value** : :ref:`MaterialId ` .. _function-mesh_component__dot__rq_visibility_Mesh: .. das:operator:: Mesh.visibility() : MeshVisibility .. _function-mesh_component__dot__rq_visibility_rq_clone_Mesh_MeshVisibility: .. das:operator:: 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: * **value** : :ref:`MeshVisibility ` .. _function-mesh_component__dot__rq_isStatic_Mesh: .. das:operator:: Mesh.isStatic() : bool .. _function-mesh_component__dot__rq_isStatic_rq_clone_Mesh_bool: .. das:operator:: 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 .. _function-mesh_component__dot__rq_color_Mesh: .. das:operator:: Mesh.color() : float4 Returns per instance color of the node. .. _function-mesh_component__dot__rq_color_rq_clone_Mesh_float4: .. das:operator:: 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 .. _function-mesh_component__dot__rq_uvRect_Mesh: .. das:operator:: Mesh.uvRect() : float4 Returns per instance UV rect of the node. .. _function-mesh_component__dot__rq_uvRect_rq_clone_Mesh_float4: .. das:operator:: 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