Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Banished Knight

Display big isometric objects

This topic is 6009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i''m planning a small isometric engine and have one fundamental problem... Every frame i compose the images (trees, players, rocks etc) for the whole visible screen. But what about the images which overlap in the visible screen ? ---------- | | <- screen | o | x | \|/ | ^ | / \ | | ---------- Here is an large Building which should be seen in the screen. How can I check elegant if an image from beyond the border is being seen in the screen ? Sorry for my bad English and thanks for the help Cya, Olli

Share this post


Link to post
Share on other sites
Advertisement
Each item, like a house excetra, if they are not part of your tilemap, should have a bounding box. Bounding boxes are typically defined by the points at the lower left and upper right of the box. These points should be defined in the same coordinate space as the rest of your map. You then create a rectangle that represents the screen and see if it intersects with any of the item bounding boxes. If it does, then you know the item must be displayed on the screen. You will have to clip the image of the item so that the correct amout of it appears on the screen.

Good luck

Share this post


Link to post
Share on other sites
Let's take an example of how I'd do it. Say my screen is 640x480, and that I'm using tiles 32x32 pixels in size. To draw my map then I'd use some kind of loop to display a grid of 20 tiles across by 15 tiles down (20x15). I draw my objects on top of each tile they may reside in, back to front.

The object tiles may be larger than 32x32 pixels, or offset such that they don't fit within a 32x32 ground tile. What do I do? Well, knowing the largest size of any one of my objects I simply overdraw them...

If I know the largest object I've got is 256x256 pixels, and that it'll be centered over the tile it resides in, then I know that this object can cover up at most the tile it's in plus 4 tiles in every direction around it (3 1/2 tiles actually, but round up). I then adjust my display loop to include 4 extra tiles all the way around.

Pseudo-code example:

int mapx, mapy; // upper left corner of where we are on the map

for (x=-4;x<24;x++)
{
for (y=-4;y<19;y++)
{
drawTerrain(x*32,y*32,mx+x,my+y);
drawObject(x*32,y*32,mx+x,my+y);
}
}

drawTerrain takes a screen coordinate pair (in pixels) and a map coord pair (in tiles) and, if it's within the limits of the map draws the terrain tile on the screen. drawObject does the same thing but for objects. It takes a pair of screen coords and a pair of map coords, and if there're any objects there it draws them to the screen.

Now, if there are big objects just off the screen they will get drawn, and the non-visible part will get clipped and we'll just see what's sticking over into the visible portion of the map.

Any questions?

Care,
Chris
Florida, USA
RTS Engine in Development
http://www.knology.net/~heaven/rts.htm



Edited by - Heaven on February 27, 2002 1:36:09 PM

Edited by - Heaven on February 27, 2002 1:37:02 PM

Share this post


Link to post
Share on other sites
why not add to each tile, a list of objects that cover it?!
by cover it I don''t mean the objects that are on it (that is a different matter), but the objects that by being too tall or flying at a height.
when you know that a tile that is being drawn (not necessarily to display) is covered by an object (maybe it''s base is offscreen) you can add that objcet to a sorted list,
and after you finished drawing all your scene (removing objects from the list that were already drawn), you can draw the objects in the list (clipped) and thats it.

no unnecessary over drawing.
cheers

(: I am what I am, more or less

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!