Problemas con la visión utilizando OpenGL
Publicado por Jesús (1 intervención) el 29/04/2006 20:22:38
Buenas a todos, estoy intentando girar la visión utilizando el ratón alrededor de una figura (en concreto una esfera) utilizando las librerías de opengl, el problema es que cuando la roto se va haciendo cada vez mas pequeña hasta q desaparece. Soy novato y os agradecería enormemente cualquier comentario al respecto. Aquí os pego el código fuente de las funciones que analizan el movimiento del raton y la funcion display, esta en python, pero se entiende facil aún sin haberlo utilizado nunca :) Muchísimas gracias
def display():
glDepthFunc(GL_LEQUAL)
glEnable(GL_DEPTH_TEST)
#activamos z-buffering
glClearColor(1.0,1.0,1.0,0.0)
#color de fondo negro
glClearDepth(1.0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
#borramos el buffer de color y z-buffer
glMatrixMode(GL_PROJECTION)
#modo proyeccion
glLoadIdentity()
gluPerspective(60,1.0,1.0,100.0)
glRotatef(rotx,1,0,0)
glRotatef(roty,0,1,0)
#cargamos matriz identidad
glMatrixMode(GL_MODELVIEW)
glTranslatef(0.0,0.0,-2.0)
glColor3f(0.0,0.0,0.5)
glutWireSphere(0.4,50,50)
glFlush()
return
def mouse(button,state,x,y):
global rotate,beginx,beginy
if button == GLUT_LEFT_BUTTON and state == GLUT_DOWN:
rotate = 1
beginx = x
beginy = y
if button == GLUT_LEFT_BUTTON and state == GLUT_UP:
rotate = 0
return
def motion(x,y):
global beginx,beginy,rotx,roty
if rotate:
rotx = rotx + (y - beginy)
roty = roty + (x - beginx)
beginx = x
beginy = y
glutPostRedisplay()
return
def display():
glDepthFunc(GL_LEQUAL)
glEnable(GL_DEPTH_TEST)
#activamos z-buffering
glClearColor(1.0,1.0,1.0,0.0)
#color de fondo negro
glClearDepth(1.0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
#borramos el buffer de color y z-buffer
glMatrixMode(GL_PROJECTION)
#modo proyeccion
glLoadIdentity()
gluPerspective(60,1.0,1.0,100.0)
glRotatef(rotx,1,0,0)
glRotatef(roty,0,1,0)
#cargamos matriz identidad
glMatrixMode(GL_MODELVIEW)
glTranslatef(0.0,0.0,-2.0)
glColor3f(0.0,0.0,0.5)
glutWireSphere(0.4,50,50)
glFlush()
return
def mouse(button,state,x,y):
global rotate,beginx,beginy
if button == GLUT_LEFT_BUTTON and state == GLUT_DOWN:
rotate = 1
beginx = x
beginy = y
if button == GLUT_LEFT_BUTTON and state == GLUT_UP:
rotate = 0
return
def motion(x,y):
global beginx,beginy,rotx,roty
if rotate:
rotx = rotx + (y - beginy)
roty = roty + (x - beginx)
beginx = x
beginy = y
glutPostRedisplay()
return
Valora esta pregunta


0