Sign in to follow this  
Geometrian

Cubemapping Views -- Camera Error

Recommended Posts

Hi, Well I finally got most of cubemapping figured out. One problem left though. The problem arises in that the reflections I'm seeing look completely wrong--i.e., they aren't in the right place on the reflecting object. When rendering to the texture, I set the view using gluLookAt(). I assume this is where the problem is. Here's the code (Python):
cubefaces = [GL_TEXTURE_CUBE_MAP_POSITIVE_X,
             GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
             GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
             GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
             GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
             GL_TEXTURE_CUBE_MAP_NEGATIVE_Z]
for i in xrange(0,6,1):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        if   i == 0: gluLookAt(x,y,z, 1, 0, 0,0,1,0)
        elif i == 1: gluLookAt(x,y,z,-1, 0, 0,0,1,0)
        elif i == 2: gluLookAt(x,y,z, 0, 1, 0,1,0,0)
        elif i == 3: gluLookAt(x,y,z, 0,-1, 0,1,0,0)
        elif i == 4: gluLookAt(x,y,z, 0, 0, 1,0,1,0)
        elif i == 5: gluLookAt(x,y,z, 0, 0,-1,0,1,0)
        #Draw objects that will be reflected.  (Turning off cubemapping first, then reenabling it after)
        glTexImage2D(cubefaces[i],0,GL_RGB,ReflectionMapSize,ReflectionMapSize,0,GL_RGB,GL_UNSIGNED_BYTE,RenderToTextureData())
        #The last function as an argument to glTexImage2D() renders the view (it simply grabs what's in the framebuffer)
        #And so on finalising texture here...

This may not be where the problem lies--if not just say so. Ideas why this isn't working? Thanks, Geometrian [Edited by - Geometrian on October 12, 2008 9:31:26 PM]

Share this post


Link to post
Share on other sites
Actually, it doesn't seem to work. The trouble is, when moving the camera, strange things happen. I got the impression it was working because it seems to work only when the camera doesn't move, i.e., the world is moved. However, when gluLookAt() is called, and the camera moved in a horizontal plane, it doesn't work:
Strangely, moving in a vertical plane works:
This is a truly bizaare error. Ideas?
Thanks,
G

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this