public Cube(Vector point, Color color, int width, int height, int depth, int scale = 1) { Width = width; Height = height; Depth = depth; Scale = scale; Points = new CubeData[] { new CubeData(new Vector(0, 0, 0), Placement.FTL), // front top left new CubeData(new Vector(Width, 0, 0), Placement.FTR), // front top right new CubeData(new Vector(0, Height, 0), Placement.FBL), // front bottom left new CubeData(new Vector(Width, Height, 0), Placement.FBR), // front bottom right // second side new CubeData(new Vector(0, 0, Depth), Placement.BTL), // back top left new CubeData(new Vector(Width, 0, Depth), Placement.BTR), // back top right new CubeData(new Vector(0, Height, Depth), Placement.BBL), // back bottom left new CubeData(new Vector(Width, Height, Depth), Placement.BBR) // back bottom right }; SetLocation(point.X, point.Y, point.Z); Rot = new Rotation { X = 0, Y = 0, Z = 0 }; Color = color; SetColor(Color); }
private CubeData[] GetBackSide() { var points = new CubeData[] { Points.FirstOrDefault(d => d.Place == Placement.BTL), Points.FirstOrDefault(d => d.Place == Placement.BTR), Points.FirstOrDefault(d => d.Place == Placement.BBR), Points.FirstOrDefault(d => d.Place == Placement.BBL) }; return(points); }
private CubeData[] GetFrontSide() { var points = new CubeData[] { Points.FirstOrDefault(d => d.Place == Placement.FTL), Points.FirstOrDefault(d => d.Place == Placement.FTR), Points.FirstOrDefault(d => d.Place == Placement.FBR), Points.FirstOrDefault(d => d.Place == Placement.FBL) }; return(points); }
/// <summary> /// Draws the given side. /// </summary> /// <param name="size">Form to draw use in 2d location calculations.</param> /// <param name="g">Graphics object to draw/fill with.</param> /// <param name="side">The side to get the points for drawing/filling from.</param> private void DrawSide(Size size, Graphics g, Side side) { var points = new CubeData[4]; switch (side) { case Side.FRONT: points = GetFrontSide(); break; case Side.LEFT: points = GetLeftSide(); break; case Side.RIGHT: points = GetRightSide(); break; case Side.TOP: points = GetTopSide(); break; case Side.BOTTOM: points = GetBottomSide(); break; case Side.BACK: points = GetBackSide(); break; default: break; } try { var points2d = Get2dPoints(size, points); // draw outline g.DrawPolygon(GetOutline(), points2d); // fill polygon g.FillPolygon(new SolidBrush(Color), points2d); } catch (OverflowException of) { // todo: find out why this is happening } }