@@ -88,7 +88,7 @@ namespace plateau::meshWriter {
8888
8989 for (int i = 0 ; i < model.getRootNodeCount (); ++i) {
9090 const auto & node = model.getRootNodeAt (i);
91- processNodeRecursive (node, fbx_scene->GetRootNode (), fbx_scene);
91+ processNodeRecursive (node, fbx_scene->GetRootNode (), fbx_scene, fs::absolute (path). u8string () );
9292 }
9393
9494 const auto exporter = FbxExporter::Create (manager_, " " );
@@ -107,14 +107,14 @@ namespace plateau::meshWriter {
107107 exporter->Destroy ();
108108
109109 // テクスチャファイルコピー
110- for (const auto & texture : required_textures_) {
111- copyTexture (fs::absolute (path).u8string (), texture );
110+ for (const auto & texture_path : required_textures_) {
111+ copyTexture (fs::absolute (path).u8string (), texture_path );
112112 }
113113
114114 return true ;
115115 }
116116
117- void processNodeRecursive (const polygonMesh::Node& node, FbxNode* parent_fbx_node, FbxScene* fbx_scene) {
117+ void processNodeRecursive (const polygonMesh::Node& node, FbxNode* parent_fbx_node, FbxScene* fbx_scene, const std::string& fbx_path ) {
118118 const auto fbx_node = FbxNode::Create (fbx_scene, node.getName ().c_str ());
119119 parent_fbx_node->AddChild (fbx_node);
120120
@@ -137,15 +137,15 @@ namespace plateau::meshWriter {
137137
138138 const auto mesh = node.getMesh ();
139139 if (mesh != nullptr )
140- addMesh (*mesh, fbx_scene, fbx_node);
140+ addMesh (*mesh, fbx_scene, fbx_node, fbx_path );
141141
142142 for (size_t i = 0 ; i < node.getChildCount (); ++i) {
143143 const auto & child_node = node.getChildAt (i);
144- processNodeRecursive (child_node, fbx_node, fbx_scene);
144+ processNodeRecursive (child_node, fbx_node, fbx_scene, fbx_path );
145145 }
146146 }
147147
148- void addMesh (const polygonMesh::Mesh& mesh, FbxScene* fbx_scene, FbxNode* fbx_node) {
148+ void addMesh (const polygonMesh::Mesh& mesh, FbxScene* fbx_scene, FbxNode* fbx_node, const std::string& fbx_path ) {
149149 const auto fbx_mesh = FbxMesh::Create (fbx_scene, " " );
150150
151151 // Create control points.
@@ -245,7 +245,10 @@ namespace plateau::meshWriter {
245245 if (FbxColorProperty.IsValid ()) {
246246 // Create a fbx property
247247 FbxFileTexture* lTexture = FbxFileTexture::Create (fbx_scene, fs::u8path (texture_path).filename ().u8string ().c_str ());
248- lTexture->SetFileName (texture_path.c_str ());
248+ auto dst_path = fs::u8path (fbx_path).parent_path ();
249+ dst_path /= fs::u8path (texture_path).parent_path ().filename ();
250+ dst_path /= fs::u8path (texture_path).filename ();
251+ lTexture->SetFileName (dst_path.u8string ().c_str ());
249252 lTexture->SetTextureUse (FbxTexture::eStandard);
250253 lTexture->SetMappingType (FbxTexture::eUV);
251254 lTexture->ConnectDstProperty (FbxColorProperty);
0 commit comments