Search Results for

    Show / Hide Table of Contents

    Class ModelBase

    Base class for asset types that can contain a model resource.

    Inheritance
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    BinaryAsset
    ModelBase
    Inherited Members
    Asset::_deleteFileOnUnload
    BinaryAsset::_dependantAssets
    ScriptingObject::_gcHandle
    StreamableResource::_group
    BinaryAsset::_header
    ScriptingObject::_id
    StreamableResource::_isDynamic
    BinaryAsset::_isSaving
    StreamableResource::_isStreaming
    Asset::_isVirtual
    Asset::_loadingTask
    Asset::_loadState
    Asset::_refCount
    BinaryAsset::_storageRef
    StreamableResource::_streamingQuality
    ScriptingObject::_type
    BinaryAsset::AddDependency(BinaryAsset* asset)
    Asset::AddReference()
    Asset::Asset(const SpawnParams& params, const AssetInfo* info)
    ModelBase
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ScriptingObject::Cast(ScriptingObject* obj)
    Asset::ChangeID(const Guid& newId)
    BinaryAsset::ClearDependencies()
    Asset::const
    BinaryAsset::createLoadingTask()
    Asset::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    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()
    ModelBase
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    StreamableResource::GetAllocatedResidency()
    BinaryAsset::GetChunk(int32 index)
    BinaryAsset::GetChunkData(int32 index, BytesContainer& data)
    BinaryAsset::GetChunkSize(int32 index)
    BinaryAsset::getChunksToPreload()
    ScriptingObject::GetClass()
    StreamableResource::GetGroup()
    ScriptingObject::GetID()
    BinaryAsset::GetImportMetadata(String& path, String& username)
    BinaryAsset::GetImportPath()
    ScriptingObject::GetManagedInstance()
    StreamableResource::GetMaxResidency()
    BinaryAsset::GetMemoryUsage()
    BinaryAsset::GetOrCreateChunk(int32 index)
    ScriptingObject::GetOrCreateManagedInstance()
    BinaryAsset::GetPath()
    Asset::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
    Asset::GetReferences()
    Asset::GetReferencesCount()
    BinaryAsset::GetSerializedVersion()
    StreamableResource::GetStreamingQuality()
    StreamableResource::GetTargetResidency()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Asset::GetTypeName()
    BinaryAsset::HasChunk(int32 index)
    BinaryAsset::HasChunkLoaded(int32 index)
    BinaryAsset::HasDependenciesModified()
    ScriptingObject::HasManagedInstance()
    BinaryAsset::Init(const FlaxStorageReference& storage, AssetHeader& header)
    BinaryAsset::Init(AssetInitData& initData)
    BinaryAsset::init(AssetInitData& initData)
    Asset::InitAsVirtual()
    BinaryAsset::InitVirtual(AssetInitData& initData)
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    StreamableResource::IsAllocated()
    StreamableResource::IsDynamic()
    Asset::IsInternalType()
    Asset::IsLoaded()
    ScriptingObject::IsRegistered()
    Asset::IsVirtual()
    Asset::LastLoadFailed()
    BinaryAsset::load()
    BinaryAsset::loadAsset()
    BinaryAsset::LoadChunk(int32 chunkIndex)
    BinaryAsset::LoadChunks(AssetChunksFlag chunks)
    ModelBase
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    ModelBase
    BinaryAsset::Metadata
    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)
    StreamableResource::RequestStreamingUpdate()
    StreamableResource::ResetStreaming(bool error=true)
    StreamableResource::ResidencyChanged
    BinaryAsset::SaveAsset(AssetInitData& data, bool silentMode=false)
    BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
    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()
    ModelBase
    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()
    Asset::WaitForLoaded(double timeoutInMilliseconds=30000.0)
    BinaryAsset::~BinaryAsset()
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    StreamableResource::~StreamableResource()
    Assembly: FlaxEngine.dll
    File: Engine/Content/Assets/ModelBase.h
    Syntax
    public class ModelBase : public BinaryAsset, public StreamableResource

    Constructors

    ~ModelBase()

    Declaration
    public ~ModelBase()

    ModelBase(const SpawnParams& params, const AssetInfo* info, StreamingGroup* group)

    Declaration
    protected ModelBase(const SpawnParams& params, const AssetInfo* info, StreamingGroup* group)
    Parameters
    SpawnParams params

    AssetInfo info

    StreamingGroup group

    Fields

    _initialized

    Declaration
    protected bool _initialized = false
    Field Value
    bool

    _loadedLODs

    Declaration
    protected int32 _loadedLODs = 0
    Field Value
    int32

    _streamingTask

    Declaration
    protected StreamModelLODTask* _streamingTask = nullptr
    Field Value
    StreamModelLODTask

    MaterialSlots

    The list of material slots.

    Declaration
    public Array<MaterialSlot> MaterialSlots
    Field Value
    Array<MaterialSlot>

    MinScreenSize

    The minimum screen size to draw this model (the bottom limit). Used to cull small models. Set to 0 to disable this feature.

    Declaration
    public float MinScreenSize = 0.0f
    Field Value
    float

    Methods

    CanBeRendered()

    Determines whether this model can be rendered.

    Declaration
    public bool CanBeRendered() const
    Returns
    bool

    CanBeUpdated()

    Determines whether this instance can be updated. Which means: no async streaming, no pending action in background.

    Declaration
    public virtual bool CanBeUpdated() const override
    Returns
    bool

    true if this instance can be updated; otherwise, false.

    Overrides
    StreamableResource::CanBeUpdated()

    CancelStreaming()

    Cancels any asynchronous content streaming by this asset (eg. mesh data streaming into GPU memory). Will release any locks for asset storage container.

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

    CancelStreamingTasks()

    Cancels any streaming task (or tasks sequence) started for this resource.

    Declaration
    public virtual void CancelStreamingTasks() override
    Overrides
    StreamableResource::CancelStreamingTasks()

    ClampLODIndex(int32 index)

    Clamps the index of the LOD to be valid for rendering (only loaded LODs).

    Declaration
    public int32 ClampLODIndex(int32 index) const
    Parameters
    int32 index

    The index.

    Returns
    int32

    The resident LOD index.

    CreateStreamingTask(int32 residency)

    Creates streaming task (or tasks sequence) to perform resource streaming for the desire residency level.

    Declaration
    public virtual Task* CreateStreamingTask(int32 residency) override
    Parameters
    int32 residency

    The target residency.

    Returns
    Task

    Async task or tasks that update resource residency level. Must be preceded with UpdateAllocation call.

    Overrides
    StreamableResource::CreateStreamingTask(int32 residency)

    GetCurrentResidency()

    Gets resource current residency level.

    Declaration
    public virtual int32 GetCurrentResidency() const override
    Returns
    int32

    Overrides
    StreamableResource::GetCurrentResidency()

    GetLoadedLODs()

    Gets the amount of loaded model LODs.

    Declaration
    public int32 GetLoadedLODs() const
    Returns
    int32

    GetLOD(int32 lodIndex)

    Gets the mesh for a particular LOD index.

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

    Returns
    ModelLODBase

    GetLODData(int32 lodIndex, BytesContainer& data)

    Gets the model LOD data (links bytes).

    Declaration
    public void GetLODData(int32 lodIndex, BytesContainer& data) const
    Parameters
    int32 lodIndex

    Index of the LOD.

    BytesContainer data

    The data (it may be missing if failed to get it).

    GetLODsCount()

    Gets amount of the level of details in the model.

    Declaration
    public virtual int32 GetLODsCount() const = 0
    Returns
    int32

    GetMaterialSlotsCount()

    Gets the amount of the material slots used by this model asset.

    Declaration
    public int32 GetMaterialSlotsCount() const
    Returns
    int32

    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 = 0
    Parameters
    int32 meshIndex

    int32 lodIndex

    Returns
    MeshBase

    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 = 0
    Parameters
    Array<MeshBase > meshes

    int32 lodIndex

    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) = 0
    Parameters
    Array<MeshBase > meshes

    int32 lodIndex

    GetReferences(Array<Guid>& assets, Array<String>& files)

    Declaration
    public void GetReferences(Array<Guid>& assets, Array<String>& files) const override
    Parameters
    Array<Guid> assets

    Array<String> files

    GetSlot(const StringView& name)

    Gets the material slot by the name.

    Declaration
    public MaterialSlot* GetSlot(const StringView& name)
    Parameters
    StringView name

    The slot name.

    Returns
    MaterialSlot

    The material slot with the given name or null if cannot find it (asset may be not loaded yet).

    HighestResidentLODIndex()

    Gets index of the highest resident LOD (it may be equal to LODs.Count if no LOD has been uploaded). Note: LOD=0 is the highest (top quality)

    Declaration
    public int32 HighestResidentLODIndex() const
    Returns
    int32

    IsInitialized()

    Gets a value indicating whether this instance is initialized.

    Declaration
    public bool IsInitialized() const
    Returns
    bool

    LoadHeader(ReadStream& stream, byte& headerVersion)

    Declaration
    protected bool LoadHeader(ReadStream& stream, byte& headerVersion)
    Parameters
    ReadStream stream

    byte headerVersion

    Returns
    bool

    LoadMesh(class MemoryReadStream& stream, byte meshVersion, MeshBase* mesh, MeshData* dataIfReadOnly=nullptr)

    Declaration
    protected virtual bool LoadMesh(class MemoryReadStream& stream, byte meshVersion, MeshBase* mesh, MeshData* dataIfReadOnly=nullptr)
    Parameters
    class MemoryReadStream stream

    byte meshVersion

    MeshBase mesh

    MeshData dataIfReadOnly

    Returns
    bool

    RequestLODDataAsync(int32 lodIndex)

    Requests the LOD data asynchronously (creates task that will gather chunk data or null if already here).

    Declaration
    public ContentLoadTask* RequestLODDataAsync(int32 lodIndex)
    Parameters
    int32 lodIndex

    Index of the LOD.

    Returns
    ContentLoadTask

    Task that will gather chunk data or null if already here.

    Save(bool withMeshDataFromGpu, Function<FlaxChunk* (int32)>& getChunk)

    Declaration
    protected virtual bool Save(bool withMeshDataFromGpu, Function<FlaxChunk* (int32)>& getChunk) const
    Parameters
    bool withMeshDataFromGpu

    Function<FlaxChunk (int32)> getChunk

    Returns
    bool

    Save(bool withMeshDataFromGpu=false, const StringView& path=StringView::Empty)

    Saves this asset to the file. Supported only in Editor.

    If you use saving with the GPU mesh data then the call has to be provided from the thread other than the main game thread.

    Declaration
    public bool Save(bool withMeshDataFromGpu=false, const StringView& path=StringView::Empty)
    Parameters
    bool withMeshDataFromGpu

    True if save also GPU mesh buffers, otherwise will keep data in storage unmodified. Valid only if saving the same asset to the same location, and it's loaded.

    StringView path

    The custom asset path to use for the saving. Use empty value to save this asset to its own storage location. Can be used to duplicate asset. Must be specified when saving virtual asset.

    Returns
    bool

    True when cannot save data, otherwise false.

    Save(const StringView& path=StringView::Empty)

    Saves this asset to the file. Supported only in Editor.

    Declaration
    public virtual bool Save(const StringView& path=StringView::Empty) override
    Parameters
    StringView path

    The custom asset path to use for the saving. Use empty value to save this asset to its own storage location. Can be used to duplicate asset. Must be specified when saving virtual asset.

    Returns
    bool

    True when cannot save data, otherwise false.

    Overrides
    Asset::Save(const StringView& path=StringView::Empty)

    SaveHeader(WriteStream& stream)

    Declaration
    protected virtual bool SaveHeader(WriteStream& stream) const
    Parameters
    WriteStream stream

    Returns
    bool

    SaveHeader(WriteStream& stream, const class ModelData& modelData)

    Declaration
    protected static bool SaveHeader(WriteStream& stream, const class ModelData& modelData)
    Parameters
    WriteStream stream

    class ModelData modelData

    Returns
    bool

    SaveLOD(WriteStream& stream, const ModelData& modelData, int32 lodIndex, bool(saveMesh)(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex)=nullptr)

    Declaration
    protected static bool SaveLOD(WriteStream& stream, const ModelData& modelData, int32 lodIndex, bool(saveMesh)(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex)=nullptr)
    Parameters
    WriteStream stream

    ModelData modelData

    int32 lodIndex

    bool(saveMesh)(WriteStreamstream, ModelDatamodelData, int32 lodIndex, int32 meshIndex) ModelBase_SaveLOD_WriteStream___const_ModelData___int32_bool_saveMesh__WriteStream__stream__const_ModelData__modelData__int32_lodIndex__int32_meshIndex__

    Returns
    bool

    SaveLOD(WriteStream& stream, int32 lodIndex)

    Declaration
    protected bool SaveLOD(WriteStream& stream, int32 lodIndex) const
    Parameters
    WriteStream stream

    int32 lodIndex

    Returns
    bool

    SaveMesh(WriteStream& stream, const MeshBase* mesh)

    Declaration
    protected virtual bool SaveMesh(WriteStream& stream, const MeshBase* mesh) const
    Parameters
    WriteStream stream

    MeshBase mesh

    Returns
    bool

    SetupMaterialSlots(int32 slotsCount)

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

    Declaration
    public virtual void SetupMaterialSlots(int32 slotsCount)
    Parameters
    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)

    UpdateAllocation(int32 residency)

    Updates the resource allocation to the given residency level. May not be updated now but in an async operation.

    Declaration
    public virtual Task* UpdateAllocation(int32 residency) override
    Parameters
    int32 residency

    The target allocation residency.

    Returns
    Task

    Async task that updates resource allocation or null if already done it. Warning: need to call task start to perform allocation.

    Overrides
    StreamableResource::UpdateAllocation(int32 residency)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat