Changeset 391 for trunk


Ignore:
Timestamp:
Mar 29, 2006, 6:33:58 PM (18 years ago)
Author:
qiaow
Message:

EventPlayer? sleeps for a little bit before plays back the next event.

Location:
trunk/gui/vizservers/nanovis
Files:
2 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/Event.cpp

    r385 r391  
    2121
    2222
    23 Event::Event(int _type, float _param[3], long _time){
     23Event::Event(int _type, float _param[3], float _time){
    2424  type = _type;
    2525  memcpy(parameter, _param, 3*sizeof(float));
    26   msc = _time;
     26  msec = _time;
    2727}
    2828   
    2929void 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);
    3131}
    3232
  • trunk/gui/vizservers/nanovis/Event.h

    r385 r391  
    2929                        //                  move: x,y,z
    3030                        //                  other: nan
    31    long msc;            //millisecond since the session started
     31   float msec;          //millisecond since the session started
    3232       
    3333   Event();
    34    Event(int _type, float _param[3], long _time);
     34   Event(int _type, float _param[3], float _time);
    3535   ~Event();
    3636   void write(FILE* fd);
  • trunk/gui/vizservers/nanovis/Makefile

    r389 r391  
    1212NANOSCALESRC = ./nanoscale
    1313
    14 LIB_NANOVIS = -ltcl8.3 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
     14LIB_NANOVIS = -ltcl8.4 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
    1515LIB_CLIENT = -L/opt/render/lib -lGL -lglut -pthread -lstdc++
    1616INCLUDES = -I../src2/core -I/opt/render/include -I/autohome/u76/qiaow/Cg/usr/include
  • trunk/gui/vizservers/nanovis/config.h

    r389 r391  
    1616
    1717#define NV40      //Uncomment if using 6 series card. By default we assume older card the 5xxx series
    18 #define XINETD  //enable render server
    19 //#define EVENTLOG  //enable event logging
     18//#define XINETD  //enable render server
     19#define EVENTLOG  //enable event logging
  • trunk/gui/vizservers/nanovis/nanoscale/EventPlayer.cpp

    r389 r391  
    2929using namespace std;
    3030
    31 Event* event[100];
     31Event* event[300];
    3232int cur_event = 0;
    3333double interval_sum = 0;
     
    106106  msg = msgstream.str();
    107107
     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 
    108114  //start timer
    109115  struct timeval clock;
     
    168174    int type;
    169175    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);
    172179    //fprintf(stderr, "%d %f %f %f\n", type, param[0], param[1], param[2]);
    173180  }
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r389 r391  
    1919#include <iostream>
    2020#include <string>
     21#include <sys/time.h>
    2122
    2223#include "nanovis.h"
     
    4546void init_event_log();
    4647void end_event_log();
     48double cur_time;        //in seconds
     49double get_time_interval();
    4750#endif
    4851
     
    667670#ifdef EVENTLOG
    668671  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());
    670673  tmp->write(event_log);
    671674  delete tmp;
     
    866869    for (int j=0; j<psys->psys_height; j++){
    867870      int index = i + psys->psys_height*j;
    868       bool particle = rand() % 256 > 100;
     871      bool particle = rand() % 256 > 200;
    869872      //particle = true;
    870873      if(particle)
     
    11031106
    11041107
    1105 
    1106 
    11071108void xinetd_listen(){
    11081109    //command:
     
    19931994   perf->disable();
    19941995   //fprintf(stderr, "volume pixels: %d\n", perf->get_pixel_count());
     1996 
     1997#ifdef XINETD
    19951998   float cost  = perf->get_pixel_count();
    19961999   write(3, &cost, sizeof(cost));
     2000#endif
    19972001   perf->reset();
    19982002
     
    20022006   display_final_fbo();
    20032007
     2008#ifdef XINETD
    20042009   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
    20072013   glutSwapBuffers();
    20082014}
     
    21432149   if(log){
    21442150     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());
    21462152     tmp->write(event_log);
    21472153     delete tmp;
     
    21672173
    21682174    //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;
    21712177
    21722178    if(left_down){
     
    21872193#ifdef EVENTLOG
    21882194    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());
    21902196    tmp->write(event_log);
    21912197    delete tmp;
     
    22182224  event_log = fopen("event.txt", "w");
    22192225  assert(event_log!=0);
     2226
     2227  struct timeval time;
     2228  gettimeofday(&time, NULL);
     2229  cur_time = time.tv_sec*1000. + time.tv_usec/1000.;
    22202230}
    22212231
     
    22232233  fclose(event_log);
    22242234}
     2235
     2236double 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
    22252246#endif
    22262247
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r389 r391  
    1616 * render one volume
    1717 */
     18
     19
     20//#define PHONG_SHADING
     21
    1822PixelOut main(v2f IN, /* uniform sampler1D tf,*/
    1923                uniform sampler3D volume,
     
    2731  float4 tex_coord = mul(modelViewInv, IN.TexCoord);
    2832       
    29   if(renderParameters.y==1){ //1 component
     33//if(renderParameters.y==1){ //1 component
    3034
    3135    float4 sample = tex3D(volume, tex_coord.xyz);
    3236
    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
    3838      //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
    4344      float3 half_vector = normalize(+eye_vector+light_vector);          //eye half angle vector
    44 */
     45#endif
     46
    4547      //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;
    4850
    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);
    5152       
    52 /*
     53
     54#ifdef PHONG_SHADING
    5355      //lighting computation
    5456      float normal_dot_light = max(dot(normal, light_vector), 0);
    5557      float normal_dot_half = max(dot(normal, half_vector), 0);
    5658
    57       float ambient = 0.3;
     59      float ambient = 0.1;
    5860      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);
    6062
    6163      float lighting = ambient + diffuse + specular;
    6264      color.xyz = color.xyz * lighting;
    63 */
    6465
    6566      //debug
    6667      //color.xyz = normal.xyz;       //display normals
    67       //if(color.z < 0)
    68         //color.xyz = float3(1,0,0);
     68#endif
    6969
    7070      OUT.Color = color;
    71     }
    72   }
     71//  }
    7372
     73/*
    7474  else if(renderParameters.y==0){
    7575    //3 component
     
    7777    OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x);
    7878  }
     79*/
    7980
    8081  //debug
Note: See TracChangeset for help on using the changeset viewer.