Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 /// <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);
     }
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 internal GameObject(SceneNode parent)
     : base(parent)
 {
     components = new List<Component>();
 }
Ejemplo n.º 7
0
 public NodeVisitor(SceneNode node)
 {
     Node = node;
     Visited = false;
 }
Ejemplo n.º 8
0
 internal SceneNode(SceneNode parent)
     : base()
 {
     this.parent = parent;
     children    = new List <SceneNode>(1);
 }
Ejemplo n.º 9
0
 public PlanetViewController(SceneNode node, double R)
     : base(node, R * 6.0)
 {
     this.R = R;
 }
Ejemplo n.º 10
0
 internal SceneNode(SceneNode parent)
     : base()
 {
     this.parent = parent;
     children = new List<SceneNode>(1);
 }
Ejemplo n.º 11
0
 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");
 }
Ejemplo n.º 12
0
        /// <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;
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 internal GameObject(SceneNode parent)
     : base(parent)
 {
     components = new List <Component>();
 }