Revision 339,
1.6 KB
checked in by bittner, 19 years ago
(diff) |
changed mailbox naming convention, added intersectable ids
|
Rev | Line | |
---|
[162] | 1 | //#include <boost/algorithm/string.hpp>
|
---|
| 2 |
|
---|
| 3 | #include <stack>
|
---|
| 4 | #include "SceneGraph.h"
|
---|
| 5 | #include "X3dExporter.h"
|
---|
[339] | 6 | #include "Intersectable.h"
|
---|
[162] | 7 |
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | bool
|
---|
| 11 | SceneGraph::Export( const string filename )
|
---|
| 12 | {
|
---|
| 13 | if (strstr(filename.c_str(), ".x3d")) {
|
---|
| 14 | X3dExporter exporter(filename);
|
---|
| 15 | exporter.ExportScene(mRoot);
|
---|
| 16 | return true;
|
---|
| 17 | } else {
|
---|
| 18 | cerr<<"Error: Currently unsuported export format, filename "<<filename<<endl;
|
---|
| 19 |
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | return false;
|
---|
| 24 |
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | int
|
---|
[176] | 29 | SceneGraph::CollectObjects(ObjectContainer *instances)
|
---|
[162] | 30 | {
|
---|
| 31 | int number = 0;
|
---|
| 32 | stack<SceneGraphNode *> nodeStack;
|
---|
[176] | 33 |
|
---|
[162] | 34 | nodeStack.push(mRoot);
|
---|
| 35 |
|
---|
| 36 | while (!nodeStack.empty()) {
|
---|
| 37 | SceneGraphNode *node = nodeStack.top();
|
---|
| 38 | nodeStack.pop();
|
---|
| 39 |
|
---|
[176] | 40 | ObjectContainer::const_iterator mi = node->mGeometry.begin();
|
---|
[162] | 41 | for (; mi != node->mGeometry.end(); mi++)
|
---|
| 42 | instances->push_back(*mi);
|
---|
| 43 |
|
---|
| 44 | SceneGraphNodeContainer::iterator ni = node->mChildren.begin();
|
---|
| 45 | for (; ni != node->mChildren.end(); ni++) {
|
---|
| 46 | nodeStack.push(*ni);
|
---|
| 47 | number++;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | }
|
---|
| 51 | return number;
|
---|
| 52 | }
|
---|
[339] | 53 |
|
---|
| 54 |
|
---|
| 55 | int
|
---|
| 56 | SceneGraph::AssignObjectIds()
|
---|
| 57 | {
|
---|
| 58 | int id = 1;
|
---|
| 59 | stack<SceneGraphNode *> nodeStack;
|
---|
| 60 |
|
---|
| 61 | nodeStack.push(mRoot);
|
---|
| 62 |
|
---|
| 63 | while (!nodeStack.empty()) {
|
---|
| 64 | SceneGraphNode *node = nodeStack.top();
|
---|
| 65 | nodeStack.pop();
|
---|
| 66 |
|
---|
| 67 | ObjectContainer::const_iterator mi = node->mGeometry.begin();
|
---|
| 68 | for (; mi != node->mGeometry.end(); mi++)
|
---|
| 69 | (*mi)->SetId(id++);
|
---|
| 70 |
|
---|
| 71 | SceneGraphNodeContainer::iterator ni = node->mChildren.begin();
|
---|
| 72 | for (; ni != node->mChildren.end(); ni++) {
|
---|
| 73 | nodeStack.push(*ni);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | // return max id
|
---|
| 77 | return id;
|
---|
| 78 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.