Adding double precision import support for formats that can be exported

This commit is contained in:
Chris Russ
2016-07-16 12:14:36 +10:00
parent fa1d6d8c55
commit 05a6ee6473
26 changed files with 204 additions and 233 deletions

View File

@@ -144,7 +144,7 @@ bool STLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
const char* tokens[] = {"STL","solid"};
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
}
return false;
}
@@ -189,7 +189,7 @@ void STLImporter::InternReadFile( const std::string& pFile,
this->mBuffer = &mBuffer2[0];
// the default vertex color is light gray.
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f;
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6;
// allocate a single node
pScene->mRootNode = new aiNode();
@@ -217,13 +217,13 @@ void STLImporter::InternReadFile( const std::string& pFile,
s.Set(AI_DEFAULT_MATERIAL_NAME);
pcMat->AddProperty(&s, AI_MATKEY_NAME);
aiColor4D clrDiffuse(0.6f,0.6f,0.6f,1.0f);
aiColor4D clrDiffuse(0.6,0.6,0.6,1.0);
if (bMatClr) {
clrDiffuse = clrColorDefault;
}
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
clrDiffuse = aiColor4D(0.05f,0.05f,0.05f,1.0f);
clrDiffuse = aiColor4D(0.05,0.05,0.05,1.0);
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);
pScene->mNumMaterials = 1;
@@ -307,11 +307,11 @@ void STLImporter::LoadASCIIFile()
}
sz += 7;
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->z );
normalBuffer.push_back(*vn);
normalBuffer.push_back(*vn);
}
@@ -332,11 +332,11 @@ void STLImporter::LoadASCIIFile()
SkipSpaces(&sz);
positionBuffer.push_back(aiVector3D());
aiVector3D* vn = &positionBuffer.back();
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->z );
faceVertexCounter++;
}
}
@@ -416,10 +416,10 @@ bool STLImporter::LoadBinaryFile()
// read the default vertex color for facets
bIsMaterialise = true;
DefaultLogger::get()->info("STL: Taking code path for Materialise files");
clrColorDefault.r = (*sz2++) / 255.0f;
clrColorDefault.g = (*sz2++) / 255.0f;
clrColorDefault.b = (*sz2++) / 255.0f;
clrColorDefault.a = (*sz2++) / 255.0f;
clrColorDefault.r = (*sz2++) / 255.0;
clrColorDefault.g = (*sz2++) / 255.0;
clrColorDefault.b = (*sz2++) / 255.0;
clrColorDefault.a = (*sz2++) / 255.0;
break;
}
}
@@ -480,18 +480,18 @@ bool STLImporter::LoadBinaryFile()
DefaultLogger::get()->info("STL: Mesh has vertex colors");
}
aiColor4D* clr = &pMesh->mColors[0][i*3];
clr->a = 1.0f;
clr->a = 1.0;
if (bIsMaterialise) // this is reversed
{
clr->r = (color & 0x31u) / 31.0f;
clr->g = ((color & (0x31u<<5))>>5u) / 31.0f;
clr->b = ((color & (0x31u<<10))>>10u) / 31.0f;
clr->r = (color & 0x31u) / 31.0;
clr->g = ((color & (0x31u<<5))>>5u) / 31.0;
clr->b = ((color & (0x31u<<10))>>10u) / 31.0;
}
else
{
clr->b = (color & 0x31u) / 31.0f;
clr->g = ((color & (0x31u<<5))>>5u) / 31.0f;
clr->r = ((color & (0x31u<<10))>>10u) / 31.0f;
clr->b = (color & 0x31u) / 31.0;
clr->g = ((color & (0x31u<<5))>>5u) / 31.0;
clr->r = ((color & (0x31u<<10))>>10u) / 31.0;
}
// assign the color to all vertices of the face
*(clr+1) = *clr;