sueda / fbx-extract Goto Github PK
View Code? Open in Web Editor NEWExtracts data from an fbx file
License: MIT License
Extracts data from an fbx file
License: MIT License
Hello, thank you for creating wonderful program.
I have a question.
I tried this program but segmentation fault error occurred.
My fbx file is simple.
My fbx file has 3d object data, skin and animation.
If you know this error, Please give me something suggests.
=== geometry ===
pSphere1: 2280 verts, 439 unique
pSphere2: 2280 verts, 439 unique
Saving to bone_pSphere1.obj
Saving to bone_pSphere2.obj
=== skin ===
pSphere1: 2280 vertices
pSphere2: 2280 vertices
Saving to bone_pSphere1_skin.txt
Saving to bone_pSphere2_skin.txt
=== skeleton ===
2 clusters
zsh: segmentation fault ./fbx-extract
I git cloned the GLM library to the same directory that I've cloned fbx-extract. I went into the glm library and performed the cmake command:
/usr/include/glm/cmake$ cmake ..
-- GLM: Version 0.9.9.9
GLM: GCC - GNU compiler
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/include/glm/cmake
Following your instructions, I get a CMake error:
/usr/include/fbx-extract/build$ sudo cmake ..
CMake Error at CMakeLists.txt:31 (MESSAGE):
Please point the environment variable GLM_INCLUDE_DIR to the root directory
of your GLM installation.
-- Configuring incomplete, errors occurred!
See also "/usr/include/fbx-extract/build/CMakeFiles/CMakeOutput.log".
I'm using Ubuntu on Windows. Here is the end of my ~/.profile file:
export GLM_INCLUDE_DIR="/usr/include/glm"
And a sanity check:
/usr/include/fbx-extract/build$ echo $GLM_INCLUDE_DIR
/usr/include/glm
What have I done wrong?
In fbx-extract on line 539 you have limbMap[limb] = (int)limbMap.size();
This has undefined behavior on which call (limbMap[limb]
or limbMap.size()
) gets evaluated first. This off-by-1 error causes a segfault error at line 807 if the order is not what is expected.
Fixing the code to look like:
int limbMapSize = (int)limbMap.size();
limbMap[limb] = limbMapSize;
solves the crashing problem with my machine and compiler.
Hi, I would really like to try this out.
could you please give us more info how to make it run ?
I would like to run it on a Linux environment if that's possible.
Best,
Albion
Hi, I tried to visualize the extracted skeletal animation. For the rest pose (1st frame), directly visualizing the bone positions (x,y,z) gives me a rest pose skeleton. For the animation frames, visualizing the bone positions does not give any meaningful skeleton. I am curious how can I get the correct skeleton sequence from the extracted skeletal animation.
I tried to guess the meaning of per frame rotation and translation (e.g. joint coordinate to world coordinate transform, world coordinate to joint coordinate transform, product of transformation matrix and bind matrix etc) and compute the per frame skeleton accordingly, but none of it correct. Maybe I am missing something.
BTW, my fbx file is downloaded from mixamo.
Running the make command in the build instructions produces an Error 2 in the make file, and the traceback suggests that you need to append #include to the header of main.cpp.
/usr/include/fbx-extract$ sudo make
[ 25%] Building CXX object CMakeFiles/fbx-extract.dir/src/main.cpp.o
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveSkin(const ofbx::IScene*)’:
/usr/include/fbx-extract/src/main.cpp:453:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
453 | fprintf(fp, "%d %d %d\n", vertex_count, limbVec.size(), mesh.maxInfluences);
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveAnim(const ofbx::IScene*)’:
/usr/include/fbx-extract/src/main.cpp:727:9: error: ‘strcmp’ was not declared in this scope
727 | if(strcmp(child->name, "R") == 0) {
| ^~~~~~
/usr/include/fbx-extract/src/main.cpp:18:1: note: ‘strcmp’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
17 | #include <math.h>
+++ |+#include <cstring>
18 |
/usr/include/fbx-extract/src/main.cpp:828:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
828 | fprintf(fp, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveInputfile()’:
/usr/include/fbx-extract/src/main.cpp:878:33: warning: format not a string literal and no format arguments [-Wformat-security]
878 | fprintf(fp, TEXTURENAME.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp:881:31: warning: format not a string literal and no format arguments [-Wformat-security]
881 | fprintf(fp, file_name.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp:887:33: warning: format not a string literal and no format arguments [-Wformat-security]
887 | fprintf(fp, input_line.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveLocalTransfomfile()’:
/usr/include/fbx-extract/src/main.cpp:1022:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1022 | fprintf(fp, "%d\n",limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1035:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1035 | fprintf(fp2, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1082:10: error: ‘strcmp’ was not declared in this scope
1082 | if (strcmp(child->name, "R") == 0) {
| ^~~~~~
/usr/include/fbx-extract/src/main.cpp:1082:10: note: ‘strcmp’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
/usr/include/fbx-extract/src/main.cpp:1181:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1181 | fprintf(fp, "%d\n", limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1196:28: warning: format not a string literal and no format arguments [-Wformat-security]
1196 | fprintf(fp, limbVec[j]->name);
/usr/include/fbx-extract/src/main.cpp:1217:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1217 | fprintf(fp, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
make[2]: *** [CMakeFiles/fbx-extract.dir/build.make:63: CMakeFiles/fbx-extract.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/fbx-extract.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
```/usr/include/fbx-extract$ sudo make
[ 25%] Building CXX object CMakeFiles/fbx-extract.dir/src/main.cpp.o
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveSkin(const ofbx::IScene*)’:
/usr/include/fbx-extract/src/main.cpp:453:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
453 | fprintf(fp, "%d %d %d\n", vertex_count, limbVec.size(), mesh.maxInfluences);
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveAnim(const ofbx::IScene*)’:
/usr/include/fbx-extract/src/main.cpp:727:9: error: ‘strcmp’ was not declared in this scope
727 | if(strcmp(child->name, "R") == 0) {
| ^~~~~~
/usr/include/fbx-extract/src/main.cpp:18:1: note: ‘strcmp’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
17 | #include <math.h>
+++ |+#include <cstring>
18 |
/usr/include/fbx-extract/src/main.cpp:828:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
828 | fprintf(fp, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveInputfile()’:
/usr/include/fbx-extract/src/main.cpp:878:33: warning: format not a string literal and no format arguments [-Wformat-security]
878 | fprintf(fp, TEXTURENAME.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp:881:31: warning: format not a string literal and no format arguments [-Wformat-security]
881 | fprintf(fp, file_name.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp:887:33: warning: format not a string literal and no format arguments [-Wformat-security]
887 | fprintf(fp, input_line.c_str());
| ^
/usr/include/fbx-extract/src/main.cpp: In function ‘bool saveLocalTransfomfile()’:
/usr/include/fbx-extract/src/main.cpp:1022:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1022 | fprintf(fp, "%d\n",limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1035:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1035 | fprintf(fp2, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1082:10: error: ‘strcmp’ was not declared in this scope
1082 | if (strcmp(child->name, "R") == 0) {
| ^~~~~~
/usr/include/fbx-extract/src/main.cpp:1082:10: note: ‘strcmp’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
/usr/include/fbx-extract/src/main.cpp:1181:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1181 | fprintf(fp, "%d\n", limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
/usr/include/fbx-extract/src/main.cpp:1196:28: warning: format not a string literal and no format arguments [-Wformat-security]
1196 | fprintf(fp, limbVec[j]->name);
/usr/include/fbx-extract/src/main.cpp:1217:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<const ofbx::Object*>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
1217 | fprintf(fp, "%d %d\n", key_count_max, limbVec.size());
| ~^ ~~~~~~~~~~~~~~
| | |
| int std::vector<const ofbx::Object*>::size_type {aka long unsigned int}
| %ld
make[2]: *** [CMakeFiles/fbx-extract.dir/build.make:63: CMakeFiles/fbx-extract.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/fbx-extract.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
input.txt
does not match the texture to the correct mesh.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.