Exemplo n.º 1
0
 /// <summary>
 /// Allows the game component to perform any initialization it needs to before starting
 /// to run.  This is where it can query for any required services and load content.
 /// </summary>
 public override void Initialize()
 {
     // TODO: Add your initialization code here
     previousMouseState    = Mouse.GetState();
     previousKeyboardState = Keyboard.GetState();
     hpt.Start();
     base.Initialize();
 }
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
            hpt.Start();
            hpt.Stop();
            camera                = new Camera(Game);
            camera.CameraArc      = -30;
            camera.CameraDistance = 50;
            quadRenderer          = new QuadRenderComponent(Game);
            Game.Components.Add(camera);
            Game.Components.Add(quadRenderer);
            previousState = Keyboard.GetState();

            spotLights = new List <SpotLight>();

            { // graph code
                int n = 300;
                //GeneratePoints generates a random graph, implementation irrelevant
                pointList = new VertexPositionColor[n];
                int height = 300;
                int minY   = 0;
                for (int i = 0; i < n; i++)
                {
                    pointList[i] = new VertexPositionColor()
                    {
                        Position = new Vector3(i * 10, 0, 0), Color = Color.Red
                    }
                }
                ;

                //links the points into a list
                lineListIndices = new short[(n * 2) - 2];
                for (int i = 0; i < n - 1; i++)
                {
                    lineListIndices[i * 2]       = (short)(i);
                    lineListIndices[(i * 2) + 1] = (short)(i + 1);
                }

                worldMatrix      = Matrix.Identity;
                viewMatrix       = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up);
                projectionMatrix = Matrix.CreateOrthographicOffCenter(0, (float)GraphicsDevice.Viewport.Width, 0, (float)GraphicsDevice.Viewport.Height, 1.0f, 1000.0f);

                basicEffect            = new BasicEffect(GraphicsDevice);
                basicEffect.World      = worldMatrix;
                basicEffect.View       = viewMatrix;
                basicEffect.Projection = projectionMatrix;

                basicEffect.VertexColorEnabled = true; //important for color
            }

            SpotLight spot = new SpotLight()
            {
                lightPosition  = new Vector3(371, 290, -120),
                lightColor     = Color.White,
                lightRadius    = 500,
                lightIntensity = 2,
                lightDirection = new Vector3(-371, -290, 120),
                spotAngle      = 15,
                decay          = 1
            };

            spotLights.Add(spot);
            spot = new SpotLight()
            {
                lightPosition  = new Vector3(-120, 290, 371),
                lightColor     = Color.White,
                lightRadius    = 500,
                lightIntensity = 2,
                lightDirection = new Vector3(120, -260, -371),
                spotAngle      = 15,
                decay          = 10
            };
            spotLights.Add(spot);
        }