Public Group

# converting 3D space to 2D screen

This topic is 4539 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Gday! Im a little stuck right now... In my game engine, the characters move around in 3d space (ie. 3 axes); however, Im using a 2D API (SDL) to draw stuff... so im a little stuck. The idea is to have a camera that either sees a rectangular prism of the 3d space, or is like a real camera where it sees a cone of the world, getting smaller as it gets closer to the lens. The latter would be better, but also seems harder. The problem is that I have very little idea as to how to display the things on the screen (assuming an oblique angle, diagonal-down). Does anyone know of an article that can explain how to do this, or is willing to explain it to me? Thanks!

##### Share on other sites
Quote:
 Original post by SilvoThe idea is to have a camera that either sees a rectangular prism of the 3d space

Orthographic projection.

Quote:
 or is like a real camera where it sees a cone of the world, getting smaller as it gets closer to the lens.

Perspective projection (the whole article is relevant).

Quote:
 The latter would be better, but also seems harder.

The principle is the same, the matrices are different. The perspective projection matrix is a bit harder to compute, but with the formulas, it's still straightforward.

Knowledge of linear algebra helps. If you need more help, we probably have articles lying around on the topic in the reference section.

##### Share on other sites
thanks for those! Im having a look at them now, looks confusing and interesting...

##### Share on other sites
my site has code for exactly what you describe (2d points on a 3d plane) with rotation too.

It's pure SDL, no opengl:
mutedvision.net

click on the donut (toroid) project one.

NOTE: This is my code. Source is free to use and very well commented, however, mention me in a project if you use stuff directly and it helps. I won't claim that this is well programmed, I did it in my first semester of university and have learned a lot in the 3 years since then.

Good luck.

Source is in QBasic or C++ take your pick... Yes, I am a masochist.

##### Share on other sites
Thanks for the link! Im about to have at it now. The wikipedia articles are very confusing and a little beyond me ('little' used loosely). I did find some article in the gamedev reference archive, google search helps when you know what to search for...

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634073
• Total Posts
3015343
×