Changeset 6695 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 25, 2006, 2:39:53 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environments/water.cc
r6684 r6695 28 28 #include "skybox.h" 29 29 30 #include "network_game_manager.h" 30 31 31 32 using namespace std; … … 238 239 this->grid->rebuildNormals(this->height); 239 240 } 241 242 243 /** 244 * Writes data from network containing information about the state 245 * @param data pointer to data 246 * @param length length of data 247 * @param sender hostID of sender 248 */ 249 int Water::writeBytes( const byte * data, int length, int sender ) 250 { 251 setRequestedSync( false ); 252 setIsOutOfSync( false ); 253 254 SYNCHELP_READ_BEGIN(); 255 256 SYNCHELP_READ_FKT( Water::writeState ); 257 258 return SYNCHELP_READ_N; 259 } 260 261 262 /** 263 * data copied in data will bee sent to another host 264 * @param data pointer to data 265 * @param maxLength max length of data 266 * @return the number of bytes writen 267 */ 268 int Water::readBytes( byte * data, int maxLength, int * reciever ) 269 { 270 SYNCHELP_WRITE_BEGIN(); 271 272 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 273 { 274 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 275 setRequestedSync( true ); 276 } 277 278 int rec = this->getRequestSync(); 279 if ( rec > 0 ) 280 { 281 *reciever = rec; 282 SYNCHELP_WRITE_FKT( Water::readState ); 283 } 284 285 *reciever = 0; 286 return SYNCHELP_WRITE_N; 287 } 288 289 290 291 /** 292 * data copied in data will bee sent to another host 293 * @param data pointer to data 294 * @param maxLength max length of data 295 * @return the number of bytes writen 296 */ 297 int Water::readState( byte * data, int maxLength ) 298 { 299 SYNCHELP_WRITE_BEGIN(); 300 301 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 302 303 // sync the size 304 SYNCHELP_WRITE_FLOAT( this->sizeX ); 305 SYNCHELP_WRITE_FLOAT( this->sizeY ); 306 307 //sync resolution 308 SYNCHELP_WRITE_INT( this->resX ); 309 SYNCHELP_WRITE_INT( this->resY ); 310 311 //sync the height 312 SYNCHELP_WRITE_FLOAT( this->height ); 313 314 return SYNCHELP_WRITE_N; 315 } 316 317 318 /** 319 * Writes data from network containing information about the state 320 * @param data pointer to data 321 * @param length length of data 322 * @param sender hostID of sender 323 */ 324 int Water::writeState( const byte * data, int length, int sender ) 325 { 326 SYNCHELP_READ_BEGIN(); 327 328 SYNCHELP_READ_FKT( WorldEntity::writeState ); 329 330 float f1, f2; 331 int i1, i2; 332 333 //read the size 334 SYNCHELP_READ_FLOAT( f1 ); 335 SYNCHELP_READ_FLOAT( f2 ); 336 this->sizeX = f1; 337 this->sizeY = f2; 338 PRINTF(0)("Setting Water to size: %f x %f\n", f1, f2); 339 340 //read the resolution 341 SYNCHELP_READ_INT( i1 ); 342 SYNCHELP_READ_INT( i2 ); 343 this->resX = i1; 344 this->resY = i2; 345 PRINTF(0)("Setting Water to resolution: %i x %i\n", i1, i2); 346 347 //read the height 348 SYNCHELP_READ_FLOAT( f1 ); 349 this->height = f1; 350 351 this->rebuildGrid(); 352 353 return SYNCHELP_READ_N; 354 } 355 356 -
trunk/src/world_entities/environments/water.h
r6518 r6695 35 35 void tick(float dt); 36 36 37 virtual int writeBytes(const byte* data, int length, int sender); 38 virtual int readBytes(byte* data, int maxLength, int * reciever); 39 40 int writeState( const byte * data, int length, int sender ); 41 int readState( byte * data, int maxLength ); 42 43 37 44 private: 38 45 Grid* grid; //!< The water-surface-model to render with -
trunk/src/world_entities/movie_entity.cc
r6676 r6695 40 40 this->toList(OM_COMMON); 41 41 42 this->loadParams(root); 42 if( root != NULL) 43 this->loadParams(root); 43 44 44 45 counter = 0; … … 52 53 MovieEntity::~MovieEntity () 53 54 { 54 delete this->media_container; 55 if( this->media_container) 56 delete this->media_container; 55 57 } 56 58 -
trunk/src/world_entities/planet.cc
r6634 r6695 27 27 #include "network_game_manager.h" 28 28 #include "converter.h" 29 #include "vertex_array_model.h" 30 #include "primitive_model.h" 29 31 30 32 using namespace std; … … 44 46 45 47 this->material = new Material(); 46 this->material->setIllum(10); 48 //this->material->setIllum(20); 49 //this->material->setAmbient(0.1, 0.1, 0.1); 50 51 52 53 //st float radius, const unsigned int loops, const unsigned int segmentsPerLoop 47 54 48 55 this->loadParams(root); 56 57 // VertexArrayModel* model = new VertexArrayModel(); 58 // model->spiralSphere(this->size, 10, 10); 59 // this->setModel(model); 60 // model->debug(); 61 // 62 PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50); 63 this->setModel(model); 49 64 } 50 65 … … 98 113 { 99 114 115 100 116 glMatrixMode(GL_MODELVIEW); 101 117 glPushMatrix(); 118 119 glShadeModel(GL_SMOOTH); 102 120 103 121 /* translate */ … … 109 127 this->material->select(); 110 128 111 112 Vector c; 113 double r = this->size; 114 int n = 200; 115 int method = 1; 116 double theta1 = 0; 117 double theta2 = 2 * M_PI; 118 double phi1 = -M_PI/2.0; 119 double phi2 = M_PI/2.0; 120 121 122 int i,j; 123 double jdivn,j1divn,idivn,dosdivn,unodivn=1/(double)n,ndiv2=(double)n/2,t1,t2,t3,cost1,cost2,cte1,cte3; 124 cte3 = (theta2-theta1)/n; 125 cte1 = (phi2-phi1)/ndiv2; 126 dosdivn = 2*unodivn; 127 Vector e,p,e2,p2; 128 129 130 t2=phi1; 131 cost2=cos(phi1); 132 j1divn=0; 133 for (j=0;j<ndiv2;j++) { 134 t1 = t2;//t1 = phi1 + j * cte1; 135 t2 += cte1;//t2 = phi1 + (j + 1) * cte1; 136 t3 = theta1 - cte3; 137 cost1 = cost2;//cost1=cos(t1); 138 cost2 = cos(t2); 139 e.y = sin(t1); 140 e2.y = sin(t2); 141 p.y = c.y + r * e.y; 142 p2.y = c.y + r * e2.y; 143 144 if (method == 0) 145 glBegin(GL_QUAD_STRIP); 146 else 147 glBegin(GL_TRIANGLE_STRIP); 148 149 idivn=0; 150 jdivn=j1divn; 151 j1divn+=dosdivn;//=2*(j+1)/(double)n; 152 for (i=0;i<=n;i++) { 153 //t3 = theta1 + i * (theta2 - theta1) / n; 154 t3 += cte3; 155 e.x = cost1 * cos(t3); 156 //e.y = sin(t1); 157 e.z = cost1 * sin(t3); 158 p.x = c.x + r * e.x; 159 //p.y = c.y + r * e.y; 160 p.z = c.z + r * e.z; 161 glNormal3f(e.x,e.y,e.z); 162 glTexCoord2f(idivn,jdivn); 163 glVertex3f(p.x,p.y,p.z); 164 165 166 e2.x = cost2 * cos(t3); 167 //e.y = sin(t2); 168 e2.z = cost2 * sin(t3); 169 p2.x = c.x + r * e2.x; 170 //p.y = c.y + r * e.y; 171 p2.z = c.z + r * e2.z; 172 glNormal3f(e2.x,e2.y,e2.z); 173 glTexCoord2f(idivn,j1divn); 174 glVertex3f(p2.x,p2.y,p2.z); 175 idivn += unodivn; 176 } 177 glEnd(); 178 } 129 // /WorldEntity::draw(); 130 this->getModel(0)->draw(); 131 // static_cast<VertexArrayModel*>(this->getModel(0))->debug(); 179 132 } 180 133 -
trunk/src/world_entities/playable.cc
r6676 r6695 36 36 // the reference to the Current Player is NULL, because we dont have one at the beginning. 37 37 this->currentPlayer = NULL; 38 } 38 39 this->setSynchronized(true); 40 } 41 42 39 43 40 44 Playable::~Playable() … … 57 61 } 58 62 63 59 64 void Playable::removeWeapon(Weapon* weapon) 60 65 { … … 63 68 this->weaponConfigChanged(); 64 69 } 70 65 71 66 72 void Playable::nextWeaponConfig() … … 70 76 } 71 77 78 72 79 void Playable::previousWeaponConfig() 73 80 { … … 76 83 } 77 84 85 78 86 void Playable::weaponConfigChanged() 79 87 { … … 81 89 this->currentPlayer->weaponConfigChanged(); 82 90 } 91 83 92 84 93 /** -
trunk/src/world_entities/power_ups/param_power_up.cc
r6547 r6695 46 46 { 47 47 this->init(); 48 this->loadParams(root); 48 if( root != NULL) 49 this->loadParams(root); 49 50 } 50 51 -
trunk/src/world_entities/power_ups/turret_power_up.cc
r6512 r6695 36 36 this->init(); 37 37 38 this->loadParams(root); 38 if( root != NULL) 39 this->loadParams(root); 39 40 } 40 41 -
trunk/src/world_entities/power_ups/weapon_power_up.cc
r6589 r6695 39 39 { 40 40 this->init(); 41 this->loadParams(root); 41 if( root != NULL) 42 this->loadParams(root); 42 43 } 43 44 -
trunk/src/world_entities/projectiles/laser.cc
r6692 r6695 30 30 #include <cassert> 31 31 32 #include "assert.h" 32 33 33 34 -
trunk/src/world_entities/skybox.cc
r6634 r6695 51 51 this->preInit(); 52 52 53 this->loadParams(root); 53 if( root != NULL) 54 this->loadParams(root); 54 55 55 56 this->postInit(); -
trunk/src/world_entities/space_ships/space_ship.cc
r6692 r6695 97 97 if (root != NULL) 98 98 this->loadParams(root); 99 else 100 { 101 this->loadModel("models/ships/reap_#.obj"); 102 } 103 104 } 105 106 107 /** 108 * initializes a Spaceship 109 */ 110 void SpaceShip::init() 111 { 112 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 113 this->setClassID(CL_SPACE_SHIP, "SpaceShip"); 114 115 PRINTF(4)("SPACESHIP INIT\n"); 99 116 100 117 //weapons: … … 112 129 113 130 this->getWeaponManager()->changeWeaponConfig(1); 114 }115 116 117 /**118 * initializes a Spaceship119 */120 void SpaceShip::init()121 {122 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));123 this->setClassID(CL_SPACE_SHIP, "SpaceShip");124 125 PRINTF(4)("SPACESHIP INIT\n");126 131 127 132 EventHandler::getInstance()->grabEvents(true); … … 206 211 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 207 212 } 213 208 214 209 215 /** -
trunk/src/world_entities/terrain.cc
r6512 r6695 39 39 { 40 40 this->init(); 41 this->loadParams(root); 41 if( root != NULL) 42 this->loadParams(root); 42 43 43 44 // if (this->model != NULL) -
trunk/src/world_entities/weapons/targeting_turret.cc
r6671 r6695 48 48 { 49 49 this->init(); 50 this->loadParams(root); 50 if( root != NULL) 51 this->loadParams(root); 51 52 } 52 53 -
trunk/src/world_entities/weapons/weapon.cc
r6671 r6695 100 100 101 101 this->energyWidget = NULL; 102 103 // set this object to be synchronized over network 104 //this->setSynchronized(true); 102 105 } 103 106 -
trunk/src/world_entities/world_entity.cc
r6634 r6695 54 54 this->energyMax = 1.0f; 55 55 this->energy = 1.0f; 56 this->scaling = 1.0f; 57 58 /* OSOLETE */ 59 this->bVisible = true; 60 this->bCollide = true; 56 61 57 62 this->md2TextureFileName = NULL; 58 59 60 this->setVisibiliy(true);61 63 62 64 this->objectListNumber = OM_INIT; … … 122 124 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber) 123 125 { 126 this->modelLODName = fileName; 124 127 this->scaling = scaling; 125 128 if ( fileName != NULL && strcmp(fileName, "") ) … … 515 518 //check if modelFileName is relative to datadir or absolute 516 519 520 521 PRINTF(0)("================ LOADING MODEL %s, %f\n", modelFileName, scaling); 522 517 523 if ( strcmp(modelFileName, "") ) 518 524 { 519 loadModel( modelFileName, scaling ); 525 loadModel( modelFileName, scaling); 526 PRINTF(0)("modelfilename: %s\n", getModel( 0 )->getName()); 520 527 } 521 528 delete[] modelFileName; -
trunk/src/world_entities/world_entity.h
r6512 r6695 111 111 std::vector<Model*> models; //!< The model that should be loaded for this entity. 112 112 const char* md2TextureFileName; //!< the file name of the md2 model texture, only if this 113 const char* modelLODName; //!< the name of the model lod file 113 114 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 114 115
Note: See TracChangeset
for help on using the changeset viewer.