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

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

Add emacs mode magic line in preparation for indentation cleanup

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