Changeset 347
- Timestamp:
- 03/12/10 09:55:04 (2 years ago)
- Location:
- trunk/avango-osg
- Files:
-
- 3 edited
-
include/avango/osg/LoadFile.h (modified) (1 diff)
-
python/avango/osg/OSGNode.cpp (modified) (3 diffs)
-
src/avango/osg/LoadFile.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/avango-osg/include/avango/osg/LoadFile.h
r1 r347 71 71 SFString Filename; 72 72 73 /** 74 * Outputs the file name of the geometry as soon as it is actually loaded. 75 * You can connect to this field to get a notification when the loading of the file was done. 76 */ 77 SFString FilenameLoaded; 78 73 79 /* virtual */ void fieldHasChangedLocalSideEffect(const av::Field& field); 74 80 /* virtual */ void evaluateLocalSideEffect(); -
trunk/avango-osg/python/avango/osg/OSGNode.cpp
r1 r347 29 29 #include "OSGNode.h" 30 30 31 #include <osg/NodeVisitor> 32 #include <osg/BoundingBox> 33 #include <osg/BoundingSphere> 34 #include <osg/MatrixTransform> 35 #include <osg/Billboard> 36 37 31 38 using namespace boost::python; 32 39 using namespace av::python; … … 43 50 } 44 51 52 53 namespace { 54 class CalculateBoundingBox : public ::osg::NodeVisitor 55 { 56 public: 57 CalculateBoundingBox() : 58 NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN) 59 { 60 m_transformMatrix.makeIdentity(); 61 } 62 63 virtual ~CalculateBoundingBox() 64 { 65 } 66 67 virtual 68 void apply(::osg::Geode &geode) 69 { 70 ::osg::BoundingBox bbox; 71 for (unsigned int i = 0; i < geode.getNumDrawables(); ++i) 72 { 73 bbox.expandBy(geode.getDrawable(i)->getBound()); 74 } 75 ::osg::BoundingBox bboxTrans; 76 for (unsigned int i = 0; i < 8; ++i) 77 { 78 ::osg::Vec3 xvec = bbox.corner(i) * m_transformMatrix; 79 bboxTrans.expandBy(xvec); 80 } 81 m_boundingBox.expandBy(bboxTrans); 82 traverse(geode); 83 } 84 85 virtual 86 void apply(::osg::MatrixTransform &node) 87 { 88 m_transformMatrix *= node.getMatrix(); 89 traverse(node); 90 } 91 92 virtual 93 void apply(::osg::Billboard &node) 94 { 95 traverse(node); 96 } 97 98 ::osg::BoundingBox &getBoundBox() 99 { 100 return m_boundingBox; 101 } 102 103 protected: 104 ::osg::BoundingBox m_boundingBox; // the overall resultant bounding box 105 ::osg::Matrix m_transformMatrix; // the current transform matrix 106 }; 107 108 109 osg::BoundingBox CalcBoundingBox(av::osg::Node* node) 110 { 111 CalculateBoundingBox bbox; 112 node->getOsgNode()->accept( bbox ); 113 return bbox.getBoundBox(); 114 } 115 116 } 117 118 119 120 45 121 void init_OSGNode(void) 46 122 { … … 52 128 .def("get_absolute_transform", &av::osg::Node::getAbsoluteTransform) 53 129 ; 130 131 def("calc_bounding_box", CalcBoundingBox); 54 132 } -
trunk/avango-osg/src/avango/osg/LoadFile.cpp
r154 r347 47 47 { 48 48 AV_FC_ADD_FIELD(Filename, mFilename); 49 AV_FC_ADD_FIELD(FilenameLoaded, ""); 49 50 } 50 51 … … 119 120 // add new geometry 120 121 getOsgMatrixTransform()->addChild(mLoadedNode.get()); 122 FilenameLoaded.setValue(mFilename); 121 123 } 122 124
Note: See TracChangeset
for help on using the changeset viewer.
