This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
natedogith1's profile picture

Changing 3D to 2D

Started by natedogith1, 31 August 2014 - 01:53 AM
natedogith1 #1
Posted 31 August 2014 - 03:53 AM
I figure it's possible, using OpenPeripheral's terminal glasses, and a bunch of their sensors, to highlight people/mobs on the player's HUD. My big issue is I'm not sure how to convert the various pieces of information I can collect into a location on the player's screen.
The pieces of information I think I'll need for this are: 3d (relative) positions (a massive array of sensors), the players rotation(sensors can tell me this), the real screen size (I assume I need this) (sadly the player will have to configure this, just play with the size until changing it doesn't cause any more of the screen to show), and something else (perhaps their fov setting(again player inputed)? not sure)
Bomb Bloke #2
Posted 31 August 2014 - 06:03 AM
One thing I've never been able to wrap my head around properly is this sort of trig. I have to sit down and relearn SIN/COS/TAN/etc every time I wish to apply it.

Let's see - if you take the viewer's co-ords and compare them to the target's co-ords relative to a neutral facing (eg looking directly due north at the horizon), you'll find there's a vertical angle between them, and a horizontal angle between them.

Likewise, if you take the viewer's facing and compare it to that same neutral facing, you'll get another pair of angles.

It'd be a matter of combining one pair of angles with the other pair in order to get the angles of the target relative to the viewer's facing.

You'd then use that pair of angles along with the distance between the viewer/target to calculate where on the viewer's display - relative to the center of their screen - the target should be plotted. Said display should be considered as part of a sphere, which yes, would rely on resolution/FOV settings to define properly.

If it helps, perhaps first think of the problem in terms of just the horizontal plane - entirely ignore which direction the viewer is looking in vertically, and entirely ignore any height differences between the viewer and target. Once you've figured out how to render that, finishing the job should be immediately obvious.
Lignum #3
Posted 31 August 2014 - 06:05 PM
What you're looking for is 3D Projection.
I haven't dealt with it myself, so I can't help you much, but from looking around the web…

x' = x/z
y' = y/z

Where x' and y' are the projected coordinates and x, y and z the 3D coordinates.
ardera #4
Posted 31 August 2014 - 06:29 PM
what about a top view, a "v", ">", "<", "^" symbol for rotation, colors for entity types, and color saturation for y values?