|
@@ -161,6 +161,7 @@ Error GltfImporter::init(CString inputFname,
|
|
|
Bool optimizeMeshes,
|
|
Bool optimizeMeshes,
|
|
|
F32 lodFactor,
|
|
F32 lodFactor,
|
|
|
U32 lodCount,
|
|
U32 lodCount,
|
|
|
|
|
+ F32 lightIntensityScale,
|
|
|
U32 threadCount)
|
|
U32 threadCount)
|
|
|
{
|
|
{
|
|
|
m_inputFname.create(inputFname);
|
|
m_inputFname.create(inputFname);
|
|
@@ -169,6 +170,8 @@ Error GltfImporter::init(CString inputFname,
|
|
|
m_texrpath.create(texrpath);
|
|
m_texrpath.create(texrpath);
|
|
|
m_optimizeMeshes = optimizeMeshes;
|
|
m_optimizeMeshes = optimizeMeshes;
|
|
|
|
|
|
|
|
|
|
+ m_lightIntensityScale = clamp(lightIntensityScale, 0.1f, 1.0f);
|
|
|
|
|
+
|
|
|
m_lodCount = clamp(lodCount, 1u, 3u);
|
|
m_lodCount = clamp(lodCount, 1u, 3u);
|
|
|
m_lodFactor = clamp(lodFactor, 0.0f, 1.0f);
|
|
m_lodFactor = clamp(lodFactor, 0.0f, 1.0f);
|
|
|
if(m_lodFactor * F32(m_lodCount - 1) > 0.7f)
|
|
if(m_lodFactor * F32(m_lodCount - 1) > 0.7f)
|
|
@@ -646,6 +649,7 @@ Error GltfImporter::visitNode(
|
|
|
|
|
|
|
|
// LOD 0
|
|
// LOD 0
|
|
|
Error err = self.m_importer->writeMesh(*self.m_mesh, CString(), 1.0f);
|
|
Error err = self.m_importer->writeMesh(*self.m_mesh, CString(), 1.0f);
|
|
|
|
|
+ U32 maxLod = 0;
|
|
|
|
|
|
|
|
// LOD 1
|
|
// LOD 1
|
|
|
if(!err && self.m_lodCount > 1)
|
|
if(!err && self.m_lodCount > 1)
|
|
@@ -653,6 +657,7 @@ Error GltfImporter::visitNode(
|
|
|
StringAuto name(self.m_importer->m_alloc);
|
|
StringAuto name(self.m_importer->m_alloc);
|
|
|
name.sprintf("%s_lod1", self.m_mesh->name);
|
|
name.sprintf("%s_lod1", self.m_mesh->name);
|
|
|
err = self.m_importer->writeMesh(*self.m_mesh, name, 1.0f - self.m_lodFactor);
|
|
err = self.m_importer->writeMesh(*self.m_mesh, name, 1.0f - self.m_lodFactor);
|
|
|
|
|
+ maxLod = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// LOD 2
|
|
// LOD 2
|
|
@@ -661,6 +666,7 @@ Error GltfImporter::visitNode(
|
|
|
StringAuto name(self.m_importer->m_alloc);
|
|
StringAuto name(self.m_importer->m_alloc);
|
|
|
name.sprintf("%s_lod2", self.m_mesh->name);
|
|
name.sprintf("%s_lod2", self.m_mesh->name);
|
|
|
err = self.m_importer->writeMesh(*self.m_mesh, name, 1.0f - self.m_lodFactor * 2.0f);
|
|
err = self.m_importer->writeMesh(*self.m_mesh, name, 1.0f - self.m_lodFactor * 2.0f);
|
|
|
|
|
+ maxLod = 2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(!err)
|
|
if(!err)
|
|
@@ -680,7 +686,7 @@ Error GltfImporter::visitNode(
|
|
|
|
|
|
|
|
if(!err && self.m_selfCollision)
|
|
if(!err && self.m_selfCollision)
|
|
|
{
|
|
{
|
|
|
- err = self.m_importer->writeCollisionMesh(*self.m_mesh);
|
|
|
|
|
|
|
+ err = self.m_importer->writeCollisionMesh(*self.m_mesh, maxLod);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(err)
|
|
if(err)
|
|
@@ -1037,7 +1043,7 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
|
|
|
return Error::NONE;
|
|
return Error::NONE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Error GltfImporter::writeCollisionMesh(const cgltf_mesh& mesh)
|
|
|
|
|
|
|
+Error GltfImporter::writeCollisionMesh(const cgltf_mesh& mesh, U32 maxLod)
|
|
|
{
|
|
{
|
|
|
StringAuto fname(m_alloc);
|
|
StringAuto fname(m_alloc);
|
|
|
fname.sprintf("%s%s.ankicl", m_outDir.cstr(), mesh.name);
|
|
fname.sprintf("%s%s.ankicl", m_outDir.cstr(), mesh.name);
|
|
@@ -1049,10 +1055,21 @@ Error GltfImporter::writeCollisionMesh(const cgltf_mesh& mesh)
|
|
|
|
|
|
|
|
ANKI_CHECK(file.writeText("%s\n", XML_HEADER));
|
|
ANKI_CHECK(file.writeText("%s\n", XML_HEADER));
|
|
|
|
|
|
|
|
- ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
|
|
|
|
|
- "%s%s_lod2.ankimesh</value>\n</collisionShape>\n",
|
|
|
|
|
- m_rpath.cstr(),
|
|
|
|
|
- mesh.name));
|
|
|
|
|
|
|
+ if(maxLod == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
|
|
|
|
|
+ "%s%s.ankimesh</value>\n</collisionShape>\n",
|
|
|
|
|
+ m_rpath.cstr(),
|
|
|
|
|
+ mesh.name));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
|
|
|
|
|
+ "%s%s_lod%u.ankimesh</value>\n</collisionShape>\n",
|
|
|
|
|
+ m_rpath.cstr(),
|
|
|
|
|
+ mesh.name,
|
|
|
|
|
+ maxLod));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return Error::NONE;
|
|
return Error::NONE;
|
|
|
}
|
|
}
|
|
@@ -1088,7 +1105,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
|
|
|
|
|
Vec3 color(light.color[0], light.color[1], light.color[2]);
|
|
Vec3 color(light.color[0], light.color[1], light.color[2]);
|
|
|
color *= light.intensity;
|
|
color *= light.intensity;
|
|
|
- color /= 100.0f; // Blender changed something
|
|
|
|
|
|
|
+ color *= m_lightIntensityScale;
|
|
|
ANKI_CHECK(
|
|
ANKI_CHECK(
|
|
|
m_sceneFile.writeText("lcomp:setDiffuseColor(Vec4.new(%f, %f, %f, 1))\n", color.x(), color.y(), color.z()));
|
|
m_sceneFile.writeText("lcomp:setDiffuseColor(Vec4.new(%f, %f, %f, 1))\n", color.x(), color.y(), color.z()));
|
|
|
|
|
|