/// <summary>Translate, Rotate, Scale. Creates a transform Matrix using all these components!</summary> /// <param name="translation">Move an object by this amount.</param> /// <param name="rotation">A Quaternion describing the rotation for this transform.</param> /// <param name="scale">How much larger or smaller this transform makes things. 1 is a good /// default, as 0 will shrink it to nothing! This will expand to a scale vector of (size, size, size)</param> /// <returns>A Matrix that combines translation, roatation, and scale information into a single Matrix!</returns> public static Matrix TRS(Vec3 translation, Quat rotation, float scale = 1) => NativeAPI.matrix_trs(translation, rotation, new Vec3(scale, scale, scale));
public static Quat Lerp(Quat a, Quat b, float lerp) => NativeAPI.quat_lerp(a, b, lerp);
/// <summary>Basic initialization constructor! Just copies in the provided values directly.</summary> /// <param name="x">X location of the pose.</param> /// <param name="y">Y location of the pose.</param> /// <param name="z">Z location of the pose.</param> /// <param name="orientation">Orientation of the pose, stored as a rotation from Vec3.Forward.</param> public Pose(float x, float y, float z, Quat orientation) { this.position = new Vec3(x, y, z); this.orientation = orientation; }
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern Vec3 quat_mul_vec(ref Quat a, ref Vec3 b);
public static Quat Difference(Quat a, Quat b) => NativeAPI.quat_difference(a, b);
public HandJoint(Vec3 position, Quat orientation, float radius) { this.position = position; this.orientation = orientation; this.radius = radius; }
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern Quat quat_normalize(ref Quat a);
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern void solid_teleport(IntPtr solid, ref Vec3 position, ref Quat rotation);
/////////////////////////////////////////// [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern Quat quat_difference(ref Quat a, ref Quat b);
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern void transform_set_rotation(IntPtr transform, ref Quat rotation);
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr solid_create(ref Vec3 position, ref Quat rotation, SolidType type = SolidType.Normal);
/// <summary>Interpolates between two poses! t is unclamped, so values outside of (0,1) will /// extrapolate their position.</summary> /// <param name="a">Starting pose, or percent == 0</param> /// <param name="b">Ending pose, or percent == 1</param> /// <param name="percent">A value usually 0->1 that tells the blend between a and b.</param> /// <returns>A new pose, blended between a and b based on percent!</returns> public static Pose Lerp(Pose a, Pose b, float percent) => new Pose(Vec3.Lerp(a.position, b.position, percent), Quat.Slerp(a.orientation, b.orientation, percent));
public void Teleport(Vec3 position, Quat rotation) { NativeAPI.solid_teleport(_solidInst, position, rotation); }
public void Move(Vec3 position, Quat rotation) { NativeAPI.solid_move(_solidInst, position, rotation); }
/// <summary>Translate, Rotate, Scale. Creates a transform Matrix using all these components!</summary> /// <param name="translation">Move an object by this amount.</param> /// <param name="rotation">A Quaternion describing the rotation for this transform.</param> /// <param name="scale">How much larger or smaller this transform makes things. Vec3.One is a good /// default, as Vec3.Zero will shrink it to nothing!</param> /// <returns>A Matrix that combines translation, roatation, and scale information into a single Matrix!</returns> public static Matrix TRS(Vec3 translation, Quat rotation, Vec3 scale) => NativeAPI.matrix_trs(translation, rotation, scale);
[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern Quat quat_lerp(ref Quat a, ref Quat b, float t);
public Pose(Vec3 position, Quat orientation) { this.position = position; this.orientation = orientation; }
public static Quat Slerp(Quat a, Quat b, float slerp) => NativeAPI.quat_slerp(a, b, slerp);