I have an logic level/map representation for a 3D game that uses vector<Area>
where:
class Area{
vector<Point2D> bounding; //determines the shape of the Area, its borders
//bounding of Area is like borders of country
//(it's easy to test if something is inside area)
vector<Obstacle> obstacles; //general type for all static objects inside this Area
//each Obstacle has boundingBox (center, halfSize, rotation)
vector<Dynamic> dynamicObjects; //same as obstacles, but the use of separated vector
//for dynamic objects helps with few things
Player * player = 0; //like Obstacle, but it has special treatment
vector<Area*> connectedAreas; //I won't went deeper into how Areas are connected.
//For simplify, let's assume we are working on one Area.
//Or that when Player leaves Area, all connectedAreas start a test if he entered
//one of them (it's not the case, but work fine for purposes of that example).
...
};
It's quite simple and very low memory-consuming representation for large areas (grid representation would grow and grow with the size of area). I also find it quite good when it comes to some AI algorithms that my game uses. I don't have too advanced collisions in my game (so I don't need to care about them in the level representation). So generally, I'm happy with that representation.
Still, I have one problem: sometimes some parts of the map have "height-levels" - e.g. bridge: you can be either under the bridge or above it (and you can go above only from certain fragments of map). How can I represent that?
For caves or multi-floor buildings I can just use vector<Area>
instead of single Area
/Area
's fragment. That vector<Area>
could hold separated Area
for each floor.
But when the mesh has kind of "smooth" transitions between levels (bridges, some parts of mountains and any non-separable fragments of map) - it doesn't looks like good solution anymore.
For example, here player is able to go either under the tree or above the trunk:
P.s. I am not asking for the graphic representation. I've separated the game logic and graphic engine as much as possible. The 3D engine uses triangles of course, with much more details then game logic need or want (less data => faster processing).
geometrical representation
with its pros & cons overgrid-based
one), but it works for me really good in certain types of games/worlds (in many others, different rep.m like sparse grids you mentioned, would be better, I agree). The reason I've posted that question is I want to know if it's possible to bypass the problem I described for structure I've described. If so, it would be useful in more situations. \$\endgroup\$ – PolGraphic Dec 7 '14 at 23:40