Class MeshBase
Base class for mesh objects.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public abstract class MeshBase : Object
Constructors
MeshBase()
Properties
Box
HasVertexColors
Determines whether this mesh has a vertex colors buffer.
Declaration
[Unmanaged]
public bool HasVertexColors { get; }
Property Value
System.Boolean
|
Index
Gets the mesh index.
Declaration
[Unmanaged]
public int Index { get; }
Property Value
System.Int32
|
IndexBufferFormat
Gets a format of the mesh index buffer.
Declaration
public PixelFormat IndexBufferFormat { get; }
Property Value
PixelFormat
|
LODIndex
Gets the mesh parent LOD index.
Declaration
[Unmanaged]
public int LODIndex { get; }
Property Value
System.Int32
|
MaterialSlot
Gets the material slot used by this mesh during rendering.
Declaration
public MaterialSlot MaterialSlot { get; }
Property Value
MaterialSlot
|
MaterialSlotIndex
Gets or sets the index of the material slot to use during this mesh rendering.
Declaration
[Unmanaged]
public int MaterialSlotIndex { get; set; }
Property Value
System.Int32
|
ModelBase
Gets the model owning this mesh.
Declaration
[Unmanaged]
public ModelBase ModelBase { get; }
Property Value
ModelBase
|
Sphere
Gets the sphere.
Declaration
[Unmanaged]
public BoundingSphere Sphere { get; }
Property Value
BoundingSphere
|
TriangleCount
Gets the triangle count.
Declaration
[Unmanaged]
public int TriangleCount { get; }
Property Value
System.Int32
|
Use16BitIndexBuffer
Determines whether this mesh is using 16 bit index buffer, otherwise it's 32 bit.
Declaration
[Unmanaged]
public bool Use16BitIndexBuffer { get; }
Property Value
System.Boolean
|
VertexCount
Gets the vertex count.
Declaration
[Unmanaged]
public int VertexCount { get; }
Property Value
System.Int32
|
VertexLayout
Gets the vertex buffers layout. Made out of all buffers used by this mesh.
Declaration
[Unmanaged]
public GPUVertexLayout VertexLayout { get; }
Property Value
GPUVertexLayout
|
Methods
DownloadData(Span<MeshBufferType>, out Byte[][], out GPUVertexLayout[], Boolean)
Extracts mesh buffers data.
Declaration
public bool DownloadData(Span<MeshBufferType> types, out byte[][] buffers, out GPUVertexLayout[] layouts, bool forceGpu = false)
Parameters
System.Span<FlaxEngine.MeshBufferType>
types
List of buffers to load. |
System.Byte[][]
buffers
The result mesh buffers. |
GPUVertexLayout[]
layouts
The result layouts of the vertex buffers. |
System.Boolean
forceGpu
If set to |
Returns
System.Boolean
True if failed, otherwise false |
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.
GetIndexBuffer()
GetVertexBuffer(Int32)
Gets the vertex buffer.
Declaration
[Unmanaged]
public GPUBuffer GetVertexBuffer(int index)
Parameters
System.Int32
index
The bind slot index. |
Returns
GPUBuffer
The buffer or null if not used. |
Init(UInt32, UInt32, IntPtr[], IntPtr, Boolean, GPUVertexLayout[])
Initializes the mesh buffers.
Declaration
[Unmanaged]
public bool Init(uint vertices, uint triangles, IntPtr[] vbData, IntPtr ibData, bool use16BitIndexBuffer, GPUVertexLayout[] vbLayout)
Parameters
System.UInt32
vertices
Amount of vertices in the vertex buffer. |
System.UInt32
triangles
Amount of triangles in the index buffer. |
System.IntPtr[]
vbData
Array with pointers to vertex buffers initial data (layout defined by |
System.IntPtr
ibData
Pointer to index buffer data. Data is uint16 or uint32 depending on |
System.Boolean
use16BitIndexBuffer
True to use 16-bit indices for the index buffer (true: uint16, false: uint32). |
GPUVertexLayout[]
vbLayout
Layout descriptors for the vertex buffers attributes (one for each vertex buffer). |
Returns
System.Boolean
True if failed, otherwise false. |
SetBounds(ref BoundingBox)
Sets the mesh bounds.
Declaration
[Unmanaged]
public void SetBounds(ref BoundingBox box)
Parameters
BoundingBox
box
The bounding box. |
SetBounds(ref BoundingBox, ref BoundingSphere)
Sets the mesh bounds.
Declaration
[Unmanaged]
public void SetBounds(ref BoundingBox box, ref BoundingSphere sphere)
Parameters
BoundingBox
box
The bounding box. |
BoundingSphere
sphere
The bounding sphere. |
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. |