本例子演示了拾取的功能。
PickHandler继承GUIEventHandler
‘s’键通过CreateModelToSaveVisitor把选中的节点写出。
virtual void apply(osg::Node& node)
{
osgFX::Scribe* scribe =
dynamic_cast<osgFX::Scribe*>(&node);
if (scribe)
{
for
(unsigned int i=0; i<scribe->getNumChildren(); ++i)
{
_group->addChild(scribe->getChild(i));
}
}
else
{
traverse(node);
}
}
‘o’键写出了整个场景。
‘p’键切换拾取的方式。
在例子中用了两种求交的方式:1、PolytopeIntersector;指定一个矩形区域求交,构造函数
PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax,
double yMax);通过cf指定了一种坐标参考,后面的参数指定了一个矩形。
enum CoordinateFrame
{
WI
PickHandler继承GUIEventHandler
‘s’键通过CreateModelToSaveVisitor把选中的节点写出。
virtual void apply(osg::Node& node)
{
osgFX::Scribe* scribe =
dynamic_cast<osgFX::Scribe*>(&node);
if (scribe)
{
for
(unsigned int i=0; i<scribe->getNumChildren(); ++i)
{
_group->addChild(scribe->getChild(i));
}
}
else
{
traverse(node);
}
}
‘o’键写出了整个场景。
‘p’键切换拾取的方式。
在例子中用了两种求交的方式:1、PolytopeIntersector;指定一个矩形区域求交,构造函数
PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax,
double yMax);通过cf指定了一种坐标参考,后面的参数指定了一个矩形。
enum CoordinateFrame
{
WI