Grass, trees etc. areas

Loockas

18-02-2007 14:39:14

Hi, I'd like to know how to make areas on the terrain that would have static geometry like grass, trees etc. Simply when I use texture splatting and I have a road texture on my terrain I don't want to have any grass or trees on it. BTW static geometry would be generating randomly like the forest addon in CVS. Should I use an alpha map to draw the areas or should I check a material on the place where I want to or don't have a grass? I searched forums but I didn't find anything about it... :(

Grom

18-02-2007 20:34:57

for each tile, get the vertex data, and place your objects based on the height of the terrain. I use a class that starts like:

class myPLSMManager
{
public:
myPLSMManager()
{
PagingLandscapeDelegate *loadTileDelegate=new PagingLandscapeDelegate();
loadTileDelegate->bind(this,&myPLSMManager::tileLoaded);
sceneMgr->setOption("addLoadTileListener",loadTileDelegate);


Then I have a function like

void tileLoaded(PagingLandscapeEvent* event)
{
int pageX=event->mPagex;
int pageZ=event->mPagez;
int tileX=event->mTilex;
int tileZ=event->mTilez;


Then, to get the vertex data of the tile, i do this:

std::vector<void*> params;
int renderLevel=0;
params.push_back(&pageX);
params.push_back(&pageZ);
params.push_back(&tileX);
params.push_back(&tileZ);
params.push_back(&renderLevel);
sceneMgr->getOption("PageGetTileVertexData_2",&params);

int* numVtx=((int*)params[5]);
Vector3* vertices=((Vector3*)params[6]);
IndexData* indexData=((IndexData*)params[7]);


there you have the vertex data in Row Major order. So you place the objects you want on the heightfield, and I would use instancing. You also create your own Unload function, to page in/out the objects per tile/page. You load/unload your objects based on either tileload/unload, or pageload/unload.

uzik

25-02-2007 14:01:32

I was trying to figure out the best way of managing objects.
I was thinking of adding an octree scenemanager and using
it to decide what gets loaded from disk. Does that sound
workable?

Grom

25-02-2007 18:54:36

i think it would be more appropriate to write a simple database that operates per page

uzik

25-02-2007 21:02:29

I considered that. I've used Sqlite extensively and done some simple
hash key stuff. I thought for something that needs to find and
load a lot of scenery between retrace intervals you'd want the most
blisteringly fast thing you could create. Hence the idea of using
the octree to identify the stuff to load.

Grom

25-02-2007 21:45:36

right but an octree decides what to cull, it doesn't do file loading. When I say write a simple database I mean basically a binary file that you read/write to/from with fstream methods.

uzik

25-02-2007 22:04:18

I thought you could hook into the scene manager events, getting
called when you needed to load the meshes attached to the terrain
for the currently visible area. Thus the scene manager culling prevents
having to load everything in the page, even if it's not visible.

I'm planning on cramming a LOT of features into this project,
so I'm shaving off clock cycles wherever I can get them.

Grom

25-02-2007 22:39:41

ah, clever