Merge branch 'master' into assimp_resource
commit
9e4fc9a40c
|
@ -106,7 +106,7 @@ bool getNodeAttribute(const XmlNode &node, const std::string &attribute, int &va
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMatrix4x4 parseTransformMatrix(std::string matrixStr) {
|
aiMatrix4x4 parseTransformMatrix(const std::string& matrixStr) {
|
||||||
// split the string
|
// split the string
|
||||||
std::vector<float> numbers;
|
std::vector<float> numbers;
|
||||||
std::string currentNumber;
|
std::string currentNumber;
|
||||||
|
|
|
@ -281,7 +281,7 @@ void BlenderImporter::ExtractScene(Scene &out, const FileDatabase &file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BlenderImporter::ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Collection> collection, ConversionData &conv_data) {
|
void BlenderImporter::ParseSubCollection(const Blender::Scene &in, aiNode *root, const std::shared_ptr<Collection>& collection, ConversionData &conv_data) {
|
||||||
|
|
||||||
std::deque<Object *> root_objects;
|
std::deque<Object *> root_objects;
|
||||||
// Count number of objects
|
// Count number of objects
|
||||||
|
|
|
@ -117,7 +117,7 @@ protected:
|
||||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||||
void ParseBlendFile(Blender::FileDatabase &out, std::shared_ptr<IOStream> stream);
|
void ParseBlendFile(Blender::FileDatabase &out, std::shared_ptr<IOStream> stream);
|
||||||
void ExtractScene(Blender::Scene &out, const Blender::FileDatabase &file);
|
void ExtractScene(Blender::Scene &out, const Blender::FileDatabase &file);
|
||||||
void ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Blender::Collection> collection, Blender::ConversionData &conv_data);
|
void ParseSubCollection(const Blender::Scene &in, aiNode *root, const std::shared_ptr<Blender::Collection>& collection, Blender::ConversionData &conv_data);
|
||||||
void ConvertBlendFile(aiScene *out, const Blender::Scene &in, const Blender::FileDatabase &file);
|
void ConvertBlendFile(aiScene *out, const Blender::Scene &in, const Blender::FileDatabase &file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1428,7 +1428,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<IfcVector2> GetContourInPlane2D(std::shared_ptr<TempMesh> mesh,IfcMatrix3 planeSpace,
|
std::vector<IfcVector2> GetContourInPlane2D(const std::shared_ptr<TempMesh>& mesh,IfcMatrix3 planeSpace,
|
||||||
IfcVector3 planeNor,IfcFloat planeOffset,
|
IfcVector3 planeNor,IfcFloat planeOffset,
|
||||||
IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first,bool& ok) {
|
IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first,bool& ok) {
|
||||||
std::vector<IfcVector2> contour;
|
std::vector<IfcVector2> contour;
|
||||||
|
@ -1491,7 +1491,7 @@ static void logSegment(std::pair<IfcVector2,IfcVector2> segment) {
|
||||||
IFCImporter::LogInfo(msg2.str().c_str());
|
IFCImporter::LogInfo(msg2.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<IfcVector2>> GetContoursInPlane3D(std::shared_ptr<TempMesh> mesh,IfcMatrix3 planeSpace,
|
std::vector<std::vector<IfcVector2>> GetContoursInPlane3D(const std::shared_ptr<TempMesh>& mesh,IfcMatrix3 planeSpace,
|
||||||
IfcFloat planeOffset) {
|
IfcFloat planeOffset) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1676,7 +1676,7 @@ std::vector<std::vector<IfcVector2>> GetContoursInPlane3D(std::shared_ptr<TempMe
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << "GetContoursInPlane3D: found " << contours.size() << " contours:\n";
|
msg << "GetContoursInPlane3D: found " << contours.size() << " contours:\n";
|
||||||
|
|
||||||
for(auto c : contours) {
|
for(const auto& c : contours) {
|
||||||
msg << " Contour: \n";
|
msg << " Contour: \n";
|
||||||
for(auto p : c) {
|
for(auto p : c) {
|
||||||
msg << " " << p.x << " " << p.y << " \n";
|
msg << " " << p.x << " " << p.y << " \n";
|
||||||
|
@ -1690,7 +1690,7 @@ std::vector<std::vector<IfcVector2>> GetContoursInPlane3D(std::shared_ptr<TempMe
|
||||||
return contours;
|
return contours;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<IfcVector2>> GetContoursInPlane(std::shared_ptr<TempMesh> mesh,IfcMatrix3 planeSpace,
|
std::vector<std::vector<IfcVector2>> GetContoursInPlane(const std::shared_ptr<TempMesh>& mesh,IfcMatrix3 planeSpace,
|
||||||
IfcVector3 planeNor,IfcFloat planeOffset,
|
IfcVector3 planeNor,IfcFloat planeOffset,
|
||||||
IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first) {
|
IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first) {
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
static const aiImporterDesc desc = { "MMD Importer",
|
static const aiImporterDesc desc = { "MMD Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -102,26 +103,32 @@ const aiImporterDesc *MMDImporter::GetInfo() const {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// MMD import implementation
|
// MMD import implementation
|
||||||
void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene,
|
void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene,
|
||||||
IOSystem * /*pIOHandler*/) {
|
IOSystem* pIOHandler) {
|
||||||
// Read file by istream
|
|
||||||
std::filebuf fb;
|
auto streamCloser = [&](IOStream *pStream) {
|
||||||
if (!fb.open(file, std::ios::in | std::ios::binary)) {
|
pIOHandler->Close(pStream);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string mode = "rb";
|
||||||
|
const std::unique_ptr<IOStream, decltype(streamCloser)> fileStream(pIOHandler->Open(file, mode), streamCloser);
|
||||||
|
|
||||||
|
if (fileStream == nullptr) {
|
||||||
throw DeadlyImportError("Failed to open file ", file, ".");
|
throw DeadlyImportError("Failed to open file ", file, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istream fileStream(&fb);
|
const size_t fileSize = fileStream->FileSize();
|
||||||
|
if (fileSize < sizeof(pmx::PmxModel))
|
||||||
// Get the file-size and validate it, throwing an exception when fails
|
{
|
||||||
fileStream.seekg(0, fileStream.end);
|
|
||||||
size_t fileSize = static_cast<size_t>(fileStream.tellg());
|
|
||||||
fileStream.seekg(0, fileStream.beg);
|
|
||||||
|
|
||||||
if (fileSize < sizeof(pmx::PmxModel)) {
|
|
||||||
throw DeadlyImportError(file, " is too small.");
|
throw DeadlyImportError(file, " is too small.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<char> contents(fileStream->FileSize());
|
||||||
|
fileStream->Read(contents.data(), 1, contents.size());
|
||||||
|
|
||||||
|
std::istringstream iss(std::string(contents.begin(), contents.end()));
|
||||||
|
|
||||||
pmx::PmxModel model;
|
pmx::PmxModel model;
|
||||||
model.Read(&fileStream);
|
model.Read(&iss);
|
||||||
|
|
||||||
CreateDataFromImport(&model, pScene);
|
CreateDataFromImport(&model, pScene);
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@ void X3DImporter::readHead(XmlNode &node) {
|
||||||
}
|
}
|
||||||
mScene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(metaArray.size()));
|
mScene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(metaArray.size()));
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (auto currentMeta : metaArray) {
|
for (const auto& currentMeta : metaArray) {
|
||||||
mScene->mMetaData->Set(i, currentMeta.name, aiString(currentMeta.value));
|
mScene->mMetaData->Set(i, currentMeta.name, aiString(currentMeta.value));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "AssetLib/MMD/MMDImporter.h"
|
#include "AssetLib/MMD/MMDImporter.h"
|
||||||
|
#include "assimp/postprocess.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
@ -51,9 +52,8 @@ class utPMXImporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
/*const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/../models-nonbsd/MMD/Alicia_blade.pmx", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/../models-nonbsd/MMD/Alicia_blade.pmx", aiProcess_ValidateDataStructure );
|
||||||
return nullptr != scene;*/
|
return nullptr != scene;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue