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

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

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

            if (destroy)
            {
                RecursiveDestruction();
            }
            else
            {
                SceneGraphManager.Root.AddChild(child);
            }
        }
Exemple #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);

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

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