示例#1
0
        protected override Vector3 DistortPointInternal(Vector3 point, float strength)
        {
            Vector3 scaledPoint = (point * scaleMultiplier) + axisOffset;

            point.x += (float)((noise.Evaluate(scaledPoint.x, Time.unscaledTime * axisSpeed.x)) * axisStrength.x * strengthMultiplier * strength);
            point.y += (float)((noise.Evaluate(scaledPoint.x + scaledPoint.y, Time.unscaledTime * axisSpeed.y)) * axisStrength.y * strengthMultiplier * strength);
            point.z += (float)((noise.Evaluate(scaledPoint.x + scaledPoint.y + scaledPoint.z, Time.unscaledTime * axisSpeed.z)) * axisStrength.z * strengthMultiplier * strength);
            return(point);
        }
        protected override Vector3 DistortPointInternal(Vector3 point, float strength)
        {
            Vector3 scaledPoint = (point * ScaleMultiplier) + AxisOffset;

            point.x = (float)(point.x + (noise.Evaluate(scaledPoint.x, scaledPoint.y, scaledPoint.z, Time.unscaledTime * AxisSpeed.x)) * AxisStrength.x * StrengthMultiplier);
            point.y = (float)(point.y + (noise.Evaluate(scaledPoint.x, scaledPoint.y, scaledPoint.z, Time.unscaledTime * AxisSpeed.y)) * AxisStrength.y * StrengthMultiplier);
            point.z = (float)(point.z + (noise.Evaluate(scaledPoint.x, scaledPoint.y, scaledPoint.z, Time.unscaledTime * AxisSpeed.z)) * AxisStrength.z * StrengthMultiplier);
            return(point);
        }
示例#3
0
    private Vector3 GetDrift(Vector3 point, int offset)
    {
        Vector3 drift = new Vector3();

        drift.x = (float)noise.Evaluate((point.x * driftScale) + offset, Time.time * driftTimeScale) * 0.01f;
        drift.y = (float)noise.Evaluate((point.y * driftScale) + offset, Time.time * driftTimeScale) * 0.01f;
        drift.z = (float)noise.Evaluate((point.z * driftScale) + offset, Time.time * driftTimeScale) * 0.01f;
        return(drift * driftIntensity);
    }
示例#4
0
    protected void UpdateWidth()
    {
        for (int i = 0; i < widthCurveKeys.Length; i++)
        {
            Keyframe key = widthCurveKeys[i];
            key.value *= (float)(noise.Evaluate(i, Time.time * 15));
            key.value *= randomWidth;
            key.value  = Mathf.Max(0.0025f, key.value);
            widthCurveAdjustedKeys[i] = key;
        }

        widthCurveAdjusted.keys = widthCurveAdjustedKeys;
        lineRenderer.widthCurve = widthCurveAdjusted;
    }
示例#5
0
        public void UpdateCollection()
        {
            if (Source == null)
            {
                return;
            }

            if (prevPoints == null || prevPoints.Length != Objects.Count)
            {
                prevPoints = new Vector3[Objects.Count];
            }

            randomPosition = new System.Random(Seed);
            Vector3    linePoint    = source.GetPoint(NormalizedDistance);
            Quaternion lineRotation = source.GetRotation(NormalizedDistance, RotationTypeOverride);

            for (int i = 0; i < Objects.Count; i++)
            {
                if (Objects[i] == null)
                {
                    continue;
                }

                Vector3 point = source.transform.TransformVector(GetRandomPoint());
                point.x = (float)(point.x + (noise.Evaluate((point.x + AxisOffset.x) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.x * SpeedMultiplier)) * AxisStrength.x * StrengthMultiplier);
                point.y = (float)(point.y + (noise.Evaluate((point.y + AxisOffset.y) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.y * SpeedMultiplier)) * AxisStrength.y * StrengthMultiplier);
                point.z = (float)(point.z + (noise.Evaluate((point.z + AxisOffset.z) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.z * SpeedMultiplier)) * AxisStrength.z * StrengthMultiplier);

                Objects[i].position = point + linePoint;
                if (SwarmVelocities)
                {
                    Vector3 velocity = prevPoints[i] - point;
                    Objects[i].rotation = Quaternion.Lerp(lineRotation, Quaternion.LookRotation(velocity, Vector3.up), VelocityBlend);
                }
                else
                {
                    Objects[i].rotation = lineRotation;
                }
                Objects[i].Rotate(RotationOffset);

                prevPoints[i] = point;
            }
        }
示例#6
0
      protected void CalculateRadialForces(Vector3 currentVertex, Vector3 originalVertex, int vertexIndex)
      {
          Vector3 currentRadialForce = radialForces[vertexIndex];
          Vector3 newRadialForce     = zero; //Vector3.zero;
          Vector3 distanceVector     = zero; //Vector3.zero;

          distanceVector.x = originalVertex.x - currentVertex.x;
          distanceVector.y = originalVertex.y - currentVertex.y;
          distanceVector.z = originalVertex.z - currentVertex.z;

          float sqrDistanceToTarget    = (distanceVector.x * distanceVector.x + distanceVector.y * distanceVector.y + distanceVector.z * distanceVector.z);
          float normalizedDistToTarget = sqrDistanceToTarget / (adjustedRadius * adjustedRadius);

          if (normalizedDistToTarget > 1)
          {
              normalizedDistToTarget = 1;
          }
          if (normalizedDistToTarget < 0)
          {
              normalizedDistToTarget = 0;
          }

          float radialForce = radialForceTable[(int)(normalizedDistToTarget * (tableResolution - 1))] * radialForceMultiplier;  //radialForceCurve.Evaluate(normalizedDistToTarget) * radialForceMultiplier;

          newRadialForce    = distanceVector;
          newRadialForce.x *= radialForce;
          newRadialForce.y *= radialForce;
          newRadialForce.z *= radialForce;

          if (useVertexNoise)
          {
              // Add random noise to force
              newRadialForce.x += ((float)noise.Evaluate(currentVertex.x * turbulenceScale, time * turbulenceSpeed) * turbulenceMultiplier);
              newRadialForce.y += ((float)noise.Evaluate(currentVertex.y * turbulenceScale, time * turbulenceSpeed) * turbulenceMultiplier);
              newRadialForce.z += ((float)noise.Evaluate(currentVertex.z * turbulenceScale, time * turbulenceSpeed) * turbulenceMultiplier);
          }

          newRadialForce            = Vector3.Lerp(currentRadialForce, newRadialForce, deltaTime * radialForceInertia);
          radialForces[vertexIndex] = newRadialForce;
      }
 private float AddNoise(float value, NoiseSetting setting, float time, int offset)
 {
     value += (float)noise.Evaluate(value * setting.Scale, time + offset * setting.Speed) * setting.Intensity;
     return(value);
 }
    public override void Initialize(Vector3 surfacePosition)
    {
        base.Initialize(surfacePosition);

        ISceneTransitionService transitionService;

        if (MixedRealityServiceRegistry.TryGetService <ISceneTransitionService>(out transitionService))
        {
            transitionService.OnTransitionStarted += OnTransitionStarted;
        }

        tileScale   = 1f / numColumns;
        tileOffsets = new Vector2[numTiles];

        int tileNum = 0;

        for (int row = 0; row < numRows; row++)
        {
            for (int column = 0; column < numColumns; column++)
            {
                Vector2 uv = Vector2.zero;
                uv.x = tileScale * column;
                uv.y = (tileScale * -row) - tileScale;
                tileOffsets[tileNum] = uv;

                tileNum++;
                if (tileNum >= numTiles)
                {
                    break;
                }
            }

            if (tileNum >= numTiles)
            {
                break;
            }
        }

        noise = new FastSimplexNoise();

        transitionColor = Color.black;

        forces      = new Force[fingers.Length];
        fingertips  = new Fingertip[fingers.Length];
        wisps       = new Wisp[numWisps];
        quads       = new Quad[numWisps];
        finalQuads  = new Quad[numWisps];
        renderOrder = new List <RenderOrder>(numWisps);

        for (int i = 0; i < numWisps; i++)
        {
            Wisp wisp = new Wisp();
            wisp.TargetPoint  = SurfacePosition + (Random.insideUnitSphere * SurfaceRadius);
            wisp.Point        = wisp.TargetPoint;
            wisp.Velocity     = Random.insideUnitSphere * initialVelocity;
            wisp.TargetRadius = Mathf.Lerp(wispSize.x, wispSize.y, (float)noise.Evaluate(wisp.Point.x, wisp.Point.y, wisp.Point.z));
            wisp.Radius       = wisp.TargetRadius;
            wisp.TileOffset   = Random.Range(0, numTiles);
            wisps[i]          = wisp;

            Quad quad = Quad.FromWisp(baseWispColor.Evaluate(Random.Range(0f, 1f)), wisp.Point, wisp.Radius, Vector3.up, Vector3.right, tileOffsets[wisp.TileOffset], tileScale);
            quad.Color    = transitionColor;
            quads[i]      = quad;
            finalQuads[i] = quads[i];

            RenderOrder r = new RenderOrder();
            renderOrder.Add(r);
        }

        for (int i = 0; i < fingers.Length; i++)
        {
            Transform finger    = fingers[i];
            Fingertip fingertip = fingertips[i];
            fingertip.Block     = new MaterialPropertyBlock();
            fingertip.Trail     = finger.GetComponentInChildren <TrailRenderer>();
            fingertip.Mesh      = finger.GetComponentInChildren <MeshRenderer>();
            fingertip.PingAudio = finger.GetComponentInChildren <AudioSource>();
            fingertips[i]       = fingertip;
        }

        Camera.onPostRender += PostRender;

        updateWisps = true;
        Task task = UpdateWispsTask();
    }
示例#9
0
        private void Update()
        {
            Growth = Mathf.Clamp01(Growth);

            if (Application.isPlaying && Growth == growbieSizeLastFrame && !IsDirty)
            {
                // Nothing to do!
                return;
            }

            IsDirty = false;

            int numTransforms = transform.childCount;

            if (numTransformLastFrame != numTransforms)
            {
                GenerateRandomGrowthValues();
            }

            for (int i = 0; i < numTransforms; i++)
            {
                Transform growbie = transform.GetChild(i);

                if (Growth < minGrowthCutoff)
                {
                    growbie.gameObject.SetActive(false);
                    continue;
                }

                float scale = Growth * (growthScaleMultiplier.Evaluate((float)i / numTransforms));

                if (growthRandomness > 0)
                {
                    scale = scale * (1f - (growthRandomness * randomGrowthValues[i]));
                }

                if (corkScrewAmount > 0)
                {
                    float   corkscrew   = (float)noise.Evaluate(Growth, (scale + i) * corkscrewJitter);
                    Vector3 eulerAngles = growbie.localEulerAngles;
                    switch (corkscrewAxis)
                    {
                    case CorkscrewAxisEnum.X:
                        eulerAngles.x = corkscrew * 360 * corkScrewAmount;
                        break;

                    case CorkscrewAxisEnum.Y:
                        eulerAngles.y = corkscrew * 360 * corkScrewAmount;
                        break;

                    case CorkscrewAxisEnum.Z:
                        eulerAngles.z = corkscrew * 360 * corkScrewAmount;
                        break;
                    }
                    growbie.localEulerAngles = eulerAngles;
                }

                if (growthJitter > 0)
                {
                    float growthJitterMultiplier = (1 + growthJitter);
                    float jitter = (float)noise.Evaluate(Growth * 15 * growthJitterMultiplier, (i * 15 * growthJitterMultiplier));
                    scale += (jitter * (growthJitter * 0.1f));
                }

                if (scale < 0.001f)
                {
                    growbie.gameObject.SetActive(false);
                }
                else
                {
                    growbie.gameObject.SetActive(true);
                    finalScale = Vector3.one * scale;
                    // Apply non-uniform scaling
                    finalScale.x = xAxisScale.Evaluate(scale);
                    finalScale.y = yAxisScale.Evaluate(scale);
                    finalScale.z = zAxisScale.Evaluate(scale);
                    // Apply final scale
                    growbie.localScale = finalScale;
                }
            }

            growbieSizeLastFrame  = Growth;
            numTransformLastFrame = numTransforms;
        }