diff options
42 files changed, 171 insertions, 1294 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/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/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/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 -} diff --git a/src/src.pro b/src/src.pro index 48385ea6e..370362fdf 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,4 +1,3 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = threed quick3d imports -SUBDIRS += plugins diff --git a/src/threed/scene/qglabstractscene.cpp b/src/threed/scene/qglabstractscene.cpp index 712b3476f..9e0d141c8 100644 --- a/src/threed/scene/qglabstractscene.cpp +++ b/src/threed/scene/qglabstractscene.cpp @@ -43,8 +43,8 @@ #include "qglsceneformatplugin.h" #include "qglpicknode.h" -// copied private header -#include "qfactoryloader_p.h" +#include "qaiscenehandler.h" +#include "qglbezierscenehandler.h" #include <QtCore/qfile.h> #include <QtCore/qfileinfo.h> @@ -56,9 +56,48 @@ #include <QtCore/qdir.h> #include <QtCore/qpluginloader.h> #include <QBuffer> +#include <QSharedPointer> QT_BEGIN_NAMESPACE +/* + Internal. + Format handlers. +*/ + +class ISceneLoaderInfo +{ +public: + virtual ~ISceneLoaderInfo() {} + virtual QStringList supportedFormats() const = 0; + virtual QGLSceneFormatHandler* createHandler() const = 0; +}; + +template <typename T> +class SceneLoaderInfo : public ISceneLoaderInfo +{ +public: + QStringList supportedFormats() const { + return T::supportedFormats(); + } + QGLSceneFormatHandler* createHandler() const { + return new T; + } +}; + +const QList< QSharedPointer<ISceneLoaderInfo> >& getSceneLoaderInfos() +{ + static QList< QSharedPointer<ISceneLoaderInfo> > infos; + if (infos.empty()) { + infos.push_back( QSharedPointer<ISceneLoaderInfo>(new SceneLoaderInfo<QAiSceneHandler>()) ); + infos.push_back( QSharedPointer<ISceneLoaderInfo>(new SceneLoaderInfo<QGLBezierSceneHandler>()) ); + } + return infos; +} +typedef QMap< QString, QSharedPointer<ISceneLoaderInfo> > FormatMap; +Q_GLOBAL_STATIC(FormatMap,qFormatMap) + + /*! \class QGLAbstractScene \brief The QGLAbstractScene class represents a 3D scene consisting of zero or more QGLSceneNode instances. @@ -331,12 +370,6 @@ QList<QGLSceneAnimation *> QGLAbstractScene::animations() const \sa objects() */ -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - ("com.trolltech.Qt.QGLSceneFormatFactoryInterface", - QLatin1String("/sceneformats"))) -#endif - /*! Loads a scene from \a device in the specified \a format using the registered scene format plugins. If \a format is an empty @@ -384,8 +417,6 @@ QGLAbstractScene *QGLAbstractScene::loadScene checkSupportedFormats(); QStringList keys = m_Formats; - QFactoryLoader *l = loader(); - // If the format is not specified, then use the filename/url extension. QString fmt = format; if (fmt.isEmpty()) { @@ -411,36 +442,29 @@ QGLAbstractScene *QGLAbstractScene::loadScene if (index >= 0) fmt = suffix; } + if (fmt.isEmpty()) + return 0; - // Find the plugin that handles the format and ask it to create a handler. - if (QGLSceneFormatFactoryInterface *factory - = qobject_cast<QGLSceneFormatFactoryInterface*> - (l->instance(fmt))) { - QGLSceneFormatHandler *handler = factory->create(device, url, fmt); - if (handler) { - handler->setDevice(device); - handler->setUrl(url); - handler->setFormat(format); - if (!options.isEmpty()) - handler->decodeOptions(options); - QGLAbstractScene *scene = 0; - if (!device) { - scene = handler->download(); - } else { - scene = handler->read(); - } - return scene; - } + FormatMap::const_iterator It = qFormatMap()->find(fmt); + if (It==qFormatMap()->end()) { + qWarning("Could not create handler for format %s",qPrintable(fmt)); + return 0; } + QGLSceneFormatHandler *handler = It.value().data()->createHandler(); + Q_ASSERT(handler); + handler->setDevice(device); + handler->setUrl(url); + handler->setFormat(format); + if (!options.isEmpty()) + handler->decodeOptions(options); + QGLAbstractScene *scene = 0; + if (!device) { + scene = handler->download(); + } else { + scene = handler->read(); + } + return scene; - // If we get here, then the format is not supported by any of the plugins. -#ifndef QT_NO_DEBUG - qWarning("Could not create handler for format %s" - "- check plugins are installed correctly in %s", - qPrintable(fmt), - qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath))); -#endif - return 0; #else // QT_NO_LIBRARY || QT_NO_SETTINGS Q_UNUSED(device); Q_UNUSED(url); @@ -559,10 +583,6 @@ QGLAbstractScene *QGLAbstractScene::loadScene Otherwise (when \a t is QGLAbstractScene::AsSuffix) it is simply a list of file name suffixes. - - Note that this function may be expensive to - call since it scans for available plugins, and loads each one it - finds to get an accurate report of formats supported at run-time. */ QStringList QGLAbstractScene::supportedFormats(QGLAbstractScene::FormatListType t) { @@ -580,8 +600,21 @@ QStringList QGLAbstractScene::supportedFormats(QGLAbstractScene::FormatListType void QGLAbstractScene::checkSupportedFormats() { if (!m_bFormatListReady) { - QFactoryLoader *l = loader(); - m_Formats = l->keys(); + Q_ASSERT(m_Formats.empty()); + Q_ASSERT(qFormatMap()->empty()); + + const QList< QSharedPointer<ISceneLoaderInfo> >& rSceneLoaderInfos = getSceneLoaderInfos(); + for (QList< QSharedPointer<ISceneLoaderInfo> >::const_iterator It=rSceneLoaderInfos.begin(); It!=rSceneLoaderInfos.end(); ++It) { + QStringList formats = It->data()->supportedFormats(); + foreach (QString sss, formats) { + sss = sss.toLower(); + if (!m_Formats.contains(sss,Qt::CaseInsensitive)) { + m_Formats.append(sss); + qFormatMap()->insert(sss,*It); + } + } + } + m_FormatsFilter.clear(); foreach (QString f, m_Formats) { m_FormatsFilter.append(f.prepend(QLatin1String("*."))); diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp b/src/threed/scene_ai/ailoaderiostream.cpp index ecc6fe2ce..ecc6fe2ce 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp +++ b/src/threed/scene_ai/ailoaderiostream.cpp diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.h b/src/threed/scene_ai/ailoaderiostream.h index fa24ecab5..fa24ecab5 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.h +++ b/src/threed/scene_ai/ailoaderiostream.h diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp b/src/threed/scene_ai/ailoaderiosystem.cpp index 222ed6d6e..222ed6d6e 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp +++ b/src/threed/scene_ai/ailoaderiosystem.cpp diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.h b/src/threed/scene_ai/ailoaderiosystem.h index c3d4c4527..c3d4c4527 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.h +++ b/src/threed/scene_ai/ailoaderiosystem.h diff --git a/src/plugins/sceneformats/assimp/qailoader.cpp b/src/threed/scene_ai/qailoader.cpp index d866c2fa4..d866c2fa4 100644 --- a/src/plugins/sceneformats/assimp/qailoader.cpp +++ b/src/threed/scene_ai/qailoader.cpp diff --git a/src/plugins/sceneformats/assimp/qailoader.h b/src/threed/scene_ai/qailoader.h index 988ba224e..988ba224e 100644 --- a/src/plugins/sceneformats/assimp/qailoader.h +++ b/src/threed/scene_ai/qailoader.h diff --git a/src/plugins/sceneformats/assimp/qaimesh.cpp b/src/threed/scene_ai/qaimesh.cpp index 918f36af0..918f36af0 100644 --- a/src/plugins/sceneformats/assimp/qaimesh.cpp +++ b/src/threed/scene_ai/qaimesh.cpp diff --git a/src/plugins/sceneformats/assimp/qaimesh.h b/src/threed/scene_ai/qaimesh.h index 87dc75460..87dc75460 100644 --- a/src/plugins/sceneformats/assimp/qaimesh.h +++ b/src/threed/scene_ai/qaimesh.h diff --git a/src/plugins/sceneformats/assimp/qaiscene.cpp b/src/threed/scene_ai/qaiscene.cpp index 5634855f9..5634855f9 100644 --- a/src/plugins/sceneformats/assimp/qaiscene.cpp +++ b/src/threed/scene_ai/qaiscene.cpp diff --git a/src/plugins/sceneformats/assimp/qaiscene.h b/src/threed/scene_ai/qaiscene.h index e1543a595..e1543a595 100644 --- a/src/plugins/sceneformats/assimp/qaiscene.h +++ b/src/threed/scene_ai/qaiscene.h diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp b/src/threed/scene_ai/qaiscenehandler.cpp index 27add9b28..897fc5657 100644 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp +++ b/src/threed/scene_ai/qaiscenehandler.cpp @@ -214,6 +214,60 @@ void QAiSceneHandler::decodeOptions(const QString &options) } } +QStringList QAiSceneHandler::supportedFormats() { + QStringList result; + result.append(QString("3d")); + result.append(QString("3ds")); + result.append(QString("ac")); + result.append(QString("ac3d")); + result.append(QString("acc")); + result.append(QString("ase")); + result.append(QString("ask")); + result.append(QString("b3d")); + result.append(QString("blend")); + result.append(QString("bvh")); + result.append(QString("cob")); + result.append(QString("csm")); + result.append(QString("dae")); + result.append(QString("dxf")); + result.append(QString("enff")); + result.append(QString("hmp")); + result.append(QString("irr")); + result.append(QString("irrmesh")); + result.append(QString("lwo")); + result.append(QString("lws")); + result.append(QString("lxo")); + result.append(QString("md2")); + result.append(QString("md3")); + result.append(QString("md5anim")); + result.append(QString("md5camera")); + result.append(QString("md5mesh")); + result.append(QString("mdc")); + result.append(QString("mdl")); + result.append(QString("mesh.xml")); + result.append(QString("mot")); + result.append(QString("ms3d")); + result.append(QString("ndo")); + result.append(QString("nff")); + result.append(QString("obj")); + result.append(QString("off")); + result.append(QString("pk3")); + result.append(QString("ply")); + result.append(QString("prj")); + result.append(QString("q3o")); + result.append(QString("q3s")); + result.append(QString("raw")); + result.append(QString("scn")); + result.append(QString("smd")); + result.append(QString("stl")); + result.append(QString("ter")); + result.append(QString("uc")); + result.append(QString("vta")); + result.append(QString("x")); + result.append(QString("xml")); + return result; +} + QGLAbstractScene *QAiSceneHandler::read() { AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url()); @@ -238,7 +292,7 @@ QGLAbstractScene *QAiSceneHandler::read() QUrl u = url(); if (u.scheme() != QLatin1String("file")) { - path = u.toEncoded(); + path = u.toEncoded() ; } else { path = u.toLocalFile(); } diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.h b/src/threed/scene_ai/qaiscenehandler.h index 45c7a2c66..489c046e7 100644 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.h +++ b/src/threed/scene_ai/qaiscenehandler.h @@ -83,6 +83,8 @@ public: QAiSceneHandler(); ~QAiSceneHandler(); + static QStringList supportedFormats(); + QGLAbstractScene *read(); QGLAbstractScene *download(); diff --git a/src/threed/scene_ai/scene_ai.pri b/src/threed/scene_ai/scene_ai.pri new file mode 100644 index 000000000..794d990f6 --- /dev/null +++ b/src/threed/scene_ai/scene_ai.pri @@ -0,0 +1,21 @@ +INCLUDEPATH += $$PWD +VPATH += $$PWD +HEADERS += \ + scene_ai/qaiscenehandler.h \ + scene_ai/qaiscene.h \ + scene_ai/qaimesh.h \ + scene_ai/qailoader.h \ + scene_ai/ailoaderiosystem.h \ + scene_ai/ailoaderiostream.h +SOURCES += \ + scene_ai/qaiscenehandler.cpp \ + scene_ai/qaiscene.cpp \ + scene_ai/qaimesh.cpp \ + scene_ai/qailoader.cpp \ + scene_ai/ailoaderiosystem.cpp \ + scene_ai/ailoaderiostream.cpp + + +# suppress warnings about std::copy using unsafe parameters +win32: DEFINES +=_SCL_SECURE_NO_WARNINGS +include(../../../3rdparty/assimp/assimp.pri) diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.cpp b/src/threed/scene_bezier/qglbezierscene.cpp index fe864f257..fe864f257 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscene.cpp +++ b/src/threed/scene_bezier/qglbezierscene.cpp diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.h b/src/threed/scene_bezier/qglbezierscene.h index 156e2266f..156e2266f 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscene.h +++ b/src/threed/scene_bezier/qglbezierscene.h diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp b/src/threed/scene_bezier/qglbezierscenehandler.cpp index 58ea68c60..86c25eb3a 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp +++ b/src/threed/scene_bezier/qglbezierscenehandler.cpp @@ -47,6 +47,12 @@ QT_BEGIN_NAMESPACE +QStringList QGLBezierSceneHandler::supportedFormats() { + QStringList result; + result.append(QString("bez")); + return result; +} + QGLAbstractScene *QGLBezierSceneHandler::read() { QTextStream stream(device()); diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h b/src/threed/scene_bezier/qglbezierscenehandler.h index 59f8945f9..ff77d577b 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h +++ b/src/threed/scene_bezier/qglbezierscenehandler.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QGLBezierSceneHandler : public QGLSceneFormatHandler { public: + static QStringList supportedFormats(); QGLAbstractScene *read(); QGLAbstractScene *download(); }; diff --git a/src/threed/scene_bezier/scene_bezier.pri b/src/threed/scene_bezier/scene_bezier.pri new file mode 100644 index 000000000..5fb11f3ed --- /dev/null +++ b/src/threed/scene_bezier/scene_bezier.pri @@ -0,0 +1,8 @@ +INCLUDEPATH += $$PWD +VPATH += $$PWD +HEADERS += \ + scene_bezier/qglbezierscenehandler.h \ + scene_bezier/qglbezierscene.h +SOURCES += \ + scene_bezier/qglbezierscenehandler.cpp \ + scene_bezier/qglbezierscene.cpp diff --git a/src/threed/threed.pri b/src/threed/threed.pri index 0c3e68cb2..9b4674569 100644 --- a/src/threed/threed.pri +++ b/src/threed/threed.pri @@ -7,6 +7,8 @@ include(geometry/geometry.pri) include(viewing/viewing.pri) include(math3d/math3d.pri) include(scene/scene.pri) +include(scene_ai/scene_ai.pri) +include(scene_bezier/scene_bezier.pri) include(network/network.pri) include(graphicsview/graphicsview.pri) include(textures/textures.pri) |