Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Object is translucent. Depth problem.

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    Object is translucent. Depth problem.

    Okay, so I'm new here. I'm trying to load the f-16 obj file that Nate Robins provided with his examples. Here is how my code goes, very simple I believe.

    Code :
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glEnable(GL_LIGHTING);
    	glEnable(GL_LIGHT0);
    	GLfloat lightpos[] = {-1, -1, -1, 0};
    	glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
    	glEnable(GL_DEPTH_TEST);
    	glPushMatrix();
    	glRotatef(-38.0,-0.84,1.00,0.00);
    	drawModel();
    	glPopMatrix();
    	glutSwapBuffers();

    This is what I get.



    I do ask glut for a depth buffer.

    Code :
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

    All I want to do is see the obj correctly, from any angle and in any way possible. Any help is much appreciated, Thank you.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    4

    Re: Object is translucent. Depth problem.

    Can't find any problem with depth in your code
    What's wrong with this picture? Can you provide more details?

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    Re: Object is translucent. Depth problem.



    This is what it should look like. Sorry if I wasn't detailed enough.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    4

    Re: Object is translucent. Depth problem.

    To my understanding, your first picture is just observing the model from another direction than the your second picture.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: Object is translucent. Depth problem.

    Yep. Your rotation is the the problem. It's actually no observable translucency anywhere.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    192

    Re: Object is translucent. Depth problem.

    Quote Originally Posted by thokra
    Yep. Your rotation is the the problem. It's actually no observable translucency anywhere.
    I differ. The view angle is same but careful observation shows parts of the plain ( especially the second rocket) visible instead the other way, as it comes just under the wing. Rotation would have affected the tail too.

    @Waleed: Please check the drawmodel(). Are you drawing backface after the front face? Are you using blending function?

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    Re: Object is translucent. Depth problem.

    @awhig:

    Here is my drawmodel() function,

    Code :
    void drawModel(void)
    {
        if(!pmodel)
    	{
    		pmodel = glmReadOBJ("f-16.obj");
    		if(!pmodel)
    			exit(0);
    		glmUnitize(pmodel);
    		glmFacetNormals(pmodel);
    		glmVertexNormals(pmodel, 90.0);
        }
    	glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
    }

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    Re: Object is translucent. Depth problem.

    @thokra:

    It's not translucent. I don't know what it is. It's the same angle and I should not be able to see the rocket in the middle. I should barely be able to see the tips of the second rockets as well. It's driving me crazy!

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: Object is translucent. Depth problem.

    How does it look when you leave out the rotation?

  10. #10
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    192

    Re: Object is translucent. Depth problem.

    @Waleed

    How are the triangles defined in the model file? Are there any entries for back faces, with negative values?

    Most probable reason looks to be wrong lighting calculations. i.e calculation between face/vertex normal and light vector is still positive for a face that is facing away from you. If this is true then back faces will look to you as front faces.

    As a test, do one thing, disable all lighting and check the quality of model drawn. If you get exactly what is desired it means there is some problem in lighting calculations.

Page 1 of 2 12 LastLast

Similar Threads

  1. Getting the depth image of a 3D object
    By Prendtout in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 03-06-2012, 08:34 AM
  2. Problem in blend texture to draw translucent line
    By anoop.singh.knit in forum OpenGL ES
    Replies: 0
    Last Post: 12-26-2011, 12:09 AM
  3. Problem in blend texture to draw translucent line
    By Anoop in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-25-2011, 11:34 PM
  4. Replies: 2
    Last Post: 09-09-2005, 06:09 AM
  5. Depth-sorting translucent parts - question
    By nagual20 in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 02-28-2002, 05:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean