source: GTP/trunk/Lib/Vis/Preprocessing/src/mixkit/MxCamera.cxx @ 1097

Revision 1097, 1.0 KB checked in by mattausch, 18 years ago (diff)
Line 
1/************************************************************************
2
3  MxCamera
4
5  Copyright (C) 1998 Michael Garland.  See "COPYING.txt" for details.
6 
7  $Id: MxCamera.cxx,v 1.1 2002/09/24 16:53:54 wimmer Exp $
8
9 ************************************************************************/
10
11#include "stdmix.h"
12#include "MxCamera.h"
13
14
15
16void MxCamera::look_at(const MxBounds& bounds, double ratio)
17{
18    double d = 3*bounds.radius / tan(60*M_PI/180.0);
19
20    at = bounds.center;
21    from = at;
22
23    from[Z] += d;
24
25    up[X] = 0; up[Y] = 1; up[Z] = 0;
26
27    fovy = 60.0;
28    aspect = ratio;
29
30    znear = d/20;
31    zfar = 10*d;
32}
33
34void MxCamera::apply()
35{
36    gluPerspective(fovy, aspect, znear, zfar);
37    gluLookAt(from[X], from[Y], from[Z],
38              at[X], at[Y], at[Z],
39              up[X], up[Y], up[Z]);
40}
41
42void MxCamera::apply(GLenum mode)
43{
44    GLint last_mode; glGetIntegerv(GL_MATRIX_MODE, &last_mode);
45      glMatrixMode(mode);
46      apply();
47    glMatrixMode((GLenum)last_mode);
48}
Note: See TracBrowser for help on using the repository browser.