Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3698 in orxonox.OLD for orxonox/branches/shadows/src/world.cc


Ignore:
Timestamp:
Mar 31, 2005, 9:04:45 PM (19 years ago)
Author:
dave
Message:

branches/shadows: so jetzt ist die Ausgangslage geschaffen

File:
1 edited

Legend:

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

    r3370 r3698  
    2828#include "helper_parent.h"
    2929#include "glmenu_imagescreen.h"
     30#include "skysphere.h"
     31#include "importer/material.h"
    3032
    3133using namespace std;
     
    9294  {20.0, 10.0, 5.0}, {40.0, -10.0, 0.0},
    9395  {60.0, -10.0, 5.0}, {80.0, 10.0, 5.0}};
     96
     97
    9498
    9599
     
    286290            orx->getLocalInput()->bind (myPlayer);
    287291           
     292           
     293            // create skybox
     294            this->skysphere =new Skysphere();
     295                   
     296                   
    288297            // bind camera
    289298            this->localCamera = new Camera(this);
     
    330339            this->pathnodes[5] = Vector(30, 50, 0);
    331340           
    332 
     341           
    333342
    334343
     
    368377
    369378  // 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   
    370392  objectList = glGenLists(1);
    371393  glNewList (objectList, GL_COMPILE);
    372394  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 
    374404  glBegin(GL_QUADS);
    375 
     405 
     406 
     407 
    376408  int sizeX = 100;
    377409  int sizeZ = 80;
    378410  float length = 1000;
    379   float width = 200;
     411  float width = 300;
    380412  float widthX = float (length /sizeX);
    381413  float widthZ = float (width /sizeZ);
     
    419451      }
    420452
    421   int snowheight=3;
     453 
    422454  for ( int i = 0; i<sizeX; i+=1)
    423455    for (int j = 0; j<sizeZ;j+=1)
     
    428460        Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
    429461        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       
    443467        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);
    444470        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       
    458473        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);
    459476        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       
    474478        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);
    475481        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       
    488483        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);
    489486        glVertex3f(v4.x, v4.y, v4.z);
    490487       
    491488      }
    492489  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 
    533496  //draw track
    534497  glBegin(GL_LINES);
     
    541504  glEnd();
    542505 
    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
    552507
    553508  trackManager->drawGraph(.01);
    554509  trackManager->debug(2);
    555510  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(); 
    568513}
    569514
     
    630575
    631576  // draw debug coord system
     577  //glLoadIdentity();
     578 
    632579  glCallList (objectList);
    633580
     581
     582  //After calling the list, draw the skysphere
     583 
     584  glEnable(GL_TEXTURE_2D);
     585 
     586  skysphere->draw();
     587 
    634588}
    635589
     
    644598void World::update ()
    645599{
     600   
    646601  /*
    647602  //List<WorldEntity> *l;
     
    711666      entity = entities->nextElement();
    712667    }
    713 
     668 
     669  skysphere->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z);
     670 
    714671  //for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    715672}
Note: See TracChangeset for help on using the changeset viewer.