【问题标题】:Render only a part of the sphere inside the cube in OpenGL using python?使用python在OpenGL中仅渲染立方体内的一部分球体?
【发布时间】:2022-01-04 00:55:21
【问题描述】:

我只想将立方体内部的部分渲染为类似于图 2 所示的部分

我当前渲染球体的代码在这里

def Sphere(ball):
    glPushMatrix()
    sphere = gluNewQuadric()
    glTranslatef(ball.pos.x,ball.pos.y,ball.pos.z) #Move to the place
    glColor3fv((1,0,0)) #Put color
    gluSphere(sphere, ball.radius, 16, 8) #Draw sphere
    glPopMatrix()

【问题讨论】:

    标签: python opengl render physics pyopengl


    【解决方案1】:

    您可以使用glClipPlane 定义剪辑窗格。例如:

    glEnable(GL_CLIP_PLANE0)
    glClipPlane(GL_CLIP_PLANE0, [1, 0, 0, distance])
    
    glEnable(GL_CLIP_PLANE1)
    glClipPlane(GL_CLIP_PLANE1, [0, 1, 0, distance])
    
    # [...]
    

    另见OpenGL overlapping ugly rendering

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-27
      • 2014-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      相关资源
      最近更新 更多