2012-08-09 09:45:04 +00:00
|
|
|
using System;
|
2012-10-13 09:09:27 +00:00
|
|
|
using ANX.Framework.NonXNA.Development;
|
2011-11-15 21:37:26 +00:00
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-11-15 21:37:26 +00:00
|
|
|
|
|
|
|
namespace ANX.Framework
|
|
|
|
{
|
2012-10-13 09:09:27 +00:00
|
|
|
[PercentageComplete(100)]
|
2012-10-13 21:36:46 +00:00
|
|
|
[Developer("floAr, Glatzemann")]
|
2012-10-13 20:40:50 +00:00
|
|
|
[TestState(TestStateAttribute.TestState.Tested)]
|
2011-11-15 21:37:26 +00:00
|
|
|
public class CurveKey : IEquatable<CurveKey>, IComparable<CurveKey>
|
|
|
|
{
|
|
|
|
#region Public
|
2012-10-13 20:40:50 +00:00
|
|
|
public float Position { get; private set; }
|
|
|
|
public float Value { get; set; }
|
|
|
|
public float TangentIn { get; set; }
|
|
|
|
public float TangentOut { get; set; }
|
|
|
|
public CurveContinuity Continuity { get; set; }
|
|
|
|
#endregion
|
2011-11-15 21:37:26 +00:00
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
public CurveKey(float position, float value)
|
|
|
|
: this(position, value, 0f, 0f, CurveContinuity.Smooth)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-13 20:40:50 +00:00
|
|
|
public CurveKey(float position, float value, float tangentIn, float tangentOut)
|
2011-11-15 21:37:26 +00:00
|
|
|
: this(position, value, tangentIn, tangentOut, CurveContinuity.Smooth)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-13 20:40:50 +00:00
|
|
|
public CurveKey(float position, float value, float tangentIn, float tangentOut, CurveContinuity continuity)
|
2011-11-15 21:37:26 +00:00
|
|
|
{
|
|
|
|
Position = position;
|
|
|
|
Value = value;
|
|
|
|
TangentIn = tangentIn;
|
|
|
|
TangentOut = tangentOut;
|
|
|
|
Continuity = continuity;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Clone
|
|
|
|
public CurveKey Clone()
|
|
|
|
{
|
|
|
|
return new CurveKey(Position, Value, TangentIn, TangentOut, Continuity);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Equals
|
2011-11-20 13:42:00 +00:00
|
|
|
public bool Equals(CurveKey other)
|
|
|
|
{
|
2011-11-21 06:22:29 +00:00
|
|
|
if (other != null)
|
2011-11-20 13:42:00 +00:00
|
|
|
{
|
|
|
|
return other.Position == Position &&
|
|
|
|
other.Value == Value &&
|
|
|
|
other.TangentIn == TangentIn &&
|
|
|
|
other.TangentOut == TangentOut &&
|
|
|
|
other.Continuity == Continuity;
|
|
|
|
}
|
2011-11-21 06:22:29 +00:00
|
|
|
|
|
|
|
return false;
|
2011-11-20 13:42:00 +00:00
|
|
|
}
|
2011-11-15 21:37:26 +00:00
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
2012-10-13 20:40:50 +00:00
|
|
|
return obj is CurveKey && this == (CurveKey)obj;
|
2011-11-15 21:37:26 +00:00
|
|
|
}
|
2012-10-13 20:40:50 +00:00
|
|
|
#endregion
|
2011-11-15 21:37:26 +00:00
|
|
|
|
|
|
|
#region GetHashCode
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
return Position.GetHashCode() + Value.GetHashCode() +
|
|
|
|
TangentIn.GetHashCode() + TangentOut.GetHashCode() +
|
|
|
|
Continuity.GetHashCode();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Equality
|
|
|
|
public static bool operator ==(CurveKey a, CurveKey b)
|
|
|
|
{
|
2011-11-22 11:59:35 +00:00
|
|
|
if (null == a as Object)
|
|
|
|
return null == b as Object;
|
|
|
|
|
|
|
|
if (null == b as Object)
|
2012-10-13 20:40:50 +00:00
|
|
|
return false;
|
2011-11-22 11:59:35 +00:00
|
|
|
|
2011-11-21 07:44:02 +00:00
|
|
|
return a.Position == b.Position &&
|
|
|
|
a.Value == b.Value &&
|
|
|
|
a.TangentIn == b.TangentIn &&
|
|
|
|
a.TangentOut == b.TangentOut &&
|
|
|
|
a.Continuity == b.Continuity;
|
|
|
|
}
|
2011-11-15 21:37:26 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Inequality
|
|
|
|
public static bool operator !=(CurveKey a, CurveKey b)
|
|
|
|
{
|
2011-11-22 11:59:35 +00:00
|
|
|
if (null == a as Object)
|
|
|
|
return null != b as Object;
|
|
|
|
|
|
|
|
if (null == b as Object)
|
2012-10-13 20:40:50 +00:00
|
|
|
return true;
|
2011-11-22 11:59:35 +00:00
|
|
|
|
2011-11-21 07:44:02 +00:00
|
|
|
return a.Position != b.Position ||
|
|
|
|
a.Value != b.Value ||
|
|
|
|
a.TangentIn != b.TangentIn ||
|
|
|
|
a.TangentOut != b.TangentOut ||
|
|
|
|
a.Continuity != b.Continuity;
|
2011-11-15 21:37:26 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region CompareTo
|
2012-10-13 20:40:50 +00:00
|
|
|
public int CompareTo(CurveKey other)
|
|
|
|
{
|
|
|
|
if (Position == other.Position)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return Position >= other.Position ? 1 : -1;
|
|
|
|
}
|
|
|
|
#endregion
|
2011-11-15 21:37:26 +00:00
|
|
|
}
|
|
|
|
}
|