1.0.14
NUGET-Changes: + Materials now have a method to draw. That should allow more freedom on how materials can have a effect on the resulting shader. ~ PostProcessEffect.Draw now needs a source ColorAttachment. ~ Added some missing summaries GIT-/SOLUTION-Changes: Remade the folder structure, to something more senseable.
This commit is contained in:
parent
db7f01dca1
commit
89de4258e1
181 changed files with 584 additions and 698 deletions
90
src/renderer/SM.Base/Animation/InterpolationProcess.cs
Normal file
90
src/renderer/SM.Base/Animation/InterpolationProcess.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using OpenTK;
|
||||
using SM.Base.Time;
|
||||
using SM.Base.Types;
|
||||
using SM.Base.Window;
|
||||
|
||||
namespace SM.Base.Animation
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to control the interpolation process.
|
||||
/// </summary>
|
||||
public class InterpolationProcess : Timer
|
||||
{
|
||||
/// <summary>
|
||||
/// The CVector object, that is interpolated.
|
||||
/// </summary>
|
||||
public CVectorBase TargetVector { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// From where the interpolation process started.
|
||||
/// </summary>
|
||||
public Vector4 From { get; }
|
||||
/// <summary>
|
||||
/// To where the interpolation is heading.
|
||||
/// </summary>
|
||||
public Vector4 To { get; }
|
||||
/// <summary>
|
||||
/// The direction towards the <see cref="To"/>
|
||||
/// </summary>
|
||||
public Vector4 Direction { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the interpolation curve.
|
||||
/// </summary>
|
||||
public BezierCurve InterpolationCurve { get; set; }
|
||||
|
||||
internal InterpolationProcess(CVectorBase targetVector, TimeSpan timeSpan, Vector4 from, Vector4 to, BezierCurve interpolationCurve) : base(timeSpan)
|
||||
{
|
||||
TargetVector = targetVector;
|
||||
|
||||
From = from;
|
||||
To = to;
|
||||
InterpolationCurve = interpolationCurve;
|
||||
|
||||
Direction = to - from;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the interpolation process.
|
||||
/// <para>This keeps the state where the interpolation was.</para>
|
||||
/// </summary>
|
||||
public new void Stop()
|
||||
{
|
||||
Stop(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the interplation process.
|
||||
/// </summary>
|
||||
/// <param name="keepState">If true, it will not set the state to the <see cref="To"/> state.</param>
|
||||
public void Stop(bool keepState)
|
||||
{
|
||||
if (Active && !keepState) SetTarget(To);
|
||||
|
||||
base.Stop();
|
||||
|
||||
}
|
||||
|
||||
private protected override void Ticking(UpdateContext context)
|
||||
{
|
||||
base.Ticking(context);
|
||||
|
||||
float posInCurve = InterpolationCurve.CalculatePoint(ElapsedNormalized).Y;
|
||||
Vector4 nextPos = From + (Direction * posInCurve);
|
||||
SetTarget(nextPos);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Stopping(UpdateContext context)
|
||||
{
|
||||
base.Stopping(context);
|
||||
SetTarget(To);
|
||||
}
|
||||
|
||||
private void SetTarget(Vector4 vec)
|
||||
{
|
||||
TargetVector.SetRaw(vec.X, vec.Y, vec.Z, vec.W);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue