Does pyGame do 3d?

前端 未结 11 890
醉话见心
醉话见心 2020-12-29 21:45

I can\'t seem to find the answer to this question anywhere. I realise that you have to use pyOpenGL or something similar to do openGL stuff, but I was wondering if its possi

11条回答
  •  一个人的身影
    2020-12-29 21:52

    You can make like this :

    def convert_2d(x, y, z, horizon):
        d = 1 - (z/horizon)
        return x*d, y*d
    def draw_list_of_points(lst):
        '''Assume that lst is a list of 3 dimentionnal points like [(0, 0, 0), (1, 6, 2)...
        Let's take 200 for the horizon, it can give us a pretty clean 3D''' 
        for x, y, z in lst:
            pygame.draw.circle(screen, color, convert_2d(x, y, z, 200), 1)
    
    

    But it's not very fast. If you want fast try to implement in C++/SDL2 or C. Pygame is not very good for 3d graphics.

提交回复
热议问题