Class MeshBase
Base class for mesh objects.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Graphics/Models/MeshBase.h
Syntax
public class MeshBase : public ScriptingObject
Constructors
~MeshBase()
Declaration
public ~MeshBase()
DEPRECATED("Use Release instead.") void Unload()
Unloads the mesh data (vertex buffers and cache). The opposite to Load. [Deprecated in v1.10]
Declaration
public DEPRECATED("Use Release instead.") void Unload()
Parameters
"Use Release instead."
MeshBase_DEPRECATED__Use_Release_instead___
|
MeshBase(const SpawnParams& params)
Declaration
protected MeshBase(const SpawnParams& params)
Parameters
SpawnParams
params
|
Fields
_box
_cachedIndexBuffer
Declaration
protected BytesContainer _cachedIndexBuffer
Field Value
BytesContainer
|
_cachedIndexBufferCount
Declaration
protected int32 _cachedIndexBufferCount = 0
Field Value
int32
|
_cachedVertexBufferCount
Declaration
protected int32 _cachedVertexBufferCount = 0
Field Value
int32
|
_cachedVertexBuffers
Declaration
protected BytesContainer _cachedVertexBuffers[MODEL_MAX_VB]
Field Value
BytesContainer
|
_cachedVertexLayouts
Declaration
protected GPUVertexLayout* _cachedVertexLayouts[MODEL_MAX_VB] = {}
Field Value
GPUVertexLayout
|
_collisionProxy
_hasBounds
Declaration
protected bool _hasBounds = false
Field Value
bool
|
_index
Declaration
protected int32 _index = 0
Field Value
int32
|
_indexBuffer
_lodIndex
Declaration
protected int32 _lodIndex = 0
Field Value
int32
|
_materialSlotIndex
Declaration
protected int32 _materialSlotIndex = 0
Field Value
int32
|
_model
_sphere
_triangles
Declaration
protected uint32 _triangles = 0
Field Value
uint32
|
_use16BitIndexBuffer
Declaration
protected bool _use16BitIndexBuffer = false
Field Value
bool
|
_vertexBuffers
_vertices
Declaration
protected uint32 _vertices = 0
Field Value
uint32
|
Methods
DownloadData(Span<MeshBufferType> types, Array<BytesContainer, FixedAllocation<4>>& buffers, Array<GPUVertexLayout* , FixedAllocation<4>>& layouts, bool forceGpu=false)
Extracts mesh buffers data.
Declaration
public bool DownloadData(Span<MeshBufferType> types, Array<BytesContainer, FixedAllocation<4>>& buffers, Array<GPUVertexLayout* , FixedAllocation<4>>& layouts, bool forceGpu=false) const
Parameters
Span<MeshBufferType>
types
List of buffers to load. |
Array<BytesContainer, FixedAllocation<4>>
buffers
The result mesh buffers. |
Array<GPUVertexLayout , FixedAllocation<4>>
layouts
The result layouts of the vertex buffers. |
bool
forceGpu
If set to |
Returns
bool
True if failed, otherwise false |
DownloadDataCPU(MeshBufferType type, BytesContainer& result, int32& count, GPUVertexLayout* *layout=nullptr)
Extract mesh buffer data from CPU. Cached internally.
Declaration
public bool DownloadDataCPU(MeshBufferType type, BytesContainer& result, int32& count, GPUVertexLayout* *layout=nullptr) const
Parameters
MeshBufferType
type
Buffer type |
BytesContainer
result
The result data |
int32
count
The amount of items inside the result buffer. |
GPUVertexLayout
layout
The result layout of the vertex buffer (optional). |
Returns
bool
True if failed, otherwise false |
DownloadDataGPU(MeshBufferType type, BytesContainer& result, GPUVertexLayout* *layout=nullptr)
Extracts mesh buffer data from a GPU. Cannot be called from the main thread.
Declaration
public bool DownloadDataGPU(MeshBufferType type, BytesContainer& result, GPUVertexLayout* *layout=nullptr) const
Parameters
MeshBufferType
type
Buffer type |
BytesContainer
result
The result data |
GPUVertexLayout
layout
The result layout of the vertex buffer (optional). |
Returns
bool
True if failed, otherwise false |
DownloadDataGPUAsync(MeshBufferType type, BytesContainer& result, GPUVertexLayout* *layout=nullptr)
Extracts mesh buffer data from GPU in the async task.
Declaration
public Task* DownloadDataGPUAsync(MeshBufferType type, BytesContainer& result, GPUVertexLayout* *layout=nullptr) const
Parameters
MeshBufferType
type
Buffer type |
BytesContainer
result
The result data |
GPUVertexLayout
layout
The result layout of the vertex buffer (optional). |
Returns
Task
Created async task used to gather the buffer data. |
GetBox()
GetCollisionProxy()
Gets the collision proxy used by the mesh.
Declaration
public CollisionProxy GetCollisionProxy() const
Returns
CollisionProxy
|
GetDrawCallGeometry(struct DrawCall& drawCall)
Gets the draw call geometry for this mesh. Sets the index and vertex buffers.
Declaration
public void GetDrawCallGeometry(struct DrawCall& drawCall) const
Parameters
struct DrawCall
drawCall
The draw call. |
GetIndex()
Gets the mesh index.
Declaration
public int32 GetIndex() const
Returns
int32
|
GetIndexBuffer()
GetLODIndex()
Gets the mesh parent LOD index.
Declaration
public int32 GetLODIndex() const
Returns
int32
|
GetMaterialSlotIndex()
Gets the index of the material slot to use during this mesh rendering.
Declaration
public int32 GetMaterialSlotIndex() const
Returns
int32
|
GetModelBase()
Gets the model owning this mesh.
Declaration
public ModelBase* GetModelBase() const
Returns
ModelBase
|
GetSphere()
GetTriangleCount()
Gets the triangle count.
Declaration
public int32 GetTriangleCount() const
Returns
int32
|
GetVertexBuffer(int32 index)
Gets the vertex buffer.
Declaration
public GPUBuffer* GetVertexBuffer(int32 index) const
Parameters
int32
index
The bind slot index. |
Returns
GPUBuffer
The buffer or null if not used. |
GetVertexCount()
Gets the vertex count.
Declaration
public int32 GetVertexCount() const
Returns
int32
|
GetVertexLayout()
Gets the vertex buffers layout. Made out of all buffers used by this mesh.
Declaration
public GPUVertexLayout* GetVertexLayout() const
Returns
GPUVertexLayout
The vertex layout. |
HasVertexColors()
Determines whether this mesh has a vertex colors buffer.
Declaration
public bool HasVertexColors() const
Returns
bool
|
Init(uint32 vertices, uint32 triangles, const Array<const void* , FixedAllocation<MODEL_MAX_VB>>& vbData, const void* ibData, bool use16BitIndexBuffer, Array<GPUVertexLayout* , FixedAllocation<MODEL_MAX_VB>> vbLayout)
Initializes the mesh buffers.
Declaration
public virtual bool Init(uint32 vertices, uint32 triangles, const Array<const void* , FixedAllocation<MODEL_MAX_VB>>& vbData, const void* ibData, bool use16BitIndexBuffer, Array<GPUVertexLayout* , FixedAllocation<MODEL_MAX_VB>> vbLayout)
Parameters
uint32
vertices
Amount of vertices in the vertex buffer. |
uint32
triangles
Amount of triangles in the index buffer. |
Array<void , FixedAllocation<MODEL_MAX_VB>>
vbData
Array with pointers to vertex buffers initial data (layout defined by vbLayout ). |
void
ibData
Pointer to index buffer data. Data is uint16 or uint32 depending on use16BitIndexBuffer value. |
bool
use16BitIndexBuffer
True to use 16-bit indices for the index buffer (true: uint16, false: uint32). |
Array<GPUVertexLayout , FixedAllocation<MODEL_MAX_VB>>
vbLayout
Layout descriptors for the vertex buffers attributes (one for each vertex buffer). |
Returns
bool
True if failed, otherwise false. |
Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal)
Determines if there is an intersection between the mesh and a ray in given world.
Declaration
public bool Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal) const
Parameters
Ray
ray
The ray to test. |
Matrix
world
The mesh instance transformation. |
Real
distance
When the method completes and returns true, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
Returns
bool
True whether the two objects intersected, otherwise false. |
Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal)
Determines if there is an intersection between the mesh and a ray in given world
Declaration
public bool Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal) const
Parameters
Ray
ray
The ray to test |
Transform
transform
The mesh instance transformation. |
Real
distance
When the method completes and returns true, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
Returns
bool
True whether the two objects intersected, otherwise false. |
IsInitialized()
Determines whether this mesh is initialized (has vertex and index buffers initialized).
Declaration
public bool IsInitialized() const
Returns
bool
|
Link(ModelBase* model, int32 lodIndex, int32 index)
Declaration
protected void Link(ModelBase* model, int32 lodIndex, int32 index)
Parameters
ModelBase
model
|
int32
lodIndex
|
int32
index
|
Release()
Releases the mesh data (GPU buffers and local cache).
Declaration
public virtual void Release()
Render(GPUContext* context)
Draws the mesh. Binds vertex and index buffers and invokes the draw call.
Declaration
public void Render(GPUContext* context) const
Parameters
GPUContext
context
The GPU context. |
SetBounds(const BoundingBox& box)
Sets the mesh bounds.
Declaration
public void SetBounds(const BoundingBox& box)
Parameters
BoundingBox
box
The bounding box. |
SetBounds(const BoundingBox& box, const BoundingSphere& sphere)
Sets the mesh bounds.
Declaration
public void SetBounds(const BoundingBox& box, const BoundingSphere& sphere)
Parameters
BoundingBox
box
The bounding box. |
BoundingSphere
sphere
The bounding sphere. |
SetMaterialSlotIndex(int32 value)
Sets the index of the material slot to use during this mesh rendering.
Declaration
public void SetMaterialSlotIndex(int32 value)
Parameters
int32
value
|
UpdateTriangles(uint32 triangleCount, const uint16* ib)
Updates the model mesh index buffer.
Declaration
public bool UpdateTriangles(uint32 triangleCount, const uint16* ib)
Parameters
uint32
triangleCount
The amount of triangles in the index buffer. |
uint16
ib
The index buffer. |
Returns
bool
True if failed, otherwise false. |
UpdateTriangles(uint32 triangleCount, const uint32* ib)
Updates the model mesh index buffer.
Declaration
public bool UpdateTriangles(uint32 triangleCount, const uint32* ib)
Parameters
uint32
triangleCount
The amount of triangles in the index buffer. |
uint32
ib
The index buffer. |
Returns
bool
True if failed, otherwise false. |
UpdateTriangles(uint32 triangleCount, const void* ib, bool use16BitIndices)
Updates the model mesh index buffer.
Declaration
public bool UpdateTriangles(uint32 triangleCount, const void* ib, bool use16BitIndices)
Parameters
uint32
triangleCount
The amount of triangles in the index buffer. |
void
ib
The index buffer. |
bool
use16BitIndices
True if index buffer uses 16-bit index buffer, otherwise 32-bit. |
Returns
bool
True if failed, otherwise false. |
Use16BitIndexBuffer()
Determines whether this mesh is using 16 bit index buffer, otherwise it's 32 bit.
Declaration
public bool Use16BitIndexBuffer() const
Returns
bool
|