Rubik’s Cube Simulator

Last semester I got my first experience with 3D programming – something I had wanted to learn how to do for quite a while. One of our first assignments was to  get a handful of primitives moving around on screen (first screenshot). I was motivated enough to continue expanding the project, and added 9 smaller cubes that formed a larger cube, along with a large sky-box-looking cube.

01 06

Once I got to that point, I figured – why not take it further? I started thinking about how I could get the “Rubik’s cube” to rotate like the real thing.

01

After many hours of trying, and several note pad pages full of indices and diagrams …

IMG_20170316_212411

… I still couldn’t get it to work.

02

I thought I’d take a break from the rotation code and fix the colours so that the inside faces were black.

05

But I could only prolong the inevitable long hall of getting stackable rotations working that was ahead of me – and long it was.

06

However eventually, after many hours – I got it! I decided to add a textured plane that cut through the cube which to show the controls for rotating the layers. Printing the controls out like this made clear just how ridiculous they were – the next step was to replace them with something more sane.

18

I only now got around to improving the input method – several months since I have last worked on the project. Now, instead of pressing one of a dozen keys to rotate a layer, you simply click on the layer you want to rotate; left for clockwise rotations, right for anti-clockwise.

OverlordProject_2017-03-16_21-07-25

2017-03-16_01.gif

Currently, you can also randomly scramble the cube by hitting a key, and reset it by hitting another key.

Like with any project there are things I’d like to fix and lots of things I’d like to add, but I have to call it at some point, and I think here is that point for this project. Especially with how many other projects I have going at the moment. Plus it feels great to have another one in the “finished” list.

Thanks for reading! I’ll be back soon with another post on my graphics API comparison project.

-AJ Weeks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s