/// <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); }
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; }
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]); } }
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); } }
int NodeCountRecursive(DGuiSceneNode node, int count) { count += node.Children.Count; foreach (DGuiSceneNode childNode in node.Children) { count = NodeCountRecursive(childNode, count); } return count; }
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]); } } }
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]); } }
public void RemoveNode(DGuiSceneNode node) { RemoveNodeRecursive(rootNode, node); }
public void InsertNode(DGuiSceneNode node, DGuiSceneNode parentNode) { if (parentNode != null) { parentNode.Children.Add(node); } else { rootNode.Children.Add(node); } }