static void Main(string[] args) { string[] files = Directory.GetFiles(args[0]); foreach (string file in files) { try { Stream stream = File.Open(file, FileMode.Open); SCBFile scb = new SCBFile(stream); List <uint> indices = new List <uint>(); List <Vector2> uvs = new List <Vector2>(); foreach (KeyValuePair <string, List <SCBFace> > material in scb.Materials) { foreach (SCBFace face in material.Value) { indices.AddRange(face.Indices); uvs.AddRange(face.UVs); } } List <OBJFace> Faces = new List <OBJFace>(); for (int i = 0; i < indices.Count; i += 3) { uint[] faceIndices = new uint[] { indices[i], indices[i + 1], indices[i + 2] }; Faces.Add(new OBJFace(faceIndices, faceIndices)); } string name = Path.GetFileNameWithoutExtension(file); Stream streame = File.OpenWrite(args[1] + "/" + name + ".obj"); using (StreamWriter sw = new StreamWriter(streame)) { foreach (Vector3 vertex in scb.Vertices) { sw.WriteLine(string.Format("v {0} {1} {2}", vertex.X, vertex.Y, vertex.Z)); } foreach (Vector2 uv in uvs) { sw.WriteLine(string.Format("vt {0} {1}", uv.X, 1 - uv.Y)); } foreach (OBJFace face in Faces) { face.Write(sw); } } } catch { continue; } } }
public static SCOFile ConvertSCB(SCBFile SCB) { List <UInt16> Indices = new List <UInt16>(); List <Vector2> UV = new List <Vector2>(); foreach (SCBFace Face in SCB.Faces) { Indices.AddRange(Face.Indices.AsEnumerable().Cast <UInt16>()); UV.AddRange(Face.UV); } return(new SCOFile(Indices, SCB.Vertices, UV)); }
/// <summary> /// Converts <paramref name="scb"/> to an <see cref="SCOFile"/> /// </summary> /// <param name="scb">The <see cref="SCBFile"/> to convert to an <see cref="SCOFile"/></param> /// <returns>An <see cref="SCOFile"/> converted from <paramref name="scb"/></returns> public static SCOFile ConvertSCB(SCBFile scb) { List <uint> indices = new List <uint>(); List <Vector2> uvs = new List <Vector2>(); foreach (KeyValuePair <string, List <SCBFace> > material in scb.Materials) { foreach (SCBFace face in material.Value) { indices.AddRange(face.Indices); uvs.AddRange(face.UVs); } } return(new SCOFile(scb.Vertices, indices, uvs)); }
public static OBJFile ConvertSCB(SCBFile SCB) { List <UInt16> Indices = new List <UInt16>(); List <Vector2> UV = new List <Vector2>(); foreach (SCBFace Face in SCB.Faces) { //Indices.AddRange(Face.Indices.AsEnumerable().Cast<ushort>()); int count = Face.Indices.Length; for (int i = 0; i < count; i++) { Indices.Add((ushort)Face.Indices[i]); } UV.AddRange(Face.UV); } return(new OBJFile(SCB.Vertices, UV, Indices)); }
public GeometryModel3D applyMesh(SCBFile scb) { List <uint> indices = new List <uint>(); List <Vector2> uv = new List <Vector2>(); foreach (KeyValuePair <string, List <SCBFace> > material in scb.Materials) { foreach (SCBFace face in material.Value) { indices.AddRange(face.Indices); uv.AddRange(face.UVs); } } var mesh = new MeshGeometry3D(); foreach (var x in scb.Vertices) { mesh.Positions.Add(new Point3D(x.X, x.Y, x.Z)); } foreach (var x in indices) { mesh.TriangleIndices.Add((int)x); } foreach (var x in uv) { mesh.TextureCoordinates.Add(new Point(x.X, x.Y)); } var model = new GeometryModel3D(); model.Geometry = mesh; _modelGroup.Children.Add(model); return(model); }
static void SCBTest() { SCBFile scb = new SCBFile("aatrox_skin02_q_pulse_01.scb"); scb.Write("aatrox_skin02_q_pulse_01Write.scb"); }