Tricky texture coordinates for isometric mapping
This thread started in the isometric land forum some days ago:
thread in sometric land forum
What I'm trying to do is to find an *easy* way to:
1/ render my diamond tiles textures on quads
or
2/ transform my diamond tiles into square textures to apply on quads
If someone has an answer for the first proposition, I would really appreciate to talk about it.
Thanks in advance,
WS
Well, if you're texture is stored as a diamond tile, such as you might use for a 'standard' 2D isometric, then you could simply draw your quad as a diamond onscreen, and map the texture to the quad using texture coordinates.
If (OX, OY) is the coordinate location of the 'top' vertex of the diamond, then your quad vertex coords (proceeding counterclockwise from top) would be:
These coords would draw a diamond onscreen (assuming X increases from left to right and Y increases from top to bottom; invert the Y offsets if Y decreases from top to bottom).
Correspondingly, the texture coords to 'snip' out the diamond texture to go with these vertices would be:
This would simply map the diamond-shaped region of the texture onto the diamond-shaped region of your quad-- no need to alpha test or blend to implement transparency of areas outside of the diamond. Just remember to slightly oversize your diamond tile to account for any filtering if artifacts appear.
You could increase speed by pre-calculating the vertices of your map and placing them in a vertex buffer, then drawing tiles from it using indexed quads.
If (OX, OY) is the coordinate location of the 'top' vertex of the diamond, then your quad vertex coords (proceeding counterclockwise from top) would be:
(OX, OY) // Top corner(OX - TextureWidth/2, OY + TextureHeight/2) // Left corner(OX, OY + TextureHeight) // Bottom corner(OX + TextureWidth/2, OY + TextureHeight/2) // Right corner
These coords would draw a diamond onscreen (assuming X increases from left to right and Y increases from top to bottom; invert the Y offsets if Y decreases from top to bottom).
Correspondingly, the texture coords to 'snip' out the diamond texture to go with these vertices would be:
(0.5, 0.0)(0.0, 0.5)(0.5, 1.0)(1.0, 0.5)
This would simply map the diamond-shaped region of the texture onto the diamond-shaped region of your quad-- no need to alpha test or blend to implement transparency of areas outside of the diamond. Just remember to slightly oversize your diamond tile to account for any filtering if artifacts appear.
You could increase speed by pre-calculating the vertices of your map and placing them in a vertex buffer, then drawing tiles from it using indexed quads.
You could use automatic texture generation. I.e using Object Linear coordinates. And setting the object plane to correspond with your quad orientation.
Just render everything as you would render it in a normal 3D mode, but use the Ortho mode, and rotate the camera to the desired angles (45, 70 will do the trick). It's faster than computing the texture coordinates on the fly, and it gives you the bonus that you can rotate the camera, which is very nice.
Is this similar to what you want? (Click to enlarge)
EDIT: Image removed.
You can see the code I used. Simply generating texture coordinates automatically based on the vertices positions relative to some local object coordinate system.
[Edited by - Kuladus on December 4, 2004 12:34:45 AM]
EDIT: Image removed.
You can see the code I used. Simply generating texture coordinates automatically based on the vertices positions relative to some local object coordinate system.
[Edited by - Kuladus on December 4, 2004 12:34:45 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement