Added basic blending and refactored some files

This commit is contained in:
Maximilian Winter
2022-12-10 15:02:53 +01:00
parent ee0fa7a5fa
commit 9f8a7fb7d8
43 changed files with 13583 additions and 345 deletions

View File

@ -3,14 +3,14 @@ using UnityEditor;
namespace TAO.VertexAnimation.Editor
{
[CustomEditor(typeof(VA_AnimationBook))]
public class VA_AnimationBookEditor : UnityEditor.Editor
[CustomEditor(typeof(AnimationBook))]
public class AnimationBookEditor : UnityEditor.Editor
{
private VA_AnimationBook animationBook = null;
private AnimationBook animationBook = null;
void OnEnable()
{
animationBook = target as VA_AnimationBook;
animationBook = target as AnimationBook;
}
public override void OnInspectorGUI()

View File

@ -3,14 +3,14 @@ using UnityEditor;
namespace TAO.VertexAnimation.Editor
{
[CustomEditor(typeof(VA_AnimationLibrary))]
public class VA_AnimationLibraryEditor : UnityEditor.Editor
[CustomEditor(typeof(AnimationLibrary))]
public class AnimationLibraryEditor : UnityEditor.Editor
{
private VA_AnimationLibrary library = null;
private AnimationLibrary library = null;
void OnEnable()
{
library = target as VA_AnimationLibrary;
library = target as AnimationLibrary;
}
public override void OnInspectorGUI()

View File

@ -20,9 +20,9 @@ namespace TAO.VertexAnimation.Editor
parent.AddComponent<LODGroup>();
}
if (!parent.TryGetComponent(out VA_AnimationLibraryComponentAuthoring _))
if (!parent.TryGetComponent(out AnimationLibraryComponentAuthoring _))
{
parent.AddComponent<VA_AnimationLibraryComponentAuthoring>();
parent.AddComponent<AnimationLibraryComponentAuthoring>();
}
//if (!parent.TryGetComponent(out Unity.Entities.ConvertToEntity _))
@ -33,7 +33,7 @@ namespace TAO.VertexAnimation.Editor
else
{
// Create parent.
parent = new GameObject(name, typeof(LODGroup), typeof(VA_AnimationLibraryComponentAuthoring));
parent = new GameObject(name, typeof(LODGroup), typeof(AnimationLibraryComponentAuthoring));
}
// Create all LODs.
@ -65,13 +65,13 @@ namespace TAO.VertexAnimation.Editor
}
else
{
child = new GameObject(childName, typeof(MeshFilter), typeof(MeshRenderer), typeof(VA_AnimationDataComponentAuthoring));
child = new GameObject(childName, typeof(MeshFilter), typeof(MeshRenderer), typeof(AnimationDataComponentAuthoring));
}
}
if (!child.TryGetComponent(out VA_AnimationDataComponentAuthoring ad))
if (!child.TryGetComponent(out AnimationDataComponentAuthoring ad))
{
child.AddComponent<VA_AnimationDataComponentAuthoring>();
child.AddComponent<AnimationDataComponentAuthoring>();
}
if (child.TryGetComponent(out MeshFilter mf))

View File

@ -3,14 +3,14 @@ using UnityEditor;
namespace TAO.VertexAnimation.Editor
{
[CustomEditor(typeof(VA_ModelBaker))]
public class VA_ModelBakerEditor : UnityEditor.Editor
[CustomEditor(typeof(VertexAnimationModelBaker))]
public class VertexAnimationModelBakerEditor : UnityEditor.Editor
{
private VA_ModelBaker modelBaker = null;
private VertexAnimationModelBaker modelBaker = null;
void OnEnable()
{
modelBaker = target as VA_ModelBaker;
modelBaker = target as VertexAnimationModelBaker;
}
public override void OnInspectorGUI()

View File

@ -6,7 +6,7 @@ using UnityEngine.Experimental.Rendering;
namespace TAO.VertexAnimation.Editor
{
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "TAO/VertexAnimation/ModelBaker", order = 400)]
public class VA_ModelBaker : ScriptableObject
public class VertexAnimationModelBaker : ScriptableObject
{
#if UNITY_EDITOR
// Input.
@ -31,8 +31,8 @@ namespace TAO.VertexAnimation.Editor
public Texture2DArray positionMap = null;
public Material material = null;
public Mesh[] meshes = null;
public VA_AnimationBook book = null;
public List<VA_Animation> animations = new List<VA_Animation>();
public AnimationBook book = null;
public List<Animation> animations = new List<Animation>();
[System.Serializable]
public class LODSettings
@ -100,7 +100,7 @@ namespace TAO.VertexAnimation.Editor
target.ConbineAndConvertGameObject(includeInactive);
AnimationBaker.BakedData bakedData = target.Bake(animationClips, applyRootMotion, fps, textureWidth);
positionMap = VA_Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}_PositionMap", name), true);
positionMap = Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}_PositionMap", name), true);
meshes = bakedData.mesh.GenerateLOD(lodSettings.LODCount(), lodSettings.GetQualitySettings());
DestroyImmediate(target);
@ -126,7 +126,9 @@ namespace TAO.VertexAnimation.Editor
}
meshes[i].Finalize();
AssetDatabase.AddObjectToAsset(meshes[i], this);
SerializedObject s = new SerializedObject(meshes[i]);
s.FindProperty("m_IsReadable").boolValue = true;
AssetDatabase.AddObjectToAsset(s.targetObject, this);
}
AssetDatabase.AddObjectToAsset(positionMap, this);
@ -179,12 +181,12 @@ namespace TAO.VertexAnimation.Editor
// Create book.
if (!book)
{
book = CreateInstance<VA_AnimationBook>();
book = CreateInstance<AnimationBook>();
}
book.name = string.Format("{0}_Book", name);
book.positionMap = positionMap;
book.animations = new List<VA_Animation>();
book.animations = new List<Animation>();
book.TryAddMaterial(material);
// Save book.
@ -207,13 +209,13 @@ namespace TAO.VertexAnimation.Editor
VA_AnimationData newData = new VA_AnimationData(animationName, info[i].frames, info[i].maxFrames, info[i].fps, i, -1);
// Either update existing animation or create a new one.
if (TryGetAnimationWithName(animationName, out VA_Animation animation))
if (TryGetAnimationWithName(animationName, out Animation animation))
{
animation.SetData(newData);
}
else
{
animation = CreateInstance<VA_Animation>();
animation = CreateInstance<Animation>();
animation.name = animationName;
animation.SetData(newData);
animations.Add(animation);
@ -229,7 +231,7 @@ namespace TAO.VertexAnimation.Editor
}
}
private bool TryGetAnimationWithName(string name, out VA_Animation animation)
private bool TryGetAnimationWithName(string name, out Animation animation)
{
foreach (var a in animations)
{
@ -269,7 +271,7 @@ namespace TAO.VertexAnimation.Editor
material = null;
meshes = null;
book = null;
animations = new List<VA_Animation>();
animations = new List<Animation>();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();