S
S
s2sk2018-02-22 02:18:02
Mathematics
s2sk, 2018-02-22 02:18:02

How to convert 3D to 2D?

Hello.
I have the coordinates of an object in the game, imagine A(x, y, z);
There are coordinates where the player is B(x, y, z);
There are coordinates where the player is looking C(x, y, z);
Based on this data, I need to get a point on the 2D monitor where the object is located, i.e. convert all these 3D coordinates to 2D. How can I do that? Screen size if anything static, 640x480

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Sivakov, 2018-02-22
@yar3333

If artisanal, then you need to move and rotate the whole world so that the plane of the player's eye coincides with the plane of the monitor (ie, with the origin in the center of the monitor). Then use the simple formula for converting from parallel to perspective projection:
X_on_monitor = X_of_3D / Z_of_3D
Y_on_monitor = Y_of_3D / Z_of_3D
This is what I did 15 years ago, when I didn’t have the Internet and books :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question