| 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 LWO2LAYER_H |
|---|
| 27 | #define LWO2LAYER_H |
|---|
| 28 | |
|---|
| 29 | #include <osg/Referenced> |
|---|
| 30 | #include <osg/Vec2> |
|---|
| 31 | #include <osg/Vec3> |
|---|
| 32 | #include <osg/Notify> |
|---|
| 33 | #include <osg/Geode> |
|---|
| 34 | #include <osg/StateSet> |
|---|
| 35 | |
|---|
| 36 | #include <osgUtil/SmoothingVisitor> |
|---|
| 37 | |
|---|
| 38 | #include <vector> |
|---|
| 39 | #include <map> |
|---|
| 40 | #include <string> |
|---|
| 41 | |
|---|
| 42 | using namespace osg; |
|---|
| 43 | using namespace std; |
|---|
| 44 | |
|---|
| 45 | struct PointData |
|---|
| 46 | { |
|---|
| 47 | PointData(): |
|---|
| 48 | point_index(0), |
|---|
| 49 | coord(Vec3(0.0f, 0.0f, 0.0f)), |
|---|
| 50 | texcoord(Vec2(-1.0f, -1.0f)) {} |
|---|
| 51 | |
|---|
| 52 | short point_index; |
|---|
| 53 | Vec3 coord; |
|---|
| 54 | Vec2 texcoord; |
|---|
| 55 | |
|---|
| 56 | inline bool operator == (const PointData& p) const |
|---|
| 57 | { |
|---|
| 58 | return coord == p.coord && texcoord == p.texcoord; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | struct Lwo2Surface |
|---|
| 64 | { |
|---|
| 65 | Lwo2Surface(): |
|---|
| 66 | image_index(-1), |
|---|
| 67 | state_set(0) {} |
|---|
| 68 | |
|---|
| 69 | short image_index; |
|---|
| 70 | string name; |
|---|
| 71 | Vec3 color; |
|---|
| 72 | StateSet* state_set; |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | typedef vector< PointData > PointsList; |
|---|
| 76 | typedef vector< PointsList > PolygonsList; |
|---|
| 77 | typedef PolygonsList::iterator IteratorPolygonsList; |
|---|
| 78 | |
|---|
| 79 | typedef map< int, int > DrawableToTagMapping; |
|---|
| 80 | typedef pair< int, int > PairDrawableToTag; |
|---|
| 81 | |
|---|
| 82 | typedef vector< PointData >::iterator IteratorPoint; |
|---|
| 83 | typedef vector< Vec2 >::iterator IteratorVec2; |
|---|
| 84 | typedef vector< short >::iterator IteratorShort; |
|---|
| 85 | |
|---|
| 86 | class Lwo2Layer |
|---|
| 87 | { |
|---|
| 88 | public: |
|---|
| 89 | friend class Lwo2; |
|---|
| 90 | Lwo2Layer(); |
|---|
| 91 | ~Lwo2Layer(); |
|---|
| 92 | void notify(NotifySeverity); |
|---|
| 93 | void GenerateGeode( Geode&, short, DrawableToTagMapping& ); |
|---|
| 94 | |
|---|
| 95 | private: |
|---|
| 96 | bool _find_triangle_fans(PolygonsList&, PolygonsList&); |
|---|
| 97 | bool _find_triangle_fan(PolygonsList&, PolygonsList&); |
|---|
| 98 | bool _find_triangle_strips(PolygonsList&, PolygonsList&); |
|---|
| 99 | bool _find_triangle_strip(PolygonsList&, PolygonsList&); |
|---|
| 100 | int _find_triangle_begins_with(PolygonsList&, PointData&, PointData&); |
|---|
| 101 | |
|---|
| 102 | short _number; |
|---|
| 103 | short _flags; |
|---|
| 104 | short _parent; |
|---|
| 105 | Vec3 _pivot; |
|---|
| 106 | string _name; |
|---|
| 107 | vector< PointData > _points; |
|---|
| 108 | PolygonsList _polygons; |
|---|
| 109 | vector< short > _polygons_tag; |
|---|
| 110 | }; |
|---|
| 111 | |
|---|
| 112 | #endif |
|---|