[SOLVED]PLSM2 SDK from CVS/RaySceneQuery

winegums

15-02-2007 12:53:56

Hi there, I've recently upgraded my PLSM2 plugin to the sdk version in the CVS, previously I was using the SDK plugin built from the source on Tuan's page. The application I had worked fine, but I wanted to incorporate mesh decals (as projective decals didnt seem to work with the plsplattingshaderlit texture mode i was using, strange!) . It seems now as if all my rayscenequeries which were pretty much carbon copies of the way the deform() fucntion in the plsm2 demo does it no longter work. When I try and deform terrain I get an error says that "vector itterator cannot be dereferenced. Seems like it's trying to access an element of the list that holds the intersections thats not there.

If i change to the plugin from Tuans page it works fine, but mesh decals dont work. Even a simple query to get height of terrain below player does not work anymore so player falls through terrain.

Decals are quite important so I'm considering taking Skulgs bounding box stuff from the new sdk and molesting the version of the sdk ion tuans page with that and hopefully building a plugin that will work for me. Unless anyone here can help me with the problem? I couldnt get the cvs version to compile either, something about the findlights function (among about 4 or 5 other errors) onlly taking one parameter when it needs to (i dont think the list to populate was being passed) Has anyone encountered similar problems or know a fix? I'm using the Ogre SDK ( version 1.2.5 Dagon).

Also is there a way for the PLSM2 to tell you when the tiles have been loaded, just now I have to wait for about one frame b4 doing raysceenqueries(with old plugin which worked) otherwise they dont intersect anything. Thanks!

nindim

15-02-2007 20:39:24

Hey again, I posted earlier under my friends account so this is just me posting how I resolved (read got around) the issue. The rayscenequery I was doing (for height) was based on the PLSM2 demos getHeight() function, went somehting like this:

mRay.setOrigin (pos);
mRayQuery->setRay (mRay);
mRayQuery->setQueryMask(RSQ_Height);

RaySceneQueryResult& qryResult = mRayQuery->execute();
RaySceneQueryResult::iterator it = qryResult.begin();
if (it != qryResult.end() && it->worldFragment)
{
height = it->worldFragment->singleIntersection.y;
}

Ive found that you must replace the line

mRayQuery->setQueryMask(RSQ_Height);

with:

mRayQuery->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
mRayQuery->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION);


Not sure why the RSQ_Height mask doesnt work, Im pretty sure thats PLSM2 only though, is it broken or am i just doing something wrong? As i said before, that mask works on the sdk on Tuan's page.

nindim

15-02-2007 21:48:00

Hmmm.... Doesnt work as well as I'd hoped, the intersection point is iinconsistent and seems to jump around (maybe where tiles change?), as I believe another thread on this forum was saying. I took a look at the code of the CVS PLSM2 and realised that the intersection code has changed dramatically, there doesnt seem to be any mention of RSQ_FIRSTTERRAIN anymore let alone any of the other masks.

Maybe I'm missing something here.....

Hmmmm, I just looked at the new demo code included with the CVS, it's using the same code i posted above for intersections so i guess the PLSM2 only masks are gone now for good.

mRayQuery->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
mRayQuery->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION);

Has no one else had problems with this? It seems to work ok for finding the height and clamping player to terrain but intersections seem off.

nindim

15-02-2007 22:06:39

Ok, so it seems this is a known issue, sorry about the post in general really :)

http://www.ogre3d.org/phpBB2addons/view ... tersection

so, now that I know other people do know about it, does anyone have any idea how to fix it or if maybe it has been fixed already (that post is from back in Novemeber. Probably just wishfulk thinking on my part seeing as (I think) I have the latest files from the CVS.

nindim

16-02-2007 01:12:23

Hi again, I have managed to fix the problem with the intersection, the fix was actually posted in another thread but hasn't made it's way to the CVS yet for some reason...... Anyway, lines 407 - 410 of the file "OgrePagingLandScapeTile.cpp"should read:

const Real invScaledDirX = dir.x * invScale.x;
const Real invScaledDirZ = dir.z * invScale.z;
Real invScaledRayX = (ray.x * invScale.x) - data->getShiftX ();
Real invScaledRayZ = (ray.z * invScale.z) - data->getShiftZ ();

instead of:

const Real invScaledDirX = dir.x * invScale.x;
const Real invScaledDirZ = dir.x * invScale.z;
Real invScaledRayX = (ray.x * invScale.x) - data->getShiftX ();
Real invScaledRayZ = (ray.x * invScale.z) - data->getShiftZ ();

The original fix was proposed in the thread here:

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=2669

Thankyou Mr. Anonymous e-mailer!!!

My app works perfectly now, dont know if this will effect the issue with multiple pages as my heightmap is only one (513x513 just now)

Maybe this should be changed next time the CVS is updated?