It started out as a small bug fix to the "Start Env3D" visualization tool, and quickly evolved into a full blown framework and code generation tool. The new Scene Creator in Env3D has to ability to setup a scene in env3d using drag and drop instead of creating and placing the objects in code -- allowing students to create nicer looking games in a fraction of the time. Furthermore, all the learning objectives are enhanced by allowing students to examine and modify generated source code.
Inspiration
I have always wanted to integrate drag-and-drop functionality into env3d -- it just makes so much more sense than placing objects in code using a series of env.addObject(...) calls. The idea really came from
Alice - a complete drag-and-drop 3D programming environment. While Alice is wonderful tool for students learning to program for the first time, the drawback of Alice, in my opinion, is that students are limited to drag and drop, so it is not very suitable for non-beginners trying to write more complex software.
Another wonderful piece of software from the BlueJ team -
Greenfoot, takes a different approach. It is a 2D programming environment with some drag-and-drop support. The major difference between Greenfoot and Alice is that students actually learn how to program in Java. Greenfoot simply provides drag-and-drop support for placement of objects, and a framework so that students can focus on programming individual objects instead of creating everything from scratch.
The Scene Creator in Env3D takes inspiration from both Alice and Greenfoot. It has a 3D drag-and-drop interface for object placement, but generates a Greenfoot-like framework where students must customize using Java. I suppose this could be a "best-of-both-worlds" solution, at least from my point of view :)
Getting started
To get started, download the latest development version of
env3d_template.zip and extract to a directory of your choice. Then start BlueJ and open the extracted directory (which is a BlueJ project).
After the env3d_template project is opened, go to the tools menu and select Env3D, you'll find the "Env3D Scene Creator" option available.
If this is your first time, you'll be presented with a black window and a few drop down menu items across the top.
The first 3 drop-down menus allows you to choose the background, the ground type, the third one allows you to drop a model into the environment. Probably best to show how it works with a video:
Feel free to change the background and the ground at any time, I have included lots of different backgrounds and floor textures. They are located in the "textures/skybox" and "textures/floor" directory if you want to add to or remove from it.
The most exciting part is of course adding models. The scene creator scans the models/ directory for appropriate models. Once you have chosen the model from the models drop-down menu, you are entered into "Object Edit Mode" where the mouse will be grabbed by the 3D window. In edit mode, you navigate with W, A, S, D keys for movement, and the mouse for looking around (just like a modern video game). When an object is selected, it will be shown in wireframe. You can use the UP and DOWN arrows keys to resize the object, and the LEFT and RIGHT arrow keys to rotate the obejct. Clicking on the mouse will place the currently selected object into the environment. Pressing ESCAPE will take you out of edit mode and you get your mouse back.
Generating Code
When you hit the save button, the code will be generated in the BlueJ project. Each model is one class, and is inherited from the GameObject class (for the Greenfoot users, this is roughly equivalent to the Actor class in Greenfoot). The Game class is where the game can be launched.
The GameObject class has an empty method called move(). This move() method is called every frame of the game, so various animations and game logic can be implemented by overriding the move() method in sub-classes, as shown in the above video.
Conclusion
That's it for our basic tour of the Env3D Scene Creator. Read the code to the GameObject class and the Game class for an idea of how the framework is setup (it is very similar to the Greenfoot framework).
There are lots more to the Scene Creator, including support for animated models, that is not covered by this introductory article. I will be posting more articles soon, so stay tuned!
Labels: 3D graphics, bluej, computer science, education, env3d, java, programming, teaching