majc
14-03-2008 00:28:46
I used userPreFilterCallback function to ignore the player body when i fire my weapon but for some reason this it isnt working, here's the code:
I can still hit the player physical body when i fire my weapon.
What im doing wrong?
Thanks in advance!
OgreNewt::BasicRaycast::BasicRaycastInfo cCollisions::getBodyInfo()
{
float x = 0.5, y = 0.5, rayDistance = 3000.0; // center of screen
Ogre::Ray ray = mCamera->getCameraToViewportRay(x, y);
Ogre::Vector3 direction = ray.getDirection();
Ogre::Vector3 origin = ray.getOrigin();
Ogre::Vector3 start = origin;
Ogre::Vector3 end = origin + direction * rayDistance;
OgreNewt::BasicRaycast::BasicRaycastInfo info;
// normalized screen coords in [0,1]
OgreNewt::BasicRaycast* verticalRay = new OgreNewt::BasicRaycast(m_World,start,end);
info = verticalRay->getFirstHit();
if (info.mBody)
{
int myValue2 = info.mBody->getType();
Debugger* mDebugger = new Debugger();
String s = StringConverter::toString(myValue2);
mDebugger->debug(s,"BodyType:", "BodyType.txt");
if(info.mBody->getType() == TYPEPLAYER)
verticalRay->userPreFilterCallback(info.mBody);
}
return info;
} I can still hit the player physical body when i fire my weapon.
What im doing wrong?
Thanks in advance!