Crystal Space
Welcome, Guest. Please login or register.
December 20, 2014, 07:52:01 pm

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9295 Members
Latest Member: Marioibuch
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  Dynamic Heightmap Loading
« previous next »
Pages: [1] Print
Author Topic: Dynamic Heightmap Loading  (Read 2952 times)
Datalurkur
Newbie
*
Posts: 4


View Profile Email
« on: March 22, 2009, 01:27:05 am »

I'm currently working on an isometric strategy game.  The "level" consists of basically two parts - a two-dimensional heightmap, and a two-dimensional character grid.  These two parts correspond directly, each being a two-dimensional array of dimensions AxB.  The heightmap is the basic geometry of the level, while the character grid dictates what type of thing each grid unit is (grass, sand, water, etc).

Now, here's where I'm having trouble: both the heightmap and grid change quite frequently, and tend to be rather large dimensionally (128 x 128 needs to run smoothly).  In my original implementation, I had a different mesh for each grid type, and would create an entity for each node in the grid, like so:

   
for(x=0; x<gameMap.width; x++)
{
   for(y=0; y<gameMap.height; y++)
   {
      char buffer[12];
      sprintf(buffer, "res%.3i%.3i", x, y);

      celentity=pl->CreateEntity(buffer, bl, "level_behave", "pcobject.mesh", CEL_PROPCLASS_END);
      pcmesh=CEL_QUERY_PROPCLASS_ENT(celentity, iPcMesh);
      pcmesh->SetPath("cellib/lev");
      pcmesh->SetMesh("genFloor", "floor");
      if(!pcmesh->GetMesh())
      {
         return ReportError("Error loading mesh...");
      }
      zonemgr->PointMesh(buffer, "main", "Origin");
      pcmesh->MoveMesh((iSector*)(0), csVector3(x, gameMap.heightmap
  • [y], y));
   }
}


This achieves the desired result in that I have a game grid that I can modify on the fly, but framerate leaves quite a bit to be desired.  My suspicion is that there's a much more efficient way to do this with static geometry that gets recompiled whenever a change occurs, but I'm a little stuck as to how to begin that, or if that's even a good idea.

Ideas?  Suggestions?  Links?  Anything helps.
Logged
Vincent
Full Member
***
Posts: 191


View Profile WWW
« Reply #1 on: May 18, 2009, 07:29:58 pm »

One thing which may help a bit is to not create a distinct entity for each tile/node,
but just add a "tagged" pcmesh to the existing one.
Probably you could also save the "character grid" by not using a complete entity
just for "ground type" information, and instead use pcproperties with a "clever"
naming scheme so you can lookup what type of ground some node is made of.
It could perhaps even be skipped if you used eg. some part of the material name for
that, which would be assigned to the tagged pcmesh I mentioned earlier.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.214 seconds with 16 queries.