File Scene.cs

File List > Render > src > Scene.cs

Go to the documentation of this file.

using System;
using System.Collections;
using System.Collections.Generic;
using Qkmaxware.Geometry;

namespace Qkmaxware.Rendering {

public class Scene : IEnumerable<SceneNode> {
    private List<SceneNode> children = new List<SceneNode>();

    public void Add(SceneNode node) {
        this.children.Add(node);
        node.root_scene = this;
    }

    public void Remove(SceneNode node) {
        if(this.children.Remove(node)) {
            node.root_scene = null;
        }
    }

    public IEnumerator<SceneNode> GetEnumerator() {
        foreach (var child in children) {
            yield return child;
            foreach (var subchild in child) {
                yield return subchild;
            }
        }
    }

    IEnumerator IEnumerable.GetEnumerator() {
        return GetEnumerator();
    }
}

}