[SOLVED] RaySceneQuery issue with PLSM2

Sabe

10-08-2006 17:14:51

Ok, I don't know if I'm missing something here, but when I do a ray query I get a world collision below my camera. The direction of the ray is not negative Y though.

I've set the direction to the normalized vector between the sun and my camera. I'm logging a lot of values to try and find something to lead me to the solution, but I'm getting nowhere on this issue.


10:50:16: //////////////////////////////
10:50:16: LOG COLLISION
10:50:16: Vec To Sun: -0.182574 0.365148 0.912871
10:50:16: Ray Direction: -0.182574 0.365148 0.912871
10:50:16: Camera Position: 2826.36 10337 15524.7
10:50:16: World Collision: 2826.36 9058.82 15524.7
10:50:16: Collision Name: page3_2tile7_1_TreeTile:537395712
10:50:16: Collision Name: page3_2tile7_2_TreeTile:537395712
10:50:16: Collision Name: debri
10:50:16: Collision Name: 4.2.0.1Rend
10:50:16: Collision Name: page4_2tile0_1_GrassTile:537395712
10:50:16: Collision Name: page4_2tile0_1_TreeTile:537395712
10:50:16: Collision Name: SunBack
10:50:16: Collision Name: SunFront
10:50:16: Collision Name: page4_2tile0_2_TreeTile:537395712
10:50:16: Collision Name: page4_2tile0_2_TreeTile:536347136
10:50:16: //////////////////////////////



The ray's direction is the same as the vector to the sun. So the direction is set correctly. Also the movable object intersections seem to be correct. The sun is returned for both of them. The oddity is the World intersection. It is directly below the camera as if the ray's direction was on the negative Y. What's worse is, when I logged this ray query there should be a world intersection between the camera and the sun, but there isn't. The world intersection is always straight down from the camera no matter where I move the camera also.

Here is the code I'm using


if( m_LogCol )
{
vecToSun = sunPos - cameraPos;
vecToSun.normalise( );
cameraPos = cameraPos + ( vecToSun * mCamera->getNearClipDistance() );
Ray rayTest( cameraPos, vecToSun );

mRayQuery->setRay( rayTest );
mRayQuery->setQueryTypeMask(
SceneManager::WORLD_GEOMETRY_TYPE_MASK | SceneManager::ENTITY_TYPE_MASK );

Ogre::RaySceneQueryResult rayResult = mRayQuery->execute();
Ogre::RaySceneQueryResult::iterator iter = rayResult.begin();

while( iter != rayResult.end( ) )
{
if( ( *iter ).movable )
{
// Object intersection
}
if( ( *iter ).worldFragment )
{
// World intersection
}
++iter;
}
m_LogCol = false;
}



I appreciate any feedback on why I might be having this problem.

viblo2

10-08-2006 17:58:52

Try to set RSQ_FirstTerrain as query mask.

Sabe

14-08-2006 16:33:35

Thank you :D
Worked great.