//public static OBJFile VisualiseNVRNodes(NVRFile Nvr) //{ // List<UInt16> Indices = new List<UInt16>(); // List<UInt16> BaseIndices = new List<UInt16>() // { // 0, 1, 2, // 0, 3, 2, // 4, 5, 6, // 4, 7, 6, // 6, 5, 1, // 6, 2, 1, // 0, 4, 7, // 0, 3, 7, // 2, 6, 7, // 2, 3, 7, // 0, 1, 5, // 0, 4, 5 // }; // List<Vector3> Vertices = new List<Vector3>(); // List<NVRNode> Nodes = Nvr.GetNodes(); // foreach (NVRNode Node in Nodes) // { // /* 0 Vector3 minLeftUp = Node.BoundingBox.Min; // 1 Vector3 minRightUp = new Vector3(Node.BoundingBox.Min.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z); // 2 Vector3 minLeftDown = new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Min.Z); // 3 Vector3 minRightDown = new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z); // 6 Vector3 maxRightDown = Node.BoundingBox.Max; // 7 Vector3 maxLeftDown = new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Max.Y, Node.BoundingBox.Min.Z); // 4 Vector3 maaxLeftUp = new Vector3(Node.BoundingBox.Min.X, Node.BoundingBox.Max.Y, Node.BoundingBox.Min.Z); // 5 Vector3 maxRightUp = new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z);*/ // Vertices.AddRange(new Vector3[] // { // Node.BoundingBox.Min, // new Vector3(Node.BoundingBox.Min.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z), // new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Min.Z), // new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z), // new Vector3(Node.BoundingBox.Min.X, Node.BoundingBox.Max.Y, Node.BoundingBox.Min.Z), // new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Min.Y, Node.BoundingBox.Max.Z), // Node.BoundingBox.Max, // new Vector3(Node.BoundingBox.Max.X, Node.BoundingBox.Max.Y, Node.BoundingBox.Min.Z), // }); // } // for (int i = 0; i * 8 < Vertices.Count; i++) // { // Indices.AddRange(BaseIndices); // for (int j = 0; j < BaseIndices.Count; j++) // { // BaseIndices[j] += 8; // } // } // return new OBJFile(Vertices, Indices); //} /// <summary> /// Converts <paramref name="model"/> to an <see cref="OBJFile"/> /// </summary> /// <param name="model">The <see cref="SimpleSkin"/> to convert to a <see cref="OBJFile"/></param> /// <returns>An <see cref="OBJFile"/> converted from <paramref name="model"/></returns> public static OBJFile ConvertSKN(SimpleSkin model) { List <uint> indices = new List <uint>(); List <Vector3> vertices = new List <Vector3>(); List <Vector2> uv = new List <Vector2>(); List <Vector3> normals = new List <Vector3>(); uint indexOffset = 0; foreach (SimpleSkinSubmesh submesh in model.Submeshes) { indices.AddRange(submesh.Indices.Select(x => x + indexOffset)); foreach (SimpleSkinVertex vertex in submesh.Vertices) { vertices.Add(vertex.Position); uv.Add(vertex.UV); normals.Add(vertex.Normal); } indexOffset += submesh.Indices.Min(); } return(new OBJFile(vertices, indices, uv, normals)); }
// ------------- COMMANDS ------------- \\ public static void ConvertSimpleSkin(SimpleSkinToGltf opts) { SimpleSkin simpleSkin = ReadSimpleSkin(opts.SimpleSkinPath); var gltf = simpleSkin.ToGltf(opts.MaterialTextures); gltf.Save(opts.OutputPath); }
private static void ConvertSimpleSkinToGltf(FileConversionParameter parameter) { WadEntry simpleSkinWadEntry = parameter.Parameter; SimpleSkin simpleSkin = new SimpleSkin(simpleSkinWadEntry.GetDataHandle().GetDecompressedStream()); ModelRoot gltf = simpleSkin.ToGltf(); gltf.SaveGLB(Path.ChangeExtension(parameter.OutputPath, "glb")); }
public static void CreateSimpleSkinFromLegacy(CreateSimpleSkinFromLegacy opts) { StaticObject staticObject = StaticObject.ReadSCO(opts.StaticObjectPath); WGTFile weightFile = new WGTFile(opts.WeightFilePath); SimpleSkin simpleSkin = new SimpleSkin(staticObject, weightFile); simpleSkin.Write(opts.SimpleSkinPath); }
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 void ConvertSimpleSkinToGltf(FileConversionParameter parameter) { WADEntry simpleSkinWadEntry = parameter.Parameter; using MemoryStream stream = new MemoryStream(simpleSkinWadEntry.GetContent(true)); SimpleSkin simpleSkin = new SimpleSkin(stream); ModelRoot gltf = simpleSkin.ToGltf(); gltf.SaveGLB(Path.ChangeExtension(parameter.OutputPath, "glb")); }
private static int DumpSimpleSkinInfo(DumpSimpleSkinInfoOptions opts) { SimpleSkin simpleSkin = ReadSimpleSkin(opts.SimpleSkinPath); if (simpleSkin != null) { DumpSimpleSkinInfo(simpleSkin); } return(1); }
private static void ConvertSimpleSkinWithSkeletonToGltf(FileConversionParameter parameter) { WadEntry simpleSkinWadEntry = parameter.Parameter; WadEntry skeletonWadEntry = parameter.AdditionalParameters.FirstOrDefault(x => x.Item1 == FileConversionAdditionalParameterType.Skeleton).Item2; SimpleSkin simpleSkin = new SimpleSkin(simpleSkinWadEntry.GetDataHandle().GetDecompressedStream()); Skeleton skeleton = new Skeleton(skeletonWadEntry.GetDataHandle().GetDecompressedStream()); ModelRoot gltf = simpleSkin.ToGltf(skeleton); gltf.SaveGLB(Path.ChangeExtension(parameter.OutputPath, "glb")); }
public SimpleSkinViewModel(SimpleSkin simpleSkin) { this.SimpleSkin = simpleSkin; foreach (SimpleSkinSubmesh submesh in simpleSkin.Submeshes) { this.Submeshes.Add(new SimpleSkinSubmeshViewModel(submesh)); this.VertexCount += submesh.Vertices.Count; this.FaceCount += submesh.Indices.Count / 3; } }
static void Main(string[] args) { SimpleSkin simpleSkin = new SimpleSkin(@"C:\Users\Crauzer\Desktop\New folder\assets\characters\aatrox\skins\base\aatrox.skn"); Skeleton skeleton = new Skeleton(@"C:\Users\Crauzer\Desktop\New folder\assets\characters\aatrox\skins\base\aatrox.skl"); var textureMap = new Dictionary <string, MagickImage>() { { "Body", new MagickImage(@"C:\Users\Crauzer\Desktop\New folder\assets\characters\aatrox\skins\base\aatrox_base_tx_cm.dds") } }; ModelRoot gltf = simpleSkin.ToGltf(skeleton, textureMap); gltf.SaveGLB(@"C:\Users\Crauzer\Desktop\New folder\assets\characters\aatrox\skins\base\aatrox.glb"); }
private static void ConvertSimpleSkinWithSkeletonToGltf(FileConversionParameter parameter) { WADEntry simpleSkinWadEntry = parameter.Parameter; WADEntry skeletonWadEntry = parameter.AdditionalParameters.FirstOrDefault(x => x.Item1 == FileConversionAdditionalParameterType.Skeleton).Item2; using MemoryStream simpleSkinStream = new MemoryStream(simpleSkinWadEntry.GetContent(true)); using MemoryStream skeletonStream = new MemoryStream(skeletonWadEntry.GetContent(true)); SimpleSkin simpleSkin = new SimpleSkin(simpleSkinStream); Skeleton skeleton = new Skeleton(skeletonStream); ModelRoot gltf = simpleSkin.ToGltf(skeleton); gltf.SaveGLB(Path.ChangeExtension(parameter.OutputPath, "glb")); }
/// <summary> /// Converts the Submeshes of the specified <see cref="SimpleSkin"/> into a List of <see cref="OBJFile"/> /// </summary> /// <param name="model"><see cref="SimpleSkin"/> to convert</param> public static IEnumerable <Tuple <string, OBJFile> > ConvertSKNModels(SimpleSkin model) { foreach (SimpleSkinSubmesh submesh in model.Submeshes) { List <uint> indices = new List <uint>(); List <Vector3> vertices = new List <Vector3>(); List <Vector2> uv = new List <Vector2>(); List <Vector3> normals = new List <Vector3>(); indices.AddRange(submesh.Indices.Select(i => (uint)i)); foreach (SimpleSkinVertex vertex in submesh.Vertices) { vertices.Add(vertex.Position); uv.Add(vertex.UV); normals.Add(vertex.Normal); } yield return(new Tuple <string, OBJFile>(submesh.Name, new OBJFile(vertices, indices, uv, normals))); } }
private static void DumpSimpleSkinInfo(SimpleSkin simpleSkin) { Console.WriteLine("----------SIMPLE SKIN INFO----------"); R3DBox boundingBox = simpleSkin.GetBoundingBox(); Console.WriteLine("Bounding Box:"); Console.WriteLine("\t Min: " + boundingBox.Min.ToString()); Console.WriteLine("\t Max: " + boundingBox.Max.ToString()); Console.WriteLine("Submesh Count: " + simpleSkin.Submeshes.Count); foreach (SimpleSkinSubmesh submesh in simpleSkin.Submeshes) { Console.WriteLine("--- SUBMESH ---"); Console.WriteLine("Material: " + submesh.Name); Console.WriteLine("Vertex Count: " + submesh.Vertices.Count); Console.WriteLine("Index Count: " + submesh.Indices.Count); Console.WriteLine("Face Count: " + submesh.Indices.Count / 3); Console.WriteLine(); } }