Q3DLoader.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2016, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Q3DLoader.cpp
  35. * @brief Implementation of the Q3D importer class
  36. */
  37. #ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
  38. // internal headers
  39. #include "Q3DLoader.h"
  40. #include "StreamReader.h"
  41. #include "fast_atof.h"
  42. #include <assimp/IOSystem.hpp>
  43. #include <assimp/DefaultLogger.hpp>
  44. #include <assimp/scene.h>
  45. using namespace Assimp;
  46. static const aiImporterDesc desc = {
  47. "Quick3D Importer",
  48. "",
  49. "",
  50. "http://www.quick3d.com/",
  51. aiImporterFlags_SupportBinaryFlavour,
  52. 0,
  53. 0,
  54. 0,
  55. 0,
  56. "q3o q3s"
  57. };
  58. // ------------------------------------------------------------------------------------------------
  59. // Constructor to be privately used by Importer
  60. Q3DImporter::Q3DImporter()
  61. {}
  62. // ------------------------------------------------------------------------------------------------
  63. // Destructor, private as well
  64. Q3DImporter::~Q3DImporter()
  65. {}
  66. // ------------------------------------------------------------------------------------------------
  67. // Returns whether the class can handle the format of the given file.
  68. bool Q3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
  69. {
  70. const std::string extension = GetExtension(pFile);
  71. if (extension == "q3s" || extension == "q3o")
  72. return true;
  73. else if (!extension.length() || checkSig) {
  74. if (!pIOHandler)
  75. return true;
  76. const char* tokens[] = {"quick3Do","quick3Ds"};
  77. return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
  78. }
  79. return false;
  80. }
  81. // ------------------------------------------------------------------------------------------------
  82. const aiImporterDesc* Q3DImporter::GetInfo () const
  83. {
  84. return &desc;
  85. }
  86. // ------------------------------------------------------------------------------------------------
  87. // Imports the given file into the given scene structure.
  88. void Q3DImporter::InternReadFile( const std::string& pFile,
  89. aiScene* pScene, IOSystem* pIOHandler)
  90. {
  91. StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
  92. // The header is 22 bytes large
  93. if (stream.GetRemainingSize() < 22)
  94. throw DeadlyImportError("File is either empty or corrupt: " + pFile);
  95. // Check the file's signature
  96. if (ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Do", 8 ) &&
  97. ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Ds", 8 ))
  98. {
  99. throw DeadlyImportError("Not a Quick3D file. Signature string is: " +
  100. std::string((const char*)stream.GetPtr(),8));
  101. }
  102. // Print the file format version
  103. DefaultLogger::get()->info("Quick3D File format version: " +
  104. std::string(&((const char*)stream.GetPtr())[8],2));
  105. // ... an store it
  106. char major = ((const char*)stream.GetPtr())[8];
  107. char minor = ((const char*)stream.GetPtr())[9];
  108. stream.IncPtr(10);
  109. unsigned int numMeshes = (unsigned int)stream.GetI4();
  110. unsigned int numMats = (unsigned int)stream.GetI4();
  111. unsigned int numTextures = (unsigned int)stream.GetI4();
  112. std::vector<Material> materials;
  113. materials.reserve(numMats);
  114. std::vector<Mesh> meshes;
  115. meshes.reserve(numMeshes);
  116. // Allocate the scene root node
  117. pScene->mRootNode = new aiNode();
  118. aiColor3D fgColor (0.6f,0.6f,0.6f);
  119. // Now read all file chunks
  120. while (true)
  121. {
  122. if (stream.GetRemainingSize() < 1)break;
  123. char c = stream.GetI1();
  124. switch (c)
  125. {
  126. // Meshes chunk
  127. case 'm':
  128. {
  129. for (unsigned int quak = 0; quak < numMeshes; ++quak)
  130. {
  131. meshes.push_back(Mesh());
  132. Mesh& mesh = meshes.back();
  133. // read all vertices
  134. unsigned int numVerts = (unsigned int)stream.GetI4();
  135. if (!numVerts)
  136. throw DeadlyImportError("Quick3D: Found mesh with zero vertices");
  137. std::vector<aiVector3D>& verts = mesh.verts;
  138. verts.resize(numVerts);
  139. for (unsigned int i = 0; i < numVerts;++i)
  140. {
  141. verts[i].x = stream.GetF4();
  142. verts[i].y = stream.GetF4();
  143. verts[i].z = stream.GetF4();
  144. }
  145. // read all faces
  146. numVerts = (unsigned int)stream.GetI4();
  147. if (!numVerts)
  148. throw DeadlyImportError("Quick3D: Found mesh with zero faces");
  149. std::vector<Face >& faces = mesh.faces;
  150. faces.reserve(numVerts);
  151. // number of indices
  152. for (unsigned int i = 0; i < numVerts;++i)
  153. {
  154. faces.push_back(Face(stream.GetI2()) );
  155. if (faces.back().indices.empty())
  156. throw DeadlyImportError("Quick3D: Found face with zero indices");
  157. }
  158. // indices
  159. for (unsigned int i = 0; i < numVerts;++i)
  160. {
  161. Face& vec = faces[i];
  162. for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
  163. vec.indices[a] = stream.GetI4();
  164. }
  165. // material indices
  166. for (unsigned int i = 0; i < numVerts;++i)
  167. {
  168. faces[i].mat = (unsigned int)stream.GetI4();
  169. }
  170. // read all normals
  171. numVerts = (unsigned int)stream.GetI4();
  172. std::vector<aiVector3D>& normals = mesh.normals;
  173. normals.resize(numVerts);
  174. for (unsigned int i = 0; i < numVerts;++i)
  175. {
  176. normals[i].x = stream.GetF4();
  177. normals[i].y = stream.GetF4();
  178. normals[i].z = stream.GetF4();
  179. }
  180. numVerts = (unsigned int)stream.GetI4();
  181. if (numTextures && numVerts)
  182. {
  183. // read all texture coordinates
  184. std::vector<aiVector3D>& uv = mesh.uv;
  185. uv.resize(numVerts);
  186. for (unsigned int i = 0; i < numVerts;++i)
  187. {
  188. uv[i].x = stream.GetF4();
  189. uv[i].y = stream.GetF4();
  190. }
  191. // UV indices
  192. for (unsigned int i = 0; i < (unsigned int)faces.size();++i)
  193. {
  194. Face& vec = faces[i];
  195. for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
  196. {
  197. vec.uvindices[a] = stream.GetI4();
  198. if (!i && !a)
  199. mesh.prevUVIdx = vec.uvindices[a];
  200. else if (vec.uvindices[a] != mesh.prevUVIdx)
  201. mesh.prevUVIdx = UINT_MAX;
  202. }
  203. }
  204. }
  205. // we don't need the rest, but we need to get to the next chunk
  206. stream.IncPtr(36);
  207. if (minor > '0' && major == '3')
  208. stream.IncPtr(mesh.faces.size());
  209. }
  210. // stream.IncPtr(4); // unknown value here
  211. }
  212. break;
  213. // materials chunk
  214. case 'c':
  215. for (unsigned int i = 0; i < numMats; ++i)
  216. {
  217. materials.push_back(Material());
  218. Material& mat = materials.back();
  219. // read the material name
  220. while (( c = stream.GetI1()))
  221. mat.name.data[mat.name.length++] = c;
  222. // add the terminal character
  223. mat.name.data[mat.name.length] = '\0';
  224. // read the ambient color
  225. mat.ambient.r = stream.GetF4();
  226. mat.ambient.g = stream.GetF4();
  227. mat.ambient.b = stream.GetF4();
  228. // read the diffuse color
  229. mat.diffuse.r = stream.GetF4();
  230. mat.diffuse.g = stream.GetF4();
  231. mat.diffuse.b = stream.GetF4();
  232. // read the ambient color
  233. mat.specular.r = stream.GetF4();
  234. mat.specular.g = stream.GetF4();
  235. mat.specular.b = stream.GetF4();
  236. // read the transparency
  237. mat.transparency = stream.GetF4();
  238. // unknown value here
  239. // stream.IncPtr(4);
  240. // FIX: it could be the texture index ...
  241. mat.texIdx = (unsigned int)stream.GetI4();
  242. }
  243. break;
  244. // texture chunk
  245. case 't':
  246. pScene->mNumTextures = numTextures;
  247. if (!numTextures)break;
  248. pScene->mTextures = new aiTexture*[pScene->mNumTextures];
  249. // to make sure we won't crash if we leave through an exception
  250. ::memset(pScene->mTextures,0,sizeof(void*)*pScene->mNumTextures);
  251. for (unsigned int i = 0; i < pScene->mNumTextures; ++i)
  252. {
  253. aiTexture* tex = pScene->mTextures[i] = new aiTexture();
  254. // skip the texture name
  255. while (stream.GetI1());
  256. // read texture width and height
  257. tex->mWidth = (unsigned int)stream.GetI4();
  258. tex->mHeight = (unsigned int)stream.GetI4();
  259. if (!tex->mWidth || !tex->mHeight)
  260. throw DeadlyImportError("Quick3D: Invalid texture. Width or height is zero");
  261. unsigned int mul = tex->mWidth * tex->mHeight;
  262. aiTexel* begin = tex->pcData = new aiTexel[mul];
  263. aiTexel* const end = & begin [mul];
  264. for (;begin != end; ++begin)
  265. {
  266. begin->r = stream.GetI1();
  267. begin->g = stream.GetI1();
  268. begin->b = stream.GetI1();
  269. begin->a = 0xff;
  270. }
  271. }
  272. break;
  273. // scene chunk
  274. case 's':
  275. {
  276. // skip position and rotation
  277. stream.IncPtr(12);
  278. for (unsigned int i = 0; i < 4;++i)
  279. for (unsigned int a = 0; a < 4;++a)
  280. pScene->mRootNode->mTransformation[i][a] = stream.GetF4();
  281. stream.IncPtr(16);
  282. // now setup a single camera
  283. pScene->mNumCameras = 1;
  284. pScene->mCameras = new aiCamera*[1];
  285. aiCamera* cam = pScene->mCameras[0] = new aiCamera();
  286. cam->mPosition.x = stream.GetF4();
  287. cam->mPosition.y = stream.GetF4();
  288. cam->mPosition.z = stream.GetF4();
  289. cam->mName.Set("Q3DCamera");
  290. // skip eye rotation for the moment
  291. stream.IncPtr(12);
  292. // read the default material color
  293. fgColor .r = stream.GetF4();
  294. fgColor .g = stream.GetF4();
  295. fgColor .b = stream.GetF4();
  296. // skip some unimportant properties
  297. stream.IncPtr(29);
  298. // setup a single point light with no attenuation
  299. pScene->mNumLights = 1;
  300. pScene->mLights = new aiLight*[1];
  301. aiLight* light = pScene->mLights[0] = new aiLight();
  302. light->mName.Set("Q3DLight");
  303. light->mType = aiLightSource_POINT;
  304. light->mAttenuationConstant = 1;
  305. light->mAttenuationLinear = 0;
  306. light->mAttenuationQuadratic = 0;
  307. light->mColorDiffuse.r = stream.GetF4();
  308. light->mColorDiffuse.g = stream.GetF4();
  309. light->mColorDiffuse.b = stream.GetF4();
  310. light->mColorSpecular = light->mColorDiffuse;
  311. // We don't need the rest, but we need to know where this chunk ends.
  312. unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
  313. // skip the background file name
  314. while (stream.GetI1());
  315. // skip background texture data + the remaining fields
  316. stream.IncPtr(temp*3 + 20); // 4 bytes of unknown data here
  317. // TODO
  318. goto outer;
  319. }
  320. break;
  321. default:
  322. throw DeadlyImportError("Quick3D: Unknown chunk");
  323. break;
  324. };
  325. }
  326. outer:
  327. // If we have no mesh loaded - break here
  328. if (meshes.empty())
  329. throw DeadlyImportError("Quick3D: No meshes loaded");
  330. // If we have no materials loaded - generate a default mat
  331. if (materials.empty())
  332. {
  333. DefaultLogger::get()->info("Quick3D: No material found, generating one");
  334. materials.push_back(Material());
  335. materials.back().diffuse = fgColor ;
  336. }
  337. // find out which materials we'll need
  338. typedef std::pair<unsigned int, unsigned int> FaceIdx;
  339. typedef std::vector< FaceIdx > FaceIdxArray;
  340. FaceIdxArray* fidx = new FaceIdxArray[materials.size()];
  341. unsigned int p = 0;
  342. for (std::vector<Mesh>::iterator it = meshes.begin(), end = meshes.end();
  343. it != end; ++it,++p)
  344. {
  345. unsigned int q = 0;
  346. for (std::vector<Face>::iterator fit = (*it).faces.begin(), fend = (*it).faces.end();
  347. fit != fend; ++fit,++q)
  348. {
  349. if ((*fit).mat >= materials.size())
  350. {
  351. DefaultLogger::get()->warn("Quick3D: Material index overflow");
  352. (*fit).mat = 0;
  353. }
  354. if (fidx[(*fit).mat].empty())++pScene->mNumMeshes;
  355. fidx[(*fit).mat].push_back( FaceIdx(p,q) );
  356. }
  357. }
  358. pScene->mNumMaterials = pScene->mNumMeshes;
  359. pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
  360. pScene->mMeshes = new aiMesh*[pScene->mNumMaterials];
  361. for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i)
  362. {
  363. if (fidx[i].empty())continue;
  364. // Allocate a mesh and a material
  365. aiMesh* mesh = pScene->mMeshes[real] = new aiMesh();
  366. aiMaterial* mat = new aiMaterial();
  367. pScene->mMaterials[real] = mat;
  368. mesh->mMaterialIndex = real;
  369. // Build the output material
  370. Material& srcMat = materials[i];
  371. mat->AddProperty(&srcMat.diffuse, 1,AI_MATKEY_COLOR_DIFFUSE);
  372. mat->AddProperty(&srcMat.specular, 1,AI_MATKEY_COLOR_SPECULAR);
  373. mat->AddProperty(&srcMat.ambient, 1,AI_MATKEY_COLOR_AMBIENT);
  374. // NOTE: Ignore transparency for the moment - it seems
  375. // unclear how to interpret the data
  376. #if 0
  377. if (!(minor > '0' && major == '3'))
  378. srcMat.transparency = 1.0f - srcMat.transparency;
  379. mat->AddProperty(&srcMat.transparency, 1, AI_MATKEY_OPACITY);
  380. #endif
  381. // add shininess - Quick3D seems to use it ins its viewer
  382. srcMat.transparency = 16.f;
  383. mat->AddProperty(&srcMat.transparency, 1, AI_MATKEY_SHININESS);
  384. int m = (int)aiShadingMode_Phong;
  385. mat->AddProperty(&m, 1, AI_MATKEY_SHADING_MODEL);
  386. if (srcMat.name.length)
  387. mat->AddProperty(&srcMat.name,AI_MATKEY_NAME);
  388. // Add a texture
  389. if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures)
  390. {
  391. srcMat.name.data[0] = '*';
  392. srcMat.name.length = ASSIMP_itoa10(&srcMat.name.data[1],1000,
  393. (srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real));
  394. mat->AddProperty(&srcMat.name,AI_MATKEY_TEXTURE_DIFFUSE(0));
  395. }
  396. mesh->mNumFaces = (unsigned int)fidx[i].size();
  397. aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
  398. // Now build the output mesh. First find out how many
  399. // vertices we'll need
  400. for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end();
  401. it != end; ++it)
  402. {
  403. mesh->mNumVertices += (unsigned int)meshes[(*it).first].faces[
  404. (*it).second].indices.size();
  405. }
  406. aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
  407. aiVector3D* norms = mesh->mNormals = new aiVector3D[mesh->mNumVertices];
  408. aiVector3D* uv;
  409. if (real < pScene->mNumTextures)
  410. {
  411. uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
  412. mesh->mNumUVComponents[0] = 2;
  413. }
  414. else uv = NULL;
  415. // Build the final array
  416. unsigned int cnt = 0;
  417. for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end();
  418. it != end; ++it, ++faces)
  419. {
  420. Mesh& m = meshes[(*it).first];
  421. Face& face = m.faces[(*it).second];
  422. faces->mNumIndices = (unsigned int)face.indices.size();
  423. faces->mIndices = new unsigned int [faces->mNumIndices];
  424. aiVector3D faceNormal;
  425. bool fnOK = false;
  426. for (unsigned int n = 0; n < faces->mNumIndices;++n, ++cnt, ++norms, ++verts)
  427. {
  428. if (face.indices[n] >= m.verts.size())
  429. {
  430. DefaultLogger::get()->warn("Quick3D: Vertex index overflow");
  431. face.indices[n] = 0;
  432. }
  433. // copy vertices
  434. *verts = m.verts[ face.indices[n] ];
  435. if (face.indices[n] >= m.normals.size() && faces->mNumIndices >= 3)
  436. {
  437. // we have no normal here - assign the face normal
  438. if (!fnOK)
  439. {
  440. const aiVector3D& pV1 = m.verts[ face.indices[0] ];
  441. const aiVector3D& pV2 = m.verts[ face.indices[1] ];
  442. const aiVector3D& pV3 = m.verts[ face.indices.size() - 1 ];
  443. faceNormal = (pV2 - pV1) ^ (pV3 - pV1).Normalize();
  444. fnOK = true;
  445. }
  446. *norms = faceNormal;
  447. }
  448. else *norms = m.normals[ face.indices[n] ];
  449. // copy texture coordinates
  450. if (uv && m.uv.size())
  451. {
  452. if (m.prevUVIdx != 0xffffffff && m.uv.size() >= m.verts.size()) // workaround
  453. {
  454. *uv = m.uv[face.indices[n]];
  455. }
  456. else
  457. {
  458. if (face.uvindices[n] >= m.uv.size())
  459. {
  460. DefaultLogger::get()->warn("Quick3D: Texture coordinate index overflow");
  461. face.uvindices[n] = 0;
  462. }
  463. *uv = m.uv[face.uvindices[n]];
  464. }
  465. uv->y = 1.f - uv->y;
  466. ++uv;
  467. }
  468. // setup the new vertex index
  469. faces->mIndices[n] = cnt;
  470. }
  471. }
  472. ++real;
  473. }
  474. // Delete our nice helper array
  475. delete[] fidx;
  476. // Now we need to attach the meshes to the root node of the scene
  477. pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
  478. pScene->mRootNode->mMeshes = new unsigned int [pScene->mNumMeshes];
  479. for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
  480. pScene->mRootNode->mMeshes[i] = i;
  481. /*pScene->mRootNode->mTransformation *= aiMatrix4x4(
  482. 1.f, 0.f, 0.f, 0.f,
  483. 0.f, -1.f,0.f, 0.f,
  484. 0.f, 0.f, 1.f, 0.f,
  485. 0.f, 0.f, 0.f, 1.f);*/
  486. // Add cameras and light sources to the scene root node
  487. pScene->mRootNode->mNumChildren = pScene->mNumLights+pScene->mNumCameras;
  488. if (pScene->mRootNode->mNumChildren)
  489. {
  490. pScene->mRootNode->mChildren = new aiNode* [ pScene->mRootNode->mNumChildren ];
  491. // the light source
  492. aiNode* nd = pScene->mRootNode->mChildren[0] = new aiNode();
  493. nd->mParent = pScene->mRootNode;
  494. nd->mName.Set("Q3DLight");
  495. nd->mTransformation = pScene->mRootNode->mTransformation;
  496. nd->mTransformation.Inverse();
  497. // camera
  498. nd = pScene->mRootNode->mChildren[1] = new aiNode();
  499. nd->mParent = pScene->mRootNode;
  500. nd->mName.Set("Q3DCamera");
  501. nd->mTransformation = pScene->mRootNode->mChildren[0]->mTransformation;
  502. }
  503. }
  504. #endif // !! ASSIMP_BUILD_NO_Q3D_IMPORTER