Esempio n. 1
0
    public static Geometry Execute(Geometry geometry, float radius, float capRadius, int tessR = 16, int tessC = 16)
    {
        GenSphericalCap processor = new GenSphericalCap();

        processor.Radius       = radius;
        processor.CapRadius    = capRadius;
        processor.RTesselation = tessR;
        processor.CTesselation = tessC;

        return(processor.Execute(geometry));
    }
Esempio n. 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);
    }