   How do I make the lights light up part of my HUD?
  Hello!I have implemented a HUD in my game and I'm currently rendering the weapon in this hud as well.In opposite to the rest of the HUD, the weapon should be affected by the lighting around the player.I'm using gluLookAt() for the world rendering and the following code for the HUD:    public void renderInterface(GLAutoDrawable drawable){   gl.glClear (GL.GL_DEPTH_BUFFER_BIT);    gl.glMatrixMode (GL.GL_MODELVIEW);    gl.glPushMatrix();    gl.glLoadIdentity();    gl.glMatrixMode (GL.GL_PROJECTION);    gl.glPushMatrix();gl.glEnable(GL.GL_COLOR_MATERIAL);    renderLights(lastLightList,true); // render lights with the player coordinate subtracted   gl.glLoadIdentity();    gl.glOrtho(0.0f, 550f, 450f, 0.0f, -1.0f, 1.0f);    ...    - render the weapon -  ...    gl.glDisable(GL.GL_COLOR_MATERIAL);    gl.glDisable(GL.GL_LIGHTING);    ...   - loads of HUD-code -   ...    gl.glPopMatrix();    gl.glMatrixMode (GL.GL_MODELVIEW);    gl.glPopMatrix();  gl.glEnable(GL.GL_LIGHTING);    }This code actually makes the weapon somewhat affected by the surroundings, howeverthe weapon is way too dark if not the whole level is fully lit up with ambiant lighting.In the current attempt for "solution" I use renderLights(lastLightList,true); wich renders the lights but subtractsthe player coordinates from the GL_POSITION for the lights.Any help with this is much appreciated!   
  Don't know if it is of any help (I don't know GL, so can't give the GL code for it). But to put the lights into cam space, take the inverse of the camera matrix and multiply the lights with it. Assuming the weapon matrix is already in cam space (i.e you specify the weapon transform relative to the camera) you can then do the usual calculations on the weapon sine they are now both in the same space. The only thing to do after that is applying the projection matrix (no transforms, just accounting for screen ratio and perspective and optionally multiplying Z with -1 if looking into the negative z-direction (like in blender).   ;Quote:Original post by Ron AF GreveDon't know if it is of any help (I don't know GL, so can't give the GL code for it). But to put the lights into cam space, take the inverse of the camera matrix and multiply the lights with it. Assuming the weapon matrix is already in cam space (i.e you specify the weapon transform relative to the camera) you can then do the usual calculations on the weapon sine they are now both in the same space. The only thing to do after that is applying the projection matrix (no transforms, just accounting for screen ratio and perspective and optionally multiplying Z with -1 if looking into the negative z-direction (like in blender).Thanks for replying!I'd love to try out your suggested solution. However matrix operations are not native in Java. So I'd have towrite an algorithm to calculate the inverse of the camera matrix, wich probably wold be hard to write as wellas slow. The viewing matrix I'm using for the HUD is Ortho (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/ortho.html).It seems the inverse of the Ortho matrix would be(right-left,0,0,right-left,0,top-bottom,0,top-bottom,0,0, zFar-zNear, zFar-zNear,0,0, 0, 1)I suppose I could make an algorithm for the matrix multiplication. Do you thinkit would work.Also, by suggesting multiplying this matrix with the lights, do you refer to the light position matrix?   ;  I would assume that by substracting the player position from the weapon, if that makes it appear in front of the camera that would be the inverse transform. But from the comment in your code that seems what you are already doing (you already substract the camera position from the ligths). So, your camera doesn't rotate?Is there also a light behind the camera (otherwise that would explain why it is of course dark).   ;Quote:Original post by Ron AF GreveI would assume that by substracting the player position from the weapon, if that makes it appear in front of the camera that would be the inverse transform. But from the comment in your code that seems what you are already doing (you already substract the camera position from the ligths). So, your camera doesn't rotate?Is there also a light behind the camera (otherwise that would explain why it is of course dark).I tried to see that the light rendering should take the rotation into consideration with the upcoming code-snippet.However the weapon still remains very darkly rendered. The effect seems to be exactly the same:if(hud){lightpos[0] = lightArray[lightsToRender][0]-new Double(px).floatValue();lightpos[1] = lightArray[lightsToRender][1]-new Double(py).floatValue();lightpos[2] = lightArray[lightsToRender][2]-new Double(pz).floatValue();}if(hud){gl.glPushMatrix();gl.glRotated(xDir/(Math.PI/2)*360,1,0,0);gl.glRotated(yDir/(Math.PI/2)*360,0,1,0);gl.glRotated(zDir/(Math.PI/2)*360,0,0,1);}gl.glLightfv(gllight,GL.GL_POSITION,lightpos,0);if(hud)gl.glPopMatrix();