I'm looking to create a 3d model of a rubiks cube and im not worrying about animations, all I want is a cube that can be rotated around. I've already implemented a sorting algorithm so once I have a 3d cube my project will be complete however I've never really gone into to 3d graphics or graphics at all with c# and was wondering the best way to do this.
Asked
Active
Viewed 198 times
0
-
If you are creating a winforms app, the easiest, while not the fastest way of creating a 2d graphic, is to use [GDI+](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/graphics-and-drawing-in-windows-forms?view=netframeworkdesktop-4.8). You can use a 2d image to to create an orthographic view of a 3d object. – Olivier Jacot-Descombes Aug 01 '22 at 14:25
-
Is there a way of doing it without a library as this is for a college project and I won't be awarded marks for using libaries – Aug 01 '22 at 16:26
-
GDI+ is an integral part of the .NET Framework and especially winforms. You will not have to install any library. It's just using the methods in the [System.Drawing namespace](https://learn.microsoft.com/en-us/dotnet/api/system.drawing). See also [Graphics Class](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics). – Olivier Jacot-Descombes Aug 01 '22 at 16:28
-
Oh right thanks. So is this where I use the paint event? – Aug 02 '22 at 15:25
-
You can either override the form's OnPaint: `protected override void OnPaint(PaintEventArgs e)` and do the drawing there or you can place a Panel on the form and add it a Paint event handler. This allows you to better control where on the Form the cube will appear. – Olivier Jacot-Descombes Aug 02 '22 at 15:45
-
see https://stackoverflow.com/a/39024016/2521214 – Spektre Aug 04 '22 at 07:39