diff options
Diffstat (limited to 'src/plugins')
37 files changed, 0 insertions, 3795 deletions
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro deleted file mode 100644 index 19979051e..000000000 --- a/src/plugins/plugins.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = sceneformats diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri deleted file mode 100644 index 54d7da432..000000000 --- a/src/plugins/qpluginbase.pri +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = lib -isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.0 -} else { - VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} -} -CONFIG += qt plugin - -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release -TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols - -include(qt_targets.pri) - -wince*:LIBS += $$QMAKE_LIBS_GUI diff --git a/src/plugins/qt_targets.pri b/src/plugins/qt_targets.pri deleted file mode 100644 index 3b2046ea7..000000000 --- a/src/plugins/qt_targets.pri +++ /dev/null @@ -1,4 +0,0 @@ -QMAKE_TARGET_COMPANY = Nokia Corporation and/or its subsidiary(-ies) -QMAKE_TARGET_PRODUCT = Qt4 -QMAKE_TARGET_DESCRIPTION = C++ application development framework. -QMAKE_TARGET_COPYRIGHT = Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) diff --git a/src/plugins/sceneformats/assimp/README.txt b/src/plugins/sceneformats/assimp/README.txt deleted file mode 100644 index cabf1bdd8..000000000 --- a/src/plugins/sceneformats/assimp/README.txt +++ /dev/null @@ -1,12 +0,0 @@ -This importer uses the Asset Importer library available from: - -http://assimp.sourceforge.net/ - -Copyright (c) 2008-2010 ASSIMP Development Team -All rights reserved. - -For convenience a stripped down source tree is included in this distribution. See the license -included at $QT3D_SOURCE/3rdparty/assimp/LICENCE, or at http://assimp.sourceforge.net/main_license.html - -To use your own build of AssImp, modify the assimp.pro file and/or export the environment variables -specified there. diff --git a/src/plugins/sceneformats/assimp/ai_plugin.cpp b/src/plugins/sceneformats/assimp/ai_plugin.cpp deleted file mode 100644 index 9e1dbd6be..000000000 --- a/src/plugins/sceneformats/assimp/ai_plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ai_plugin.h" -#include "qaiscenehandler.h" - -QT_BEGIN_NAMESPACE - -QAiScenePlugin::QAiScenePlugin() {} -QAiScenePlugin::~QAiScenePlugin() {} - -QGLSceneFormatHandler *QAiScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QAiSceneHandler; -} - -QT_END_NAMESPACE - - diff --git a/src/plugins/sceneformats/assimp/ai_plugin.h b/src/plugins/sceneformats/assimp/ai_plugin.h deleted file mode 100644 index ea0696785..000000000 --- a/src/plugins/sceneformats/assimp/ai_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef AI_PLUGIN_H -#define AI_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QAiScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "ai_scene_plugin.json") -public: - QAiScenePlugin(); - ~QAiScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // AI_PLUGIN_H diff --git a/src/plugins/sceneformats/assimp/ai_scene_plugin.json b/src/plugins/sceneformats/assimp/ai_scene_plugin.json deleted file mode 100644 index a0c272e2b..000000000 --- a/src/plugins/sceneformats/assimp/ai_scene_plugin.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "Keys": [ - "3d", - "3ds", - "ac", - "ac3d", - "acc", - "ase", - "ask", - "b3d", - "blend", - "bvh", - "cob", - "csm", - "dae", - "dxf", - "enff", - "hmp", - "irr", - "irrmesh", - "lwo", - "lws", - "lxo", - "md2", - "md3", - "md5anim", - "md5camera", - "md5mesh", - "mdc", - "mdl", - "mesh.xml", - "mot", - "ms3d", - "ndo", - "nff", - "obj", - "off", - "pk3", - "ply", - "prj", - "q3o", - "q3s", - "raw", - "scn", - "smd", - "stl", - "ter", - "uc", - "vta", - "x", - "xml" - ] -} diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp b/src/plugins/sceneformats/assimp/ailoaderiostream.cpp deleted file mode 100644 index ecc6fe2ce..000000000 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ailoaderiostream.h" - -#include <QtCore/qiodevice.h> - -#include <QtCore/qdebug.h> - -AiLoaderIOStream::AiLoaderIOStream(QIODevice *device) - : m_device(device) - , m_errorState(false) -{ - Q_ASSERT(device); -} - -AiLoaderIOStream::~AiLoaderIOStream() -{ - // Nothing to do here -} - -size_t AiLoaderIOStream::Read( void* pvBuffer, size_t pSize, size_t pCount) -{ - qint64 result = m_device->read((char*)pvBuffer, pSize * pCount); - size_t res = result; - m_errorState = (result == -1); - if (m_errorState) - qWarning("AI read error: %s\n", qPrintable(m_device->errorString())); - if ((pSize * pCount) != res) // AI will treat as error - { - long unsigned int pSizeP = pSize; - long unsigned int pCountP = pCount; - long unsigned int pRes = res; - qWarning("read mismatch requested size: %lu x count: %lu = %lu != %lu actuall read\n", - pSizeP, pCountP, (pSizeP * pCountP), pRes); - } - return res; -} - -size_t AiLoaderIOStream::Write( const void* pvBuffer, size_t pSize, size_t pCount) -{ - qint64 result = m_device->write((char*)pvBuffer, pSize * pCount); - m_errorState = (result == -1); - if (m_errorState) - qWarning("AI write error: %s\n", qPrintable(m_device->errorString())); - return result; -} - -aiReturn AiLoaderIOStream::Seek(size_t pOffset, aiOrigin pOrigin) -{ - // cannot deal with sockets right now - Q_ASSERT(!m_device->isSequential()); - switch (pOrigin) - { - case aiOrigin_SET: - m_errorState = m_device->seek(pOffset); - break; - case aiOrigin_CUR: - m_errorState = m_device->seek(m_device->pos() + pOffset); - break; - case aiOrigin_END: - m_errorState = m_device->seek(m_device->size() + pOffset); - break; - default: - Q_ASSERT(0); - return(aiReturn_FAILURE); - } - if (m_errorState) - return aiReturn_FAILURE; - return aiReturn_SUCCESS; -} - -size_t AiLoaderIOStream::Tell() const -{ - return m_device->pos(); -} - -size_t AiLoaderIOStream::FileSize() const -{ - return m_device->size(); -} - -void AiLoaderIOStream::Flush() -{ - // do nothing -} diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.h b/src/plugins/sceneformats/assimp/ailoaderiostream.h deleted file mode 100644 index fa24ecab5..000000000 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef AILOADERIOSTREAM_H -#define AILOADERIOSTREAM_H - -#include <QtGlobal> -#include "IOStream.h" -#include "IOSystem.h" - -QT_BEGIN_NAMESPACE -class QIODevice; -QT_END_NAMESPACE - -class AiLoaderIOStream : public Assimp::IOStream -{ -public: - AiLoaderIOStream(QIODevice *device); - ~AiLoaderIOStream(); - size_t Read( void* pvBuffer, size_t pSize, size_t pCount); - size_t Write( const void* pvBuffer, size_t pSize, size_t pCount); - aiReturn Seek( size_t pOffset, aiOrigin pOrigin); - size_t Tell() const; - size_t FileSize() const; - void Flush(); - QIODevice *device() const { return m_device; } -private: - QIODevice *m_device; - bool m_errorState; -}; - -#endif // AILOADERIOSTREAM_H diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp b/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp deleted file mode 100644 index 222ed6d6e..000000000 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ailoaderiosystem.h" -#include "ailoaderiostream.h" -#include "DefaultLogger.h" - -#include <QtCore/qfile.h> -#include <QtCore/qdir.h> - -AiLoaderIOSystem::AiLoaderIOSystem(QIODevice *device, QUrl url) - : m_device(device) - , m_url(url) -{ -} - -AiLoaderIOSystem::~AiLoaderIOSystem() -{ - // we don't own m_device - qDeleteAll(m_sub); -} - -bool AiLoaderIOSystem::Exists(const char* path) const -{ - return m_device->isReadable(); -} - -char AiLoaderIOSystem::getOsSeparator() const -{ - return QDir::separator().toLatin1(); -} - -/*! - \internal - Open the pFile with the pMode, where mode is given by "man fopen" -*/ -Assimp::IOStream* AiLoaderIOSystem::Open(const char* pFile, const char* pMode) -{ - // This is just the file already opened on the device - if (m_url.toEncoded().endsWith(pFile)) - return new AiLoaderIOStream(m_device); - - // New relative file - QUrl rel; - rel.setScheme(m_url.scheme()); - rel.setPath(QLatin1String(pFile)); - QUrl url = m_url.resolved(rel); - - // TODO: handle network case - if (url.scheme() != QLatin1String("file")) - { - //network cases should already be opened by this stage - they - //depend entirely on the download manager returning a QBuffer, so - //cannot be handled as the simple "open file" case shown below. - qWarning("Directly opening a network URL is not supported. Use scene handler code. (URL: %s).", qPrintable(url.scheme())); - return 0; - } - - char mode_str[4]; - memset(mode_str, '\0', 4); - int i = 0; - for (const char *ptr = pMode; i < 4 && *ptr; ++ptr) - { - if (*ptr != 'b') // ignore the binary attribute - mode_str[i++] = *ptr; - } - QIODevice::OpenMode mode = QIODevice::NotOpen; - if (::strncmp("r", mode_str, 1) == 0) - { - mode = QIODevice::ReadOnly; - } - else if (::strncmp("r+", mode_str, 2) == 0) - { - mode = QIODevice::ReadWrite; - } - else if (::strncmp("w", mode_str, 1) == 0) - { - mode = QIODevice::WriteOnly | QIODevice::Truncate; - } - else if (::strncmp("w+", mode_str, 2) == 0) - { - mode = QIODevice::ReadWrite | QIODevice::Truncate; - } - else if (::strncmp("a", mode_str, 1) == 0) - { - mode = QIODevice::WriteOnly | QIODevice::Append; - } - else if (::strncmp("a+", mode_str, 2) == 0) - { - mode = QIODevice::ReadWrite | QIODevice::Append; - } - else - { - std::string err("Error: invalid mode flag:"); - err.append(mode_str).append(" when opening ").append(pFile); - Assimp::DefaultLogger::get()->warn(err); - return 0; - } - - QFile *f = new QFile(url.toLocalFile()); - bool res = f->open(mode); - if (!res) - { - std::string err("Error: could not open subsequent file:"); - err.append(pFile).append("--").append(f->errorString().toAscii().constData()); - Assimp::DefaultLogger::get()->warn(err); - delete f; - return 0; - } - m_sub.append(f); - AiLoaderIOStream *s = new AiLoaderIOStream(f); - return s; -} - -void AiLoaderIOSystem::Close(Assimp::IOStream* stream) -{ - AiLoaderIOStream *s = static_cast<AiLoaderIOStream*>(stream); - Q_ASSERT(s); - s->device()->close(); - delete stream; -} diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.h b/src/plugins/sceneformats/assimp/ailoaderiosystem.h deleted file mode 100644 index c3d4c4527..000000000 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef AILOADERIOSYSTEM_H -#define AILOADERIOSYSTEM_H - -#include "IOSystem.h" - -#include <QtCore/qurl.h> - -QT_BEGIN_NAMESPACE -class QIODevice; -QT_END_NAMESPACE - -class IOStream; - -class AiLoaderIOSystem : public Assimp::IOSystem -{ -public: - AiLoaderIOSystem(QIODevice *device, QUrl url); - ~AiLoaderIOSystem(); - virtual bool Exists( const char* path) const; - virtual char getOsSeparator() const; - virtual Assimp::IOStream* Open(const char* pFile, const char* pMode = "rb"); - virtual void Close(Assimp::IOStream* pFile); -private: - QIODevice *m_device; - QList<QIODevice*> m_sub; - QUrl m_url; -}; - -#endif // AILOADERIOSYSTEM_H diff --git a/src/plugins/sceneformats/assimp/assimp.pro b/src/plugins/sceneformats/assimp/assimp.pro deleted file mode 100644 index 5a0fca51d..000000000 --- a/src/plugins/sceneformats/assimp/assimp.pro +++ /dev/null @@ -1,47 +0,0 @@ -TARGET = qsceneai -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) -HEADERS += qailoader.h \ - qaiscene.h \ - qaiscenehandler.h \ - qaimesh.h \ - ailoaderiostream.h \ - ailoaderiosystem.h \ - ai_plugin.h -SOURCES += \ - qailoader.cpp \ - qaiscene.cpp \ - qaiscenehandler.cpp \ - qaimesh.cpp \ - ailoaderiostream.cpp \ - ailoaderiosystem.cpp \ - ai_plugin.cpp - -OTHER_FILES += \ - ai_scene_plugin.json - - - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target - -# suppress warnings about std::copy using unsafe parameters -win32: DEFINES +=_SCL_SECURE_NO_WARNINGS - -system_ai { - !isEmpty(QMAKE_INCDIR_AI):INCLUDEPATH += $$QMAKE_INCDIR_AI - !isEmpty(QMAKE_LIBDIR_AI):LIBS += -L$$QMAKE_LIBDIR_AI - - !isEmpty(QMAKE_LIBS_AI):LIBS += -l$$QMAKE_LIBS_AI - else { - win32:LIBS += -llibai-1_3 - else:LIBS += -lai - } -} else { - include(../../../../3rdparty/assimp/assimp.pri) -} - diff --git a/src/plugins/sceneformats/assimp/qailoader.cpp b/src/plugins/sceneformats/assimp/qailoader.cpp deleted file mode 100644 index d866c2fa4..000000000 --- a/src/plugins/sceneformats/assimp/qailoader.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qailoader.h" -#include "qaiscenehandler.h" -#include "qaiscene.h" -#include "qaimesh.h" - -#include "qgeometrydata.h" -#include "qgltwosidedmaterial.h" -#include "qglmaterial.h" -#include "qglmaterialcollection.h" -#include "qglpainter.h" -#include "qgltexture2d.h" -#include "qglscenenode.h" -#include "qlogicalvertex.h" - -#include "aiScene.h" -#include "aiMaterial.h" -#include "aiMesh.h" -#include "DefaultLogger.h" - -#include <QtCore/qdir.h> -#include <QtCore/qobject.h> -#include <QtCore/qfileinfo.h> - -QAiLoader::QAiLoader(const aiScene *scene, QAiSceneHandler* handler) - : m_scene(scene) - , m_root(0) - , m_handler(handler) - , m_hasTextures(false) - , m_hasLitMaterials(false) - , m_builder(new QGLMaterialCollection(m_root)) -{ -} - -QAiLoader::~QAiLoader() -{ - // nothing to do here - m_rootNode is taken ownership of by caller of - // rootNode() method -} - -static inline void assertOnePrimitiveType(aiMesh *mesh) -{ -#ifndef QT_NO_DEBUG - int k = 0; // count the number of bits set in the primitives - unsigned int msk = 0x01; - for (unsigned int p = mesh->mPrimitiveTypes; p; p >>= 1) - if (p & msk) - ++k; - Q_ASSERT(k == 1); // Assimp SortByPType promises this -#else - Q_UNUSED(mesh); -#endif -} - -static inline bool qHasTextures(const QGLSceneNode *node) -{ - QGLMaterial *mat = node->material(); - for (int i = 0; i < mat->textureLayerCount(); ++i) - if (node->material()->texture(i)) - return true; - return false; -} - -void QAiLoader::loadMesh(aiMesh *mesh) -{ - QString name = QString::fromUtf8(mesh->mName.data, mesh->mName.length); - // qDebug() << "loadMesh" << name << "with" << mesh->mNumVertices << "vertices" - // << "and" << mesh->mNumFaces << "faces"; - - assertOnePrimitiveType(mesh); - - if (mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE) - { - m_builder.newSection(); - QGLSceneNode *node = m_builder.currentNode(); - node->setObjectName(name); - QAiMesh m(mesh); - m.build(m_builder, m_handler->showWarnings()); - m_meshes.append(node); - if (qHasTextures(node)) - m_hasTextures = true; - else - m_hasLitMaterials = true; - } - else - { - // TODO: Implement other types in qaimesh.cpp - if (m_handler->showWarnings()) - { - QString error = QLatin1String("Bad primitive type in mesh %1 : %2"); - error = error.arg(name).arg(mesh->mPrimitiveTypes); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - } - - if (m_handler->showWarnings()) - { - if (!(m_handler->removeComponentFlags() & aiComponent_COLORS)) - { - // TODO: Implement models with per vertex colors. Ok, the - // vertex colors were wanted but are not supported yet. - for (int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) - { - if (mesh->HasVertexColors(i)) - { - QString error = QLatin1String( - "Found color information in mesh %1, channel %2" - "- per vertex color not yet supported"); - error = error.arg(name).arg(i); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - break; - } - } - } - if (mesh->HasBones()) - { - // TODO: Implement skeletal animation - QString error = QLatin1String("Bones in mesh %1 not yet supported"); - error.arg(name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - if (mesh->HasTangentsAndBitangents()) - { - // TODO: Implement normal maps - here and in the texture import - QString error = QLatin1String("Tangents for normal map in mesh %1 not yet supported"); - error.arg(name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - } -} - -inline static QMatrix4x4 getNodeMatrix(aiNode *node) -{ - QMatrix4x4 nodeMatrix; - if (node->mTransformation.IsIdentity()) - return nodeMatrix; - aiQuaternion rotation; - aiVector3D position; - aiVector3D scale; - node->mTransformation.Decompose(scale, rotation, position); - QVector3D qscale(scale.x,scale.y, scale.z); - QVector3D qposition(position.x, position.y, position.z); - QQuaternion qrotation(rotation.w, rotation.x, rotation.y, rotation.z); - if (!qscale.isNull()) - nodeMatrix.scale(qscale); - if (!qposition.isNull()) - nodeMatrix.translate(qposition); - if (!qrotation.isNull()) - nodeMatrix.rotate(qrotation); - return nodeMatrix; -} - -void QAiLoader::loadNodes(aiNode *nodeList, QGLSceneNode *parentNode) -{ - QMap<aiNode *, QGLSceneNode *>::const_iterator it = m_nodeMap.constFind(nodeList); - QGLSceneNode *node = 0; - if (it == m_nodeMap.constEnd()) // not found - { - node = new QGLSceneNode(parentNode); - m_nodes.append(node); - QString name = QString::fromUtf8(nodeList->mName.data, nodeList->mName.length); - if (name.isEmpty()) - name = QString(QLatin1String("aiNode %1")).arg(m_nodes.size()); - node->setObjectName(name); - QMatrix4x4 mat = getNodeMatrix(nodeList); - if (!mat.isIdentity()) - node->setLocalTransform(mat); - for (unsigned int i = 0; i < nodeList->mNumChildren; ++i) - loadNodes(nodeList->mChildren[i], node); - for (unsigned int i = 0; i < nodeList->mNumMeshes; ++i) - { - int n = nodeList->mMeshes[i]; - if (n < m_meshes.size()) - node->addNode(m_meshes.at(n)); - } - } - else - { - node = it.value(); - parentNode->addNode(node); - } -} - -/*! - \internal - Loads all the geometry, materials, and texture associations from the assigned - file, and returns the root node of the resulting scene graph. - - The caller must take ownership of the root node returned, and delete it - when its no longer required. -*/ -QGLSceneNode *QAiLoader::loadMeshes() -{ - Q_ASSERT(m_scene); - for (unsigned int i = 0; i < m_scene->mNumMaterials; ++i) - loadMaterial(m_scene->mMaterials[i]); - - // builds a naive scene heierarchy with all meshes under the root node - for (unsigned int i = 0; i < m_scene->mNumMeshes; ++i) - loadMesh(m_scene->mMeshes[i]); - - // fetch the naive scene heierarchy from the builder - m_root = m_builder.finalizedSceneNode(); - - QString name = m_handler->url().path(); - int pos = name.lastIndexOf("/"); - if (pos == -1) - pos = name.lastIndexOf("\\"); - if (pos != -1) - name = name.mid(pos+1); - m_root->setObjectName(name); - - // if scene has a node heierarchy replace the naive heierarchy with that - if (m_scene->mRootNode->mNumChildren > 0 && m_scene->mRootNode->mChildren) - { - m_root->removeNodes(m_root->children()); - loadNodes(m_scene->mRootNode, m_root); - } - - setEffectRecursive(m_root); - - if (m_hasTextures) // make textures the default - { - m_root->setEffect(QGL::LitModulateTexture2D); - if (m_hasLitMaterials) - { - for (int i = 0; i < m_meshes.size(); ++i) - if (!qHasTextures(m_meshes.at(i))) - m_meshes.at(i)->setEffect(QGL::LitMaterial); - } - } - else - { - m_root->setEffect(QGL::LitMaterial); - } - - if (m_handler->showWarnings()) - { - QString message = QLatin1String("AssetImporter loader %1 -- " - "Mesh count: %2 -- Node count: %3 -- " - "Material count: %4"); - QUrl url = m_handler->url(); - message = message.arg(url.toString()).arg(m_meshes.size()) - .arg(m_nodes.size()).arg(m_root->palette()->size()); - Assimp::DefaultLogger::get()->warn(message.toAscii().constData()); - } - -//#define DEBUG_ME -#ifdef DEBUG_ME - qDumpScene(m_root); - - QList<QGLSceneNode*> c = m_root->allChildren(); - QSet<quint64> debugged; - for (int i = 0; i < c.size(); ++i) - { - if (c.at(i)->geometry().count() > 0) - { - QGeometryData g = c.at(i)->geometry(); - qDebug() << "geometry for:" << c.at(i) << "is:" << g.id(); - if (!debugged.contains(g.id())) - { - qDebug() << g; - debugged.insert(g.id()); - } - } - } -#endif - - return m_root; -} - -/*! - TODO: docs - */ -QList<QGLSceneAnimation *> QAiLoader::loadAnimations() -{ - Q_ASSERT(m_scene); - m_animations.clear(); - - for (unsigned int i=0; i<m_scene->mNumAnimations; ++i) { - m_animations.append( new QGLSceneAnimation( QString(m_scene->mAnimations[i]->mName.data), 0 ) ); - } - - return m_animations; -} - -/*! - \internal - Search for a resource based on the given \a path. - - If the URL for the currently loading mesh has a scheme other than - "file" then a URL with the path relative to that URL is returned. - - If the URL for the currently loading mesh has a "file" scheme, then - first a case-sensitive search is done of all of the current directory, - and the :/ resource directory, and the directory of the current mesh - file. - - If the file is not found in any of those locations then they are - searched again case-insensitively. If the file is found, then a - URL based on the absolute file path of the matching file is returned. - - Otherwise an empty string is returned. -*/ -QUrl QAiLoader::ensureResource(const QString &path) -{ - QUrl res; - QUrl base = m_handler->url(); - if (base.scheme() == QLatin1String("file")) - { - res = base.resolved(path); - //qDebug() << "ensureResource - base:" << base - // << " -- path:" << path << "-- resolved:" << res; - if (QFile::exists(res.path())) // shortcut common case - return res; - QStringList paths; - paths << QLatin1String(".") << QLatin1String(":/"); // current directory and aliased/root resource file - if (!base.isEmpty()) - { - QFileInfo fi(base.path()); - paths.prepend(fi.absoluteDir().absolutePath()); - } - bool caseInsensitive = false; - do { - QStringList::const_iterator it(paths.begin()); - for ( ; it != paths.end(); ++it) - { - QDir resDir(*it); - QStringList fileList = resDir.entryList(QDir::Files); - if (caseInsensitive) - { - QStringList::const_iterator fit(fileList.begin()); - for ( ; fit != fileList.end(); ++fit) - { - if (fit->toLower() == path.toLower()) - { - res.setScheme(QLatin1String("file")); - res.setPath(resDir.absoluteFilePath(*fit)); - break; - } - } - } - else - { - if (fileList.contains(path)) - { - //return resDir.absoluteFilePath(path); - res.setScheme(QLatin1String("file")); - res.setPath(resDir.absoluteFilePath(path)); - break; - } - } - } - if (caseInsensitive) - break; - caseInsensitive = true; - } while (true); - } - else - { - // non-file url - res = base.resolved(path); - } - return res; -} - -void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq) -{ - int texCount; - aiTextureType texType; - if (m_handler->showWarnings()) - { - // TODO: AssImp has a very rich set of texture related functionality - // but until things in this list get implemented, all are just going - // to get ignored, tho' they will generate a warning in verbose mode. - // So for now, its just inside this conditional - move it out once - // implementation of these items begins. - static const char * typeNames[] = { - "None", - "Diffuse", - "Specular", - "Ambient", - "Emissive", - "Height", - "Normals", - "Shininess", - "Opacity", - "Displacement", - "Lightmap", - "Reflection", - "Unknown", - 0 - }; - - for (unsigned int i = 0; i <= aiTextureType_UNKNOWN; ++i) - { - texType = static_cast<aiTextureType>(i); - texCount = ma->GetTextureCount(texType); - if (texCount && texType != aiTextureType_DIFFUSE) - { - QString error = QLatin1String("Unsupported texture type \"%1\" in material \"%2\"."); - error.arg(typeNames[i]).arg(mq->objectName()); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - } - } - // TODO: For now assume the only texture we care about is the diffuse one - // - texCount = ma->GetTextureCount(aiTextureType_DIFFUSE); - if (texCount > 0) - { - if (texCount > 1 && m_handler->showWarnings()) - { - QString error = QLatin1String("Multi-textures not supported: \"%1\" has %2"); - error.arg(mq->objectName()).arg(texCount); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - else - { - aiString path; - ma->Get(AI_MATKEY_TEXTURE_DIFFUSE(0), path); - QString qpath = QString::fromUtf8(path.data, path.length); - QUrl url = ensureResource(qpath); - if (url.isEmpty()) - { - if (m_handler->showWarnings()) - { - QString error = QLatin1String("Could not load texture: %1 for material %2"); - error.arg(url.toString()).arg(mq->objectName()); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - } - else - { - mq->setTextureUrl(url); - } - } - } -} - -/*! - Load a material -*/ -void QAiLoader::loadMaterial(aiMaterial *ma) -{ - QGLMaterial *mq = new QGLMaterial; - mq->setObjectName("___DEFAULT_NAME___"); - - bool isTwoSided = false; - bool isWireframe = false; - struct aiColor4D clr; - float shininess; - float amplitude; - - aiReturn r; - - // In AssImp if the material is two sided then it means cull face - // should be turned off: http://assimp.sourceforge.net/lib_html/materials.html - r = ma->Get(AI_MATKEY_TWOSIDED, isTwoSided); - if (r == aiReturn_SUCCESS && isTwoSided) - mq->setProperty("isTwoSided", isTwoSided); - - aiString aName; - r = ma->Get(AI_MATKEY_NAME, aName); - if (r == aiReturn_SUCCESS && aName.length > 0) - mq->setObjectName(QLatin1String(aName.data)); - - r = ma->Get(AI_MATKEY_COLOR_AMBIENT, clr); - if (r == aiReturn_SUCCESS) - mq->setAmbientColor(QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a)); - - r = ma->Get(AI_MATKEY_COLOR_DIFFUSE, clr); - if (r == aiReturn_SUCCESS) - mq->setDiffuseColor(QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a)); - - r = ma->Get(AI_MATKEY_COLOR_SPECULAR, clr); - if (r == aiReturn_SUCCESS) - { - QColor spec = QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a); - mq->setSpecularColor(spec); - - // By default the specular color is black - very dark. - // If the specular color is bright be careful with shininess - - // a shininess of 0 will blow everything out to full white. So in - // the case of bad materials with this problem, set shiness low. - mq->setShininess(64.0); - } - - r = ma->Get(AI_MATKEY_SHININESS, shininess); - if (r == aiReturn_SUCCESS) - mq->setShininess(shininess); - - r = ma->Get(AI_MATKEY_SHININESS_STRENGTH, amplitude); - if (r == aiReturn_SUCCESS) - mq->setShininess(shininess * amplitude); - - r = ma->Get(AI_MATKEY_ENABLE_WIREFRAME, isWireframe); - if (r == aiReturn_SUCCESS && isWireframe) - mq->setProperty("isWireFrame", isWireframe); - - loadTextures(ma, mq); - - // INVARIANT: since we create the palette newly in this class, and this - // function is the only place we add materials to this palette, the index - // values (the positions in the palette generated by this call to addMaterial) - // will exactly match the index values of the materials traversed in the - // for loop in loadMeshes() - so therefore AI's index values and the ones in - // the palette will be the same. - // - // executive summary: don't muck around with the palettte outside of this call - - int k = m_builder.palette()->addMaterial(mq); - - 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 deleted file mode 100644 index 988ba224e..000000000 --- a/src/plugins/sceneformats/assimp/qailoader.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAILOADER_H -#define QAILOADER_H - -#include <QtCore/qurl.h> -#include <QtCore/qstring.h> -#include <QtCore/qmap.h> - -#include "aiScene.h" - -#include "qglbuilder.h" - -struct aiMaterial; - -QT_BEGIN_NAMESPACE - -class QAiMesh; -class QAiScene; -class QGLSceneNode; -class QAiSceneHandler; -class QGLSceneAnimation; -class QGLMaterial; - -class QAiLoader -{ -public: - QAiLoader(const aiScene *scene, QAiSceneHandler* handler); - ~QAiLoader(); - QGLSceneNode *loadMeshes(); - QList<QGLSceneAnimation *> loadAnimations(); - -private: - friend class QAiScene; - - void loadMesh(aiMesh *); - void loadNodes(aiNode *, QGLSceneNode *); - void loadMaterial(aiMaterial *); - void loadTextures(aiMaterial *, QGLMaterial *); - QUrl ensureResource(const QString &); - void optimizeData(); - void optimizeNodes(QGLSceneNode *node = 0, QGLSceneNode *parent = 0); - void countChildNodeReferences(); - void setEffectRecursive(QGLSceneNode *node); - - const aiScene *m_scene; - QGLSceneNode *m_root; - QAiSceneHandler *m_handler; - QList<QGLSceneNode *> m_nodes; - QList<QGLMaterial *> m_materials; - QList<QGLSceneNode *> m_meshes; - QMap<aiNode *, QGLSceneNode *> m_nodeMap; - QMap<QGLSceneNode *, int> m_refCounts; - QList<QGLSceneAnimation *> m_animations; - bool m_hasTextures; - bool m_hasLitMaterials; - QGLBuilder m_builder; -}; - -QT_END_NAMESPACE - -#endif // QAILOADER_H diff --git a/src/plugins/sceneformats/assimp/qaimesh.cpp b/src/plugins/sceneformats/assimp/qaimesh.cpp deleted file mode 100644 index 918f36af0..000000000 --- a/src/plugins/sceneformats/assimp/qaimesh.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaimesh.h" -#include "qglscenenode.h" -#include "qglmaterialcollection.h" -#include "qglbuilder.h" - -#include <QtGui/qmatrix4x4.h> -#include <QtCore/qmath.h> - -#include "aiMesh.h" -#include "DefaultLogger.h" - -QAiMesh::QAiMesh(aiMesh *mesh) - : m_mesh(mesh) -{ -} - -QAiMesh::~QAiMesh() -{ -} - -static inline QVector2D qv2d(const aiVector3D &v) -{ - return QVector2D(v.x, v.y); -} - -static inline QVector2D qv2d_inv(const aiVector3D &v) -{ - // invert the v coord because Qt is upside-down - return QVector2D(v.x, (1.0 - v.y)); -} - -static inline QVector3D qv3d(const aiVector3D &v) -{ - return QVector3D(v.x, v.y, v.z); -} - -void QAiMesh::loadTriangles(QGLBuilder &builder) -{ - QGeometryData data; - for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i) - data.appendVertex(qv3d(m_mesh->mVertices[i])); - if (m_mesh->HasNormals()) - for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i) - data.appendNormal(qv3d(m_mesh->mNormals[i])); - int k = m_mesh->GetNumUVChannels(); - for (int t = 0; t < k; ++t) - { - if (m_mesh->mNumUVComponents[t] != 2) - Assimp::DefaultLogger::get()->warn("Tex co-ords only supports U & V"); - QGLMaterial *m = builder.currentNode()->material(); - if (m && m->textureUrl().path().endsWith(".dds", Qt::CaseInsensitive)) - { - for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i) - data.appendTexCoord(qv2d_inv(m_mesh->mTextureCoords[t][i]), static_cast<QGL::VertexAttribute>(QGL::TextureCoord0 + t)); - } - else - { - for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i) - data.appendTexCoord(qv2d(m_mesh->mTextureCoords[t][i]), static_cast<QGL::VertexAttribute>(QGL::TextureCoord0 + t)); - } - } - - for (unsigned int i = 0; i < m_mesh->mNumFaces; ++i) - { - aiFace *face = &m_mesh->mFaces[i]; - data.appendIndices(face->mIndices[0], face->mIndices[1], face->mIndices[2]); - } - - // raw triangle mode - builder.addTriangles(data); -} - -void QAiMesh::build(QGLBuilder &builder, bool showWarnings) -{ - QGLSceneNode *node = builder.currentNode(); - QString name = node->objectName(); - - if (!m_mesh->HasFaces() || !m_mesh->HasPositions()) - { - if (showWarnings) - { - QString error = QLatin1String("Mesh %1 has zero vertex/face count"); - error.arg(name.isEmpty() ? QString(QLatin1String("<unnamed mesh>")) : name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); - } - return; - } - - node->setMaterialIndex(m_mesh->mMaterialIndex); - node->palette()->markMaterialAsUsed(m_mesh->mMaterialIndex); - - if (m_mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE) - loadTriangles(builder); - else - return; // TODO - lines, points, quads, polygons - - QGLMaterial * mat = node->palette()->material(m_mesh->mMaterialIndex); - if (mat->property("isTwoSided").isValid() && mat->property("isTwoSided").toBool()) - node->setBackMaterialIndex(m_mesh->mMaterialIndex); - if (mat->property("isWireFrame").isValid() && mat->property("isWireFrame").toBool()) - node->setDrawingMode(QGL::Lines); -} diff --git a/src/plugins/sceneformats/assimp/qaimesh.h b/src/plugins/sceneformats/assimp/qaimesh.h deleted file mode 100644 index 87dc75460..000000000 --- a/src/plugins/sceneformats/assimp/qaimesh.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAIMESH_H -#define QAIMESH_H - -#include "qaiscenehandler.h" -#include "qgeometrydata.h" - -struct aiMesh; - -QT_BEGIN_NAMESPACE - -class QGLMaterialCollection; -class QGLSceneNode; -class QGLBuilder; -class QAiLoader; - -class QAiMesh -{ -public: - QAiMesh(aiMesh *mesh); - virtual ~QAiMesh(); - - void build(QGLBuilder &builder, bool showWarnings = false); -private: - void loadTriangles(QGLBuilder &builder); - - aiMesh *m_mesh; -}; - -QT_END_NAMESPACE - -#endif // QAIMESH_H diff --git a/src/plugins/sceneformats/assimp/qaiscene.cpp b/src/plugins/sceneformats/assimp/qaiscene.cpp deleted file mode 100644 index 5634855f9..000000000 --- a/src/plugins/sceneformats/assimp/qaiscene.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaiscene.h" -#include "qaimesh.h" -#include "qailoader.h" - -#include "qglscenenode.h" - -QT_BEGIN_NAMESPACE - -/*! - \internal - \class QAiScene - \brief The QAiScene class manages and contains an asset importer scene. - The scene consists of a QGLSceneNode object which is the top-level node - and references the geometry imported from a file. -*/ - -/*! - \internal - Construct a new QAiScene object using the data in the \a scene, - and setting the given \a parent. - - The QAiScene object takes ownership of the \a file. -*/ -QAiScene::QAiScene(const aiScene *scene, QAiSceneHandler *handler) - : QGLAbstractScene(0) -{ - Q_ASSERT(handler); - Q_ASSERT(scene); - QAiLoader loader(scene, handler); - m_root = loader.loadMeshes(); - m_root->setParent(this); - m_animations = loader.loadAnimations(); - m_aiLoader = 0; -} - -/*! - \internal - Construct a new QAiScene object and setting the given \a handler. - - Note that the scene which will be used to generate the QAiScene has - not been added yet - this is used in the network case and requires - a later call to the loadScene function to work correctly - - \sa loadScene() -*/ -QAiScene::QAiScene(QAiSceneHandler *handler) - : QGLAbstractScene(0) -{ - Q_ASSERT(handler); - //create a temporary loader and get a temporary root node for the scene. - m_aiLoader = new QAiLoader(0, handler); - m_root=m_aiLoader->m_builder.sceneNode(); -} - -/*! - \internal - \reimp - Destroy this QAiScene, recovering all resources. -*/ -QAiScene::~QAiScene() -{ - delete m_aiLoader; -} - -/*! - \internal - \reimp -*/ -QList<QObject *> QAiScene::objects() const -{ - QList<QObject *> objs; - if (!m_root) - return objs; - objs.append(m_root); - QList<QGLSceneNode*> children = m_root->allChildren(); - QList<QGLSceneNode*>::const_iterator it = children.constBegin(); - for ( ; it != children.constEnd(); ++it) - objs.append(*it); - return objs; -} - -/*! - \internal - \reimp -*/ -QGLSceneNode *QAiScene::mainNode() const -{ - return m_root; -} - -/*! - \internal - Returns the aiLoader associated with the scene (if any). -*/ -QAiLoader * QAiScene::aiLoader() const -{ - return m_aiLoader; -} - -/*! - \internal - Load the new \a scene and swap the extant palette from the temporary roote - node into the current root node. - - The QAiScene object takes ownership of the \a file. -*/ -void QAiScene::loadScene(const aiScene *scene) -{ - Q_ASSERT(scene); - - //Get the old material information - QSharedPointer<QGLMaterialCollection>oldPalette= m_aiLoader->m_builder.palette(); - int oldIndex = m_root->materialIndex(); - - //Reset the palette for the root node. - QSharedPointer<QGLMaterialCollection>newPalette = QSharedPointer<QGLMaterialCollection>(new QGLMaterialCollection()); - m_aiLoader->m_builder.sceneNode()->setPalette(newPalette); - m_aiLoader->m_scene = scene; - - //Commence loading of the mesh. - m_root = m_aiLoader->loadMeshes(); //this won't actually change the root unless we've messed up. - delete m_aiLoader; - m_aiLoader = 0; - - //Swap out the materials palette - int indexCount=0; - int materialCount=0; - QGLMaterial * currentMaterial = NULL; - do { - currentMaterial = oldPalette->removeMaterial(indexCount); - if (currentMaterial) { - materialCount = m_root->palette()->addMaterial(currentMaterial); - indexCount++; - } - } while (currentMaterial); - m_root->setMaterialIndex(materialCount-(indexCount-1)+oldIndex); - - //update picking nodes for the whole scene if needed - if (pickable()) generatePickNodes(); - - emit sceneUpdated(); -} - -QList<QGLSceneAnimation *> QAiScene::animations() const -{ - return m_animations; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/assimp/qaiscene.h b/src/plugins/sceneformats/assimp/qaiscene.h deleted file mode 100644 index e1543a595..000000000 --- a/src/plugins/sceneformats/assimp/qaiscene.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAISCENE_H -#define QAISCENE_H - -#include "qglabstractscene.h" - -#include "aiScene.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class QGLSceneNode; -class QAiSceneHandler; -class QAiLoader; - -class QAiScene : public QGLAbstractScene -{ - Q_OBJECT -public: - explicit QAiScene(const aiScene *scene, QAiSceneHandler *handler); - explicit QAiScene(QAiSceneHandler *handler); - virtual ~QAiScene(); - - //load a scene with the current handler - void loadScene(const aiScene*scene); - - QList<QObject *> objects() const; - QGLSceneNode *mainNode() const; - QList<QGLSceneAnimation *> animations() const; -private: - QAiLoader * aiLoader() const; - QList<QGLSceneAnimation *> m_animations; -protected: - QGLSceneNode *m_root; - QAiLoader *m_aiLoader; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp b/src/plugins/sceneformats/assimp/qaiscenehandler.cpp deleted file mode 100644 index 27add9b28..000000000 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp +++ /dev/null @@ -1,449 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaiscenehandler.h" -#include "qaiscene.h" -#include "qdownloadmanager.h" -#include "ailoaderiosystem.h" - -#include "aiScene.h" -#include "aiPostProcess.h" -#include "DefaultLogger.h" - -#include <QtCore/qdir.h> -#include <QtCore/qdebug.h> -#include <QObject> -#include <QBuffer> - - -#define qAiPostProcessPreset ( \ - aiProcess_CalcTangentSpace | \ - aiProcess_GenSmoothNormals | \ - aiProcess_JoinIdenticalVertices | \ - aiProcess_ImproveCacheLocality | \ - aiProcess_LimitBoneWeights | \ - aiProcess_RemoveRedundantMaterials | \ - aiProcess_SplitLargeMeshes | \ - aiProcess_Triangulate | \ - aiProcess_GenUVCoords | \ - aiProcess_SortByPType | \ - aiProcess_FindDegenerates | \ - aiProcess_FindInvalidData ) - -QT_BEGIN_NAMESPACE - -void DumpScene(const aiScene* pScene); - -QAiSceneHandler::QAiSceneHandler() - : m_options(qAiPostProcessPreset) - , m_showWarnings(false) - , m_mayHaveLinesPoints(false) - , m_meshSplitVertexLimit(2000) - , m_meshSplitTriangleLimit(2000) - , m_removeComponentFlags(0) - , m_removeSortFlags(0) -{ - // by default remove per vertex colors from the data - no-one uses that in - // models - if they need it it can be turned on with UseVertexColors - m_removeComponentFlags |= aiComponent_COLORS; - - // by default remove points and lines from the model, since these are usually - // degenerate structures from bad modelling or bad import/export. if they - // are needed it can be turned on with IncludeLinesPoints - m_removeSortFlags |= aiPrimitiveType_POINT | aiPrimitiveType_LINE; -} - -QAiSceneHandler::~QAiSceneHandler() -{ - // nothing to do -} - -void QAiSceneHandler::decodeOptions(const QString &options) -{ - if (options.isEmpty()) - return; - - // See aiPostProcess.h for aiProcessPreset_TargetRealtime_Quality - // - a useful default set of values - its exactly what we want but - // wont compile with flags, so redefined with the above macro. - // Also, allow the user to override some settings - m_options = qAiPostProcessPreset; - - // Has to match the enum - static const char *validOptions[] = { - "NoOptions", - "ShowWarnings", - "CalculateNormals", - "ForceFaceted", - "ForceSmooth", - "IncludeAllMaterials", - "IncludeLinesPoints", - "FixNormals", - "DeDupMeshes", - "Optimize", - "FlipUVs", - "FlipWinding", - "UseVertexColors", - "VertexSplitLimitx2", - "TriangleSplitLimitx2", - 0 - }; - - QStringList opList = options.simplified().split(QLatin1Char(' '), QString::SkipEmptyParts); - - for (int i = 0; i < opList.count(); ++i) - { - QString op = opList.at(i); - op = op.trimmed(); - int k = 0; - for ( ; validOptions[k]; ++k) - if (op == QString::fromLatin1(validOptions[k])) - break; - if (validOptions[k]) // found - { - Options o = static_cast<Options>(k); - switch (o) - { - case NoOptions: - break; - case ShowWarnings: - if (m_showWarnings) - { - m_importer.SetExtraVerbose(true); - } - else - { - m_showWarnings = true; - m_options |= aiProcess_ValidateDataStructure; - } - break; - case CalculateNormals: - m_removeComponentFlags |= aiComponent_NORMALS; - m_options |= aiProcess_GenSmoothNormals; - m_options &= ~aiProcess_GenNormals; - break; - case ForceFaceted: - m_removeComponentFlags |= aiComponent_NORMALS; - m_options |= aiProcess_GenNormals; - m_options &= ~aiProcess_GenSmoothNormals; - m_options &= ~aiProcess_JoinIdenticalVertices; - break; - case ForceSmooth: - Assimp::DefaultLogger::get()->warn("ForceSmooth is deprecated - ignoring (meshes now smooth by default)"); - break; - case IncludeAllMaterials: - m_options &= ~aiProcess_RemoveRedundantMaterials; - break; - case IncludeLinesPoints: - m_removeSortFlags &= ~(aiPrimitiveType_LINE | aiPrimitiveType_POINT); - m_mayHaveLinesPoints = true; - // leave it with the FindDegenerates option turned on - we want zero - // area triangles to display as proper GL lines or points - break; - case FixNormals: - m_options |= aiProcess_FixInfacingNormals; - break; - case DeDupMeshes: - m_options |= aiProcess_FindInstances; - break; - case Optimize: - m_options |= aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes; - break; - case FlipUVs: - m_options |= aiProcess_FlipUVs; - break; - case FlipWinding: - m_options |= aiProcess_FlipWindingOrder; - break; - case UseVertexColors: - m_removeComponentFlags &= ~aiComponent_COLORS; - break; - case VertexSplitLimitx2: - m_meshSplitVertexLimit <<= 1; - // repeating this in the option string more than once works... - break; - case TriangleSplitLimitx2: - // ....and we're OK with that, just don't overdo it - m_meshSplitTriangleLimit <<= 1; - break; - } - } - else - { - qWarning("Bad option: \"%s\" in %s", qPrintable(op), - qPrintable(options)); - } - } -} - -QGLAbstractScene *QAiSceneHandler::read() -{ - AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url()); - m_importer.SetIOHandler(ios); - - Assimp::Logger *log = 0; - Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL; - if (m_showWarnings) - { - severity = Assimp::Logger::VERBOSE; - int streams = aiDefaultLogStream_FILE | -#ifdef Q_CC_MSVC - aiDefaultLogStream_DEBUGGER -#else - aiDefaultLogStream_STDERR -#endif - ; - log = Assimp::DefaultLogger::create("AssimpLog.txt", severity, streams); - } - - QString path; - QUrl u = url(); - if (u.scheme() != QLatin1String("file")) - { - path = u.toEncoded(); - } else { - path = u.toLocalFile(); - } - - if (m_removeComponentFlags) - m_options |= aiProcess_RemoveComponent; - else - m_options &= ~aiProcess_RemoveComponent; - - m_importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, m_removeComponentFlags); - m_importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, m_removeSortFlags); - //m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, m_meshSplitVertexLimit); - //m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, m_meshSplitTriangleLimit); - - // force this on, and provide no way to turn it off. Its set by the - // aiProcessPreset_TargetRealtime_Quality option in the constructor. - // Guarantees that all meshes only have one primitive type - Q_ASSERT(m_options & aiProcess_SortByPType); - - // the importer owns the scene, so when the it goes out of scope on exiting - // this function the scene will get destroyed - const aiScene* scene = m_importer.ReadFile(path.toAscii().constData(), m_options); - - if (!scene) - { - // Notes on import success flags - according to assimp doco if validation - // is requested the flags AI_SCENE_FLAGS_VALIDATION_WARNING will be set - // if there's a warning, and AI_SCENE_FLAGS_VALIDATED is set on success. - // This does not happen. Also AI_SCENE_FLAGS_INCOMPLETE can be set on a - // valid model, so checking for that is no use either. Best way to proceed - // is that if ShowWarnings is turned on above, then any pertinent warnings - // will be shown; and if a NULL result is returned here, then its a fatal - // error and a message is shown here. If a non-NULL result is returned - // just go ahead and try to load it. - QString c = QDir::current().absolutePath(); - qWarning("Asset importer error: %s\n", m_importer.GetErrorString()); - if (log) - qWarning("For details check log: %s/AssimpLog.txt\n", qPrintable(c)); - return 0; - } - else { - if (!qgetenv("QT3D_DEBUG_MODEL").isEmpty()) - DumpScene(scene); - } - - QAiScene *qscene = new QAiScene(scene, this); - - Assimp::DefaultLogger::kill(); - - finalize(); - return qscene; -} - -void LogPrint(const char* pFormat, ...) -{ - static char buff[1024]; - buff[0] = '\0'; - va_list args; - va_start(args, pFormat); - vsnprintf( buff, sizeof(buff) - 1, pFormat, args); -#ifndef QT_NO_DEBUG_STREAM - qDebug() << buff; -#endif -} - -void DumpAnimation(int i, const aiAnimation* pAnimation, const aiScene* pScene) -{ - Q_UNUSED(pScene); - LogPrint(" Animation %d",i); - LogPrint(" name = '%s'",pAnimation->mName.data); - LogPrint(" ticks = %f",pAnimation->mDuration); - LogPrint(" ticks per sec = %f",pAnimation->mTicksPerSecond); - for (unsigned int i=0; i<pAnimation->mNumChannels; ++i) { - const aiNodeAnim* pNodeAnim = pAnimation->mChannels[i]; - LogPrint(" channel %d affects: '%s'", i, pNodeAnim->mNodeName.data); - } -} - -void DumpMesh(int i, const aiMesh* pMesh, const aiScene* pScene) -{ - Q_UNUSED(pScene); - LogPrint(" Mesh %d",i); - LogPrint(" name = '%s'",pMesh->mName.data); - LogPrint(" has bones: %s (%d)",pMesh->HasBones()?"YES":"no ",pMesh->mNumBones); - for (unsigned int i=0; i<pMesh->mNumBones; ++i) { - LogPrint(" bone(%02d): '%s'", i, pMesh->mBones[i]->mName.data); - } -} -void DumpNodeRecursive(int level, const aiNode* pNode, const aiScene* pScene) -{ - if (level > 100) - level = 100; - char Prefix[256]; - memset(Prefix,' ',level*2); - Prefix[level*2] = '\0'; - LogPrint(" %sNode, name='%s', nMeshes=%d",Prefix,pNode->mName.data,pNode->mNumMeshes); - for (unsigned int i=0; i<pNode->mNumChildren; ++i) { - DumpNodeRecursive(level+1, pNode->mChildren[i], pScene); - } -} - -void DumpScene(const aiScene* pScene) -{ - LogPrint("DumpScene(%p)",pScene); - if (pScene) { - LogPrint(" has animations: %s (%d)",pScene->HasAnimations()?"YES":"no ",pScene->mNumAnimations); - LogPrint(" has meshes: %s (%d)",pScene->HasMeshes()?"YES":"no ",pScene->mNumMeshes); - for (unsigned int i=0; i<pScene->mNumAnimations; ++i) { - DumpAnimation(i,pScene->mAnimations[i],pScene); - } - for (unsigned int i=0; i<pScene->mNumMeshes; ++i) { - DumpMesh(i,pScene->mMeshes[i],pScene); - } - DumpNodeRecursive(0,pScene->mRootNode,pScene); - } -} - -QGLAbstractScene * QAiSceneHandler::download() -{ - QUrl u = url(); - - if (u.scheme() == QLatin1String("file")) { - qWarning() << "Cannot download urls with FILE scheme. Use the read() method."; - } else { - if (m_removeComponentFlags) - m_options |= aiProcess_RemoveComponent; - else - m_options &= ~aiProcess_RemoveComponent; - - m_importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, m_removeComponentFlags); - m_importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, m_removeSortFlags); - m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, m_meshSplitVertexLimit); - m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, m_meshSplitTriangleLimit); - - // force this on, and provide no way to turn it off. Its set by the - // aiProcessPreset_TargetRealtime_Quality option in the constructor. - // Guarantees that all meshes only have one primitive type - Q_ASSERT(m_options & aiProcess_SortByPType); - - setScene(new QAiScene(this)); - //m_scene = new QAiScene(this); - - //m_scene->begindownLoad(url()); - - downloadScene(); - } - return getScene(); -} - -void QAiSceneHandler::downloadComplete(QByteArray *sceneData) -{ - //Create i/o device to use for file reading. - QBuffer sceneBuffer(sceneData); - sceneBuffer.open(QIODevice::ReadOnly); - setDevice(&sceneBuffer); - - //Set i/o system to use non-file based device. - AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url()); - m_importer.SetIOHandler(ios); - - QString path; - path = url().toEncoded(); - - Assimp::Logger *log = 0; - Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL; - if (m_showWarnings) - { - severity = Assimp::Logger::VERBOSE; - int streams = aiDefaultLogStream_FILE | -#ifdef Q_CC_MSVC - aiDefaultLogStream_DEBUGGER -#else - aiDefaultLogStream_STDERR -#endif - ; - log = Assimp::DefaultLogger::create("AssimpLog.txt", severity, streams); - } - - const aiScene* scene = m_importer.ReadFile(path.toStdString(), m_options); - if (!scene) - { - // Notes on import success flags - according to assimp doco if validation - // is requested the flags AI_SCENE_FLAGS_VALIDATION_WARNING will be set - // if there's a warning, and AI_SCENE_FLAGS_VALIDATED is set on success. - // This does not happen. Also AI_SCENE_FLAGS_INCOMPLETE can be set on a - // valid model, so checking for that is no use either. Best way to proceed - // is that if ShowWarnings is turned on above, then any pertinent warnings - // will be shown; and if a NULL result is returned here, then its a fatal - // error and a message is shown here. If a non-NULL result is returned - // just go ahead and try to load it. - QString c = QDir::current().absolutePath(); - qWarning("Asset importer error: %s\n", m_importer.GetErrorString()); - if (log) - qWarning("For details check log: %s/AssimpLog.txt\n", qPrintable(c)); - } else { - //If we have reached this point everything has proceeded correctly, - //load the scene. - QAiScene *theScene = qobject_cast<QAiScene*>(getScene()); - theScene->loadScene(scene); - } - - Assimp::DefaultLogger::kill(); - - delete sceneData; - finalize(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.h b/src/plugins/sceneformats/assimp/qaiscenehandler.h deleted file mode 100644 index 45c7a2c66..000000000 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAISCENEHANDLER_H -#define QAISCENEHANDLER_H - -#include "qglsceneformatplugin.h" - -#include "aiPostProcess.h" -#include "assimp.hpp" - -#include <QtCore/qurl.h> -#include <QObject> - -Q_DECLARE_FLAGS(aiPostProcessFlags, aiPostProcessSteps); -Q_DECLARE_OPERATORS_FOR_FLAGS(aiPostProcessFlags); - - -QT_BEGIN_NAMESPACE - -class QIODevice; - -class QAiSceneHandler : public QGLSceneFormatHandler -{ - Q_OBJECT -public: - enum Options { - NoOptions, - ShowWarnings, // show any warnings while loading the file - CalculateNormals, // replace normals from the file with smooth generated ones - ForceFaceted, // generate non-smooth normals (implies CalculateNormals) - ForceSmooth, // deprecated - retained only for backward compatibility - IncludeAllMaterials, // include even redundant (unused) materials - IncludeLinesPoints, // include even collapsed triangles (lines or points) - FixNormals, // try to fix incorrect (in facing) normals - DeDupMeshes, // replace copied meshes with refs to a single instance - Optimize, // collapse meshes, nodes & scene heierarchies - FlipUVs, // flips UV's on the y-axis (for upside-down textures) - FlipWinding, // makes faces CW instead of CCW - UseVertexColors, // use vertex colors that are in a model - VertexSplitLimitx2, // double the vertex count which will split a large mesh - TriangleSplitLimitx2 // double the triangle count which will split a large mesh - }; - - QAiSceneHandler(); - ~QAiSceneHandler(); - - QGLAbstractScene *read(); - QGLAbstractScene *download(); - - void decodeOptions(const QString &options); - - bool showWarnings() const { return m_showWarnings; } - bool mayHaveLinesPoints() const { return m_mayHaveLinesPoints; } - - aiPostProcessFlags options() const { return m_options; } - quint32 removeComponentFlags() const { return m_removeComponentFlags; } - quint32 removeSortFlags() const { return m_removeSortFlags; } - -public slots: - void downloadComplete(QByteArray *sceneData); - -private: - aiPostProcessFlags m_options; - bool m_showWarnings; - bool m_mayHaveLinesPoints; - int m_meshSplitVertexLimit; - int m_meshSplitTriangleLimit; - Assimp::Importer m_importer; - quint32 m_removeComponentFlags; - quint32 m_removeSortFlags; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/bezier/bezier.pro b/src/plugins/sceneformats/bezier/bezier.pro deleted file mode 100644 index 870d6970c..000000000 --- a/src/plugins/sceneformats/bezier/bezier.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qscenebezier -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) - -HEADERS += qglbezierscene.h \ - qglbezierscenehandler.h \ - bezier_plugin.h -SOURCES += \ - qglbezierscene.cpp \ - qglbezierscenehandler.cpp \ - bezier_plugin.cpp - -OTHER_FILES += \ - bezier_scene_plugin.json - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target diff --git a/src/plugins/sceneformats/bezier/bezier_plugin.cpp b/src/plugins/sceneformats/bezier/bezier_plugin.cpp deleted file mode 100644 index 91a81afe6..000000000 --- a/src/plugins/sceneformats/bezier/bezier_plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bezier_plugin.h" -#include "qglbezierscenehandler.h" - -QT_BEGIN_NAMESPACE - -QGLBezierScenePlugin::QGLBezierScenePlugin() {} -QGLBezierScenePlugin::~QGLBezierScenePlugin() {} - -QGLSceneFormatHandler *QGLBezierScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QGLBezierSceneHandler; -} - -QT_END_NAMESPACE - - diff --git a/src/plugins/sceneformats/bezier/bezier_plugin.h b/src/plugins/sceneformats/bezier/bezier_plugin.h deleted file mode 100644 index 83b40b726..000000000 --- a/src/plugins/sceneformats/bezier/bezier_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BEZIER_PLUGIN_H -#define BEZIER_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QGLBezierScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "bezier_scene_plugin.json") -public: - QGLBezierScenePlugin(); - ~QGLBezierScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // BEZIER_PLUGIN_H diff --git a/src/plugins/sceneformats/bezier/bezier_scene_plugin.json b/src/plugins/sceneformats/bezier/bezier_scene_plugin.json deleted file mode 100644 index d91418547..000000000 --- a/src/plugins/sceneformats/bezier/bezier_scene_plugin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Keys": [ - "bezier", - "bez" - ] -} diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.cpp b/src/plugins/sceneformats/bezier/qglbezierscene.cpp deleted file mode 100644 index fe864f257..000000000 --- a/src/plugins/sceneformats/bezier/qglbezierscene.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglbezierscene.h" -#include "qglscenenode.h" - -QT_BEGIN_NAMESPACE - -QGLBezierScene::QGLBezierScene(QGLSceneNode *geometry, QObject *parent) - : QGLAbstractScene(parent) -{ - mainObject = geometry; - mainObject->setObjectName(QLatin1String("mesh")); // No tr - mainObject->setParent(this); -} - -QGLBezierScene::~QGLBezierScene() -{ -} - -QList<QObject *> QGLBezierScene::objects() const -{ - QList<QObject *> objs; - objs.append(mainObject); - return objs; -} - -QGLSceneNode *QGLBezierScene::mainNode() const -{ - return mainObject; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.h b/src/plugins/sceneformats/bezier/qglbezierscene.h deleted file mode 100644 index 156e2266f..000000000 --- a/src/plugins/sceneformats/bezier/qglbezierscene.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLBEZIERSCENE_H -#define QGLBEZIERSCENE_H - -#include "qglabstractscene.h" -#include "qglbuilder.h" - -QT_BEGIN_NAMESPACE - -class QGLBezierScene : public QGLAbstractScene -{ - Q_OBJECT -public: - explicit QGLBezierScene(QGLSceneNode *geometry, QObject *parent = 0); - virtual ~QGLBezierScene(); - - QList<QObject *> objects() const; - QGLSceneNode *mainNode() const; - -private: - QGLSceneNode *mainObject; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp b/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp deleted file mode 100644 index 58ea68c60..000000000 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglbezierscenehandler.h" -#include "qglbezierscene.h" -#include "qglbezierpatches.h" -#include "qvector3darray.h" -#include <QtCore/qtextstream.h> - -QT_BEGIN_NAMESPACE - -QGLAbstractScene *QGLBezierSceneHandler::read() -{ - QTextStream stream(device()); - QGLBezierPatches patches; - - // Read the number of patches from the first line. - int patchCount; - stream >> patchCount; - stream.skipWhiteSpace(); - if (patchCount <= 0) - return 0; - - // Read the patch indices. - int depth = 0; - QArray<int> indices; - for (int patch = 0; patch < patchCount; ++patch) { - bool eoln = false; - for (int index = 0; index < 16; ++index) { - int value; - stream >> value; - indices.append(value - 1); - - QChar sep; - stream >> sep; - if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r')) { - eoln = true; - break; - } - if (sep != QLatin1Char(',')) - return 0; - } - if (!eoln) { - // Optional sub-division depth on the end. - int value; - stream >> value; - if (value > depth) - depth = value; - } - stream.skipWhiteSpace(); - } - - // Read the number of vertices. - int vertexCount; - stream >> vertexCount; - stream.skipWhiteSpace(); - if (vertexCount <= 0) - return 0; - - // Read the vertex values. - QVector3DArray vertices; - for (int vertex = 0; vertex < vertexCount; ++vertex) { - bool eoln = false; - qreal coords[3] = {0.0f, 0.0f, 0.0f}; - for (int index = 0; index < 3; ++index) { - stream >> coords[index]; - - QChar sep; - stream >> sep; - if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r')) { - eoln = true; - break; - } - if (sep != QLatin1Char(',')) - return 0; - } - vertices.append(coords[0], coords[1], coords[2]); - if (!eoln) { - // Optional normal on the end: read it but discard. - for (int index = 0; index < 3; ++index) { - stream >> coords[index]; - - QChar sep; - stream >> sep; - if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r')) - break; - if (sep != QLatin1Char(',')) - return 0; - } - } - stream.skipWhiteSpace(); - } - - // Check for options at the end of the stream. - if (!stream.atEnd()) { - QChar ch; - stream >> ch; - if (ch == QLatin1Char('#')) { - QString options = stream.readLine(); - if (options.contains(QLatin1String("teapot-adjust"))) { - // Perform the "teapot adjustment" to convert the raw - // teapot data into something more suitable for applications. - // i.e., do the equivalent of the following transformation: - // matrix.rotate(270.0f, 1.0f, 0.0f, 0.0f); - // matrix.scale(0.5f, 0.5f, 0.5f); - // matrix.translate(0.0f, 0.0f, -1.5f); - for (int vertex = 0; vertex < vertexCount; ++vertex) { - QVector3D vec = vertices[vertex]; - qreal x = vec.x(); - qreal y = vec.y(); - qreal z = vec.z(); - z -= 1.5f; - x *= 0.5f; - y *= 0.5f; - z *= 0.5f; - qreal y2 = z; - qreal z2 = -y; - y = y2; - z = z2; - vertices[vertex] = QVector3D(x, y, z); - } - } - if (options.contains(QLatin1String("reverse-patches"))) { - // Reverse the patch order to convert clockwise - // patches into standard anti-clockwise patches. - QArray<int> newIndices; - for (int patch = 0; patch < patchCount; ++patch) { - int temp[16]; - for (int index = 0; index < 16; ++index) - temp[index] = indices[patch * 16 + index]; - for (int i = 0; i < 16; ++i) - newIndices.append(temp[(i & 0x0C) + (3 - (i % 4))]); - } - indices = newIndices; - } - } - } - - // Create the geometry node from the Bezier patch data. - if (depth != 0) - patches.setSubdivisionDepth(depth); - QVector3DArray positions; - for (int pindex = 0; pindex < indices.size(); ++pindex) - positions += vertices[indices[pindex]]; - patches.setPositions(positions); - QGLBuilder geometry; - geometry << patches; - - // Create a scene with a single object containing the geometry. - return new QGLBezierScene(geometry.finalizedSceneNode()); -} - -QGLAbstractScene *QGLBezierSceneHandler::download() -{ - qWarning() << "Network loading is not supported for .bez files."; - return NULL; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h b/src/plugins/sceneformats/bezier/qglbezierscenehandler.h deleted file mode 100644 index 59f8945f9..000000000 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLBEZIERSCENEHANDLER_H -#define QGLBEZIERSCENEHANDLER_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QGLBezierSceneHandler : public QGLSceneFormatHandler -{ -public: - QGLAbstractScene *read(); - QGLAbstractScene *download(); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/obj/obj.pro b/src/plugins/sceneformats/obj/obj.pro deleted file mode 100644 index 73bd0e8ec..000000000 --- a/src/plugins/sceneformats/obj/obj.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qsceneobj -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) - -HEADERS += qglobjscene.h \ - qglobjscenehandler.h \ - obj_plugin.h -SOURCES += \ - qglobjscene.cpp \ - qglobjscenehandler.cpp \ - obj_plugin.cpp - -OTHER_FILES += \ - obj_scene_plugin.json - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target diff --git a/src/plugins/sceneformats/obj/obj_plugin.cpp b/src/plugins/sceneformats/obj/obj_plugin.cpp deleted file mode 100644 index ae88ae374..000000000 --- a/src/plugins/sceneformats/obj/obj_plugin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "obj_plugin.h" -#include "qglobjscenehandler.h" - -QT_BEGIN_NAMESPACE - -QGLObjScenePlugin::QGLObjScenePlugin() {} -QGLObjScenePlugin::~QGLObjScenePlugin() {} - -QGLSceneFormatHandler *QGLObjScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QGLObjSceneHandler; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/obj/obj_plugin.h b/src/plugins/sceneformats/obj/obj_plugin.h deleted file mode 100644 index de9283a23..000000000 --- a/src/plugins/sceneformats/obj/obj_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef OBJ_PLUGIN_H -#define OBJ_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QGLObjScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "obj_scene_plugin.json") -public: - QGLObjScenePlugin(); - ~QGLObjScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // OBJ_PLUGIN_H diff --git a/src/plugins/sceneformats/obj/obj_scene_plugin.json b/src/plugins/sceneformats/obj/obj_scene_plugin.json deleted file mode 100644 index b33d38205..000000000 --- a/src/plugins/sceneformats/obj/obj_scene_plugin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Keys": [ - "obj" - ] -} diff --git a/src/plugins/sceneformats/obj/qglobjscene.cpp b/src/plugins/sceneformats/obj/qglobjscene.cpp deleted file mode 100644 index f2203b9e8..000000000 --- a/src/plugins/sceneformats/obj/qglobjscene.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglobjscene.h" -#include "qglbuilder.h" -#include "qglscenenode.h" - -QT_BEGIN_NAMESPACE - -QGLObjScene::QGLObjScene(QGLSceneNode *defaultNode, QObject *parent) - : QGLAbstractScene(parent) - , mainObject(defaultNode) -{ - defaultNode->setParent(this); -} - -QGLObjScene::~QGLObjScene() -{ -} - -QList<QObject *> QGLObjScene::objects() const -{ - QList<QObject *> objs; - objs.append(mainObject); - QList<QGLSceneNode *> children = mainObject->allChildren(); - for (int index = 0; index < children.count(); ++index) - objs.append(children.at(index)); - return objs; -} - -QGLSceneNode *QGLObjScene::mainNode() const -{ - return mainObject; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/obj/qglobjscene.h b/src/plugins/sceneformats/obj/qglobjscene.h deleted file mode 100644 index 8a7074c73..000000000 --- a/src/plugins/sceneformats/obj/qglobjscene.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLOBJSCENE_H -#define QGLOBJSCENE_H - -#include "qglabstractscene.h" - -QT_BEGIN_NAMESPACE - -class QGLBuilder; -class QGLSceneNode; - -//! [1] -class QGLObjScene : public QGLAbstractScene -{ - Q_OBJECT -public: -//! [1] - explicit QGLObjScene(QGLSceneNode *defaultNode, QObject *parent = 0); - virtual ~QGLObjScene(); - -//! [2] - QList<QObject *> objects() const; - QGLSceneNode *mainNode() const; -//! [2] - -private: - QGLSceneNode *mainObject; -//! [3] -}; -//! [3] - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp b/src/plugins/sceneformats/obj/qglobjscenehandler.cpp deleted file mode 100644 index aea28126c..000000000 --- a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglobjscenehandler.h" -#include "qglobjscene.h" -#include "qvector2darray.h" -#include "qvector3darray.h" -#include "qglbuilder.h" - -#include <QtCore/qiodevice.h> -#include <QtCore/qfile.h> -#include <QtGui/qimage.h> - -QT_BEGIN_NAMESPACE - -QGLObjSceneHandler::QGLObjSceneHandler() - : QGLSceneFormatHandler() - , smoothing(QGL::Faceted) - , smoothingForced(false) -{ -} - -// Documentation for OBJ and MTL files from: -// http://www.fileformat.info/format/wavefrontobj/egff.htm -// http://www.fileformat.info/format/material/ - -static int objSkipWS(const QByteArray& line, int posn) -{ - while (posn < line.size() && (line[posn] == ' ' || line[posn] == '\t')) - ++posn; - return posn; -} - -static int objSkipNonWS(const QByteArray& line, int posn, int stopch) -{ - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t' && line[posn] != stopch) - ++posn; - return posn; -} - -static qreal objReadFloat(const QByteArray& line, int *posn) -{ - *posn = objSkipWS(line, *posn); - int end = objSkipNonWS(line, *posn, 0); - qreal value; - if (end > *posn) - value = qreal(line.mid(*posn, end - *posn).toDouble()); - else - value = 0.0f; - *posn = end; - return value; -} - -static int objReadInteger(const QByteArray& line, int *posn) -{ - *posn = objSkipWS(line, *posn); - int end = objSkipNonWS(line, *posn, '/'); - int value; - if (end > *posn) - value = line.mid(*posn, end - *posn).toInt(); - else - value = 0; - //*posn = objSkipNonWS(line, end, 0); - *posn = end; - return value; -} - -static int objReadSlashInteger(const QByteArray& line, int *posn) -{ - if (*posn >= line.size() || line[*posn] != '/') - return 0; - ++(*posn); - int end = objSkipNonWS(line, *posn, '/'); - int value; - if (end > *posn) - value = line.mid(*posn, end - *posn).toInt(); - else - value = 0; - //*posn = objSkipNonWS(line, end, 0); - *posn = end; - return value; -} - -static QColor objReadColor(const QByteArray& line, int posn) -{ - qreal red = objReadFloat(line, &posn); - qreal green = objReadFloat(line, &posn); - qreal blue = objReadFloat(line, &posn); - qreal alpha = 1.0f; - posn = objSkipWS(line, posn); - if (posn < line.size()) - alpha = objReadFloat(line, &posn); - return QColor::fromRgbF(red, green, blue, alpha); -} - -void QGLObjSceneHandler::decodeOptions(const QString &options) -{ - if (options.contains(QLatin1String("ForceSmooth"))) - { - smoothingForced = true; - smoothing = QGL::Smooth; - } - else - { - smoothingForced = true; - smoothing = QGL::Faceted; - } -} - -QGLAbstractScene *QGLObjSceneHandler::read() -{ - QByteArray line; - QByteArray keyword; - int posn, index, count; - int tindex, nindex; - QVector3DArray positions; - QVector2DArray texCoords; - QVector3DArray normals; - qreal x, y, z; - quint32 fields = 0; - QGLMaterial *material = 0; - QGLSceneNode *defaultNode; - - // Create the geometry builder and start an initial Faceted section. - QGLBuilder builder; - builder.newSection(smoothing); - QGLSceneNode *root = builder.sceneNode(); - palette = root->palette(); - defaultNode = root; - defaultNode->setObjectName(QLatin1String("__main")); - builder.pushNode(); - - QGeometryData op; - while (!device()->atEnd()) { - // Read the next line, including any backslash continuations. - line = device()->readLine().trimmed(); - while (line.endsWith('\\')) { - line.truncate(line.size() - 1); - if (device()->atEnd()) - break; - line += device()->readLine().trimmed(); - } - if (line.startsWith('#') || line.isEmpty()) - continue; // Skip comments and blank lines. - - // Extract the keyword at the start of the line. - posn = 0; - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t') - ++posn; - keyword = line.left(posn); - - // Determine how to process this line from the keyword. - if (keyword == "v") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - z = objReadFloat(line, &posn); - positions.append(x, y, z); - } else if (keyword == "vt") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - texCoords.append(x, y); - } else if (keyword == "vn") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - z = objReadFloat(line, &posn); - normals.append(x, y, z); - } else if (keyword == "f") { - posn = objSkipWS(line, posn); - count = 0; - //QGeometryData op; //(dlist, QGL::TRIANGLE_FAN); - op = QGeometryData(); // clear leaves field definitions - while (posn < line.size()) { - // Note: we currently only read the initial vertex - // index and also use it for texture co-ordinates - // and normals. e.g. "2/2", "3/3", etc. This will - // need to be fixed to handle "2/1", "3/7", etc. - index = objReadInteger(line, &posn); - tindex = objReadSlashInteger(line, &posn); - nindex = objReadSlashInteger(line, &posn); - if (index < 0) - index = positions.count() + index; - else if (index > 0) - --index; // Indices in obj are 1-based. - if (index >= 0 && index < positions.count()) - op.appendVertex(positions[index]); - if (tindex < 0) - tindex = texCoords.count() + tindex; - else if (tindex > 0) - --tindex; // Indices in obj are 1-based. - else - tindex = -1; - if (tindex >= 0 && tindex < texCoords.count()) - op.appendTexCoord(texCoords[tindex]); - if (nindex < 0) - nindex = normals.count() + nindex; - else if (nindex > 0) - --nindex; // Indices in obj are 1-based. - else - nindex = -1; - if (nindex >= 0 && nindex < normals.count()) - op.appendNormal(normals[nindex]); - ++count; - posn = objSkipNonWS(line, posn, 0); - posn = objSkipWS(line, posn); - } - // if geometry has already been added with a different combination - // of fields start a new section - // the primitive doesn't get posted to the section until op.end() - if (op.fields() != fields) - { - if (fields && builder.currentNode()->count() > 0) - builder.newSection(smoothing); - fields = op.fields(); - } - builder.addTriangleFan(op); - } else if (keyword == "usemtl") { - // Specify a material for the faces that follow. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - QString materialName = QString::fromLocal8Bit(rest.constData(), rest.size()); - if (!materialName.isEmpty() && - materialName != QLatin1String("(null)")) { - index = palette->indexOf(materialName); - if (index != -1) { - QGLSceneNode *node = builder.newNode(); - node->setMaterialIndex(index); - QGLMaterial *material = palette->material(index); - if (material->texture()) - node->setEffect(QGL::LitDecalTexture2D); - else - node->setEffect(QGL::LitMaterial); - } else { - qWarning() << "obj material" << materialName << "not found"; - material = 0; - } - } - } else if (keyword == "mtllib") { - // Load a material library. - posn = objSkipWS(line, posn); - QByteArray filename = line.mid(posn); - loadMaterialLibrary(QString::fromLocal8Bit(filename.constData(), filename.size())); - } else if (keyword == "s") { - if (!smoothingForced) - { - // Set smoothing on or off. - posn = objSkipWS(line, posn); - index = objSkipNonWS(line, posn, 0); - QByteArray arg = line.mid(posn, index - posn); - QGL::Smoothing smooth; - if (arg == "on" || arg == "1") - smooth = QGL::Smooth; - else - smooth = QGL::Faceted; - if (smoothing != smooth) { - smoothing = smooth; - builder.newSection(smooth); - } - } - } else if (keyword == "g" || keyword == "o") { - // Label the faces that follow as part of a named group or object. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - QString objectName = QString::fromLocal8Bit(rest.constData(), rest.size()); - QGLSceneNode *node = builder.currentNode(); - // if content has already been added to a current group, then - // create a new node in the scene graph for the group, otherwise - // just label the existing group with this name - QGLSceneNode *p = qobject_cast<QGLSceneNode*>(node->parent()); - if (node->count() > 0 && p && p->objectName().isEmpty()) - { - node = p; - } - else - { - builder.popNode(); - node = builder.currentNode(); - builder.pushNode(); - } - node->setObjectName(objectName); - } else { - qWarning() << "unsupported obj command: " << keyword.constData(); - } - } - - // Create a scene from the geometry - return new QGLObjScene(builder.finalizedSceneNode()); -} - -QGLAbstractScene *QGLObjSceneHandler::download() -{ - qWarning() << "Network loading of obj files using this plugin is not implemented."; - return NULL; -} - -void QGLObjSceneHandler::loadMaterialLibrary(const QString& name) -{ - QUrl materialUrl = url().resolved(name); - if (materialUrl.scheme() == QLatin1String("file")) { - QFile file(materialUrl.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) - qWarning() << "QGLObjSceneHandler::loadMaterialLibrary: could not open:" << materialUrl.toLocalFile(); - else - loadMaterials(&file); - } else { - // TODO - qWarning("QGLObjSceneHandler::loadMaterialLibrary: non-file urls not supported"); - } -} - -void QGLObjSceneHandler::loadMaterials(QIODevice *device) -{ - QByteArray line; - QByteArray keyword; - int posn, index; - QGLMaterial *material = 0; - QString materialName; - QString textureName; - - while (!device->atEnd()) { - // Read the next line, including any backslash continuations. - line = device->readLine().trimmed(); - while (line.endsWith('\\')) { - line.truncate(line.size() - 1); - if (device->atEnd()) - break; - line += device->readLine().trimmed(); - } - if (line.startsWith('#') || line.isEmpty()) - continue; // Skip comments and blank lines. - - // Extract the keyword at the start of the line. - posn = 0; - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t') - ++posn; - keyword = line.left(posn); - - // Determine how to process this line from the keyword. - if (keyword == "newmtl") { - // Start a new material definition. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - materialName = QString::fromLocal8Bit(rest.constData(), rest.size()); - index = palette->indexOf(materialName); - if (index != -1) { - qWarning() << "redefining obj material:" << materialName; - material = palette->material(index); - } else { - material = new QGLMaterial(); - material->setObjectName(materialName); - palette->addMaterial(material); - } - } else if (keyword == "Ka") { - // Ambient color of the material. - if (material) - material->setAmbientColor(objReadColor(line, posn)); - } else if (keyword == "Kd") { - // Diffuse color of the material. - if (material) - material->setDiffuseColor(objReadColor(line, posn)); - } else if (keyword == "Ks") { - // Specular color of the material. - if (material) - material->setSpecularColor(objReadColor(line, posn)); - } else if (keyword == "map_Kd") { - // Texture associated with the material. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - textureName = QString::fromLocal8Bit(rest.constData(), rest.size()); - QGLTexture2D *texture = loadTexture(textureName); - if (texture) { - index = palette->indexOf(materialName); - if (index >= 0) { - QGLMaterial *material = palette->material(index); - texture->setParent(material); - material->setTexture(texture); - } else { - delete texture; - } - } - } else if (keyword == "d") { - // "Dissolve factor" of the material, which is its opacity. - if (material) { - qreal alpha = objReadFloat(line, &posn); - QColor ambient = material->ambientColor(); - QColor diffuse = material->diffuseColor(); - ambient.setAlphaF(alpha); - diffuse.setAlphaF(alpha); - material->setAmbientColor(ambient); - material->setDiffuseColor(diffuse); - } - } else if (keyword == "Ns") { - // Specular exponent of the material. - if (material) - material->setShininess(qRound(objReadFloat(line, &posn))); - } else if (keyword == "illum") { - // Illumination model - ignored at present. - } else if (keyword == "Ni") { - // Optical density - ignored at present. - } else { - qWarning() << "unsupported obj material command: " << keyword.constData(); - } - } -} - -QGLTexture2D *QGLObjSceneHandler::loadTexture(const QString& name) -{ - QUrl textureUrl = url().resolved(name); - if (textureUrl.scheme() == QLatin1String("file")) { - QFile file(textureUrl.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "QGLObjSceneHandler::loadTexture: could not open:" << textureUrl.toLocalFile(); - return 0; - } else { - file.close(); - QImage image(textureUrl.toLocalFile()); - QGLTexture2D *tex = new QGLTexture2D(); - tex->setImage(image); - return tex; - } - } else { - // TODO - qWarning("QGLObjSceneHandler::loadTexture: non-file urls not supported"); - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.h b/src/plugins/sceneformats/obj/qglobjscenehandler.h deleted file mode 100644 index 0f62bc370..000000000 --- a/src/plugins/sceneformats/obj/qglobjscenehandler.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLOBJSCENEHANDLER_H -#define QGLOBJSCENEHANDLER_H - -#include "qglsceneformatplugin.h" -#include "qglmaterialcollection.h" -#include <QtCore/qmap.h> -#include <QtCore/qset.h> - -QT_BEGIN_NAMESPACE - -//! [1] -class QGLObjSceneHandler : public QGLSceneFormatHandler -{ -public: - QGLObjSceneHandler(); - QGLAbstractScene *read(); - QGLAbstractScene *download(); -//! [1] - void decodeOptions(const QString &options); - -private: - void loadMaterialLibrary(const QString& name); - void loadMaterials(QIODevice *device); - QGLTexture2D *loadTexture(const QString& name); - - QSharedPointer<QGLMaterialCollection> palette; - QGL::Smoothing smoothing; - bool smoothingForced; -//! [2] -}; -//! [2] - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/sceneformats.pro b/src/plugins/sceneformats/sceneformats.pro deleted file mode 100644 index dd44a5dff..000000000 --- a/src/plugins/sceneformats/sceneformats.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs - -old_importer { - SUBDIRS = bezier obj -} else { - SUBDIRS = bezier assimp -} |