The Env3D Scene Creator is a graphical user interface (GUI) for editing terrain and placing objects inside a Env3D world.

To access the Scene Creator under BlueJ, select “Tools->Env3D->Env3D Scene Creator” from the pull-down menu.

Selecting the sky and terrain

The first step is to select the sky and terrain textures. Sky textures are stored under the directory textures/skybox/ while the terrain textures are stored in textures/terrain/.

Adding objects

Objects can be added into the environment by selecting from the pull-down menu. Once an object is select, you are put into “Edit Mode” where the mouse is captured. You can then use the standard WASD keys to move around the enivornment and use the left mouse click to place the object into the world. Multiple objects can be placed by repeatedly clicking on the left mouse button. While in EDIT mode, you can use the LEFT and RIGHT arrow keys to rotate the object.

Pressing the ESCAPE key will exit “Edit Mode”.

Once the objects are placed, press the save button on the top left, or close the Scene Creator window. This will save your scene and the corresponding java classes will be generated in the BlueJ editor.

The generated classes

For every model that you add into your scene, a corresponding java class is generated, with the most basic generated class looking like the following:

/**
 * This class is generated by the env3d plugin to make
 * it easier to work with models.  It scans a model
 * directory for all the obj files and organized them.
 */
public class Tux extends GameObject
{
    /**
     * Zero-argument constructor that places the object in location 0, 0, 0
     */
    public Tux()
    {
        this(0,0,0);
    }

    /**
     * Parameterized constructor - allows arbitary of object
     */
    public Tux(double x, double y, double z)
    {
        setX(x);
        setY(y);
        setZ(z);
        setScale(1);
        setTexture("models/tux/tux.png");
        setModel("models/tux/tux.obj");
    }
}

Animating the objects

Right now, the objects are static. To animate them, you need to define a move() method. Each class’ move method is automatically called 30 times per second. To animate the Tux object in the above example, add the following code to the Tux class:

    public void move()
    {
        moveForward(0.1);
    }

This makes the Tux move forward by 0.1 unit 30 times per second.

To see this application in action, compile and run the Game class’ main method.

Previous Chapter Next Chapter