Filtering raycasts

shanefarris

14-07-2011 17:25:20

I'm having some problems filtering my raycasts. I am using the "SampleRaycast" example that comes with the PhysX SDK, and I am trying to get the horizontal raycast to ignore the terrain. What I've done is set the shape group to the terrain to 1 inside the "InitTerrain()" function like so:


NxActorDesc ActorDesc;
ActorDesc.shapes.pushBack(&terrainShapeDesc);
ActorDesc.shapes[0]->group = 1;
gScene->createActor(ActorDesc)->userData = (void*)0;


And I've set my raycast to group 2 like so: (RaycastAllShapes())


gScene->raycastAllShapes(worldRay, gMyReport, NX_ALL_SHAPES, 2);


Now I've been able to filter the cubes to pass right through the terrain, but I am having problems with the raycast and the terrain. Any ideas?

Thanks.

SniperBinaire

15-07-2011 20:12:49

This is maybe a messy idea, because I don't use that system, but try to put the cubes in a different collision group.

shanefarris

20-07-2011 21:21:52

My problem is with the terrain. Anyone got any ideas?

SniperBinaire

21-07-2011 11:10:13

CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();
std::pair <bool, Ogre::Vector3> intersection = sys0.terrain->rayIntersects(sys0.cam->getCameraToViewportRay(mousePos.d_x/float(sys0.vp->getActualWidth()), mousePos.d_y/float(sys0.vp->getActualHeight())),10000);


This is how I set up a collision from the mouse position and the terrain.
But this snippet uses the inntegrated Ogre terrain system. If the NxOgre terraan accords to the Ogre one, this snippet will run fine.