| [2225] | 1 | #ifndef _CONVERTFROMINVENTOR_H_ |
|---|
| 2 | #define _CONVERTFROMINVENTOR_H_ |
|---|
| 3 | |
|---|
| 4 | #include <osg/Group> |
|---|
| 5 | #include <osg/Geometry> |
|---|
| 6 | #include <osg/PrimitiveSet> |
|---|
| 7 | #include <osg/Texture2D> |
|---|
| 8 | #include <osg/Light> |
|---|
| 9 | #include <Inventor/actions/SoCallbackAction.h> |
|---|
| [9053] | 10 | #include <Inventor/SbLinear.h> |
|---|
| [2225] | 11 | #include <vector> |
|---|
| 12 | #include <stack> |
|---|
| 13 | |
|---|
| [6543] | 14 | class ConvertFromInventor |
|---|
| [2225] | 15 | { |
|---|
| 16 | public: |
|---|
| 17 | ConvertFromInventor(); |
|---|
| 18 | ~ConvertFromInventor(); |
|---|
| [6543] | 19 | |
|---|
| 20 | osg::Node* convert(SoNode* rootIVNode); |
|---|
| 21 | |
|---|
| [2225] | 22 | private: |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | static SoCallbackAction::Response preShape(void* data, |
|---|
| 28 | SoCallbackAction* action, const SoNode* node); |
|---|
| 29 | static SoCallbackAction::Response postShape(void* data, |
|---|
| 30 | SoCallbackAction* action, const SoNode* node); |
|---|
| 31 | static SoCallbackAction::Response preGroup(void* data, |
|---|
| 32 | SoCallbackAction* action, const SoNode* node); |
|---|
| 33 | static SoCallbackAction::Response postGroup(void* data, |
|---|
| 34 | SoCallbackAction* action, const SoNode* node); |
|---|
| 35 | static SoCallbackAction::Response preTexture(void* data, |
|---|
| 36 | SoCallbackAction* action, const SoNode* node); |
|---|
| 37 | static SoCallbackAction::Response preLight(void* data, |
|---|
| 38 | SoCallbackAction* action, const SoNode* node); |
|---|
| 39 | static SoCallbackAction::Response preRotor(void* data, |
|---|
| 40 | SoCallbackAction* action, const SoNode* node); |
|---|
| 41 | static SoCallbackAction::Response prePendulum(void* data, |
|---|
| 42 | SoCallbackAction* action, const SoNode* node); |
|---|
| 43 | static SoCallbackAction::Response preShuttle(void* data, |
|---|
| 44 | SoCallbackAction* action, const SoNode* node); |
|---|
| [6543] | 45 | static SoCallbackAction::Response postLOD(void* data, |
|---|
| [2225] | 46 | SoCallbackAction* action, const SoNode* node); |
|---|
| [6543] | 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | static SoCallbackAction::Response preVRMLImageTexture(void* data, |
|---|
| 52 | SoCallbackAction* action, const SoNode* node); |
|---|
| [9053] | 53 | static SoCallbackAction::Response preVRMLAppearance(void* data, |
|---|
| 54 | SoCallbackAction* action, const SoNode* node); |
|---|
| 55 | static SoCallbackAction::Response postVRMLAppearance(void* data, |
|---|
| 56 | SoCallbackAction* action, const SoNode* node); |
|---|
| 57 | static SoCallbackAction::Response preInfo(void* data, |
|---|
| 58 | SoCallbackAction* action, const SoNode* node); |
|---|
| [2225] | 59 | |
|---|
| 60 | static void addTriangleCB(void* data, SoCallbackAction* action, |
|---|
| [5802] | 61 | const SoPrimitiveVertex *v0, |
|---|
| [2225] | 62 | const SoPrimitiveVertex *v1, |
|---|
| 63 | const SoPrimitiveVertex *v2); |
|---|
| 64 | static void addLineSegmentCB(void* data, SoCallbackAction* action, |
|---|
| 65 | const SoPrimitiveVertex *v0, |
|---|
| 66 | const SoPrimitiveVertex *v1); |
|---|
| 67 | static void addPointCB(void* data, SoCallbackAction* action, |
|---|
| 68 | const SoPrimitiveVertex *v0); |
|---|
| [6543] | 69 | |
|---|
| [2225] | 70 | private: |
|---|
| [9053] | 71 | SbString transformInfoName; |
|---|
| 72 | SbName appearanceName; |
|---|
| 73 | bool inAppearanceWithNoTexture; |
|---|
| [2225] | 74 | |
|---|
| [9053] | 75 | void addMatrixTransform(const std::string& name, SbVec3f axis, float angle, SbVec3f center, SbVec3f trans, SbVec3f scale); |
|---|
| [2225] | 76 | void addVertex(SoCallbackAction* action, const SoPrimitiveVertex* v, |
|---|
| 77 | int index); |
|---|
| 78 | |
|---|
| [6543] | 79 | osg::ref_ptr<osg::StateSet> getStateSet(SoCallbackAction* action); |
|---|
| [2225] | 80 | |
|---|
| [6543] | 81 | osg::Texture2D* convertIVTexToOSGTex(const SoNode* soNode, |
|---|
| 82 | SoCallbackAction* action); |
|---|
| [2225] | 83 | |
|---|
| 84 | void transformLight(SoCallbackAction* action, const SbVec3f& vec, |
|---|
| 85 | osg::Vec3& transVec); |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | void transposeMatrix(osg::Matrix& mat); |
|---|
| [6543] | 89 | |
|---|
| [2225] | 90 | private: |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | osg::Geometry::AttributeBinding normalBinding; |
|---|
| 94 | osg::Geometry::AttributeBinding colorBinding; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | std::vector<osg::Vec3> vertices; |
|---|
| 98 | std::vector<osg::Vec3> normals; |
|---|
| 99 | std::vector<osg::Vec4> colors; |
|---|
| 100 | std::vector<osg::Vec2> textureCoords; |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | int numPrimitives; |
|---|
| 104 | osg::PrimitiveSet::Mode primitiveType; |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | enum VertexOrder { CLOCKWISE, COUNTER_CLOCKWISE }; |
|---|
| 108 | VertexOrder vertexOrder; |
|---|
| 109 | |
|---|
| 110 | |
|---|
| [5802] | 111 | std::stack<osg::Group* > groupStack; |
|---|
| [2225] | 112 | |
|---|
| [6543] | 113 | |
|---|
| 114 | std::stack<const SoNode*> soTexStack; |
|---|
| [2225] | 115 | |
|---|
| [6543] | 116 | |
|---|
| 117 | |
|---|
| 118 | std::map<const SoNode*, osg::Texture2D*> ivToOsgTexMap; |
|---|
| [2225] | 119 | |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | typedef std::vector<osg::Light *> LightList; |
|---|
| 123 | std::stack<LightList> lightStack; |
|---|
| [5802] | 124 | |
|---|
| 125 | osg::ref_ptr<osg::MatrixTransform> _root; |
|---|
| [9053] | 126 | |
|---|
| 127 | osg::ref_ptr<osg::Group> lightGroup; |
|---|
| [2225] | 128 | }; |
|---|
| 129 | |
|---|
| 130 | #endif |
|---|