ClothViewer

This commit is contained in:
ousttrue
2024-10-17 21:33:51 +09:00
parent bbcb74c4ed
commit 3936ce5efa
26 changed files with 14024 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using UniHumanoid;
using UnityEngine;
namespace UniVRM10.Cloth.Viewer
{
public class BvhMotion : IVrm10Animation
{
UniHumanoid.BvhImporterContext m_context;
public Transform Root => m_context?.Root.transform;
public SkinnedMeshRenderer m_boxMan;
public SkinnedMeshRenderer BoxMan => m_boxMan;
(INormalizedPoseProvider, ITPoseProvider) m_controlRig;
(INormalizedPoseProvider, ITPoseProvider) IVrm10Animation.ControlRig => m_controlRig;
IDictionary<ExpressionKey, Func<float>> _ExpressionMap = new Dictionary<ExpressionKey, Func<float>>();
public IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap => (IReadOnlyDictionary<ExpressionKey, Func<float>>)_ExpressionMap;
public LookAtInput? LookAt { get; set; }
public BvhMotion(UniHumanoid.BvhImporterContext context)
{
m_context = context;
var provider = new AnimatorPoseProvider(m_context.Root.transform, m_context.Root.GetComponent<Animator>());
m_controlRig = (provider, provider);
// create SkinnedMesh for bone visualize
var animator = m_context.Root.GetComponent<Animator>();
m_boxMan = SkeletonMeshUtility.CreateRenderer(animator);
var shaderName = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null
? "Standard"
: "Universal Render Pipeline/Lit"
;
var material = new Material(Shader.Find(shaderName));
BoxMan.sharedMaterial = material;
var mesh = BoxMan.sharedMesh;
mesh.name = "box-man";
}
public static BvhMotion LoadBvhFromText(string source, string path = "tmp.bvh")
{
var context = new UniHumanoid.BvhImporterContext();
context.Parse(path, source);
context.Load();
return new BvhMotion(context);
}
public static BvhMotion LoadBvhFromPath(string path)
{
return LoadBvhFromText(File.ReadAllText(path), path);
}
public void ShowBoxMan(bool enable)
{
m_boxMan.enabled = enable;
}
public void Dispose()
{
GameObject.Destroy(m_context.Root);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d57facd372741a44a4216655733cdf5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 487929d3039a63544a0825523ac6a8ab
timeCreated: 1546851178
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant: