Exemplo n.º 1
0
 public GroundPlane(Vector3 position, Vector2 size, Shader shader)
 {
     _meshes.Add(new Mesh(
                     PrimitiveUtils.CreateTopVertices(position, size, 0),
                     Enumerable.Empty <Vector2>(), // untextured flat colored plane
                     shader));
 }
Exemplo n.º 2
0
        public IEnumerable <IRenderable> CreateStreetLights(IEnumerable <GroundNode> sites)
        {
            var lightColor = _lightColors[_random.Next(_lightColors.Count)];

            _lightShader.SetUniformValue("u_color", new Vector3Uniform
            {
                Value = lightColor
            });
            _logger.Information($"Set streetlight color to: {lightColor}");

            var areaBorder = new Vector2(_config.AreaBorderSize - 4);
            var lightSize  = new Vector2(2, 2);

            foreach (var site in sites)
            {
                var position = new Vector3(site.StartPosition.X + areaBorder.X, 0, site.StartPosition.Y + areaBorder.Y);
                var area     = site.EndPosition - site.StartPosition - (areaBorder * 2);

                for (int i = (int)position.X + 2 + 1; i <= position.X + area.X; i += 12)
                {
                    var northPosition = new Vector3(i, position.Y, position.Z);
                    var northVertices = PrimitiveUtils.CreateTopVertices(northPosition, lightSize, 0.2f);
                    var northUvs      = PrimitiveUtils.CreateTopUVs(1, 1);

                    yield return(new StreetLightStrip(northVertices, northUvs, _lightShader));

                    var southPosition = new Vector3(i, position.Y, position.Z + area.Y + 2);
                    var southVertices = PrimitiveUtils.CreateTopVertices(southPosition, lightSize, 0.2f);
                    var southUvs      = PrimitiveUtils.CreateTopUVs(1, 1);

                    yield return(new StreetLightStrip(southVertices, southUvs, _lightShader));
                }

                for (int i = (int)position.Z + 2 + 1; i <= position.Z + area.Y; i += 12)
                {
                    var westPosition = new Vector3(position.X, position.Y, i);
                    var westVertices = PrimitiveUtils.CreateTopVertices(westPosition, lightSize, 0.2f);
                    var westUvs      = PrimitiveUtils.CreateTopUVs(1, 1);

                    yield return(new StreetLightStrip(westVertices, westUvs, _lightShader));

                    var eastPosition = new Vector3(position.X + area.X + 2, position.Y, i);
                    var eastVertices = PrimitiveUtils.CreateTopVertices(eastPosition, lightSize, 0.2f);
                    var eastUvs      = PrimitiveUtils.CreateTopUVs(1, 1);

                    yield return(new StreetLightStrip(eastVertices, eastUvs, _lightShader));
                }
            }
        }