Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Rendering for isometric tilemap based games


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 11 March 2013 - 09:18 PM

Hi,

 

I've been trying to create an isometric tilemap based game and got stuck for several days on sprite rendering. Just want to check with guys if my approach is even viable. Can I render everything in flat 2D quads (using x,y,z-axis) and still be able to use openGL's depth buffer to automatically sort objects based on their z-value? or must I render everything in cubes?

 

So far I've got the isometric maps to render correctly (in glOrthf() projection ). Each tile is rendered using a quad (x,y,z for each vertex).

For each object on map,  I'm using a formula to calculate its z-value: z = -(map_width + map_height )+ (mapX + mapY), z-value is calculated based on the tile the object is sitting on. The player's z-value is updated as he moves around the map.  However, my player sprite and objects are not overlapping correctly. whenever he is standing is front of an object, the top half of the player sprite gets overlapped by the object. on the other hand, when he is behind objects the image is rendered correctly. 

 

What could be the problem? Do I need to render everything in cubes?

 

Thanks for any input!

 

 

 

 

 



Sponsor:

#2 Steve_Segreto   Members   -  Reputation: 885

Like
0Likes
Like

Posted 12 March 2013 - 01:21 AM

I believe that when you use an orthographic projection matrix then z-value becomes linear in the range 0.0 to 1.0f. Your z-value is far greater than 1.0f so all tiles are at same z-level and thus drawing order creates the visual you see.

 

If you want to stay in ortho, you could try sorting the 2-d quads before you render them. This is likely the best choice if you want to have transparency in your tiles.


Edited by Steve_Segreto, 12 March 2013 - 01:49 AM.


#3 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 13 March 2013 - 08:50 PM

i got it to work. it turned out that i had assigned the wrong z-values to tiles. how stupid of me.

thanks for the tips though.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS