1
다른 3D GL 게임의 코드를 연구하면서, 매우 간단한 것을 만들려고 노력했습니다.OpenGL : Camera theta 및 zooming
모든 것이 정상적으로 작동하지만 하나의 축에서만 작동합니다. 앞뒤로 한 방향으로 걷는다면 모두 잘됩니다. 하지만, 90도 회전하여 앞으로/뒤로 걷기 시작하면 뒤로 앞으로 및 뒤로 앞으로 움직입니다.
def drawground(self):
glPushMatrix()
glTranslate(-1, -1, -3)
glRotate(90, True, False, False)
glBegin(GL_QUADS)
glColor(0.6, 0.6, 0.6)
glVertex(0, 0)
glVertex(0, self.winmain.world.xlen)
glVertex(self.winmain.world.ylen, self.winmain.world.xlen)
glVertex(self.winmain.world.ylen, 0)
glEnd()
glPopMatrix()
이동 코드 :
if pygame.key.get_pressed()[K_w]:
self.campos[0] -= 0.005*math.sin(self.camtheta * 3.14159/180)
self.campos[1] -= 0.005*math.cos(self.camtheta * 3.14159/180)
if pygame.key.get_pressed()[K_s]:
self.campos[0] += 0.005*math.sin(self.camtheta * 3.14159/180)
self.campos[1] += 0.005*math.cos(self.camtheta * 3.14159/180)
그리고, 카메라 세타 회전 :
if event.type == MOUSEMOTION:
self.camtheta -= 2 * event.rel[0] #Subtracting 2 * the relative moved pixels from the last position.
는 어떤이의 문제가 발생할 수 있습니다 여기에
땅 그리기 코드?
감사합니다,하지만 난이가 직면하고있는 방향으로 카메라를 이동에 관한 생각하지 않습니다. –
예. 내 오래된 C++ 코드를 읽을 수 있다면 [gluLookAt] (https://bitbucket.org/thrustmaster/firstpersonshooter/src/393e18698c3e/Player.cpp)를 사용하여 3D 공간에서 이동할 수 있습니다. 그리고 네, 저는 이것이 직접적인 대답이 아니라는 것을 이해합니다. 조금 파헤쳐 야합니다. 당신이 어찌할 수 없다면 알려주세요. 답장을 전액 답변으로 업데이트 할 것입니다. – SuperSaiyan