source: trunk/packages/vizservers/nanovis/VolumeRenderer.h @ 2973

Last change on this file since 2973 was 2973, checked in by ldelgass, 10 years ago

Fix clipping bug in nanovis volume renderer. Use computed eye space bounds of
transformed volume bounding box to initialize view-aligned quads before
clipping. Previously an arbitrary eye-space bound was used, and this was too
small for long volumes like nanowires in omennanowire.

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
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 *
10 *  Copyright (c) 2004-2006  Purdue Research Foundation
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
19#include <GL/glew.h>
20
21#include "Mat4x4.h"
22#include "Volume.h"
23#include "VolumeInterpolator.h"
24#include "NvRegularVolumeShader.h"
25#include "NvZincBlendeVolumeShader.h"
26#include "NvStdVertexShader.h"
27
28class VolumeRenderer
29{
30public:
31    VolumeRenderer();
32
33    ~VolumeRenderer();
34
35    /// render all enabled volumes
36    void renderAll();
37
38    void specular(float val);
39
40    void diffuse(float val);
41
42    /// control independently
43    void setSliceMode(bool val)
44    {
45        _sliceMode = val;
46    }
47
48    void setVolumeMode(bool val)
49    {
50        _volumeMode = val;
51    }
52
53    /// switch_cutplane_mode
54    void switchSliceMode()
55    {
56        _sliceMode = (!_sliceMode);
57    }
58
59    void switchVolumeMode()
60    {
61        _volumeMode = (!_volumeMode);
62    }
63
64    void clearAnimatedVolumeInfo()
65    {
66        _volumeInterpolator->clearAll();
67    }
68
69    void addAnimatedVolume(Volume* volume)
70    {
71        _volumeInterpolator->addVolume(volume);
72    }
73
74    void startVolumeAnimation()
75    {
76        _volumeInterpolator->start();
77    }
78
79    void stopVolumeAnimation()
80    {
81        _volumeInterpolator->stop();
82    }
83
84    VolumeInterpolator* getVolumeInterpolator()
85    {
86        return _volumeInterpolator;
87    }
88
89    friend class NanoVis;
90
91private:
92    void initShaders();
93
94    void activateVolumeShader(Volume *vol, bool slice_mode);
95
96    void deactivateVolumeShader();
97
98    void drawBoundingBox(float x0, float y0, float z0,
99                         float x1, float y1, float z1,
100                         float r, float g, float b, float line_width);
101
102    void getEyeSpaceBounds(const Mat4x4& mv,
103                           double& xMin, double& xMax,
104                           double& yMin, double& yMax,
105                           double& zNear, double& zFar);
106
107    bool initFont(const char *filename);
108
109    /// there are two sets of font in the texture. 0, 1
110    void glPrint(char *string, int set);
111
112    /// draw label using bitmap texture
113    void drawLabel(Volume *vol);
114
115    /// Register the location of each alphabet in
116    void buildFont();
117
118    VolumeInterpolator *_volumeInterpolator;
119
120    bool _sliceMode;  ///< enable cut planes
121    bool _volumeMode; ///< enable full volume rendering
122
123    /**
124     * shader parameters for rendering a single cubic volume
125     */
126    NvRegularVolumeShader *_regularVolumeShader;
127
128    /**
129     * Shader parameters for rendering a single zincblende orbital.  A
130     * simulation contains S, P, D and SS, total of 4 orbitals. A full
131     * rendering requires 4 zincblende orbital volumes.  A zincblende orbital
132     * volume is decomposed into two "interlocking" cubic volumes and passed
133     * to the shader.  We render each orbital with its own independent
134     * transfer functions then blend the result.
135     *
136     * The engine is already capable of rendering multiple volumes and combine
137     * them. Thus, we just invoke this shader on S, P, D and SS orbitals with
138     * different transfor functions. The result is a multi-orbital rendering.
139     * This is equivalent to rendering 4 unrelated data sets occupying the
140     * same space.
141     */
142    NvZincBlendeVolumeShader *_zincBlendeShader;
143
144    /**
145     * standard vertex shader
146     */
147    NvStdVertexShader *_stdVertexShader;
148
149    GLuint _fontBase;      ///< The base of the font display list.
150    GLuint _fontTexture;   ///< The id of the font texture
151};
152
153#endif
Note: See TracBrowser for help on using the repository browser.