Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6695 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 25, 2006, 2:39:53 PM (19 years ago)
Author:
patrick
Message:

merged the network branche to the trunk

Location:
trunk/src/world_entities
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/water.cc

    r6684 r6695  
    2828#include "skybox.h"
    2929
     30#include "network_game_manager.h"
    3031
    3132using namespace std;
     
    238239  this->grid->rebuildNormals(this->height);
    239240}
     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 */
     249int 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 */
     268int 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 */
     297int 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 */
     324int 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  
    3535   void tick(float dt);
    3636
     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
    3744  private:
    3845    Grid*           grid;            //!< The water-surface-model to render with
  • trunk/src/world_entities/movie_entity.cc

    r6676 r6695  
    4040  this->toList(OM_COMMON);
    4141
    42   this->loadParams(root);
     42  if( root != NULL)
     43    this->loadParams(root);
    4344
    4445  counter = 0;
     
    5253MovieEntity::~MovieEntity ()
    5354{
    54   delete this->media_container;
     55  if( this->media_container)
     56    delete this->media_container;
    5557}
    5658
  • trunk/src/world_entities/planet.cc

    r6634 r6695  
    2727#include "network_game_manager.h"
    2828#include "converter.h"
     29#include "vertex_array_model.h"
     30#include "primitive_model.h"
    2931
    3032using namespace std;
     
    4446
    4547  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
    4754
    4855  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);
    4964}
    5065
     
    98113{
    99114
     115
    100116  glMatrixMode(GL_MODELVIEW);
    101117  glPushMatrix();
     118
     119  glShadeModel(GL_SMOOTH);
    102120
    103121  /* translate */
     
    109127  this->material->select();
    110128
    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();
    179132}
    180133
  • trunk/src/world_entities/playable.cc

    r6676 r6695  
    3636  // the reference to the Current Player is NULL, because we dont have one at the beginning.
    3737  this->currentPlayer = NULL;
    38 }
     38
     39  this->setSynchronized(true);
     40}
     41
     42
    3943
    4044Playable::~Playable()
     
    5761}
    5862
     63
    5964void Playable::removeWeapon(Weapon* weapon)
    6065{
     
    6368    this->weaponConfigChanged();
    6469}
     70
    6571
    6672void Playable::nextWeaponConfig()
     
    7076}
    7177
     78
    7279void Playable::previousWeaponConfig()
    7380{
     
    7683}
    7784
     85
    7886void Playable::weaponConfigChanged()
    7987{
     
    8189    this->currentPlayer->weaponConfigChanged();
    8290}
     91
    8392
    8493/**
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r6547 r6695  
    4646{
    4747  this->init();
    48   this->loadParams(root);
     48  if( root != NULL)
     49    this->loadParams(root);
    4950}
    5051
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6512 r6695  
    3636  this->init();
    3737
    38   this->loadParams(root);
     38  if( root != NULL)
     39    this->loadParams(root);
    3940}
    4041
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r6589 r6695  
    3939{
    4040  this->init();
    41   this->loadParams(root);
     41  if( root != NULL)
     42    this->loadParams(root);
    4243}
    4344
  • trunk/src/world_entities/projectiles/laser.cc

    r6692 r6695  
    3030#include <cassert>
    3131
     32#include "assert.h"
    3233
    3334
  • trunk/src/world_entities/skybox.cc

    r6634 r6695  
    5151  this->preInit();
    5252
    53   this->loadParams(root);
     53  if( root != NULL)
     54    this->loadParams(root);
    5455
    5556  this->postInit();
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6692 r6695  
    9797  if (root != NULL)
    9898    this->loadParams(root);
     99  else
     100  {
     101    this->loadModel("models/ships/reap_#.obj");
     102  }
     103
     104}
     105
     106
     107/**
     108 * initializes a Spaceship
     109 */
     110void 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");
    99116
    100117  //weapons:
     
    112129
    113130  this->getWeaponManager()->changeWeaponConfig(1);
    114 }
    115 
    116 
    117 /**
    118  * initializes a Spaceship
    119  */
    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");
    126131
    127132  EventHandler::getInstance()->grabEvents(true);
     
    206211  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    207212}
     213
    208214
    209215/**
  • trunk/src/world_entities/terrain.cc

    r6512 r6695  
    3939{
    4040  this->init();
    41   this->loadParams(root);
     41  if( root != NULL)
     42    this->loadParams(root);
    4243
    4344//  if (this->model != NULL)
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r6671 r6695  
    4848{
    4949  this->init();
    50   this->loadParams(root);
     50  if( root != NULL)
     51    this->loadParams(root);
    5152}
    5253
  • trunk/src/world_entities/weapons/weapon.cc

    r6671 r6695  
    100100
    101101  this->energyWidget = NULL;
     102
     103  // set this object to be synchronized over network
     104  //this->setSynchronized(true);
    102105}
    103106
  • trunk/src/world_entities/world_entity.cc

    r6634 r6695  
    5454  this->energyMax = 1.0f;
    5555  this->energy = 1.0f;
     56  this->scaling = 1.0f;
     57
     58  /* OSOLETE */
     59  this->bVisible = true;
     60  this->bCollide = true;
    5661
    5762  this->md2TextureFileName = NULL;
    58 
    59 
    60   this->setVisibiliy(true);
    6163
    6264  this->objectListNumber = OM_INIT;
     
    122124void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
    123125{
     126  this->modelLODName = fileName;
    124127  this->scaling = scaling;
    125128  if ( fileName != NULL && strcmp(fileName, "") )
     
    515518  //check if modelFileName is relative to datadir or absolute
    516519
     520
     521  PRINTF(0)("================ LOADING MODEL %s, %f\n", modelFileName, scaling);
     522
    517523  if ( strcmp(modelFileName, "") )
    518524  {
    519     loadModel( modelFileName, scaling );
     525    loadModel( modelFileName, scaling);
     526    PRINTF(0)("modelfilename: %s\n", getModel( 0 )->getName());
    520527  }
    521528  delete[] modelFileName;
  • trunk/src/world_entities/world_entity.h

    r6512 r6695  
    111111  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
    112112  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
    113114  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
    114115
Note: See TracChangeset for help on using the changeset viewer.