add Physics support
This commit is contained in:
@@ -124,11 +124,11 @@ public class CameraOrbit : MonoBehaviour
|
||||
Camera.main.fieldOfView = OrbitCamFovSlider.value;
|
||||
Vector3 position = transform.position;
|
||||
|
||||
if (Input.GetMouseButtonDown(0) && !eventSystem.IsPointerOverGameObject())
|
||||
if (Input.GetMouseButtonDown(2) && !eventSystem.IsPointerOverGameObject())
|
||||
{
|
||||
controlOn = true;
|
||||
}
|
||||
if (Input.GetMouseButton(0) && controlOn)
|
||||
if (Input.GetMouseButton(2) && controlOn)
|
||||
{
|
||||
position -= Input.GetAxis("Mouse X") * transform.right * OrbitCamSpeedSlider.value;
|
||||
OrbitCamZoomSlider.value -= Input.mouseScrollDelta.y * OrbitCamZoomSpeedSlider.value;
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
|
||||
class SelectAllOfTag : ScriptableWizard
|
||||
{
|
||||
//此函数可将无法读写的Tex克隆成一份可读写的Tex,用于提取图片至png
|
||||
Texture2D duplicateTexture(Texture2D source)
|
||||
{
|
||||
RenderTexture renderTex = RenderTexture.GetTemporary(
|
||||
source.width,
|
||||
source.height,
|
||||
0,
|
||||
RenderTextureFormat.Default,
|
||||
RenderTextureReadWrite.Linear);
|
||||
|
||||
Graphics.Blit(source, renderTex);
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
RenderTexture.active = renderTex;
|
||||
Texture2D readableText = new Texture2D(source.width, source.height);
|
||||
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
|
||||
readableText.Apply();
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(renderTex);
|
||||
return readableText;
|
||||
}
|
||||
|
||||
[MenuItem("Model/Get Select Model")]
|
||||
static void CreateWindow()
|
||||
{
|
||||
ScriptableWizard.DisplayWizard(
|
||||
"Get Select Model",
|
||||
typeof(SelectAllOfTag),
|
||||
"Start!");
|
||||
}
|
||||
|
||||
void OnWizardCreate()
|
||||
{
|
||||
|
||||
Debug.Log(Selection.objects[0]);
|
||||
|
||||
GameObject gameobj = (GameObject)Selection.objects[0];
|
||||
|
||||
if (!AssetDatabase.IsValidFolder("Assets/Model"))
|
||||
{
|
||||
AssetDatabase.CreateFolder("Assets", "Model");
|
||||
}
|
||||
|
||||
string folder_name = "Assets/Model/" + gameobj.name;
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(folder_name))
|
||||
{
|
||||
AssetDatabase.CreateFolder("Assets/Model", gameobj.name);
|
||||
}
|
||||
|
||||
foreach (SkinnedMeshRenderer skin_mesh in gameobj.transform.GetComponentsInChildren<SkinnedMeshRenderer>())
|
||||
{
|
||||
//提取所有Mesh至文件夹
|
||||
Mesh m = skin_mesh.sharedMesh;
|
||||
|
||||
string m_parent = folder_name + "/Mesh";
|
||||
string m_path = folder_name + "/Mesh/" + m.name + ".mesh";
|
||||
if (!AssetDatabase.IsValidFolder(m_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Mesh");
|
||||
}
|
||||
|
||||
Debug.Log(m.name);
|
||||
Debug.Log(AssetDatabase.IsValidFolder(m_parent));
|
||||
AssetDatabase.RemoveObjectFromAsset(m);
|
||||
AssetDatabase.CreateAsset(m, folder_name + "/Mesh/" + m.name + ".mesh");
|
||||
|
||||
//创建Texture2D文件夹
|
||||
string tex_parent = folder_name + "/Texture2D";
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(tex_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Texture2D");
|
||||
}
|
||||
|
||||
//创建Material文件夹
|
||||
string mat_parent = folder_name + "/Material";
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(mat_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Material");
|
||||
}
|
||||
|
||||
foreach (Material mat in skin_mesh.sharedMaterials)
|
||||
{
|
||||
|
||||
JArray p_name_list = new JArray();
|
||||
JArray tex_name_list = new JArray();
|
||||
|
||||
//获得材质的所有属性名,如果改属性名对应的是贴图,提取该贴图
|
||||
Shader mat_shader = mat.shader;
|
||||
int p_num = mat_shader.GetPropertyCount();
|
||||
Debug.Log(p_num);
|
||||
for (int i = 0; i < p_num; i++)
|
||||
{
|
||||
//Debug.Log(mat_shader.GetPropertyName(i));
|
||||
//Debug.Log(mat_shader.GetPropertyType(i));
|
||||
string p_name = mat_shader.GetPropertyName(i);
|
||||
if (mat_shader.GetPropertyType(i) == UnityEngine.Rendering.ShaderPropertyType.Texture)
|
||||
{
|
||||
//Debug.Log("Hello!");
|
||||
Debug.Log(p_name);
|
||||
Texture2D mat_texture = (Texture2D)mat.GetTexture(p_name);
|
||||
if (mat_texture)
|
||||
{
|
||||
//Debug.Log("There is a Name!");
|
||||
string tex_name = mat_texture.name;
|
||||
string tex_path = folder_name + "/Texture2D/" + tex_name + ".png";
|
||||
if (!File.Exists(tex_path))
|
||||
{
|
||||
mat_texture = duplicateTexture(mat_texture);
|
||||
byte[] bytes = mat_texture.EncodeToPNG();
|
||||
File.WriteAllBytes(tex_path, bytes);
|
||||
}
|
||||
//记忆图片与属性名之间的关联
|
||||
p_name_list.Add(new JValue(p_name));
|
||||
tex_name_list.Add(new JValue(tex_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//提取材质
|
||||
AssetDatabase.RemoveObjectFromAsset(mat);
|
||||
AssetDatabase.CreateAsset(mat, folder_name + "/Material/" + mat.name + ".mat");
|
||||
|
||||
//刷新资源,将所有提取出来的图片载入Assets
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
//将图片附加进材质
|
||||
for (int i = 0; i < p_name_list.Count; i++)
|
||||
{
|
||||
Debug.Log(p_name_list[i]);
|
||||
Debug.Log(tex_name_list[i]);
|
||||
mat.SetTexture(p_name_list[i].ToString(), (Texture2D)AssetDatabase.LoadAssetAtPath(tex_name_list[i].ToString(), typeof(Texture2D)));
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MeshFilter mf in gameobj.transform.GetComponentsInChildren<MeshFilter>())
|
||||
{
|
||||
//提取所有Mesh至文件夹
|
||||
Mesh m = mf.sharedMesh;
|
||||
|
||||
string m_parent = folder_name + "/Mesh";
|
||||
string m_path = folder_name + "/Mesh/" + m.name + ".mesh";
|
||||
if (!AssetDatabase.IsValidFolder(m_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Mesh");
|
||||
}
|
||||
|
||||
Debug.Log(m.name);
|
||||
Debug.Log(AssetDatabase.IsValidFolder(m_parent));
|
||||
AssetDatabase.RemoveObjectFromAsset(m);
|
||||
AssetDatabase.CreateAsset(m, folder_name + "/Mesh/" + m.name + ".mesh");
|
||||
}
|
||||
|
||||
foreach (MeshRenderer mr in gameobj.transform.GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
//创建Texture2D文件夹
|
||||
string tex_parent = folder_name + "/Texture2D";
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(tex_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Texture2D");
|
||||
}
|
||||
|
||||
//创建Material文件夹
|
||||
string mat_parent = folder_name + "/Material";
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(mat_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Material");
|
||||
}
|
||||
|
||||
foreach (Material mat in mr.sharedMaterials)
|
||||
{
|
||||
|
||||
JArray p_name_list = new JArray();
|
||||
JArray tex_name_list = new JArray();
|
||||
|
||||
//获得材质的所有属性名,如果改属性名对应的是贴图,提取该贴图
|
||||
Shader mat_shader = mat.shader;
|
||||
int p_num = mat_shader.GetPropertyCount();
|
||||
Debug.Log(p_num);
|
||||
for (int i = 0; i < p_num; i++)
|
||||
{
|
||||
//Debug.Log(mat_shader.GetPropertyName(i));
|
||||
//Debug.Log(mat_shader.GetPropertyType(i));
|
||||
string p_name = mat_shader.GetPropertyName(i);
|
||||
if (mat_shader.GetPropertyType(i) == UnityEngine.Rendering.ShaderPropertyType.Texture)
|
||||
{
|
||||
//Debug.Log("Hello!");
|
||||
Debug.Log(p_name);
|
||||
Texture2D mat_texture = (Texture2D)mat.GetTexture(p_name);
|
||||
if (mat_texture)
|
||||
{
|
||||
//Debug.Log("There is a Name!");
|
||||
string tex_name = mat_texture.name;
|
||||
string tex_path = folder_name + "/Texture2D/" + tex_name + ".png";
|
||||
if (!File.Exists(tex_path))
|
||||
{
|
||||
mat_texture = duplicateTexture(mat_texture);
|
||||
byte[] bytes = mat_texture.EncodeToPNG();
|
||||
File.WriteAllBytes(tex_path, bytes);
|
||||
}
|
||||
//记忆图片与属性名之间的关联
|
||||
p_name_list.Add(new JValue(p_name));
|
||||
tex_name_list.Add(new JValue(tex_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//提取材质
|
||||
AssetDatabase.RemoveObjectFromAsset(mat);
|
||||
AssetDatabase.CreateAsset(mat, folder_name + "/Material/" + mat.name + ".mat");
|
||||
|
||||
//刷新资源,将所有提取出来的图片载入Assets
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
//将图片附加进材质
|
||||
for (int i = 0; i < p_name_list.Count; i++)
|
||||
{
|
||||
Debug.Log(p_name_list[i]);
|
||||
Debug.Log(tex_name_list[i]);
|
||||
mat.SetTexture(p_name_list[i].ToString(), (Texture2D)AssetDatabase.LoadAssetAtPath(tex_name_list[i].ToString(), typeof(Texture2D)));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Animator anim in gameobj.transform.GetComponentsInChildren<Animator>())
|
||||
{
|
||||
//提取所有Avatar至文件夹
|
||||
Avatar av = anim.avatar;
|
||||
|
||||
string av_parent = folder_name + "/Avatar";
|
||||
string av_path = folder_name + "/Avatar/" + av.name + ".asset";
|
||||
if (!AssetDatabase.IsValidFolder(av_parent))
|
||||
{
|
||||
AssetDatabase.CreateFolder(folder_name, "Avatar");
|
||||
}
|
||||
|
||||
Debug.Log(av.name);
|
||||
Debug.Log(AssetDatabase.IsValidFolder(av_parent));
|
||||
AssetDatabase.RemoveObjectFromAsset(av);
|
||||
AssetDatabase.CreateAsset(av, folder_name + "/Avatar/" + av.name + ".asset");
|
||||
}
|
||||
|
||||
//提取预制体
|
||||
PrefabUtility.SaveAsPrefabAsset(gameobj, folder_name + "/" + gameobj.name + ".prefab");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f45bcbff6c596104888b02292eba909a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,6 @@
|
||||
using Gallop;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RootMotion.Dynamics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -15,7 +16,8 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
[Header("Face")]
|
||||
public List<AnimationClip> FacialClips = new List<AnimationClip>();
|
||||
public List<FaceDrivenKeyTarget> FaceDrivenKeyTargets = new List<FaceDrivenKeyTarget>();
|
||||
public FaceDrivenKeyTarget FaceDrivenKeyTargets;
|
||||
|
||||
|
||||
[Header("Generic")]
|
||||
public bool IsGeneric = false;
|
||||
@@ -32,7 +34,6 @@ public class UmaContainer : MonoBehaviour
|
||||
public List<GameObject> Heads = new List<GameObject>();
|
||||
public List<Transform> HeadNeckBones = new List<Transform>();
|
||||
public List<Transform> HeadHeadBones = new List<Transform>();
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (Body != null && Heads.Count > 0)
|
||||
@@ -66,6 +67,11 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
if (TryGetComponent<PuppetMaster>(out PuppetMaster t))
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
else { Destroy(gameObject); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class UmaViewerBuilder : MonoBehaviour
|
||||
@@ -129,18 +130,33 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
//Load Body
|
||||
RecursiveLoadAsset(asset);
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00")&& asset1.Name.Contains("bust"+ bust) )
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
RecursiveLoadAsset(asset);
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{id}_{costumeId}/pfb_chr{id}_{costumeId}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == head);
|
||||
|
||||
bool isDefaultHead = false;
|
||||
//Some costumes don't have custom heads
|
||||
if (costumeId != "00" && asset == null)
|
||||
{
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == UmaDatabaseController.HeadPath + $"chr{id}_00/pfb_chr{id}_00");
|
||||
isDefaultHead = true;
|
||||
}
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Hair Textures
|
||||
@@ -150,6 +166,24 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
//Load Head
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
if (isDefaultHead)
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{id}_00/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{id}_{costumeId}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int tailId = (int)charaData["tailModelId"];
|
||||
@@ -166,12 +200,19 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{tailPath}clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("no tail");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadMiniUma(int id, string costumeId)
|
||||
@@ -327,8 +368,9 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
foreach (string name in bundle.GetAllAssetNames())
|
||||
{
|
||||
object asset = bundle.LoadAsset(name);
|
||||
|
||||
if (asset == null) { continue; }
|
||||
Debug.Log(bundle.name + "/" + name + $" ({asset.GetType()})");
|
||||
Debug.Log("##"+bundle.name + "/" + name + $" ({asset.GetType()})");
|
||||
Type aType = asset.GetType();
|
||||
if (aType == typeof(AnimationClip))
|
||||
{
|
||||
@@ -347,7 +389,23 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
else if (aType == typeof(GameObject))
|
||||
{
|
||||
if (bundle.name.Contains("/head/"))
|
||||
if (bundle.name.Contains("cloth"))
|
||||
{
|
||||
if (bundle.name.Contains("chr"))
|
||||
{
|
||||
GameObject head = Instantiate(asset as GameObject, CurrentContainer.Heads[0].transform);
|
||||
}
|
||||
else if(bundle.name.Contains("bdy"))
|
||||
{
|
||||
GameObject head = Instantiate(asset as GameObject, CurrentContainer.Body.transform);
|
||||
}
|
||||
else if (bundle.name.Contains("tail"))
|
||||
{
|
||||
GameObject head = Instantiate(asset as GameObject, CurrentContainer.Tail.transform);
|
||||
}
|
||||
|
||||
}
|
||||
else if (bundle.name.Contains("/head/"))
|
||||
{
|
||||
LoadHead(asset as GameObject);
|
||||
}
|
||||
@@ -395,7 +453,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentContainer.Body = Instantiate(go, CurrentContainer.transform);
|
||||
CurrentContainer.UmaAnimator = CurrentContainer.Body.GetComponent<Animator>();
|
||||
CurrentContainer.UmaAnimator.runtimeAnimatorController = CurrentContainer.OverrideController = Instantiate(OverrideController);
|
||||
|
||||
|
||||
if (CurrentContainer.IsGeneric)
|
||||
{
|
||||
List<Texture2D> textures = CurrentContainer.GenericBodyTextures;
|
||||
@@ -413,6 +471,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
string mainTex = "", toonMap = "", tripleMap = "", optionMap = "";
|
||||
if (CurrentContainer.IsMini)
|
||||
{
|
||||
|
||||
m.SetTexture("_MainTex", textures[0]);
|
||||
}
|
||||
else
|
||||
@@ -469,6 +528,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name == tripleMap));
|
||||
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name == optionMap));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,6 +548,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LoadHead(GameObject go)
|
||||
{
|
||||
GameObject head = Instantiate(go, CurrentContainer.transform);
|
||||
@@ -495,6 +556,17 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentContainer.HeadNeckBones.Add(UmaContainer.FindBoneInChildren(head.transform, "Neck"));
|
||||
CurrentContainer.HeadHeadBones.Add(UmaContainer.FindBoneInChildren(head.transform, "Head"));
|
||||
|
||||
var FaceDriven = head.GetComponent<AssetHolder>()._assetTable.list.Find(
|
||||
a => { return a.Key == "facial_target"; }
|
||||
).Value as FaceDrivenKeyTarget;
|
||||
|
||||
var newFaceDriven = head.AddComponent<FaceDrivenKeyTarget>();
|
||||
newFaceDriven._eyebrowTarget = FaceDriven._eyebrowTarget;
|
||||
newFaceDriven._eyeTarget = FaceDriven._eyeTarget;
|
||||
newFaceDriven._mouthTarget = FaceDriven._mouthTarget;
|
||||
CurrentContainer.FaceDrivenKeyTargets = newFaceDriven;
|
||||
|
||||
|
||||
foreach (Renderer r in head.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
foreach (Material m in r.sharedMaterials)
|
||||
|
||||
@@ -7,16 +7,25 @@ public class UmaViewerDownload : MonoBehaviour
|
||||
{
|
||||
public static IEnumerator DownloadText(string url, System.Action<string> callback)
|
||||
{
|
||||
UnityWebRequest www = UnityWebRequest.Get(url);
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
if (www.result != UnityWebRequest.Result.Success)
|
||||
if (PlayerPrefs.GetString(url, "")=="")
|
||||
{
|
||||
Debug.Log(www.error);
|
||||
UnityWebRequest www = UnityWebRequest.Get(url);
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
if (www.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.Log(www.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetString(url, www.downloadHandler.text);
|
||||
callback(www.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
callback(www.downloadHandler.text);
|
||||
callback(PlayerPrefs.GetString(url, ""));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class UmaViewerMain : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 30;
|
||||
Application.targetFrameRate = -1;
|
||||
Instance = this;
|
||||
AbList = UmaDatabaseController.Instance.MetaEntries.ToList();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Gallop
|
||||
{
|
||||
public class AssetHolder : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private AssetTable _assetTable;
|
||||
[SerializeField] public AssetTable _assetTable;
|
||||
[SerializeField] private AssetTableValue _assetTableValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gallop
|
||||
{
|
||||
public class CySpringDataContainer:MonoBehaviour
|
||||
{
|
||||
public List<CySpringCollisionData> collisionParam;
|
||||
public List<CySpringParamDataElement> springParam;
|
||||
public List<ConnectedBoneData> ConnectedBoneList;
|
||||
public bool enableVerticalWind;
|
||||
public bool enableHorizontalWind;
|
||||
public float centerWindAngleSlow;
|
||||
public float centerWindAngleFast;
|
||||
public float verticalCycleSlow;
|
||||
public float horizontalCycleSlow;
|
||||
public float verticalAngleWidthSlow;
|
||||
public float horizontalAngleWidthSlow;
|
||||
public float verticalCycleFast;
|
||||
public float horizontalCycleFast;
|
||||
public float verticalAngleWidthFast;
|
||||
public float horizontalAngleWidthFast;
|
||||
public bool IsEnableHipMoveParam;
|
||||
public float HipMoveInfluenceDistance;
|
||||
public float HipMoveInfluenceMaxDistance;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetPhysics();
|
||||
}
|
||||
public void SetPhysics()
|
||||
{
|
||||
List<Transform> gameObjects = new List<Transform>();
|
||||
gameObjects.AddRange(transform.parent.GetComponentsInChildren<Transform>());
|
||||
|
||||
foreach (CySpringParamDataElement spring in springParam)
|
||||
{
|
||||
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
||||
if (bone)
|
||||
{
|
||||
var dynamic = bone.gameObject.AddComponent<DynamicBone>();
|
||||
dynamic.m_Root = bone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fe5648789d7c474ea19357a222413fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,8 +4,10 @@ using UnityEngine;
|
||||
|
||||
namespace Gallop
|
||||
{
|
||||
|
||||
public class DrivenKeyTarget : MonoBehaviour
|
||||
{
|
||||
|
||||
public List<TargetInfomation> _targetFaces { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6ba56ede2604dd4082ed2d0b4f435dd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21a42390d25252341a66bc19a8addaea
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 902c84bf971339c459ce4b757e333a55
|
||||
DefaultImporter:
|
||||
userData:
|
||||
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Demo1Settings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 50
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 0
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dd7bdf003c8b3944b71a7cc678a8079
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class DynamicBoneDemo1 : MonoBehaviour
|
||||
{
|
||||
public GameObject m_Player;
|
||||
float m_weight = 1;
|
||||
float m_sleepTime;
|
||||
|
||||
void Update()
|
||||
{
|
||||
m_Player.transform.Rotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.deltaTime * 200, 0));
|
||||
m_Player.transform.Translate(transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * 4);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
float x = 50;
|
||||
float y = 50;
|
||||
float w1 = 100;
|
||||
float w2 = 200;
|
||||
float h = 24;
|
||||
|
||||
GUI.Label(new Rect(x, y, w2, h), "Press arrow key to move");
|
||||
Animation a = m_Player.GetComponentInChildren<Animation>();
|
||||
y += h;
|
||||
a.enabled = GUI.Toggle(new Rect(x, y, w2, h), a.enabled, "Play Animation");
|
||||
|
||||
y += h * 2;
|
||||
DynamicBone[] dbs = m_Player.GetComponents<DynamicBone>();
|
||||
GUI.Label(new Rect(x, y, w2, h), "Choose dynamic bone:");
|
||||
y += h;
|
||||
dbs[0].enabled = dbs[1].enabled = GUI.Toggle(new Rect(x, y, w1, h), dbs[0].enabled, "Breasts");
|
||||
y += h;
|
||||
dbs[2].enabled = GUI.Toggle(new Rect(x, y, w1, h), dbs[2].enabled, "Tail");
|
||||
|
||||
y += h;
|
||||
GUI.Label(new Rect(x, y, w2, h), "Weight");
|
||||
m_weight = GUI.HorizontalSlider(new Rect(x + 50, y, w1, h), m_weight, 0, 1);
|
||||
foreach (var db in dbs)
|
||||
db.SetWeight(m_weight);
|
||||
/*
|
||||
y += h * 2;
|
||||
GUI.Label(new Rect(x, y, w2, h), "Sleep");
|
||||
m_sleepTime = GUI.HorizontalSlider(new Rect(x + 50, y, w1, h), m_sleepTime, 0, 1);
|
||||
if (m_sleepTime > 0)
|
||||
System.Threading.Thread.Sleep((int)(m_sleepTime * 100));
|
||||
|
||||
y += h;
|
||||
GUI.Label(new Rect(x, y, w2, h), "Time Scale");
|
||||
Time.timeScale = GUI.HorizontalSlider(new Rect(x + 80, y, w1, h), Time.timeScale, 0, 2);
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 178320cedf292cb4f8d6c0b737b35953
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Binary file not shown.
@@ -0,0 +1,421 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba128457d0ea5e3439dbe4a53b9d1273
|
||||
ModelImporter:
|
||||
serializedVersion: 16
|
||||
fileIDToRecycleName:
|
||||
100000: abdomen
|
||||
100002: abdomen2
|
||||
100004: //RootNode
|
||||
100006: chest
|
||||
100008: Genesis2Female
|
||||
100010: Genesis2Female.Shape
|
||||
100012: head
|
||||
100014: hip
|
||||
100016: lBigToe
|
||||
100018: lCarpal1
|
||||
100020: lCarpal2
|
||||
100022: lCollar
|
||||
100024: lEye
|
||||
100026: lFoot
|
||||
100028: lForeArm
|
||||
100030: lHand
|
||||
100032: lIndex1
|
||||
100034: lIndex2
|
||||
100036: lIndex3
|
||||
100038: lMid1
|
||||
100040: lMid2
|
||||
100042: lMid3
|
||||
100044: lowerJaw
|
||||
100046: lPectoral
|
||||
100048: lPinky1
|
||||
100050: lPinky2
|
||||
100052: lPinky3
|
||||
100054: lRing1
|
||||
100056: lRing2
|
||||
100058: lRing3
|
||||
100060: lShin
|
||||
100062: lShldr
|
||||
100064: lSmallToe1
|
||||
100066: lSmallToe2
|
||||
100068: lSmallToe3
|
||||
100070: lSmallToe4
|
||||
100072: lThigh
|
||||
100074: lThumb1
|
||||
100076: lThumb2
|
||||
100078: lThumb3
|
||||
100080: lToe
|
||||
100082: neck
|
||||
100084: pelvis
|
||||
100086: rBigToe
|
||||
100088: rCarpal1
|
||||
100090: rCarpal2
|
||||
100092: rCollar
|
||||
100094: rEye
|
||||
100096: rFoot
|
||||
100098: rForeArm
|
||||
100100: rHand
|
||||
100102: rIndex1
|
||||
100104: rIndex2
|
||||
100106: rIndex3
|
||||
100108: rMid1
|
||||
100110: rMid2
|
||||
100112: rMid3
|
||||
100114: rPectoral
|
||||
100116: rPinky1
|
||||
100118: rPinky2
|
||||
100120: rPinky3
|
||||
100122: rRing1
|
||||
100124: rRing2
|
||||
100126: rRing3
|
||||
100128: rShin
|
||||
100130: rShldr
|
||||
100132: rSmallToe1
|
||||
100134: rSmallToe2
|
||||
100136: rSmallToe3
|
||||
100138: rSmallToe4
|
||||
100140: rThigh
|
||||
100142: rThumb1
|
||||
100144: rThumb2
|
||||
100146: rThumb3
|
||||
100148: rToe
|
||||
100150: tongue01
|
||||
100152: tongue02
|
||||
100154: tongue03
|
||||
100156: tongue04
|
||||
100158: tongue05
|
||||
100160: tongueBase
|
||||
100162: tongueTip
|
||||
100164: upperJaw
|
||||
400000: abdomen
|
||||
400002: abdomen2
|
||||
400004: //RootNode
|
||||
400006: chest
|
||||
400008: Genesis2Female
|
||||
400010: Genesis2Female.Shape
|
||||
400012: head
|
||||
400014: hip
|
||||
400016: lBigToe
|
||||
400018: lCarpal1
|
||||
400020: lCarpal2
|
||||
400022: lCollar
|
||||
400024: lEye
|
||||
400026: lFoot
|
||||
400028: lForeArm
|
||||
400030: lHand
|
||||
400032: lIndex1
|
||||
400034: lIndex2
|
||||
400036: lIndex3
|
||||
400038: lMid1
|
||||
400040: lMid2
|
||||
400042: lMid3
|
||||
400044: lowerJaw
|
||||
400046: lPectoral
|
||||
400048: lPinky1
|
||||
400050: lPinky2
|
||||
400052: lPinky3
|
||||
400054: lRing1
|
||||
400056: lRing2
|
||||
400058: lRing3
|
||||
400060: lShin
|
||||
400062: lShldr
|
||||
400064: lSmallToe1
|
||||
400066: lSmallToe2
|
||||
400068: lSmallToe3
|
||||
400070: lSmallToe4
|
||||
400072: lThigh
|
||||
400074: lThumb1
|
||||
400076: lThumb2
|
||||
400078: lThumb3
|
||||
400080: lToe
|
||||
400082: neck
|
||||
400084: pelvis
|
||||
400086: rBigToe
|
||||
400088: rCarpal1
|
||||
400090: rCarpal2
|
||||
400092: rCollar
|
||||
400094: rEye
|
||||
400096: rFoot
|
||||
400098: rForeArm
|
||||
400100: rHand
|
||||
400102: rIndex1
|
||||
400104: rIndex2
|
||||
400106: rIndex3
|
||||
400108: rMid1
|
||||
400110: rMid2
|
||||
400112: rMid3
|
||||
400114: rPectoral
|
||||
400116: rPinky1
|
||||
400118: rPinky2
|
||||
400120: rPinky3
|
||||
400122: rRing1
|
||||
400124: rRing2
|
||||
400126: rRing3
|
||||
400128: rShin
|
||||
400130: rShldr
|
||||
400132: rSmallToe1
|
||||
400134: rSmallToe2
|
||||
400136: rSmallToe3
|
||||
400138: rSmallToe4
|
||||
400140: rThigh
|
||||
400142: rThumb1
|
||||
400144: rThumb2
|
||||
400146: rThumb3
|
||||
400148: rToe
|
||||
400150: tongue01
|
||||
400152: tongue02
|
||||
400154: tongue03
|
||||
400156: tongue04
|
||||
400158: tongue05
|
||||
400160: tongueBase
|
||||
400162: tongueTip
|
||||
400164: upperJaw
|
||||
4300000: Genesis2Female.Shape
|
||||
7400000: Animation
|
||||
9500000: //RootNode
|
||||
11100000: //RootNode
|
||||
13700000: Genesis2Female.Shape
|
||||
materials:
|
||||
importMaterials: 0
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
optimizeGameObjects: 0
|
||||
animationCompression: 2
|
||||
animationRotationError: .5
|
||||
animationPositionError: .5
|
||||
animationScaleError: .5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
clipAnimations:
|
||||
- serializedVersion: 16
|
||||
name: Animation
|
||||
takeName: Animation
|
||||
firstFrame: 0
|
||||
lastFrame: 206
|
||||
wrapMode: 2
|
||||
orientationOffsetY: 0
|
||||
level: 0
|
||||
cycleOffset: 0
|
||||
loop: 0
|
||||
loopTime: 0
|
||||
loopBlend: 0
|
||||
loopBlendOrientation: 0
|
||||
loopBlendPositionY: 0
|
||||
loopBlendPositionXZ: 0
|
||||
keepOriginalOrientation: 0
|
||||
keepOriginalPositionY: 1
|
||||
keepOriginalPositionXZ: 0
|
||||
heightFromFeet: 0
|
||||
mirror: 0
|
||||
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||
curves: []
|
||||
events: []
|
||||
transformMask:
|
||||
- path:
|
||||
weight: 1
|
||||
- path: Genesis2Female
|
||||
weight: 1
|
||||
- path: Genesis2Female/Genesis2Female.Shape
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1/lIndex2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1/lIndex2/lIndex3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1/lMid2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1/lMid2/lMid3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1/lPinky2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1/lPinky2/lPinky3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1/lRing2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1/lRing2/lRing3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1/lThumb2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1/lThumb2/lThumb3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/lPectoral
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lEye
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04/tongue05
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04/tongue05/tongueTip
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/rEye
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/upperJaw
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1/rIndex2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1/rIndex2/rIndex3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1/rMid2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1/rMid2/rMid3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1/rPinky2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1/rPinky2/rPinky3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1/rRing2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1/rRing2/rRing3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1/rThumb2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1/rThumb2/rThumb3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/abdomen/abdomen2/chest/rPectoral
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lBigToe
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe4
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rBigToe
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe1
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe2
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe3
|
||||
weight: 1
|
||||
- path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe4
|
||||
weight: 1
|
||||
maskType: 0
|
||||
maskSource: {instanceID: 0}
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: .00999999978
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
importBlendShapes: 0
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
optimizeMeshForGPU: 1
|
||||
weldVertices: 1
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVPackMargin: 4
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
splitTangentsAcrossUV: 1
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 2
|
||||
importAnimation: 1
|
||||
copyAvatar: 0
|
||||
humanDescription:
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: .5
|
||||
foreArmTwist: .5
|
||||
upperLegTwist: .5
|
||||
legTwist: .5
|
||||
armStretch: .0500000007
|
||||
legStretch: .0500000007
|
||||
feetSpacing: 0
|
||||
rootMotionBoneName:
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
animationType: 1
|
||||
additionalBone: 0
|
||||
userData:
|
||||
Binary file not shown.
@@ -0,0 +1,98 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19015a5957bbaa745a61cba005220542
|
||||
ModelImporter:
|
||||
serializedVersion: 16
|
||||
fileIDToRecycleName:
|
||||
100000: Bone01
|
||||
100002: Bone02
|
||||
100004: Bone03
|
||||
100006: Bone04
|
||||
100008: Bone05
|
||||
100010: Bone06
|
||||
100012: Bone07
|
||||
100014: Bone08
|
||||
100016: //RootNode
|
||||
100018: tail
|
||||
100020: tail1
|
||||
100022: tail2
|
||||
100024: tail3
|
||||
100026: tail4
|
||||
100028: tail5
|
||||
100030: tail6
|
||||
100032: tail7
|
||||
100034: tail8
|
||||
400000: Bone01
|
||||
400002: Bone02
|
||||
400004: Bone03
|
||||
400006: Bone04
|
||||
400008: Bone05
|
||||
400010: Bone06
|
||||
400012: Bone07
|
||||
400014: Bone08
|
||||
400016: //RootNode
|
||||
400018: tail
|
||||
400020: tail1
|
||||
400022: tail2
|
||||
400024: tail3
|
||||
400026: tail4
|
||||
400028: tail5
|
||||
400030: tail6
|
||||
400032: tail7
|
||||
400034: tail8
|
||||
4300000: tail
|
||||
9500000: //RootNode
|
||||
11100000: //RootNode
|
||||
13700000: tail
|
||||
materials:
|
||||
importMaterials: 0
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
optimizeGameObjects: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: .5
|
||||
animationPositionError: .5
|
||||
animationScaleError: .5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: .00999999978
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
importBlendShapes: 0
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
optimizeMeshForGPU: 1
|
||||
weldVertices: 1
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVPackMargin: 4
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
splitTangentsAcrossUV: 1
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 2
|
||||
importAnimation: 0
|
||||
copyAvatar: 0
|
||||
humanDescription:
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: .5
|
||||
foreArmTwist: .5
|
||||
upperLegTwist: .5
|
||||
legTwist: .5
|
||||
armStretch: .0500000007
|
||||
legStretch: .0500000007
|
||||
feetSpacing: 0
|
||||
rootMotionBoneName:
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
animationType: 1
|
||||
additionalBone: 0
|
||||
userData:
|
||||
@@ -0,0 +1,143 @@
|
||||
Dynamic Bone apply physics to character's bones or joints.
|
||||
With simple setup, your character's hair, cloth, breasts or any part will move realistically.
|
||||
|
||||
Open Assets/DynamicBone/Demo/Demo1 to see how it works.
|
||||
If you have any questions or suggestions, please contact willhongcom@gmail.com.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Basic setup:
|
||||
|
||||
1. Prepare a properly setup character, both Mecanim and legacy rigs are supported.
|
||||
2. Select the game object you want to apply Dynamic Bone.
|
||||
3. In the component menu, select Dynamic Bone -> Dynamic Bone.
|
||||
4. In the inspector, select root object.
|
||||
5. Adjust dynamic bone parameters (see detail descriptions in the following section).
|
||||
|
||||
|
||||
You can add collider objects if required:
|
||||
|
||||
1. Select game object the collider will attached.
|
||||
2. In the component menu, select Dynamic Bone -> Dynamic Bone Collider.
|
||||
3. Adjust position and size of the collider.
|
||||
4. In Dynamic Bone component, increase size of colliders and append corresponding object.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Dynamic Bone component description:
|
||||
|
||||
- Root
|
||||
The root of the transform hierarchy to apply physics.
|
||||
|
||||
- Update Rate
|
||||
Internal physics simulation rate, measures in frames per seconds.
|
||||
|
||||
- Update Mode
|
||||
Normal: Update physics in fixed timestamp as specified rate.
|
||||
AnimatePhysics: Updates during the physic loop in order to synchronized with the physics engine.
|
||||
UnscaledTime: Updates independently of Time.timeScale.
|
||||
Default: Update physics every frame instead of specified rate, recommended.
|
||||
|
||||
- Damping
|
||||
How much the bones slowed down.
|
||||
|
||||
- Elasticity
|
||||
How much the force applied to return each bone to original orientation.
|
||||
|
||||
- Stiffness
|
||||
How much bone's original orientation are preserved.
|
||||
|
||||
- Inert
|
||||
How much character's position change is ignored in physics simulation.
|
||||
|
||||
- Friction
|
||||
How much the bones slowed down when collide.
|
||||
|
||||
- Radius
|
||||
Each bone can be a sphere to collide with colliders. Radius describe sphere's size.
|
||||
|
||||
- Damping Distrib, Elasticity Distrib, Stiffness Distrib, Inert Distrib, Radius Distrib
|
||||
How parameters change over hierarchy chain. Curve values are multiplied to corresponding parameters.
|
||||
|
||||
- End Length
|
||||
If End Length is not zero, an extra bone is generated at the end of transform hierarchy,
|
||||
length is multiplied by last two bone's distance.
|
||||
|
||||
- End Offset
|
||||
If End Offset is not zero, an extra bone is generated at the end of transform hierarchy,
|
||||
offset is in character's local space.
|
||||
|
||||
- Gravity
|
||||
The force apply to bones, in world space. Partial force apply to character's initial pose is cancelled out.
|
||||
|
||||
- Force
|
||||
The force apply to bones, in world space.
|
||||
|
||||
- Colliders
|
||||
Collider objects interact with the bones.
|
||||
|
||||
- Exclusions
|
||||
Bones exclude from physics simulation.
|
||||
|
||||
- Freeze Axis
|
||||
Constrain bones to move on specified plane.
|
||||
|
||||
- Distant Disable, Reference Object, Distance To Object
|
||||
Disable physics simulation automatically if character is far from camera or player.
|
||||
If there is no reference object, default main camera is used.
|
||||
|
||||
|
||||
Dynamic Bone Collider component description:
|
||||
|
||||
- Center
|
||||
The center of the sphere or capsule, in the object's local space.
|
||||
|
||||
- Radius
|
||||
The radius of the sphere or capsule, will be scaled by the transform's scale.
|
||||
|
||||
- Height
|
||||
The height of the capsule, including two half-spheres, will be scaled by the transform's scale.
|
||||
|
||||
- Direction
|
||||
The axis of the capsule's height.
|
||||
|
||||
- Bound
|
||||
Constrain bones to outside bound or inside bound.
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Dynamic Bone script reference:
|
||||
|
||||
- public void SetWeight(float w);
|
||||
Control how physics blend with existing animation.
|
||||
|
||||
- public void UpdateParameters();
|
||||
Update parameters at runtime, call this funtion after modifing parameters.
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Version History
|
||||
|
||||
1.0.1 Initial release.
|
||||
1.0.2 Improve inspector UI.
|
||||
1.0.3 Fix inert unstable when enabled / disabled.
|
||||
1.1.0 Use curve to setup parameters over hierarchy chain.
|
||||
Collider can configured to constrain bones inside bound.
|
||||
1.1.1 Add exclusion setting.
|
||||
1.1.2 Deal with negative scale problem.
|
||||
1.1.3 Fix bug with bones contain scale.
|
||||
1.1.4 Add freeze axis.
|
||||
Fix bug when added via script.
|
||||
1.1.5 Add distant disable.
|
||||
Reduce GC alloc.
|
||||
1.1.6 Fix capsule collider bug.
|
||||
1.1.7 Unity 5 support.
|
||||
1.1.8 Fix problems caused by negative scale.
|
||||
1.1.9 Improve detecting negative scale.
|
||||
Fix bug if collider is set as inside.
|
||||
Add UpdateMode setting.
|
||||
1.1.10 Fix problems caused by negative scale after Unity 5.4.
|
||||
1.2.0 Add tool tips.
|
||||
Add plane collider.
|
||||
Add function to update parameters at runtime.
|
||||
1.2.1 Add friction parameter.
|
||||
Update UNITY_5 to compatible with newer version.
|
||||
1.2.2 Add "Default" update mode, fix some jitter issue.
|
||||
@@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdbe6feeda2a62b45ad9a4e311031478
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 993edbffbda2d3e4abd24f1bf074c5f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
@@ -0,0 +1,714 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[AddComponentMenu("Dynamic Bone/Dynamic Bone")]
|
||||
public class DynamicBone : MonoBehaviour
|
||||
{
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The root of the transform hierarchy to apply physics.")]
|
||||
#endif
|
||||
public Transform m_Root = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Internal physics simulation rate.")]
|
||||
#endif
|
||||
public float m_UpdateRate = 60.0f;
|
||||
|
||||
public enum UpdateMode
|
||||
{
|
||||
Normal,
|
||||
AnimatePhysics,
|
||||
UnscaledTime,
|
||||
Default
|
||||
}
|
||||
public UpdateMode m_UpdateMode = UpdateMode.Default;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("How much the bones slowed down.")]
|
||||
#endif
|
||||
[Range(0, 1)]
|
||||
public float m_Damping = 0.1f;
|
||||
public AnimationCurve m_DampingDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("How much the force applied to return each bone to original orientation.")]
|
||||
#endif
|
||||
[Range(0, 1)]
|
||||
public float m_Elasticity = 0.1f;
|
||||
public AnimationCurve m_ElasticityDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("How much bone's original orientation are preserved.")]
|
||||
#endif
|
||||
[Range(0, 1)]
|
||||
public float m_Stiffness = 0.1f;
|
||||
public AnimationCurve m_StiffnessDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("How much character's position change is ignored in physics simulation.")]
|
||||
#endif
|
||||
[Range(0, 1)]
|
||||
public float m_Inert = 0;
|
||||
public AnimationCurve m_InertDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("How much the bones slowed down when collide.")]
|
||||
#endif
|
||||
public float m_Friction = 0;
|
||||
public AnimationCurve m_FrictionDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Each bone can be a sphere to collide with colliders. Radius describe sphere's size.")]
|
||||
#endif
|
||||
public float m_Radius = 0;
|
||||
public AnimationCurve m_RadiusDistrib = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("If End Length is not zero, an extra bone is generated at the end of transform hierarchy.")]
|
||||
#endif
|
||||
public float m_EndLength = 0;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("If End Offset is not zero, an extra bone is generated at the end of transform hierarchy.")]
|
||||
#endif
|
||||
public Vector3 m_EndOffset = Vector3.zero;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The force apply to bones. Partial force apply to character's initial pose is cancelled out.")]
|
||||
#endif
|
||||
public Vector3 m_Gravity = Vector3.zero;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The force apply to bones.")]
|
||||
#endif
|
||||
public Vector3 m_Force = Vector3.zero;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Collider objects interact with the bones.")]
|
||||
#endif
|
||||
public List<DynamicBoneColliderBase> m_Colliders = null;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Bones exclude from physics simulation.")]
|
||||
#endif
|
||||
public List<Transform> m_Exclusions = null;
|
||||
|
||||
|
||||
public enum FreezeAxis
|
||||
{
|
||||
None, X, Y, Z
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Constrain bones to move on specified plane.")]
|
||||
#endif
|
||||
public FreezeAxis m_FreezeAxis = FreezeAxis.None;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Disable physics simulation automatically if character is far from camera or player.")]
|
||||
#endif
|
||||
public bool m_DistantDisable = false;
|
||||
public Transform m_ReferenceObject = null;
|
||||
public float m_DistanceToObject = 20;
|
||||
|
||||
Vector3 m_LocalGravity = Vector3.zero;
|
||||
Vector3 m_ObjectMove = Vector3.zero;
|
||||
Vector3 m_ObjectPrevPosition = Vector3.zero;
|
||||
float m_BoneTotalLength = 0;
|
||||
float m_ObjectScale = 1.0f;
|
||||
float m_Time = 0;
|
||||
float m_Weight = 1.0f;
|
||||
bool m_DistantDisabled = false;
|
||||
|
||||
class Particle
|
||||
{
|
||||
public Transform m_Transform = null;
|
||||
public int m_ParentIndex = -1;
|
||||
public float m_Damping = 0;
|
||||
public float m_Elasticity = 0;
|
||||
public float m_Stiffness = 0;
|
||||
public float m_Inert = 0;
|
||||
public float m_Friction = 0;
|
||||
public float m_Radius = 0;
|
||||
public float m_BoneLength = 0;
|
||||
public bool m_isCollide = false;
|
||||
|
||||
public Vector3 m_Position = Vector3.zero;
|
||||
public Vector3 m_PrevPosition = Vector3.zero;
|
||||
public Vector3 m_EndOffset = Vector3.zero;
|
||||
public Vector3 m_InitLocalPosition = Vector3.zero;
|
||||
public Quaternion m_InitLocalRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
List<Particle> m_Particles = new List<Particle>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
SetupParticles();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (m_UpdateMode == UpdateMode.AnimatePhysics)
|
||||
PreUpdate();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (m_UpdateMode != UpdateMode.AnimatePhysics)
|
||||
PreUpdate();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (m_DistantDisable)
|
||||
CheckDistance();
|
||||
|
||||
if (m_Weight > 0 && !(m_DistantDisable && m_DistantDisabled))
|
||||
{
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
float dt = m_UpdateMode == UpdateMode.UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
|
||||
#else
|
||||
float dt = Time.deltaTime;
|
||||
#endif
|
||||
UpdateDynamicBones(dt);
|
||||
}
|
||||
}
|
||||
|
||||
void PreUpdate()
|
||||
{
|
||||
if (m_Weight > 0 && !(m_DistantDisable && m_DistantDisabled))
|
||||
InitTransforms();
|
||||
}
|
||||
|
||||
void CheckDistance()
|
||||
{
|
||||
Transform rt = m_ReferenceObject;
|
||||
if (rt == null && Camera.main != null)
|
||||
rt = Camera.main.transform;
|
||||
if (rt != null)
|
||||
{
|
||||
float d = (rt.position - transform.position).sqrMagnitude;
|
||||
bool disable = d > m_DistanceToObject * m_DistanceToObject;
|
||||
if (disable != m_DistantDisabled)
|
||||
{
|
||||
if (!disable)
|
||||
ResetParticlesPosition();
|
||||
m_DistantDisabled = disable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
ResetParticlesPosition();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
InitTransforms();
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
m_UpdateRate = Mathf.Max(m_UpdateRate, 0);
|
||||
m_Damping = Mathf.Clamp01(m_Damping);
|
||||
m_Elasticity = Mathf.Clamp01(m_Elasticity);
|
||||
m_Stiffness = Mathf.Clamp01(m_Stiffness);
|
||||
m_Inert = Mathf.Clamp01(m_Inert);
|
||||
m_Friction = Mathf.Clamp01(m_Friction);
|
||||
m_Radius = Mathf.Max(m_Radius, 0);
|
||||
|
||||
if (Application.isEditor && Application.isPlaying)
|
||||
{
|
||||
InitTransforms();
|
||||
SetupParticles();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
if (!enabled || m_Root == null)
|
||||
return;
|
||||
|
||||
if (Application.isEditor && !Application.isPlaying && transform.hasChanged)
|
||||
{
|
||||
InitTransforms();
|
||||
SetupParticles();
|
||||
}
|
||||
|
||||
Gizmos.color = Color.white;
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
Gizmos.DrawLine(p.m_Position, p0.m_Position);
|
||||
}
|
||||
if (p.m_Radius > 0)
|
||||
Gizmos.DrawWireSphere(p.m_Position, p.m_Radius * m_ObjectScale);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWeight(float w)
|
||||
{
|
||||
if (m_Weight != w)
|
||||
{
|
||||
if (w == 0)
|
||||
InitTransforms();
|
||||
else if (m_Weight == 0)
|
||||
ResetParticlesPosition();
|
||||
m_Weight = w;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetWeight()
|
||||
{
|
||||
return m_Weight;
|
||||
}
|
||||
|
||||
void UpdateDynamicBones(float t)
|
||||
{
|
||||
if (m_Root == null)
|
||||
return;
|
||||
|
||||
m_ObjectScale = Mathf.Abs(transform.lossyScale.x);
|
||||
m_ObjectMove = transform.position - m_ObjectPrevPosition;
|
||||
m_ObjectPrevPosition = transform.position;
|
||||
|
||||
int loop = 1;
|
||||
float timeVar = 1;
|
||||
|
||||
if (m_UpdateMode == UpdateMode.Default)
|
||||
{
|
||||
if (m_UpdateRate > 0)
|
||||
{
|
||||
timeVar = Time.deltaTime * m_UpdateRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeVar = Time.deltaTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_UpdateRate > 0)
|
||||
{
|
||||
float dt = 1.0f / m_UpdateRate;
|
||||
m_Time += t;
|
||||
loop = 0;
|
||||
|
||||
while (m_Time >= dt)
|
||||
{
|
||||
m_Time -= dt;
|
||||
if (++loop >= 3)
|
||||
{
|
||||
m_Time = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loop > 0)
|
||||
{
|
||||
for (int i = 0; i < loop; ++i)
|
||||
{
|
||||
UpdateParticles1(timeVar);
|
||||
UpdateParticles2(timeVar);
|
||||
m_ObjectMove = Vector3.zero;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SkipUpdateParticles();
|
||||
}
|
||||
|
||||
ApplyParticlesToTransforms();
|
||||
}
|
||||
|
||||
public void SetupParticles()
|
||||
{
|
||||
m_Particles.Clear();
|
||||
if (m_Root == null)
|
||||
return;
|
||||
|
||||
m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity);
|
||||
m_ObjectScale = Mathf.Abs(transform.lossyScale.x);
|
||||
m_ObjectPrevPosition = transform.position;
|
||||
m_ObjectMove = Vector3.zero;
|
||||
m_BoneTotalLength = 0;
|
||||
AppendParticles(m_Root, -1, 0);
|
||||
UpdateParameters();
|
||||
}
|
||||
|
||||
void AppendParticles(Transform b, int parentIndex, float boneLength)
|
||||
{
|
||||
Particle p = new Particle();
|
||||
p.m_Transform = b;
|
||||
p.m_ParentIndex = parentIndex;
|
||||
if (b != null)
|
||||
{
|
||||
p.m_Position = p.m_PrevPosition = b.position;
|
||||
p.m_InitLocalPosition = b.localPosition;
|
||||
p.m_InitLocalRotation = b.localRotation;
|
||||
}
|
||||
else // end bone
|
||||
{
|
||||
Transform pb = m_Particles[parentIndex].m_Transform;
|
||||
if (m_EndLength > 0)
|
||||
{
|
||||
Transform ppb = pb.parent;
|
||||
if (ppb != null)
|
||||
p.m_EndOffset = pb.InverseTransformPoint((pb.position * 2 - ppb.position)) * m_EndLength;
|
||||
else
|
||||
p.m_EndOffset = new Vector3(m_EndLength, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.m_EndOffset = pb.InverseTransformPoint(transform.TransformDirection(m_EndOffset) + pb.position);
|
||||
}
|
||||
p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset);
|
||||
}
|
||||
|
||||
if (parentIndex >= 0)
|
||||
{
|
||||
boneLength += (m_Particles[parentIndex].m_Transform.position - p.m_Position).magnitude;
|
||||
p.m_BoneLength = boneLength;
|
||||
m_BoneTotalLength = Mathf.Max(m_BoneTotalLength, boneLength);
|
||||
}
|
||||
|
||||
int index = m_Particles.Count;
|
||||
m_Particles.Add(p);
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
for (int i = 0; i < b.childCount; ++i)
|
||||
{
|
||||
Transform child = b.GetChild(i);
|
||||
bool exclude = false;
|
||||
if (m_Exclusions != null)
|
||||
{
|
||||
exclude = m_Exclusions.Contains(child);
|
||||
}
|
||||
if (!exclude)
|
||||
AppendParticles(child, index, boneLength);
|
||||
else if (m_EndLength > 0 || m_EndOffset != Vector3.zero)
|
||||
AppendParticles(null, index, boneLength);
|
||||
}
|
||||
|
||||
if (b.childCount == 0 && (m_EndLength > 0 || m_EndOffset != Vector3.zero))
|
||||
AppendParticles(null, index, boneLength);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateParameters()
|
||||
{
|
||||
if (m_Root == null)
|
||||
return;
|
||||
|
||||
m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity);
|
||||
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
p.m_Damping = m_Damping;
|
||||
p.m_Elasticity = m_Elasticity;
|
||||
p.m_Stiffness = m_Stiffness;
|
||||
p.m_Inert = m_Inert;
|
||||
p.m_Friction = m_Friction;
|
||||
p.m_Radius = m_Radius;
|
||||
|
||||
if (m_BoneTotalLength > 0)
|
||||
{
|
||||
float a = p.m_BoneLength / m_BoneTotalLength;
|
||||
if (m_DampingDistrib != null && m_DampingDistrib.keys.Length > 0)
|
||||
p.m_Damping *= m_DampingDistrib.Evaluate(a);
|
||||
if (m_ElasticityDistrib != null && m_ElasticityDistrib.keys.Length > 0)
|
||||
p.m_Elasticity *= m_ElasticityDistrib.Evaluate(a);
|
||||
if (m_StiffnessDistrib != null && m_StiffnessDistrib.keys.Length > 0)
|
||||
p.m_Stiffness *= m_StiffnessDistrib.Evaluate(a);
|
||||
if (m_InertDistrib != null && m_InertDistrib.keys.Length > 0)
|
||||
p.m_Inert *= m_InertDistrib.Evaluate(a);
|
||||
if (m_FrictionDistrib != null && m_FrictionDistrib.keys.Length > 0)
|
||||
p.m_Friction *= m_FrictionDistrib.Evaluate(a);
|
||||
if (m_RadiusDistrib != null && m_RadiusDistrib.keys.Length > 0)
|
||||
p.m_Radius *= m_RadiusDistrib.Evaluate(a);
|
||||
}
|
||||
|
||||
p.m_Damping = Mathf.Clamp01(p.m_Damping);
|
||||
p.m_Elasticity = Mathf.Clamp01(p.m_Elasticity);
|
||||
p.m_Stiffness = Mathf.Clamp01(p.m_Stiffness);
|
||||
p.m_Inert = Mathf.Clamp01(p.m_Inert);
|
||||
p.m_Friction = Mathf.Clamp01(p.m_Friction);
|
||||
p.m_Radius = Mathf.Max(p.m_Radius, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void InitTransforms()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
if (p.m_Transform != null)
|
||||
{
|
||||
p.m_Transform.localPosition = p.m_InitLocalPosition;
|
||||
p.m_Transform.localRotation = p.m_InitLocalRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResetParticlesPosition()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
if (p.m_Transform != null)
|
||||
{
|
||||
p.m_Position = p.m_PrevPosition = p.m_Transform.position;
|
||||
}
|
||||
else // end bone
|
||||
{
|
||||
Transform pb = m_Particles[p.m_ParentIndex].m_Transform;
|
||||
p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset);
|
||||
}
|
||||
p.m_isCollide = false;
|
||||
}
|
||||
m_ObjectPrevPosition = transform.position;
|
||||
}
|
||||
|
||||
void UpdateParticles1(float timeVar)
|
||||
{
|
||||
Vector3 force = m_Gravity;
|
||||
Vector3 fdir = m_Gravity.normalized;
|
||||
Vector3 rf = m_Root.TransformDirection(m_LocalGravity);
|
||||
Vector3 pf = fdir * Mathf.Max(Vector3.Dot(rf, fdir), 0); // project current gravity to rest gravity
|
||||
force -= pf; // remove projected gravity
|
||||
force = (force + m_Force) * (m_ObjectScale * timeVar);
|
||||
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
// verlet integration
|
||||
Vector3 v = p.m_Position - p.m_PrevPosition;
|
||||
Vector3 rmove = m_ObjectMove * p.m_Inert;
|
||||
p.m_PrevPosition = p.m_Position + rmove;
|
||||
float damping = p.m_Damping;
|
||||
if (p.m_isCollide)
|
||||
{
|
||||
damping += p.m_Friction;
|
||||
if (damping > 1)
|
||||
damping = 1;
|
||||
p.m_isCollide = false;
|
||||
}
|
||||
p.m_Position += v * (1 - damping) + force + rmove;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.m_PrevPosition = p.m_Position;
|
||||
p.m_Position = p.m_Transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateParticles2(float timeVar)
|
||||
{
|
||||
Plane movePlane = new Plane();
|
||||
|
||||
for (int i = 1; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
|
||||
float restLen;
|
||||
if (p.m_Transform != null)
|
||||
restLen = (p0.m_Transform.position - p.m_Transform.position).magnitude;
|
||||
else
|
||||
restLen = p0.m_Transform.localToWorldMatrix.MultiplyVector(p.m_EndOffset).magnitude;
|
||||
|
||||
// keep shape
|
||||
float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
|
||||
if (stiffness > 0 || p.m_Elasticity > 0)
|
||||
{
|
||||
Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
|
||||
m0.SetColumn(3, p0.m_Position);
|
||||
Vector3 restPos;
|
||||
if (p.m_Transform != null)
|
||||
restPos = m0.MultiplyPoint3x4(p.m_Transform.localPosition);
|
||||
else
|
||||
restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
|
||||
|
||||
Vector3 d = restPos - p.m_Position;
|
||||
p.m_Position += d * (p.m_Elasticity * timeVar);
|
||||
|
||||
if (stiffness > 0)
|
||||
{
|
||||
d = restPos - p.m_Position;
|
||||
float len = d.magnitude;
|
||||
float maxlen = restLen * (1 - stiffness) * 2;
|
||||
if (len > maxlen)
|
||||
p.m_Position += d * ((len - maxlen) / len);
|
||||
}
|
||||
}
|
||||
|
||||
// collide
|
||||
if (m_Colliders != null)
|
||||
{
|
||||
float particleRadius = p.m_Radius * m_ObjectScale;
|
||||
for (int j = 0; j < m_Colliders.Count; ++j)
|
||||
{
|
||||
DynamicBoneColliderBase c = m_Colliders[j];
|
||||
if (c != null && c.enabled)
|
||||
p.m_isCollide |= c.Collide(ref p.m_Position, particleRadius);
|
||||
}
|
||||
}
|
||||
|
||||
// freeze axis, project to plane
|
||||
if (m_FreezeAxis != FreezeAxis.None)
|
||||
{
|
||||
switch (m_FreezeAxis)
|
||||
{
|
||||
case FreezeAxis.X:
|
||||
movePlane.SetNormalAndPosition(p0.m_Transform.right, p0.m_Position);
|
||||
break;
|
||||
case FreezeAxis.Y:
|
||||
movePlane.SetNormalAndPosition(p0.m_Transform.up, p0.m_Position);
|
||||
break;
|
||||
case FreezeAxis.Z:
|
||||
movePlane.SetNormalAndPosition(p0.m_Transform.forward, p0.m_Position);
|
||||
break;
|
||||
}
|
||||
p.m_Position -= movePlane.normal * movePlane.GetDistanceToPoint(p.m_Position);
|
||||
}
|
||||
|
||||
// keep length
|
||||
Vector3 dd = p0.m_Position - p.m_Position;
|
||||
float leng = dd.magnitude;
|
||||
if (leng > 0)
|
||||
p.m_Position += dd * ((leng - restLen) / leng);
|
||||
}
|
||||
}
|
||||
|
||||
// only update stiffness and keep bone length
|
||||
void SkipUpdateParticles()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
p.m_PrevPosition += m_ObjectMove;
|
||||
p.m_Position += m_ObjectMove;
|
||||
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
|
||||
float restLen;
|
||||
if (p.m_Transform != null)
|
||||
restLen = (p0.m_Transform.position - p.m_Transform.position).magnitude;
|
||||
else
|
||||
restLen = p0.m_Transform.localToWorldMatrix.MultiplyVector(p.m_EndOffset).magnitude;
|
||||
|
||||
// keep shape
|
||||
float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
|
||||
if (stiffness > 0)
|
||||
{
|
||||
Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
|
||||
m0.SetColumn(3, p0.m_Position);
|
||||
Vector3 restPos;
|
||||
if (p.m_Transform != null)
|
||||
restPos = m0.MultiplyPoint3x4(p.m_Transform.localPosition);
|
||||
else
|
||||
restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
|
||||
|
||||
Vector3 d = restPos - p.m_Position;
|
||||
float len = d.magnitude;
|
||||
float maxlen = restLen * (1 - stiffness) * 2;
|
||||
if (len > maxlen)
|
||||
p.m_Position += d * ((len - maxlen) / len);
|
||||
}
|
||||
|
||||
// keep length
|
||||
Vector3 dd = p0.m_Position - p.m_Position;
|
||||
float leng = dd.magnitude;
|
||||
if (leng > 0)
|
||||
p.m_Position += dd * ((leng - restLen) / leng);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.m_PrevPosition = p.m_Position;
|
||||
p.m_Position = p.m_Transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Vector3 MirrorVector(Vector3 v, Vector3 axis)
|
||||
{
|
||||
return v - axis * (Vector3.Dot(v, axis) * 2);
|
||||
}
|
||||
|
||||
void ApplyParticlesToTransforms()
|
||||
{
|
||||
#if !UNITY_5_4_OR_NEWER
|
||||
// detect negative scale
|
||||
Vector3 ax = Vector3.right;
|
||||
Vector3 ay = Vector3.up;
|
||||
Vector3 az = Vector3.forward;
|
||||
bool nx = false, ny = false, nz = false;
|
||||
|
||||
Vector3 loosyScale = transform.lossyScale;
|
||||
if (loosyScale.x < 0 || loosyScale.y < 0 || loosyScale.z < 0)
|
||||
{
|
||||
Transform mirrorObject = transform;
|
||||
do
|
||||
{
|
||||
Vector3 ls = mirrorObject.localScale;
|
||||
nx = ls.x < 0;
|
||||
if (nx)
|
||||
ax = mirrorObject.right;
|
||||
ny = ls.y < 0;
|
||||
if (ny)
|
||||
ay = mirrorObject.up;
|
||||
nz = ls.z < 0;
|
||||
if (nz)
|
||||
az = mirrorObject.forward;
|
||||
if (nx || ny || nz)
|
||||
break;
|
||||
|
||||
mirrorObject = mirrorObject.parent;
|
||||
}
|
||||
while (mirrorObject != null);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < m_Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
|
||||
if (p0.m_Transform.childCount <= 1) // do not modify bone orientation if has more then one child
|
||||
{
|
||||
Vector3 v;
|
||||
if (p.m_Transform != null)
|
||||
v = p.m_Transform.localPosition;
|
||||
else
|
||||
v = p.m_EndOffset;
|
||||
Vector3 v2 = p.m_Position - p0.m_Position;
|
||||
#if !UNITY_5_4_OR_NEWER
|
||||
if (nx)
|
||||
v2 = MirrorVector(v2, ax);
|
||||
if (ny)
|
||||
v2 = MirrorVector(v2, ay);
|
||||
if (nz)
|
||||
v2 = MirrorVector(v2, az);
|
||||
#endif
|
||||
Quaternion rot = Quaternion.FromToRotation(p0.m_Transform.TransformDirection(v), v2);
|
||||
p0.m_Transform.rotation = rot * p0.m_Transform.rotation;
|
||||
}
|
||||
|
||||
if (p.m_Transform != null)
|
||||
p.m_Transform.position = p.m_Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9ac8d30c6a0d9642a11e5be4c440740
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,235 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("Dynamic Bone/Dynamic Bone Collider")]
|
||||
public class DynamicBoneCollider : DynamicBoneColliderBase
|
||||
{
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The radius of the sphere or capsule.")]
|
||||
#endif
|
||||
public float m_Radius = 0.5f;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The height of the capsule.")]
|
||||
#endif
|
||||
public float m_Height = 0;
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
m_Radius = Mathf.Max(m_Radius, 0);
|
||||
m_Height = Mathf.Max(m_Height, 0);
|
||||
}
|
||||
|
||||
public override bool Collide(ref Vector3 particlePosition, float particleRadius)
|
||||
{
|
||||
float radius = m_Radius * Mathf.Abs(transform.lossyScale.x);
|
||||
float h = m_Height * 0.5f - m_Radius;
|
||||
if (h <= 0)
|
||||
{
|
||||
if (m_Bound == Bound.Outside)
|
||||
return OutsideSphere(ref particlePosition, particleRadius, transform.TransformPoint(m_Center), radius);
|
||||
else
|
||||
return InsideSphere(ref particlePosition, particleRadius, transform.TransformPoint(m_Center), radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 c0 = m_Center;
|
||||
Vector3 c1 = m_Center;
|
||||
|
||||
switch (m_Direction)
|
||||
{
|
||||
case Direction.X:
|
||||
c0.x -= h;
|
||||
c1.x += h;
|
||||
break;
|
||||
case Direction.Y:
|
||||
c0.y -= h;
|
||||
c1.y += h;
|
||||
break;
|
||||
case Direction.Z:
|
||||
c0.z -= h;
|
||||
c1.z += h;
|
||||
break;
|
||||
}
|
||||
if (m_Bound == Bound.Outside)
|
||||
return OutsideCapsule(ref particlePosition, particleRadius, transform.TransformPoint(c0), transform.TransformPoint(c1), radius);
|
||||
else
|
||||
return InsideCapsule(ref particlePosition, particleRadius, transform.TransformPoint(c0), transform.TransformPoint(c1), radius);
|
||||
}
|
||||
}
|
||||
|
||||
static bool OutsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
|
||||
{
|
||||
float r = sphereRadius + particleRadius;
|
||||
float r2 = r * r;
|
||||
Vector3 d = particlePosition - sphereCenter;
|
||||
float len2 = d.sqrMagnitude;
|
||||
|
||||
// if is inside sphere, project onto sphere surface
|
||||
if (len2 > 0 && len2 < r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = sphereCenter + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool InsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
|
||||
{
|
||||
float r = sphereRadius - particleRadius;
|
||||
float r2 = r * r;
|
||||
Vector3 d = particlePosition - sphereCenter;
|
||||
float len2 = d.sqrMagnitude;
|
||||
|
||||
// if is outside sphere, project onto sphere surface
|
||||
if (len2 > r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = sphereCenter + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool OutsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius)
|
||||
{
|
||||
float r = capsuleRadius + particleRadius;
|
||||
float r2 = r * r;
|
||||
Vector3 dir = capsuleP1 - capsuleP0;
|
||||
Vector3 d = particlePosition - capsuleP0;
|
||||
float t = Vector3.Dot(d, dir);
|
||||
|
||||
if (t <= 0)
|
||||
{
|
||||
// check sphere1
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > 0 && len2 < r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = capsuleP0 + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float dl = dir.sqrMagnitude;
|
||||
if (t >= dl)
|
||||
{
|
||||
// check sphere2
|
||||
d = particlePosition - capsuleP1;
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > 0 && len2 < r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = capsuleP1 + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (dl > 0)
|
||||
{
|
||||
// check cylinder
|
||||
t /= dl;
|
||||
d -= dir * t;
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > 0 && len2 < r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition += d * ((r - len) / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool InsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius)
|
||||
{
|
||||
float r = capsuleRadius - particleRadius;
|
||||
float r2 = r * r;
|
||||
Vector3 dir = capsuleP1 - capsuleP0;
|
||||
Vector3 d = particlePosition - capsuleP0;
|
||||
float t = Vector3.Dot(d, dir);
|
||||
|
||||
if (t <= 0)
|
||||
{
|
||||
// check sphere1
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = capsuleP0 + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float dl = dir.sqrMagnitude;
|
||||
if (t >= dl)
|
||||
{
|
||||
// check sphere2
|
||||
d = particlePosition - capsuleP1;
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition = capsuleP1 + d * (r / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (dl > 0)
|
||||
{
|
||||
// check cylinder
|
||||
t /= dl;
|
||||
d -= dir * t;
|
||||
float len2 = d.sqrMagnitude;
|
||||
if (len2 > r2)
|
||||
{
|
||||
float len = Mathf.Sqrt(len2);
|
||||
particlePosition += d * ((r - len) / len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (m_Bound == Bound.Outside)
|
||||
Gizmos.color = Color.yellow;
|
||||
else
|
||||
Gizmos.color = Color.magenta;
|
||||
float radius = m_Radius * Mathf.Abs(transform.lossyScale.x);
|
||||
float h = m_Height * 0.5f - m_Radius;
|
||||
if (h <= 0)
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.TransformPoint(m_Center), radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 c0 = m_Center;
|
||||
Vector3 c1 = m_Center;
|
||||
|
||||
switch (m_Direction)
|
||||
{
|
||||
case Direction.X:
|
||||
c0.x -= h;
|
||||
c1.x += h;
|
||||
break;
|
||||
case Direction.Y:
|
||||
c0.y -= h;
|
||||
c1.y += h;
|
||||
break;
|
||||
case Direction.Z:
|
||||
c0.z -= h;
|
||||
c1.z += h;
|
||||
break;
|
||||
}
|
||||
Gizmos.DrawWireSphere(transform.TransformPoint(c0), radius);
|
||||
Gizmos.DrawWireSphere(transform.TransformPoint(c1), radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baedd976e12657241bf7ff2d1c685342
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DynamicBoneColliderBase : MonoBehaviour
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
X, Y, Z
|
||||
}
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The axis of the capsule's height.")]
|
||||
#endif
|
||||
public Direction m_Direction = Direction.Y;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("The center of the sphere or capsule, in the object's local space.")]
|
||||
#endif
|
||||
public Vector3 m_Center = Vector3.zero;
|
||||
|
||||
public enum Bound
|
||||
{
|
||||
Outside,
|
||||
Inside
|
||||
}
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[Tooltip("Constrain bones to outside bound or inside bound.")]
|
||||
#endif
|
||||
public Bound m_Bound = Bound.Outside;
|
||||
|
||||
public virtual bool Collide(ref Vector3 particlePosition, float particleRadius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04878769c08021a41bc2d2375e23ec0b
|
||||
timeCreated: 1482666371
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("Dynamic Bone/Dynamic Bone Plane Collider")]
|
||||
public class DynamicBonePlaneCollider : DynamicBoneColliderBase
|
||||
{
|
||||
void OnValidate()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Collide(ref Vector3 particlePosition, float particleRadius)
|
||||
{
|
||||
Vector3 normal = Vector3.up;
|
||||
switch (m_Direction)
|
||||
{
|
||||
case Direction.X:
|
||||
normal = transform.right;
|
||||
break;
|
||||
case Direction.Y:
|
||||
normal = transform.up;
|
||||
break;
|
||||
case Direction.Z:
|
||||
normal = transform.forward;
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3 p = transform.TransformPoint(m_Center);
|
||||
Plane plane = new Plane(normal, p);
|
||||
float d = plane.GetDistanceToPoint(particlePosition);
|
||||
|
||||
if (m_Bound == Bound.Outside)
|
||||
{
|
||||
if (d < 0)
|
||||
{
|
||||
particlePosition -= normal * d;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d > 0)
|
||||
{
|
||||
particlePosition -= normal * d;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (m_Bound == Bound.Outside)
|
||||
Gizmos.color = Color.yellow;
|
||||
else
|
||||
Gizmos.color = Color.magenta;
|
||||
|
||||
Vector3 normal = Vector3.up;
|
||||
switch (m_Direction)
|
||||
{
|
||||
case Direction.X:
|
||||
normal = transform.right;
|
||||
break;
|
||||
case Direction.Y:
|
||||
normal = transform.up;
|
||||
break;
|
||||
case Direction.Z:
|
||||
normal = transform.forward;
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3 p = transform.TransformPoint(m_Center);
|
||||
Gizmos.DrawLine(p, p + normal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e535bdf3689369408cc4d078260ef6a
|
||||
timeCreated: 1482666461
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,8 +6,8 @@ namespace Gallop
|
||||
{
|
||||
public class FaceDrivenKeyTarget : MonoBehaviour
|
||||
{
|
||||
public List<EyeTarget> _eyeTarget { get; set; }
|
||||
public List<EyebrowTarget> _eyebrowTarget { get; set; }
|
||||
public List<MouthTarget> _mouthTarget { get; set; }
|
||||
public List<EyeTarget> _eyeTarget;
|
||||
public List<EyebrowTarget> _eyebrowTarget;
|
||||
public List<MouthTarget> _mouthTarget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class AssetTable
|
||||
public List<StringObjectPair> list;
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class AssetTableValue
|
||||
{
|
||||
@@ -19,7 +20,7 @@ public class AssetTableValue
|
||||
public class StringObjectPair
|
||||
{
|
||||
public string Key;
|
||||
public GameObject Value;
|
||||
public Object Value;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -32,40 +33,114 @@ public class StringValuePair
|
||||
[System.Serializable]
|
||||
public class TrsArray
|
||||
{
|
||||
public string _path { get; set; }
|
||||
public int _isValidScaleTransform { get; set; }
|
||||
public Vector3 _position { get; set; }
|
||||
public Vector3 _scale { get; set; }
|
||||
public Vector3 _rotation { get; set; }
|
||||
public int IsOverrideTarget { get; set; }
|
||||
public string _path;
|
||||
public int _isValidScaleTransform;
|
||||
public Vector3 _position;
|
||||
public Vector3 _scale;
|
||||
public Vector3 _rotation;
|
||||
public int IsOverrideTarget;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FaceGroupInfo
|
||||
{
|
||||
public List<TrsArray> _trsArray { get; set; }
|
||||
public List<TrsArray> _trsArray;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class EyeTarget
|
||||
{
|
||||
public List<FaceGroupInfo> _faceGroupInfo { get; set; }
|
||||
public List<FaceGroupInfo> _faceGroupInfo;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class EyebrowTarget
|
||||
{
|
||||
public List<FaceGroupInfo> _faceGroupInfo { get; set; }
|
||||
public List<FaceGroupInfo> _faceGroupInfo;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MouthTarget
|
||||
{
|
||||
public List<FaceGroupInfo> _faceGroupInfo { get; set; }
|
||||
public List<FaceGroupInfo> _faceGroupInfo;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class TargetInfomation
|
||||
{
|
||||
public List<FaceGroupInfo> _faceGroupInfo { get; set; }
|
||||
public List<FaceGroupInfo> _faceGroupInfo;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringCollisionData
|
||||
{
|
||||
public string _collisionName;
|
||||
public string _targetObjectName;
|
||||
public bool _isOtherTarget;
|
||||
public Vector3 _offset;
|
||||
public Vector3 _offset2;
|
||||
public float _radius;
|
||||
public float _distance;
|
||||
public Vector3 _normal;
|
||||
public CollisionType _type;
|
||||
public bool _isInner;
|
||||
public enum CollisionType
|
||||
{
|
||||
Sphere,
|
||||
None,
|
||||
Capsule,
|
||||
Plane,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringParamDataElement
|
||||
{
|
||||
public string _boneName;
|
||||
public float _stiffnessForce;
|
||||
public float _dragForce;
|
||||
public float _gravity;
|
||||
public float _collisionRadius;
|
||||
public bool _needEnvCollision;
|
||||
public List<string> _collisionNameList;
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
public bool _needSimulateEndBone;
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
public List<CySpringParamDataChildElement> _childElements;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringParamDataChildElement
|
||||
{
|
||||
public string _boneName;
|
||||
public float _stiffnessForce;
|
||||
public float _dragForce;
|
||||
public float _gravity;
|
||||
public float _collisionRadius;
|
||||
public bool _needEnvCollision;
|
||||
public List<string> _collisionNameList;
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ConnectedBoneData
|
||||
{
|
||||
public string Bone1;
|
||||
public string Bone2;
|
||||
public float Intensity;
|
||||
public bool IsFold;
|
||||
}
|
||||
Reference in New Issue
Block a user