Search Results for

    Show / Hide Table of Contents

    Class Model

    Model asset that contains model object made of meshes which can rendered on the GPU.

    Inheritance
    System.Object
    Object
    Asset
    BinaryAsset
    ModelBase
    Model
    Inherited Members
    ModelBase.SetupMaterialSlots(Int32)
    ModelBase.GetSlot(String)
    ModelBase.GetLOD(Int32)
    ModelBase.GetMesh(Int32, Int32)
    ModelBase.GetMeshes(MeshBase[], Int32)
    ModelBase.Save(Boolean, String)
    ModelBase.MinScreenSize
    ModelBase.MaterialSlots
    ModelBase.MaterialSlotsCount
    ModelBase.LoadedLODs
    ModelBase.LODsCount
    BinaryAsset.Reimport()
    BinaryAsset.ImportPath
    Asset.Reload()
    Asset.WaitForLoaded(Double)
    Asset.GetReferences()
    Asset.Save(String)
    Asset.ToString()
    Asset.ReferencesCount
    Asset.Path
    Asset.IsLoaded
    Asset.LastLoadFailed
    Asset.IsVirtual
    Asset.ShouldDeleteFileOnUnload
    Asset.MemoryUsage
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public class Model : ModelBase

    Constructors

    Model()

    Initializes a new instance of the Model.

    Declaration
    public Model()

    Fields

    MaxLODs

    The maximum amount of levels of detail for the model.

    Declaration
    public const int MaxLODs = 6
    Field Value
    System.Int32

    MaxMaterialSlots

    The maximum allowed amount of material slots per model resource

    Declaration
    public const int MaxMaterialSlots = 4096
    Field Value
    System.Int32

    MaxMeshes

    The maximum amount of meshes per model LOD.

    Declaration
    public const int MaxMeshes = 4096
    Field Value
    System.Int32

    Properties

    LODs

    Model level of details. The first entry is the highest quality LOD0 followed by more optimized versions.

    Declaration
    [Unmanaged]
    public ModelLOD[] LODs { get; }
    Property Value
    ModelLOD[]

    SDF

    The generated Sign Distant Field (SDF) for this model (merged all meshes). Use GenerateSDF to update it.

    Declaration
    [Unmanaged]
    public ModelBase.SDFData SDF { get; }
    Property Value
    ModelBase.SDFData

    Methods

    Draw(ref RenderContext, MaterialBase, ref Matrix, StaticFlags, Boolean, SByte)

    Draws the model.

    Declaration
    [Unmanaged]
    public void Draw(ref RenderContext renderContext, MaterialBase material, ref Matrix world, StaticFlags flags, bool receiveDecals = true, 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.

    System.SByte sortOrder

    Object sorting key.

    GenerateSDF(Single, Int32, Boolean, Single, Boolean)

    Generates the Sign Distant Field for this model.

    Declaration
    [Unmanaged]
    public bool GenerateSDF(float resolutionScale = 1F, int lodIndex = 6, bool cacheData = true, float backfacesThreshold = 0.6F, bool useGPU = true)
    Parameters
    System.Single resolutionScale

    The SDF texture resolution scale. Use higher values for more precise data but with significant performance and memory overhead.

    System.Int32 lodIndex

    The index of the LOD to use for the SDF building.

    System.Boolean cacheData

    If true, the generated SDF texture data will be cached on CPU (in asset chunk storage) to allow saving it later, otherwise it will be runtime for GPU-only. Ignored for virtual assets or in build.

    System.Single backfacesThreshold

    Custom threshold (in range 0-1) for adjusting mesh internals detection based on the percentage of test rays hit triangle backfaces. Use lower value for more dense mesh.

    System.Boolean useGPU

    Enables using GPU for SDF generation, otherwise CPU will be used (async via Job System).

    Returns
    System.Boolean

    True if failed, otherwise false.

    Remarks

    Can be called in async in case of SDF generation on a CPU (assuming model is not during rendering).

    GetBox(Matrix, Int32)

    Gets the model bounding box in custom matrix world space.

    Declaration
    [Unmanaged]
    public BoundingBox GetBox(Matrix world, int lodIndex = 0)
    Parameters
    Matrix world

    The transformation matrix.

    System.Int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    GetBox(Transform, Int32)

    Gets the model bounding box in custom transformation.

    Declaration
    [Unmanaged]
    public BoundingBox GetBox(Transform transform, int lodIndex = 0)
    Parameters
    Transform transform

    The instance transformation.

    System.Int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    GetBox(Int32)

    Gets the model bounding box in local space.

    Declaration
    [Unmanaged]
    public BoundingBox GetBox(int lodIndex = 0)
    Parameters
    System.Int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    SetSDF(ModelBase.SDFData)

    Sets set SDF data (releases the current one).

    Declaration
    [Unmanaged]
    public void SetSDF(ModelBase.SDFData sdf)
    Parameters
    ModelBase.SDFData sdf

    SetupLODs(Int32[])

    Setups the model LODs collection including meshes creation.

    Declaration
    [Unmanaged]
    public bool SetupLODs(int[] meshesCountPerLod)
    Parameters
    System.Int32[] meshesCountPerLod

    The meshes count per lod array (amount of meshes per LOD).

    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