| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #ifndef LWO2_H |
|---|
| 27 | #define LWO2_H 1 |
|---|
| 28 | |
|---|
| 29 | #include <vector> |
|---|
| 30 | #include <map> |
|---|
| 31 | #include <string> |
|---|
| 32 | |
|---|
| 33 | #include <osg/Referenced> |
|---|
| 34 | #include <osg/Vec2> |
|---|
| 35 | #include <osg/Vec3> |
|---|
| 36 | #include <osg/Geometry> |
|---|
| 37 | #include <osg/Group> |
|---|
| 38 | #include <osg/Notify> |
|---|
| 39 | |
|---|
| 40 | #include <osgDB/fstream> |
|---|
| 41 | |
|---|
| 42 | using namespace osg; |
|---|
| 43 | using namespace std; |
|---|
| 44 | |
|---|
| 45 | class Lwo2Layer; |
|---|
| 46 | struct Lwo2Surface; |
|---|
| 47 | struct Lwo2PolygonMapping; |
|---|
| 48 | |
|---|
| 49 | typedef vector< string >::iterator IteratorString; |
|---|
| 50 | typedef map< int, Lwo2Layer* >::iterator IteratorLayers; |
|---|
| 51 | typedef map< string, Lwo2Surface* >::iterator IteratorSurfaces; |
|---|
| 52 | typedef pair< const short, Lwo2PolygonMapping > PairVMAD; |
|---|
| 53 | |
|---|
| 54 | class Lwo2 |
|---|
| 55 | { |
|---|
| 56 | public: |
|---|
| 57 | Lwo2(); |
|---|
| 58 | ~Lwo2(); |
|---|
| 59 | bool ReadFile( const string& filename ); |
|---|
| 60 | bool GenerateGroup( Group& ); |
|---|
| 61 | |
|---|
| 62 | private: |
|---|
| 63 | map< int, Lwo2Layer* > _layers; |
|---|
| 64 | map< string, Lwo2Surface* > _surfaces; |
|---|
| 65 | Lwo2Layer* _current_layer; |
|---|
| 66 | vector< string > _tags; |
|---|
| 67 | vector< string > _images; |
|---|
| 68 | osgDB::ifstream _fin; |
|---|
| 69 | |
|---|
| 70 | unsigned char _read_char(); |
|---|
| 71 | unsigned short _read_short(); |
|---|
| 72 | unsigned int _read_uint(); |
|---|
| 73 | float _read_float(); |
|---|
| 74 | string& _read_string(string&); |
|---|
| 75 | |
|---|
| 76 | bool _successfully_read; |
|---|
| 77 | |
|---|
| 78 | void _print_tag(unsigned int, unsigned int); |
|---|
| 79 | void _print_type(unsigned int); |
|---|
| 80 | |
|---|
| 81 | void _read_tag_strings(unsigned long); |
|---|
| 82 | void _read_layer(unsigned long); |
|---|
| 83 | void _read_points(unsigned long); |
|---|
| 84 | void _read_vertex_mapping(unsigned long); |
|---|
| 85 | void _read_polygons(unsigned long); |
|---|
| 86 | void _read_polygons_mapping(unsigned long); |
|---|
| 87 | void _read_polygon_tag_mapping(unsigned long); |
|---|
| 88 | void _read_image_definition(unsigned long); |
|---|
| 89 | void _read_surface(unsigned long); |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | void _generate_statesets_from_surfaces(); |
|---|
| 93 | }; |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | unsigned long make_id(const char* tag); |
|---|
| 99 | |
|---|
| 100 | const unsigned long tag_FORM = make_id("FORM"); |
|---|
| 101 | const unsigned long tag_LWO2 = make_id("LWO2"); |
|---|
| 102 | const unsigned long tag_LAYR = make_id("LAYR"); |
|---|
| 103 | const unsigned long tag_TAGS = make_id("TAGS"); |
|---|
| 104 | const unsigned long tag_PNTS = make_id("PNTS"); |
|---|
| 105 | const unsigned long tag_VMAP = make_id("VMAP"); |
|---|
| 106 | const unsigned long tag_VMAD = make_id("VMAD"); |
|---|
| 107 | const unsigned long tag_TXUV = make_id("TXUV"); |
|---|
| 108 | const unsigned long tag_POLS = make_id("POLS"); |
|---|
| 109 | const unsigned long tag_FACE = make_id("FACE"); |
|---|
| 110 | const unsigned long tag_PTAG = make_id("PTAG"); |
|---|
| 111 | const unsigned long tag_SURF = make_id("SURF"); |
|---|
| 112 | const unsigned long tag_CLIP = make_id("CLIP"); |
|---|
| 113 | const unsigned long tag_STIL = make_id("STIL"); |
|---|
| 114 | const unsigned long tag_BLOK = make_id("BLOK"); |
|---|
| 115 | const unsigned long tag_IMAP = make_id("IMAP"); |
|---|
| 116 | const unsigned long tag_TMAP = make_id("TMAP"); |
|---|
| 117 | const unsigned long tag_IMAG = make_id("IMAG"); |
|---|
| 118 | const unsigned long tag_COLR = make_id("COLR"); |
|---|
| 119 | |
|---|
| 120 | #endif |
|---|