Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2005, 11:32:19 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: removed redundant stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/primitive_model.cc

    r4468 r4678  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828
    2929   if you want to just display a Cube/Sphere/Cylinder/... without any material.
    30    
     30
    3131   \todo implement Cube/Sphere/Cylinder/...
    3232*/
     
    5959
    6060*/
    61 PrimitiveModel::~PrimitiveModel () 
     61PrimitiveModel::~PrimitiveModel ()
    6262{
    6363  // delete what has to be deleted here
     
    7171void PrimitiveModel::sphereModel(float size, unsigned int detail)
    7272{
    73   if (detail <= 0) 
     73  if (detail <= 0)
    7474    detail = 1;
    7575  size /= 2;
    7676  //  detail = 2; // make it even
    7777  float df = (float)detail;
    78  
     78
    7979  // defining the Vertices
    8080  for (float i = 0; i < df *2.0; i+=1.0)
     
    8282      float vi = i/df *PI;
    8383      for (float j = -df / 2.0 +1.0; j < df / 2.0; j+=1.0 *df/(df+1.0))
    84         {
    85           float vj = j/df *PI;
    86           this->addVertex(size * cos(vi) * cos(vj),
    87                           size * sin(vj),
    88                           size * sin(vi) * cos(vj));
    89           this->addVertexTexture(i / (df *2.0), (j-1.0)/(df)+.5);
    90         }
     84        {
     85          float vj = j/df *PI;
     86          this->addVertex(size * cos(vi) * cos(vj),
     87                          size * sin(vj),
     88                          size * sin(vi) * cos(vj));
     89          this->addVertexTexture(i / (df *2.0), (j-1.0)/(df)+.5);
     90        }
    9191    }
    9292  this->addVertex(0, -size, 0);
     
    100100    {
    101101      for (int j = 0; j <= detail; j++)
    102         {
    103          
    104           v1 = i*detail + j-1;
    105           v4 = i*detail + j;
    106          
    107           if (i == detail*2 -1)
    108             {
    109               v2 = j-1;
    110               v3 = j;
    111             }
    112           else
    113             {
    114               v2 = (i+1)*detail + j-1;
    115               v3 = (i+1)*detail + j;
    116             }
    117 
    118           if (j == 0)
    119             {
    120               v1 = this->getVertexCount()-2;
    121               this->addFace(3, VERTEX_TEXCOORD, v1, v1, v3, v3, v4, v4);
    122             }
    123           else if (j == detail)
    124             {
    125               v3 = this->getVertexCount()-1;
    126               this->addFace(3, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3);
    127             }
    128           else
    129             this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
    130         }
     102        {
     103
     104          v1 = i*detail + j-1;
     105          v4 = i*detail + j;
     106
     107          if (i == detail*2 -1)
     108            {
     109              v2 = j-1;
     110              v3 = j;
     111            }
     112          else
     113            {
     114              v2 = (i+1)*detail + j-1;
     115              v3 = (i+1)*detail + j;
     116            }
     117
     118          if (j == 0)
     119            {
     120              v1 = this->getVertexCount() - 2;
     121              this->addFace(3, VERTEX_TEXCOORD, v1, v1, v3, v3, v4, v4);
     122            }
     123          else if (j == detail)
     124            {
     125              v3 = this->getVertexCount()-1;
     126              this->addFace(3, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3);
     127            }
     128          else
     129            this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
     130        }
    131131    }
    132132}
     
    181181  this->addVertex(0,-size,0);
    182182  this->addVertex(0,size,0);
    183   if (detail <= 0) 
     183  if (detail <= 0)
    184184    detail = 1;
    185185  float df = (float)detail;
    186  
     186
    187187  // defining the Vertices
    188188  for (float i = 0; i < df; i+=1.0)
     
    190190      float vi = i/df *2.0*PI;
    191191      this->addVertex(size* sin(vi),
    192                       -size,
    193                       size* cos(vi));
     192                      -size,
     193                      size* cos(vi));
    194194    }
    195195
     
    200200      v1 = i+2;
    201201      if (i == detail -1)
    202         v2 = 2;
     202        v2 = 2;
    203203      else
    204         v2 = i+3;
     204        v2 = i+3;
    205205      this->addFace(3, VERTEX_ONLY, 0, v1, v2);
    206       this->addFace(3, VERTEX_ONLY, 1, v1, v2); 
     206      this->addFace(3, VERTEX_ONLY, 1, v1, v2);
    207207    }
    208208}
     
    219219    for (int j = 0; j < detail; j++)
    220220      {
    221         this->addVertex(((float)i/(float)(detail-1) -.5)*size,
    222                         0,
    223                         ((float)j/(float)(detail-1) -.5)*size);
    224         this->addVertexTexture((float)i/(float)(detail-1),
    225                                (float)j/(float)(detail-1));
     221        this->addVertex(((float)i/(float)(detail-1) -.5)*size,
     222                        0,
     223                        ((float)j/(float)(detail-1) -.5)*size);
     224        this->addVertexTexture((float)i/(float)(detail-1),
     225                               (float)j/(float)(detail-1));
    226226      }
    227227  //defining Faces
     
    230230    for (int j = 0; j < detail-1; j++)
    231231      {
    232         v1 = i*detail + j;
    233         v2 = (i+1)*detail + j;
    234         v3 = (i+1)*detail + (j+1);
    235         v4 = i*detail + (j+1);
    236         this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
     232        v1 = i*detail + j;
     233        v2 = (i+1)*detail + j;
     234        v3 = (i+1)*detail + (j+1);
     235        v4 = i*detail + (j+1);
     236        this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
    237237      }
    238238}
Note: See TracChangeset for help on using the changeset viewer.