Rays

Faxnico

21-09-2008 19:01:33

Hello.

Today I built for the first time the latest OgreBullet SVN version + Bullet 2.7.1... but after a whole day of attempts I wasn't able to make rays working in any way.

Could somebody take a look at my code, please?

...
Ogre::AxisAlignedBox aabb(
Ogre::Vector3(
TERRAIN_SIDE_SIZE*-5000,
ALTITUDE_UNIT*-1250,
TERRAIN_SIDE_SIZE*-5000),
Ogre::Vector3(
TERRAIN_SIDE_SIZE*5000,
ALTITUDE_UNIT*1250,
TERRAIN_SIDE_SIZE*5000)
);
m_btWorld = new OgreBulletCollisions::CollisionsWorld(m_SceneMgr, aabb);

...
OgreBulletCollisions::StaticMeshToShapeConverter conv(entity);
OgreBulletCollisions::Object* btObj = new OgreBulletCollisions::Object(
Ogre::String("road_object_") + idStr, m_btWorld, true);
btObj->setShape(conv.createConvex(), Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY);
btObj->setPosition(m_Offset);
btObj->setOrientation(Ogre::Quaternion(m_Direction, Ogre::Vector3::UNIT_Y));
btObj->showDebugShape(true);
m_btWorld->addObject(btObj);
...
OgreBulletCollisions::CollisionsWorld* btWorld = tm.getBulletWorld();
Ogre::Vector3 p = m_Camera->getPosition();
Ogre::Ray camRay(p, Ogre::Vector3::NEGATIVE_UNIT_Y);
OgreBulletCollisions::CollisionClosestRayResultCallback rayRes(camRay, btWorld, 10000000.f);
btWorld->launchRay(rayRes);

if (rayRes.doesCollide())
{
// ray has collided
// it never enters here
}


Thank you in advance.
Nicolò