mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-12 15:35:30 +01:00
GenerateTexture2DArray in ModelBaker
This commit is contained in:
parent
efc5c179e4
commit
e31ddd5631
@ -4,7 +4,7 @@ using UnityEditor;
|
||||
|
||||
namespace TAO.VertexAnimation.Editor
|
||||
{
|
||||
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "VA_ModelBaker/ModelBaker", order = 400)]
|
||||
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "TAO/VertexAnimation/ModelBaker", order = 400)]
|
||||
public class VA_ModelBaker : ScriptableObject
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@ -23,6 +23,7 @@ namespace TAO.VertexAnimation.Editor
|
||||
|
||||
// Output.
|
||||
public GameObject prefab = null;
|
||||
public Texture2DArray positionMap = null;
|
||||
public Material material = null;
|
||||
public Mesh[] meshes = null;
|
||||
public VA_AnimationBook book = null;
|
||||
@ -89,6 +90,8 @@ namespace TAO.VertexAnimation.Editor
|
||||
target.ConbineAndConvertGameObject();
|
||||
bakedData = target.Bake(animationClips, fps, textureWidth);
|
||||
|
||||
positionMap = VA_Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}-PositionMap", name), true);
|
||||
|
||||
if (lodSettings.generate)
|
||||
{
|
||||
meshes = bakedData.mesh.GenerateLOD(lodSettings.LODCount(), lodSettings.GetQualitySettings());
|
||||
@ -105,16 +108,16 @@ namespace TAO.VertexAnimation.Editor
|
||||
{
|
||||
AssetDatabaseUtils.RemoveChildAssets(this, new Object[2] { book, material });
|
||||
|
||||
// TODO: LODs
|
||||
foreach (var m in meshes)
|
||||
{
|
||||
AssetDatabase.AddObjectToAsset(m, this);
|
||||
}
|
||||
|
||||
foreach (var pm in bakedData.positionMaps)
|
||||
{
|
||||
AssetDatabase.AddObjectToAsset(pm, this);
|
||||
}
|
||||
AssetDatabase.AddObjectToAsset(positionMap, this);
|
||||
//foreach (var pm in bakedData.positionMaps)
|
||||
//{
|
||||
// AssetDatabase.AddObjectToAsset(pm, this);
|
||||
//}
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
@ -176,6 +179,9 @@ namespace TAO.VertexAnimation.Editor
|
||||
material.shader = materialShader;
|
||||
}
|
||||
|
||||
material.SetTexture("_PositionMap", positionMap);
|
||||
material.SetInt("_MaxFrames", bakedData.maxFrames);
|
||||
|
||||
// Generate Prefab
|
||||
prefab = AnimationPrefab.Create(path, name, meshes, material, lodSettings.GetTransitionSettings());
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TAO.VertexAnimation.Editor
|
||||
{
|
||||
[CreateAssetMenu(fileName = "new AssetConverter", menuName = "VA_Animation/AssetConverter", order = 400)]
|
||||
public class VA_AssetConverter : ScriptableObject
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55b196764521c964c84e8f2edd5c8da5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -10,6 +10,7 @@ namespace TAO.VertexAnimation
|
||||
{
|
||||
public Mesh mesh;
|
||||
public List<Texture2D> positionMaps;
|
||||
public int maxFrames;
|
||||
|
||||
// Returns main position map.
|
||||
public Texture2D GetPositionMap
|
||||
@ -84,6 +85,7 @@ namespace TAO.VertexAnimation
|
||||
BakedData bd = Bake(model, ac, animationInfo);
|
||||
bakedData.mesh = bd.mesh;
|
||||
bakedData.positionMaps.AddRange(bd.positionMaps);
|
||||
bakedData.maxFrames = maxFrames;
|
||||
}
|
||||
|
||||
return bakedData;
|
||||
@ -106,7 +108,8 @@ namespace TAO.VertexAnimation
|
||||
BakedData bakedData = new BakedData()
|
||||
{
|
||||
mesh = mesh,
|
||||
positionMaps = new List<Texture2D>() { BakePositionMap(model, animationClip, animationInfo) }
|
||||
positionMaps = new List<Texture2D>() { BakePositionMap(model, animationClip, animationInfo) },
|
||||
maxFrames = animationInfo.maxFrames
|
||||
};
|
||||
|
||||
return bakedData;
|
||||
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
[CreateAssetMenu(fileName = "new AnimationBook", menuName = "VA_Animation/AnimationBook", order = 400)]
|
||||
[CreateAssetMenu(fileName = "new AnimationBook", menuName = "TAO/VertexAnimation/AnimationBook", order = 400)]
|
||||
public class VA_AnimationBook : ScriptableObject
|
||||
{
|
||||
public PlayData playData = null;
|
||||
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "VA_Animation/AnimationLibrary", order = 400)]
|
||||
[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "TAO/VertexAnimation/AnimationLibrary", order = 400)]
|
||||
public class VA_AnimationLibrary : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -5,7 +5,7 @@ namespace TAO.VertexAnimation
|
||||
public static class VA_Texture2DArrayUtils
|
||||
{
|
||||
public static Texture2DArray CreateTextureArray(Texture2D[] a_textures, bool a_useMipChain, bool a_isLinear,
|
||||
TextureWrapMode a_wrapMode = TextureWrapMode.Repeat, FilterMode a_filterMode = FilterMode.Bilinear, int a_anisoLevel = 1, string a_name = "")
|
||||
TextureWrapMode a_wrapMode = TextureWrapMode.Repeat, FilterMode a_filterMode = FilterMode.Bilinear, int a_anisoLevel = 1, string a_name = "", bool a_makeNoLongerReadable = true)
|
||||
{
|
||||
if(!IsValidForTextureArray(a_textures) || !IsValidCopyTexturePlatform())
|
||||
{
|
||||
@ -27,7 +27,7 @@ namespace TAO.VertexAnimation
|
||||
textureArray.anisoLevel = a_anisoLevel;
|
||||
textureArray.name = a_name;
|
||||
|
||||
textureArray.Apply(false, false);
|
||||
textureArray.Apply(false, a_makeNoLongerReadable);
|
||||
|
||||
return textureArray;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user