PDA

View Full Version : Cube map reflection behavior



halo
02-27-2005, 07:16 AM
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.

{cYanide}
02-27-2005, 08:57 AM
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.

halo
02-27-2005, 09:42 AM
I know, I know, I just get really frustrated and angry when I get stuck on something technical.

Java Cool Dude
03-04-2005, 07:37 AM
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 (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=11;t=000641) , plus there are binaries :)

jwatte
03-05-2005, 07:25 PM
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" ?