载入中...
搜索中...
未找到
eve::sceneloader::SceneLoader类 参考

Loads a 3D scene (glTF / OBJ / FBX / GLB ... via Assimp/medialoader) into the ECS scene tree. 更多...

#include <SceneLoader.h>

类 eve::sceneloader::SceneLoader 继承关系图:
eve::Module

struct  CpuImage
 CPU-decoded texture (RGBA8) keyed by the same source+suffix key as TextureCache. 更多...
 

Public 类型

using TextureCache = std::unordered_map< std::string, graphics::Texture * >
 Caches shared across the loader: textures by source key, GPU meshes per aiMesh.
 
using MeshCache = std::unordered_map< const aiMesh *, graphics::Mesh * >
 
using CpuImageMap = std::unordered_map< std::string, CpuImage >
 

Public 成员函数

 Module_REG (SceneLoader)
 
 ~SceneLoader () override
 
scene::SceneHostload (const std::string &path, bool linkRenderables=true, const LoadOptions &options={})
 Full load: build the GameObject tree from path, mount it, return host.
 
scene::SceneHostload (const std::string &path, const LoadOptions &options)
 
bool reload (const std::string &path, SceneDiff *out=nullptr, const LoadOptions &options={})
 Hot-reload path. Re-decodes, diffs, and applies only what changed. Returns false if the file failed to decode (old scene is kept) or nothing changed. When out is non-null it is filled with the applied diff.
 
bool reloadChecked (const std::string &path)
 Script-friendly reload: returns true when anything was updated.
 
SceneDiff diff (const std::string &path)
 Dry-run diff for path against the currently mounted tree (no mutation).
 
scene::SceneHosthost (const std::string &path)
 The mounted host for path, or nullptr if not loaded.
 
void unload (const std::string &path)
 Drop the loaded scene for path, destroying linked Renderable3D objects.
 
int nodeCount (const std::string &path)
 Number of GameObjects (SceneNodes) currently mounted for path; 0 if none.
 
bool loaded (const std::string &path)
 True if path is currently loaded.
 
bool loadAsync (const std::string &path, const LoadOptions &options={}, std::function< void(scene::SceneHost *)> done=nullptr)
 Decode path on a worker thread, then apply it on the main thread the next time pollAsync() is called (GPU upload + ECS mount happen there). done fires on the main thread during pollAsync() with the mounted host. Returns false when a load for path is already in flight.
 
int pollAsync ()
 Mount every decoded-but-not-applied scene. Must be called on the main / render thread. Returns the number of scenes applied this call.
 
bool prewarmAsync (const std::string &path, const LoadOptions &options={})
 Decode and retain a scene without creating ECS/GPU objects.
 
bool prewarmed (const std::string &path) const
 True when a decoded scene is ready for load() to consume.
 
void clearPrewarm (const std::string &path)
 Drop a decoded prewarm result and release its CPU scene.
 
int pendingAsyncCount () const
 Number of async loads still waiting to be mounted.
 
int lightCount (const std::string &path)
 Number of imported Light3D entities for path; 0 if none / disabled.
 
graphics::Light3Dlight (const std::string &path, int index)
 
int cameraCount (const std::string &path)
 Number of imported Camera3D entities for path; 0 if none / disabled.
 
graphics::Camera3Dcamera (const std::string &path, int index)
 
int animationCount (const std::string &path)
 Number of imported animation clips for path; 0 if none / disabled.
 
animation::AnimSkeletonskeleton (const std::string &path)
 Imported skeleton for path (nullptr when the scene has no animations).
 
animation::AnimClipclip (const std::string &path, int index)
 
- Public 成员函数 继承自 eve::Module
virtual ~Module ()
 
virtual std::string getName () const =0
 

静态 Public 成员函数

static scene::NodeDesc buildNodeDesc (const aiScene *scene, MeshSlotMap *slotsOut=nullptr)
 Flatten an Assimp scene into a scene::NodeDesc tree (id = object id).
 
static SceneDiff diffTree (scene::SceneHost *host, const scene::NodeDesc &newRoot)
 Diff a mounted host tree against a freshly built NodeDesc tree.
 
static bool applyTreeDiff (scene::SceneHost *host, const scene::NodeDesc &newRoot, const SceneDiff &diff, graphics::Graphics *gfx, const MeshSlotMap *slots)
 Apply a diff to the host arena in place. Creates/destroys Renderable3D for added/removed mesh objects when gfx and slots are provided; otherwise only the GameObject tree is mutated (useful for logic-only tests).
 
static void fillSceneBounds (scene::SceneHost *host, const MeshSlotMap &slots)
 Fill node bounds from Assimp mesh AABBs (mesh GameObjects get the exact local-space AABB; ancestors get the union of their children in local space), so picking / frustum culling work on loaded models.
 

详细描述

Loads a 3D scene (glTF / OBJ / FBX / GLB ... via Assimp/medialoader) into the ECS scene tree.

For every aiNode it creates a scene::SceneHost GameObject (SceneNode) mirroring the source hierarchy, and for every referenced aiMesh it creates a child GameObject that links a graphics::Renderable3D (mesh + material). Materials import the PBR base-color / metallic / roughness / normal / height factors and textures. Textures are cached by path and shared across meshes; meshes referenced by several nodes share one GPU buffer (LoadOptions::sharedMeshes). aiLight / aiCamera / aiAnimation entries are imported as graphics::Light3D / graphics::Camera3D entities and animation::AnimSkeleton + AnimClip objects when the corresponding LoadOptions flags are enabled.

Hot-reload: reload() re-decodes the file, diffs the new tree against the mounted tree, and applies only the changed GameObjects in place — transform / visibility edits patch the existing node, added objects are appended (mesh uploaded once), removed objects are destroyed, and identical objects are left completely untouched (no re-upload, no rebuild).

在文件 SceneLoader.h137 行定义.

成员类型定义说明

◆ CpuImageMap

using eve::sceneloader::SceneLoader::CpuImageMap = std::unordered_map<std::string, CpuImage>

在文件 SceneLoader.h227 行定义.

◆ MeshCache

using eve::sceneloader::SceneLoader::MeshCache = std::unordered_map<const aiMesh *, graphics::Mesh *>

在文件 SceneLoader.h220 行定义.

◆ TextureCache

using eve::sceneloader::SceneLoader::TextureCache = std::unordered_map<std::string, graphics::Texture *>

Caches shared across the loader: textures by source key, GPU meshes per aiMesh.

在文件 SceneLoader.h219 行定义.

构造及析构函数说明

◆ ~SceneLoader()

eve::sceneloader::SceneLoader::~SceneLoader ( )
override

在文件 SceneLoader.cpp55 行定义.

成员函数说明

◆ animationCount()

int eve::sceneloader::SceneLoader::animationCount ( const std::string &  path)

Number of imported animation clips for path; 0 if none / disabled.

在文件 SceneLoader.cpp1090 行定义.

◆ applyTreeDiff()

bool eve::sceneloader::SceneLoader::applyTreeDiff ( scene::SceneHost host,
const scene::NodeDesc newRoot,
const SceneDiff diff,
graphics::Graphics gfx,
const MeshSlotMap slots 
)
static

Apply a diff to the host arena in place. Creates/destroys Renderable3D for added/removed mesh objects when gfx and slots are provided; otherwise only the GameObject tree is mutated (useful for logic-only tests).

在文件 SceneLoader.cpp633 行定义.

引用了 c, d, diff(), eve::sceneloader::SceneDiff::empty(), fillSceneBounds(), eve::scene::SceneHost::findLink(), eve::scene::findLinkKind(), host(), eve::scene::SceneNode::id, idx, eve::scene::SceneHost::invalidateIndex(), eve::scene::SceneHost::markTransformDirty() , 以及 n.

被这些函数引用 reload().

◆ buildNodeDesc()

scene::NodeDesc eve::sceneloader::SceneLoader::buildNodeDesc ( const aiScene *  scene,
MeshSlotMap slotsOut = nullptr 
)
static

Flatten an Assimp scene into a scene::NodeDesc tree (id = object id).

在文件 SceneLoader.cpp591 行定义.

被这些函数引用 diff().

◆ camera()

graphics::Camera3D * eve::sceneloader::SceneLoader::camera ( const std::string &  path,
int  index 
)

在文件 SceneLoader.cpp1082 行定义.

◆ cameraCount()

int eve::sceneloader::SceneLoader::cameraCount ( const std::string &  path)

Number of imported Camera3D entities for path; 0 if none / disabled.

在文件 SceneLoader.cpp1077 行定义.

◆ clearPrewarm()

void eve::sceneloader::SceneLoader::clearPrewarm ( const std::string &  path)

Drop a decoded prewarm result and release its CPU scene.

在文件 SceneLoader.cpp1051 行定义.

◆ clip()

animation::AnimClip * eve::sceneloader::SceneLoader::clip ( const std::string &  path,
int  index 
)

在文件 SceneLoader.cpp1100 行定义.

被这些函数引用 unload().

◆ diff()

SceneDiff eve::sceneloader::SceneLoader::diff ( const std::string &  path)

Dry-run diff for path against the currently mounted tree (no mutation).

在文件 SceneLoader.cpp921 行定义.

引用了 eve::sceneloader::SceneDiffEntry::Add, buildNodeDesc(), c, d, diffTree(), eve::ResourceManager::getInstance(), eve::model3d::ModelData::getScene(), n, parent , 以及 eve::ResourceManager::reload().

被这些函数引用 applyTreeDiff() , 以及 reload().

◆ diffTree()

SceneDiff eve::sceneloader::SceneLoader::diffTree ( scene::SceneHost host,
const scene::NodeDesc newRoot 
)
static

Diff a mounted host tree against a freshly built NodeDesc tree.

在文件 SceneLoader.cpp599 行定义.

引用了 c, d, eve::sceneloader::SceneDiff::entries, host(), eve::scene::SceneNode::id, n, eve::sceneloader::SceneDiffEntry::Remove , 以及 eve::sceneloader::SceneDiff::removed.

被这些函数引用 diff() , 以及 reload().

◆ fillSceneBounds()

void eve::sceneloader::SceneLoader::fillSceneBounds ( scene::SceneHost host,
const MeshSlotMap slots 
)
static

Fill node bounds from Assimp mesh AABBs (mesh GameObjects get the exact local-space AABB; ancestors get the union of their children in local space), so picking / frustum culling work on loaded models.

在文件 SceneLoader.cpp746 行定义.

引用了 host() , 以及 n.

被这些函数引用 applyTreeDiff().

◆ host()

scene::SceneHost * eve::sceneloader::SceneLoader::host ( const std::string &  path)

The mounted host for path, or nullptr if not loaded.

在文件 SceneLoader.cpp952 行定义.

被这些函数引用 applyTreeDiff(), diffTree(), fillSceneBounds(), load() , 以及 nodeCount().

◆ light()

graphics::Light3D * eve::sceneloader::SceneLoader::light ( const std::string &  path,
int  index 
)

在文件 SceneLoader.cpp1069 行定义.

◆ lightCount()

int eve::sceneloader::SceneLoader::lightCount ( const std::string &  path)

Number of imported Light3D entities for path; 0 if none / disabled.

在文件 SceneLoader.cpp1064 行定义.

◆ load() [1/2]

scene::SceneHost * eve::sceneloader::SceneLoader::load ( const std::string &  path,
bool  linkRenderables = true,
const LoadOptions options = {} 
)

Full load: build the GameObject tree from path, mount it, return host.

在文件 SceneLoader.cpp871 行定义.

引用了 eve::scene::SceneHost::createHost(), d, host(), eve::Loaded, eve::scene::SceneHost::setTree() , 以及 eve::scene::TransformSystem::updateHost().

被这些函数引用 load() , 以及 reload().

◆ load() [2/2]

scene::SceneHost * eve::sceneloader::SceneLoader::load ( const std::string &  path,
const LoadOptions options 
)

在文件 SceneLoader.cpp893 行定义.

引用了 load().

◆ loadAsync()

bool eve::sceneloader::SceneLoader::loadAsync ( const std::string &  path,
const LoadOptions options = {},
std::function< void(scene::SceneHost *)>  done = nullptr 
)

Decode path on a worker thread, then apply it on the main thread the next time pollAsync() is called (GPU upload + ECS mount happen there). done fires on the main thread during pollAsync() with the mounted host. Returns false when a load for path is already in flight.

在文件 SceneLoader.cpp986 行定义.

引用了 d , 以及 p.

◆ loaded()

bool eve::sceneloader::SceneLoader::loaded ( const std::string &  path)

True if path is currently loaded.

在文件 SceneLoader.cpp962 行定义.

◆ Module_REG()

eve::sceneloader::SceneLoader::Module_REG ( SceneLoader  )

◆ nodeCount()

int eve::sceneloader::SceneLoader::nodeCount ( const std::string &  path)

Number of GameObjects (SceneNodes) currently mounted for path; 0 if none.

在文件 SceneLoader.cpp957 行定义.

引用了 h , 以及 host().

◆ pendingAsyncCount()

int eve::sceneloader::SceneLoader::pendingAsyncCount ( ) const

Number of async loads still waiting to be mounted.

在文件 SceneLoader.cpp1057 行定义.

◆ pollAsync()

int eve::sceneloader::SceneLoader::pollAsync ( )

Mount every decoded-but-not-applied scene. Must be called on the main / render thread. Returns the number of scenes applied this call.

在文件 SceneLoader.cpp1008 行定义.

引用了 d , 以及 h.

◆ prewarmAsync()

bool eve::sceneloader::SceneLoader::prewarmAsync ( const std::string &  path,
const LoadOptions options = {} 
)

Decode and retain a scene without creating ECS/GPU objects.

在文件 SceneLoader.cpp1026 行定义.

引用了 d , 以及 p.

◆ prewarmed()

bool eve::sceneloader::SceneLoader::prewarmed ( const std::string &  path) const

True when a decoded scene is ready for load() to consume.

在文件 SceneLoader.cpp1047 行定义.

◆ reload()

bool eve::sceneloader::SceneLoader::reload ( const std::string &  path,
SceneDiff out = nullptr,
const LoadOptions options = {} 
)

Hot-reload path. Re-decodes, diffs, and applies only what changed. Returns false if the file failed to decode (old scene is kept) or nothing changed. When out is non-null it is filled with the applied diff.

在文件 SceneLoader.cpp897 行定义.

引用了 applyTreeDiff(), d, diff(), diffTree(), eve::sceneloader::SceneDiff::empty(), load(), eve::Loaded , 以及 eve::scene::TransformSystem::updateHost().

被这些函数引用 reloadChecked().

◆ reloadChecked()

bool eve::sceneloader::SceneLoader::reloadChecked ( const std::string &  path)
inline

Script-friendly reload: returns true when anything was updated.

在文件 SceneLoader.h157 行定义.

引用了 reload().

◆ skeleton()

animation::AnimSkeleton * eve::sceneloader::SceneLoader::skeleton ( const std::string &  path)

Imported skeleton for path (nullptr when the scene has no animations).

在文件 SceneLoader.cpp1095 行定义.

◆ unload()

void eve::sceneloader::SceneLoader::unload ( const std::string &  path)

Drop the loaded scene for path, destroying linked Renderable3D objects.

在文件 SceneLoader.cpp964 行定义.

引用了 c, clip(), eve::scene::findLinkKind() , 以及 n.


该类的文档由以下文件生成: