Jump to content

  • Log In with Google      Sign In   
  • Create Account


Isometric Staggered - Drawing objects bigger than 1 tile - Depth Error


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
5 replies to this topic

#1 Alex3k   Members   -  Reputation: 115

Like
0Likes
Like

Posted 27 May 2013 - 08:44 AM

Hi Guys,

 

So I am new here, I have often used GameDev.net to find answers to problems I have had previously but never really come to the stage of registering to ask a question... however a bug that I have been stuck on for 18 hour straight has brought here. Apologies if this is in the incorrect section.

 

I am developing an Isometric map for a game that I plan to develop in the near future. I based my implementation on the tutorials found here

 

My issue is the following, when I try to draw objects that require more than one tile (for example a building), it seems as though my depth handling goes out of the window. When I place the building, I set all tiles below it to be unwalkable. This was tested by initially setting those tiles to be another tile to check I have the correct ones (which I do), I then took this further by drawing the building to test if it worked and I noticed that the building was being drawn on top of the player.

 

My tiles are split into three types, base, overlay and height. The base type is used for the ground (grass), the overlay type is used for things such as bushes, water, trees ect, the height type is used for mountains and hills. I set my building to be an overlay type. 

 

Obviously the building needs an "origin" cell. This is the cell that holds the actual overlay texture. 

 

To view images that will help explain the issue more go here.

 

In these images, the origin tile is the highlighted (slighty) red tile.

 

As you can see, in the incorrect image the building is drawn on top of the player. Hence my reasoning for thinking that it is a depth issue.

 

How I have tried to fix so far:

  • Set the depth of the cell to be the same as the origin cell 
  • Draw a transparent cell on top of each cell with the correct depth that tile should have

 

I have searched high and low for someone who has the same issue as this yet no one seems to have it! I have also looked for resources explaining it but with no avail. My only theory on how to solve this is cut the image up into tile images and then place them on the map tile by tile.. however I would rather not do that as it is absurd. 

 

Just to make it clear, my depth handling does work for all other scenarios such as walking behind hills/mountains/trees.

 

Has anyone heard or seen this before? Any help will be greatly appreciated.. I have been working on this bug for a good 18 hours straight now and I am feeling slightly disheartened by it.

 

If you need to see the code, I can send you a copy.

 

Cheers,

 

Alex

 

PS If I have missed something crucial just let me know and I will try and provide the details.

 



Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8337

Like
2Likes
Like

Posted 27 May 2013 - 09:06 AM

These sorts of problems were common in the days before people had access to modern 3D hardware. They occur when you try to fake 3D using 2D overlay techniques. Some configurations are difficult, if not impossible, to represent as simple stacked 2D representations without breaking them up into smaller pieces. However, most people these days tend to use 3D techniques if on a platform that supports them, even if it is only as far as mapping their 2D tiles onto 3D impostor geometry in order to take advantage of the depth buffer for proper drawing. If your tiles have an actual 3D presence that at least roughly conforms to the shape that it could be, it solves a lot of sticky overlap problems. 

 

gamedev.net used to have an Isometric and Tile-based Games sub-forum, but it is now defunct, given that a lot of these older techniques are basically obsolete now. All of the old Isometric posts were folded into the game programming forum. Additionally, some time back I talked more about using a 3D basis here.



#3 Alex3k   Members   -  Reputation: 115

Like
0Likes
Like

Posted 27 May 2013 - 09:10 AM

Aaa I see. So would you recommend branching off into using 3D techniques? Your explanation does bring some closure! I felt like a mad man just sitting in front of my white board going over and over it.



#4 JTippetts   Moderators   -  Reputation: 8337

Like
1Likes
Like

Posted 27 May 2013 - 09:30 AM

I do recommend branching off into using 3D, yes. If you were on a platform where 3D support is extremely limited (some weaker mobiles, perhaps) or non-existent, then it might be okay to continue trying to use the old fashioned 2D techniques. But given that you are using XNA, not using the available 3D stuff would be gimping yourself unnecessarily. In a 3D abstraction, an isometric projection boils down to using an orthographic camera rotated 30 degrees above the horizon (for a 2:1 tile ratio) and 45 degrees around the vertical. That's it. No mouse-maps for picking, no complicated layer stacking, no weird overlap bugs. Project your tile graphics onto appropriately shaped impostor geometry, place them in the map and render. Use standard reverse-projection and geometry-intersection math to perform mouse picking. There has been so much effort and advancement poured into these types of techniques, that the old techniques are completely obsolete by now. In fact, you can usually get significantly better rendering performance by using 3D techniques, given that you can take advantage of things such as batching.

 

Here is a simple scene rendered as an isometric scene mapped with pre-rendered wall and floor textures and rendered again as the underlying geometry with no texturing:

 

sdrElOq.png

 

You can see that the underlying geometry is very basic. It just needs to provide a rough approximation of the geometry it is supposed to represent. When that geometry is rendered, it populates the depth buffer with the information needed so that subsequent objects to be drawn (characters, props, etc...) are correctly clipped against the shape of the geometry. No worrying about sorting. However, you do have to sort any partially-transparent objects (particles, flames, ghosts, etc...) and draw them in a pass after the solid geometry is drawn; that is standard for a forward rendering engine.



#5 Alex3k   Members   -  Reputation: 115

Like
0Likes
Like

Posted 27 May 2013 - 09:40 AM

Okay, this is a great deal of help I really appreciate it! I haven't done any 3D programming before so I will do some research into that first. So from my understanding it is a 3D world but just shown in an isometric view point? 

 

By any chance, do you happen to know of any tutorials that can point me in the correct direction? I will obviously do my own search however it is great to have a starting point.



#6 KnolanCross   Members   -  Reputation: 1271

Like
0Likes
Like

Posted 28 May 2013 - 08:27 AM

Have you taken a look at this one?

 

http://www.gameproducer.net/2011/09/18/illustrated-newbies-guide-to-isometric-game-development/


Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).





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