OpenGL:对象旋转异常

问题描述

我有一个不断旋转的多维数据集对象,但是遇到了一个问题。如果我将对象从(0,0)移开,则对象开始以奇怪的方式旋转。我不知道为什么以及如何解决这个问题。

这是我的对象的样子:

enter image description here

这就是我旋转立方体的方式:

    def draw_edges(self,color):
        """Draws the cube's edges"""
        glPushMatrix()
        glRotate(self.rotation[3],self.rotation[0],self.rotation[1],self.rotation[2])
        glBegin(GL_LINES)
        for edge in self.edges:
            for vertex in edge:
                glColor3fv(color)
                glVertex3fv(self.vertices[vertex])
        glEnd()
        glPopMatrix()

然后我在多维数据集上调用一个rotate方法,该方法将传入的值添加到位置:

    def rotate(self,rotval,mult):
        self.rotation[0] = rotval[0]
        self.rotation[1] = rotval[1]
        self.rotation[2] = rotval[2]
        self.rotation[3] += mult
        if self.rotation[3] >= 360:
            self.rotation[3] = self.rotation[3] - 360

任何人都可以帮忙。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)