XNA - Finding boundaries in isometric tilemap
- by Yheeky
I have an issue with my 2D isometric engine. I'm using my own 2D camera class which works with matrices and need to find the tilemaps boundaries so the user always sees the map.
Currently my map size is 100x100 (with 128x128 tiles) so the calculation (e.g. for the right boundary) is:
var maxX = (TileMap.MapWidth + 1) * (TileMap.TileWidth / 2) - ViewSize.X;
var maxX = (100 + 1) * (128 / 2) - 1360; // = 5104 pixels.
This works fine while having scale factor of 1.0f but not for any other zoom factor. When I zoom out to 0.9f the right border should be at approx. 4954.
I´m using the following code for transformation but I always get a wrong value:
var maxXVector = new Vector2(maxX, 0);
var maxXTransformed = Vector2.Transform(maxXVector, tempTransform).X;
The result is 4593.
Does anyone of you have an idea what I´m during wrong?
Thanks for your help!
Yheeky