Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3400 in orxonox.OLD for orxonox/trunk/src/importer


Ignore:
Timestamp:
Feb 7, 2005, 12:34:47 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: model: extended funtionality, now one can also use float values instead of char*

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

Legend:

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

    r3398 r3400  
    5252int main(int argc, char *argv[])
    5353{
    54   verbose = 2;
     54  verbose = 3;
    5555
    5656  Uint8* keys; // This variable will be used in the keyboard routine
     
    8080      obj = (OBJModel*) new Model();
    8181      obj->setName("CUBE");
    82       obj->addVertex ("-0.5 -0.5 0.5");
    83       obj->addVertex ("0.5 -0.5 0.5");
    84       obj->addVertex ("-0.5 0.5 0.5");
    85       obj->addVertex ("0.5 0.5 0.5");
    86       obj->addVertex ("-0.5 0.5 -0.5");
    87       obj->addVertex ("0.5 0.5 -0.5");
    88       obj->addVertex ("-0.5 -0.5 -0.5");
    89       obj->addVertex ("0.5 -0.5 -0.5");
     82      obj->addVertex (-0.5, -0.5, 0.5);
     83      obj->addVertex (0.5, -0.5, 0.5);
     84      obj->addVertex (-0.5, 0.5, 0.5);
     85      obj->addVertex (0.5, 0.5, 0.5);
     86      obj->addVertex (-0.5, 0.5, -0.5);
     87      obj->addVertex (0.5, 0.5, -0.5);
     88      obj->addVertex (-0.5, -0.5, -0.5);
     89      obj->addVertex (0.5, -0.5, -0.5);
    9090     
    91       obj->addVertexTexture ("0.0 0.0");
    92       obj->addVertexTexture ("1.0 0.0");
    93       obj->addVertexTexture ("0.0 1.0");
    94       obj->addVertexTexture ("1.0 1.0");
    95       obj->addVertexTexture ("0.0 2.0");
    96       obj->addVertexTexture ("1.0 2.0");
    97       obj->addVertexTexture ("0.0 3.0");
    98       obj->addVertexTexture ("1.0 3.0");
    99       obj->addVertexTexture ("0.0 4.0");
    100       obj->addVertexTexture ("1.0 4.0");
    101       obj->addVertexTexture ("2.0 0.0");
    102       obj->addVertexTexture ("2.0 1.0");
    103       obj->addVertexTexture ("-1.0 0.0");
    104       obj->addVertexTexture ("-1.0 1.0");
     91      obj->addVertexTexture (0.0, 0.0);
     92      obj->addVertexTexture (1.0, 0.0);
     93      obj->addVertexTexture (0.0, 1.0);
     94      obj->addVertexTexture (1.0, 1.0);
     95      obj->addVertexTexture (0.0, 2.0);
     96      obj->addVertexTexture (1.0, 2.0);
     97      obj->addVertexTexture (0.0, 3.0);
     98      obj->addVertexTexture (1.0, 3.0);
     99      obj->addVertexTexture (0.0, 4.0);
     100      obj->addVertexTexture (1.0, 4.0);
     101      obj->addVertexTexture (2.0, 0.0);
     102      obj->addVertexTexture (2.0, 1.0);
     103      obj->addVertexTexture (-1.0, 0.0);
     104      obj->addVertexTexture (-1.0, 1.0);
    105105
    106106      obj->addFace ("1 2 4 3");
  • orxonox/trunk/src/importer/model.cc

    r3398 r3400  
    1515
    1616#include "model.h"
     17#include <math.h>
    1718
    1819using namespace std;
     
    3940  this->initialize();
    4041
    41   if (type == CUBE)
    42     this->BoxModel();
    43 
     42  switch (type)
     43    {
     44    default:
     45    case CUBE:
     46      this->cubeModel();
     47      break;
     48    case SPHERE:
     49      break;
     50    case CYLINDER:
     51      break;
     52
     53    }
    4454  this->importToGL ();
    4555
     
    369379
    370380/**
     381   \brief parses a vertex-String
     382   \param x the X-coordinate of the Vertex to add.
     383   \param y the Y-coordinate of the Vertex to add.
     384   \param z the Z-coordinate of the Vertex to add.
     385   
     386*/
     387bool Model::addVertex(const float x, const float y, const float z)
     388{
     389  PRINTF(4)("reading in a vertex: %f %f %f\n", x, y, z);
     390  this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor);
     391  return true;
     392}
     393
     394/**
    371395   \brief parses a face-string
    372396   \param faceString The String that will be parsed.
    373397
    374398   If a face line is found this function will add it to the glList.
    375    The function makes a difference between QUADS and TRIANGLES, and will if changed re-open, set and re-close the gl-processe.
    376399*/
    377400bool Model::addFace (char* faceString)
     
    433456
    434457/**
     458   \brief imports a new Face.
     459   \param faceElemCount The Cout of Vertices this Face has.
     460   \param ... The Elements by number.
     461
     462   \todo hmmpf... this also has to parse normals and vertices... sounds like stress...
     463*/
     464bool Model::addFace(const float faceElemCount, ...)
     465{
     466  // TODO
     467
     468}
     469
     470/**
    435471   \brief parses a vertexNormal-String
    436472   \param normalString The String that will be parsed.
     
    450486
    451487/**
     488   \brief adds a VertexNormal.
     489   \param x The x coordinate of the Normal.
     490   \param y The y coordinate of the Normal.
     491   \param z The z coordinate of the Normal.
     492
     493   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
     494*/
     495bool Model::addVertexNormal(const float x, const float y, const float z)
     496{
     497  PRINTF(3)("found vertex-Normal %f, %f, %f\n", x, y, z);
     498  this->normals->addEntry(x, y, z);
     499}
     500
     501/**
    452502   \brief parses a vertexTextureCoordinate-String
    453503   \param vTextureString The String that will be parsed.
     
    465515  this->vTexture->addEntry(subbuffer2);
    466516  return true;
     517}
     518
     519/**
     520   \brief adds a Texture Coordinate
     521   \param u The u coordinate of the TextureCoordinate.
     522   \param v The y coordinate of the TextureCoordinate.
     523
     524   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
     525*/
     526bool Model::addVertexTexture(const float u, const float v)
     527{
     528  PRINTF(3)("found vertex-Texture %f, %f\n", u, v);
     529  this->vTexture->addEntry(u);
     530  this->vTexture->addEntry(v);
    467531}
    468532
     
    696760   This will inject a Cube, because this is the most basic model.
    697761*/
    698 void Model::BoxModel(void)
     762void Model::cubeModel(void)
    699763{
    700764  this->addVertex ("-0.5 -0.5 0.5");
     
    764828
    765829}
     830
     831
     832void Model::cylinderModel()
     833{
     834  int detailLevel = 10;
     835  float size;
     836  for (int i = 0; i < detailLevel; i++)
     837    {
     838      this->addVertex(sin((float)i/detailLevel), -size/2, cos((float)i/detailLevel));
     839    }
     840}
  • orxonox/trunk/src/importer/model.h

    r3398 r3400  
    9292  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    9393
    94   bool initialize (void);
     94  bool initialize(void);
    9595  bool initGroup(Group* group);
    9696  bool initFace (Face* face);
     
    101101
    102102 public:
    103   bool addGroup (char* groupString);
    104   bool addVertex (char* vertexString);
    105   bool addFace (char* faceString);
    106   bool addVertexNormal (char* normalString);
    107   bool addVertexTexture (char* vTextureString);
    108   bool addUseMtl (char* mtlString);
     103  bool addGroup(char* groupString);
     104  bool addVertex(char* vertexString);
     105  bool addVertex(const float x, const float y, const float z);
     106  bool addFace(char* faceString);
     107  bool addFace(const float faceElemCount, ...);
     108  bool addVertexNormal(char* normalString);
     109  bool addVertexNormal(const float x, const float y, const float z);
     110  bool addVertexTexture(char* vTextureString);
     111  bool addVertexTexture(const float u, const float v);
     112  bool addUseMtl(char* mtlString);
    109113  void finalize(void);
    110114
    111115 protected:
    112   bool importToGL (void);
    113   bool addGLElement (FaceElement* elem);
     116  bool importToGL(void);
     117  bool addGLElement(FaceElement* elem);
    114118
    115   bool buildVertexNormals ();
     119  bool buildVertexNormals(void);
    116120
    117   void BoxModel (void);
     121  void cubeModel(void);
     122  void cylinderModel(void);
    118123};
    119124
  • orxonox/trunk/src/importer/objModel.cc

    r3398 r3400  
    133133  if (OBJ_FILE->fail())
    134134    {
    135       PRINTF(1)("unable to open .OBJ file: %s\n Loading Box Model instead.\n", fileName);
    136       BoxModel();
     135      PRINTF(1)("unable to open .OBJ file: %s\n Loading cube-Model instead.\n", fileName);
     136      cubeModel();
    137137      OBJ_FILE->close();
    138138      delete []fileName;
Note: See TracChangeset for help on using the changeset viewer.