Changeset 2037 in orxonox.OLD for orxonox/branches
- Timestamp:
- Jun 28, 2004, 12:59:44 AM (20 years ago)
- Location:
- orxonox/branches/burli/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/burli/src/world.cc
r1956 r2037 19 19 20 20 #include <iostream> 21 #include <stdlib.h> 22 #include <math.h> 21 23 22 24 using namespace std; … … 175 177 { 176 178 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); 178 180 /* first draw all players */ 179 181 playerList* tmpPlayer = lastPlayer; … … 200 202 } 201 203 202 /* draw the ground grid */204 /* draw the repeating ground grid */ 203 205 glColor3f(0.0, 1.0, 0.0); 204 206 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) 209 216 { 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++) 220 221 { 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 } 225 243 glEnd(); 226 244 227 245 //primitiveMove+=0.07; 228 246 DataTank::yOffset += step; 229 247 230 248 tmpPlayer = lastPlayer; 231 249 while( tmpPlayer != null ) 232 250 { 233 251 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; 234 254 tmpPlayer = tmpPlayer->next; 235 255 } 236 237 256 238 257 } … … 241 260 void World::initEnvironement() 242 261 { 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++) 247 266 { 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 } 251 274 } 252 275 -
orxonox/branches/burli/src/world.h
r1956 r2037 15 15 #include "stdincl.h" 16 16 #include "data_tank.h" 17 18 const long GRIDWIDTH = 100; 19 const long GRIDLENGTH = 120; 17 20 18 21 class World { … … 71 74 72 75 private: 73 float surface[ 120][120];76 float surface[GRIDWIDTH][GRIDLENGTH]; 74 77 float step; 75 78
Note: See TracChangeset
for help on using the changeset viewer.