Exemplo n.º 1
0
        /// <summary>
        /// Intializes an instance of the <see cref="SceneGraph"/> class.
        /// </summary>
        /// <param name="device">The <see cref="GraphicsDevice"/> that will be used for rendering.</param>
        public DGuiSceneGraph(Game game)
            : base(game)
        {
            rootNode = new DGuiSceneNode(game);

            //camera = new Camera();
            //camera.Position = new Vector3(0, 0, 400);
        }
Exemplo n.º 2
0
 public DGuiManager(Game game, SpriteBatch spriteBatch)
     : base(game)
 {
     _game = game;
     _sceneGraph = new DGuiSceneGraph(game);
     _controlsSceneNode = new DGuiSceneNode(game);
     _foregroundSceneNode = new DGuiSceneNode(game);
     _controlTextSceneNode = new DGuiSceneNode(game);
     _foregroundTextSceneNode = new DGuiSceneNode(game);
     _sceneGraph.RootNode.Children.Add(_controlsSceneNode);
     _sceneGraph.RootNode.Children.Add(_controlTextSceneNode);
     _sceneGraph.RootNode.Children.Add(_foregroundSceneNode);
     _sceneGraph.RootNode.Children.Add(_foregroundTextSceneNode);
     _spriteBatch = spriteBatch;
 }
Exemplo n.º 3
0
        void UpdateRecursive(GameTime time, DGuiSceneNode node)
        {
            //Update node
            node.Update(time);

            // Set update index, for height calculations
            _updateIndex++;
            node.UpdateIndex = _updateIndex;

            //Update children recursively
            for (int i = 0; i < node.Children.Count; i++) // (SceneNode childNode in node.Children)
            {
                UpdateRecursive(time,node.Children[i]);
            }
        }
Exemplo n.º 4
0
 void RemoveNodeRecursive(DGuiSceneNode node, DGuiSceneNode removeNode)
 {
     // Depth-first remove
     for (int i = 0; i < node.Children.Count; i++)
     {
         DGuiSceneNode childNode = node.Children[i];
         if (childNode == removeNode)
         {
             node.Children.Remove(childNode);
             break;
         }
         else
             RemoveNodeRecursive(childNode, removeNode);
     }
 }
Exemplo n.º 5
0
 int NodeCountRecursive(DGuiSceneNode node, int count)
 {
     count += node.Children.Count;
     foreach (DGuiSceneNode childNode in node.Children)
     {
         count = NodeCountRecursive(childNode, count);
     }
     return count;
 }
Exemplo n.º 6
0
        void DrawRecursive(GameTime gameTime, DGuiSceneNode node)
        {
            //Draw
            if (node.Visible || node.AlwaysVisible)
            {
                node.Draw(gameTime);

                for (int i = 0; i < node.Children.Count; i++)
                {
                    DrawRecursive(gameTime, node.Children[i]);
                }
            }
        }
Exemplo n.º 7
0
        void CalculateTransformsRecursive(GameTime time, DGuiSceneNode node)
        {
            node.AbsoluteTransform += new Vector3(node.Position.X, node.Position.Y, node.Rotation);

            for (int i = 0; i < node.Children.Count; i++) // (SceneNode childNode in node.Children)
            {
                node.Children[i].AbsoluteTransform = node.AbsoluteTransform;
                CalculateTransformsRecursive(time, node.Children[i]);
            }
        }
Exemplo n.º 8
0
 public void RemoveNode(DGuiSceneNode node)
 {
     RemoveNodeRecursive(rootNode, node);
 }
Exemplo n.º 9
0
 public void InsertNode(DGuiSceneNode node, DGuiSceneNode parentNode)
 {
     if (parentNode != null)
     {
         parentNode.Children.Add(node);
     }
     else
     {
         rootNode.Children.Add(node);
     }
 }