- Timestamp:
- Feb 28, 2005, 9:09:10 PM (20 years ago)
- Location:
- orxonox/trunk/src/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/importer/framework.cc
r3418 r3426 52 52 int main(int argc, char *argv[]) 53 53 { 54 verbose = 1;54 verbose = 3; 55 55 56 56 Uint8* keys; // This variable will be used in the keyboard routine … … 112 112 obj->finalize(); 113 113 */ 114 obj = (OBJModel*) new Model( SPHERE);114 obj = (OBJModel*) new Model(CYLINDER); 115 115 } 116 116 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); -
orxonox/trunk/src/importer/model.cc
r3418 r3426 51 51 break; 52 52 case CYLINDER: 53 this->cylinderModel(); 53 54 break; 54 55 … … 589 590 this->vertices->finalizeArray(); 590 591 this->vTexture->finalizeArray(); 591 if (normals->getCount() == 0) // vertices-Array must be uilt for this592 if (normals->getCount() == 0) // vertices-Array must be built for this 592 593 this->buildVertexNormals(); 593 594 this->normals->finalizeArray(); … … 770 771 normArray[i].normalize(); 771 772 PRINTF(3)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z); 772 773 773 774 this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z); 774 775 … … 896 897 } 897 898 898 void Model::cylinderModel() 899 { 900 int detailLevel = 10; 901 float size; 902 for (int i = 0; i < detailLevel; i++) 903 { 904 this->addVertex(sin((float)i/detailLevel), -size/2, cos((float)i/detailLevel)); 905 } 906 } 899 /** 900 \brief Creates a Cylinder. 901 */ 902 void Model::cylinderModel(void) 903 { 904 unsigned int detail = 20; 905 float size = 1.0; 906 907 // check if devision by zero 908 if (detail <= 3) 909 detail = 3; 910 int count = 0; 911 // defining Points of the Cylinder. 912 for (float phi = 0.0; phi < 2.0*PI; phi += 2.0*PI/(float)detail) 913 { 914 this->addVertex(size*cos(phi), size*sin(phi), -size); 915 this->addVertex(size*cos(phi), size*sin(phi), size); 916 count ++; 917 } 918 this->addVertex(0, 0, -size); 919 this->addVertex(0, 0, size); 920 921 922 if (count != detail) 923 cout << "calculation error, count should be " << detail << " but is " << count << endl; 924 vertices->debug(); 925 926 // adding Faces 927 for (int i = 0; i < detail-1; i++) 928 { 929 int p1, p2, p3, p4; 930 p1 = 2*i+1; 931 p2 = 2*i+2; 932 if (i <= detail); 933 p3 = 2*i+4; 934 p4 = 2*i+3; 935 cout <<i+1 <<": "<< p1 <<" "<< p2 <<" "<< p3 <<" "<< p4 <<endl; 936 this->addFace(4, 0, p1, p2, p3, p4); 937 this->addFace(3, 0, p4, p1, 2*detail+1); 938 this->addFace(3, 0, p2, p3, 2*detail+2); 939 } 940 addFace(4,0, 2*detail-1, 2*detail, 2, 1); 941 this->addFace(3, 0, 1, 2*detail-1, 2*detail+1); 942 this->addFace(3, 0, 2*detail, 2, 2*detail+2); 943 944 }
Note: See TracChangeset
for help on using the changeset viewer.