private static void ReadMeshes(FSHP fshp, Shape shp) { fshp.lodMeshes.Clear(); foreach (Mesh msh in shp.Meshes) { uint FaceCount = msh.IndexCount; uint[] indicesArray = msh.GetIndices().ToArray(); FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh(); foreach (SubMesh subMsh in msh.SubMeshes) { FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh(); sub.size = subMsh.Count; sub.offset = subMsh.Offset; lod.subMeshes.Add(sub); } lod.IndexFormat = (STIndexFormat)msh.IndexFormat; lod.PrimitiveType = (STPolygonType)msh.PrimitiveType; lod.FirstVertex = msh.FirstVertex; for (int face = 0; face < FaceCount; face++) { lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex); } fshp.lodMeshes.Add(lod); } }
private void lodListView_SelectedIndexChanged(object sender, EventArgs e) { if (lodListView.SelectedIndices.Count > 0) { btnFacesView.Enabled = true; subMeshesViewBtn.Enabled = true; int index = lodListView.SelectedIndices[0]; activeLodMesh = activeShape.lodMeshes[index]; lodFormatCB.Bind(typeof(STIndexFormat), activeLodMesh, "IndexFormat"); lodFormatCB.SelectedItem = activeLodMesh.IndexFormat; lodPrimativeTypeCB.Bind(typeof(STPrimitiveType), activeLodMesh, "PrimitiveType"); lodPrimativeTypeCB.SelectedItem = activeLodMesh.PrimativeType; lodVertexSkipUD.Value = activeLodMesh.FirstVertex; lodFaceCountUD.Value = activeLodMesh.faces.Count; } else { btnFacesView.Enabled = false; activeLodMesh = null; lodFormatCB.DataSource = null; lodPrimativeTypeCB.DataSource = null; lodFormatCB.Items.Clear(); lodPrimativeTypeCB.Items.Clear(); lodVertexSkipUD.Value = 0; lodFaceCountUD.Value = 0; subMeshesViewBtn.Enabled = false; } }
private static void ReadMeshes(FSHP fshp, Shape shp) { fshp.lodMeshes.Clear(); foreach (Mesh msh in shp.Meshes) { uint FaceCount = msh.IndexCount; uint[] indicesArray = msh.GetIndices().ToArray(); FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh(); foreach (SubMesh subMsh in msh.SubMeshes) { FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh(); sub.size = subMsh.Count; sub.offset = subMsh.Offset; lod.subMeshes.Add(sub); } lod.IndexFormat = (STIndexFormat)msh.IndexFormat; switch (msh.PrimitiveType) { case GX2PrimitiveType.Triangles: lod.PrimativeType = STPrimitiveType.Triangles; break; case GX2PrimitiveType.TriangleStrip: lod.PrimativeType = STPrimitiveType.TrangleStrips; break; case GX2PrimitiveType.Quads: lod.PrimativeType = STPrimitiveType.Quads; break; case GX2PrimitiveType.Lines: lod.PrimativeType = STPrimitiveType.Lines; break; case GX2PrimitiveType.LineStrip: lod.PrimativeType = STPrimitiveType.LineStrips; break; case GX2PrimitiveType.Points: lod.PrimativeType = STPrimitiveType.Points; break; } lod.FirstVertex = msh.FirstVertex; for (int face = 0; face < FaceCount; face++) { lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex); } fshp.lodMeshes.Add(lod); } }
public void LoadMesh(FSHP.LOD_Mesh mesh, FSHP fshp) { activeShape = fshp; activeMesh = mesh; int index = 0; foreach (var subMesh in mesh.subMeshes) { listViewCustom1.Items.Add($"Sub Mesh{index}"); } }