Exemple #1
0
    // the distancefunction from the player
    public float DistanceField(Vector3 p)
    {
        float dist = Camera.main.farClipPlane + 1;

        //menger sponge
        if (camScript._drawMergerSponge)
        {
            dist = Df.sdMerger(p, camScript._GlobalScale, camScript._iterations, camScript._modOffsetPos, camScript._iterationTransform.inverse, camScript._globalTransform.inverse, camScript._smoothRadius, camScript._scaleFactor);
        }
        // menger cylinder
        else if (camScript._drawTowerIFS)
        {
            dist = Df.towerIFS(p, camScript._GlobalScale);
        }

        return(dist);
    }
Exemple #2
0
    // the distancefunction from the player
    public float DistanceField(Vector3 p)
    {
        float dist = Camera.main.farClipPlane + 1;

        // check symmetry
        if (camScript._useSymmetry)
        {
            p = Df.sdSymXYZ(p);
        }
        // check modulor
        if (camScript._useModulor)
        {
            p.x = Df.mod(p.x, camScript._modInterval.x * camScript._GlobalScale * 2);
            p.y = Df.mod(p.y, camScript._modInterval.y * camScript._GlobalScale * 2);
            p.z = Df.mod(p.z, camScript._modInterval.z * camScript._GlobalScale * 2);
        }
        //menger sponge
        if (camScript._drawMergerSponge)
        {
            dist = Df.sdMerger(p, camScript._GlobalScale, camScript._iterations, camScript._modOffsetPos, camScript._iterationTransform.inverse, camScript._globalTransform.inverse, camScript._smoothRadius, camScript._scaleFactor);
        }
        // menger cylinder
        else if (camScript._drawMergerCylinder)
        {
            dist = Df.sdMergerCyl(p, camScript._GlobalScale, camScript._iterations, camScript._modOffsetPos, camScript._iterationTransform.inverse, camScript._globalTransform.inverse, camScript._smoothRadius, camScript._scaleFactor);
        }
        // terpinski triangle menger pyramid
        else if (camScript._drawMergerPyramid)
        {
            dist = Df.sdMergerPyr(p, camScript._GlobalScale, camScript._iterations, camScript._modOffsetPos, camScript._iterationTransform.inverse, camScript._globalTransform.inverse, camScript._smoothRadius, camScript._scaleFactor);
        }
        // negative sphere
        else if (camScript._drawNegativeSphere)
        {
            dist = Df.sdNegSphere(p, camScript._GlobalScale, camScript._iterations, camScript._modOffsetPos, camScript._iterationTransform.inverse, camScript._globalTransform.inverse, camScript._innerSphereRad, camScript._scaleFactor);
        }
        // sphere
        else if (camScript._drawSphere)
        {
            dist = Df.sdSphere(p - camScript._globalPosition, camScript._GlobalScale);
        }
        // box
        else if (camScript._drawBox)
        {
            dist = Df.sdBox(p - camScript._globalPosition, Vector3.one * camScript._GlobalScale);
        }


        // check section plane
        if (camScript._useSectionPlane)
        {
            float plane = Df.sdPlane(p, camScript._sectionTransform.inverse);
            return(Mathf.Max(dist, plane));
        }

        return(dist);

        /* debug modulor line
         * //modLine.GetComponent<LineRenderer>().SetPosition(0, p);
         * //modLine.GetComponent<LineRenderer>().SetPosition(1, p - dist);
         */
    }