Why when I render a scene with a revolving camera objects that you'd expect to appear behind others

Posted by seaworthy on Stack Overflow See other posts from Stack Overflow or by seaworthy
Published on 2010-04-19T02:39:33Z Indexed on 2010/04/19 2:43 UTC
Read the original article Hit count: 405

Filed under:
|
|
|
|

Hello, I am rendering a scene in which I have two spheres. I am revolving a camera around one of them. What happens is counter-intuitive. When the camera goes around the sphere the other gets in front of it when you'd expect it to be behind. So it appears as though the spheres aren't revolving around each other and the one the should go around is always upfront. Please help.

Here is the code that renders the scene:

glLoadIdentity();

[self positionCamera];

glutSolidSphere(2, 12,12);

glPushMatrix();
glTranslatef(5, 0, 0);
glutSolidSphere(0.5, 12,12);
glPopMatrix();

glFlush();  

This block is part of a class that gets called on using.

[NSTimer scheduledTimerWithTimeInterval:DEFAULT_ANIMATION_INTERVAL 
                                 target:self 
                               selector:@selector(drawRect) 
                               userInfo:nil 
                                repeats:YES];

And

-(void)positionCamera{}

Contains math do camera revolution and gluLookAt()

© Stack Overflow or respective owner

Related posts about opengl

Related posts about objective-c