diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-04-11 14:58:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-04-23 11:14:30 +0000 |
commit | 0542f1614aa6d50c4c9809fb0ce5f1adb5666d67 (patch) | |
tree | 77a1ed41c16262f5cc7aa9ddb2d66d3f9b61a719 /src/render/defaults | |
parent | 8677f62fa690efa29fbb6f870af1ea2b4e7111cf (diff) |
Move defaults and geometries out of Qt3DRender and into Qt3DExtras
QBoundingVolumeDebug has been disabled for now. Will be re-enabled later on.
Change-Id: Id6b0abab2ec2aa697330bd20d782f9d104d25d50
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/defaults')
34 files changed, 0 insertions, 5318 deletions
diff --git a/src/render/defaults/defaults.pri b/src/render/defaults/defaults.pri deleted file mode 100644 index 1560f55ec..000000000 --- a/src/render/defaults/defaults.pri +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qphongmaterial.h \ - $$PWD/qphongmaterial_p.h \ - $$PWD/qdiffusemapmaterial_p.h \ - $$PWD/qdiffusemapmaterial.h \ - $$PWD/qnormaldiffusespecularmapmaterial.h \ - $$PWD/qnormaldiffusespecularmapmaterial_p.h \ - $$PWD/qnormaldiffusemapmaterial.h \ - $$PWD/qnormaldiffusemapmaterial_p.h \ - $$PWD/qnormaldiffusemapalphamaterial.h \ - $$PWD/qnormaldiffusemapalphamaterial_p.h \ - $$PWD/qdiffusespecularmapmaterial.h \ - $$PWD/qdiffusespecularmapmaterial_p.h \ - $$PWD/qforwardrenderer.h \ - $$PWD/qforwardrenderer_p.h \ - $$PWD/qpervertexcolormaterial.h \ - $$PWD/qpervertexcolormaterial_p.h \ - $$PWD/qskyboxentity.h \ - $$PWD/qskyboxentity_p.h \ - $$PWD/qgoochmaterial.h \ - $$PWD/qgoochmaterial_p.h \ - $$PWD/qphongalphamaterial.h \ - $$PWD/qphongalphamaterial_p.h - -SOURCES += \ - $$PWD/qphongmaterial.cpp \ - $$PWD/qdiffusemapmaterial.cpp \ - $$PWD/qnormaldiffusespecularmapmaterial.cpp \ - $$PWD/qnormaldiffusemapmaterial.cpp \ - $$PWD/qnormaldiffusemapalphamaterial.cpp \ - $$PWD/qdiffusespecularmapmaterial.cpp \ - $$PWD/qforwardrenderer.cpp \ - $$PWD/qpervertexcolormaterial.cpp \ - $$PWD/qskyboxentity.cpp \ - $$PWD/qgoochmaterial.cpp \ - $$PWD/qphongalphamaterial.cpp - diff --git a/src/render/defaults/qdiffusemapmaterial.cpp b/src/render/defaults/qdiffusemapmaterial.cpp deleted file mode 100644 index 985b6c569..000000000 --- a/src/render/defaults/qdiffusemapmaterial.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdiffusemapmaterial.h" -#include "qdiffusemapmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QDiffuseMapMaterialPrivate::QDiffuseMapMaterialPrivate() - : QMaterialPrivate() - , m_diffuseMapEffect(new QEffect()) - , m_diffuseTexture(new QTexture2D()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture)) - , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f))) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f)) - , m_diffuseMapGL3Technique(new QTechnique()) - , m_diffuseMapGL2Technique(new QTechnique()) - , m_diffuseMapES2Technique(new QTechnique()) - , m_diffuseMapGL3RenderPass(new QRenderPass()) - , m_diffuseMapGL2RenderPass(new QRenderPass()) - , m_diffuseMapES2RenderPass(new QRenderPass()) - , m_diffuseMapGL3Shader(new QShaderProgram()) - , m_diffuseMapGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ - m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_diffuseTexture->setGenerateMipMaps(true); - m_diffuseTexture->setMaximumAnisotropy(16.0f); -} - -void QDiffuseMapMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseMapMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseMapMaterialPrivate::handleDiffuseChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseMapMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseMapMaterialPrivate::handleShininessChanged); - connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseMapMaterialPrivate::handleTextureScaleChanged); - - m_diffuseMapGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.vert")))); - m_diffuseMapGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.frag")))); - m_diffuseMapGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.vert")))); - m_diffuseMapGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.frag")))); - - m_diffuseMapGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_diffuseMapGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_diffuseMapGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_diffuseMapGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_diffuseMapGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_diffuseMapGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_diffuseMapGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_diffuseMapGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_diffuseMapES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_diffuseMapES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_diffuseMapES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_diffuseMapES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QDiffuseMapMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_diffuseMapGL3Technique->addFilterKey(m_filterKey); - m_diffuseMapGL2Technique->addFilterKey(m_filterKey); - m_diffuseMapES2Technique->addFilterKey(m_filterKey); - - m_diffuseMapGL3RenderPass->setShaderProgram(m_diffuseMapGL3Shader); - m_diffuseMapGL2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader); - m_diffuseMapES2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader); - - m_diffuseMapGL3Technique->addRenderPass(m_diffuseMapGL3RenderPass); - m_diffuseMapGL2Technique->addRenderPass(m_diffuseMapGL2RenderPass); - m_diffuseMapES2Technique->addRenderPass(m_diffuseMapES2RenderPass); - - m_diffuseMapEffect->addTechnique(m_diffuseMapGL3Technique); - m_diffuseMapEffect->addTechnique(m_diffuseMapGL2Technique); - m_diffuseMapEffect->addTechnique(m_diffuseMapES2Technique); - - m_diffuseMapEffect->addParameter(m_ambientParameter); - m_diffuseMapEffect->addParameter(m_diffuseParameter); - m_diffuseMapEffect->addParameter(m_specularParameter); - m_diffuseMapEffect->addParameter(m_shininessParameter); - m_diffuseMapEffect->addParameter(m_textureScaleParameter); - - q->setEffect(m_diffuseMapEffect); -} - -void QDiffuseMapMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QDiffuseMapMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QDiffuseMapMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QDiffuseMapMaterial); - emit q->diffuseChanged(var.value<QAbstractTexture *>()); -} - -void QDiffuseMapMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QDiffuseMapMaterial); - emit q->specularChanged(var.value<QColor>()); -} - -void QDiffuseMapMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QDiffuseMapMaterial); - emit q->shininessChanged(var.toFloat()); -} - -void QDiffuseMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var) -{ - Q_Q(QDiffuseMapMaterial); - emit q->textureScaleChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QDiffuseMapMaterial - \brief The QDiffuseMapMaterial provides a default implementation of the phong lighting effect where the diffuse light component - is read from a texture map. - \inmodule Qt3DRender - \since 5.5 - - The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - Constructs a new Qt3DRender::QDiffuseMapMaterial instance with parent object \a parent. - */ -QDiffuseMapMaterial::QDiffuseMapMaterial(QNode *parent) - : QMaterial(*new QDiffuseMapMaterialPrivate, parent) -{ - Q_D(QDiffuseMapMaterial); - d->init(); -} - -/*! - Destroys the QDiffuseMapMaterial instance. -*/ -QDiffuseMapMaterial::~QDiffuseMapMaterial() -{ -} - -/*! - \property Qt3DRender::QDiffuseMapMaterial::ambient - - Holds the current ambient color. -*/ - -QColor QDiffuseMapMaterial::ambient() const -{ - Q_D(const QDiffuseMapMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QDiffuseMapMaterial::specular - - Holds the current specular color. -*/ -QColor QDiffuseMapMaterial::specular() const -{ - Q_D(const QDiffuseMapMaterial); - return d->m_specularParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QDiffuseMapMaterial::shininess - - Holds the current shininess as a float value. -*/ -float QDiffuseMapMaterial::shininess() const -{ - Q_D(const QDiffuseMapMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QDiffuseMapMaterial::diffuse - - Holds the current QTexture used as the diffuse map. - - By default, the diffuse texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QDiffuseMapMaterial::diffuse() const -{ - Q_D(const QDiffuseMapMaterial); - return d->m_diffuseParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QDiffuseMapMaterial::textureScale - - Holds the current texture scale as a float value. - -*/ -float QDiffuseMapMaterial::textureScale() const -{ - Q_D(const QDiffuseMapMaterial); - return d->m_textureScaleParameter->value().toFloat(); -} - -void QDiffuseMapMaterial::setAmbient(const QColor &ambient) -{ - Q_D(const QDiffuseMapMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QDiffuseMapMaterial::setSpecular(const QColor &specular) -{ - Q_D(QDiffuseMapMaterial); - d->m_specularParameter->setValue(specular); -} - -void QDiffuseMapMaterial::setShininess(float shininess) -{ - Q_D(QDiffuseMapMaterial); - d->m_shininessParameter->setValue(shininess); -} - -void QDiffuseMapMaterial::setDiffuse(QAbstractTexture *diffuseMap) -{ - Q_D(QDiffuseMapMaterial); - d->m_diffuseParameter->setValue(QVariant::fromValue(diffuseMap)); -} - -void QDiffuseMapMaterial::setTextureScale(float textureScale) -{ - Q_D(QDiffuseMapMaterial); - d->m_textureScaleParameter->setValue(textureScale); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qdiffusemapmaterial.h b/src/render/defaults/qdiffusemapmaterial.h deleted file mode 100644 index cf30630ae..000000000 --- a/src/render/defaults/qdiffusemapmaterial.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QDIFFUSEMAPMATERIAL_H -#define QT3DRENDER_RENDER_QDIFFUSEMAPMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QDiffuseMapMaterialPrivate; -class QAbstractTexture; - -class QT3DRENDERSHARED_EXPORT QDiffuseMapMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged) - -public: - explicit QDiffuseMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QDiffuseMapMaterial(); - - QColor ambient() const; - QColor specular() const; - float shininess() const; - QAbstractTexture *diffuse() const; - float textureScale() const; - -public Q_SLOTS: - void setAmbient(const QColor &color); - void setSpecular(const QColor &specular); - void setShininess(float shininess); - void setDiffuse(QAbstractTexture *diffuse); - void setTextureScale(float textureScale); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(QAbstractTexture *diffuse); - void specularChanged(const QColor &specular); - void shininessChanged(float shininess); - void textureScaleChanged(float textureScale); - -private: - Q_DECLARE_PRIVATE(QDiffuseMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QDIFFUSEMAPMATERIAL_H diff --git a/src/render/defaults/qdiffusemapmaterial_p.h b/src/render/defaults/qdiffusemapmaterial_p.h deleted file mode 100644 index 3a0d721a3..000000000 --- a/src/render/defaults/qdiffusemapmaterial_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QDIFFUSEMAPMATERIAL_P_H -#define QT3DRENDER_RENDER_QDIFFUSEMAPMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QAbstractTexture; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QDiffuseMapMaterial; - -class QDiffuseMapMaterialPrivate : public QMaterialPrivate -{ - QDiffuseMapMaterialPrivate(); - - void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - void handleTextureScaleChanged(const QVariant &var); - - QEffect *m_diffuseMapEffect; - QAbstractTexture *m_diffuseTexture; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QParameter *m_textureScaleParameter; - QTechnique *m_diffuseMapGL3Technique; - QTechnique *m_diffuseMapGL2Technique; - QTechnique *m_diffuseMapES2Technique; - QRenderPass *m_diffuseMapGL3RenderPass; - QRenderPass *m_diffuseMapGL2RenderPass; - QRenderPass *m_diffuseMapES2RenderPass; - QShaderProgram *m_diffuseMapGL3Shader; - QShaderProgram *m_diffuseMapGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QDiffuseMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QDIFFUSEAPMATERIAL_P_H - diff --git a/src/render/defaults/qdiffusespecularmapmaterial.cpp b/src/render/defaults/qdiffusespecularmapmaterial.cpp deleted file mode 100644 index 26b98bd2c..000000000 --- a/src/render/defaults/qdiffusespecularmapmaterial.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdiffusespecularmapmaterial.h" -#include "qdiffusespecularmapmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QDiffuseSpecularMapMaterialPrivate::QDiffuseSpecularMapMaterialPrivate() - : QMaterialPrivate() - , m_diffuseSpecularMapEffect(new QEffect()) - , m_diffuseTexture(new QTexture2D()) - , m_specularTexture(new QTexture2D()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture)) - , m_specularParameter(new QParameter(QStringLiteral("specularTexture"), m_specularTexture)) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f)) - , m_diffuseSpecularMapGL3Technique(new QTechnique()) - , m_diffuseSpecularMapGL2Technique(new QTechnique()) - , m_diffuseSpecularMapES2Technique(new QTechnique()) - , m_diffuseSpecularMapGL3RenderPass(new QRenderPass()) - , m_diffuseSpecularMapGL2RenderPass(new QRenderPass()) - , m_diffuseSpecularMapES2RenderPass(new QRenderPass()) - , m_diffuseSpecularMapGL3Shader(new QShaderProgram()) - , m_diffuseSpecularMapGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ - m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_diffuseTexture->setGenerateMipMaps(true); - m_diffuseTexture->setMaximumAnisotropy(16.0f); - - m_specularTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_specularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_specularTexture->setGenerateMipMaps(true); - m_specularTexture->setMaximumAnisotropy(16.0f); -} - -void QDiffuseSpecularMapMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseSpecularMapMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseSpecularMapMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseSpecularMapMaterialPrivate::handleShininessChanged); - connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged); - - m_diffuseSpecularMapGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.vert")))); - m_diffuseSpecularMapGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusespecularmap.frag")))); - m_diffuseSpecularMapGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.vert")))); - m_diffuseSpecularMapGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusespecularmap.frag")))); - - m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QDiffuseSpecularMapMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_diffuseSpecularMapGL3Technique->addFilterKey(m_filterKey); - m_diffuseSpecularMapGL2Technique->addFilterKey(m_filterKey); - m_diffuseSpecularMapES2Technique->addFilterKey(m_filterKey); - - m_diffuseSpecularMapGL3RenderPass->setShaderProgram(m_diffuseSpecularMapGL3Shader); - m_diffuseSpecularMapGL2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader); - m_diffuseSpecularMapES2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader); - - m_diffuseSpecularMapGL3Technique->addRenderPass(m_diffuseSpecularMapGL3RenderPass); - m_diffuseSpecularMapGL2Technique->addRenderPass(m_diffuseSpecularMapGL2RenderPass); - m_diffuseSpecularMapES2Technique->addRenderPass(m_diffuseSpecularMapES2RenderPass); - - m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapGL3Technique); - m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapGL2Technique); - m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapES2Technique); - - m_diffuseSpecularMapEffect->addParameter(m_ambientParameter); - m_diffuseSpecularMapEffect->addParameter(m_diffuseParameter); - m_diffuseSpecularMapEffect->addParameter(m_specularParameter); - m_diffuseSpecularMapEffect->addParameter(m_shininessParameter); - m_diffuseSpecularMapEffect->addParameter(m_textureScaleParameter); - - q->setEffect(m_diffuseSpecularMapEffect); -} - -void QDiffuseSpecularMapMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QDiffuseSpecularMapMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QDiffuseSpecularMapMaterial); - emit q->diffuseChanged(var.value<QAbstractTexture *>()); -} - -void QDiffuseSpecularMapMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QDiffuseSpecularMapMaterial); - emit q->specularChanged(var.value<QAbstractTexture *>()); -} - -void QDiffuseSpecularMapMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QDiffuseSpecularMapMaterial); - emit q->shininessChanged(var.toFloat()); -} - -void QDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var) -{ - Q_Q(QDiffuseSpecularMapMaterial); - emit q->textureScaleChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QDiffuseSpecularMapMaterial - \brief The QDiffuseSpecularMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse and specular light components - are read from texture maps. - \inmodule Qt3DRender - \since 5.5 - - The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - Constructs a new Qt3DRender::QDiffuseSpecularMapMaterial instance with parent object \a parent. -*/ -QDiffuseSpecularMapMaterial::QDiffuseSpecularMapMaterial(QNode *parent) - : QMaterial(*new QDiffuseSpecularMapMaterialPrivate, parent) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->init(); -} - -/*! - Destroys the QDiffuseSpecularMapMaterial instance. -*/ -QDiffuseSpecularMapMaterial::~QDiffuseSpecularMapMaterial() -{ -} - -/*! - \property Qt3DRender::QDiffuseSpecularMapMaterial::ambient - - Holds the current ambient color. -*/ -QColor QDiffuseSpecularMapMaterial::ambient() const -{ - Q_D(const QDiffuseSpecularMapMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QDiffuseSpecularMapMaterial::diffuse - - Holds the current diffuse map texture. - - By default, the diffuse texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QDiffuseSpecularMapMaterial::diffuse() const -{ - Q_D(const QDiffuseSpecularMapMaterial); - return d->m_diffuseParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QDiffuseSpecularMapMaterial::specular - - Holds the current specular map texture. - - By default, the specular texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QDiffuseSpecularMapMaterial::specular() const -{ - Q_D(const QDiffuseSpecularMapMaterial); - return d->m_specularParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QDiffuseSpecularMapMaterial::shininess - - Holds the current shininess as a float value. -*/ -float QDiffuseSpecularMapMaterial::shininess() const -{ - Q_D(const QDiffuseSpecularMapMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QDiffuseSpecularMapMaterial::textureScale - - Holds the current texture scale as a float value. -*/ -float QDiffuseSpecularMapMaterial::textureScale() const -{ - Q_D(const QDiffuseSpecularMapMaterial); - return d->m_textureScaleParameter->value().toFloat(); -} - -void QDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QDiffuseSpecularMapMaterial::setDiffuse(QAbstractTexture *diffuse) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse)); -} - -void QDiffuseSpecularMapMaterial::setSpecular(QAbstractTexture *specular) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->m_specularParameter->setValue(QVariant::fromValue(specular)); -} - -void QDiffuseSpecularMapMaterial::setShininess(float shininess) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->m_shininessParameter->setValue(shininess); -} - -void QDiffuseSpecularMapMaterial::setTextureScale(float textureScale) -{ - Q_D(QDiffuseSpecularMapMaterial); - d->m_textureScaleParameter->setValue(textureScale); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qdiffusespecularmapmaterial.h b/src/render/defaults/qdiffusespecularmapmaterial.h deleted file mode 100644 index ebeda9860..000000000 --- a/src/render/defaults/qdiffusespecularmapmaterial.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_H -#define QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QAbstractTexture; -class QDiffuseSpecularMapMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QDiffuseSpecularMapMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged) - -public: - explicit QDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QDiffuseSpecularMapMaterial(); - - QColor ambient() const; - QAbstractTexture *diffuse() const; - QAbstractTexture *specular() const; - float shininess() const; - float textureScale() const; - -public Q_SLOTS: - void setAmbient(const QColor &ambient); - void setDiffuse(QAbstractTexture *diffuse); - void setSpecular(QAbstractTexture *specular); - void setShininess(float shininess); - void setTextureScale(float textureScale); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(QAbstractTexture *diffuse); - void specularChanged(QAbstractTexture *specular); - void shininessChanged(float shininess); - void textureScaleChanged(float textureScale); - -private: - Q_DECLARE_PRIVATE(QDiffuseSpecularMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_H diff --git a/src/render/defaults/qdiffusespecularmapmaterial_p.h b/src/render/defaults/qdiffusespecularmapmaterial_p.h deleted file mode 100644 index 58e4e63ba..000000000 --- a/src/render/defaults/qdiffusespecularmapmaterial_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H -#define QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QAbstractTexture; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QDiffuseSpecularMapMaterial; - -class QDiffuseSpecularMapMaterialPrivate : public QMaterialPrivate -{ -public: - QDiffuseSpecularMapMaterialPrivate(); - - void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - void handleTextureScaleChanged(const QVariant &var); - - QEffect *m_diffuseSpecularMapEffect; - QAbstractTexture *m_diffuseTexture; - QAbstractTexture *m_specularTexture; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QParameter *m_textureScaleParameter; - QTechnique *m_diffuseSpecularMapGL3Technique; - QTechnique *m_diffuseSpecularMapGL2Technique; - QTechnique *m_diffuseSpecularMapES2Technique; - QRenderPass *m_diffuseSpecularMapGL3RenderPass; - QRenderPass *m_diffuseSpecularMapGL2RenderPass; - QRenderPass *m_diffuseSpecularMapES2RenderPass; - QShaderProgram *m_diffuseSpecularMapGL3Shader; - QShaderProgram *m_diffuseSpecularMapGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QDiffuseSpecularMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H - diff --git a/src/render/defaults/qforwardrenderer.cpp b/src/render/defaults/qforwardrenderer.cpp deleted file mode 100644 index cd8f2a507..000000000 --- a/src/render/defaults/qforwardrenderer.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qforwardrenderer.h" -#include "qforwardrenderer_p.h" - -#include <Qt3DRender/qviewport.h> -#include <Qt3DRender/qcameraselector.h> -#include <Qt3DRender/qclearbuffers.h> -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qfrustumculling.h> -#include <Qt3DRender/qrendersurfaceselector.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QForwardRendererPrivate::QForwardRendererPrivate() - : QTechniqueFilterPrivate() - , m_surfaceSelector(new QRenderSurfaceSelector) - , m_viewport(new QViewport()) - , m_cameraSelector(new QCameraSelector()) - , m_clearBuffer(new QClearBuffers()) - , m_frustumCulling(new QFrustumCulling()) -{ -} - -void QForwardRendererPrivate::init() -{ - Q_Q(QForwardRenderer); - - m_frustumCulling->setParent(m_clearBuffer); - m_clearBuffer->setParent(m_cameraSelector); - m_cameraSelector->setParent(m_viewport); - m_viewport->setParent(m_surfaceSelector); - m_surfaceSelector->setParent(q); - - m_viewport->setNormalizedRect(QRectF(0.0f, 0.0f, 1.0f, 1.0f)); - m_clearBuffer->setClearColor(Qt::white); - m_clearBuffer->setBuffers(QClearBuffers::ColorDepthBuffer); - - QFilterKey *forwardRenderingStyle = new QFilterKey(q); - forwardRenderingStyle->setName(QStringLiteral("renderingStyle")); - forwardRenderingStyle->setValue(QStringLiteral("forward")); - q->addMatch(forwardRenderingStyle); -} - -/*! - \class Qt3DRender::QForwardRenderer - \brief The Qt3DRender::QForwardRenderer provides a default \l {QFrameGraph}{FrameGraph} implementation of a forward renderer. - \inmodule Qt3DRender - \since 5.5 - - Forward rendering is how OpenGL is traditionally. It renders directly to the backbuffer - one object at a time shading each one as it goes. - - Internally the Qt3DRender::QForwardRenderer is a subclass of Qt3DRender::QTechniqueFilter. - This a is a single leaf Framegraph tree which contains a Qt3DRender::QViewport, a Qt3DRender::QCameraSelector - and a Qt3DRender::QClearBuffers. - The Qt3DRender::QForwardRenderer has a default requirement annotation whose name is "renderingStyle" and value "forward". - If you need to filter out your techniques, you should do so based on that annotation. - - By default the viewport occupies the whole screen and the clear color is white. Frustum culling is also enabled. -*/ - -/*! - Constructs a new Qt3DRender::QForwardRenderer instance with parent object \a parent. - */ -QForwardRenderer::QForwardRenderer(QNode *parent) - : QTechniqueFilter(*new QForwardRendererPrivate, parent) -{ - Q_D(QForwardRenderer); - QObject::connect(d->m_clearBuffer, SIGNAL(clearColorChanged(const QColor &)), this, SIGNAL(clearColorChanged(const QColor &))); - QObject::connect(d->m_viewport, SIGNAL(normalizedRectChanged(const QRectF &)), this, SIGNAL(viewportRectChanged(const QRectF &))); - QObject::connect(d->m_cameraSelector, SIGNAL(cameraChanged(Qt3DCore::QEntity *)), this, SIGNAL(cameraChanged(Qt3DCore::QEntity *))); - QObject::connect(d->m_surfaceSelector, SIGNAL(surfaceChanged(QObject *)), this, SIGNAL(surfaceChanged(QObject *))); - d->init(); -} - -/*! - Destroys the QForwardRenderer instance. -*/ -QForwardRenderer::~QForwardRenderer() -{ -} - -void QForwardRenderer::setViewportRect(const QRectF &viewportRect) -{ - Q_D(QForwardRenderer); - d->m_viewport->setNormalizedRect(viewportRect); -} - -void QForwardRenderer::setClearColor(const QColor &clearColor) -{ - Q_D(QForwardRenderer); - d->m_clearBuffer->setClearColor(clearColor); -} - -/*! - Sets the camera which should be used to render the scene to \a camera. - - \note A camera is a QEntity having a QCameraLens as one of its components. -*/ -void QForwardRenderer::setCamera(Qt3DCore::QEntity *camera) -{ - Q_D(QForwardRenderer); - d->m_cameraSelector->setCamera(camera); -} - -void QForwardRenderer::setSurface(QObject *surface) -{ - Q_D(QForwardRenderer); - d->m_surfaceSelector->setSurface(surface); -} - -/*! - \property Qt3DRender::QForwardRenderer::viewportRect - - Holds the current viewport normalizedRect. - */ -QRectF QForwardRenderer::viewportRect() const -{ - Q_D(const QForwardRenderer); - return d->m_viewport->normalizedRect(); -} - -/*! - \property Qt3DRender::QForwardRenderer::clearColor - - Holds the current clearColor. -*/ -QColor QForwardRenderer::clearColor() const -{ - Q_D(const QForwardRenderer); - return d->m_clearBuffer->clearColor(); -} - -/*! - \property Qt3DRender::QForwardRenderer::camera - - Holds the current QEntity camera used to render the scene. - - \note A camera is a QEntity that has a QCameraLens as one of its components. -*/ -Qt3DCore::QEntity *QForwardRenderer::camera() const -{ - Q_D(const QForwardRenderer); - return d->m_cameraSelector->camera(); -} - -QObject *QForwardRenderer::surface() const -{ - Q_D(const QForwardRenderer); - return d->m_surfaceSelector->surface(); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qforwardrenderer.h b/src/render/defaults/qforwardrenderer.h deleted file mode 100644 index e256affd6..000000000 --- a/src/render/defaults/qforwardrenderer.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QFORWARDRENDERER_H -#define QT3DRENDER_RENDER_QFORWARDRENDERER_H - -#include <Qt3DRender/qtechniquefilter.h> -#include <QRectF> -#include <QColor> - -QT_BEGIN_NAMESPACE - -class QSurface; - -namespace Qt3DRender { - -class QForwardRendererPrivate; - -class QT3DRENDERSHARED_EXPORT QForwardRenderer : public QTechniqueFilter -{ - Q_OBJECT - Q_PROPERTY(QObject *surface READ surface WRITE setSurface NOTIFY surfaceChanged) - Q_PROPERTY(QRectF viewportRect READ viewportRect WRITE setViewportRect NOTIFY viewportRectChanged) - Q_PROPERTY(QColor clearColor READ clearColor WRITE setClearColor NOTIFY clearColorChanged) - Q_PROPERTY(Qt3DCore::QEntity *camera READ camera WRITE setCamera NOTIFY cameraChanged) -public: - explicit QForwardRenderer(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QForwardRenderer(); - - QRectF viewportRect() const; - QColor clearColor() const; - Qt3DCore::QEntity *camera() const; - QObject *surface() const; - -public Q_SLOTS: - void setViewportRect(const QRectF &viewportRect); - void setClearColor(const QColor &clearColor); - void setCamera(Qt3DCore::QEntity *camera); - void setSurface(QObject * surface); - -Q_SIGNALS: - void viewportRectChanged(const QRectF &viewportRect); - void clearColorChanged(const QColor &clearColor); - void cameraChanged(Qt3DCore::QEntity *camera); - void surfaceChanged(QObject *surface); - -private: - Q_DECLARE_PRIVATE(QForwardRenderer) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDERER_QFORWARDRENDERER_H diff --git a/src/render/defaults/qforwardrenderer_p.h b/src/render/defaults/qforwardrenderer_p.h deleted file mode 100644 index 5e5e6f696..000000000 --- a/src/render/defaults/qforwardrenderer_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QFORWARDRENDERER_P_H -#define QT3DRENDER_RENDER_QFORWARDRENDERER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qtechniquefilter_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QForwardRenderer; -class QViewport; -class QClearBuffers; -class QCameraSelector; -class QFrustumCulling; -class QRenderSurfaceSelector; - -class QForwardRendererPrivate: public QTechniqueFilterPrivate -{ -public: - QForwardRendererPrivate(); - - QRenderSurfaceSelector *m_surfaceSelector; - QViewport *m_viewport; - QCameraSelector *m_cameraSelector; - QClearBuffers *m_clearBuffer; - QFrustumCulling *m_frustumCulling; - - void init(); - - Q_DECLARE_PUBLIC(QForwardRenderer) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QFORWARDRENDERER_P_H - diff --git a/src/render/defaults/qgoochmaterial.cpp b/src/render/defaults/qgoochmaterial.cpp deleted file mode 100644 index 7b4865734..000000000 --- a/src/render/defaults/qgoochmaterial.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgoochmaterial.h" -#include "qgoochmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qtechnique.h> - -#include <QtCore/qurl.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QGoochMaterialPrivate::QGoochMaterialPrivate() - : QMaterialPrivate() - , m_effect(new QEffect) - , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.0f, 0.0f, 0.0f))) - , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.0f, 0.0f, 0.0f))) - , m_coolParameter(new QParameter(QStringLiteral("kblue"), QColor::fromRgbF(0.0f, 0.0f, 0.4f))) - , m_warmParameter(new QParameter(QStringLiteral("kyellow"), QColor::fromRgbF(0.4f, 0.4f, 0.0f))) - , m_alphaParameter(new QParameter(QStringLiteral("alpha"), 0.25f)) - , m_betaParameter(new QParameter(QStringLiteral("beta"), 0.5f)) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 100.0f)) - , m_gl3Technique(new QTechnique) - , m_gl2Technique(new QTechnique) - , m_es2Technique(new QTechnique) - , m_gl3RenderPass(new QRenderPass) - , m_gl2RenderPass(new QRenderPass) - , m_es2RenderPass(new QRenderPass) - , m_gl3Shader(new QShaderProgram) - , m_gl2ES2Shader(new QShaderProgram) - , m_filterKey(new QFilterKey) -{ -} - -void QGoochMaterialPrivate::init() -{ - Q_Q(QGoochMaterial); - - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleDiffuseChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleSpecularChanged); - connect(m_coolParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleCoolChanged); - connect(m_warmParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleWarmChanged); - connect(m_alphaParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleAlphaChanged); - connect(m_betaParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleBetaChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QGoochMaterialPrivate::handleShininessChanged); - - m_gl3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/gooch.vert")))); - m_gl3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/gooch.frag")))); - m_gl2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/gooch.vert")))); - m_gl2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/gooch.frag")))); - - m_gl3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_gl3Technique->graphicsApiFilter()->setMajorVersion(3); - m_gl3Technique->graphicsApiFilter()->setMinorVersion(1); - m_gl3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_gl2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_gl2Technique->graphicsApiFilter()->setMajorVersion(2); - m_gl2Technique->graphicsApiFilter()->setMinorVersion(0); - m_gl2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_es2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_es2Technique->graphicsApiFilter()->setMajorVersion(2); - m_es2Technique->graphicsApiFilter()->setMinorVersion(0); - m_es2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_gl3Technique->addFilterKey(m_filterKey); - m_gl2Technique->addFilterKey(m_filterKey); - m_es2Technique->addFilterKey(m_filterKey); - - m_gl3RenderPass->setShaderProgram(m_gl3Shader); - m_gl2RenderPass->setShaderProgram(m_gl2ES2Shader); - m_es2RenderPass->setShaderProgram(m_gl2ES2Shader); - - m_gl3Technique->addRenderPass(m_gl3RenderPass); - m_gl2Technique->addRenderPass(m_gl2RenderPass); - m_es2Technique->addRenderPass(m_es2RenderPass); - - m_effect->addTechnique(m_gl3Technique); - m_effect->addTechnique(m_gl2Technique); - m_effect->addTechnique(m_es2Technique); - - m_effect->addParameter(m_diffuseParameter); - m_effect->addParameter(m_specularParameter); - m_effect->addParameter(m_coolParameter); - m_effect->addParameter(m_warmParameter); - m_effect->addParameter(m_alphaParameter); - m_effect->addParameter(m_betaParameter); - m_effect->addParameter(m_shininessParameter); - - q->setEffect(m_effect); -} - -void QGoochMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->diffuseChanged(var.value<QColor>()); -} - -void QGoochMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->specularChanged(var.value<QColor>()); -} - -void QGoochMaterialPrivate::handleCoolChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->coolChanged(var.value<QColor>()); -} - -void QGoochMaterialPrivate::handleWarmChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->warmChanged(var.value<QColor>()); -} - -void QGoochMaterialPrivate::handleAlphaChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->alphaChanged(var.toFloat()); -} - -void QGoochMaterialPrivate::handleBetaChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->betaChanged(var.toFloat()); -} - -void QGoochMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QGoochMaterial); - emit q->shininessChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QGoochMaterial - \brief The QGoochMaterial provides a material that implements the Gooch - shading model, popular in CAD and CAM applications. - \inmodule Qt3DRender - \since 5.5 - - The Gooch lighting model uses both color and brightness to help show the - curvature of 3D surfaces. This is often better than models such as Phong - that rely purely upon changes in brightness. In situations such as in CAD - and CAM applications where photorealism is not a goal, the Gooch shading - model in conjunction with some kind of silhouette edge inking is a popular - solution. - - The Gooch lighting model is explained fully in the \l{original Gooch - paper}. The Gooch model mixes a diffuse objetc color with a user-provided - cool color and warm color to produce the end points of a color ramp that is - used to shade the object based upon the cosine of the angle between the - vector from the fragment to the light source and the fragment's normal - vector. Optionally, a specular highlight can be added on top. The relative - contributions to the cool and warm colors by the diffuse color are - controlled by the alpha and beta properties respecitvely. - - This material uses an effect with a single render pass approach and - performs per fragment lighting. Techniques are provided for OpenGL 2, - OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - Constructs a new Qt3DCore::QGoochMaterial instance with parent object \a parent. -*/ -QGoochMaterial::QGoochMaterial(QNode *parent) - : QMaterial(*new QGoochMaterialPrivate, parent) -{ - Q_D(QGoochMaterial); - d->init(); -} - -QGoochMaterial::QGoochMaterial(QGoochMaterialPrivate &dd, QNode *parent) - : QMaterial(dd, parent) -{ - Q_D(QGoochMaterial); - d->init(); -} - -/*! - \property Qt3DRender::QGoochMaterial::diffuse - - Holds the current diffuse color. -*/ -QColor QGoochMaterial::diffuse() const -{ - Q_D(const QGoochMaterial); - return d->m_diffuseParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QGoochMaterial::specular - - Holds the current specular color. -*/ -QColor QGoochMaterial::specular() const -{ - Q_D(const QGoochMaterial); - return d->m_specularParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QGoochMaterial::cool - - Holds the current cool color. -*/ -QColor QGoochMaterial::cool() const -{ - Q_D(const QGoochMaterial); - return d->m_coolParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QGoochMaterial::warm - - Holds the current warm color. -*/ -QColor QGoochMaterial::warm() const -{ - Q_D(const QGoochMaterial); - return d->m_warmParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QGoochMaterial::alpha - - Holds the current alpha value. The start point of the color ramp - used by the Gooch shader is calculated as {c = cool + alpha * diffuse}. -*/ -float QGoochMaterial::alpha() const -{ - Q_D(const QGoochMaterial); - return d->m_alphaParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QGoochMaterial::beta - - Holds the current beta value. The start point of the color ramp - used by the Gooch shader is calculated as {c = warm + beta * diffuse}. -*/ -float QGoochMaterial::beta() const -{ - Q_D(const QGoochMaterial); - return d->m_betaParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QGoochMaterial::shininess - - Holds the current shininess value. Higher values of shininess result in - a smaller and brighter highlight. -*/ -float QGoochMaterial::shininess() const -{ - Q_D(const QGoochMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -void QGoochMaterial::setDiffuse(const QColor &diffuse) -{ - Q_D(QGoochMaterial); - return d->m_diffuseParameter->setValue(diffuse); -} - -void QGoochMaterial::setSpecular(const QColor &specular) -{ - Q_D(QGoochMaterial); - return d->m_specularParameter->setValue(specular); -} - -void QGoochMaterial::setCool(const QColor &cool) -{ - Q_D(QGoochMaterial); - return d->m_coolParameter->setValue(cool); -} - -void QGoochMaterial::setWarm(const QColor &warm) -{ - Q_D(QGoochMaterial); - return d->m_warmParameter->setValue(warm); -} - -void QGoochMaterial::setAlpha(float alpha) -{ - Q_D(QGoochMaterial); - return d->m_alphaParameter->setValue(alpha); -} - -void QGoochMaterial::setBeta(float beta) -{ - Q_D(QGoochMaterial); - return d->m_betaParameter->setValue(beta); -} - -void QGoochMaterial::setShininess(float shininess) -{ - Q_D(QGoochMaterial); - return d->m_shininessParameter->setValue(shininess); -} - -} - -QT_END_NAMESPACE diff --git a/src/render/defaults/qgoochmaterial.h b/src/render/defaults/qgoochmaterial.h deleted file mode 100644 index 3a6bfdd51..000000000 --- a/src/render/defaults/qgoochmaterial.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QGOOCHMATERIAL_H -#define QT3DRENDER_RENDER_QGOOCHMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QGoochMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QGoochMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(QColor cool READ cool WRITE setCool NOTIFY coolChanged) - Q_PROPERTY(QColor warm READ warm WRITE setWarm NOTIFY warmChanged) - Q_PROPERTY(float alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) - Q_PROPERTY(float beta READ beta WRITE setBeta NOTIFY betaChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - -public: - explicit QGoochMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - QColor diffuse() const; - QColor specular() const; - QColor cool() const; - QColor warm() const; - float alpha() const; - float beta() const; - float shininess() const; - -public Q_SLOTS: - void setDiffuse(const QColor &diffuse); - void setSpecular(const QColor &specular); - void setCool(const QColor &cool); - void setWarm(const QColor &warm); - void setAlpha(float alpha); - void setBeta(float beta); - void setShininess(float shininess); - -Q_SIGNALS: - void diffuseChanged(const QColor &diffuse); - void specularChanged(const QColor &specular); - void coolChanged(const QColor &cool); - void warmChanged(const QColor &warm); - void alphaChanged(float alpha); - void betaChanged(float beta); - void shininessChanged(float shininess); - -protected: - QGoochMaterial(QGoochMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR); - -private: - Q_DECLARE_PRIVATE(QGoochMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QGOOCHMATERIAL_H diff --git a/src/render/defaults/qgoochmaterial_p.h b/src/render/defaults/qgoochmaterial_p.h deleted file mode 100644 index 3dfca1d50..000000000 --- a/src/render/defaults/qgoochmaterial_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QGOOCHMATERIAL_P_H -#define QT3DRENDER_RENDER_QGOOCHMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QRenderPass; -class QShaderProgram; -class QTechnique; - -class QGoochMaterialPrivate : public QMaterialPrivate -{ -public: - QGoochMaterialPrivate(); - - void init(); - - void handleDiffuseChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleCoolChanged(const QVariant &var); - void handleWarmChanged(const QVariant &var); - void handleAlphaChanged(const QVariant &var); - void handleBetaChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - - QEffect *m_effect; - QParameter *m_diffuseParameter; - QParameter *m_specularParameter; - QParameter *m_coolParameter; - QParameter *m_warmParameter; - QParameter *m_alphaParameter; - QParameter *m_betaParameter; - QParameter *m_shininessParameter; - QTechnique *m_gl3Technique; - QTechnique *m_gl2Technique; - QTechnique *m_es2Technique; - QRenderPass *m_gl3RenderPass; - QRenderPass *m_gl2RenderPass; - QRenderPass *m_es2RenderPass; - QShaderProgram *m_gl3Shader; - QShaderProgram *m_gl2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QGoochMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QGOOCHMATERIAL_P_H - diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial.cpp b/src/render/defaults/qnormaldiffusemapalphamaterial.cpp deleted file mode 100644 index 8a741e702..000000000 --- a/src/render/defaults/qnormaldiffusemapalphamaterial.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnormaldiffusemapalphamaterial.h" -#include "qnormaldiffusemapalphamaterial_p.h" - -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <Qt3DRender/qalphacoverage.h> -#include <Qt3DRender/qdepthtest.h> - -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - - -QNormalDiffuseMapAlphaMaterialPrivate::QNormalDiffuseMapAlphaMaterialPrivate() - : QNormalDiffuseMapMaterialPrivate() - , m_alphaCoverage(new QAlphaCoverage()) - , m_depthTest(new QDepthTest()) -{ -} - -void QNormalDiffuseMapAlphaMaterialPrivate::init() -{ - m_normalDiffuseGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert")))); - m_normalDiffuseGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemapalpha.frag")))); - m_normalDiffuseGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert")))); - m_normalDiffuseGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemapalpha.frag")))); - - m_normalDiffuseGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_normalDiffuseGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_normalDiffuseES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_normalDiffuseES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QNormalDiffuseMapMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_normalDiffuseGL3Technique->addFilterKey(m_filterKey); - m_normalDiffuseGL2Technique->addFilterKey(m_filterKey); - m_normalDiffuseES2Technique->addFilterKey(m_filterKey); - - m_depthTest->setDepthFunction(QDepthTest::Less); - - m_normalDiffuseGL3RenderPass->setShaderProgram(m_normalDiffuseGL3Shader); - m_normalDiffuseGL3RenderPass->addRenderState(m_alphaCoverage); - m_normalDiffuseGL3RenderPass->addRenderState(m_depthTest); - - m_normalDiffuseGL2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader); - m_normalDiffuseGL2RenderPass->addRenderState(m_alphaCoverage); - m_normalDiffuseGL2RenderPass->addRenderState(m_depthTest); - - m_normalDiffuseES2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader); - m_normalDiffuseES2RenderPass->addRenderState(m_alphaCoverage); - m_normalDiffuseES2RenderPass->addRenderState(m_depthTest); - - m_normalDiffuseGL3Technique->addRenderPass(m_normalDiffuseGL3RenderPass); - m_normalDiffuseGL2Technique->addRenderPass(m_normalDiffuseGL2RenderPass); - m_normalDiffuseES2Technique->addRenderPass(m_normalDiffuseES2RenderPass); - - m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL3Technique); - m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL2Technique); - m_normalDiffuseEffect->addTechnique(m_normalDiffuseES2Technique); - - m_normalDiffuseEffect->addParameter(m_ambientParameter); - m_normalDiffuseEffect->addParameter(m_diffuseParameter); - m_normalDiffuseEffect->addParameter(m_normalParameter); - m_normalDiffuseEffect->addParameter(m_specularParameter); - m_normalDiffuseEffect->addParameter(m_shininessParameter); - m_normalDiffuseEffect->addParameter(m_textureScaleParameter); - - q->setEffect(m_normalDiffuseEffect); -} - - -/*! - \class Qt3DRender::QNormalDiffuseMapAlphaMaterial - \brief The QNormalDiffuseMapAlphaMaterial provides a default implementation of the phong lighting and bump effect where the diffuse light component - is read from a texture map and the normals of the mesh being rendered from a normal texture map. In addition, it defines an alpha to coverage and - a depth test to be performed in the rendering pass. - \inmodule Qt3DRender - \since 5.5 - - The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ -/*! - Constructs a new Qt3DRender::QNormalDiffuseMapAlphaMaterial instance with parent object \a parent. -*/ -QNormalDiffuseMapAlphaMaterial::QNormalDiffuseMapAlphaMaterial(QNode *parent) - : QNormalDiffuseMapMaterial(*new QNormalDiffuseMapAlphaMaterialPrivate, parent) -{ -} - -/*! - Destroys the QNormalDiffuseMapAlphaMaterial instance. -*/ -QNormalDiffuseMapAlphaMaterial::~QNormalDiffuseMapAlphaMaterial() -{ -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial.h b/src/render/defaults/qnormaldiffusemapalphamaterial.h deleted file mode 100644 index 3decf2ebb..000000000 --- a/src/render/defaults/qnormaldiffusemapalphamaterial.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H - -#include <Qt3DRender/qnormaldiffusemapmaterial.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QNormalDiffuseMapAlphaMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QNormalDiffuseMapAlphaMaterial : public QNormalDiffuseMapMaterial -{ - Q_OBJECT -public: - explicit QNormalDiffuseMapAlphaMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QNormalDiffuseMapAlphaMaterial(); - -private: - Q_DECLARE_PRIVATE(QNormalDiffuseMapAlphaMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial_p.h b/src/render/defaults/qnormaldiffusemapalphamaterial_p.h deleted file mode 100644 index d94fdaedd..000000000 --- a/src/render/defaults/qnormaldiffusemapalphamaterial_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qnormaldiffusemapmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QNormalDiffuseMapAlphaMaterial; - -class QAlphaCoverage; -class QDepthTest; - -class QNormalDiffuseMapAlphaMaterialPrivate: public QNormalDiffuseMapMaterialPrivate -{ -public: - QNormalDiffuseMapAlphaMaterialPrivate(); - - void init() Q_DECL_OVERRIDE; - - QAlphaCoverage *m_alphaCoverage; - QDepthTest *m_depthTest; - - Q_DECLARE_PUBLIC(QNormalDiffuseMapAlphaMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QNORMALDIFFUSEMAPALPHAMATERIAL_P_H - diff --git a/src/render/defaults/qnormaldiffusemapmaterial.cpp b/src/render/defaults/qnormaldiffusemapmaterial.cpp deleted file mode 100644 index d1eef5929..000000000 --- a/src/render/defaults/qnormaldiffusemapmaterial.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnormaldiffusemapmaterial.h" -#include "qnormaldiffusemapmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> - -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QNormalDiffuseMapMaterialPrivate::QNormalDiffuseMapMaterialPrivate() - : QMaterialPrivate() - , m_normalDiffuseEffect(new QEffect()) - , m_diffuseTexture(new QTexture2D()) - , m_normalTexture(new QTexture2D()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.1f, 0.1f, 0.1f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture)) - , m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture)) - , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f))) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f)) - , m_normalDiffuseGL3Technique(new QTechnique()) - , m_normalDiffuseGL2Technique(new QTechnique()) - , m_normalDiffuseES2Technique(new QTechnique()) - , m_normalDiffuseGL3RenderPass(new QRenderPass()) - , m_normalDiffuseGL2RenderPass(new QRenderPass()) - , m_normalDiffuseES2RenderPass(new QRenderPass()) - , m_normalDiffuseGL3Shader(new QShaderProgram()) - , m_normalDiffuseGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ - m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_diffuseTexture->setGenerateMipMaps(true); - m_diffuseTexture->setMaximumAnisotropy(16.0f); - - m_normalTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_normalTexture->setMinificationFilter(QAbstractTexture::Linear); - m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_normalTexture->setMaximumAnisotropy(16.0f); -} - -void QNormalDiffuseMapMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleDiffuseChanged); - connect(m_normalParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleNormalChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleShininessChanged); - connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseMapMaterialPrivate::handleTextureScaleChanged); - - m_normalDiffuseGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert")))); - m_normalDiffuseGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.frag")))); - m_normalDiffuseGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert")))); - m_normalDiffuseGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.frag")))); - - m_normalDiffuseGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_normalDiffuseGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_normalDiffuseGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_normalDiffuseES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_normalDiffuseES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QNormalDiffuseMapMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_normalDiffuseGL3Technique->addFilterKey(m_filterKey); - m_normalDiffuseGL2Technique->addFilterKey(m_filterKey); - m_normalDiffuseES2Technique->addFilterKey(m_filterKey); - - m_normalDiffuseGL3RenderPass->setShaderProgram(m_normalDiffuseGL3Shader); - m_normalDiffuseGL2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader); - m_normalDiffuseES2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader); - - m_normalDiffuseGL3Technique->addRenderPass(m_normalDiffuseGL3RenderPass); - m_normalDiffuseGL2Technique->addRenderPass(m_normalDiffuseGL2RenderPass); - m_normalDiffuseES2Technique->addRenderPass(m_normalDiffuseES2RenderPass); - - m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL3Technique); - m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL2Technique); - m_normalDiffuseEffect->addTechnique(m_normalDiffuseES2Technique); - - m_normalDiffuseEffect->addParameter(m_ambientParameter); - m_normalDiffuseEffect->addParameter(m_diffuseParameter); - m_normalDiffuseEffect->addParameter(m_normalParameter); - m_normalDiffuseEffect->addParameter(m_specularParameter); - m_normalDiffuseEffect->addParameter(m_shininessParameter); - m_normalDiffuseEffect->addParameter(m_textureScaleParameter); - - q->setEffect(m_normalDiffuseEffect); -} - -void QNormalDiffuseMapMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QNormalDiffuseMapMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->diffuseChanged(var.value<QAbstractTexture *>()); -} - -void QNormalDiffuseMapMaterialPrivate::handleNormalChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->normalChanged(var.value<QAbstractTexture *>()); -} - -void QNormalDiffuseMapMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->specularChanged(var.value<QColor>()); -} - -void QNormalDiffuseMapMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->shininessChanged(var.toFloat()); -} - -void QNormalDiffuseMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseMapMaterial); - emit q->textureScaleChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QNormalDiffuseMapMaterial - \brief The QNormalDiffuseMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse light component - is read from a texture map and the normals of the mesh being rendered from a normal texture map. - \inmodule Qt3DRender - \since 5.5 - - The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - Constructs a new Qt3DRender::QNormalDiffuseMapMaterial instance with parent object \a parent. -*/ -QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNode *parent) - : QMaterial(*new QNormalDiffuseMapMaterialPrivate, parent) -{ - Q_D(QNormalDiffuseMapMaterial); - d->init(); -} - -/*! \internal */ -QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, QNode *parent) - : QMaterial(dd, parent) -{ - Q_D(QNormalDiffuseMapMaterial); - d->init(); -} - -/*! - Destroys the QNormalDiffuseMapMaterial instance. -*/ -QNormalDiffuseMapMaterial::~QNormalDiffuseMapMaterial() -{ -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::ambient - - Holds the current ambient color. -*/ -QColor QNormalDiffuseMapMaterial::ambient() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::specular - - Holds the current specular color. -*/ -QColor QNormalDiffuseMapMaterial::specular() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_specularParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::diffuse - - Holds the current diffuse map texture. - - By default, the diffuse texture has these properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap modeM - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QNormalDiffuseMapMaterial::diffuse() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_diffuseParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::normal - - Holds the current normal map texture. - - By default, the normal texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QNormalDiffuseMapMaterial::normal() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_normalParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::shininess - - Holds the current shininess as a float value. -*/ -float QNormalDiffuseMapMaterial::shininess() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QNormalDiffuseMapMaterial::textureScale - - Holds the current texture scale as a float value. -*/ -float QNormalDiffuseMapMaterial::textureScale() const -{ - Q_D(const QNormalDiffuseMapMaterial); - return d->m_textureScaleParameter->value().toFloat(); -} - -void QNormalDiffuseMapMaterial::setAmbient(const QColor &ambient) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QNormalDiffuseMapMaterial::setSpecular(const QColor &specular) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_specularParameter->setValue(specular); -} - -void QNormalDiffuseMapMaterial::setDiffuse(QAbstractTexture *diffuse) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse)); -} - -void QNormalDiffuseMapMaterial::setNormal(QAbstractTexture *normal) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_normalParameter->setValue(QVariant::fromValue(normal)); -} - -void QNormalDiffuseMapMaterial::setShininess(float shininess) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_shininessParameter->setValue(shininess); -} - -void QNormalDiffuseMapMaterial::setTextureScale(float textureScale) -{ - Q_D(QNormalDiffuseMapMaterial); - d->m_textureScaleParameter->setValue(textureScale); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qnormaldiffusemapmaterial.h b/src/render/defaults/qnormaldiffusemapmaterial.h deleted file mode 100644 index 4f843bd05..000000000 --- a/src/render/defaults/qnormaldiffusemapmaterial.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSEMAPMATERIAL_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSEMAPMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QAbstractTexture; -class QNormalDiffuseMapMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QNormalDiffuseMapMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *normal READ normal WRITE setNormal NOTIFY normalChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged) - -public: - explicit QNormalDiffuseMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QNormalDiffuseMapMaterial(); - - QColor ambient() const; - QColor specular() const; - QAbstractTexture *diffuse() const; - QAbstractTexture *normal() const; - float shininess() const; - float textureScale() const; - -public Q_SLOTS: - void setAmbient(const QColor &ambient); - void setSpecular(const QColor &specular); - void setDiffuse(QAbstractTexture *diffuse); - void setNormal(QAbstractTexture *normal); - void setShininess(float shininess); - void setTextureScale(float textureScale); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(QAbstractTexture *diffuse); - void normalChanged(QAbstractTexture *normal); - void specularChanged(const QColor &specular); - void shininessChanged(float shininess); - void textureScaleChanged(float textureScale); - -protected: - QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR); - -private: - Q_DECLARE_PRIVATE(QNormalDiffuseMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QNORMALDIFFUSEMAPMATERIAL_H diff --git a/src/render/defaults/qnormaldiffusemapmaterial_p.h b/src/render/defaults/qnormaldiffusemapmaterial_p.h deleted file mode 100644 index a446faa13..000000000 --- a/src/render/defaults/qnormaldiffusemapmaterial_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QAbstractTexture; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QNormalDiffuseMapMaterial; - -class QNormalDiffuseMapMaterialPrivate: public QMaterialPrivate -{ -public: - QNormalDiffuseMapMaterialPrivate(); - - virtual void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleNormalChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - void handleTextureScaleChanged(const QVariant &var); - - QEffect *m_normalDiffuseEffect; - QAbstractTexture *m_diffuseTexture; - QAbstractTexture *m_normalTexture; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_normalParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QParameter *m_textureScaleParameter; - QTechnique *m_normalDiffuseGL3Technique; - QTechnique *m_normalDiffuseGL2Technique; - QTechnique *m_normalDiffuseES2Technique; - QRenderPass *m_normalDiffuseGL3RenderPass; - QRenderPass *m_normalDiffuseGL2RenderPass; - QRenderPass *m_normalDiffuseES2RenderPass; - QShaderProgram *m_normalDiffuseGL3Shader; - QShaderProgram *m_normalDiffuseGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QNormalDiffuseMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H - diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp b/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp deleted file mode 100644 index 7457ee38b..000000000 --- a/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnormaldiffusespecularmapmaterial.h" -#include "qnormaldiffusespecularmapmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QNormalDiffuseSpecularMapMaterialPrivate::QNormalDiffuseSpecularMapMaterialPrivate() - : QMaterialPrivate() - , m_normalDiffuseSpecularEffect(new QEffect()) - , m_diffuseTexture(new QTexture2D()) - , m_normalTexture(new QTexture2D()) - , m_specularTexture(new QTexture2D()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture)) - , m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture)) - , m_specularParameter(new QParameter(QStringLiteral("specularTexture"), m_specularTexture)) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f)) - , m_normalDiffuseSpecularGL3Technique(new QTechnique()) - , m_normalDiffuseSpecularGL2Technique(new QTechnique()) - , m_normalDiffuseSpecularES2Technique(new QTechnique()) - , m_normalDiffuseSpecularGL3RenderPass(new QRenderPass()) - , m_normalDiffuseSpecularGL2RenderPass(new QRenderPass()) - , m_normalDiffuseSpecularES2RenderPass(new QRenderPass()) - , m_normalDiffuseSpecularGL3Shader(new QShaderProgram()) - , m_normalDiffuseSpecularGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ - m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_diffuseTexture->setGenerateMipMaps(true); - m_diffuseTexture->setMaximumAnisotropy(16.0f); - - m_normalTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_normalTexture->setMinificationFilter(QAbstractTexture::Linear); - m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_normalTexture->setMaximumAnisotropy(16.0f); - - m_specularTexture->setMagnificationFilter(QAbstractTexture::Linear); - m_specularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear); - m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat)); - m_specularTexture->setGenerateMipMaps(true); - m_specularTexture->setMaximumAnisotropy(16.0f); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged); - connect(m_normalParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleNormalChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleShininessChanged); - connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QNormalDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged); - - m_normalDiffuseSpecularGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert")))); - m_normalDiffuseSpecularGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusespecularmap.frag")))); - m_normalDiffuseSpecularGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert")))); - m_normalDiffuseSpecularGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusespecularmap.frag")))); - - m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QNormalDiffuseSpecularMapMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_normalDiffuseSpecularGL3Technique->addFilterKey(m_filterKey); - m_normalDiffuseSpecularGL2Technique->addFilterKey(m_filterKey); - m_normalDiffuseSpecularES2Technique->addFilterKey(m_filterKey); - - m_normalDiffuseSpecularGL3RenderPass->setShaderProgram(m_normalDiffuseSpecularGL3Shader); - m_normalDiffuseSpecularGL2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader); - m_normalDiffuseSpecularES2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader); - - m_normalDiffuseSpecularGL3Technique->addRenderPass(m_normalDiffuseSpecularGL3RenderPass); - m_normalDiffuseSpecularGL2Technique->addRenderPass(m_normalDiffuseSpecularGL2RenderPass); - m_normalDiffuseSpecularES2Technique->addRenderPass(m_normalDiffuseSpecularES2RenderPass); - - m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularGL3Technique); - m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularGL2Technique); - m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularES2Technique); - - m_normalDiffuseSpecularEffect->addParameter(m_ambientParameter); - m_normalDiffuseSpecularEffect->addParameter(m_diffuseParameter); - m_normalDiffuseSpecularEffect->addParameter(m_normalParameter); - m_normalDiffuseSpecularEffect->addParameter(m_specularParameter); - m_normalDiffuseSpecularEffect->addParameter(m_shininessParameter); - m_normalDiffuseSpecularEffect->addParameter(m_textureScaleParameter); - - q->setEffect(m_normalDiffuseSpecularEffect); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->diffuseChanged(var.value<QAbstractTexture *>()); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleNormalChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->normalChanged(var.value<QAbstractTexture *>()); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->specularChanged(var.value<QAbstractTexture *>()); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->shininessChanged(var.toFloat()); -} - -void QNormalDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var) -{ - Q_Q(QNormalDiffuseSpecularMapMaterial); - emit q->textureScaleChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QNormalDiffuseSpecularMapMaterial - \brief The QNormalDiffuseSpecularMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse and specular light components - are read from texture maps and the normals of the mesh being rendered from a normal texture map. - \inmodule Qt3DRender - \since 5.5 - - The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - Constructs a new Qt3DRender::QNormalDiffuseSpecularMapMaterial instance with parent object \a parent. -*/ -QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNode *parent) - : QMaterial(*new QNormalDiffuseSpecularMapMaterialPrivate, parent) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->init(); -} - -/*! \internal */ -QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, QNode *parent) - : QMaterial(dd, parent) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->init(); -} - -/*! - Destroys the Qt3DRender::QNormalDiffuseSpecularMapMaterial instance. -*/ -QNormalDiffuseSpecularMapMaterial::~QNormalDiffuseSpecularMapMaterial() -{ -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::ambient - - Holds the current ambient color. -*/ -QColor QNormalDiffuseSpecularMapMaterial::ambient() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::diffuse - - Holds the current diffuse map texture. - - By default, the diffuse texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QNormalDiffuseSpecularMapMaterial::diffuse() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_diffuseParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::normal - - Holds the current normal map texture. - - By default, the normal texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QNormalDiffuseSpecularMapMaterial::normal() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_normalParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::specular - - Holds the current specular map texture. - - By default, the specular texture has the following properties: - - \list - \li Linear minification and magnification filters - \li Linear mipmap with mipmapping enabled - \li Repeat wrap mode - \li Maximum anisotropy of 16.0 - \endlist -*/ -QAbstractTexture *QNormalDiffuseSpecularMapMaterial::specular() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_specularParameter->value().value<QAbstractTexture *>(); -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::shininess - - Holds the current shininess as a float value. -*/ -float QNormalDiffuseSpecularMapMaterial::shininess() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::textureScale - - Holds the current texture scale as a float value. -*/ -float QNormalDiffuseSpecularMapMaterial::textureScale() const -{ - Q_D(const QNormalDiffuseSpecularMapMaterial); - return d->m_textureScaleParameter->value().toFloat(); -} - -void QNormalDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QNormalDiffuseSpecularMapMaterial::setDiffuse(QAbstractTexture *diffuse) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse)); -} - -void QNormalDiffuseSpecularMapMaterial::setNormal(QAbstractTexture *normal) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_normalParameter->setValue(QVariant::fromValue(normal)); -} - -void QNormalDiffuseSpecularMapMaterial::setSpecular(QAbstractTexture *specular) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_specularParameter->setValue(QVariant::fromValue(specular)); -} - -void QNormalDiffuseSpecularMapMaterial::setShininess(float shininess) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_shininessParameter->setValue(shininess); -} - -void QNormalDiffuseSpecularMapMaterial::setTextureScale(float textureScale) -{ - Q_D(QNormalDiffuseSpecularMapMaterial); - d->m_textureScaleParameter->setValue(textureScale); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.h b/src/render/defaults/qnormaldiffusespecularmapmaterial.h deleted file mode 100644 index 581ca6fb2..000000000 --- a/src/render/defaults/qnormaldiffusespecularmapmaterial.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QNormalDiffuseSpecularMapMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QNormalDiffuseSpecularMapMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *normal READ normal WRITE setNormal NOTIFY normalChanged) - Q_PROPERTY(Qt3DRender::QAbstractTexture *specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged) - -public: - explicit QNormalDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QNormalDiffuseSpecularMapMaterial(); - - QColor ambient() const; - QAbstractTexture *diffuse() const; - QAbstractTexture *normal() const; - QAbstractTexture *specular() const; - float shininess() const; - float textureScale() const; - -public Q_SLOTS: - void setAmbient(const QColor &ambient); - void setDiffuse(QAbstractTexture *diffuse); - void setNormal(QAbstractTexture *normal); - void setSpecular(QAbstractTexture *specular); - void setShininess(float shininess); - void setTextureScale(float textureScale); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(QAbstractTexture *diffuse); - void normalChanged(QAbstractTexture *normal); - void specularChanged(QAbstractTexture *specular); - void shininessChanged(float shininess); - void textureScaleChanged(float textureScale); - -protected: - QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR); - -private: - Q_DECLARE_PRIVATE(QNormalDiffuseSpecularMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h b/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h deleted file mode 100644 index cdd12abff..000000000 --- a/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H -#define QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QAbstractTexture; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QNormalDiffuseSpecularMapMaterial; - -class QNormalDiffuseSpecularMapMaterialPrivate : public QMaterialPrivate -{ -public: - QNormalDiffuseSpecularMapMaterialPrivate(); - - void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleNormalChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - void handleTextureScaleChanged(const QVariant &var); - - QEffect *m_normalDiffuseSpecularEffect; - QAbstractTexture *m_diffuseTexture; - QAbstractTexture *m_normalTexture; - QAbstractTexture *m_specularTexture; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_normalParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QParameter *m_textureScaleParameter; - QTechnique *m_normalDiffuseSpecularGL3Technique; - QTechnique *m_normalDiffuseSpecularGL2Technique; - QTechnique *m_normalDiffuseSpecularES2Technique; - QRenderPass *m_normalDiffuseSpecularGL3RenderPass; - QRenderPass *m_normalDiffuseSpecularGL2RenderPass; - QRenderPass *m_normalDiffuseSpecularES2RenderPass; - QShaderProgram *m_normalDiffuseSpecularGL3Shader; - QShaderProgram *m_normalDiffuseSpecularGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QNormalDiffuseSpecularMapMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H - diff --git a/src/render/defaults/qpervertexcolormaterial.cpp b/src/render/defaults/qpervertexcolormaterial.cpp deleted file mode 100644 index 6b8db44d9..000000000 --- a/src/render/defaults/qpervertexcolormaterial.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Lorenz Esch (TU Ilmenau). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qpervertexcolormaterial.h" -#include "qpervertexcolormaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QPerVertexColorMaterialPrivate::QPerVertexColorMaterialPrivate() - : QMaterialPrivate() - , m_vertexEffect(new QEffect()) - , m_vertexGL3Technique(new QTechnique()) - , m_vertexGL2Technique(new QTechnique()) - , m_vertexES2Technique(new QTechnique()) - , m_vertexGL3RenderPass(new QRenderPass()) - , m_vertexGL2RenderPass(new QRenderPass()) - , m_vertexES2RenderPass(new QRenderPass()) - , m_vertexGL3Shader(new QShaderProgram()) - , m_vertexGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ -} - -/*! - \class Qt3DRender::QPerVertexColorMaterial - \brief The QPerVertexColorMaterial class provides a default implementation for rendering the color properties set for each vertex. - \inmodule Qt3DRender - \since 5.5 - - This lighting effect is based on the combination of 2 lighting components ambient and diffuse. Ambient is set by the vertex color. - Diffuse takes in account the normal distribution of each vertex. - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rough surface reflections with the lights - \endlist - - This material uses an effect with a single render pass approach and forms fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - \fn Qt3DRender::QPerVertexColorMaterial::QPerVertexColorMaterial(Qt3DCore::QNode *parent) - - Constructs a new QPerVertexColorMaterial instance with parent object \a parent. -*/ -QPerVertexColorMaterial::QPerVertexColorMaterial(QNode *parent) - : QMaterial(*new QPerVertexColorMaterialPrivate, parent) -{ - Q_D(QPerVertexColorMaterial); - d->init(); -} - -/*! - \fn Qt3DRender::QPerVertexColorMaterial::~QPerVertexColorMaterial() - - Destroys the QPerVertexColorMaterial -*/ -QPerVertexColorMaterial::~QPerVertexColorMaterial() -{ -} - -// TODO: Define how lights are proties are set in the shaders. Ideally using a QShaderData -void QPerVertexColorMaterialPrivate::init() -{ - m_vertexGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/pervertexcolor.vert")))); - m_vertexGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/pervertexcolor.frag")))); - m_vertexGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/pervertexcolor.vert")))); - m_vertexGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/pervertexcolor.frag")))); - - m_vertexGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_vertexGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_vertexGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_vertexGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_vertexGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_vertexGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_vertexGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_vertexGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_vertexES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_vertexES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_vertexES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_vertexES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QPerVertexColorMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_vertexGL3Technique->addFilterKey(m_filterKey); - m_vertexGL2Technique->addFilterKey(m_filterKey); - m_vertexES2Technique->addFilterKey(m_filterKey); - - m_vertexGL3RenderPass->setShaderProgram(m_vertexGL3Shader); - m_vertexGL2RenderPass->setShaderProgram(m_vertexGL2ES2Shader); - m_vertexES2RenderPass->setShaderProgram(m_vertexGL2ES2Shader); - - m_vertexGL3Technique->addRenderPass(m_vertexGL3RenderPass); - m_vertexGL2Technique->addRenderPass(m_vertexGL2RenderPass); - m_vertexES2Technique->addRenderPass(m_vertexES2RenderPass); - - m_vertexEffect->addTechnique(m_vertexGL3Technique); - m_vertexEffect->addTechnique(m_vertexGL2Technique); - m_vertexEffect->addTechnique(m_vertexES2Technique); - - q->setEffect(m_vertexEffect); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qpervertexcolormaterial.h b/src/render/defaults/qpervertexcolormaterial.h deleted file mode 100644 index 43e2a095b..000000000 --- a/src/render/defaults/qpervertexcolormaterial.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Lorenz Esch (TU Ilmenau). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_H -#define QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QPerVertexColorMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QPerVertexColorMaterial : public QMaterial -{ - Q_OBJECT - -public: - explicit QPerVertexColorMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QPerVertexColorMaterial(); - -private: - Q_DECLARE_PRIVATE(QPerVertexColorMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_H diff --git a/src/render/defaults/qpervertexcolormaterial_p.h b/src/render/defaults/qpervertexcolormaterial_p.h deleted file mode 100644 index a5f5458e0..000000000 --- a/src/render/defaults/qpervertexcolormaterial_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Lorenz Esch (TU Ilmenau). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_P_H -#define QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QPerVertexColorMaterial; - -class QPerVertexColorMaterialPrivate : public QMaterialPrivate -{ -public: - QPerVertexColorMaterialPrivate(); - - void init(); - - QEffect *m_vertexEffect; - QTechnique *m_vertexGL3Technique; - QTechnique *m_vertexGL2Technique; - QTechnique *m_vertexES2Technique; - QRenderPass *m_vertexGL3RenderPass; - QRenderPass *m_vertexGL2RenderPass; - QRenderPass *m_vertexES2RenderPass; - QShaderProgram *m_vertexGL3Shader; - QShaderProgram *m_vertexGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QPerVertexColorMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPERVERTEXCOLORMATERIAL_P_H - diff --git a/src/render/defaults/qphongalphamaterial.cpp b/src/render/defaults/qphongalphamaterial.cpp deleted file mode 100644 index 858b58314..000000000 --- a/src/render/defaults/qphongalphamaterial.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qphongalphamaterial.h" -#include "qphongalphamaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <Qt3DRender/qblendequation.h> -#include <Qt3DRender/qblendequationarguments.h> -#include <Qt3DRender/qnodepthmask.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QPhongAlphaMaterialPrivate::QPhongAlphaMaterialPrivate() - : QMaterialPrivate() - , m_phongEffect(new QEffect()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f))) - , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f))) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_alphaParameter(new QParameter(QStringLiteral("alpha"), 0.5f)) - , m_phongAlphaGL3Technique(new QTechnique()) - , m_phongAlphaGL2Technique(new QTechnique()) - , m_phongAlphaES2Technique(new QTechnique()) - , m_phongAlphaGL3RenderPass(new QRenderPass()) - , m_phongAlphaGL2RenderPass(new QRenderPass()) - , m_phongAlphaES2RenderPass(new QRenderPass()) - , m_phongAlphaGL3Shader(new QShaderProgram()) - , m_phongAlphaGL2ES2Shader(new QShaderProgram()) - , m_noDepthMask(new QNoDepthMask()) - , m_blendState(new QBlendEquationArguments()) - , m_blendEquation(new QBlendEquation()) - , m_filterKey(new QFilterKey) -{ -} - -// TODO: Define how lights are properties are set in the shaders. Ideally using a QShaderData -void QPhongAlphaMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongAlphaMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongAlphaMaterialPrivate::handleDiffuseChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongAlphaMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongAlphaMaterialPrivate::handleShininessChanged); - connect(m_alphaParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongAlphaMaterialPrivate::handleAlphaChanged); - - m_phongAlphaGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.vert")))); - m_phongAlphaGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phongalpha.frag")))); - m_phongAlphaGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.vert")))); - m_phongAlphaGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phongalpha.frag")))); - - m_phongAlphaGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_phongAlphaGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_phongAlphaGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_phongAlphaGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_phongAlphaGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_phongAlphaGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_phongAlphaGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_phongAlphaGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_phongAlphaES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_phongAlphaES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_phongAlphaES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_phongAlphaES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - Q_Q(QPhongAlphaMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_phongAlphaGL3Technique->addFilterKey(m_filterKey); - m_phongAlphaGL2Technique->addFilterKey(m_filterKey); - m_phongAlphaES2Technique->addFilterKey(m_filterKey); - - m_blendState->setSourceRgb(QBlendEquationArguments::SourceAlpha); - m_blendState->setDestinationRgb(QBlendEquationArguments::OneMinusSourceAlpha); - m_blendEquation->setBlendFunction(QBlendEquation::Add); - - m_phongAlphaGL3RenderPass->setShaderProgram(m_phongAlphaGL3Shader); - m_phongAlphaGL2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader); - m_phongAlphaES2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader); - - m_phongAlphaGL3RenderPass->addRenderState(m_noDepthMask); - m_phongAlphaGL3RenderPass->addRenderState(m_blendState); - m_phongAlphaGL3RenderPass->addRenderState(m_blendEquation); - - m_phongAlphaGL2RenderPass->addRenderState(m_noDepthMask); - m_phongAlphaGL2RenderPass->addRenderState(m_blendState); - m_phongAlphaGL2RenderPass->addRenderState(m_blendEquation); - - m_phongAlphaES2RenderPass->addRenderState(m_noDepthMask); - m_phongAlphaES2RenderPass->addRenderState(m_blendState); - m_phongAlphaES2RenderPass->addRenderState(m_blendEquation); - - m_phongAlphaGL3Technique->addRenderPass(m_phongAlphaGL3RenderPass); - m_phongAlphaGL2Technique->addRenderPass(m_phongAlphaGL2RenderPass); - m_phongAlphaES2Technique->addRenderPass(m_phongAlphaES2RenderPass); - - m_phongEffect->addTechnique(m_phongAlphaGL3Technique); - m_phongEffect->addTechnique(m_phongAlphaGL2Technique); - m_phongEffect->addTechnique(m_phongAlphaES2Technique); - - m_phongEffect->addParameter(m_ambientParameter); - m_phongEffect->addParameter(m_diffuseParameter); - m_phongEffect->addParameter(m_specularParameter); - m_phongEffect->addParameter(m_shininessParameter); - m_phongEffect->addParameter(m_alphaParameter); - - q->setEffect(m_phongEffect); -} - -void QPhongAlphaMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QPhongAlphaMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QPhongAlphaMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QPhongAlphaMaterial); - emit q->diffuseChanged(var.value<QColor>()); -} - -void QPhongAlphaMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QPhongAlphaMaterial); - emit q->specularChanged(var.value<QColor>()); -} - -void QPhongAlphaMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QPhongAlphaMaterial); - emit q->shininessChanged(var.toFloat()); -} - -void QPhongAlphaMaterialPrivate::handleAlphaChanged(const QVariant &var) -{ - Q_Q(QPhongAlphaMaterial); - emit q->alphaChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QPhongAlphaMaterial - - \brief The QPhongAlphaMaterial class provides a default implementation of - the phong lighting effect with alpha. - \inmodule Qt3DRenderer - \since 5.5 - - The phong lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \li Alpha is the transparency of the surface between 0 (fully transparent) and 1 (opaque). - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - \fn Qt3DRender::QPhongAlphaMaterial::QPhongAlphaMaterial(Qt3DCore::QNode *parent) - - Constructs a new QPhongAlphaMaterial instance with parent object \a parent. -*/ -QPhongAlphaMaterial::QPhongAlphaMaterial(QNode *parent) - : QMaterial(*new QPhongAlphaMaterialPrivate, parent) -{ - Q_D(QPhongAlphaMaterial); - d->init(); -} - -/*! - Destroys the QPhongAlphaMaterial. -*/ -QPhongAlphaMaterial::~QPhongAlphaMaterial() -{ -} - -/*! - \property Qt3DRender::QPhongAlphaMaterial::ambient - - Holds the ambient color. -*/ -QColor QPhongAlphaMaterial::ambient() const -{ - Q_D(const QPhongAlphaMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongAlphaMaterial::diffuse - - Holds the diffuse color. -*/ -QColor QPhongAlphaMaterial::diffuse() const -{ - Q_D(const QPhongAlphaMaterial); - return d->m_diffuseParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongAlphaMaterial::specular - - Holds the specular color. -*/ -QColor QPhongAlphaMaterial::specular() const -{ - Q_D(const QPhongAlphaMaterial); - return d->m_specularParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongAlphaMaterial::shininess - - Holds the shininess exponent. -*/ -float QPhongAlphaMaterial::shininess() const -{ - Q_D(const QPhongAlphaMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -/*! - \property Qt3DRender::QPhongAlphaMaterial::alpha - - Holds the alpha component of the object which varies between 0 and 1. - - \note: default value is 0.5f -*/ -float QPhongAlphaMaterial::alpha() const -{ - Q_D(const QPhongAlphaMaterial); - return d->m_alphaParameter->value().toFloat(); -} - -void QPhongAlphaMaterial::setAmbient(const QColor &ambient) -{ - Q_D(QPhongAlphaMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QPhongAlphaMaterial::setDiffuse(const QColor &diffuse) -{ - Q_D(QPhongAlphaMaterial); - d->m_diffuseParameter->setValue(diffuse); -} - -void QPhongAlphaMaterial::setSpecular(const QColor &specular) -{ - Q_D(QPhongAlphaMaterial); - d->m_specularParameter->setValue(specular); -} - -void QPhongAlphaMaterial::setShininess(float shininess) -{ - Q_D(QPhongAlphaMaterial); - d->m_shininessParameter->setValue(shininess); -} - -void QPhongAlphaMaterial::setAlpha(float alpha) -{ - Q_D(QPhongAlphaMaterial); - d->m_alphaParameter->setValue(alpha); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qphongalphamaterial.h b/src/render/defaults/qphongalphamaterial.h deleted file mode 100644 index 9a258b09f..000000000 --- a/src/render/defaults/qphongalphamaterial.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_H -#define QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QPhongAlphaMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QPhongAlphaMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - Q_PROPERTY(float alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) - -public: - explicit QPhongAlphaMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QPhongAlphaMaterial(); - - QColor ambient() const; - QColor diffuse() const; - QColor specular() const; - float shininess() const; - float alpha() const; - -public Q_SLOTS: - void setAmbient(const QColor &ambient); - void setDiffuse(const QColor &diffuse); - void setSpecular(const QColor &specular); - void setShininess(float shininess); - void setAlpha(float alpha); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(const QColor &diffuse); - void specularChanged(const QColor &specular); - void shininessChanged(float shininess); - void alphaChanged(float alpha); - -private: - Q_DECLARE_PRIVATE(QPhongAlphaMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_H diff --git a/src/render/defaults/qphongalphamaterial_p.h b/src/render/defaults/qphongalphamaterial_p.h deleted file mode 100644 index 2adf59736..000000000 --- a/src/render/defaults/qphongalphamaterial_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_P_H -#define QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; -class QNoDepthMask; -class QBlendEquationArguments; -class QBlendEquation; - -class QPhongAlphaMaterial; - -class QPhongAlphaMaterialPrivate : public QMaterialPrivate -{ -public: - QPhongAlphaMaterialPrivate(); - - void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - void handleAlphaChanged(const QVariant &var); - - QEffect *m_phongEffect; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QParameter *m_alphaParameter; - QTechnique *m_phongAlphaGL3Technique; - QTechnique *m_phongAlphaGL2Technique; - QTechnique *m_phongAlphaES2Technique; - QRenderPass *m_phongAlphaGL3RenderPass; - QRenderPass *m_phongAlphaGL2RenderPass; - QRenderPass *m_phongAlphaES2RenderPass; - QShaderProgram *m_phongAlphaGL3Shader; - QShaderProgram *m_phongAlphaGL2ES2Shader; - QNoDepthMask *m_noDepthMask; - QBlendEquationArguments *m_blendState; - QBlendEquation *m_blendEquation; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QPhongAlphaMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPHONGALPHAMATERIAL_P_H - diff --git a/src/render/defaults/qphongmaterial.cpp b/src/render/defaults/qphongmaterial.cpp deleted file mode 100644 index 28dcd390a..000000000 --- a/src/render/defaults/qphongmaterial.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qphongmaterial.h" -#include "qphongmaterial_p.h" -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qshaderprogram.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <QUrl> -#include <QVector3D> -#include <QVector4D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QPhongMaterialPrivate::QPhongMaterialPrivate() - : QMaterialPrivate() - , m_phongEffect(new QEffect()) - , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f))) - , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f))) - , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f))) - , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f)) - , m_phongGL3Technique(new QTechnique()) - , m_phongGL2Technique(new QTechnique()) - , m_phongES2Technique(new QTechnique()) - , m_phongGL3RenderPass(new QRenderPass()) - , m_phongGL2RenderPass(new QRenderPass()) - , m_phongES2RenderPass(new QRenderPass()) - , m_phongGL3Shader(new QShaderProgram()) - , m_phongGL2ES2Shader(new QShaderProgram()) - , m_filterKey(new QFilterKey) -{ -} - -void QPhongMaterialPrivate::init() -{ - connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongMaterialPrivate::handleAmbientChanged); - connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongMaterialPrivate::handleDiffuseChanged); - connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongMaterialPrivate::handleSpecularChanged); - connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QPhongMaterialPrivate::handleShininessChanged); - - - m_phongGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.vert")))); - m_phongGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.frag")))); - m_phongGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.vert")))); - m_phongGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.frag")))); - - m_phongGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_phongGL3Technique->graphicsApiFilter()->setMajorVersion(3); - m_phongGL3Technique->graphicsApiFilter()->setMinorVersion(1); - m_phongGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_phongGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_phongGL2Technique->graphicsApiFilter()->setMajorVersion(2); - m_phongGL2Technique->graphicsApiFilter()->setMinorVersion(0); - m_phongGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_phongES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_phongES2Technique->graphicsApiFilter()->setMajorVersion(2); - m_phongES2Technique->graphicsApiFilter()->setMinorVersion(0); - m_phongES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_phongGL3RenderPass->setShaderProgram(m_phongGL3Shader); - m_phongGL2RenderPass->setShaderProgram(m_phongGL2ES2Shader); - m_phongES2RenderPass->setShaderProgram(m_phongGL2ES2Shader); - - m_phongGL3Technique->addRenderPass(m_phongGL3RenderPass); - m_phongGL2Technique->addRenderPass(m_phongGL2RenderPass); - m_phongES2Technique->addRenderPass(m_phongES2RenderPass); - - Q_Q(QPhongMaterial); - m_filterKey->setParent(q); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_phongGL3Technique->addFilterKey(m_filterKey); - m_phongGL2Technique->addFilterKey(m_filterKey); - m_phongES2Technique->addFilterKey(m_filterKey); - - m_phongEffect->addTechnique(m_phongGL3Technique); - m_phongEffect->addTechnique(m_phongGL2Technique); - m_phongEffect->addTechnique(m_phongES2Technique); - - m_phongEffect->addParameter(m_ambientParameter); - m_phongEffect->addParameter(m_diffuseParameter); - m_phongEffect->addParameter(m_specularParameter); - m_phongEffect->addParameter(m_shininessParameter); - - q->setEffect(m_phongEffect); -} - -void QPhongMaterialPrivate::handleAmbientChanged(const QVariant &var) -{ - Q_Q(QPhongMaterial); - emit q->ambientChanged(var.value<QColor>()); -} - -void QPhongMaterialPrivate::handleDiffuseChanged(const QVariant &var) -{ - Q_Q(QPhongMaterial); - emit q->diffuseChanged(var.value<QColor>()); -} - -void QPhongMaterialPrivate::handleSpecularChanged(const QVariant &var) -{ - Q_Q(QPhongMaterial); - emit q->specularChanged(var.value<QColor>()); -} - -void QPhongMaterialPrivate::handleShininessChanged(const QVariant &var) -{ - Q_Q(QPhongMaterial); - emit q->shininessChanged(var.toFloat()); -} - -/*! - \class Qt3DRender::QPhongMaterial - \brief The QPhongMaterial class provides a default implementation of the phong lighting effect. - \inmodule Qt3DRender - \since 5.5 - - The phong lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular. - The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets: - - \list - \li Ambient is the color that is emitted by an object without any other light source. - \li Diffuse is the color that is emitted for rought surface reflections with the lights. - \li Specular is the color emitted for shiny surface reflections with the lights. - \li The shininess of a surface is controlled by a float property. - \endlist - - This material uses an effect with a single render pass approach and performs per fragment lighting. - Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2. -*/ - -/*! - \fn Qt3DRender::QPhongMaterial::QPhongMaterial(Qt3DCore::QNode *parent) - - Constructs a new QPhongMaterial instance with parent object \a parent. -*/ -QPhongMaterial::QPhongMaterial(QNode *parent) - : QMaterial(*new QPhongMaterialPrivate, parent) -{ - Q_D(QPhongMaterial); - d->init(); -} - -/*! - \fn Qt3DRender::QPhongMaterial::~QPhongMaterial() - - Destroys the QPhongMaterial. -*/ -QPhongMaterial::~QPhongMaterial() -{ -} - -/*! - \property Qt3DRender::QPhongMaterial::ambient - - Holds the ambient color. -*/ -QColor QPhongMaterial::ambient() const -{ - Q_D(const QPhongMaterial); - return d->m_ambientParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongMaterial::diffuse - - Holds the diffuse color. -*/ -QColor QPhongMaterial::diffuse() const -{ - Q_D(const QPhongMaterial); - return d->m_diffuseParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongMaterial::specular - - Holds the specular color. -*/ -QColor QPhongMaterial::specular() const -{ - Q_D(const QPhongMaterial); - return d->m_specularParameter->value().value<QColor>(); -} - -/*! - \property Qt3DRender::QPhongMaterial::shininess - - Holds the shininess exponent. -*/ -float QPhongMaterial::shininess() const -{ - Q_D(const QPhongMaterial); - return d->m_shininessParameter->value().toFloat(); -} - -void QPhongMaterial::setAmbient(const QColor &ambient) -{ - Q_D(QPhongMaterial); - d->m_ambientParameter->setValue(ambient); -} - -void QPhongMaterial::setDiffuse(const QColor &diffuse) -{ - Q_D(QPhongMaterial); - d->m_diffuseParameter->setValue(diffuse); -} - -void QPhongMaterial::setSpecular(const QColor &specular) -{ - Q_D(QPhongMaterial); - d->m_specularParameter->setValue(specular); -} - -void QPhongMaterial::setShininess(float shininess) -{ - Q_D(QPhongMaterial); - d->m_shininessParameter->setValue(shininess); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qphongmaterial.h b/src/render/defaults/qphongmaterial.h deleted file mode 100644 index ff518e2a7..000000000 --- a/src/render/defaults/qphongmaterial.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPHONGMATERIAL_H -#define QT3DRENDER_RENDER_QPHONGMATERIAL_H - -#include <Qt3DRender/qmaterial.h> -#include <QColor> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QPhongMaterialPrivate; - -class QT3DRENDERSHARED_EXPORT QPhongMaterial : public QMaterial -{ - Q_OBJECT - Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged) - Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged) - Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged) - Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) - -public: - explicit QPhongMaterial(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QPhongMaterial(); - - QColor ambient() const; - QColor diffuse() const; - QColor specular() const; - float shininess() const; - -public Q_SLOTS: - void setAmbient(const QColor &ambient); - void setDiffuse(const QColor &diffuse); - void setSpecular(const QColor &specular); - void setShininess(float shininess); - -Q_SIGNALS: - void ambientChanged(const QColor &ambient); - void diffuseChanged(const QColor &diffuse); - void specularChanged(const QColor &specular); - void shininessChanged(float shininess); - -private: - Q_DECLARE_PRIVATE(QPhongMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPHONGMATERIAL_H diff --git a/src/render/defaults/qphongmaterial_p.h b/src/render/defaults/qphongmaterial_p.h deleted file mode 100644 index 74fc05ea6..000000000 --- a/src/render/defaults/qphongmaterial_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QPHONGMATERIAL_P_H -#define QT3DRENDER_RENDER_QPHONGMATERIAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DRender/private/qmaterial_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QFilterKey; -class QEffect; -class QTechnique; -class QParameter; -class QShaderProgram; -class QRenderPass; - -class QPhongMaterial; - -class QPhongMaterialPrivate : public QMaterialPrivate -{ -public: - QPhongMaterialPrivate(); - - void init(); - - void handleAmbientChanged(const QVariant &var); - void handleDiffuseChanged(const QVariant &var); - void handleSpecularChanged(const QVariant &var); - void handleShininessChanged(const QVariant &var); - - QEffect *m_phongEffect; - QParameter *m_ambientParameter; - QParameter *m_diffuseParameter; - QParameter *m_specularParameter; - QParameter *m_shininessParameter; - QTechnique *m_phongGL3Technique; - QTechnique *m_phongGL2Technique; - QTechnique *m_phongES2Technique; - QRenderPass *m_phongGL3RenderPass; - QRenderPass *m_phongGL2RenderPass; - QRenderPass *m_phongES2RenderPass; - QShaderProgram *m_phongGL3Shader; - QShaderProgram *m_phongGL2ES2Shader; - QFilterKey *m_filterKey; - - Q_DECLARE_PUBLIC(QPhongMaterial) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QPHONGMATERIAL_P_H - diff --git a/src/render/defaults/qskyboxentity.cpp b/src/render/defaults/qskyboxentity.cpp deleted file mode 100644 index 6e333ab64..000000000 --- a/src/render/defaults/qskyboxentity.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qskyboxentity.h" -#include "qskyboxentity_p.h" - -#include <Qt3DCore/qtransform.h> -#include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qeffect.h> -#include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qmaterial.h> -#include <Qt3DRender/qcullface.h> -#include <Qt3DRender/qdepthtest.h> -#include <Qt3DRender/qparameter.h> -#include <Qt3DRender/qtechnique.h> -#include <Qt3DRender/qcuboidmesh.h> -#include <Qt3DRender/qrenderpass.h> -#include <Qt3DRender/qgraphicsapifilter.h> -#include <Qt3DRender/qshaderprogram.h> - -QT_BEGIN_NAMESPACE - -using namespace Qt3DCore; - -namespace Qt3DRender { - -QSkyboxEntityPrivate::QSkyboxEntityPrivate() - : QEntityPrivate() - , m_effect(new QEffect()) - , m_material(new QMaterial()) - , m_skyboxTexture(new QTextureCubeMap()) - , m_gl3Shader(new QShaderProgram()) - , m_gl2es2Shader(new QShaderProgram()) - , m_gl2Technique(new QTechnique()) - , m_es2Technique(new QTechnique()) - , m_gl3Technique(new QTechnique()) - , m_filterKey(new QFilterKey) - , m_gl2RenderPass(new QRenderPass()) - , m_es2RenderPass(new QRenderPass()) - , m_gl3RenderPass(new QRenderPass()) - , m_mesh(new QCuboidMesh()) - , m_transform(new Qt3DCore::QTransform()) - , m_textureParameter(new QParameter(QStringLiteral("skyboxTexture"), m_skyboxTexture)) - , m_posXImage(new QTextureImage()) - , m_posYImage(new QTextureImage()) - , m_posZImage(new QTextureImage()) - , m_negXImage(new QTextureImage()) - , m_negYImage(new QTextureImage()) - , m_negZImage(new QTextureImage()) - , m_extension(QStringLiteral(".png")) -{ -} - -/*! - * \internal - */ -void QSkyboxEntityPrivate::init() -{ - m_gl3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/skybox.vert")))); - m_gl3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/skybox.frag")))); - m_gl2es2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/skybox.vert")))); - m_gl2es2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/skybox.frag")))); - - m_gl3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_gl3Technique->graphicsApiFilter()->setMajorVersion(3); - m_gl3Technique->graphicsApiFilter()->setMajorVersion(1); - m_gl3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); - - m_gl2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); - m_gl2Technique->graphicsApiFilter()->setMajorVersion(2); - m_gl2Technique->graphicsApiFilter()->setMajorVersion(0); - m_gl2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_es2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES); - m_es2Technique->graphicsApiFilter()->setMajorVersion(2); - m_es2Technique->graphicsApiFilter()->setMajorVersion(0); - m_es2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile); - - m_filterKey->setParent(m_effect); - m_filterKey->setName(QStringLiteral("renderingStyle")); - m_filterKey->setValue(QStringLiteral("forward")); - - m_gl3Technique->addFilterKey(m_filterKey); - m_gl2Technique->addFilterKey(m_filterKey); - m_es2Technique->addFilterKey(m_filterKey); - - m_gl3RenderPass->setShaderProgram(m_gl3Shader); - m_gl2RenderPass->setShaderProgram(m_gl2es2Shader); - m_es2RenderPass->setShaderProgram(m_gl2es2Shader); - - QCullFace *cullFront = new QCullFace(); - cullFront->setMode(QCullFace::Front); - QDepthTest *depthTest = new QDepthTest(); - depthTest->setDepthFunction(QDepthTest::LessOrEqual); - - m_gl3RenderPass->addRenderState(cullFront); - m_gl3RenderPass->addRenderState(depthTest); - m_gl2RenderPass->addRenderState(cullFront); - m_gl2RenderPass->addRenderState(depthTest); - m_es2RenderPass->addRenderState(cullFront); - m_es2RenderPass->addRenderState(depthTest); - - m_gl3Technique->addRenderPass(m_gl3RenderPass); - m_gl2Technique->addRenderPass(m_gl2RenderPass); - m_es2Technique->addRenderPass(m_es2RenderPass); - - m_effect->addTechnique(m_gl3Technique); - m_effect->addTechnique(m_gl2Technique); - m_effect->addTechnique(m_es2Technique); - - m_material->setEffect(m_effect); - m_material->addParameter(m_textureParameter); - - m_mesh->setXYMeshResolution(QSize(2, 2)); - m_mesh->setXZMeshResolution(QSize(2, 2)); - m_mesh->setYZMeshResolution(QSize(2, 2)); - - m_posXImage->setFace(QTextureCubeMap::CubeMapPositiveX); - m_posYImage->setFace(QTextureCubeMap::CubeMapPositiveY); - m_posZImage->setFace(QTextureCubeMap::CubeMapPositiveZ); - m_negXImage->setFace(QTextureCubeMap::CubeMapNegativeX); - m_negYImage->setFace(QTextureCubeMap::CubeMapNegativeY); - m_negZImage->setFace(QTextureCubeMap::CubeMapNegativeZ); - - m_skyboxTexture->setMagnificationFilter(QTextureCubeMap::Linear); - m_skyboxTexture->setMinificationFilter(QTextureCubeMap::Linear); - m_skyboxTexture->setGenerateMipMaps(false); - m_skyboxTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::ClampToEdge)); - - m_skyboxTexture->addTextureImage(m_posXImage); - m_skyboxTexture->addTextureImage(m_posYImage); - m_skyboxTexture->addTextureImage(m_posZImage); - m_skyboxTexture->addTextureImage(m_negXImage); - m_skyboxTexture->addTextureImage(m_negYImage); - m_skyboxTexture->addTextureImage(m_negZImage); - - q_func()->addComponent(m_mesh); - q_func()->addComponent(m_material); - q_func()->addComponent(m_transform); -} - -/*! - * \internal - */ -void QSkyboxEntityPrivate::reloadTexture() -{ - m_posXImage->setSource(QUrl(m_baseName + QStringLiteral("_posx") + m_extension)); - m_posYImage->setSource(QUrl(m_baseName + QStringLiteral("_posy") + m_extension)); - m_posZImage->setSource(QUrl(m_baseName + QStringLiteral("_posz") + m_extension)); - m_negXImage->setSource(QUrl(m_baseName + QStringLiteral("_negx") + m_extension)); - m_negYImage->setSource(QUrl(m_baseName + QStringLiteral("_negy") + m_extension)); - m_negZImage->setSource(QUrl(m_baseName + QStringLiteral("_negz") + m_extension)); -} - -/*! - * \class Qt3DRender::QSkyboxEntity - * \inmodule Qt3DRender - * - * \brief Qt3DRender::QSkyboxEntity is a convenience Qt3DCore::QEntity subclass that can - * be used to insert a skybox in a 3D scene. - * - * By specifying a base name and an extension, Qt3DCore::QSkyboxEntity - * will take care of building a TextureCubeMap to be rendered at runtime. The - * images in the source directory should match the pattern: - * \b base name + * "_posx|_posy|_posz|_negx|_negy|_negz" + extension - * - * By default the extension defaults to .png. - * - * \note Please note that you shouldn't try to render skybox with an - * orthographic projection. - * - * \since 5.5 - */ - -/*! - * Constructs a new Qt3DCore::QSkyboxEntity object with \a parent as parent. - */ -QSkyboxEntity::QSkyboxEntity(QNode *parent) - : QEntity(*new QSkyboxEntityPrivate, parent) -{ - d_func()->init(); -} - -QSkyboxEntity::~QSkyboxEntity() -{ - QNode::cleanup(); -} - -/*! - * Sets the base name to \a baseName. - */ -void QSkyboxEntity::setBaseName(const QString &baseName) -{ - Q_D(QSkyboxEntity); - if (baseName != d->m_baseName) { - d->m_baseName = baseName; - emit sourceDirectoryChanged(baseName); - d->reloadTexture(); - } -} -/*! - * Returns the base name. - */ -QString QSkyboxEntity::baseName() const -{ - Q_D(const QSkyboxEntity); - return d->m_baseName; -} - -/*! - * Sets the extension to \a extension. - */ -void QSkyboxEntity::setExtension(const QString &extension) -{ - Q_D(QSkyboxEntity); - if (extension != d->m_extension) { - d->m_extension = extension; - emit extensionChanged(extension); - d->reloadTexture(); - } -} - -/*! - * Returns the extension - */ -QString QSkyboxEntity::extension() const -{ - Q_D(const QSkyboxEntity); - return d->m_extension; -} - -/*! - * Sets the camera position to \a cameraPosition. - */ -void QSkyboxEntity::setCameraPosition(const QVector3D &cameraPosition) -{ - Q_D(QSkyboxEntity); - if (cameraPosition != d->m_position) { - d->m_position = cameraPosition; - d->m_transform->setTranslation(d->m_position); - emit cameraPositionChanged(cameraPosition); - } -} - -/*! - * Returns the camera position. - */ -QVector3D QSkyboxEntity::cameraPosition() const -{ - Q_D(const QSkyboxEntity); - return d->m_position; -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/defaults/qskyboxentity.h b/src/render/defaults/qskyboxentity.h deleted file mode 100644 index e52e4bcd5..000000000 --- a/src/render/defaults/qskyboxentity.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QSKYBOXENTITY_H -#define QT3DRENDER_RENDER_QSKYBOXENTITY_H - -#include <Qt3DCore/qentity.h> -#include <Qt3DRender/qt3drender_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QSkyboxEntityPrivate; - -class QT3DRENDERSHARED_EXPORT QSkyboxEntity : public Qt3DCore::QEntity -{ - Q_OBJECT -public: - explicit QSkyboxEntity(Qt3DCore::QNode *parent = Q_NULLPTR); - ~QSkyboxEntity(); - - void setBaseName(const QString &path); - QString baseName() const; - - void setExtension(const QString &extension); - QString extension() const; - - void setCameraPosition(const QVector3D &cameraPosition); - QVector3D cameraPosition() const; - -Q_SIGNALS: - void sourceDirectoryChanged(const QString &path); - void extensionChanged(const QString &extension); - void cameraPositionChanged(const QVector3D &cameraPosition); - -private: - Q_DECLARE_PRIVATE(QSkyboxEntity) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QSKYBOXENTITY_H diff --git a/src/render/defaults/qskyboxentity_p.h b/src/render/defaults/qskyboxentity_p.h deleted file mode 100644 index f020ac824..000000000 --- a/src/render/defaults/qskyboxentity_p.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QSKYBOXENTITY_P_H -#define QT3DRENDER_RENDER_QSKYBOXENTITY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DCore/private/qentity_p.h> -#include <QVector3D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { -class QTransform; -} - -namespace Qt3DRender { - -class QFilterKey; -class QTextureCubeMap; -class QShaderProgram; -class QSkyboxEntity; -class QTextureImage; -class QCuboidMesh; -class QRenderPass; -class QTechnique; -class QParameter; -class QMaterial; -class QEffect; - -class QSkyboxEntityPrivate : public Qt3DCore::QEntityPrivate -{ - QSkyboxEntityPrivate(); - - void init(); - void reloadTexture(); - - Q_DECLARE_PUBLIC(QSkyboxEntity) - - QEffect *m_effect; - QMaterial *m_material; - QTextureCubeMap *m_skyboxTexture; - QShaderProgram *m_gl3Shader; - QShaderProgram *m_gl2es2Shader; - QTechnique *m_gl2Technique; - QTechnique *m_es2Technique; - QTechnique *m_gl3Technique; - QFilterKey *m_filterKey; - QRenderPass *m_gl2RenderPass; - QRenderPass *m_es2RenderPass; - QRenderPass *m_gl3RenderPass; - QCuboidMesh *m_mesh; - Qt3DCore::QTransform *m_transform; - QParameter *m_textureParameter; - QTextureImage *m_posXImage; - QTextureImage *m_posYImage; - QTextureImage *m_posZImage; - QTextureImage *m_negXImage; - QTextureImage *m_negYImage; - QTextureImage *m_negZImage; - QString m_extension; - QString m_baseName; - QVector3D m_position; -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QSKYBOXENTITY_P_H - |