Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/resource_obj.cc @ 10146

Last change on this file since 10146 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.5 KB
Line 
1
2#include "resource_obj.h"
3#include "substring.h"
4#include "multi_type.h"
5#include "debug.h"
6
7
8ResourceOBJ::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
27ResourceOBJ 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
42Resources::tType<ResourceOBJ> ResourceOBJ::type("OBJ");
43
44
45
46
47
48ResourceOBJ::OBJResourcePointer::OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data)
49    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
50{}
51
52
Note: See TracBrowser for help on using the repository browser.