У меня есть карта, которую я хочу вращать вокруг точки с определенным радиусом.Мне удалось это сделать, но моя проблема в том, что я хочу иногда менять радиус на ходу и соответственно обновлять камеру
pygame.init()
display = (1700, 1000)
pygame.display.set_mode(display, DOUBLEBUF | OPENGL)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(50, (display[0] / display[1]), 0.1, 5000)
glTranslatef(1, 1, -(radius/2))
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glRotatef(10, 1, 0, 0) # i gave it 10 degrees for the camera to look at
# the ground
gluLookAt(offset_x - radius / 2, height, offset_z - radius / 2,
offset_x, 0, offset_z,
0, 1, 0)
# offset_x,offset_z are the center of the circle,
# and the distance of rotation is the radius.
# This gets me to the point i want to be, everything is good so far.
while True:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glPushMatrix()
if not move:
glTranslatef(offset_x, 0, offset_z)
glRotatef(rotation_angle, 0, 1, 0)
glTranslatef(-offset_x, 0, -offset_z)
rotation_angle += 0.5
else:
glTranslatef(offset_x, 0, offset_z)
glRotatef(rotation_angle, 0, 1, 0)
glTranslatef(-offset_x, 0, -offset_z)
#### this rotates around the point at the start.
#### the radius and the view distance is perfect.
Теперь я получаю новый радиус из текстового файла, и я хочу изменитьвид для вращения вокруг нового радиуса центра от нового радиуса расстояния.У меня есть это «если», которое знает, когда радиус изменился, но я не понимаю, как использовать glTranslatef () или gluLookAt (), чтобы изменить вращение вокруг новой точки.
#####################################################
if radius_changed:
glTranslatef(0, 0, radius - old_radius_copy) # this isnt working
radius_changed = False
else:
glTranslatef(0, 0, radius - old_radius_copy) # this isnt working
######################################################
glCallList(obj.gl_list)
DrawBuffer(bufferObj, noPoints, noCirclePoints, noCrossPoints)
glPopMatrix()