Exemple #1
0
        public void AddPlantType(uint numInstances, string imageName,
                                 float scaleWidthLow, float scaleWidthHi,
                                 float scaleHeightLow, float scaleHeightHi,
                                 ColorEx color, float colorMultLow, float colorMultHi,
                                 float windMagnitude)
        {
            PlantType plantType = new PlantType(numInstances, imageName,
                                                scaleWidthLow, scaleWidthHi, scaleHeightLow, scaleHeightHi,
                                                color, colorMultLow, colorMultHi, windMagnitude);

            AddPlantType(plantType);
        }
        internal VegetationTile(SceneNode parentSceneNode,
                                List <VegetationSemantic> vegetationBoundaries, int x, int z,
                                PageCoord newPage, int blockSize,
                                float roadClearRadius,
                                MVImageSet imageSet,
                                Random rand)
        {
            this.roadClearRadius = roadClearRadius;

            plantTypes = new List <PlantType>();

            PageCoord tmpPage = new PageCoord(x + newPage.X - 1, z + newPage.Z - 1);

            pc = tmpPage;

            Vector3 blockLoc = tmpPage.WorldLocation(blockSize);
            Vector2 blockMin = new Vector2(blockLoc.x, blockLoc.z);
            Vector2 blockMax = new Vector2(blockMin.x + blockSize * TerrainManager.oneMeter,
                                           blockMin.y + blockSize * TerrainManager.oneMeter);

            List <Vector2> roadSegments = TerrainManager.Instance.Roads.IntersectBlock(blockMin, blockMax);

            foreach (VegetationSemantic vegetationBoundary in vegetationBoundaries)
            {
                Boundary boundary = vegetationBoundary.BoundaryObject;
                if (boundary.IntersectSquare(new Vector3(blockMin.x, 0f, blockMin.y), blockSize))
                {
                    foreach (PlantType boundaryPlantType in vegetationBoundary.PlantTypes)
                    {
                        PlantType plantType = boundaryPlantType.Clone();
                        plantType.MaybeUseImageSet(imageSet);
                        plantTypes.Add(plantType);
                        totalInstances += plantType.AddPlantInstances(boundary, blockMin, blockSize, rand);
                    }
                }
            }
            if (totalInstances > 0)
            {
                BuildIndexBuffer();
                AxisAlignedBox bounds;
                VertexData     vertexData = BuildVertexData(blockLoc, blockSize, roadSegments, out bounds);
                plantRenderable = new PlantRenderable(indexData, vertexData, bounds, tmpPage, parentSceneNode, blockLoc);
            }
        }
Exemple #3
0
 public void RemovePlantType(PlantType plantType)
 {
     plantTypes.Remove(plantType);
     TerrainManager.Instance.RefreshVegetation();
 }
Exemple #4
0
 public void AddPlantType(PlantType plantType)
 {
     plantTypes.Add(plantType);
     TerrainManager.Instance.RefreshVegetation();
 }