public static void ConvertSkinnedModel(SkinnedModelToGltf opts) { SimpleSkin simpleSkin = ReadSimpleSkin(opts.SimpleSkinPath); Skeleton skeleton = ReadSkeleton(opts.SkeletonPath); var gltf = simpleSkin.ToGltf(skeleton, opts.MaterialTextures, opts.Animations); gltf.Save(opts.OutputPath); }
private static int ConvertSkinnedModel(SkinnedModelToGltfOptions opts) { try { Skeleton skeleton = ReadSkeleton(opts.SkeletonPath); List <(string, LeagueAnimation)> animations = null; if (!string.IsNullOrEmpty(opts.AnimationsFolder)) { string[] animationFiles = Directory.GetFiles(opts.AnimationsFolder, "*.anm"); animations = ReadAnimations(animationFiles); } else { animations = ReadAnimations(opts.AnimationPaths); } // Check animation compatibility foreach (var animation in animations) { if (!animation.Item2.IsCompatibleWithSkeleton(skeleton)) { Console.WriteLine("Warning: Found an animation that's potentially not compatible with the provided skeleton - " + animation.Item1); } } SkinnedModelToGltf skinnedModelToGltf = new SkinnedModelToGltf() { OutputPath = opts.OutputPath, Animations = animations, MaterialTextures = CreateMaterialTextureMap(opts.MaterialTextures), SimpleSkinPath = opts.SimpleSkinPath, SkeletonPath = opts.SkeletonPath }; LeagueConverter.ConvertSkinnedModel(skinnedModelToGltf); } catch (Exception exception) { Console.WriteLine("Failed to convert Skinned Model to glTF"); Console.WriteLine(exception); } return(1); }
public void TestConvertSkinnedModelToGltf(string modelName) { string modelDirectoryPath = Path.Join(TESTFILES_SIMPLE_SKIN_DIR, modelName); var materialTextureMap = CreateMaterialTextureMap(modelName); SkinnedModelToGltf skinnedModelToGltf = new SkinnedModelToGltf() { OutputPath = Path.Join(TESTFILES_SIMPLE_SKIN_DIR, modelName, modelName + "_skinned" + ".glb"), MaterialTextures = materialTextureMap, SimpleSkinPath = Path.Join(modelDirectoryPath, modelName + ".skn"), Animations = CreateAnimations(modelName), SkeletonPath = Path.Join(modelDirectoryPath, modelName + ".skl") }; Assert.DoesNotThrow(() => Converter.ConvertSkinnedModel(skinnedModelToGltf), "Failed to convert skinned model to gltf: {0}", modelName); Assert.Pass("Successfully converted skinned model <{0}> to glTF", modelName); }