|
我现在在MFC框架的OSG中调用OsgOcean.dll库加载海浪已经实现,但是怎样加入船与ocean的碰撞检测??在oceanExample中的application中是可以实现碰撞检测,有没有人移植过这段代码??
if (testCollision)
{
osgDB::Registry::instance()->getDataFilePathList().push_back("resources/boat");
const std::string filename = "boat.3ds";
osg::ref_ptr<osg::Node> boat = osgDB::readNodeFile(filename);
if(boat.valid())
{
boat->setNodeMask( scene->getOceanScene()->getNormalSceneMask() |
scene->getOceanScene()->getReflectedSceneMask() |
scene->getOceanScene()->getRefractedSceneMask() );
osg::ref_ptr<osg::MatrixTransform> boatTransform = new osg::MatrixTransform;
boatTransform->addChild(boat.get());
boatTransform->setMatrix(osg::Matrix::translate(osg::Vec3f(0.0f, 160.0f,1.0f)));
boatTransform->setUpdateCallback( new BoatPositionCallback(scene->getOceanScene()) );
scene->getOceanScene()->addChild(boatTransform.get());
}
else
{
osg::notify(osg::WARN) << "testCollision flag ignored - Could not find: " << filename << std::endl;
}
} |
|