| 1 | #include "osg/StateAttribute" |
|---|
| 2 | |
|---|
| 3 | #include "osgDB/Registry" |
|---|
| 4 | #include "osgDB/Input" |
|---|
| 5 | #include "osgDB/Output" |
|---|
| 6 | |
|---|
| 7 | using namespace osg; |
|---|
| 8 | using namespace osgDB; |
|---|
| 9 | using namespace std; |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | bool StateAttribute_readLocalData(Object& obj, Input& fr); |
|---|
| 13 | bool StateAttribute_writeLocalData(const Object& obj, Output& fw); |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | osg::StateAttribute* g_stateAttribute = 0; |
|---|
| 17 | REGISTER_DOTOSGWRAPPER(StateAttribute) |
|---|
| 18 | ( |
|---|
| 19 | g_stateAttribute, |
|---|
| 20 | "StateAttribute", |
|---|
| 21 | "Object StateAttribute", |
|---|
| 22 | &StateAttribute_readLocalData, |
|---|
| 23 | &StateAttribute_writeLocalData |
|---|
| 24 | ); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | bool StateAttribute_readLocalData(Object& obj, Input& fr) |
|---|
| 28 | { |
|---|
| 29 | bool iteratorAdvanced = false; |
|---|
| 30 | StateAttribute& stateAttribute = static_cast<StateAttribute&>(obj); |
|---|
| 31 | |
|---|
| 32 | static ref_ptr<StateAttribute::Callback> s_callback = new osg::StateAttribute::Callback; |
|---|
| 33 | while (fr.matchSequence("UpdateCallback {")) |
|---|
| 34 | { |
|---|
| 35 | |
|---|
| 36 | fr += 2; |
|---|
| 37 | StateAttribute::Callback* callback = dynamic_cast<StateAttribute::Callback*>(fr.readObjectOfType(*s_callback)); |
|---|
| 38 | if (callback) { |
|---|
| 39 | stateAttribute.setUpdateCallback(callback); |
|---|
| 40 | } |
|---|
| 41 | iteratorAdvanced = true; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | while (fr.matchSequence("EventCallback {")) |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | fr += 2; |
|---|
| 48 | StateAttribute::Callback* callback = dynamic_cast<StateAttribute::Callback*>(fr.readObjectOfType(*s_callback)); |
|---|
| 49 | if (callback) { |
|---|
| 50 | stateAttribute.setEventCallback(callback); |
|---|
| 51 | } |
|---|
| 52 | iteratorAdvanced = true; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | return iteratorAdvanced; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | bool StateAttribute_writeLocalData(const Object& obj,Output& fw) |
|---|
| 59 | { |
|---|
| 60 | const StateAttribute& stateAttribute = static_cast<const StateAttribute&>(obj); |
|---|
| 61 | |
|---|
| 62 | if (stateAttribute.getUpdateCallback()) |
|---|
| 63 | { |
|---|
| 64 | fw.indent() << "UpdateCallback {" << std::endl; |
|---|
| 65 | fw.moveIn(); |
|---|
| 66 | fw.writeObject(*stateAttribute.getUpdateCallback()); |
|---|
| 67 | fw.moveOut(); |
|---|
| 68 | fw.indent() << "}" << std::endl; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | if (stateAttribute.getEventCallback()) |
|---|
| 72 | { |
|---|
| 73 | fw.indent() << "EventCallback {" << std::endl; |
|---|
| 74 | fw.moveIn(); |
|---|
| 75 | fw.writeObject(*stateAttribute.getEventCallback()); |
|---|
| 76 | fw.moveOut(); |
|---|
| 77 | fw.indent() << "}" << std::endl; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | return true; |
|---|
| 81 | } |
|---|