public override void Update()
        {
            NormalPointLightMaterial material = ((NormalPointLightMaterial)Material);

            float _radius = material.Attenuation;
            Color _color  = material.LightColor;
            float _speed  = 1f;

            DebugEngine.AddBoundingSphere(new BoundingSphere(material.Position, _radius), _color);

            if (InputEngine.IsKeyHeld(Keys.Up))
            {
                material.Position += new Vector3(0, 0, -_speed);
            }

            if (InputEngine.IsKeyHeld(Keys.Down))
            {
                material.Position += new Vector3(0, 0, _speed);
            }

            if (InputEngine.IsKeyHeld(Keys.Left))
            {
                material.Position += new Vector3(-_speed, 0, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.Right))
            {
                material.Position += new Vector3(_speed, 0, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.PageUp))
            {
                material.Position += new Vector3(0, _speed, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.PageDown))
            {
                material.Position += new Vector3(0, -_speed, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.Add))
            {
                material.Attenuation += _speed * 2;
            }

            if (InputEngine.IsKeyHeld(Keys.Subtract))
            {
                material.Attenuation -= _speed * 2;
            }

            base.Update();
        }
Пример #2
0
        public OcTree(Vector3 position, float size)
        {
            Center = position;
            Size   = size;

            Objects = new List <GameObject3D>();
            Nodes   = new List <OcTree>();

            var minV2 = Vector3.Subtract(Center, new Vector3(size / 2, size / 2, size / 2));
            var maxV2 = Vector3.Add(Center, new Vector3(size / 2, size / 2, size / 2));

            Bounds = new BoundingBox(
                new Vector3(minV2.X, minV2.Y, minV2.Z),
                new Vector3(maxV2.X, maxV2.Y, maxV2.Z));

            DebugEngine.AddBoundingSphere(new BoundingSphere(Center, 0.5f), Color.Black, 1000);
        }
Пример #3
0
        public QuadTree(float size, Vector2 position, int maxObjects)
        {
            Size       = size;
            Position   = position;
            MaxObjects = maxObjects;

            Objects = new List <GameObject3D>();
            Nodes   = new List <QuadTree>();

            float   halfSize = size / 2;
            Vector3 min      = new Vector3(position.X - halfSize, position.Y - halfSize, 0);
            Vector3 max      = new Vector3(position.X + halfSize, position.Y + halfSize, 0);

            Bounds = new BoundingBox(min, max);

            DebugEngine.AddBoundingBox(Bounds, Color.Red, 1000);
            DebugEngine.AddBoundingSphere(new BoundingSphere(new Vector3(position, 0), 1), Color.Black, 1000);
        }
Пример #4
0
        public Octree(float size, Vector3 position, int maxObjects)
        {
            Size       = size;
            Position   = position;
            MaxObjects = maxObjects;

            Objects = new List <GameObject3D>();
            Nodes   = new List <Octree>();

            //TODO: create bounds of given size at given position
            float   halfSize = size / 2;
            Vector3 min      = new Vector3(position.X - halfSize, position.Y - halfSize, position.Z - halfSize);
            Vector3 max      = new Vector3(position.X + halfSize, position.Y + halfSize, position.Z + halfSize);

            Bounds = new BoundingBox(min, max);

            DebugEngine.AddBoundingBox(Bounds, Color.LimeGreen, 1000);
            DebugEngine.AddBoundingSphere(new BoundingSphere(new Vector3(position.X, position.Y, position.Z), 1), Color.Black, 1000);
        }
        public override void Update()
        {
            if (DoMove)
            {
                if (!HasReachedDestination())
                {
                    MoveTowardsDestination((float)GameUtilities.Time.ElapsedGameTime.TotalSeconds);
                }
                else
                {
                    if (Looping)
                    {
                        AddWaypoint(Destination);
                    }

                    if (Waypoints.Count > 0)
                    {
                        NextWaypoint();
                    }
                    else
                    if (Complete != null)
                    {
                        Complete(ID);
                    }
                }
            }

            if (System.Diagnostics.Debugger.IsAttached)
            {
                DebugEngine.AddBoundingSphere(new BoundingSphere(Destination, 1.0f), Color.Black);

                foreach (var p in Waypoints)
                {
                    DebugEngine.AddBoundingSphere(new BoundingSphere(p, 1.0f), Color.LawnGreen);
                }
            }

            base.Update();
        }
Пример #6
0
        public override void Update()
        {
            //Attenuation Range and Light Position Debug Spheres
            for (int i = 0; i < PointLightPositions.Length; i++)
            {
                DebugEngine.AddBoundingSphere(new BoundingSphere(PointLightPositions[i], PointLightAttenuations[i]), PointLightColors[i]);
                DebugEngine.AddBoundingSphere(new BoundingSphere(PointLightPositions[i], 1f), Color.DarkMagenta);
            }

            //Move Light 1
            if (InputEngine.IsKeyHeld(Keys.Right))
            {
                PointLightPositions[0] += new Vector3(1, 0, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.Down))
            {
                PointLightPositions[0] += new Vector3(0, 0, 1);
            }
            if (InputEngine.IsKeyHeld(Keys.Up))
            {
                PointLightPositions[0] += new Vector3(0, 0, -1);
            }
            if (InputEngine.IsKeyHeld(Keys.Left))
            {
                PointLightPositions[0] += new Vector3(-1, 0, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.PageUp))
            {
                PointLightPositions[0] += new Vector3(0, 1, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.PageDown))
            {
                PointLightPositions[0] += new Vector3(0, -1, 0);
            }

            //Move Light 2
            if (InputEngine.IsKeyHeld(Keys.L))
            {
                PointLightPositions[1] += new Vector3(1, 0, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.K))
            {
                PointLightPositions[1] += new Vector3(0, 0, 1);
            }
            if (InputEngine.IsKeyHeld(Keys.I))
            {
                PointLightPositions[1] += new Vector3(0, 0, -1);
            }
            if (InputEngine.IsKeyHeld(Keys.J))
            {
                PointLightPositions[1] += new Vector3(-1, 0, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.U))
            {
                PointLightPositions[1] += new Vector3(0, 1, 0);
            }
            if (InputEngine.IsKeyHeld(Keys.O))
            {
                PointLightPositions[1] += new Vector3(0, -1, 0);
            }

            base.Update();
        }
Пример #7
0
        public override void Update()
        {
            var dt = (float)GameUtilities.Time.ElapsedGameTime.TotalSeconds;

            MultiplePointLightMaterial material = ((MultiplePointLightMaterial)Material);

            for (int i = 0; i < material.Position.Length; i++)
            {
                float[] radius = material.Attenuation;
                Color[] color  = material.LightColor;
                float[] speed  = { 100f, 100f, 100f };

                DebugEngine.AddBoundingSphere(new BoundingSphere(material.Position[i], radius[i]), color[i]);

                if (InputEngine.IsKeyHeld(Keys.Up))
                {
                    material.Position[i] += new Vector3(0, 0, -speed[i] * dt);
                }

                if (InputEngine.IsKeyHeld(Keys.Down))
                {
                    material.Position[i] += new Vector3(0, 0, speed[i] * dt);
                }

                if (InputEngine.IsKeyHeld(Keys.Left))
                {
                    material.Position[i] += new Vector3(-speed[i] * dt, 0, 0);
                }

                if (InputEngine.IsKeyHeld(Keys.Right))
                {
                    material.Position[i] += new Vector3(speed[i] * dt, 0, 0);
                }

                if (InputEngine.IsKeyHeld(Keys.PageUp))
                {
                    material.Position[i] += new Vector3(0, speed[i] * dt, 0);
                }

                if (InputEngine.IsKeyHeld(Keys.PageDown))
                {
                    material.Position[i] += new Vector3(0, -speed[i] * dt, 0);
                }

                if (material.IsAlternateTexture)
                {
                    if (InputEngine.IsKeyHeld(Keys.L))
                    {
                        material.Rotation += 0.1f * dt;
                    }

                    if (InputEngine.IsKeyHeld(Keys.J))
                    {
                        material.Rotation -= 0.1f * dt;
                    }
                }

                if (InputEngine.IsKeyHeld(Keys.Add))
                {
                    material.Attenuation[i] += (speed[i] * 2) * dt;
                }

                if (InputEngine.IsKeyHeld(Keys.Subtract))
                {
                    material.Attenuation[i] -= (speed[i] * 2) * dt;
                }

                if (InputEngine.IsKeyPressed(Keys.Space))
                {
                    material.IsAlternateTexture =
                        !material.IsAlternateTexture;
                }

                if (InputEngine.IsKeyPressed(Keys.C))
                {
                    material.LightColor = new[] { Color.White, Color.White, Color.White }
                }
                ;
            }

            base.Update();
        }
    }