本文整理汇总了C++中osg::ref_ptr::accept方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::accept方法的具体用法?C++ ref_ptr::accept怎么用?C++ ref_ptr::accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::accept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersection_terrain
bool intersection_terrain( float x, float y, osg::Node* terrain, osg::Vec3& inter, osg::Vec3& normal)
{
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,1000), osg::Vec3(x, y,-1000));
osgUtil::IntersectionVisitor iv(intersector.get());
terrain->accept(iv);
if (intersector->containsIntersections()){
osgUtil::LineSegmentIntersector::Intersections& intersections = intersector->getIntersections();
// Le segment étant vertical, on prend la première (et à priori unique) intersection trouvée
const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin());
inter = intersection.getWorldIntersectPoint();
normal = intersection.getWorldIntersectNormal();
return true;
}
return false;
}
示例2: overrideFirstRootTexture
void overrideFirstRootTexture(const std::string &texture, Resource::ResourceSystem *resourceSystem, osg::ref_ptr<osg::Node> node)
{
TextureOverrideVisitor overrideVisitor(texture, resourceSystem);
node->accept(overrideVisitor);
}
示例3: setSmooth
void myModel::setSmooth()
{
_model->accept( _sv );
}
示例4: copyVisitor
osg::ref_ptr<osg::Node> attach(osg::ref_ptr<osg::Node> toAttach, osg::Node *master, const std::string &filter, osg::Group* attachNode)
{
if (dynamic_cast<SceneUtil::Skeleton*>(toAttach.get()))
{
osg::ref_ptr<osg::Group> handle = new osg::Group;
osg::UserDataContainer* udc = toAttach->getUserDataContainer();
CopyRigVisitor copyVisitor(handle, filter);
toAttach->accept(copyVisitor);
copyVisitor.doCopy();
if (handle->getNumChildren() == 1)
{
osg::ref_ptr<osg::Node> newHandle = handle->getChild(0);
handle->removeChild(newHandle);
master->asGroup()->addChild(newHandle);
newHandle->setUserDataContainer(udc);
return newHandle;
}
else
{
master->asGroup()->addChild(handle);
handle->setUserDataContainer(udc);
return handle;
}
}
else
{
FindByNameVisitor findBoneOffset("BoneOffset");
toAttach->accept(findBoneOffset);
osg::ref_ptr<osg::PositionAttitudeTransform> trans;
if (findBoneOffset.mFoundNode)
{
osg::MatrixTransform* boneOffset = dynamic_cast<osg::MatrixTransform*>(findBoneOffset.mFoundNode);
if (!boneOffset)
throw std::runtime_error("BoneOffset must be a MatrixTransform");
trans = new osg::PositionAttitudeTransform;
trans->setPosition(boneOffset->getMatrix().getTrans());
// The BoneOffset rotation seems to be incorrect
trans->setAttitude(osg::Quat(osg::DegreesToRadians(-90.f), osg::Vec3f(1,0,0)));
// Now that we used it, get rid of the redundant node.
if (boneOffset->getNumChildren() == 0 && boneOffset->getNumParents() == 1)
boneOffset->getParent(0)->removeChild(boneOffset);
}
if (attachNode->getName().find("Left") != std::string::npos)
{
if (!trans)
trans = new osg::PositionAttitudeTransform;
trans->setScale(osg::Vec3f(-1.f, 1.f, 1.f));
// Need to invert culling because of the negative scale
// Note: for absolute correctness we would need to check the current front face for every mesh then invert it
// However MW isn't doing this either, so don't. Assuming all meshes are using backface culling is more efficient.
static osg::ref_ptr<osg::StateSet> frontFaceStateSet;
if (!frontFaceStateSet)
{
frontFaceStateSet = new osg::StateSet;
osg::FrontFace* frontFace = new osg::FrontFace;
frontFace->setMode(osg::FrontFace::CLOCKWISE);
frontFaceStateSet->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
}
trans->setStateSet(frontFaceStateSet);
}
if (trans)
{
attachNode->addChild(trans);
trans->addChild(toAttach);
return trans;
}
else
{
attachNode->addChild(toAttach);
return toAttach;
}
}
}
示例5: setSceneData
void BindDialog::setSceneData(osg::ref_ptr<osg::Node> pModel)
{
NodeVisitor visitor( ui->nodeTree->invisibleRootItem() );
pModel->accept(visitor);
ui->nodeTree->expandAll();
}