XFileExporter.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2020, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. @author: Richard Steffen, 2014
  32. ----------------------------------------------------------------------
  33. */
  34. #ifndef ASSIMP_BUILD_NO_EXPORT
  35. #ifndef ASSIMP_BUILD_NO_X_EXPORTER
  36. #include "AssetLib/X/XFileExporter.h"
  37. #include "PostProcessing/ConvertToLHProcess.h"
  38. #include <assimp/Bitmap.h>
  39. #include <assimp/BaseImporter.h>
  40. #include <assimp/fast_atof.h>
  41. #include <assimp/SceneCombiner.h>
  42. #include <assimp/DefaultIOSystem.h>
  43. #include <assimp/Exceptional.h>
  44. #include <assimp/IOSystem.hpp>
  45. #include <assimp/scene.h>
  46. #include <assimp/light.h>
  47. #include <ctime>
  48. #include <set>
  49. #include <memory>
  50. using namespace Assimp;
  51. namespace Assimp
  52. {
  53. // ------------------------------------------------------------------------------------------------
  54. // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
  55. void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
  56. {
  57. std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
  58. std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
  59. // create/copy Properties
  60. ExportProperties props(*pProperties);
  61. // set standard properties if not set
  62. if (!props.HasPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT)) props.SetPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT, false);
  63. // invoke the exporter
  64. XFileExporter iDoTheExportThing( pScene, pIOSystem, path, file, &props);
  65. if (iDoTheExportThing.mOutput.fail()) {
  66. throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
  67. }
  68. // we're still here - export successfully completed. Write result to the given IOSYstem
  69. std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
  70. if (outfile == nullptr) {
  71. throw DeadlyExportError("could not open output .x file: " + std::string(pFile));
  72. }
  73. // XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy.
  74. outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast<size_t>(iDoTheExportThing.mOutput.tellp()),1);
  75. }
  76. } // end of namespace Assimp
  77. // ------------------------------------------------------------------------------------------------
  78. // Constructor for a specific scene to export
  79. XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties)
  80. : mProperties(pProperties),
  81. mIOSystem(pIOSystem),
  82. mPath(path),
  83. mFile(file),
  84. mScene(pScene),
  85. mSceneOwned(false),
  86. endstr("\n")
  87. {
  88. // make sure that all formatting happens using the standard, C locale and not the user's current locale
  89. mOutput.imbue( std::locale("C") );
  90. mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
  91. // start writing
  92. WriteFile();
  93. }
  94. // ------------------------------------------------------------------------------------------------
  95. // Destructor
  96. XFileExporter::~XFileExporter()
  97. {
  98. if(mSceneOwned) {
  99. delete mScene;
  100. }
  101. }
  102. // ------------------------------------------------------------------------------------------------
  103. // Starts writing the contents
  104. void XFileExporter::WriteFile()
  105. {
  106. // note, that all realnumber values must be comma separated in x files
  107. mOutput.setf(std::ios::fixed);
  108. mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION); // precision for ai_real
  109. // entry of writing the file
  110. WriteHeader();
  111. mOutput << startstr << "Frame DXCC_ROOT {" << endstr;
  112. PushTag();
  113. aiMatrix4x4 I; // identity
  114. WriteFrameTransform(I);
  115. WriteNode(mScene->mRootNode);
  116. PopTag();
  117. mOutput << startstr << "}" << endstr;
  118. }
  119. // ------------------------------------------------------------------------------------------------
  120. // Writes the asset header
  121. void XFileExporter::WriteHeader()
  122. {
  123. if (mProperties->GetPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT) == true)
  124. mOutput << startstr << "xof 0303txt 0064" << endstr;
  125. else
  126. mOutput << startstr << "xof 0303txt 0032" << endstr;
  127. mOutput << endstr;
  128. mOutput << startstr << "template Frame {" << endstr;
  129. PushTag();
  130. mOutput << startstr << "<3d82ab46-62da-11cf-ab39-0020af71e433>" << endstr;
  131. mOutput << startstr << "[...]" << endstr;
  132. PopTag();
  133. mOutput << startstr << "}" << endstr;
  134. mOutput << endstr;
  135. mOutput << startstr << "template Matrix4x4 {" << endstr;
  136. PushTag();
  137. mOutput << startstr << "<f6f23f45-7686-11cf-8f52-0040333594a3>" << endstr;
  138. mOutput << startstr << "array FLOAT matrix[16];" << endstr;
  139. PopTag();
  140. mOutput << startstr << "}" << endstr;
  141. mOutput << endstr;
  142. mOutput << startstr << "template FrameTransformMatrix {" << endstr;
  143. PushTag();
  144. mOutput << startstr << "<f6f23f41-7686-11cf-8f52-0040333594a3>" << endstr;
  145. mOutput << startstr << "Matrix4x4 frameMatrix;" << endstr;
  146. PopTag();
  147. mOutput << startstr << "}" << endstr;
  148. mOutput << endstr;
  149. mOutput << startstr << "template Vector {" << endstr;
  150. PushTag();
  151. mOutput << startstr << "<3d82ab5e-62da-11cf-ab39-0020af71e433>" << endstr;
  152. mOutput << startstr << "FLOAT x;" << endstr;
  153. mOutput << startstr << "FLOAT y;" << endstr;
  154. mOutput << startstr << "FLOAT z;" << endstr;
  155. PopTag();
  156. mOutput << startstr << "}" << endstr;
  157. mOutput << endstr;
  158. mOutput << startstr << "template MeshFace {" << endstr;
  159. PushTag();
  160. mOutput << startstr << "<3d82ab5f-62da-11cf-ab39-0020af71e433>" << endstr;
  161. mOutput << startstr << "DWORD nFaceVertexIndices;" << endstr;
  162. mOutput << startstr << "array DWORD faceVertexIndices[nFaceVertexIndices];" << endstr;
  163. PopTag();
  164. mOutput << startstr << "}" << endstr;
  165. mOutput << endstr;
  166. mOutput << startstr << "template Mesh {" << endstr;
  167. PushTag();
  168. mOutput << startstr << "<3d82ab44-62da-11cf-ab39-0020af71e433>" << endstr;
  169. mOutput << startstr << "DWORD nVertices;" << endstr;
  170. mOutput << startstr << "array Vector vertices[nVertices];" << endstr;
  171. mOutput << startstr << "DWORD nFaces;" << endstr;
  172. mOutput << startstr << "array MeshFace faces[nFaces];" << endstr;
  173. mOutput << startstr << "[...]" << endstr;
  174. PopTag();
  175. mOutput << startstr << "}" << endstr;
  176. mOutput << endstr;
  177. mOutput << startstr << "template MeshNormals {" << endstr;
  178. PushTag();
  179. mOutput << startstr << "<f6f23f43-7686-11cf-8f52-0040333594a3>" << endstr;
  180. mOutput << startstr << "DWORD nNormals;" << endstr;
  181. mOutput << startstr << "array Vector normals[nNormals];" << endstr;
  182. mOutput << startstr << "DWORD nFaceNormals;" << endstr;
  183. mOutput << startstr << "array MeshFace faceNormals[nFaceNormals];" << endstr;
  184. PopTag();
  185. mOutput << startstr << "}" << endstr;
  186. mOutput << endstr;
  187. mOutput << startstr << "template Coords2d {" << endstr;
  188. PushTag();
  189. mOutput << startstr << "<f6f23f44-7686-11cf-8f52-0040333594a3>" << endstr;
  190. mOutput << startstr << "FLOAT u;" << endstr;
  191. mOutput << startstr << "FLOAT v;" << endstr;
  192. PopTag();
  193. mOutput << startstr << "}" << endstr;
  194. mOutput << endstr;
  195. mOutput << startstr << "template MeshTextureCoords {" << endstr;
  196. PushTag();
  197. mOutput << startstr << "<f6f23f40-7686-11cf-8f52-0040333594a3>" << endstr;
  198. mOutput << startstr << "DWORD nTextureCoords;" << endstr;
  199. mOutput << startstr << "array Coords2d textureCoords[nTextureCoords];" << endstr;
  200. PopTag();
  201. mOutput << startstr << "}" << endstr;
  202. mOutput << endstr;
  203. mOutput << startstr << "template ColorRGBA {" << endstr;
  204. PushTag();
  205. mOutput << startstr << "<35ff44e0-6c7c-11cf-8f52-0040333594a3>" << endstr;
  206. mOutput << startstr << "FLOAT red;" << endstr;
  207. mOutput << startstr << "FLOAT green;" << endstr;
  208. mOutput << startstr << "FLOAT blue;" << endstr;
  209. mOutput << startstr << "FLOAT alpha;" << endstr;
  210. PopTag();
  211. mOutput << startstr << "}" << endstr;
  212. mOutput << endstr;
  213. mOutput << startstr << "template IndexedColor {" << endstr;
  214. PushTag();
  215. mOutput << startstr << "<1630b820-7842-11cf-8f52-0040333594a3>" << endstr;
  216. mOutput << startstr << "DWORD index;" << endstr;
  217. mOutput << startstr << "ColorRGBA indexColor;" << endstr;
  218. PopTag();
  219. mOutput << startstr << "}" << endstr;
  220. mOutput << endstr;
  221. mOutput << startstr << "template MeshVertexColors {" << endstr;
  222. PushTag();
  223. mOutput << startstr << "<1630b821-7842-11cf-8f52-0040333594a3>" << endstr;
  224. mOutput << startstr << "DWORD nVertexColors;" << endstr;
  225. mOutput << startstr << "array IndexedColor vertexColors[nVertexColors];" << endstr;
  226. PopTag();
  227. mOutput << startstr << "}" << endstr;
  228. mOutput << endstr;
  229. mOutput << startstr << "template VertexElement {" << endstr;
  230. PushTag();
  231. mOutput << startstr << "<f752461c-1e23-48f6-b9f8-8350850f336f>" << endstr;
  232. mOutput << startstr << "DWORD Type;" << endstr;
  233. mOutput << startstr << "DWORD Method;" << endstr;
  234. mOutput << startstr << "DWORD Usage;" << endstr;
  235. mOutput << startstr << "DWORD UsageIndex;" << endstr;
  236. PopTag();
  237. mOutput << startstr << "}" << endstr;
  238. mOutput << endstr;
  239. mOutput << startstr << "template DeclData {" << endstr;
  240. PushTag();
  241. mOutput << startstr << "<bf22e553-292c-4781-9fea-62bd554bdd93>" << endstr;
  242. mOutput << startstr << "DWORD nElements;" << endstr;
  243. mOutput << startstr << "array VertexElement Elements[nElements];" << endstr;
  244. mOutput << startstr << "DWORD nDWords;" << endstr;
  245. mOutput << startstr << "array DWORD data[nDWords];" << endstr;
  246. PopTag();
  247. mOutput << startstr << "}" << endstr;
  248. mOutput << endstr;
  249. }
  250. // Writes the material setup
  251. void XFileExporter::WriteFrameTransform(aiMatrix4x4& m)
  252. {
  253. mOutput << startstr << "FrameTransformMatrix {" << endstr << " ";
  254. PushTag();
  255. mOutput << startstr << m.a1 << ", " << m.b1 << ", " << m.c1 << ", " << m.d1 << "," << endstr;
  256. mOutput << startstr << m.a2 << ", " << m.b2 << ", " << m.c2 << ", " << m.d2 << "," << endstr;
  257. mOutput << startstr << m.a3 << ", " << m.b3 << ", " << m.c3 << ", " << m.d3 << "," << endstr;
  258. mOutput << startstr << m.a4 << ", " << m.b4 << ", " << m.c4 << ", " << m.d4 << ";;" << endstr;
  259. PopTag();
  260. mOutput << startstr << "}" << endstr << endstr;
  261. }
  262. // ------------------------------------------------------------------------------------------------
  263. // Recursively writes the given node
  264. void XFileExporter::WriteNode( aiNode* pNode)
  265. {
  266. if (pNode->mName.length==0)
  267. {
  268. std::stringstream ss;
  269. ss << "Node_" << pNode;
  270. pNode->mName.Set(ss.str());
  271. }
  272. mOutput << startstr << "Frame " << toXFileString(pNode->mName) << " {" << endstr;
  273. PushTag();
  274. aiMatrix4x4 m = pNode->mTransformation;
  275. WriteFrameTransform(m);
  276. for (size_t i = 0; i < pNode->mNumMeshes; ++i)
  277. WriteMesh(mScene->mMeshes[pNode->mMeshes[i]]);
  278. // recursive call the Nodes
  279. for (size_t i = 0; i < pNode->mNumChildren; ++i)
  280. WriteNode(pNode->mChildren[i]);
  281. PopTag();
  282. mOutput << startstr << "}" << endstr << endstr;
  283. }
  284. void XFileExporter::WriteMesh(aiMesh* mesh)
  285. {
  286. mOutput << startstr << "Mesh " << toXFileString(mesh->mName) << "_mShape" << " {" << endstr;
  287. PushTag();
  288. // write all the vertices
  289. mOutput << startstr << mesh->mNumVertices << ";" << endstr;
  290. for (size_t a = 0; a < mesh->mNumVertices; a++)
  291. {
  292. aiVector3D &v = mesh->mVertices[a];
  293. mOutput << startstr << v[0] << ";"<< v[1] << ";" << v[2] << ";";
  294. if (a < mesh->mNumVertices - 1)
  295. mOutput << "," << endstr;
  296. else
  297. mOutput << ";" << endstr;
  298. }
  299. // write all the faces
  300. mOutput << startstr << mesh->mNumFaces << ";" << endstr;
  301. for( size_t a = 0; a < mesh->mNumFaces; ++a )
  302. {
  303. const aiFace& face = mesh->mFaces[a];
  304. mOutput << startstr << face.mNumIndices << ";";
  305. // must be counter clockwise triangle
  306. //for(int b = face.mNumIndices - 1; b >= 0 ; --b)
  307. for(size_t b = 0; b < face.mNumIndices ; ++b)
  308. {
  309. mOutput << face.mIndices[b];
  310. //if (b > 0)
  311. if (b<face.mNumIndices-1)
  312. mOutput << ",";
  313. else
  314. mOutput << ";";
  315. }
  316. if (a < mesh->mNumFaces - 1)
  317. mOutput << "," << endstr;
  318. else
  319. mOutput << ";" << endstr;
  320. }
  321. mOutput << endstr;
  322. if (mesh->HasTextureCoords(0))
  323. {
  324. const aiMaterial* mat = mScene->mMaterials[mesh->mMaterialIndex];
  325. aiString relpath;
  326. mat->Get(_AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0, relpath);
  327. mOutput << startstr << "MeshMaterialList {" << endstr;
  328. PushTag();
  329. mOutput << startstr << "1;" << endstr; // number of materials
  330. mOutput << startstr << mesh->mNumFaces << ";" << endstr; // number of faces
  331. mOutput << startstr;
  332. for( size_t a = 0; a < mesh->mNumFaces; ++a )
  333. {
  334. mOutput << "0"; // the material index
  335. if (a < mesh->mNumFaces - 1)
  336. mOutput << ", ";
  337. else
  338. mOutput << ";" << endstr;
  339. }
  340. mOutput << startstr << "Material {" << endstr;
  341. PushTag();
  342. mOutput << startstr << "1.0; 1.0; 1.0; 1.000000;;" << endstr;
  343. mOutput << startstr << "1.000000;" << endstr; // power
  344. mOutput << startstr << "0.000000; 0.000000; 0.000000;;" << endstr; // specularity
  345. mOutput << startstr << "0.000000; 0.000000; 0.000000;;" << endstr; // emission
  346. mOutput << startstr << "TextureFilename { \"";
  347. writePath(relpath);
  348. mOutput << "\"; }" << endstr;
  349. PopTag();
  350. mOutput << startstr << "}" << endstr;
  351. PopTag();
  352. mOutput << startstr << "}" << endstr;
  353. }
  354. // write normals (every vertex has one)
  355. if (mesh->HasNormals())
  356. {
  357. mOutput << endstr << startstr << "MeshNormals {" << endstr;
  358. mOutput << startstr << mesh->mNumVertices << ";" << endstr;
  359. for (size_t a = 0; a < mesh->mNumVertices; a++)
  360. {
  361. aiVector3D &v = mesh->mNormals[a];
  362. // because we have a LHS and also changed wth winding, we need to invert the normals again
  363. mOutput << startstr << -v[0] << ";"<< -v[1] << ";" << -v[2] << ";";
  364. if (a < mesh->mNumVertices - 1)
  365. mOutput << "," << endstr;
  366. else
  367. mOutput << ";" << endstr;
  368. }
  369. mOutput << startstr << mesh->mNumFaces << ";" << endstr;
  370. for (size_t a = 0; a < mesh->mNumFaces; a++)
  371. {
  372. const aiFace& face = mesh->mFaces[a];
  373. mOutput << startstr << face.mNumIndices << ";";
  374. //for(int b = face.mNumIndices-1; b >= 0 ; --b)
  375. for(size_t b = 0; b < face.mNumIndices ; ++b)
  376. {
  377. mOutput << face.mIndices[b];
  378. //if (b > 0)
  379. if (b<face.mNumIndices-1)
  380. mOutput << ",";
  381. else
  382. mOutput << ";";
  383. }
  384. if (a < mesh->mNumFaces-1)
  385. mOutput << "," << endstr;
  386. else
  387. mOutput << ";" << endstr;
  388. }
  389. mOutput << startstr << "}" << endstr;
  390. }
  391. // write texture UVs if available
  392. if (mesh->HasTextureCoords(0))
  393. {
  394. mOutput << endstr << startstr << "MeshTextureCoords {" << endstr;
  395. mOutput << startstr << mesh->mNumVertices << ";" << endstr;
  396. for (size_t a = 0; a < mesh->mNumVertices; a++)
  397. //for (int a = (int)mesh->mNumVertices-1; a >=0 ; a--)
  398. {
  399. aiVector3D& uv = mesh->mTextureCoords[0][a]; // uv of first uv layer for the vertex
  400. mOutput << startstr << uv.x << ";" << uv.y;
  401. if (a < mesh->mNumVertices-1)
  402. //if (a >0 )
  403. mOutput << ";," << endstr;
  404. else
  405. mOutput << ";;" << endstr;
  406. }
  407. mOutput << startstr << "}" << endstr;
  408. }
  409. // write color channel if available
  410. if (mesh->HasVertexColors(0))
  411. {
  412. mOutput << endstr << startstr << "MeshVertexColors {" << endstr;
  413. mOutput << startstr << mesh->mNumVertices << ";" << endstr;
  414. for (size_t a = 0; a < mesh->mNumVertices; a++)
  415. {
  416. aiColor4D& mColors = mesh->mColors[0][a]; // color of first vertex color set for the vertex
  417. mOutput << startstr << a << ";" << mColors.r << ";" << mColors.g << ";" << mColors.b << ";" << mColors.a << ";;";
  418. if (a < mesh->mNumVertices-1)
  419. mOutput << "," << endstr;
  420. else
  421. mOutput << ";" << endstr;
  422. }
  423. mOutput << startstr << "}" << endstr;
  424. }
  425. /*
  426. else
  427. {
  428. mOutput << endstr << startstr << "MeshVertexColors {" << endstr;
  429. mOutput << startstr << mesh->mNumVertices << ";" << endstr;
  430. for (size_t a = 0; a < mesh->mNumVertices; a++)
  431. {
  432. aiColor4D* mColors = mesh->mColors[a];
  433. mOutput << startstr << a << ";0.500000;0.000000;0.000000;0.500000;;";
  434. if (a < mesh->mNumVertices-1)
  435. mOutput << "," << endstr;
  436. else
  437. mOutput << ";" << endstr;
  438. }
  439. mOutput << startstr << "}" << endstr;
  440. }
  441. */
  442. PopTag();
  443. mOutput << startstr << "}" << endstr << endstr;
  444. }
  445. std::string XFileExporter::toXFileString(aiString &name)
  446. {
  447. std::string pref = ""; // node name prefix to prevent unexpected start of string
  448. std::string str = pref + std::string(name.C_Str());
  449. for (int i=0; i < (int) str.length(); ++i)
  450. {
  451. if ((str[i] >= '0' && str[i] <= '9') || // 0-9
  452. (str[i] >= 'A' && str[i] <= 'Z') || // A-Z
  453. (str[i] >= 'a' && str[i] <= 'z')) // a-z
  454. continue;
  455. str[i] = '_';
  456. }
  457. return str;
  458. }
  459. void XFileExporter::writePath(const aiString &path)
  460. {
  461. std::string str = std::string(path.C_Str());
  462. BaseImporter::ConvertUTF8toISO8859_1(str);
  463. while( str.find( "\\\\") != std::string::npos)
  464. str.replace( str.find( "\\\\"), 2, "\\");
  465. while( str.find( "\\") != std::string::npos)
  466. str.replace( str.find( "\\"), 1, "/");
  467. mOutput << str;
  468. }
  469. #endif
  470. #endif