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
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    BinaryAsset
    ModelBase
    Model
    Inherited Members
    Asset::_deleteFileOnUnload
    BinaryAsset::_dependantAssets
    ScriptingObject::_gcHandle
    StreamableResource::_group
    BinaryAsset::_header
    ScriptingObject::_id
    ModelBase::_initialized
    StreamableResource::_isDynamic
    BinaryAsset::_isSaving
    StreamableResource::_isStreaming
    Asset::_isVirtual
    ModelBase::_loadedLODs
    Asset::_loadingTask
    Asset::_loadState
    Asset::_refCount
    BinaryAsset::_storageRef
    StreamableResource::_streamingQuality
    ModelBase::_streamingTask
    ScriptingObject::_type
    BinaryAsset::AddDependency(BinaryAsset* asset)
    Asset::AddReference()
    Asset::Asset(const SpawnParams& params, const AssetInfo* info)
    ModelBase::CanBeRendered()
    ModelBase::CanBeUpdated()
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ModelBase::CancelStreaming()
    ModelBase::CancelStreamingTasks()
    ScriptingObject::Cast(ScriptingObject* obj)
    Asset::ChangeID(const Guid& newId)
    ModelBase::ClampLODIndex(int32 index)
    BinaryAsset::ClearDependencies()
    Asset::const
    BinaryAsset::createLoadingTask()
    Asset::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    ModelBase::CreateStreamingTask(int32 residency)
    Asset::DECLARE_ENUM_7(LoadResult, Ok, Failed, MissingDataChunk, CannotLoadData, CannotLoadStorage, CannotLoadInitData, InvalidData)
    ScriptingObject::Deleted
    Asset::DeleteManaged()
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    BinaryAsset::Dependencies
    Asset::DEPRECATED("Use GetReferences with assets and files parameter instead")
    Asset::DestroyManaged()
    Model
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    BinaryAsset::GetChunk(int32 index)
    BinaryAsset::GetChunkData(int32 index, BytesContainer& data)
    BinaryAsset::GetChunkSize(int32 index)
    ScriptingObject::GetClass()
    ModelBase::GetCurrentResidency()
    StreamableResource::GetGroup()
    ScriptingObject::GetID()
    BinaryAsset::GetImportMetadata(String& path, String& username)
    BinaryAsset::GetImportPath()
    ModelBase::GetLoadedLODs()
    ModelBase::GetLODData(int32 lodIndex, BytesContainer& data)
    ScriptingObject::GetManagedInstance()
    ModelBase::GetMaterialSlotsCount()
    BinaryAsset::GetMemoryUsage()
    BinaryAsset::GetOrCreateChunk(int32 index)
    ScriptingObject::GetOrCreateManagedInstance()
    BinaryAsset::GetPath()
    ModelBase::GetReferences(Array<Guid>& assets, Array<String>& files)
    Asset::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
    Asset::GetReferences()
    Asset::GetReferencesCount()
    BinaryAsset::GetSerializedVersion()
    ModelBase::GetSlot(const StringView& name)
    StreamableResource::GetStreamingQuality()
    StreamableResource::GetTargetResidency()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Asset::GetTypeName()
    BinaryAsset::HasChunk(int32 index)
    BinaryAsset::HasChunkLoaded(int32 index)
    BinaryAsset::HasDependenciesModified()
    ScriptingObject::HasManagedInstance()
    ModelBase::HighestResidentLODIndex()
    BinaryAsset::init(AssetInitData& initData)
    BinaryAsset::Init(const FlaxStorageReference& storage, AssetHeader& header)
    BinaryAsset::Init(AssetInitData& initData)
    BinaryAsset::InitVirtual(AssetInitData& initData)
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    StreamableResource::IsAllocated()
    StreamableResource::IsDynamic()
    ModelBase::IsInitialized()
    Asset::IsInternalType()
    Asset::IsLoaded()
    ScriptingObject::IsRegistered()
    Asset::IsVirtual()
    Asset::LastLoadFailed()
    BinaryAsset::loadAsset()
    BinaryAsset::LoadChunk(int32 chunkIndex)
    BinaryAsset::LoadChunks(AssetChunksFlag chunks)
    ModelBase::LoadMesh(class MemoryReadStream& stream, byte meshVersion, MeshBase* mesh, MeshData* dataIfReadOnly=nullptr)
    Model
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    ModelBase::MaterialSlots
    BinaryAsset::Metadata
    ModelBase::MinScreenSize
    ModelBase::ModelBase(const SpawnParams& params, const AssetInfo* info, StreamingGroup* group)
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Asset::OnCheckSave(const StringView& path=StringView::Empty)
    BinaryAsset::OnDeleteObject()
    BinaryAsset::OnDependencyModified(BinaryAsset* asset)
    Asset::onLoad(LoadAssetTask* task)
    Asset::onLoaded()
    Asset::OnLoaded
    Asset::onLoaded_MainThread()
    Asset::OnManagedInstanceDeleted()
    Asset::OnReloading
    BinaryAsset::onRename(const StringView& newPath)
    Asset::OnScriptingDispose()
    Asset::onUnload_MainThread()
    Asset::OnUnloaded
    ScriptingObject::RegisterObject()
    BinaryAsset::Reimport()
    BinaryAsset::ReleaseChunk(int32 index)
    BinaryAsset::ReleaseChunks()
    BinaryAsset::releaseStorage()
    Asset::Reload()
    Asset::RemoveReference()
    BinaryAsset::RequestChunkDataAsync(int32 index)
    ModelBase::RequestLODDataAsync(int32 lodIndex)
    StreamableResource::RequestStreamingUpdate()
    StreamableResource::ResetStreaming(bool error=true)
    StreamableResource::ResidencyChanged
    ModelBase::Save(bool withMeshDataFromGpu=false, const StringView& path=StringView::Empty)
    ModelBase::Save(const StringView& path=StringView::Empty)
    BinaryAsset::SaveAsset(AssetInitData& data, bool silentMode=false)
    BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
    ModelBase::SaveHeader(WriteStream& stream, const class ModelData& modelData)
    ModelBase::SaveLOD(WriteStream& stream, int32 lodIndex)
    ModelBase::SaveLOD(WriteStream& stream, const ModelData& modelData, int32 lodIndex, bool(saveMesh)(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex)=nullptr)
    ModelBase::SaveMesh(WriteStream& stream, const MeshBase* mesh)
    BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    BinaryAsset::SetChunk(int32 index, const Span<byte>& data)
    ManagedScriptingObject::SetManagedInstance(MObject* instance)
    Asset::ShouldDeleteFileOnUnload()
    Model
    Asset::startLoading()
    StreamableResource::StartStreaming(bool isDynamic)
    StreamableResource::StopStreaming()
    BinaryAsset::Storage
    StreamableResource::StreamableResource(StreamingGroup* group)
    StreamableResource::Streaming
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Asset::ToString()
    ScriptingObject::UnregisterObject()
    ModelBase::UpdateAllocation(int32 residency)
    Asset::WaitForLoaded(double timeoutInMilliseconds=30000.0)
    BinaryAsset::~BinaryAsset()
    ModelBase::~ModelBase()
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    StreamableResource::~StreamableResource()
    Assembly: FlaxEngine.dll
    File: Engine/Content/Assets/Model.h
    Syntax
    public class Model : public ModelBase

    Fields

    LODs

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

    Declaration
    public Array<ModelLOD, FixedAllocation<MODEL_MAX_LODS>> LODs
    Field Value
    Array<ModelLOD, FixedAllocation<MODEL_MAX_LODS>>

    SDF

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

    Declaration
    public SDFData SDF
    Field Value
    SDFData

    Methods

    Draw(const RenderContext& renderContext, const Mesh::DrawInfo& info)

    Draws the model.

    Declaration
    public void Draw(const RenderContext& renderContext, const Mesh::DrawInfo& info)
    Parameters
    RenderContext renderContext

    The rendering context.

    Mesh::DrawInfo info

    The packed drawing info data.

    Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags=StaticFlags::None, bool receiveDecals=true, int8 sortOrder = 0)

    Draws the model.

    Declaration
    public void Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags=StaticFlags::None, bool receiveDecals=true, int8 sortOrder = 0) const
    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.

    bool receiveDecals

    True if rendered geometry can receive decals, otherwise false.

    int8 sortOrder

    Object sorting key.

    Draw(const RenderContextBatch& renderContextBatch, const Mesh::DrawInfo& info)

    Draws the model.

    Declaration
    public void Draw(const RenderContextBatch& renderContextBatch, const Mesh::DrawInfo& info)
    Parameters
    RenderContextBatch renderContextBatch

    The rendering context batch.

    Mesh::DrawInfo info

    The packed drawing info data.

    GenerateSDF(float resolutionScale=1.0f, int32 lodIndex=6, bool cacheData=true, float backfacesThreshold = 0.6f, bool useGPU=true)

    Generates the Sign Distant Field for this model.

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

    Declaration
    public bool GenerateSDF(float resolutionScale=1.0f, int32 lodIndex=6, bool cacheData=true, float backfacesThreshold = 0.6f, bool useGPU=true)
    Parameters
    float resolutionScale

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

    int32 lodIndex

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

    bool 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.

    float 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.

    bool useGPU

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

    Returns
    bool

    True if failed, otherwise false.

    GetAllocatedResidency()

    Gets resource allocated residency level.

    Declaration
    public virtual int32 GetAllocatedResidency() const override
    Returns
    int32

    Overrides
    StreamableResource::GetAllocatedResidency()

    GetBox(const Matrix& world, int32 lodIndex = 0)

    Gets the model bounding box in custom matrix world space.

    Declaration
    public BoundingBox GetBox(const Matrix& world, int32 lodIndex = 0) const
    Parameters
    Matrix world

    The transformation matrix.

    int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    GetBox(const Transform& transform, int32 lodIndex = 0)

    Gets the model bounding box in custom transformation.

    Declaration
    public BoundingBox GetBox(const Transform& transform, int32 lodIndex = 0) const
    Parameters
    Transform transform

    The instance transformation.

    int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    GetBox(int32 lodIndex = 0)

    Gets the model bounding box in local space.

    Declaration
    public BoundingBox GetBox(int32 lodIndex = 0) const
    Parameters
    int32 lodIndex

    The Level Of Detail index.

    Returns
    BoundingBox

    The bounding box.

    getChunksToPreload()

    Gets packed chunks indices to preload before asset loading action

    Declaration
    protected virtual AssetChunksFlag getChunksToPreload() const override
    Returns
    AssetChunksFlag

    Chunks to load flags

    Overrides
    BinaryAsset::getChunksToPreload()

    GetLOD(int32 lodIndex)

    Gets the mesh for a particular LOD index.

    Declaration
    public virtual ModelLODBase* GetLOD(int32 lodIndex) const override
    Parameters
    int32 lodIndex

    Returns
    ModelLODBase

    Overrides
    ModelBase::GetLOD(int32 lodIndex)

    GetLODsCount()

    Gets amount of the level of details in the model.

    Declaration
    public virtual int32 GetLODsCount() const override
    Returns
    int32

    Overrides
    ModelBase::GetLODsCount()

    GetMaxResidency()

    Gets resource maximum residency level.

    Declaration
    public virtual int32 GetMaxResidency() const override
    Returns
    int32

    Overrides
    StreamableResource::GetMaxResidency()

    GetMesh(int32 meshIndex, int32 lodIndex = 0)

    Gets the mesh for a particular LOD index.

    Declaration
    public virtual MeshBase* GetMesh(int32 meshIndex, int32 lodIndex = 0) const override
    Parameters
    int32 meshIndex

    int32 lodIndex

    Returns
    MeshBase

    Overrides
    ModelBase::GetMesh(int32 meshIndex, int32 lodIndex = 0)

    GetMeshes(Array<const MeshBase* >& meshes, int32 lodIndex = 0)

    Gets the meshes for a particular LOD index.

    Declaration
    public virtual void GetMeshes(Array<const MeshBase* >& meshes, int32 lodIndex = 0) const override
    Parameters
    Array<MeshBase > meshes

    int32 lodIndex

    Overrides
    ModelBase::GetMeshes(Array<const MeshBase* >& meshes, int32 lodIndex = 0)

    GetMeshes(Array<MeshBase* >& meshes, int32 lodIndex = 0)

    Gets the meshes for a particular LOD index.

    Declaration
    public virtual void GetMeshes(Array<MeshBase* >& meshes, int32 lodIndex = 0) override
    Parameters
    Array<MeshBase > meshes

    int32 lodIndex

    Overrides
    ModelBase::GetMeshes(Array<MeshBase* >& meshes, int32 lodIndex = 0)

    HasAnyLODInitialized()

    Determines whether any LOD has been initialized.

    Declaration
    public bool HasAnyLODInitialized() const
    Returns
    bool

    InitAsVirtual()

    Initializes asset data as virtual asset.

    Declaration
    public virtual void InitAsVirtual() override
    Overrides
    Asset::InitAsVirtual()

    Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal, Mesh* *mesh, int32 lodIndex = 0)

    Determines if there is an intersection between the Model and a Ray in given world using given instance.

    Declaration
    public bool Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal, Mesh* *mesh, int32 lodIndex = 0)
    Parameters
    Ray ray

    The ray to test

    Matrix world

    World to test

    Real distance

    When the method completes, contains the distance of the intersection (if any valid).

    Vector3 normal

    When the method completes, contains the intersection surface normal vector (if any valid).

    Mesh mesh

    Mesh, or null

    int32 lodIndex

    Level Of Detail index

    Returns
    bool

    True whether the two objects intersected

    Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal, Mesh* *mesh, int32 lodIndex = 0)

    Determines if there is an intersection between the Model and a Ray in given world using given instance.

    Declaration
    public bool Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal, Mesh* *mesh, int32 lodIndex = 0)
    Parameters
    Ray ray

    The ray to test

    Transform transform

    The instance transformation.

    Real distance

    When the method completes, contains the distance of the intersection (if any valid).

    Vector3 normal

    When the method completes, contains the intersection surface normal vector (if any valid).

    Mesh mesh

    Mesh, or null

    int32 lodIndex

    Level Of Detail index

    Returns
    bool

    True whether the two objects intersected

    load()

    Load data from the chunks

    Declaration
    protected virtual LoadResult load() override
    Returns
    LoadResult

    Loading result

    Overrides
    BinaryAsset::load()

    Render(GPUContext* context, int32 lodIndex = 0)

    Draws the meshes. Binds vertex and index buffers and invokes the draw calls.

    Declaration
    public void Render(GPUContext* context, int32 lodIndex = 0)
    Parameters
    GPUContext context

    GPU context to draw with.

    int32 lodIndex

    The Level Of Detail index.

    SetSDF(const SDFData& sdf)

    Sets set SDF data (releases the current one).

    Declaration
    public void SetSDF(const SDFData& sdf)
    Parameters
    SDFData sdf

    SetupLODs(const Span<int32>& meshesCountPerLod)

    Setups the model LODs collection including meshes creation.

    Declaration
    public bool SetupLODs(const Span<int32>& meshesCountPerLod)
    Parameters
    Span<int32> meshesCountPerLod

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

    Returns
    bool

    True if failed, otherwise false.

    SetupMaterialSlots(int32 slotsCount)

    Resizes the material slots collection. Updates meshes that were using removed slots.

    Declaration
    public virtual void SetupMaterialSlots(int32 slotsCount) override
    Parameters
    int32 slotsCount

    Overrides
    ModelBase::SetupMaterialSlots(int32 slotsCount)

    unload(bool isReloading)

    Unloads asset data

    Declaration
    protected virtual void unload(bool isReloading) override
    Parameters
    bool isReloading

    True if asset is reloading data, otherwise false.

    Overrides
    Asset::unload(bool isReloading)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat