diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2018-04-03 17:19:43 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2018-04-04 13:31:46 +0000 |
commit | 2a260617b96281375e2ee018af8c7547d99e4a6d (patch) | |
tree | a5aee129a69c0b2e9b6dab42a5fcddd17f3c5361 /examples/qt3d/materials-cpp | |
parent | 634529d899e99c2fb40429d3d0be6295aa444a40 (diff) |
Add replacement materials examplev5.11.0-beta3
All texture assets were made by KDAB under the CLA. The material
"sphere" mesh is from Allegorithmic and published under the
Creative Commons 4 license. See paragraph 1.2 of
https://www.allegorithmic.com/legal/substance-share
Task-number: QTBUG-61415
Change-Id: I23d61723bbac561e22e11fa57105b29148c01699
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 74c06c02f896c6aba408cfd0857d317378572736)
Diffstat (limited to 'examples/qt3d/materials-cpp')
-rw-r--r-- | examples/qt3d/materials-cpp/barrel.cpp | 168 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/barrel.h | 113 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/doc/images/materials-cpp.png | bin | 25144 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/materials-cpp/doc/src/materials-cpp.qdoc | 39 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/houseplant.cpp | 179 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/houseplant.h | 117 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/main.cpp | 200 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/materials-cpp.pro | 29 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/planeentity.cpp | 73 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/planeentity.h | 71 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/renderableentity.cpp | 70 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/renderableentity.h | 71 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp | 77 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/rotatingtrefoilknot.h | 69 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/trefoilknot.cpp | 137 | ||||
-rw-r--r-- | examples/qt3d/materials-cpp/trefoilknot.h | 99 |
16 files changed, 0 insertions, 1512 deletions
diff --git a/examples/qt3d/materials-cpp/barrel.cpp b/examples/qt3d/materials-cpp/barrel.cpp deleted file mode 100644 index 147f586aa..000000000 --- a/examples/qt3d/materials-cpp/barrel.cpp +++ /dev/null @@ -1,168 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "barrel.h" - -const char *diffuseColorsName[] = { - "red", - "blue", - "green", - "rust", - "stainless_steel" -}; - -const char *specularColorsName[] = { - "_rust", - "_stainless_steel", - "" -}; - -const char *bumpsName[] = { - "no_bumps", - "soft_bumps", - "middle_bumps", - "hard_bumps" -}; - -Barrel::Barrel(Qt3DCore::QNode *parent) - : RenderableEntity(parent) - , m_bumps(NoBumps) - , m_diffuseColor(Red) - , m_specularColor(None) - , m_material(new Qt3DExtras::QNormalDiffuseSpecularMapMaterial()) - , m_diffuseTexture(m_material->diffuse()) - , m_normalTexture(m_material->normal()) - , m_specularTexture(m_material->specular()) - , m_diffuseTextureImage(new Qt3DRender::QTextureImage()) - , m_normalTextureImage(new Qt3DRender::QTextureImage()) - , m_specularTextureImage(new Qt3DRender::QTextureImage()) -{ - mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/metalbarrel/metal_barrel.obj"))); - transform()->setScale(0.03f); - - m_diffuseTexture->addTextureImage(m_diffuseTextureImage); - m_normalTexture->addTextureImage(m_normalTextureImage); - m_specularTexture->addTextureImage(m_specularTextureImage); - - setNormalTextureSource(); - setDiffuseTextureSource(); - setSpecularTextureSource(); - m_material->setShininess(10.0f); - addComponent(m_material); -} - -Barrel::~Barrel() -{ -} - -void Barrel::setDiffuse(Barrel::DiffuseColor diffuse) -{ - if (diffuse != m_diffuseColor) { - m_diffuseColor = diffuse; - setDiffuseTextureSource(); - } -} - -void Barrel::setSpecular(Barrel::SpecularColor specular) -{ - if (specular != m_specularColor) { - m_specularColor = specular; - setSpecularTextureSource(); - } -} - -void Barrel::setBumps(Barrel::Bumps bumps) -{ - if (bumps != m_bumps) { - m_bumps = bumps; - setNormalTextureSource(); - } -} - -void Barrel::setShininess(float shininess) -{ - if (shininess != m_material->shininess()) - m_material->setShininess(shininess); -} - -Barrel::DiffuseColor Barrel::diffuse() const -{ - return m_diffuseColor; -} - -Barrel::SpecularColor Barrel::specular() const -{ - return m_specularColor; -} - -Barrel::Bumps Barrel::bumps() const -{ - return m_bumps; -} - -float Barrel::shininess() const -{ - return m_material->shininess(); -} - -void Barrel::setNormalTextureSource() -{ - m_normalTextureImage->setSource(QUrl(QStringLiteral("qrc:/assets/metalbarrel/normal_") + bumpsName[m_bumps] + QStringLiteral(".webp"))); -} - -void Barrel::setDiffuseTextureSource() -{ - m_diffuseTextureImage->setSource(QUrl(QStringLiteral("qrc:/assets/metalbarrel/diffus_") + diffuseColorsName[m_diffuseColor] + QStringLiteral(".webp"))); -} - -void Barrel::setSpecularTextureSource() -{ - m_specularTextureImage->setSource(QUrl(QStringLiteral("qrc:/assets/metalbarrel/specular") + specularColorsName[m_specularColor] + QStringLiteral(".webp"))); -} diff --git a/examples/qt3d/materials-cpp/barrel.h b/examples/qt3d/materials-cpp/barrel.h deleted file mode 100644 index 237ab446c..000000000 --- a/examples/qt3d/materials-cpp/barrel.h +++ /dev/null @@ -1,113 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BARREL_H -#define BARREL_H - -#include <Qt3DExtras/QNormalDiffuseSpecularMapMaterial> -#include <Qt3DRender/qtexture.h> -#include "renderableentity.h" - -class Barrel : public RenderableEntity -{ -public: - Barrel(Qt3DCore::QNode *parent = 0); - ~Barrel(); - - enum DiffuseColor { - Red = 0, - Blue, - Green, - RustDiffuse, - StainlessSteelDiffuse - }; - - enum SpecularColor { - RustSpecular = 0, - StainlessSteelSpecular, - None - }; - - enum Bumps { - NoBumps = 0, - SoftBumps, - MiddleBumps, - HardBumps - }; - - void setDiffuse(DiffuseColor diffuse); - void setSpecular(SpecularColor specular); - void setBumps(Bumps bumps); - void setShininess(float shininess); - - DiffuseColor diffuse() const; - SpecularColor specular() const; - Bumps bumps() const; - float shininess() const; - -private: - Bumps m_bumps; - DiffuseColor m_diffuseColor; - SpecularColor m_specularColor; - Qt3DExtras::QNormalDiffuseSpecularMapMaterial *m_material; - Qt3DRender::QAbstractTexture *m_diffuseTexture; - Qt3DRender::QAbstractTexture *m_normalTexture; - Qt3DRender::QAbstractTexture *m_specularTexture; - Qt3DRender::QTextureImage *m_diffuseTextureImage; - Qt3DRender::QTextureImage *m_normalTextureImage; - Qt3DRender::QTextureImage *m_specularTextureImage; - - void setNormalTextureSource(); - void setDiffuseTextureSource(); - void setSpecularTextureSource(); - -}; - -#endif // BARREL_H diff --git a/examples/qt3d/materials-cpp/doc/images/materials-cpp.png b/examples/qt3d/materials-cpp/doc/images/materials-cpp.png Binary files differdeleted file mode 100644 index 5eb695403..000000000 --- a/examples/qt3d/materials-cpp/doc/images/materials-cpp.png +++ /dev/null diff --git a/examples/qt3d/materials-cpp/doc/src/materials-cpp.qdoc b/examples/qt3d/materials-cpp/doc/src/materials-cpp.qdoc deleted file mode 100644 index 496a3c985..000000000 --- a/examples/qt3d/materials-cpp/doc/src/materials-cpp.qdoc +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example materials-cpp - \title Qt 3D: Materials C++ Example - \ingroup qt3d-examples-cpp - \brief A C++ application that demonstrates using materials. - - \image materials-cpp.png - - \e {Materials} demonstrates using the Qt 3D material system. - - \include examples-run.qdocinc -*/ diff --git a/examples/qt3d/materials-cpp/houseplant.cpp b/examples/qt3d/materials-cpp/houseplant.cpp deleted file mode 100644 index 638f8c4d1..000000000 --- a/examples/qt3d/materials-cpp/houseplant.cpp +++ /dev/null @@ -1,179 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "houseplant.h" -#include <Qt3DRender/qtexture.h> - -const char *potNames[] = { - "cross", - "square", - "triangle", - "sphere" -}; - -const char *plantNames[] = { - "bamboo", - "palm", - "pine", - "spikes", - "shrub" -}; - - -HousePlant::HousePlant(Qt3DCore::QNode *parent) - : Qt3DCore::QEntity(parent) - , m_pot(new RenderableEntity(this)) - , m_plant(new RenderableEntity(m_pot)) - , m_cover(new RenderableEntity(m_pot)) - , m_potMaterial(new Qt3DExtras::QNormalDiffuseMapMaterial()) - , m_plantMaterial(new Qt3DExtras::QNormalDiffuseMapAlphaMaterial()) - , m_coverMaterial(new Qt3DExtras::QNormalDiffuseMapMaterial()) - , m_potImage(new Qt3DRender::QTextureImage()) - , m_potNormalImage(new Qt3DRender::QTextureImage()) - , m_plantImage(new Qt3DRender::QTextureImage()) - , m_plantNormalImage(new Qt3DRender::QTextureImage()) - , m_coverImage(new Qt3DRender::QTextureImage()) - , m_coverNormalImage(new Qt3DRender::QTextureImage()) - , m_plantType(Bamboo) - , m_potShape(Cross) -{ - m_pot->transform()->setScale(0.03f); - m_pot->addComponent(m_potMaterial); - m_plant->addComponent(m_plantMaterial); - m_cover->addComponent(m_coverMaterial); - - m_potMaterial->diffuse()->addTextureImage(m_potImage); - m_potMaterial->normal()->addTextureImage(m_potNormalImage); - m_plantMaterial->diffuse()->addTextureImage(m_plantImage); - m_plantMaterial->normal()->addTextureImage(m_plantNormalImage); - m_coverMaterial->diffuse()->addTextureImage(m_coverImage); - m_coverMaterial->normal()->addTextureImage(m_coverNormalImage); - - updatePlantType(); - updatePotShape(); - - m_coverImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/cover.webp"))); - m_coverNormalImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/cover_normal.webp"))); - m_potImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/pot.webp"))); - m_potNormalImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/pot_normal.webp"))); - - m_potMaterial->setShininess(10.0f); - m_potMaterial->setSpecular(QColor::fromRgbF(0.75f, 0.75f, 0.75f, 1.0f)); - - m_plantMaterial->setShininess(10.0f); - - m_coverMaterial->setSpecular(QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)); - m_coverMaterial->setShininess(5.0f); -} - -HousePlant::~HousePlant() -{ -} - -void HousePlant::setPotShape(HousePlant::PotShape shape) -{ - if (shape != m_potShape) { - m_potShape = shape; - updatePotShape(); - } -} - -void HousePlant::setPlantType(HousePlant::Plant plant) -{ - if (plant != m_plantType) { - m_plantType = plant; - updatePlantType(); - } -} - -HousePlant::PotShape HousePlant::potShape() const -{ - return m_potShape; -} - -HousePlant::Plant HousePlant::plantType() const -{ - return m_plantType; -} - -void HousePlant::setPosition(const QVector3D &pos) -{ - m_pot->transform()->setTranslation(pos); -} - -void HousePlant::setScale(float scale) -{ - m_pot->transform()->setScale(scale); -} - -QVector3D HousePlant::position() const -{ - return m_pot->transform()->translation(); -} - -float HousePlant::scale() const -{ - return m_pot->transform()->scale(); -} - -void HousePlant::updatePotShape() -{ - m_pot->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + potNames[m_potShape] + QStringLiteral("-pot.obj"))); - m_plant->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + potNames[m_potShape] + QStringLiteral("-") + plantNames[m_plantType] + QStringLiteral(".obj"))); -} - -void HousePlant::updatePlantType() -{ - m_plant->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + potNames[m_potShape] + QStringLiteral("-") + plantNames[m_plantType] + QStringLiteral(".obj"))); - - m_plantImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + plantNames[m_plantType] + QStringLiteral(".webp"))); - m_plantNormalImage->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + plantNames[m_plantType] + QStringLiteral("_normal.webp"))); -} - diff --git a/examples/qt3d/materials-cpp/houseplant.h b/examples/qt3d/materials-cpp/houseplant.h deleted file mode 100644 index d2081b3d1..000000000 --- a/examples/qt3d/materials-cpp/houseplant.h +++ /dev/null @@ -1,117 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef HOUSEPLANT_H -#define HOUSEPLANT_H - -#include "renderableentity.h" -#include <QEntity> -#include <Qt3DExtras/QNormalDiffuseMapAlphaMaterial> -#include <Qt3DExtras/QNormalDiffuseMapMaterial> -#include <QTextureImage> - -class HousePlant : public Qt3DCore::QEntity -{ - Q_OBJECT -public: - explicit HousePlant(Qt3DCore::QNode *parent = 0); - ~HousePlant(); - - enum PotShape { - Cross = 0, - Square, - Triangle, - Sphere - }; - - enum Plant { - Bamboo = 0, - Palm, - Pine, - Spikes, - Shrub - }; - - void setPotShape(PotShape shape); - void setPlantType(Plant plant); - - PotShape potShape() const; - Plant plantType() const; - - void setPosition(const QVector3D &pos); - void setScale(float scale); - - QVector3D position() const; - float scale() const; - -private: - RenderableEntity *m_pot; - RenderableEntity *m_plant; - RenderableEntity *m_cover; - - Qt3DExtras::QNormalDiffuseMapMaterial *m_potMaterial; - Qt3DExtras::QNormalDiffuseMapAlphaMaterial *m_plantMaterial; - Qt3DExtras::QNormalDiffuseMapMaterial *m_coverMaterial; - - Qt3DRender::QTextureImage *m_potImage; - Qt3DRender::QTextureImage *m_potNormalImage; - Qt3DRender::QTextureImage *m_plantImage; - Qt3DRender::QTextureImage *m_plantNormalImage; - Qt3DRender::QTextureImage *m_coverImage; - Qt3DRender::QTextureImage *m_coverNormalImage; - - Plant m_plantType; - PotShape m_potShape; - - void updatePotShape(); - void updatePlantType(); -}; - -#endif // HOUSEPLANT_H diff --git a/examples/qt3d/materials-cpp/main.cpp b/examples/qt3d/materials-cpp/main.cpp deleted file mode 100644 index b788bff30..000000000 --- a/examples/qt3d/materials-cpp/main.cpp +++ /dev/null @@ -1,200 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QGuiApplication> - -#include <Qt3DCore/QEntity> -#include <Qt3DCore/QAspectEngine> -#include <Qt3DRender/QCamera> - -#include <Qt3DInput/QInputAspect> - -#include <Qt3DRender/QRenderAspect> -#include <Qt3DExtras/QPhongMaterial> -#include <Qt3DExtras/QDiffuseMapMaterial> -#include <Qt3DExtras/QForwardRenderer> -#include <Qt3DRender/QTextureImage> - -#include "planeentity.h" -#include "rotatingtrefoilknot.h" -#include "barrel.h" -#include "houseplant.h" -#include <Qt3DExtras/qt3dwindow.h> -#include <Qt3DExtras/qfirstpersoncameracontroller.h> - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - - Qt3DExtras::Qt3DWindow view; - - // Scene Root - Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); - - // Scene Camera - Qt3DRender::QCamera *basicCamera = view.camera(); - basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); - basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); - basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); - basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); - // For camera controls - Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot); - camController->setCamera(basicCamera); - - // Scene floor - PlaneEntity *planeEntity = new PlaneEntity(sceneRoot); - planeEntity->mesh()->setHeight(100.0f); - planeEntity->mesh()->setWidth(100.0f); - planeEntity->mesh()->setMeshResolution(QSize(20, 20)); - - Qt3DExtras::QNormalDiffuseSpecularMapMaterial *normalDiffuseSpecularMapMaterial = new Qt3DExtras::QNormalDiffuseSpecularMapMaterial(); - normalDiffuseSpecularMapMaterial->setTextureScale(10.0f); - normalDiffuseSpecularMapMaterial->setShininess(80.0f); - normalDiffuseSpecularMapMaterial->setAmbient(QColor::fromRgbF(0.2f, 0.2f, 0.2f, 1.0f)); - - Qt3DRender::QTextureImage *diffuseImage = new Qt3DRender::QTextureImage(); - diffuseImage->setSource(QUrl(QStringLiteral("qrc:/assets/textures/pattern_09/diffuse.webp"))); - normalDiffuseSpecularMapMaterial->diffuse()->addTextureImage(diffuseImage); - - Qt3DRender::QTextureImage *specularImage = new Qt3DRender::QTextureImage(); - specularImage->setSource(QUrl(QStringLiteral("qrc:/assets/textures/pattern_09/specular.webp"))); - normalDiffuseSpecularMapMaterial->specular()->addTextureImage(specularImage); - - Qt3DRender::QTextureImage *normalImage = new Qt3DRender::QTextureImage(); - normalImage->setSource(QUrl((QStringLiteral("qrc:/assets/textures/pattern_09/normal.webp")))); - normalDiffuseSpecularMapMaterial->normal()->addTextureImage(normalImage); - - planeEntity->addComponent(normalDiffuseSpecularMapMaterial); - - // Chest - RenderableEntity *chest = new RenderableEntity(sceneRoot); - chest->transform()->setScale(0.03f); - chest->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/chest/Chest.obj"))); - Qt3DExtras::QDiffuseMapMaterial *diffuseMapMaterial = new Qt3DExtras::QDiffuseMapMaterial(); - diffuseMapMaterial->setSpecular(QColor::fromRgbF(0.2f, 0.2f, 0.2f, 1.0f)); - diffuseMapMaterial->setShininess(2.0f); - - Qt3DRender::QTextureImage *chestDiffuseImage = new Qt3DRender::QTextureImage(); - chestDiffuseImage->setSource(QUrl(QStringLiteral("qrc:/assets/chest/diffuse.webp"))); - diffuseMapMaterial->diffuse()->addTextureImage(chestDiffuseImage); - - chest->addComponent(diffuseMapMaterial); - - - // TrefoilKnot - RotatingTrefoilKnot *trefoil = new RotatingTrefoilKnot(sceneRoot); - trefoil->setPosition(QVector3D(0.0f, 3.5f, 0.0f)); - trefoil->setScale(0.5f); - Qt3DExtras::QPhongMaterial *phongMaterial = new Qt3DExtras::QPhongMaterial(); - phongMaterial->setDiffuse(QColor(204, 205, 75)); // Safari Yellow #cccd4b - phongMaterial->setSpecular(Qt::white); - trefoil->addComponent(phongMaterial); - - // Barrels - Barrel *basicBarrel = new Barrel(sceneRoot); - basicBarrel->transform()->setTranslation(QVector3D(8.0f, 0.0f, 0.0f)); - - Barrel *rustyBarrel = new Barrel(sceneRoot); - rustyBarrel->setDiffuse(Barrel::RustDiffuse); - rustyBarrel->setSpecular(Barrel::RustSpecular); - rustyBarrel->setBumps(Barrel::HardBumps); - rustyBarrel->transform()->setTranslation(QVector3D(10.0f, 0.0f, 0.0f)); - - Barrel *blueBarrel = new Barrel(sceneRoot); - blueBarrel->setDiffuse(Barrel::Blue); - blueBarrel->setBumps(Barrel::MiddleBumps); - blueBarrel->transform()->setTranslation(QVector3D(12.0f, 0.0f, 0.0f)); - - Barrel *greenBarrel = new Barrel(sceneRoot); - greenBarrel->setDiffuse(Barrel::Green); - greenBarrel->setBumps(Barrel::SoftBumps); - greenBarrel->transform()->setTranslation(QVector3D(14.0f, 0.0f, 0.0f)); - - Barrel *stainlessBarrel = new Barrel(sceneRoot); - stainlessBarrel->setDiffuse(Barrel::StainlessSteelDiffuse); - stainlessBarrel->setBumps(Barrel::NoBumps); - stainlessBarrel->setSpecular(Barrel::StainlessSteelSpecular); - stainlessBarrel->setShininess(150.0f); - stainlessBarrel->transform()->setTranslation(QVector3D(16.0f, 0.0f, 0.0f)); - - // Plants - HousePlant *squareBamboo = new HousePlant(sceneRoot); - squareBamboo->setPotShape(HousePlant::Square); - squareBamboo->setPosition(QVector3D(4.0f, 0.0f, 0.0f)); - - HousePlant *trianglePalm = new HousePlant(sceneRoot); - trianglePalm->setPlantType(HousePlant::Palm); - trianglePalm->setPotShape(HousePlant::Triangle); - trianglePalm->setPosition(QVector3D(0.0f, 0.0f, 4.0f)); - - HousePlant *spherePine = new HousePlant(sceneRoot); - spherePine->setPlantType(HousePlant::Pine); - spherePine->setPotShape(HousePlant::Sphere); - spherePine->setPosition(QVector3D(-4.0f, 0.0f, 0.0f)); - - HousePlant *crossSpikes = new HousePlant(sceneRoot); - crossSpikes->setPlantType(HousePlant::Spikes); - crossSpikes->setPosition(QVector3D(0.0f, 0.0f, -4.0f)); - - HousePlant *crossPalm = new HousePlant(sceneRoot); - crossPalm->setPlantType(HousePlant::Palm); - crossPalm->setPosition(QVector3D(0.0f, 0.0f, -8.0f)); - crossPalm->setScale(0.05f); - - HousePlant *crossShrub = new HousePlant(sceneRoot); - crossShrub->setPlantType(HousePlant::Shrub); - crossShrub->setPosition(QVector3D(0.0f, 0.0f, 8.0f)); - crossShrub->setScale(0.05f); - - view.setRootEntity(sceneRoot); - view.show(); - - return app.exec(); -} diff --git a/examples/qt3d/materials-cpp/materials-cpp.pro b/examples/qt3d/materials-cpp/materials-cpp.pro deleted file mode 100644 index 326feca75..000000000 --- a/examples/qt3d/materials-cpp/materials-cpp.pro +++ /dev/null @@ -1,29 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -QT += 3dcore 3drender 3dinput 3dextras - -HEADERS += \ - planeentity.h \ - renderableentity.h \ - trefoilknot.h \ - barrel.h \ - rotatingtrefoilknot.h \ - houseplant.h - -SOURCES += \ - main.cpp \ - planeentity.cpp \ - renderableentity.cpp \ - trefoilknot.cpp \ - barrel.cpp \ - rotatingtrefoilknot.cpp \ - houseplant.cpp - -RESOURCES += \ - ../exampleresources/chest.qrc \ - ../exampleresources/houseplants.qrc \ - ../exampleresources/metalbarrel.qrc \ - ../exampleresources/obj.qrc \ - ../exampleresources/textures.qrc diff --git a/examples/qt3d/materials-cpp/planeentity.cpp b/examples/qt3d/materials-cpp/planeentity.cpp deleted file mode 100644 index b60e6c186..000000000 --- a/examples/qt3d/materials-cpp/planeentity.cpp +++ /dev/null @@ -1,73 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "planeentity.h" - -#include <Qt3DExtras/QPlaneMesh> -#include <Qt3DCore/QTransform> - -PlaneEntity::PlaneEntity(Qt3DCore::QNode *parent) - : Qt3DCore::QEntity(new Qt3DCore::QEntity(parent)) - , m_mesh(new Qt3DExtras::QPlaneMesh()) - , m_transform(new Qt3DCore::QTransform()) -{ - addComponent(m_mesh); - addComponent(m_transform); -} - -PlaneEntity::~PlaneEntity() -{ -} - -Qt3DExtras::QPlaneMesh *PlaneEntity::mesh() const -{ - return m_mesh; -} - diff --git a/examples/qt3d/materials-cpp/planeentity.h b/examples/qt3d/materials-cpp/planeentity.h deleted file mode 100644 index 8491efb1a..000000000 --- a/examples/qt3d/materials-cpp/planeentity.h +++ /dev/null @@ -1,71 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLANEENTITY_H -#define PLANEENTITY_H - -#include <Qt3DCore/QEntity> -#include <Qt3DCore/QTransform> -#include <Qt3DExtras/QPlaneMesh> - -class PlaneEntity : public Qt3DCore::QEntity -{ -public: - PlaneEntity(Qt3DCore::QNode *parent = 0); - ~PlaneEntity(); - - Qt3DExtras::QPlaneMesh *mesh() const; - -private: - Qt3DExtras::QPlaneMesh *m_mesh; - Qt3DCore::QTransform *m_transform; -}; - -#endif // PLANEENTITY_H diff --git a/examples/qt3d/materials-cpp/renderableentity.cpp b/examples/qt3d/materials-cpp/renderableentity.cpp deleted file mode 100644 index 87474f6e1..000000000 --- a/examples/qt3d/materials-cpp/renderableentity.cpp +++ /dev/null @@ -1,70 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "renderableentity.h" - -RenderableEntity::RenderableEntity(Qt3DCore::QNode *parent) - : Qt3DCore::QEntity(parent) - , m_mesh(new Qt3DRender::QMesh()) - , m_transform(new Qt3DCore::QTransform()) -{ - addComponent(m_mesh); - addComponent(m_transform); -} - -Qt3DRender::QMesh *RenderableEntity::mesh() const -{ - return m_mesh; -} - -Qt3DCore::QTransform *RenderableEntity::transform() const -{ - return m_transform; -} diff --git a/examples/qt3d/materials-cpp/renderableentity.h b/examples/qt3d/materials-cpp/renderableentity.h deleted file mode 100644 index 5ed767b54..000000000 --- a/examples/qt3d/materials-cpp/renderableentity.h +++ /dev/null @@ -1,71 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RENDERABLEENTITY_H -#define RENDERABLEENTITY_H - -#include <Qt3DCore/QEntity> -#include <Qt3DCore/QTransform> -#include <Qt3DRender/QMesh> - -class RenderableEntity : public Qt3DCore::QEntity -{ -public: - RenderableEntity(Qt3DCore::QNode *parent = 0); - - Qt3DRender::QMesh *mesh() const; - Qt3DCore::QTransform *transform() const; - -private: - Qt3DRender::QMesh *m_mesh; - Qt3DCore::QTransform *m_transform; -}; - -#endif // RENDERABLEENTITY_H diff --git a/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp b/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp deleted file mode 100644 index 6e50ccbdf..000000000 --- a/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp +++ /dev/null @@ -1,77 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "rotatingtrefoilknot.h" - -RotatingTrefoilKnot::RotatingTrefoilKnot(Qt3DCore::QNode *parent) - : TrefoilKnot(parent) - , m_thetaAnimation(new QPropertyAnimation(this)) - , m_phiAnimation(new QPropertyAnimation(this)) -{ - m_thetaAnimation->setDuration(2000); - m_thetaAnimation->setStartValue(0.0f); - m_thetaAnimation->setEndValue(360.0f); - m_thetaAnimation->setLoopCount(-1); - m_thetaAnimation->setTargetObject(this); - m_thetaAnimation->setPropertyName("phi"); - m_thetaAnimation->start(); - - m_phiAnimation->setDuration(2000); - m_phiAnimation->setStartValue(0.0f); - m_phiAnimation->setEndValue(360.0f); - m_phiAnimation->setLoopCount(-1); - m_phiAnimation->setTargetObject(this); - m_phiAnimation->setPropertyName("theta"); - m_phiAnimation->start(); -} - -RotatingTrefoilKnot::~RotatingTrefoilKnot() -{ -} diff --git a/examples/qt3d/materials-cpp/rotatingtrefoilknot.h b/examples/qt3d/materials-cpp/rotatingtrefoilknot.h deleted file mode 100644 index 6f1858863..000000000 --- a/examples/qt3d/materials-cpp/rotatingtrefoilknot.h +++ /dev/null @@ -1,69 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ROTATINGTREFOILKNOT_H -#define ROTATINGTREFOILKNOT_H - -#include "trefoilknot.h" -#include <QPropertyAnimation> - -class RotatingTrefoilKnot : public TrefoilKnot -{ -public: - explicit RotatingTrefoilKnot(Qt3DCore::QNode *parent = 0); - ~RotatingTrefoilKnot(); - -private: - QPropertyAnimation *m_thetaAnimation; - QPropertyAnimation *m_phiAnimation; - -}; - -#endif // ROTATINGTREFOILKNOT_H diff --git a/examples/qt3d/materials-cpp/trefoilknot.cpp b/examples/qt3d/materials-cpp/trefoilknot.cpp deleted file mode 100644 index 82a65e294..000000000 --- a/examples/qt3d/materials-cpp/trefoilknot.cpp +++ /dev/null @@ -1,137 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "trefoilknot.h" - -TrefoilKnot::TrefoilKnot(Qt3DCore::QNode *parent) - : Qt3DCore::QEntity(parent) - , m_mesh(new Qt3DRender::QMesh()) - , m_transform(new Qt3DCore::QTransform()) - , m_position() - , m_scale(1.0f) -{ - m_mesh->setSource(QUrl("qrc:/assets/obj/trefoil.obj")); - addComponent(m_mesh); - addComponent(m_transform); -} - -TrefoilKnot::~TrefoilKnot() -{ -} - -void TrefoilKnot::updateTransform() -{ - QMatrix4x4 m; - m.translate(m_position); - m.rotate(m_phi, QVector3D(1.0f, 0.0f, 0.0f)); - m.rotate(m_phi, QVector3D(0.0f, 1.0f, 0.0f)); - m.scale(m_scale); - m_transform->setMatrix(m); -} - -float TrefoilKnot::theta() const -{ - return m_theta; -} - -float TrefoilKnot::phi() const -{ - return m_phi; -} - -QVector3D TrefoilKnot::position() const -{ - return m_position; -} - -float TrefoilKnot::scale() const -{ - return m_scale; -} - -void TrefoilKnot::setTheta(float theta) -{ - if (m_theta == theta) - return; - - m_theta = theta; - emit thetaChanged(theta); - updateTransform(); -} - -void TrefoilKnot::setPhi(float phi) -{ - if (m_phi == phi) - return; - - m_phi = phi; - emit phiChanged(phi); - updateTransform(); -} - -void TrefoilKnot::setPosition(QVector3D position) -{ - if (m_position == position) - return; - - m_position = position; - emit positionChanged(position); - updateTransform(); -} - -void TrefoilKnot::setScale(float scale) -{ - if (m_scale == scale) - return; - - m_scale = scale; - emit scaleChanged(scale); - updateTransform(); -} diff --git a/examples/qt3d/materials-cpp/trefoilknot.h b/examples/qt3d/materials-cpp/trefoilknot.h deleted file mode 100644 index 42ac3419b..000000000 --- a/examples/qt3d/materials-cpp/trefoilknot.h +++ /dev/null @@ -1,99 +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:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TREFOILKNOT_H -#define TREFOILKNOT_H - -#include <Qt3DCore/QEntity> -#include <Qt3DCore/QTransform> -#include <Qt3DRender/QMesh> - -class TrefoilKnot : public Qt3DCore::QEntity -{ - Q_OBJECT - Q_PROPERTY(float theta READ theta WRITE setTheta NOTIFY thetaChanged) - Q_PROPERTY(float phi READ phi WRITE setPhi NOTIFY phiChanged) - Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged) - Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) - -public: - explicit TrefoilKnot(Qt3DCore::QNode *parent = 0); - ~TrefoilKnot(); - - float theta() const; - float phi() const; - QVector3D position() const; - float scale() const; - -public slots: - void setTheta(float theta); - void setPhi(float phi); - void setPosition(QVector3D position); - void setScale(float scale); - -signals: - void thetaChanged(float theta); - void phiChanged(float phi); - void positionChanged(QVector3D position); - void scaleChanged(float scale); - -protected: - void updateTransform(); - -private: - Qt3DRender::QMesh *m_mesh; - Qt3DCore::QTransform *m_transform; - float m_theta; - float m_phi; - QVector3D m_position; - float m_scale; -}; - -#endif // TREFOILKNOT_H |