NickHardeman/ofxFBX

errors on 0.10.0

Closed this issue · 13 comments

So, when passing to ofx v0.10 some things break.
I'm compiling the examples (that worked with no problems on v0.9..), and getting:

ofx/of_v0.10.0_linux64gcc6_release/addons/ofxFBX/src/ofxFBXBone.cpp:109:16: error: ‘class ofxFBXBone’ has no member named ‘setTransformMatrix’; did you mean ‘localTransformMatrix’?
         sbone->setTransformMatrix( getLocalTransformMatrix() );
                ^~~~~~~~~~~~~~~~~~
                localTransformMatrix

I tried as a temporary workarround:

diff --git a/src/ofxFBXManager.cpp b/src/ofxFBXManager.cpp
index 30af6f9..7d94e01 100755
--- a/src/ofxFBXManager.cpp
+++ b/src/ofxFBXManager.cpp
@@ -109,7 +109,10 @@ void ofxFBXManager::update(float aElapsedSeconds) {
         } else {
             fbxMeshes[i]->update( animations[animationIndex].fbxCurrentTime, lPose );
         }
-        meshTransforms[i].setTransformMatrix( fbxMeshes[i]->getGlobalTransformMatrix() );

+        setTransformMatrix(meshTransforms[i], fbxMeshes[i]->getGlobalTransformMatrix())
+
     }
     
     for( auto& skel : skeletons ) {
@@ -478,7 +481,23 @@ vector< shared_ptr<ofxFBXPose> > ofxFBXManager::getPoses() {
 
 
 
+void ofxFBXManager::setTransformMatrix(ofNode& node, const ofMatrix4x4 &m44) {
+        localTransformMatrix = m44;
 
+        ofVec3f position;
+        ofQuaternion orientation;
+        ofVec3f scale;
+        ofQuaternion so;
+        localTransformMatrix.decompose(position, orientation, scale, so);
+        node.position = position;
+        node.orientation = orientation;
+        node.scale = scale;
+        node.updateAxis();
+        
+        node.onPositionChanged();
+        node.onOrientationChanged();
+        node.onScaleChanged();
+}
 
 
 
diff --git a/src/ofxFBXManager.h b/src/ofxFBXManager.h
index c630bfc..671a671 100755
--- a/src/ofxFBXManager.h
+++ b/src/ofxFBXManager.h
@@ -81,6 +81,10 @@ protected:
     bool bAnimationsEnabled = true;
     int poseIndex = 0;
     bool bPosesEnabled = false;
+
+
+    //----------------------------------------
+    void setTransformMatrix(ofNode& node, const ofMatrix4x4 &m44);
     
 };

Which requires some minor changes on the ofx core: 😅

diff --git a/ofNode.h b/ofNode.h
index dca3566..8f2fb0e 100644
--- a/ofNode.h
+++ b/ofNode.h
@@ -450,7 +450,7 @@ public:
 
 	/// \}
 	
-protected:
+public:
 	void createMatrix();
 	void updateAxis();
 	
@@ -466,7 +466,7 @@ protected:
 
 	ofNode * parent = nullptr;
 
-private:
+public:
 	void onParentPositionChanged(glm::vec3 & position) {onPositionChanged();}
 	void onParentOrientationChanged(glm::quat & orientation) {onOrientationChanged();}
 	void onParentScaleChanged(glm::vec3 & scale) {onScaleChanged();}

but still:

ofx/of_v0.10.0_linux64gcc6_release/addons/ofxFBX/src/ofxFBXManager.cpp:492:30: error: ‘glm::mat4 {aka struct glm::tmat4x4<float, (glm::precision)0>}’ has no member named ‘decompose’
         localTransformMatrix.decompose(position, orientation, scale, so);
                              ^~~~~~~~~

trying to solve this too. any news around?

no news 😞
@NickHardeman if you don't have time to get into it at least point us in the right direction please!

Looks like there is no longer a setTransformMatrix function in ofNode which ofxFBXMesh was extending. Looking into alternatives that don't involve modifying the core...

I am able to get the animations playing correctly by making changes to account for the change in ofNode and the switch to glm. However, I am not able to get the OF bones to line up. The animated meshes appear correctly but accessing the bones to manipulate them is not working. I can push this up in another branch as a temporary fix if that would be helpful.

It took a while to convert to glm, but I finally got it. Does master now work for you?

hey @NickHardeman , thanks for the update!
I just tested on VS2017 and OF masterbranch but still having errors:

`Severity Code Description Project File Line Suppression State
Error (active) E0757 overloaded function "std::chrono::duration<_Rep, _Period>::duration [with _Rep=long long, _Period=std::nano]" is not a type name example-ImporterAnimations C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\chrono 195
Error C2039 'isnan': is not a member of 'std' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\detail\func_common.inl 623
Error C2873 'isnan': symbol cannot be used in a using-declaration (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\detail\func_common.inl 623
Error C2672 'glm::isnan': no matching overloaded function found (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 120
Error C2784 'glm::tvec4<bool,P> glm::isnan(const glm::tquat<T,P> &)': could not deduce template argument for 'const glm::tquat<T,P> &' from 'float' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 120
Error C2784 'vecType<bool,P> glm::isnan(const vecType<T,P> &)': could not deduce template argument for 'const vecType<T,P> &' from 'float' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 120
Error C2672 'glm::isnan': no matching overloaded function found (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 150
Error C2784 'glm::tvec4<bool,P> glm::isnan(const glm::tquat<T,P> &)': could not deduce template argument for 'const glm::tquat<T,P> &' from 'float' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 150
Error C2784 'vecType<bool,P> glm::isnan(const vecType<T,P> &)': could not deduce template argument for 'const vecType<T,P> &' from 'float' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\glm\include\glm\gtc\packing.inl 150
Error C2039 'isnan': is not a member of 'std' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\openframeworks\math\ofmatrix4x4.h 677
Error C2039 'isnan': is not a member of 'std' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\openframeworks\math\ofmatrix4x4.h 678
Error C2039 'isnan': is not a member of 'std' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\openframeworks\math\ofmatrix4x4.h 679
Error C2039 'isnan': is not a member of 'std' (compiling source file ......\addons\ofxFBX\src\GetPosition.cxx) example-ImporterAnimations c:\users\myUser\documents\openframeworks\libs\openframeworks\math\ofmatrix4x4.h 680

//- warnings

Warning C4553 '==': result of expression not used; did you intend '='? example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxbone.cpp 196
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\example-importeranimations\src\ofapp.cpp 84
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 25
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 46
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 63
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 91
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 115
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 144
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 149
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 159
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 164
Warning C4018 '>=': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 181
Warning C4018 '>=': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 192
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 204
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 214
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 224
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 233
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 296
Warning C4018 '>': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 307
Warning C4018 '>=': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 342
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 373
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 381
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 432
Warning C4018 '>=': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 441
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmanager.cpp 448
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 61
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 240
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 261
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 361
Warning C4018 '>=': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxnode.cpp 70
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxnode.cpp 108
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxnode.cpp 135
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 771
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxmesh.cpp 785
Warning C4101 'lResult': unreferenced local variable example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxscene.cpp 36
Warning C4996 'ofGetGlInternalFormat': Use ofGetGLInternalFormat() instead example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxscene.cpp 263
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxscene.cpp 415
Warning C4018 '<': signed/unsigned mismatch example-ImporterAnimations c:\users\myUser\documents\openframeworks\addons\ofxfbx\src\ofxfbxscene.cpp 423
`

Hmm. seems like the FBX Sdk is altering the std::isnan function somehow.

I just commented out the isnan file and cleaned up a few other places that was using decompose from glm. I removed the VS projects in the addon. I used the project generator to create the VS2017 project and was able to compile in Release 64 bit

yes!
now the examples compiled in Release x64. (I believe not in Debug or Win32 combinations..).

Phew! Converting to glm was quite a bit of work. I dev mostly on OSX, so let me know if you come across any additional windows issues. Thank you for testing! Going to close this since it works on at least OSX and Windows (Release).

It's also compiling and running in linux with gcc 7.3! (and ofx v0.10.0)
thanks man!

The only detail (I don't know if I'm wrong) but in the BoneControl example.. shouln't the character be staring at the light? It seems like the head is rotated by 90degrees..

export

Yes, that happens here too

Yeah, that's still an issue with the ofxFbxBone pointTo function. Still trying to figure out glm rotations. Need to rotate the head locally around the y axis. :)