Cube map reflection behavior

I want my cube maps to move with the camera position, not with the camera rotation, like in this Blitz3D demo:
http://www.leadwerks.com/post/cube.zip

How do I do this in OpenGL? If the camera position is x,y,z, what do I do to the texture matrix to make my cube map move? (I am using GL_REFLECTION_MAP). I have experimented, A LOT, with normals, moving the texture matrix, using EYE_LINEAR projection modes, and I am not getting anything close to what I want.

Most explanations I read say to rotate the texture matrix by the camera rotation. This makes no sense. The reflection should only change with position, not camera angle.

are you gonna just insult people helping again? if so dont bother. its pathetic, i know exactly what you need but im damned if im gonna help you.

I know, I know, I just get really frustrated and angry when I get stuck on something technical.

Load the inverse modelView matrix (minus the translation part) into the texture matrix correponding to your CubeMap, that should fix it.

void SceneFrame::updateTextureMatrix()
{
  if(!reflectiveGroup)
    return;

  for(int s = 0; s < reflectiveGroup->getShapesCount(); s++)
    reflectiveGroup->getShape(s)   ->
                    getAppearance()->
                    getTexture(0)  ->
                    getTransform() ->set(inverseModelView);
}

void SceneFrame::modifyTextureMatrix()
{
  inverseModelView = camera.getModelViewMatrix();
  /*inverseModelView.m00 = 0; inverseModelView.m01 = 0; inverseModelView.m02 = 0;*/ inverseModelView[ 3] = 0;
  /*inverseModelView.m10 = 0; inverseModelView.m11 = 0; inverseModelView.m12 = 0;*/ inverseModelView[ 7] = 0;
  /*inverseModelView.m20 = 0; inverseModelView.m21 = 0; inverseModelView.m22 = 0;*/ inverseModelView[11] = 0;
  inverseModelView[12] = 0; inverseModelView[13] = 0; inverseModelView[14] = 0;   inverseModelView[15] = 1;
  inverseModelView.setInverse();
}

I discuss a similar thing here , plus there are binaries :slight_smile:

Most explanations I read say to rotate the texture matrix by the camera rotation. This makes no sense. The reflection should only change with position, not camera angle.
If that’s too “technical” for you to figure it out on your own, how about just trying it, rather than saying “it makes no sense” ?