Ignore:
Timestamp:
Nov 13, 2008, 3:24:00 PM (16 years ago)
Author:
gah
Message:

changes to allow panning and zooming (via scrollwhell)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/NvCamera.cpp

    r953 r1215  
    2020
    2121NvCamera::NvCamera(int startx, int starty, int w, int h,
    22                    double loc_x, double loc_y, double loc_z,
    23                    double target_x, double target_y, double target_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)
    3232{
    3333    /*empty*/
    3434}
    3535
    36 NvCamera::~NvCamera()
    37 {
    38     /*empty*/
    39 }       
    40 
    41 void
    42 NvCamera::move(double loc_x, double loc_y, double loc_z)
    43 {
    44     location = Vector3(loc_x, loc_y, loc_z);
    45 }
    46 
    47 void
    48 NvCamera::aim(double target_x, double target_y, double target_z)
    49 {
    50     target = Vector3(target_x, target_y, target_z);
    51 }
    52 
    53 void
    54 NvCamera::rotate(double angle_x, double angle_y, double angle_z)
    55 {
    56     angle = Vector3(angle_x, angle_y, angle_z);
    57 }
    5836
    5937void
     
    6139{
    6240    //fprintf(stderr, "camera: %d, %d\n", width, height);
    63     glViewport(startX, startY, width, height);
     41    glViewport(startX_, startY_, width_, height_);
    6442    glMatrixMode(GL_PROJECTION);
    6543    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);
    6847
    6948    glMatrixMode(GL_MODELVIEW);
    7049    glLoadIdentity();
    7150
    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,
    7453              0., 1., 0.);
    7554
    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.);
    7958}
    8059
    81 void
    82 NvCamera::set_screen_size(int sx, int sy, int w, int h)
    83 {
    84     width = w, height = h;
    85     startX = sx, startY = sy;
    86 }
Note: See TracChangeset for help on using the changeset viewer.