Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/md2/resource_md2.cc @ 10727

Last change on this file since 10727 was 10488, checked in by patrick, 18 years ago

less md2 debug pls

File size: 1.9 KB
Line 
1
2#include "resource_md2.h"
3#include "substring.h"
4#include "multi_type.h"
5#include "debug.h"
6
7
8ResourceMD2::ResourceMD2(const std::string& modelName, const std::string& skinName, float scale, const Resources::KeepLevel& keepLevel)
9    : Resource(&ResourceMD2::type)
10{
11  Resources::StorePointer* ptr = this->acquireResource(loadString(modelName, skinName, scale));
12
13  if (ptr)
14  {
15    PRINTF(4)("FOUND MD2: %s\n", modelName.c_str());
16    this->acquireData(static_cast<ResourceMD2::MD2ResourcePointer*>(ptr)->ptr());
17  }
18  else
19  {
20    PRINTF(4)("NOT FOUND MD2: %s\n", modelName.c_str());
21    std::string modelFileName = this->Resource::locateFile(modelName);
22    std::string skinFileName = this->Resource::locateFile(skinName);
23    PRINTF(4)("NEW %s::%s\n", modelName.c_str(), modelFileName.c_str());
24    this->MD2Model::load(modelFileName, skinName, scale);
25    this->Resource::addResource(new ResourceMD2::MD2ResourcePointer(loadString(modelName, skinFileName, scale), keepLevel, this->MD2Model::dataPointer()));
26  }
27
28}
29
30ResourceMD2 ResourceMD2::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 ResourceMD2(modelName, skinName, scale, keepLevel);
44}
45
46std::string ResourceMD2::loadString(const std::string& modelName, const std::string& skinName, float scale)
47{
48  return modelName + ',' + skinName + ',' + MultiType(scale).getString();
49}
50
51
52Resources::tType<ResourceMD2> ResourceMD2::type("MD2");
53
54
55
56
57
58ResourceMD2::MD2ResourcePointer::MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data)
59    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
60{}
61
62
Note: See TracBrowser for help on using the repository browser.