Changeset 7954 in orxonox.OLD for trunk/src/world_entities/world_entity.cc
- Timestamp:
- May 29, 2006, 3:28:41 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/world_entity.cc
r7927 r7954 70 70 this->toList(OM_NULL); 71 71 72 //this->collisionHandles = new *CollisionHandle[CREngine::CR_NUMBER](); 72 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 73 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) ); 73 74 } 74 75 … … 132 133 this->modelLODName = fileName; 133 134 this->scaling = scaling; 135 136 std::string name = fileName; 137 138 if ( name.find( ResourceManager::getInstance()->getDataDir() ) == 0 ) 139 { 140 name.erase(ResourceManager::getInstance()->getDataDir().size()); 141 } 142 143 this->modelFileName = name; 144 134 145 if (!fileName.empty()) 135 146 { … … 524 535 525 536 526 527 528 /******************************************************************************************** 529 NETWORK STUFF 530 ********************************************************************************************/ 531 532 533 /** 534 * Writes data from network containing information about the state 535 * @param data pointer to data 536 * @param length length of data 537 * @param sender hostID of sender 538 */ 539 int WorldEntity::writeState( const byte * data, int length, int sender ) 540 { 541 std::string modelFileName; 542 SYNCHELP_READ_BEGIN(); 543 544 SYNCHELP_READ_FKT( PNode::writeState, NWT_WE_PN_WRITESTATE ); 545 546 SYNCHELP_READ_STRING( modelFileName, NWT_WE_PN_MODELFILENAME ); 547 SYNCHELP_READ_FLOAT( scaling, NWT_WE_PN_SCALING ); 548 //check if modelFileName is relative to datadir or absolute 549 550 551 PRINTF(0)("================ LOADING MODEL %s, %f\n", modelFileName.c_str(), scaling); 552 553 if ( modelFileName != "" ) 554 { 555 loadModel( modelFileName, scaling); 556 PRINTF(0)("modelfilename: %s\n", getModel( 0 )->getName()); 557 } 558 559 /*SYNCHELP_READ_STRINGM( modelFileName ); 560 561 if ( strcmp(modelFileName, "") ) 562 if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) ) 563 { 564 this->md2TextureFileName = new char[strlen(modelFileName)-strlen(ResourceManager::getInstance()->getDataDir())+1]; 565 strcpy((char*)this->md2TextureFileName, modelFileName+strlen(ResourceManager::getInstance()->getDataDir())); 566 } 567 else 568 { 569 this->md2TextureFileName = modelFileName; 570 } 571 */ 572 573 return SYNCHELP_READ_N; 574 } 575 576 577 /** 578 * data copied in data will bee sent to another host 579 * @param data pointer to data 580 * @param maxLength max length of data 581 * @return the number of bytes writen 582 */ 583 int WorldEntity::readState( byte * data, int maxLength ) 584 { 585 SYNCHELP_WRITE_BEGIN(); 586 587 SYNCHELP_WRITE_FKT( PNode::readState, NWT_WE_PN_WRITESTATE ); 588 589 if ( getModel(0) && getModel(0)->getName() != "" ) 590 { 591 std::string name = getModel( 0 )->getName(); 592 593 if ( name.find( ResourceManager::getInstance()->getDataDir() ) == 0 ) 594 { 595 name.erase(ResourceManager::getInstance()->getDataDir().size()); 596 } 597 598 SYNCHELP_WRITE_STRING( name, NWT_WE_PN_MODELFILENAME ); 599 } 600 else 601 { 602 SYNCHELP_WRITE_STRING("", NWT_WE_PN_MODELFILENAME); 603 } 604 605 SYNCHELP_WRITE_FLOAT( scaling, NWT_WE_PN_SCALING ); 606 /*if ( this->md2TextureFileName!=NULL && strcmp(this->md2TextureFileName, "") ) 607 { 608 SYNCHELP_WRITE_STRING(this->md2TextureFileName); 609 } 610 else 611 { 612 SYNCHELP_WRITE_STRING(""); 613 }*/ 614 615 return SYNCHELP_WRITE_N; 616 } 537 /** 538 * handler for changes on registred vars 539 * @param id id's which changed 540 */ 541 void WorldEntity::varChangeHandler( std::list< int > & id ) 542 { 543 if ( std::find( id.begin(), id.end(), modelFileName_handle ) != id.end() || 544 std::find( id.begin(), id.end(), scaling_handle ) != id.end() 545 ) 546 { 547 loadModel( modelFileName, scaling ); 548 } 549 550 PNode::varChangeHandler( id ); 551 } 552
Note: See TracChangeset
for help on using the changeset viewer.