File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed
Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ struct ImportSettings {
4242// bool importLights = false;
4343 bool convertToLeftHanded = true ; // aiProcess_ConvertToLeftHanded
4444 bool transformRootNode = true ; // orient based on src scene root node, helps with correct orientation
45+ bool applyTransformsToMeshesWithoutBones = false ; // apply offset transforms to meshes without bones.
4546 std::vector<std::string> excludeNodesContainingStrings;
4647 unsigned int aiFlags = 0 ; // ai process flags, ie. aiProcess_FixInfacingNormals
4748};
Original file line number Diff line number Diff line change @@ -103,13 +103,13 @@ std::size_t Mesh::getNumIndices() {
103103}
104104
105105// -------------------------------------------
106- void Mesh::setSrcMesh ( std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh ) {
106+ void Mesh::setSrcMesh ( std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, bool bApplyTransform ) {
107107 mSrcMesh = aSrcMesh;
108108
109109 // if we have bones, no offset, since we are controlled by the bones //
110- // if( mSrcMesh->getAiMesh() && mSrcMesh->getAiMesh()->mNumBones < 1 ) {
111- // setOfNodeFromAiMatrix(mSrcMesh->getAiNode()->mTransformation, this );
112- // }
110+ if ( bApplyTransform && mSrcMesh ->getAiMesh () && mSrcMesh ->getAiMesh ()->mNumBones < 1 ) {
111+ ofxAssimp::Utils:: setOfNodeFromAiMatrix (mSrcMesh ->getAiNode ()->mTransformation , this );
112+ }
113113
114114 if ( mSrcMesh ) {
115115 material = mSrcMesh ->material ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class Mesh : public ofxAssimp::Node {
3838 aiMesh* getAiMesh ();
3939 std::size_t getNumIndices ();
4040
41- void setSrcMesh ( std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh );
41+ void setSrcMesh ( std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, bool bApplyTransform );
4242
4343 ofMesh& getStaticMesh ();
4444 ofMesh& getMesh ();
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ void Scene::processSceneNodesRecursive( std::shared_ptr<ofxAssimp::SrcNode> aSrc
166166 if ( nodeType == ofxAssimp::NodeType::OFX_ASSIMP_MESH ) {
167167 auto tmesh = make_shared<ofxAssimp::Mesh>();
168168 auto srcMesh = std::dynamic_pointer_cast<ofxAssimp::SrcMesh>(aSrcNode);
169- tmesh->setSrcMesh ( srcMesh );
169+ tmesh->setSrcMesh ( srcMesh, mSrcScene -> getImportSettings (). applyTransformsToMeshesWithoutBones );
170170 mMeshes .push_back (tmesh);
171171 newNode = tmesh;
172172 } else if ( nodeType == ofxAssimp::NodeType::OFX_ASSIMP_BONE ) {
You can’t perform that action at this time.
0 commit comments