FModelInstantiator
Turns an imported model's source node graph into an actor/entity tree, the UE analogue of dragging an FBX with several mesh objects: a model whose nodes carry more than one geometry object expands into a parent + one child entity per node (each with its own TransformComponent and a MeshRendererComponent bound to that node's submeshes), instead of collapsing everything onto a single flat entity. Single-mesh and skinned models keep the single-entity representation. Pure CPU — no GPU objects are touched, so the same builder backs both the editor drop path and the headless tests.
- Module
- Game
- Header
#include "Scene/ModelInstantiator.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
int32_t | GeometryNodeCount | Number of nodes in the tree that carry geometry (non-empty meshIndices). |
bool | ShouldInstantiateHierarchy | A model earns a hierarchy when it has a real node tree with more than one geometry-bearing node and is NOT skinned (a skinned mesh stays one entity carrying the skeletal mesh + skeleton, never one entity per bone). |
int32_t | BuildHierarchy | Build one child entity per node under rootEntity, preserving the source parent links (root nodes attach to rootEntity). |
void | AssignNode | Resolve a single node's submeshes onto mrc, at identity local transforms (the node's placement lives in the entity's TransformComponent + parent chain, so baking it here would double-apply it). |
Function details
GeometryNodeCount
static int32_t GeometryNodeCount(const std::vector<ModelNode>& nodes)Number of nodes in the tree that carry geometry (non-empty meshIndices).
ShouldInstantiateHierarchy
static bool ShouldInstantiateHierarchy(const ModelResource& model)A model earns a hierarchy when it has a real node tree with more than one geometry-bearing node and is NOT skinned (a skinned mesh stays one entity carrying the skeletal mesh + skeleton, never one entity per bone).
BuildHierarchy
static int32_t BuildHierarchy(Scene& scene, EntityID rootEntity, const std::string& modelPath, const std::vector<ModelNode>& nodes)Build one child entity per node under rootEntity, preserving the source parent links (root nodes attach to rootEntity). Geometry nodes receive a MeshRendererComponent bound to modelPath with modelNodeIndex set so the resolver pulls only that node's submeshes; every node receives a TransformComponent decomposed from its local transform. gpuMesh is left unresolved (the scene's hydration pass fills it, same as a flat drop). Returns the number of entities created.
AssignNode
static void AssignNode(MeshRendererComponent& mrc, const Ref<MeshAsset>& asset, int32_t nodeIndex)Resolve a single node's submeshes onto mrc, at identity local transforms (the node's placement lives in the entity's TransformComponent + parent chain, so baking it here would double-apply it). Used by the scene-hydration / runtime resolvers when a MeshRenderer carries a modelNodeIndex >= 0. No-op when the asset or node index is invalid.