Skip to content

Commit 28e74d6

Browse files
authored
Added Multi-Bone skinned mesh unit tests (#440)
* Added the Unit Test BagofBones Test and associated FBX file. Also added one line to the gitignore so it ignores the autogenerated Visual Studio Code folder so I don't have to delete it every time. * Removed autoformat * Test Cleanup * Added More Unit Tests Tests for: + BasicSeparateBind + BonesParentedInMesh + NullRootMultipleMeshes + MultipleMeshesOneHierarchy + LooseSkinnedJoints + LooseLocators + LooseNulls + LocatorsInHiearchy + NullsInHiearchy + MeshesInHierarchy + ImproperRootNaming + MultipleRoots * TestBoneWeightExport + TestSkinnedMeshExport Cleaned up TestMultiRoot and added the extended cases to TestBoneWeightExport and TestSkinnedMeshExport * Refactor Merged the three different SkinnedMesh units tests into one and combined the various skinned mesh case Collections into SkinnedMeshCases * Added descriptions to the various skinned character tests * Edit of fbx descriptions * Removed ImproperRootNaming
1 parent 95bc91f commit 28e74d6

23 files changed

+1408
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[Oo]ut/
1010
[Bb]in/
1111
[Dd]ebug/
12+
.vscode/
1213

1314
[Aa]ssets/FbxExporters/*.zip
1415

Assets/com.unity.formats.fbx.tests/ModelExporterTest.cs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -551,22 +551,37 @@ private void ExportSkinnedMesh(string fileToExport, out SkinnedMeshRenderer orig
551551

552552
public class SkinnedMeshTestDataClass
553553
{
554-
public static System.Collections.IEnumerable TestCases1 {
555-
get {
556-
// for now use this cowboy taken from the asset store as the test file
557-
// TODO: find a better/simpler test file
558-
yield return "Models/Cowboy/cowboyMidPoly(riged).fbx";
559-
}
560-
}
561-
public static System.Collections.IEnumerable TestCases2 {
554+
public static System.Collections.IEnumerable SkinnedMeshCases {
562555
get {
556+
// Basic Rig with one mesh and one standard hierarchy
557+
yield return "Models/MultiRootCharacters/BasicSeparateBind.fbx";
558+
// Basic Rig with one mesh and one standard hierarchy, with the Mesh parenting the bone structure
559+
yield return "Models/MultiRootCharacters/BonesParentedInMesh.fbx";
560+
// Thigh-bone level Locators in Hierarchy that act as Handles for some of the bones
561+
yield return "Models/MultiRootCharacters/LocatorsInHierachy.fbx";
562+
// Root-Level Locators included in the fbx.
563+
yield return "Models/MultiRootCharacters/LooseLocators.fbx";
564+
// Root-Level Null Objects included in the fbx.
565+
yield return "Models/MultiRootCharacters/LooseNulls.fbx";
566+
// Basic Rig with additional floating joints independant in hierarchy and skinned to the mesh.
567+
yield return "Models/MultiRootCharacters/LooseSkinnedJoints.fbx";
568+
// Unskinned meshes in hierarchy - eg. Sword & Shield as children of hand nodes
569+
yield return "Models/MultiRootCharacters/MeshesInHierarchy.fbx";
570+
// Rig with one mesh but two bone Hierarchies
571+
yield return "Models/MultiRootCharacters/MultipleRoots.fbx";
572+
// Rig with one standard hierarchy but skinned to multiple meshes at once, All parented under a Null Object
573+
yield return "Models/MultiRootCharacters/NullRootMultipleMeshes.fbx";
574+
// Thigh-bone level Null Objects in Hierarchy that act as Handles for some of the bones
575+
yield return "Models/MultiRootCharacters/NullsInHierarchy.fbx";
576+
// Characters from the asset store
563577
yield return "Models/SimpleMan/SimpleMan.fbx";
578+
yield return "Models/Cowboy/cowboyMidPoly(riged).fbx";
564579
}
565580
}
566581
}
567582

568-
[Test, TestCaseSource(typeof(SkinnedMeshTestDataClass), "TestCases1")]
569-
public void TestSkinnedMeshExport(string fbxPath){
583+
[Test, TestCaseSource(typeof(SkinnedMeshTestDataClass), "SkinnedMeshCases")]
584+
public void TestSkinnedMeshes (string fbxPath) {
570585
fbxPath = FindPathInUnitTests (fbxPath);
571586
Assert.That (fbxPath, Is.Not.Null);
572587

@@ -626,23 +641,7 @@ public void TestSkinnedMeshExport(string fbxPath){
626641
}
627642
}
628643

629-
// TODO: find a way to compare bone weights.
630-
// The boneweights are by vertex, and duplicate vertices
631-
// are removed on export so the lists are not necessarily
632-
// the same length or order.
633-
var origWeights = origMesh.boneWeights;
634-
Assert.IsNotNull (origWeights);
635-
var expWeights = exportedMesh.boneWeights;
636-
Assert.IsNotNull (expWeights);
637-
}
638-
639-
[Test, TestCaseSource(typeof(SkinnedMeshTestDataClass), "TestCases2")]
640-
public void TestBoneWeightExport(string fbxPath){
641-
fbxPath = FindPathInUnitTests (fbxPath);
642-
Assert.That (fbxPath, Is.Not.Null);
643-
644-
SkinnedMeshRenderer originalSkinnedMesh, exportedSkinnedMesh;
645-
ExportSkinnedMesh (fbxPath, out originalSkinnedMesh, out exportedSkinnedMesh);
644+
// Test Bone Weights
646645

647646
var origVerts = originalSkinnedMesh.sharedMesh.vertices;
648647
Assert.That (origVerts, Is.Not.Null);
@@ -699,7 +698,6 @@ public void TestBoneWeightExport(string fbxPath){
699698
Debug.LogWarningFormat ("Compared {0} out of a possible {1} bone weights", comparisonCount, minVertCount);
700699
}
701700

702-
703701
public class Vector3Comparer : IComparer<Vector3>
704702
{
705703
public int Compare(Vector3 a, Vector3 b)

Assets/com.unity.formats.fbx.tests/Models/MultiRootCharacters.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/com.unity.formats.fbx.tests/Models/MultiRootCharacters/BasicSeparateBind.fbx.meta

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/com.unity.formats.fbx.tests/Models/MultiRootCharacters/BonesParentedInMesh.fbx.meta

Lines changed: 132 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)