Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2757 in orxonox.OLD for orxonox/branches/importer


Ignore:
Timestamp:
Nov 9, 2004, 1:11:17 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/importer: read in from File

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

Legend:

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

    r2755 r2757  
    11#include "object.h"
    2 #include <iostream.h>
     2
    33Object::Object ()
    44{
    5   this->readFromObjFile ("test");
     5  this->readFromObjFile ("cube.obj");
    66   
    77  glEnableClientState (GL_VERTEX_ARRAY);
     
    1919 
    2020
    21   /* 
    22   glVertex3f(0,0,0); 
    23   glVertex3f(0,1,0);
    24   glVertex3f(1,0,0);
    25   */
    2621  glEnd();
    2722  glEndList();
     
    3934bool Object::readFromObjFile (char* fileName)
    4035{
    41   vertices = new Array(2000);
    42   vertices->addEntry(0,0,0);
    43   vertices->addEntry(0,1,0);
    44   vertices->addEntry(1,0,1);
    45   vertices->finalizeArray();
    46  
    47  
     36  if ( (OBJ_FILE = fopen (fileName, "r")) == NULL)
     37    {
     38      printf ("file: %s not found.\n", fileName);
     39      return false;
     40    }
     41  else
     42    {
     43      char Buffer[10];
     44      vertices = new Array();
     45     
     46      while (fscanf (OBJ_FILE, "%s", Buffer) != EOF)
     47        {
     48          printf ("%s\n",Buffer);
    4849
    49   return true;
     50          // case we read it is a vertex
     51          if (!strcmp (Buffer, "v"))
     52            { 
     53              for (int i=0; i<=2;i++)
     54                {
     55                  fscanf (OBJ_FILE, "%s", Buffer);
     56                  printf ("float: %f\n", atof(Buffer));
     57                  vertices->addEntry(atof(Buffer));
     58                }
     59            }
     60        }
     61      //      vertices->addEntry(0,0,0);
     62      //      vertices->addEntry(0,1,0);
     63      //      vertices->addEntry(1,0,1);
     64      vertices->finalizeArray();
     65      for (int i=0;i<=10;i++)
     66        printf("%f\n",vertices->getArray()[i]);
     67      fclose (OBJ_FILE);
     68      return true;
     69    }
    5070}
  • orxonox/branches/importer/importer/object.h

    r2754 r2757  
    1818  int verticesCount;
    1919  Array* colors;
    20 
     20  FILE* OBJ_FILE;
     21  FILE* MTL_FILE;
    2122 
    2223
Note: See TracChangeset for help on using the changeset viewer.