|
Revision 13041, 3.0 kB
(checked in by robert, 15 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Drawable.h" |
|---|
| 16 | #include "Exception.h" |
|---|
| 17 | #include "ShapeDrawable.h" |
|---|
| 18 | #include "Object.h" |
|---|
| 19 | |
|---|
| 20 | using namespace ive; |
|---|
| 21 | |
|---|
| 22 | void ShapeDrawable::write(DataOutputStream* out) |
|---|
| 23 | { |
|---|
| 24 | |
|---|
| 25 | out->writeInt(IVESHAPEDRAWABLE); |
|---|
| 26 | |
|---|
| 27 | if ( out->getVersion() >= VERSION_0004 ) |
|---|
| 28 | { |
|---|
| 29 | |
|---|
| 30 | osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(this); |
|---|
| 31 | if(drawable){ |
|---|
| 32 | ((ive::Drawable*)(drawable))->write(out); |
|---|
| 33 | } |
|---|
| 34 | else |
|---|
| 35 | out_THROW_EXCEPTION("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object."); |
|---|
| 36 | |
|---|
| 37 | } |
|---|
| 38 | else |
|---|
| 39 | { |
|---|
| 40 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 41 | if(obj){ |
|---|
| 42 | ((ive::Object*)(obj))->write(out); |
|---|
| 43 | } |
|---|
| 44 | else |
|---|
| 45 | out_THROW_EXCEPTION("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object."); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | out->writeVec4(getColor()); |
|---|
| 50 | |
|---|
| 51 | if (getShape()) |
|---|
| 52 | { |
|---|
| 53 | out->writeBool(true); |
|---|
| 54 | out->writeShape(getShape()); |
|---|
| 55 | } |
|---|
| 56 | else |
|---|
| 57 | { |
|---|
| 58 | out->writeBool(false); |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | void ShapeDrawable::read(DataInputStream* in) |
|---|
| 63 | { |
|---|
| 64 | |
|---|
| 65 | int id = in->peekInt(); |
|---|
| 66 | if(id == IVESHAPEDRAWABLE) |
|---|
| 67 | { |
|---|
| 68 | |
|---|
| 69 | id = in->readInt(); |
|---|
| 70 | |
|---|
| 71 | if ( in->getVersion() >= VERSION_0004 ) |
|---|
| 72 | { |
|---|
| 73 | |
|---|
| 74 | osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(this); |
|---|
| 75 | if(drawable){ |
|---|
| 76 | ((ive::Drawable*)(drawable))->read(in); |
|---|
| 77 | } |
|---|
| 78 | else |
|---|
| 79 | in_THROW_EXCEPTION("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object."); |
|---|
| 80 | } |
|---|
| 81 | else |
|---|
| 82 | { |
|---|
| 83 | |
|---|
| 84 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 85 | if(obj){ |
|---|
| 86 | ((ive::Object*)(obj))->read(in); |
|---|
| 87 | } |
|---|
| 88 | else |
|---|
| 89 | in_THROW_EXCEPTION("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object."); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | setColor(in->readVec4()); |
|---|
| 94 | |
|---|
| 95 | if (in->readBool()) |
|---|
| 96 | { |
|---|
| 97 | setShape(in->readShape()); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | } |
|---|
| 101 | else |
|---|
| 102 | { |
|---|
| 103 | in_THROW_EXCEPTION("ShapeDrawable::read(): Expected ShapeDrawable identification."); |
|---|
| 104 | } |
|---|
| 105 | } |
|---|