source: trunk/orbital/camera.h @ 1302

Last change on this file since 1302 was 1302, checked in by sam, 9 years ago

orbital: make better use of the camera.

File size: 1.2 KB
Line 
1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7/* FIXME: this file is pure crap; it's only a test. */
8
9#if !defined __CAMERA_H__
10#define __CAMERA_H__
11
12class Camera : public WorldEntity
13{
14public:
15    Camera(vec3 const &position, vec3 const &target, vec3 const &up)
16      : m_target(target),
17        m_up(up)
18    {
19        m_gamegroup = GAMEGROUP_BEFORE;
20
21        SetPosition(position);
22    }
23
24    ~Camera()
25    {
26    }
27
28    char const *GetName() { return "<camera>"; }
29
30    void SetPosition(vec3 const &pos) { m_position = pos; }
31
32    mat4 const &GetViewMatrix() { return m_view_matrix; }
33    mat4 const &GetProjMatrix() { return m_proj_matrix; }
34
35protected:
36    virtual void TickGame(float deltams)
37    {
38        WorldEntity::TickGame(deltams);
39
40        m_view_matrix = mat4::lookat(m_position, m_target, m_up);
41        m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 1000.0f);
42        //m_proj_matrix = mat4::ortho(0, 640, 0, -480, .1f, 2000.0f);
43    }
44
45    virtual void TickDraw(float deltams)
46    {
47        WorldEntity::TickDraw(deltams);
48    }
49
50private:
51    mat4 m_view_matrix, m_proj_matrix;
52    vec3 m_target, m_up;
53};
54
55#endif /* __CAMERA_H__ */
56
Note: See TracBrowser for help on using the repository browser.