Changeset 3698 in orxonox.OLD for orxonox/branches/shadows/src/world.cc
- Timestamp:
- Mar 31, 2005, 9:04:45 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/shadows/src/world.cc
r3370 r3698 28 28 #include "helper_parent.h" 29 29 #include "glmenu_imagescreen.h" 30 #include "skysphere.h" 31 #include "importer/material.h" 30 32 31 33 using namespace std; … … 92 94 {20.0, 10.0, 5.0}, {40.0, -10.0, 0.0}, 93 95 {60.0, -10.0, 5.0}, {80.0, 10.0, 5.0}}; 96 97 94 98 95 99 … … 286 290 orx->getLocalInput()->bind (myPlayer); 287 291 292 293 // create skybox 294 this->skysphere =new Skysphere(); 295 296 288 297 // bind camera 289 298 this->localCamera = new Camera(this); … … 330 339 this->pathnodes[5] = Vector(30, 50, 0); 331 340 332 341 333 342 334 343 … … 368 377 369 378 // initialize debug coord system 379 380 381 382 383 384 385 // Initializing the Ground, and loading a Texture into it. 386 Material* boden = new Material("Ground"); 387 boden->setDiffuseMap("../data/pictures/ground.tga"); 388 // Setting the illumination mode otherwise it is flat-shaded. 389 boden->setIllum(3); 390 391 370 392 objectList = glGenLists(1); 371 393 glNewList (objectList, GL_COMPILE); 372 394 glLoadIdentity(); 373 glColor3f(1.0,0,0); 395 //glColor3f(1.0,0,0); 396 397 // Enabling Textures 398 glEnable(GL_TEXTURE_2D); 399 400 // Selecting the new Ground Material. 401 boden->select(); 402 403 374 404 glBegin(GL_QUADS); 375 405 406 407 376 408 int sizeX = 100; 377 409 int sizeZ = 80; 378 410 float length = 1000; 379 float width = 200;411 float width = 300; 380 412 float widthX = float (length /sizeX); 381 413 float widthZ = float (width /sizeZ); … … 419 451 } 420 452 421 int snowheight=3;453 422 454 for ( int i = 0; i<sizeX; i+=1) 423 455 for (int j = 0; j<sizeZ;j+=1) … … 428 460 Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); 429 461 float a[3]; 430 if(height[i][j]<snowheight){ 431 a[0]=0; 432 a[1]=1.0-height[i][j]/10-.3; 433 a[2]=0; 434 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 435 } 436 else{ 437 a[0]=1.0; 438 a[1]=1.0; 439 a[2]=1.0; 440 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 441 442 } 462 a[0]=1.0; 463 a[1]=1.0; 464 a[2]=1.0; 465 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 466 443 467 glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); 468 glTexCoord2f(0.0f,0.0f); 469 //glTexCoord2f((float)i/(float)sizeX,(float)j/(float)sizeZ); 444 470 glVertex3f(v1.x, v1.y, v1.z); 445 if(height[i+1][j]<snowheight){ 446 a[0]=0; 447 a[1] =1.0-height[i+1][j]/10-.3; 448 a[2]=0; 449 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 450 } 451 else{ 452 a[0]=1.0; 453 a[1]=1.0; 454 a[2]=1.0; 455 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 456 457 } 471 472 458 473 glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); 474 glTexCoord2f(1.0f,0.0f); 475 //glTexCoord2f((float)(i+1.0)/(float)sizeX,(float)j/(float)sizeZ); 459 476 glVertex3f(v2.x, v2.y, v2.z); 460 if(height[i+1][j+1]<snowheight){ 461 a[0]=0; 462 a[1] =1.0-height[i+1][j+1]/10-.3; 463 a[2]=0; 464 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 465 } 466 else{ 467 a[0]=1.0; 468 a[1]=1.0; 469 a[2]=1.0; 470 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 471 472 473 } 477 474 478 glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); 479 glTexCoord2f(1.0f,1.0f); 480 //glTexCoord2f((float)(i+1.0)/(float)sizeX,(float)(j+1.0)/(float)sizeZ); 475 481 glVertex3f(v3.x, v3.y, v3.z); 476 if(height[i][j+1]<snowheight){ 477 a[0]=0; 478 a[1] =1.0-height[i+1][j+1]/10-.3; 479 a[2]=0; 480 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 481 } 482 else{ 483 a[0]=1.0; 484 a[1]=1.0; 485 a[2]=1.0; 486 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 487 } 482 488 483 glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); 484 glTexCoord2f(0.0f,1.0f); 485 //glTexCoord2f((float)(i)/(float)sizeX,(float)(j+1.0)/(float)sizeZ); 489 486 glVertex3f(v4.x, v4.y, v4.z); 490 487 491 488 } 492 489 glEnd(); 493 /* 494 glBegin(GL_LINES); 495 for( float x = -128.0; x < 128.0; x += 25.0) 496 { 497 for( float y = -128.0; y < 128.0; y += 25.0) 498 { 499 glColor3f(1,0,0); 500 glVertex3f(x,y,-128.0); 501 glVertex3f(x,y,0.0); 502 glColor3f(0.5,0,0); 503 glVertex3f(x,y,0.0); 504 glVertex3f(x,y,128.0); 505 } 506 } 507 for( float y = -128.0; y < 128.0; y += 25.0) 508 { 509 for( float z = -128.0; z < 128.0; z += 25.0) 510 { 511 glColor3f(0,1,0); 512 glVertex3f(-128.0,y,z); 513 glVertex3f(0.0,y,z); 514 glColor3f(0,0.5,0); 515 glVertex3f(0.0,y,z); 516 glVertex3f(128.0,y,z); 517 } 518 } 519 for( float x = -128.0; x < 128.0; x += 25.0) 520 { 521 for( float z = -128.0; z < 128.0; z += 25.0) 522 { 523 glColor3f(0,0,1); 524 glVertex3f(x,-128.0,z); 525 glVertex3f(x,0.0,z); 526 glColor3f(0,0,0.5); 527 glVertex3f(x,0.0,z); 528 glVertex3f(x,128.0,z); 529 } 530 531 } 532 */ 490 491 // Disable Textures Again, for Performance reasons. 492 //glLoadIdentity(); 493 glDisable(GL_TEXTURE_2D); 494 495 533 496 //draw track 534 497 glBegin(GL_LINES); … … 541 504 glEnd(); 542 505 543 /* 544 glBegin(GL_LINE_STRIP); 545 glColor3f(1.0, 5.0, 1.0); 546 for( int i = 0; i <= 30; i++) 547 { 548 glEvalCoord1f ((GLfloat) i/30.0); 549 } 550 glEnd(); 551 */ 506 552 507 553 508 trackManager->drawGraph(.01); 554 509 trackManager->debug(2); 555 510 delete trackManager; 556 557 /* 558 glBegin(GL_LINES); 559 float i; 560 for(i = 0.0; i<1; i+=.01) 561 { 562 printf("%f, %f, %f\n",tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z); 563 glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z); 564 } 565 glEnd(); 566 */ 567 glEndList(); 511 512 glEndList(); 568 513 } 569 514 … … 630 575 631 576 // draw debug coord system 577 //glLoadIdentity(); 578 632 579 glCallList (objectList); 633 580 581 582 //After calling the list, draw the skysphere 583 584 glEnable(GL_TEXTURE_2D); 585 586 skysphere->draw(); 587 634 588 } 635 589 … … 644 598 void World::update () 645 599 { 600 646 601 /* 647 602 //List<WorldEntity> *l; … … 711 666 entity = entities->nextElement(); 712 667 } 713 668 669 skysphere->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z); 670 714 671 //for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 715 672 }
Note: See TracChangeset
for help on using the changeset viewer.