summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2019-08-30 10:22:03 +0300
committerTomi Korpipaa <tomi.korpipaa@qt.io>2019-08-30 16:32:52 +0300
commitcd88fefac16b842d938f154d574330fcc0ed2432 (patch)
treed5c258012b69401ff32a4440252e3e89de0acf22
parent9efa08540b45d2bb6055301e9abcfe9131d8b8dc (diff)
Fix light imports from Collada
Lights exported from Blender did not get converted correctly in DAE. We need to dig the correct values from inside blender extras in the file. Task-number: QT3DS-3391 Change-Id: I16c6d3101b67eca38b7fe4473808257c3955cc64 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp11
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp37
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h2
3 files changed, 39 insertions, 11 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index cd8c0425..2e773291 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -5427,23 +5427,26 @@ void IDocumentEditor::DisplayImportErrors(const QString &inImportSource,
const wchar_t *formatStr = L"Unrecognized warning";
switch (warning.first) {
case ESceneGraphWarningCode_OnlySupportTriangles:
- formatStr = L"Model %ls contains geometric elements other than triangles";
+ formatStr = L"Model \"%ls\" contains geometric elements other than triangles";
break;
case ESceneGraphWarningCode_TrianglesDuplicateSemantic:
formatStr = L"Triangle contains duplicate semantics, ex: 1 triangle has multiple "
L"TEXCOORD (multiple UV maps)";
break;
case ESceneGraphWarningCode_MissingSourceFile:
- formatStr = L"Couldn't find a source image file %ls";
+ formatStr = L"Couldn't find a source image file \"%ls\"";
break;
case ESceneGraphWarningCode_LockedDestFile:
- formatStr = L"An image or mesh file %ls is not writeable";
+ formatStr = L"An image or mesh file \"%ls\" is not writeable";
break;
case ESceneGraphWarningCode_VertexBufferTooLarge:
formatStr = L"A single mesh exceeds the maximum vertex count of 65535";
break;
case ESceneGraphWarningCode_MissingMaterial:
- formatStr = L"Materials are missing from mesh %ls, it was not created";
+ formatStr = L"Materials are missing from mesh \"%ls\", it was not created";
+ break;
+ case ESceneGraphWarningCode_UnsupportedLight:
+ formatStr = L"Light type for \"%ls\" is not supported, it was converted to Directional";
break;
default:
break;
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
index 16b0ebc0..c58d4436 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
@@ -515,9 +515,9 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
{
switch (inNode->getType()) {
case NODETYPE_NODE: {
- const domInstance_geometry_Array &theInstanceGeometryArray =
- inNode->getInstance_geometry_array();
- long theGeometryCount = (long)theInstanceGeometryArray.getCount();
+ const domInstance_geometry_Array &theInstanceGeometryArray
+ = inNode->getInstance_geometry_array();
+ size_t theGeometryCount = theInstanceGeometryArray.getCount();
bool thePushModelFlag = false;
bool lightFlag = false;
bool cameraFlag = false;
@@ -541,9 +541,9 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
PushGroup(GetNameOrIDOrSid(inNode));
ProcessTransform(inNode);
- for (long theIndex = 0; theIndex < theGeometryCount; ++theIndex) {
+ for (size_t theIndex = 0; theIndex < theGeometryCount; ++theIndex) {
const domInstance_geometryRef theInstanceGeometryRef =
- theInstanceGeometryArray[theIndex];
+ theInstanceGeometryArray[theIndex];
PushModel(GetNameOrIDOrSid(theInstanceGeometryRef));
ProcessInstanceGeometry(inNode, theInstanceGeometryRef);
PopModel();
@@ -603,6 +603,28 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
color = point->getColor()->getValue();
linearFade = point->getLinear_attenuation()->getValue() * 1000;
quadFade = point->getQuadratic_attenuation()->getValue() * 1000;
+ // Blender exports Area light as Point type, so we need to check if we are
+ // dealing with Blender, and dig the actual light type from inside extra
+ // elements
+ const domExtra_Array &lightExtraArray = light->getExtra_array();
+ size_t extrasCount = lightExtraArray.getCount();
+ for (size_t i = 0; i < extrasCount; ++i) {
+ domExtraRef lightExtra = lightExtraArray[i];
+ const domTechnique_Array &lightExtraTechniqueArray
+ = lightExtra->getTechnique_array();
+ size_t techniqueCount = lightExtraTechniqueArray.getCount();
+ for (size_t j = 0; j < techniqueCount; ++j) {
+ domTechniqueRef lightExtraTechnique = lightExtraTechniqueArray[i];
+ const char *profile = lightExtraTechnique->getProfile();
+ if (::strcmp(profile, "blender") == 0) {
+ if (daeElement *theElement
+ = lightExtraTechnique->getChild("type")) {
+ type = GetIntFromElementChar(theElement);
+ }
+ break;
+ }
+ }
+ }
} else if (technique->getDirectional()) {
type = 1;
domLight::domTechnique_common::domDirectionalRef directional
@@ -620,11 +642,12 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
color = spot->getColor()->getValue();
linearFade = spot->getLinear_attenuation()->getValue() * 1000;
quadFade = spot->getQuadratic_attenuation()->getValue() * 1000;
+ LogWarning(ESceneGraphWarningCode_UnsupportedLight, GetNameOrIDOrSid(inNode));
}
// Collada does not seem to have info about casting shadows or light intensity.
// We'll use the defaults (intensity 100, no shadows)
- SetLightProperties(type,
- SFloat4(color.get(0), color.get(1), color.get(2), color.get(3)),
+ SetLightProperties(type, SFloat4(float(color.get(0)), float(color.get(1)),
+ float(color.get(2)), 1.0f),
100, linearFade, quadFade, false);
}
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
index 5bcf2dcf..9808c12d 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
@@ -53,6 +53,8 @@ typedef enum _ESceneGraphWarningCode {
ESceneGraphWarningCode_LockedDestFile,
// Mesh is missing a material.
ESceneGraphWarningCode_MissingMaterial,
+ // Unsupported light type.
+ ESceneGraphWarningCode_UnsupportedLight,
// For generic warnings.
ESceneGraphWarningCode_Generic
} ESceneGraphWarningCode;