Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6771 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 26, 2006, 2:39:31 PM (19 years ago)
Author:
bensch
Message:

Water is better now (but still quite Bad)

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/event/event_handler.cc

    r6769 r6771  
    156156  PRINTF(4)("Subscribing event type: %i\n", eventType);
    157157  if( state == ES_ALL )
    158     {
    159       for(unsigned int i = 0; i < ES_NUMBER; i++)
    160         if( likely(this->listeners[i][eventType] == NULL))
    161           this->listeners[i][eventType] = el;
    162         else
    163           PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
    164     }
     158  {
     159    for(unsigned int i = 0; i < ES_NUMBER; i++)
     160      if( likely(this->listeners[i][eventType] == NULL))
     161        this->listeners[i][eventType] = el;
     162      else
     163        PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
     164  }
    165165  else
    166166    if( likely(this->listeners[state][eventType] == NULL))
    167       {
    168         this->listeners[state][eventType] = el;
    169       }
     167    {
     168      this->listeners[state][eventType] = el;
     169    }
    170170    else
    171171      PRINTF(2)("% of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
     
    203203    return;
    204204  if( state == ES_ALL)
    205     {
    206       for(unsigned int i = 0; i < ES_NUMBER; i++)
    207         {
    208           for(unsigned int j = 0; j < EV_NUMBER; j++)
    209             {
    210               if( this->listeners[i][j] == el )
    211                 this->listeners[i][j] = NULL;
    212             }
    213         }
    214     }
    215   else
    216     {
    217       for(int j = 0; j < EV_NUMBER; j++)
    218         {
    219           if( this->listeners[state][j] == el )
    220             this->listeners[state][j] = NULL;
    221         }
    222     }
     205  {
     206    for(unsigned int i = 0; i < ES_NUMBER; i++)
     207    {
     208      for(unsigned int j = 0; j < EV_NUMBER; j++)
     209      {
     210        if( this->listeners[i][j] == el )
     211          this->listeners[i][j] = NULL;
     212      }
     213    }
     214  }
     215  else
     216  {
     217    for(int j = 0; j < EV_NUMBER; j++)
     218    {
     219      if( this->listeners[state][j] == el )
     220        this->listeners[state][j] = NULL;
     221    }
     222  }
    223223}
    224224
     
    231231{
    232232  if( state == ES_ALL)
    233     {
    234       for(int i = 0; i < ES_NUMBER; ++i)
    235         {
    236           for(int j = 0; j < EV_NUMBER; ++j)
    237             {
    238               this->listeners[i][j] = NULL;
    239             }
    240         }
    241     }
    242   else
     233  {
     234    for(int i = 0; i < ES_NUMBER; ++i)
    243235    {
    244236      for(int j = 0; j < EV_NUMBER; ++j)
    245         {
    246           this->listeners[state][j] = NULL;
    247         }
    248     }
     237      {
     238        this->listeners[i][j] = NULL;
     239      }
     240    }
     241  }
     242  else
     243  {
     244    for(int j = 0; j < EV_NUMBER; ++j)
     245    {
     246      this->listeners[state][j] = NULL;
     247    }
     248  }
    249249}
    250250
     
    262262    SDL_WM_GrabInput(SDL_GRAB_OFF);
    263263  else
    264     ;//    SDL_WM_GrabInput(SDL_GRAB_ON);
     264    SDL_WM_GrabInput(SDL_GRAB_ON);
    265265}
    266266
     
    276276  EventListener* listener = NULL;
    277277  while( SDL_PollEvent (&event))
    278     {
    279       switch( event.type)
    280         {
    281         case SDL_KEYDOWN:
    282           ev.bPressed = true;
    283           ev.type = event.key.keysym.sym;
    284           if (unlikely(this->bUNICODE))
    285               ev.x = event.key.keysym.unicode;
    286           break;
    287         case SDL_KEYUP:
    288           ev.bPressed = false;
    289           ev.type = event.key.keysym.sym;
    290           if (unlikely(this->bUNICODE))
    291             ev.x = event.key.keysym.unicode;
    292           break;
    293         case SDL_MOUSEMOTION:
    294           ev.bPressed = false;
    295           ev.type = EV_MOUSE_MOTION;
    296           ev.x = event.motion.x;
    297           ev.y = event.motion.y;
    298           ev.xRel = event.motion.xrel;
    299           ev.yRel = event.motion.yrel;
    300           break;
    301         case SDL_MOUSEBUTTONUP:
    302           ev.bPressed = false;
    303           ev.type = event.button.button + SDLK_LAST;
    304           break;
    305         case SDL_MOUSEBUTTONDOWN:
    306           ev.bPressed = true;
    307           ev.type = event.button.button + SDLK_LAST;
    308           break;
    309         case SDL_JOYAXISMOTION:
    310           ev.bPressed = false;
    311           ev.type = EV_JOY_AXIS_MOTION;
    312           break;
    313         case SDL_JOYBALLMOTION:
    314           ev.bPressed = false;
    315           ev.type = EV_JOY_BALL_MOTION;
    316           break;
    317         case SDL_JOYHATMOTION:
    318           ev.bPressed = false;
    319           ev.type = EV_JOY_HAT_MOTION;
    320           break;
    321         case SDL_JOYBUTTONDOWN:
    322           ev.bPressed = true;
    323           ev.type = EV_JOY_BUTTON;
    324           break;
    325         case SDL_JOYBUTTONUP:
    326           ev.bPressed = true;
    327           ev.type = EV_JOY_BUTTON;
    328           break;
    329         case SDL_VIDEORESIZE:
    330           ev.resize = event.resize;
    331           ev.type = EV_VIDEO_RESIZE;
    332           break;
    333         case SDL_QUIT:
    334           ev.type = EV_MAIN_QUIT;
    335           break;
    336         default:
    337           ev.type = EV_UNKNOWN;
    338           break;
    339         }
    340 
    341       /* small debug routine: shows all events dispatched by the event handler */
    342       PRINT(4)("\n==========================| EventHandler::process () |===\n");
    343       PRINT(4)("=  Got Event nr %i, for state %i", ev.type, this->state);
    344 
    345       listener = this->listeners[this->state][ev.type];
    346       if( listener != NULL)
    347         {
    348           PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
    349           PRINT(4)("=======================================================\n");
    350           listener->process(ev);
    351         }
    352       else
    353         {
    354           PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
    355           PRINT(4)("=======================================================\n");
    356         }
    357     }
     278  {
     279    switch( event.type)
     280    {
     281      case SDL_KEYDOWN:
     282        ev.bPressed = true;
     283        ev.type = event.key.keysym.sym;
     284        if (unlikely(this->bUNICODE))
     285          ev.x = event.key.keysym.unicode;
     286        break;
     287      case SDL_KEYUP:
     288        ev.bPressed = false;
     289        ev.type = event.key.keysym.sym;
     290        if (unlikely(this->bUNICODE))
     291          ev.x = event.key.keysym.unicode;
     292        break;
     293      case SDL_MOUSEMOTION:
     294        ev.bPressed = false;
     295        ev.type = EV_MOUSE_MOTION;
     296        ev.x = event.motion.x;
     297        ev.y = event.motion.y;
     298        ev.xRel = event.motion.xrel;
     299        ev.yRel = event.motion.yrel;
     300        break;
     301      case SDL_MOUSEBUTTONUP:
     302        ev.bPressed = false;
     303        ev.type = event.button.button + SDLK_LAST;
     304        break;
     305      case SDL_MOUSEBUTTONDOWN:
     306        ev.bPressed = true;
     307        ev.type = event.button.button + SDLK_LAST;
     308        break;
     309      case SDL_JOYAXISMOTION:
     310        ev.bPressed = false;
     311        ev.type = EV_JOY_AXIS_MOTION;
     312        break;
     313      case SDL_JOYBALLMOTION:
     314        ev.bPressed = false;
     315        ev.type = EV_JOY_BALL_MOTION;
     316        break;
     317      case SDL_JOYHATMOTION:
     318        ev.bPressed = false;
     319        ev.type = EV_JOY_HAT_MOTION;
     320        break;
     321      case SDL_JOYBUTTONDOWN:
     322        ev.bPressed = true;
     323        ev.type = EV_JOY_BUTTON;
     324        break;
     325      case SDL_JOYBUTTONUP:
     326        ev.bPressed = true;
     327        ev.type = EV_JOY_BUTTON;
     328        break;
     329      case SDL_VIDEORESIZE:
     330        ev.resize = event.resize;
     331        ev.type = EV_VIDEO_RESIZE;
     332        break;
     333      case SDL_QUIT:
     334        ev.type = EV_MAIN_QUIT;
     335        break;
     336      default:
     337        ev.type = EV_UNKNOWN;
     338        break;
     339    }
     340
     341    /* small debug routine: shows all events dispatched by the event handler */
     342    PRINT(4)("\n==========================| EventHandler::process () |===\n");
     343    PRINT(4)("=  Got Event nr %i, for state %i", ev.type, this->state);
     344
     345    listener = this->listeners[this->state][ev.type];
     346    if( listener != NULL)
     347    {
     348      PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
     349      PRINT(4)("=======================================================\n");
     350      listener->process(ev);
     351    }
     352    else
     353    {
     354      PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
     355      PRINT(4)("=======================================================\n");
     356    }
     357  }
    358358}
    359359
  • trunk/src/lib/graphics/importer/vertex_array_model.cc

    r6769 r6771  
    268268          this->addNormal(0.0, 1, 0.0);
    269269          this->addTexCoor((float)i/(float)resolutionX, (float)j/(float)resolutionY);
    270           this->addColor((float)i/20.0, 0.0, (float)j/20.0);
     270          this->addColor(1.0, 1.0, 1.0);
    271271        }
    272272    }
  • trunk/src/story_entities/game_world_data.cc

    r6634 r6771  
    3333#include "test_entity.h"
    3434#include "terrain.h"
     35#include "skybox.h"
    3536#include "md2Model.h"
    3637#include "world_entities/projectiles/projectile.h"
     
    5960#include "ogg_player.h"
    6061#include "shader.h"
    61 
    6262
    6363
     
    207207      //todo do this more elegant
    208208      if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
     209      {
    209210        this->sky = dynamic_cast<WorldEntity*>(created);
     211        State::setSkyBox(dynamic_cast<SkyBox*>(this->sky));
     212      }
    210213      if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    211214      {
     
    263266    delete this->objectManager;
    264267  }
     268  if(State::getSkyBox())
     269    State::setSkyBox(NULL);
    265270}
    266271
  • trunk/src/world_entities/environments/water.cc

    r6766 r6771  
    8585}
    8686
     87/**
     88 * @brief rebuilds the Grid below the WaterSurface, killing all hight information
     89 *
     90 * This should be called on all subGrid changes except wave and tick.
     91 */
    8792void Water::rebuildGrid()
    8893{
     
    118123}
    119124
     125/**
     126 * after this a rebuild() must be called
     127 */
    120128void Water::setResolution(unsigned int resX, unsigned int resY)
    121129{
     
    124132}
    125133
     134/**
     135 * after this a rebuild() must be called
     136 */
    126137void Water::setSize(float sizeX, float sizeY)
    127138{
     
    136147
    137148
     149/**
     150 * @brief calculated the Position in the Grid, this Point is nearest to
     151 * @param x, the x-position over the Grid
     152 * @param z: the z-Position(or y) over the Grid
     153 * @param row returns the row if not out of range
     154 * @param column returns the column if not out of range
     155 * @returns true if a valid point is found, false if any x or y are out of range
     156 */
    138157bool Water::posToGridPoint(float x, float z, unsigned int& row, unsigned int& column)
    139158{
     
    152171void Water::draw() const
    153172{
    154   if (this->grid != NULL)
    155   {
    156     //SkyBox::enableCubeMap();
    157     WorldEntity::draw();
    158     glBindTexture(GL_TEXTURE_2D, 15);
    159     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    160 
    161     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    162     glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    163     glEnable(GL_TEXTURE_GEN_S);
    164     glEnable(GL_TEXTURE_GEN_T);
    165 
    166     glEnable(GL_BLEND);
     173  assert (this->grid != NULL);
     174  {
     175    glMatrixMode(GL_MODELVIEW);
     176    glPushMatrix();
     177
     178    /* translate */
     179    glTranslatef (this->getAbsCoor ().x,
     180                  this->getAbsCoor ().y,
     181                  this->getAbsCoor ().z);
     182    Vector tmpRot = this->getAbsDir().getSpacialAxis();
     183    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     184
     185    if (State::getSkyBox())
     186    {
     187      glBindTexture(GL_TEXTURE_2D, State::getSkyBox()->getTexture(SKY_TOP));
     188      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     189
     190      glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     191      glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     192      glEnable(GL_TEXTURE_GEN_S);
     193      glEnable(GL_TEXTURE_GEN_T);
     194    }
    167195    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     196    this->grid->draw();
    168197    // this->waterShader->activateShader();
    169198    //  this->waterMaterial->select();
  • trunk/src/world_entities/skybox.h

    r6634 r6771  
    1212/* INCLUDES */
    1313#include "world_entity.h"
     14#include "material.h"
    1415
    15 /* FORWARD DECLARATION */
    16 class Material;
    17 class Texture;
     16enum SKY_SIDE
     17{
     18  SKY_TOP = 0,
     19  SKY_BOTTOM,
     20  SKY_LEFT,
     21  SKY_RIGHT,
     22  SKY_FRONT,
     23  SKY_BACK
     24};
    1825
    1926//! A Class to handle a SkyBox
     
    4653                           const char* right, const char* front, const char* back);
    4754
     55  GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->getDiffuseTexture(): 0; };
     56
    4857  static void enableCubeMap();
    4958  static void disableCubeMap();
Note: See TracChangeset for help on using the changeset viewer.