|
Revision 13041, 2.7 kB
(checked in by robert, 14 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 "Exception.h" |
|---|
| 16 | #include "Node.h" |
|---|
| 17 | #include "Geode.h" |
|---|
| 18 | #include "Geometry.h" |
|---|
| 19 | |
|---|
| 20 | #include <osg/Node> |
|---|
| 21 | #include <osg/Geometry> |
|---|
| 22 | |
|---|
| 23 | using namespace ive; |
|---|
| 24 | |
|---|
| 25 | void Geode::write(DataOutputStream* out){ |
|---|
| 26 | |
|---|
| 27 | out->writeInt(IVEGEODE); |
|---|
| 28 | |
|---|
| 29 | osg::Node* node = dynamic_cast<osg::Node*>(this); |
|---|
| 30 | if(node){ |
|---|
| 31 | ((ive::Node*)(node))->write(out); |
|---|
| 32 | } |
|---|
| 33 | else |
|---|
| 34 | out_THROW_EXCEPTION("Geode::write(): Could not cast this osg::Geode to an osg::Node."); |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | out->writeInt(getNumDrawables()); |
|---|
| 41 | |
|---|
| 42 | for(unsigned int i=0;i<getNumDrawables();i++){ |
|---|
| 43 | osg::Drawable* drawable = getDrawable(i); |
|---|
| 44 | #if 0 |
|---|
| 45 | if(dynamic_cast<osg::Geometry*>(drawable)) |
|---|
| 46 | ((ive::Geometry*)(drawable))->write(out); |
|---|
| 47 | else{ |
|---|
| 48 | in_THROW_EXCEPTION("Unknown drawable in Geode::write()"); |
|---|
| 49 | } |
|---|
| 50 | #else |
|---|
| 51 | out->writeDrawable(drawable); |
|---|
| 52 | #endif |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | void Geode::read(DataInputStream* in){ |
|---|
| 57 | |
|---|
| 58 | int id = in->peekInt(); |
|---|
| 59 | if(id == IVEGEODE){ |
|---|
| 60 | |
|---|
| 61 | id = in->readInt(); |
|---|
| 62 | |
|---|
| 63 | osg::Node* node = dynamic_cast<osg::Node*>(this); |
|---|
| 64 | if(node){ |
|---|
| 65 | ((ive::Node*)(node))->read(in); |
|---|
| 66 | } |
|---|
| 67 | else |
|---|
| 68 | in_THROW_EXCEPTION("Geode::read(): Could not cast this osg::Geode to an osg::Node."); |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | int size = in->readInt(); |
|---|
| 73 | |
|---|
| 74 | for(int i = 0; i<size; i++){ |
|---|
| 75 | #if 0 |
|---|
| 76 | int id = in->peekInt(); |
|---|
| 77 | osg::Drawable* drawable; |
|---|
| 78 | if(id == IVEGEOMETRY){ |
|---|
| 79 | drawable = new osg::Geometry(); |
|---|
| 80 | ((Geometry*)(drawable))->read(in); |
|---|
| 81 | addDrawable(drawable); |
|---|
| 82 | } |
|---|
| 83 | else |
|---|
| 84 | in_THROW_EXCEPTION("Unknown drawable identification in Geode::read()"); |
|---|
| 85 | #else |
|---|
| 86 | addDrawable(in->readDrawable()); |
|---|
| 87 | #endif |
|---|
| 88 | } |
|---|
| 89 | } |
|---|
| 90 | else{ |
|---|
| 91 | in_THROW_EXCEPTION("Geode::read(): Expected Geode identification."); |
|---|
| 92 | } |
|---|
| 93 | } |
|---|