# cube mapping

This topic is 3324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
Use Ati's CubeMapGen tool, it can convert cube cross to cubemap.

##### 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 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 on other sites
vry. useful

i can do it now

i heard that openGL had some commands that simplify this process... do u know?

##### 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