Wednesday, November 2, 2011

Introducing: the Env3D Scene Creator

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: , , , , , , ,

Friday, November 20, 2009

Site redesign and new version

I have completely redesigned the env3d website. Besides looking way better, I have also included complete lessons on how to use env3d in CS1. You can find them under the "Learn" section of the website.

A new version of env3d is also available. A couple of major changes:

* No need to "install" the extension anymore. Simply download and open the blank project, and follow the lessons to add your own code.

* You can now create 3D-accelerated applets for online distribution.

If you like env3d or have questions or comments, feel free to drop me a line.

Labels: , , , , , ,

Wednesday, September 16, 2009

I'm back!

After working in industry for over a year, I am now back teaching. In my absence, some of my colleagues have used env3d in their courses with positive results. I'm glad and will continue to develop and support the software.

The code repository is now subversion and I have cleaned up the code a bit. The latest version will work on both mac and windows and the bluej extension will work with BlueJ version 2.5.2. In this new version, you no longer have to install the env3d extension for BlueJ, the extension will work on a per project basis.

The OSX 64bit conversion is a bit of a mess to deal with. It seems that BlueJ 2.5.2 on the Mac will default to use 64bit Java 1.6 and will not honor the Java Preferences setting.

I have also been experimenting with the Wii Remote and have integrated it into env3d, so students can interface with the Wii Remote controller directly.

Hopefully, I will have some time to do a new release soon, as well as revamp the website.

Labels: , , , , , ,

Friday, December 21, 2007

Wrapping up for the year

Well, I have just finished using env3d in my first year class. Feedbacks from students are very positive. I have also learned a lot about designing a good API and have been making changes to env3d through each assignment. Lots of work but I think the results are worth it. Here are some students videos on youtube.

I'm now working on using env3d in the follow-up course which teaches inheritance and software design. A few new improvements are already in CVS, the most notable being a new EnvCanvas class for use in GUI applications, a new EnvObject base class, and a new EnvObjectInterface. These new classes will (hopefully) be used to illustrate the usefulness of an inheritance hierarchy.

Labels: , , ,

Saturday, October 20, 2007

New features and some lessons learned

The latest version of env3d (still in cvs, not released yet) will have the following new features:
  • Transparent sprite support
  • Setting of camera angles
  • All resources can be loaded from a jar file.
Since all resources are now loaded from a jar file, you can distribute your application very easily. If you are using BlueJ, you can simply export the project to a jar file. Make sure that the lwjgl native library (lwjgl.dll in windows) is in the same directory as your jar. You can now execute the jar file directly.

This also means any application written using env3d can be setup to use java webstart technology. This will be a big plus for students who want to show off their projects! In the future, I may even incorporate applet support.

New features are great and all, but in my opinion, the most important update is the removal of some of the features.
  • The "move" method will no longer be called automatically
  • Adding a room will no longer automatically add all the objects inside the room
  • Adding of "systems" are not supported
What this means is that every object must be added/removed manually (by students). Env3d is meant to be a learning engine, and as I gain more experience using it, I find that it is best to make the engine do as little "magic" as possible. The only magic here is being able to put objects into a 3d environment. The rest should be done manually.

I am having so much fun using env3d in my class this term. I think that my students are having fun as well. I am able to create examples in Env3d that map almost directly to each chapter of the textbook, I will share them on the website once I have some time (end of term most likely).

Labels: , ,

Monday, July 9, 2007

Introducing env3d

I created env3d to help with my introductory Java course. The internal 3d engine was written a couple of years ago to help me learn OpenGL. Since then, I have been trying to find a way to apply some real-time 3d graphics into my teaching.

What I am planning to do is to cover the first 7 chapters of the bluej textbook using env3d as a tool for in-class demonstration and projects. That's why you'll find that I have used java reflection instead of interface for all 3d objects definitions in my examples.

Env3d is free (under GPL). Please try it out and let me know what you think. I would really appreciate some feedback before I start using it this Fall.

Labels: , , ,