Hello Guest

orthographic isometric with 2D billboard sprites drawn on tiles.

  • 1 Replies
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 1x1 scaled images, I'm finding it impossible to figure out how to translate this.

Here is the ortho / lookat:

float scale = 80.0f;
GL11.glOrtho(-w/scale, w/scale, h/scale, -h/scale, 0.000001f, 1000);
GLU.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.

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:

a 52 x 83 section of a texture. 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, 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 and practically wanting to smash my monitor at this point so not sure I can see the wood for the trees. (I suck at 3D math :( )

Code: [Select]
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.

Any help would be greatly appreciated!


« Last Edit: September 21, 2013, 00:25:31 by lemmy101 »

Re: orthographic isometric with 2D billboard sprites drawn on tiles.
« Reply #1 on: September 23, 2013, 13:54:13 »
I'm probably missing something, but it looks like you just creating a skewed 2D view so you should be able to get a 1-to-1 by taking your sprite and changing the width/height by the amount you're scaling (i.e. multiply width by (w * 2 / scale) and height by (h * 2 / scale)).

P.S. My math is also terrible, so don't be suprised if this doesn't work.  :P
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D