'Render order for 3D graphics engine to stop occlusion

I am currently working on a 3D rendering program in Java, It uses a 3D point class as vertices to draw lines between on a 2d plane using matrix multiplication using isometric projection. Currently the system uses wire frames for all the objects but I want to move it over to drawing the objects filled in. But this comes with the problem of in which order to draw objects to stop it from drawing over/occluding other objects when they shouldn’t as the program just draws them to the screen, in the order they’re created.

I have thought of a few ways to get around this, the first was to draw them in ascending Z values but this then creates problems with big objects creating wildly different Z values. The two options I have thought of is to keep an index of where has been drawn to already and if it is drawing to a place already in that it compares the Z values and picks which one should be visible, the other is to make a sudo ray casting system where it doesn’t simulate reflection or anything complex. But these both seem clunky and not good for real time drawing
Any help would be greatly appreciated, if anyone also knows how programs like unity or blender handle this that would also be greatly appreciated. Thankyou

3d


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source