Changeset 6341 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Dec 30, 2005, 1:57:12 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/npcs/npc.cc
r6222 r6341 62 62 this->collider = entity; 63 63 } 64 else if (entity->isA(CL_PLAYER))65 this->applyForce(Vector(0,0,0)-location*100);64 // else if (entity->isA(CL_PLAYER)) 65 // this->applyForce(Vector(0,0,0)-location*100); 66 66 else if (entity->isA(CL_NPC)) 67 67 { -
trunk/src/world_entities/npcs/npc.h
r6004 r6341 8 8 class AI; 9 9 10 class NPC : public WorldEntity , public PhysicsInterface{10 class NPC : public WorldEntity { 11 11 12 12 public: -
trunk/src/world_entities/skybox.cc
r6307 r6341 22 22 #include "static_model.h" 23 23 #include "material.h" 24 #include "network_game_manager.h" 25 #include "converter.h" 24 26 25 27 using namespace std; … … 77 79 } 78 80 this->setParentMode(PNODE_MOVEMENT); 81 82 this->textureName = NULL; 79 83 } 80 84 … … 208 212 this->setModel(model); 209 213 } 214 215 int SkyBox::writeBytes( const byte * data, int length, int sender ) 216 { 217 setRequestedSync( false ); 218 setIsOutOfSync( false ); 219 220 SYNCHELP_READ_BEGIN(); 221 222 SYNCHELP_READ_FKT( WorldEntity::writeState ); 223 224 SYNCHELP_READ_FLOAT( size ); 225 if ( textureName ) 226 { 227 delete[] textureName; 228 textureName = NULL; 229 } 230 SYNCHELP_READ_STRINGM( textureName ); 231 232 PRINT(0)("GOT DATA: size=%f texture='%s'\n", size, textureName); 233 234 this->setSize( size ); 235 this->setTextureAndType( textureName, "jpg" ); 236 this->rebuild(); 237 238 return SYNCHELP_READ_N; 239 } 240 241 242 243 int SkyBox::readBytes( byte * data, int maxLength, int * reciever ) 244 { 245 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 246 { 247 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 248 setRequestedSync( true ); 249 } 250 251 int rec = this->getRequestSync(); 252 if ( rec > 0 ) 253 { 254 PRINT(0)("SEND DATA: size=%f texture='%s'\n", size, textureName); 255 *reciever = rec; 256 257 SYNCHELP_WRITE_BEGIN(); 258 259 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 260 261 SYNCHELP_WRITE_FLOAT(this->size); 262 SYNCHELP_WRITE_STRING(this->textureName); 263 264 return SYNCHELP_WRITE_N; 265 } 266 267 *reciever = 0; 268 return 0; 269 } 270 271 void SkyBox::writeDebug( ) const 272 { 273 } 274 275 void SkyBox::readDebug( ) const 276 { 277 } -
trunk/src/world_entities/skybox.h
r6307 r6341 35 35 void setSize(float size); 36 36 /** assumes jpg as input-format */ 37 void setTexture(const char* name) { this->setTextureAndType (name, "jpg"); };37 void setTexture(const char* name) { if (textureName) delete[] textureName; textureName = new char[strlen(name)+1]; strcpy(textureName, name); this->setTextureAndType (name, "jpg"); }; 38 38 39 39 void setTextureAndType(const char* name, const char* extension); 40 40 void setTextures(const char* top, const char* bottom, const char* left, 41 41 const char* right, const char* front, const char* back); 42 43 virtual int writeBytes(const byte* data, int length, int sender); 44 virtual int readBytes(byte* data, int maxLength, int * reciever); 45 virtual void writeDebug() const; 46 virtual void readDebug() const; 42 47 43 48 private: … … 46 51 Material* material[6]; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 47 52 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 53 char* textureName; //!< Name of the Texture 48 54 49 55 }; -
trunk/src/world_entities/space_ships/space_ship.cc
r6306 r6341 121 121 PRINTF(4)("SPACESHIP INIT\n"); 122 122 123 EventHandler::getInstance()->grabEvents(true);123 // EventHandler::getInstance()->grabEvents(true); 124 124 125 125 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; -
trunk/src/world_entities/terrain.cc
r6142 r6341 24 24 #include "resource_manager.h" 25 25 #include "model.h" 26 #include "network_game_manager.h" 27 26 28 27 29 #include "glincl.h" … … 111 113 void Terrain::loadVegetation(const char* vegetationFile) 112 114 { 115 PRINTF(0)("loadVegetation: %s\n", vegetationFile); 113 116 if (this->vegetation) 114 117 ResourceManager::getInstance()->unload(this->vegetation, RP_LEVEL); … … 116 119 { 117 120 PRINTF(4)("fetching %s\n", vegetationFile); 118 121 this->vegetation = (Model*)ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN); 119 122 } 120 123 else … … 315 318 } 316 319 } 320 321 int Terrain::writeBytes( const byte * data, int length, int sender ) 322 { 323 setRequestedSync( false ); 324 setIsOutOfSync( false ); 325 326 SYNCHELP_READ_BEGIN(); 327 SYNCHELP_READ_FKT( WorldEntity::writeState ); 328 329 return SYNCHELP_READ_N; 330 } 331 332 int Terrain::readBytes( byte * data, int maxLength, int * reciever ) 333 { 334 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 335 { 336 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 337 setRequestedSync( true ); 338 } 339 340 int rec = this->getRequestSync(); 341 if ( rec > 0 ) 342 { 343 *reciever = rec; 344 345 return WorldEntity::readState( data, maxLength ); 346 347 } 348 349 *reciever = 0; 350 return 0; 351 } 352 353 void Terrain::writeDebug( ) const 354 { 355 } 356 357 void Terrain::readDebug( ) const 358 { 359 } -
trunk/src/world_entities/terrain.h
r5500 r6341 30 30 virtual ~Terrain(); 31 31 32 virtual int writeBytes(const byte* data, int length, int sender); 33 virtual int readBytes(byte* data, int maxLength, int * reciever); 34 virtual void writeDebug() const; 35 virtual void readDebug() const; 36 32 37 void init(); 33 38 void loadParams(const TiXmlElement* root); … … 44 49 Model* vegetation; 45 50 int objectList; 51 46 52 }; 47 53 -
trunk/src/world_entities/weapons/ground_turret.cc
r6142 r6341 19 19 20 20 #include "factory.h" 21 #include "network_game_manager.h" 21 22 #include "load_param.h" 22 23 … … 168 169 169 170 } 171 172 /** 173 * Writes data from network containing information about the state 174 * @param data pointer to data 175 * @param length length of data 176 * @param sender hostID of sender 177 */ 178 int GroundTurret::writeBytes( const byte * data, int length, int sender ) 179 { 180 setRequestedSync( false ); 181 setIsOutOfSync( false ); 182 183 SYNCHELP_READ_BEGIN(); 184 185 SYNCHELP_READ_FKT( WorldEntity::writeState ); 186 187 return SYNCHELP_READ_N; 188 } 189 190 /** 191 * data copied in data will bee sent to another host 192 * @param data pointer to data 193 * @param maxLength max length of data 194 * @return the number of bytes writen 195 */ 196 int GroundTurret::readBytes( byte * data, int maxLength, int * reciever ) 197 { 198 SYNCHELP_WRITE_BEGIN(); 199 200 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 201 { 202 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 203 setRequestedSync( true ); 204 } 205 206 int rec = this->getRequestSync(); 207 if ( rec > 0 ) 208 { 209 *reciever = rec; 210 211 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 212 213 } 214 215 *reciever = 0; 216 return SYNCHELP_WRITE_N; 217 } -
trunk/src/world_entities/weapons/ground_turret.h
r5819 r6341 30 30 virtual void collidesWith (WorldEntity* entity, const Vector& location); 31 31 32 virtual int writeBytes(const byte* data, int length, int sender); 33 virtual int readBytes(byte* data, int maxLength, int * reciever); 34 32 35 private: 33 36 Weapon *left, *right; -
trunk/src/world_entities/world_entity.cc
r6281 r6341 105 105 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber) 106 106 { 107 if ( fileName != NULL)107 if ( fileName != NULL && strcmp(fileName, "") ) 108 108 { 109 109 // search for the special character # in the LoadParam … … 144 144 } 145 145 else 146 { 146 147 this->setModel(NULL); 148 } 147 149 } 148 150 … … 340 342 glPopMatrix(); 341 343 } 344 345 /** 346 * Writes data from network containing information about the state 347 * @param data pointer to data 348 * @param length length of data 349 * @param sender hostID of sender 350 */ 351 int WorldEntity::writeState( const byte * data, int length, int sender ) 352 { 353 char* modelFileName; 354 SYNCHELP_READ_BEGIN(); 355 356 SYNCHELP_READ_FKT( PNode::writeState ); 357 358 SYNCHELP_READ_STRINGM( modelFileName ); 359 SYNCHELP_READ_FLOAT( scaling ); 360 //check if modelFileName is relative to datadir or absolute 361 if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) ) 362 { 363 loadModel( modelFileName+strlen(ResourceManager::getInstance()->getDataDir()), scaling ); 364 } 365 else 366 { 367 loadModel( modelFileName, scaling ); 368 } 369 delete[] modelFileName; 370 371 return SYNCHELP_READ_N; 372 } 373 374 /** 375 * data copied in data will bee sent to another host 376 * @param data pointer to data 377 * @param maxLength max length of data 378 * @return the number of bytes writen 379 */ 380 int WorldEntity::readState( byte * data, int maxLength ) 381 { 382 SYNCHELP_WRITE_BEGIN(); 383 384 SYNCHELP_WRITE_FKT( PNode::readState ); 385 386 SYNCHELP_WRITE_STRING( getModel( 0 )->getName() ); 387 SYNCHELP_WRITE_FLOAT( scaling ); 388 return SYNCHELP_WRITE_N; 389 } -
trunk/src/world_entities/world_entity.h
r6281 r6341 74 74 std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; } 75 75 76 int writeState(const byte* data, int length, int sender); 77 int readState(byte* data, int maxLength ); 76 78 77 79 protected: 78 80 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 81 79 82 80 83 private: … … 89 92 std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager. 90 93 94 float scaling; 95 96 91 97 }; 92 98
Note: See TracChangeset
for help on using the changeset viewer.