Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 27, 2005, 1:51:26 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: added tc a library to convert Vertice-Melanges into VertexArrayStrips. Also implemented it partly in the VertexArrayModel-class…. testing

File:
1 edited

Legend:

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

    r6038 r6308  
    2121#include <stdarg.h>
    2222
     23#include "tc.h"
     24
    2325using namespace std;
    2426
     
    3941}
    4042
    41 
    42 /**
    43  * @brief deletes an VertexArrayModel.
     43/**
     44 * @brief special copy constructor for converting Models to VertexArray-Stripes
     45 * @param model the Model to produce a VertexArray model from.
     46 *
     47 * Code that uses Brad Granthams
     48 * excelent TC-code for generating stripes out of a mix of ModelCoordinates.
     49 */
     50VertexArrayModel::VertexArrayModel(const Model& model)
     51{
     52  this->setClassID(CL_MODEL, "VertexArrayModel");
     53  this->bFinalized = false;
     54  this->newStripe();
     55
     56  for (unsigned int i = 0; i < model.getVertexCount(); i+=3)
     57    this->addVertex(model.getVertexArray()[i], model.getVertexArray()[i+1], model.getVertexArray()[i+2]);
     58  for (unsigned int i = 0; i < model.getNormalsCount(); i+=3)
     59    this->addNormal(model.getNormalsArray()[i], model.getNormalsArray()[i+1], model.getNormalsArray()[i+2]);
     60  for (unsigned int i = 0; i < model.getTexCoordCount(); i+=2)
     61    this->addTexCoor(model.getTexCoordArray()[i], model.getTexCoordArray()[i+1]);
     62
     63  // The acTC object generating this Model. //
     64  ACTCData *tc;
     65  tc = actcNew();
     66  if(tc == NULL) {
     67    /* memory allocation failed */
     68    /* print error here and exit or whatever */
     69  }
     70
     71  // inputing the data of model to the tc
     72  actcBeginInput(tc);
     73  for(unsigned int i = 0; i < model.getTriangleCount(); i++)
     74      actcAddTriangle(tc, model.getTriangles()[i].indexToVertices[0], model.getTriangles()[i].indexToVertices[1], model.getTriangles()[i].indexToVertices[2]);
     75  actcEndInput(tc);
     76
     77  // importing the data to the new Model.
     78  int prim;
     79  unsigned int v1, v2, v3;
     80
     81  actcBeginOutput(tc);
     82  while((prim = actcStartNextPrim(tc, &v1, &v2) != ACTC_DATABASE_EMPTY))
     83  {
     84    this->addIndice(v1);
     85    this->addIndice(v2);
     86    /* start a primitive of type "prim" with v1 and v2 */
     87    while(actcGetNextVert(tc, &v3) != ACTC_PRIM_COMPLETE)
     88    {
     89      /* continue primitive using v3 */
     90      this->addIndice(v3);
     91    }
     92    this->newStripe();
     93  }
     94  actcEndOutput(tc);
     95
     96  this->finalize();
     97}
     98
     99/**
     100 * @brief deletes a VertexArrayModel.
    44101 *
    45102 * Looks if any from model allocated space is still in use, and if so deleted it.
     
    75132  glVertexPointer(3, GL_FLOAT, 0, this->vertices.getArray());
    76133  glNormalPointer(GL_FLOAT, 0, this->normals.getArray());
    77   glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray()); 
     134  glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray());
    78135
    79136  for (GLuint i = 1; i < this->stripes.size(); ++i)
Note: See TracChangeset for help on using the changeset viewer.