Planet should go behind the sun (invisible for some time) and then it would be visible after coming back, but that' not happening.
您必须启用深度测试,并且必须清除深度缓冲区。在
深度测试可以通过^{}启用。默认深度函数^{}是GL_LESS。这会导致跳过之前绘制的片段后面的片段:
在每一帧之前,深度缓冲区必须通过^{}清除,以重新启动此过程。在
在display的开头向代码中添加以下行:glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glEnable( GL_DEPTH_TEST )
您必须创建一个具有深度缓冲区(^{})的窗口:
^{pr2}$
查看预览:
Can you also tell how to make circle where the planet is revolving?
我建议使用^{}来设置模拟。以下示例显示了太阳、地球和月球(当然,这是一个非常简化的模拟,其大小和距离关系完全错误):import time
start_time = time.time()
def display():
t = time.time() - start_time
year_period &