Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/chris/src/camera.cc @ 2068

Last change on this file since 2068 was 2068, checked in by chris, 20 years ago

orxonox/branches/chris: First snippet of the totally revamped base system… perhaps a bit confusing at the moment, but when finished theoretically you only have to subclass the worldentity and track classes to create the game content (even the menu will be a WorldEntity I suppose)

File size: 1.6 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: ...
15   co-programmer: ...
16*/
17
18
19#include "camera.h"
20
21using namespace std;
22
23Camera::Camera ()
24{
25        bound = NULL;
26        desired_place.r = Vector (0,0,0);
27        desired_place.w = Rotation (0,0,0);
28        actual_place.r = Vector (0,0,0);
29        actual_place.w = Rotation (0,0,0);
30}
31
32Camera::~Camera ()
33{
34}
35
36void Camera::time_slice (Uint32 deltaT)
37{
38        update_desired_place ();
39}
40
41void Camera::update_desired_place ()
42{
43                Orxonox *orx = Orxonox::getInstance();
44                Location lookat;
45               
46                if( bound != NULL)
47                {
48                        bound->get_lookat (&lookat);
49                        orx->get_world()->calc_camera_pos (&lookat, &desired_place);
50                }
51                else
52                {
53                        desired_place.r = Vector (0,0,0);
54                        desired_place.w = Rotation (0,0,0); 
55                }
56}
57
58void Camera::apply ()
59{
60        glMatrixMode (GL_PROJECTION);
61                // view
62                // TO DO: implement options for frustum generation
63        glFrustum( -1.0,1.0,-1.0,1.0,1.5,20.0);
64        // rotation
65  float matrix[16];
66  actual_place.w.glmatrix (matrix);
67  glLoadMatrixf (matrix);
68        // translation
69  glTranslatef (actual_place.v.x, actual_place.v.y, actual_place.v.z);
70 
71  glMatrixMode (GL_MODELVIEW);
72}
73
74void Camera::jump (Placement* plc = NULL)
75{
76        if( plc == NULL)
77        {
78                actual_place = desired_place;
79        }
80        else
81        {
82                desired_place = *plc;
83                actual_place = *plc;
84        }
85}
86
87void Camera::bind (WorldEntity* entity)
88{
89        if( entity != NULL) bound = entity; 
90}
Note: See TracBrowser for help on using the repository browser.