Exemple #1
0
    public static Geometry Execute(Geometry geometry, IEnumerable <Geometry> others)
    {
        var processor = new AttachGeometry();

        processor.Others.AddRange(others);
        return(processor.Execute(geometry));
    }
Exemple #2
0
    void UpdateMesh()
    {
        var mr = GetComponent <MeshRenderer>();

        if (mr == null)
        {
            mr = gameObject.AddComponent <MeshRenderer>();
        }

        var mf = GetComponent <MeshFilter>();

        if (mf == null)
        {
            mf = gameObject.AddComponent <MeshFilter>();
        }

        var m = mf.sharedMesh;

        if (m == null)
        {
            m             = new Mesh();
            mf.sharedMesh = m;
        }


        if (Mathf.Abs(R1) < RLense)
        {
            return;
        }


        //generate cylinder
        var cyl  = GenCylinder.Execute(new Geometry(), RLense, Thickness, tessR);
        var cap1 = GenSphericalCap.Execute(new Geometry(), RLense, R1, tessR, tessC);

        cap1 = VectorOffset.Execute(cap1, new Vector3(0, Thickness * 0.5f, 0));

        var cap2 = GenSphericalCap.Execute(new Geometry(), RLense, R2, tessR, tessC);

        cap2 = VectorOffset.Execute(cap2, new Vector3(0, -Thickness * 0.5f, 0));
        cap2 = FlipFaces.ExecuteStatic(cap2);

        AttachGeometry.Execute(new Geometry(), new [] { cyl, cap1, cap2 }).StoreToMesh(m);
    }