source: trunk/packages/vizservers/nanovis/nanovis.h @ 1380

Last change on this file since 1380 was 1370, checked in by vrinside, 15 years ago

improving the flow vis engine

  • particle advection for multiple vector field
  • specifying multiple advection planes
  • specifying the position of a particle injection plane
  • specifying the axis of a particle injection plane
  • specifying the visibility of particle injection planes
  • specifying the particle color for each particle injection plane
  • rendering device shapes

[NOTE] Currently, I commented out with the MACRO NEW_FLOW_ENGINE in config
To use this, please comment NEW_FLOW_ENGINE in

File size: 5.9 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  nanovis.h: package header
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#ifndef __NANOVIS_H__
16#define __NANOVIS_H__
17
18#include <tcl.h>
19
20#include <GL/glew.h>
21#include <GL/glut.h>
22#include <Cg/cgGL.h>
23#include <stdlib.h>
24#include <math.h>
25#include <time.h>
26#include <iostream>
27#include <stdio.h>
28#include <assert.h>
29#include <float.h>
30#include <getopt.h>
31#include <stdio.h>
32#include <math.h>
33#include <fstream>
34#include <sstream>
35#include <string>
36#include <sys/time.h>
37#include <sys/types.h>
38#include <unistd.h>
39#include <fcntl.h>
40#include <signal.h>
41
42#include "define.h"
43#include "global.h"
44#include "socket/Socket.h"
45#include "NvCamera.h"
46#include "ConvexPolygon.h"
47#include "Texture3D.h"
48#include "Texture2D.h"
49#include "Texture1D.h"
50#include "TransferFunction.h"
51#include "Mat4x4.h"
52#include "Volume.h"
53#include "NvParticleRenderer.h"
54#include "NvFlowVisRenderer.h"
55#include "PerfQuery.h"
56#include "Event.h"
57#include "VolumeRenderer.h"
58#include "PlaneRenderer.h"
59#include "NvColorTableRenderer.h"
60#include "PointSetRenderer.h"
61#include "PointSet.h"
62#include "HeightMap.h"
63#include "Grid.h"
64
65#include "config.h"
66
67
68//defines for the image based flow visualization
69#define NPN 256         //resolution of background pattern
70#define NMESH 256       //resolution of flow mesh
71#define DM  ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines
72#define NPIX  512       //display size
73#define SCALE 3.0       //scale for background pattern. small value -> fine texture
74
75class NvVectorField;
76
77struct Vector2 {
78    float x, y;
79    float mag(void) {
80        return sqrt(x*x+y*y);
81    }
82};
83
84struct RegGrid2{
85    int width, height;
86    Vector2* field;
87   
88    RegGrid2(int w, int h){
89        width = w;
90        height = h;
91        field = new Vector2[w*h];
92    }
93
94    void put(Vector2& v, int x ,int y) {
95        field[x+y*width] = v;
96    }
97   
98    Vector2& get(int x, int y) {
99        return field[x+y*width];
100    }
101};
102
103class NvLIC;
104
105class NanoVis {
106    //frame buffer for final rendering
107    static NVISid final_fbo, final_color_tex, final_depth_rb;
108public:
109    static VolumeRenderer* vol_renderer;
110    static PointSetRenderer* pointset_renderer;
111#ifndef NEW_FLOW_ENGINE
112    static NvParticleRenderer* flowVisRenderer;
113#else
114    static NvFlowVisRenderer* flowVisRenderer;
115#endif
116    static NvLIC* licRenderer;
117    static vector<PointSet*> pointSet;
118    static PlaneRenderer* plane_render;
119
120    /**
121     *  pointers to 2D planes, currently handle up 10
122     */
123    static Texture2D* plane[10];
124    static NvColorTableRenderer* color_table_renderer;
125    static graphics::RenderContext* renderContext;
126    static vector<HeightMap*> heightMap;
127    static unsigned char* screen_buffer;
128    static vector<Volume*> volume;
129    static vector<NvVectorField*> flow;
130    static Grid* grid;
131    static R2Fonts* fonts;
132    static int n_volumes;
133    static int updir;
134    static NvCamera *cam;
135
136    static float lic_slice_x;
137    static float lic_slice_y;
138    static float lic_slice_z;
139    static bool lic_slice_x_visible;
140    static bool lic_slice_y_visible;
141    static bool lic_slice_z_visible;
142    static int lic_axis;        /* 0:x, 1:y, 2:z */
143
144    static bool axis_on;
145    static bool config_pending; // Indicates if the limits need to be recomputed.
146    static int win_width;       //size of the render window
147    static int win_height;      //size of the render window
148    static int render_window;
149
150    static bool debug_flag;
151    static bool lic_on;
152    static bool particle_on;
153    static bool vector_on;
154
155    static Tcl_Interp *interp;
156    static Tcl_DString cmdbuffer;
157
158    static TransferFunction* get_transfunc(const char *name);
159    static TransferFunction* DefineTransferFunction(const char *name,
160        size_t n, float *data);
161    static void SetVolumeRanges(void);
162    static void SetHeightmapRanges(void);
163    static void init(const char* path);
164    static void initGL(void);
165    static void init_lic(void);
166    static void init_offscreen_buffer(void);
167    static void initParticle();
168    static void resize_offscreen_buffer(int w, int h);
169
170    // For development
171    static void resize(int w, int h);
172    static void render();
173
174    static void ppm_write(const char *prefix);
175    static void sendDataToClient(const char *command, const char *data,
176        size_t dlen);
177    static void bmp_write(const char *prefix);
178    static void bmp_write_to_file(int frame_number, const char* directory_name);
179    static void display(void);
180    static void idle(void);
181    static void update(void);
182    static void display_offscreen_buffer();
183    static int render_legend(TransferFunction *tf, double min, double max,
184        int width, int height, const char* volArg);
185    static Volume *load_volume(int index, int width, int height, int depth,
186        int n, float* data, double vmin, double vmax, double nzero_min);
187    static void xinetd_listen(void);
188    static int render_2d_contour(HeightMap* heightmap, int width, int height);
189    static void pan(float dx, float dy);
190
191#ifndef XINETD
192    static void keyboard(unsigned char key, int x, int y);
193    static void mouse(int button, int state, int x, int y);
194    static void motion(int x, int y);
195    static void update_rot(int delta_x, int delta_y);
196    static void update_trans(int delta_x, int delta_y, int delta_z);
197#endif
198
199    static FILE *stdin, *logfile, *recfile;
200
201    static void read_screen(void) {
202        glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
203                screen_buffer);
204    }
205    static void offscreen_buffer_capture(void) {
206        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
207    }
208};
209
210
211#endif  /* __NANOVIS_H__ */
Note: See TracBrowser for help on using the repository browser.