Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2037 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jun 28, 2004, 12:59:44 AM (20 years ago)
Author:
adrian
Message:

orxonox/branches/burli: Repeating ground grid (plus player-centered view for testing)

Location:
orxonox/branches/burli/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/burli/src/world.cc

    r1956 r2037  
    1919
    2020#include <iostream>
     21#include <stdlib.h>
     22#include <math.h>
    2123
    2224using namespace std;
     
    175177{
    176178  glLoadIdentity();
    177   gluLookAt(0.0, -14.0 + DataTank::yOffset, 15.0, 0.0, 0.0 + DataTank::yOffset, 0.0, 0.0, 1.0, 0.0);
     179  gluLookAt(2*sin(DataTank::yOffset/90*3.141)+DataTank::xOffset, -17.0 + DataTank::yOffset, 14.0 + 5*cos(DataTank::yOffset/50*3.141), DataTank::xOffset, 0.0 + DataTank::yOffset, 0.0, 0.0, 1.0, 0.0);
    178180  /* first draw all players */
    179181  playerList* tmpPlayer = lastPlayer;
     
    200202    }
    201203 
    202   /* draw the ground grid  */
     204  /* draw the repeating ground grid  */
    203205  glColor3f(0.0, 1.0, 0.0);
    204206  glBegin(GL_LINES);
    205   /* for the moment, we've got only pseudo moving ground */
    206   for (int y = 0; y < 60; y += 2)
    207     {
    208       for (int x = 0; x < 60; x += 2)
     207  float drawx, drawy;
     208  int offsetx, offsety;
     209  float s1, s2;
     210 
     211  for (int y = 0; y < GRIDLENGTH; y++)
     212  {
     213        drawy = y + floor(DataTank::yOffset) - GRIDLENGTH / 2;
     214        offsety = (int)floor(DataTank::yOffset) + y;
     215        if (offsety < 0)
    209216        {
    210           glVertex3f((float)(x - 30), (float)(y - 30), surface[x][y]);
    211           glVertex3f((float)(x - 28), (float)(y - 30), surface[x+2][y]);
    212         }
    213     }
    214   glEnd();
    215  
    216   glBegin(GL_LINES);
    217   for (int x = 0; x < 60; x += 2)
    218     {
    219       for (int y = 0; y < 60; y += 2)
     217          offsety = GRIDLENGTH - ((-offsety) % GRIDLENGTH);
     218        }
     219       
     220        for (int x = 0; x < GRIDWIDTH; x++)
    220221        {
    221           glVertex3f((float)(x - 30), (float)(y - 30), surface[x][y]);
    222           glVertex3f((float)(x - 30), (float)(y - 28), surface[x][y+2]);
    223         }
    224     }
     222          drawx = x + floor(DataTank::xOffset) - GRIDWIDTH / 2;
     223          offsetx = (int)floor(DataTank::xOffset) + x;
     224          if (offsetx < 0)
     225          {
     226                offsetx = GRIDWIDTH - ((-offsetx) % GRIDWIDTH);
     227          }
     228                 
     229          /* horizontal */
     230          /* not simplified! */
     231          s1 = surface[(offsetx+GRIDWIDTH   )%GRIDWIDTH][offsety%GRIDLENGTH];
     232          s2 = surface[(offsetx+GRIDWIDTH+1)%GRIDWIDTH][offsety%GRIDLENGTH];
     233          glVertex3f(drawx, drawy, s1);
     234          glVertex3f(drawx+1, drawy, s2);
     235         
     236          /* vertical */
     237          s1 = surface[offsetx%GRIDWIDTH][(offsety+GRIDLENGTH  )%GRIDLENGTH];
     238          s2 = surface[offsetx%GRIDWIDTH][(offsety+GRIDLENGTH+1)%GRIDLENGTH];
     239          glVertex3f(drawx, drawy, s1);
     240          glVertex3f(drawx, drawy+1, s2);
     241        }
     242  }
    225243  glEnd();
    226244
    227245  //primitiveMove+=0.07;
    228246  DataTank::yOffset += step;
    229 
     247 
    230248  tmpPlayer = lastPlayer;
    231249  while( tmpPlayer != null )
    232250    {
    233251      tmpPlayer->player->yCor += step;
     252      /* just for testing: alway have the player in the center */
     253      DataTank::xOffset = (20 * DataTank::xOffset + (float)tmpPlayer->player->xCor) / 21.0;
    234254      tmpPlayer = tmpPlayer->next;
    235255    }
    236 
    237256 
    238257}
     
    241260void World::initEnvironement()
    242261{
    243 
    244  for (int x = 0; x < 60; x += 2)
    245     {
    246       for (int y = 0; y < 60; y += 2)
     262 double rx;
     263 for (int y = 0; y < GRIDLENGTH; y++)
     264 {
     265    for (int x = 0; x < GRIDWIDTH; x++)
    247266        {
    248           surface[x][y] = 0;
    249         }
    250     }
     267          /*surface[x][y] = cos(y*3.141/8 )*0.7 * (0.6 + sin(x*3.141/5 + phase)*cos(y*3.141/5*3) * 0.4);*/
     268         rx = double(x - GRIDWIDTH/2 + GRIDWIDTH / 20)/GRIDWIDTH*12;
     269         surface[x][y] = -exp(-abs(rx))*rx*5 + cos(y*3.141/6)*0.6-3;
     270         surface[x][y] += (x%8 && y%12) ? 5 : 0;
     271         surface[x][y] -= (x%3 && y%3) ? 0.3 : 0;
     272        }       
     273  }
    251274}
    252275
  • orxonox/branches/burli/src/world.h

    r1956 r2037  
    1515#include "stdincl.h"
    1616#include "data_tank.h"
     17
     18const long GRIDWIDTH = 100;
     19const long GRIDLENGTH = 120;
    1720
    1821class World {
     
    7174
    7275 private:
    73   float surface[120][120];
     76  float surface[GRIDWIDTH][GRIDLENGTH];
    7477  float step;
    7578
Note: See TracChangeset for help on using the changeset viewer.