Esempio n. 1
0
 public static void Draw(SceneGraphNode node)
 {
     if (DoInstantDraw)
         InstantDraw(node);
     else
         DeferedDraw(node);
 }
Esempio n. 2
0
        public void AddChild(SceneGraphNode child)
        {
            if (child.Parent != null)
                child.Parent.RemoveChildFromSceneGraph(child);

            Childs.Add(child);
            child.Parent = this;
        }
Esempio n. 3
0
        public void AddChild(Entity child)
        {
            if (child.Node == null)
            {
                SceneGraphNode node = new SceneGraphNode(child);
            }

            AddChild(child.Node);
        }
Esempio n. 4
0
        public void RemoveChild(SceneGraphNode child, bool destroy = false)
        {
            child.Parent = null;
            Childs.Remove(child);

            if (destroy)
            {
                RecursiveDestruction();
            }
            else
            {
                SceneGraphManager.Root.AddChild(child);
            }
        }
Esempio n. 5
0
        public static void InstantDraw(SceneGraphNode node)
        {
            MeshRenderer renderer = node.Entity.MeshRenderer;
            Camera activeCamera = CameraManager.ActiveCamera;

            if (renderer != null)
            {
                Light dir = (Light)EntityManager.GetComponentManager<Light>()[0];
                Light point = (Light)EntityManager.GetComponentManager<Light>()[1];
                renderer.Material.SetLights(dir, point, null);
                renderer.Material.Apply(activeCamera.Owner.Transform.Position, renderer.Mesh, 
                    node.ToWorld, activeCamera.ViewMatrix, activeCamera.ProjectionMatrix);

            }
        }
Esempio n. 6
0
        static void DepthFirstWalk(SceneGraphNode node, bool draw)
        {
            matrixStack.PushMatrix(node.Transform.Transformation);

            node.ToWorld = matrixStack.Result;

            if(draw)
                Renderer.Draw(node);

            foreach (SceneGraphNode child in node.Childs)
            {
                DepthFirstWalk(child, draw);
            }

            matrixStack.PopMatrix();
        }
Esempio n. 7
0
 public static void Init()
 {
     Entity rootEntity = EntityManager.CreateEntity("root");
     Root = new SceneGraphNode(rootEntity);
 }
Esempio n. 8
0
        public static void DeferedDraw(SceneGraphNode node)
        {

        }
Esempio n. 9
0
 public void RemoveChildFromSceneGraph(SceneGraphNode child)
 {
     child.Parent = null;
     Childs.Remove(child);
 }
Esempio n. 10
0
 public void MoveChild(SceneGraphNode child, SceneGraphNode newParent)
 {
     Childs.Remove(child);
     newParent.AddChild(child);
 }