I'd like to rework a tile engine I have been working on (for what seems like an eternity) to use resolution independent coordinates for the tiles(i.e., 0-1) instead of pixel coordinates. Doing so is rather easy. However, I want to be able to scale the tile map dynamically with the camera and this leads to an issue. If the tile's mip map level 0 is 256x256 pixels, for example, that is the largest I want the tiles to scale. This means that I need to know exactly how large the tiles are being drawn on screen; information that I will not have. If I want the tile map to initially start with 64x64 pixel tiles, I also need a way to set up the camera so that this happens.
How do I do this? The only thing I can think of is to use gluUnproject (or a hand rolled variant) on a random visible tile to get the screen coordinates and calculate from there, but that seems rather brute force and wont help with camera set up. Is there a more elegant way to go about this?
Show differencesHistory of post edits
#1MarkS
Posted 31 August 2012 - 05:20 AM
I'd like to rework a tile engine I have been working on (for what seems like an eternity) to use resolution independent coordinates for the tiles(i.e., 0-1) instead of pixel coordinates. Doing so is rather easy. However, I want to be able to scale the tile map dynamically with the camera and this leads to an issue. If the tile's mip map level 0 is 256x256 pixels, for example, that is the largest I want the tiles to scale. This means that I need to know exactly how large the tiles are being drawn on screen, information that I will not have. If I want the tile map to initially start with 64x64 pixel tiles, I also need a way to set up the camera so that this happens.
How do I do this? The only thing I can think of is to use gluUnproject (or a hand rolled variant) on a random visible tile to get the screen coordinates and calculate from there, but that seems rather brute force and wont help with camera set up. Is there a more elegant way to go about this?
How do I do this? The only thing I can think of is to use gluUnproject (or a hand rolled variant) on a random visible tile to get the screen coordinates and calculate from there, but that seems rather brute force and wont help with camera set up. Is there a more elegant way to go about this?