Changeset 2853 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Nov 14, 2004, 6:41:02 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/array.cc
r2835 r2853 16 16 #include "array.h" 17 17 18 /** 19 \brief creates a new Array 20 */ 18 21 Array::Array () 19 22 { 20 createArray ();23 initializeArray (); 21 24 } 22 25 23 void Array::createArray () 26 /** 27 \brief deletes an Array. 28 It does this by first deleting all the array-entries, and then delete the array[] itself 29 */ 30 Array::~Array() 31 { 32 if (verbose >= 2) 33 printf("deleting array\n"); 34 Entry* walker = firstEntry; 35 Entry* last; 36 while (walker != NULL) 37 { 38 last = walker; 39 walker = walker->next; 40 delete last; 41 } 42 if (finalized) 43 delete [] array; 44 } 45 46 /** 47 \brief initializes an Array 48 the Function does this by setting up a fistEntry, and setting the entryCount. 49 */ 50 void Array::initializeArray () 24 51 { 25 52 if (verbose >= 2) … … 33 60 } 34 61 62 /** 63 \brief finalizes an array. 64 This Function creates the array, and makes it ready to be sent to the application. 65 */ 35 66 void Array::finalizeArray (void) 36 67 { … … 49 80 } 50 81 51 82 /** 83 \brief adds a new Entry to the Array 84 \param entry Entry to add. 85 */ 52 86 void Array::addEntry (GLfloat entry) 53 87 { … … 68 102 } 69 103 104 /** 105 \brief Adds 3 entries at once (convenience) 106 */ 70 107 void Array::addEntry (GLfloat entry0, GLfloat entry1, GLfloat entry2) 71 108 { … … 75 112 } 76 113 77 114 /** 115 \brief Gives back the array !! MUST be executed AFTER finalize. 116 \returns The created array. 117 */ 78 118 GLfloat* Array::getArray () 79 119 { … … 81 121 } 82 122 123 /** 124 \returns The Count of entries in the Array 125 */ 83 126 int Array::getCount() 84 127 { … … 86 129 } 87 130 88 89 131 /** 132 \brief Simple debug info about the Array 133 */ 90 134 void Array::debug () 91 135 { -
orxonox/trunk/src/array.h
r2835 r2853 1 /*! 2 \file array.h 3 \brief Contains the Array Class that handles float arrays. 4 this class creates a Array of a semi-Dynamic length. 5 beware, that after finalizing the array may not be resized again. 6 */ 7 1 8 #ifndef _ARRAY_H 2 9 #define _ARRAY_H 3 10 4 extern int verbose; 11 extern int verbose; //!< will be obsolete soon 5 12 6 13 #include <GL/gl.h> 7 14 #include <GL/glu.h> 8 15 #include <fstream> 16 17 18 //! Array Class that handles dynamic-float arrays. 9 19 class Array 10 20 { 11 21 public: 12 22 Array (); 23 ~Array(); 13 24 14 void createArray ();25 void initializeArray (); 15 26 void finalizeArray (void); 16 27 void addEntry (GLfloat entry); -
orxonox/trunk/src/material.cc
r2835 r2853 16 16 #include "material.h" 17 17 18 /** 19 \brief creates a default Material with no Name 20 normally you call this to create a material List (for an obj-file) and then append with addMaterial() 21 */ 18 22 Material::Material() 19 23 { … … 23 27 } 24 28 29 /** 30 \brief creates a Material. 31 \param mtlName Name of the Material to be added to the Material List 32 */ 25 33 Material::Material (char* mtlName) 26 34 { … … 30 38 } 31 39 40 /** 41 \brief deletes a Material 42 */ 43 Material::~Material() 44 { 45 if (verbose >= 2) 46 printf ("delete Material %s\n", name); 47 if (nextMat != NULL) 48 delete nextMat; 49 } 50 51 /** 52 \brief adds a new Material to the List. 53 this Function will append a new Material to the end of a Material List. 54 \param mtlName The name of the Material to be added. 55 */ 32 56 Material* Material::addMaterial(char* mtlName) 33 57 { … … 45 69 } 46 70 71 /** 72 \brief initializes a new Material with its default Values 73 */ 47 74 void Material::init(void) 48 75 { … … 55 82 setAmbient(0,0,0); 56 83 setSpecular(0,0,0); 84 setShininess(2.0); 57 85 setTransparency(0.0); 58 } 59 60 86 87 } 88 89 /** 90 \brief Set the Name of the Material. (Important for searching) 91 \param mtlName the Name of the Material to be set. 92 */ 61 93 void Material::setName (char* mtlName) 62 94 { … … 67 99 68 100 } 101 /** 102 \returns The Name of The Material 103 */ 69 104 char* Material::getName (void) 70 105 { … … 72 107 } 73 108 74 109 /** 110 \brief Sets the Material Illumination Model. 111 \brief illu illumination Model in int form 112 */ 75 113 void Material::setIllum (int illum) 76 114 { … … 80 118 // printf ("setting illumModel to: %i\n", illumModel); 81 119 } 82 void Material::setIllum (char* illum) 120 /** 121 \brief Sets the Material Illumination Model. 122 \brief illu illumination Model in char* form 123 */void Material::setIllum (char* illum) 83 124 { 84 125 setIllum (atoi(illum)); 85 126 } 86 127 128 /** 129 \brief Sets the Material Diffuse Color. 130 \param r Red Color Channel. 131 \param g Green Color Channel. 132 \param b Blue Color Channel. 133 */ 87 134 void Material::setDiffuse (float r, float g, float b) 88 135 { … … 95 142 96 143 } 144 /** 145 \brief Sets the Material Diffuse Color. 146 \param rgb The red, green, blue channel in char format (with spaces between them) 147 */ 97 148 void Material::setDiffuse (char* rgb) 98 149 { … … 102 153 } 103 154 155 /** 156 \brief Sets the Material Ambient Color. 157 \param r Red Color Channel. 158 \param g Green Color Channel. 159 \param b Blue Color Channel. 160 */ 104 161 void Material::setAmbient (float r, float g, float b) 105 162 { … … 111 168 ambient[3] = 1.0; 112 169 } 170 /** 171 \brief Sets the Material Ambient Color. 172 \param rgb The red, green, blue channel in char format (with spaces between them) 173 */ 113 174 void Material::setAmbient (char* rgb) 114 175 { … … 118 179 } 119 180 181 /** 182 \brief Sets the Material Specular Color. 183 \param r Red Color Channel. 184 \param g Green Color Channel. 185 \param b Blue Color Channel. 186 */ 120 187 void Material::setSpecular (float r, float g, float b) 121 188 { … … 127 194 specular[3] = 1.0; 128 195 } 196 /** 197 \brief Sets the Material Specular Color. 198 \param rgb The red, green, blue channel in char format (with spaces between them) 199 */ 129 200 void Material::setSpecular (char* rgb) 130 201 { … … 134 205 } 135 206 136 207 /** 208 \brief Sets the Material Shininess. 209 \param shini stes the Shininess from float. 210 */ 211 void Material::setShininess (float shini) 212 { 213 shininess = shini; 214 } 215 /** 216 \brief Sets the Material Shininess. 217 \param shini stes the Shininess from char*. 218 */ 219 void Material::setShininess (char* shini) 220 { 221 setShininess (atof(shini)); 222 } 223 224 /** 225 \brief Sets the Material Transparency. 226 \param trans stes the Transparency from int. 227 */ 137 228 void Material::setTransparency (float trans) 138 229 { … … 141 232 transparency = trans; 142 233 } 234 /** 235 \brief Sets the Material Transparency. 236 \param trans stes the Transparency from char*. 237 */ 143 238 void Material::setTransparency (char* trans) 144 239 { … … 148 243 } 149 244 150 245 /** 246 \brief Search for a Material called mtlName 247 \param mtlName the Name of the Material to search for 248 \returns Material named mtlName if it is found. NULL otherwise. 249 */ 151 250 Material* Material::search (char* mtlName) 152 251 { … … 169 268 } 170 269 270 /** 271 \brief sets the material with which the following Faces will be painted 272 */ 171 273 bool Material::select (void) 172 274 { … … 180 282 // setting up Sprecular 181 283 glMaterialfv(GL_FRONT, GL_SPECULAR, specular); 284 285 // setting up Shininess 286 glMaterialf(GL_FRONT, GL_SHININESS, shininess); 182 287 183 288 // setting illumination Model -
orxonox/trunk/src/material.h
r2835 r2853 1 /*! 2 \file material.h 3 \brief Contains the Material Class that handles Material for 3D-Objects. 4 */ 5 1 6 #ifndef _MATERIAL_H 2 7 #define _MATERIAL_H 3 8 4 extern int verbose; 9 extern int verbose; //!< will be obsolete soon. 5 10 6 11 #include <GL/gl.h> … … 9 14 #include <fstream> 10 15 16 //! Class to handle Materials. 11 17 class Material 12 18 { … … 30 36 void setSpecular (float r, float g, float b); 31 37 void setSpecular (char* rgb); 38 void setShininess (float shini); 39 void setShininess (char* shini); 32 40 void setTransparency (float trans); 33 41 void setTransparency (char* trans); … … 37 45 bool select (void); 38 46 39 Material* nextMat; 47 Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. 40 48 41 49 private: … … 45 53 float ambient [4]; 46 54 float specular [4]; 55 float shininess; 47 56 float transparency; 48 57 -
orxonox/trunk/src/object.cc
r2835 r2853 18 18 #include "object.h" 19 19 20 /** 21 \brief Creates a 3D-Object, but does not load any 3D-models 22 pretty useless 23 */ 20 24 Object::Object () 21 25 { … … 23 27 initialize(); 24 28 25 importFile ("reaphigh.obj");29 BoxObject(); 26 30 27 31 finalize(); 28 32 } 29 33 34 /** 35 \brief Crates a 3D-Object and loads in a File 36 \param fileName file to parse and load (must be a .obj file) 37 */ 30 38 Object::Object(char* fileName) 31 39 { … … 36 44 finalize(); 37 45 } 46 47 /** 48 \brief Crates a 3D-Object, loads in a File and scales it. 49 \param fileName file to parse and load (must be a .obj file) 50 \param scaling The factor that the object will be scaled with. 51 */ 38 52 39 53 Object::Object(char* fileName, float scaling) … … 47 61 } 48 62 63 /** 64 \brief deletes an Object 65 */ 66 Object::~Object() 67 { 68 if (verbose >= 2) 69 printf ("Deleting display List.\n"); 70 Group* walker = firstGroup; 71 while (walker != NULL) 72 { 73 glDeleteLists (walker->listNumber, 1); 74 Group* lastWalker = walker; 75 walker = walker->nextGroup; 76 delete lastWalker; 77 } 78 } 79 80 /** 81 \brief initializes the Object 82 This Function initializes all the needed arrays, Lists and clientStates 83 */ 49 84 bool Object::initialize (void) 50 85 { 51 86 if (verbose >=3) 52 87 printf("new 3D-Object is being created\n"); 53 faceMode = -1; 54 if ( (listNumber = glGenLists(1)) == 0 )55 {56 printf ("list could not be created for this Object\n");57 return false;58 }59 88 89 // setting the start group; 90 firstGroup = new Group; 91 currentGroup = firstGroup; 92 groupCount = 0; 93 94 initGroup (currentGroup); 60 95 mtlFileName = ""; 61 96 scaleFactor = 1; 62 vertices = new Array(); 63 normals = new Array(); 64 vTexture = new Array(); 65 66 glNewList (listNumber, GL_COMPILE); 97 material = new Material(); 98 67 99 glEnableClientState (GL_VERTEX_ARRAY); 68 glEnableClientState (GL_NORMAL_ARRAY);100 // glEnableClientState (GL_NORMAL_ARRAY); 69 101 // glEnableClientState (GL_TEXTURE_COORD_ARRAY); 70 102 103 71 104 return true; 72 105 } 73 106 107 /** 108 \brief Imports a obj file and handles the the relative location 109 \param fileName The file to import 110 */ 74 111 bool Object::importFile (char* fileName) 75 112 { … … 81 118 } 82 119 120 /** 121 \brief finalizes an Object. 122 This funcion is needed, to close the glList and all the other lists. 123 */ 83 124 bool Object::finalize(void) 84 125 { 85 if (verbose >=3)126 // if (verbose >=3) 86 127 printf("finalizing the 3D-Object\n"); 87 OBJ_FILE->close(); 128 finalizeGroup (currentGroup); 129 if (material != NULL) 130 delete material; 131 return true; 132 } 133 134 /** 135 \brief Draws the Objects of all Groups. 136 It does this by just calling the Lists that must have been created earlier. 137 */ 138 void Object::draw (void) 139 { 140 if (verbose >=2) 141 printf("drawing the 3D-Objects\n"); 142 Group* walker = firstGroup; 143 while (walker != NULL) 144 { 145 if (verbose >= 3) 146 printf ("Drawing object %s\n", walker->name); 147 glCallList (walker->listNumber); 148 walker = walker->nextGroup; 149 } 150 } 151 152 /** 153 \brief Draws the Object number groupNumber 154 It does this by just calling the List that must have been created earlier. 155 \param groupNumber The number of the group that will be displayed. 156 */ 157 void Object::draw (int groupNumber) 158 { 159 if (groupNumber >= groupCount) 160 { 161 if (verbose>=2) 162 printf ("You requested object number %i, but this File only contains of %i Objects.\n", groupNumber-1, groupCount); 163 return; 164 } 165 if (verbose >=2) 166 printf("drawing the requested 3D-Objects if found.\n"); 167 Group* walker = firstGroup; 168 int counter = 0; 169 while (walker != NULL) 170 { 171 if (counter == groupNumber) 172 { 173 if (verbose >= 2) 174 printf ("Drawing object number %s named %s\n", counter, walker->name); 175 glCallList (walker->listNumber); 176 return; 177 } 178 ++counter; 179 walker = walker->nextGroup; 180 } 181 if (verbose >= 2) 182 printf("Object number %i in %s not Found.\n", groupNumber, objFileName); 183 return; 184 185 } 186 187 /** 188 \brief Draws the Object with a specific groupname 189 It does this by just calling the List that must have been created earlier. 190 \param groupName The name of the group that will be displayed. 191 */ 192 void Object::draw (char* groupName) 193 { 194 if (verbose >=2) 195 printf("drawing the requested 3D-Objects if found.\n"); 196 Group* walker = firstGroup; 197 while (walker != NULL) 198 { 199 if (!strcmp(walker->name, groupName)) 200 { 201 if (verbose >= 2) 202 printf ("Drawing object %s\n", walker->name); 203 glCallList (walker->listNumber); 204 return; 205 } 206 walker = walker->nextGroup; 207 } 208 if (verbose >= 2) 209 printf("Object Named %s in %s not Found.\n", groupName, objFileName); 210 return; 211 } 212 213 /** 214 \returns Count of the Objects in this File 215 */ 216 int Object::getGroupCount (void) 217 { 218 return groupCount; 219 } 220 221 /** 222 \brief initializes a new Group object 223 */ 224 bool Object::initGroup(Group* group) 225 { 226 if (verbose >= 2) 227 printf("Adding new Group\n"); 228 group->faceMode = -1; 229 group->name = ""; 230 if ((group->listNumber = glGenLists(1)) == 0 ) 231 { 232 printf ("list could not be created for this Object\n"); 233 return false; 234 } 235 236 if (groupCount == 0) 237 { 238 group->firstVertex = 0; 239 group->firstNormal = 0; 240 group->firstNormal = 0; 241 } 242 else 243 { 244 group->firstVertex = currentGroup->firstVertex + currentGroup->vertices->getCount()/3; 245 group->firstNormal = currentGroup->firstNormal + currentGroup->normals->getCount()/3; 246 group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2; 247 } 248 249 group->vertices = new Array(); 250 group->normals = new Array(); 251 group->vTexture = new Array(); 252 253 glNewList (group->listNumber, GL_COMPILE); 254 } 255 256 /** 257 \brief finalizes a Group. 258 */ 259 bool Object::finalizeGroup(Group* group) 260 { 88 261 glEnd(); 89 262 glEndList(); 90 return true; 91 } 92 93 void Object::draw (void) 94 { 95 if (verbose >=3) 96 printf("drawing the 3D-Object\n"); 97 glCallList (listNumber); 98 } 99 100 263 264 delete group->vertices; 265 delete group->normals; 266 delete group->vTexture; 267 } 268 /** 269 \brief Reads in the .obj File and sets all the Values. 270 This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks 271 \param fileName the File that will be parsed (.obj-file) 272 */ 101 273 bool Object::readFromObjFile (char* fileName) 102 274 { … … 146 318 } 147 319 148 // case vt320 // case VertexTextureCoordinate 149 321 else if (!strncmp(Buffer, "vt ", 2)) 150 322 { 151 323 readVertexTexture(Buffer+3); 152 324 } 153 154 155 } 156 157 158 159 160 } 161 162 325 // case group 326 else if (!strncmp(Buffer, "g", 1)) 327 { 328 readGroup (Buffer+2); 329 } 330 } 331 OBJ_FILE->close(); 332 333 } 334 335 /** 336 \brief parses a vertex-String 337 If a vertex line is found this function will inject it into the vertex-Array 338 \param vertexString The String that will be parsed. 339 */ 163 340 bool Object::readVertex (char* vertexString) 164 341 { 165 read Vertices = true;342 readingVertices = true; 166 343 char subbuffer1[20]; 167 344 char subbuffer2[20]; … … 170 347 if (verbose >= 3) 171 348 printf ("reading in a vertex: %s %s %s\n", subbuffer1, subbuffer2, subbuffer3); 172 vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor);349 currentGroup->vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor); 173 350 return true; 174 351 } 175 352 353 /** 354 \brief parses a face-string 355 If a face line is found this function will add it to the glList. 356 The function makes a difference between QUADS and TRIANGLES, and will if changed re-open, set and re-close the gl-processe. 357 \param faceString The String that will be parsed. 358 */ 176 359 bool Object::readFace (char* faceString) 177 360 { 178 if (readVertices == true) 179 { 180 vertices->finalizeArray(); 181 glVertexPointer(3, GL_FLOAT, 0, vertices->getArray()); 182 normals->finalizeArray(); 183 glNormalPointer(GL_FLOAT, 0, normals->getArray()); 184 vTexture->finalizeArray(); 185 } 186 187 readVertices = false; 361 // finalize the Arrays; 362 if (readingVertices == true) 363 { 364 currentGroup->vertices->finalizeArray(); 365 glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray()); 366 currentGroup->normals->finalizeArray(); 367 glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray()); 368 currentGroup->vTexture->finalizeArray(); 369 } 370 371 readingVertices = false; 188 372 char subbuffer1[20]; 189 373 char subbuffer2[20]; … … 193 377 if (!strcmp(subbuffer4, "")) 194 378 { 195 if ( faceMode != 3)196 { 197 if ( faceMode != -1)379 if (currentGroup->faceMode != 3) 380 { 381 if (currentGroup->faceMode != -1) 198 382 glEnd(); 199 383 glBegin(GL_TRIANGLES); 200 384 } 201 385 202 faceMode = 3;386 currentGroup->faceMode = 3; 203 387 if (verbose >=3) 204 388 printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3); … … 210 394 else 211 395 { 212 if ( faceMode != 4)213 { 214 if ( faceMode != -1)396 if (currentGroup->faceMode != 4) 397 { 398 if (currentGroup->faceMode != -1) 215 399 glEnd(); 216 400 glBegin(GL_QUADS); 217 401 } 218 faceMode = 4;402 currentGroup->faceMode = 4; 219 403 if (verbose >=3 ) 220 404 printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4); … … 227 411 } 228 412 413 /** 414 \brief Adds a Face-element (one vertex of a face) with all its information. 415 It does this by searching: 416 1. The Vertex itself 417 2. The VertexNormale 418 3. The VertexTextureCoordinate 419 merging this information, the face will be drawn. 420 421 */ 229 422 bool Object::addGLElement (char* elementString) 230 423 { … … 237 430 texture[0] = '\0'; 238 431 texture ++; 239 glTexCoord2fv( vTexture->getArray()+(atoi(texture)-1)*2);432 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 240 433 241 434 char* normal; … … 245 438 normal ++; 246 439 //glArrayElement(atoi(vertex)-1); 247 glNormal3fv(normals->getArray() +(atoi(normal)-1)*3); 248 } 249 glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3); 250 251 } 252 440 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 441 } 442 glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3); 443 444 } 445 446 /** 447 \brief parses a vertexNormal-String 448 If a vertexNormal line is found this function will inject it into the vertexNormal-Array 449 \param normalString The String that will be parsed. 450 */ 253 451 bool Object::readVertexNormal (char* normalString) 254 452 { 255 read Vertices = true;453 readingVertices = true; 256 454 char subbuffer1[20]; 257 455 char subbuffer2[20]; … … 260 458 if (verbose >=3 ) 261 459 printf("found vertex-Normal %s, %s, %s\n", subbuffer1,subbuffer2,subbuffer3); 262 normals->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));460 currentGroup->normals->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3)); 263 461 return true; 264 462 } 265 463 464 /** 465 \brief parses a vertexTextureCoordinate-String 466 If a vertexTextureCoordinate line is found this function will inject it into the vertexTexture-Array 467 \param vTextureString The String that will be parsed. 468 */ 266 469 bool Object::readVertexTexture (char* vTextureString) 267 470 { 268 read Vertices = true;471 readingVertices = true; 269 472 char subbuffer1[20]; 270 473 char subbuffer2[20]; … … 272 475 if (verbose >=3 ) 273 476 printf("found vertex-Texture %s, %s\n", subbuffer1,subbuffer2); 274 vTexture->addEntry(atof(subbuffer1));275 vTexture->addEntry(atof(subbuffer2));477 currentGroup->vTexture->addEntry(atof(subbuffer1)); 478 currentGroup->vTexture->addEntry(atof(subbuffer2)); 276 479 return true; 277 480 } 278 481 279 482 /** 483 \brief parses a group String 484 This function initializes a new Group. 485 With it you should be able to import .obj-files with more than one Objects inside. 486 \param groupString the new Group to create 487 */ 488 bool Object::readGroup (char* groupString) 489 { 490 // printf ("test\n"); 491 if (!strcmp(groupString, "default")) 492 { 493 if (groupCount != 0) 494 { 495 Group* newGroup = new Group; 496 finalizeGroup(currentGroup); 497 currentGroup->nextGroup = newGroup; 498 initGroup(newGroup); 499 currentGroup = newGroup; // must be after init see initGroup for more info 500 } 501 ++groupCount; 502 } 503 else 504 { 505 506 currentGroup->name = new char [strlen(groupString)]; 507 strcpy(currentGroup->name, groupString); 508 } 509 } 510 511 /** 512 \brief Function to read in a mtl File. 513 this Function parses all Lines of an mtl File 514 \param mtlFile The .mtl file to read 515 */ 280 516 bool Object::readMtlLib (char* mtlFile) 281 517 { … … 291 527 printf ("Opening mtlFile: %s\n", mtlFileName); 292 528 char Buffer[500]; 293 vertices = new Array();294 material = new Material();295 529 Material* tmpMat = material; 296 530 while(!MTL_FILE->eof()) … … 328 562 tmpMat->setSpecular(Buffer+3); 329 563 } 564 // setting The Specular Shininess 565 else if (!strncmp(Buffer, "Ns", 2)) 566 { 567 tmpMat->setShininess(Buffer+3); 568 } 569 // setting up transparency 570 else if (!strncmp(Buffer, "d", 1)) 571 { 572 tmpMat->setTransparency(Buffer+2); 573 } 574 else if (!strncpy(Buffer, "Tf", 2)) 575 { 576 tmpMat->setTransparency(Buffer+3); 577 } 578 330 579 } 331 580 return true; 332 581 } 582 583 /** 584 \brief Function that selects a material, if changed in the obj file. 585 \param matString the Material that will be set. 586 */ 333 587 334 588 bool Object::readUseMtl (char* matString) … … 341 595 } 342 596 343 if ( faceMode != -1)597 if (currentGroup->faceMode != -1) 344 598 glEnd(); 345 faceMode = 0;599 currentGroup->faceMode = 0; 346 600 if (verbose >= 2) 347 601 printf ("using material %s for coming Faces.\n", matString); … … 349 603 } 350 604 351 605 /** 606 \brief Includes a default object 607 This will inject a Cube, because this is the most basic object. 608 */ 352 609 void Object::BoxObject(void) 353 610 { -
orxonox/trunk/src/object.h
r2835 r2853 1 1 /*! 2 \file object.h3 \brief Contains the Object Class that handles 3D-Objects2 \file object.h 3 \brief Contains the Object Class that handles 3D-Objects 4 4 */ 5 5 … … 16 16 using namespace std; 17 17 18 extern int verbose; //!< fill be removed and added again as a verbose-class 19 20 18 21 //! Class that handles 3D-Objects. it can also read them in and display them. 19 22 class Object … … 29 32 bool finalize(void); 30 33 void draw (void); 31 32 bool readFromObjFile (char* fileName);33 34 void draw (int groupNumber); 35 void draw (char* groupName); 36 int getGroupCount(); 34 37 35 38 private: 36 GLuint listNumber; 37 Array* vertices; 38 int verticesCount; 39 Array* colors; 40 Array* normals; 41 Array* vTexture; 39 //! Group to handle multiple Objects per obj-file 40 struct Group 41 { 42 char* name; 43 44 GLuint listNumber; 45 Array* vertices; 46 int verticesCount; 47 Array* colors; 48 Array* normals; 49 Array* vTexture; 50 int faceMode; 51 52 int firstVertex; 53 int firstNormal; 54 int firstVertexTexture; 55 56 Group* nextGroup; 57 }; 58 59 Group* firstGroup; //!< the first of all groups. 60 Group* currentGroup; //!< the currentGroup. this is the one we will work with. 61 int groupCount; 62 63 bool readingVertices; 64 42 65 char* objFileName; 43 66 char* mtlFileName; 44 int faceMode; 45 bool readVertices; 67 46 68 Material* material; 47 69 float scaleFactor; … … 49 71 ifstream* OBJ_FILE; 50 72 ifstream* MTL_FILE; 73 74 bool initGroup(Group* group); 75 bool finalizeGroup (Group* group); 76 77 78 ///// readin /// 79 bool readFromObjFile (char* fileName); 51 80 52 81 bool readVertex (char* vertexString); … … 55 84 bool readVertexNormal (char* normalString); 56 85 bool readVertexTexture (char* vTextureString); 86 bool readGroup (char* groupString); 57 87 bool readMtlLib (char* matFile); 58 88 bool readUseMtl (char* mtlString);
Note: See TracChangeset
for help on using the changeset viewer.