コード例 #1
0
    private Mesh GetMesh(int index)
    {
        SgtHelper.ClearCapacity(positions, 1024);
        SgtHelper.ClearCapacity(coords0, 1024);
        SgtHelper.ClearCapacity(indices, 1024);
        SgtHelper.ClearCapacity(colors, 1024);
        SgtHelper.ClearCapacity(normals, 1024);

        if (index >= Meshes.Count)
        {
            var newMesh = SgtHelper.CreateTempMesh("Aurora Mesh (Generated)");

            Meshes.Add(newMesh);

            return(newMesh);
        }

        var mesh = Meshes[index];

        if (mesh == null)
        {
            mesh = Meshes[index] = SgtHelper.CreateTempMesh("Aurora Mesh (Generated)");
        }

        return(mesh);
    }
コード例 #2
0
    private void WriteIndices(SgtRectL outer, SgtRectL inner, long detail, long size)
    {
        SgtHelper.ClearCapacity(indices, 1024);

        for (var y = outer.minY; y < outer.maxY; y++)
        {
            for (var x = outer.minX; x < outer.maxX; x++)
            {
                if (x >= inner.minX && x < inner.maxX && y >= inner.minY && y < inner.maxY)
                {
                    continue;
                }

                var aX = x; var aY = y;
                var bX = x + 1; var bY = y;
                var cX = x; var cY = y + 1;
                var dX = x + 1; var dY = y + 1;

                if (y == outer.minY && y > -detail)
                {
                    if (x % 2 == 0)
                    {
                        bX -= 1;
                    }
                    else
                    {
                        aX -= 1;
                    }
                }

                if (y == outer.maxY - 1 && y < detail - 1)
                {
                    if (x % 2 == 0)
                    {
                        dX += 1;
                    }
                    else
                    {
                        cX += 1;
                    }
                }

                if (x == outer.minX && x > -detail)
                {
                    if (y % 2 == 0)
                    {
                        cY -= 1;
                    }
                    else
                    {
                        aY -= 1;
                    }
                }

                if (x == outer.maxX - 1 && x < detail - 1)
                {
                    if (y % 2 == 0)
                    {
                        dY += 1;
                    }
                    else
                    {
                        bY += 1;
                    }
                }

                var a = Wrap(aX, aY, size);
                var b = Wrap(bX, bY, size);
                var c = Wrap(cX, cY, size);
                var d = Wrap(dX, dY, size);

                /*
                 * var posA = positions[a];
                 * var posB = positions[b];
                 * var posC = positions[c];
                 * var posD = positions[d];
                 *
                 * var areaA = Area(posA, posB, posC) + Area(posD, posC, posB);
                 * var areaB = Area(posA, posB, posD) + Area(posD, posC, posA);
                 *
                 * if (a < b)
                 * {
                 *      var t = a;
                 *
                 *      a = b;
                 *      b = d;
                 *      d = c;
                 *      c = t;
                 * }*/

                indices.Add(a); indices.Add(c); indices.Add(b);
                indices.Add(d); indices.Add(b); indices.Add(c);
            }
        }
    }