Ejemplo n.º 1
0
        private void PrepareEnvironment()
        {
            ground = new GameObject(Content.Load <Model>("ground"),
                                    new Vector3(0, -10f, 0), Vector3.Zero, Vector3.One, GraphicsDevice);

            //sky = new Sky(Content, GraphicsDevice, Content.Load<TextureCube>("clouds"));

            List <Vector3> treePositions = new List <Vector3>();
            Random         r             = new Random();

            for (int i = 0; i < 250; i++)
            {
                Vector3 pos = new Vector3((float)r.NextDouble() * 20000 - groundSize, 0, (float)r.NextDouble() * 20000 - groundSize);
                if (!track.IsOnTrackOrRoadside(pos))
                {
                    treePositions.Add(new Vector3(pos.X, 240, pos.Z));
                }
                else
                {
                    Console.WriteLine("is on track " + pos);
                }
            }

            trees1 = new BillboardCross(GraphicsDevice, Content,
                                        Content.Load <Texture2D>("tree_billboard"), new Vector2(500),
                                        treePositions.ToArray());
            trees1.EnsureOcclusion = true;
            treePositions.Clear();
            for (int i = 0; i < 250; i++)
            {
                Vector3 pos = new Vector3((float)r.NextDouble() * 20000 - groundSize, 0, (float)r.NextDouble() * 20000 - groundSize);
                if (!track.IsOnTrackOrRoadside(pos))
                {
                    treePositions.Add(new Vector3(pos.X, 240, pos.Z));
                }
                else
                {
                    Console.WriteLine("is on track " + pos);
                }
            }

            trees2 = new BillboardSystem(GraphicsDevice, Content, Content.Load <Texture2D>("tree"), new Vector2(500), treePositions.ToArray());
            trees2.EnsureOcclusion = true;

            Vector3 [] position = new Vector3[1];
            position[0] = new Vector3(startingPoint, 0);
            startSign   = new BillboardSystem(GraphicsDevice, Content, Content.Load <Texture2D>("checkerd"), new Vector2(800), position);

            Vector3[] cloudPositions = new Vector3[350];

            for (int i = 0; i < cloudPositions.Length; i++)
            {
                cloudPositions[i] = new Vector3(
                    r.Next(-6000, 6000),
                    r.Next(1000, 3000),
                    r.Next(-6000, 6000));
            }

            clouds = new BillboardSystem(GraphicsDevice, Content,
                                         Content.Load <Texture2D>("cloud2"), new Vector2(1000),
                                         cloudPositions);

            clouds.EnsureOcclusion = false;
        }
Ejemplo n.º 2
0
        private void PrepareEnvironment()
        {
            ground = new GameObject(Content.Load<Model>("ground"),
            new Vector3(0, -10f, 0), Vector3.Zero, Vector3.One, GraphicsDevice);

            //sky = new Sky(Content, GraphicsDevice, Content.Load<TextureCube>("clouds"));

            List<Vector3> treePositions = new List<Vector3>();
            Random r = new Random();

            for (int i = 0; i < 250; i++)
            {
                Vector3 pos=new Vector3((float)r.NextDouble() * 20000 - groundSize, 0, (float)r.NextDouble() * 20000 - groundSize);
                if (!track.IsOnTrackOrRoadside(pos))
                    treePositions.Add(new Vector3(pos.X, 240, pos.Z));
                else
                    Console.WriteLine("is on track " + pos);
            }

            trees1 = new BillboardCross(GraphicsDevice, Content,
                Content.Load<Texture2D>("tree_billboard"), new Vector2(500),
                treePositions.ToArray());
            trees1.EnsureOcclusion = true;
            treePositions.Clear();
            for (int i = 0; i < 250; i++)
            {
                Vector3 pos = new Vector3((float)r.NextDouble() * 20000 - groundSize, 0, (float)r.NextDouble() * 20000 - groundSize);
                if (!track.IsOnTrackOrRoadside(pos))
                    treePositions.Add(new Vector3(pos.X, 240, pos.Z));
                else
                    Console.WriteLine("is on track " + pos);
            }

            trees2 = new BillboardSystem(GraphicsDevice, Content, Content.Load<Texture2D>("tree"), new Vector2(500), treePositions.ToArray());
            trees2.EnsureOcclusion = true;

            Vector3 [] position=new Vector3[1];
            position[0]=new Vector3(startingPoint, 0);
            startSign = new BillboardSystem(GraphicsDevice, Content, Content.Load<Texture2D>("checkerd"), new Vector2(800), position);

            Vector3[] cloudPositions = new Vector3[350];

            for (int i = 0; i < cloudPositions.Length; i++)
            {
                cloudPositions[i] = new Vector3(
                    r.Next(-6000, 6000),
                    r.Next(1000, 3000),
                    r.Next(-6000, 6000));
            }

            clouds = new BillboardSystem(GraphicsDevice, Content,
                Content.Load<Texture2D>("cloud2"), new Vector2(1000),
                cloudPositions);

            clouds.EnsureOcclusion = false;
        }