diff --git a/AssimpToMesh/AssimpToMesh.vcxproj b/AssimpToMesh/AssimpToMesh.vcxproj
index 57898ad..46477b8 100644
--- a/AssimpToMesh/AssimpToMesh.vcxproj
+++ b/AssimpToMesh/AssimpToMesh.vcxproj
@@ -84,11 +84,13 @@
+
+
diff --git a/AssimpToMesh/AssimpToMesh.vcxproj.filters b/AssimpToMesh/AssimpToMesh.vcxproj.filters
index 1c0b7da..9a185ee 100644
--- a/AssimpToMesh/AssimpToMesh.vcxproj.filters
+++ b/AssimpToMesh/AssimpToMesh.vcxproj.filters
@@ -30,6 +30,9 @@
Source Files
+
+ Source Files
+
@@ -41,5 +44,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/AssimpToMesh/src/main.cpp b/AssimpToMesh/src/main.cpp
index fa64915..e594988 100644
--- a/AssimpToMesh/src/main.cpp
+++ b/AssimpToMesh/src/main.cpp
@@ -9,6 +9,7 @@
#include "utils/utils.h"
#include "assimputils/utils.h"
#include "convert/convert.h"
+#include "nodetree/nodetree.h"
int main(int argc, char *argv[])
{
@@ -16,22 +17,23 @@ int main(int argc, char *argv[])
if (argc == 1)
{
- printf("Usage: assimptomesh.exe [inputfile]\n\n");
+ printf("Usage: assimptomesh.exe [--showinfo] inputfile\n\n");
return 0;
}
- std::string file = argv[1];
- std::string outputFile = GetMeshFilenameFromInput(file);
+ // input file is always the last argument
+ std::string file = argv[argc - 1];
+ bool showInfo = false;
- if (outputFile.length() == 0)
+ // find any options
+ for (int i = 1; i < argc - 1; ++i)
{
- printf("Unable to determine output mesh filename from the input file name.\n\n");
- return 1;
+ if (strcmp(argv[i], "--showinfo") == 0)
+ showInfo = true;
}
+ // attempt to load the input file
printf("Input file: %s\n", file.c_str());
- printf("Output file: %s\n", outputFile.c_str());
-
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(file,
aiProcess_JoinIdenticalVertices |
@@ -47,9 +49,22 @@ int main(int argc, char *argv[])
printf("Failed to load input file: %s\n\n", importer.GetErrorString());
return 1;
}
-
printf("Scene loaded.\n");
+ // input file loaded, now get the output filename
+ std::string outputFile = GetMeshFilenameFromInput(file);
+ if (outputFile.length() == 0)
+ {
+ printf("Unable to determine output mesh filename from the input file name.\n\n");
+ return 1;
+ }
+ printf("Output file: %s\n", outputFile.c_str());
+
+ // optionally show info about the entire scene before doing the conversion
+ if (showInfo)
+ Walk(scene);
+
+ // attempt conversion using an appropriate converter based on what kind of scene it is
if (IsSceneStatic(scene))
{
printf("Using static converter.\n");
diff --git a/AssimpToMesh/src/nodetree/nodetree.cpp b/AssimpToMesh/src/nodetree/nodetree.cpp
new file mode 100644
index 0000000..dd3d4c1
--- /dev/null
+++ b/AssimpToMesh/src/nodetree/nodetree.cpp
@@ -0,0 +1,213 @@
+#include "nodetree.h"
+
+#include
+
+void WalkNode(const aiNode *node);
+void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene);
+void ShowMaterialInfo(const aiMaterial *material);
+void ShowAnimationInfo(const aiAnimation *animation);
+
+unsigned int g_level;
+
+std::string GetIndentString()
+{
+ std::string indent;
+ for (unsigned int i = 0; i < g_level; ++i)
+ indent += " ";
+ return indent;
+}
+
+void Walk(const aiScene *scene)
+{
+ g_level = 0;
+
+ printf("\n*** GENERAL SCENE INFO ***\n\n");
+ printf("HasAnimations: %s\n", scene->HasAnimations() ? "yes" : "no");
+ printf("HasMaterials: %s\n", scene->HasMaterials() ? "yes" : "no");
+ printf("HasMeshes: %s\n", scene->HasMeshes() ? "yes" : "no");
+ printf("mNumAnimations: %d\n", scene->mNumAnimations);
+ printf("mNumMaterials: %d\n", scene->mNumMaterials);
+ printf("mNumMeshes: %d\n", scene->mNumMeshes);
+ printf("\n");
+
+ if (scene->mNumMaterials > 0)
+ {
+ printf("\n*** MATERIALS ***\n\n");
+
+ for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
+ {
+ printf("[%d]:\n", i);
+ ShowMaterialInfo(scene->mMaterials[i]);
+ }
+ }
+
+ printf("\n*** MESHES ***\n\n");
+
+ for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
+ {
+ printf("[%d]\n", i);
+ ShowMeshInfo(scene->mMeshes[i], scene);
+ }
+
+ printf("\n*** NODES ***\n");
+ WalkNode(scene->mRootNode);
+
+ if (scene->mNumAnimations > 0)
+ {
+ printf("\n*** ANIMATIONS ***\n\n");
+
+ for (unsigned int i = 0; i < scene->mNumAnimations; ++i)
+ {
+ printf("[%d]:\n", i);
+ ShowAnimationInfo(scene->mAnimations[i]);
+ }
+ }
+
+ printf("\n");
+}
+
+void WalkNode(const aiNode *node)
+{
+ ++g_level;
+ printf("\n");
+
+ std::string indent = GetIndentString();
+
+ aiQuaternion rotation;
+ aiVector3D scaling;
+ aiVector3D position;
+ node->mTransformation.Decompose(scaling, rotation, position);
+
+ printf("%sName: %s\n", indent.c_str(), node->mName.data);
+ printf("%smNumChildren: %d\n", indent.c_str(), node->mNumChildren);
+ printf("%smNumMeshes: %d", indent.c_str(), node->mNumMeshes);
+ if (node->mNumMeshes > 0)
+ {
+ printf(" [");
+ for (unsigned int i = 0; i < node->mNumMeshes; ++i)
+ {
+ if (i > 0)
+ printf(", ");
+ printf("%d", node->mMeshes[i]);
+ }
+ printf("]");
+ }
+ printf("\n");
+ printf("%sRotation: %f, %f, %f, %f\n", indent.c_str(), rotation.x, rotation.y, rotation.z, rotation.w);
+ printf("%sScaling: %f, %f, %f\n", indent.c_str(), scaling.x, scaling.y, scaling.z);
+ printf("%sPosition: %f, %f, %f\n", indent.c_str(), position.x, position.y, position.z);
+
+ for (unsigned int i = 0; i < node->mNumChildren; ++i)
+ WalkNode(node->mChildren[i]);
+
+ --g_level;
+}
+
+void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene)
+{
+ printf(" Name: %s\n", mesh->mName.data);
+ printf(" HasBones: %s\n", mesh->HasBones() ? "yes" : "no");
+ printf(" HasFaces: %s\n", mesh->HasFaces() ? "yes" : "no");
+ printf(" HasNormals: %s\n", mesh->HasNormals() ? "yes" : "no");
+ printf(" HasPositions: %s\n", mesh->HasPositions() ? "yes" : "no");
+ printf(" HasTangentsAndBitangents: %s\n", mesh->HasTangentsAndBitangents() ? "yes" : "no");
+ printf(" HasTextureCoords: %s, %s, %s, %s\n",
+ (mesh->HasTextureCoords(0) ? "yes" : "no"),
+ (mesh->HasTextureCoords(1) ? "yes" : "no"),
+ (mesh->HasTextureCoords(2) ? "yes" : "no"),
+ (mesh->HasTextureCoords(3) ? "yes" : "no")
+ );
+ printf(" HasVertexColors: %s, %s, %s, %s\n",
+ (mesh->HasVertexColors(0) ? "yes" : "no"),
+ (mesh->HasVertexColors(1) ? "yes" : "no"),
+ (mesh->HasVertexColors(2) ? "yes" : "no"),
+ (mesh->HasVertexColors(3) ? "yes" : "no")
+ );
+ printf(" mMaterialIndex: %d\n", mesh->mMaterialIndex);
+ printf(" mNumFaces: %d\n", mesh->mNumFaces);
+ printf(" mPrimitiveTypes: %d - (All Triangles? %s)\n", mesh->mPrimitiveTypes, mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE ? "yes" : "no");
+ printf(" mNumVertices: %d\n", mesh->mNumVertices);
+ printf(" mNumUVComponents: %d, %d, %d, %d\n", mesh->mNumUVComponents[0], mesh->mNumUVComponents[1], mesh->mNumUVComponents[2], mesh->mNumUVComponents[3]);
+ printf(" mNumBones: %d\n", mesh->mNumBones);
+ printf(" mNumAnimMeshes: %d\n", mesh->mNumAnimMeshes);
+ for (unsigned int i = 0; i < mesh->mNumBones; ++i)
+ {
+ aiBone *bone = mesh->mBones[i];
+
+ aiQuaternion rotation;
+ aiVector3D scaling;
+ aiVector3D position;
+ bone->mOffsetMatrix.Decompose(scaling, rotation, position);
+
+ aiString parentName = "[null]";
+ aiNode *boneNode = scene->mRootNode->FindNode(bone->mName);
+ if (boneNode != NULL)
+ {
+ aiNode *parent = boneNode->mParent;
+ if (parent != NULL)
+ parentName = parent->mName;
+ }
+
+ printf(" [%d]\n", i);
+ printf(" Name: %s\n", bone->mName.data);
+ printf(" Parent Name: %s\n", parentName.data);
+ printf(" mNumWeights: %d\n", bone->mNumWeights);
+ printf(" Rotation: %f, %f, %f, %f\n", rotation.x, rotation.y, rotation.z, rotation.w);
+ printf(" Scaling: %f, %f, %f\n", scaling.x, scaling.y, scaling.z);
+ printf(" Position: %f, %f, %f\n", position.x, position.y, position.z);
+ }
+}
+
+void ShowMaterialInfo(const aiMaterial *material)
+{
+ aiString name;
+ aiColor3D ambient;
+ aiColor3D diffuse;
+ aiColor3D specular;
+ aiColor3D emissive;
+ float shininess;
+ float opacity;
+
+ material->Get(AI_MATKEY_NAME, name);
+ material->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
+ material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
+ material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
+ material->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
+ material->Get(AI_MATKEY_SHININESS, shininess);
+ material->Get(AI_MATKEY_OPACITY, opacity);
+
+ printf(" Name: %s\n", name.data);
+ printf(" Ambient: %f, %f, %f\n", ambient.r, ambient.g, ambient.b);
+ printf(" Diffuse: %f, %f, %f\n", diffuse.r, diffuse.g, diffuse.b);
+ printf(" Specular: %f, %f, %f\n", specular.r, specular.g, specular.b);
+ printf(" Emissive: %f, %f, %f\n", emissive.r, emissive.g, emissive.b);
+ printf(" Shininess: %f\n", shininess);
+ printf(" Opacity: %f\n", opacity);
+}
+
+void ShowAnimationInfo(const aiAnimation *animation)
+{
+ printf(" Name: %s\n", animation->mName.data);
+ printf(" mDuration: %f\n", animation->mDuration);
+ printf(" mTicksPerSecond: %f\n", animation->mTicksPerSecond);
+ printf(" mNumChannels: %d\n", animation->mNumChannels);
+ for (unsigned int i = 0; i < animation->mNumChannels; ++i)
+ {
+ aiNodeAnim *channel = animation->mChannels[i];
+
+ printf(" [%d]:\n", i);
+ printf(" Name: %s\n", channel->mNodeName.data);
+ printf(" mNumPositionKeys: %d\n", channel->mNumPositionKeys);
+ printf(" mNumRotationKeys: %d\n", channel->mNumRotationKeys);
+ printf(" mNumScalingKeys: %d\n", channel->mNumScalingKeys);
+ }
+ printf(" mNumMeshChannels: %d\n", animation->mNumMeshChannels);
+ for (unsigned int i = 0; i < animation->mNumMeshChannels; ++i)
+ {
+ aiMeshAnim *channel = animation->mMeshChannels[i];
+
+ printf(" [%d]:\n", i);
+ printf(" Name: %s\n", channel->mName.data);
+ printf(" mNumKeys: %d\n", channel->mNumKeys);
+ }
+}
diff --git a/AssimpToMesh/src/nodetree/nodetree.h b/AssimpToMesh/src/nodetree/nodetree.h
new file mode 100644
index 0000000..70298b5
--- /dev/null
+++ b/AssimpToMesh/src/nodetree/nodetree.h
@@ -0,0 +1,8 @@
+#ifndef __NODETREE_NODETREE_H_INCLUDED__
+#define __NODETREE_NODETREE_H_INCLUDED__
+
+#include
+
+void Walk(const aiScene *scene);
+
+#endif