本文整理汇总了C++中osg::NodePtr类的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr类的具体用法?C++ NodePtr怎么用?C++ NodePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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
///////////////////////
//.........这里部分代码省略.........
示例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
}
示例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;
//.........这里部分代码省略.........