Esempio n. 1
0
        public DetailVeg(int blockSize, SceneNode parent)
        {
            rand           = new Random(0);
            this.blockSize = blockSize;

            parentSceneNode = parent;

            vegetationBoundaries = new List <VegetationSemantic>();

            detailVegImageSet = MVImageSet.FindMVImageSet("DetailVeg.imageset");
        }
Esempio n. 2
0
 public void MaybeUseImageSet(MVImageSet imageSet)
 {
     if (imageSet != null && imageName != "")
     {
         Vector2 start, size;
         if (imageSet.FindImageStartAndSize(imageName, out start, out size))
         {
             atlasStartX = start.x;
             atlasStartY = start.y;
             atlasEndX   = start.x + size.x;
             atlasEndY   = start.y + size.y;
         }
     }
 }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        public static MVImageSet FindMVImageSet(string fileName)
        {
            Stream stream = null;

            try {
                stream = ResourceManager.FindCommonResourceData(fileName);
            } catch (AxiomException) {
                return(null);
            }
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;
            XmlReader r = XmlReader.Create(stream, settings);

            r.Read();
            if (r.Name == "MVImageSet")
            {
                MVImageSet imageSet = new MVImageSet();
                imageSet.FromXML(r);
                return(imageSet);
            }
            return(null);
        }
 public static MVImageSet FindMVImageSet(string fileName)
 {
     Stream stream  = null;
     try {
         stream = ResourceManager.FindCommonResourceData(fileName);
     } catch (AxiomException) {
         return null;
     }
     XmlReaderSettings settings = new XmlReaderSettings();
     settings.IgnoreWhitespace = true;
     XmlReader r = XmlReader.Create(stream, settings);
     r.Read();
     if (r.Name == "MVImageSet")
     {
         MVImageSet imageSet = new MVImageSet();
         imageSet.FromXML(r);
         return imageSet;
     }
     return null;
 }