OSDN Git Service

形状データインポート処理の整理
authorqw_fuku <fkhideaki@gmail.com>
Sun, 11 Sep 2016 12:19:58 +0000 (21:19 +0900)
committerqw_fuku <fkhideaki@gmail.com>
Sun, 11 Sep 2016 12:19:58 +0000 (21:19 +0900)
14 files changed:
Src/LibQtGeoViewerCore/Format/DaeLoader.cpp
Src/LibQtGeoViewerCore/Format/DaeLoader.h
Src/LibQtGeoViewerCore/Format/Mqo/MqoLoader.cpp
Src/LibQtGeoViewerCore/Format/Mqo/MqoLoader.h
Src/LibQtGeoViewerCore/Format/Obj/ObjLoader.cpp
Src/LibQtGeoViewerCore/Format/Obj/ObjLoader.h
Src/LibQtGeoViewerCore/Format/Ply/Plyloader.cpp
Src/LibQtGeoViewerCore/Format/Ply/Plyloader.h
Src/LibQtGeoViewerCore/Format/Pmd/PmdLoader.cpp
Src/LibQtGeoViewerCore/Format/Pmd/PmdLoader.h
Src/LibQtGeoViewerCore/Format/Stl/StlLoader.cpp
Src/LibQtGeoViewerCore/Format/Stl/StlLoader.h
Src/LibQtGeoViewerCore/Format/X/XFileLoader.cpp
Src/LibQtGeoViewerCore/Format/X/XFileLoader.h

index eb8f170..2347c2a 100644 (file)
@@ -7,10 +7,15 @@
 
 
 
-bool DaeLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* DaeLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
        AssimpReader reader(geom::GeomFileFormat::Collada);
-       geom::GeomObject* geom = reader.LoadGeom(scene, filename);
+       return reader.LoadGeom(scene, filename);
+}
+
+bool DaeLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
        if (geom == NULL)
                return false;
 
index c4b08bd..193b71a 100644 (file)
@@ -3,8 +3,18 @@
 #include "GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class DaeLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };
index 58f98be..89ac28a 100644 (file)
@@ -9,13 +9,13 @@
 
 
 
-bool MqoLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* MqoLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
        lib_geo::MqoObject mqo_obj;
        lib_geo::MqoLoader loader;
        loader.Load( mqo_obj , filename );
 
-       GeomObject* geom = scene.CreateNewGeometry();
+       GeomObject* geom = new GeomObject();
        MeshBuf* mbuf = geom->CreateNewMeshBuf();
 
        mqo_obj.ConvertToBaseMesh(mbuf->m_Mesh);
@@ -37,6 +37,17 @@ bool MqoLoader::Load(SceneMain& scene, const std::string& filename)
        geom->m_FilePath = filename;
        geom->InitializeBufferCommon();
 
+       return geom;
+}
+
+bool MqoLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
+       if (geom == NULL)
+               return false;
+
+       scene.m_Objects.push_back(geom);
+
        scene.RefreshObjectIndex();
        scene.UpdateTransform();
        scene.ReportDoneEditGeometry();
index 2eb1b01..75887e7 100644 (file)
@@ -3,8 +3,18 @@
 #include "..\GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class MqoLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };
index 0e58bb1..c68ff94 100644 (file)
 
 
 
-bool ObjLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* ObjLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
        lib_geo::ObjMesh obj_mesh;
        if (!obj_mesh.Load(filename))
-               return false;
+               return NULL;
 
-       GeomObject* geom = NULL;
+       GeomObject* geom = new GeomObject();
 
        ObjSplitMode splitMode = ObjSplitMode::None;
        if (scene.m_IOConfig.ObjSplit)
@@ -27,8 +27,6 @@ bool ObjLoader::Load(SceneMain& scene, const std::string& filename)
 
        if (splitMode == ObjSplitMode::None)
        {
-               geom = scene.CreateNewGeometry();
-
                MeshBuf* mbuf = geom->CreateNewMeshBuf();
 
                obj_mesh.ConvertToBaseMesh(mbuf->m_Mesh);
@@ -46,9 +44,7 @@ bool ObjLoader::Load(SceneMain& scene, const std::string& filename)
                std::vector<lib_geo::BaseMesh> mesh_ary;
                obj_mesh.ConvertToBaseMeshSeparated(splitMode, mesh_ary);
                if (mesh_ary.empty())
-                       return true;
-
-               geom = scene.CreateNewGeometry();
+                       return geom;
 
                for (size_t i = 0; i < mesh_ary.size(); ++i)
                {
@@ -80,6 +76,17 @@ bool ObjLoader::Load(SceneMain& scene, const std::string& filename)
 
        geom->InitializeBufferCommon();
 
+       return geom;
+}
+
+bool ObjLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
+       if (geom == NULL)
+               return false;
+
+       scene.m_Objects.push_back(geom);
+
        scene.RefreshObjectIndex();
        scene.UpdateTransform();
        scene.ReportDoneEditGeometry();
index 6b6de42..82aadc4 100644 (file)
@@ -18,6 +18,7 @@ class ObjLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 
 private:
        void InitTextureFromObjMeshBuf(SceneMain& scene, geom::MeshBuf& mbuf, const lib_geo::ObjMesh& obj_mesh);
index 60e842b..bc95878 100644 (file)
@@ -9,13 +9,13 @@
 
 
 
-bool PlyLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* PlyLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
        lib_geo::ply::PlyMesh ply_mesh;
        if (!ply_mesh.Load(filename))
-               return false;
+               return NULL;
 
-       GeomObject* geom = scene.CreateNewGeometry();
+       GeomObject* geom = new GeomObject();
        MeshBuf* mbuf = geom->CreateNewMeshBuf();
 
        lib_geo::BaseMesh& mesh_dst = mbuf->m_Mesh;
@@ -30,6 +30,17 @@ bool PlyLoader::Load(SceneMain& scene, const std::string& filename)
        geom->m_FilePath = filename;
        geom->InitializeBufferCommon();
 
+       return geom;
+}
+
+bool PlyLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
+       if (geom == NULL)
+               return false;
+
+       scene.m_Objects.push_back(geom);
+
        scene.RefreshObjectIndex();
        scene.UpdateTransform();
        scene.ReportDoneEditGeometry();
index 6fd204e..d5fc3bd 100644 (file)
@@ -3,8 +3,18 @@
 #include "..\GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class PlyLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };
index 7945395..3a98ea8 100644 (file)
 
 
 
-bool PmdLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* PmdLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
        meshio::pmd::IO pm;
        if (!pm.read(filename.c_str()))
-               return false;
+               return NULL;
 
-       GeomObject* geom = scene.CreateNewGeometry();
+       GeomObject* geom = new GeomObject();
        MeshBuf* mbuf = geom->CreateNewMeshBuf();
 
        lib_geo::BaseMesh& m = mbuf->m_Mesh;
@@ -116,6 +116,17 @@ bool PmdLoader::Load(SceneMain& scene, const std::string& filename)
        geom->m_FilePath = filename;
        geom->InitializeBufferCommon();
 
+       return geom;
+}
+
+bool PmdLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
+       if (geom == NULL)
+               return false;
+
+       scene.m_Objects.push_back(geom);
+
        scene.RefreshObjectIndex();
        scene.UpdateTransform();
        scene.ReportDoneEditGeometry();
index 1d5593d..670e9ed 100644 (file)
@@ -3,8 +3,18 @@
 #include "..\GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class PmdLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };
index b2049a6..c4eb97e 100644 (file)
@@ -9,9 +9,9 @@
 
 
 
-bool StlLoader::Load(SceneMain& scene, const std::string& filename)
+GeomObject* StlLoader::LoadGeom(SceneMain& scene, const std::string& filename)
 {
-       GeomObject* geom = scene.CreateNewGeometry();
+       GeomObject* geom = new GeomObject();
        MeshBuf* mbuf = geom->CreateNewMeshBuf();
        lib_geo::BaseMesh& mesh_dst = mbuf->m_Mesh;
 
@@ -32,6 +32,17 @@ bool StlLoader::Load(SceneMain& scene, const std::string& filename)
        geom->m_FilePath = filename;
        geom->InitializeBufferCommon();
 
+       return geom;
+}
+
+bool StlLoader::Load(SceneMain& scene, const std::string& filename)
+{
+       GeomObject* geom = LoadGeom(scene, filename);
+       if (geom == NULL)
+               return false;
+
+       scene.m_Objects.push_back(geom);
+
        scene.RefreshObjectIndex();
        scene.UpdateTransform();
        scene.ReportDoneEditGeometry();
index f00e641..e4450dd 100644 (file)
@@ -3,8 +3,18 @@
 #include "..\GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class StlLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };
index 6920c51..11bcab5 100644 (file)
@@ -7,10 +7,15 @@
 
 
 
+GeomObject* XFileLoader::LoadGeom(SceneMain& scene, const std::string& filename)
+{
+       AssimpReader reader(geom::GeomFileFormat::Collada);
+       return reader.LoadGeom(scene, filename);
+}
+
 bool XFileLoader::Load(SceneMain& scene, const std::string& filename)
 {
-       AssimpReader reader(geom::GeomFileFormat::XFile);
-       geom::GeomObject* geom = reader.LoadGeom(scene, filename);
+       GeomObject* geom = LoadGeom(scene, filename);
        if (geom == NULL)
                return false;
 
index b057af6..e577324 100644 (file)
@@ -3,8 +3,18 @@
 #include "..\GeomFileReader.h"
 
 
+
+namespace geom
+{
+
+class GeomObject;
+
+}
+
+
 class XFileLoader : public GeomFileReader
 {
 public:
        bool Load(SceneMain& scene, const std::string& filename);
+       virtual geom::GeomObject* LoadGeom(SceneMain& scene, const std::string& filename);
 };