mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-12-04 01:05:34 +01:00
Interpolation
Smooth animations :)
This commit is contained in:
parent
c928f6daae
commit
f7fc4434d5
@ -45,6 +45,9 @@ namespace TAO.VertexAnimation.Editor
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("materialShader"), new GUIContent(""));
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("useNormalA"), new GUIContent("Use Normal (A)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("useInterpolation"));
|
||||
|
||||
if (GUILayout.Button("Bake", GUILayout.Height(32)))
|
||||
{
|
||||
modelBaker.Bake();
|
||||
|
@ -22,6 +22,8 @@ namespace TAO.VertexAnimation.Editor
|
||||
public bool generateAnimationBook = true;
|
||||
public bool generatePrefab = true;
|
||||
public Shader materialShader = null;
|
||||
public bool useInterpolation = true;
|
||||
public bool useNormalA = true;
|
||||
|
||||
// Output.
|
||||
public GameObject prefab = null;
|
||||
@ -153,6 +155,24 @@ namespace TAO.VertexAnimation.Editor
|
||||
material.SetTexture("_PositionMap", positionMap);
|
||||
material.SetInt("_MaxFrames", bakedData.maxFrames);
|
||||
|
||||
if (useNormalA)
|
||||
{
|
||||
material.EnableKeyword("USE_NORMALA_ON");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword("USE_NORMALA_ON");
|
||||
}
|
||||
|
||||
if(useInterpolation)
|
||||
{
|
||||
material.EnableKeyword("USE_INTERPOLATION_ON");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword("USE_INTERPOLATION_ON");
|
||||
}
|
||||
|
||||
// Generate Prefab
|
||||
prefab = AnimationPrefab.Create(path, name, meshes, material, lodSettings.GetTransitionSettings());
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ namespace TAO.VertexAnimation
|
||||
public struct VA_AnimatorComponent : IComponentData
|
||||
{
|
||||
public int animationIndex;
|
||||
// TODO: Animation blending.
|
||||
//public int animationIndexSchedule;
|
||||
public int animationIndexNext;
|
||||
public float animationTime;
|
||||
public BlobAssetReference<VA_AnimationLibraryData> animationLibrary;
|
||||
}
|
||||
@ -38,7 +37,7 @@ namespace TAO.VertexAnimation
|
||||
VA_AnimatorComponent animatorComponent = new VA_AnimatorComponent
|
||||
{
|
||||
animationIndex = 0,
|
||||
//animationIndexSchedule = -1,
|
||||
animationIndexNext = -1,
|
||||
animationTime = 0,
|
||||
animationLibrary = animLib
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Transforms;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
@ -21,14 +22,31 @@ namespace TAO.VertexAnimation
|
||||
// Get the animation lib data.
|
||||
ref VA_AnimationLibraryData animationsRef = ref ac.animationLibrary.Value;
|
||||
|
||||
// Lerp animations.
|
||||
// Set animation for lerp.
|
||||
int animationIndexNext = ac.animationIndexNext;
|
||||
if (ac.animationIndexNext < 0)
|
||||
{
|
||||
animationIndexNext = ac.animationIndex;
|
||||
}
|
||||
|
||||
// Calculate next frame time for lerp.
|
||||
float animationTimeNext = ac.animationTime + (1.0f / animationsRef.animations[animationIndexNext].maxFrames);
|
||||
if (animationTimeNext > animationsRef.animations[animationIndexNext].duration)
|
||||
{
|
||||
// Set time. Using the difference to smooth out animations when looping.
|
||||
animationTimeNext -= ac.animationTime;
|
||||
}
|
||||
|
||||
// Set material data.
|
||||
animationData[child] = new VA_AnimationDataComponent
|
||||
{
|
||||
Value = new float4
|
||||
{
|
||||
x = ac.animationTime,
|
||||
y = VA_AnimationLibraryUtils.GetAnimationMapIndex(ref animationsRef, ac.animationIndex),
|
||||
z = VA_AnimationLibraryUtils.GetColorMapIndex(ref animationsRef, ac.animationIndex),
|
||||
w = 0
|
||||
z = animationTimeNext,
|
||||
w = VA_AnimationLibraryUtils.GetAnimationMapIndex(ref animationsRef, animationIndexNext)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
8
Tests/Runtime/Scripts.meta
Normal file
8
Tests/Runtime/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc1ccacb918e10a43bc1d707ec935205
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user