Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a dynamic skybox with a moving sun


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.

Getting ready

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:

How to do it...

  1. We begin by creating a new application class extending SimpleApplication.

  2. In the simpleInitApp method, we first need to create Geometry for the sun:

    Geometry sun = new Geometry("Sun", new Quad(1.5f, 1.5f));
  3. We need to set some rendering hints on it, as shown in the following code:

    sun.setQueueBucket(RenderQueue.Bucket.Sky);...