Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2794 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Nov 10, 2004, 10:47:40 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/importer: vertex normals are read in for real.

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

Legend:

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

    r2780 r2794  
    1515  glLoadIdentity(); // Reset the view
    1616 
    17   glMatrixMode(GL_PROJECTION);                                          // Select The Projection Matrix
     17  glMatrixMode(GL_PROJECTION);
    1818  glLoadIdentity();     
    1919  gluPerspective(45.0f,500/375,0.1f,100.0f);
     
    2121  whiteLight[1] = .5+.5*sin(rotator*10);
    2222  whiteLight[2] = .5+.5*sin(rotator*10);
     23
     24  GLfloat lightPosition[] = {10.0*sin(rotator*10), 10, 19.0, 0.0};
     25  glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
     26
    2327  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    2428  obj->draw();
     
    4650  obj = new Object (argv[1]);
    4751
    48   GLfloat lightPosition[] = {10.0, 5.0, 19.0, 0.0};
    4952  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
    50   glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    5153  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    5254  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
  • orxonox/branches/importer/importer/object.cc

    r2779 r2794  
    3737  glNewList (listNumber, GL_COMPILE);
    3838  glEnableClientState (GL_VERTEX_ARRAY);
     39  glEnableClientState (GL_NORMAL_ARRAY);
     40  //  glEnableClientState (GL_TEXTURE_COORD_ARRAY);
    3941
    4042  return true;
     
    6466  char Buffer[500];
    6567  vertices = new Array();
    66   faces = new Array();
     68  normals = new Array();
    6769  while(!OBJ_FILE->eof())
    6870    {
     
    9294          readUseMtl (Buffer+7);
    9395        }
     96
     97      // case VertexNormal
     98      else if (!strncmp(Buffer, "vn ", 2))
     99      {
     100        readVertexNormal(Buffer+3);
     101      }
     102
    94103      // case vt
    95104      else if (!strncmp(Buffer, "vt ", 2))
     
    126135      vertices->finalizeArray();
    127136      glVertexPointer(3, GL_FLOAT, 0, vertices->getArray());
     137      normals->finalizeArray();
     138      glNormalPointer(GL_FLOAT, 0, normals->getArray());
    128139    }
    129140
     
    134145  char subbuffer4[20] ="";
    135146  sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    136   //      vertices->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));
     147  //  printf("%s, %s, %s\n", subbuffer1,subbuffer2,subbuffer3);
    137148  if (!strcmp(subbuffer4, ""))
    138149    {
     
    171182bool Object::addGLElement (char* elementString)
    172183{
    173   char* pointTo;
    174   pointTo = strstr (elementString, "/");
    175   pointTo[0] = '\0';
    176   //  printf ("f: %s\n", elementString);
    177   glArrayElement(atoi(elementString)-1);
    178 
     184  char* vertex = elementString;
     185  char* texture;
     186  char* normal;
     187  texture = strstr (vertex, "/");
     188  texture[0] = '\0';
     189  texture ++;
     190  normal = strstr (texture, "/");
     191  normal[0] = '\0';
     192  normal ++;
     193 
     194  //glArrayElement(atoi(vertex)-1);
     195  glNormal3fv(normals->getArray() +(atoi(normal)-1)*3);
     196  glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3);
     197
     198}
     199
     200bool Object::readVertexNormal (char* normalString)
     201{
     202  readVertices = true;
     203  char subbuffer1[20];
     204  char subbuffer2[20];
     205  char subbuffer3[20];
     206  sscanf (normalString, "%s %s %s", subbuffer1, subbuffer2, subbuffer3);
     207  //  printf("%s, %s, %s\n", subbuffer1,subbuffer2,subbuffer3);
     208  normals->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));
     209  return true;
    179210}
    180211
     
    190221  char Buffer[500];
    191222  vertices = new Array();
    192   faces = new Array();
    193223  material = new Material();
    194224  Material* tmpMat = material;
  • orxonox/branches/importer/importer/object.h

    r2776 r2794  
    2929  int verticesCount;
    3030  Array* colors;
    31   Array* faces;
     31  Array* normals;
    3232  char* objFile;
    3333  int faceMode;
     
    4141  bool readFace (char* faceString);
    4242  bool readVT (char* vtString);
     43  bool readVertexNormal (char* normalString);
    4344  bool readMtlLib (char* matFile);
    4445  bool readUseMtl (char* mtlString);
Note: See TracChangeset for help on using the changeset viewer.