Sign in to follow this  
wondersonic

Tricky texture coordinates for isometric mapping

Recommended Posts

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

Share this post


Link to post
Share on other sites
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:


(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.

Share this post


Link to post
Share on other sites
You could use automatic texture generation. I.e using Object Linear coordinates. And setting the object plane to correspond with your quad orientation.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Well, thank you everybody for your help,
for the code sample, the remark about vertex buffer, the camera rotation and the automatic texture generation...

I'm sure this will be useful to me!

In fact, I've posted in the isometric land thread what I really needed, thanks to you.

WS

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this