private void AddMeshes(Node node, CModelAsset asset, string assetPath, CMeshLoadingJob loadingJob, ref Matrix transform) { Matrix previousTransform = transform; transform = Matrix.Multiply(previousTransform, FromAssimpMatrix(node.Transform)); if (node.HasMeshes) { foreach (int meshIndex in node.MeshIndices) { CMeshAsset meshAsset = new CMeshAsset(); // We always import all meshes in a file so we use always import here LoadMeshInternal(meshIndex, meshAsset, loadingJob, assetPath, null, true); meshAsset.LoadFinished(); SMeshChild modelChild = new SMeshChild() { meshAsset = meshAsset, relativeTransform = transform }; asset.MeshChildren.Add(modelChild); } } for (int i = 0; i < node.ChildCount; i++) { AddMeshes(node.Children[i], asset, assetPath, loadingJob, ref transform); } transform = previousTransform; }
public bool TryExecute(Device device, DeviceContext deviceContext, CRenderScene scene) { if (!m_sourceAsset.IsLoaded) { return(false); } for (int i = 0; i < m_sourceAsset.MeshChildren.Count; i++) { SMeshChild meshChild = m_sourceAsset.MeshChildren[i]; Transform childTransform = new Transform(); childTransform.SetFromMatrix(in meshChild.relativeTransform); childTransform.Parent = m_modelTransform; CMeshRenderNode renderNode = new CMeshRenderNode(m_outer, meshChild.meshAsset, null, childTransform); if (meshChild.meshAsset.GetAsset().IsLoaded) { renderNode.TryCreateResources(); } scene.RegisterRenderNode(renderNode); } return(true); }