Changeset 4139 in orxonox.OLD for orxonox/branches/md2_loader/src/lib/graphics
- Timestamp:
- May 10, 2005, 10:39:01 AM (20 years ago)
- Location:
- orxonox/branches/md2_loader/src/lib/graphics
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/lib/graphics/Makefile.in
r4063 r4139 113 113 PACKAGE_VERSION = @PACKAGE_VERSION@ 114 114 PATH_SEPARATOR = @PATH_SEPARATOR@ 115 PKG_CONFIG = @PKG_CONFIG@ 115 116 RANLIB = @RANLIB@ 116 117 SET_MAKE = @SET_MAKE@ -
orxonox/branches/md2_loader/src/lib/graphics/graphics_engine.cc
r4126 r4139 17 17 18 18 #include "graphics_engine.h" 19 #include "resource_manager.h" 19 20 20 21 #include "debug.h" … … 34 35 this->maxFPS = 0; 35 36 this->setClassName ("GraphicsEngine"); 37 38 this->fullscreen = false; 39 36 40 this->initVideo(); 37 41 … … 105 109 106 110 // TO DO: Create a cool icon and use it here 107 SDL_WM_SetIcon(SDL_LoadBMP("../data/pictures/orxonox-icon32x32.bmp"), NULL); 108 111 char* loadPic = new char[strlen(ResourceManager::getInstance()->getDataDir())+ 100]; 112 sprintf(loadPic, "%s%s", ResourceManager::getInstance()->getDataDir(), "pictures/orxonox-icon32x32.bmp"); 113 SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 114 delete loadPic; 109 115 // Enable default GL stuff 110 116 glEnable(GL_DEPTH_TEST); … … 141 147 int GraphicsEngine::setResolution(int width, int height, int bpp) 142 148 { 149 Uint32 fullscreenFlag; 143 150 this->resolutionX = width; 144 151 this->resolutionY = height; 145 152 this->bitsPerPixel = bpp; 153 if (this->fullscreen) 154 fullscreenFlag = SDL_FULLSCREEN; 155 else 156 fullscreenFlag = 0; 146 157 147 158 printf ("ok\n"); 148 if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags )) == NULL)159 if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | fullscreenFlag)) == NULL) 149 160 { 150 161 PRINTF(1)("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags, SDL_GetError()); … … 152 163 // return -1; 153 164 } 154 165 } 166 167 void GraphicsEngine::setFullscreen(bool fullscreen) 168 { 169 this->fullscreen = fullscreen; 170 this->setResolution(this->resolutionX, this->resolutionY, this->bitsPerPixel); 155 171 } 156 172 … … 258 274 /* Check if our resolution is restricted */ 259 275 if(this->videoModes == (SDL_Rect **)-1){ 260 PRINTF( 1)("All resolutions available.\n");276 PRINTF(2)("All resolutions available.\n"); 261 277 } 262 278 else{ … … 264 280 PRINT(0)("Available Resoulution Modes are\n"); 265 281 for(int i = 0; this->videoModes[i]; ++i) 266 PRINT( 0)(" | %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h);282 PRINT(4)(" | %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h); 267 283 } 268 284 } -
orxonox/branches/md2_loader/src/lib/graphics/graphics_engine.h
r4070 r4139 26 26 int setGLattribs(void); 27 27 int setResolution(int width, int height, int bpp); 28 void setFullscreen(bool fullscreen = false); 28 29 /** \returns the x resolution */ 29 30 inline int getResolutionX(void) {return this->resolutionX;} -
orxonox/branches/md2_loader/src/lib/graphics/importer/Makefile.in
r4078 r4139 42 42 subdir = src/lib/graphics/importer 43 43 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 44 $(srcdir)/Makefile.in TODO44 $(srcdir)/Makefile.in 45 45 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 46 46 am__aclocal_m4_deps = $(top_srcdir)/configure.ac … … 144 144 PACKAGE_VERSION = @PACKAGE_VERSION@ 145 145 PATH_SEPARATOR = @PATH_SEPARATOR@ 146 PKG_CONFIG = @PKG_CONFIG@ 146 147 RANLIB = @RANLIB@ 147 148 SET_MAKE = @SET_MAKE@ -
orxonox/branches/md2_loader/src/lib/graphics/importer/array.cc
r3590 r4139 112 112 113 113 /** 114 \brief Gives back the array !! MUST be executed AFTER finalize.115 \returns The created array.116 */117 GLfloat* Array::getArray ()118 {119 return this->array;120 }121 122 /**123 \returns The Count of entries in the Array124 */125 int Array::getCount()126 {127 return this->entryCount;128 }129 130 /**131 114 \brief Simple debug info about the Array 132 115 */ 133 void Array::debug ( )116 void Array::debug (void) const 134 117 { 135 118 PRINT(0)("entryCount=%i, address=%p\n", this->entryCount, this->array); -
orxonox/branches/md2_loader/src/lib/graphics/importer/array.h
r3590 r4139 23 23 void addEntry(GLfloat entry0, GLfloat entry1, GLfloat entry2); 24 24 25 GLfloat* getArray (); 26 int getCount(); 27 void debug(void); 25 /** \returns The array */ 26 inline const GLfloat* getArray () const {return this->array;} 27 /** \returns The Count of entries in the Array*/ 28 inline int getCount(void)const {return this->entryCount;} 29 void debug(void) const ; 28 30 private: 29 31 //! One entry of the Array -
orxonox/branches/md2_loader/src/lib/graphics/importer/framework.cc
r3910 r4139 79 79 obj = new OBJModel(argv[1]); 80 80 else 81 obj = new PrimitiveModel( SPHERE);81 obj = new PrimitiveModel(CYLINDER); 82 82 83 83 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); -
orxonox/branches/md2_loader/src/lib/graphics/importer/material.cc
r3966 r4139 45 45 this->setTransparency(1.0); 46 46 47 48 47 this->diffuseTexture = NULL; 49 48 this->ambientTexture = NULL; 50 49 this->specularTexture = NULL; 51 52 this->diffuseTextureSet = false;53 this->ambientTextureSet = false;54 this->specularTextureSet = false;55 50 56 51 this->setName(mtlName); … … 107 102 glShadeModel(GL_SMOOTH); 108 103 109 if (this->diffuseTexture Set)104 if (this->diffuseTexture) 110 105 { 111 106 glEnable(GL_TEXTURE_2D); … … 300 295 { 301 296 PRINTF(4)("setting Diffuse Map %s\n", dMap); 302 // diffuseTexture = new Texture();303 // this->diffuseTextureSet = diffuseTexture->loadImage(dMap);304 297 305 298 //! \todo check if RESOURCE MANAGER is availiable 306 299 //! \todo Textures from .mtl-file need special care. 307 this->diffuseTexture Set = this->diffuseTexture= (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE);300 this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE); 308 301 } 309 302 -
orxonox/branches/md2_loader/src/lib/graphics/importer/material.h
r3914 r4139 67 67 Texture* ambientTexture; //!< The ambient texture of the Material. 68 68 Texture* specularTexture;//!< The specular texture of the Material. 69 70 bool diffuseTextureSet; //!< Chekcs if the diffuse texture is Set.71 bool ambientTextureSet; //!< Chekcs if the ambient texture is Set.72 bool specularTextureSet;//!< Chekcs if the specular texture is Set.73 74 69 }; 75 70 #endif -
orxonox/branches/md2_loader/src/lib/graphics/importer/model.cc
r4063 r4139 36 36 ModelFaceElement::ModelFaceElement() 37 37 { 38 this->vertexNumber = -1; 39 this->normalNumber = -1; 40 this->texCoordNumber = -1; 41 38 42 this->next = NULL; 39 43 } … … 140 144 this->currentGroup = this->firstGroup = new ModelGroup; 141 145 this->groupCount = 0; 146 this->vertexCount = 0; 147 this->normalCount = 0; 148 this->texCoordCount = 0; 142 149 143 150 this->scaleFactor = 1; … … 355 362 Material* Model::addMaterial(const char* materialName) 356 363 { 357 358 364 Material* newMat = new Material(); 359 365 newMat->setName(materialName); … … 424 430 PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3); 425 431 this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor); 432 this->vertexCount++; 426 433 return true; 427 434 } … … 438 445 PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z); 439 446 this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor); 447 this->vertexCount++; 440 448 return true; 441 449 } … … 455 463 PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3); 456 464 this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3); 465 this->normalCount++; 457 466 return true; 458 467 } … … 470 479 PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z); 471 480 this->normals->addEntry(x, y, z); 481 this->normalCount++; 482 return true; 472 483 } 473 484 … … 487 498 this->vTexture->addEntry(subbuffer1); 488 499 this->vTexture->addEntry(subbuffer2); 500 this->texCoordCount++; 489 501 return true; 490 502 } … … 502 514 this->vTexture->addEntry(u); 503 515 this->vTexture->addEntry(v); 516 this->texCoordCount++; 517 return true; 504 518 } 505 519 … … 509 523 510 524 If a face line is found this function will add it to the glList. 525 526 String is different from the argument addFace, in this that the first Vertex/Normal/Texcoord is 1 instead of 0 511 527 */ 512 528 bool Model::addFace (const char* faceString) … … 546 562 if (vertex) 547 563 tmpElem->vertexNumber = atoi(vertex)-1; 548 else549 tmpElem->vertexNumber = -1;550 564 if (texture) 551 565 tmpElem->texCoordNumber = atoi(texture)-1; 552 else553 tmpElem->texCoordNumber = -1;554 566 if (normal) 555 567 tmpElem->normalNumber = atoi(normal)-1; 556 else557 tmpElem->normalNumber = -1;558 568 559 569 faceString += tmpLen; … … 569 579 \brief adds a new Face 570 580 \param faceElemCount the number of Vertices to add to the Face. 571 \param type 0: vertex only, 1: vertex and normal, 2: vertex and Texture, 3 vertex, normal and texture581 \param type The information Passed with each Vertex 572 582 */ 573 583 bool Model::addFace(int faceElemCount, VERTEX_FORMAT type, ...) … … 583 593 for (int i = 0; i < faceElemCount; i++) 584 594 { 585 if (this->currentGroup->currentFace->vertexCount >0)595 if (this->currentGroup->currentFace->vertexCount > 0) 586 596 tmpElem = tmpElem->next = new ModelFaceElement; 587 597 588 tmpElem->vertexNumber = va_arg (itemlist, int) -1;598 tmpElem->vertexNumber = va_arg (itemlist, int); 589 599 if (type & TEXCOORD) 590 tmpElem->texCoordNumber = va_arg (itemlist, int) -1;600 tmpElem->texCoordNumber = va_arg (itemlist, int); 591 601 if (type & NORMAL) 592 tmpElem->normalNumber = va_arg(itemlist, int) -1;602 tmpElem->normalNumber = va_arg(itemlist, int); 593 603 this->currentGroup->currentFace->vertexCount++; 594 604 } … … 693 703 } 694 704 695 for (int i=0; i <vertices->getCount()/3;i++)705 for (int i=0; i < vertices->getCount()/3;i++) 696 706 { 697 707 normArray[i].normalize(); 698 708 PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z); 699 709 700 this-> normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);710 this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z); 701 711 702 712 } … … 834 844 835 845 if (elem->texCoordNumber != -1) 836 glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2); 846 { 847 if (likely(elem->texCoordNumber < this->texCoordCount)) 848 glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2); 849 else 850 PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n", 851 elem->texCoordNumber, this->texCoordCount); 852 } 837 853 if (elem->normalNumber != -1) 838 glNormal3fv(this->normals->getArray() + elem->normalNumber * 3); 854 { 855 if (likely(elem->normalNumber < this->normalCount)) 856 glNormal3fv(this->normals->getArray() + elem->normalNumber * 3); 857 else 858 PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete", 859 elem->normalNumber, this->normalCount); 860 } 839 861 if (elem->vertexNumber != -1) 840 glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3); 862 { 863 if (likely(elem->vertexNumber < this->vertexCount)) 864 glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3); 865 else 866 PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete", 867 elem->vertexNumber, this->vertexCount); 868 } 869 841 870 } 842 871 … … 897 926 this->addVertexNormal (-1.0, 0.0, 0.0); 898 927 899 /* normaleLess-testingMode 900 this->addFace ("1 2 4 3"); 901 this->addFace ("3 4 6 5"); 902 this->addFace ("5 6 8 7"); 903 this->addFace ("7 8 2 1"); 904 this->addFace ("2 8 6 4"); 905 this->addFace ("7 1 3 5"); 906 */ 907 908 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,1, 2,2,2, 4,4,3, 3,3,4); 909 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 3,3,5, 4,4,6, 6,6,7, 5,5,8); 910 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 5,5,9, 6,6,10, 8,8,11, 7,7,12); 911 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,7,13, 8,8,14, 2,10,15, 1,9,16); 912 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,2,17, 8,11,18, 6,12,19, 4,4,20); 913 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,13,21, 1,1,22, 3,3,23, 5,14,24); 914 915 } 928 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,1, 3,3,2, 2,2,3); 929 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,2,4, 3,3,5, 5,5,6, 4,4,7); 930 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,4,8, 5,5,9, 7,7,10, 6,6,11); 931 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,6,12, 7,7,13, 1,9,14, 0,8,15); 932 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,16, 7,10,17, 5,11,18, 3,3,19); 933 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,12,20, 0,0,21, 2,2,22, 4,13,23); 934 935 } -
orxonox/branches/md2_loader/src/lib/graphics/importer/model.h
r4065 r4139 100 100 bool finalized; //!< Sets the Object to be finalized. 101 101 102 int vertexCount; //!< A modelwide Counter for vertices. 103 int normalCount; //!< A modelwide Counter for the normals. 104 int texCoordCount; //!< A modelwide Counter for the texCoord. 102 105 Array* vertices; //!< The Array that handles the Vertices. 103 int verticesCount; //!< A global Counter for vertices.104 106 Array* normals; //!< The Array that handles the Normals. 105 107 Array* vTexture; //!< The Array that handles the VertexTextureCoordinates. … … 159 161 bool setMaterial(Material* mtl); 160 162 void finalize(void); 163 164 /** \returns The number of Vertices of the Model */ 165 inline int getVertexCount(void) const {return this->vertexCount;} 166 /** \returns The number of Normals of the Model */ 167 inline int getNormalCount(void) const {return this->normalCount;} 168 /** \returns The number of Texture Coordinates of the Model*/ 169 inline int getTexCoordCount(void) const {return this->texCoordCount;} 161 170 }; 162 171 -
orxonox/branches/md2_loader/src/lib/graphics/importer/objModel.cc
r4063 r4139 34 34 OBJModel::OBJModel(const char* fileName, float scaling) : Model(fileName) 35 35 { 36 this->initializeOBJ(); 36 this->objPath = "./"; 37 37 38 this->scaleFactor = scaling; 38 39 … … 52 53 if (this->objPath) 53 54 delete []this->objPath; 54 if (this->objFileName)55 delete []this->objFileName;56 if (this->mtlFileName)57 delete []this->mtlFileName;58 }59 60 /**61 \brief Initializes an obj-model62 */63 void OBJModel::initializeOBJ(void)64 {65 this->objPath = NULL;66 this->objFileName = NULL;67 this->mtlFileName = NULL;68 55 } 69 56 … … 71 58 \brief Imports a obj file and handles the the relative location 72 59 \param fileName The file to import 60 61 Splits the FileName from the DirectoryName 73 62 */ 74 63 bool OBJModel::importFile (const char* fileName) 75 64 { 76 65 PRINTF(4)("preparing to read in file: %s\n", fileName); 77 78 79 #ifdef __WIN32__ 80 // win32 path reading 81 char pathSplitter= '\\'; 82 #else /* __WIN32__ */ 83 // unix path reading 84 char pathSplitter='/'; 85 #endif /* __WIN32__ */ 86 char* tmpName; 87 strcpy(tmpName, fileName); 88 if (tmpName[0] == pathSplitter) 89 tmpName++; 90 char* name = tmpName; 91 while (( tmpName = strchr (tmpName+1, pathSplitter))) 92 { 93 name = tmpName+1; 94 } 95 this->objPath = new char[name-fileName+1]; 96 strncpy(this->objPath, fileName, name-fileName); 97 this->objPath[name-fileName] = '\0'; 98 if (strlen(objPath)> 0) 99 PRINTF(5)("Resolved file %s to folder: %s.\n", name, objPath); 100 else 101 PRINTF(5)("Resolved file %s.\n", name); 102 103 this->setName(name); 104 105 this->objFileName = new char[strlen(name)+1]; 106 strcpy (this->objFileName, name); 107 this->readFromObjFile (); 66 // splitting the 67 char* split = NULL; 68 69 if (!(split = strrchr(fileName, '/'))) 70 split = strrchr(fileName, '\\'); // windows Case 71 if (split) 72 { 73 int len = split - fileName+1; 74 this->objPath = new char[len +2]; 75 strncpy(this->objPath, fileName, len); 76 this->objPath[len] = '\0'; 77 PRINTF(1)("Resolved file %s to Path %s.\n", fileName, this->objPath); 78 } 79 this->readFromObjFile (fileName); 108 80 return true; 109 81 } … … 113 85 This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks 114 86 */ 115 bool OBJModel::readFromObjFile (void) 116 { 117 char* fileName = new char [strlen(objPath)+strlen(objFileName)+1]; 118 if (this->objFileName != NULL && !strcmp(this->objFileName, "")) 119 return false; 120 strcpy(fileName, this->objPath); 121 strcat(fileName, this->objFileName); 122 87 bool OBJModel::readFromObjFile(const char* fileName) 88 { 123 89 FILE* stream; 124 90 if( (stream = fopen (fileName, "r")) == NULL) 125 91 { 126 printf(" IniParser could not open%s\n", fileName);92 printf("Object File Could not be Opened %s\n", fileName); 127 93 return false; 128 94 } … … 179 145 } 180 146 fclose (stream); 181 delete []fileName;182 147 return true; 183 148 } … … 194 159 bool OBJModel::readMtlLib (const char* mtlFile) 195 160 { 196 this->mtlFileName = new char [strlen(mtlFile)+1]; 197 strcpy(this->mtlFileName, mtlFile); 198 char* fileName = new char [strlen(this->objPath) + strlen(this->mtlFileName)+1]; 199 sprintf(fileName, "%s%s", this->objPath, this->mtlFileName); 200 161 char* fileName = new char [strlen(this->objPath) + strlen(mtlFile)+1]; 162 sprintf(fileName, "%s%s", this->objPath, mtlFile); 201 163 202 164 FILE* stream; 203 165 if( (stream = fopen (fileName, "r")) == NULL) 204 166 { 205 printf("IniParser could not open %s\n", fileName); 167 PRINTF(2)("MaterialLibrary could not be opened %s\n", fileName); 168 delete []fileName; 206 169 return false; 207 170 } -
orxonox/branches/md2_loader/src/lib/graphics/importer/objModel.h
r3916 r4139 15 15 OBJModel(const char* fileName, float scaling = 1.0); 16 16 virtual ~OBJModel(); 17 void initializeOBJ(void);18 17 19 18 private: 20 19 // Variables 21 20 char* objPath; //!< The Path where the obj and mtl-file are located. 22 char* objFileName; //!< The Name of the obj-file.23 char* mtlFileName; //!< The Name of the mtl-file (parsed out of the obj-file)24 21 25 22 ///// readin ///// 26 23 bool importFile (const char* fileName); 27 bool readFromObjFile ( void);24 bool readFromObjFile (const char* fileName); 28 25 bool readMtlLib (const char* matFile); 29 26 }; -
orxonox/branches/md2_loader/src/lib/graphics/importer/primitive_model.cc
r3911 r4139 71 71 void PrimitiveModel::sphereModel(float size, unsigned int detail) 72 72 { 73 int vertexCount = 0;74 73 if (detail <= 0) 75 74 detail = 1; … … 89 88 size * sin(vi) * cos(vj)); 90 89 this->addVertexTexture(i / (df *2.0), (j-1.0)/(df)+.5); 91 vertexCount++;92 90 } 93 91 } 94 92 this->addVertex(0, -size, 0); 93 this->addVertexTexture(0,0); 95 94 this->addVertex(0, size, 0); 95 this->addVertexTexture(0 ,1); 96 96 97 97 // defining the binding Faces. … … 102 102 { 103 103 104 v1 = i*detail + j ;105 v4 = i*detail + (j+1);104 v1 = i*detail + j-1; 105 v4 = i*detail + j; 106 106 107 107 if (i == detail*2 -1) 108 108 { 109 v2 = j ;110 v3 = j +1;109 v2 = j-1; 110 v3 = j; 111 111 } 112 112 else 113 113 { 114 v2 = (i+1)*detail + j ;115 v3 = (i+1)*detail + (j+1);116 } 117 114 v2 = (i+1)*detail + j-1; 115 v3 = (i+1)*detail + j; 116 } 117 118 118 if (j == 0) 119 119 { 120 v1 = vertexCount+1;120 v1 = this->getVertexCount()-2; 121 121 this->addFace(3, VERTEX_TEXCOORD, v1, v1, v3, v3, v4, v4); 122 122 } 123 123 else if (j == detail) 124 124 { 125 v3 = vertexCount+2;125 v3 = this->getVertexCount()-1; 126 126 this->addFace(3, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3); 127 127 } … … 157 157 { 158 158 int p1, p2, p3, p4; 159 p1 = 2*i +1;160 p2 = 2*i+ 2;161 p3 = 2*i+ 4;162 p4 = 2*i+ 3;159 p1 = 2*i; 160 p2 = 2*i+1; 161 p3 = 2*i+3; 162 p4 = 2*i+2; 163 163 // something is wrong here 164 164 this->addFace(4, VERTEX_ONLY, p1, p2, p3, p4); 165 this->addFace(3, VERTEX_ONLY, p4, p1, 2*detail +1);166 this->addFace(3, VERTEX_ONLY, p2, p3, 2*detail+ 2);165 this->addFace(3, VERTEX_ONLY, p4, p1, 2*detail); 166 this->addFace(3, VERTEX_ONLY, p2, p3, 2*detail+1); 167 167 } 168 168 // caps 169 this->addFace(4, VERTEX_ONLY, 2*detail- 1, 2*detail, 2, 1);170 this->addFace(3, VERTEX_ONLY, 1, 2*detail-1, 2*detail+1);171 this->addFace(3, VERTEX_ONLY, 2*detail , 2, 2*detail+2);169 this->addFace(4, VERTEX_ONLY, 2*detail-2, 2*detail-1, 1, 0); 170 this->addFace(3, VERTEX_ONLY, 0, 2*detail-2, 2*detail); 171 this->addFace(3, VERTEX_ONLY, 2*detail-1, 1, 2*detail+1); 172 172 } 173 173 … … 198 198 { 199 199 unsigned int v1, v2; 200 v1 = i+ 3;200 v1 = i+2; 201 201 if (i == detail -1) 202 v2 = 3;202 v2 = 2; 203 203 else 204 v2 = i+ 4;205 this->addFace(3, VERTEX_ONLY, 1, v1, v2);206 this->addFace(3, VERTEX_ONLY, 2, v1, v2);204 v2 = i+3; 205 this->addFace(3, VERTEX_ONLY, 0, v1, v2); 206 this->addFace(3, VERTEX_ONLY, 1, v1, v2); 207 207 } 208 208 } … … 228 228 unsigned int v1, v2, v3, v4; 229 229 for (int i = 0; i < detail-1; i++) 230 for (int j = 1; j < detail; j++)230 for (int j = 0; j < detail-1; j++) 231 231 { 232 232 v1 = i*detail + j; -
orxonox/branches/md2_loader/src/lib/graphics/particles/particle_system.cc
r4017 r4139 40 40 this->particleType = type; 41 41 this->particles = NULL; 42 this->deadList = NULL; 42 43 this->setConserve(.8); 43 44 this->setLifeSpan(.1); … … 57 58 // delete what has to be deleted here 58 59 ParticleEngine::getInstance()->removeSystem(this); 60 61 // deleting all the living Particles 62 while (this->particles) 63 { 64 Particle* tmpDelPart = this->particles; 65 this->particles = this->particles->next; 66 delete tmpDelPart; 67 } 68 69 // deleting all the dead particles 70 while (this->deadList) 71 { 72 Particle* tmpDelPart = this->deadList; 73 this->deadList = this->deadList->next; 74 delete tmpDelPart; 75 } 59 76 } 60 77 … … 199 216 { 200 217 prevPart->next = tickPart->next; 201 delete tickPart; 218 tickPart->next = this->deadList; 219 this->deadList = tickPart; 202 220 tickPart = prevPart->next; 203 221 } … … 206 224 prevPart = NULL; 207 225 this->particles = tickPart->next; 208 delete tickPart; 226 tickPart->next = this->deadList; 227 this->deadList = tickPart; 209 228 tickPart = this->particles; 210 229 } … … 266 285 if (unlikely(particles == NULL)) 267 286 { 268 this->particles = new Particle; 287 if (likely(deadList != NULL)) 288 { 289 this->particles = this->deadList; 290 deadList = deadList->next; 291 } 292 else 293 this->particles = new Particle; 269 294 this->particles->next = NULL; 270 295 } … … 272 297 else 273 298 { 274 Particle* tmpPart = new Particle; 299 Particle* tmpPart; 300 if (likely(deadList != NULL)) 301 { 302 tmpPart = this->deadList; 303 deadList = deadList->next; 304 } 305 else 306 tmpPart = new Particle; 275 307 tmpPart->next = this->particles; 276 308 this->particles = tmpPart; … … 300 332 PRINT(0)(" ParticleSystem %s\n", this->name); 301 333 PRINT(0)(" ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount); 302 } 334 if (deadList) 335 { 336 PRINT(0)(" - ParticleDeadList is used: "); 337 int i = 1; 338 Particle* tmpPart = this->deadList; 339 while (tmpPart = tmpPart->next) ++i; 340 PRINT(0)("count: %d\n", i); 341 } 342 } -
orxonox/branches/md2_loader/src/lib/graphics/particles/particle_system.h
r4017 r4139 92 92 Material* material; //!< A Material for all the Particles. 93 93 Particle* particles; //!< A list of particles of this System. 94 Particle* deadList; //!< A list of dead Particles in the System. 94 95 95 96 GLuint* glID; //!< A List of different gl-List-ID's
Note: See TracChangeset
for help on using the changeset viewer.