Search Results for

    Show / Hide Table of Contents

    Class MeshAccessor

    General purpose utility for accessing mesh data (both read and write).

    Inheritance
    System.Object
    MeshAccessor
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    public class MeshAccessor : Object

    Constructors

    MeshAccessor()

    Declaration
    public MeshAccessor()

    Properties

    Colors

    Gets or sets the vertex colors. Null if Color does not exist in vertex buffers of the mesh.

    Declaration
    public Color[] Colors { get; set; }
    Property Value
    Color[]

    Remarks

    Uses Color() stream to read or write data to the vertex buffer.

    Normals

    Gets or sets the vertex normal vectors (unpacked, normalized). Null if Normal does not exist in vertex buffers of the mesh.

    Declaration
    public Float3[] Normals { get; set; }
    Property Value
    Float3[]

    Remarks

    Uses Normal() stream to read or write data to the vertex buffer.

    Positions

    Gets or sets the vertex positions. Null if Position does not exist in vertex buffers of the mesh.

    Declaration
    public Float3[] Positions { get; set; }
    Property Value
    Float3[]

    Remarks

    Uses Position() stream to read or write data to the vertex buffer.

    TexCoords

    Gets or sets the vertex UVs (texcoord channel 0). Null if TexCoord does not exist in vertex buffers of the mesh.

    Declaration
    public Float2[] TexCoords { get; set; }
    Property Value
    Float2[]

    Remarks

    Uses TexCoord(Int32) stream to read or write data to the vertex buffer.

    Methods

    AllocateBuffer(MeshBufferType, Int32, GPUVertexLayout)

    Allocates the data for the mesh vertex buffer.

    Declaration
    public bool AllocateBuffer(MeshBufferType bufferType, int count, GPUVertexLayout layout)
    Parameters
    FlaxEngine.MeshBufferType bufferType

    Type of the mesh buffer to initialize.

    System.Int32 count

    Amount of items in the buffer.

    GPUVertexLayout layout

    Layout of the elements in the buffer.

    Returns
    System.Boolean

    True if failed, otherwise false.

    AllocateBuffer(MeshBufferType, Int32, PixelFormat)

    Allocates the data for the mesh buffer.

    Declaration
    public bool AllocateBuffer(MeshBufferType bufferType, int count, PixelFormat format)
    Parameters
    FlaxEngine.MeshBufferType bufferType

    Type of the mesh buffer to initialize.

    System.Int32 count

    Amount of items in the buffer.

    PixelFormat format

    Format of the elements in the buffer.

    Returns
    System.Boolean

    True if failed, otherwise false.

    Attribute(VertexElement.Types)

    Access stream with a specific vertex attribute.

    Declaration
    public MeshAccessor.Stream Attribute(VertexElement.Types attribute)
    Parameters
    VertexElement.Types attribute

    Type of the attribute.

    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    BlendIndices()

    Access stream with vertex skeleton bones blend indices attribute.

    Declaration
    public MeshAccessor.Stream BlendIndices()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    BlendWeights()

    Access stream with vertex skeleton bones blend weights attribute.

    Declaration
    public MeshAccessor.Stream BlendWeights()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    Color()

    Access stream with vertex color attribute.

    Declaration
    public MeshAccessor.Stream Color()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    Index()

    Access stream with index buffer.

    Declaration
    public MeshAccessor.Stream Index()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if data is not provided).

    LoadBuffer(MeshBufferType, Span<Byte>, GPUVertexLayout)

    Loads the data from the provided mesh buffer.

    Declaration
    public bool LoadBuffer(MeshBufferType bufferType, Span<byte> bufferData, GPUVertexLayout layout)
    Parameters
    FlaxEngine.MeshBufferType bufferType

    Type of the mesh buffer to load.

    System.Span<System.Byte> bufferData

    Data used by that buffer.

    GPUVertexLayout layout

    Layout of the elements in the buffer.

    Returns
    System.Boolean

    True if failed, otherwise false.

    LoadMesh(MeshBase, Boolean, Span<MeshBufferType>)

    Loads the data from the mesh.

    Declaration
    public bool LoadMesh(MeshBase mesh, bool forceGpu = false, Span<MeshBufferType> buffers = null)
    Parameters
    MeshBase mesh

    The source mesh object to access.

    System.Boolean forceGpu

    If set to true the data will be downloaded from the GPU, otherwise it can be loaded from the drive (source asset file) or from memory (if cached). Downloading mesh from GPU requires this call to be made from the other thread than main thread. Virtual assets are always downloaded from GPU memory due to lack of dedicated storage container for the asset data.

    System.Span<FlaxEngine.MeshBufferType> buffers

    Custom list of mesh buffers to load. Use empty value to access all of them.

    Returns
    System.Boolean

    True if failed, otherwise false.

    Normal()

    Access stream with vertex normal vector attribute.

    Declaration
    public MeshAccessor.Stream Normal()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    PackNormal(ref Float3)

    Packs normal/tangent vector to normalized range from full range.

    Declaration
    public static void PackNormal(ref Float3 value)
    Parameters
    Float3 value

    In and out value.

    Position()

    Access stream with vertex position attribute.

    Declaration
    public MeshAccessor.Stream Position()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    Tangent()

    Access stream with vertex tangent vector attribute.

    Declaration
    public MeshAccessor.Stream Tangent()
    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    TexCoord(Int32)

    Access stream with vertex texture coordinates attribute (specific UV channel).

    Declaration
    public MeshAccessor.Stream TexCoord(int channel = 0)
    Parameters
    System.Int32 channel

    UV channel index (zero-based).

    Returns
    MeshAccessor.Stream

    Mesh data stream (might be invalid if attribute is not provided).

    UnpackNormal(ref Float3)

    Unpacks normal/tangent vector from normalized range to full range.

    Declaration
    public static void UnpackNormal(ref Float3 value)
    Parameters
    Float3 value

    In and out value.

    UnpackNormal(ref Float4, out Single)

    Unpacks normal/tangent vector from normalized range to full range.

    Declaration
    public static void UnpackNormal(ref Float4 value, out float sign)
    Parameters
    Float4 value

    In and out value.

    System.Single sign

    Encoded sign in the alpha channel.

    UpdateMesh(MeshBase, Boolean)

    Updates the mesh vertex and index buffers with data assigned to the accessor (eg. via AllocateBuffer).

    Declaration
    public bool UpdateMesh(MeshBase mesh, bool calculateBounds = true)
    Parameters
    MeshBase mesh

    The target mesh to update.

    System.Boolean calculateBounds

    True if auto-calculate mesh local bounding box based on input positions stream. Otherwise, mesh bound swill stay unchanged.

    Returns
    System.Boolean

    True if failed, otherwise false.

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat