Пример #1
0
        // Constructor
        public SceneGraphManager()
        {
            rootNode = new Actor("rootNode", null);
            CullingActive = true;
            LightingActive = true;

            Lighting = new PrelightingRenderer(GameApplication.Instance.GetGraphics(), this);

               /* Lighting.Lights = new List<PointLight>()
            {
                new PointLight("pointLight01",null,new Vector3(-1000, 1000, 0), Color.Red * .85f, 2000),
                new PointLight("pointLight09",null,new Vector3(0, 0, 0), Color.Red * .85f, 2000),
                new PointLight("pointLight02",null,new Vector3(1000, 1000, 0), Color.Orange * .85f, 2000),
                new PointLight("pointLight03",null,new Vector3(0, 1000, 1000), Color.Yellow * .85f, 2000),
                new PointLight("pointLight04",null,new Vector3(0, 1000, -1000), Color.Green * .85f, 2000),
                new PointLight("pointLight05",null,new Vector3(1000, 1000, 1000), Color.Blue * .85f, 2000),
                new PointLight("pointLight06",null,new Vector3(-1000, 1000, 1000), Color.Indigo * .85f, 2000),
                new PointLight("pointLight07",null,new Vector3(1000, 1000, -1000), Color.Violet * .85f, 2000),
                new PointLight("pointLight08",null,new Vector3(-1000, 1000, -1000), Color.White * .85f, 2000)
            };*/
        }
Пример #2
0
        void UpdateRecursive(Actor node)
        {
            if (node.Updateable)
            {   //Update node
                node.Update(this);
            }

            //Update children recursively
            foreach (Actor childNode in node.Children)
            {
                UpdateRecursive(childNode);
            }
        }
Пример #3
0
        void DrawRecursive(Actor node)
        {
            //Draw
            if (node.Visible)
            {
                if (CameraManager.Instance.CurrentCamera != null)
                {
                    BoundingSphere transformedSphere = new BoundingSphere();

                    transformedSphere.Center = Vector3.Transform(node.BoundingSphere.Center,
                                                                 node.AbsoluteTransform);
                    transformedSphere.Radius = node.BoundingSphere.Radius;

                    if (CullingActive)
                    {
                        if (CameraManager.Instance.GetCurrentCamera().Frustum.Intersects(transformedSphere))
                        {
                            node.PreRender();
                            node.Render(this);
                            node.PostRender();
                        }
                        else
                        {
                            nodesCulled++;
                        }
                    }
                    else
                    {
                        node.PreRender();
                        node.Render(this);
                        node.PostRender();
                    }
                }
            }

            foreach (Actor childNode in node.Children)
            {
                DrawRecursive(childNode);
            }
        }
Пример #4
0
        // Methods
        void CalculateTransformsRecursive(Actor node)
        {
            node.AbsoluteTransform = Matrix.CreateScale(node.Scale) * Matrix.CreateWorld(node.Offset, node.Forward, node.Up) *
                Matrix.CreateFromQuaternion(node.Rotation) *
                node.AbsoluteTransform *
                Matrix.CreateWorld(node.Position, node.Forward, node.Up);

            //Update children recursively
            foreach (Actor childNode in node.Children)
            {
                childNode.AbsoluteTransform = node.AbsoluteTransform;
                CalculateTransformsRecursive(childNode);
            }
        }
Пример #5
0
 public Move (Direction dir, Actor actor)
 {
     this.dir = dir;
     this.actor = actor;
 }
Пример #6
0
 public void MoveActor (Actor actor)
 {
     ActorMovedArgs a = new ActorMovedArgs();
     a.actor = actor;
     OnActorMoved(a);
 }