iCub-main
Loading...
Searching...
No Matches
camera.cpp
Go to the documentation of this file.
1/*
2* camera.cpp
3*/
4
5/*
6* Copyright (C) 2009 RobotCub Consortium
7* Author: Alessandro Scalzo alessandro.scalzo@iit.it
8* CopyPolicy: Released under the terms of the GNU GPL v2.0.
9*
10* Based on:
11*
12* Qavimator
13* Copyright (C) 2006 by Zi Ree *
14* Zi Ree @ SecondLife *
15* Released under the terms of the GNU GPL v2.0.
16*/
17
18#ifdef __APPLE__
19#include <OpenGL/glu.h>
20#else
21#if defined(WIN32) || defined(WIN64)
22#include <windows.h>
23#endif
24#include <GL/glu.h>
25#endif
26
27#include "camera.h"
28
30{
31 reset();
32}
33
34void Camera::rotate(float x, float y)
35{
36 rotX += x;
37 if (rotX < 2) rotX = 2;
38 if (rotX > 80) rotX = 80;
39 rotY += y;
40 if (rotY < 0) rotY += 360;
41 if (rotY > 360) rotY -= 360;
42}
43
44void Camera::pan(float x, float y, float z)
45{
46 panX -= x/2;
47 if (panX < -500) panX = -500;
48 if (panX > 500) panX = 500;
49 panY += y/2;
50 if (panY < 5) panY = 5;
51 if (panY > 500) panY = 500;
52 panZ += z;
53 if (panZ < 10) panZ = 10;
54 if (panZ > 1000) panZ = 1000;
55}
56
58{
59 glMatrixMode(GL_MODELVIEW);
60 glLoadIdentity();
61 gluLookAt(panX, panY, panZ, panX, panY, 0, 0, 1, 0);
62 glRotatef(rotX, 1, 0, 0);
63 glRotatef(rotY, 0, 1, 0);
64}
65
67{
68 rotX = 10;
69 rotY = 0;
70 panX = 0;
71 panY = 40;
72 panZ = 100;
73}
74
75float Camera::xRotation() const
76{
77 return rotX;
78}
79
80float Camera::yRotation() const
81{
82 return rotY;
83}
Camera()
Definition camera.cpp:29
void reset()
Definition camera.cpp:66
void setModelView()
Definition camera.cpp:57
float xRotation() const
Definition camera.cpp:75
float yRotation() const
Definition camera.cpp:80
void rotate(float x, float y)
Definition camera.cpp:34
void pan(float x, float y, float z)
Definition camera.cpp:44