Skip to content

Commit 410641e

Browse files
authored
ofxAssimp::Scene import setting for applying mesh transform. (#8461)
#changelog #ofxAssimp
1 parent f501852 commit 410641e

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

addons/ofxAssimp/src/Source/ofxAssimpSrcScene.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
};

addons/ofxAssimp/src/ofxAssimpMesh.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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;

addons/ofxAssimp/src/ofxAssimpMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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();

addons/ofxAssimp/src/ofxAssimpScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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 ) {

0 commit comments

Comments
 (0)