| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Exception.h" |
|---|
| 16 | #include "TexEnvCombine.h" |
|---|
| 17 | #include "Object.h" |
|---|
| 18 | |
|---|
| 19 | using namespace ive; |
|---|
| 20 | |
|---|
| 21 | void TexEnvCombine::write(DataOutputStream* out){ |
|---|
| 22 | |
|---|
| 23 | out->writeInt(IVETEXENVCOMBINE); |
|---|
| 24 | |
|---|
| 25 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 26 | if(obj){ |
|---|
| 27 | ((ive::Object*)(obj))->write(out); |
|---|
| 28 | } |
|---|
| 29 | else |
|---|
| 30 | out_THROW_EXCEPTION("TexEnvCombine::write(): Could not cast this osg::TexEnvCombine to an osg::Object."); |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | out->writeInt(getCombine_RGB()); |
|---|
| 35 | out->writeInt(getCombine_Alpha()); |
|---|
| 36 | |
|---|
| 37 | out->writeInt(getSource0_RGB()); |
|---|
| 38 | out->writeInt(getSource1_RGB()); |
|---|
| 39 | out->writeInt(getSource2_RGB()); |
|---|
| 40 | out->writeInt(getSource0_Alpha()); |
|---|
| 41 | out->writeInt(getSource1_Alpha()); |
|---|
| 42 | out->writeInt(getSource2_Alpha()); |
|---|
| 43 | |
|---|
| 44 | out->writeInt(getOperand0_RGB()); |
|---|
| 45 | out->writeInt(getOperand1_RGB()); |
|---|
| 46 | out->writeInt(getOperand2_RGB()); |
|---|
| 47 | out->writeInt(getOperand0_Alpha()); |
|---|
| 48 | out->writeInt(getOperand1_Alpha()); |
|---|
| 49 | out->writeInt(getOperand2_Alpha()); |
|---|
| 50 | |
|---|
| 51 | out->writeFloat(getScale_RGB()); |
|---|
| 52 | out->writeFloat(getScale_Alpha()); |
|---|
| 53 | out->writeVec4(getConstantColor()); |
|---|
| 54 | |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | void TexEnvCombine::read(DataInputStream* in){ |
|---|
| 58 | |
|---|
| 59 | int id = in->peekInt(); |
|---|
| 60 | if(id == IVETEXENVCOMBINE){ |
|---|
| 61 | |
|---|
| 62 | id = in->readInt(); |
|---|
| 63 | |
|---|
| 64 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 65 | if(obj){ |
|---|
| 66 | ((ive::Object*)(obj))->read(in); |
|---|
| 67 | } |
|---|
| 68 | else |
|---|
| 69 | in_THROW_EXCEPTION("TexEnvCombine::read(): Could not cast this osg::TexEnvCombine to an osg::Object."); |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | setCombine_RGB((GLint)in->readInt()); |
|---|
| 74 | setCombine_Alpha((GLint)in->readInt()); |
|---|
| 75 | |
|---|
| 76 | setSource0_RGB((GLint)in->readInt()); |
|---|
| 77 | setSource1_RGB((GLint)in->readInt()); |
|---|
| 78 | setSource2_RGB((GLint)in->readInt()); |
|---|
| 79 | setSource0_Alpha((GLint)in->readInt()); |
|---|
| 80 | setSource1_Alpha((GLint)in->readInt()); |
|---|
| 81 | setSource2_Alpha((GLint)in->readInt()); |
|---|
| 82 | |
|---|
| 83 | setOperand0_RGB((GLint)in->readInt()); |
|---|
| 84 | setOperand1_RGB((GLint)in->readInt()); |
|---|
| 85 | setOperand2_RGB((GLint)in->readInt()); |
|---|
| 86 | setOperand0_Alpha((GLint)in->readInt()); |
|---|
| 87 | setOperand1_Alpha((GLint)in->readInt()); |
|---|
| 88 | setOperand2_Alpha((GLint)in->readInt()); |
|---|
| 89 | |
|---|
| 90 | setScale_RGB(in->readFloat()); |
|---|
| 91 | setScale_Alpha(in->readFloat()); |
|---|
| 92 | setConstantColor(in->readVec4()); |
|---|
| 93 | |
|---|
| 94 | } |
|---|
| 95 | else{ |
|---|
| 96 | in_THROW_EXCEPTION("TexEnvCombine::read(): Expected TexEnvCombine identification."); |
|---|
| 97 | } |
|---|
| 98 | } |
|---|