ryak2002
12-10-2006 22:08:34
EDIT: Appearently, setting the plain mask to 4 makes it work. What exactly does the querytypemask do if it doesn't limit the results?
I'm trying to determine the point on the terrain where the user clicks and place a knot there. But the ray scene query is always wrongly returning a point directly below the camera and exactly 4 entity intersections. (why is it returning entities anyway with the world geometry mask?)
The ray is always pointed in the correct direction. In fact, the location returned isn't even on the ray.
I'm trying to determine the point on the terrain where the user clicks and place a knot there. But the ray scene query is always wrongly returning a point directly below the camera and exactly 4 entity intersections. (why is it returning entities anyway with the world geometry mask?)
The ray is always pointed in the correct direction. In fact, the location returned isn't even on the ray.
mRaySceneQuery = mSceneMgr->createRayQuery( Ray() );
mRaySceneQuery->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
mRaySceneQuery->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION);
// Setup the ray scene query
Ray mouseRay = mCamera->getCameraToViewportRay( e->getX(), e->getY() );
mRaySceneQuery->setRay( mouseRay );
// Execute query
RaySceneQueryResult &result = mRaySceneQuery->execute();
RaySceneQueryResult::iterator itr = result.begin( );
// Get results, create a node/entity on the position
if ( itr != result.end() && itr->worldFragment )
{
char name[16];
sprintf( name, "Point%d", mCount++ );
Entity *ent = mSceneMgr->createEntity( name, "knot.mesh" );
mCurrentObject = mSceneMgr->getRootSceneNode( )->createChildSceneNode( String(name) + "Node", itr->worldFragment->singleIntersection );
mCurrentObject->attachObject( ent );
mCurrentObject->setScale( 0.1f, 0.1f, 0.1f );
mWalkList.push_back(String(name));
} // if