Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6654 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 23, 2006, 12:08:34 PM (19 years ago)
Author:
patrick
Message:

network: synchronizeable and network manager start of new concept implementation

Location:
branches/network/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/graphics/importer/vertex_array_model.cc

    r6519 r6654  
    305305    this->addColor(.125,.436,.246); ///FIXME
    306306  }
     307
    307308  for (unsigned int loopNumber = 0; loopNumber <= loops; ++loopNumber)
    308309  {
     
    326327    }
    327328  }
     329
    328330  for (unsigned int loopSegmentNumber = 0; loopSegmentNumber < segmentsPerLoop; ++loopSegmentNumber)
    329331  {
     
    331333    this->addIndice(segmentsPerLoop + loopSegmentNumber);
    332334  }
     335
    333336  for (unsigned int loopNumber = 0; loopNumber < loops; ++loopNumber)
    334337  {
  • branches/network/src/lib/network/network_manager.cc

    r6341 r6654  
    4949  this->netStreamList = NULL;
    5050  this->syncList = NULL;
    51   this->tmpStream = NULL;
     51  this->defaultSyncStream = NULL;
    5252
    5353  this->hostID = -1;
     
    9898  }
    9999
    100   this->tmpStream = new NetworkStream(ipAddress);
     100  this->defaultSyncStream = new NetworkStream(ipAddress);
    101101  return 1;
    102102}
     
    111111  this->hostID = 0;
    112112  this->bGameServer = true;
    113   this->tmpStream = new NetworkStream(port);
     113  this->defaultSyncStream = new NetworkStream(port);
    114114  this->bGameServer = true;
    115115  SDL_Delay(20);
     
    126126{
    127127  /* creating a new network stream, it will register itself automaticaly to the class list */
    128   this->tmpStream = new NetworkStream(address);
    129   this->tmpStream->connectSynchronizeable(sync);
     128  this->defaultSyncStream = new NetworkStream(address);
     129  this->defaultSyncStream->connectSynchronizeable(sync);
    130130}
    131131
     
    142142void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    143143{
    144   this->tmpStream->connectSynchronizeable(sync);
     144  this->defaultSyncStream->connectSynchronizeable(sync);
    145145}
    146146
  • branches/network/src/lib/network/network_manager.h

    r6341 r6654  
    5151    void synchronize();
    5252
     53    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
     54
     55
    5356  private:
    5457    NetworkManager();
     
    5962    const std::list<BaseObject*>*    syncList;                // list of synchronizeables
    6063    static NetworkManager*           singletonRef;            //!< Pointer to the only instance of this Class
    61     NetworkStream*                   tmpStream;               //!< FIXME: this is only for testing purposes
     64    NetworkStream*                   defaultSyncStream;       //!< FIXME: this is only for testing purposes
    6265    int                              hostID;                  //!< The Host-ID of the Manager
    6366    bool                             bGameServer;             //!< true if it is a server
  • branches/network/src/lib/network/synchronizeable.h

    r6341 r6654  
    163163
    164164class Synchronizeable : virtual public BaseObject
    165   {
     165{
     166
    166167  public:
    167168    Synchronizeable();
     
    179180    bool isOutOfSync();
    180181    bool requestedSync();
     182
    181183    inline void setUniqueID( int id ){ uniqueID = id; }
    182     inline int  getUniqueID() const { return uniqueID; };
     184    inline int  getUniqueID() const { return uniqueID; }
     185    inline int getHostID() { return this->hostID; }
     186
     187    inline int getOwner(){ return owner; }
     188    inline void setOwner(int owner){ this->owner = owner; }
     189
     190    /** @returns true if this Synchronizeable has to be synchronized over network */
     191    inline bool beSynchronized() { return this->bSynchronize; }
     192    /** @param bSynchronize sets the Synchronizeable to be sunchronized or not */
     193    inline void setSynchronized(bool bSynchronize) { this->bSynchronize = bSynchronize; }
     194
    183195    inline void requestSync( int hostID ){ this->synchronizeRequests.push_back( hostID ); }
    184196    inline int getRequestSync( void ){ if ( this->synchronizeRequests.size()>0 ){ int n = *(synchronizeRequests.begin()); synchronizeRequests.pop_front(); return n; } else { return -1; } };
    185     inline int getHostID() { return this->hostID; }
    186 
    187     inline int getOwner(){ return owner; }
    188     inline void setOwner(int owner){ this->owner = owner; }
    189197
    190198    inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
    191199
     200
     201  protected:
     202    NetworkStream*    networkStream;
     203    int               state;
     204
     205
    192206  private:
    193 
    194207    int               uniqueID;
    195 
    196 
    197 
    198     //static std::vector<Synchronizeable*> classList;
    199     int owner;
    200     int hostID;
     208    int               owner;
     209    int               hostID;
     210    bool              bSynchronize;
    201211
    202212    std::list<int> synchronizeRequests;
    203213
    204   protected:
    205     NetworkStream* networkStream;
    206     int state;
    207 
    208   };
     214};
    209215#endif /* _SYNCHRONIZEABLE_H */
  • branches/network/src/world_entities/planet.cc

    r6634 r6654  
    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
  • branches/network/src/world_entities/projectiles/laser.cc

    r6622 r6654  
    2626#include "particle_emitter.h"
    2727#include "sprite_particles.h"
     28
     29#include "assert.h"
    2830
    2931
Note: See TracChangeset for help on using the changeset viewer.