About Store Forum Documentation Contact



Post Reply 
Access mesh data for objects embedded into terrain?
Author Message
fatcoder Offline
Member

Post: #1
Access mesh data for objects embedded into terrain?
I have embedded some static objects into the terrain (such as rocks for example). When I load the terrain in, I want to be able to access the mesh data for the terrain including the embedded objects.

I have some code like this that runs through the active world areas (I'm loading the world using WORLD_FULL and only have 4 areas).

Code:
for(int x=0; x>-2; --x)
   for(int z=0; z>-2; --z)
   {
      Grid<Game::Area> *g = Game::World.areaActive(VecI2(x,z));
      MeshGroup &mg = g->data->data()->mshg();
   }

This lets me access the mesh data for each area so that I can perform some additional processing and terrain analysis. The MeshGroup for each area contains several LOD levels, each with one mesh part for the terrain in that area. There is nothing in there for the meshes of the embedded objects.

I can't access the static objects from the object container, i.e. setObjType(Statics,OBJ_STATIC), because the objects are embedded into the terrain. So they don't load into the object containers. The objects aren't in g->data->objs() either as they are embedded into the terrain.

Where is the mesh data for these objects stored and how do I access it? I don't want to modify them, just read the mesh data.
03-26-2011 06:36 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Access mesh data for objects embedded into terrain?
Game::Area::Data::embedObj
03-26-2011 07:14 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: Access mesh data for objects embedded into terrain?
Great! Not sure how I missed this...
03-27-2011 02:02 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #4
RE: Access mesh data for objects embedded into terrain?
Is it possible to determine what type of object the embedded object is? I can't see any way to do it and EmbedObj doesn't have a type member. If not, is it possible to add "Int type()" to EmbedObj like in Game::Obj? It is essential to know what type of object it is when processing the mesh for generating things like navigation meshes.
03-30-2011 09:44 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Access mesh data for objects embedded into terrain?
no, this is not accessible, all embeded objects are put into one group
03-30-2011 10:50 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: Access mesh data for objects embedded into terrain?
Hmm... that is a bit of a problem. For performance reasons, objects should use Embed into Terrain whenever possible. However, without knowing what the object is (what type it is) at run-time, then you have way too many objects to process when building a navigation mesh. Every small plant in the world gets processed.

There needs to be a way to check what type of embedded object it is so that only large objects like big rocks and buildings are processed. You can then easily skip all other smaller objects like plants (which is about 90% of the embedded objects).

The only way I can do it is to make all objects Constant instead of Embed into Terrain. But then you end up with hundreds of dynamic objects that don't need to be, which is obviously bad for performance.

In the World Editor you know what type the object is when placing it. Can this type be saved as part of EmbedObj (as a UInt) along with the mesh, phys, etc... when building the world?
04-03-2011 05:38 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Access mesh data for objects embedded into terrain?
I wont add this anytime soon
(you can do it manually when having company license - access to programmable world editor)
04-03-2011 04:18 PM
Find all posts by this user Quote this message in a reply
Post Reply