本文整理汇总了C++中osg::Node::getUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::getUserData方法的具体用法?C++ Node::getUserData怎么用?C++ Node::getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Node
的用法示例。
在下文中一共展示了Node::getUserData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void apply(osg::Node& node)
{
if (node.getStateSet()) process(node.getStateSet());
if (node.getUpdateCallback())
{
_operatorList.insert(new CallbackOperator(&node, node.getUpdateCallback()));
}
LayerAttributes* la = dynamic_cast<LayerAttributes*>(node.getUserData());
if (la)
{
if ((_objectsHandled[la]++)==0)
{
OSG_NOTICE<<"LayerAttributeOperator for "<<la<<" required, assigning one."<<std::endl;
_operatorList.insert(new LayerAttributesOperator(&node, la));
}
else
{
OSG_NOTICE<<"LayerAttributeOperator for "<<la<<" not required, as one already assigned."<<std::endl;
}
}
traverse(node);
}
示例2: apply
void apply(osg::Node& node)
{
HomePosition* homePosition = dynamic_cast<HomePosition*>(node.getUserData());
if (homePosition)
{
_homePosition = homePosition;
}
traverse(node);
}
示例3: apply
void OsgIconSizeUpdaterVisitor::apply( osg::Node& node )
{
std::string node_name = node.getName();
if (node_name == "-icon-")
{
//get the position of the icon by asking it´s parents
osg::Group *father_node = node.getParent(0);
if (std::string("MatrixTransform") == father_node->className())
{
osg::MatrixTransform *mt = (osg::MatrixTransform *) father_node;
osg::Vec3d icon_position = mt->getMatrix().getTrans();
osg::Matrixd md = mt->getMatrix();
IconUserData *iud = (IconUserData *)node.getUserData();
/*float distance = (float) sqrt(pow(icon_position.x() - camera_pos_x, 2) +
pow(icon_position.y() - camera_pos_y, 2) +
pow(icon_position.z() - camera_pos_z, 2));*/
icon_position.set(osg::Vec3(iud->GetPosition().x, iud->GetPosition().y, iud->GetPosition().z));
float distance = (float) sqrt(pow(icon_position.x() - camera_pos_x, 2) +
pow(icon_position.y() - camera_pos_y, 2) +
pow(icon_position.z() - camera_pos_z, 2));
float final_size = 0.0f;
if (iud->GetHeight() != 0.0f)
min_height = iud->GetHeight();
cpw::Point3d<float> op = iud->GetPosition();
if (distance <= min_distance)
{
final_size = max_size;
md.setTrans(osg::Vec3d(op.x, op.y, op.z + min_height));
}
else if (distance >= max_distance)
{
final_size = min_size;
md.setTrans(osg::Vec3d(op.x, op.y, op.z + max_height));
}
else if ((min_distance < distance) && (distance < max_distance))
{
float increment_distance = max_distance - min_distance;
float size_difference = max_size - min_size;
float height_difference = max_height - min_height;
float final_height;
final_size = max_size - (size_difference * ((distance-min_distance)/increment_distance));
final_height = min_height + (height_difference * ((distance-min_distance)/increment_distance));
md.setTrans(op.x, op.y, op.z + final_height);
//update the matrix
}
osg::ref_ptr<osg::StateSet> set = node.getStateSet();
/// Give some size to the points to be able to see the sprite
osg::ref_ptr<osg::Point> point = new osg::Point();
mt->setMatrix(md);
point->setSize(final_size);
set->setAttribute(point.get());
}
}
//keep searching
traverse(node);
}