コード例 #1
0
        public CrossSection(int nPoints)
        {
            ellipse = new Vector2[nPoints];

            float w   = width / 2f;
            float h   = height / 2f;
            float arc = 360f / (nPoints - 1);

            for (int i = 0; i < nPoints; i++)
            {
                float t = (360f - i * arc) * Mathf.Deg2Rad;
                ellipse[i] = new Vector3(w * Mathf.Cos(t), h * Mathf.Sin(t));
            }

            if (animationEnabled)
            {
                // Noise should scale with size.
                // noiseScale = 1 for a 16 x 9 ellipse.
                noiseScale = (width * height) / 144f;

                w         += width * distrMargin;
                h         += height * distrMargin;
                attractors = new Attractor[] {
                    new Attractor(-w, w, h, 0f, distrMinIncr, distrMaxIncr),
                    new Attractor(-w, w, 0f, -h, distrMinIncr, distrMaxIncr),
                    new Attractor(-w, 0f, -h, h, distrMinIncr, distrMaxIncr),
                    new Attractor(0f, w, -h, h, distrMinIncr, distrMaxIncr),
                    new Attractor(-w, w, -h, h, distrMinIncr, distrMaxIncr)
                };

                cNoiseOsc = new Oscillator(noiseMinIncr, noiseMaxIncr);
                fNoiseOsc = new Oscillator(noiseMinIncr, noiseMaxIncr);
            }
        }
コード例 #2
0
 public Attractor(float x1, float x2,
                  float y1, float y2,
                  float minIncr, float maxIncr)
 {
     osc     = new Oscillator(minIncr, maxIncr);
     bounds  = new Rect(x1, y1, x2 - x1, y2 - y1);
     posNext = bounds.center;
 }
コード例 #3
0
        public Path(float ringWidth)
        {
            position  = new Vector3(0f, 0f, ringWidth * -2f);
            direction = Vector3.forward;
            step      = direction * ringWidth;

            if (curvatureEnabled)
            {
                hCurveOsc = new Oscillator(hCurveMinIncr, hCurveMaxIncr);
                vCurveOsc = new Oscillator(vCurveMinIncr, vCurveMaxIncr);
            }
        }
コード例 #4
0
 private void AnimateSharedMaterial()
 {
     if (material == null)
     {
         if (chunkCount > 0)
         {
             lumOsc   = new Oscillator(300f, 400f);
             material = transform.GetChild(0).GetComponent <Renderer>().sharedMaterial;
         }
     }
     else
     {
         if (!lumOsc.MoveNext())
         {
             lumPrev = lumNext;
             lumNext = Random.Range(-0.4f, 0.4f);
         }
         lum            = Mathf.Lerp(lumPrev, lumNext, lumOsc.Current);
         material.color = Color.HSVToRGB(0.085f, 0.3f, 0.4f + lum);
         material.SetFloat("_Glossiness", 0.4f - lum);
         material.SetFloat("_Metallic", 0.5f - lum * 0.5f);
     }
 }