diff --git a/code/nel/tools/3d/mesh_utils/assimp_shape.cpp b/code/nel/tools/3d/mesh_utils/assimp_shape.cpp
new file mode 100644
index 000000000..5c43c3b38
--- /dev/null
+++ b/code/nel/tools/3d/mesh_utils/assimp_shape.cpp
@@ -0,0 +1,41 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2015 Winch Gate Property Limited
+// Author: Jan Boon
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#include
+#include "assimp_shape.h"
+
+#include
+#include
+#include
+
+#define NL_NODE_INTERNAL_TYPE aiNode
+#define NL_SCENE_INTERNAL_TYPE aiScene
+#include "scene_context.h"
+
+#include
+#include
+#include
+
+using namespace std;
+using namespace NLMISC;
+
+void assimpShape(CMeshUtilsContext &context, CNodeContext &nodeContext)
+{
+
+}
+
+/* end of file */
diff --git a/code/nel/tools/3d/mesh_utils/assimp_shape.h b/code/nel/tools/3d/mesh_utils/assimp_shape.h
new file mode 100644
index 000000000..5f1c3c817
--- /dev/null
+++ b/code/nel/tools/3d/mesh_utils/assimp_shape.h
@@ -0,0 +1,25 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2015 Winch Gate Property Limited
+// Author: Jan Boon
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#include
+
+struct CMeshUtilsContext;
+struct CNodeContext;
+
+void assimpShape(CMeshUtilsContext &context, CNodeContext &nodeContext);
+
+/* end of file */
diff --git a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp
index 011ed36f6..46ad1465e 100644
--- a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp
+++ b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp
@@ -29,6 +29,11 @@
#include
#include
+#define NL_NODE_INTERNAL_TYPE aiNode
+#define NL_SCENE_INTERNAL_TYPE aiScene
+#include "scene_context.h"
+#include "assimp_shape.h"
+
CMeshUtilsSettings::CMeshUtilsSettings()
{
/*ShapeDirectory = "shape";
@@ -36,52 +41,29 @@ CMeshUtilsSettings::CMeshUtilsSettings()
SkelDirectory = "skel";*/
}
-struct CNodeContext
+void importShapes(CMeshUtilsContext &context, const aiNode *node)
{
- CNodeContext() :
- AssimpNode(NULL),
- IsBone(false)
+ if (node != context.InternalScene->mRootNode)
{
-
- }
-
- const aiNode *AssimpNode;
- bool IsBone;
-};
-
-typedef std::map TNodeContextMap;
-struct CMeshUtilsContext
-{
- CMeshUtilsContext(const CMeshUtilsSettings &settings) : Settings(settings), AssimpScene(NULL)
- {
-
- }
-
- const CMeshUtilsSettings &Settings;
-
- NLMISC::CToolLogger ToolLogger;
-
- const aiScene *AssimpScene;
- CSceneMeta SceneMeta;
-
- TNodeContextMap Nodes; // Impl note: Should never end up containing the scene root node.
- // std::map MeshNames; // Maps meshes to a node name ********************* todo ***************
-};
-
-void importNode(CMeshUtilsContext &context, const aiNode *node)
-{
- if (node->mNumMeshes)
- {
- // TODO
+ CNodeContext &nodeContext = context.Nodes[node->mName.C_Str()];
+ CNodeMeta &nodeMeta = context.SceneMeta.Nodes[node->mName.C_Str()];
+ if (nodeMeta.ExportMesh == TMeshShape)
+ {
+ if (node->mNumMeshes)
+ {
+ nldebug("Shape '%s' found containing '%u' meshes", node->mName.C_Str(), node->mNumMeshes);
+ assimpShape(context, nodeContext);
+ }
+ }
}
for (unsigned int i = 0; i < node->mNumChildren; ++i)
- importNode(context, node->mChildren[i]);
+ importShapes(context, node->mChildren[i]);
}
-void validateAssimpNodeNames(CMeshUtilsContext &context, const aiNode *node)
+void validateInternalNodeNames(CMeshUtilsContext &context, const aiNode *node)
{
- if (!node->mParent || node == context.AssimpScene->mRootNode)
+ if (!node->mParent || node == context.InternalScene->mRootNode)
{
// do nothing
}
@@ -94,25 +76,25 @@ void validateAssimpNodeNames(CMeshUtilsContext &context, const aiNode *node)
{
CNodeContext &nodeContext = context.Nodes[node->mName.C_Str()];
- if (nodeContext.AssimpNode && nodeContext.AssimpNode != node)
+ if (nodeContext.InternalNode && nodeContext.InternalNode != node)
{
tlerror(context.ToolLogger, context.Settings.SourceFilePath.c_str(),
"Node name '%s' appears multiple times", node->mName.C_Str());
}
else
{
- nodeContext.AssimpNode = node;
+ nodeContext.InternalNode = node;
}
}
for (unsigned int i = 0; i < node->mNumChildren; ++i)
- validateAssimpNodeNames(context, node->mChildren[i]);
+ validateInternalNodeNames(context, node->mChildren[i]);
}
void flagAssimpBones(CMeshUtilsContext &context)
{
// Find out which nodes are bones by checking the mesh meta info
- const aiScene *scene = context.AssimpScene;
+ const aiScene *scene = context.InternalScene;
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
{
// nldebug("FOUND MESH '%s'\n", scene->mMeshes[i]->mName.C_Str());
@@ -120,7 +102,7 @@ void flagAssimpBones(CMeshUtilsContext &context)
for (unsigned int j = 0; j < mesh->mNumBones; ++j)
{
CNodeContext &nodeContext = context.Nodes[mesh->mBones[j]->mName.C_Str()];
- if (!nodeContext.AssimpNode)
+ if (!nodeContext.InternalNode)
{
tlerror(context.ToolLogger, context.Settings.SourceFilePath.c_str(),
"Bone '%s' has no associated node", mesh->mBones[j]->mName.C_Str());
@@ -131,7 +113,7 @@ void flagAssimpBones(CMeshUtilsContext &context)
nodeContext.IsBone = true;
// Flag all parents as bones
- /*const aiNode *parent = nodeContext.AssimpNode;
+ /*const aiNode *parent = nodeContext.InternalNode;
while (parent = parent->mParent) if (parent->mName.length)
{
context.Nodes[parent->mName.C_Str()].IsBone = true;
@@ -147,7 +129,7 @@ void flagAssimpBones(CMeshUtilsContext &context)
void flagRecursiveBones(CMeshUtilsContext &context, CNodeContext &nodeContext, bool autoStop = false)
{
nodeContext.IsBone = true;
- const aiNode *node = nodeContext.AssimpNode;
+ const aiNode *node = nodeContext.InternalNode;
nlassert(node);
for (unsigned int i = 0; i < node->mNumChildren; ++i)
{
@@ -173,13 +155,13 @@ void flagMetaBones(CMeshUtilsContext &context)
void flagLocalParentBones(CMeshUtilsContext &context, CNodeContext &nodeContext)
{
- const aiNode *node = nodeContext.AssimpNode;
+ const aiNode *node = nodeContext.InternalNode;
}
void flagAllParentBones(CMeshUtilsContext &context, CNodeContext &nodeContext, bool autoStop = false)
{
- const aiNode *parent = nodeContext.AssimpNode;
- while (parent = parent->mParent) if (parent->mName.length && parent != context.AssimpScene->mRootNode)
+ const aiNode *parent = nodeContext.InternalNode;
+ while (parent = parent->mParent) if (parent->mName.length && parent != context.InternalScene->mRootNode)
{
CNodeContext &ctx = context.Nodes[parent->mName.C_Str()];
if (autoStop && ctx.IsBone)
@@ -190,8 +172,8 @@ void flagAllParentBones(CMeshUtilsContext &context, CNodeContext &nodeContext, b
bool hasIndirectParentBone(CMeshUtilsContext &context, CNodeContext &nodeContext)
{
- const aiNode *parent = nodeContext.AssimpNode;
- while (parent = parent->mParent) if (parent->mName.length && parent != context.AssimpScene->mRootNode)
+ const aiNode *parent = nodeContext.InternalNode;
+ while (parent = parent->mParent) if (parent->mName.length && parent != context.InternalScene->mRootNode)
if (context.Nodes[parent->mName.C_Str()].IsBone) return true;
return false;
}
@@ -264,11 +246,11 @@ int exportScene(const CMeshUtilsSettings &settings)
// aiProcess_ImproveCacheLocality: TODO: Verify this does not modify vertex indices
//scene->mRootNode->mMetaData
- context.AssimpScene = scene;
+ context.InternalScene = scene;
if (context.SceneMeta.load(context.Settings.SourceFilePath))
context.ToolLogger.writeDepend(NLMISC::BUILD, "*", context.SceneMeta.metaFilePath().c_str()); // Meta input file
- validateAssimpNodeNames(context, context.AssimpScene->mRootNode);
+ validateInternalNodeNames(context, context.InternalScene->mRootNode);
// -- SKEL FLAG --
flagAssimpBones(context);
@@ -283,7 +265,7 @@ int exportScene(const CMeshUtilsSettings &settings)
// ]
// -- SKEL FLAG --
- importNode(context, scene->mRootNode);
+ importShapes(context, context.InternalScene->mRootNode);
return EXIT_SUCCESS;
}
diff --git a/code/nel/tools/3d/mesh_utils/mesh_utils.h b/code/nel/tools/3d/mesh_utils/mesh_utils.h
index de6dd63fc..18be11e60 100644
--- a/code/nel/tools/3d/mesh_utils/mesh_utils.h
+++ b/code/nel/tools/3d/mesh_utils/mesh_utils.h
@@ -15,6 +15,8 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
+#ifndef NL_MESH_UTILS_H
+#define NL_MESH_UTILS_H
#include
#include
@@ -37,4 +39,6 @@ struct CMeshUtilsSettings
int exportScene(const CMeshUtilsSettings &settings);
+#endif /* NL_MESH_UTILS_H */
+
/* end of file */
diff --git a/code/nel/tools/3d/mesh_utils/scene_context.cpp b/code/nel/tools/3d/mesh_utils/scene_context.cpp
new file mode 100644
index 000000000..6812a312a
--- /dev/null
+++ b/code/nel/tools/3d/mesh_utils/scene_context.cpp
@@ -0,0 +1,30 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2015 Winch Gate Property Limited
+// Author: Jan Boon
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#include
+#include "scene_context.h"
+
+#include
+#include
+#include
+
+using namespace std;
+using namespace NLMISC;
+
+void dummy_scene_context_cpp();
+
+/* end of file */
diff --git a/code/nel/tools/3d/mesh_utils/scene_context.h b/code/nel/tools/3d/mesh_utils/scene_context.h
new file mode 100644
index 000000000..0f23f9694
--- /dev/null
+++ b/code/nel/tools/3d/mesh_utils/scene_context.h
@@ -0,0 +1,69 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2015 Winch Gate Property Limited
+// Author: Jan Boon
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef NL_SCENE_CONTEXT_H
+#define NL_SCENE_CONTEXT_H
+#include
+
+#include "mesh_utils.h"
+#include "scene_meta.h"
+
+#include
+#include
+
+#ifndef NL_NODE_INTERNAL_TYPE
+#define NL_NODE_INTERNAL_TYPE void
+#endif
+#ifndef NL_SCENE_INTERNAL_TYPE
+#define NL_SCENE_INTERNAL_TYPE void
+#endif
+
+struct CNodeContext
+{
+ CNodeContext() :
+ InternalNode(NULL),
+ IsBone(false)
+ {
+
+ }
+
+ const NL_NODE_INTERNAL_TYPE *InternalNode;
+ bool IsBone;
+};
+
+typedef std::map TNodeContextMap;
+struct CMeshUtilsContext
+{
+ CMeshUtilsContext(const CMeshUtilsSettings &settings) : Settings(settings), InternalScene(NULL)
+ {
+
+ }
+
+ const CMeshUtilsSettings &Settings;
+
+ NLMISC::CToolLogger ToolLogger;
+
+ const NL_SCENE_INTERNAL_TYPE *InternalScene;
+ CSceneMeta SceneMeta;
+
+ TNodeContextMap Nodes; // Impl note: Should never end up containing the scene root node.
+ // std::map MeshNames; // Maps meshes to a node name ********************* todo ***************
+};
+
+#endif /* NL_SCENE_CONTEXT_H */
+
+/* end of file */
diff --git a/code/nel/tools/3d/mesh_utils/scene_meta.h b/code/nel/tools/3d/mesh_utils/scene_meta.h
index 04c5660c0..98d8621f6 100644
--- a/code/nel/tools/3d/mesh_utils/scene_meta.h
+++ b/code/nel/tools/3d/mesh_utils/scene_meta.h
@@ -15,6 +15,8 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
+#ifndef NL_SCENE_META_H
+#define NL_SCENE_META_H
#include
#include
@@ -80,4 +82,6 @@ private:
};
+#endif NL_SCENE_META_H
+
/* end of file */