| 1 | #include "osg/TexGenNode" |
|---|
| 2 | |
|---|
| 3 | #include "osgDB/Registry" |
|---|
| 4 | #include "osgDB/Input" |
|---|
| 5 | #include "osgDB/Output" |
|---|
| 6 | |
|---|
| 7 | using namespace osg; |
|---|
| 8 | using namespace osgDB; |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | bool TexGenNode_readLocalData(Object& obj, Input& fr); |
|---|
| 12 | bool TexGenNode_writeLocalData(const Object& obj, Output& fw); |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | REGISTER_DOTOSGWRAPPER(TexGenNode) |
|---|
| 16 | ( |
|---|
| 17 | new osg::TexGenNode, |
|---|
| 18 | "TexGenNode", |
|---|
| 19 | "Object Node TexGenNode Group", |
|---|
| 20 | &TexGenNode_readLocalData, |
|---|
| 21 | &TexGenNode_writeLocalData |
|---|
| 22 | ); |
|---|
| 23 | |
|---|
| 24 | bool TexGenNode_readLocalData(Object& obj, Input& fr) |
|---|
| 25 | { |
|---|
| 26 | bool iteratorAdvanced = false; |
|---|
| 27 | |
|---|
| 28 | TexGenNode& texGenNode = static_cast<TexGenNode&>(obj); |
|---|
| 29 | |
|---|
| 30 | unsigned int textureUnit = 0; |
|---|
| 31 | if (fr[0].matchWord("TextureUnit") && fr[1].getUInt(textureUnit)) |
|---|
| 32 | { |
|---|
| 33 | |
|---|
| 34 | texGenNode.setTextureUnit(textureUnit); |
|---|
| 35 | |
|---|
| 36 | fr+=2; |
|---|
| 37 | iteratorAdvanced = true; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | osg::ref_ptr<StateAttribute> sa=0; |
|---|
| 42 | while((sa=fr.readStateAttribute())!=0) |
|---|
| 43 | { |
|---|
| 44 | TexGen* texgen = dynamic_cast<TexGen*>(sa.get()); |
|---|
| 45 | if (texgen) texGenNode.setTexGen(texgen); |
|---|
| 46 | iteratorAdvanced = true; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | return iteratorAdvanced; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | bool TexGenNode_writeLocalData(const Object& obj, Output& fw) |
|---|
| 54 | { |
|---|
| 55 | const TexGenNode& texGenNode = static_cast<const TexGenNode&>(obj); |
|---|
| 56 | |
|---|
| 57 | fw.indent()<<"TextureUnit "<<texGenNode.getTextureUnit()<<std::endl; |
|---|
| 58 | |
|---|
| 59 | if (texGenNode.getTexGen()) |
|---|
| 60 | { |
|---|
| 61 | fw.writeObject(*texGenNode.getTexGen()); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | return true; |
|---|
| 65 | } |
|---|