Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10468 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 28, 2007, 11:22:33 PM (18 years ago)
Author:
patrick
Message:

added scriptable stuff to the now finished scrollertext. thx silvan for the good tutorial, it realy is complete

Location:
trunk/src/world_entities
Files:
2 edited

Legend:

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

    r10467 r10468  
    2626#include "camera.h"
    2727
     28#include "script_class.h"
     29
     30
    2831ObjectListDefinition(ScrollingScreen);
    2932CREATE_FACTORY(ScrollingScreen);
    3033
     34CREATE_SCRIPTABLE_CLASS(ScrollingScreen,
     35                        addMethod("start", Executor0<ScrollingScreen, lua_State*>(&ScrollingScreen::start))
     36                       );
    3137
    3238
     
    5864{}
    5965
     66void ScrollingScreen::start()
     67{
     68  this->bRun = true;
     69}
    6070
    6171/**
     
    7888  this->ySize = 0.;
    7989  this->mode = SCSC_VIEW;
     90  this->bRun = false;
    8091}
    8192
     
    119130void ScrollingScreen::draw() const
    120131{
     132
     133  if( this->offset - this->ratio > 1.|| this->offset < -1. || !this->bRun)
     134    return;
    121135
    122136  if( this->mode == SCSC_FULL)
     
    147161  glBegin(GL_QUADS);
    148162
    149     // unten links
    150     glTexCoord2f(0., 1.);
    151     glVertex3f(0., -this->xSize*0.5, -this->ySize*0.5);
    152 
    153     // unten rechts
    154     glTexCoord2f(1., 1.);
    155     glVertex3f(0., -this->xSize*0.5, this->ySize*0.5);
    156 
    157     // oben rechts
    158     glTexCoord2f(1., 0.);
    159     glVertex3f(0., this->xSize*0.5, this->ySize*0.5);
    160 
    161     // oben links
    162     glTexCoord2f(0., 0.);
    163     glVertex3f(0., this->xSize*0.5, -this->ySize*0.5);
     163  // unten links
     164  glTexCoord2f(0., 1.);
     165  glVertex3f(0., -this->xSize*0.5, -this->ySize*0.5);
     166
     167  // unten rechts
     168  glTexCoord2f(1., 1.);
     169  glVertex3f(0., -this->xSize*0.5, this->ySize*0.5);
     170
     171  // oben rechts
     172  glTexCoord2f(1., 0.);
     173  glVertex3f(0., this->xSize*0.5, this->ySize*0.5);
     174
     175  // oben links
     176  glTexCoord2f(0., 0.);
     177  glVertex3f(0., this->xSize*0.5, -this->ySize*0.5);
    164178
    165179  glEnd();
     
    201215  }
    202216
     217  float ratShift = 0.;
    203218  float borderTex = this->offset + ratio;
    204219  // we are above/below
     
    206221  {
    207222    borderTex = 1.0;
     223    ratShift = 1. - (1.-offset)/ratio;
    208224  }
    209225
    210226  glBegin(GL_QUADS);
    211     // unten links
    212     glTexCoord2f(0., borderTex);
    213     glVertex3f(0., -x*0.5, -y*0.5);
    214 
    215     // unten rechts
    216     glTexCoord2f(1., borderTex);
    217     glVertex3f(0., -x*0.5, y*0.5);
    218 
    219     // oben rechts
    220     glTexCoord2f(1., this->offset);
    221     glVertex3f(0., x*0.5, y*0.5);
    222 
    223     // oben links
    224     glTexCoord2f(0., this->offset);
    225     glVertex3f(0., x*0.5, -y*0.5);
     227  // unten links
     228  glTexCoord2f(0., borderTex);
     229  glVertex3f(0., -(x*0.5 - x*ratShift), -y*0.5);
     230
     231  // unten rechts
     232  glTexCoord2f(1., borderTex);
     233  glVertex3f(0., -(x*0.5 - x*ratShift), y*0.5);
     234
     235  // oben rechts
     236  glTexCoord2f(1., this->offset);
     237  glVertex3f(0., x*0.5, y*0.5);
     238
     239  // oben links
     240  glTexCoord2f(0., this->offset);
     241  glVertex3f(0., x*0.5, -y*0.5);
    226242
    227243  glEnd();
     
    238254{
    239255
    240     CameraMan* cm = State::getCameraman();
    241     const Camera* cam = cm->getCurrentCam();
    242     PNode* tar = cam->getTargetNode();
    243 
    244     Vector dir = tar->getAbsCoor() - cam->getAbsCoor();
    245     dir = dir.getNormalized();
    246 
    247     float offset = 4.;
    248 
    249     this->setAbsCoor( cam->getAbsCoor() + dir * offset);
    250 
    251 
    252     Vector ddir = dir.cross( cam->getAbsDirV());
    253     Quaternion q(ddir, cam->getAbsDirY());
    254     this->setAbsDir( q);
    255 
    256     // scroll the texture
    257     this->offset += time * this->scrollingSpeed;
    258     if( this->offset > 1.|| this->offset < -1.)
    259       this->offset = 0.;
    260 
    261 /*    PRINTF(0)("offset %f, offset: %f\n", this->offset, time * this->scrollingSpeed);*/
    262 
    263 //     if( this->getParent() != cam)
    264 //     {
    265 //       this->setParent( cam);
    266 //       this->setRelCoor( 4.0, 0., 0.);
    267 //       this->setRelDir();
    268 //     }
    269 
     256  if( !this->bRun)
     257    return;
     258
     259  CameraMan* cm = State::getCameraman();
     260  const Camera* cam = cm->getCurrentCam();
     261  PNode* tar = cam->getTargetNode();
     262
     263  Vector dir = tar->getAbsCoor() - cam->getAbsCoor();
     264  dir = dir.getNormalized();
     265
     266  float offset = 6.;
     267
     268  this->setAbsCoor( cam->getAbsCoor() + dir * offset);
     269
     270
     271  Vector ddir = dir.cross( cam->getAbsDirV());
     272  Quaternion q(ddir, cam->getAbsDirY());
     273  this->setAbsDir( q);
     274
     275  // scroll the texture
     276  this->offset += time * this->scrollingSpeed;
     277  //     if( this->offset - this->ratio > 1.|| this->offset < -1.)
     278  //       this->offset = 0.;
    270279
    271280}
     
    273282void ScrollingScreen::fadeIn(float speed)
    274283{
    275 
    276284}
    277285
    278286void ScrollingScreen::fadeOut(float speed)
    279287{
    280 
    281 }
     288}
  • trunk/src/world_entities/scrolling_screen.h

    r10466 r10468  
    2727  void init();
    2828  virtual void loadParams(const TiXmlElement* root);
     29
     30  void start();
    2931
    3032  void fadeIn(float speed);
     
    6163  int             mode;
    6264
     65  bool            bRun;
    6366};
    6467
Note: See TracChangeset for help on using the changeset viewer.