## How to represent 3d objects in 2d

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### How to represent 3d objects in 2d

So I came across a few pico-8 projects that actually display 3d models and I thought, I want to know how to do that.

First of all which types of 3d techniques are there? No matter which type do they all have to use 3d to 2d projection in order to draw the stuff on the screen? Or is there also "real 3d" that stays 3d? Can somebody explain to me the main types?

My solution would be something like: 3d stuff is handled by the machine and then converted to 2d to draw in on the screen.

Of course I would start with something very simple. A cube or a pyramid with a fixed camera or stuff like that. So I would convert the 5 points in the 3d space to a 2d space and then connect them by a triangle drawing function and the bottom points through a square drawing function.

I've searched the web but didn't really find something valuable.

ZodaInk
Prole
Posts: 18
Joined: Thu Jan 08, 2015 5:18 am

### Re: How to represent 3d objects in 2d

https://www.youtube.com/watch?v=Kdyviza ... bUghwO1RQo

Here are a few videos of basic 3d modelling.
3d engines are not easy, if you're new to programming I would suggest something easier.

There is also LÖVE3D: viewtopic.php?f=5&t=78943

adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### Re: How to represent 3d objects in 2d

I'm pretty used to math it wouldn't be the problem. I know how to use vectors matrices etc. I know how 3d to 2d projection works I just don't know what techniques are used which are the most performant ones and stuff like that.

I really would start off with just a small pyramid in the center of the screen which you could then rotate with the direction keys around x,y and z axis. And I'm not really new to programming anyways .

Does this even make sense in Love2D? I would say yes because you can draw lines and simple shapes which would be all you need to represent simple geometric objects in a 2D space. So my question is, why would anyone need access to something complicated like OpenGL if you just need to create code to convert points from a 3D space to a 2D space. I think this can surely be done with Love and Lua. At least for simple objects. But when do you need something more down to the hardware?

Thanks for the link. Its a good start.

Davidobot
Party member
Posts: 1148
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

### Re: How to represent 3d objects in 2d

Here is an old abandoned not finished project of mine - Lovecraft.
Use the mouse to look around and the standard FPS controls to navigate (Q and E to ascend/descend). You can also press the ~/` button to bring up the debug menu. Also, you can press tab to release the mouse.
Feel free to look around the code. You can turn textures on/off as well as edges and faces in code/misc.lua in lines 23-27.
This should give you an idea how to do 3D.
Attachments
LoveCraft.love
(17.13 KiB) Downloaded 179 times
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### Re: How to represent 3d objects in 2d

Thank you very much! This will really get me started. Works very well!

Davidobot
Party member
Posts: 1148
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

### Re: How to represent 3d objects in 2d

adge wrote:Thank you very much! This will really get me started. Works very well!
Glad I could help. I would love to see what you could make of it.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### Re: How to represent 3d objects in 2d

Probably not much at first. Will take me some time to get into it. I will upload it if I managed to create some "interesting artful" stuff

adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### Re: How to represent 3d objects in 2d

If anybody is interested, this is what I came up with for now:

viewtopic.php?f=5&t=82207

Its just simple 3d to 2d projection. There is now camera view or stuff like that. I still need to implement that. I want the view to be adjustable and the object to be rotatable on its own not affecting the camera view. I took a look at LoveCraft but seemed a bit too overwhelming at first. Have to dig more into it.

Davidobot
Party member
Posts: 1148
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

### Re: How to represent 3d objects in 2d

adge wrote:..
Dude, I'm like always on the forum, so if you have any questions, don't be shy and ask.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

### Re: How to represent 3d objects in 2d

Ok so I got 3D to 2D projection and some basic rotations. Translation isn't that hard at all. Just add a number to the direction you want to move the object to all vertices.
Should I maybe use matrices? Are they faster? Add lighting. That would be cool. But that exceeds my knowledge. I would use normals for every face and the more the normal and the lightning vector are facing each other the brighter the face will be drawn.
How are faces done? Just draw a polygon or rectangle with the nodes positions?

### Who is online

Users browsing this forum: damv and 4 guests