Changeset 1232 for code/branches/network3/src/orxonox/objects/SpaceShip.cc
- Timestamp:
- May 5, 2008, 1:19:22 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/orxonox/objects/SpaceShip.cc
r1212 r1232 80 80 81 81 this->camNode_ = 0; 82 this->camName_ = "camNode"; 82 83 83 84 this->tt_ = 0; … … 160 161 161 162 void SpaceShip::registerAllVariables(){ 162 163 164 163 registerVar( &camName_, camName_.length()+1, network::STRING); 165 164 } 166 165 167 166 void SpaceShip::init() 168 167 { 169 createCamera();168 COUT(4) << "================ \t\t\t\tspaceship::init" << std::endl; 170 169 // START CREATING THRUSTER 171 170 this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 198 197 this->greenNode_->setInheritScale(false); 199 198 199 COUT(4) << "attaching red billboard" << std::endl; 200 200 this->redNode_->attachObject(this->redBillboard_.getBillboardSet()); 201 201 this->redNode_->setScale(0.3, 0.3, 0.3); 202 202 203 COUT(4) << "attaching green billboard" << std::endl; 203 204 this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet()); 204 205 this->greenNode_->setScale(0.3, 0.3, 0.3); … … 214 215 this->chFarNode_->setInheritScale(false); 215 216 217 COUT(4) << "attaching crosshair near billboard" << std::endl; 216 218 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 217 219 this->chNearNode_->setScale(0.2, 0.2, 0.2); 218 220 221 COUT(4) << "attaching crosshair far billboard" << std::endl; 219 222 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 220 223 this->chFarNode_->setScale(0.4, 0.4, 0.4); 221 224 COUT(4) << "attaching camera" << std::endl; 225 226 createCamera(); 222 227 // END of testing crosshair 223 228 } … … 232 237 void SpaceShip::loadParams(TiXmlElement* xmlElem) 233 238 { 239 COUT(4) << "using loadparams" << std::endl; 234 240 Model::loadParams(xmlElem); 235 241 this->create(); 242 this->getFocus(); 236 243 /* 237 244 if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) … … 284 291 void SpaceShip::setCamera(const std::string& camera) 285 292 { 293 camName_=camera; 286 294 // change camera attributes here, if you want to ;) 295 } 296 297 void SpaceShip::getFocus(){ 298 COUT(4) << "requesting focus" << std::endl; 299 if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID) 300 CameraHandler::getInstance()->requestFocus(cam_); 301 287 302 } 288 303 289 304 void SpaceShip::createCamera(){ 290 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 291 camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 305 COUT(4) << "begin camera creation" << std::endl; 306 this->camNode_ = this->getNode()->createChildSceneNode(camName_); 307 COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl; 308 this->camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 309 COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl; 292 310 /* 293 311 // node->setInheritOrientation(false); … … 295 313 cam->lookAt(Vector3(0,20,0)); 296 314 cam->roll(Degree(0)); 297 */ 315 */COUT(4) << "creating new camera" << std::endl; 298 316 cam_ = new Camera(this->camNode_); 317 COUT(4) << "setting target node" << std::endl; 299 318 cam_->setTargetNode(this->getNode()); 300 CameraHandler::getInstance()->requestFocus(cam_); 319 // this only applies to clients 320 if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID) 321 CameraHandler::getInstance()->requestFocus(cam_); 301 322 // cam->setPosition(Vector3(0,-350,0)); 302 323 //cam->roll(Degree(-90)); 303 324 304 325 //this->camNode_->attachObject(cam); 305 326 COUT(4) << "created camera" << std::endl; 306 327 } 307 328 … … 329 350 void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) 330 351 { 352 COUT(4) << "using xmlport" << std::endl; 331 353 Model::XMLPort(xmlelement, mode); 332 354 … … 339 361 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode); 340 362 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode); 363 364 SpaceShip::create(); 365 getFocus(); 341 366 } 342 367 … … 534 559 } 535 560 536 if(!network::Client::getSingleton() ){561 if(!network::Client::getSingleton() || network::Client::getSingleton()->getShipID() == objectID){ 537 562 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 538 563 this->acceleration_.x = this->translationAcceleration_;
Note: See TracChangeset
for help on using the changeset viewer.