mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 22:39:39 -05:00
Merge pull request #699 from ousttrue/fix/fix_unittest
Fix/fix unittest
This commit is contained in:
@@ -59,7 +59,7 @@ namespace UniGLTF
|
||||
|
||||
public glTFExtensionExport Add(string key, ArraySegment<byte> raw)
|
||||
{
|
||||
m_serialized.Add(key, raw);
|
||||
m_serialized[key] = raw;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -728,7 +728,7 @@ namespace UniVRM10
|
||||
joint.GravityDir = gltfJoint.GravityDir.ToVector3();
|
||||
joint.GravityPower = gltfJoint.GravityPower.Value;
|
||||
joint.Stiffness = gltfJoint.Stiffness.Value;
|
||||
joint.Exclude = gltfJoint.Exclude.Value;
|
||||
joint.Exclude = gltfJoint.Exclude.GetValueOrDefault();
|
||||
springBone.Joints.Add(joint);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ namespace UniVRM10
|
||||
return null;
|
||||
}
|
||||
|
||||
var springBone = new VRMC_springBone();
|
||||
var springBone = new VRMC_springBone
|
||||
{
|
||||
Springs = new List<Spring>(),
|
||||
};
|
||||
|
||||
//
|
||||
// VRMC_node_collider
|
||||
@@ -26,7 +29,10 @@ namespace UniVRM10
|
||||
foreach (var nodeCollider in self.Springs.SelectMany(x => x.Colliders))
|
||||
{
|
||||
var index = nodes.IndexOfThrow(nodeCollider.Node);
|
||||
var gltfCollider = new VRMC_node_collider();
|
||||
var gltfCollider = new VRMC_node_collider
|
||||
{
|
||||
Shapes = new List<ColliderShape>(),
|
||||
};
|
||||
foreach (var y in nodeCollider.Colliders)
|
||||
{
|
||||
switch (y.ColliderType)
|
||||
@@ -80,12 +86,14 @@ namespace UniVRM10
|
||||
{
|
||||
Name = x.Comment,
|
||||
Colliders = x.Colliders.Select(y => nodes.IndexOfThrow(y.Node)).ToArray(),
|
||||
Joints = new List<SpringBoneJoint>(),
|
||||
};
|
||||
|
||||
foreach (var y in x.Joints)
|
||||
{
|
||||
spring.Joints.Add(new SpringBoneJoint
|
||||
{
|
||||
Node = nodes.IndexOfThrow(y.Node),
|
||||
HitRadius = y.HitRadius,
|
||||
DragForce = y.DragForce,
|
||||
GravityDir = y.GravityDir.ToFloat3(),
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace UniVRM10.Test
|
||||
{
|
||||
public class MaterialTests
|
||||
{
|
||||
const string _vrmPath = "Tests/Models/Alicia_vrm-1.00/AliciaSolid_vrm-1.00.vrm";
|
||||
const string _vrmPath = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm";
|
||||
|
||||
string[] _mtooSrgbTextureProperties = {
|
||||
VrmLib.MToon.Utils.PropMainTex,
|
||||
@@ -33,6 +33,10 @@ namespace UniVRM10.Test
|
||||
{
|
||||
var fi = new FileInfo(_vrmPath);
|
||||
var bytes = File.ReadAllBytes(fi.FullName);
|
||||
|
||||
// migrate to 1.0
|
||||
bytes = Migration.Migrate(bytes);
|
||||
|
||||
return ToUnity(bytes);
|
||||
}
|
||||
|
||||
@@ -170,11 +174,31 @@ namespace UniVRM10.Test
|
||||
|
||||
var model = ToVrmModel(assets.Root);
|
||||
var gltfMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial;
|
||||
gltfMaterial.Definition.Color.LitColor = new LinearColor { RGBA = srclinerColor };
|
||||
gltfMaterial.Definition.Color.ShadeColor = new LinearColor { RGBA = srclinerColor };
|
||||
gltfMaterial.Definition.Outline.OutlineColor = new LinearColor { RGBA = srclinerColor };
|
||||
gltfMaterial.Definition.Emission.EmissionColor = new LinearColor { RGBA = srclinerColor };
|
||||
gltfMaterial.Definition.Rim.RimColor = new LinearColor { RGBA = srclinerColor };
|
||||
if (gltfMaterial == null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
gltfMaterial.Definition = new VrmLib.MToon.MToonDefinition
|
||||
{
|
||||
Color = new VrmLib.MToon.ColorDefinition
|
||||
{
|
||||
LitColor = new LinearColor { RGBA = srclinerColor },
|
||||
ShadeColor = new LinearColor { RGBA = srclinerColor },
|
||||
},
|
||||
Outline = new VrmLib.MToon.OutlineDefinition
|
||||
{
|
||||
OutlineColor = new LinearColor { RGBA = srclinerColor },
|
||||
},
|
||||
Emission = new VrmLib.MToon.EmissionDefinition
|
||||
{
|
||||
EmissionColor = new LinearColor { RGBA = srclinerColor },
|
||||
},
|
||||
Rim = new VrmLib.MToon.RimDefinition
|
||||
{
|
||||
RimColor = new LinearColor { RGBA = srclinerColor },
|
||||
}
|
||||
};
|
||||
|
||||
var bytes = model.ToGlb();
|
||||
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
]
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace UniVRM10.Test
|
||||
{
|
||||
VrmLib.Model ReadModel(string path)
|
||||
{
|
||||
var bytes = File.ReadAllBytes(path);
|
||||
var bytes = Migration.Migrate(File.ReadAllBytes(path));
|
||||
|
||||
if (!UniGLTF.Glb.TryParse(bytes, out UniGLTF.Glb glb, out Exception ex))
|
||||
{
|
||||
@@ -17,7 +18,7 @@ namespace UniVRM10.Test
|
||||
return null;
|
||||
}
|
||||
|
||||
var model = UniVRM10.VrmLoader.CreateVrmModel(path);
|
||||
var model = UniVRM10.VrmLoader.CreateVrmModel(bytes, new FileInfo(path));
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -43,10 +44,10 @@ namespace UniVRM10.Test
|
||||
return bytes;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public bool Sample()
|
||||
[Test]
|
||||
public void Sample()
|
||||
{
|
||||
var path = "Tests/Models/Alicia_vrm-1.00/AliciaSolid_vrm-1.00.vrm";
|
||||
var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm";
|
||||
Debug.Log($"load: {path}");
|
||||
|
||||
// import
|
||||
@@ -74,8 +75,6 @@ namespace UniVRM10.Test
|
||||
|
||||
var vrmBytes = ToVrm10(dstModel);
|
||||
Debug.Log($"export {vrmBytes.Length} bytes");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user