public void UpdateVec2D() { PXValue pxValue = GetComponentInParent <PXValue>(); float vr = pxValue.GetValue(_chl0); float vt = pxValue.GetValue(_chl1); float radius = _RadiusRange.MapValue(vr); float theta = _ThetaRangeDegs.MapValue(vt); float vx = radius * Mathf.Cos(theta); float vy = radius * Mathf.Sin(theta); _Vec2D = new Vector2(vx, vy); }
protected override void ComputeTargetTF( PXValue pxValue, out Vector3 tgtLocPos, out Vector3 tgtLocScale, out Quaternion tgtLocRot) { base.ComputeTargetTF( pxValue, out tgtLocPos, out tgtLocScale, out tgtLocRot); float timeNow = GetScaledTime(); float pixelValue = pxValue.GetValue(_valueChl); float spd = _Speed.MapValue(pixelValue); float delay = spd * _Delay.MapValue(pixelValue); timeNow = timeNow * spd + delay; int chlCount = Mathf.Min(3, _LocCurves.Count); Vector3 locEuler = tgtLocRot.eulerAngles; for (int i = 0; i < chlCount; i++) { AnimationCurve ACurve = _LocCurves[i]; locEuler[i] = _Amplitude * ACurve.Evaluate(timeNow); } tgtLocRot.eulerAngles = locEuler; }
private void UpdatePlayableDirector() { PlayableDirector [] playableDirectors = GetComponentsInChildren <PlayableDirector>(); if (playableDirectors.Length == 0) { return; } PXValue pxValue = GetComponentInParent <PXValue>(); if (!pxValue) { return; } float valSpd = pxValue.GetValue(_ChlIdSpeed); float spd = _Speed.MapValue(valSpd); float valDelay = pxValue.GetValue(_ChlIdDelay); float delay = _Delay.MapValue(valDelay); foreach (var playableDirector in playableDirectors) { if (_delayMode == DelayMode.Normalized) { delay = (float)playableDirector.duration * delay; } double TNow = playableDirector.time; double T = _TimeScale * (spd * Time.realtimeSinceStartup + delay); double Duration = playableDirector.duration; if (timeExtraPolationMode == ExtraPolationMode.PingPong) { T = Mathf.PingPong((float)T, (float)Duration); } else if (timeExtraPolationMode == ExtraPolationMode.Repeat) { T = Mathf.Repeat((float)T, (float)Duration); } playableDirector.time = T; } }
// ----------------- assist ------------------------------------------- private void PaintOnPXValue( float lerpT, Vector2 vel, PXValue pXValue) { float val0, val1; GetVal2_RadiusTheta(vel, out val0, out val1); float alpha = GetPaintAlpha(Time.deltaTime, pXValue); float lerpT2 = lerpT * alpha; float v00 = pXValue.GetValue(0); float v10 = pXValue.GetValue(1); Vector2 vec0 = GetVec2FromRT(v00, v10); Vector2 vec1 = Vector2.Lerp(vec0, vel, lerpT); Vector2 rt = GetRTFromVec2(vec1); pXValue.LerpValue(rt.x, 1.0f, 0); pXValue.LerpValue(rt.y, 1.0f, 1); }
public bool ConfigVideoPlayer() { PXValue pxValue = GetComponentInParent <PXValue>(); if (!pxValue) { return(false); } float valSpd = pxValue.GetValue(_ChlPlaySpeed); float spd = _PlaySpeed.MapValue(valSpd); float valDelay = pxValue.GetValue(_ChlDelay); float delay = _Delay.MapValue(valDelay); VideoPlayer vp = _videoPlayer; double VideoLength = vp.clip.length; float t = delay + Time.realtimeSinceStartup; t = Mathf.Repeat(t, (float)VideoLength); vp.playbackSpeed = spd; vp.time = t; return(true); }
protected override void ComputeTargetTF( PXValue pxValue, out Vector3 tgtLocPos, out Vector3 tgtLocScale, out Quaternion tgtLocRot) { base.ComputeTargetTF( pxValue, out tgtLocPos, out tgtLocScale, out tgtLocRot); // adjust timeNow by pixel value float timeNow = GetScaledTime(); float pixelValue = pxValue.GetValue(_valueChl); float spd = _Speed.MapValue(pixelValue); float delay = spd * _Delay.MapValue(pixelValue); timeNow = timeNow * spd + delay; // compute localPosition int chlCount = Mathf.Min(3, _LocCurves.Count); if (_coordMode == CoordMode.Cartisian) { for (int i = 0; i < chlCount; i++) { AnimationCurve ACurve = _LocCurves[i]; tgtLocPos[i] = ACurve.Evaluate(timeNow); } } else if (_coordMode == CoordMode.Polar) { Vector3 tgr = Vector3.zero; for (int i = 0; i < chlCount; i++) { AnimationCurve ACurve = _LocCurves[i]; tgr[i] = ACurve.Evaluate(timeNow); } tgtLocPos = Polar2Cart(tgr); } tgtLocPos *= _Amplitude; }
private void UpdateText() { PXValue pXValue = GetComponentInParent <PXValue>(); float val = pXValue.GetValue(chlId); float dispVal = Utils.MapValue( val, _InputMin, _InputMax, _DispMin, _DispMax); float crT = Utils.MapValue( val, _InputMin, _InputMax, 0, 1); Color crText = _ColorGrad.Evaluate(crT); string Format = "F" + _FracNum.ToString(); string text = dispVal.ToString(Format); TextMesh textMesh = GetComponent <TextMesh>(); textMesh.text = text; textMesh.color = crText; }