- Timestamp:
- Jan 29, 2007, 1:53:29 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/cameraman.cc
r10476 r10480 82 82 83 83 84 85 84 void CameraMan::createCam(const TiXmlElement* root) 86 85 { 87 //Camera* newCamera=new Camera(root);88 86 this->cameras.push_back(new Camera(root)); 89 // cameras[cameras.size()-1]->target->detach();90 87 cameras[cameras.size()-1]->setClipRegion(nearClip, farClip); 91 92 } 93 94 void CameraMan::setCam(int cameraNo) 88 } 89 90 91 92 93 void CameraMan::setCam(unsigned int cameraNo) 95 94 { 96 95 if (cameraNo<cameras.size()) … … 106 105 if(object != NULL) 107 106 { 108 Camera* currentCam = dynamic_cast<Camera*>(object) ; 109 110 this->setCam(currentCam); 107 this->setCam(dynamic_cast<Camera*>(object)); 111 108 return; 112 109 } … … 120 117 { 121 118 PRINTF(0)("trying to add a zero camera! uiuiui!\n"); 122 } 119 return; 120 } 121 123 122 this->currentCam = camera; 124 123 … … 141 140 142 141 142 void CameraMan::changeCurrTarget(const std::string& className, const std::string& objectName) 143 { 144 BaseObject* object = ObjectListBase::getBaseObject(className, objectName); 145 if( object != NULL && object->isA(PNode::staticClassID())) 146 { 147 currentCam->lookAt(dynamic_cast<PNode*>(object)); 148 State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(object)); 149 } 150 } 151 152 void CameraMan::atachCurrTarget(PNode* target) 153 { 154 currentCam->target->atach(target); 155 State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(target)); 156 157 } 158 159 void CameraMan::atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity) 160 { 161 BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity); 162 163 if(object != NULL && object->isA(PNode::staticClassID())) 164 { 165 this->atachCurrTarget(dynamic_cast<PNode*>(object)); 166 return; 167 } 168 169 printf("ERROR CAMERAMANAGER: Couldn't set camera to: %s %s \n", className.c_str(),targetEntity.c_str() ); 170 } 171 172 173 174 void CameraMan::detachCurrCamera() 175 { 176 currentCam->target->detach(); 177 } 178 179 180 181 void CameraMan::jumpCurrCam(float x, float y, float z) 182 { 183 currentCam->target->jump(x, y, z); 184 } 185 186 void CameraMan::togglFade() 187 { 188 if( this->fadeToBlack) 189 fadeToBlack->toggleFade(); 190 } 191 192 void CameraMan::initFadeBlack() 193 { 194 if( this->fadeToBlack) 195 fadeToBlack->initFadeBlack(); 196 } 197 198 143 199 void CameraMan::moveCam(int x, int y, int z, int camNo) 144 200 { … … 164 220 { 165 221 dynamic_cast<Camera*>(newCam)->lookAt(dynamic_cast<PNode*>(object)); 166 this->setCam( dynamic_cast<Camera*>(newCam));167 222 State::setCamera( dynamic_cast<Camera*>(newCam), dynamic_cast<CameraTarget*>(object)); 168 223 } 169 }170 171 void CameraMan::changeCurrTarget(const std::string& className, const std::string& objectName)172 {173 BaseObject* object = ObjectListBase::getBaseObject(className, objectName);174 if( object != NULL && object->isA(PNode::staticClassID()))175 {176 currentCam->lookAt(dynamic_cast<PNode*>(object));177 State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(object));178 }179 }180 181 void CameraMan::atachCurrTarget(PNode* target)182 {183 currentCam->target->atach(target);184 State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(target));185 186 }187 188 void CameraMan::atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity)189 {190 BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);191 192 if(object != NULL)193 {194 this->atachCurrTarget(dynamic_cast<PNode*>(object));195 //State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(object));196 return;197 }198 199 printf("ERROR CAMERAMANAGER: Couldn't set camera to: %s %s \n", className.c_str(),targetEntity.c_str() );200 224 } 201 225 … … 206 230 BaseObject* targetCam = ObjectListBase::getBaseObject("Camera", cameraName); 207 231 208 if(object != NULL && targetCam != NULL) 209 { 210 dynamic_cast<Camera*>(targetCam)->target->atach(dynamic_cast<PNode*>(object)); 211 State::setCamera(this->currentCam, dynamic_cast<CameraTarget*>(object)); 212 return; 213 } 214 215 printf("ERROR CAMERAMANAGER: Couldn't set camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() ); 216 } 217 218 219 void CameraMan::detachCurrCamera() 220 { 221 currentCam->target->detach(); 222 } 232 if( object != NULL && targetCam != NULL && object->isA(PNode::staticClassID()) ) 233 { 234 dynamic_cast<Camera*>(targetCam)->target->atach(dynamic_cast<PNode*>(object)); 235 State::setCamera(dynamic_cast<Camera*>(targetCam), dynamic_cast<CameraTarget*>(object)); 236 return; 237 } 238 239 printf("ERROR CAMERAMANAGER: Couldn't set camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() ); 240 } 241 242 223 243 224 244 void CameraMan::jumpCam(int x, int y, int z, int camNo) … … 234 254 this->farClip=farCli; 235 255 236 for( int i = 0; i < this->cameras.size(); i++)256 for(unsigned int i = 0; i < this->cameras.size(); i++) 237 257 cameras[i]->setClipRegion(nearCli, farCli); 238 258 } 239 259 240 241 void CameraMan::jumpCurrCam(float x, float y, float z)242 {243 currentCam->target->jump(x, y, z);244 }245 246 247 248 249 void CameraMan::togglFade()250 {251 if( this->fadeToBlack)252 fadeToBlack->toggleFade();253 }254 255 void CameraMan::initFadeBlack()256 {257 if( this->fadeToBlack)258 fadeToBlack->initFadeBlack();259 }260 260 261 261 -
trunk/src/world_entities/cameraman.h
r10473 r10480 22 22 std::vector<Camera*> cameras; 23 23 CameraMan(const TiXmlElement* root = NULL); 24 void setCam( int CameraNo);24 void setCam(unsigned int CameraNo); 25 25 void setCam(const std::string& camName); 26 26 void setCam(Camera* camera); 27 27 28 /// LOADING 29 virtual void loadParams(const TiXmlElement* root); 28 30 void createCameras(const TiXmlElement* camerasTag); 29 31 void createCam(const TiXmlElement* root); 30 void moveCam(int x, int y, int z, int camNo);31 void moveCurrCam(int x, int y, int z);32 void changeTarget(int camNo, const std::string& className,const std::string& objectName);33 void changeTarget(const std::string& camName,const std::string& className, const std::string& objectName);34 void changeCurrTarget(const std::string& className, const std::string& objectName);35 void atachCurrTarget(PNode* target);36 void atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity);37 void atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity);38 void detachCurrCamera();39 void jumpCam(int x, int y, int z, int camNo);40 void jumpCurrCam(float x, float y, float z);41 void changeSpeed(float speed);42 void setClipRegion(float nearClip, float farClip);43 void togglFade();44 void initFadeBlack();45 46 void cameraInfo();47 48 /// LOADING49 virtual void loadParams(const TiXmlElement* root);50 32 51 33 /// POLLING … … 55 37 const Camera* getCurrentCam() const { return this->currentCam; } 56 38 Camera* getCurrentCam() { return this->currentCam; } 39 40 41 /// Current camera 42 void moveCurrCam(int x, int y, int z); 43 void changeCurrTarget(const std::string& className, const std::string& objectName); 44 void atachCurrTarget(PNode* target); 45 void atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity); 46 void detachCurrCamera(); 47 void jumpCurrCam(float x, float y, float z); 48 void togglFade(); 49 void initFadeBlack(); 50 51 /// Camera 52 void moveCam(int x, int y, int z, int camNo); 53 void changeTarget(int camNo, const std::string& className,const std::string& objectName); 54 void changeTarget(const std::string& camName,const std::string& className, const std::string& objectName); 55 void atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity); 56 void jumpCam(int x, int y, int z, int camNo); 57 58 void changeSpeed(float speed); 59 void setClipRegion(float nearClip, float farClip); 60 void cameraInfo(); 61 62 private: 57 63 bool cameraIsInVector(Camera* camera); 64 58 65 59 66 };
Note: See TracChangeset
for help on using the changeset viewer.