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

Thursday, July 14, 2011

Release of stable and development versions

As you probably know, Env3D uses JavaMonkeyEngine (jME) internally. By using a commercial quality 3d engine, env3d gains the ability to take advantage of the latest graphics technology available to Java. It also provides a path for env3d users to access jME features to create visually sophisticated software. The latest lessons on nifty gui and particle system are examples of how env3d can access internal jME features.

All these, of course, came with a price. The latest version of jME makes exclusive use of shaders technology, which means it may not run on older hardware. To make env3d available to as many people as possible, I have decided to maintain 2 versions of env3d:

1) A "stable" version which is compatible with more hardware, but does not have access to all the latest and greatest features (Part III of the lessons page).

2) A "development" version that have full access to all the features, but need better graphics hardware.

Both versions can be downloaded on the download page.

Labels: , , ,

Saturday, March 12, 2011

Mouse picking

The latest version of env3d adds the ability to use the mouse to interact with objects in 3D space.

Previously, the only mouse position related methods are Env.getMouseX(), and Env.getMouseY(). These methods return only the screen coordinates but not the pointer coordinates in 3D space. This makes it hard to implement features such as using a mouse of select an object inside the 3D environment.

Users of env3d now has a few more methods to use, the details can be found at http://env3d.org/beta/node/113.

Perhaps that most important method is Env.getPick(int screenX, int screenY). This method takes the screen's x and y coordinate and returns the first object in 3D space under that coordinate. The object returned is of the generic Object type so users will have to cast it to the appropriate type before using it.

Labels: , , , , , ,

Friday, January 7, 2011

env3d.org launched

Very exciting news -- Over Christmas, one of my students, Kenny, decided to create a community website for Env3D. The result is http://env3d.org. This new site has lots of features, including community forums, applet sharing, and all of the lessons from the old sourceforge site.

Enjoy the new site and give us some feedback on our forum!

Labels: ,

Friday, November 5, 2010

A little history of Env3D

One of my students asked me recently about the history of Env3D. I thought I'd share it here:

It was 2002, I wanted to learn opengl and see if there was any way Java can use hardware acceleration. During my research, I came across 2 opengl wrapper libraries: LWJGL and JOGL. LWJGL is a community driven project while JOGL is supported by Sun (the company behind Java).

While the logical decision was to go with JOGL, I decided to use LWJGL instead as it has a much more active and vibrant community (just visit http://lwjgl.org to see for yourself). The result was a simple 3D engine which I used to create a few simple demos, but nothing that students can actually use.

Fast forward to 2006, machines have gotten more powerful and 3D hardware acceleration is available on even the cheapest of the motherboards, so I thought it might be interesting to use 3D graphics to teach first year Java. At the same time, we switched to the BlueJ textbook which is excellent, but in my opinion, lacks the "visual punch". So I started writing the first version of Env3D to support the textbook. That first version was based on the simple engine that I created back in 2002.

After using Env3D for the first time back in 2007, I realized that the library can be used for much more than just to support BlueJ -- it is actually a general purpose library that students can use to create fun little flash like games. There are 2 problems:

1) It's not easy to distribute the game to others -- it's not good to have your user install BlueJ and the Java JDK.

2) The underlying engine was not powerful enough to support high-end features like bone animation, shaders, etc.

The first problem was relatively easy to solve, it turned out that the LWJGL community had already come up with a way to turn LWJGL programs into applets! So I modified some of my code and added a a new feature in the Env3D-BlueJ extension to automate the creation of applets.

The second problem was much harder to solve, in order to support state-of-the-art graphical features, I needed to re-program my custom engine. I decided that it was too much work for one guy, so I started looking around for an alternative engine that Env3D can be based on. My research resulted in the javamonkey engine (http://www.jmonkeyengine.com/ ). It is an open-source engine that has all the features that I wanted, and it uses LWJGL for rendering! So for the past many months, I worked really hard to switch the internals of Env3D to use the Java Monkey engine. The version that you are using right now is the result of my months-long effort. In theory, future versions of Env3D can now use all of the features of the JavaMonkey engine!

So, in a nutshell, this is how the Env3D library look now:

Your program --> Env3D --> Java Monkey Engine --> LWJGL --> 3D hardware.

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