/// <summary> /// Clones a Scene node with its children and all attached Properties. /// Meshes will only be cloned when <see cref="cloneMeshs"/> is true. /// </summary> /// <param name="nodeToClone">Node to clone</param> /// <param name="cloneMeshs">Force cloning mesh data.</param> /// <returns>SceneNode cloned.</returns> public SceneNode CloneNode(SceneNode nodeToClone, bool cloneMeshs = false) { var cloned = nodeToClone.Clone(cloneMeshs); _allNodes.Add(cloned); CloneChildren(cloned, nodeToClone, cloneMeshs); return cloned; }
private void CloneChildren(SceneNode parentCloned, SceneNode parentOriginal, bool cloneMeshs) { foreach (var childNode in parentOriginal.Children) { var clonedChild = childNode.Clone(cloneMeshs); _allNodes.Add(clonedChild); parentCloned.AddChild(clonedChild); CloneChildren(clonedChild, childNode, cloneMeshs); } }
public void RemoveChild(SceneNode childElement) { if (_childNodes.Remove(childElement)) { childElement.Parent = null; } }
public void AddChild(SceneNode childElement) { childElement.Parent?.RemoveChild(childElement); _childNodes.Add(childElement); childElement.Parent = this; }
public void SetParent(SceneNode parent) { Parent?.RemoveChild(this); parent?.AddChild(this); }
internal SceneNode Clone(bool cloneMesh) { var sceneNode = new SceneNode { Mesh = cloneMesh ? Mesh?.Clone() : Mesh, Material = Material.Clone(), Position = Position, IsBillboard = IsBillboard, Scale = Scale, Forward = Forward, Right = Right, Rotation = Rotation, Up = Up }; sceneNode.SetParent(Parent); return sceneNode; }
public SceneNode CreateSceneNode() { var sceneNode = new SceneNode(); _allNodes.Add(sceneNode); return sceneNode; }