private void AddCube(Point coordinates, int index) { var l = new List<Solid>(); var k = new Solid(); //MathOperations.DebugMatrix(k.Points); switch (index) { case 0: k.Points = MathOperations.MatrixMultiplication( MathOperations.Translation(coordinates.X, 0, coordinates.Y), k.Points); k.ComputeVisibility(new Vector(0, 1, 0)); break; case 1: k.Points = MathOperations.MatrixMultiplication( MathOperations.Translation(0, coordinates.Y, coordinates.X), k.Points); k.ComputeVisibility(new Vector(1, 0, 0)); break; case 2: k.Points = MathOperations.MatrixMultiplication( MathOperations.Translation(coordinates.X, coordinates.Y, 0), k.Points); k.ComputeVisibility(new Vector(0, 0, 1)); break; } //MathOperations.DebugMatrix(k.Points); l.Add(k); solidsList.Add(l); //Console.WriteLine(l[0]); }
private void DrawSolidFaces(Solid solid, PictureBox pc, int ipc, Pen myPen = null) { var x = 0; var y = 0; switch (ipc) { case 0: //Top View x = 0; y = 2; solid.ComputeVisibility(new Vector(solid.Points[0, 8], 1, solid.Points[2, 8])); break; case 1: //Front View x = 0; y = 1; solid.ComputeVisibility(new Vector(solid.Points[0, 8], solid.Points[1, 8], 1)); break; case 2: //Left View x = 2; y = 1; solid.ComputeVisibility(new Vector(1, solid.Points[1, 8], solid.Points[2, 8])); break; case 3: //Perspective x = 0; y = 1; if (isometricCheckBox.Checked) { solid.ComputeVisibility(new Vector(0, 0, 1), new Vector(0, 0, 0)); } else { solid.ComputeVisibility(VRP, P); } break; } var g = Graphics.FromImage(pc.Image); g.SmoothingMode = SmoothingMode.AntiAlias; if (myPen == null) { myPen = new Pen(Color.Black, 1); } var matrix = solid.Points; for (var i = 0; i < 6; i++) { if (!solid.VisibleFaces[i] && hideFacesBox.Checked) continue; for (int j = 0; j < 3; j++) { g.DrawLine(myPen, (float)matrix[x, solid.Faces[i, j]], (float)matrix[y, solid.Faces[i, j]], (float)matrix[x, solid.Faces[i, j + 1]], (float)matrix[y, solid.Faces[i, j + 1]]); } g.DrawLine(myPen, (float)matrix[x, solid.Faces[i, 3]], (float)matrix[y, solid.Faces[i, 3]], (float)matrix[x, solid.Faces[i, 0]], (float)matrix[y, solid.Faces[i, 0]]); } pc.Invalidate(); }