| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include <osg/OcclusionQueryNode> |
|---|
| 16 | |
|---|
| 17 | #include <iostream> |
|---|
| 18 | #include <sstream> |
|---|
| 19 | #include <string> |
|---|
| 20 | |
|---|
| 21 | #include <osg/io_utils> |
|---|
| 22 | |
|---|
| 23 | #include <osgDB/Registry> |
|---|
| 24 | #include <osgDB/Input> |
|---|
| 25 | #include <osgDB/Output> |
|---|
| 26 | #include <osgDB/ParameterOutput> |
|---|
| 27 | |
|---|
| 28 | bool OQN_readLocalData( osg::Object &obj, osgDB::Input &fr ); |
|---|
| 29 | bool OQN_writeLocalData( const osg::Object &obj, osgDB::Output &fw ); |
|---|
| 30 | |
|---|
| 31 | REGISTER_DOTOSGWRAPPER(OcclusionQueryNode) |
|---|
| 32 | ( |
|---|
| 33 | new osg::OcclusionQueryNode, |
|---|
| 34 | "OcclusionQueryNode", |
|---|
| 35 | "Object Node OcclusionQueryNode Group", |
|---|
| 36 | OQN_readLocalData, |
|---|
| 37 | OQN_writeLocalData |
|---|
| 38 | ); |
|---|
| 39 | |
|---|
| 40 | bool OQN_readLocalData( osg::Object &obj, osgDB::Input &fr ) |
|---|
| 41 | { |
|---|
| 42 | osg::OcclusionQueryNode& oqn = static_cast<osg::OcclusionQueryNode&>( obj ); |
|---|
| 43 | bool advanced( false ); |
|---|
| 44 | int param; |
|---|
| 45 | if (fr[0].matchWord( "QueriesEnabled" )) |
|---|
| 46 | { |
|---|
| 47 | bool enable( fr[1].getStr() == std::string("TRUE") ); |
|---|
| 48 | oqn.setQueriesEnabled( enable ); |
|---|
| 49 | fr+=2; |
|---|
| 50 | advanced = true; |
|---|
| 51 | } |
|---|
| 52 | if (fr.matchSequence( "VisibilityThreshold %i" )) |
|---|
| 53 | { |
|---|
| 54 | fr[1].getInt( param ); |
|---|
| 55 | oqn.setVisibilityThreshold( param ); |
|---|
| 56 | fr+=2; |
|---|
| 57 | advanced = true; |
|---|
| 58 | } |
|---|
| 59 | if (fr.matchSequence( "QueryFrameCount %i" )) |
|---|
| 60 | { |
|---|
| 61 | fr[1].getInt( param ); |
|---|
| 62 | oqn.setQueryFrameCount( param ); |
|---|
| 63 | fr+=2; |
|---|
| 64 | advanced = true; |
|---|
| 65 | } |
|---|
| 66 | if (fr[0].matchWord( "DebugDisplay" )) |
|---|
| 67 | { |
|---|
| 68 | bool enable( fr[1].getStr() == std::string("TRUE") ); |
|---|
| 69 | oqn.setDebugDisplay( enable ); |
|---|
| 70 | fr+=2; |
|---|
| 71 | advanced = true; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | return advanced; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | bool OQN_writeLocalData( const osg::Object &obj, osgDB::Output &fw ) |
|---|
| 78 | { |
|---|
| 79 | const osg::OcclusionQueryNode& oqn = static_cast<const osg::OcclusionQueryNode&>( obj ); |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | fw.indent() << "QueriesEnabled " << |
|---|
| 84 | (oqn.getQueriesEnabled() ? "TRUE" : "FALSE") |
|---|
| 85 | << std::endl; |
|---|
| 86 | fw.indent() << "VisibilityThreshold " << |
|---|
| 87 | oqn.getVisibilityThreshold() << std::endl; |
|---|
| 88 | fw.indent() << "QueryFrameCount " << |
|---|
| 89 | oqn.getQueryFrameCount() << std::endl; |
|---|
| 90 | fw.indent() << "DebugDisplay " << |
|---|
| 91 | (oqn.getDebugDisplay() ? "TRUE" : "FALSE") |
|---|
| 92 | << std::endl; |
|---|
| 93 | |
|---|
| 94 | return true; |
|---|
| 95 | } |
|---|