| | 39 | static SoCallbackAction::Response preNode(void* data, |
| | 40 | SoCallbackAction* action, const SoNode* node); |
| | 41 | static SoCallbackAction::Response postNode(void* data, |
| | 42 | SoCallbackAction* action, const SoNode* node); |
| | 43 | static SoCallbackAction::Response preTransformSeparator(void* data, |
| | 44 | SoCallbackAction* action, const SoNode* node); |
| | 45 | static SoCallbackAction::Response postTransformSeparator(void* data, |
| | 46 | SoCallbackAction* action, const SoNode* node); |
| | 47 | static SoCallbackAction::Response preLOD(void* data, |
| | 48 | SoCallbackAction* action, const SoNode* node); |
| | 49 | static SoCallbackAction::Response postLOD(void* data, |
| | 50 | 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); |
| 45 | | static SoCallbackAction::Response postLOD(void* data, |
| 46 | | SoCallbackAction* action, const SoNode* node); |
| 47 | | ///Callback for VRMLImageTexture |
| 48 | | ///\param data The pointer to ConvertFromInventor object |
| 49 | | ///\param action The action handling class |
| 50 | | ///\param node The current VRMLImageTexture node |
| 51 | | static SoCallbackAction::Response preVRMLImageTexture(void* data, |
| 52 | | SoCallbackAction* action, const SoNode* node); |
| 53 | | static SoCallbackAction::Response preVRMLAppearance(void* data, |
| 54 | | SoCallbackAction* action, const SoNode* node); |
| 55 | | static SoCallbackAction::Response postVRMLAppearance(void* data, |
| | 55 | static SoCallbackAction::Response postTexture(void* data, |
| | 56 | SoCallbackAction* action, const SoNode* node); |
| | 57 | static SoCallbackAction::Response preLight(void* data, |
| | 58 | SoCallbackAction* action, const SoNode* node); |
| | 59 | static SoCallbackAction::Response preEnvironment(void* data, |
| | 60 | SoCallbackAction* action, const SoNode* node); |
| | 61 | static SoCallbackAction::Response preShaderProgram(void* data, |
| | 62 | SoCallbackAction* action, const SoNode* node); |
| | 63 | static SoCallbackAction::Response preRotor(void* data, |
| | 64 | SoCallbackAction* action, const SoNode* node); |
| | 65 | static SoCallbackAction::Response prePendulum(void* data, |
| | 66 | SoCallbackAction* action, const SoNode* node); |
| | 67 | static SoCallbackAction::Response preShuttle(void* data, |
| 127 | | osg::ref_ptr<osg::Group> lightGroup; |
| | 133 | /** |
| | 134 | * IvStateItem aids lack of some state retrieval methods |
| | 135 | * of SoCallbackAction. State is maintained in stack |
| | 136 | * manner separately from Open Inventor. |
| | 137 | */ |
| | 138 | class IvStateItem { |
| | 139 | public: |
| | 140 | |
| | 141 | // Pop flags and node caused the push |
| | 142 | enum Flags { |
| | 143 | DEFAULT_FLAGS = 0, |
| | 144 | MULTI_POP = 1, |
| | 145 | KEEP_CHILDREN_ORDER = 2, |
| | 146 | APPEND_AT_PUSH = 4, |
| | 147 | UPDATE_STATE = 8, |
| | 148 | UPDATE_STATE_EXCEPT_TRANSFORM = 0x10 // this has the same |
| | 149 | // effect as UPDATE_STATE at the present time |
| | 150 | }; |
| | 151 | int flags; |
| | 152 | const SoNode *pushInitiator; |
| | 153 | |
| | 154 | // Tracking of model transformation |
| | 155 | SbMatrix inheritedTransformation; |
| | 156 | SbMatrix lastUsedTransformation; |
| | 157 | |
| | 158 | // Active texture node (used for attaching the right texture to the |
| | 159 | // geosets). Supported types are SoTexture2 and SoVRMLImageTexture for now. |
| | 160 | // No multitexturing yet. |
| | 161 | const SoNode* inheritedTexture; |
| | 162 | const SoNode* currentTexture; |
| | 163 | |
| | 164 | // List of active lights |
| | 165 | std::vector<osg::ref_ptr<osg::Light> > inheritedLights; |
| | 166 | std::vector<osg::ref_ptr<osg::Light> > currentLights; |
| | 167 | |
| | 168 | // Active OpenGL glProgram and associated shaders |
| | 169 | osg::ref_ptr<osg::Program> inheritedGLProgram; |
| | 170 | osg::ref_ptr<osg::Program> currentGLProgram; |
| | 171 | |
| | 172 | // Ambient light (of SoEnvironment) |
| | 173 | SbColor inheritedAmbientLight; |
| | 174 | SbColor currentAmbientLight; |
| | 175 | |
| | 176 | // Generated OSG graph |
| | 177 | osg::ref_ptr<osg::Group> osgStateRoot; |
| | 178 | |
| | 179 | // Extra variables |
| | 180 | const SoNode *keepChildrenOrderParent; |
| | 181 | |
| | 182 | IvStateItem(const SoNode *initiator, osg::Group *root = NULL) : |
| | 183 | flags(IvStateItem::DEFAULT_FLAGS), |
| | 184 | pushInitiator(initiator), |
| | 185 | inheritedTransformation(SbMatrix::identity()), |
| | 186 | lastUsedTransformation(SbMatrix::identity()), |
| | 187 | inheritedTexture(NULL), |
| | 188 | currentTexture(NULL), |
| | 189 | inheritedLights(), |
| | 190 | currentLights(), |
| | 191 | inheritedGLProgram(NULL), |
| | 192 | currentGLProgram(NULL), |
| | 193 | inheritedAmbientLight(SbColor(0.2f,0.2f,0.2f)), |
| | 194 | currentAmbientLight(SbColor(0.2f,0.2f,0.2f)), |
| | 195 | osgStateRoot(root ? root : new osg::Group) {} |
| | 196 | |
| | 197 | IvStateItem(const IvStateItem& i, const SoCallbackAction *action, |
| | 198 | const SoNode *initiator, const int f, |
| | 199 | osg::Group *root) : |
| | 200 | flags(f), |
| | 201 | pushInitiator(initiator), |
| | 202 | inheritedTransformation(action->getModelMatrix()), |
| | 203 | lastUsedTransformation(action->getModelMatrix()), |
| | 204 | inheritedTexture(i.currentTexture), |
| | 205 | currentTexture(i.currentTexture), |
| | 206 | inheritedLights(i.currentLights), |
| | 207 | currentLights(i.currentLights), |
| | 208 | inheritedGLProgram(i.currentGLProgram), |
| | 209 | currentGLProgram(i.currentGLProgram), |
| | 210 | inheritedAmbientLight(i.inheritedAmbientLight), |
| | 211 | currentAmbientLight(i.currentAmbientLight), |
| | 212 | osgStateRoot(root) {} |
| | 213 | }; |
| | 214 | |
| | 215 | /// State stack for Inventor scene traversal |
| | 216 | std::stack<IvStateItem> ivStateStack; |
| | 217 | |
| | 218 | void ivPushState(const SoCallbackAction *action, |
| | 219 | const SoNode *initiator, const int flags = IvStateItem::DEFAULT_FLAGS, |
| | 220 | osg::Group *root = new osg::Group); |
| | 221 | void ivPopState(const SoCallbackAction *action, const SoNode *initator); |
| | 222 | |
| | 223 | void appendNode(osg::Node *n, const SoCallbackAction *action); |
| | 224 | |