00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_VOLUME_GROUP_
00025 #define _SO_VOLUME_GROUP_
00026
00027 #include <VolumeViz/nodes/SoVolumeRender.h>
00028 #include <Inventor/nodes/SoSeparator.h>
00029
00030 #if defined(_WIN32)
00031 #pragma warning(push)
00032 #pragma warning(disable: 4251) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
00033 #endif
00034
00035 class SoGLObjectCache;
00036 class SoLDMVirtualTexture;
00037 class SoVolumeOffscreenImpl;
00038
00128 class SoVolumeGroup : public SoSeparator {
00129
00130 SO_NODE_HEADER( SoVolumeGroup );
00131
00132 public:
00137 SoSFBool multiVolumes;
00138
00142 SoVolumeGroup();
00143
00144
00145
00146 private:
00147
00176 enum VGState
00177 {
00181 REGISTERING_VR,
00185 COLLECTING_SLICE,
00189 RENDERING_FIRST_PATH,
00193 RENDERING,
00194 };
00195
00201 virtual bool affectsPath() const;
00202
00203 static void initClass();
00204 static void exitClass();
00205
00206 void addVolume(SoState* state, SbVec3f& planeNormal, const SoPath* vrPath, const SoVolumeRender* vr, SoVolumeRenderingQuality* vrq, int vpScale);
00207 void addSlice(SoLDMVirtualTexture* vt, int, SbVec3f*, float, const SbVec3f& zAxis, const SoVolumeRender* vr);
00208 VGState getVGState() const { return m_vgState; };
00209
00210
00211 int getEdgeDetectFragDataId() const;
00212
00213 private:
00214
00215 virtual ~SoVolumeGroup();
00216
00217 private:
00218
00219 struct VGSlice {
00220 float sliceSpacing;
00221
00222
00223 float distance;
00224 SoLDMVirtualTexture* texID;
00225 int numVertices;
00226 SbVec3f vertices[6];
00227 SbVec3f zAxis;
00228 const SoVolumeRender* vr;
00229 };
00230
00231 struct VRInfo {
00232 SoPath* path;
00234 SoGLObjectCache* startDL;
00236 SoGLObjectCache* endDL;
00237 SoVolumeRenderingQuality* vrq;
00238
00239 int vpScale;
00240 };
00241
00242 typedef std::map<const SoVolumeRender*, VRInfo> VRInfoMap;
00243
00244 SoVolumeOffscreenImpl* m_volumeOffscreenImpl;
00245
00247 SoVRImageSpaceEffects* m_imageSpaceEffects;
00248
00252 static void clearVRInfoStruct(const VRInfoMap::value_type& p);
00253
00254 VGState m_vgState;
00255 VRInfoMap m_vrInfoMap;
00256
00260 std::vector<VGSlice*> m_slices;
00261
00266 int m_currentVolume;
00267
00268 SbMatrix m_currentMatrix, m_currentMatrixInv;
00269 SbVec3f m_currentPlane;
00270
00271 virtual void GLRenderBelowPath(SoGLRenderAction *action);
00272 virtual void GLRenderInPath(SoGLRenderAction *action);
00273
00274 void sortSlices();
00275 void renderSlices(SoState *state);
00276 static bool compareSlice(const VGSlice *s1, const VGSlice *s2);
00277 void renderVertices(const std::vector<int>& numVertices, const std::vector<SbVec3f>& vertices);
00278
00285 bool preRender(SoGLRenderAction *action, int &numberOfVolume);
00289 void postRender(SoGLRenderAction *action, int numberOfVolume);
00290
00291 void setVGSlice(VGSlice* slice, float distance, SoLDMVirtualTexture* vt, int numVertices, SbVec3f vertices[], float sliceSpacing, const SbVec3f& zAxis, const SoVolumeRender* vr);
00292
00297 void beginOffscreenRendering(SoState* state);
00298
00303 void endOffscreenRendering(SoState* state);
00304
00309 bool needRttColor(SoState* state, GLenum& internalColorFormat) const;
00310
00313 bool needRttEdgeDetect(SoState* state, GLenum& internalFormat) const;
00314
00317 int getEdgeDetect2DMethod(SoState* state) const;
00318
00320 int getLowResolutionScale(SoState* state) const;
00321
00323 void updateVRQ(int bitmask, std::vector<int>& bitMaskVector);
00324
00326 void restoreVRQ(const std::vector<int>& bitMaskVector);
00327
00328 };
00329
00330 #if defined(_WIN32)
00331 #pragma warning(pop)
00332 #endif
00333
00334 #endif // _SO_VOLUME_GROUP_
00335
00336
00337