Changeset 3400 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Feb 7, 2005, 12:34:47 AM (20 years ago)
- Location:
- orxonox/trunk/src/importer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/importer/framework.cc
r3398 r3400 52 52 int main(int argc, char *argv[]) 53 53 { 54 verbose = 2;54 verbose = 3; 55 55 56 56 Uint8* keys; // This variable will be used in the keyboard routine … … 80 80 obj = (OBJModel*) new Model(); 81 81 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); 90 90 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); 105 105 106 106 obj->addFace ("1 2 4 3"); -
orxonox/trunk/src/importer/model.cc
r3398 r3400 15 15 16 16 #include "model.h" 17 #include <math.h> 17 18 18 19 using namespace std; … … 39 40 this->initialize(); 40 41 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 } 44 54 this->importToGL (); 45 55 … … 369 379 370 380 /** 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 */ 387 bool 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 /** 371 395 \brief parses a face-string 372 396 \param faceString The String that will be parsed. 373 397 374 398 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.376 399 */ 377 400 bool Model::addFace (char* faceString) … … 433 456 434 457 /** 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 */ 464 bool Model::addFace(const float faceElemCount, ...) 465 { 466 // TODO 467 468 } 469 470 /** 435 471 \brief parses a vertexNormal-String 436 472 \param normalString The String that will be parsed. … … 450 486 451 487 /** 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 */ 495 bool 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 /** 452 502 \brief parses a vertexTextureCoordinate-String 453 503 \param vTextureString The String that will be parsed. … … 465 515 this->vTexture->addEntry(subbuffer2); 466 516 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 */ 526 bool 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); 467 531 } 468 532 … … 696 760 This will inject a Cube, because this is the most basic model. 697 761 */ 698 void Model:: BoxModel(void)762 void Model::cubeModel(void) 699 763 { 700 764 this->addVertex ("-0.5 -0.5 0.5"); … … 764 828 765 829 } 830 831 832 void 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 92 92 float scaleFactor; //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation 93 93 94 bool initialize 94 bool initialize(void); 95 95 bool initGroup(Group* group); 96 96 bool initFace (Face* face); … … 101 101 102 102 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); 109 113 void finalize(void); 110 114 111 115 protected: 112 bool importToGL 113 bool addGLElement 116 bool importToGL(void); 117 bool addGLElement(FaceElement* elem); 114 118 115 bool buildVertexNormals ();119 bool buildVertexNormals(void); 116 120 117 void BoxModel (void); 121 void cubeModel(void); 122 void cylinderModel(void); 118 123 }; 119 124 -
orxonox/trunk/src/importer/objModel.cc
r3398 r3400 133 133 if (OBJ_FILE->fail()) 134 134 { 135 PRINTF(1)("unable to open .OBJ file: %s\n Loading BoxModel instead.\n", fileName);136 BoxModel();135 PRINTF(1)("unable to open .OBJ file: %s\n Loading cube-Model instead.\n", fileName); 136 cubeModel(); 137 137 OBJ_FILE->close(); 138 138 delete []fileName;
Note: See TracChangeset
for help on using the changeset viewer.