| 1 |  | 
|---|
| 2 | #include "resource_obj.h" | 
|---|
| 3 | #include "substring.h" | 
|---|
| 4 | #include "multi_type.h" | 
|---|
| 5 | #include "debug.h" | 
|---|
| 6 |  | 
|---|
| 7 |  | 
|---|
| 8 | ResourceOBJ::ResourceOBJ(const std::string& imageName, float scaling, const Resources::KeepLevel& keepLevel) | 
|---|
| 9 |     : Resource(&ResourceOBJ::type) | 
|---|
| 10 | { | 
|---|
| 11 |   Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType(scaling).getString()); | 
|---|
| 12 |  | 
|---|
| 13 |   if (ptr) | 
|---|
| 14 |   { | 
|---|
| 15 |     PRINTF(5)("FOUND OBJ: %s\n", imageName.c_str()); | 
|---|
| 16 |     this->acquireData(static_cast<ResourceOBJ::OBJResourcePointer*>(ptr)->ptr()); | 
|---|
| 17 |   } | 
|---|
| 18 |   else | 
|---|
| 19 |   { | 
|---|
| 20 |     PRINTF(5)("NOT FOUND OBJ: %s\n", imageName.c_str()); | 
|---|
| 21 |     std::string fileName = this->Resource::locateFile(imageName); | 
|---|
| 22 |     this->acquireData(OBJModel(fileName, scaling).dataPointer()); | 
|---|
| 23 |     this->Resource::addResource(new ResourceOBJ::OBJResourcePointer(imageName + ',' + MultiType(scaling).getString(), keepLevel, this->StaticModel::dataPointer())); | 
|---|
| 24 |   } | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | ResourceOBJ ResourceOBJ::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel) | 
|---|
| 28 | { | 
|---|
| 29 |   SubString loadValues(loadString, ','); | 
|---|
| 30 |   std::string imageName; | 
|---|
| 31 |   float scaling = 1.0f; | 
|---|
| 32 |   if (loadValues.size() > 0) | 
|---|
| 33 |     imageName = loadValues[0]; | 
|---|
| 34 |   if (loadValues.size() > 1) | 
|---|
| 35 |     scaling = (GLenum)MultiType(loadValues[2]).getFloat(); | 
|---|
| 36 |  | 
|---|
| 37 |   return ResourceOBJ(imageName, scaling, keepLevel); | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | Resources::tType<ResourceOBJ> ResourceOBJ::type("OBJ"); | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | ResourceOBJ::OBJResourcePointer::OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data) | 
|---|
| 49 |     : Resources::StorePointer(loadString, keepLevel) , pointer(data) | 
|---|
| 50 | {} | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|