コード例 #1
0
        private GrassEntity GenerateOnePlantSegment(float yEulerAngle, float xScale, float xPos,
                                                    float zPos, float minUv, float maxUv, float randSeed)
        {
            var obj = new GrassEntity
            {
                Rotation = MyMathUtils.DegToRad(new Vector3(0, yEulerAngle, 0)),
                Scale    = new Vector3(xScale, 1, 1),
                Position = new Vector3(xPos, 0, zPos)
            };

            obj.AddUniform(GrassShaderUniformName._MinUv, minUv);
            obj.AddUniform(GrassShaderUniformName._MaxUv, maxUv);
            obj.AddUniform(GrassShaderUniformName._RandSeed, randSeed);
            return(obj);
        }
コード例 #2
0
        public GrassEntitiesSet GenerateStarTuft(int elementsInTuftCount = 3)
        {
            var entities = new List <GrassEntity>();

            for (int i = 0; i < elementsInTuftCount; i++)
            {
                var obj = new GrassEntity {
                    Rotation = MyMathUtils.DegToRad(new Vector3(0, 0, ((float)i) / elementsInTuftCount * 180))
                };
                obj.AddUniform(GrassShaderUniformName._MinUv, 0);
                obj.AddUniform(GrassShaderUniformName._MaxUv, 1);
                obj.AddUniform(GrassShaderUniformName._RandSeed, UnityEngine.Random.value);
                entities.Add(obj);
            }
            return(new GrassEntitiesSet(entities));
        }
コード例 #3
0
        public GrassEntitiesWithMaterials GenerateUniformRectangeBillboardGrass(Material material, IGrassPlacer placer, int lodLevel)
        {
            List <GrassEntity> createdEntities = new List <GrassEntity>();
            var billboardGenerator             = new GrassBillboardGenerator();

            var meshGenerator = new GrassMeshGenerator();
            var mesh          = meshGenerator.GetGrassBillboardMesh(0, 1);

            for (int i = 0; i < 75; i++)
            {
                var triangleTurf = billboardGenerator.GenerateTriangleTurf(); //todo : use grass entities set and rotate
                triangleTurf.Rotation = (MyMathUtils.DegToRad(new Vector3(0, UnityEngine.Random.Range(0, 360), 0)));
                placer.Set(triangleTurf);
                createdEntities.AddRange(triangleTurf.EntitiesAfterTransform);
            }

            return(null); // new GrassEntitiesWithMaterials(createdEntities, material, mesh);
        }