Пример #1
0
        public static GOMesh PreloadLine(GOFeature feature)
        {
            if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1]))
            {
                return(null);
            }

            GOMesh preMesh = new GOMesh();

            GOLineMesh lineMesh = new GOLineMesh(feature, true);

            lineMesh.width = feature.renderingOptions.lineWidth * feature.goTile.worldScale;
            preMesh        = lineMesh.CreatePremesh();
            feature.isLoop = lineMesh.isLoop;
//			GORoad road = new GORoad (feature, 25, 1, 0);
//			road.computeRoad ();
//			preMesh = road.goMesh;

            if (feature.goTile.useElevation && feature.height == 0)
            {
                feature.height += GOFeature.RoadsHeightForElevation;
            }

            if (feature.height > 0)
            {
                float h = feature.height * feature.goTile.worldScale;
                if (feature.goTile.useElevation)
                {
                    h += GOFeature.BuildingElevationOffset;
                }
                preMesh = SimpleExtruder.ExtrudePremesh(preMesh, h + Noise(), false);
            }

            if (feature.renderingOptions.outlineWidth > 0 && !feature.goTile.useElevation)
            {
                lineMesh.width        = (feature.renderingOptions.lineWidth + feature.layer.defaultRendering.outlineWidth) * feature.goTile.worldScale;
                preMesh.secondaryMesh = lineMesh.CreatePremesh();

                if (feature.height > 0)
                {
                    float h = feature.height * feature.goTile.worldScale;
                    if (feature.goTile.useElevation)
                    {
                        h += GOFeature.BuildingElevationOffset;
                    }
                    preMesh.secondaryMesh = SimpleExtruder.ExtrudePremesh(preMesh.secondaryMesh, h + Noise(), false);
                }
            }

            return(preMesh);
        }
Пример #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);
        }