| 1 | #include <osg/ClearNode> |
|---|
| 2 | #include <osg/io_utils> |
|---|
| 3 | |
|---|
| 4 | #include <osgDB/Registry> |
|---|
| 5 | #include <osgDB/Input> |
|---|
| 6 | #include <osgDB/Output> |
|---|
| 7 | |
|---|
| 8 | using namespace osg; |
|---|
| 9 | using namespace osgDB; |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | bool ClearNode_readLocalData(Object& obj, Input& fr); |
|---|
| 13 | bool ClearNode_writeLocalData(const Object& obj, Output& fw); |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | REGISTER_DOTOSGWRAPPER(EarthSky) |
|---|
| 18 | ( |
|---|
| 19 | new osg::ClearNode, |
|---|
| 20 | "EarthSky", |
|---|
| 21 | "Object Node EarthSky Group", |
|---|
| 22 | &ClearNode_readLocalData, |
|---|
| 23 | &ClearNode_writeLocalData |
|---|
| 24 | ); |
|---|
| 25 | |
|---|
| 26 | REGISTER_DOTOSGWRAPPER(ClearNode) |
|---|
| 27 | ( |
|---|
| 28 | new osg::ClearNode, |
|---|
| 29 | "ClearNode", |
|---|
| 30 | "Object Node ClearNode Group", |
|---|
| 31 | &ClearNode_readLocalData, |
|---|
| 32 | &ClearNode_writeLocalData |
|---|
| 33 | ); |
|---|
| 34 | |
|---|
| 35 | bool ClearNode_readLocalData(Object& obj, Input& fr) |
|---|
| 36 | { |
|---|
| 37 | bool iteratorAdvanced = false; |
|---|
| 38 | |
|---|
| 39 | ClearNode& es = static_cast<ClearNode&>(obj); |
|---|
| 40 | |
|---|
| 41 | if (fr.matchSequence("requiresClear")) |
|---|
| 42 | { |
|---|
| 43 | if (fr[1].matchWord("TRUE")) |
|---|
| 44 | { |
|---|
| 45 | es.setRequiresClear(true); |
|---|
| 46 | iteratorAdvanced = true; |
|---|
| 47 | fr+=2; |
|---|
| 48 | } |
|---|
| 49 | else if (fr[1].matchWord("FALSE")) |
|---|
| 50 | { |
|---|
| 51 | es.setRequiresClear(false); |
|---|
| 52 | iteratorAdvanced = true; |
|---|
| 53 | fr+=2; |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | osg::Vec4 vec4(0.0f,0.0f,0.0f,1.0f); |
|---|
| 58 | |
|---|
| 59 | if (fr[0].matchWord("clearColor") && |
|---|
| 60 | fr[1].getFloat(vec4[0]) && |
|---|
| 61 | fr[2].getFloat(vec4[1]) && |
|---|
| 62 | fr[3].getFloat(vec4[2]) && |
|---|
| 63 | fr[4].getFloat(vec4[3])) |
|---|
| 64 | { |
|---|
| 65 | es.setClearColor(vec4); |
|---|
| 66 | fr+=5; |
|---|
| 67 | iteratorAdvanced = true; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | if (fr[0].matchWord("clearMask")) |
|---|
| 71 | { |
|---|
| 72 | if (fr[1].isUInt()) |
|---|
| 73 | { |
|---|
| 74 | unsigned int value=0; |
|---|
| 75 | fr[1].getUInt(value); |
|---|
| 76 | es.setClearMask(static_cast<GLbitfield>(value)); |
|---|
| 77 | iteratorAdvanced = true; |
|---|
| 78 | fr+=2; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | return iteratorAdvanced; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | bool ClearNode_writeLocalData(const Object& obj, Output& fw) |
|---|
| 87 | { |
|---|
| 88 | const ClearNode& es = static_cast<const ClearNode&>(obj); |
|---|
| 89 | |
|---|
| 90 | fw.indent() << "requiresClear "; |
|---|
| 91 | if (es.getRequiresClear()) |
|---|
| 92 | { |
|---|
| 93 | fw<<"TRUE"<< std::endl; |
|---|
| 94 | } |
|---|
| 95 | else |
|---|
| 96 | { |
|---|
| 97 | fw<<"FALSE"<< std::endl; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | fw.indent() << "clearColor "<<es.getClearColor()<< std::endl; |
|---|
| 101 | fw.indent() << "clearMask "<<static_cast<unsigned int>(es.getClearMask())<< std::endl; |
|---|
| 102 | |
|---|
| 103 | return true; |
|---|
| 104 | } |
|---|