protected virtual void OnGUICurve(ref Rect contentRect, Interpolator dummyInstance, AnimationCurveUtility.TangentMode mode = AnimationCurveUtility.TangentMode.Smooth) { if (null == dummyInstance) { return; } var count = 100; var keyFrames = new Keyframe[count]; for (int n = 0; n < count; ++n) { var t = n / (float)(count - 1); var k = new Keyframe(t, dummyInstance.Interpolate(t)); keyFrames[n] = k; } var curve = new AnimationCurve(keyFrames); AnimationCurveUtility.SetLinear(ref curve, mode); contentRect.height = InterpolatorPropertyDrawer.heightCurve; EditorGUI.CurveField(contentRect, curve); contentRect.y += InterpolatorPropertyDrawer.heightCurve; }
public FloatPropertyAnimation(ReactiveObject obj, string property, int duration, float start, float end, Interpolator interpolator) : base(obj, duration, property) { _interpolator = interpolator; _start = start; _end = end; }
public static IEnumerator AnimateValue(float from, float to, float duration, Interpolator interpolator, OnAnimationUpdateObj oau, object o) { float startTime = Time.time; while (Time.time - startTime <= duration) { float value; if (interpolator != null) { value = (from + (to - from) * interpolator((Time.time - startTime) / duration)); } else { value = (from + (to - from) * ((Time.time - startTime) / duration)); } if (oau != null) { oau(value, o); } yield return(new WaitForEndOfFrame()); } if (oau != null) { oau(to, o); } }
/// <summary>Creates a new <see cref="VectorInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation, or <c>null</c>.</param> /// <param name="toValue">The ending value of the animation, or <c>null</c>.</param> /// <param name="isAdditive">Indicates whether the interpolation is additive.</param> /// <param name="isCumulative">Indicates whether the interpolation is cumulative.</param> public VectorInterpolation(Interpolator interpolator, Vector? fromValue, Vector? toValue, bool isAdditive, bool isCumulative) : this() { Interpolator = interpolator; if (fromValue.HasValue) base.From = fromValue.Value; else if (isAdditive) base.From = new Vector(); if (toValue.HasValue) base.To = toValue.Value; else if (isAdditive) base.To = new Vector(); base.IsAdditive = isAdditive; base.IsCumulative = isCumulative; }
protected virtual void Start() { cubeArray = new List <GameObject>(); cubeArray.Add(cube1); cubeArray.Add(cube2); cubeArray.Add(cube3); cubeArray.Add(cube4); cubeArray.Add(cube5); cubeArray.Add(cube6); cubeArray.Add(cube7); Debug.Log("Is Being Placed on start" + IsBeingPlaced.ToString()); if (PlaceParentOnTap) { ParentGameObjectToPlace = GetParentToPlace(); PlaceParentOnTap = ParentGameObjectToPlace != null; } interpolator = EnsureInterpolator(); if (IsBeingPlaced) { StartPlacing(); } else // If we are not starting out with actively placing the object, give it a World Anchor { AttachWorldAnchor(); } }
public void ShowSqlCreator() { if (_appConfig.GetCredentialsRequired == AppConfig.CredentialsRequired.None || _appConfig.User != null) { var sqlCreator = new SqlCreatorView(_appConfig, _workbookPropertiesConfig); DialogResult result = sqlCreator.ShowDialog(); if (result == DialogResult.OK) { _workbookPropertiesConfig = sqlCreator.WorkbookPropertiesConfig; var queries = new Dictionary <string, DataTable>(); queries = sqlCreator.SQLResult; // add main query to dict //if (_workbookPropertiesConfig.LastMainQuery != null) //{ var dbConnection = new DatabaseConnectionFactory().CreateDbConnection(_appConfig.DatabaseType, _appConfig.ConnectionString); foreach (KeyValuePair <string, string> query in _workbookPropertiesConfig.AdditionalQueriesAsDictionary()) { // create interpolator object var interpolator = new Interpolator(); // test if string needs interpolation var needsInterpolation = interpolator.SetFormattable(query.Value).SetCriteria(_workbookPropertiesConfig.LastMainQuery.Criteria).NeedsInterpolation(); // if no, then use sql to query against database and add results to queries dict if (!needsInterpolation) { try { queries.Add(query.Key, dbConnection.Query(query.Value)); } catch { MessageBox.Show($"{query.Key} did not run successfully", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // if yes, then interpolate try { var interpolatedQuery = interpolator.Interpolate(); queries.Add(query.Key, dbConnection.Query(interpolatedQuery)); } catch { MessageBox.Show($"{query.Key} did not run successfully", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } //} _presenter.PasteQueriesIntoExcel(queries); } } else { LogIn(); } }
private void Start() { contentVolume = TransitionManager.Instance.ViewVolume; volumeTightTagalong = contentVolume.GetComponent <TightTagalong>(); volumeTightTagalong.FollowMotionControllerIfAvailable = true; volumeInterpolator = contentVolume.GetComponent <Interpolator>(); }
void Start() { interpolator = gameObject.GetComponent <Interpolator>(); interpolator.SmoothLerpToTarget = true; interpolator.SmoothPositionLerpRatio = SmoothingFactor; mainCamera = Camera.main; }
public static void ExampleInterpolatorUse() { Interpolator interpolator = Interpolator.CreateInterpolator(Slerp, Arch2); //Creates interpolation (first Slerp T then use it to create arch2) interpolator = Interpolator.CreateInterpolator(Flip, Slerp //Normal Interpolation Delegate , (float time) => SmoothStart(time, 1) //Sometimes you need to use anonymous functions.(GOD BLESS C#) ); //Creates interpolation (first Slerp T then use it to plug a SmoothStartCurve) Interpolator test = Interpolator.CreateInterpolator(Flip, Flip); for (int i = 0; i < 10000; i++) { float t = i / 10000f; float ff = test.Interpolate(t); } test = Interpolator.CreateInterpolator(Flip); for (int i = 0; i < 10000; i++) { float t = i / 10000f; float hh = interpolator.Interpolate(t); } }
///<summary> ///</summary> ///<param name="term"></param> ///<param name="strike"></param> ///<returns></returns> public double GetValueByExpiryTermAndStrike(string term, double strike) { var expiryTerm = PeriodHelper.Parse(term).ToYearFraction(); IPoint point = new Point2D(expiryTerm, strike); return(Interpolator.Value(point)); }
/// <summary>Creates a new <see cref="IGridPointCurve<TLabel>"/> object with respect to specified interpolation and extrapolation approaches. /// </summary> /// <param name="curveInterpolator">The curve interpolator.</param> /// <param name="leftExtrapolator">The extrapolator on the left side, i.e. from the first grid point to -\infinity.</param> /// <param name="rightExtrapolator">The extrapolator on the right side, i.e. from the last grid point to \infinity.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> /// <returns>A <see cref="IGridPointCurve{TLabel}"/> object with respect to the desired interpolation and extrapolation approaches.</returns> public static IGridPointCurve <double> Create(Interpolator curveInterpolator, Extrapolator leftExtrapolator, Extrapolator rightExtrapolator, int capacity = 20) { if (curveInterpolator == null) { throw new ArgumentException(nameof(curveInterpolator)); } var interpolator = curveInterpolator.Create(); if (leftExtrapolator == null) { throw new ArgumentNullException(nameof(leftExtrapolator)); } if (leftExtrapolator.ExtrapolationBuildingDirection != Extrapolator.BuildingDirection.FromFirstGridPoint) { throw new ArgumentException("Wrong building direction of curve extrapolation", "leftExtrapolator"); } var left = leftExtrapolator.Create(interpolator); if (rightExtrapolator == null) { throw new ArgumentNullException(nameof(rightExtrapolator)); } var right = rightExtrapolator.Create(interpolator); if (rightExtrapolator.ExtrapolationBuildingDirection != Extrapolator.BuildingDirection.FromLastGridPoint) { throw new ArgumentException("Wrong building direction of curve extrapolation", "rightExtrapolation"); } if ((interpolator is IDifferentiableRealValuedCurve) && (left is IDifferentiableRealValuedCurve) && (right is IDifferentiableRealValuedCurve)) { return(new StandardGridPointCurveNoLabels.Differentiable(curveInterpolator, interpolator, leftExtrapolator, left, rightExtrapolator, right, capacity)); } return(new StandardGridPointCurveNoLabels(curveInterpolator, interpolator, leftExtrapolator, left, rightExtrapolator, right, capacity)); }
public SegmentedLinearIntent(TypeOfValue startValue, TypeOfValue endValue, TimeSpan timeSpan, Interpolator <TypeOfValue> interpolator = null) : this(startValue, endValue, timeSpan) { interpolator = interpolator ?? Interpolator.Interpolator.Create <TypeOfValue>(); _segments = new LinearInterpolatedIntentSegmentCollection <TypeOfValue>(startValue, endValue, timeSpan, interpolator); }
/// <summary>Creates a new <see cref="PointInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation, or <c>null</c>.</param> /// <param name="toValue">The ending value of the animation, or <c>null</c>.</param> /// <param name="isAdditive">Indicates whether the interpolation is additive.</param> /// <param name="isCumulative">Indicates whether the interpolation is cumulative.</param> public PointInterpolation(Interpolator interpolator, Point? fromValue, Point? toValue, bool isAdditive, bool isCumulative) : this() { Interpolator = interpolator; if (fromValue.HasValue) base.From = fromValue.Value; else if (isAdditive) base.From = new Point(); if (toValue.HasValue) base.To = toValue.Value; else if (isAdditive) base.To = new Point(); base.IsAdditive = isAdditive; base.IsCumulative = isCumulative; }
protected virtual void Start() { if (PlaceParentOnTap) { ParentGameObjectToPlace = GetParentToPlace(); PlaceParentOnTap = ParentGameObjectToPlace != null; } interpolator = EnsureInterpolator(); if (IsBeingPlaced) { StartPlacing(); } else //Si le reset des Anchors est actif, on détruit l'Anchor, sinon on l'attache à l'objet { if (Config.Instance.FetchBoolFromConfig("resetAnchorOnLaunch")) { if (!Config.Instance.GetBool("resetAnchorOnLaunch")) { AttachWorldAnchor(); } else { WorldAnchorManager.Instance.RemoveAnchor(gameObject.name); } } } }
protected virtual void Start() { // 必要なコンポーネントがすべてシーンにあるか確認する if (WorldAnchorManager.Instance == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } if (WorldAnchorManager.Instance != null) { // オブジェクトの設置で開始する場合でなければ, World Anchorを置いてください if (!IsBeingPlaced) { WorldAnchorManager.Instance.AttachAnchor(gameObject, SavedAnchorFriendlyName); } } DetermineParent(); interpolator = PlaceParentOnTap ? ParentGameObjectToPlace.EnsureComponent <Interpolator>() : gameObject.EnsureComponent <Interpolator>(); if (IsBeingPlaced) { HandlePlacement(); } }
private void WriteCameraInterpolator(BinaryWriter writer, Interpolator interpolator) { writer.Write((((byte)Math.Round(interpolator.ax * 127) + 0x80) ^ 0x80) & 0xFF); writer.Write((((byte)Math.Round(interpolator.bx * 127) + 0x80) ^ 0x80) & 0xFF); writer.Write((((byte)Math.Round(interpolator.ay * 127) + 0x80) ^ 0x80) & 0xFF); writer.Write((((byte)Math.Round(interpolator.by * 127) + 0x80) ^ 0x80) & 0xFF); }
public void MultipleInterpolatorTypes() { Interpolator <float> lerpFloat = Interpolators <float> .Linear; Interpolator <double> lerpDouble = Interpolators <double> .Linear; var floats = new float[] { 0.0f, 1.0f }; var doubles = new double[] { 0.0, 1.0 }; InterpolatorSource <float> floatWindow = (i) => { return(ref floats[i]); }; InterpolatorSource <double> doubleWindow = (i) => { return(ref doubles[i]); }; Assert.AreEqual( 0.5f, lerpFloat(floatWindow, 0, 0.5f) ); Assert.AreEqual( 0.5, lerpDouble(doubleWindow, 0, 0.5f) ); }
public PositionAnimator( Interpolator interpolator, Position begin, Position end, PropertyAccessor.PositionAccessor propertyAccessor) : base(interpolator) { if (interpolator == null) { this.interpolator = new ScheduledInterpolator(10000); } if (begin == null || end == null) { string message = Logging.getMessage("nullValue.PositionIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (propertyAccessor == null) { string message = Logging.getMessage("nullValue.ViewPropertyAccessorIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } this.begin = begin; this.end = end; this.propertyAccessor = propertyAccessor; }
public Vector3Interpolator(InterpolationType interpolationType, EasingType easingType, Vector3 startValue, Vector3 deltaValue, float duration) { this.duration = duration; this.x = makeInterpolator(interpolationType, easingType, startValue.x, deltaValue.x, duration); this.y = makeInterpolator(interpolationType, easingType, startValue.y, deltaValue.y, duration); this.z = makeInterpolator(interpolationType, easingType, startValue.z, deltaValue.z, duration); }
public static bool SetEnabled(Interpolator interpolator) { HashSet <Interpolator> interpolators; HashSet <Interpolator> interpolators1; if (!Interpolator.Interpolators.iterating) { return(((!Interpolator.Interpolators.swapped ? Interpolator.Interpolators.hashset1 : Interpolator.Interpolators.hashset2)).Add(interpolator)); } if (Interpolator.Interpolators.caughtIterating) { return(((!Interpolator.Interpolators.swapped ? Interpolator.Interpolators.hashset2 : Interpolator.Interpolators.hashset1)).Add(interpolator)); } if (!Interpolator.Interpolators.swapped) { interpolators = Interpolator.Interpolators.hashset1; interpolators1 = Interpolator.Interpolators.hashset2; } else { interpolators = Interpolator.Interpolators.hashset2; interpolators1 = Interpolator.Interpolators.hashset1; } if (interpolators.Contains(interpolator)) { return(false); } Interpolator.Interpolators.caughtIterating = true; interpolators1.UnionWith(interpolators); return(interpolators1.Add(interpolator)); }
public void should_return_abscissa_of_interpolated_regular_point_linear() { SortedDictionary <double, double> mainPoints = new SortedDictionary <double, double> { { 0.25, 1 }, { 0.5, 3 }, { 0.75, 4 }, { 1, 9 }, { 1.25, 10 }, { 1.5, 16 }, { 2, 18 }, }; double x = 0.37; double expectedY = 1.96; double x1 = 0.25; try { double y = Interpolator.PointLinearInterpolation(mainPoints, x); double y1 = Interpolator.PointLinearInterpolation(mainPoints, x1); Assert.IsTrue(y.Equals(expectedY)); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
public void should_interpolate_whole_curve_by_step() { double step = 0.25; SortedDictionary <double, double> interpolatedDictionary = Interpolator.CurveLinearSmoothing(dict, step); Assert.IsTrue(interpolatedDictionary[1.25].Equals(12.5) && interpolatedDictionary[1.75].Equals(17)); }
public double[] GetPhase(double[] symmetryPulse, Complex[] correspondSpectrum) { if (_interpolator == null || _phaseArray == null) { _interpolator = new Interpolator(_centerHalfWidth * 2, symmetryPulse.Length); _phaseArray = new double[symmetryPulse.Length / 2]; } // extract central portion var centerBurst = symmetryPulse.Length / 2; var centralPulse = _centerRealContainer; Array.Copy(symmetryPulse, centerBurst - _centerHalfWidth, centralPulse, 0, _centerHalfWidth * 2); // apodize & rotate _apodizer.Apodize(centralPulse); _rotator.Rotate(centralPulse); // fft _centerRealContainer.ToComplex(_centerComplexContainer); Fourier.Forward(_centerComplexContainer, FourierOptions.Matlab); // get phase from spectrum var complexSpectrum = _centerComplexContainer; for (var i = 0; i < _centerRealContainer.Length; i++) { _centerRealContainer[i] = _complexToPhaseFunc(complexSpectrum[i]); } // interpolate into full length _interpolator.Interpolate(_centerRealContainer, _phaseArray); return(_phaseArray); }
protected override void OnUpdate() { float progressRatio = Timer.ProgressRatio; m_transform.Position = new Vector2(Interpolator.GetInterpolation(m_startPos.X, m_target.X, progressRatio), Interpolator.GetInterpolation(m_startPos.Y, m_target.Y, progressRatio)); }
public NotifierMessage(String message, double startTime, Interpolator fadeOut) { Message = message; StartTime = startTime; FadeOutInterpolator = fadeOut; StartFadeOut = false; }
public void FadeToBlue() { RedInterpolator = new Interpolator(RedInterpolator.CurrentValue, ColorFade.BlueTargetRed, REMEMBERDURATION - REMEMBERCLIMAX); GreenInterpolator = new Interpolator(GreenInterpolator.CurrentValue, ColorFade.BlueTargetGreen, REMEMBERDURATION - REMEMBERCLIMAX); BlueInterpolator = new Interpolator(BlueInterpolator.CurrentValue, ColorFade.BlueTargetBlue, RECOVERDURATION + REMEMBERDURATION - REMEMBERCLIMAX); new Timer(RECOVERDURATION + REMEMBERDURATION - REMEMBERCLIMAX, FadeToNone); }
/// <summary> /// Performs an animated iteration through the wrapped collection's /// elements. /// </summary> /// /// <param name="action"> /// the action to perform for every iteration through the collection. /// </param> /// <param name="duration"> /// the number of milliseconds that the animation should last. /// </param> /// <param name="interpolator"> /// the interpolation function that should be used for the animation. /// </param> public void ForEach(IterationAction action, long duration, Interpolator interpolator) { // Perform an animation that will animate through // all of the indices in the collection. var lastIndex = this.Collection.Count() - 1; var indexAnimation = new ValueAnimation(0, lastIndex, duration, interpolator); // Every time the index animation is iterated, iterate the // "loop" and perform the action for every item up to the // current index. int i = 0; indexAnimation.AnimationIncremented += (_, __) => { while (i <= indexAnimation.CurrentValue) { var element = this.Collection.ElementAt(i); action(element, i); i++; } }; // Add the index animation to the list of animations being // performed. this.AddAnimation(indexAnimation); // Start the animation. indexAnimation.Start(); }
public void TestInterpolation() { { var one = new OuterComponent { @float = new FloatProperty(1.0f), vector = new VectorProperty(Vector3.one) }; var two = new OuterComponent { @float = new FloatProperty(2.0f), vector = new VectorProperty(Vector3.zero) }; var interpolated = new OuterComponent(); Interpolator.InterpolateInto(one, two, interpolated, 0.5f); Assert.AreEqual(1.5f, [email protected], 1e-6f); Assert.AreEqual(new Vector3(0.5f, 0.5f, 0.5f), interpolated.vector.Value); } { var one = new CyclicComponent { @float = new FloatProperty(0.9f) }; var two = new CyclicComponent { @float = new FloatProperty(0.3f) }; var interpolated = new CyclicComponent(); Interpolator.InterpolateInto(one, two, interpolated, 0.5f); Assert.AreEqual(0.1f, [email protected], 1e-6f); } }
/// <summary>Creates a new <see cref="ThicknessInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation, or <c>null</c>.</param> /// <param name="toValue">The ending value of the animation, or <c>null</c>.</param> /// <param name="isAdditive">Indicates whether the interpolation is additive.</param> /// <param name="isCumulative">Indicates whether the interpolation is cumulative.</param> public ThicknessInterpolation(Interpolator interpolator, Thickness? fromValue, Thickness? toValue, bool isAdditive, bool isCumulative) : this() { Interpolator = interpolator; if (fromValue.HasValue) base.From = fromValue.Value; else if (isAdditive) base.From = new Thickness(); if (toValue.HasValue) base.To = toValue.Value; else if (isAdditive) base.To = new Thickness(); base.IsAdditive = isAdditive; base.IsCumulative = isCumulative; }
/// <summary>Creates a new <see cref="DoubleInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation, or <c>null</c>.</param> /// <param name="toValue">The ending value of the animation, or <c>null</c>.</param> /// <param name="isAdditive">Indicates whether the interpolation is additive.</param> /// <param name="isCumulative">Indicates whether the interpolation is cumulative.</param> public DoubleInterpolation(Interpolator interpolator, double? fromValue, double? toValue, bool isAdditive, bool isCumulative) : this() { Interpolator = interpolator; if (fromValue.HasValue) base.From = fromValue.Value; else if (isAdditive) base.From = 0.0; if (toValue.HasValue) base.To = toValue.Value; else if (isAdditive) base.To = 0.0; base.IsAdditive = isAdditive; base.IsCumulative = isCumulative; }
public static Interpolator2D CreateInterpolator2D(this STFReader stf) { List <double> xlist = new List <double>(); List <Interpolator> ilist = new List <Interpolator>(); stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { xlist.Add(stf.ReadFloat(STFReader.Units.Any, null)); ilist.Add(stf.CreateInterpolator()); } stf.SkipRestOfBlock(); int n = xlist.Count; if (n < 2) { STFException.TraceWarning(stf, "Interpolator must have at least two x values."); } double[] xArray = new double[n]; Interpolator[] yArray = new Interpolator[n]; for (int i = 0; i < n; i++) { xArray[i] = xlist[i]; yArray[i] = ilist[i]; if (i > 0 && xArray[i - 1] >= xArray[i]) { STFException.TraceWarning(stf, " Interpolator x values must be increasing."); } } return(new Interpolator2D(xArray, yArray)); }
public Interpolator<float> Initialize(InterpolatedFloat interpolated, bool useThreshold = false) { m_interpolator = new Interpolator<float>(interpolated, useThreshold); m_interpolated = interpolated; m_initialized = true; return m_interpolator; }
private static void InterpolationComparison() { string filepath = "D:/Users/yrmal/Desktop/doublegyro"; double voxelSize = 0.25; InputDataSet ids = new InputDataSet(filepath, voxelSize, null); double xMax = 2; double yMax = 1; double step = 0.01; Point[,] matrix = new Point[(int)(xMax / step), (int)(yMax / step)]; for (int x = 0; x < xMax / step; x++) { for (int y = 0; y < yMax / step; y++) { matrix[x, y] = Interpolator <Point> .NNInterpolatePoint(new Vector3((float)(x * step), (float)(y * step), 0), ids.GetPoints()); } } int pointSize = sizeof(float) * 6; byte[] serialized = new byte[matrix.Length * pointSize]; int i = 0; foreach (Point p in matrix) { if (p != null) { Array.Copy(p.Serialize(), 0, serialized, i * pointSize, pointSize); } i++; } using (FileStream fileStream = new FileStream("./NN.dat", FileMode.Create)) { fileStream.Write(serialized, 0, serialized.Length); } for (int x = 0; x < xMax / step; x++) { for (int y = 0; y < yMax / step; y++) { matrix[x, y] = ids.GetPoint(new Vector3((float)(x * step), (float)(y * step), 0)); } } serialized = new byte[matrix.Length * pointSize]; i = 0; foreach (Point p in matrix) { if (p != null) { Array.Copy(p.Serialize(), 0, serialized, i * pointSize, pointSize); } i++; } using (FileStream fileStream = new FileStream("./IDW.dat", FileMode.Create)) { fileStream.Write(serialized, 0, serialized.Length); } }
protected virtual void Start() { // Make sure we have all the components in the scene we need. if (WorldAnchorManager.Instance == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } if (WorldAnchorManager.Instance != null) { // If we are not starting out with actively placing the object, give it a World Anchor if (!IsBeingPlaced) { WorldAnchorManager.Instance.AttachAnchor(gameObject, SavedAnchorFriendlyName); } } DetermineParent(); interpolator = PlaceParentOnTap ? ParentGameObjectToPlace.EnsureComponent <Interpolator>() : gameObject.EnsureComponent <Interpolator>(); if (IsBeingPlaced) { HandlePlacement(); } }
public void Update(float seconds) { if (!_isTransitioning) { return; } _transitionCurrentTime += seconds; _fraction = _transitionCurrentTime / _transitionTotalTime; if (_fraction >= 1.0f) { _fraction = 1.0f; _isTransitioning = false; } _current.SingleColour = Interpolator.Interpolate(_previous.SingleColour, _target.SingleColour, ref _fraction); _current.Negative = Interpolator.Interpolate(_previous.Negative, _target.Negative, ref _fraction); _current.Colourise = Interpolator.Interpolate(_previous.Colourise, _target.Colourise, ref _fraction); _current.GrayScale = Interpolator.Interpolate(_previous.GrayScale, _target.GrayScale, ref _fraction); _current.Opacity = Interpolator.Interpolate(_previous.Opacity, _target.Opacity, ref _fraction); _current.ColourForSingleColourAndColourise = Interpolator.Interpolate(_previous.ColourForSingleColourAndColourise, _target.ColourForSingleColourAndColourise, ref _fraction); _current.BackgroundClearColour = Interpolator.Interpolate(_previous.BackgroundClearColour, _target.BackgroundClearColour, ref _fraction); _current.ClearBackground = _fraction == 1.0f ? _target.ClearBackground : _previous.ClearBackground; UpdateBufferAndClearColour(); }
private void Initialize() { this.GetComponent<Renderer>().material = new Material(this.GetComponent<Renderer>().material); this.fade = new Interpolator<float>(0.0f, 1.0f, Mathf.Lerp); if (this.StartVisible == true) this.fade.ForceMax(); else this.fade.ForceMin(); }
void Start() { // Clone all of the materials foreach (Transform child in WallGroup) child.GetComponent<Renderer>().material = new Material(child.GetComponent<Renderer>().material); this.fade = new Interpolator<float>(0.0f, 1.0f, Mathf.Lerp); this.fade.ForceMax(); }
void Start() { animator = GetComponent<Animator>(); component = GetComponent<CharAnimEffComp>(); resultantInterpolator = new Interpolator<CharAnimEffComp.NetworkResultantState>( useInterpolation, interpolatorBackTime, CharAnimEffComp.NetworkResultantState.Interpolate, useExtrapolation, interpolatorExTime, CharAnimEffComp.NetworkResultantState.Extrapolate); }
void Start() { this.start = this.Door.transform.localPosition; this.target = new Vector3( this.Door.transform.localPosition.x + this.OpenXOffset, this.Door.transform.localPosition.y, this.Door.transform.localPosition.z); this.interpolator = new Interpolator<Vector3>(start, target, Vector3.Lerp); if (this.Door.GetComponent<Renderer>() != null) this.Door.GetComponent<Renderer>().material = new Material(this.Door.GetComponent<Renderer>().material); }
public DeltaProgressBar() : base() { lossGraphic = new StretchingImageGraphic { Texture = new TextureConcretizer { TextureDescription = new Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(200, System.Drawing.Color.Red)) } }; gainGraphic = new StretchingImageGraphic { Texture = new TextureConcretizer { TextureDescription = new Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(255, 0, 225, 0)) } }; lossInterpolator = new Interpolator(); gainInterpolator = new Interpolator(); GainInterpolateTime = 1f; LossInterpolateTime = 0.5f; Updateable = true; }
void Start() { component = GetComponent<CharPosEffComp>(); moveDirInterpolator = new Interpolator<CharPosEffComp.NetworkMoveDirection>( useInterpolation, interpolatorBackTime, CharPosEffComp.NetworkMoveDirection.Interpolate, useExtrapolation, interpolatorExTime, CharPosEffComp.NetworkMoveDirection.Extrapolate); resultantInterpolator = new Interpolator<CharPosEffComp.NetworkResultant>( useInterpolation, interpolatorBackTime, CharPosEffComp.NetworkResultant.Interpolate, useExtrapolation, interpolatorExTime, CharPosEffComp.NetworkResultant.Extrapolate); }
private float weight; // Current weight public LookAtIKController( CrossfadeLookAtIK lookAt, float bodyWeightMax, float bodyWeightDelay) { this.lookAt = lookAt; this.targetInterp = new Interpolator<Vector3>( Vector3.zero, Vector3.zero, Vector3.Lerp); this.weightInterp = new Interpolator<float>( 0.0f, 1.0f, Mathf.Lerp); this.controlInterp = new Interpolator<float>( 0.0f, bodyWeightMax, Mathf.Lerp); this.controlInterp.ForceMax(); }
private void MakePlayersFromBytes(byte[] data) { for (int x = 0; x < data.Length; x += 26) { var xPosition = BitConverter.ToSingle(data, x + 0); var yPosition = BitConverter.ToSingle(data, x + 4); var xSpeed = BitConverter.ToSingle(data, x + 8); var ySpeed = BitConverter.ToSingle(data, x + 12); PositionBehavior thisData = new PositionBehavior(xPosition, yPosition, xSpeed, ySpeed); var id = BitConverter.ToInt32(data, x + 16); var packetNumber = BitConverter.ToInt32(data, x + 20); if (id != this.id) { if (!otherPlayers.ContainsKey(id)) { var newObject = Instantiate(anotherPlayer); newObject.SetActive(true); var newInterpolator = new Interpolator(thisData); otherPlayers[id] = newObject; interpolators[id] = newInterpolator; LatestUpdate[id] = packetNumber; shouldDeleteOld[id] = 100; } else if (LatestUpdate[id] < packetNumber) { LatestUpdate[id] = packetNumber; shouldDeleteOld[id] = 100; interpolators[id].CalculateNewInterpolation(thisData); otherPlayers[id].GetComponent<Rigidbody>().position = interpolators[id].PositionAfterTime(0); } } } }
/// <summary>Creates a new <see cref="ThicknessInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> public ThicknessInterpolation(Interpolator interpolator) : this() { Interpolator = interpolator; }
private void Start() { contentVolume = TransitionManager.Instance.ViewVolume; volumeTightTagalong = contentVolume.GetComponent<TightTagalong>(); volumeInterpolator = contentVolume.GetComponent<Interpolator>(); }
/// <summary> /// Starts a nudge towards a desired position /// </summary> public void NavNudgeStop() { this.nudge = null; this.NavSetOrientationBehavior(OrientationBehavior.LookForward); }
private void Awake() { interpolator = GetComponent<Interpolator>(); }
public Tweener Fn(Interpolator fn) { int n = values.Length; for (int i = 0; i < n; ++i) values[i].fn = fn; return this; }
/// <summary>Creates a new <see cref="ThicknessInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation.</param> /// <param name="toValue">The ending value of the animation.</param> /// <param name="duration">The duration of the animation.</param> public ThicknessInterpolation(Interpolator interpolator, Thickness fromValue, Thickness toValue, Duration duration) : this() { Interpolator = interpolator; base.From = fromValue; base.To = toValue; base.Duration = duration; }
private IEnumerable<RunStatus> SnapToTarget( Vector3 position, Vector3 target, float time) { Interpolator<Vector3> interp = new Interpolator<Vector3>( position, target, Vector3.Lerp); interp.ForceMin(); interp.ToMax(time); while (interp.State != InterpolationState.Max) { transform.position = interp.Value; yield return RunStatus.Running; } yield return RunStatus.Success; yield break; }
/// <summary>Creates a new <see cref="DoubleInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> public DoubleInterpolation(Interpolator interpolator) : this() { Interpolator = interpolator; }
/// <summary>Creates a new <see cref="DoubleInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="duration">The duration of the animation.</param> public DoubleInterpolation(Interpolator interpolator, Duration duration) : this() { Interpolator = interpolator; base.Duration = duration; }
public Tweener fnAlpha(Interpolator fn) { values[5].fn = fn; return this; }
public Tweener fnRot(Interpolator fn) { values[4].fn = fn; return this; }
/// <summary> /// Starts a nudge towards a desired position /// </summary> public void NavNudge(Vector3 target, float time) { this.NavSetOrientationBehavior(OrientationBehavior.None); this.nudge = new Interpolator<Vector3>( transform.position, target, Vector3.Lerp); this.nudge.ForceMin(); this.nudge.ToMax(time); }
public Tweener fnY(Interpolator fn) { values[1].fn = fn; return this; }
public Animation() { interpolator = "linear"; _interpolator = new LinearInterpolator(); }
/// <summary>Creates a new <see cref="ThicknessInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="duration">The duration of the animation.</param> public ThicknessInterpolation(Interpolator interpolator, Duration duration) : this() { Interpolator = interpolator; base.Duration = duration; }
private void Awake() { tightTagalong = GetComponent<TightTagalong>(); interpolator = GetComponent<Interpolator>(); }
/// <summary>Creates a new <see cref="DoubleInterpolation"/> instance with the specified parameters.</summary> /// <param name="interpolator">The interpolation function.</param> /// <param name="fromValue">The starting value of the animation.</param> /// <param name="toValue">The ending value of the animation.</param> /// <param name="duration">The duration of the animation.</param> public DoubleInterpolation(Interpolator interpolator, double fromValue, double toValue, Duration duration) : this() { Interpolator = interpolator; base.From = fromValue; base.To = toValue; base.Duration = duration; }