Changeset 8309 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Jun 11, 2006, 12:24:11 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/md2Model.cc
r8293 r8309 89 89 #define BULK_CONV( _ptr, _num ) 90 90 #define BULK_CONV16( _ptr, _num ) 91 #endif 91 #endif 92 92 93 93 /******************************************************************************** … … 103 103 /* this creates the data container via ressource manager */ 104 104 if (!modelFileName.empty()) 105 this->data = (MD2Data*)ResourceManager::getInstance()->load( 105 this->data = (MD2Data*)ResourceManager::getInstance()->load( 106 106 modelFileName, MD2, RP_GAME, skinFileName, scale); 107 108 //When arriving here it is assumed that everything is in the correct byte order. 107 108 //When arriving here it is assumed that everything is in the correct byte order. 109 109 if( unlikely(this->data == NULL)) 110 110 PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n"); … … 125 125 this->pModelInfo.numNormals = 0; 126 126 this->pModelInfo.numTexCoor = this->data->numTexCoor; 127 127 128 128 this->pModelInfo.pVertices = (float*)this->data->pVertices; 129 129 130 130 this->pModelInfo.pNormals = NULL; 131 131 132 132 this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor; 133 133 134 134 // triangle conversion 135 135 this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles]; … … 388 388 //PRINTF(0)("\n==========================| MD2Model::debug() |===\n"); 389 389 PRINTF(0)("= Model FileName:\t%s\n", this->data->fileName.c_str()); 390 PRINTF(0)("= Skin FileName:\t%s\n", 390 PRINTF(0)("= Skin FileName:\t%s\n", 391 391 this->data->skinFileName.c_str()); 392 PRINTF(0)("= Size in Memory:\t%i Bytes\n", 392 PRINTF(0)("= Size in Memory:\t%i Bytes\n", 393 393 this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size 394 394 PRINTF(0)("= Number of Vertices:\t%i\n", this->data->header->numVertices); … … 438 438 MD2Data::~MD2Data() 439 439 { 440 delete this->header;440 /* delete this->header; 441 441 442 442 delete [] this->pVertices; 443 443 delete [] this->pGLCommands; 444 444 delete [] this->pLightNormals; 445 delete [] this->pTexCoor; 445 delete [] this->pTexCoor;*/ 446 446 } 447 447 … … 508 508 /* triangle list */ 509 509 fseek(pFile, this->header->offsetTriangles, SEEK_SET); 510 fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile); 510 fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile); 511 511 BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 ); 512 512 -
trunk/src/lib/graphics/importer/texture_sequence.cc
r8298 r8309 20 20 #include "debug.h" 21 21 #include "graphics_engine.h" 22 #include <stdarg.h> 22 23 23 24 #ifdef HAVE_SDL_IMAGE_H … … 40 41 } 41 42 43 42 44 /** 43 45 * Destructor of a TextureSequence … … 66 68 this->textures.pop_back(); 67 69 } 68 }69 70 /**71 * @brief rebuilds all the textures from the Images stored in this FrameSequence72 */73 bool TextureSequence::rebuild()74 {75 PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassName(), this->getName());76 77 for (unsigned int i = 0; i < this->textures.size(); i++)78 {79 if (glIsTexture(this->textures[i]))80 {81 glDeleteTextures(1, &this->textures[i]);82 this->textures[i] = 0;83 }84 85 if (this->images[i] != NULL)86 this->textures[i] = loadTexToGL(this->images[i]);87 }88 return true;89 70 } 90 71 … … 97 78 bool TextureSequence::loadImageSeries(unsigned int count, ...) 98 79 { 80 bool retVal = true; 99 81 va_list textureNameList; 100 82 va_start(textureNameList, count); 101 83 102 return this->loadImageSeries(count, textureNameList);103 }104 105 /**106 * @brief loads an image Sequence107 * @param count how many images to load to the TextureSequence108 * @param textures the names of the Images to load109 * @returns true on success, false otherwise110 */111 bool TextureSequence::loadImageSeries(unsigned int count, va_list textures)112 {113 bool retVal = true;114 84 for (unsigned int i = 0; i < count; i++) 115 85 { 116 if( !this->addFrame(va_arg(texture s, char*)))86 if( !this->addFrame(va_arg(textureNameList, char*))) 117 87 retVal = false; 118 88 } … … 120 90 } 121 91 122 bool TextureSequence::loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to, const std::string& extension) 92 93 /** 94 * @brief Loads an Image-Series into the TextureSequence. 95 * @param imagePrefix The Prefix of the Image 96 * @param from From which image 97 * @param to To which image 98 * @return true on success. 99 * 100 * @example to load the Files image_001.jpg, image_002.jpg, ... image_099.jpg 101 * use loadImageSeries("image_###.jpg", 0, 99); 102 * @note important is, that the count of ###'s is correct. 103 */ 104 bool TextureSequence::loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to) 123 105 { 124 106 unsigned int index = 0; … … 134 116 frameSize++; 135 117 } 136 _imagePrefix += "." + extension;137 printf("TESTING %s\n", _imagePrefix.c_str());138 118 139 119 PRINTF(4)("Found %d '#'s in %s... searching for LOD's\n", frameSize, imagePrefix.c_str()); … … 150 130 } 151 131 132 152 133 /** 153 134 * @brief adds a new Frame to this Sequence (at the end) … … 198 179 } 199 180 200 /** 201 * @brief moves to the n'th texture which can then be retrieved via the Texture function: this->getTexture() 202 * @param frameNumber the n-th frame 203 */ 204 /*void TextureSequence::gotoFrame(unsigned int frameNumber) 205 { 206 if (this->textures.size() > frameNumber) 207 this->setTexture(this->textures[frameNumber]); 208 } 209 */ 181 182 183 /** 184 * @brief rebuilds all the textures from the Images stored in this FrameSequence 185 */ 186 bool TextureSequence::rebuild() 187 { 188 PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassName(), this->getName()); 189 190 for (unsigned int i = 0; i < this->textures.size(); i++) 191 { 192 if (glIsTexture(this->textures[i])) 193 { 194 glDeleteTextures(1, &this->textures[i]); 195 this->textures[i] = 0; 196 } 197 198 if (this->images[i] != NULL) 199 this->textures[i] = loadTexToGL(this->images[i]); 200 } 201 return true; 202 } -
trunk/src/lib/graphics/importer/texture_sequence.h
r8297 r8309 10 10 11 11 #include <vector> 12 #include <stdarg.h>13 12 14 13 … … 18 17 public: 19 18 TextureSequence(unsigned int count = 0, ...); 20 // Texture(TEXTURE_TYPE type, int resolution); 19 TextureSequence(const std::vector<std::string>*& textureNames); 20 // Texture(TEXTURE_TYPE type, int resolution); 21 21 virtual ~TextureSequence(); 22 22 23 23 bool loadImageSeries(unsigned int count, ...); 24 bool loadImageSeries(unsigned int count, va_listtextureNames);25 bool loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to , const std::string& extension = "png");24 bool loadImageSeries(unsigned int count, std::vector<std::string>& textureNames); 25 bool loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to); 26 26 bool addFrame(const std::string& image); 27 27 bool addFrame(SDL_Surface* surface);
Note: See TracChangeset
for help on using the changeset viewer.