Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6308 in orxonox.OLD


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

Location:
trunk/src/lib
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/Makefile.am

    r6100 r6308  
    55
    66libORXimporter_a_SOURCES = model.cc \
     7                           tc.c \
    78                           vertex_array_model.cc \
    89                           static_model.cc \
     
    1819
    1920noinst_HEADERS = model.h \
     21                 tc.h \
    2022                 vertex_array_model.h \
    2123                 static_model.h \
     
    2830                 height_map.h \
    2931                 anorms.h \
    30                  anormtab.h
     32                 anormtab.h 
  • trunk/src/lib/graphics/importer/model.h

    r6222 r6308  
    3232typedef struct
    3333{
    34   unsigned int   indexToVertices[3];   //!< index to the verteces of the triangle
     34  unsigned int   indexToVertices[3];   //!< index to the vertices of the triangle
    3535  unsigned int   indexToNormals[3];    //!< index to the normals of the triangle
    3636  unsigned int   indexToTexCoor[3];    //!< index to the texture coordinates
     
    8383    inline sTriangleExt* getTriangles() const { return this->pModelInfo.pTriangles; };
    8484    /** @returns the Count of Faces of this Model */
    85     inline unsigned int getFaceCount() const { return this->pModelInfo.numTriangles; };
     85    inline unsigned int getTriangleCount() const { return this->pModelInfo.numTriangles; };
    8686
    8787
  • 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)
  • trunk/src/lib/graphics/importer/vertex_array_model.h

    r6037 r6308  
    2929 public:
    3030  VertexArrayModel();
     31  VertexArrayModel(const Model& model);
    3132  virtual ~VertexArrayModel();
    3233
     
    4344  void finalize();
    4445
    45   // 
     46  //
    4647  void planeModel();
    4748
  • trunk/src/lib/particles/particle_system.cc

    r6222 r6308  
    386386    case PARTICLE_MODEL:
    387387      if (this->getModel(0))
    388         return this->count * this->getModel()->getFaceCount();
     388        return this->count * this->getModel()->getTriangleCount();
    389389      break;
    390390  }
Note: See TracChangeset for help on using the changeset viewer.