Skyboxes and Cube Maps

A skybox is a method for creating the illusion of distant three-dimensional surroundings in your scene. Images are applied as textures to each of the six faces of a cube with the viewer placed in the middle of the cube or skybox. As the viewer moves around the scene, the skybox images remain stationary so that they seem infinitely distant like the horizon in a seascape.

../../_images/skybox_cube_faces.jpg ../../_images/skybox_example_faces.jpg

This figure shows how textures map onto a skybox.

Before we create a skybox in HOOPS, we need to create with Define_Texture. In the call to Define_Texture, we pass six image image “sources” to essentially create a cube map. The sources are applied to the cube map in the following sequence: negative Z-plane, positive Z-plane, negative X-plane, positive X-plane, negative Y-plane, and positive Y-plane. Additionally, we can also set the “camera” option which tells HOOPS which segment contains the camera information for the skybox. Once you have defined the texture for your skybox, call Set_Color under a driver instance using the “windows” option to set the skybox texture. HOOPS will recognize the window backdrop as a texture with six sources and create a skybox from it.

    // creating a texture with six sources
    HC_Set_Camera_Field(12, 12);
    HC_Orbit_Camera(0, 0);

        "source=(mountain_neg_z,mountain_pos_z,mountain_neg_x,mountain_pos_x,mountain_neg_y,mountain_pos_y) camera=SkyboxCamera");

    // using the texture to define a skybox

A helicopter flying by a mountain range created using a skybox and a cube environment map derived from the same texture source.

You can also use the cube map texture as an environment map on faceted geometry as seen in the sample code below:

    HC_Set_Color("faces=(diffuse=white, environment=mountain_cube, mirror=grey)");