1
\$\begingroup\$

I have this isometric map and im using IsometricTiledMapRenderer to render the map I have a OrthographicCamera. I know where each tile is in the isometric map, but the isometric map is kinda rotated?

So I was wondering how to convert Map Coordinates to Isometric and viceversa?

Here I tried to draw a color cube in each tile coordinates.... enter image description here


Thanks in advance, I have been struggling with this for 2 days, and my lack english vocabulary isnt helping with the research, please some one point me to something

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Looking at the source code for the Isometric renderer I found this piece of code (slightly edited):

private void init () {

    // create the isometric transform
    isoTransform = new Matrix4();

    isoTransform.idt();


    // isoTransform.translate(0, 32, 0);

    isoTransform.scale((float)(Math.sqrt(2.0) / 2.0), (float)(Math.sqrt(2.0) / 4.0), 1.0f);

    isoTransform.rotate(0.0f, 0.0f, 1.0f, -45);


    // ... and the inverse matrix
    isoTransform.inv();

}


private Vector3 translateScreenToIso (Vector2 vec) {

    Vector3 screenPos = new Vector3(vec.x, vec.y, 0);

    screenPos.mul(isoTransform);


    return screenPos;

}

Try using this to convert your screen coordinates to Isometric coordinates.

\$\endgroup\$
2
  • \$\begingroup\$ I tried this Yesterday with no luck :/ thanks for your reply! \$\endgroup\$
    – centenond
    May 2, 2017 at 23:24
  • \$\begingroup\$ Actually I tried this again and it just worked, thanks man really thanks alot \$\endgroup\$
    – centenond
    May 3, 2017 at 0:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .