3
#include <osgDB/Registry>
4
#include <osgDB/FileUtils>
5
#include <osgDB/ReadFile>
7
#include "ReaderWriterMDL.h"
12
using namespace osgDB;
15
const char* ReaderWriterMDL::className() const
17
// Return a description of this class
18
return "Valve/Source Engine MDL Reader";
22
bool ReaderWriterMDL::acceptsExtension(const std::string& extension) const
24
// If the extension is empty or "mdl", we accept it
25
return osgDB::equalCaseInsensitive(extension, "mdl") || extension.empty();
29
ReaderWriter::ReadResult ReaderWriterMDL::readNode(
30
const std::string& file,
31
const ReaderWriter::Options* options) const
33
MDLReader * mdlReader;
36
// See if we handle this kind of file
37
if (!acceptsExtension(osgDB::getFileExtension(file)))
38
return ReadResult::FILE_NOT_HANDLED;
40
// See if we can find the requested file
41
std::string fileName = osgDB::findDataFile(file, options, CASE_INSENSITIVE);
43
return ReadResult::FILE_NOT_FOUND;
45
// Read the file (pass the base name and not the file that was found, this
46
// allows us to also find the .vvd and .vtx files without the leading
47
// path confusing things)
48
mdlReader = new MDLReader();
49
if (mdlReader->readFile(file))
51
// Get the results of our read
52
result = mdlReader->getRootNode();
54
// Clean up the reader
58
return ReadResult(result.get());
62
// Clean up the reader
66
return ReadResult::ERROR_IN_READING_FILE;
71
REGISTER_OSGPLUGIN(mdl, ReaderWriterMDL)