Hi,
I am trying to see how big/far my objects can be in (py)opengl. I
thought there was no limit and everything should be visible but a sphere
with radius 70 and the camera is 150 units away, only half of the sphere
is visible. What is causing this? Is it plane clipping? How do I set it
so that it renders regardless of distance and size? Im not after
performance so I dont care if it is slow.
Cheers
Astan
PS: Here is the code I use:
from OpenGL.GL import *
from OpenGL.GLU import *
import pygame
from pygame.locals import *
rtri = 0.0
dlBody = None
def resize((width, height)):
if height==0:
height=1
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, 1.0*width/height, 0.1, 100.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
def init():
global dlBody
glShadeModel(GL_SMOOTH)
glClearColor(0.0, 0.0, 0.0, 0.0)
glClearDepth(1.0)
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST)
glEnable(GL_COLOR_MATERIAL)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
radius = 70
color = (0.7,1.5,0.5)
dlBody = glGenLists(1)
glNewList(dlBody,GL_COMPILE)
Sphere = gluNewQuadric()
gluSphere(Sphere, radius, 32, 32)
gluQuadricNormals(Sphere, GLU_SMOOTH)
gluQuadricDrawStyle(Sphere, GLU_FILL)
glEndList()
def draw():
global dlBody
global rtri
if dlBody:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(0.0,0.0,-150)
glPushMatrix()
glColor3f(0.7,1.5,0.5)
glRotatef(10,1,0,0)
glRotatef(rtri, 0.0, 1.0, 0.0)
glCallList(dlBody)
glPopMatrix()
rtri+=1
if rtri == 360:
rtri = 0
def main():
video_flags = OPENGL|DOUBLEBUF
pygame.init()
pygame.display.set_mode((640,480), video_flags)
resize((640,480))
init()
frames = 0
ticks = pygame.time.get_ticks()
while 1:
event = pygame.event.poll()
if event.type == QUIT or (event.type == KEYDOWN and event.key ==
K_ESCAPE):
break
draw()
pygame.display.flip()
frames = frames+1
print "fps: %d" % ((frames*1000)/(pygame.time.get_ticks()-ticks))
pygame.quit()
if __name__ == '__main__': main()
--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two."
Animal Logic
http://www.animallogic.com
Please think of the environment before printing this email.
This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free.
|