Mini Cube - Ready for Developers (Can you finish it?)

I love 3D, so I'm always trying to incorporate it in my projects. And what better opportunity to work with 3D than a blog post! This week I want to share this Mini Cube project, which is a (2x2) simplified version of that famous game that gave me so many headaches in the past. This is a perfect candidate for a 3D sample, since you have to visualize the cube in three dimensions in order to play it properly.

This project is not finished yet, I've prepared the 3D objects and some interaction, but the cube doesn't "work", which means you can't rotate the blocks. But that's the point of this post... invite you to finish it ;-) So, let me give you an idea of what I have done so far and see if someone wants to take it to the next level:

Download the project here (Maya and Blend projects included).

image

Creating the 3D Objects

The workflow I used was Maya 6.0 > Export to Obj > Import Obj in Blend. In Maya I was able to create the geometry, separate materials, and adjust the pivot points for each block. For the geometry, I also created a few extra objects that will receive mouse events in Blend. If you click on one corner, you will notice that a Message Box shows the name of that corner (red1, red2, etc...) Please, see the following image to see where they are located. You can find the original Maya project in the project ZIP file (/miniCube/Maya_files).

 image

Importing the Obj File in Blend

To import a Obj file you just need to drag the files to your WPF Project in Blend. Just remember that you have to drag the .obj and the .mtl files. The latter contains all the materials that you defined in Maya. Double click the file cube.obj to insert into the Artboard. Then use Camera Orbit to rotate the 3D space.

image

What else is Ready in Blend?

Ok, that's the general idea. Now if you open the Blend project you will see that I've prepared a few more steps:

  • I've created new groups in Blend for the blocks (b1, b2, b3, etc...)
  • The project has several Storyboards for each block. Those Storyboards are rotating each block in X, Y and Z, in both directions.
  • The code behind (Window1.xaml.cs) has basic interaction to rotate the cube.
  • If you click on a corner, you can see a Message Box that shows you which corner got the event (look for the method OnMouseUp in Window.xaml.cs).

What's Next?

Well, since you have the Holidays, you can use that time off to finish this project! The next steps are not easy, but interesting. You can use the Storyboards that are already there, or you can rotate the blocks using just code. The idea now is to make the cube work, so you can come back from the Holidays and spend your time playing the game at work! Just kidding...

I will publish the final project in January, but I would be glad to publish any solution that you might send us!

 

Enjoy, and Happy Holidays!
-Celso