4
\$\begingroup\$

What values correspond to a 3D vector for screen-normal from within an isometric game?

It needs to be in game coordinates. It is a standard isometric where tiles are rotated 45 degrees and half height (in 2D projection).

http://community.roll20.net/uploads//FileUpload/07/6d89bcd782b67e3646835d5fb4bc23.png

For example [+x,0] in game corresponds to north-east on screen. But what is the vector leading out of the screen. This vector is always the same (a fixed orthographic projection).

\$\endgroup\$
  • 1
    \$\begingroup\$ Ideally the vector would be represented the same way, since the world coordinates are not isometric, only the visual representation of the world is. \$\endgroup\$ – MichaelHouse Sep 9 '13 at 22:15
  • \$\begingroup\$ Yeah, but same as what. I know I need to rotate to rotate it 45° to left (starting from heading north [0, -y] in iso coordinates). This way it will head up (in screen coordinates). Then I need to somehow rotate it towards me (out of the screen). That's when I got lost. \$\endgroup\$ – SmartK8 Sep 9 '13 at 22:20
  • \$\begingroup\$ I mean they would be represented without rotation. There are considerably less headaches when making an isometric game if the coordinates system for the game world is a standard 2D (or 3D) cartesian coordinates system. The isometric property just comes from the visual representation. \$\endgroup\$ – MichaelHouse Sep 9 '13 at 22:28
  • \$\begingroup\$ My conversion algorithms work well, but this is not a conversion (at least I think so). I need vector in iso coordinates that leads outside the monitor (is normal to a monitor screen). \$\endgroup\$ – SmartK8 Sep 9 '13 at 22:32
  • \$\begingroup\$ If you have two (linearly independent) vectors and require one orthogonal to both of them, simply calculate the cross- or vector-product of the original two vectors. Then normalize. \$\endgroup\$ – Pieter Geerkens Sep 9 '13 at 22:39
6
\$\begingroup\$

I need vector in iso coordinates that leads outside the monitor (is normal to a monitor screen).

It's two rotations. Your tiles are half as high as they are wide. Projection/dot product is proportional to cosine, and arccosine(1/2) == 60 degrees, which means that's your first rotation. It is followed by a 45-degree rotation.

You start with unit-z, 0, 0, 1
The first 60 degree rotation (about the x-axis) yields (0, -ROOT(3)/2, 0.5)
The next 45 degree rotation (about the z-axis) yields -ROOT(2)*ROOT(3)/4, -ROOT(2)*ROOT(3)/4, 0.5)

Invert it, and it's your camera's direction.

Vector3 camera_forward = (0.612375, 0.612375, -0.50000);

(I assumed that up-left was position Y, and up-right was positive X)

\$\endgroup\$
0
\$\begingroup\$

Maybe I'm missing something right now (bare with me; it's late in the night).

Essentially you'll just need two tiny steps here to get from world space to screen space (i.e. from world coordinates to screen coordinates):

  • Rotate your coordinates by 45° (rotation axis pointing out of the screen).
  • Divide the new y coordinate by 2.

For the other way (from screen coordinates to world coordinates) you just reverse this:

  • Multiply the y coordinate by 2.
  • Rotate your coordinates by -45°.

Remember that you're doing isometric projection, not perspective projection (so you don't have to fiddle with real rotation along the x axis).

\$\endgroup\$
  • \$\begingroup\$ But I don't need conversion. I need what vector in iso coordinates corresponds to a vector out of the screen. I as I've said in iso coordinates (for example) is [0, -1, 0] north, but what is the vector leading out of the screen. \$\endgroup\$ – SmartK8 Sep 9 '13 at 22:30
  • \$\begingroup\$ What exactly are you trying to achieve? \$\endgroup\$ – Mario Sep 9 '13 at 22:33
  • \$\begingroup\$ Exactly what I've said, there's no way around it. I really don't how to explain it better. Imagine a vector leading from this isometric "ground" to screen, it would be a point from every place on that ground. But what is the vector from the ground to a screen in iso coordinates (it is 3D vector). \$\endgroup\$ – SmartK8 Sep 9 '13 at 22:35
  • \$\begingroup\$ I understood that part, but why do you need it? Do you want to do raycasting for mouse interaction? \$\endgroup\$ – Mario Sep 9 '13 at 22:36
  • \$\begingroup\$ I need it for light calculation, I don't know how is it relevant? \$\endgroup\$ – SmartK8 Sep 9 '13 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.