Duekiller

Members
  • Content count

    65
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Duekiller

  • Rank
    Member
  1. Normal problem

    Alright I think I got it working. I give it the regular normal that is prependicular to the screen and then i supply the matterial with GL_LIGHT_TWO_SIDE and it seems to be working. Thanks for all your help I appreciate it.
  2. Normal problem

    Is there any way I can give the back face the same properties as the front face, just with a diffrent normal ?
  3. Normal problem

    Yeaha that is what I am thinking. I am thinking that there might be a trick to this that I am missing.
  4. Normal problem

    Quote:Original post by levjs Backfaces' normals are the exact same except they are flipped. Couldn't you use this to your advantage. For example, instead of recomputing the whole thing, couldn't you just multiply the vectors by -1 to flip it? That would take much less time. Levi Yes I could, but the problem is How to I get to the normal without recomputing my scene. I set the normal when I compute the geometry and then as soon as I am done it all gets dumped into a display list. My question is how do I change the normals in the display list ?
  5. Normal problem

    Quote:Original post by levjs Well, if you rotate 180 degrees, you would not be looking at a backface. When you look at a cube, the backfaces are the ones that you cannot see unless you are INSIDE of the cube. The back of the cube's backface is the face you would see if the front was removed. So you should only flip normals when you are able to see the faces insid the cube. Levi That is the problem I am using a display list to display the results and make them interactive.... Reseting the normals would require me to recompute the geometry, which takes a decent amount of time.
  6. Normal problem

    I am trying to achieve two sided lighting. Imagine you have a rectangle and you are staring straight down at it, now I want to have the same lighting if you stare at the back face (the light source is the "camera")
  7. Normal problem

    I am really stubled here and I was wondering if anyone had a good solution. Alright here is my problem: I have a geometry that takes a while to compute, but once computed I use display lists to rotate and zoom (its a CAD software). The problem that I am having is that I was the normals to always face user, so when I original compute I negate the normal depending on which direction it is facing. Now, here is the issue that I am having. Since all normals face the user when the geometry is computed if you pan 180 degrees everything appears screwed up. My question is, is there a way to change the normals in a display list without having to recompute the scene ?
  8. Lighting Problem

    Solved this finally. There was code in the normal vector to always have the vector point towards the user. The problem was that the vector was not correctly.
  9. Lighting Problem

    Quote:Original post by Nit Ahhhhh. Let me guess what you are doing. When you use display lists, you make only 1 call to glNormal3f(...), before you do a glCallLists(), right? If that is the case, then that completely explains why you are getting erroneous lighting. You are assigning all faces the same normal, which is wrong. Well when I make the glnewlist() I assign the normals in that code.
  10. Lighting Problem

    Quote:Original post by Nit I notice that your light position is at 0.0f, 0.0f, 0.0f. Try setting it to 15.0f, 0.0f, 0.0f. Perhaps the light source is inside your sphere. Even when I create a dozen speheres I get the same result on all the speheres. There front side has normal lighting and the back side does not light corectly, only until I redraw without the display list. During regular draw we compute the normals, but the normals should not matter for spheres because they always face outwards... because the lighting works fine for the front faces, but not the back faces.
  11. Lighting Problem

    Quote:Original post by Nit Copy and paste this: glLightfv(GL_LIGHT0, GL_POSITION, fltLightPos); and put it right after you perform your rotations and translations. ROTFL, now the wrong side is lit. The backside has proper lighting now, but the front side is dark. (reveresed)
  12. Lighting Problem

    Quote:Original post by Nit Copy and paste this: glLightfv(GL_LIGHT0, GL_POSITION, fltLightPos); and put it right after you perform your rotations and translations. Explain, please????
  13. Lighting Problem

    Here is the setup code [code] // Store current OpenGL machine state: { // Viewport: glGetIntegerv(GL_VIEWPORT, m_dOldViewport); // Matrices: glGetIntegerv(GL_MATRIX_MODE, &m_dOldMatrixMode); glGetDoublev(GL_MODELVIEW_MATRIX, m_dblOldModelViewMatrix); glGetDoublev(GL_PROJECTION_MATRIX, m_dblOldModelionMatrix); // Light: glGetFloatv(GL_LIGHT_MODEL_AMBIENT, m_fltOldLightModelAmbient); glGetLightfv(GL_LIGHT0, GL_AMBIENT, m_fltOldLight0Ambient); glGetLightfv(GL_LIGHT0, GL_DIFFUSE, m_fltOldLight0Diffuse); glGetLightfv(GL_LIGHT0, GL_SPECULAR, m_fltOldLight0Specular); glGetLightfv(GL_LIGHT0, GL_POSITION, m_fltOldLight0Pos); } { glViewport(lpOpenGL->vx, lpOpenGL->vy, lpOpenGL->vw, lpOpenGL->vh); glScissor(lpOpenGL->vx, lpOpenGL->vy, lpOpenGL->vw, lpOpenGL->vh); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(mode == GL_SELECT) { GLint viewport[4] = {lpOpenGL->vx, lpOpenGL->vy, lpOpenGL->vw, lpOpenGL->vh}; LPPOINT pMouse = reinterpret_cast<LPPOINT>(pModeParam); if(pMouse) gluPickMatrix((double)pMouse->x, (double)pMouse->y, 5.0, 5.0, viewport); else _ASSERT(FALSE); } float zDepth = 0.f; double aspect = double(lpOpenGL->vw)/double(lpOpenGL->vh); if(perspective) { zDepth = lpOpenGL->dz/tan((PERSPECTIVE_ASPECT_ON*float(PI))/360.f); gluPerspective(PERSPECTIVE_ASPECT_ON, aspect, 0.01f*zDepth, 100.f*zDepth); } else { zDepth = lpOpenGL->dz/tan((PERSPECTIVE_ASPECT_OFF*float(PI))/360.f); gluPerspective(PERSPECTIVE_ASPECT_OFF, aspect, 0.01*zDepth, 100.0*zDepth); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Setup light model for the 3D-scene: { // Ambient light: { // Bright white light - full intensity RGB values: const GLfloat fltAmbientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f }; // Set light model to use ambient light specified by fltAmbientLight[]: glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, fltAmbientLight); } // GL_LIGHT0 source: { // Light values and coordinates const GLfloat fltAmbientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f }, fltDiffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f }, fltSpecular[] = { 1.0f, 1.0f, 1.0f, 1.0f }, fltLightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f }; // Setup and enable light 0 glLightfv(GL_LIGHT0, GL_AMBIENT, fltAmbientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, fltDiffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, fltSpecular); glLightfv(GL_LIGHT0, GL_POSITION, fltLightPos); } } // Move observer away from screen: glTranslatef(lpOpenGL->px, lpOpenGL->py, -zDepth); // Z Up -> Rotate x, rotate y, rotate z; glRotatef(lpOpenGL->rx, 1.0f, 0.0f, 0.0f); glRotatef(lpOpenGL->ry, 0.0f, 1.0f, 0.0f); glRotatef(lpOpenGL->rz, 0.0f, 0.0f, 1.0f); // Move observer to a specified location: glTranslatef(lpOpenGL->ox, lpOpenGL->oy, lpOpenGL->oz); [\code]
  14. Lighting Problem

    Quote:Original post by Nit Just to test, set the light position after you perform your rotations. I think ViLio might have been on to something, the light position needs to be rotated by the rotation matrix. Right now the light is moved to the correct position and then the model is rotated.
  15. Lighting Problem

    Quote:Original post by levjs Perhaps your vertices on the back are not in the proper order? Try setting lighting to be computed for both front and back faces by putting glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); in your init code and see if it works right. Levi Nope did not seem to fix the problem.... I think that its an ambient lighting problem.