2020-12-10 19:51:02 +01:00
|
|
|
|
using Unity.Entities;
|
|
|
|
|
using Unity.Collections;
|
|
|
|
|
|
|
|
|
|
namespace TAO.VertexAnimation
|
|
|
|
|
{
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public struct VA_AnimationData
|
|
|
|
|
{
|
2021-01-19 16:35:37 +01:00
|
|
|
|
public VA_AnimationData(FixedString64 a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1)
|
2021-01-19 01:18:25 +01:00
|
|
|
|
{
|
|
|
|
|
name = a_name;
|
|
|
|
|
frames = a_frames;
|
|
|
|
|
maxFrames = a_maxFrames;
|
|
|
|
|
animationMapIndex = a_positionMapIndex;
|
|
|
|
|
colorMapIndex = a_colorMapIndex;
|
|
|
|
|
frameTime = 1.0f / a_maxFrames * a_fps;
|
|
|
|
|
duration = 1.0f / a_maxFrames * (a_frames - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 20:27:44 +01:00
|
|
|
|
// The name of the animation.
|
2021-01-19 16:35:37 +01:00
|
|
|
|
public FixedString64 name;
|
2020-12-14 20:27:44 +01:00
|
|
|
|
// The frames in this animation.
|
2020-12-10 19:51:02 +01:00
|
|
|
|
public int frames;
|
2020-12-14 20:27:44 +01:00
|
|
|
|
// The maximum of frames the texture holds.
|
2020-12-10 19:51:02 +01:00
|
|
|
|
public int maxFrames;
|
2020-12-14 20:27:44 +01:00
|
|
|
|
// The index of the related animation texture.
|
|
|
|
|
public int animationMapIndex;
|
|
|
|
|
// The index of the related color textures if/when added.
|
|
|
|
|
public int colorMapIndex;
|
2021-01-19 01:18:25 +01:00
|
|
|
|
// Time of a single frame.
|
|
|
|
|
public float frameTime;
|
|
|
|
|
// Total time of the animation.
|
|
|
|
|
public float duration;
|
2020-12-10 19:51:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct VA_AnimationLibraryData
|
|
|
|
|
{
|
|
|
|
|
public BlobArray<VA_AnimationData> animations;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 00:45:25 +01:00
|
|
|
|
public static class VA_AnimationLibraryUtils
|
2020-12-10 19:51:02 +01:00
|
|
|
|
{
|
2020-12-16 11:59:22 +01:00
|
|
|
|
public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary";
|
|
|
|
|
|
2021-01-19 16:35:37 +01:00
|
|
|
|
public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64 animationName)
|
2021-01-14 00:45:25 +01:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < animationsRef.animations.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (animationsRef.animations[i].name == animationName)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-10 19:51:02 +01:00
|
|
|
|
|
2021-01-14 00:45:25 +01:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2020-12-14 20:27:44 +01:00
|
|
|
|
|
2021-01-14 00:45:25 +01:00
|
|
|
|
public static int GetAnimationMapIndex(ref VA_AnimationLibraryData animationsRef, int animation)
|
2020-12-14 20:27:44 +01:00
|
|
|
|
{
|
2021-01-14 00:45:25 +01:00
|
|
|
|
return animationsRef.animations[animation].animationMapIndex;
|
|
|
|
|
}
|
2020-12-14 20:27:44 +01:00
|
|
|
|
|
|
|
|
|
public static int GetColorMapIndex(ref VA_AnimationLibraryData animationsRef, int animation)
|
|
|
|
|
{
|
|
|
|
|
return animationsRef.animations[animation].colorMapIndex;
|
|
|
|
|
}
|
2020-12-10 19:51:02 +01:00
|
|
|
|
}
|
|
|
|
|
}
|