Mapping a texture on several squars in a staggered iso map

Started by
0 comments, last by Gandalf 21 years, 9 months ago
Hello! I have stumbled across a problem that is hard to find a solution for... My isometric map has the following coordinate system... (0,6)-(1,6)-(2,6)-(3,6)- ----------------------- -(0,5)-(1,5)-(2,5)-(3,5) ----------------------- (0,4)-(1,4)-(2,4)-(3,4)- ----------------------- -(0,3)-(1,3)-(2,2)-(3,3) ----------------------- (0,2)-(1,2)-(2,2)-(3,2)- ----------------------- -(0,1)-(1,1)-(2,1)-(3,1) ----------------------- (0,0)-(1,0)-(2,0)-(3,0)- ...and I want to map a texture over several quads. So if I stretch my texture over 4 quads starting at square (2,0) it would look somthing like this: Map squars ////////////////////////// ---------(2,6)---------- ----------------------- ------(1,5)-(2,5)------- ----------------------- ---(1,4)-(2,4)-(3,4)---- ----------------------- (0,3)-(1,3)-(2,3)-(3,3)- ----------------------- ---(1,2)-(2,2)-(3,2)---- ----------------------- ------(1,1)-(2,1)------- ----------------------- ---------(2,0)---------- Texture squars ////////////////////////// ---------(5,3)---------- ----------------------- ------(4,3)-(5,2)------- ----------------------- ---(3,3)-(4,2)-(5,1)---- ----------------------- (2,3)-(3,2)-(4,1)-(5,0)- ----------------------- ---(2,2)-(3,1)-(4,0)---- ----------------------- ------(2,1)-(3,0)------- ----------------------- ---------(2,0)---------- I´m looking for a simple formula to convert from isometric map space to ordinary rectangular texture space... or something. For example. How can I find out which texture square I should pick on map suare (3,4)? By looking at the picutre, everyone can see that it´s square (5,1) but how can the the computer calculate that? Thanks, [edited by - Gandalf on July 30, 2002 11:02:56 AM] [edited by - Gandalf on July 30, 2002 11:04:45 AM]
Gandalf the Black
Advertisement
I fixed it. I needed this lookup table:


  POINT texArray[] ={ {0,0}, {1,3}, {2,2}, {3,1}, {1,0}, {2,3}, {3,2}, {0,1}, {1,1}, {2,0}, {3,3}, {0,2}, {2,1}, {3,0}, {0,3}, {1,2}, {2,2}, {3,1}, {0,0}, {1,3}, {3,2}, {0,1}, {1,0}, {2,3}, {3,3}, {0,2}, {1,1}, {2,0}, {0,3}, {1,2}, {2,1}, {3,0}};  


and this calculation:


  int offset = (y%8)*4+(x%4);		txSolid = texArray[offset].x*fTileSizeSolid;tySolid = texArray[offset].y*fTileSizeSolid;  


Thanks anyway,

Gandalf the Black
Gandalf the Black

This topic is closed to new replies.

Advertisement