Changeset 2833 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Nov 12, 2004, 11:55:07 AM (20 years ago)
- Location:
- orxonox/trunk/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/object.cc
r2823 r2833 35 35 } 36 36 37 Object::Object(char* fileName, float scaling) 38 { 39 initialize(); 40 scaleFactor = scaling; 41 42 importFile (fileName); 43 44 finalize(); 45 } 46 47 bool Object::initialize (void) 48 { 49 if (verbose >=3) 50 printf("new 3D-Object is being created\n"); 51 faceMode = -1; 52 if ( (listNumber = glGenLists(1)) == 0 ) 53 { 54 printf ("list could not be created for this Object\n"); 55 return false; 56 } 57 58 mtlFileName = ""; 59 scaleFactor = 1; 60 vertices = new Array(); 61 normals = new Array(); 62 vTexture = new Array(); 63 64 glNewList (listNumber, GL_COMPILE); 65 glEnableClientState (GL_VERTEX_ARRAY); 66 glEnableClientState (GL_NORMAL_ARRAY); 67 // glEnableClientState (GL_TEXTURE_COORD_ARRAY); 68 69 return true; 70 } 71 37 72 bool Object::importFile (char* fileName) 38 73 { … … 41 76 objFileName = fileName; 42 77 this->readFromObjFile (objFileName); 43 return true;44 }45 46 bool Object::initialize (void)47 {48 if (verbose >=3)49 printf("new 3D-Object is being created\n");50 faceMode = -1;51 if ( (listNumber = glGenLists(1)) == 0 )52 {53 printf ("list could not be created for this Object\n");54 return false;55 }56 vertices = new Array();57 normals = new Array();58 vTexture = new Array();59 60 glNewList (listNumber, GL_COMPILE);61 glEnableClientState (GL_VERTEX_ARRAY);62 glEnableClientState (GL_NORMAL_ARRAY);63 // glEnableClientState (GL_TEXTURE_COORD_ARRAY);64 65 78 return true; 66 79 } … … 155 168 if (verbose >= 3) 156 169 printf ("reading in a vertex: %s %s %s\n", subbuffer1, subbuffer2, subbuffer3); 157 vertices->addEntry(atof(subbuffer1) , atof(subbuffer2), atof(subbuffer3));170 vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor); 158 171 return true; 159 172 } … … 214 227 bool Object::addGLElement (char* elementString) 215 228 { 229 if (verbose >=3) 230 printf ("importing grafical Element.... including to openGL\n"); 216 231 char* vertex = elementString; 232 217 233 char* texture; 218 char* normal;219 234 texture = strstr (vertex, "/"); 220 235 texture[0] = '\0'; 221 236 texture ++; 222 normal = strstr (texture, "/");223 normal[0] = '\0';224 normal ++;225 if (verbose >= 4)226 printf ("importing grafical Element.... including to openGL\n");227 //glArrayElement(atoi(vertex)-1);228 glNormal3fv(normals->getArray() +(atoi(normal)-1)*3);229 237 glTexCoord2fv(vTexture->getArray()+(atoi(texture)-1)*2); 238 239 char* normal; 240 if ((normal = strstr (texture, "/")) !=NULL) 241 { 242 normal[0] = '\0'; 243 normal ++; 244 //glArrayElement(atoi(vertex)-1); 245 glNormal3fv(normals->getArray() +(atoi(normal)-1)*3); 246 } 230 247 glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3); 231 248 … … 315 332 bool Object::readUseMtl (char* matString) 316 333 { 334 if (!strcmp (mtlFileName, "")) 335 { 336 if (verbose >= 1) 337 printf ("Not using new defined material, because no mtlFile found yet\n"); 338 return false; 339 } 340 317 341 if (faceMode != -1) 318 342 glEnd(); -
orxonox/trunk/importer/object.h
r2823 r2833 23 23 Object (); 24 24 Object (char* fileName); 25 Object(char* fileName, float scaling); 25 26 ~Object (); 26 27 … … 45 46 bool readVertices; 46 47 Material* material; 48 float scaleFactor; 47 49 48 50 ifstream* OBJ_FILE;
Note: See TracChangeset
for help on using the changeset viewer.