Posted 26 December 2012 - 11:57 AM
Can anyone please share an example or a link to the information about 2D Game map spritie visibility detection?
I have googled for a while now and only found the way to render 2D tile maps which is easy.
What i am looking for is a basic info on how to Render what is visible in the camera and not render invisible objects.
My project has a map with few big ground textures and a lot of objects placed on top in the Editor. Objects are not snapped to a grid and can be places anywhere in a free-form way (can be stretched, rotated). Basically i am moving around the map, and placing the objects anywhere i want.
What I am looking for is how to detect what sprites are in the viewport and only render them.
Posted 26 December 2012 - 12:08 PM
Otherwise it's a simple matter of checking which sprites intersect with the view rectangle.
Posted 26 December 2012 - 12:24 PM
Yes, i have thought about it. but what if the map is huge and we have like 10.000 sprites, starting from small dirt, stones, grass textures
up to trees, buildings, NPCs ? Then looping through array that huge is not a good idea. That is what i have right now. And In the future,
our maps might have a lot more then 10.000 sprites, as the Artist has a full freedom to load the editor and place any objects anywhere.
It is a top down 2d map and i am looking for a way to detect visible sprites for that and not having to go through a loop of all sprites. Any ideas?
Posted 26 December 2012 - 07:33 PM
to allow for dynamic allocation, I would simply use regions. Divide the world into say a 16 by 16 space and create a class which contains all the sprites in that region
You could make each class cover the visible region. So depending on view direction and position you may only have to check 4 regions
Say you have 10,000 sprites in the map evenly distributed, then each cell would contain about 40 sprites. So at most you will have to check 160
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users