remove GLTF plugin, bug fix

This commit is contained in:
CroakFang
2023-06-30 08:28:36 +08:00
parent 36d037f0a3
commit 7fb0a48996
534 changed files with 70 additions and 78609 deletions
+3 -28
View File
@@ -2,38 +2,13 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;
using UnityGLTF;
//using UnityGLTF;
public class ModelExporter
{
public static string RetrieveTexturePath(UnityEngine.Texture texture)
public static void exportModel(string path,GameObject gameobj)
{
string m_Path = Application.dataPath;
var path = m_Path + "/../unknown/" + texture.name; ;
return path;
}
public static void Export(Transform[] transforms, string sceneName)
{
var exportOptions = new UnityGLTF.ExportOptions { TexturePathRetriever = RetrieveTexturePath };
var exporter = new GLTFSceneExporter(transforms, exportOptions);
string m_Path = Application.dataPath;
string path = m_Path + "/../Exported/" + sceneName;
var resultFile = GLTFSceneExporter.GetFileName(path, sceneName, ".gltf");
exporter.SaveGLTFandBin(path, sceneName);
}
public static void exportModel(GameObject gameobj)
{
string sceneName = gameobj.name;
Transform[] rootTransforms = new Transform[] { gameobj.transform };
Export(rootTransforms, sceneName);
//Todo Export PmX
}
}
+2 -4
View File
@@ -27,11 +27,9 @@ public class TextureExporter
return readableText;
}
static public void exportAllTexture(GameObject gameobj)
static public void exportAllTexture(string path, GameObject gameobj)
{
string m_Path = Application.dataPath;
string savePath = m_Path + "/../Exported/" + gameobj.name + "/Texture2D/";
string savePath = path + "/Texture2D/";
if (!Directory.Exists(savePath))
{
+44 -7
View File
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Data;
using System.Linq;
using UnityEngine;
using Random = UnityEngine.Random;
public class UmaContainer : MonoBehaviour
{
@@ -290,7 +291,7 @@ public class UmaContainer : MonoBehaviour
{
if (TrackTarget && EnableEyeTracking && !isAnimatorControl)
{
if (!IK.enabled)
if (IK && !IK.enabled)
{
IK.enabled = true;
if(PuppetMaster.mode != PuppetMaster.Mode.Active)
@@ -316,8 +317,11 @@ public class UmaContainer : MonoBehaviour
{
if (dragCollider && dragCollider.attachedRigidbody)
{
PuppetMaster.pinWeight = 0.75f;
PuppetMaster.muscleWeight = 0.25f;
if (PuppetMaster)
{
PuppetMaster.pinWeight = 0.75f;
PuppetMaster.muscleWeight = 0.25f;
}
dragCollider.attachedRigidbody.isKinematic = true;
dragCollider.transform.position = Vector3.Lerp(dragCollider.transform.position, cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, dragdistance)) - dragStartPos, Time.fixedDeltaTime * 4);
//LookAt Mouse when Dragging
@@ -337,8 +341,11 @@ public class UmaContainer : MonoBehaviour
}
else
{
PuppetMaster.pinWeight = 1;
PuppetMaster.muscleWeight = 1;
if (PuppetMaster)
{
PuppetMaster.pinWeight = 1;
PuppetMaster.muscleWeight = 1;
}
//LookAt Camera
TrackTarget.position = Vector3.Lerp(TrackTarget.position, cam.transform.position, Time.fixedDeltaTime * 3);
if (dragCollider && dragCollider.attachedRigidbody) dragCollider.attachedRigidbody.isKinematic = false;
@@ -347,7 +354,7 @@ public class UmaContainer : MonoBehaviour
}
else
{
if (IK.enabled)
if (IK && IK.enabled)
{
IK.enabled = false;
if (PuppetMaster.mode != PuppetMaster.Mode.Kinematic)
@@ -385,6 +392,35 @@ public class UmaContainer : MonoBehaviour
}
}
public MeshRenderer debug;
private void Update()
{
//if (Input.GetMouseButtonDown(1))
//{
// var cam = Camera.main;
// var distance = Mathf.Clamp(cam.transform.InverseTransformPoint(HeadBone.transform.position).magnitude - 0.1f, 0, 2);
// var mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
// var worldPos = cam.ScreenToWorldPoint(mousePos);
// if (Physics.Raycast(Camera.main.ScreenPointToRay(mousePos), out RaycastHit hit))
// {
// hit.rigidbody.AddForce(Camera.main.transform.forward * 50, ForceMode.Impulse);
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[0], 2, FaceDrivenKeyTarget.OtherMorphs[2]);
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[1], 1, FaceDrivenKeyTarget.OtherMorphs[2]);
// Invoke(nameof(Test), 0.3f);
// }
//}
}
//public void Test()
//{
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[0], 0, FaceDrivenKeyTarget.OtherMorphs[2]);
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[1], 0, FaceDrivenKeyTarget.OtherMorphs[2]);
// FaceEmotionKeyTarget.FaceEmotionKey.ForEach(e => { if (e.target) e.Weight = 0; });
// var tmp = FaceEmotionKeyTarget.FaceEmotionKey[Random.Range(22, 26)];
// tmp.Weight = 1;
// FaceDrivenKeyTarget.ChangeMorph();
//}
public void SetNextAnimationCut(string cutName)
{
@@ -412,7 +448,7 @@ public class UmaContainer : MonoBehaviour
{
if (IsMini) return;
var container = this;
var animator = container.GetComponent<Animator>();
var animator = UmaAnimator;
BipedRagdollReferences r = BipedRagdollReferences.FromAvatar(animator);
BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(r);
@@ -448,6 +484,7 @@ public class UmaContainer : MonoBehaviour
PuppetMaster.FlattenHierarchy();
}
class MaterialHelper
{
public Material Mat;
+8 -13
View File
@@ -1,8 +1,4 @@
using Gallop;
using RootMotion;
using RootMotion.Demos;
using RootMotion.Dynamics;
using RootMotion.FinalIK;
using SFB;
using System;
using System.Collections;
@@ -392,12 +388,7 @@ public class UmaViewerUI : MonoBehaviour
}
container.Slider.onValueChanged.AddListener((a) =>
{
target.ChangeMorphWeight(prop, a);
if (prop.Type == BindProperty.BindType.Enable && morph.name.Contains("Manga"))
{
target.ChangeMorphWeight(target.EyeMorphs[42], container.Slider.value > 0 ? 1 : 0);
target.ChangeMorphWeight(target.EyeMorphs[43], container.Slider.value > 0 ? 1 : 0);
}
target.ChangeMorphWeight(prop, a, morph);
});
}
}
@@ -1318,9 +1309,13 @@ public class UmaViewerUI : MonoBehaviour
{
if (Builder.CurrentUMAContainer)
{
//TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
ModelExporter.exportModel(Builder.CurrentUMAContainer.gameObject);
TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
var container = Builder.CurrentUMAContainer;
var path = StandaloneFileBrowser.SaveFilePanel("Save PMX File", Config.Instance.MainPath, container.gameObject.name, "pmx");
if (!string.IsNullOrEmpty(path))
{
ModelExporter.exportModel(path,container.gameObject);
TextureExporter.exportAllTexture(Path.GetDirectoryName(path),container.gameObject);
}
}
}
}
+1 -2
View File
@@ -7,8 +7,7 @@
"GUID:d60799ab2a985554ea1a39cd38695018",
"GUID:fd1d627189c561043911a07470238b9c",
"GUID:145e2572884581c48a08acf566c1a1d6",
"GUID:86ee6720b4f4f604caf8a6add1fd3b06",
"GUID:18d18f811ba286c49814567a3cfba688"
"GUID:86ee6720b4f4f604caf8a6add1fd3b06"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -364,10 +364,7 @@ namespace Gallop
public void ChangeMorphEye()
{
FacialResetEye();
ProcessMorph(LeftEyeXrange);
ProcessMorph(LeftEyeYrange);
ProcessMorph(RightEyeXrange);
ProcessMorph(RightEyeYrange);
EyeMorphs.ForEach(morph => ProcessMorph(morph));
ApplyRotationEye();
}
@@ -542,11 +539,17 @@ namespace Gallop
ChangeMorph();
}
public void ChangeMorphWeight(BindProperty property, float val)
public void ChangeMorphWeight(BindProperty property, float val, FacialMorph morph)
{
Container.isAnimatorControl = false;
property.Value = val < 0 ? 0 : val;
ChangeMorph();
if (property.Type == BindProperty.BindType.Enable && morph.name.Contains("Manga"))
{
ChangeMorphWeight(EyeMorphs[42], val > 0 ? 1 : 0);
ChangeMorphWeight(EyeMorphs[43], val > 0 ? 1 : 0);
}
}
public void SetEyeRange(float lx, float ly, float rx, float ry)
@@ -71,6 +71,7 @@ public class FaceEmotionKeyTarget : ScriptableObject
{
FaceDrivenKeyTarget.Container.isAnimatorControl = false;
emotion.Weight = val;
FaceDrivenKeyTarget.ChangeMorph();
}
public void UpdateAllFacialKeyTargets()
@@ -88,7 +89,6 @@ public class FaceEmotionKeyTarget : ScriptableObject
}
}
}
FaceDrivenKeyTarget.ChangeMorph();
}
}