source: trunk/gui/vizservers/nanovis/VolumeRenderer.h @ 455

Last change on this file since 455 was 455, checked in by mmc, 18 years ago

Added a new "legend" command, which can be used to request the
legend strip for a transfer function.

File size: 3.3 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 "PerfQuery.h"
35
36using namespace std;
37
38class VolumeRenderer{
39
40private:
41  vector <Volume*> volume;      //array of volumes
42  vector <TransferFunction*> tf;//array of corresponding transfer functions
43  int n_volumes;
44
45  bool slice_mode;      //enable cut planes
46  bool volume_mode;     //enable full volume rendering
47
48
49  //cg related
50  CGcontext g_context;          //the Nvidia cg context
51  CGprogram m_one_volume_fprog;
52  CGparameter m_vol_one_volume_param;
53  CGparameter m_tf_one_volume_param;
54  CGparameter m_mvi_one_volume_param;
55  CGparameter m_mv_one_volume_param;
56  CGparameter m_render_param_one_volume_param;
57
58  CGprogram m_vert_std_vprog;
59  CGparameter m_mvp_vert_std_param;
60  CGparameter m_mvi_vert_std_param;
61
62  void init_shaders();
63  void activate_volume_shader(int volume_index, bool slice_mode);
64  void deactivate_volume_shader();
65
66  //draw bounding box
67  void draw_bounding_box(float x0, float y0, float z0,
68                        float x1, float y1, float z1,
69                        float r, float g, float b, float line_width);
70
71  void get_near_far_z(Mat4x4 mv, double &zNear, double &zFar);
72
73  void init_font(char* filename);
74  GLuint font_texture;                          //the id of the font texture
75  void glPrint(char* string, int set);          //there are two sets of font in the texture. 0, 1
76  void draw_label(int volume_index);            //draw label using bitmap texture
77  GLuint font_base;                             //the base of the font display list
78  void build_font();                            //register the location of each alphabet in the texture
79
80public:
81  VolumeRenderer(CGcontext _context);
82  ~VolumeRenderer();
83
84  int add_volume(Volume* _vol, TransferFunction* _tf);
85                                                //add a volume and its transfer function
86                                                //we require a transfer function when a
87                                                //volume is added.
88  void shade_volume(Volume* _vol, TransferFunction* _tf);
89  TransferFunction* get_volume_shading(Volume* _vol);
90
91  void render(int volume_index);
92  void render_all();    //render all enabled volumes;
93  void set_specular(float val);
94  void set_diffuse(float val);
95  void set_slice_mode(bool val); //control independently.
96  void set_volume_mode(bool val);
97  void switch_slice_mode(); //switch_cutplane_mode
98  void switch_volume_mode();
99  void enable_volume(int index); //enable a volume
100  void disable_volume(int index); //disable a volume
101};
102
103#endif
Note: See TracBrowser for help on using the repository browser.