1 | |
---|
2 | #include "resource_oif.h" |
---|
3 | |
---|
4 | #include "substring.h" |
---|
5 | #include "multi_type.h" |
---|
6 | #include "debug.h" |
---|
7 | |
---|
8 | |
---|
9 | ResourceOIF::ResourceOIF(const std::string& modelName, const Resources::KeepLevel& keepLevel) |
---|
10 | : Resource(&ResourceOIF::type) |
---|
11 | { |
---|
12 | Resources::StorePointer* ptr = this->acquireResource(loadString(modelName)); |
---|
13 | |
---|
14 | if (ptr) |
---|
15 | { |
---|
16 | PRINTF(0)("FOUND OIF: %s\n", modelName.c_str()); |
---|
17 | //this->acquireData(static_cast<ResourceOIF::OIFResourcePointer*>(ptr)->ptr()); |
---|
18 | } |
---|
19 | else |
---|
20 | { |
---|
21 | PRINTF(0)("NOT FOUND OIF: %s\n", modelName.c_str()); |
---|
22 | // std::string modelFileName = this->Resource::locateFile(modelName); |
---|
23 | // //std::string skinFileName = this->Resource::locateFile(skinName); |
---|
24 | // this->MD2Model::load(modelFileName, skinName, scale); |
---|
25 | // this->Resource::addResource(new ResourceOIF::OIFResourcePointer(loadString(modelName, skinName, scale), keepLevel, this->MD2Model::dataPointer())); |
---|
26 | } |
---|
27 | |
---|
28 | } |
---|
29 | |
---|
30 | ResourceOIF ResourceOIF::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel) |
---|
31 | { |
---|
32 | SubString loadValues(loadString, ','); |
---|
33 | std::string modelName; |
---|
34 | std::string skinName; |
---|
35 | float scale = 1.0f; |
---|
36 | if (loadValues.size() > 0) |
---|
37 | modelName = loadValues[0]; |
---|
38 | if (loadValues.size() > 1) |
---|
39 | skinName = loadValues[1]; |
---|
40 | if (loadValues.size() > 2) |
---|
41 | scale = MultiType(loadValues[2]).getFloat(); |
---|
42 | |
---|
43 | return ResourceOIF(modelName); |
---|
44 | } |
---|
45 | |
---|
46 | std::string ResourceOIF::loadString(const std::string& modelName) |
---|
47 | { |
---|
48 | return modelName; |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | Resources::tType<ResourceOIF> ResourceOIF::type("OIF"); |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | ResourceOIF::OIFResourcePointer::OIFResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const OIFData::Pointer& data) |
---|
59 | : Resources::StorePointer(loadString, keepLevel) , pointer(data) |
---|
60 | {} |
---|
61 | |
---|
62 | |
---|