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

Last change on this file since 2720 was 2096, checked in by ldelgass, 14 years ago

Normalize line endings, set eol-style to native on *.cpp, *.h files

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * VolumeRenderer.h : VolumeRenderer class for volume visualization
4 *
5 * ======================================================================
6 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
7 *           Purdue Rendering and Perceptualization Lab (PURPL)
8 *
9 *  Copyright (c) 2004-2006  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15
16#ifndef _VOLUME_RENDERER_H_
17#define _VOLUME_RENDERER_H_
18
19#include <GL/glew.h>
20#include <Cg/cgGL.h>
21#include <GL/glut.h>
22#include <math.h>
23#include <stdio.h>
24#include <assert.h>
25#include <float.h>
26#include <vector>
27
28#include "define.h"
29#include "global.h"
30#include "ConvexPolygon.h"
31#include "TransferFunction.h"
32#include "Mat4x4.h"
33#include "Volume.h"
34#include "ZincBlendeVolume.h"
35#include "PerfQuery.h"
36#include "NvRegularVolumeShader.h"
37#include "NvZincBlendeVolumeShader.h"
38#include "NvStdVertexShader.h"
39#include "VolumeInterpolator.h"
40
41class VolumeRenderer {
42    friend class NanoVis;
43private:
44    VolumeInterpolator* _volumeInterpolator;
45
46    bool slice_mode;                    //!<- enable cut planes
47    bool volume_mode;                   //!<- enable full volume rendering
48
49    /**
50     * shader parameters for rendering a single cubic volume
51     */
52    NvRegularVolumeShader* _regularVolumeShader;
53
54    /**
55     * Shader parameters for rendering a single zincblende orbital.  A
56     * simulation contains S, P, D and SS, total of 4 orbitals. A full
57     * rendering requires 4 zincblende orbital volumes.  A zincblende orbital
58     * volume is decomposed into two "interlocking" cubic volumes and passed
59     * to the shader.  We render each orbital with its own independent
60     * transfer functions then blend the result.
61     *
62     * The engine is already capable of rendering multiple volumes and combine
63     * them. Thus, we just invoke this shader on S, P, D and SS orbitals with
64     * different transfor functions. The result is a multi-orbital rendering.
65     * This is equivalent to rendering 4 unrelated data sets occupying the
66     * same space.
67     */
68    NvZincBlendeVolumeShader* _zincBlendeShader;
69 
70    /**
71     * standard vertex shader
72     */
73    NvStdVertexShader* _stdVertexShader;
74 
75    //standard vertex shader parameters
76    CGprogram m_vert_std_vprog;
77    CGparameter m_mvp_vert_std_param;
78    CGparameter m_mvi_vert_std_param;
79    GLuint font_base;           // The base of the font display list.
80    GLuint font_texture;        //the id of the font texture
81
82    void init_shaders();
83    void activate_volume_shader(Volume* vol, bool slice_mode);
84    void deactivate_volume_shader();
85    //draw bounding box
86    void draw_bounding_box(float x0, float y0, float z0,
87                           float x1, float y1, float z1,
88                           float r, float g, float b, float line_width);
89
90    void get_near_far_z(Mat4x4 mv, double &zNear, double &zFar);
91    bool init_font(const char* filename);
92    void glPrint(char* string, int set); //there are two sets of font in the
93                                         //texture. 0, 1
94    void draw_label(Volume* vol); //draw label using bitmap texture
95                                // the texture.
96    void build_font();          // Register the location of each alphabet in
97
98public:
99    VolumeRenderer();
100    ~VolumeRenderer();
101
102    void render_all();                  //render all enabled volumes;
103    void specular(float val);
104    void diffuse(float val);
105    void set_slice_mode(bool val);      //control independently.
106    void set_volume_mode(bool val);
107    void switch_slice_mode();           //switch_cutplane_mode
108    void switch_volume_mode();
109
110    void clearAnimatedVolumeInfo(void) {
111        _volumeInterpolator->clearAll();
112    }
113    void addAnimatedVolume(Volume* volume) {
114        _volumeInterpolator->addVolume(volume);
115    }
116    void startVolumeAnimation(void) {
117        _volumeInterpolator->start();
118    }
119    void stopVolumeAnimation(void) {
120        _volumeInterpolator->stop();
121    }
122    VolumeInterpolator* getVolumeInterpolator(void) {
123        return _volumeInterpolator;
124    }
125};
126
127#endif  /*_VOLUME_RENDERER_H_*/
Note: See TracBrowser for help on using the repository browser.