gpt4 book ai didi

python - 汽车 opengl 转换的旋转轮胎轮辋

转载 作者:太空宇宙 更新时间:2023-11-04 11:02:42 24 4
gpt4 key购买 nike

这是绘制汽车零件的绘图函数,在这个函数中检查汽车轮辋并检查标志,我需要在移动汽车时旋转轮胎轮辋。由于轮辋已旋转但从汽车模型中取出,因此无法正常工作,当我按下向上箭头键时,但汽车确实在移动。

我还在初始化函数中初始化了self.fFlag = "false":

def on_draw(self):
# Clears the screen and draws the car
# If needed, extra transformations may be set-up here
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)


for name in self.parts:
colors = self.colors
color = colors.get(name, colors["default"])
glColor3f(*color)

if (name == 'Front Driver tire rim') & (self.fFlag == "true"):
bodyFace = self.mini.group(name)
glPushMatrix()
glRotatef(45,1,0,0)

# Drawing the rim
for face in bodyFace:
if len(face) == 3:
glBegin(GL_TRIANGLES)
elif len(face) == 4:
glBegin(GL_QUADS)
else:
glBegin(GL_POLYGON)
for i in face:
glNormal3f(*self.mini.normal(i))
glVertex3f(*self.mini.vertex(i))
glEnd()



glPopMatrix()
self.fFlag == "false"

else:
bodyFace = self.mini.group(name)
for face in bodyFace:
if len(face) == 3:
glBegin(GL_TRIANGLES)
elif len(face) == 4:
glBegin(GL_QUADS)
else:
glBegin(GL_POLYGON)
for i in face:
glNormal3f(*self.mini.normal(i))
glVertex3f(*self.mini.vertex(i))
glEnd()



def on_key_release(self, symbol, modifiers):
"""Process a key pressed event.
"""

if symbol == key.UP:
# Move car forward
# TODO

glTranslatef(0,-1,0)
self.fFlag = "true"
self.on_draw()

pass

已编辑:当我按下向上箭头键时,我试图让汽车轮辋旋转,这会使汽车向前移动。

最佳答案

我强烈建议将其发布到类(class)论坛。我认为 TJ 不会真的喜欢看到这个,而且它很容易找到。

关于python - 汽车 opengl 转换的旋转轮胎轮辋,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3950829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com