Exemplo n.º 1
0
        public override double GetValue(double x, double y, double z)
        {
            // Stretch out t by times to repeat:
            double rep    = SourceModule2.GetValue(x, y, z);
            bool   mirror = (SourceModule3.GetValue(x, y, z) > 0.5);

            x *= rep;
            y *= rep;
            z *= rep;

            // Get the current repetition:
            int baseRepetition = (int)x;

            // Shift:
            x -= baseRepetition;

            // X is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                x = 1.0 - x;
            }

            // Get the current repetition:
            baseRepetition = (int)y;

            // Shift:
            y -= baseRepetition;

            // Y is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                y = 1.0 - y;
            }

            // Get the current repetition:
            baseRepetition = (int)z;

            // Shift:
            z -= baseRepetition;

            // Z is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                z = 1.0 - z;
            }

            // Read source:
            return(SourceModule1.GetValue(x, y, z));
        }
Exemplo n.º 2
0
        public override double GetValue(double t)
        {
            // Stretch out t by times to repeat:
            t *= SourceModule2.GetValue(t);

            // Get the current repetition:
            int baseRepetition = (int)t;

            // Shift t:
            t -= baseRepetition;

            // T is now in the 0-1 range.
            bool mirror = (SourceModule3.GetValue(t) > 0.5);

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                t = 1.0 - t;
            }

            // Read source:
            return(SourceModule1.GetValue(t));
        }