当前位置: 首页>>代码示例>>C++>>正文


C++ Node::getUserData方法代码示例

本文整理汇总了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);
    }
开发者ID:johndpope,项目名称:OpenSceneGraph_iOS_3.2.1,代码行数:25,代码来源:SlideEventHandler.cpp

示例2: apply

    void apply(osg::Node& node)
    {
        HomePosition* homePosition = dynamic_cast<HomePosition*>(node.getUserData());
        if (homePosition)
        {
            _homePosition = homePosition;
        }

        traverse(node);
    }
开发者ID:BriacB,项目名称:osg,代码行数:10,代码来源:SlideEventHandler.cpp

示例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);
}
开发者ID:BackupTheBerlios,项目名称:rvzware,代码行数:75,代码来源:OsgIconSizeUpdaterVisitor.cpp


注:本文中的osg::Node::getUserData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。