Skip to main content
gamedev.net
🔒 Locked

Cubemapping Views -- Camera Error

Started by Geometrian 2 replies 700+ views
Original Post
Geometrian
Geometrian
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,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]
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
Geometrian
Geometrian
Nevermind--I got it working.
-G
[EDIT] NO I DIDN'T. Next Post.

[Edited by - Geometrian on October 12, 2008 9:06:22 PM]
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
Geometrian
Geometrian
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
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
Geometrian
Geometrian
My mistake--the teapot threw me off--the reflections are still wrong except when the camera hasn't moved. The thread continues here: http://www.gamedev.net/community/forums/topic.asp?topic_id=511996
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.