source: trunk/packages/vizservers/nanovis/NvCamera.cpp @ 1297

Last change on this file since 1297 was 1215, checked in by gah, 16 years ago

changes to allow panning and zooming (via scrollwhell)

File size: 1.6 KB
Line 
1
2/*
3 * ----------------------------------------------------------------------
4 * NvCamera.cpp : NvCamera class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2006  Purdue Research Foundation
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16
17#include <stdio.h>
18#include <GL/glu.h>
19#include "NvCamera.h"
20
21NvCamera::NvCamera(int startx, int starty, int w, int h,
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{
33    /*empty*/
34}
35
36
37void
38NvCamera::activate()
39{
40    //fprintf(stderr, "camera: %d, %d\n", width, height);
41    glViewport(startX_, startY_, width_, height_);
42    glMatrixMode(GL_PROJECTION);
43    glLoadIdentity();
44    gluPerspective(30,
45                   (GLdouble)(width_ - startX_)/(GLdouble)(height_ - startY_),
46                   0.1, 50.0);
47
48    glMatrixMode(GL_MODELVIEW);
49    glLoadIdentity();
50
51    gluLookAt(location_.x, location_.y, location_.z,
52              target_.x, target_.y, target_.z,
53              0., 1., 0.);
54
55    glRotated(angle_.x, 1., 0., 0.);
56    glRotated(angle_.y, 0., 1., 0.);
57    glRotated(angle_.z, 0., 0., 1.);
58}
59
Note: See TracBrowser for help on using the repository browser.