Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3426 in orxonox.OLD


Ignore:
Timestamp:
Feb 28, 2005, 9:09:10 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: added cylinderModel to importer

Location:
orxonox/trunk/src/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/importer/framework.cc

    r3418 r3426  
    5252int main(int argc, char *argv[])
    5353{
    54   verbose = 1;
     54  verbose = 3;
    5555
    5656  Uint8* keys; // This variable will be used in the keyboard routine
     
    112112      obj->finalize();
    113113      */
    114       obj = (OBJModel*) new Model(SPHERE);
     114      obj = (OBJModel*) new Model(CYLINDER);
    115115    }
    116116  M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0);
  • orxonox/trunk/src/importer/model.cc

    r3418 r3426  
    5151      break;
    5252    case CYLINDER:
     53      this->cylinderModel();
    5354      break;
    5455
     
    589590  this->vertices->finalizeArray();
    590591  this->vTexture->finalizeArray();
    591   if (normals->getCount() == 0) // vertices-Array must be uilt for this
     592  if (normals->getCount() == 0) // vertices-Array must be built for this
    592593    this->buildVertexNormals();
    593594  this->normals->finalizeArray();
     
    770771      normArray[i].normalize();
    771772      PRINTF(3)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
    772 
     773     
    773774      this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
    774775
     
    896897}
    897898
    898 void Model::cylinderModel()
    899 {
    900   int detailLevel = 10;
    901   float size;
    902   for (int i = 0; i < detailLevel; i++)
    903     {
    904       this->addVertex(sin((float)i/detailLevel), -size/2, cos((float)i/detailLevel));
    905     }
    906 }
     899/**
     900   \brief Creates a Cylinder.
     901*/
     902void Model::cylinderModel(void)
     903{
     904  unsigned int detail = 20;
     905  float size = 1.0;
     906
     907  // check if devision by zero
     908  if (detail <= 3)
     909    detail = 3;
     910  int count = 0;
     911  // defining Points of the Cylinder.
     912  for (float phi = 0.0; phi < 2.0*PI; phi += 2.0*PI/(float)detail)
     913    {
     914      this->addVertex(size*cos(phi), size*sin(phi), -size);
     915      this->addVertex(size*cos(phi), size*sin(phi), size);
     916      count ++;
     917    }
     918  this->addVertex(0, 0, -size);
     919  this->addVertex(0, 0, size);
     920
     921 
     922  if (count != detail)
     923    cout << "calculation error, count should be " << detail << " but is " << count << endl;
     924  vertices->debug();
     925
     926  // adding Faces
     927  for (int i = 0; i < detail-1; i++)
     928    {
     929      int p1, p2, p3, p4;
     930      p1 = 2*i+1;
     931      p2 = 2*i+2;
     932      if (i <= detail);
     933      p3 = 2*i+4;
     934      p4 = 2*i+3;
     935      cout <<i+1 <<": "<< p1 <<" "<< p2 <<" "<< p3 <<" "<< p4 <<endl;
     936      this->addFace(4, 0, p1, p2, p3, p4);
     937      this->addFace(3, 0, p4, p1, 2*detail+1);
     938      this->addFace(3, 0, p2, p3, 2*detail+2);
     939    }
     940  addFace(4,0, 2*detail-1, 2*detail, 2, 1);
     941  this->addFace(3, 0, 1, 2*detail-1, 2*detail+1);
     942  this->addFace(3, 0, 2*detail, 2, 2*detail+2);
     943
     944}
Note: See TracChangeset for help on using the changeset viewer.