Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2833 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Nov 12, 2004, 11:55:07 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: check if mtl exists, vn, vt do not have to be defined. Scaling ablility.

Location:
orxonox/trunk/importer
Files:
2 edited

Legend:

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

    r2823 r2833  
    3535}
    3636
     37Object::Object(char* fileName, float scaling)
     38{
     39  initialize();
     40  scaleFactor = scaling;
     41
     42  importFile (fileName);
     43
     44  finalize();
     45}
     46
     47bool Object::initialize (void)
     48{
     49  if (verbose >=3)
     50    printf("new 3D-Object is being created\n");
     51  faceMode = -1;
     52  if ( (listNumber = glGenLists(1)) == 0 )
     53    {
     54      printf ("list could not be created for this Object\n");
     55      return false;
     56    }
     57
     58  mtlFileName = "";
     59  scaleFactor = 1;
     60  vertices = new Array();
     61  normals = new Array();
     62  vTexture = new Array();
     63
     64  glNewList (listNumber, GL_COMPILE);
     65  glEnableClientState (GL_VERTEX_ARRAY);
     66  glEnableClientState (GL_NORMAL_ARRAY);
     67  //  glEnableClientState (GL_TEXTURE_COORD_ARRAY);
     68
     69  return true;
     70}
     71
    3772bool Object::importFile (char* fileName)
    3873{
     
    4176  objFileName = fileName;
    4277  this->readFromObjFile (objFileName);
    43   return true;
    44 }
    45 
    46 bool Object::initialize (void)
    47 {
    48   if (verbose >=3)
    49     printf("new 3D-Object is being created\n");
    50   faceMode = -1;
    51   if ( (listNumber = glGenLists(1)) == 0 )
    52     {
    53       printf ("list could not be created for this Object\n");
    54       return false;
    55     }
    56   vertices = new Array();
    57   normals = new Array();
    58   vTexture = new Array();
    59 
    60   glNewList (listNumber, GL_COMPILE);
    61   glEnableClientState (GL_VERTEX_ARRAY);
    62   glEnableClientState (GL_NORMAL_ARRAY);
    63   //  glEnableClientState (GL_TEXTURE_COORD_ARRAY);
    64 
    6578  return true;
    6679}
     
    155168  if (verbose >= 3)
    156169    printf ("reading in a vertex: %s %s %s\n", subbuffer1, subbuffer2, subbuffer3);
    157   vertices->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));
     170  vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor);
    158171  return true;
    159172}
     
    214227bool Object::addGLElement (char* elementString)
    215228{
     229  if (verbose >=3)
     230    printf ("importing grafical Element.... including to openGL\n");
    216231  char* vertex = elementString;
     232
    217233  char* texture;
    218   char* normal;
    219234  texture = strstr (vertex, "/");
    220235  texture[0] = '\0';
    221236  texture ++;
    222   normal = strstr (texture, "/");
    223   normal[0] = '\0';
    224   normal ++;
    225   if (verbose >= 4)
    226     printf ("importing grafical Element.... including to openGL\n");
    227   //glArrayElement(atoi(vertex)-1);
    228   glNormal3fv(normals->getArray() +(atoi(normal)-1)*3);
    229237  glTexCoord2fv(vTexture->getArray()+(atoi(texture)-1)*2);
     238
     239  char* normal;
     240  if ((normal = strstr (texture, "/")) !=NULL)
     241    {
     242      normal[0] = '\0';
     243      normal ++;
     244      //glArrayElement(atoi(vertex)-1);
     245      glNormal3fv(normals->getArray() +(atoi(normal)-1)*3);
     246    }
    230247  glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3);
    231248
     
    315332bool Object::readUseMtl (char* matString)
    316333{
     334  if (!strcmp (mtlFileName, ""))
     335    {
     336      if (verbose >= 1)
     337        printf ("Not using new defined material, because no mtlFile found yet\n");
     338      return false;
     339    }
     340     
    317341  if (faceMode != -1)
    318342    glEnd();
  • orxonox/trunk/importer/object.h

    r2823 r2833  
    2323  Object ();
    2424  Object (char* fileName);
     25  Object(char* fileName, float scaling);
    2526  ~Object ();
    2627 
     
    4546  bool readVertices;
    4647  Material* material;
     48  float scaleFactor;
    4749
    4850  ifstream* OBJ_FILE;
Note: See TracChangeset for help on using the changeset viewer.