public void DrawCube(Plotter3D p, float XWidth, float YHeight, float ZThick) { /* for (int i = 0; i < 4; i++) * { * //DrawSquare(p, sideLength); * DrawRect(p, sideLength+10, sideLength-10); * p.Forward(sideLength); * p.TurnDown(90); * } */ DrawRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); DrawRect(p, ZThick, YHeight); p.Forward(ZThick); p.TurnDown(90); DrawRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); DrawRect(p, ZThick, YHeight); }
private void drawWinningLine(Plotter3D p, Board board, Player winner) { p.PenWidth = (float)7.5; p.PenColor = Color.White; int[,] winningLine = winner.getWin(); if ((boardAngle == defaultBoardAngle) && winningLine != null) { for (int i = 0; i < 4; i++) { int z = winningLine[i, 0]; int y = winningLine[i, 1]; int x = winningLine[i, 2]; p.Location = new CPI.Plot3D.Point3D((int)defaultXCord - (y * 11) + (int)sideLength * x * 3, (int)defaultYCord - (y * 2) + (int)sideLength * y + planeDistance * z, 0); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } } }
private void DrawRotatedSquare(Plotter3D p, float sideLength, float rotationAngle) { // Since we don't want to draw while repositioning ourselves at the // center of the object, we'll lift the pen up p.PenUp(); // Move to the center of the square p.Forward(sideLength / 2); p.TurnRight(90); p.Forward(sideLength / 2); p.TurnLeft(90); // Now we rotate as much as we want p.TurnRight(rotationAngle); // Now we retrace our steps to get back // to the (rotated) starting point p.TurnLeft(90); p.Forward(sideLength / 2); p.TurnLeft(90); p.Forward(sideLength / 2); p.TurnRight(180); // Put the pen back down, so we start drawing again p.PenDown(); // Finally we draw the square as we normally would DrawSquare(p, sideLength); }
private void DrawCircle(Plotter3D p, float diameter) { float radius = diameter / 2; // Increasing this number will create a better approximation, // but will require more work to draw int sides = 64; float innerAngle = 360F / sides; float sideLength = (float)(radius * Math.Sin(Orientation3D.DegreesToRadians(innerAngle) / 2) * 2); // Save the initial position and orientation of the cursor Point3D initialLocation = p.Location; Orientation3D initialOrientation = p.Orientation.Clone(); // Move to the starting point of the circle p.PenUp(); p.Forward(radius - (sideLength / 2)); p.PenDown(); // Draw the circle for (int i = 0; i < sides; i++) { p.Forward(sideLength); p.TurnRight(innerAngle); } // Restore the position and orientation to what they were before // we drew the circle p.Location = initialLocation; p.Orientation = initialOrientation; }
public void DrawSphere(Plotter3D p, float diameter) { Point3D initialLocation = p.Location; Orientation3D initialOrientation = p.Orientation.Clone(); for (int i = 0; i < 180; i += 20) { p.PenUp(); p.Forward(diameter / 2); // Rotate appropriately p.TurnDown(i); // Go back to the starting point p.TurnDown(180); p.Forward(diameter / 2); p.TurnDown(180); p.PenDown(); DrawCircle(p, 100); p.Orientation = initialOrientation.Clone(); p.Location = initialLocation; } }
public void Draw3DCube(Plotter3D p, float XWidth, float YHeight, float ZThick) { /* for (int i = 0; i < 4; i++) * { * //DrawSquare(p, sideLength); * DrawRect(p, sideLength+10, sideLength-10); * p.Forward(sideLength); * p.TurnDown(90); * } */ Draw3DRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); Draw3DRect(p, ZThick, YHeight); p.Forward(ZThick); p.TurnDown(90); Draw3DRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); Draw3DRect(p, ZThick, YHeight); //and go to initial position p.PenUp(); p.Forward(ZThick); // Draw a line sideLength long p.TurnDown(90); p.PenDown(); }
public void DrawSquare(Plotter3D p, float sideLength) { for (int i = 0; i < 4; i++) { p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(90); // Turn right 90 degrees } }
// Use this for initialization void Start() { Plotter3D s = (Plotter3D)Instantiate(surface, Vector3.zero, Quaternion.identity); s.transform.SetParent(transform.parent, false); s.Sampling3D(myFn, minX, maxX, minZ, maxZ, offset); s.DrawMesh(); }
public void DrawCube(Plotter3D p, float sideLength) { for (int i = 0; i < 4; i++) { DrawSquare(p, sideLength); p.Forward(sideLength); p.TurnDown(90); } }
public Plotter3D CreateSurface() { if (surface != null) { return(surface); } surface = (Plotter3D)Instantiate(surfacePrefab, Vector3.zero, Quaternion.identity); surface.Sampling3D(MyFn1, 0f, 5f, 0f, 5f, 0.1f); surface.DrawMesh(); return(surface); }
public void Render(Plotter3D p) { foreach (Domino d in dominoArray) { d.Render(p); p.IsPenDown = false; p.Forward(distanceBetweenDominoes); p.IsPenDown = true; } }
private void DrawRhombusRow(Plotter3D p, int y, int z, Board board) { float initX = p.Location.X; float initY = p.Location.Y; for (int i = 0; i < boardX; i++) { DrawRhombus(p, i, y, z, board); p.Location = new CPI.Plot3D.Point3D(p.Location.X + sideLength * (float)3, p.Location.Y, 0); } p.Location = new CPI.Plot3D.Point3D(initX, initY, 0); }
////////////////////////////////////////////////////////////////////// public void DrawRect(Plotter3D p, float sideWidth, float sideHeight) { p.Forward(sideWidth); // Draw a line sideLength long p.TurnRight(90); // Turn right 90 degrees p.Forward(sideHeight); // Draw a line sideLength long p.TurnRight(90); // Turn right 90 degrees p.Forward(sideWidth); // Draw a line sideLength long p.TurnRight(90); // Turn right 90 degrees p.Forward(sideHeight); // Draw a line sideLength long p.TurnRight(90); // Turn right 90 degrees }
void dominoes_PositionChanged(object sender, EventArgs e) { using (Graphics g = this.CreateGraphics()) { System.Threading.Thread.Sleep(50); g.Clear(SystemColors.Control); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; using (Plotter3D p = new Plotter3D(g, new Point3D(350, 100, -600))) { p.Location = new Point3D(100, 200, 0); p.TurnDown(dominoRotationAngle); ((Dominoes)sender).Render(p); } } }
/// <summary> /// Calculates points of cube /// </summary> /// <param name="region">Region of the Cube shape</param> /// <returns>List of calculated <see cref="System.Drawing.PointF"/>s</returns> public static List <PointF> GetCubePoints(Region region) { Plotter3D plotter = new Plotter3D(); List <PointF> cubePoints = new List <PointF>(); plotter.Location = new Point3D(region.X0, region.Y0, 0); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cubePoints.AddRange(plotter.Forward(region.Width)); plotter.TurnRight(90); } cubePoints.AddRange(plotter.Forward(region.Width)); plotter.TurnDown(90); } return(cubePoints); }
private void DrawRhombusPanel(Plotter3D p, int z, Board board) { float initX = p.Location.X; float initY = p.Location.Y; for (int i = 0; i < boardY; i++) { DrawRhombusRow(p, i, z, board); p.PenUp(); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(180); // Turn right 90 degrees p.PenDown(); } p.Location = new CPI.Plot3D.Point3D(initX, initY, 0); }
public void Draw3DCube(Plotter3D p, float XWidth, float YHeight, float ZThick) { Draw3DRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); Draw3DRect(p, ZThick, YHeight); p.Forward(ZThick); p.TurnDown(90); Draw3DRect(p, XWidth, YHeight); p.Forward(XWidth); p.TurnDown(90); Draw3DRect(p, ZThick, YHeight); //and go to initial position p.PenUp(); p.Forward(ZThick); // Draw a line sideLength long p.TurnDown(90); p.PenDown(); }
private void drawMovePreview(Plotter3D p, int x, int y, int z, Board board) { p.PenWidth = (float)7.5; p.PenColor = Color.White; if (boardAngle == defaultBoardAngle || y <= 0) { if (x >= 0 && y >= 0 && z >= 0) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord - (y * 11) + (int)sideLength * x * 3, (int)defaultYCord - (y * 2) + (int)sideLength * y + planeDistance * z, 0); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } else if (x < 0 && y < 0 && z >= 0) { p.Location = new CPI.Plot3D.Point3D(defaultXCord, defaultYCord + planeDistance * z, 0); p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } else if (x < 0 && y >= 0 && z < 0) { for (int zc = 0; zc < 4; zc++) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord - (y * 11), (int)defaultYCord - (y * 2) + (int)sideLength * y + planeDistance * zc, 0); p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } } else if (x >= 0 && y < 0 && z < 0) { for (int zc = 0; zc < 4; zc++) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord + (int)sideLength * x * 3, (int)defaultYCord + planeDistance * zc, 0); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } } else if (x < 0 && y >= 0 && z >= 0) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord - (y * 11), (int)defaultYCord - (y * 2) + (int)sideLength * y + planeDistance * z, 0); p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3 * 4); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } else if (x >= 0 && y < 0 && z >= 0) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord + (int)sideLength * x * 3, (int)defaultYCord + planeDistance * z, 0); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength * 4); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } else if (x >= 0 && y >= 0 && z < 0) { for (int zc = 0; zc < 4; zc++) { p.Location = new CPI.Plot3D.Point3D((int)defaultXCord - (y * 11) + (int)sideLength * x * 3, (int)defaultYCord - (y * 2) + (int)sideLength * y + planeDistance * zc, 0); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } } } }
public void Render(Plotter3D p) { Point3D startLocation = p.Location; Orientation3D startOrientation = p.Orientation.Clone(); bool startPenDown = p.IsPenDown; AngleMeasurement startAngleMeasurement = p.AngleMeasurement; p.AngleMeasurement = AngleMeasurement.Degrees; // Move to the back edge of the domino p.IsPenDown = false; p.Forward(depth); p.TurnUp(90); p.IsPenDown = startPenDown; // Tilt the domino accordingly p.Orientation.RollLeft(90 - fallAngle); // Draw the back surface of the domino p.Forward(width); p.TurnLeft(90); p.Forward(height); p.TurnLeft(90); p.Forward(width); p.TurnLeft(90); p.Forward(height); p.TurnLeft(90); // Draw the middle bits of the domino p.TurnUp(90); p.Forward(depth); p.TurnDown(90); p.IsPenDown = false; p.Forward(width); p.TurnDown(90); p.IsPenDown = startPenDown; p.Forward(depth); p.TurnUp(90); p.TurnLeft(90); p.IsPenDown = false; p.Forward(height); p.TurnUp(90); p.IsPenDown = startPenDown; p.Forward(depth); p.TurnDown(90); p.TurnLeft(90); p.IsPenDown = false; p.Forward(width); p.TurnDown(90); p.IsPenDown = startPenDown; p.Forward(depth); p.IsPenDown = false; p.TurnUp(180); p.Forward(depth); p.TurnUp(90); p.Orientation.RollRight(180); p.IsPenDown = startPenDown; // Draw the front of the domino p.Forward(width); p.TurnRight(90); p.Forward(height); p.TurnRight(90); p.Forward(width); p.TurnRight(90); p.Forward(height); // Return the the start orientation and location, then advance to the back edge of the domino. p.IsPenDown = false; p.Orientation = startOrientation; p.Location = startLocation; p.Forward(depth); p.IsPenDown = startPenDown; p.AngleMeasurement = startAngleMeasurement; }
public void ClearSurface() { surface.Delete(); surface = null; }
private void DrawRhombus(Plotter3D p, int x, int y, int z, Board board) { Player player = null; p.PenWidth = (float)2; p.PenColor = Color.White; try { player = board.getPlayerInPosition(z + 1, y + 1, x + 1); } catch (Exception) { } if (player != null) { //set pen color to the player's color p.PenColor = Color.FromName(player.getColor()); p.PenWidth = (float)6; float initX = p.Location.X; float initY = p.Location.Y; p.PenUp(); //colored in squares p.Forward(sideLength * 3); p.TurnRight(boardAngle); p.Forward(sideLength / 2); p.TurnRight(180 - boardAngle); p.PenWidth = (float)sideLength / (float)1.25; p.PenDown(); p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); p.TurnRight(180 - boardAngle); p.Location = new CPI.Plot3D.Point3D(initX, initY, 0); p.PenWidth = (float)6; // draws the thick color outline p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees } //white thin outline p.PenWidth = (float)2; p.PenColor = Color.White; p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees p.Forward(sideLength * 3); // Draw a line sideLength long p.TurnRight(boardAngle); // Turn right 90 degrees p.Forward(sideLength); // Draw a line sideLength long p.TurnRight(180 - boardAngle); // Turn right 90 degrees //this commented out secion is for displaying the win that works with all angles /* * * int[,] win = null; * * try * { * win = player.getWin(); * } * catch (Exception) { } * * if (win != null) * { * * * if ((win[0, 0] == z && win[0, 1] == y && win[0, 2] == x) || * (win[1, 0] == z && win[1, 1] == y && win[1, 2] == x) || * (win[2, 0] == z && win[2, 1] == y && win[2, 2] == x) || * (win[3, 0] == z && win[3, 1] == y && win[3, 2] == x)) * { * p.PenWidth = (float)7.5; * p.PenColor = Color.White; * p.Forward(sideLength * 3); // Draw a line sideLength long * p.TurnRight(boardAngle); // Turn right 90 degrees * * p.Forward(sideLength); // Draw a line sideLength long * p.TurnRight(180 - boardAngle); // Turn right 90 degrees * * p.Forward(sideLength * 3); // Draw a line sideLength long * p.TurnRight(boardAngle); // Turn right 90 degrees * * p.Forward(sideLength); // Draw a line sideLength long * p.TurnRight(180 - boardAngle); // Turn right 90 degrees * * } * } */ }