Class Mesh
Represents part of the model that is made of vertices and can be rendered using custom material and transformation.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public class Mesh : MeshBase
Constructors
Mesh()
Properties
HasLightmapUVs
Determines whether this mesh contains valid lightmap texture coordinates data.
Declaration
[Unmanaged]
public bool HasLightmapUVs { get; }
Property Value
System.Boolean
|
HasVertexColors
Determines whether this mesh has a vertex colors buffer.
Declaration
[Unmanaged]
public bool HasVertexColors { get; }
Property Value
System.Boolean
|
IndexBufferFormat
Gets a format of the mesh index buffer.
Declaration
public PixelFormat IndexBufferFormat { get; }
Property Value
PixelFormat
|
MaterialSlot
Gets the material slot used by this mesh during rendering.
Declaration
public MaterialSlot MaterialSlot { get; }
Property Value
MaterialSlot
|
ParentModel
Methods
DownloadIndexBuffer(Boolean)
Downloads the index buffer that contains mesh triangles data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public uint[] DownloadIndexBuffer(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
System.UInt32[]
The gathered data. |
Remarks
If mesh index buffer format (see IndexBufferFormat) is R16_UInt then it's faster to call .
DownloadIndexBufferUShort(Boolean)
Downloads the index buffer that contains mesh triangles data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public ushort[] DownloadIndexBufferUShort(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
System.UInt16[]
The gathered data. |
Remarks
If mesh index buffer format (see IndexBufferFormat) is R32_UInt then data won't be downloaded.
DownloadVertexBuffer(Boolean)
Downloads the raw vertex buffer that contains mesh vertices data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public Mesh.Vertex[] DownloadVertexBuffer(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
Mesh.Vertex[]
The gathered data. |
DownloadVertexBuffer0(Boolean)
Downloads the first vertex buffer that contains mesh vertices data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public Mesh.Vertex0[] DownloadVertexBuffer0(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
Mesh.Vertex0[]
The gathered data. |
DownloadVertexBuffer1(Boolean)
Downloads the second vertex buffer that contains mesh vertices data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public Mesh.Vertex1[] DownloadVertexBuffer1(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
Mesh.Vertex1[]
The gathered data. |
DownloadVertexBuffer2(Boolean)
Downloads the third vertex buffer that contains mesh vertices data. To download data from GPU set forceGpu
to true and call this method from the thread other than main thread (see IsInMainThread).
Declaration
public Mesh.Vertex2[] DownloadVertexBuffer2(bool forceGpu = false)
Parameters
System.Boolean
forceGpu
If set to |
Returns
Mesh.Vertex2[]
The gathered data or null if mesh has no vertex colors. |
Remarks
If mesh has no vertex colors (stored in vertex buffer 2) the returned value is null.
Draw(ref RenderContext, MaterialBase, ref Matrix, StaticFlags, Boolean, DrawPass, Single, SByte)
Draws the mesh.
Declaration
[Unmanaged]
public void Draw(ref RenderContext renderContext, MaterialBase material, ref Matrix world, StaticFlags flags, bool receiveDecals = true, DrawPass drawModes, float perInstanceRandom = 0F, sbyte sortOrder = 0)
Parameters
RenderContext
renderContext
The rendering context. |
MaterialBase
material
The material to use for rendering. |
Matrix
world
The world transformation of the model. |
StaticFlags
flags
The object static flags. |
System.Boolean
receiveDecals
True if rendered geometry can receive decals, otherwise false. |
DrawPass
drawModes
The draw passes to use for rendering this object. |
System.Single
perInstanceRandom
The random per-instance value (normalized to range 0-1). |
System.SByte
sortOrder
Object sorting key. |
UpdateMesh(Float3[], Int32[], Float3[], Float3[], Float2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(Float3[] vertices, int[] triangles, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null, Color32[] colors = null)
Parameters
Float3[]
vertices
The mesh vertices positions. Cannot be null. |
System.Int32[]
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
Float3[]
normals
The normal vectors (per vertex). |
Float3[]
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
Float2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(Float3[], UInt16[], Float3[], Float3[], Float2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(Float3[] vertices, ushort[] triangles, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null, Color32[] colors = null)
Parameters
Float3[]
vertices
The mesh vertices positions. Cannot be null. |
System.UInt16[]
triangles
The mesh index buffer (clockwise triangles). Uses 16-bit stride buffer. Cannot be null. |
Float3[]
normals
The normal vectors (per vertex). |
Float3[]
tangents
The tangent vectors (per vertex). Use null to compute them from normal vectors. |
Float2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(Float3[], UInt32[], Float3[], Float3[], Float2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(Float3[] vertices, uint[] triangles, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null, Color32[] colors = null)
Parameters
Float3[]
vertices
The mesh vertices positions. Cannot be null. |
System.UInt32[]
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
Float3[]
normals
The normal vectors (per vertex). |
Float3[]
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
Float2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(Vector3[], Int32[], Vector3[], Vector3[], Vector2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(Vector3[] vertices, int[] triangles, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null, Color32[] colors = null)
Parameters
Vector3[]
vertices
The mesh vertices positions. Cannot be null. |
System.Int32[]
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
Vector3[]
normals
The normal vectors (per vertex). |
Vector3[]
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
Vector2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(Vector3[], UInt16[], Vector3[], Vector3[], Vector2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(Vector3[] vertices, ushort[] triangles, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null, Color32[] colors = null)
Parameters
Vector3[]
vertices
The mesh vertices positions. Cannot be null. |
System.UInt16[]
triangles
The mesh index buffer (clockwise triangles). Uses 16-bit stride buffer. Cannot be null. |
Vector3[]
normals
The normal vectors (per vertex). |
Vector3[]
tangents
The tangent vectors (per vertex). Use null to compute them from normal vectors. |
Vector2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(Vector3[], UInt32[], Vector3[], Vector3[], Vector2[], Color32[])
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(Vector3[] vertices, uint[] triangles, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null, Color32[] colors = null)
Parameters
Vector3[]
vertices
The mesh vertices positions. Cannot be null. |
System.UInt32[]
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
Vector3[]
normals
The normal vectors (per vertex). |
Vector3[]
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
Vector2[]
uv
The texture coordinates (per vertex). |
Color32[]
colors
The vertex colors (per vertex). |
UpdateMesh(List<Float3>, List<Int32>, List<Float3>, List<Float3>, List<Float2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(List<Float3> vertices, List<int> triangles, List<Float3> normals = null, List<Float3> tangents = null, List<Float2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Float3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.Int32>
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Float3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Float3>
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Float2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateMesh(List<Float3>, List<UInt16>, List<Float3>, List<Float3>, List<Float2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(List<Float3> vertices, List<ushort> triangles, List<Float3> normals = null, List<Float3> tangents = null, List<Float2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Float3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.UInt16>
triangles
The mesh index buffer (clockwise triangles). Uses 16-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Float3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Float3>
tangents
The tangent vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Float2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateMesh(List<Float3>, List<UInt32>, List<Float3>, List<Float3>, List<Float2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateMesh(List<Float3> vertices, List<uint> triangles, List<Float3> normals = null, List<Float3> tangents = null, List<Float2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Float3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.UInt32>
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Float3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Float3>
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Float2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateMesh(List<Vector3>, List<Int32>, List<Vector3>, List<Vector3>, List<Vector2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(List<Vector3> vertices, List<int> triangles, List<Vector3> normals = null, List<Vector3> tangents = null, List<Vector2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Vector3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.Int32>
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Vector3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Vector3>
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Vector2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateMesh(List<Vector3>, List<UInt16>, List<Vector3>, List<Vector3>, List<Vector2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(List<Vector3> vertices, List<ushort> triangles, List<Vector3> normals = null, List<Vector3> tangents = null, List<Vector2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Vector3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.UInt16>
triangles
The mesh index buffer (clockwise triangles). Uses 16-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Vector3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Vector3>
tangents
The tangent vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Vector2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateMesh(List<Vector3>, List<UInt32>, List<Vector3>, List<Vector3>, List<Vector2>, List<Color32>)
Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay. [Deprecated on 26.05.2022, expires on 26.05.2024]
Declaration
public void UpdateMesh(List<Vector3> vertices, List<uint> triangles, List<Vector3> normals = null, List<Vector3> tangents = null, List<Vector2> uv = null, List<Color32> colors = null)
Parameters
System.Collections.Generic.List<Vector3>
vertices
The mesh vertices positions. Cannot be null. |
System.Collections.Generic.List<System.UInt32>
triangles
The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null. |
System.Collections.Generic.List<Vector3>
normals
The normal vectors (per vertex). |
System.Collections.Generic.List<Vector3>
tangents
The normal vectors (per vertex). Use null to compute them from normal vectors. |
System.Collections.Generic.List<Vector2>
uv
The texture coordinates (per vertex). |
System.Collections.Generic.List<Color32>
colors
The vertex colors (per vertex). |
UpdateTriangles(List<Int32>)
Updates the model mesh index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateTriangles(List<int> triangles)
Parameters
System.Collections.Generic.List<System.Int32>
triangles
The mesh index buffer (triangles). Uses 32-bit stride buffer. Cannot be null. |
UpdateTriangles(List<UInt16>)
Updates the model mesh index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateTriangles(List<ushort> triangles)
Parameters
System.Collections.Generic.List<System.UInt16>
triangles
The mesh index buffer (triangles). Uses 16-bit stride buffer. Cannot be null. |
UpdateTriangles(Int32[])
Updates the model mesh index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateTriangles(int[] triangles)
Parameters
System.Int32[]
triangles
The mesh index buffer (triangles). Uses 32-bit stride buffer. Cannot be null. |
UpdateTriangles(UInt16[])
Updates the model mesh index buffer data. Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()). Mesh data will be cached and uploaded to the GPU with a delay.
Declaration
public void UpdateTriangles(ushort[] triangles)
Parameters
System.UInt16[]
triangles
The mesh index buffer (triangles). Uses 16-bit stride buffer. Cannot be null. |