public void UpdateModelPointer() { if (ModelPointer == 0) { _textBoxAddress.Text = ModelPointer == 0 ? "0x00000000" : "(None)"; _dataGridViewVertices.Rows.Clear(); _dataGridViewTriangles.Rows.Clear(); _modelView?.ClearModel(); return; } _textBoxAddress.Text = String.Format("0x{0:X8}", ModelPointer); uint modelPtr = ModelPointer; List <short[]> vertices = GetVerticesFromModelPointer(ref modelPtr); List <int[]> triangles = GetTrianglesFromContinuedModelPonter(modelPtr); _modelView?.ChangeModel(vertices, triangles); // TODO: transformation _dataGridViewVertices.Rows.Clear(); for (int i = 0; i < vertices.Count; i++) { short[] v = vertices[i]; _dataGridViewVertices.Rows.Add(i, v[0], v[1], v[2]); } _dataGridViewTriangles.Rows.Clear(); for (int i = 0; i < triangles.Count; i++) { int[] t = triangles[i]; _dataGridViewTriangles.Rows.Add(t[3], t[4], t[0], t[1], t[2]); } }
private void SwitchLevelModel() { List <TriangleDataModel> triangleStructs = TriangleUtilities.GetLevelTriangles(); // Build vertice and triangle list from triangle set List <int[]> triangles = new List <int[]>(); List <short[]> vertices = new List <short[]>(); List <int> surfaceTypes = new List <int>(); triangleStructs.ForEach(t => { var vIndex = vertices.Count; triangles.Add(new int[] { vIndex, vIndex + 1, vIndex + 2 }); surfaceTypes.Add(t.SurfaceType); vertices.Add(new short[] { t.X1, t.Y1, t.Z1 }); vertices.Add(new short[] { t.X2, t.Y2, t.Z2 }); vertices.Add(new short[] { t.X3, t.Y3, t.Z3 }); }); _modelView?.ChangeModel(vertices, triangles); // Update tables dataGridViewVertices.Rows.Clear(); for (int i = 0; i < vertices.Count; i++) { short[] v = vertices[i]; dataGridViewVertices.Rows.Add(i, v[0], v[1], v[2]); } dataGridViewTriangles.Rows.Clear(); for (int i = 0; i < triangles.Count; i++) { int[] t = triangles[i]; dataGridViewTriangles.Rows.Add(0, surfaceTypes[i], t[0], t[1], t[2]); } dataGridViewTriangles.SelectAll(); ModelObjectAddress = _previousModelPointer = 0; }