1- //
2- // ofxAssimpSrcMesh.cpp
3- // ofxAssimpExample
4- //
5- // Created by Nick Hardeman on 10/24/23.
6- //
7-
81#include " ofxAssimpSrcMesh.h"
92#include " ofxAssimpUtils.h"
103#include " of3dGraphics.h"
136using std::make_shared;
147using std::shared_ptr;
158
16- using namespace ofx ::assimp ;
9+ using namespace ofxAssimp ;
1710
1811static unsigned int sUniqueMeshCounter = 0 ;
1912ofTexture SrcMesh::sDummyTex ;
2013
2114// -------------------------------------------
22- void SrcMesh::addTexture ( std::shared_ptr<ofx::assimp ::Texture> aAssimpTex){
15+ void SrcMesh::addTexture ( std::shared_ptr<ofxAssimp ::Texture> aAssimpTex){
2316
2417 if (!material) {
2518 material = std::make_shared<ofMaterial>();
2619 }
2720
2821 auto tAiType = aAssimpTex->getAiTextureType ();
29- auto tofType = ofx::assimp ::Texture::ofTextureTypeForAiType (tAiType);
22+ auto tofType = ofxAssimp ::Texture::ofTextureTypeForAiType (tAiType);
3023
3124 if (tofType == OF_MATERIAL_TEXTURE_NONE ) {
32- ofLogError (" ofx::assimp ::Mesh::addTexture" ) << aAssimpTex->getAiTextureTypeAsString ();
25+ ofLogError (" ofxAssimp ::Mesh::addTexture" ) << aAssimpTex->getAiTextureTypeAsString ();
3326 return ;
3427 }
3528
@@ -70,7 +63,7 @@ bool SrcMesh::hasTexture(aiTextureType aTexType){
7063
7164// -------------------------------------------
7265bool SrcMesh::hasTexture (ofMaterialTextureType aType){
73- return hasTexture ( ofx::assimp ::Texture::aiTextureTypeForOfType (aType));
66+ return hasTexture ( ofxAssimp ::Texture::aiTextureTypeForOfType (aType));
7467}
7568
7669// -------------------------------------------
@@ -80,13 +73,13 @@ std::size_t SrcMesh::getNumTextures() {
8073
8174// -------------------------------------------
8275ofTexture& SrcMesh::getTexture () {
83- for ( auto iter = ofx::assimp:: Texture::sAiTexTypeToOfTexTypeMap .begin (); iter != ofx::assimp ::Texture::sAiTexTypeToOfTexTypeMap .end (); iter++ ) {
76+ for ( auto iter = ofxAssimp:: Texture::sAiTexTypeToOfTexTypeMap .begin (); iter != ofxAssimp ::Texture::sAiTexTypeToOfTexTypeMap .end (); iter++ ) {
8477 if ( hasTexture ((aiTextureType)iter->first ) ) {
8578 return getTexture ((aiTextureType)iter->first );
8679 }
8780 }
8881
89- ofLogWarning (" ofx::assimp ::Mesh::getTexture" ) << " unable to find any allocated texture" ;
82+ ofLogWarning (" ofxAssimp ::Mesh::getTexture" ) << " unable to find any allocated texture" ;
9083 return sDummyTex ;
9184}
9285
@@ -97,13 +90,13 @@ ofTexture& SrcMesh::getTexture(aiTextureType aTexType){
9790 return tex->getTextureRef ();
9891 }
9992 }
100- ofLogWarning (" ofx::assimp ::SrcMesh::getTexture : unable to find texture ref for " ) << aTexType;
93+ ofLogWarning (" ofxAssimp ::SrcMesh::getTexture : unable to find texture ref for " ) << aTexType;
10194 return sDummyTex ;
10295}
10396
10497// -------------------------------------------
10598ofTexture& SrcMesh::getTexture (ofMaterialTextureType aType){
106- return getTexture ( ofx::assimp ::Texture::aiTextureTypeForOfType (aType) );
99+ return getTexture ( ofxAssimp ::Texture::aiTextureTypeForOfType (aType) );
107100}
108101
109102// -------------------------------------------
@@ -132,9 +125,9 @@ void SrcMesh::setAiMesh( aiMesh* amesh, aiNode* aAiNode ) {
132125void SrcMesh::setupVbo ( std::shared_ptr<ofVbo> avbo ) {
133126 ofMesh tempMesh;
134127 if ( hasTexture () ) {
135- aiMeshToOfMesh (mAiMesh , tempMesh, !bConvertedToLeftHand, &getTexture () );
128+ ofxAssimp::Utils:: aiMeshToOfMesh (mAiMesh , tempMesh, !bConvertedToLeftHand, &getTexture () );
136129 } else {
137- aiMeshToOfMesh (mAiMesh , tempMesh, !bConvertedToLeftHand, nullptr );
130+ ofxAssimp::Utils:: aiMeshToOfMesh (mAiMesh , tempMesh, !bConvertedToLeftHand, nullptr );
138131 }
139132
140133 avbo->setVertexData (&mAiMesh ->mVertices [0 ].x ,3 ,mAiMesh ->mNumVertices ,usage,sizeof (aiVector3D));
@@ -164,9 +157,9 @@ void SrcMesh::setupVbo( std::shared_ptr<ofVbo> avbo ) {
164157void SrcMesh::setMeshFromAiMesh ( ofMesh& amesh ) {
165158 if ( mAiMesh != NULL && amesh.getNumVertices () < 1 ) {
166159 if ( hasTexture () ) {
167- aiMeshToOfMesh (mAiMesh , amesh, !bConvertedToLeftHand, &getTexture ());
160+ ofxAssimp::Utils:: aiMeshToOfMesh (mAiMesh , amesh, !bConvertedToLeftHand, &getTexture ());
168161 } else {
169- aiMeshToOfMesh (mAiMesh , amesh, !bConvertedToLeftHand, nullptr );
162+ ofxAssimp::Utils:: aiMeshToOfMesh (mAiMesh , amesh, !bConvertedToLeftHand, nullptr );
170163 }
171164 }
172165}
0 commit comments