Example

3D gfx example

8

Jonnywhateva 2019-12-04 11:18

Renders a paper airplane and spins it around on each axis. Drawing is in subs and the model is easy enough to edit, use how you like. The best way I can describe the drawing method is a z buffered ortho projection. It doesn't run at 100% speed right now rendering 6 polygons, might at like 2. Next step will be to combine the 3 rotations into one faster transformation, and also to render the model as a triangle strip, to avoid transforming vertexes multiple times, might be faster.

Test 3d Gfx.nx | Open in app
2019-12-04 11:18

was8bit 2019-12-04 12:13

Very cool :)


Mrlegoboy 2019-12-10 06:09

Well now i feel stupid >:( this seams way better than my triangle drawer


Jonnywhateva 2019-12-12 23:41

Don't feel stupid. A triangle drawer is basically all this is, with some added trig to rotate some 3D points. Never feel stupid about your work, and especially never let it stop you. Just keep programming, even when your program seems like a waste of time. Because the knowledge and experience you gain will mean it was never time wasted.


Roger Davis 2019-12-13 08:26 (Edited)

Wow! Well said Jonnywhateva! Words to code & live by! The truth is that both programs have their merits, and there's plenty for everyone to learn from and use as inspiration for coming up with even better routines. As Jonnywhateva just said Mrlegoboy, - it's not at all a waste of time. : )


Jonnywhateva 2019-12-13 10:30

So I just got around to checking out your triangle drawer with the spaceship that rotates around Mrlegoboy, and i actually found it very impressive, because unlike my program, it runs smoothly lol. When I get a chance I'll have to check out your code and compare. And I saw you mentioned depth buffering. In my example I use a method of depth buffering. It's not great, basically it makes a list referencing all of the triangles and reorganizes them based on the z position of the first point in the triangle. It might work better if instead I used an average of z values for each triangle, but I was worried it would be slower than it already is.


Mrlegoboy 2019-12-14 21:48

Thats not depth buffering. Depth buffering is when you have an array of depth values for each pixel. If you use sorting of the triangles by the average of the 3 points in junction with backface culling, you might get good results, but there seems to be (or at least it hasnt been discovered yet)no perfect way to draw 3d triangles by sorting alone. In theory, if you made an algorithm that checks if the triangle you are currently drawing intersects with any of the previous ones, and clips it in certain areas you could get perfect rendering, but coming up with the algorithm for that would be fantastically complicated.

Either way i think that backface culling combined with per pixel depth buffering is the way to go for now. Maybe we could even get away with only one depth check for every 4 pixels, and sacrifice intersecting edge sharpness for more speed


Mrlegoboy 2019-12-14 21:50

If you wanted to use the average of all 3 of the z values, you could just add them up, you wouldn’t need to divide them by 3 because its relative.


Jonnywhateva 2019-12-14 22:54

Wow, I'll have to do more research into exactly what depth buffering is. I've always wondered how in modern 3d games the polygons don't overlap one another like they would in the ps1 days.


Log in to reply.