source: trunk/src/camera.cpp @ 1307

Last change on this file since 1307 was 1307, checked in by sam, 8 years ago

core: move the Camera class from Orbital to the engine core.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstring>
16#include <cstdlib>
17
18#include "core.h"
19
20#if defined _WIN32 || defined _XBOX
21#   define strcasecmp _stricmp
22#endif
23
24namespace lol
25{
26
27Camera::Camera(vec3 const &position, vec3 const &target, vec3 const &up)
28  : m_target(target),
29    m_up(up)
30{
31    m_gamegroup = GAMEGROUP_BEFORE;
32
33    SetPosition(position);
34}
35
36Camera::~Camera()
37{
38}
39
40void Camera::SetPosition(vec3 const &pos)
41{
42    m_position = pos;
43}
44
45mat4 const &Camera::GetViewMatrix()
46{
47    return m_view_matrix;
48}
49
50mat4 const &Camera::GetProjMatrix()
51{
52    return m_proj_matrix;
53}
54
55void Camera::TickGame(float deltams)
56{
57    WorldEntity::TickGame(deltams);
58
59    m_view_matrix = mat4::lookat(m_position, m_target, m_up);
60    m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 1000.0f);
61    //m_proj_matrix = mat4::ortho(-160, 160, -120, 120, .1f, 2000.0f);
62}
63
64void Camera::TickDraw(float deltams)
65{
66    WorldEntity::TickDraw(deltams);
67}
68
69} /* namespace lol */
70
Note: See TracBrowser for help on using the repository browser.