Assets
A Mesh is an Object that carries a 3D model made of vertices.
As of current version, the mesh vertices are read-only.
Functions
Computes and returns the smallest axis-aligned box that encompasses all of Assets's vertices, in local space (i.e. expressed from This.Pivot).
Flips the winding order of the mesh's triangles. Use this to debug or quickly fix a mesh that has the wrong triangles winding order.
Returns the vertex attributes at given index, as a table: { position, normal, uv, color },
- position is a Number3, the vertex position expressed in model space.
- normal is a Number3, the vertex normal expressed in model space.
- uv is a Number2, the vertex UV in texture coordinates.
- color is a Color, the vertex color.
As of current version, the vertex attributes are read-only. This is mostly useful to debug a mesh.
Properties
The bounding box represents the bounds of the Assets in model space (the space where vertices are placed).
It is the smallest axis-aligned box that encompasses all of Assets's vertices.
If you are looking for the bounding box in a different space, see Assets.ComputeLocalBoundingBox and Assets.ComputeWorldBoundingBox.
The center of the Assets's bounding box. Shortcut to Assets.BoundingBox.Center.
Returns Assets's depth, expressed in model space (the space where vertices are placed). Shortcut to Assets.BoundingBox.Size.Z.
Returns Assets's height, expressed in model space (the space where vertices are placed). Shortcut to Assets.BoundingBox.Size.Y.
Whether or not the mesh should ignore scene lighting, false by default. If true, the mesh won't be affected by any light and shadows from other objects.
Integer or table of integers between 1 and 12. Cameras only render meshes corresponding to their layers, and lights only affect meshes in matching layers.
A table of material properties, they are typically set for you when imported from an external file. See the Assets.Load function for detail on how to import a mesh.
The following properties can generally be accessed and changed: { metallic, roughness, albedo, emissive, cutout, opaque, doublesided, unlit, filtering },
- metallic is the metallic factor, expressed as a number between 0.0 and 1.0. It has no effect if the material uses a metallic-roughness map instead.
- roughness is the roughness factor, expressed as a number between 0.0 and 1.0. It has no effect if the material uses a metallic-roughness map instead.
- albedo is a Color. If the mesh has an albedo texture, it is applied multiplicatively.
- emissive is a Color. It has no effect if the mesh uses an emissive texture instead.
- cutout is a number between 0.0 and 1.0, this is the alpha cutout threshold.
- opaque is a boolean set to false by default. If your mesh is semi-transparent, set this to true.
- doublesided is a boolean set to false by default. This generally shouldn't be changed, unless for specific needs or to debug a mesh.
- unlit is a boolean, equivalent to Mesh.IsUnlit
- filtering is a boolean, whether or not filtering should be enabled for all textures of the mesh. Use this only if you need to fix how the mesh looks. Typically, each texture has its own filtering setting (currently not accessible, but set when importing).
In the current version, whether or not a mesh uses a metallic-roughness map, an albedo texture, an emissive texture and a normal map depends on the file it was imported from. There is currently no way to access or change these textures.
Note that the mesh metallic-roughness will only be used if Config.UsePBR is true.
Metallic-roughness is a lighting model that describes how a surface will look when under the effect of a Light, it is made of three components,
- the albedo is the base color. It usually comes from an albedo texture.
- the metallic value determines how reflective the surface must be. It usually comes from a metallic-roughness map. A value of 0.0 means non-metal (like wood) and 1.0 means pure metal (like gold).
- the roughness value determines how rough the surface must be, making reflections sharp or diffuse accross the surface. It usually comes from a metallic-roughness map. A value of 0.0 means smooth (like a mirror) and 1.0 means rough (like chalk).
A metallic-roughness map allows to make different part of the mesh have different reflective properties, eg. make only some parts look like a metal while others do not reflect the light. If the mesh doesn't have one, setting the metallic and roughness values will affect the entirety of the mesh surface.
Likewise, an emissive map will allow to make only some parts of the mesh emissive. Otherwise, the emissive color is applied to the whole mesh.
The maximum point of the Assets's bounding box. Shortcut to Assets.BoundingBox.Max.
The minimum point of the Assets's bounding box. Shortcut to Assets.BoundingBox.Min.
Assets's pivot is a point expressed in model space (the space where vertices are placed), that acts as a reference for its transformations:
- translation is applied from its parent's pivot to its own pivot
- rotation is applied around the pivot
It is set by default to Assets's geometric center, which is equal to myMesh.BoundingBox.Min + myMesh.BoundingBox.Center.
You can override it with any point, even outside of the Assets's bounding box, as a way to modify how transformations are applied.
Note that setting the pivot to zero effectively means you are using the Assets's model origin as reference point for transformations.
Whether or not the mesh should cast shadows onto other lit objects. Light objects set as shadow casters will affect all meshes in matching layers (see Light.CastsShadows).
Note that whether or not the mesh is affected by lights and shadows from other objects depends on the separate property Assets.IsUnlit.
Returns Assets's bounding box size, expressed in model space (the space where vertices are placed). Shortcut to Assets.BoundingBox.Size.
The number of vertices in this mesh.
Returns Assets's width, expressed in model space (the space where vertices are placed). Shortcut to Assets.BoundingBox.Size.X.