My engine finally has no more bugs (unless you count speed optimizations) and can show triangles in proper order with normal shading. Here's a picture of my marvelous self-replica rendered by my engine:
The applet is Here. Unfortunately inside the Applet there is only a cube as the above figure is loaded from a text file and an applet can not do that for security reasons.
Now how did I remove the hidden surfaces? Well you simply find the Z-normal of a triangle and see if it's positive or not. If it is, it's facing you, otherwise it isn't. To find the Z-normal use the following formula:
normal = (t.b.x-t.a.x)*(t.a.y-t.c.y)-(t.b.y-t.a.y)*(t.a.x-t.c.x)
Where t is your triangle, a,b, and c are the three vertices and x,y, and z are the vertices coordinates.
I'm not sure where to go next. Until now, bugs have guided me but now there are none left (Yaaaay! o.o). A few options which I can think of are:
- speed optimisations
- Shading with interpolation (smoother shading)
- Add colors and textures (textures are main problem)
- create a very simple game with my current engine
- take a break and do something else
I'll probably do speed optimisations first but as I said, I'm not sure yet.