How to render a skybox
A skybox is a panoramic view representing a sky or any other scenery. It is a simple way to add realism to a game with minimal performance cost. A skybox is generated from a cube. Each face of the cube contains a texture representing a visible view (up, down, front, back, left, right) of the scenery.
Note: Please make sure to read the Untold Engine Toolchain before continuing on with this tutorial. All images must be converted to binary format (.u4d) using the Digital Asset Converter.
Skybox Example
The Untold Engine represents a skybox as a U4DEngine::
Step 1. Create a Skybox instance
To instantiate a skybox, you must create an instance of the U4DEngine::
U4DEngine::U4DSkybox *skybox=new U4DEngine::U4DSkybox();
Step 2. Initialize a Skybox
Once the skybox has been instantiated, you initialize the skybox with the images representing the scenery and the size of the skybox.
//The resource loader singleton will load all binary data into the engine U4DEngine::U4DResourceLoader *resourceLoader=U4DEngine::U4DResourceLoader::sharedInstance(); //The .u4d file should contain the binary representation of your image. Please read about the Untold Engine Toolchain resourceLoader->loadTextureData("uiTextures.u4d"); //initialize the skybox skybox->initSkyBox(20.0,"LeftImage.png","RightImage.png","TopImage.png","BottomImage.png","FrontImage.png", "BackImage.png"); //add the skybox to the scenegraph with a z-depth of -1 addChild(skybox,-1);
Here is an example of a Skybox added to represent a space scenery:
Tip
- All skyboxes images need to be inverted (flipped) verticaly.
- The images representing Top and Bottom must be rotate 180 degrees and then inverted vertically.