summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorSergey Dubitskiy <sergey.dubitskiy@nokia.com>2012-03-13 10:35:58 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-14 20:12:38 +0100
commit4a4a033ae00831c5d741bcace48433a931ad7fc0 (patch)
tree258fc561ff4621c3089a05a543e91073a24b7e02 /src/plugins
parent234bf39096be424f56487b67756c07552a322963 (diff)
Set correct effect for all geometry nodes.
Before this fix objects were rendered flat white if only a subset of model's QGLSceneNode tree was rendered. Change-Id: Id008f16e00b2b26d0f5f984c72ba2073e4e734f2 Reviewed-by: Danny Pope <daniel.pope@nokia.com> Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sceneformats/assimp/qailoader.cpp23
-rw-r--r--src/plugins/sceneformats/assimp/qailoader.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/sceneformats/assimp/qailoader.cpp b/src/plugins/sceneformats/assimp/qailoader.cpp
index a9444b5b6..d866c2fa4 100644
--- a/src/plugins/sceneformats/assimp/qailoader.cpp
+++ b/src/plugins/sceneformats/assimp/qailoader.cpp
@@ -257,6 +257,8 @@ QGLSceneNode *QAiLoader::loadMeshes()
loadNodes(m_scene->mRootNode, m_root);
}
+ setEffectRecursive(m_root);
+
if (m_hasTextures) // make textures the default
{
m_root->setEffect(QGL::LitModulateTexture2D);
@@ -552,3 +554,24 @@ void QAiLoader::loadMaterial(aiMaterial *ma)
Q_UNUSED(k);
//qDebug() << "loaded material" << k << mq;
}
+
+/*!
+ set effects for all nodes
+*/
+void QAiLoader::setEffectRecursive(QGLSceneNode *node)
+{
+ if (node!=0) {
+ if (node->count()>0) {
+ if (qHasTextures(node)) {
+ node->setEffect(QGL::LitModulateTexture2D);
+ } else {
+ node->setEffect(QGL::LitMaterial);
+ }
+
+ }
+ QList<QGLSceneNode *> nodeChildren = node->children();
+ foreach (QGLSceneNode *ch, nodeChildren) {
+ setEffectRecursive(ch);
+ }
+ }
+}
diff --git a/src/plugins/sceneformats/assimp/qailoader.h b/src/plugins/sceneformats/assimp/qailoader.h
index 2381c585d..ad620d2a1 100644
--- a/src/plugins/sceneformats/assimp/qailoader.h
+++ b/src/plugins/sceneformats/assimp/qailoader.h
@@ -77,6 +77,7 @@ private:
void optimizeData();
void optimizeNodes(QGLSceneNode *node = 0, QGLSceneNode *parent = 0);
void countChildNodeReferences();
+ void setEffectRecursive(QGLSceneNode *node);
const aiScene *m_scene;
QGLSceneNode *m_root;