Perspective projection with multiple 3D objects on different depths in Python <p>For my personal project I need to:</p> <ol> <li><p>Produce a perspective projection from a 3D objet to a 2D plane (on a point defined in the space, which will be the camera).</p></li> <li><p>Get the exact area/points coordinates of the perspective projectio</p></li> <li><p>Produce the perspective projection of multiple 3D objects where some objects may be behind others.</p></li> <li><p>Render the scene (only one image, there won't be any animation, so no need for a realtime rendering).</p></li> </ol> <p>For points 1,2 and 4 I think I've found a way to do that using PyGame as described here: <a href="http://codentronix.com/2011/04/21/rotating-3d-wireframe-cube-with-python/" rel="nofollow">http://codentronix.com/2011/04/21/rotating-3d-wireframe-cube-with-python/</a></p> <p>But for point 3 I'm kind of stuck, because even if I can get the perspective projections for each of my objects, how can I know what object is really visible and which (full object or part of it) is not?</p> <p>I really need to exactly know what parts of objects are visible and what parts are not, thus my ultimate goal would be to have a matrix of my screen image with the areas of every object's projection clearly defined.</p> <p>For example, if the matrix contains all pixels of my screen image, and we have 10 objects, we would get 0 where there is no object, 1 where we can see object n1, 2 where object n2 is visible, etc..</p> <p>I must add that I'm an accomplished developer in Python and many other languages, but I never did any game-related nor rendering development before.</p> <p>Can someone help me get on the right tracks?</p> <p>PS: side-question: if you could also point me to a better optimized implementation of perspective projection and rendering than PyGame, I'd be very interested!</p>