Saturday, 10 March 2007

Ajax3D experiment: Learning X3D

One of the problems with X3D is how little useful information there is on how to use it. There is the occasional tutorial, blog entry or forum post which is relevant to what you want to know, but beyond this it seems to come down to blind experimentation. With plugins which also support Firefox but tend to be very crash prone in it. Or largely undocumented editing studios.

Now X3D is a standard and it does have specifications which you can browse and download, but in my experience they tend to have their own accessibility issues. Designed using frames and not available in a form conducive to either printing or looking up items of interest, what you really need is for them to be available in other more accessible forms. Like PDF. Unfortunately they are not.. well, actually they are available to some definition of the word. You can pay an extortionately high price to get a PDF of at least the main specification from ISO:


230 CHF? That's around 270 $NZ in real money. Or 11000 ISK in not so real money. It'd almost be worth my time for that price to write a Python script to reformat the frame based HTML.

On the bright side however, www.web3d.org does provide zipped versions of the HTML for download. And I may refer to a few problems with Media Machines' plugin and editing studio in my initial paragraph, but they are both very capable and free and still my X3D tools of choice.

Friday, 9 March 2007

Ajax3D experiment

Years ago I used to do MUD development as a hobby. The direction we were heading was to define the text based game world in 3D in order to have a continuous world rather than room based as was the standard. The long term goal was to have a simple 3D editor to streamline world building. Luckily one of the other programmers, Brian Behlendorf, was a doer and he put his head down and came up with a prototype. A VRML viewer for the game world. It took advantage of the fact that our MUD had an integrated web server, which could be used to fetch the static world data, and used Javascript to make a VRML plugin (Cosmo Player) fetch that data from it.

Nowadays I have a hobby project I need to visualise. There are easy ways to do this like PyOpenGL or PyGame, but taking the direction behind Brian's VRML viewer and extending it for the latest trends like AJAX (which I assumed could be used to establish a bidirectional channel) has a lot more advantages. It is in my best interest to educate myself about the latest web development techniques like AJAX and the end goal of having an X3D based browser client is an interesting project in and of itself.

The first step was to learn what AJAX was and to get it working with a web server. I encountered Pyjamas which looked promising, but the problem was that it had been a long time since I last did Javascript programming and given that it replaces that with Python, it looked like it would get in the way of the learning process. Next were the various Javascript frameworks and as interesting as they looked, it also looked like I needed to learn Javascript before I could benefit from what they offered. In fact it looked like the approach I needed to take in order to achieve what I wanted and to ensure I understood how it all worked from the ground up was to build it from the ground up.

Interestingly the people behind my X3D plugin of choice (Flux Player) have started Ajax3D.org in order to forward the use of AJAX with X3D. Although the examples it provides are just simple client based AJAX and none go to the extent of establishing bidirectional communication.

Anyway AJAX led to JSON and I ended up using BaseHTTPServer with simplejson on the server side and JSON in Javascript on the client side with Flux Player embedded. And this is the point I am at now, learning X3D and how to use it, especially controlled by browser based Javascript. One setback however, is the fact that Flux Player seems crash prone. When you combine that with Firefox's saving of tabs, what you get is a browser which
continually crashes every time it restarts unless you are willing to throw away whatever else is in your other tabs. In theory Flux Player is open source but it looks like releases of the latest source code have trailed off years ago, so debugging this myself is out of the question. Oh well, will see how it goes.