CS32310 A Simple 3D Renderer

This applet was written during my final year @uni, for the Advanced Graphics Module It got me an A++ :-P
Currently for this applet to work you need the Java 1.3 JRE (Java runtime enviroment) installed. This is available from java.sun.com and is approx. 5mb to download( Java 2 Runtime Environment, Standard Edition, v 1.3.1)

I have now made a 1.1 version for all those ppl without 1.2+ JRE installed, arn't i kind

</COMMENT>

Controls

Mouse1 (Left) - Rotation
Mouse2 (Middle) - Zoom
Mouse3 (Right) - 2D Translation
P - Toggles pause
Escape - Start/Stop Applet

Bugs

1) In *Some* browsers with *Some* graphics cards scrolling of the page will cause corruption of the Applet canvas(IE4 is fine, IE5 causes corruption). Might place the Applet in a seperate page to prevent scrolling, as this bug is unrelated to Java.

Fixed Bugs

1) The Java2D polygon drawing methods did not perform polygon clipping correctly, this caused the paint method to stall (not crash). As a temp. fix faces that fall outside of the view window are not rendered.

2) Repeated running of the Applet no longer causes a crash. When the applets stop() was called, the Thread was told to die, but wasn't dying before the stop() returned. Hence the next instance was created before the currect had died. When the Thread is told to die, it now calls join(), guaranteeing the Thread is dead before stop() returns. (Though join() can still fail with an InterruptedException)

Future Modifications (in no particular order)

1) Add 1.1 and 1.2 version of the Applet - the applet doesn't realy use any nice features of 1.2 or 1.3, so i might go back to 1.1, so everyone can run it. Why don't browsers have built-in support for the newer java versions yet?!??!?!

2) Z-Buffer - Current the program uses a very primitve and inefficient method of calculating rendering order (orders the faces by their perpendicular distance from the view plane). I intend to replace this with a z-buffer when i get around to it.....

3) Dynamic rendering structure - at present objects can only be added at the initialisation stage - I'm going to change this so objects may be created/destroyed at run-time(then I can have a proper interface)

4) Polygon clipping - Javas polygon drawing methods don't seem to implement a polygon clipping mechanism, (If very dodgy values are passed in, [draw/fill]Polygon(..) gets into an infinite loop and doesn't return) im going to have to write my own.... typical.

5) Light Source - the light source at present is just projected then rendered over the top of the scene, even if it is obscured. The Light will be made part of the scene soon.

6) Wire Frames - you might notice the wireframe edges change color depending upon the order in which the faces are rendered. This is a result of the sorting of the faces, I would like to fix this (and implement an optimisation) by adding an edgelist

7) linked with the [6], it would be nice if hidden edges were drawn with a dotted stroke.

8) Add a model definition - so the geometries of objects don't have to be hard coded I am going to write a definition for models, would be nice if I could make it load in lwo or obj files, or somehting like that (but thats alot more work, and not realy necessary)

Update!! (these changes have not been uploaded yet - 'cos they aint quite done ;-)

0) removed some of the typos ;-}

1) still not reverted back to 1.1

2) still not implemented a Z-Buffer

3) Done the Dynamic Rendering structure - along with this i've done a nice (ish) gui interface for selecting objects and adding them to the scene

4) Not even thought about doing a polygon clipping algorithm

5) Implemented the underlying structure for making lights part of the scene (added them to the inheritance heirarchy) but not yet done specific LightSource subclass

6) Yeah, well this is only a minor bug

7) same as above

8) Done a textual object definition along with all the associated loader classes filefilters etc. also created an object library structure for caching object geometry

All together this 'Simple' 3DRenderer is becoming quite complicated :-P