Hi all! So we're converting out isometric engine to use proper orthographic projection, as well as turning walls and floors into actual poly's instead of iso tiles. The problem I have is now I'm using an isometric viewport in the projection / view, and since we still do have 2D sprites that we wish to place in the scene as billboard 1 to 1 unscaled images, I'm finding it impossible to figure out how to translate this or even if it's possible to do at all.
Here is the ortho / lookat:
Code :glMatrixMode(GL11.GL_PROJECTION); glLoadIdentity(); float scale = 80.0f; glOrtho(-w/scale, w/scale, h/scale, -h/scale, 0.000001f, 1000); glMatrixMode(GL11.GL_MODELVIEW); glLoadIdentity(); gluLookAt(30.0f, 30.0f, 25.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f);
This works great, and allows us to easily plop down walls and floors in iso perspective. It also matches the angle and proportions of the old fake iso tiles perfectly.
However, since we have a whole ton of sprites for stuff like refrigerators and tables etc that are not polys but drawn in matching fake iso perspective and thus need to be drawn as camera facing at 1 to 1, and also since we'll still be drawing characters in 2D, I can't for the life of me figure out how to draw the sprites at a guaranteed 1 to 1, without of course resetting all the matrices to screen space (which would defeat the point, since a big factor in doing this was to completely get rid of all the manual java iso -> screen conversions and use the zbuffer to allow us to batch and texture sort everything, instead of the strict painfully slow and inefficient iso draw order we've had to abide by in the past )
Take this for example:
*CAN'T POST AN IMAGE? *
(a 52 x 80 refrigerator texture drawn by the artist in isometric perspective)
In the olden days I would just (-width / 2) and -height it to centre bottom align it it in the world (well, more specifically, to align it to the centre of the iso diamond that can be assumed to be at the bottom of the sprite), and of course drawing it 1 to 1 was trivial, but this is no longer possible since I'm on a completely different coordinate system. All I want to do is be able to generate a rectangle within the coordinate system, bottom centre at the exact x, y, z coordinates I pass, to draw this at perfect 1 to 1 in the correct place on a tile given an x, y, z coordinate of that tile, without having to completely switch to flat 2D perspective and therefore have to calculate its position in the world manually in relation to the camera etc.
So I tried to manually make some kinda billboard poly that extends across the diag of an iso tile, scaled to match the texture's size if it was drawn directly with a standard pixel aligned 2d orthographic viewport, but I have absolutely no context to work out the width and height of it exactly. I've sat here for about 3 hours messing with it and my head is going to explode, so if anyone can point me at the answer I would much appreciate it. Perhaps it's obvious but I'm seeing red so not sure I can see the wood for the trees. (I suck at 3D math )
Code :float someWidth = XXXX; float someHeight = XXXX; float half = someWidth / 2.0f; render(tex, x-half, y+half, z, x-half, y+half, z-someHeight, x+half, y-half, z-someHeight, x+half, y-half, z);
The fact that these sprites could be different sizes on the texture pages means I can't even magic number it and just make an end of it, I've thought I'd cracked it about 10 times so far but then I switch to another sprite and it goes haywire, and whatever I do they are never 1 to 1 which at this resolution of sprite is ugly beyond words. At this point I'm half prepared to live with blurry sprites if they would at the very least be proportionally correct and equivalent sizes to each other.
Any help would be greatly appreciated!