Changeset 9824 in orxonox.OLD for branches/new_class_id/src/lib/graphics/importer/md2/resource_md2.cc
- Timestamp:
- Sep 26, 2006, 12:43:56 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
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 {}
Note: See TracChangeset
for help on using the changeset viewer.