• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Lucky808

Isometric tilemap rendering

7 posts in this topic

Hi all,

 

Has anyone read the book "Learning IOS Game Programming"? I'm current using the rendering method (for Orthogonal maps) taught in the book in my new game. I've successfully converted some of the code to work with Isometric tilemap. However, I hit a road block when it comes to rendering objects on the map in the right order. I'm using 3 map layers. (1.ground, 2.grass, 3.wall and trees). I render the first 2 layers, then the player object, then the 3rd layer. However I could not get it to render objects in correct orders. i.e. a player standing in front of a tree should show up as such, meaning the tree should be rendered 1st then the player.

I've implemented a depth buffer and set up the following:

 

 

        glOrthof(0.0f, rect.size.width, 0.0f, rect.size.height, 0.0f, 100.0f);

 

 

        glEnable(GL_DEPTH_TEST);

        glDepthMask(GL_TRUE);

        glDepthFunc(GL_LEQUAL);

        glDepthRangef(0.0f, 1.0f);

 

        glClearDepthf(1.0f);

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 

But objects are still not being rendered in the correct order. If someone who is familiar with the rendering method in that book can you please point me to the right direction.

Any input will be appreciated!

 

Thanks in advance.

 

0

Share this post


Link to post
Share on other sites

glOrtho() takes six parameters: left clipping plane, right clipping plane, a top one and a bottom one, and values of "near" and "far", respectively. What do the last two values mean? Other than being clipping planes, too (making the viewport of glOrtho() look like a cube in which you look into from one side), they are essential for making the depth buffer work. The depth buffer stores the values not in the linear sense, but we can roughly say that they are inversed (as in 1/depth), so the precision is lost only far away from camera where we don't see it. However, this is only "roughly" - the actual equation is much more precise and depends greatly on relationship of "near" and "far" values.

 

Your problem is that near is 0 in your case, that means that the relationship of "near" and "far" is zero division; that means you lose all of your depth buffer precision.

The solution? Set near (the second-last parameter to glOrtho()) to 1.0. It is maybe not the only cause of your depth buffer problem, but it is certainly one of them.

Edited by ifthen
0

Share this post


Link to post
Share on other sites

Thanks for the tips. however as soon as I adjust the second last parameter to 1.0,  the screen becomes blank. i don't see anything being rendered.

0

Share this post


Link to post
Share on other sites

Well... you could be rendering your objects with the Z axis set to zero (if you are rendering "fake 3D" orthogonal tilemaps and not true 3D ones). Make sure that you translate them properly to the screen. If you are using the old fixed-pipeline OpenGL, you can simply translate the object like this

//in the drawing routine
void drawSomeObject()
{
int Z = 5; // from 1 up, if you want to use 1 too, lower "near" to 0.5 or something so the object is not clipped due to floating errors
glTranslate(0,0,Z);
//draw it somehow, e.g. using glBegin()/glEnd()
glTranslate(0,0,-Z);
}

 

The objects with higher Z value (i.e. farther from you) will be obscured by the objects with lower Z value if you do this.

0

Share this post


Link to post
Share on other sites

Yes, the objects were loaded without z-axis values. do they need z values for rendering in an isometric tilemap?

also, i tried implementing glTranslatef() into my rendering routine but made no difference. the moment i changed the 2nd last parameter to 1 in glOrtho() the screen went blank again :(

0

Share this post


Link to post
Share on other sites
If you're wanting to render using the depth buffer to do layering for you, you should ideally be actually placing your scene contents in real 3D space. At the very least, you need to have different Z values for objects at different depths, or else the depth buffer is doing nothing at all. If you want to manually composite the depth of the scene using old-school 2D-esque sorting techniques, then disable the depth buffer, set the Z bounds to -1,+1 (you're currently using 0.0f,100.0f), and go wild with objects at Z=0. There are places for mixing the two, but most of them are in the realm of scene composition effects like distortion, full-screen shaders, etc.
0

Share this post


Link to post
Share on other sites

Ok, think I will go with placing my scene in a 3D space. In that case, how do I set up the z value for each tile on an Isometric tilemap. x and y position are determined by their index from an 2D array.(X increases towards southeast, Y increases towards northeast) something like:

 

 

        vertex1.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);

              vertex1.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);

              vertex2.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);

              vertex2.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);

              vertex3.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);

              vertex3.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);

              vertex4.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);

              vertex4.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);

 

what should I put in for z?
0

Share this post


Link to post
Share on other sites

Your problem is that near is 0 in your case, that means that the relationship of "near" and "far" is zero division; that means you lose all of your depth buffer precision.

This is true for perspective projection because that's achieved by dividing the coordinates by the depth. Orthographic projection doesn't have this issue and the depth buffer in fact is linear in that case.

0

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  
Followers 0