public TerrainViewController(SceneNode sceneNode, double d0) { this.node = sceneNode; fov = 80.0; x0 = 0f; y0 = 0f; theta = 0.0; phi = 0.0; d = d0; zoom = 1.0; groundHeight = 0f; }
public void DFTraversal(SceneNode root, Action<SceneNode> visit) { Stack<SceneNode> dfs = new Stack<SceneNode>(); dfs.Push(root); while (dfs.Count > 0) { var obj = dfs.Pop(); visit(obj); foreach (var child in obj.Children) dfs.Push(child); } }
public void BFTraversal(SceneNode root, Action<SceneNode> visit) { Queue<SceneNode> bfs = new Queue<SceneNode>(); bfs.Enqueue(root); while (bfs.Count > 0) { var obj = bfs.Dequeue(); visit(obj); foreach (var child in obj.Children) bfs.Enqueue(child); } }
/// <summary> /// 'node' becomes a child of 'insertLocation' or the Root of the /// SceneGraph if 'insertLocation' is null /// </summary> /// <param name="node"></param> /// <param name="insertLocation"></param> public void Insert(SceneNode node, SceneNode insertLocation) { if (insertLocation == null) { Root = node; } else { insertLocation.AddChild(node); } }
/// <summary> /// Moves the subtree rooted at 'node' such that 'node' is a child of 'newParent' /// </summary> /// <param name="node"></param> /// <param name="newParent"></param> public void ChangeParent(SceneNode node, SceneNode newParent) { node.ChangeParent(newParent); }
internal GameObject(SceneNode parent) : base(parent) { components = new List<Component>(); }
public NodeVisitor(SceneNode node) { Node = node; Visited = false; }
internal SceneNode(SceneNode parent) : base() { this.parent = parent; children = new List <SceneNode>(1); }
public PlanetViewController(SceneNode node, double R) : base(node, R * 6.0) { this.R = R; }
internal SceneNode(SceneNode parent) : base() { this.parent = parent; children = new List<SceneNode>(1); }
internal void RemoveChild(SceneNode childToRemove) { if (!children.Remove(childToRemove)) throw new InvalidOperationException("Node you are trying to remove is not a child of this node"); }
/// <summary> /// Explicitly change this SceneNodes parent... this is broken /// out into a seperate method rather than allowing direct setting /// of the Parent property because changes of Parent should be /// exceptional and have, at the very least, spatial consequences for /// the entire subtree rooted at this SceneNode /// </summary> /// <param name="newParent"></param> internal virtual void ChangeParent(SceneNode newParent) { if (newParent == null) throw new ArgumentNullException(); if (parent != null) parent.RemoveChild(this); newParent.AddChild(this); parent = newParent; }
internal void AddChild(SceneNode newChild) { // O(N) // validate that we aren't adding a duplicate node if (children.Contains(newChild)) throw new InvalidOperationException("Node is already a child of this node"); children.Add(newChild); }
internal GameObject(SceneNode parent) : base(parent) { components = new List <Component>(); }