I was wondering how to make wireframe objects in a 2d environment. I know that it is mostly math but I have no idea where to begin. If anyone could give me any references/sources to examples or explanations of how to learn about it, I would be great full. However I need just the math mostly, not a example or it handed to me for that ruins the fun. Also no viewport frames. (To make this more fun)
Thanks!
I’ve never done anything like this before (other than attempting to draw 3D objects with Love2D), but my guess is you would need to figure out how to represent 3D objects in a 2D space (you can google how to calculate this).
Then, to visualize this with GUIs, you would create a line and adjust the size and rotate it to connect it between each point. For example, if you’re trying to render a wireframe cube, you would calculate the position of each corner of the cube, and then use rotated lines to connect them.
Hope this helps!
EDIT: oof I realized you were asking specifically for the math for this. I’m not that good at math in this case and not aware of any tutorials/references, but hope my visualization technique helps either way.
thebennybox has a brilliant series on software 3D rendering. While it’s definitely overkill for this project, it will help you get an idea of how exactly 3D works.
Here’s a few tips from me:
-
If you have a point in 3D space (x, y, z) that you want to find the screen position for, you can divide x and y by z. (This assumes the middle of the screen is where x = 0 and y = 0)
-
Moving the camera is as simple as moving every single point on screen in the opposite direction e.g. I have a point at (1, 1, 1), and my camera is at (-1, -1, -1), so we move the point to (1-(-1), 1-(-1), 1-(-1)), aka (2, 2, 2)
Hopefully this helps!