0
OpenGLでは、シーンの左下にあるVTK(vtkaxesactorクラス)のようなx-y-z軸を表示する必要があります。OpenGLのvtkaxesactorタイプの軸
フォアグラウンドで3軸(x、y、z)の色のついた軸を探していますが、回転すると向きが変わりますが、ズーミングには無関心です。
これを行うGLUTクラスはありますか?これをどうやって実装していないのですか?
EDIT次datenwolfのコメントは:
私はX、Y、Zパンや変換の範囲を追跡します。 (私はpyopenglを使用しています)
def renderAxis(self):
glViewport(0,0,self.width()/8,self.height()/8)
self.translate([-1*self.xpan,-1*self.ypan,-1*self.zpan])
glMatrixMode(GL_MODELVIEW)
glLineWidth(2)
glBegin(GL_LINES)
glColor(1, 0, 0) #Xaxis, Red color
glVertex3f(0, 0, 0)
glVertex3f(0.15, 0, 0)
glColor(0, 1, 0) #Yaxis, Green color
glVertex3f(0, 0, 0)
glVertex3f(0, 0.15, 0)
glColor(0, 0, 1) #Zaxis, Blue color
glVertex3f(0, 0, 0)
glVertex3f(0, 0, 0.15)
glEnd()
glutInit()
glColor(1,0,0)
glRasterPos3f(0.16, 0.0, 0.0)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13,88)#ascii x
glColor(0,1,0)
glRasterPos3f(0.0, 0.16, 0.0)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13,89)#ascii y
glColor(0,0,1)
glRasterPos3f(0.0, 0.0, 0.16)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13,90)#ascii z
self.translate([self.xpan,self.ypan,self.zpan])
glViewport(0,0,self.width(),self.height())
def translate(self, _trans):
self.makeCurrent()
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glTranslated(_trans[0], _trans[1], _trans[2])
glMultMatrixd(self.modelview_matrix_)
self.modelview_matrix_ = glGetDoublev(GL_MODELVIEW_MATRIX)
self.translate_vector_[0] = self.modelview_matrix_[3][0]
self.translate_vector_[1] = self.modelview_matrix_[3][1]
self.translate_vector_[2] = self.modelview_matrix_[3][2]
これは仕事になりますが、これは最善の方法ですか?