Changeset 3418 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Feb 22, 2005, 6:14:44 PM (20 years ago)
- Location:
- orxonox/trunk/src/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/importer/framework.cc
r3400 r3418 52 52 int main(int argc, char *argv[]) 53 53 { 54 verbose = 3;54 verbose = 1; 55 55 56 56 Uint8* keys; // This variable will be used in the keyboard routine … … 77 77 // This also packs everything into a DisplayList, and can be handled exactly as any other model. 78 78 // This is an example of a cube with Texture-Coordinates, but without explicite Vertex-Normals. (they are soft-created). 79 79 /* 80 80 obj = (OBJModel*) new Model(); 81 81 obj->setName("CUBE"); … … 111 111 obj->addFace ("7 1 3 5"); 112 112 obj->finalize(); 113 */ 114 obj = (OBJModel*) new Model(SPHERE); 113 115 } 114 116 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); … … 252 254 obj = new OBJModel(argv[1]); 253 255 break; 256 case SDLK_a: 257 zoomTo /=2; 258 break; 259 case SDLK_z: 260 zoomTo *=2; 261 254 262 } 255 263 break; -
orxonox/trunk/src/importer/model.cc
r3400 r3418 16 16 #include "model.h" 17 17 #include <math.h> 18 #include <stdarg.h> 18 19 19 20 using namespace std; … … 47 48 break; 48 49 case SPHERE: 50 this->sphereModel(); 49 51 break; 50 52 case CYLINDER: … … 456 458 457 459 /** 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 460 \brief adds a new Face 461 \param faceElemCount the number of Vertices to add to the Face. 462 \param type 0: vertex only, 1: vertex and normal, 2: vertex and Texture, 3 vertex, normal and texture 463 */ 464 bool Model::addFace(const float faceElemCount, int type, ...) 465 { 466 if (this->currentGroup->faceCount > 0) 467 this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face; 468 this->initFace (this->currentGroup->currentFace); 469 470 FaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new FaceElement; 471 tmpElem->next = NULL; 472 473 va_list itemlist; 474 va_start (itemlist, type); 475 476 for (int i = 0; i < faceElemCount; i++) 477 { 478 if (this->currentGroup->currentFace->vertexCount>0) 479 tmpElem = tmpElem->next = new FaceElement; 480 tmpElem->next = NULL; 481 482 tmpElem->vertexNumber = va_arg (itemlist, int) -1; 483 if (type >= 2) 484 tmpElem->texCoordNumber = va_arg (itemlist, int) -1; 485 if (type == 1 || type ==3) 486 tmpElem->normalNumber = va_arg(itemlist, int) -1; 487 this->currentGroup->currentFace->vertexCount++; 488 } 489 va_end(itemlist); 490 491 this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount - 2; 468 492 } 469 493 … … 830 854 831 855 856 void Model::sphereModel() 857 { 858 int detail = 30; 859 if (detail <= 0) detail = 1; 860 float df = (float)detail; 861 for (float i = 0.0; i < df/2; i+=1.0) 862 { 863 for (float j = 0.0; j < df; j+=1.0) 864 { 865 float vz = i/df *2.0*PI - PI/2.0; 866 this->addVertex(cos(j/df*2.0*PI) * cos(vz) , 867 sin(j/df*2.0*PI) * cos(vz), 868 sin(vz)); 869 //if (j==0.0) 870 //printf ("%f %f\n", vz, sin (vz)); 871 if (i==0.0) 872 printf("%f, %f\n", j/df*2.0*PI, cos(j/df*PI)); 873 } 874 } 875 vertices->debug(); 876 for (int i = 0; i < detail/2; i++) 877 for (int j = 1; j < detail; j++) 878 { 879 unsigned int v1,v2,v3,v4; 880 v1 = i*detail +j; 881 882 /* if (j+1 == detail) 883 { 884 v2 = i*detail +1; 885 v3 = i*detail+detail + 1; 886 } 887 else*/ 888 { 889 v2 = i*detail +j+1; 890 v3 = i*detail+detail + j+1; 891 } 892 v4 = i*detail+detail + j; 893 //printf("%i %i %i %i\n", v1, v2, v3, v4); 894 this->addFace(4, 0, v1, v2, v3, v4); 895 } 896 } 897 832 898 void Model::cylinderModel() 833 899 { -
orxonox/trunk/src/importer/model.h
r3400 r3418 47 47 48 48 //! This is the placeholder of a Face belonging to a Group of Faces. 49 /** 50 \todo take Material to a call for itself. 51 52 This can also be a Material-Change switch. 53 That means if you want to change a Material inside of a group, 54 you can create an empty face and apply a material to it, and the Importer will cahnge Colors 55 */ 56 struct Face 49 struct Face 57 50 { 58 51 int vertexCount; //!< The Count of vertices this Face has. … … 105 98 bool addVertex(const float x, const float y, const float z); 106 99 bool addFace(char* faceString); 107 bool addFace(const float faceElemCount, ...);100 bool addFace(const float faceElemCount, int type, ...); 108 101 bool addVertexNormal(char* normalString); 109 102 bool addVertexNormal(const float x, const float y, const float z); … … 120 113 121 114 void cubeModel(void); 115 void sphereModel(void); 122 116 void cylinderModel(void); 123 117 };
Note: See TracChangeset
for help on using the changeset viewer.