Discuss Scratch

ajjjasas
Scratcher
1 post

3D triangle and wireframe filling help

I have made some 3D games. As of now, I have a raycasting engine and a wireframe one, but I see all of these 3D engines with triangles; they look like wireframe models with the frame filled in by triangles, but I'm not sure how to make one of these or convert a wireframe engine into a filled model.
If you can help, please tell me how to do this.

Here is the engine I made. if you can make it fill the shapes, please tell me here

https://scratch.mit.edu/projects/1243129721/


Last edited by ajjjasas (Nov. 27, 2025 22:09:22)

dspace1015
Scratcher
90 posts

3D triangle and wireframe filling help

If you want to go beyond wireframe, there are a few modifications that you will need to make.

The first isn't actually the triangles themselves, but solving new rendering problems.

When you go to draw your screen, before anything is drawn you must put all of the triangles/lines/points into a list.
Your 3D engine will need to make sure triangles that are behind objects aren't drawn in front of those objects.

To do this you need to do one of two things:

- Sort this list from furthest to closest, and then draw the triangles in order from back to front. To do this you would need to use a Sorting Algorithm.

- Or you could make a Depth buffer that keeps track of the distance of each drawn pixel.

Your choice depends on what technique you wish to use for your 3D engine, with the way yours is going I would recommend using a Sorting Algorithm, because a depth buffer is if you are using textured triangles that are drawn per pixel, vs filling in a triangle in solid color.

The next step is the triangles themselves. You can find many Triangle fillers already made on scratch, which is probably the easiest option, but if you want to try make your own I would look into the math behind a triangle's Incenter.

One more thing I would mention that you have not included in your 3D engine is some form of Frustum Culling. This is just not drawing objects that cannot be seen by the camera, such as objects behind them. You do not want to draw a line or triangle if it is behind the camera because it is not seen and usually will mess up the projection on the screen.

Last edited by dspace1015 (Nov. 28, 2025 01:39:58)

Powered by DjangoBB