コード例 #1
0
    void Start()
    {
        meshFilter = GetComponent <MeshFilter>();
        switch (shape)
        {
        case PGMesh.Shape.Triangle:
            meshFilter.sharedMesh = PGMesh.Triangle(Vector3.left / 2 + Vector3.down / 2, Vector3.up, Vector3.right / 2 + Vector3.down / 2);
            break;

        case PGMesh.Shape.Quad:
            meshFilter.sharedMesh = PGMesh.Quad(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up);
            break;

        case PGMesh.Shape.Plane:
            meshFilter.sharedMesh = PGMesh.Plane(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up, 1, 3);
            break;

        case PGMesh.Shape.Tetrahedron:
            meshFilter.sharedMesh = PGMesh.Tetrahedron(1);
            break;

        case PGMesh.Shape.Cube:
            meshFilter.sharedMesh = PGMesh.Cube(1);
            break;

        case PGMesh.Shape.Octahedron:
            meshFilter.sharedMesh = PGMesh.Octahedron(1);
            break;

        case PGMesh.Shape.Icosahedron:
            meshFilter.sharedMesh = PGMesh.Icosahedron(1);
            break;
        }
    }
コード例 #2
0
    Mesh BalconyPanel(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3)
    {
        var normal = Vector3.Cross((v1 - v0), (v3 - v0)).normalized;
        var v4     = v0 + (v1 - v0) * 0.4f;
        var v5     = v3 + (v2 - v3) * 0.4f;

        var combine     = new List <Mesh>();
        var submeshMask = new List <List <int> >();

        combine.Add(PGMesh.Quad(v0, v4, v4 + normal, v0 + normal));
        submeshMask.Add(new List <int> {
            0
        });
        combine.Add(PGMesh.Quad(v0 + normal, v4 + normal, v5 + normal, v3 + normal));
        submeshMask.Add(new List <int> {
            0
        });
        combine.Add(PGMesh.Quad(v3 + normal, v5 + normal, v5, v3));
        submeshMask.Add(new List <int> {
            0
        });
        combine.Add(PGMesh.Quad(v0, v0 + normal, v3 + normal, v3));
        submeshMask.Add(new List <int> {
            0
        });

        combine.Add(PGMesh.Quad(v4, v1, v1 + normal, v4 + normal));
        submeshMask.Add(new List <int> {
            1
        });
        combine.Add(PGMesh.Quad(v4 + normal, v1 + normal, v2 + normal, v5 + normal));
        submeshMask.Add(new List <int> {
            1
        });
        combine.Add(PGMesh.Quad(v5 + normal, v2 + normal, v2, v5));
        submeshMask.Add(new List <int> {
            1
        });

        combine.Add(PGMesh.Quad(v2, v2 + normal, v1 + normal, v1));
        submeshMask.Add(new List <int> {
            0
        });

        return(PGMesh.CombineMeshes(combine));
    }