Changeset 9824 in orxonox.OLD for branches/new_class_id/src/lib/graphics
- Timestamp:
- Sep 26, 2006, 12:43:56 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib/graphics/importer
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/importer/Makefile.am
r9781 r9824 33 33 \ 34 34 md2/md2Model.cc \ 35 md2/resource_md2.cc \ 35 36 \ 36 37 md3/md3_model.cc \ … … 77 78 \ 78 79 md2/md2Model.h \ 80 md2/resource_md2.h \ 79 81 \ 80 82 md3/md3_model.h \ -
branches/new_class_id/src/lib/graphics/importer/md2/md2Model.cc
r9715 r9824 19 19 20 20 #include "debug.h" 21 #include " util/loading/resource_manager.h"21 #include "resource_md2.h" 22 22 23 23 … … 26 26 //! the model anorms 27 27 sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = { 28 29 };28 #include "anorms.h" 29 }; 30 30 31 31 //! anormal dots, no idea of how this shall work, but it does 32 32 float MD2Model::anormsDots[SHADEDOT_QUANT][256] = { 33 34 };33 #include "anormtab.h" 34 }; 35 35 36 36 … … 42 42 sAnim MD2Model::animationList[22] = 43 43 { 44 // begin, end, fps, interruptable44 // begin, end, fps, interruptable 45 45 { 0, 39, 9, 1 }, //!< STAND 46 46 { 40, 45, 10, 1 }, //!< RUN … … 73 73 ********************************************************************************/ 74 74 75 MD2Model::MD2Model() 76 : data(new MD2Data()) 77 { 78 this->init(); 79 } 80 81 #include "resource_md2.h" 75 82 /** 76 83 \brief simple constructor initializing all variables 77 84 */ 78 85 MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale) 79 { 80 this->registerObject(this, MD2Model::_objectList); 81 /* this creates the data container via ressource manager */ 82 if (!modelFileName.empty()) 83 this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale); 84 if( unlikely(this->data == NULL)) 85 PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n"); 86 86 : data(new MD2Data()) 87 { 88 this->init(); 87 89 this->scaleFactor = scale; 88 this->animationSpeed = 1.0f; 89 90 shadeDots = MD2Model::anormsDots[0]; 91 /* set the animation stat mannualy */ 92 this->animationState.type = STAND; 93 this->animationState.numPlays = 1; 94 this->setAnimation(STAND); 90 91 this->data = ResourceMD2(modelFileName, skinFileName, scale).data; 92 rebuildInfo(); 95 93 96 94 this->debug(); 97 98 //write the modelinfo information 95 } 96 97 MD2Model& MD2Model::operator=(const MD2Model& md2model) 98 { 99 this->data = md2model.data; 100 rebuildInfo(); 101 return *this; 102 } 103 104 void MD2Model::rebuildInfo() 105 { 106 //write the modelinfo information 99 107 this->pModelInfo.numVertices = this->data->numVertices; 100 108 this->pModelInfo.numTriangles = this->data->numTriangles; … … 107 115 108 116 // triangle conversion 117 if (this->pModelInfo.pTriangles != NULL) 118 delete[] this->pModelInfo.pTriangles; 109 119 this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles]; 110 120 for( int i = 0; i < this->data->numTriangles; i++) … … 118 128 this->pModelInfo.pTriangles[i].indexToTexCoor[2] = this->data->pTriangles[i].indexToTexCoor[2]; 119 129 } 130 } 131 132 bool MD2Model::load(const std::string& modelFileName, const std::string& skinFileName, float scale) 133 { 134 this->data = MD2Data::Pointer(new MD2Data(modelFileName, skinFileName, scale)); 120 135 } 121 136 … … 132 147 this->pModelInfo.pTexCoor = NULL; 133 148 this->pModelInfo.pTriangles = NULL; 134 135 ResourceManager::getInstance()->unload(this->data); 136 } 137 149 } 150 151 152 void MD2Model::init() 153 { 154 this->registerObject(this, MD2Model::_objectList); 155 /* this creates the data container via ressource manager */ 156 if( unlikely(this->data.isNull())) 157 PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n"); 158 159 this->scaleFactor = 1.0f; 160 this->animationSpeed = 1.0f; 161 162 shadeDots = MD2Model::anormsDots[0]; 163 /* set the animation stat mannualy */ 164 this->animationState.type = STAND; 165 this->animationState.numPlays = 1; 166 this->setAnimation(STAND); 167 } 138 168 139 169 /** … … 153 183 154 184 for( int i = 0; i < this->data->numVertices; ++i) 155 156 157 158 159 185 { 186 this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]); 187 this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]); 188 this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]); 189 } 160 190 } 161 191 … … 259 289 /* draw the triangles */ 260 290 while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */ 291 { 292 if( i < 0) 261 293 { 262 if( i < 0) 263 { 264 glBegin(GL_TRIANGLE_FAN); 265 i = -i; 266 } 267 else 268 { 269 glBegin(GL_TRIANGLE_STRIP); 270 } 271 272 for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */ 273 { 274 glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] ); 275 glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]); 276 glVertex3fv(this->verticesList[pCommands[2]]); 277 } 278 glEnd(); 279 294 glBegin(GL_TRIANGLE_FAN); 295 i = -i; 280 296 } 297 else 298 { 299 glBegin(GL_TRIANGLE_STRIP); 300 } 301 302 for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */ 303 { 304 glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] ); 305 glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]); 306 glVertex3fv(this->verticesList[pCommands[2]]); 307 } 308 glEnd(); 309 310 } 281 311 glDisable(GL_CULL_FACE); 282 312 glPopAttrib(); … … 289 319 int* pCommands = this->data->pGLCommands; 290 320 /* some face culling stuff */ 291 // glPushAttrib(GL_POLYGON_BIT);292 // glFrontFace(GL_CW);293 // glEnable(GL_CULL_FACE);294 // glCullFace(GL_BACK);295 //296 // this->processLighting();297 // this->interpolate(/*this->verticesList*/);321 // glPushAttrib(GL_POLYGON_BIT); 322 // glFrontFace(GL_CW); 323 // glEnable(GL_CULL_FACE); 324 // glCullFace(GL_BACK); 325 // 326 // this->processLighting(); 327 // this->interpolate(/*this->verticesList*/); 298 328 this->data->material.select(); 299 329 … … 337 367 338 368 if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps)) 369 { 370 this->animationState.currentFrame = this->animationState.nextFrame; 371 this->animationState.nextFrame++; 372 373 if( this->animationState.nextFrame > this->animationState.endFrame ) 339 374 { 340 this->animationState.currentFrame = this->animationState.nextFrame; 341 this->animationState.nextFrame++; 342 343 if( this->animationState.nextFrame > this->animationState.endFrame ) 375 if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP) 344 376 { 345 if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP) 346 { 347 this->animationState.nextFrame = this->animationState.startFrame; 348 this->animationState.numPlays++; 349 } 350 else 351 { 352 this->animationState.nextFrame = this->animationState.endFrame; 353 } 377 this->animationState.nextFrame = this->animationState.startFrame; 378 this->animationState.numPlays++; 354 379 } 355 this->animationState.lastTime = this->animationState.localTime; 380 else 381 { 382 this->animationState.nextFrame = this->animationState.endFrame; 383 } 356 384 } 357 358 // if( this->animationState.currentFrame > (this->data->numFrames - 1) ) 359 // this->animationState.currentFrame = 0; 360 361 // if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP) 362 // this->animationState.nextFrame = 0; 385 this->animationState.lastTime = this->animationState.localTime; 386 } 387 388 // if( this->animationState.currentFrame > (this->data->numFrames - 1) ) 389 // this->animationState.currentFrame = 0; 390 391 // if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP) 392 // this->animationState.nextFrame = 0; 363 393 364 394 this->animationState.interpolationState = this->animationState.fps * 365 (this->animationState.localTime - this->animationState.lastTime);395 (this->animationState.localTime - this->animationState.lastTime); 366 396 } 367 397 … … 390 420 PRINT(0)("= Number of Frames: \t%i\n", this->data->header->numFrames); 391 421 PRINT(0)("= Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth); 392 PRINT(0)("= Pointer to the data object: %p\n", this->data);422 //PRINT(0)("= Pointer to the data object: %p\n", this->data); 393 423 PRINT(0)("===================================================\n\n"); 394 424 } … … 399 429 ********************************************************************************/ 400 430 431 MD2Data::MD2Data() 432 { 433 this->init(); 434 } 435 401 436 /** 402 437 \brief simple constructor … … 404 439 MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale) 405 440 { 406 scale *= 0.1f; 407 441 this->init(); 442 this->scaleFactor = scale; 443 444 this->loadModel(modelFileName); 445 this->loadSkin(skinFileName); 446 } 447 448 void MD2Data::init() 449 { 450 this->scaleFactor = 1.0; 408 451 this->pVertices = NULL; 409 452 this->pGLCommands = NULL; 410 453 this->pLightNormals = NULL; 411 454 this->pTexCoor = NULL; 455 this->header = NULL; 412 456 413 457 this->numFrames = 0; … … 415 459 this->numGLCommands = 0; 416 460 this->numTexCoor = 0; 417 418 // this->scaleFactor = 1.0f; 419 this->scaleFactor = scale; 420 421 this->fileName = ""; 422 this->skinFileName = ""; 423 this->loadModel(modelFileName); 424 this->loadSkin(skinFileName); 425 } 426 461 } 427 462 428 463 /** … … 462 497 pFile = fopen(fileName.c_str(), "rb"); 463 498 if( unlikely(!pFile)) 464 465 466 467 499 { 500 PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n"); 501 return false; 502 } 468 503 this->header = new MD2Header; 469 504 fread(this->header, 1, sizeof(MD2Header), pFile); 470 505 /* check for the header version: make sure its a md2 file :) */ 471 506 if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT)) 472 473 474 475 507 { 508 PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str()); 509 return false; 510 } 476 511 477 512 this->fileName =fileName; … … 506 541 507 542 for(int i = 0; i < this->numFrames; ++i) 543 { 544 frame = (sFrame*)(buffer + this->header->frameSize * i); 545 pVertex = this->pVertices + this->numVertices * i; 546 pNormals = this->pLightNormals + this->numVertices * i; 547 548 for(int j = 0; j < this->numVertices; ++j) 508 549 { 509 frame = (sFrame*)(buffer + this->header->frameSize * i); 510 pVertex = this->pVertices + this->numVertices * i; 511 pNormals = this->pLightNormals + this->numVertices * i; 512 513 for(int j = 0; j < this->numVertices; ++j) 514 { 515 /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)... */ 516 pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor; 517 pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor; 518 pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor; 519 520 //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]); 521 522 pNormals[j] = frame->pVertices[j].lightNormalIndex; 523 } 550 /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)... */ 551 pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor; 552 pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor; 553 pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor; 554 555 //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]); 556 557 pNormals[j] = frame->pVertices[j].lightNormalIndex; 524 558 } 525 PRINTF(4)("Finished loading the md2 file\n"); 559 } 560 PRINTF(4)("Finished loading the md2 file\n"); 526 561 527 562 delete [] buffer; … … 538 573 { 539 574 if( fileName.empty()) 540 541 542 543 575 { 576 this->skinFileName = ""; 577 return false; 578 } 544 579 545 580 this->skinFileName = fileName; -
branches/new_class_id/src/lib/graphics/importer/md2/md2Model.h
r9722 r9824 20 20 21 21 #include "base_object.h" 22 #include "count_pointer.h" 22 23 23 24 #include "interactive_model.h" … … 45 46 struct MD2Header 46 47 { 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 48 int ident; //!< This is used to identify the file 49 int version; //!< The version number of the file (Must be 8) 50 51 int skinWidth; //!< The skin width in pixels 52 int skinHeight; //!< The skin height in pixels 53 int frameSize; //!< The size in bytes the frames are 54 55 int numSkins; //!< The number of skins associated with the model 56 int numVertices; //!< The number of vertices (constant for each frame) 57 int numTexCoords; //!< The number of texture coordinates 58 int numTriangles; //!< The number of faces (polygons) 59 int numGlCommands; //!< The number of gl commands 60 int numFrames; //!< The number of animation frames 61 62 int offsetSkins; //!< The offset in the file for the skin data 63 int offsetTexCoords; //!< The offset in the file for the texture data 64 int offsetTriangles; //!< The offset in the file for the face data 65 int offsetFrames; //!< The offset in the file for the frames data 66 int offsetGlCommands; //!< The offset in the file for the gl commands data 67 int offsetEnd; //!< The end of the file offset 67 68 }; 68 69 … … 70 71 //! animation names enumeration 71 72 typedef enum MD2animType 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 73 { 74 STAND, //0 75 RUN, //1 76 ATTACK, //2 77 PAIN_A, //3 78 PAIN_B, //4 79 PAIN_C, //5 80 JUMP, //6 81 FLIP, //7 82 SALUTE, //8 83 FALLBACK, //9 84 WAVE, //10 85 POINT, //11 86 CROUCH_STAND, 87 CROUCH_WALK, 88 CROUCH_ATTACK, 89 CROUCH_PAIN, 90 CROUCH_DEATH, 91 DEATH_FALLBACK, 92 DEATH_FALLFORWARD, 93 DEATH_FALLBACKSLOW, 94 BOOM, 95 WALK, 96 97 MAX_ANIMATIONS 98 }; 98 99 99 100 … … 116 117 class MD2Data : public BaseObject 117 118 { 118 public: 119 MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f); 119 public: 120 typedef CountPointer<MD2Data> Pointer; 121 public: 122 MD2Data(); 123 MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f); 120 124 virtual ~MD2Data(); 121 125 122 private: 123 bool loadModel(const std::string& fileName); 124 bool loadSkin(const std::string& fileName = ""); 125 126 public: 126 private: 127 void init(); 128 bool loadModel(const std::string& fileName); 129 bool loadSkin(const std::string& fileName = ""); 130 131 public: 127 132 int numFrames; //!< number of frames 128 133 int numVertices; //!< number of vertices … … 148 153 149 154 //! This is a MD2 Model class 150 class MD2Model : public InteractiveModel { 155 class MD2Model : public InteractiveModel 156 { 151 157 ObjectListDeclaration(MD2Model); 152 158 public: 159 MD2Model(); 153 160 MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f); 154 161 virtual ~MD2Model(); 162 163 MD2Model& operator=(const MD2Model& md2model); 164 165 bool load(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f); 155 166 156 167 virtual void draw() const; … … 162 173 inline int getAnimation() { return this->animationState.type; } 163 174 virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; } 164 175 virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; } 165 176 /** scales the current model @param scaleFactor: the factor [0..1] to use for scaling */ 166 177 void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;} 167 178 179 180 void acquireData(const MD2Data::Pointer& data) { this->data = data; rebuildInfo(); }; 181 const MD2Data::Pointer& dataPointer() const { return this->data; }; 168 182 virtual void tick(float dtS); 169 183 void debug(); … … 171 185 172 186 private: 187 void init(); 188 void rebuildInfo(); 189 173 190 void animate(float time); 174 191 void processLighting(); … … 177 194 178 195 179 196 public: 180 197 /* these variables are static, because they are all the same for every model */ 181 static sVec3D anorms[NUM_VERTEX_NORMALS]; //!< the anormals182 static float anormsDots[SHADEDOT_QUANT][256]; //!< the anormals dot products183 static sAnim animationList[22]; //!< the anomation list184 185 float* shadeDots;186 187 MD2Data* data;//!< the md2 data pointer188 189 190 float scaleFactor; //!< the scale factor (individual)191 float animationSpeed; //!< the speed of the animation (factor for the time)192 sAnimState animationState; //!< animation state of the model193 sVec3D verticesList[MD2_MAX_VERTICES]; //!< place to temp sav the vert198 static sVec3D anorms[NUM_VERTEX_NORMALS]; //!< the anormals 199 static float anormsDots[SHADEDOT_QUANT][256]; //!< the anormals dot products 200 static sAnim animationList[22]; //!< the anomation list 201 //! again one of these strange id software parts 202 float* shadeDots; 203 204 CountPointer<MD2Data> data; //!< the md2 data pointer 205 206 private: 207 float scaleFactor; //!< the scale factor (individual) 208 float animationSpeed; //!< the speed of the animation (factor for the time) 209 sAnimState animationState; //!< animation state of the model 210 sVec3D verticesList[MD2_MAX_VERTICES]; //!< place to temp sav the vert 194 211 }; 195 212 -
branches/new_class_id/src/lib/graphics/importer/md2/resource_md2.cc
r9823 r9824 1 1 2 #include "resource_ texture.h"2 #include "resource_md2.h" 3 3 #include "substring.h" 4 4 #include "multi_type.h" … … 6 6 7 7 8 Resource Texture::ResourceTexture(const std::string& imageName, GLenum target)9 : NewResource(&Resource Texture::type)8 ResourceMD2::ResourceMD2(const std::string& modelName, const std::string& skinName, float scale) 9 : NewResource(&ResourceMD2::type) 10 10 { 11 Resources::StorePointer* ptr = this->acquireResource( imageName + ',' + "TEST");11 Resources::StorePointer* ptr = this->acquireResource(loadString(modelName, skinName, scale)); 12 12 13 13 if (ptr) 14 14 { 15 PRINTF(5)("FOUN T TEXTURE: %s\n", imageName.c_str());16 this->acquireData(static_cast<Resource Texture::TextureResourcePointer*>(ptr)->ptr());15 PRINTF(5)("FOUND MD2: %s\n", modelName.c_str()); 16 this->acquireData(static_cast<ResourceMD2::MD2ResourcePointer*>(ptr)->ptr()); 17 17 } 18 18 else 19 19 { 20 PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str()); 21 std::string fileName = this->NewResource::locateFile(imageName); 22 this->Texture::loadImage(fileName, target); 23 this->NewResource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Texture::dataPointer())); 20 PRINTF(5)("NOT FOUND MD2: %s\n", modelName.c_str()); 21 std::string modelFileName = this->NewResource::locateFile(modelName); 22 std::string skinFileName = this->NewResource::locateFile(skinName); 23 this->MD2Model::load(modelFileName, skinFileName, scale); 24 this->NewResource::addResource(new ResourceMD2::MD2ResourcePointer(loadString(modelName, skinName, scale), Resources::KeepLevel(0), this->MD2Model::dataPointer())); 24 25 } 26 25 27 } 26 28 27 Resource Texture ResourceTexture::createFromString(const std::string& loadString)29 ResourceMD2 ResourceMD2::createFromString(const std::string& loadString) 28 30 { 29 31 SubString loadValues(loadString, ','); 30 std::string imageName; 31 GLenum target = GL_TEXTURE_2D; 32 std::string modelName; 33 std::string skinName; 34 float scale = 1.0f; 32 35 if (loadValues.size() > 0) 33 imageName = loadValues[0];36 modelName = loadValues[0]; 34 37 if (loadValues.size() > 1) 35 target = (GLenum)MultiType(loadValues[2]).getInt(); 38 skinName = loadValues[1]; 39 if (loadValues.size() > 2) 40 scale = MultiType(loadValues[2]).getFloat(); 36 41 37 return ResourceTexture(imageName, target); 42 return ResourceMD2(modelName, skinName, scale); 43 } 44 45 std::string ResourceMD2::loadString(const std::string& modelName, const std::string& skinName, float scale) 46 { 47 return modelName + ',' + skinName + ',' + MultiType(scale).getString(); 38 48 } 39 49 40 50 41 42 Resources::tType<ResourceTexture> ResourceTexture::type("Texture"); 51 Resources::tType<ResourceMD2> ResourceMD2::type("MD2"); 43 52 44 53 … … 46 55 47 56 48 Resource Texture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)57 ResourceMD2::MD2ResourcePointer::MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data) 49 58 : Resources::StorePointer(loadString, keepLevel) , pointer(data) 50 59 {} -
branches/new_class_id/src/lib/graphics/importer/md2/resource_md2.h
r9823 r9824 1 1 /*! 2 * @file resource_ texture.h3 * @brief Contains the Resource Texture class, that handles the Resource-specific loading part of the Texture.2 * @file resource_md2.h 3 * @brief Contains the ResourceMD2 class, that handles the Resource-specific loading part of the MD2. 4 4 * 5 5 */ 6 6 7 #ifndef _RESOURCE_ TEXTURE_H8 #define _RESOURCE_ TEXTURE_H7 #ifndef _RESOURCE_MD2_H 8 #define _RESOURCE_MD2_H 9 9 10 10 #include "util/loading/resource.h" 11 #include " texture.h"11 #include "md2Model.h" 12 12 13 13 14 class Resource Texture : public Texture, public Resources::NewResource14 class ResourceMD2 : public MD2Model, public Resources::NewResource 15 15 { 16 16 public: 17 ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D); 18 static ResourceTexture createFromString(const std::string& loadString); 17 ResourceMD2(const std::string& modelName, const std::string& skinName = "", float scale = 1.0f); 18 static ResourceMD2 createFromString(const std::string& loadString); 19 static std::string loadString(const std::string& modelName, const std::string& skinName = "", float scale = 1.0f); 19 20 20 21 private: 21 class TextureResourcePointer : public Resources::StorePointer22 class MD2ResourcePointer : public Resources::StorePointer 22 23 { 23 24 public: 24 TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data);25 inline const TextureData::Pointer& ptr() const { return pointer; }25 MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data); 26 inline const MD2Data::Pointer& ptr() const { return pointer; } 26 27 private: 27 TextureData::Pointer pointer;28 MD2Data::Pointer pointer; 28 29 }; 29 30 30 31 private: 31 static Resources::tType<Resource Texture> type;32 static Resources::tType<ResourceMD2> type; 32 33 }; 33 34 34 35 35 #endif /* _RESOURCE_ TEXTURE_H */36 #endif /* _RESOURCE_MD2_H */
Note: See TracChangeset
for help on using the changeset viewer.