Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2780 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Nov 10, 2004, 4:34:21 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/importer: added specular, ambient light. Also made some fancy lightshow in framework (LIGHT IS NECESSARY NOW)

Location:
orxonox/branches/importer/importer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/importer/importer/framework.cc

    r2773 r2780  
    66Object* obj;
    77float rotator = 0.0;
     8  GLfloat whiteLight[] = {1.0, 1.0, 0.0,1.0};
    89
    910void DrawGLScene()
     
    1819  gluPerspective(45.0f,500/375,0.1f,100.0f);
    1920  gluLookAt (5*sin(rotator),7.5,5*cos(rotator), 0,0,0, 0,1,0);
    20  
     21  whiteLight[1] = .5+.5*sin(rotator*10);
     22  whiteLight[2] = .5+.5*sin(rotator*10);
     23  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    2124  obj->draw();
    2225
     
    4245
    4346  obj = new Object (argv[1]);
     47
     48  GLfloat lightPosition[] = {10.0, 5.0, 19.0, 0.0};
     49  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
     50  glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
     51  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
     52  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
     53  glEnable(GL_LIGHTING);
     54  glEnable(GL_LIGHT0);
     55  glEnable(GL_DEPTH_TEST);
    4456
    4557  // Build the font from a TGA image font.tga in the data directory
  • orxonox/branches/importer/importer/material.cc

    r2778 r2780  
    6666  diffuse[0] = r;
    6767  diffuse[1] = g;
    68   diffuse[2] = b;
     68  diffuse[2] = b; 
     69  diffuse[3] = 1.0;
     70
    6971  //  printf ("setting Diffuse Color to r=%f g=%f b=%f\n", r, g, b);
    7072}
     
    8183  ambient[1] = g;
    8284  ambient[2] = b;
     85  ambient[3] = 1.0;
    8386  //  printf ("setting Ambient Color to r=%f g=%f b=%f\n", r, g, b);
    8487}
     
    9598  specular[1] = g;
    9699  specular[2] = b;
     100  specular[3] = 1.0;
    97101  //printf ("setting Specular Color to r=%f g=%f b=%f\n", r, g, b);
    98102}
     
    131135bool Material::select (void)
    132136{
    133   glColor3f (diffuse[0], diffuse[1], diffuse[2]);
     137  // setting diffuse color
     138  //  glColor3f (diffuse[0], diffuse[1], diffuse[2]);
     139  glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
     140
     141  // setting ambient color
     142  glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
     143
     144  // setting up Sprecular
     145  glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
     146 
     147  // setting illumination Model
     148  if (illumModel == 1)
     149    glShadeModel(GL_FLAT);
     150  else if (illumModel >= 2)
     151    glShadeModel(GL_SMOOTH);
    134152}
  • orxonox/branches/importer/importer/material.h

    r2778 r2780  
    3939  char name [50];
    4040  int illumModel;
    41   float diffuse [3];
    42   float ambient [3];
    43   float specular [3];
     41  float diffuse [4];
     42  float ambient [4];
     43  float specular [4];
    4444  float transparency;
    4545
Note: See TracChangeset for help on using the changeset viewer.