Ejemplo n.º 1
0
        public static GOMesh PreloadPolygon(GOFeature feature)
        {
            if (feature.convertedGeometry == null)
            {
                return(null);
            }

            if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1]))
            {
                return(null);
            }

            List <Vector3> clean = feature.convertedGeometry.Distinct().ToList();

            if (clean == null || clean.Count <= 2)
            {
                return(null);
            }


            Poly2Mesh.Polygon poly = new Poly2Mesh.Polygon();
            poly.outside = feature.convertedGeometry;
            if (feature.clips != null)
            {
                foreach (List <Vector3> clipVerts in feature.clips)
                {
                    poly.holes.Add(clipVerts);
                }
            }

            GOMesh preMesh = null;

            preMesh = Poly2Mesh.CreateMeshInBackground(poly);

            if (preMesh != null)
            {
//				if (feature.layer.layerType != GOLayer.GOLayerType.Buildings) {
                Vector2[] uvs      = new Vector2[preMesh.vertices.Length];
                Vector3[] vertices = preMesh.vertices;
                for (int i = 0; i < uvs.Length; i++)
                {
                    uvs [i] = new Vector2(vertices [i].x, vertices [i].z) * 0.01f;
                }
                preMesh.uv = uvs;
//				}

                if (feature.goTile.useElevation)
                {
                    feature.ComputeHighestAltitude();
                }
//					feature.height += GOFeature.BuildingElevationOffset;


                if (feature.height > 0)
                {
                    feature.height *= feature.goTile.worldScale;

                    preMesh.secondaryMesh = new GOMesh(preMesh);

                    float h = feature.height;

                    if (feature.goTile.useElevation)
                    {
                        h += GOFeature.BuildingElevationOffset;
                    }

                    h += Noise();
                    preMesh.separateTop = feature.renderingOptions.hasRoof;
                    preMesh             = SimpleExtruder.SliceExtrudePremesh(preMesh, h, 4f, 4f, 10f * feature.goTile.worldScale);
                }
            }


            return(preMesh);
        }
Ejemplo n.º 2
0
        public static GOMesh PreloadPolygon(GOFeature feature)
        {
            if (feature.convertedGeometry == null)
            {
                return(null);
            }

            if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1]))
            {
                return(null);
            }

            List <Vector3> clean = feature.convertedGeometry.Distinct().ToList();

            if (clean == null || clean.Count <= 2)
            {
                return(null);
            }


            Poly2Mesh.Polygon poly = new Poly2Mesh.Polygon();
            poly.outside = feature.convertedGeometry;
            if (feature.clips != null)
            {
                foreach (List <Vector3> clipVerts in feature.clips)
                {
                    poly.holes.Add(clipVerts);
                }
            }

            GOMesh goMesh = null;

            goMesh = Poly2Mesh.CreateMeshInBackground(poly);

            if (goMesh != null)
            {
                goMesh.uvMappingStyle = feature.layer.uvMappingStyle;
                goMesh.ApplyUV(feature.convertedGeometry);
                goMesh.Y = feature.y;

                if (feature.goTile.useElevation)
                {
                    feature.ComputeHighestAltitude();
                }

                if (feature.height > 0)
                {
                    feature.height      *= feature.goTile.worldScale;
                    goMesh.secondaryMesh = new GOMesh(goMesh);

                    float h = feature.height;

                    if (feature.goTile.useElevation)
                    {
                        h += GOFeature.BuildingElevationOffset;
                    }

                    h += Noise();
                    goMesh.separateTop = feature.renderingOptions.hasRoof;

                    if (feature.layer.slicedExtrusion)
                    {
                        goMesh = SimpleExtruder.SliceExtrudePremesh(goMesh, h, 4f, 4f, 10f * feature.goTile.worldScale);
                    }
                    else
                    {
                        goMesh = SimpleExtruder.ExtrudePremesh(goMesh, h);
                    }
                }

                if (feature.height < feature.layer.colliderHeight)
                {
                    float h = feature.layer.colliderHeight;
                    h *= feature.goTile.worldScale;
                    if (feature.goTile.useElevation)
                    {
                        h += GOFeature.BuildingElevationOffset;
                    }

                    goMesh.secondaryMesh = new GOMesh(goMesh);
                    goMesh.secondaryMesh = SimpleExtruder.SliceExtrudePremesh(goMesh.secondaryMesh, h, 4f, 4f, 10f * feature.goTile.worldScale);
                }
            }

            return(goMesh);
        }