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

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

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

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