View Full Version : CUBIC ENV MAPPING

04-12-2001, 10:24 AM
I have been playing around with cubic env mapping, how do I get env mapping to reflect based on the objects location in relation to the camera, so that the reflection on a sphere changes with the camera?

04-12-2001, 10:50 AM
before rendering the sphere grab the modelviewmatrix, grab its rotation and invert it, load this into the texturematrix of your cubemapstage

grab its rotation:

just kill the 4th line / row.. means this:

a b c 0
d e f 0
g h i 0
0 0 0 1

then inverting is simple cause its just rotation: you have to transpose it simply..

a d g 0
b e h 0
c f i 0
0 0 0 1

then load this into the texturematrix.. like that the cube rotates in the inverted way you do.. that means ( cause cubemap is viewindependand, so you dont rotate.. ) it works like the camera system.. instead of moving the cam you move the scene in the opposite..

04-12-2001, 11:01 AM
Cool thanks, i'll give that a go! http://www.opengl.org/discussion_boards/ubb/smile.gif

04-12-2001, 11:04 AM
Is there a way with GL to copy the current matrix into a local matrix?

04-12-2001, 11:06 AM
as long as i am online, you can grab a demo here.. ( i have a 56k modem, so slow uploading.. but its not soo big.. )

hope you are fast enough.. its just this code i wrote above.. nothing else..

btw, its my harddrive you will grab it when you do it.. so be fast, i have to reboot in bout 20minutes, and then i will loose this ip..

[This message has been edited by davepermen (edited 04-12-2001).]

04-12-2001, 11:13 AM
float matrix[ 16 ];
glGetFloatv( GL_MODELVIEW (_MATRIX.. i dont remember ), matrix );

do you have MSDN library? if you have, just browse it, it has every opengl function described.. ( very usefull, have to upload it sometimes onto my official page )

04-12-2001, 11:35 AM
Resolved dynamic IP address []
Resolved dynamic IP address [] localhost - [12/Apr/2001:21:33:28 +0200] "GET /Demonstration.zip HTTP/1.1" 206 17631 "" "FlashGet"
Resolved dynamic IP address []
Resolved dynamic IP address []

hm.. whas that you mwanderson? what the hell is "FlashGet"..

04-12-2001, 11:57 AM
A nice FTP programm, you can get it at www.amazesoft.com. (http://www.amazesoft.com.)

(But i didn't download, just wan'ted to give an answer)


04-12-2001, 12:45 PM
Nope I just downloaded it a second ago