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

Last change on this file since 2824 was 2798, checked in by ldelgass, 12 years ago

Add emacs mode magic line in preparation for indentation cleanup

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
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 "Trace.h"
19#include <GL/glu.h>
20#include "NvCamera.h"
21
22NvCamera::NvCamera(int startx, int starty, int w, int h,
23                   float loc_x, float loc_y, float loc_z,
24                   float target_x, float target_y, float target_z,
25                   float angle_x, float angle_y, float angle_z):
26    location_(Vector3(loc_x, loc_y, loc_z)),
27    target_(Vector3(target_x, target_y, target_z)),
28    angle_(Vector3(angle_x, angle_y, angle_z)),
29    width_(w),
30    height_(h),
31    startX_(startx),
32    startY_(starty)
33{
34    /*empty*/
35}
36
37
38void
39NvCamera::initialize()
40{
41    TRACE("camera: %d, %d\n", width_, height_);
42    glViewport(startX_, startY_, width_, height_);
43    glMatrixMode(GL_PROJECTION);
44    glLoadIdentity();
45    gluPerspective(30,
46                   (GLdouble)(width_ - startX_)/(GLdouble)(height_ - startY_),
47                   0.1, 50.0);
48
49    glMatrixMode(GL_MODELVIEW);
50    glLoadIdentity();
51
52    gluLookAt(location_.x, location_.y, location_.z,
53              target_.x, target_.y, target_.z,
54              0., 1., 0.);
55
56    glRotated(angle_.x, 1., 0., 0.);
57    glRotated(angle_.y, 0., 1., 0.);
58    glRotated(angle_.z, 0., 0., 1.);
59}
60
Note: See TracBrowser for help on using the repository browser.