Changeset 6273 in orxonox.OLD for branches/network/src/world_entities
- Timestamp:
- Dec 23, 2005, 5:30:22 PM (19 years ago)
- Location:
- branches/network/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/skybox.cc
r6142 r6273 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; … … 210 212 this->setModel(model); 211 213 } 214 215 void SkyBox::writeBytes( const byte * data, int length, int sender ) 216 { 217 setRequestedSync( false ); 218 setIsOutOfSync( false ); 219 220 int flsize = Converter::byteArrayToFloat( data, &size ); 221 Converter::byteArrayToString( data+flsize, textureName, length-flsize ); 222 223 PRINT(0)("GOT DATA: size=%f texture=%s\n", size, textureName); 224 225 this->setSize( size ); 226 this->setTexture( textureName ); 227 this->rebuild(); 228 } 229 230 int SkyBox::readBytes( byte * data, int maxLength, int * reciever ) 231 { 232 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 233 { 234 PRINTF(0)("Requesting sync! %d\n", this->getUniqueID()); 235 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 236 setRequestedSync( true ); 237 } 238 239 int rec = this->getRequestSync(); 240 if ( rec > 0 ) 241 { 242 PRINTF(0)("Serving client %d which requested sync %d size=%f texture=%s\n", rec, this->getUniqueID(), this->size, this->textureName); 243 *reciever = rec; 244 245 int flsize = Converter::floatToByteArray( this->size, data, maxLength ); 246 247 if ( flsize <= 0 ) 248 { 249 PRINTF(1)("Byte array is too small (%d) to store float\n", maxLength ); 250 return 0; 251 } 252 253 if ( strlen(textureName)+INTSIZE+flsize > maxLength ) 254 { 255 PRINTF(1)("Byte array is too small (%d) to store data\n", maxLength ); 256 return 0; 257 } 258 259 return flsize + Converter::stringToByteArray( textureName, data+flsize, strlen(textureName), maxLength-flsize ); 260 261 } 262 263 *reciever = 0; 264 return 0; 265 } 266 267 void SkyBox::writeDebug( ) const 268 { 269 } 270 271 void SkyBox::readDebug( ) const 272 { 273 } -
branches/network/src/world_entities/skybox.h
r5511 r6273 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) { strncpy(textureName, name, 1024); this->setTextureAndType (name, "jpg"); }; 38 38 39 39 void setTextureAndType(const char* name, const char* extension); … … 41 41 const char* right, const char* front, const char* back); 42 42 43 virtual void 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; 47 43 48 private: 44 49 void rebuild(); 45 50 46 Material** material; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 47 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 51 Material** material; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 52 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 53 char textureName[1024]; //!< Name of the Texture 48 54 49 55 };
Note: See TracChangeset
for help on using the changeset viewer.