private void ReaderSCO(string fileName) { SCOLoader loader = new SCOLoader(); SCOFile sco = loader.Read(fileName); lbAIMeshVerticsCount.Text = sco.CurrentAIMesh.Vertices.Count.ToString(); lbAIMeshEdgeCount.Text = sco.CurrentAIMesh.Edages.Count.ToString(); lbAIMeshFaceCount.Text = sco.CurrentAIMesh.Faces.Count.ToString(); lbGroundPaintLayerNum.Text = sco.CurrentGroundPaint != null?sco.CurrentGroundPaint.Layers.Count.ToString() : "N/A"; lbGroundPaintLayerSize.Text = sco.CurrentGroundPaint != null?sco.CurrentGroundPaint.SizeX.ToString() + "," + sco.CurrentGroundPaint.SizeY.ToString() : "N/A"; txtMissionObjectCount.Text = sco.MissionObjects.Count.ToString(); missionObject.Items.Clear(); foreach (var missObj in sco.MissionObjects) { ListViewItem lvi = new ListViewItem(); lvi.Text = missObj.ID; lvi.SubItems.Add(missObj.MetaType.ToString()); lvi.SubItems.Add(missObj.SubKindNo.ToString()); lvi.SubItems.Add(missObj.VariationId.ToString()); lvi.SubItems.Add(missObj.VariationId2.ToString()); missionObject.Items.Add(lvi); } }
public void Open(string currentFile) { SCOLoader loader = new SCOLoader(); scoFile = loader.Read(currentFile); currentFilePath = currentFile; mainWin.SetState(FormState.Open); }
public static SCBFile ConvertSCO(SCOFile SCO) { List <UInt32> Indices = new List <UInt32>(); List <Vector2> UV = new List <Vector2>(); foreach (SCOFace Face in SCO.Faces) { Indices.AddRange(Face.Indices.Cast <UInt32>()); UV.AddRange(Face.UV); } return(new SCBFile(Indices, SCO.Vertices, UV)); }
public static OBJFile ConvertSCO(SCOFile SCO) { List <UInt16> Indices = new List <UInt16>(); List <Vector2> UV = new List <Vector2>(); foreach (SCOFace Face in SCO.Faces) { Indices.AddRange(Face.Indices); UV.AddRange(Face.UV); } return(new OBJFile(SCO.Vertices, UV, Indices)); }
/// <summary> /// Converts <paramref name="sco"/> to an <see cref="SCBFile"/> /// </summary> /// <param name="sco">The <see cref="SCOFile"/> to convert to an <see cref="SCBFile"/></param> /// <returns>An <see cref="SCBFile"/> converted from <paramref name="sco"/></returns> public static SCBFile ConvertSCO(SCOFile sco) { List <uint> indices = new List <uint>(); List <Vector2> uvs = new List <Vector2>(); foreach (KeyValuePair <string, List <SCOFace> > material in sco.Materials) { foreach (SCOFace face in material.Value) { indices.AddRange(face.Indices); uvs.AddRange(face.UVs); } } return(new SCBFile(sco.Vertices, indices, uvs)); }
public SKNFile(WGTFile Weights, SCOFile Model) { this.Submeshes.Add(new SKNSubmesh(Model.Name, 0, (uint)Model.Vertices.Count, 0, (uint)Model.Faces.Count * 3)); foreach (Vector3 Vertex in Model.Vertices) { this.Vertices.Add(new SKNVertex(Vertex)); } for (int i = 0; i < this.Vertices.Count; i++) { this.Vertices[i].SetWeight(Weights.Weights[i].Indices, Weights.Weights[i].Weights); } for (int i = 0; i < Model.Faces.Count; i++) { for (int j = 0; j < 3; j++) { this.Vertices[Model.Faces[i].Indices[j]].SetUV(Model.Faces[i].UV[j]); } for (int j = 0; j < 3; j++) { this.Indices.Add(Model.Faces[i].Indices[j]); } } for (int i = 0; i < Indices.Count; i += 3) { Vector3 cp = Vector3.Cross( Vertices[Indices[i + 1]].Position - Vertices[Indices[i]].Position, Vertices[Indices[i + 2]].Position - Vertices[Indices[i]].Position); Vertices[Indices[i]].SetNormal(Vertices[Indices[i]].Normal + cp); Vertices[Indices[i + 1]].SetNormal(Vertices[Indices[i + 1]].Normal + cp); Vertices[Indices[i + 2]].SetNormal(Vertices[Indices[i + 2]].Normal + cp); } foreach (SKNVertex Vertex in Vertices) { float s = Vertex.Normal.X + Vertex.Normal.Y + Vertex.Normal.Z; Vertex.SetNormal(new Vector3( Vertex.Normal.X / s, Vertex.Normal.Y / s, Vertex.Normal.Z / s ) ); } }
public GeometryModel3D applyMesh(SCOFile scb) { List <uint> indices = new List <uint>(); List <Vector2> uv = new List <Vector2>(); foreach (KeyValuePair <string, List <SCOFace> > material in scb.Materials) { foreach (SCOFace 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); }
public ucMissionObjectEditor(ref SCOFile scoFile) { InitializeComponent(); this.scoFile = scoFile; LoadMissionObjects(); }
static void SCOTest() { SCOFile sco = new SCOFile("Aatrox_Basic_A_trail_01.sco"); sco.Write("kek.sco"); }
/// <summary> /// Converts <paramref name="weights"/> and <paramref name="model"/> to an <see cref="SKNFile"/> /// </summary> /// <param name="weights">The <see cref="WGTFile"/> to be used for weights</param> /// <param name="model">The <see cref="SCOFile"/> to be used for model data</param> /// <returns>An <see cref="SKNFile"/> converted from <paramref name="weights"/> and <paramref name="model"/></returns> public static SKNFile ConvertLegacyModel(WGTFile weights, SCOFile model) { return(new SKNFile(weights, model)); }
public ucAIMeshEditor(SCOFile scoFile) { InitializeComponent(); this.scoFile = scoFile; LoadAIMesh(); }
public ucGroudPaintLayerEditor(SCOFile scoFile) { InitializeComponent(); this.scoFile = scoFile; LoadGroudPaintLayers(); }
/// <summary> /// Initializes a new <see cref="SKNFile"/> from legacy files /// </summary> /// <param name="weightsFile">Weights of this <see cref="SKNFile"/></param> /// <param name="modelFile">Model Data of this <see cref="SKNFile"/></param> public SKNFile(WGTFile weightsFile, SCOFile modelFile) { List <Vector3> vertices = new List <Vector3>(); List <Vector4Byte> boneIndices = new List <Vector4Byte>(); List <Vector4> weights = new List <Vector4>(); List <Vector2> uvs = new List <Vector2>(); List <uint> indices = new List <uint>(); foreach (WGTWeight weight in weightsFile.Weights) { boneIndices.Add(weight.BoneIndices); weights.Add(weight.Weights); } foreach (KeyValuePair <string, List <SCOFace> > material in modelFile.Materials) { foreach (SCOFace face in material.Value) { indices.AddRange(face.Indices); for (int i = 0; i < 3; i++) { vertices.Add(modelFile.Vertices[(int)face.Indices[i]]); uvs.Add(face.UVs[i]); } } } //Calculates smooth normals for the mesh List <Vector3> normals = new List <Vector3>(new Vector3[vertices.Count]); for (int i = 0; i < indices.Count; i += 3) { uint a = indices[i]; uint b = indices[i + 1]; uint c = indices[i + 2]; Vector3 edgeA = vertices[(int)a] - vertices[(int)b]; Vector3 edgeB = vertices[(int)c] - vertices[(int)b]; Vector3 normal = Vector3.Cross(edgeA, edgeB); normals[(int)a] = normal; normals[(int)b] = normal; normals[(int)c] = normal; } //Normalizes normals for (int j = 0; j < normals.Count; j++) { Vector3 normalNormalize = normals[j]; float sum = normalNormalize.X + normalNormalize.Y + normalNormalize.Z; normals[j] = new Vector3(normalNormalize.X / sum, normalNormalize.Y / sum, normalNormalize.Z / sum); } //Creates SKNVertex list from componets List <SKNVertex> sknVertices = new List <SKNVertex>(); for (int i = 0; i < vertices.Count; i++) { sknVertices.Add(new SKNVertex(vertices[i], boneIndices[i], weights[i], normals[i], uvs[i])); } //Creates Submeshes based on the Materials in the SCO File int indexOffset = 0; foreach (KeyValuePair <string, List <SCOFace> > material in modelFile.Materials) { this.Submeshes.Add(new SKNSubmesh(material.Key, indices.GetRange(indexOffset, material.Value.Count).Cast <ushort>().ToList(), sknVertices.GetRange(indexOffset, material.Value.Count), this)); } }
public static SKNFile ConvertLegacyModel(WGTFile Weights, SCOFile Model) { return(new SKNFile(Weights, Model)); }
public void New(string saveFilePath) { scoFile = new SCOFile(); currentFilePath = saveFilePath; mainWin.SetState(FormState.New); }