parent
3086569e36
commit
646d0d29a4
|
@ -219,6 +219,12 @@ SET( Irr_SRCS
|
|||
)
|
||||
SOURCE_GROUP( Irr FILES ${Irr_SRCS})
|
||||
|
||||
SET( LDR_SRCS
|
||||
LDrawImporter.cpp
|
||||
LDrawImporter.h
|
||||
)
|
||||
SOURCE_GROUP( LDR FILES ${LDR_SRCS})
|
||||
|
||||
SET( LWO_SRCS
|
||||
LWOAnimation.cpp
|
||||
LWOAnimation.h
|
||||
|
@ -637,6 +643,7 @@ SET( assimp_src
|
|||
${CSM_SRCS}
|
||||
${HMP_SRCS}
|
||||
${Irr_SRCS}
|
||||
${LDR_SRCS}
|
||||
${LWO_SRCS}
|
||||
${LWS_SRCS}
|
||||
${MD2_SRCS}
|
||||
|
|
|
@ -166,6 +166,9 @@ corresponding preprocessor flag to selectively disable formats.
|
|||
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
# include "FBXImporter.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_LDR_IMPORTER
|
||||
# include "LDrawImporter.h"
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
@ -291,6 +294,9 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
|
|||
#if ( !defined ASSIMP_BUILD_NO_FBX_IMPORTER )
|
||||
out.push_back( new FBXImporter() );
|
||||
#endif
|
||||
#if ( !defined ASSIMP_BUILD_NO_LDR_IMPORTER )
|
||||
out.push_back( new LDrawImporter() );
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
/** @file LDrawImporter.cpp
|
||||
* @brief Implementation of the LDraw importer.
|
||||
*/
|
||||
#ifndef ASSIMP_BUILD_NO_LDR_IMPORTER
|
||||
#include "LDrawImporter.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
"LDraw Importer",
|
||||
"Tobias 'diiigle' Rittig",
|
||||
"",
|
||||
"ignoring Linetype 5 'optional lines'",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"ldr dat mpd"
|
||||
};
|
||||
|
||||
LDrawImporter::LDrawImporter()
|
||||
{
|
||||
}
|
||||
|
||||
LDrawImporter::~LDrawImporter()
|
||||
{
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool LDrawImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler,
|
||||
bool checkSig) const
|
||||
{
|
||||
const std::string extension = GetExtension(pFile);
|
||||
if (extension == "ldr" || extension == "dat" || extension == "mpd") {
|
||||
return true;
|
||||
}
|
||||
if (!extension.length() || checkSig) {
|
||||
const char* tokens[] = { "0 !LDRAW_ORG", "0 !LICENSE" };
|
||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// -------------------------------------------------------------------------------
|
||||
const aiImporterDesc* LDrawImporter::GetInfo() const {
|
||||
return &desc;
|
||||
}
|
||||
// -------------------------------------------------------------------------------
|
||||
void LDrawImporter::InternReadFile(const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
boost::scoped_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
||||
// Check whether we can read from the file
|
||||
if (file.get() == NULL) {
|
||||
throw DeadlyImportError("Failed to open LDraw file " + pFile + ".");
|
||||
}
|
||||
|
||||
// Your task: fill pScene
|
||||
// Throw a ImportErrorException with a meaningful (!) error message if
|
||||
// something goes wrong.
|
||||
std::vector<char> buffer;
|
||||
TextFileToBuffer(file.get(), buffer);
|
||||
}
|
||||
|
||||
#endif // !ASSIMP_BUILD_NO_LDR_IMPORTER
|
|
@ -0,0 +1,37 @@
|
|||
/** @file LDrawImporter.h
|
||||
* @brief Declaration of the LDraw importer class
|
||||
*/
|
||||
#ifndef INCLUDED_AI_LDR_IMPORTER_H
|
||||
#define INCLUDED_AI_LDR_IMPORTER_H
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
namespace Assimp{
|
||||
|
||||
class LDrawImporter : public BaseImporter
|
||||
{
|
||||
public:
|
||||
LDrawImporter();
|
||||
~LDrawImporter();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
bool CanRead(const std::string& pFile, IOSystem* pIOHandler,
|
||||
bool checkSig) const;
|
||||
|
||||
protected:
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
const aiImporterDesc* GetInfo() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
void InternReadFile(const std::string& pFile, aiScene* pScene,
|
||||
IOSystem* pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
}; //end of class LDrawImporter
|
||||
|
||||
} // end of namespace Assimp
|
||||
#endif // !INCLUDED_AI_LDR_IMPORTER_H
|
Loading…
Reference in New Issue