|
1 #include <osg/Node>
2 #include <osgDB/ReadFile>
3 #include <iostream>
4
5 using namespace std;
6
7 class InfoVisitor: public osg::NodeVisitor
8 {
9 public:
10 InfoVisitor()
11 sg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0)
12 {}
13
14 virtual void apply(osg::Node& node)
15 {
16 for(int i = 0; i < _indent; i++) cout << " ";
17 cout << "[" << _indent+1 << "]"<< node.libraryName()
18 << "::" << node.className() << endl;
19
20 _indent++;
21 traverse(node);
22 _indent--;
27 }
28
29 virtual void apply(osg::Geode& node)
30 {
31 for(int i = 0; i < _indent; i++) cout << " ";
32 cout << "[" << _indent+1 << "] "<< node.libraryName()
33 << "::" << node.className() << endl;
34
35
36
37 for(unsigned int n = 0; n < node.getNumDrawables(); n++)
38 {
39 osg:rawable* draw = node.getDrawable(n);
40 if(!draw)
41 continue;
42 for(int i = 0; i < _indent; i++) cout << " ";
43 cout << "[" << _indent << "]" << draw->libraryName() << "::"
44 << draw->className() << endl;
45 }
_indent++;
47 traverse(node);
48 _indent--;
53 }
54 private:
55 int _indent;
56 };
57
58 int main(int argc, char** argv)
59 {
60 osg::ArgumentParser parser(&argc, argv);
61 osg::Node* root = osgDB::readNodeFiles(parser);
62
63 if(!root)
64 {
65 root = osgDB::readNodeFile("avatar.osg");
66 }
67
68 InfoVisitor infoVisitor;
69 if(root)
70 {
71 root->accept(infoVisitor);
72 }
73
74 system("pause");
75 return 0;
76 }
请问执行21行的traverse(node)函数后,是执行22行代码,还是跳到29行 virtual void apply(osg::Geode& node)?执行47行代码后,48行代码会执行吗?望各位大神帮助! |
|