Ejemplo n.º 1
0
        private void OnDrawGizmosSelected()
        {
            if (!EditorApplication.isPlaying)
            {
                startPosition = this.transform.position;
            }

            Gizmos.color = Color.cyan;
            float   detailPer = gizmoLength / gizmoDetail;
            float   phase = 0;
            Vector3 pos1 = Vector3.negativeInfinity, pos2 = Vector3.negativeInfinity;

            for (int j = 0; j < gizmoDetail + 1; j++)
            {
                phase = detailPer * j;
                pos2  = pos1;
                var posCalc = Vector3.zero;
                for (int i = 0; i < waves.Length; i++)
                {
                    //where we are on this wave
                    var d = WaveMathHelper.EvalWave(phase, waves[i].frequency, waves[i].amplitude, waves[i].baseStart, waves[i].waveForm);
                    //position of this wave
                    posCalc += Vector3.LerpUnclamped(Vector3.zero, waves[i].moveToPossition, d);
                }
                pos1 = posCalc;
                if (pos1 != Vector3.negativeInfinity && pos2 != Vector3.negativeInfinity)
                {
                    Gizmos.DrawLine(startPosition + pos1, startPosition + pos2);
                }
            }
        }
Ejemplo n.º 2
0
 void Awake()
 {
     startPosition = this.transform.position;
     for (int i = 0; i < waves.Length; i++)
     {
         waves[i].distance = WaveMathHelper.EvalWave(waves[i].phase, waves[i].frequency, waves[i].amplitude, waves[i].baseStart, waves[i].waveForm);
         Debug.Log(waves[i].distance);
     }
 }
Ejemplo n.º 3
0
        private Vector3 CalculateChangeInPossition(Wave[] waves, float deltaTime)
        {
            var currentChangeInPossition = Vector3.zero;

            for (int i = 0; i < waves.Length; i++)
            {
                waves[i].prevDistance     = waves[i].distance;
                waves[i].phase           += deltaTime;
                waves[i].distance         = WaveMathHelper.EvalWave(waves[i].phase, waves[i].frequency, waves[i].amplitude, waves[i].baseStart, waves[i].waveForm);
                currentChangeInPossition += Vector3.LerpUnclamped(Vector3.zero, waves[i].moveToPossition, waves[i].distance);
            }
            return(currentChangeInPossition);
        }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     lightRef.color = orginalColor * WaveMathHelper.EvalWave(phase, frequency, amplitude, baseStart, waveForm, polynomial);
 }