• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ osg::NodePtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中osg::NodePtr的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr类的具体用法?C++ NodePtr怎么用?C++ NodePtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了NodePtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: enter

            //method that will be called when entering
            //a new node
			osg::Action::ResultE enter(osg::NodePtr& node)
			{
                if (node->getCore()->getType().isDerivedFrom(OSG::CharacterBase::getClassType()))
				{
					osg::CharacterPtr charac = osg::CharacterPtr::dcast(node->getCore());
					std::string name;
					if (getName(node))
					{
						name = getName(node);
					}
					else 
					{
						osg::CharacterModelPtr model = charac->getModel();
						name = model->getConfigFile();
						std::cout << "character model file " << name << std::endl;
						std::string::size_type slashpos = name.size()-1;
						slashpos = name.find_last_of("/");
						if(slashpos != name.npos)
							name = name.substr(slashpos+1);
						slashpos = name.size()-1;
						slashpos = name.find_last_of("\\");
						if(slashpos != name.npos)
							name = name.substr(slashpos+1);
						std::string::size_type dotpos = 0;
						dotpos = name.find_last_of(".");
						if(dotpos != name.npos)
							name = name.substr(0, dotpos);
					}
					std::cout << name << " is a character" << std::endl;
					return process(node, charac, name);
				}
                return osg::Action::Continue;
            }
开发者ID:marcogillies,项目名称:Piavca,代码行数:35,代码来源:PiavcaOpenSGCore.cpp


示例2: main

int main(int argc, char **argv)
{
    OSG::NodePtr pRoot;

    int i = 0;

    OSG::osgInit(i, NULL);

    OSG::Node::create();

    if((argc > 2) && (OSG::stringcmp(argv[2], "pushNames") == 0))
    {    
        OSG::SceneFileHandler::the().setOptions("wrl", "pushNames=true");
    }
    
    pRoot = OSG::SceneFileHandler::the().read(argv[1]);

    std::cerr << "Tree : " << std::endl;

    if(pRoot == OSG::NullFC)
    {
        std::cerr << "\t Empty" << std::endl;
    }
    else
    {
        pRoot->dump();
    }

//    char *szFilename = "stirnwand.wrl";

    OSG::osgExit();

    return 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:34,代码来源:testVRML.cpp


示例3: makePolygon

OSG::NodePtr makePolygon(double pntData[][3], int numPoints) {

  OSG::GeometryPtr geoPtr  = OSG::Geometry::create();
  OSG::NodePtr     nodePtr = OSG::Node::create();

  GeoPositions3fPtr    pnts    = GeoPositions3f::create();
  GeoNormals3fPtr      norms   = GeoNormals3f::create();
  GeoTexCoords2fPtr    tex     = GeoTexCoords2f::create();
  GeoIndicesUI32Ptr    indices = GeoIndicesUI32::create();   
  GeoPLengthsUI32Ptr   lens    = GeoPLengthsUI32::create();  
  GeoPTypesUI8Ptr      types   = GeoPTypesUI8::create();     

  //Set up the properties according to the geometry defined above
  beginEditCP(pnts);
  beginEditCP(norms);
  
  for(int i = 0; i < numPoints; i++) 
    {
      pnts->push_back(Pnt3f(pntData[i][0],
                            pntData[i][1], 
                            pntData[i][2]));

      indices->push_back(2*i);

      norms->push_back(Vec3f(0.0, 0.0, pntData[i][2]));
      indices->push_back(2*i + 1);
    }

  endEditCP(pnts);
  endEditCP(norms);

  beginEditCP(types);
  beginEditCP(lens);
  types->push_back(GL_POLYGON);
  lens->push_back(numPoints);
  endEditCP(types);
  endEditCP(lens);

  beginEditCP(geoPtr);
  
  geoPtr->setMaterial(getDefaultMaterial());
  geoPtr->setPositions(pnts);
  geoPtr->setNormals(norms);
  geoPtr->setIndices(indices);
  
  geoPtr->editMFIndexMapping()->push_back(Geometry::MapPosition | 
                                          Geometry::MapNormal);
  
  geoPtr->setTypes(types);
  geoPtr->setLengths(lens);
  
  endEditCP(geoPtr);

  nodePtr->setCore(geoPtr);
  return nodePtr;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:56,代码来源:testCreateConvexPrimitives.cpp


示例4: setActive

void testObj::setActive( osg::NodePtr parent, bool active )
{
	if ( _isActive && ! active )
	{
		osg::addRefCP( node );
		parent->subChild( node );
	}
	else if ( ! _isActive && active )
 		parent->addChild( node );
	_isActive = active;
}
开发者ID:tl3shi,项目名称:kcbp_cgal_cuda,代码行数:11,代码来源:intersect.cpp


示例5: testNode

void testNode(void)
{
#if 0
    OSG::SFNodePtr sfNode;
    OSG::MFNodePtr mfNode;

    OSG::NodePtr pNode = OSG::Node::create();

    sfNode.setValue(pNode);
    mfNode.push_back(pNode);

/*
    fprintf(stderr, "%p %p %p | %d %d\n", 
            pNode, 
            sfNode.getValue(), 
            mfNode[0],
            OSG::Node::VolumeFieldId,
            OSG::Node::TravMaskFieldId);
 */

    OSG::NodePtr pNode1 = OSG::Node::create();

    sfNode.setValue(pNode1);
    mfNode.resize(2);
    mfNode.replace(1, pNode1);

    const OSG::Field *pF1 = pNode->getSFVolume();
          OSG::Field *pF2 = pNode->editSFVolume();

    OSG::GetFieldHandlePtr  pRF1 = pNode->getField("volume");
    OSG::EditFieldHandlePtr pRF2 = pNode->editField("volume");

    fprintf(stderr, "#### Field %p %p | %p %p\n", 
            pF1, 
            pF2, 
            pRF1.get(), 
            pRF2.get());

//    fprintf(stderr, "%p %p %p\n", pNode1, sfNode.getValue(), mfNode[1]);

    const OSG::SFNodePtr constSFNode;

//    fprintf(stderr, "%p %p\n", pNode1, constSFNode.getValue());

    OSG::FieldContainerPtr pNodeClone = deepClone(pNode);

    OSG::FieldContainerPtr pFC = 
        OSG::FieldContainerFactory::the()->createContainer("Billboard");

    fprintf(stderr, "### FOO %p\n", getCPtr(pFC));

#endif
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:53,代码来源:testFieldContainer.cpp


示例6: addWithHull

void addWithHull( osg::NodePtr	testObj )
{
	testGeom = osg::GeometryPtr::dcast( testObj->getCore() );
	testHull = testGeom;
	testHullObj = testHull.getGeomNode();

	testHull.print();

	// set material
	osg::SimpleMaterialPtr mat = osg::SimpleMaterial::create();
    	mat->setDiffuse( osg::Color3f( 1.0,0.7,1.0 ) );
    	mat->setAmbient( osg::Color3f( 0.2,0.2,0.2 ) );
    	mat->setSpecular( osg::Color3f( 1,1,1 ) );
    	mat->setShininess( 20 );

	testGeom->setMaterial( mat );
	osg::GeometryPtr::dcast(testHullObj->getCore())->setMaterial( mat );

	// add to scene graph
	beginEditCP(root);

	root->addChild( testObj );
	root->addChild( testHullObj );

	endEditCP(root);
}
开发者ID:tl3shi,项目名称:kcbp_cgal_cuda,代码行数:26,代码来源:convexHull.cpp


示例7: Group

Transform::Transform(OSG::NodePtr node) : Group(node)
{
    _transform = OSG::cast_dynamic<OSG::TransformPtr>(node->getCore());
   
    // OSG::beginEditCP(_node);
    _node->setCore(_transform);
    // OSG::endEditCP(_node);
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:8,代码来源:Nodes.cpp


示例8: NodeBase

Group::Group(OSG::NodePtr node) : NodeBase(node)
{
    _group = OSG::cast_dynamic<OSG::GroupPtr>(node->getCore());
   
    // OSG::beginEditCP(_node);
    _node->setCore(_group);
    // OSG::endEditCP(_node);
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:8,代码来源:Nodes.cpp


示例9: next

NodeBase NodeIterator::next(void)
{
    while(!_stack.empty())
    {
        OSG::NodePtr act = _stack.back();

        _stack.pop_back();

        for(OSG::UInt32 i = 0; i < act->getNChildren(); ++i)
            _stack.push_back(act->getChild(i));

        if(act->getCore()->getType().isDerivedFrom(*_type))
        {
            return NodeBase(act);
        }    
    }
   
    PyErr_SetString(PyExc_StopIteration, "Out of Nodes");   
    boost::python::throw_error_already_set();
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:20,代码来源:Nodes.cpp


示例10: subRefCP

void InventorLoader::checkForRedundancy( osg::NodePtr OSGGroup )
{
  return;
  
    // TODO: Check the type of the node and return, if it's not a node
    // that should be discarded (discardable: group, not discardable: geometry)

    // If the group node has no children, then let's kick it !
    if( OSGGroup->getNChildren() == 0 )
    {
        if(OSGGroup->getParent() != NullFC)
        {
            OSGGroup->getParent()->subChild(OSGGroup);
        }
        else
        {
            subRefCP(OSGGroup);
        }
    }
    // If there's only one child, then add it to the parent of the group,
    // copy the name and remove the group
    else if ( OSGGroup->getNChildren() == 1 )
    {
        // Get parent and child
        osg::NodePtr _Child = OSGGroup->getChild(0);
        osg::NodePtr _Parent = OSGGroup->getParent();

        // Copy the name
        const char* _Name = getName(OSGGroup);
        if( _Name )
            setName( _Child, _Name );

        // Add the child to the parent
        _Parent->addChild( _Child );

        // Remove the group node
        _Parent->subChild( OSGGroup );
    }
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:39,代码来源:OSGInventorLoader.cpp


示例11: createScoreBoards

NodePtr createScoreBoards()
{
	GeometryPtr geo;
	NodePtr bg;
	SimpleMaterialPtr m;
	ScoreBoard1 = new TextStuff() ;
	ScoreBoard2 = new TextStuff() ;

	// First get the global group node
    OSG::NodePtr scoreBoardsNodePtr = OSG::Node::create();
    scoreBoardsNodePtr->setCore(OSG::Group::create());

    // Setup text 1
    ScoreBoard1->initialize();
    ScoreBoard1->updateFace();
    ScoreBoard1->updateScore(0,0);
    // Setup text 2
    ScoreBoard2->initialize();
    ScoreBoard2->updateFace();
    ScoreBoard2->updateScore(0,0);

	////////// 1 /////////
	// make its transform
	TransformPtr trans1;
    NodePtr trans_node1 = makeCoredNode<Transform>(&trans1);
    beginEditCP(trans1);
		trans1->getMatrix().setTransform(Vec3f(0,4,-10.5),Quaternion( Vec3f(0,1,0),deg2rad(0)));
    endEditCP(trans1);

	// make geometry
	bg = makePlane(9.3, 1, 8,2);
	 m= SimpleMaterial::create();
    beginEditCP(m);
    {		
        m->setAmbient      (Color3f(0,0,0));
        m->setDiffuse      (Color3f(0.0,0.0,0.0));
    }
    endEditCP  (m);  
	geo = GeometryPtr::dcast(bg->getCore());  
    beginEditCP(geo);
		geo->setMaterial(m);
    beginEditCP(geo);

	beginEditCP(bg);
	bg->addChild(ScoreBoard1->mRootNode);
	endEditCP(bg);

	beginEditCP(trans_node1);
		trans_node1->addChild(bg);
	endEditCP(trans_node1);

	////////// 2 /////////
	// make its transform
	TransformPtr trans2;
    NodePtr trans_node2 = makeCoredNode<Transform>(&trans2);
    beginEditCP(trans2);
		trans2->getMatrix().setTransform(Vec3f(0,4,10.5),Quaternion( Vec3f(0,1,0),deg2rad(180)));
    endEditCP(trans2);

	// make geometry
	bg = makePlane(9.3, 1, 8,2);
	m = SimpleMaterial::create();
    beginEditCP(m);
    {		
        m->setAmbient      (Color3f(0,0,0));
        m->setDiffuse      (Color3f(0.0,0.0,0.0));
    }
    endEditCP  (m);  
	geo = GeometryPtr::dcast(bg->getCore());  
    beginEditCP(geo);
		geo->setMaterial(m);
    beginEditCP(geo);

	beginEditCP(bg);
	bg->addChild(ScoreBoard2->mRootNode);
	endEditCP(bg);

	beginEditCP(trans_node2);
		trans_node2->addChild(bg);
	endEditCP(trans_node2);


	beginEditCP(scoreBoardsNodePtr);
		scoreBoardsNodePtr->addChild(trans_node1);
		scoreBoardsNodePtr->addChild(trans_node2);
	endEditCP(scoreBoardsNodePtr);
  

    return scoreBoardsNodePtr;
}
开发者ID:astanin,项目名称:mirror-studierstube,代码行数:90,代码来源:text.cpp


示例12: main


//.........这里部分代码省略.........

		file << patt_trans[0][0] << " " << patt_trans[0][1] << " " << patt_trans[0][2] << " " << patt_trans[0][3] << " "<<endl;
		file << patt_trans[1][0] << " " << patt_trans[1][1] << " " << patt_trans[1][2] << " " << patt_trans[1][3] << " "<<endl;
		file << patt_trans[2][0] << " " << patt_trans[2][1] << " " << patt_trans[2][2] << " " << patt_trans[2][3] << " "<<endl;

		//file << patt_center[0] << " " << patt_center[1] <<endl;
		//cout << "patt width: " << patt_width <<endl;


		file << marker_info[k].pos[0] << " " << marker_info[k].pos[1] <<endl;

		cout << "p1: " << marker_info[k].vertex[0][0] << " " << marker_info[k].vertex[0][1]<< endl;
		cout << "p2: " << marker_info[k].vertex[1][0] << " " << marker_info[k].vertex[1][1]<< endl;
		cout << "p3: " << marker_info[k].vertex[2][0] << " " << marker_info[k].vertex[2][1]<< endl;
		cout << "p4: " << marker_info[k].vertex[3][0] << " " << marker_info[k].vertex[3][1]<< endl;

		cv::line(newAR,cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),CV_RGB(255,0,0));
		cv::line(newAR,cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),CV_RGB(255,0,0));
		cv::line(newAR,cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),CV_RGB(255,0,0));
		cv::line(newAR,cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),CV_RGB(255,0,0));

		cv::line(newAR,cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),CV_RGB(255,0,0));
		cv::line(newAR,cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),CV_RGB(255,0,0));

		cv::line(RGB,cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),CV_RGB(255,0,0));
		cv::line(RGB,cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),CV_RGB(255,0,0));
		cv::line(RGB,cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),CV_RGB(255,0,0));
		cv::line(RGB,cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),CV_RGB(255,0,0));

		cv::line(RGB,cv::Point(marker_info[k].vertex[0][0],marker_info[k].vertex[0][1]),cv::Point(marker_info[k].vertex[2][0],marker_info[k].vertex[2][1]),CV_RGB(255,0,0));
		cv::line(RGB,cv::Point(marker_info[k].vertex[1][0],marker_info[k].vertex[1][1]),cv::Point(marker_info[k].vertex[3][0],marker_info[k].vertex[3][1]),CV_RGB(255,0,0));

		cv::waitKey(1);
	    }
	stringstream stream2;
	stream2 << "pics/new/";
	stream2 << u;
	stream2 << ".bmp";
	//cv::imwrite(stream2.str().c_str(),RGB);

	file<< "##"<<endl;
	cv::imshow("looky looky",RGB);
	cv::waitKey(1);
    }
    file.close();

*/
    // AR _ENDE_ !!
    //}


  //  QCoreApplication a(argc, argv);

	OSG::osgInit(argc,argv);
	cout << "argc " << argc <<endl;
	for(int ar(0);ar<argc;++ar)
		cout << argv[ar] << " ";
	cout << endl;
	int winid = setupGLUT(&argc,argv);
	//GLUTWindowPtr gwin = GLUTWindow::create();
	//gwin->setGlutId(winid);
	//gwin->init();


	OSG::NodePtr scene = SceneFileHandler::the().read("data/test__1.obj");
	//OSG::NodePtr scene = SceneFileHandler::the().read("data/test3_4.obj");
	//GroupPtr scene = GroupPtr::dcast(scene);


	cout << "type: " << scene.getCore()->getTypeName()<< endl;

	cout << "children in scene: " << scene->getNChildren()<<endl;

		GeometryPtr geo = GeometryPtr::dcast(scene->getCore());

		GeoPTypesPtr type = GeoPTypesUI8::create();
		type->addValue(GL_LINE);

		LineIterator lit;
		int lines(0);
		TEST = geo;
		for(lit = geo->beginLines();lit != geo->endLines();++lit){
			lines++;
		}

		cout << "lines: " << lines <<endl;
		SimpleMaterialPtr mat = SimpleMaterial::create();
		geo->setMaterial(mat);

	// Create and setup our little friend - the SSM
	mgr = new SimpleSceneManager;
	//mgr->setWindow(gwin);
	//mgr->setRoot(scene);
	//mgr->showAll();
	//glutCreateWindow("test");

    glutMainLoop();

    return 0;
}
开发者ID:stefanedm,项目名称:track,代码行数:101,代码来源:main.cpp


示例13: FDEBUG

osg::NodePtr InventorLoader::traverseGraph( SoNode* OIVNode,
                                            osg::NodePtr OSGNode )
{
    ////////////////////////////////////////////////////////////////////////////
  FDEBUG(("   InventorLoader::traverseGraph( %x )\n",
                          OIVNode));
    ////////////////////////////////////////////////////////////////////////////


    /////////////////
    // Material node
    /////////////////

    if( OIVNode->isOfType( SoMaterial::getClassTypeId() ) )
    {
        // Convert current material
        osg::SimpleMaterialPtr _Material;
        _Material = convertMaterial( ( SoMaterial* ) OIVNode );

        if( mMergeMaterial )
        {
            // Check if that material was already encountered
            TMaterialSet::iterator _Iter;
            for(_Iter = mMaterialSet.begin();
                _Iter != mMaterialSet.end();
                ++_Iter )
            {
                if( compareMaterial( *_Iter, _Material, mMergeTolerance ) )
                    break;
            }

            if( _Iter != mMaterialSet.end() )
            {
                mCurrentState.Material = *_Iter;

                // Delete the converted material from above as it isn't used.
                subRefCP( _Material );
            }
            else
            {
                mMaterialSet.insert( _Material );
                mCurrentState.Material = _Material;
            }
        }
        else
        {
            mCurrentState.Material = _Material;
        }

        // Return the old OSG node as the current OSG node
        return OSGNode;
    }


    ///////////////////
    // Coordinate node
    ///////////////////

    if( OIVNode->isOfType( SoCoordinate3::getClassTypeId() ) )
    {
        // Save current coordinates
        mCurrentState.Positions = convertCoordinates((SoCoordinate3*)OIVNode);

        // Return the old OSG node as the current OSG node
        return OSGNode;
    }


    //////////////////////
    // Normalbinding node
    //////////////////////

    if( OIVNode->isOfType( SoNormalBinding::getClassTypeId() ) )
    {
        // Save current normalbinding
        SoNormalBinding* _Binding = ( SoNormalBinding* ) OIVNode;
        mCurrentState.NormalBinding = _Binding->value.getValue();

        // Return the old OSG node as the current OSG node
        return OSGNode;
    }


    ///////////////
    // Normal node
    ///////////////

    if( OIVNode->isOfType( SoNormal::getClassTypeId() ) )
    {
        // Save current normals
        mCurrentState.Normals = convertNormals( ( SoNormal* ) OIVNode );

        // Return the old OSG node as the current OSG node
        return OSGNode;
    }


    ///////////////////////
    // Transformation node
    ///////////////////////
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:OSGInventorLoader.cpp


示例14: testRefCount

void testRefCount(void)
{
#if 0
    OSG::NodePtr pNode = OSG::Node::create();

    OSG::NodePtr pNode1 = OSG::Node::create();

    fprintf(stderr, "1\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif

    pNode->addChild(pNode1);

    fprintf(stderr, "2\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif

    fprintf(stderr, "3\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif

    applyToAspect(1, false);
    applyToAspect(2);

    fprintf(stderr, "4\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif
    
    fprintf(stderr, "5\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif

    applyToAspect(1, false);

    fprintf(stderr, "6\n");

//XX
#if 0
    pNode.dump();
    pNode1.dump();
#endif

    applyToAspect(2);

    fprintf(stderr, "7\n");
#endif
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:67,代码来源:testFieldContainer.cpp


示例15: main

int main( int argc, char *argv[] )
{

	// OSG init
	osg::osgLog().setLogLevel(osg::LOG_WARNING);
	osg::osgInit(argc, argv);

	// parse command line options
	parsecommandline( argc, argv );

	// disable display lists
	osg::FieldContainerPtr pProto= osg::Geometry::getClassType().getPrototype();
	osg::GeometryPtr pGeoProto = osg::GeometryPtr::dcast(pProto);
    if ( pGeoProto != osg::NullFC )
        pGeoProto->setDlistCache(false);

	// create the graph
	osg::NodePtr node;

	// root
	root = osg::Node::create();
	beginEditCP(root);
	root->setCore( osg::Group::create() );

	// beacon for camera and light
	osg::NodePtr beacon;
	beacon = osg::Node::create();
	beginEditCP(beacon);
	beacon->setCore( osg::Group::create() );
	endEditCP(beacon);

	// light
	light_node = osg::Node::create();
	osg::DirectionalLightPtr light = osg::DirectionalLight::create();
	beginEditCP( light_node );
	light_node->setCore( light );
	root->addChild( light_node );
	beginEditCP(light);
	light->setAmbient( .3, .3, .3, 1 );
	light->setDiffuse( 1, 1, 1, 1 );
	light->setDirection(0,0,1);
	light->setBeacon( beacon );
	endEditCP(light);

	// transformation, parent of beacon
	node = osg::Node::create();
	cam_trans = osg::Transform::create();
	beginEditCP(node);
	node->setCore( cam_trans );
	node->addChild( beacon );
	endEditCP(node);
	root->addChild( node );

	// Camera
	osg::PerspectiveCameraPtr cam = osg::PerspectiveCamera::create();
	cam->setBeacon( beacon );
	cam->setFov( 50 );
	cam->setNear( 0.1 );
	cam->setFar( 10000 );

	// Background
	osg::SolidBackgroundPtr background = osg::SolidBackground::create();
	if ( White_background )
	{
		beginEditCP( background );
		background->setColor(osg::Color3f(1,1,1));
		endEditCP( background );
	}

	// Viewport
	osg::ViewportPtr vp = osg::Viewport::create();
	vp->setCamera( cam );
	vp->setBackground( background );
	vp->setRoot( root );
	vp->setSize( 0,0, 1,1 );

	if ( With_window )
	{
		// GLUT init
		glutInitWindowSize( 400, 400 );		// before glutInit so user can
		glutInitWindowPosition( 100, 100 );	// override with comannd line args
		glutInit(&argc, argv);
		glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
		int winid = glutCreateWindow("Collision Benchmark");
		glutKeyboardFunc(key);
		glutVisibilityFunc(vis);
		glutReshapeFunc(reshape);
		glutDisplayFunc(display);
		glutMouseFunc(mouse);
		glutMotionFunc(motion);

		glutIdleFunc(display);

		glEnable( GL_DEPTH_TEST );
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );
		glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);

		// Window
		osg::GLUTWindowPtr gwin;
//.........这里部分代码省略.........
开发者ID:tl3shi,项目名称:kcbp_cgal_cuda,代码行数:101,代码来源:tangleibench.cpp


示例16: main

int main( int argc, char *argv[] )
{
	// parse command line options
	parsecommandline( argc, argv );


	// OSG init
	osg::osgLog().setLogLevel(osg::LOG_WARNING);
	osg::osgInit(argc, argv);

	// disable display lists
	osg::FieldContainerPtr pProto= osg::Geometry::getClassType().getPrototype();
	osg::GeometryPtr pGeoProto = osg::GeometryPtr::dcast(pProto);
    if ( pGeoProto != osg::NullFC )
        pGeoProto->setDlistCache(false);

	// create the graph
	osg::NodePtr node;

	// root
	root = osg::Node::create();
	beginEditCP(root);
	root->setCore( osg::Group::create() );

	// beacon for camera and light
	osg::NodePtr beacon;
	beacon = osg::Node::create();
	beginEditCP(beacon);
	beacon->setCore( osg::Group::create() );
	endEditCP(beacon);

	// light
	light_node = osg::Node::create();
	osg::DirectionalLightPtr light = osg::DirectionalLight::create();
	beginEditCP( light_node );
	light_node->setCore( light );
	endEditCP( light_node );
	root->addChild( light_node );
	beginEditCP(light);
	light->setAmbient( .3, .3, .3, 1 );
	light->setDiffuse( 1, 1, 1, 1 );
	light->setDirection(0,0,1);
	light->setBeacon( beacon );
	endEditCP(light);

	// transformation, parent of beacon
	node = osg::Node::create();
	cam_trans = osg::Transform::create();
	beginEditCP(node);
	node->setCore( cam_trans );
	node->addChild( beacon );
	endEditCP(node);
	root->addChild( node );

	// finish scene graph
	endEditCP(root);

	// Camera
	osg::PerspectiveCameraPtr cam = osg::PerspectiveCamera::create();
	cam->setBeacon( beacon );
	cam->setFov( 50 );
	cam->setNear( 0.1 );
	cam->setFar( 10000 );

	// Background
	osg::SolidBackgroundPtr background = osg::SolidBackground::create();

	// Viewport
	osg::ViewportPtr vp = osg::Viewport::create();
	vp->setCamera( cam );
	vp->setBackground( background );
	vp->setRoot( root );
	vp->setSize( 0,0, 1,1 );

	if ( with_window )
	{
		// GLUT init
		glutInitWindowSize( 400, 400 );		// before glutInit so user can
		glutInitWindowPosition( 100, 100 );	// override with comannd line args
		glutInit(&argc, argv);
		glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
		int winid = glutCreateWindow("Polygon Intersection Check Test");
		glutKeyboardFunc(key);
		glutVisibilityFunc(vis);
		glutReshapeFunc(reshape);
		glutDisplayFunc(display);
		glutMouseFunc(mouse);
		glutMotionFunc(motion);

		glutIdleFunc(display);

		glEnable( GL_DEPTH_TEST );
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );

		// Window
		osg::GLUTWindowPtr gwin;
		GLint glvp[4];
		glGetIntegerv( GL_VIEWPORT, glvp );
		gwin = osg::GLUTWindow::create();
//.........这里部分代码省略.........
开发者ID:tl3shi,项目名称:kcbp_cgal_cuda,代码行数:101,代码来源:intersect.cpp


示例17: switch

	void SimulationEngine::createChildVisualEntity(osg::NodePtr parentNode, 
		/*osg::TransformPtr trans,*/ const opal::ShapeData* data, const std::string& name, 
		const std::string& materialName)
	{
		// Create an Ogre SceneNode for the Entity.		
		osg::Matrix m;
		
		opal::Point3r offsetPos = data->offset.getPosition();
		//Ogre::Vector3 translationOffset(offsetPos[0], offsetPos[1], 
			//offsetPos[2]);
		opal::Quaternion offsetQuat = data->offset.getQuaternion();
		//Ogre::Quaternion rotationOffset;
		//rotationOffset.x = offsetQuat.x;
		//rotationOffset.y = offsetQuat.y;
		//rotationOffset.z = offsetQuat.z;
		//rotationOffset.w = offsetQuat.w;
		
		//Ogre::SceneNode* newChildNode = NULL;
		//Ogre::Entity* e = NULL;
		
		// OSG covention: we need one new node and transformation
		osg::NodePtr newChildNode; //= osg::Node::create();
		osg::TransformPtr newTransCore = osg::Transform::create();	
		
		osg::beginEditCP(newTransCore);
			m.setIdentity();
				
   			m.setTranslate(
   						(osg::Real32)offsetPos[0], 
   						(osg::Real32)offsetPos[1], 
						(osg::Real32)offsetPos[2]);
			
  			m.setRotate(
  						osg::Quaternion(
  							osg::Vec3f(
  								(osg::Real32)offsetQuat[1],
  								(osg::Real32)offsetQuat[2],
  								(osg::Real32)offsetQuat[3]), 
  							(osg::Real32)offsetQuat[0]));
  				
            newTransCore->setMatrix(m);
       	osg::endEditCP(newTransCore);
		
		switch(data->getType())
		{
			case opal::BOX_SHAPE:
			{				
				//newChildNode = parentNode->createChildSceneNode(name, 
					//translationOffset, rotationOffset);	

				// Scale the object according to the given dimensions.
				opal::Vec3r boxDim = static_cast<const opal::BoxShapeData*>
					(data)->dimensions;
					
				//Ogre::Vector3 dimensions(boxDim[0], boxDim[1], boxDim[2]);
				//newChildNode->scale(dimensions[0], dimensions[1], 
					//dimensions[2]);
					
				//create the geometry which we will assign a texture to
				newChildNode = osg::makeBox((osg::Real32)boxDim[0],
											(osg::Real32)boxDim[1],
											(osg::Real32)boxDim[2],1,1,1);

				// Create an Ogre Entity using a cube mesh.  This mesh must be 
				// stored as a box with dimensions 1x1x1.
				//e = mOgreSceneMgr->createEntity(name, "cube.mesh");
				//e->setMaterialName(materialName);

				// Keep the normals normalized even after scaling.
				//e->setNormaliseNormals(true);

				// Attach the Entity to the SceneNode.
				//newChildNode->attachObject(e);
				
				//osg::beginEditCP(parentNode, osg::Node::CoreFieldMask | osg::Node::ChildrenFieldMask);
				osg::beginEditCP(parentNode);
    				parentNode->setCore(newTransCore);
    				parentNode->addChild(newChildNode);
    			osg::endEditCP(parentNode);
				//osg::endEditCP(parentNode, osg::Node::CoreFieldMask | osg::Node::ChildrenFieldMask);				
				  				
				break;
			}

			case opal::SPHERE_SHAPE:
			{
				//newChildNode = parentNode->createChildSceneNode(name, 
					//translationOffset, rotationOffset);

				// Scale the object according to the given dimensions.
				//Ogre::Real radius = static_cast<const opal::SphereShapeData*>
					//(data)->radius;
				//newChildNode->scale(radius, radius, radius);
				
				opal::real radius = static_cast<const opal::SphereShapeData*>
					(data)->radius;
					
				newChildNode = osg::makeSphere(3, (osg::Real32)radius);

				// Create an Ogre Entity using a sphere mesh.  This mesh must be 
//.........这里部分代码省略.........
开发者ID:sub77,项目名称:hobbycode,代码行数:101,代码来源:SimulationEngine.cpp


示例18: main

// No arguments: batch convert all vt* files
// switch argument: batch convert all vt* files into one osb file with a switch
// file argument: convert only the specified file
int main (int argc, char const* argv[])
{
	vector<string> filenames;
	bool useSwitch = false;
	if (argc == 2)
	{
		if (string(argv[1]).find("switch") != string::npos)
			useSwitch = true;
		else
			filenames.push_back(string(argv[1]));
	}

	if (useSwitch || filenames.empty())
	{
		const boost::regex e(".+\\.vt[a-z]");
		directory_iterator end;
		for (directory_iterator it("./"); it != end; ++it)
		{
			string curFile = it->path().filename().string();
			if (regex_match(curFile, e))
				filenames.push_back(curFile);
		}
	}

	OSG::osgInit(0, NULL);

	vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
	OSG::NodePtr switchNode = OSG::Node::create();
	OSG::SwitchPtr switchCore = OSG::Switch::create();
	beginEditCP(switchCore);
	switchCore->setChoice(0);
	endEditCP(switchCore);
	beginEditCP(switchNode);
	switchNode->setCore(switchCore);
	endEditCP(switchNode);

	for (vector<string>::const_iterator it = filenames.begin(); it != filenames.end(); ++it)
	{
		string filename(*it);
		cout << "Opening file " << filename << " ... " << endl << flush;
		string fileExt = getFileExt(filename);

		vtkXMLDataReader* reader = NULL;
		vtkGenericDataObjectReader* oldStyleReader = NULL;
		if (fileExt.find("vti") != string::npos)
		{
			reader = vtkXMLImageDataReader::New();
			vtkSmartPointer<vtkImageDataGeometryFilter> geoFilter =
			        vtkSmartPointer<vtkImageDataGeometryFilter>::New();
			geoFilter->SetInputConnection(reader->GetOutputPort());
			mapper->SetInputConnection(geoFilter->GetOutputPort());
		}
		if (fileExt.find("vtr") != string::npos)
		{
			reader = vtkXMLRectilinearGridReader::New();
			vtkSmartPointer<vtkGeometryFilter> geoFilter =
			        vtkSmartPointer<vtkGeometryFilter>::New();
			geoFilter->SetInputConnection(reader->GetOutputPort());
			mapper->SetInputConnection(geoFilter->GetOutputPort());
		}
		else if (fileExt.find("vts") != string::npos)
		{
			reader = vtkXMLStructuredGridReader::New();
			vtkSmartPointer<vtkGeometryFilter> geoFilter =
			        vtkSmartPointer<vtkGeometryFilter>::New();
			geoFilter->SetInputConnection(reader->GetOutputPort());
			mapper->SetInputConnection(geoFilter->GetOutputPort());
		}
		else if (fileExt.find("vtp") != string::npos)
		{
			reader = vtkXMLPolyDataReader::New();
			mapper->SetInputConnection(reader->GetOutputPort());
		}
		else if (fileExt.find("vtu") != string::npos)
		{
			reader = vtkXMLUnstructuredGridReader::New();
			vtkSmartPointer<vtkGeometryFilter> geoFilter =
			        vtkSmartPointer<vtkGeometryFilter>::New();
			geoFilter->SetInputConnection(reader->GetOutputPort());
			mapper->SetInputConnection(geoFilter->GetOutputPort());
		}
		else if (fileExt.find("vtk") != string::npos)
		{
			oldStyleReader = vtkGenericDataObjectReader::New();
			oldStyleReader->SetFileName(filename.c_str());
			oldStyleReader->Update();
			if(oldStyleReader->IsFilePolyData())
				mapper->SetInputConnection(oldStyleReader->GetOutputPort());
			else
			{
				vtkSmartPointer<vtkGeometryFilter> geoFilter =
				        vtkSmartPointer<vtkGeometryFilter>::New();
				geoFilter->SetInputConnection(oldStyleReader->GetOutputPort());
				mapper->SetInputConnection(geoFilter->GetOutputPort());
			}
		}
		else
//.........这里部分代码省略.........
开发者ID:MichaelRink,项目名称:ogs_ufz,代码行数:101,代码来源:ConvertVtkToOsg.cpp


示例19: init

CameraPtr Camera::init()
{
   // Create a transform to contain the location and orientation of the camera.
   mTransform = OSG::Transform::create();

   OSG::NodePtr beacon = OSG::Node::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor be(beacon, OSG::Node::CoreFieldMask);
#endif
   beacon->setCore(mTransform);

   mLeftTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor lte(mLeftTexture);
   mLeftTexture->setEnvMode(GL_MODULATE);
#else
   mLeftTexEnv = OSG::TextureEnvChunk::create();
   mLeftTexEnv->setEnvMode(GL_MODULATE);
#endif

   mRightTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor rte(mRightTexture);
   mRightTexture->setEnvMode(GL_MODULATE);
#else
   mRightTexEnv = OSG::TextureEnvChunk::create();
   mRightTexEnv->setEnvMode(GL_MODULATE);
#endif

   mCurrentTexture = mLeftTexture;
#if OSG_MAJOR_VERSION >= 2
   mCurrentTexEnv = mLeftTexEnv;
#endif

   // setup camera
   mCamera = OSG::PerspectiveCamera::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor ce(mCamera);
#endif
   mCamera->setFov(
#if OSG_MAJOR_VERSION < 2
      OSG::osgdegree2rad(60.0)
#else
      OSG::osgDegree2Rad(60.0)
#endif
   );
   mCamera->setNear(0.01);
   mCamera->setFar(10000);
   mCamera->setBeacon(beacon);

   mLeftImage = OSG::Image::create();
   mRightImage = OSG::Image::create();

   OSG::ImagePtr img;

   // Set up FBO textures.
   img = mLeftImage;
   mLeftTexture->setMinFilter(GL_LINEAR);
   mLeftTexture->setMagFilter(GL_LINEAR);
   mLeftTexture->setTarget(GL_TEXTURE_2D);
   mLeftTexture->setInternalFormat(GL_RGBA8);
   mLeftTexture->setImage(img);

   img = mRightImage;
   mRightTexture->setMinFilter(GL_LINEAR);
   mRightTexture->setMagFilter(GL_LINEAR);
   mRightTexture->setTarget(GL_TEXTURE_2D);
   mRightTexture->setInternalFormat(GL_RGBA8);
   mRightTexture->setImage(img);

   mCurrentImage = mLeftImage;

   return shared_from_this();
}
开发者ID:patrickhartling,项目名称:vrkit,代码行数:74,代码来源:Camera.cpp


示例20: parsecommandline

void parsecommandline( int argc, char *argv[] )
{
	/* valid option characters; last char MUST be 0 ! */
	char optionchar[] =   { 'h', 'g', 'x', 'v', 'n', 'a', 'w', 'd', 'A',
							'T', 'f', 'W', 'c',  'r', 'p', 0 };
	int musthaveparam[] = {  0 ,  1,   1,   1,   2,   1,   0,   2,   1,
							 0,   1,   0,   0,   1, 0, 0 };
	int nopts;
	int mhp[256];
	int isopt[256];
	int optchar;


	nopts = strlen(optionchar);
	if ( nopts > 50 )
	{
		fprintf(stderr, "\n\nparsecommandline: the option-chars string "
				"seems to be\nVERY long (%d bytes) !\n\n", nopts );
		exit(-1);
	}

	fill_n( isopt, 256, 0 );
	fill_n( mhp, 256, 0 );
	for ( int i = 0; i < nopts; i ++ )
	{
		if ( isopt[static_cast<int>(optionchar[i])] )
		{
			fprintf(stderr, "\n\nparsecommandline: Bug: option character '%c'"
					" is specified twice in the\n"
				   "option character array !\n\n", optionchar[i] );
			exit(-1);
		}
		isopt[ static_cast<int>(optionchar[i]) ] = 1;
		mhp[ static_cast<int>(optionchar[i])] = musthaveparam[i];
	}

	++argv; --argc;
	while ( argc > 0 )
	{
		if ( argv[0][0] == '-' )
		{
			optchar = argv[0][1];

			if ( ! isopt[optchar] )
			{
				fprintf(stderr, "\nIs not a valid command line option\n");
				commandlineerror( argv[0], NULL );
			}
			for ( int i = 0; i < mhp[optchar]; i ++ )
				if ( ! argv[1+i] || argv[1+i][0] == '-' )
				{
					fprintf(stderr, "\nCommand line option -%c must "
							"have %d parameter(s)\n",
							argv[0][1], mhp[optchar] );
					commandlineerror( argv[0], NULL );
					argv += 1 + i;
					argc -= 1 + i;
					continue;
				}

			switch ( optchar )
			{
				case 'h': commandlineerror( NULL, NULL);  break;

				case 'w': With_window = true; break;
				case 'T': No_timing = true; break;
				case 'W': White_background = true; break;
				case 'c': All_collisions = true; break;

				case 'x': Complexity = atoi( argv[1] ); break;
				case 'a': Rot_vel = atof( argv[1] ); break;

				case 'n': Ndistances = atoi( argv[1] );
						  Nrotations = atoi( argv[2] );
						  break;

				case 'd': Dist_1 = atof( argv[1] );
						  Dist_2 = atof( argv[2] );
						  break;


				case 'v': for ( unsigned int i = 0; i < strlen(argv[1]); i ++ )
							  switch ( argv[1][i] )
							  {
								  case 'v': col_verbose = true;
											break;
								  case 'b': verbose |= VERBOSE_PRINT;
											break;
								  case 'h': col_verboseShowHulls = true;
											break;
								  default : commandlineerror(argv[0],argv[1]);
							  }
						  break;

				case 'g': if ( ! strcmp(argv[1],"pl") )
							  geom_type = OBJ_PLANES;
						  else
						  if ( ! strcmp(argv[1],"sh")  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osg::NodeRecPtr类代码示例发布时间:2022-05-31
下一篇:
C++ osg::Node类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap