Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9904 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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(0)("FOUND MD2: %s\n", modelName.c_str());
16    this->acquireData(static_cast<ResourceMD2::MD2ResourcePointer*>(ptr)->ptr());
17  }
18  else
19  {
20    PRINTF(0)("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    this->MD2Model::load(modelFileName, skinName, scale);
24    this->Resource::addResource(new ResourceMD2::MD2ResourcePointer(loadString(modelName, skinName, scale), keepLevel, this->MD2Model::dataPointer()));
25  }
26
27}
28
29ResourceMD2 ResourceMD2::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
30{
31  SubString loadValues(loadString, ',');
32  std::string modelName;
33  std::string skinName;
34  float scale = 1.0f;
35  if (loadValues.size() > 0)
36    modelName = loadValues[0];
37  if (loadValues.size() > 1)
38    skinName = loadValues[1];
39  if (loadValues.size() > 2)
40    scale = MultiType(loadValues[2]).getFloat();
41
42  return ResourceMD2(modelName, skinName, scale, keepLevel);
43}
44
45std::string ResourceMD2::loadString(const std::string& modelName, const std::string& skinName, float scale)
46{
47  return modelName + ',' + skinName + ',' + MultiType(scale).getString();
48}
49
50
51Resources::tType<ResourceMD2> ResourceMD2::type("MD2");
52
53
54
55
56
57ResourceMD2::MD2ResourcePointer::MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data)
58    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
59{}
60
61
Note: See TracBrowser for help on using the repository browser.