Exemple #1
0
        private void AddPolygon(GOTempPolyNew poly, Vector3 normal)
        {
            int ind1 = AddVertex(poly.vertices[0], normal, poly.indices[0]);
            int ind2 = AddVertex(poly.vertices[1], normal, poly.indices[1]);
            int ind3 = AddVertex(poly.vertices[2], normal, poly.indices[2]);

            bufIndices.Add(ind1);
            bufIndices.Add(ind2);
            bufIndices.Add(ind3);
        }
Exemple #2
0
        public GOMesh ProjectFeature(GOFeature feature, GOMesh terrainMesh, float distance)
        {
            Vector3[] vertices  = terrainMesh.vertices;
            int[]     triangles = terrainMesh.triangles;

            GOTempPolyNew poly;

            ComputeFeatureRanges(feature);

            for (int i = 0; i < triangles.Length; i += 3)
            {
                int i1 = triangles[i];
                int i2 = triangles[i + 1];
                int i3 = triangles[i + 2];

                Vector3 v1 = feature.goTile.position + vertices [i1];
                Vector3 v2 = feature.goTile.position + vertices [i2];
                Vector3 v3 = feature.goTile.position + vertices [i3];

                Vector3 side1  = v2 - v1;
                Vector3 side2  = v3 - v1;
                Vector3 normal = Vector3.Cross(side1, side2).normalized;

                poly        = new GOTempPolyNew(v1, v2, v3);
                poly.normal = normal;
                poly.indices.AddRange(new int[] { i1, i2, i3 });
                poly.xRange = xRange;
                poly.zRange = zRange;

//				Profiler.BeginSample ("Wrap Polygon");
                poly = poly.WrapPolygon(feature.convertedGeometry.ToArray(), terrainMesh);
//				Profiler.EndSample ();

                if (poly == null)
                {
                    continue;
                }

                polys.Add(poly);
            }

            return(MergeTempPolys(distance));
        }