Пример #1
0
 public static void Draw(SceneGraphNode node)
 {
     if (DoInstantDraw)
         InstantDraw(node);
     else
         DeferedDraw(node);
 }
Пример #2
0
        public void AddChild(SceneGraphNode child)
        {
            if (child.Parent != null)
                child.Parent.RemoveChildFromSceneGraph(child);

            Childs.Add(child);
            child.Parent = this;
        }
Пример #3
0
        public void AddChild(Entity child)
        {
            if (child.Node == null)
            {
                SceneGraphNode node = new SceneGraphNode(child);
            }

            AddChild(child.Node);
        }
Пример #4
0
        public void RemoveChild(SceneGraphNode child, bool destroy = false)
        {
            child.Parent = null;
            Childs.Remove(child);

            if (destroy)
            {
                RecursiveDestruction();
            }
            else
            {
                SceneGraphManager.Root.AddChild(child);
            }
        }
Пример #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);

            }
        }
Пример #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();
        }
Пример #7
0
 public static void Init()
 {
     Entity rootEntity = EntityManager.CreateEntity("root");
     Root = new SceneGraphNode(rootEntity);
 }
Пример #8
0
        public static void DeferedDraw(SceneGraphNode node)
        {

        }
Пример #9
0
 public void RemoveChildFromSceneGraph(SceneGraphNode child)
 {
     child.Parent = null;
     Childs.Remove(child);
 }
Пример #10
0
 public void MoveChild(SceneGraphNode child, SceneGraphNode newParent)
 {
     Childs.Remove(child);
     newParent.AddChild(child);
 }