Click to See Complete Forum and Search --> : "Ghosts" in my scene when using spheres/ellipsoids


roby1984
August 14th, 2008, 01:43 PM
Good evening,
I have a very very strange problem: I've created a 3D visor, that is, a program that displays shapes according to an XML file. The problem is that, as soon as I've started introducing spheres (and ellipsoids rendered as scaled gluSpheres), some spurious shapes appear/disappear from my scene according to the current camera orientation.
I've taken a couple of pictures just to be clearer:
http://roby1984.netsons.org/phantom01.png
http://roby1984.netsons.org/phantom02.png
I've rendered shapes using display lists, the one regarding ellipsoids/spheres is the following:

/**
Quadric object
**/
GLUquadricObj *Sphere;

/**
Obtain a new quadric
**/
Sphere = gluNewQuadric();
gluQuadricNormals(Sphere, GLU_SMOOTH);
gluQuadricTexture(Sphere, GL_TRUE);

/**
Start filling display list
**/
glNewList(dObj.listID, GL_COMPILE);
/**
Set polygon's filling
**/
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

/**
Set ellipsoid's color
**/
glColor4d(eo.ellipsoid_color_R_,
eo.ellipsoid_color_G_,
eo.ellipsoid_color_B_,
eo.ellipsoid_color_A_);

/**
Save current modelview matrix
**/
glPushMatrix();

/**
Translate to reach ellipsoid's center
**/
glTranslated(eo.ellipsoid_center_X_,
eo.ellipsoid_center_Y_,
eo.ellipsoid_center_Z_);

/**
Rotate around the Y axis
**/
glRotated(eo.ellipsoid_orientation_Rho_,
0.0, 1.0, 0.0);

/**
Rotate around the X axis
**/
glRotated(eo.ellipsoid_orientation_Theta_,
1.0, 0.0, 0.0);

/**
Alter scale factors so as to obtain an ellipsoid from a
sphere
**/
glScaled(eo.ellipsoid_scaleFactor_X_,
eo.ellipsoid_scaleFactor_Y_,
eo.ellipsoid_scaleFactor_Z_);

/**
Draw the sphere
**/
gluSphere(Sphere,
1.0,
eo.ellipsoid_nSegments_U_,
eo.ellipsoid_nSegments_V_);

/**
Restore previous modelview matrix
**/
glPopMatrix();
glEndList();

Does anyone have any clue why this happens?
Thanks in advance to anyone willing to help me.
Roberto

(I've already posted this on OpenGL.org one week ago, but I've received no responses so far, so I've decided to post it here...)

bitshifter420
August 15th, 2008, 05:49 AM
Scaling an object sometimes produces strange artifacts.
Try scaling the sphere first, then rotations next and translate last.
Mixing the order around seems to make a difference.
Try fooling with the order of these three function calls.
I didnt see your pictures because im not member of that site so...

roby1984
August 15th, 2008, 09:35 AM
Scaling an object sometimes produces strange artifacts.
Try scaling the sphere first, then rotations next and translate last.
Mixing the order around seems to make a difference.
Try fooling with the order of these three function calls.
I didnt see your pictures because im not member of that site so...
You're right, here are the images:
http://img80.imageshack.us/my.php?image=phantom01oa8.png
http://img141.imageshack.us/img141/8311/phantom02la7.th.png
Now I'll try and I'll let you know... Thank you very much for your help!

roby1984
August 15th, 2008, 09:52 AM
You were absolutely right, I just moved the scale operation before the rototranslation and everything now works perfectly... Thanks again!!!!!