Changeset 10314 in orxonox.OLD for trunk/src/lib/graphics/importer/oif
- Timestamp:
- Jan 24, 2007, 12:45:39 AM (18 years ago)
- Location:
- trunk/src/lib/graphics/importer/oif
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/oif/object_information_file.cc
r10147 r10314 24 24 25 25 26 27 /** 28 * constructor 29 */ 30 OIFData::OIFData() 31 { 32 this->_root = NULL; 33 } 34 35 26 36 /** 27 37 * constructor … … 30 40 OIFData::OIFData(const std::string& fileName) 31 41 { 42 this->_root = NULL; 32 43 this->load(fileName); 44 } 45 46 47 OIFData::~OIFData() 48 { 49 if( this->_root) 50 delete this->_root; 33 51 } 34 52 … … 40 58 void OIFData::load(const std::string& fileName) 41 59 { 42 // 43 if( fileName.empty()) 60 if( fileName.empty()) 44 61 { 45 PRINTF( 3)("No filename specified for object information loading");62 PRINTF(1)("No filename specified for object information loading"); 46 63 return; 47 64 } 48 65 49 TiXmlDocument XMLDoc(fileName);66 TiXmlDocument* XMLDoc = new TiXmlDocument(fileName); 50 67 // load the campaign document 51 if( !XMLDoc .LoadFile(fileName))68 if( !XMLDoc->LoadFile(fileName)) 52 69 { 53 70 // report an error 54 PRINTF( 3)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());71 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 55 72 return; 56 73 } 57 74 58 75 // check basic validity 59 TiXmlElement* root = XMLDoc.RootElement();60 assert( root != NULL);76 this->_root = XMLDoc->RootElement(); 77 assert( this->_root != NULL); 61 78 62 if( strcmp( root->Value(), "ObjectInformationFile"))79 if( strcmp( this->_root->Value(), "ObjectInformationFile")) 63 80 { 64 81 // report an error 65 PRINTF( 2)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n");82 PRINTF(1)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n"); 66 83 return; 67 84 } 68 85 69 // construct campaign 70 // return new Campaign( root); 86 // this->initMountPoint( this->_root); 71 87 } 72 88 73 89 74 75 90 /** 76 * standard constructor 91 * constructor 92 * @param fileName name of the file 77 93 */ 78 94 ObjectInformationFile::ObjectInformationFile() 95 : data(new OIFData) 79 96 { 80 97 this->init(); … … 107 124 108 125 /** 126 * the definition of the assignment operator 127 * @param oif 128 * @return 129 */ 130 ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif) 131 { 132 this->init(); 133 this->data = oif.data; 134 135 return *this; 136 } 137 138 /** 109 139 * initizlizing function 110 140 */ … … 112 142 { 113 143 144 } 145 146 147 void ObjectInformationFile::load(const std::string& fileName) 148 { 149 this->data = OIFData::Pointer(new OIFData(fileName)); 114 150 } 115 151 … … 124 160 125 161 162 /** 163 * this initializes the mount point 164 * @param mountPoint to be initialized 165 */ 166 // void ObjectInformationFile::initMountPoint(MountPoint* mountPoint) 167 // { 168 // TiXmlElement* root = this->data->root(); 169 // 170 // } 126 171 127 ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif)128 {129 this->data = oif.data;130 return *this;131 }132 133 134 -
trunk/src/lib/graphics/importer/oif/object_information_file.h
r10147 r10314 20 20 21 21 public: 22 OIFData(); 22 23 OIFData(const std::string& fileName); 23 virtual ~OIFData() {}24 virtual ~OIFData(); 24 25 25 26 void load(const std::string& fileName); 27 void initMountPoint(const TiXmlElement* root); 28 29 inline const TiXmlElement* root() { return this->_root; } 26 30 27 31 28 32 private: 29 33 TiXmlElement* _root; //!< root of the xml file 30 34 }; 31 35 … … 40 44 virtual ~ObjectInformationFile(); 41 45 46 void load(const std::string& fileName); 47 42 48 ObjectInformationFile& operator=(const ObjectInformationFile& oif); 49 50 /** @returns a reference to the xml oif file */ 51 inline const TiXmlElement* getMountPointDescription() { return this->data->root(); } 52 53 inline void acquireData(const OIFData::Pointer& data) { this->data = data; } 54 const OIFData::Pointer& dataPointer() const { return this->data; }; 55 56 43 57 44 58 private: -
trunk/src/lib/graphics/importer/oif/resource_oif.cc
r10147 r10314 26 26 Resources::StorePointer* ptr = this->acquireResource(fileName); 27 27 28 28 29 if (ptr) 29 30 { 30 PRINTF( 0)("FOUND OIF: %s\n", fileName.c_str());31 //this->acquireData(static_cast<ResourceOIF::OIFResourcePointer*>(ptr)->ptr());31 PRINTF(5)("FOUND OIF: %s\n", fileName.c_str()); 32 this->acquireData(static_cast<ResourceOIF::OIFResourcePointer*>(ptr)->ptr()); 32 33 } 33 34 else 34 35 { 35 PRINTF( 4)("NOT FOUND OIF: %s\n", fileName.c_str());36 // std::string modelFileName = this->Resource::locateFile(modelName);37 // //std::string skinFileName = this->Resource::locateFile(skinName);38 // this->MD2Model::load(modelFileName, skinName, scale);39 // this->Resource::addResource(new ResourceOIF::OIFResourcePointer(loadString(modelName, skinName, scale), keepLevel, this->MD2Model::dataPointer()));36 PRINTF(5)("NOT FOUND OIF: %s\n", fileName.c_str()); 37 std::string fullName = this->Resource::locateFile(fileName); 38 PRINTF(5)("trying loading of: %s\n", fullName.c_str()); 39 this->load(fullName); 40 this->Resource::addResource(new ResourceOIF::OIFResourcePointer(fileName, keepLevel, this->ObjectInformationFile::dataPointer())); 40 41 } 41 42 -
trunk/src/lib/graphics/importer/oif/resource_oif.h
r10147 r10314 15 15 { 16 16 public: 17 ResourceOIF(const std::string& fileName, const Resources::KeepLevel& keepLevel = Resources::KeepLevel()); 17 ResourceOIF(const std::string& fileName, 18 const Resources::KeepLevel& keepLevel = Resources::KeepLevel()); 18 19 static ResourceOIF createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel = Resources::KeepLevel()); 19 20
Note: See TracChangeset
for help on using the changeset viewer.