Getting the screen co-ordinates of a projected model

Here’s an annotated image to describe what I’m after…

The bounding box of the model is …
(-0.7019637823, -0.6984329224, -0.5315929055)
(0.7019637227, 0.698432982, 0.5315929055)

When projected in orthogonal with camera at (1, -2, 1) the points A + B are (919, 5583) and (4534, 8140) respectively and the angle of the diagonal is 35.15 degrees (I want to make it 45 degrees)

What I’m after is some function that given the following TVector3 returns the value indicated

[A] : (-0.7019637823, -0.6984329224, -0.5315929055) = (919, 5583)
[B] : (-0.7019637823, -0.6984329224, 0.5315929055) = (4534, 8140)

Adjusting the origin is easy so ignore that bit, the 2D co-ordinates are from a paint program

Armed with these two numbers it becomes a very simple matter to resize the image forcing the angles to 45 degrees simply by calculating the slope like this

dx(AB) = 4534 - 919 = 3615
dy(AB) = 8140 - 5583 = 2557

dy/dx = 2557 / 3615 = 0.70733056708

New image width = original image width * dy/dy = c, 5794

Giving me a perfect Miitary projection

The diagonals are now guaranteed to be 45 degrees. This post-processing works for any model of any shape and the resulting images are perfect for that Ultima7 look and feel

1 Like