diff options
Diffstat (limited to 'examples/qt3d/builder')
-rw-r--r-- | examples/qt3d/builder/builder.cpp | 195 | ||||
-rw-r--r-- | examples/qt3d/builder/builder.h | 69 | ||||
-rw-r--r-- | examples/qt3d/builder/builder.pro | 16 | ||||
-rw-r--r-- | examples/qt3d/builder/builder.qrc | 5 | ||||
-rw-r--r-- | examples/qt3d/builder/builder.rc | 1 | ||||
-rw-r--r-- | examples/qt3d/builder/main.cpp | 79 | ||||
-rw-r--r-- | examples/qt3d/builder/qt-soup.png | bin | 91448 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/builder/qt3d.ico | bin | 54334 -> 0 bytes |
8 files changed, 0 insertions, 365 deletions
diff --git a/examples/qt3d/builder/builder.cpp b/examples/qt3d/builder/builder.cpp deleted file mode 100644 index 34dabb1d9..000000000 --- a/examples/qt3d/builder/builder.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "builder.h" -#include "qglbuilder.h" -#include "qglmaterialcollection.h" -#include "qgltexture2d.h" -#include "qglmaterial.h" -#include "qglscenenode.h" -#include "qgllightmodel.h" - -#include <QtGui/qmatrix4x4.h> - -#include <QtCore/qmath.h> - -BuilderView::BuilderView(QWindow *parent) - : QGLView(parent) - , canScene(new QGLSceneNode(this)) - , texture(0) -{ - //! [0] - QGLSceneNode *can = buildGeometry(); - canScene->addNode(can); - { - // rotate the can around so its label shows; and down - // so the base is facing down - QMatrix4x4 mat; - QQuaternion q1 = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, 270.0f); - QQuaternion q2 = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 100.0f); - mat.rotate(q2 * q1); - can->setLocalTransform(mat); - } - - // display a copy of the can to the left - QGLSceneNode *node = new QGLSceneNode(canScene); - node->addNode(can); - { - QMatrix4x4 mat; - mat.translate(-2.0f, 0.0f, -2.0f); - node->setLocalTransform(mat); - } - - // display a copy of the can to the right - node = new QGLSceneNode(canScene); - node->addNode(can); - { - QMatrix4x4 mat; - mat.translate(2.0f, 0.0f, -2.0f); - node->setLocalTransform(mat); - } - //! [0] - - // rotate the whole scene about x-axis so that - // can tops are visible when scene is first displayed - { - QMatrix4x4 mat; - mat.rotate(1.0f, 0.0f, 0.0f, -30.0f); - canScene->setLocalTransform(mat); - } -} - -BuilderView::~BuilderView() -{ - texture->cleanupResources(); - delete canScene; -} - -void BuilderView::initializeGL(QGLPainter *painter) -{ - QGLLightParameters *light0 = new QGLLightParameters(this); - light0->setAmbientColor(Qt::white); - light0->setDiffuseColor(Qt::white); - light0->setDirection(QVector3D(0.0f, 0.2f, 2.0f)); - painter->setMainLight(light0); - QGLLightModel *model = new QGLLightModel(this); - model->setAmbientSceneColor(Qt::white); - painter->setLightModel(model); -} - -//! [1] -void BuilderView::paintGL(QGLPainter *painter) -{ - canScene->draw(painter); -} -//! [1] - -QGLSceneNode *BuilderView::buildGeometry() -{ - //! [2] - QGLBuilder builder; - QGLSceneNode *root = builder.sceneNode(); - - QGLMaterial *mat = new QGLMaterial; - mat->setAmbientColor(Qt::lightGray); - mat->setDiffuseColor(Qt::lightGray); - QUrl url; - url.setPath(QLatin1String(":/images/qt-soup.png")); - url.setScheme(QLatin1String("file")); - mat->setTextureUrl(url); - texture = mat->texture(); - int canMat = root->palette()->addMaterial(mat); - root->setMaterialIndex(canMat); - root->setEffect(QGL::LitMaterial); - //! [2] - - // size data for can - const float canRadius = 1.0f; - const float canHeight = 2.5f; - const int numSlices = 32; - - QGeometryData canRim; - QVector3D canExtrudeVec(0.0f, 0.0f, -canHeight); - - // do the math for the defining points - for (int i = 0; i < numSlices; ++i) - { - float angle = (float(i) * 2.0 * M_PI) / numSlices; - canRim.appendVertex(QVector3D(canRadius * cosf(angle), - canRadius * sinf(angle), - canHeight / 2.0f)); - } - - //! [3] - // create the flat top lid of the can - builder.newSection(); - builder.currentNode()->setObjectName(QLatin1String("CanTop")); - QGeometryData top; - top.appendVertex(canRim.center()); - top.appendVertexArray(canRim.vertices()); - builder.addTriangulatedFace(top); - - // create the sides of the can - builder.newSection(); - builder.currentNode()->setObjectName(QLatin1String("CanSides")); - builder.currentNode()->setMaterialIndex(canMat); - builder.currentNode()->setEffect(QGL::LitModulateTexture2D); - QGeometryData canTop = canRim; - canTop.detach(); - canTop.appendVertex(canTop.vertex(0)); // doubled vert for texture seam - canTop.generateTextureCoordinates(); // generate x texture coords - QGeometryData canBase = canTop.translated(canExtrudeVec); // base has tex.y == 0 - for (int i = 0; i < canTop.count(); ++i) - canTop.texCoord(i).setY(1.0); // top has tex.y == 1 - builder.addQuadsInterleaved(canTop, canBase); - - // create the flat bottom lid of the can - builder.newSection(); - builder.currentNode()->setObjectName(QLatin1String("CanBottom")); - builder.currentNode()->setEffect(QGL::LitMaterial); - QGeometryData rimReversed = canRim.translated(canExtrudeVec).reversed(); - QGeometryData canBottom; - canBottom.appendVertex(rimReversed.center()); - canBottom.appendVertexArray(rimReversed.vertices()); - builder.addTriangulatedFace(canBottom); - - return builder.finalizedSceneNode(); - //! [3] -} diff --git a/examples/qt3d/builder/builder.h b/examples/qt3d/builder/builder.h deleted file mode 100644 index b0aa45248..000000000 --- a/examples/qt3d/builder/builder.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 BUILDER_H -#define BUILDER_H - -#include "qglview.h" - -QT_BEGIN_NAMESPACE -class QGLSceneNode; -class QGLBuilder; -QT_END_NAMESPACE - -class BuilderView : public QGLView -{ - Q_OBJECT -public: - BuilderView(QWindow *parent = 0); - ~BuilderView(); - -protected: - void initializeGL(QGLPainter *painter); - void paintGL(QGLPainter *painter); - -private: - QGLSceneNode *buildGeometry(); - - QGLSceneNode *canScene; - QGLTexture2D *texture; -}; - -#endif diff --git a/examples/qt3d/builder/builder.pro b/examples/qt3d/builder/builder.pro deleted file mode 100644 index 277b5ed57..000000000 --- a/examples/qt3d/builder/builder.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = builder - -QT += 3d - -include(../../../pkg.pri) - -SOURCES = builder.cpp \ - main.cpp -HEADERS = builder.h -RESOURCES += builder.qrc - -OTHER_FILES += \ - builder.rc - -RC_FILE = builder.rc diff --git a/examples/qt3d/builder/builder.qrc b/examples/qt3d/builder/builder.qrc deleted file mode 100644 index 8eefbaf1d..000000000 --- a/examples/qt3d/builder/builder.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/images" > - <file>qt-soup.png</file> - </qresource> -</RCC> diff --git a/examples/qt3d/builder/builder.rc b/examples/qt3d/builder/builder.rc deleted file mode 100644 index b40ecdc12..000000000 --- a/examples/qt3d/builder/builder.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "qt3d.ico" diff --git a/examples/qt3d/builder/main.cpp b/examples/qt3d/builder/main.cpp deleted file mode 100644 index e857d5b6d..000000000 --- a/examples/qt3d/builder/main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "builder.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - BuilderView view; - - if (view.stereoType() != QGLView::RedCyanAnaglyph) - view.camera()->setEyeSeparation(0.3f); - QStringList args = QCoreApplication::arguments(); - int w_pos = args.indexOf("-width"); - int h_pos = args.indexOf("-height"); - if (w_pos >= 0 && h_pos >= 0) - { - bool ok = true; - int w = args.at(w_pos + 1).toInt(&ok); - if (!ok) - { - qWarning() << "Could not parse width argument:" << args; - return 1; - } - int h = args.at(h_pos + 1).toInt(&ok); - if (!ok) - { - qWarning() << "Could not parse height argument:" << args; - return 1; - } - view.resize(w, h); - } - else - { - view.resize(800, 600); - } - view.show(); - - return app.exec(); -} diff --git a/examples/qt3d/builder/qt-soup.png b/examples/qt3d/builder/qt-soup.png Binary files differdeleted file mode 100644 index 5b264fffa..000000000 --- a/examples/qt3d/builder/qt-soup.png +++ /dev/null diff --git a/examples/qt3d/builder/qt3d.ico b/examples/qt3d/builder/qt3d.ico Binary files differdeleted file mode 100644 index 1d07c43dd..000000000 --- a/examples/qt3d/builder/qt3d.ico +++ /dev/null |