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