Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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*

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.