Skip to main content
GameDev.net gamedev.net
🔒 Locked

3d engine basics

Started by jimjimjim Feb 3, 2006 at 5:45 AM 0 replies 800+ views
Original Post
jimjimjim
jimjimjim
hi i'm building a basic 3d engine in ... wait for it ... Flash! using actionscript 2.0 ... no sniggering at the back please, i'll have you know i cut my programming teeth doing assembler on 16 bit motorola chips way back in the day ;) wireframe engine was a breeze http://www.jellyandicecream.com/temp/world3d.html (note, camera implimentation is very basic) so then i moved on to solid surfaces ... eh things didn't go quite so well i'll spare you all reams of source code and just ask a few basic questions as i suspect some of my understanding is a little awry the main problem was pretty flakey z depth sorting for the polygons i used the simple method of averaging the z of each point in the polygon to get the average depth and then sorted by that (i have seen other methods but i think this is the only one that's realistic given the computational limits of something like flash although i'd be open to suggestions) i have read that this method isn't great 100% of the time, could anybody explain why? i was using very simple shapes similar to the example above in addition, it turned out it wasn't great, eh, quite a lot of the time because i was doing the dev with a simple cube i used surfaces (or polygons) with 4 points ... now i've always understood that 3d models are made up of triangular polygons, could this be my problem? thanks jim
jsgcdude
jsgcdude
Quote:
Original post by jimjimjim
so then i moved on to solid surfaces ... eh things didn't go quite so well

i'll spare you all reams of source code and just ask a few basic questions as i suspect some of my understanding is a little awry

the main problem was pretty flakey z depth sorting for the polygons
i used the simple method of averaging the z of each point in the polygon to get the average depth and then sorted by that

(i have seen other methods but i think this is the only one that's realistic given the computational limits of something like flash although i'd be open to suggestions)

i have read that this method isn't great 100% of the time, could anybody explain why? i was using very simple shapes similar to the example above


Hi jim, nice demo. The reason z-sorting polygons sometimes fails is the fact that the meshes (polyhedra, whatever) have to be convex; ie they have to be like boxes and spheres and not turn in on themselves. Check out this demo I made as a java applet using the java api's fillPolygon() function. Notice how when you spin the tank the barrel disappears when it's pointing away from you. That's because the tank hull polygon is closer than the barrel's polygons.

Hope that helps!
------------------

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.