Esempio n. 1
0
    public MeshBuilder Create()
    {
        CircleMesh circleMesh = new CircleMesh();

        circleMesh.radius        = radius;
        circleMesh.direction1    = direction1;
        circleMesh.direction2    = direction2;
        circleMesh.totalVertices = totalPerimeterVertices;

        Vector3 direction3 = Vector3.Cross(direction1, direction2).normalized;

        MeshBuilder upCircle = circleMesh.Create()
                               .Translate(0.5f * height * direction3);

        MeshBuilder downCircle = circleMesh.Create()
                                 .Translate(-0.5f * height * direction3);

        MeshUnion meshUnion = new MeshUnion();

        meshUnion.size          = height;
        meshUnion.totalSegments = totalVerticalSegments;

        MeshBuilder tunnel = meshUnion.Create(upCircle, downCircle);

        return(MeshBuilder.Join(upCircle, downCircle).Join(tunnel));
    }
Esempio n. 2
0
    public MeshBuilder Create()
    {
        CircleMesh circleMesh = new CircleMesh();

        circleMesh.radius        = radius;
        circleMesh.direction1    = direction1;
        circleMesh.direction2    = direction2;
        circleMesh.totalVertices = totalPerimeterVertices;

        if ((direction3 - Vector3.up).magnitude < 0.001f)
        {
            direction3 = Vector3.Cross(direction1, direction2).normalized;
        }

        MeshBuilder baseCircle = circleMesh.Create()
                                 .Translate(-0.5f * height * direction3);

        MeshBuilder top = new MeshBuilder();

        top.AddVertice(new Vector3(0f, -0.5f * height, 0f) + height * direction3, "border");

        MeshUnion meshUnion = new MeshUnion();

        meshUnion.size          = height;
        meshUnion.totalSegments = totalVerticalSegments;

        MeshBuilder cone = meshUnion.Create(top, baseCircle);

        return(cone.Join(baseCircle));
    }
Esempio n. 3
0
    public void Generate()
    {
        MeshBuilder baseMesh1 = new MeshBuilder();

        QuadMesh.Create(baseMesh1,
                        Vector3.right * baseSize.x,
                        Vector3.forward * baseSize.y);

        baseMesh1 = ExtrudeMesh.From(baseMesh1, Vector3.up * height1).Join(baseMesh1);

        MeshBuilder circleMesh = CircleMesh.Create(height2, 0f, 180f,
                                                   -Vector3.forward,
                                                   Vector3.up).
                                 Translate(Vector3.up * height1 + Vector3.forward * 0.5f * baseSize.y);

        circleMesh = ExtrudeMesh.From(circleMesh, Vector3.right * baseSize.x).Join(circleMesh);

        MeshFilter filter = gameObject.GetComponent <MeshFilter>();
        Mesh       mesh   = MeshBuilder.Join(baseMesh1, circleMesh).CreateMesh();

        mesh.RecalculateBounds();
        filter.mesh = mesh;
    }