Changeset 1215 for trunk/packages/vizservers
- Timestamp:
- Nov 13, 2008 3:24:00 PM (16 years ago)
- Location:
- trunk/packages/vizservers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r1194 r1215 694 694 695 695 static int 696 CameraAimOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 697 { 698 double x0, y0, z0; 699 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x0) != TCL_OK) || 700 (Tcl_GetDoubleFromObj(interp, objv[3], &y0) != TCL_OK) || 701 (Tcl_GetDoubleFromObj(interp, objv[4], &z0) != TCL_OK)) { 702 return TCL_ERROR; 703 } 704 NanoVis::cam->aim(x0, y0, z0); 705 return TCL_OK; 706 } 707 708 static int 709 CameraAngleOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 710 { 711 double xangle, yangle, zangle; 712 if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) || 713 (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) || 714 (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) { 715 return TCL_ERROR; 716 } 717 NanoVis::cam->rotate(xangle, yangle, zangle); 718 return TCL_OK; 719 } 696 CameraPanOp(ClientData cdata, Tcl_Interp *interp, int objc, 697 Tcl_Obj *const *objv) 698 { 699 double dx, dy, dz; 700 if ((Tcl_GetDoubleFromObj(interp, objv[2], &dx) != TCL_OK) || 701 (Tcl_GetDoubleFromObj(interp, objv[3], &dy) != TCL_OK) || 702 (Tcl_GetDoubleFromObj(interp, objv[4], &dz) != TCL_OK)) { 703 return TCL_ERROR; 704 } 705 NanoVis::cam->aim(dx, dy, dz); 706 NanoVis::cam->x(dx); 707 NanoVis::cam->y(dy); 708 NanoVis::cam->z(dz); 709 return TCL_OK; 710 } 711 712 static int 713 CameraAimOp(ClientData cdata, Tcl_Interp *interp, int objc, 714 Tcl_Obj *const *objv) 715 { 716 double x, y, z; 717 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK) || 718 (Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK) || 719 (Tcl_GetDoubleFromObj(interp, objv[4], &z) != TCL_OK)) { 720 return TCL_ERROR; 721 } 722 NanoVis::cam->aim(x, y, z); 723 return TCL_OK; 724 } 725 726 static int 727 CameraAngleOp(ClientData cdata, Tcl_Interp *interp, int objc, 728 Tcl_Obj *const *objv) 729 { 730 double theta, phi, psi; 731 if ((Tcl_GetDoubleFromObj(interp, objv[2], &phi) != TCL_OK) || 732 (Tcl_GetDoubleFromObj(interp, objv[3], &theta) != TCL_OK) || 733 (Tcl_GetDoubleFromObj(interp, objv[4], &psi) != TCL_OK)) { 734 return TCL_ERROR; 735 } 736 NanoVis::cam->rotate(phi, theta, psi); 737 return TCL_OK; 738 } 739 720 740 721 741 static int … … 726 746 return TCL_ERROR; 727 747 } 728 NanoVis:: zoom(zoom);748 NanoVis::cam->z(-2.5 / zoom); 729 749 return TCL_OK; 730 750 } … … 733 753 {"aim", 2, CameraAimOp, 5, 5, "x y z",}, 734 754 {"angle", 2, CameraAngleOp, 5, 5, "xAngle yAngle zAngle",}, 755 {"pan", 1, CameraPanOp, 5, 5, "x y z",}, 735 756 {"zoom", 1, CameraZoomOp, 3, 3, "factor",}, 736 757 }; … … 2128 2149 2129 2150 // the variables below should be reassigned 2130 int heightmap_index = 0;2131 2151 int image_width = 512; 2132 2152 int image_height = 512; -
trunk/packages/vizservers/nanovis/NvCamera.cpp
r953 r1215 20 20 21 21 NvCamera::NvCamera(int startx, int starty, int w, int h, 22 double loc_x, double loc_y, doubleloc_z,23 double target_x, double target_y, doubletarget_z,24 int angle_x, int angle_y, int angle_z):25 location (Vector3(loc_x, loc_y, loc_z)),26 target (Vector3(target_x, target_y, target_z)),27 angle (Vector3(angle_x, angle_y, angle_z)),28 width (w),29 height (h),30 startX (startx),31 startY (starty)22 float loc_x, float loc_y, float loc_z, 23 float target_x, float target_y, float target_z, 24 float angle_x, float angle_y, float angle_z): 25 location_(Vector3(loc_x, loc_y, loc_z)), 26 target_(Vector3(target_x, target_y, target_z)), 27 angle_(Vector3(angle_x, angle_y, angle_z)), 28 width_(w), 29 height_(h), 30 startX_(startx), 31 startY_(starty) 32 32 { 33 33 /*empty*/ 34 34 } 35 35 36 NvCamera::~NvCamera()37 {38 /*empty*/39 }40 41 void42 NvCamera::move(double loc_x, double loc_y, double loc_z)43 {44 location = Vector3(loc_x, loc_y, loc_z);45 }46 47 void48 NvCamera::aim(double target_x, double target_y, double target_z)49 {50 target = Vector3(target_x, target_y, target_z);51 }52 53 void54 NvCamera::rotate(double angle_x, double angle_y, double angle_z)55 {56 angle = Vector3(angle_x, angle_y, angle_z);57 }58 36 59 37 void … … 61 39 { 62 40 //fprintf(stderr, "camera: %d, %d\n", width, height); 63 glViewport(startX , startY, width, height);41 glViewport(startX_, startY_, width_, height_); 64 42 glMatrixMode(GL_PROJECTION); 65 43 glLoadIdentity(); 66 gluPerspective(30, (GLdouble)(width - startX)/(GLdouble)(height - startY), 67 0.1, 50.0); 44 gluPerspective(30, 45 (GLdouble)(width_ - startX_)/(GLdouble)(height_ - startY_), 46 0.1, 50.0); 68 47 69 48 glMatrixMode(GL_MODELVIEW); 70 49 glLoadIdentity(); 71 50 72 gluLookAt(location .x, location.y, location.z,73 target .x, target.y, target.z,51 gluLookAt(location_.x, location_.y, location_.z, 52 target_.x, target_.y, target_.z, 74 53 0., 1., 0.); 75 54 76 glRotated(angle .x, 1., 0., 0.);77 glRotated(angle .y, 0., 1., 0.);78 glRotated(angle .z, 0., 0., 1.);55 glRotated(angle_.x, 1., 0., 0.); 56 glRotated(angle_.y, 0., 1., 0.); 57 glRotated(angle_.z, 0., 0., 1.); 79 58 } 80 59 81 void82 NvCamera::set_screen_size(int sx, int sy, int w, int h)83 {84 width = w, height = h;85 startX = sx, startY = sy;86 } -
trunk/packages/vizservers/nanovis/NvCamera.h
r953 r1215 22 22 class NvCamera { 23 23 24 public: 25 Vector3 location; //Location of the camera in the scene 26 Vector3 target; //Location the camera is looking at. 24 Vector3 location_; //Location of the camera in the scene 25 Vector3 target_; //Location the camera is looking at. 27 26 //location and target: two points define the 28 27 //line-of-sight 29 Vector3 angle ;//rotation angles of camera along x, y, z30 int width ; //screen size31 int height ; //screen size32 int startX ;33 int startY ;28 Vector3 angle_; //rotation angles of camera along x, y, z 29 int width_; //screen width 30 int height_; //screen height 31 int startX_; 32 int startY_; 34 33 35 ~NvCamera(); 34 public: 35 ~NvCamera(void) { 36 /*empty*/ 37 } 36 38 NvCamera(int startx, int starty, int w, int h, 37 double loc_x, double loc_y, double loc_z, 38 double target_x, double target_y, double target_z, 39 int angle_x, int angle_y, int angle_z); 40 void move(double loc_x, double loc_y, double loc_z); //move location of camera 41 void aim(double target_x, double target_y, double target_z); //change target point 42 void rotate(double angle_x, double angle_y, double angle_z); //change target point 43 void activate(); //make the camera setting active, this has to be called 44 //before drawing things. 45 void set_screen_size(int startx, int starty, int w, int h); 39 float loc_x, float loc_y, float loc_z, 40 float target_x, float target_y, float target_z, 41 float angle_x, float angle_y, float angle_z); 42 43 //move location of camera 44 void x(double loc_x) { 45 location_.x = loc_x; 46 } 47 float x(void) { 48 return location_.x; 49 } 50 void y(double loc_y) { 51 location_.y = loc_y; 52 } 53 float y(void) { 54 return location_.y; 55 } 56 void z(double loc_z) { 57 location_.z = loc_z; 58 } 59 float z(void) { 60 return location_.z; 61 } 62 63 void aim(double target_x, double target_y, double target_z) { 64 target_ = Vector3(target_x, target_y, target_z); 65 } 66 Vector3 aim(void) { 67 return target_; 68 } 69 void rotate(double angle_x, double angle_y, double angle_z) { 70 angle_ = Vector3(angle_x, angle_y, angle_z); 71 } 72 void rotate(Vector3 angle) { 73 angle_ = angle; 74 } 75 Vector3 rotate(void) { 76 return angle_; 77 } 78 void set_screen_size(int sx, int sy, int w, int h) { 79 width_ = w, height_ = h; 80 startX_ = sx, startY_ = sy; 81 } 82 void activate(void); //make the camera setting active, this has to be 83 //called before drawing things. 46 84 }; 47 85 -
trunk/packages/vizservers/nanovis/nanovis.cpp
r1211 r1215 171 171 172 172 // Object rotation angles 173 static float live_rot_x = 90.;174 static float live_rot_y = 180.;175 static float live_rot_z = -135;173 const float def_rot_x = 90.; 174 const float def_rot_y = 180.; 175 const float def_rot_z = -135; 176 176 177 177 // Object translation location from the origin 178 static float live_obj_x = -0.0;179 static float live_obj_y = -0.0;180 static float live_obj_z = -2.5;178 const float def_obj_x = -0.0; 179 const float def_obj_y = -0.0; 180 const float def_obj_z = -2.5; 181 181 182 182 … … 507 507 } 508 508 return tf; 509 }510 511 void512 NanoVis::zoom(double zoom)513 {514 live_obj_z = -2.5 / zoom;515 cam->move(live_obj_x, live_obj_y, live_obj_z);516 509 } 517 510 … … 884 877 //create the camera with default setting 885 878 cam = new NvCamera(0, 0, win_width, win_height, 886 live_obj_x, live_obj_y, live_obj_z,887 888 (int)live_rot_x, (int)live_rot_y, (int)live_rot_z);879 def_obj_x, def_obj_y, def_obj_z, 880 0., 0., 100., 881 def_rot_x, def_rot_y, def_rot_z); 889 882 890 883 glEnable(GL_TEXTURE_2D); … … 1336 1329 float y = vert[3*i+1]; 1337 1330 float z = vert[3*i+2]; 1338 1339 float dis = (x-live_obj_x)*(x-live_obj_x) + (y-live_obj_y)*(y-live_obj_y) + (z-live_obj_z)*(z-live_obj_z); 1331 float dx, dy, dz; 1332 dx = x - cam->x(); 1333 dy = y - cam->y(); 1334 dz = z - cam->z(); 1335 float dis = (dx * dx) + (dy * dy) + (dz * dz); 1340 1336 p[i].x = x; 1341 1337 p[i].y = y; … … 1929 1925 NanoVis::update_rot(int delta_x, int delta_y) 1930 1926 { 1931 live_rot_x += delta_x; 1932 live_rot_y += delta_y; 1933 1934 if (live_rot_x > 360.0) { 1935 live_rot_x -= 360.0; 1936 } else if(live_rot_x < -360.0) { 1937 live_rot_x += 360.0; 1938 } 1939 if (live_rot_y > 360.0) { 1940 live_rot_y -= 360.0; 1941 } else if(live_rot_y < -360.0) { 1942 live_rot_y += 360.0; 1943 } 1944 cam->rotate(live_rot_x, live_rot_y, live_rot_z); 1927 Vector3 angle; 1928 1929 angle = cam->rotate(); 1930 angle.x += delta.x; 1931 angle.y += delta.y; 1932 1933 if (angle.x > 360.0) { 1934 angle.x -= 360.0; 1935 } else if(angle.x < -360.0) { 1936 angle.x += 360.0; 1937 } 1938 if (angle.y > 360.0) { 1939 angle.y -= 360.0; 1940 } else if(angle.y < -360.0) { 1941 angle.y += 360.0; 1942 } 1943 cam->rotate(angle); 1945 1944 } 1946 1945 … … 1948 1947 NanoVis::update_trans(int delta_x, int delta_y, int delta_z) 1949 1948 { 1950 live_obj_x += delta_x*0.03;1951 live_obj_y += delta_y*0.03;1952 live_obj_z += delta_z*0.03;1949 cam->x(cam->x() + delta_x * 0.03); 1950 cam->y(cam->y() + delta_y * 0.03); 1951 cam->z(cam->z() + delta_z * 0.03); 1953 1952 } 1954 1953 … … 1988 1987 break; 1989 1988 case 'w': //zoom out 1990 live_obj_z-=0.05;1989 cam->z(cam->z() - 0.05); 1991 1990 log = true; 1992 cam->move(live_obj_x, live_obj_y, live_obj_z);1993 1991 break; 1994 1992 case 's': //zoom in 1995 live_obj_z+=0.05;1993 cam->z(cam->z() + 0.05); 1996 1994 log = true; 1997 cam->move(live_obj_x, live_obj_y, live_obj_z);1998 1995 break; 1999 1996 case 'a': //left 2000 live_obj_x-=0.05;1997 cam->x(cam->x() - 0.05); 2001 1998 log = true; 2002 cam->move(live_obj_x, live_obj_y, live_obj_z);2003 1999 break; 2004 2000 case 'd': //right 2005 live_obj_x+=0.05;2001 cam->x(cam->x() + 0.05); 2006 2002 log = true; 2007 cam->move(live_obj_x, live_obj_y, live_obj_z);2008 2003 break; 2009 2004 case 'i': … … 2027 2022 #ifdef EVENTLOG 2028 2023 if(log){ 2029 float param[3] = {live_obj_x, live_obj_y, live_obj_z}; 2024 float param[3]; 2025 param[0] = cam->x(); 2026 param[1] = cam->y(); 2027 param[2] = cam->z(); 2030 2028 Event* tmp = new Event(EVENT_MOVE, param, NvGetTimeInterval()); 2031 2029 tmp->write(event_log); … … 2070 2068 2071 2069 #ifdef EVENTLOG 2072 float param[3] = {live_rot_x, live_rot_y, live_rot_z};2073 Event* tmp = new Event(EVENT_ROTATE, param, NvGetTimeInterval());2070 Vector3 angle = cam->rotate(); 2071 Event* tmp = new Event(EVENT_ROTATE, &angle, NvGetTimeInterval()); 2074 2072 tmp->write(event_log); 2075 2073 delete tmp; -
trunk/packages/vizservers/nanovis/nanovis.h
r1194 r1215 163 163 static void update(void); 164 164 static void display_offscreen_buffer(); 165 static void zoom(double zoom);166 165 static int render_legend(TransferFunction *tf, double min, double max, 167 166 int width, int height, const char* volArg); -
trunk/packages/vizservers/pymolproxy/pymolproxy.c
r1213 r1215 1087 1087 { 1088 1088 double factor = 0.0; 1089 double zmove = 0.0;1090 1089 PymolProxy *proxyPtr = clientData; 1091 1090 int defer = 0, push = 0, arg, varg = 1; … … 1103 1102 } 1104 1103 } 1105 zmove = factor * -75;1106 1107 1104 proxyPtr->need_update = !defer || push; 1108 1105 proxyPtr->immediate_update |= push; 1109 1106 proxyPtr->invalidate_cache = 1; 1110 1111 if (zmove != 0.0) 1112 Send(proxyPtr,"move z, %f\n", factor); 1113 1107 if (factor != 0.0) { 1108 Send(proxyPtr,"move z,%f\n", factor); 1109 } 1110 return proxyPtr->status; 1111 } 1112 1113 static int 1114 PanCmd(ClientData clientData, Tcl_Interp *interp, int argc, 1115 const char *argv[]) 1116 { 1117 PymolProxy *proxyPtr = clientData; 1118 double x, y; 1119 int i; 1120 int defer, push; 1121 1122 clear_error(proxyPtr); 1123 defer = push = FALSE; 1124 for (i = 1; i < argc; i++) { 1125 if (strcmp(argv[i],"-defer") == 0) { 1126 defer = 1; 1127 } else if (strcmp(argv[i],"-push") == 0) { 1128 push = 1; 1129 } else { 1130 break; 1131 } 1132 } 1133 if ((Tcl_GetDouble(interp, argv[i], &x) != TCL_OK) || 1134 (Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) { 1135 return TCL_ERROR; 1136 } 1137 proxyPtr->need_update = !defer || push; 1138 proxyPtr->immediate_update |= push; 1139 proxyPtr->invalidate_cache = 1; 1140 if (x != 0.0) { 1141 Send(proxyPtr,"move x,%f\n", x * 0.005); 1142 } 1143 if (y != 0.0) { 1144 Send(proxyPtr,"move y,%f\n", -y * 0.005); 1145 } 1114 1146 return proxyPtr->status; 1115 1147 } … … 1326 1358 Tcl_CreateCommand(interp, "disable", DisableCmd, &proxy, NULL); 1327 1359 Tcl_CreateCommand(interp, "enable", EnableCmd, &proxy, NULL); 1360 Tcl_CreateCommand(interp, "pan", PanCmd, &proxy, NULL); 1328 1361 1329 1362 // Main Proxy Loop … … 1355 1388 if (!proxy.immediate_update) { 1356 1389 status = poll(ufd, 3, timeout); 1357 trace("result of poll = %d: %s", status, strerror(errno));1358 1390 } 1359 1391 if ( status < 0 ) { … … 1405 1437 if (nRead <= 0) { 1406 1438 /* It's possible to have already drained the channel in 1407 * response to a client command (handled above). Skip1439 * response to a client command handled above. Skip 1408 1440 * it if we're blocking. */ 1409 1441 if ((errno == EAGAIN) || (errno == EINTR)) {
Note: See TracChangeset
for help on using the changeset viewer.