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

Last change on this file since 2968 was 2968, checked in by ldelgass, 12 years ago

Remove unused Cg parameters from VolumeRenderer? (handled in shader classes now).

  • Property svn:eol-style set to native
File size: 3.9 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 getNearFarZ(const Mat4x4& mv, double& zNear, double& zFar);
103
104    bool initFont(const char *filename);
105
106    /// there are two sets of font in the texture. 0, 1
107    void glPrint(char *string, int set);
108
109    /// draw label using bitmap texture
110    void drawLabel(Volume *vol);
111
112    /// Register the location of each alphabet in
113    void buildFont();
114
115    VolumeInterpolator *_volumeInterpolator;
116
117    bool _sliceMode;  ///< enable cut planes
118    bool _volumeMode; ///< enable full volume rendering
119
120    /**
121     * shader parameters for rendering a single cubic volume
122     */
123    NvRegularVolumeShader *_regularVolumeShader;
124
125    /**
126     * Shader parameters for rendering a single zincblende orbital.  A
127     * simulation contains S, P, D and SS, total of 4 orbitals. A full
128     * rendering requires 4 zincblende orbital volumes.  A zincblende orbital
129     * volume is decomposed into two "interlocking" cubic volumes and passed
130     * to the shader.  We render each orbital with its own independent
131     * transfer functions then blend the result.
132     *
133     * The engine is already capable of rendering multiple volumes and combine
134     * them. Thus, we just invoke this shader on S, P, D and SS orbitals with
135     * different transfor functions. The result is a multi-orbital rendering.
136     * This is equivalent to rendering 4 unrelated data sets occupying the
137     * same space.
138     */
139    NvZincBlendeVolumeShader *_zincBlendeShader;
140
141    /**
142     * standard vertex shader
143     */
144    NvStdVertexShader *_stdVertexShader;
145
146    GLuint _fontBase;      ///< The base of the font display list.
147    GLuint _fontTexture;   ///< The id of the font texture
148};
149
150#endif
Note: See TracBrowser for help on using the repository browser.