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 | |
---|
16 | #include <GL/glew.h> |
---|
17 | #include <GL/glut.h> |
---|
18 | #include <Cg/cgGL.h> |
---|
19 | #include <stdlib.h> |
---|
20 | #include <math.h> |
---|
21 | #include <time.h> |
---|
22 | #include <iostream> |
---|
23 | #include <stdio.h> |
---|
24 | #include <assert.h> |
---|
25 | #include <float.h> |
---|
26 | |
---|
27 | #include "define.h" |
---|
28 | #include "global.h" |
---|
29 | #include "socket/Socket.h" |
---|
30 | #include "Camera.h" |
---|
31 | #include "ConvexPolygon.h" |
---|
32 | #include "Texture3D.h" |
---|
33 | #include "Texture2D.h" |
---|
34 | #include "Texture1D.h" |
---|
35 | #include "TransferFunction.h" |
---|
36 | #include "Mat4x4.h" |
---|
37 | #include "Volume.h" |
---|
38 | #include "ParticleSystem.h" |
---|
39 | #include "PerfQuery.h" |
---|
40 | #include "Event.h" |
---|
41 | #include "Lic.h" |
---|
42 | #include "VolumeRenderer.h" |
---|
43 | #include "PlaneRenderer.h" |
---|
44 | |
---|
45 | #include "config.h" |
---|
46 | |
---|
47 | #include <tcl.h> |
---|
48 | #ifndef CONST84 |
---|
49 | # define CONST84 |
---|
50 | #endif |
---|
51 | |
---|
52 | |
---|
53 | //defines for the image based flow visualization |
---|
54 | #define NPN 256 //resolution of background pattern |
---|
55 | #define NMESH 256 //resolution of flow mesh |
---|
56 | #define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines |
---|
57 | #define NPIX 512 //display size |
---|
58 | #define SCALE 3.0 //scale for background pattern. small value -> fine texture |
---|
59 | #define MAX_N_VOLUMES 10 //maximum of volumes the application can handle |
---|
60 | |
---|
61 | |
---|
62 | typedef struct Vector2{ |
---|
63 | float x,y; |
---|
64 | float mag(){ |
---|
65 | return sqrt(x*x+y*y); |
---|
66 | } |
---|
67 | }; |
---|
68 | |
---|
69 | |
---|
70 | typedef struct RegGrid2{ |
---|
71 | int width, height; |
---|
72 | Vector2* field; |
---|
73 | |
---|
74 | RegGrid2(int w, int h){ |
---|
75 | width = w; |
---|
76 | height = h; |
---|
77 | field = new Vector2[w*h]; |
---|
78 | } |
---|
79 | |
---|
80 | void put(Vector2& v, int x ,int y){ |
---|
81 | field[x+y*width] = v; |
---|
82 | } |
---|
83 | |
---|
84 | Vector2& get(int x, int y){ |
---|
85 | return field[x+y*width]; |
---|
86 | } |
---|
87 | }; |
---|
88 | |
---|
89 | |
---|
90 | //variables for mouse events |
---|
91 | float live_rot_x = 0.; //object rotation angles |
---|
92 | float live_rot_y = 0.; |
---|
93 | float live_rot_z = 0.; |
---|
94 | |
---|
95 | float live_obj_x = -0.0; //object translation location from the origin |
---|
96 | float live_obj_y = -0.0; |
---|
97 | float live_obj_z = -2.5; |
---|
98 | |
---|
99 | float live_diffuse = 1.; |
---|
100 | float live_specular = 3.; |
---|
101 | |
---|
102 | int left_last_x, left_last_y, right_last_x, right_last_y; //last locations mouse events |
---|
103 | bool left_down = false; |
---|
104 | bool right_down = false; |
---|
105 | |
---|
106 | float lic_slice_x=0, lic_slice_y=0, lic_slice_z=0.3;//image based flow visualization slice location |
---|
107 | |
---|
108 | int win_width = NPIX; //size of the render window |
---|
109 | int win_height = NPIX; //size of the render window |
---|
110 | |
---|
111 | |
---|
112 | //image based flow visualization variables |
---|
113 | int iframe = 0; |
---|
114 | int Npat = 64; |
---|
115 | int alpha = (int)round(0.12*255); |
---|
116 | float sa; |
---|
117 | float tmax = NPIX/(SCALE*NPN); |
---|
118 | float dmax = SCALE/NPIX; |
---|
119 | |
---|
120 | |
---|
121 | //currently active shader, default renders one volume only |
---|
122 | int cur_shader = 0; |
---|