public static void DrawTrackUnit(OpenGL gl) { gl.SetColor(Color.Black); gl.SetColor(42, 42, 42, true); gl.Rotate(Vector3.UnitY * -90, true); // основная плашка gl.DrawParallelepiped(new Vector3(TrackUnitWidth, TrackUnitThickness, TrackUnitLength), true); // передние соединительные звенья gl.DoTranslate(Vector3.UnitX * TrackUnitConnectorWidth, true); gl.Repeat(() => { var edges = new Vector3(TrackUnitConnectorWidth, TrackUnitThickness, -TrackUnitConnectorLength); gl.DrawParallelepiped(edges, true); }, 4, Vector3.UnitX * TrackUnitConnectorWidth * 2, Vector3.Zero); gl.UndoTranslation(); // задние соединители gl.DoTranslate(Vector3.UnitZ * TrackUnitLength, true); gl.Repeat(() => { var edges = new Vector3(TrackUnitConnectorWidth, TrackUnitThickness, TrackUnitConnectorLength); gl.DrawParallelepiped(edges, true); }, 5, Vector3.UnitX * TrackUnitConnectorWidth * 2, Vector3.Zero); gl.UndoTranslation(); gl.UndoRotation(); gl.SetColor(Color.Black, true); }
private static void DrawHatch(OpenGL gl, Texture texture) { const float hatchWidth = TurretTopFrontWidth; const float hatchLength = 2.5f; const float hatchThickness = .1f; const float hatchFastenersWidth = .3f; const float hatchFastenersLength = .5f; texture.Bind(gl); gl.DrawParallelepiped(new Vector3(hatchLength, hatchThickness, hatchWidth), true, true); // крепления gl.DoTranslate(hatchLength, 0, hatchFastenersWidth, true); gl.Repeat(() => { gl.DrawParallelepiped( new Vector3(hatchFastenersLength, hatchThickness, hatchFastenersWidth), true); }, 2, Vector3.UnitZ * (hatchWidth - hatchFastenersWidth * 3), Vector3.Zero); }
private static void DrawCabinet(OpenGL gl) { // середина (кабина) gl.DoTranslate(-BumperLength, 0, BaseWidth / 2f, true); // передняя и задняя наклонные gl.Repeat(() => { gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.UnitZ * (-CabinetBottomWidth / 2)); gl.Vertex(Vector3.UnitZ * (CabinetBottomWidth / 2)); gl.Vertex(-CabinetSlopeLength, CabinetHeight, CabinetTopWidth / 2); gl.Vertex(-CabinetSlopeLength, CabinetHeight, -CabinetTopWidth / 2); }); }, 2, Vector3.UnitX * -BaseLength, Vector3.UnitY * 180); // боковые наклонные var zDiff = 1; gl.Repeat(() => { gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.UnitZ * (CabinetBottomWidth / 2 * zDiff)); gl.Vertex(-BaseLength, 0, CabinetBottomWidth / 2 * zDiff); gl.Vertex(-(BaseLength - CabinetSlopeLength), CabinetHeight, CabinetTopWidth / 2 * zDiff); gl.Vertex(-CabinetSlopeLength, CabinetHeight, CabinetTopWidth / 2 * zDiff); }); zDiff = -1; }, 2, Vector3.Zero, Vector3.Zero); // крышка gl.Draw(BeginMode.Polygon, () => { gl.Vertex(-CabinetSlopeLength, CabinetHeight, CabinetTopWidth / 2); gl.Vertex(-(BaseLength - CabinetSlopeLength), CabinetHeight, CabinetTopWidth / 2); gl.Vertex(-(BaseLength - CabinetSlopeLength), CabinetHeight, -CabinetTopWidth / 2); gl.Vertex(-CabinetSlopeLength, CabinetHeight, -CabinetTopWidth / 2); }); // задние коробки gl.DoTranslate(-(BaseLength + 0.8f), 0, CabinetBottomWidth / 2, true); gl.Repeat(() => { gl.DrawParallelepiped(new Vector3(BackBoxLength, BackBoxHalfHeight, -BackBoxWidth), true); gl.DoTranslate(Vector3.UnitY * BackBoxHalfHeight, true); gl.DrawParallelepiped(new Vector3(BackBoxTopLength, BackBoxTopHeight, -BackBoxWidth), true); gl.DoTranslate(Vector3.UnitX * BackBoxTopLength, true); gl.Repeat(() => { gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.Zero); gl.Vertex(Vector3.UnitY * BackBoxTopHeight); gl.Vertex(Vector3.UnitX * (BackBoxLength - BackBoxTopLength)); }); }, 2, Vector3.UnitZ * -BackBoxWidth, Vector3.Zero); gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.UnitY * BackBoxTopHeight); gl.Vertex(0, BackBoxTopHeight, -BackBoxWidth); gl.Vertex(BackBoxLength - BackBoxTopLength, 0, -BackBoxWidth); gl.Vertex(BackBoxLength - BackBoxTopLength, 0, 0); }); gl.UndoTranslation(2); }, 2, Vector3.UnitZ * -(CabinetBottomWidth - BackBoxWidth), Vector3.Zero); gl.UndoTranslation(); }
private static void DrawBase(OpenGL gl) { // Основа (низ) gl.Color(Color.DarkGreen); gl.DrawParallelepiped(new Vector3(BaseLength, BaseHeight, BaseWidth)); // угловой бампер gl.DoTranslate(Vector3.UnitX * BaseLength, true); gl.SetColor(Color.Green); var plateAngle = (float)(Math.Atan2(BumperMiddleHeight, BumperLength) / Math.PI * 180); gl.Repeat(() => { //верх и ниж пластины gl.Repeat(() => { gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.Zero); gl.Vertex(BumperLength, BumperMiddleHeight); gl.Vertex(BumperLength, BumperMiddleHeight, BaseWidth); gl.Vertex(Vector3.UnitZ * BaseWidth); }); }, 2, Vector3.UnitY * BaseHeight, Vector3.UnitZ * -plateAngle * 2); // стенки gl.Repeat(() => { gl.Draw(BeginMode.Triangles, () => { gl.Vertex(Vector3.Zero); gl.Vertex(BumperLength, BumperMiddleHeight); gl.Vertex(Vector3.UnitY * BaseHeight); }); }, 2, Vector3.UnitZ * BaseWidth, Vector3.Zero); }, 2, new Vector3(-BaseLength, 0, BaseWidth), Vector3.UnitY * 180); // крылья gl.Translate(BumperLength, BaseHeight, 0); var zDiff = 0f; gl.Repeat(() => { // верхняя пластина gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.Zero); gl.Vertex(-(BumperLength + BaseLength), 0); gl.Vertex(-(BumperLength + BaseLength), 0, -WingsWidth); gl.Vertex(0, 0, -WingsWidth); }); // передняя наклонная gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.Zero); gl.Vertex(Vector3.UnitZ * -WingsWidth); gl.Vertex(FrontWingsLength, -FrontWingsHeight, -WingsWidth); gl.Vertex(FrontWingsLength, -FrontWingsHeight); }); // задняя наклонная gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.Zero); gl.Vertex(-BumperLength, -BumperMiddleHeight, 0); gl.Vertex(-BumperLength, -BumperMiddleHeight, -WingsWidth); gl.Vertex(Vector3.UnitZ * -WingsWidth); }, Vector3.UnitX * -(BaseLength + BumperLength), Vector3.Zero); // передние стенки крыльев gl.Draw(BeginMode.Polygon, () => { gl.Vertex(Vector3.UnitZ * zDiff); gl.Vertex(FrontWingsLength, -FrontWingsHeight, zDiff); gl.Vertex(0, -FrontWingsHeight, zDiff); gl.Vertex(-BumperLength, 0, zDiff); }); zDiff = -WingsWidth; }, 2, Vector3.UnitZ * (BaseWidth + WingsWidth), Vector3.Zero); }