1
私は、その重心と座標系の中心(反時計回り)の周りを時計回りに回転させたい三角形を持っています。問題は、両方の動きが反時計回りであり、解決策を理解できないということです。三角回転のOpenGLシーケンス
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
def init():
glClearColor(0.0, 0.0, 0.0, 0.0)
glClearDepth(1.0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0.0, 640.0, 0.0, 480.0)
rotation = 1
def display():
global rotation
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glRotate(rotation, 0.0, 0.0, 0.1)
glTranslatef(0.0, 0.0, -0.1)
glTranslatef(0.17, 0.17, 0.0)
glRotate(rotation, 0.0, 0.0, 0.1)
glTranslatef(-0.17, -0.17, 0.0)
glBegin(GL_TRIANGLES)
glColor3f(0.5, 0.5, 0.9)
glVertex3f(0.5, 0.0, 0.0)
glVertex3f(0.0, 0.5, 0.0)
glVertex3f(0.0, 0.0, 0.0)
glEnd()
glPopMatrix()
rotation += 1
if rotation >= 360:
rotation = 0
glFlush()
if __name__ == '__main__':
glutInit()
glutCreateWindow('Rotating triangles')
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(640, 480)
glutDisplayFunc(display)
glutIdleFunc(display)
init()
glutMainLoop()