Changeset 1184
- Timestamp:
- Apr 24, 2008, 11:00:30 PM (17 years ago)
- Location:
- code/branches/network3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/bin/levels/sample.oxw
r1170 r1184 41 41 for i = 1, 226, 1 42 42 do ?> 43 < !--Model position="<?lua print(math.random(-19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" /-->43 <Model position="<?lua print(math.random(-19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" /> 44 44 <?lua 45 45 end -
code/branches/network3/src/network/Client.cc
r1168 r1184 44 44 namespace network 45 45 { 46 Client* Client::_sClient = 0; 47 48 Client* Client::createSingleton(){ 49 if(!_sClient) 50 _sClient = new Client(); 51 return _sClient; 52 } 53 54 Client* Client::createSingleton(std::string address, int port){ 55 if(!_sClient) 56 _sClient = new Client(address, port); 57 return _sClient; 58 } 59 60 Client* Client::createSingleton(const char *address, int port){ 61 if(!_sClient) 62 _sClient = new Client(address, port); 63 return _sClient; 64 } 65 66 void Client::destroySingleton(){ 67 if(_sClient){ 68 delete _sClient; 69 _sClient = 0; 70 } 71 } 72 73 Client* Client::getSingleton(){ 74 return _sClient; 75 } 76 46 77 /** 47 78 * Constructor for the Client class … … 71 102 } 72 103 104 Client::~Client(){ 105 if(isConnected) 106 closeConnection(); 107 } 108 73 109 /** 74 110 * Establish the Connection to the Server -
code/branches/network3/src/network/Client.h
r1168 r1184 65 65 class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{ 66 66 public: 67 Client(); 68 Client(std::string address, int port); 69 Client(const char *address, int port); 70 67 68 static Client* createSingleton(); 69 static Client* createSingleton(std::string address, int port); 70 static Client* createSingleton(const char *address, int port); 71 static void destroySingleton(); 72 static Client *getSingleton(); 73 71 74 bool establishConnection(); 72 75 bool closeConnection(); … … 84 87 85 88 private: 89 Client(); 90 Client(std::string address, int port); 91 Client(const char *address, int port); 92 ~Client(); 93 94 static Client* _sClient; 95 86 96 ClientConnection client_connection; 87 97 PacketGenerator pck_gen; -
code/branches/network3/src/network/Server.cc
r1175 r1184 143 143 updateGamestate(); 144 144 145 sleep(1); // TODO remove145 //sleep(1); // TODO remove 146 146 return; 147 147 } -
code/branches/network3/src/orxonox/Orxonox.cc
r1174 r1184 184 184 GraphicsEngine::getSingleton().destroy(); 185 185 186 if ( client_g)187 delete client_g;186 if (network::Client::getSingleton()) 187 network::Client::destroySingleton(); 188 188 if (server_g) 189 189 delete server_g; … … 281 281 ogre_->setup(); 282 282 if(serverIp_.compare("")==0) 283 client_g = ne w network::Client();283 client_g = network::Client::createSingleton(); 284 284 else 285 client_g = ne w network::Client(serverIp_, NETWORK_PORT);285 client_g = network::Client::createSingleton(serverIp_, NETWORK_PORT); 286 286 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 287 287 } … … 422 422 ib->registerListener(console, &Testconsole::execute, '\n', false); 423 423 ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true); 424 ib->registerListener(console, &Testconsole::clear, ' §', true);424 ib->registerListener(console, &Testconsole::clear, '�', true); 425 425 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 426 426 ib->registerListener(console, &Testconsole::exit, (char)0x1B, true); -
code/branches/network3/src/orxonox/objects/SpaceShip.cc
r1180 r1184 50 50 #include "core/XMLPort.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "network/Client.h" 52 53 53 54 namespace orxonox … … 165 166 void SpaceShip::init() 166 167 { 168 createCamera(); 167 169 // START CREATING THRUSTER 168 170 this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 281 283 void SpaceShip::setCamera(const std::string& camera) 282 284 { 283 Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam"); 284 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 285 // change camera attributes here, if you want to ;) 286 } 287 288 void SpaceShip::createCamera(){ 289 Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam"); 290 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 285 291 /* 286 292 // node->setInheritOrientation(false); 287 288 289 290 */ 291 292 293 cam->setPosition(Vector3(0,50,-150)); 294 cam->lookAt(Vector3(0,20,0)); 295 cam->roll(Degree(0)); 296 */ 297 298 cam->setPosition(Vector3(-200,0,35)); 293 299 // cam->setPosition(Vector3(0,-350,0)); 294 cam->lookAt(Vector3(0,0,35)); 295 cam->roll(Degree(-90)); 296 297 this->camNode_->attachObject(cam); 298 GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam); 300 cam->lookAt(Vector3(0,0,35)); 301 cam->roll(Degree(-90)); 302 303 this->camNode_->attachObject(cam); 304 GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam); 305 299 306 } 300 307 … … 427 434 void SpaceShip::tick(float dt) 428 435 { 429 if (InputManager::getSingleton().getMouse()->getEventCallback() != this) 436 // only do this if not client TODO: remove this hack 437 if (!network::Client::getSingleton() && InputManager::getSingleton().getMouse()->getEventCallback() != this) 430 438 { 431 439 if (InputManager::getSingleton().getMouse()) … … 526 534 } 527 535 528 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 529 this->acceleration_.x = this->translationAcceleration_; 530 else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) 531 this->acceleration_.x = -this->translationAcceleration_; 532 else 533 this->acceleration_.x = 0; 534 535 if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) 536 this->acceleration_.y = -this->translationAcceleration_; 537 else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) 538 this->acceleration_.y = this->translationAcceleration_; 539 else 540 this->acceleration_.y = 0; 541 542 if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q)) 543 this->momentum_ = Radian(-this->rotationAccelerationRadian_); 544 else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E)) 545 this->momentum_ = Radian(this->rotationAccelerationRadian_); 546 else 547 this->momentum_ = 0; 536 if(!network::Client::getSingleton()){ 537 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 538 this->acceleration_.x = this->translationAcceleration_; 539 else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) 540 this->acceleration_.x = -this->translationAcceleration_; 541 else 542 this->acceleration_.x = 0; 543 544 if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) 545 this->acceleration_.y = -this->translationAcceleration_; 546 else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) 547 this->acceleration_.y = this->translationAcceleration_; 548 else 549 this->acceleration_.y = 0; 550 551 if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q)) 552 this->momentum_ = Radian(-this->rotationAccelerationRadian_); 553 else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E)) 554 this->momentum_ = Radian(this->rotationAccelerationRadian_); 555 else 556 this->momentum_ = 0; 557 } 548 558 549 559 WorldEntity::tick(dt); -
code/branches/network3/src/orxonox/objects/SpaceShip.h
r1056 r1184 71 71 72 72 private: 73 void createCamera(); 73 74 static SpaceShip* instance_s; 74 75 -
code/branches/network3/src/orxonox/objects/WorldEntity.cc
r1174 r1184 216 216 registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA); 217 217 registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA); 218 219 registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA); 220 registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA); 221 registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA); 218 222 } 219 223
Note: See TracChangeset
for help on using the changeset viewer.