source: trunk/vizservers/nanovis/NvCamera.cpp @ 953

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

remove warnings from compile

File size: 2.1 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                   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)
32{
33    /*empty*/
34}
35
36NvCamera::~NvCamera()
37{
38    /*empty*/
39}       
40
41void
42NvCamera::move(double loc_x, double loc_y, double loc_z)
43{
44    location = Vector3(loc_x, loc_y, loc_z);
45}
46
47void
48NvCamera::aim(double target_x, double target_y, double target_z)
49{
50    target = Vector3(target_x, target_y, target_z);
51}
52
53void
54NvCamera::rotate(double angle_x, double angle_y, double angle_z)
55{
56    angle = Vector3(angle_x, angle_y, angle_z);
57}
58
59void
60NvCamera::activate()
61{
62    //fprintf(stderr, "camera: %d, %d\n", width, height);
63    glViewport(startX, startY, width, height);
64    glMatrixMode(GL_PROJECTION);
65    glLoadIdentity();
66    gluPerspective(30, (GLdouble)(width - startX)/(GLdouble)(height - startY),
67        0.1, 50.0);
68
69    glMatrixMode(GL_MODELVIEW);
70    glLoadIdentity();
71
72    gluLookAt(location.x, location.y, location.z,
73              target.x, target.y, target.z,
74              0., 1., 0.);
75
76    glRotated(angle.x, 1., 0., 0.);
77    glRotated(angle.y, 0., 1., 0.);
78    glRotated(angle.z, 0., 0., 1.);
79}
80
81void
82NvCamera::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 TracBrowser for help on using the repository browser.