Projects

WebGL Demos
PHP Data Pivot
PHP Data Subtotals
HTML5 Graph
Java NW3D2
JS Code Formatter
HTML5 Clock
Silverlight Gauge
Java NW3D
Java Fireworks
Java Early 3D
Java Snow
Java Dogfight
Java Water Simulation
Java Bump Mapping
Java Elite Ships
 

       


Your first time?

If you're visiting this site before visiting my original Elite site then I suggest you head on over there {link removed} and read the about page on that site first. The original site explains my fascination with Elite and some technical discussion about the approach I took with the site, whereas this page attempts to explain why I did it all over again!

No, then read on....

During the construction of the first site I realised that the target audience, i.e. like-minded Elite fans, would be limited to those with the necessary PC configuration. And quite a restrictive configuration it was too: Windows PC running IE4 or greater and DirectX 6 or greater. I pressed on anyway but thought it would be great if one day I could present the same animations to users of non-Windows non-IE platforms with no special API/plug-in requirements. When I started giving this idea more serious thought during June'01 I had the following self-imposed requirements:-

  • Must download and begin rendering as quickly as the ActiveX version.

  • Mustn't use non-standard API's or plug-ins such as Java 3D.

  • Must be capable of rendering a 300x300 pixel image at 10 frames per second.

  • The animation must be interactive with the web page, i.e. able to react to mouse movement and JavaScript method calls.

I decided to write the rendering code myself and set out to learn the Java language, beginning of course with the obligatory 'hello world' application. About a week later I had a spinning cube rendering at 30fps+ with mouse interaction to control the rate of rotation. A couple of days later and I'd added double buffering and a directional light source which produced elementary lighting/shading. Life was good. Happy that I'd gotten the basics right, I hand-coded the vertices for a Cobra Mk. 3 into my code to replace the cube. Initially I thought all was well but quickly realised that the engine ports and side thrusters weren't being drawn in the correct sequence. Until now I'd used a crude z-order sort to determine the face drawing sequence and 'drawPolygon' method to render each face. I looked at variations of the basic z-order as well as various hidden surface removal algorithms.

Some of you will by now be shouting "z-Buffer" at your screen, and you'll be relieved to know that's exactly what I did. For those not familiar with this term, suffice to say it's a means of ensuring the correct drawing sequence by rendering the object pixel at a time, each time checking that a pixel with a lower z co-ordinate, i.e. closer, hasn't already been drawn. There are some disadvantages to this approach, namely performance and the need to write lower level code. However, the advantage of ensuring the correct drawing sequence and making it possible to draw complex objects with intersecting surfaces more than makes up for this.  Once finished it would also be fairly straightforward to add Gouraud shading, something that wouldn't have been possible using 'drawPolygon'.

I'm planning to publish elsewhere on my web site a full description of the Java code produced for this project and the learning curve experienced along the way. As ever, if you'd like to comment or offer any tips for improvement contact me at neil@neilwallis.com.