Skip to main content
gamedev.net
🔒 Locked

map structure

Started by staticVoid2 1 reply 750+ views
Original Post
staticVoid2
staticVoid2
does anyone know how a 3d map is generally stored in object orientated code, what classes would be needed etc. I have a model class and was wondering if a map would simply be an array of models or even just one big model itself. If it is a model, or an array of models - do you convert each models vertices into world space before passing them to the renderer or would you be better passing the models object matrix along with its object space vertices to the renderer.? if anyone knows any good articles, or other posts about this subject, please post a link. thanx for any help.
ToohrVyk
ToohrVyk
I would probably give the "Map Aspect" object the following responsibilities:

  • Load and save its internal data to and from a binary stream. This data and the corresponding loading should be standalone—that is, it shouldn't rely on any other functionality, such as loading meshes or loading textures, since this is already being done by other subsystems.
  • Permanently attach itself to a renderer and configure that renderer—telling the renderer that certain meshes are required in certain positions with certain textures (the renderer then loads the meshes and textures) along with culling and LOD information not already present in the meshes.
  • Allow editing of its internal mesh and texture data using ad hoc accessors. This should keep the renderer updated with the changes.
  • Optimize itself for faster rendering, upon request (this task may take a short while, perhaps even require a side-thread to perform while the renderer keeps churning out frames using the unoptimized map).
  • Unregister itself from the renderer and removing anything that has been added or modified there.


The actual internal representation of the map would probably include:
  • A vector of texture names (with vector indices used to refer to textures) that can be used by the renderer to load and use the requested texture.
  • A vector of mesh names (with mesh indices used to refer to meshes) that can be used by the renderer to load and use the requested mesh.
  • A vector of light templates that can be used by the renderer to apply dynamic lights, possibly bake the illumination into nearby static polygons for improved performance, and cast dynamic shadows.
  • Some sort of visibility reduction scheme, such as portals-and-sectors.
  • A list of light and mesh positions and orientations in the world as part of the visibility scheme, with mesh-texture bindings.
OldProgie2
OldProgie2
There is no one general solution.

It varies, depending on thinks like how your renderer works, what sort of map you want to represent and where your source data is coming from.

For example, for a war game, you may use a height map for the terrain, with objects placed at certain locations. The model structure for a Doom type map would be completely different.

I think you need to thing about what you need for your maps before deciding how to implement it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.