Sign in to follow this  
nicknametooshort

cube mapping

Recommended Posts

hey, can someone show me how to make this image: http://www.outerspace-software.com/images/bixorama/panorama3.jpg to become something of a cube... a full program would be helpful, as i would like to know how to do it... i know how to use 6 separate image to make a cube map but 1 image with 6 squares in it.. i dunno [Edited by - nicknametooshort on December 15, 2008 1:03:57 AM]

Share this post


Link to post
Share on other sites
forgot to mention..

i want to know how to do it, as in code it ourself...
I tried to look all over internet, but it seems that most of the examples on the net utilizes 6 separate image files rather than
my target: cube cross -> cube

thanks for ur suggestion btw...

Share this post


Link to post
Share on other sites
Each face of a cube is a square rectangle. In terms of of these squares, the image you posted is 4 x 3, meaning that it's four squares wide and three squares high. As a result, all you need to do is divide the width of your image by 4 to get the size of each cell. From there, you can calculate the top left and bottom right corners of each cell which gives you its exact size and location inside the image. For instance, the second cell in the top row of an image that is 640x480 pixels is located at [(160, 0), (320, 160)]; the first tuple being the coordinate of the top left corner. Needless to say that the above coordinates assume that the center of the coordinate system is placed on the top left corner of the image.

You can now read each of those cells and upload them to the correct face of a cube texture.

HTH

Share this post


Link to post
Share on other sites
Not OpenGL-specific, but generally you set the field of view (FOV) to 90 degrees, the aspect ratio of the faces to 1:1 (so the field of view is 90° both left-to-right and top-to-down).

Then you have a Yaw-Pitch-Roll-Camera (can do with LookAt, too). Now render the scene 6 times; just to get you an idea, you have 6 camera settings:

yaw pitch roll
[0] 0° 0° 0°
[1] 90° 0° 0°
[2] 180° 0° 0°
[3] 270°=-90° 0° 0°
[4] 0° 90° 0°
[5] 0° 270°=-90° 0°


With a LookAt, the at-points are as follows (with y pointing up):

x y z
[0] 0, 0, 1 front
[1] -1, 0, 0 left
[2] 0, 0,-1 back
[3] 1, 0, 0 right
[4] 0, 1, 0 up
[5] 0,-1, 0 down


Then place them seamlessly as in mentioned image.


edit:typo

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