08-04-2007, 04:33 PM
i have written a program for the graphics class i'm in. it is a sun with planets rotating around it and moons rotating around the planet. my problem is this... when the planets are go behind the sun from the camera perspective they are larger and appear to be closer than when they pass in front of the sun. any idea what the problem might be? the camera class i'm using is very similar to the one on my text book's website. here is the link to the book's source.
08-04-2007, 05:01 PM
Make sure you request and really get a framebuffer with depth buffer.
Enable depth testing.
EDIT: ie. with glut, init your window like this :
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
08-04-2007, 06:02 PM
actually i am using that call. here is the code in Main()
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA |GLUT_DEPTH);
glClearColor(0.0f, 0.0f, 0.0f, 01.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
I have classes that handle the camera, light, planets and moons. the program is also setup to toggle the lights on and off, move the camera, change the speed application and toggle between alpha blending and depth testing. here is my RenderScene method.
//draw the sun
//apply the time multiplier to the planets and moons
//draw the planets and moons++
SolarDay += .004 * nSpeedMultiplier; //25 earth day = 1 solar day
08-05-2007, 01:40 AM
cam.SetShape(30.0f,1, -10,10);Based on your camera code this call will send negative near plane distance to gluPerspective which expects the value to always be positive.
08-05-2007, 04:48 AM
Thanks That did the trick.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.