mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-09 22:32:55 +01:00
max
abd6cc9e9e
MeshCombiner, combine SkinnedMeshRenderers and MeshRenderers into one. AnimationBaker, bake SkinnedMeshRenderer with of animations into vertex animations. Test shader, flipped Y compared to previvious version, it now starts at 0,0 and goes into the positive direciton.
34 lines
725 B
C#
34 lines
725 B
C#
using UnityEngine;
|
|
|
|
namespace TAO.VertexAnimation
|
|
{
|
|
public static class VectorUtils
|
|
{
|
|
public static Vector2 Float3ToFloat2(this Vector3 f3)
|
|
{
|
|
Vector3 rotation = Vector3.Normalize(new Vector3(f3.x, 0, f3.z));
|
|
|
|
Vector2 f2 = new Vector2();
|
|
f2.x = Mathf.Acos(Vector3.Dot(rotation, new Vector3(1, 0, 0))) * Mathf.Sign(f3.z);
|
|
f2.x = ((f2.x / Mathf.PI) + 1) * 0.5f;
|
|
|
|
f2.y = Mathf.Acos(f3.y) / Mathf.PI;
|
|
|
|
f2 *= 15;
|
|
f2.x = Mathf.Round(f2.x);
|
|
f2.y = Mathf.Round(f2.y);
|
|
|
|
return f2;
|
|
}
|
|
|
|
public static float Float2ToFloat(this Vector2 f2)
|
|
{
|
|
return (f2.x + (16 * f2.y)) / 255;
|
|
}
|
|
|
|
public static float Float3ToFloat(this Vector3 f3)
|
|
{
|
|
return Float2ToFloat(Float3ToFloat2(f3));
|
|
}
|
|
}
|
|
} |