We covered how to create static skyboxes in Chapter 1, SDK Game Development Hub. While they are fine for many implementations, some games require day and night cycles.
This recipe will show us how to create a moving sun, which can be superimposed on a regular skybox. In this case, a neutral skybox without any protruding features such as mountains will work best. We'll also learn how to make a sky that changes color during the day. In this case, no skybox is required.
We will also need a texture that should have a transparent background with a filled, white circle in it, as shown in the following figure:
We begin by creating a new application class extending
SimpleApplication
.In the
simpleInitApp
method, we first need to createGeometry
for the sun:Geometry sun = new Geometry("Sun", new Quad(1.5f, 1.5f));
We need to set some rendering hints on it, as shown in the following code:
sun.setQueueBucket(RenderQueue.Bucket.Sky);...