user3482407
user3482407

Reputation: 319

Qt, C++, 3D Matrix Cube

I am not a very experienced Qt C++ Programmer, but unfortunately I have to create a 3D Cube containing 8x8x8 points.

I already found the Qt tutorial to create a simple cube, but I am completely lost on how to make it hollow and draw the 512point matrix within the cube. Furthermore the goal is to change the color of specific points within this matrix. Anybody know how to proceed?

Thank you in advance!

Upvotes: 2

Views: 2862

Answers (1)

phyatt
phyatt

Reputation: 19132

enter image description here

https://github.com/peteristhegreat/circles-in-a-cube

Check out the awesome example I put together!

Basically I took the Grabber example and did some modifications to it.

http://doc.qt.io/qt-5/examples-widgets-opengl.html

http://doc.qt.digia.com/qt-quick3d-snapshot/qt3d-examples.html

http://doc.qt.digia.com/qt-5.2/qtopengl-grabber-example.html

It looks like you could modify this one to something similar.

http://doc.qt.io/qt-5/qtopengl-hellogl2-example.html

The core features of what is going on, is holding on to information about the individual spheres and modifying them when you need to.

To hold the pointers to sphere objects, I used two different lists.

One is a straight forward QList, and the other is a 3D Vector. The 3D QVector allows you to access a sphere pointer with spheresInSpace[x][y][z], where x,y,z are any integer between 0-7.

To change the colors of the spheres, I change the reflectance values.

Hope that helps.

Upvotes: 3

Related Questions