[SOLVED?] Hiding a tile

nindim

07-03-2007 21:12:25

I'm having some problems managing to hide a tile. They are just renderables but I really dont know where to start, so much code!

I tried setting the mvisible bool of a paginglandscapetile (by making it public first) but there seems to be more to it than that. Is there an example I should look at in the plugin as to how to effectively hide a tile? Tried loking at the tilehide event but it seem empty....

this is the code I'm trying so far, first time really looking at the plugin code so not too sure whats going on (I used the setoption for PageGetTileVertexData_2 as a starting point):


if (strKey == "myHideTile")
{
/**
* This is the optimized, yet a bit fuzzy implementation of the getVertexDataPatch
* Usage: Pass in a std::vector<void*> Pointer to the getOption call containing at least 5 Elements
* [0](Ogre::unsigned int*) = X Index of the Page to retrieve data from
* [1](Ogre::unsigned int*) = Z Index of the Page to retrieve data from
* [2](Ogre::unsigned int*) = X Index of the Tile within the Page to retrieve data from
* [3](Ogre::unsigned int*) = Z Index of the Tile within the Page to retrieve data from
* [4](Ogre::unsigned int*) = LodLevel to get the data at (note that level 0 means highest detail)
* The getData call will then append 3 entries to the end of the vector. In Detail(in order)
* [End-2](Ogre::unsigned int*) = Number of vertices returned
* [End-1] (Ogre::Vector3*) = The actual vertices, this is a array containing as many elements as returned in [End-2]
* [End] (Ogre::IndexData*) = The index data for the terrain polygons at the queried LodLevel
* @remark note that the caller is in charge of deleting the vector array, vertices array and indice array.
*/
unsigned int requestPageX = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[0]);
unsigned int requestPageZ = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[1]);
unsigned int requestTileX = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[2]);
unsigned int requestTileZ = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[3]);
unsigned int requestLodLevel = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[4]);
PagingLandScapePage* page = mPageManager->getPage(requestPageX,requestPageZ);

if(page)
{
PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
if(tile)
{
PagingLandScapeRenderable* rend = tile->getRenderable();
if(rend)
{
if(tile->mVisible)
{
//printf("CRAP!!!!!!!!!");
//tile->mVisible = false;
AxisAlignedBox crap = tile->getCullWorldBbox();
mListenerManager->fireTileHide(requestPageX, requestPageZ, requestTileX, requestTileZ,crap);
return true;
}
}
}
}
return false;
}


If anyone could point me in the right direction I would be grateful.

nindim

08-03-2007 17:51:20

I got the page to disappear by doing the following:


if (strKey == "HideTile")
{
/**
* This, as the naem suggests, "hides" a tile.
* Usage: Pass in a std::vector<void*> Pointer to the getOption call containing at least 4 Elements
* [0](Ogre::unsigned int*) = X Index of the Page to retrieve data from
* [1](Ogre::unsigned int*) = Z Index of the Page to retrieve data from
* [2](Ogre::unsigned int*) = X Index of the Tile within the Page to retrieve data from
* [3](Ogre::unsigned int*) = Z Index of the Tile within the Page to retrieve data from
**/
unsigned int requestPageX = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[0]);
unsigned int requestPageZ = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[1]);
unsigned int requestTileX = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[2]);
unsigned int requestTileZ = *static_cast<unsigned int *>((*static_cast<std::vector<void*>*>(pDestValue))[3]);

PagingLandScapePage* page = mPageManager->getPage(requestPageX,requestPageZ);

if(page)
{
PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
if(tile)
{
PagingLandScapeRenderable* rend = tile->getRenderable();
if(rend)
{
if(tile->mVisible)
{
rend->setInUse(false);
tile->mVisible=false;//not needed to hide tile but just in case

//mTileManager->getSceneManager()->getListenerManager ()->fireTileHide
//(requestPageX, requestPageZ, requestTileX, requestTileZ, tile->mWorldBounds);
return true;
}
}
}
}
return false;
}


Not sure if I should be doing anything else to let the rest of PLSM2 know I've done it, but for now it seems to work anyway.

kungfoomasta

08-03-2007 19:20:49

You should submit a patch to Tuan, this is really useful if you want to add in mesh parts like caves.

KungFooMasta

nindim

09-03-2007 00:16:42

Kungfoomasta: That's what I'm using it for, I have the mesh tiles exporting to obj files, which I then convert to .mesh using ms3d. I just use the same texture format for the mesh (modified plsplattingshaderlit) so it blends in really well, slight problem with the lighting on the mesh, but not too noticeable, expecially if you make sure there are no parts that will be really shaded around the tile.

There is still a problem with the implemtation Im using. the mesh decal still hugs to the terrain as if it were still there, meaning that if i change the mesh I place there instead, it could be hovering in mid air for instance. Is there a way to completely stop the tile from doing anything, ie loading, getting registered by rayscene queries, maybe Tuan could help? Thanks.

kungfoomasta

09-03-2007 00:22:24

nindim, sounds like you've done a lot of great things with PLSM2! If PLSM3 came out, would you switch to using it? In either case, it would be awesome if you could wiki some of your implementations for others. :D

I would be working on similar things, but I didn't get too far, seeing that I couldn't get OgreOpcode and PLSM2 working. Something about PLSM2's Octree implementation that I couldn't figure out..

KungFooMasta

nindim

09-03-2007 00:36:22

Well, from what I've read of PLSM3, it sounds pretty awesome. The game I'm making just now is actually for a University group project, and the deadline is sometime in May, whether I will have the need to use the PLSM after that is uncertain at this poin. If I ever did have to make soemthing with a large outdoor terrain after this project though, I'm pretty sure I'd probably be using ogre and PLSM3. I wouldnt say I've done a lot of great things, just what I need for my game :)

I'm planning on uploading my source code here for the export to mesh etc when its done (aka portable and clean!), I've never done a wiki page b4, but if ppl would be interested (and it weas deemed worthy!) I'd give it a try.