Esempio n. 1
0
 /// <inheritdoc/>
 public override IEnumerable <Vector3> GetVertices(IExplicitShape <int> shape, GridMap <int> map)
 {
     return(shape
            .Points
            .SelectMany(p => vertices[GridPoint1.GetColor(p, colorFunction1)]
                        .Select(q => map.GridToWorld(q + map.DeRound(p)))));
 }
Esempio n. 2
0
 /// <inheritdoc/>
 public override IEnumerable <Vector3> GetNormals(IExplicitShape <int> shape, GridMap <int> map, bool flip)
 {
     return(shape
            .Points
            .SelectMany(p => vertices[GridPoint1.GetColor(p, colorFunction1)]
                        .Select((q, i) => map.GridToWorld(q + map.DeRound(p) + (flip ? -normals[GridPoint1.GetColor(p, colorFunction1)][i] : normals[GridPoint1.GetColor(p, colorFunction1)][i])).normalized)));
 }
Esempio n. 3
0
        private IEnumerable <int> GetTrianglesNormal(IExplicitShape <int> shape)
        {
            var points          = shape.Points.ToArray();
            var triangleOffsets = new int[shape.Points.Count()];

            triangleOffsets[0] = 0;

            for (int i = 1; i < triangleOffsets.Length; i++)
            {
                triangleOffsets[i] = triangleOffsets[i - 1] + vertices[GridPoint1.GetColor(points[i - 1], colorFunction1)].Count;
            }

            return(shape
                   .Points
                   .SelectMany((p, i) => triangles[GridPoint1.GetColor(p, colorFunction1)]
                               .Select(t => t + triangleOffsets[i])));
        }
Esempio n. 4
0
        private IEnumerable <int> GetTrianglesFlipped(IExplicitShape <int> shape)
        {
            var flippedTriangles = new IntArray[triangles.Length];

            for (int j = 0; j < triangles.Length; j++)
            {
                flippedTriangles[j] = new IntArray()
                {
                    data = triangles[j].ToList()
                };

                for (int i = 0; i < triangles[j].Count; i += 3)
                {
                    flippedTriangles[j][i]     = triangles[j][i + 1];
                    flippedTriangles[j][i + 1] = triangles[j][i];
                    flippedTriangles[j][i + 2] = triangles[j][i + 2];
                }
            }

            return(shape
                   .Points
                   .SelectMany((p, i) => flippedTriangles[GridPoint1.GetColor(p, colorFunction1)]
                               .Select(t => t + i * vertices.Length)));
        }
Esempio n. 5
0
 /// <inheritdoc/>
 public override IEnumerable <Vector2> GetUVs(IExplicitShape <int> shape)
 {
     return(shape.Points.SelectMany(p => uvs[GridPoint1.GetColor(p, colorFunction1)]));
 }