//Draws a line given a list of vector 3
        public GameObject dropLine(List <Vector3> polyline, float witdh, float height, Material material, bool curved = false)
        {
            GameObject line = new GameObject("Polyline");

            MeshFilter   filter   = line.AddComponent <MeshFilter>();
            MeshRenderer renderer = line.AddComponent <MeshRenderer>();

            GOLineMesh lineMesh = new GOLineMesh(polyline, curved);

            lineMesh.width = witdh;
            lineMesh.load(line);
            Mesh mesh = lineMesh.mesh;

            if (height > 0)
            {
                mesh = SimpleExtruder.SliceExtrude(mesh, line, height, 4f, 4f, 10f);
            }

            filter.sharedMesh = mesh;
            renderer.material = material;

            line.AddComponent <MeshCollider> ();

            return(line);
        }
        //Draws a line given a list of vector 3
        public GameObject dropLine(List <Vector3> polyline, float witdh, float height, Material material, GOUVMappingStyle uvMappingStyle, bool curved = false)
        {
            GameObject line = new GameObject("Polyline");

            MeshFilter   filter   = line.AddComponent <MeshFilter>();
            MeshRenderer renderer = line.AddComponent <MeshRenderer>();

            GOLineMesh lineMesh = new GOLineMesh(polyline, curved);

            lineMesh.width = witdh;
            lineMesh.load(line);

            GOMesh goMesh = lineMesh.CreatePremesh();

            goMesh.uvMappingStyle = uvMappingStyle;

            if (height > 0)
            {
                goMesh = SimpleExtruder.SliceExtrudePremesh(goMesh, height, 4f, 4f, 10f);
            }

            filter.sharedMesh = goMesh.ToMesh();
            renderer.material = material;

            line.AddComponent <MeshCollider> ();

            return(line);
        }
        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.convertedGeometry);

            lineMesh.width = feature.renderingOptions.lineWidth;
            preMesh        = lineMesh.CreatePremesh();

            if (feature.height > 0)
            {
                float h = feature.height;

                if (GOMap.GOLink)
                {
                    h += GOFeature.BuildingElevationOffset;
                }

                preMesh = SimpleExtruder.SliceExtrudePremesh(preMesh, h + Noise(), 4f, 4f, 10f);
            }

            if (feature.renderingOptions.outlineWidth > 0)
            {
                lineMesh.width        = feature.renderingOptions.lineWidth + feature.layer.defaultRendering.outlineWidth;
                preMesh.secondaryMesh = lineMesh.CreatePremesh();
            }

            return(preMesh);
        }
示例#4
0
        public GameObject BuildLine(GOLayer layer, GORenderingOptions renderingOptions, GOMap map, GameObject parent)
        {
            if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1]))
            {
                return(null);
            }

            GameObject line = GameObject.Instantiate(feature.goTile.featurePrototype, parent.transform);

            if (renderingOptions.tag.Length > 0)
            {
                line.tag = renderingOptions.tag;
            }

            if (renderingOptions.material)
            {
                renderingOptions.material.renderQueue = -(int)feature.sort;
            }
            if (renderingOptions.outlineMaterial)
            {
                renderingOptions.outlineMaterial.renderQueue = -(int)feature.sort;
            }

            GOLineMesh lineMesh = new GOLineMesh(feature.convertedGeometry);

            lineMesh.width = renderingOptions.lineWidth;
            lineMesh.load(line);
            mesh = lineMesh.mesh;
            line.GetComponent <Renderer>().material = renderingOptions.material;

            Vector3 position = line.transform.position;

            position.y = feature.y;

            line.transform.position = position;

            if (renderingOptions.outlineMaterial != null)
            {
                GameObject outline = CreateRoadOutline(line, renderingOptions.outlineMaterial, renderingOptions.lineWidth + layer.defaultRendering.outlineWidth);
                if (layer.useColliders)
                {
                    MeshCollider mc = outline.GetComponent <MeshCollider> ();
                    mc.enabled    = true;
                    mc.sharedMesh = outline.GetComponent <MeshFilter> ().sharedMesh;
                }

                outline.layer = line.layer;
                outline.tag   = line.tag;
            }
            else if (layer.useColliders)
            {
                line.GetComponent <MeshCollider> ().enabled = true;
            }

            return(line);
        }
示例#5
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);
        }
示例#6
0
        GameObject CreateRoadOutline(GameObject line, Material material, float width)
        {
            GameObject outline = new GameObject("outline");

            outline.transform.parent = line.transform;

            material.renderQueue = -((int)feature.sort - 1);

            GOLineMesh lineMesh = new GOLineMesh(feature.convertedGeometry);

            lineMesh.width = width;
            lineMesh.load(outline);

            Vector3 position = outline.transform.position;

            position.y = -0.039f;
            outline.transform.localPosition = position;

            outline.GetComponent <Renderer>().material = material;

            return(outline);
        }
        public void BuildLine(GameObject line, GOLayer layer, GORenderingOptions renderingOptions, GOMap map)
        {
            if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1]))
            {
                return;
            }

                        #if GOLINK
            feature.convertedGeometry = GOFeatureMeshBuilder.BreakLine(feature.convertedGeometry, map.goTerrain);
                        #endif

            if (renderingOptions.tag.Length > 0)
            {
                line.tag = renderingOptions.tag;
            }

            if (renderingOptions.material)
            {
                renderingOptions.material.renderQueue = -(int)feature.sort;
            }
            if (renderingOptions.outlineMaterial)
            {
                renderingOptions.outlineMaterial.renderQueue = -(int)feature.sort;
            }

            GOLineMesh lineMesh = new GOLineMesh(feature.convertedGeometry);
            lineMesh.width = renderingOptions.lineWidth;
            lineMesh.load(line);
            mesh = lineMesh.mesh;
            line.GetComponent <Renderer>().material = renderingOptions.material;

            Vector3 position = line.transform.position;
            position.y = feature.y;

                        #if GOLINK
            if (renderingOptions.polygonHeight > 0)
            {
                int offset = GOFeature.BuildingElevationOffset;
                line.GetComponent <MeshFilter> ().sharedMesh = SimpleExtruder.Extrude(line.GetComponent <MeshFilter> ().sharedMesh, line, renderingOptions.polygonHeight + offset);
                position.y -= offset;
            }
                        #else
                        #endif

            line.transform.position = position;

            if (renderingOptions.outlineMaterial != null)
            {
                GameObject outline = CreateRoadOutline(line, renderingOptions.outlineMaterial, renderingOptions.lineWidth + layer.defaultRendering.outlineWidth);
                if (layer.useColliders)
                {
                    outline.AddComponent <MeshCollider> ().sharedMesh = outline.GetComponent <MeshFilter> ().sharedMesh;
                }

                outline.layer = line.layer;
                outline.tag   = line.tag;
            }
            else if (layer.useColliders)
            {
//				Mesh m = gameObject.GetComponent<MeshFilter> ().sharedMesh;
                line.AddComponent <MeshCollider> ();
            }
        }