Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 26, 2007, 7:12:37 PM (18 years ago)
Author:
patrick
Message:

more on camera loading and many planet properties

Location:
trunk/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/camera.cc

    r10389 r10391  
    4141{
    4242  this->registerObject(this, Camera::_objectList);
     43
    4344  this->init();
    4445}
    4546
    46 /*
     47
    4748Camera::Camera(const TiXmlElement* root)
    4849{
    4950  this->registerObject(this, Camera::_objectList);
     51
     52  if( root != NULL)
     53    this->loadParams(root);
     54
    5055  this->init();
    51   this->loadParams(root);
    52 }
    53 */
     56
     57}
     58
    5459
    5560/**
     
    8792  this->viewLeftDistance = 10;
    8893
    89   //this->loadParams(doc.RootElement());
    90 
    9194  this->setViewMode(Camera::ViewNormal);
    9295
    9396  this->setParentMode(PNODE_ALL);
    9497  this->eventHandling = true;
    95  
     98
    9699  //add to track
    97100  if(this->entityTrack)
     
    213216  if (fabsf(tmpFovy) > 0.01)
    214217    this->fovy += tmpFovy * fabsf(dt);
    215    
     218
    216219  if(this->entityTrack)
    217220    this->entityTrack->tick(dt);
     
    302305{
    303306  // Do the PNode loading stuff
    304   PNode::loadParams(root);
     307  WorldEntity::loadParams(root);
    305308
    306309  LoadParam(root, "viewTopFovy", this, Camera, setViewTopFovy);
  • trunk/src/world_entities/planet.cc

    r10387 r10391  
    4545  this->toList(OM_GROUP_01);
    4646
     47  this->rotSpeedPlanet = 0.0;
     48  this->rotSpeedCloud = 0.0;
     49
    4750  //this->materialPlanet->setIllum(20);
    4851  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
     
    5457  this->setModel(model);
    5558
    56 
    57 
     59  this->cloudModel = new PrimitiveModel(PRIM_SPHERE, this->size + 10, 50);
    5860}
    5961
     
    7779  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
    7880      .describe("Sets the cloud texture of the planet");
     81
     82  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
     83      .describe("Sets the cloud rotation speed");
    7984
    8085  LoadParam(root, "size", this, Planet, setSize)
     
    103108
    104109
     110void Planet::setCloudRotation(float rotationSpeed)
     111{
     112  this->rotSpeedCloud = rotationSpeed;
     113}
     114
    105115/**
    106116 * @param size The new size of the Planet
     
    114124
    115125
     126void Planet::tick( float dt)
     127{
     128  if( dt != 0.)
     129    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
     130}
    116131
     132
     133/**
     134 * draws the planet
     135 */
    117136void Planet::draw() const
    118137{
     138  // draw the clouds
    119139  this->materialPlanet.select();
     140  WorldEntity::draw();
    120141
    121   WorldEntity::draw();
     142  this->materialCloud.select();
     143  WorldEntity::draw(this->cloudModel);
     144
    122145}
    123146
  • trunk/src/world_entities/planet.h

    r10387 r10391  
    2929  void setTexture(const std::string& textureName);
    3030  void setCloudTexture(const std::string& textureName);
     31  void setCloudRotation(float rotationSpeed);
    3132
    3233
    3334
     35  virtual void tick( float dt);
    3436  virtual void draw() const;
    3537
     
    4244  Model*          cloudModel;      //!< the model for the cloud
    4345
    44 
     46  float           rotSpeedCloud;   //! cloud rotation speed
     47  float           rotSpeedPlanet;  //! planet rotation speed
    4548  float           size;            //!< Size of the Planet. This should match the frustum maximum range.
    4649  float           textureSize;     //!< this is the length of a texture (assumes a square texture)
  • trunk/src/world_entities/world_entity.cc

    r10368 r10391  
    6868 */
    6969WorldEntity::WorldEntity()
    70   : Synchronizeable(), _collisionFilter(this)
     70    : Synchronizeable(), _collisionFilter(this)
    7171{
    7272  this->registerObject(this, WorldEntity::_objectList);
     
    171171  // Track
    172172  LoadParamXML(root, "Track", this, WorldEntity, addTrack)
    173    .describe("creates and adds a track to this WorldEntity");
     173  .describe("creates and adds a track to this WorldEntity");
    174174}
    175175
     
    191191  }
    192192  LOAD_PARAM_END_CYCLE(element);*/
    193  
     193
    194194
    195195}
     
    252252        this->setModel(model, modelNumber);
    253253
    254         if( modelNumber == 0)
     254        if( modelNumber == 0)
    255255        {
    256           this->buildObbTree(obbTreeDepth);
     256          this->buildObbTree(obbTreeDepth);
    257257        }
    258258      }
     
    275275    {
    276276      PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str());
    277 //      Model* m = new md3::MD3Model(fileName, this->scaling);
    278 //      this->setModel(m, 0);
     277      //      Model* m = new md3::MD3Model(fileName, this->scaling);
     278      //      this->setModel(m, 0);
    279279
    280280      //       if( m != NULL)
     
    448448void WorldEntity::unmount(int slot)
    449449{
    450     if( this->mountPoints[slot] == NULL)
     450  if( this->mountPoints[slot] == NULL)
    451451  {
    452452    PRINTF(0)("you tried to remove an entity from a mount point that doesn't exist (slot %i)\n", slot);
     
    649649*/
    650650void WorldEntity::tick(float time)
    651 {
    652 }
     651{}
    653652
    654653
     
    689688      this->models[0]->draw();
    690689    }
    691    
     690
    692691    //if (this->entityTrack)
    693        //this->entityTrack->drawGraph(0.02);
     692    //this->entityTrack->drawGraph(0.02);
    694693
    695694    //     if( this->aabbNode != NULL)
     
    699698  }
    700699}
     700
     701
     702/**
     703 *  the entity is drawn onto the screen with this function
     704 *
     705 * This is a central function of an entity: call it to let the entity painted to the screen.
     706 * Just override this function with whatever you want to be drawn.
     707*/
     708void WorldEntity::draw(const Model* model) const
     709{
     710  glMatrixMode(GL_MODELVIEW);
     711  glPushMatrix();
     712
     713  /* translate */
     714  glTranslatef (this->getAbsCoor ().x,
     715                this->getAbsCoor ().y,
     716                this->getAbsCoor ().z);
     717  Vector tmpRot = this->getAbsDir().getSpacialAxis();
     718  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     719
     720
     721  // This Draws the LOD's
     722  if( model != NULL)
     723    model->draw();
     724
     725  glPopMatrix();
     726}
     727
    701728
    702729/**
  • trunk/src/world_entities/world_entity.h

    r10368 r10391  
    7575  virtual void tick (float time);
    7676  virtual void draw () const;
     77  void draw(const Model* model) const;
    7778  void debugDrawMountPoints() const;
    7879
Note: See TracChangeset for help on using the changeset viewer.