[2798] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
[1362] | 2 | /* |
---|
| 3 | * ---------------------------------------------------------------------- |
---|
| 4 | * VolumeRenderer.h : VolumeRenderer class for volume visualization |
---|
| 5 | * |
---|
| 6 | * ====================================================================== |
---|
| 7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
| 8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
| 9 | * |
---|
[3177] | 10 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[1362] | 11 | * |
---|
| 12 | * See the file "license.terms" for information on usage and |
---|
| 13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 14 | * ====================================================================== |
---|
| 15 | */ |
---|
| 16 | #ifndef _VOLUME_RENDERER_H_ |
---|
| 17 | #define _VOLUME_RENDERER_H_ |
---|
| 18 | |
---|
[3492] | 19 | #include <vrmath/Matrix4x4d.h> |
---|
| 20 | |
---|
[1362] | 21 | #include "Volume.h" |
---|
[2822] | 22 | #include "VolumeInterpolator.h" |
---|
[1362] | 23 | #include "NvRegularVolumeShader.h" |
---|
| 24 | #include "NvZincBlendeVolumeShader.h" |
---|
| 25 | #include "NvStdVertexShader.h" |
---|
| 26 | |
---|
[2822] | 27 | class VolumeRenderer |
---|
| 28 | { |
---|
[1362] | 29 | public: |
---|
| 30 | VolumeRenderer(); |
---|
[2822] | 31 | |
---|
[1362] | 32 | ~VolumeRenderer(); |
---|
| 33 | |
---|
[2853] | 34 | /// render all enabled volumes |
---|
[2877] | 35 | void renderAll(); |
---|
[2822] | 36 | |
---|
[1474] | 37 | void specular(float val); |
---|
[2822] | 38 | |
---|
[1474] | 39 | void diffuse(float val); |
---|
[1362] | 40 | |
---|
[2822] | 41 | void clearAnimatedVolumeInfo() |
---|
| 42 | { |
---|
| 43 | _volumeInterpolator->clearAll(); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | void addAnimatedVolume(Volume* volume) |
---|
| 47 | { |
---|
| 48 | _volumeInterpolator->addVolume(volume); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void startVolumeAnimation() |
---|
| 52 | { |
---|
| 53 | _volumeInterpolator->start(); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | void stopVolumeAnimation() |
---|
| 57 | { |
---|
[2853] | 58 | _volumeInterpolator->stop(); |
---|
[1362] | 59 | } |
---|
[2822] | 60 | |
---|
| 61 | VolumeInterpolator* getVolumeInterpolator() |
---|
| 62 | { |
---|
[2853] | 63 | return _volumeInterpolator; |
---|
[1362] | 64 | } |
---|
[2853] | 65 | |
---|
| 66 | private: |
---|
[2877] | 67 | void initShaders(); |
---|
[2853] | 68 | |
---|
[3362] | 69 | void activateVolumeShader(Volume *vol, bool sliceMode, float sampleRatio); |
---|
[2853] | 70 | |
---|
[2877] | 71 | void deactivateVolumeShader(); |
---|
[2853] | 72 | |
---|
[2877] | 73 | void drawBoundingBox(float x0, float y0, float z0, |
---|
| 74 | float x1, float y1, float z1, |
---|
| 75 | float r, float g, float b, float line_width); |
---|
[2853] | 76 | |
---|
[3492] | 77 | void getEyeSpaceBounds(const vrmath::Matrix4x4d& mv, |
---|
[2973] | 78 | double& xMin, double& xMax, |
---|
| 79 | double& yMin, double& yMax, |
---|
| 80 | double& zNear, double& zFar); |
---|
[2853] | 81 | |
---|
| 82 | VolumeInterpolator *_volumeInterpolator; |
---|
| 83 | |
---|
[3362] | 84 | /** |
---|
| 85 | * Shader for single slice cutplane render |
---|
[2853] | 86 | */ |
---|
[3362] | 87 | NvShader *_cutplaneShader; |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | * Shader for rendering a single cubic volume |
---|
| 91 | */ |
---|
[2853] | 92 | NvRegularVolumeShader *_regularVolumeShader; |
---|
| 93 | |
---|
| 94 | /** |
---|
[3362] | 95 | * Shader for rendering a single zincblende orbital. A |
---|
[2853] | 96 | * simulation contains S, P, D and SS, total of 4 orbitals. A full |
---|
| 97 | * rendering requires 4 zincblende orbital volumes. A zincblende orbital |
---|
| 98 | * volume is decomposed into two "interlocking" cubic volumes and passed |
---|
| 99 | * to the shader. We render each orbital with its own independent |
---|
| 100 | * transfer functions then blend the result. |
---|
| 101 | * |
---|
| 102 | * The engine is already capable of rendering multiple volumes and combine |
---|
| 103 | * them. Thus, we just invoke this shader on S, P, D and SS orbitals with |
---|
| 104 | * different transfor functions. The result is a multi-orbital rendering. |
---|
| 105 | * This is equivalent to rendering 4 unrelated data sets occupying the |
---|
| 106 | * same space. |
---|
| 107 | */ |
---|
| 108 | NvZincBlendeVolumeShader *_zincBlendeShader; |
---|
| 109 | |
---|
| 110 | /** |
---|
| 111 | * standard vertex shader |
---|
| 112 | */ |
---|
| 113 | NvStdVertexShader *_stdVertexShader; |
---|
[1362] | 114 | }; |
---|
| 115 | |
---|
[2853] | 116 | #endif |
---|