I am using pygame to make a visual representation of a colored and solid cube.
So far I have a cube-like shape consisting of 12 lines that I can rotate using the mouse. However, when I attempted to fill in the surfaces of the cube, I quickly ran into the following problem: Depending on the rotation, certain surfaces that should be invisible due to being on the backside of the cube are covering those that should be in the foreground.
I am using a parallel projection matrix.
I am looking for a way to determine in which order planes should be drawn depending on the rotation of the cube.
At the moment I use lists of 4 vertices in 2d space and draw a connecting polygon in the right color with pygame.draw.polygon(...)
An even better alternative would be an algorithm that discards those vertice-groups whose connecting polygon would be entirely hidden, while adjusting the vertices of those that should be partially hidden (this second part is only necessary for more compley shapes than a cube, but I would still like to know about it.)
I did some research about projections of 3d objects but I mostly found videos detailing how to project a 'hollow' 3d shape (which I already know how to do) or some very elaborate and complicated tutorials for perspective projection, which I did not quite understand.