예제 #1
0
파일: Scene.cs 프로젝트: Aragas/Pokemon3D-1
 /// <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;
 }
예제 #2
0
파일: Scene.cs 프로젝트: Aragas/Pokemon3D-1
        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);
            }
        }
예제 #3
0
 public void RemoveChild(SceneNode childElement)
 {
     if (_childNodes.Remove(childElement))
     {
         childElement.Parent = null;
     }
 }
예제 #4
0
 public void AddChild(SceneNode childElement)
 {
     childElement.Parent?.RemoveChild(childElement);
     _childNodes.Add(childElement);
     childElement.Parent = this;
 }
예제 #5
0
 public void SetParent(SceneNode parent)
 {
     Parent?.RemoveChild(this);
     parent?.AddChild(this);
 }
예제 #6
0
 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;
 }
예제 #7
0
파일: Scene.cs 프로젝트: Aragas/Pokemon3D-1
 public SceneNode CreateSceneNode()
 {
     var sceneNode = new SceneNode();
     _allNodes.Add(sceneNode);
     return sceneNode;
 }