CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    15

    "Ghosts" in my scene when using spheres/ellipsoids

    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:


    I've rendered shapes using display lists, the one regarding ellipsoids/spheres is the following:
    Code:
      /**
         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...)

  2. #2
    Join Date
    Jun 2007
    Location
    MA-USA
    Posts
    247

    Re: "Ghosts" in my scene when using spheres/ellipsoids

    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...

  3. #3
    Join Date
    Mar 2008
    Posts
    15

    Re: "Ghosts" in my scene when using spheres/ellipsoids

    Quote Originally Posted by bitshifter420
    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?im...antom01oa8.png
    http://img141.imageshack.us/img141/8...om02la7.th.png
    Now I'll try and I'll let you know... Thank you very much for your help!

  4. #4
    Join Date
    Mar 2008
    Posts
    15

    Re: "Ghosts" in my scene when using spheres/ellipsoids

    You were absolutely right, I just moved the scale operation before the rototranslation and everything now works perfectly... Thanks again!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured