Is this spotlight stuck to the camera or what???

I’m getting slightly lost. Just trying to put a spotlight in a 3d scene. But check this screencapture. It looks to me this spotlight is stuck to the camera while it should be where the cone is drawn.

https://vimeo.com/45782142

Is there anything I should know about ofLights, ofCamera and or the drawing mechanism. I’m using the ofxGameCamera addon btw.

basically in setup i’m doing:

  
  
ofEnableLighting(); //== glEnable(GL_LIGHTING);  
glShadeModel(GL_SMOOTH);  
ofEnableSeparateSpecularLight();  
ofEnableNormalizedTexCoords();  
ofDisableArbTex();  
  
light.setSpotlight();  
light.setPosition(mPosition);  
light.setSpotConcentration(64);  
light.setSpotlightCutOff(30);  
light.setDiffuseColor(mColorDiffuse);  

Then in draw:

  
  
cam.begin();  
light.customDraw();  
ofPushMatrix(); ofPushStyle();  
        ofEnableLighting();  
        glEnable(GL_NORMALIZE);  
        glEnable(GL_DEPTH_TEST);  
        //fix blender axis  
        ofRotate(-90, 1, 0, 0);  
        movie.getTextureReference().bind();  
        //assimp stuff  
        material.begin();  
        mesh.drawFaces();  
        material.end();  
        movie.getTextureReference().unbind();  
ofPopMatrix(); ofPopStyle();  
cam.end();  
  

Just tried the ofxGrabCam addon but the same issue… I’m definitely over seeing something. :’(

Hmmm found a pointer
http://www.opengl.org/archives/resources/faq/technical/lights.htm

So apparently you need to reset the light position after a camera has moved. Otherwise the light will keep remain relative to the camera not to the world.

Tried to that by just setting the position of the light after camera.begin. And it works :slight_smile: Another thingy in opengl you wouldn’t think of naturally :slight_smile:

Best would be now to have a listener… anyway…