Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/camera/src/world_entities/cameraman.cc @ 10348

Last change on this file since 10348 was 10348, checked in by gfilip, 17 years ago

new

File size: 2.8 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Filip Gospodinov
13   co-programmer:
14*/
15
16#include "shell_command.h"
17#include "cameraman.h"
18#include "game_world_data.h"
19#include "state.h"
20#include "sound_engine.h"
21#include <string>
22
23ObjectListDefinition(CameraMan);
24
25
26CameraMan::CameraMan()
27{
28  this->registerObject(this, CameraMan::_objectList);
29
30  this->nearClip = 1.0;
31  this->farClip = 1000.0;
32
33  currentCam=State::getCamera();
34  this->cameras.push_back(currentCam);
35  State::setCamera(currentCam, currentCam->getTarget());
36  this->fadeToBlack=new BlackScreen();
37}
38
39
40void CameraMan::createCam()
41{
42 // Camera* newCamera=new Camera();
43  this->cameras.push_back(new Camera());
44  cameras[cameras.size()-1]->target->detach();
45  cameras[cameras.size()-1]->setClipRegion(nearClip, farClip);
46
47}
48
49void CameraMan::setCam(int cameraNo)
50{
51  if (cameraNo<cameras.size())
52  {
53  currentCam=cameras[cameraNo];
54  State::setCamera(currentCam, currentCam->getTarget());
55  OrxSound::SoundEngine::getInstance()->setListener(currentCam);
56
57  this->fadeToBlack->setParent(this->currentCam);
58  this->fadeToBlack->setRelCoor(3., 0., 0.);
59  }
60
61}
62
63
64
65void CameraMan::moveCurrCam(int x, int y, int z)
66{
67currentCam->target->trans(x,y,z);
68}
69
70
71void CameraMan::moveCam(int x, int y, int z, int camNo)
72{
73cameras[camNo]->target->trans(x,y,z);
74}
75
76
77void CameraMan::changeTarget(int camNo, std::string className, std::string objectName)
78{
79  BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
80  if( object != NULL && object->isA(PNode::staticClassID()))
81    cameras[camNo]->lookAt(dynamic_cast<PNode*>(object));
82}
83
84
85void CameraMan::changeCurrTarget(std::string className, std::string objectName)
86{
87  BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
88  if( object != NULL && object->isA(PNode::staticClassID()))
89    currentCam->lookAt(dynamic_cast<PNode*>(object));
90}
91
92void CameraMan::atachCurrTarget(PNode* target)
93{
94  currentCam->target->atach(target);
95}
96
97void CameraMan::jumpCam(int x, int y, int z, int camNo)
98{
99  cameras[camNo]->target->jump(x, y, z);
100}
101
102
103
104void CameraMan::setClipRegion(float nearCli, float farCli)
105{
106  this->nearClip=nearCli;
107  this->farClip=farCli;
108
109  for(int i = 0; i < this->cameras.size(); i++)
110    cameras[i]->setClipRegion(nearCli, farCli);
111}
112
113
114void CameraMan::jumpCurrCam(int x, int y, int z)
115{
116  currentCam->target->jump(x, y, z);
117}
118
119
120
121
122void CameraMan::togglFade()
123{
124  if( this->fadeToBlack)
125    fadeToBlack->toggleFade();
126}
127
128
129
130//how to get a class fkt pointer
131
132//BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Note: See TracBrowser for help on using the repository browser.