File: camera.hpp

package info (click to toggle)
3ddesktop 0.2.9-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,132 kB
  • ctags: 763
  • sloc: cpp: 6,525; sh: 3,426; makefile: 84
file content (81 lines) | stat: -rw-r--r-- 2,078 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//  ----------------------------------------------------------
//
//  Copyright (C) 2004 Brad Wasson <bard@wassonartistry.com>
//
//  This file is part of 3ddesktop.
//
//  3ddesktop is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.
//
//  3ddesktop is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with 3ddesktop; see the file COPYING.   If not, write to
//  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//

#ifndef _CAMERA_HPP
#define _CAMERA_HPP

using namespace std;

class Vector
{
public:
    
    Vector() { x = y = z = 0.0f;}

    Vector(float _x, float _y, float _z) 
    { 
        x = _x; y = _y; z = _z;
    }

    Vector operator+(Vector vector)
    {
        return Vector(vector.x + x, vector.y + y, vector.z + z);
    }

    Vector operator-(Vector vector)
    {
        return Vector(x - vector.x, y - vector.y, z - vector.z);
    }
    
    Vector operator*(float num)
    {
        return Vector(x * num, y * num, z * num);
    }

    Vector operator/(float num)
    {
        return Vector(x / num, y / num, z / num);
    }

    float x, y, z;
};


class Camera {

public:

    Vector position;
    Vector viewvector;
    Vector upvector;

    Camera();
    
    void PositionCamera(float position_x, float position_y, float position_z,
                        float viewvector_x, float viewvector_y, float viewvector_z,
                        float upvector_x, float upvector_y, float upvector_z);
    void RotateView(float angle, float x, float y, float z);
    void RotateAroundPoint(Vector center, float angle, float x, float y, float z);
    void Look(void);
};


#endif // _CAMERA_HPP