[10206] | 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 | |
---|
[10192] | 16 | #include "shell_command.h" |
---|
| 17 | #include "cameraman.h" |
---|
[10238] | 18 | #include "game_world_data.h" |
---|
[10195] | 19 | #include "state.h" |
---|
[10259] | 20 | #include "sound_engine.h" |
---|
[10338] | 21 | #include <string> |
---|
[10192] | 22 | |
---|
[10343] | 23 | ObjectListDefinition(CameraMan); |
---|
[10192] | 24 | |
---|
[10272] | 25 | |
---|
[10343] | 26 | CameraMan::CameraMan() |
---|
[10192] | 27 | { |
---|
[10343] | 28 | this->registerObject(this, CameraMan::_objectList); |
---|
[10272] | 29 | |
---|
| 30 | this->nearClip = 1.0; |
---|
| 31 | this->farClip = 1000.0; |
---|
| 32 | |
---|
[10197] | 33 | currentCam=State::getCamera(); |
---|
[10206] | 34 | this->cameras.push_back(currentCam); |
---|
[10238] | 35 | State::setCamera(currentCam, currentCam->getTarget()); |
---|
[10342] | 36 | this->fadeToBlack=new BlackScreen(); |
---|
[10192] | 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
[10343] | 40 | void CameraMan::createCam() |
---|
[10192] | 41 | { |
---|
[10238] | 42 | // Camera* newCamera=new Camera(); |
---|
| 43 | this->cameras.push_back(new Camera()); |
---|
[10254] | 44 | cameras[cameras.size()-1]->target->detach(); |
---|
[10272] | 45 | cameras[cameras.size()-1]->setClipRegion(nearClip, farClip); |
---|
[10259] | 46 | |
---|
[10192] | 47 | } |
---|
| 48 | |
---|
[10343] | 49 | void CameraMan::setCam(int cameraNo) |
---|
[10192] | 50 | { |
---|
[10206] | 51 | if (cameraNo<cameras.size()) |
---|
[10197] | 52 | { |
---|
[10193] | 53 | currentCam=cameras[cameraNo]; |
---|
[10198] | 54 | State::setCamera(currentCam, currentCam->getTarget()); |
---|
[10259] | 55 | OrxSound::SoundEngine::getInstance()->setListener(currentCam); |
---|
[10343] | 56 | this->fadeToBlack->setParent(this->currentCam); |
---|
| 57 | this->fadeToBlack->setRelCoor(3., 0., 0.); |
---|
[10197] | 58 | } |
---|
[10195] | 59 | |
---|
[10192] | 60 | } |
---|
| 61 | |
---|
[10195] | 62 | |
---|
[10343] | 63 | void CameraMan::testCam() |
---|
[10254] | 64 | { |
---|
| 65 | cameras[1]->lookAt(currentCam->getTarget()); |
---|
| 66 | cameras[1]->setParentSoft(currentCam->getParent()); |
---|
| 67 | } |
---|
[10204] | 68 | |
---|
[10254] | 69 | |
---|
[10343] | 70 | void CameraMan::moveCurrCam(int x, int y, int z) |
---|
[10204] | 71 | { |
---|
| 72 | currentCam->target->trans(x,y,z); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
[10343] | 76 | void CameraMan::moveCam(int x, int y, int z, int camNo) |
---|
[10204] | 77 | { |
---|
| 78 | cameras[camNo]->target->trans(x,y,z); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
[10343] | 82 | void CameraMan::changeTarget(int camNo, std::string className, std::string objectName) |
---|
[10204] | 83 | { |
---|
[10338] | 84 | BaseObject* object = ObjectListBase::getBaseObject(className, objectName); |
---|
| 85 | if( object != NULL && object->isA(PNode::staticClassID())) |
---|
| 86 | cameras[camNo]->lookAt(dynamic_cast<PNode*>(object)); |
---|
[10204] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
[10343] | 90 | void CameraMan::changeCurrTarget(std::string className, std::string objectName) |
---|
[10204] | 91 | { |
---|
[10338] | 92 | BaseObject* object = ObjectListBase::getBaseObject(className, objectName); |
---|
| 93 | if( object != NULL && object->isA(PNode::staticClassID())) |
---|
| 94 | currentCam->lookAt(dynamic_cast<PNode*>(object)); |
---|
[10236] | 95 | } |
---|
| 96 | |
---|
[10343] | 97 | void CameraMan::atachCurrTarget(PNode* target) |
---|
[10236] | 98 | { |
---|
[10205] | 99 | currentCam->target->atach(target); |
---|
[10204] | 100 | } |
---|
| 101 | |
---|
[10343] | 102 | void CameraMan::jumpCam(int x, int y, int z, int camNo) |
---|
[10204] | 103 | { |
---|
[10206] | 104 | cameras[camNo]->target->jump(x, y, z); |
---|
[10204] | 105 | } |
---|
| 106 | |
---|
| 107 | |
---|
[10272] | 108 | |
---|
[10343] | 109 | void CameraMan::setClipRegion(float nearCli, float farCli) |
---|
[10272] | 110 | { |
---|
| 111 | this->nearClip=nearCli; |
---|
| 112 | this->farClip=farCli; |
---|
| 113 | |
---|
| 114 | for(int i = 0; i < this->cameras.size(); i++) |
---|
| 115 | cameras[i]->setClipRegion(nearCli, farCli); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | |
---|
[10343] | 119 | void CameraMan::jumpCurrCam(int x, int y, int z) |
---|
[10204] | 120 | { |
---|
[10206] | 121 | currentCam->target->jump(x, y, z); |
---|
[10204] | 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
[10343] | 127 | void CameraMan::togglFade() |
---|
[10330] | 128 | { |
---|
| 129 | if( this->fadeToBlack) |
---|
| 130 | fadeToBlack->toggleFade(); |
---|
| 131 | } |
---|
[10204] | 132 | |
---|
| 133 | |
---|
| 134 | |
---|
[10330] | 135 | //how to get a class fkt pointer |
---|
[10204] | 136 | |
---|
[10330] | 137 | //BaseObject* object = ObjectListBase::getBaseObject(className, objectName); |
---|
[10204] | 138 | |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|
[10330] | 150 | |
---|
| 151 | |
---|