VOXELFORMAT: debug logging
parent
6ed39e0e54
commit
2a6042adc4
|
@ -28,6 +28,9 @@ General:
|
||||||
- Improved color sampling for voxelization
|
- Improved color sampling for voxelization
|
||||||
- Started to support different palettes in one scene
|
- Started to support different palettes in one scene
|
||||||
- Fixed vxc support
|
- Fixed vxc support
|
||||||
|
- Load the palette from the source file
|
||||||
|
- Fixed vxm file path when saving vxr
|
||||||
|
- Save vxmc (version 12) now
|
||||||
|
|
||||||
VoxEdit:
|
VoxEdit:
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ bool GLTFFormat::saveMeshes(const core::Map<int, int> &meshIdxNodeMap, const Sce
|
||||||
const auto palTexIter = paletteMaterialIndices.find(palette.hash());
|
const auto palTexIter = paletteMaterialIndices.find(palette.hash());
|
||||||
if (palTexIter != paletteMaterialIndices.end()) {
|
if (palTexIter != paletteMaterialIndices.end()) {
|
||||||
materialId = palTexIter->second;
|
materialId = palTexIter->second;
|
||||||
|
Log::debug("Re-use material id %i for hash %" PRIu64, materialId, palette.hash());
|
||||||
} else {
|
} else {
|
||||||
const int textureIndex = (int)m.textures.size();
|
const int textureIndex = (int)m.textures.size();
|
||||||
const int imageIndex = (int)m.images.size();
|
const int imageIndex = (int)m.images.size();
|
||||||
|
@ -116,33 +117,40 @@ bool GLTFFormat::saveMeshes(const core::Map<int, int> &meshIdxNodeMap, const Sce
|
||||||
palettename.append(hashId);
|
palettename.append(hashId);
|
||||||
palettename.append(".png");
|
palettename.append(".png");
|
||||||
|
|
||||||
tinygltf::Image colorPaletteImg;
|
{
|
||||||
colorPaletteImg.uri = core::string::extractFilenameWithExtension(palettename).c_str();
|
tinygltf::Image colorPaletteImg;
|
||||||
m.images.emplace_back(core::move(colorPaletteImg));
|
colorPaletteImg.uri = core::string::extractFilenameWithExtension(palettename).c_str();
|
||||||
|
m.images.emplace_back(core::move(colorPaletteImg));
|
||||||
|
}
|
||||||
|
|
||||||
if (!palette.save(palettename.c_str())) {
|
if (!palette.save(palettename.c_str())) {
|
||||||
Log::error("Failed to save palette data");
|
Log::error("Failed to save palette data");
|
||||||
}
|
}
|
||||||
|
|
||||||
tinygltf::Texture paletteTexture;
|
{
|
||||||
paletteTexture.source = imageIndex;
|
tinygltf::Texture paletteTexture;
|
||||||
m.textures.emplace_back(core::move(paletteTexture));
|
paletteTexture.source = imageIndex;
|
||||||
|
m.textures.emplace_back(core::move(paletteTexture));
|
||||||
tinygltf::Material mat;
|
|
||||||
if (withTexCoords) {
|
|
||||||
mat.pbrMetallicRoughness.baseColorTexture.index = textureIndex;
|
|
||||||
} else if (withColor) {
|
|
||||||
mat.pbrMetallicRoughness.baseColorFactor = {1.0f, 1.0f, 1.0f, 1.0f};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mat.name = hashId.c_str();
|
{
|
||||||
mat.pbrMetallicRoughness.roughnessFactor = 1;
|
tinygltf::Material mat;
|
||||||
mat.pbrMetallicRoughness.metallicFactor = 0;
|
if (withTexCoords) {
|
||||||
mat.doubleSided = false;
|
mat.pbrMetallicRoughness.baseColorTexture.index = textureIndex;
|
||||||
|
} else if (withColor) {
|
||||||
|
mat.pbrMetallicRoughness.baseColorFactor = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||||
|
}
|
||||||
|
|
||||||
materialId = (int)m.materials.size();
|
mat.name = hashId.c_str();
|
||||||
m.materials.emplace_back(core::move(mat));
|
mat.pbrMetallicRoughness.roughnessFactor = 1;
|
||||||
|
mat.pbrMetallicRoughness.metallicFactor = 0;
|
||||||
|
mat.doubleSided = false;
|
||||||
|
|
||||||
|
materialId = (int)m.materials.size();
|
||||||
|
m.materials.emplace_back(core::move(mat));
|
||||||
|
}
|
||||||
paletteMaterialIndices.put(palette.hash(), materialId);
|
paletteMaterialIndices.put(palette.hash(), materialId);
|
||||||
|
Log::debug("New material id %i for hash %" PRIu64, materialId, palette.hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,9 +371,11 @@ bool GLTFFormat::saveMeshes(const core::Map<int, int> &meshIdxNodeMap, const Sce
|
||||||
expMesh.primitives.emplace_back(core::move(meshPrimitive));
|
expMesh.primitives.emplace_back(core::move(meshPrimitive));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinygltf::Node node;
|
{
|
||||||
node.mesh = nthNodeIdx;
|
tinygltf::Node node;
|
||||||
processGltfNode(m, node, scene, graphNode, stack);
|
node.mesh = nthNodeIdx;
|
||||||
|
processGltfNode(m, node, scene, graphNode, stack);
|
||||||
|
}
|
||||||
|
|
||||||
m.meshes.emplace_back(core::move(expMesh));
|
m.meshes.emplace_back(core::move(expMesh));
|
||||||
m.buffers.emplace_back(core::move(buffer));
|
m.buffers.emplace_back(core::move(buffer));
|
||||||
|
|
Loading…
Reference in New Issue