@ exported Hermite spline functions for use by plugins

This commit is contained in:
codeimp 2010-01-30 20:46:51 +00:00
parent 90d867db6a
commit 35268f8e3c
2 changed files with 36 additions and 1 deletions

View file

@ -23,6 +23,7 @@ using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
using SlimDX;
using SlimDX.Direct3D9;
using System.Drawing;
using CodeImp.DoomBuilder.Map;
@ -1694,7 +1695,7 @@ namespace CodeImp.DoomBuilder.Geometry
public static void RenumberMarkedTags()
{
Dictionary<int, int> tagsmap = new Dictionary<int, int>();
SlimDX.Vector2.CatmullRom(
// Collect the tag numbers used in the marked geometry
General.Map.Map.ForAllTags(CollectTagNumbersHandler, true, tagsmap);
@ -1751,5 +1752,27 @@ namespace CodeImp.DoomBuilder.Geometry
}
#endregion
#region ================== Misc Exported Functions
/// <summary>
/// This performs a Hermite spline interpolation and returns the result position.
/// Where u (0 - 1) is the wanted position on the curve between p1 (using tangent t1) and p2 (using tangent t2).
/// </summary>
public static Vector2D HermiteSpline(Vector2D p1, Vector2D t1, Vector2D p2, Vector2D t2, float u)
{
return D3DDevice.V2D(Vector2.Hermite(D3DDevice.V2(p1), D3DDevice.V2(t1), D3DDevice.V2(p2), D3DDevice.V2(t2), u));
}
/// <summary>
/// This performs a Hermite spline interpolation and returns the result position.
/// Where u (0 - 1) is the wanted position on the curve between p1 (using tangent t1) and p2 (using tangent t2).
/// </summary>
public static Vector3D HermiteSpline(Vector3D p1, Vector3D t1, Vector3D p2, Vector3D t2, float u)
{
return D3DDevice.V3D(Vector3.Hermite(D3DDevice.V3(p1), D3DDevice.V3(t1), D3DDevice.V3(p2), D3DDevice.V3(t2), u));
}
#endregion
}
}

View file

@ -573,6 +573,18 @@ namespace CodeImp.DoomBuilder.Rendering
return new Vector3D(v3.X, v3.Y, v3.Z);
}
// This makes a Vector2 from Vector2D
public static Vector2 V2(Vector2D v2d)
{
return new Vector2(v2d.x, v2d.y);
}
// This makes a Vector2D from Vector2
public static Vector2D V2D(Vector2 v2)
{
return new Vector2D(v2.X, v2.Y);
}
#endregion
}
}