- Timestamp:
- Mar 29, 2006, 6:33:58 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 2 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/Event.cpp
r385 r391 21 21 22 22 23 Event::Event(int _type, float _param[3], long_time){23 Event::Event(int _type, float _param[3], float _time){ 24 24 type = _type; 25 25 memcpy(parameter, _param, 3*sizeof(float)); 26 ms c = _time;26 msec = _time; 27 27 } 28 28 29 29 void Event::write(FILE* fd){ 30 fprintf(fd, "%d %f %f %f \n", type, parameter[0], parameter[1], parameter[2]);30 fprintf(fd, "%d %f %f %f %g\n", type, parameter[0], parameter[1], parameter[2], msec); 31 31 } 32 32 -
trunk/gui/vizservers/nanovis/Event.h
r385 r391 29 29 // move: x,y,z 30 30 // other: nan 31 long msc; //millisecond since the session started31 float msec; //millisecond since the session started 32 32 33 33 Event(); 34 Event(int _type, float _param[3], long_time);34 Event(int _type, float _param[3], float _time); 35 35 ~Event(); 36 36 void write(FILE* fd); -
trunk/gui/vizservers/nanovis/Makefile
r389 r391 12 12 NANOSCALESRC = ./nanoscale 13 13 14 LIB_NANOVIS = -ltcl8. 3-L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++14 LIB_NANOVIS = -ltcl8.4 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++ 15 15 LIB_CLIENT = -L/opt/render/lib -lGL -lglut -pthread -lstdc++ 16 16 INCLUDES = -I../src2/core -I/opt/render/include -I/autohome/u76/qiaow/Cg/usr/include -
trunk/gui/vizservers/nanovis/config.h
r389 r391 16 16 17 17 #define NV40 //Uncomment if using 6 series card. By default we assume older card the 5xxx series 18 #define XINETD //enable render server19 //#define EVENTLOG //enable event logging18 //#define XINETD //enable render server 19 #define EVENTLOG //enable event logging -
trunk/gui/vizservers/nanovis/nanoscale/EventPlayer.cpp
r389 r391 29 29 using namespace std; 30 30 31 Event* event[ 100];31 Event* event[300]; 32 32 int cur_event = 0; 33 33 double interval_sum = 0; … … 106 106 msg = msgstream.str(); 107 107 108 //sleep a little 109 struct timespec ts; 110 ts.tv_sec = 0; 111 ts.tv_nsec = cur->msec*1000000000; 112 nanosleep(&ts, 0); 113 108 114 //start timer 109 115 struct timeval clock; … … 168 174 int type; 169 175 float param[3]; 170 fscanf(fd, "%d %f %f %f\n", &type, param, param+1, param+2); 171 event[i] = new Event(type, param, 0); 176 double interval; 177 fscanf(fd, "%d %f %f %f %g\n", &type, param, param+1, param+2, &interval); 178 event[i] = new Event(type, param, interval); 172 179 //fprintf(stderr, "%d %f %f %f\n", type, param[0], param[1], param[2]); 173 180 } -
trunk/gui/vizservers/nanovis/nanovis.cpp
r389 r391 19 19 #include <iostream> 20 20 #include <string> 21 #include <sys/time.h> 21 22 22 23 #include "nanovis.h" … … 45 46 void init_event_log(); 46 47 void end_event_log(); 48 double cur_time; //in seconds 49 double get_time_interval(); 47 50 #endif 48 51 … … 667 670 #ifdef EVENTLOG 668 671 float param[3] = {0,0,0}; 669 Event* tmp = new Event(EVENT_ROTATE, param, 0);672 Event* tmp = new Event(EVENT_ROTATE, param, get_time_interval()); 670 673 tmp->write(event_log); 671 674 delete tmp; … … 866 869 for (int j=0; j<psys->psys_height; j++){ 867 870 int index = i + psys->psys_height*j; 868 bool particle = rand() % 256 > 100;871 bool particle = rand() % 256 > 200; 869 872 //particle = true; 870 873 if(particle) … … 1103 1106 1104 1107 1105 1106 1107 1108 void xinetd_listen(){ 1108 1109 //command: … … 1993 1994 perf->disable(); 1994 1995 //fprintf(stderr, "volume pixels: %d\n", perf->get_pixel_count()); 1996 1997 #ifdef XINETD 1995 1998 float cost = perf->get_pixel_count(); 1996 1999 write(3, &cost, sizeof(cost)); 2000 #endif 1997 2001 perf->reset(); 1998 2002 … … 2002 2006 display_final_fbo(); 2003 2007 2008 #ifdef XINETD 2004 2009 read_screen(); 2005 glClear(GL_COLOR_BUFFER_BIT); 2006 glDrawPixels(win_width, win_height, GL_RGB, /*GL_COLOR_ATTACHMENT0_EXT*/ GL_UNSIGNED_BYTE, screen_buffer); 2010 glClear(GL_COLOR_BUFFER_BIT); 2011 glDrawPixels(win_width, win_height, GL_RGB, /*GL_COLOR_ATTACHMENT0_EXT*/ GL_UNSIGNED_BYTE, screen_buffer); 2012 #endif 2007 2013 glutSwapBuffers(); 2008 2014 } … … 2143 2149 if(log){ 2144 2150 float param[3] = {live_obj_x, live_obj_y, live_obj_z}; 2145 Event* tmp = new Event(EVENT_MOVE, param, 0);2151 Event* tmp = new Event(EVENT_MOVE, param, get_time_interval()); 2146 2152 tmp->write(event_log); 2147 2153 delete tmp; … … 2167 2173 2168 2174 //more coarse event handling 2169 //if(abs(delta_x)<5 && abs(delta_y)<5)2170 //return;2175 if(abs(delta_x)<10 && abs(delta_y)<10) 2176 return; 2171 2177 2172 2178 if(left_down){ … … 2187 2193 #ifdef EVENTLOG 2188 2194 float param[3] = {live_rot_x, live_rot_y, live_rot_z}; 2189 Event* tmp = new Event(EVENT_ROTATE, param, 0);2195 Event* tmp = new Event(EVENT_ROTATE, param, get_time_interval()); 2190 2196 tmp->write(event_log); 2191 2197 delete tmp; … … 2218 2224 event_log = fopen("event.txt", "w"); 2219 2225 assert(event_log!=0); 2226 2227 struct timeval time; 2228 gettimeofday(&time, NULL); 2229 cur_time = time.tv_sec*1000. + time.tv_usec/1000.; 2220 2230 } 2221 2231 … … 2223 2233 fclose(event_log); 2224 2234 } 2235 2236 double get_time_interval(){ 2237 struct timeval time; 2238 gettimeofday(&time, NULL); 2239 double new_time = time.tv_sec*1000. + time.tv_usec/1000.; 2240 2241 double interval = new_time - cur_time; 2242 cur_time = new_time; 2243 return interval; 2244 } 2245 2225 2246 #endif 2226 2247 -
trunk/gui/vizservers/nanovis/shaders/one_volume.cg
r389 r391 16 16 * render one volume 17 17 */ 18 19 20 //#define PHONG_SHADING 21 18 22 PixelOut main(v2f IN, /* uniform sampler1D tf,*/ 19 23 uniform sampler3D volume, … … 27 31 float4 tex_coord = mul(modelViewInv, IN.TexCoord); 28 32 29 33 //if(renderParameters.y==1){ //1 component 30 34 31 35 float4 sample = tex3D(volume, tex_coord.xyz); 32 36 33 if (sample.x < 0.) { 34 OUT.Color = float4(0.0, 0.0, 0.0, 0.0); 35 } 36 else{ 37 /* 37 #ifdef PHONG_SHADING 38 38 //lighting parameters 39 float4 worldnormal = float4(sample.yzw, 1); 40 float3 normal = normalize(mul(modelView, worldnormal)).xyz; //eye space normal 41 float3 light_vector = normalize(mul(modelView, float4(0, -1, -2, 1))); //eye space light vector 42 float3 eye_vector = normalize(mul(modelView, float4(IN.EyeVector,1))).xyz; //eye space eye vector 39 float4 worldnormal = float4(normalize(sample.yzw), 1); 40 float3 normal = normalize(mul(modelView, worldnormal).xyz); //eye space normal 41 //float3 light_vector = normalize(mul(modelView, float4(0, -1, -2, 1))); //eye space light vector 42 float3 light_vector = normalize(float3(0, -1, -2)); //eye space light vector 43 float3 eye_vector = normalize(mul(modelView, float4(IN.EyeVector,1)).xyz); //eye space eye vector 43 44 float3 half_vector = normalize(+eye_vector+light_vector); //eye half angle vector 44 */ 45 #endif 46 45 47 //sample the transfer function texture 46 float4 color = tex1D(tf, sample.x);47 color.w = 10*color.w/renderParameters.x;48 //float4 color = tex1D(tf, sample.x); 49 //color.w = 10*color.w/renderParameters.x; 48 50 49 if(sample.x > 0.5) 50 color = float4(sample.x, 0, 0, sample.x); 51 float4 color = float4(sample.x, 0, 0, sample.x); 51 52 52 /* 53 54 #ifdef PHONG_SHADING 53 55 //lighting computation 54 56 float normal_dot_light = max(dot(normal, light_vector), 0); 55 57 float normal_dot_half = max(dot(normal, half_vector), 0); 56 58 57 float ambient = 0. 3;59 float ambient = 0.1; 58 60 float diffuse = normal_dot_light * renderParameters.z; 59 float specular = pow(normal_dot_half, renderParameters.w);61 float specular = pow(normal_dot_half, -renderParameters.w)*(1-ambient-diffuse); 60 62 61 63 float lighting = ambient + diffuse + specular; 62 64 color.xyz = color.xyz * lighting; 63 */64 65 65 66 //debug 66 67 //color.xyz = normal.xyz; //display normals 67 //if(color.z < 0) 68 //color.xyz = float3(1,0,0); 68 #endif 69 69 70 70 OUT.Color = color; 71 } 72 } 71 // } 73 72 73 /* 74 74 else if(renderParameters.y==0){ 75 75 //3 component … … 77 77 OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x); 78 78 } 79 */ 79 80 80 81 //debug
Note: See TracChangeset
for help on using the changeset viewer.