diff options
Diffstat (limited to 'examples/qt3d/geometry')
-rw-r--r-- | examples/qt3d/geometry/EarthFlat_512x512.jpg | bin | 183612 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/geometry/bullseye.png | bin | 2737 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/geometry/geometry.cpp | 210 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometry.desktop | 7 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometry.h | 58 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometry.pro | 22 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometry.qrc | 6 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometry.rc | 1 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometryview.cpp | 122 | ||||
-rw-r--r-- | examples/qt3d/geometry/geometryview.h | 88 | ||||
-rw-r--r-- | examples/qt3d/geometry/main.cpp | 62 | ||||
-rw-r--r-- | examples/qt3d/geometry/qt3d.ico | bin | 67646 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/geometry/qt3d.png | bin | 3677 -> 0 bytes | |||
-rw-r--r-- | examples/qt3d/geometry/quadplane.cpp | 92 | ||||
-rw-r--r-- | examples/qt3d/geometry/quadplane.h | 57 |
15 files changed, 0 insertions, 725 deletions
diff --git a/examples/qt3d/geometry/EarthFlat_512x512.jpg b/examples/qt3d/geometry/EarthFlat_512x512.jpg Binary files differdeleted file mode 100644 index 28864977..00000000 --- a/examples/qt3d/geometry/EarthFlat_512x512.jpg +++ /dev/null diff --git a/examples/qt3d/geometry/bullseye.png b/examples/qt3d/geometry/bullseye.png Binary files differdeleted file mode 100644 index e67cf703..00000000 --- a/examples/qt3d/geometry/bullseye.png +++ /dev/null diff --git a/examples/qt3d/geometry/geometry.cpp b/examples/qt3d/geometry/geometry.cpp deleted file mode 100644 index 870d68d5..00000000 --- a/examples/qt3d/geometry/geometry.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 "geometry.h" -#include "qgltexture2d.h" -#include "qglmaterialcollection.h" -#include "qtriangle3d.h" - -#include <QImage> -#include <QPainter> - -// icosahedron is defined by phi, derived from the golden section -// http://en.wikipedia.org/wiki/Icosahedron#Cartesian_coordinates -const qreal phi = 1.618033988749894848f; - -Geometry::Geometry(QObject *parent, QGLMaterialCollection *materials) - : QGLSceneNode(parent) -{ - setPalette(materials); - - float ico[12][3] = { - { 0.0f, 1.0f, phi }, // A - 0 - { 0.0f, 1.0f, -phi }, // B - 1 - { 0.0f, -1.0f, phi }, // C - 2 - { 0.0f, -1.0f, -phi }, // D - 3 - { 1.0f, phi, 0.0f }, // E - 4 - { 1.0f, -phi, 0.0f }, // F - 5 - { -1.0f, phi, 0.0f }, // G - 6 - { -1.0f, -phi, 0.0f }, // H - 7 - { phi, 0.0f, 1.0f }, // I - 8 - { phi, 0.0f, -1.0f }, // J - 9 - { -phi, 0.0f, 1.0f }, // K - 10 - { -phi, 0.0f, -1.0f } // L - 11 - }; - - int face[20][3] = { - { 4, 0, 8 }, // E-A-I - { 6, 0, 4 }, // G-A-E - { 6, 10, 0 }, // G-K-A - { 11, 10, 6 }, // L-K-G - { 0, 2, 8 }, // A-C-I - { 10, 2, 0 }, // K-C-A - { 10, 7, 2 }, // K-H-C - { 11, 7, 10 }, // L-H-K - { 2, 5, 8 }, // C-F-I - { 7, 5, 2 }, // H-F-C - { 7, 3, 5 }, // H-D-F - { 11, 3, 7 }, // L-D-H - { 5, 9, 8 }, // F-J-I - { 3, 9, 5 }, // D-J-F - { 3, 1, 9 }, // D-B-J - { 11, 1, 3 }, // L-B-D - { 9, 4, 8 }, // J-E-I - { 1, 4, 9 }, // B-E-J - { 1, 6, 4 }, // B-G-E - { 11, 6, 1 } // L-G-B - }; - - const float u0 = 0.0f; - const float u1 = 0.173205081f; - const float u2 = 0.346410162f; - const float u3 = 0.519615242f; - const float u4 = 0.692820323f; - const float u5 = 0.866025402f; - const float v0 = 0.0f; - const float v1 = 0.111111111f; - const float v2 = 0.222222222f; - const float v3 = 0.333333333f; - const float v4 = 0.444444444f; - const float v5 = 0.555555555f; - const float v6 = 0.666666666f; - const float v7 = 0.777777777f; - const float v8 = 0.888888888f; - const float v9 = 1.0f; - - float tex[20][3][2] = { - { { u0, v1 }, { u1, v2 }, { u1, v0 } }, // E-A-I - { { u0, v3 }, { u1, v2 }, { u0, v1 } }, // G-A-E - { { u0, v3 }, { u1, v4 }, { u1, v2 } }, // G-K-A - { { u0, v5 }, { u1, v4 }, { u0, v3 } }, // L-K-G - { { u1, v2 }, { u2, v3 }, { u2, v1 } }, // A-C-I - { { u1, v4 }, { u2, v3 }, { u1, v2 } }, // K-C-A - { { u1, v4 }, { u2, v5 }, { u2, v3 } }, // K-H-C - { { u1, v6 }, { u2, v5 }, { u1, v4 } }, // L-H-K - { { u2, v3 }, { u3, v4 }, { u3, v2 } }, // C-F-I - { { u2, v5 }, { u3, v4 }, { u2, v3 } }, // H-F-C - { { u2, v5 }, { u3, v6 }, { u3, v4 } }, // H-D-F - { { u2, v7 }, { u3, v6 }, { u2, v5 } }, // L-D-H - { { u3, v4 }, { u4, v5 }, { u4, v3 } }, // F-J-I - { { u3, v6 }, { u4, v5 }, { u3, v4 } }, // D-J-F - { { u3, v6 }, { u4, v7 }, { u4, v5 } }, // D-B-J - { { u3, v8 }, { u4, v7 }, { u3, v6 } }, // L-B-D - { { u4, v5 }, { u5, v6 }, { u5, v4 } }, // J-E-I - { { u4, v7 }, { u5, v6 }, { u4, v5 } }, // B-E-J - { { u4, v7 }, { u5, v8 }, { u5, v6 } }, // B-G-E - { { u4, v9 }, { u5, v8 }, { u4, v7 } } // L-G-B - }; - -#ifdef Q_OS_SYMBIAN - const int imgSize = 256; - const int txtSize = 6; -#else - const int imgSize = 1024; - const int txtSize = 36; -#endif - - QImage uv(imgSize, imgSize, QImage::Format_ARGB32); - uv.fill(qRgba(196, 196, 196, 196)); - QPainter painter; - painter.begin(&uv); - painter.setRenderHint(QPainter::Antialiasing); - QPen pen = painter.pen(); - pen.setWidth(2.0); - painter.setPen(pen); - QFont font = painter.font(); - font.setPointSize(txtSize); - painter.setFont(font); - QFontMetrics metrics = painter.fontMetrics(); - - QGLBuilder b; - b.newSection(); - b.currentNode()->setEffect(QGL::LitDecalTexture2D); - for (int ix = 0; ix < 20; ++ix) - { - QVector3D v0(ico[face[ix][0]][0], ico[face[ix][0]][1], ico[face[ix][0]][2]); - QVector3D v1(ico[face[ix][1]][0], ico[face[ix][1]][1], ico[face[ix][1]][2]); - QVector3D v2(ico[face[ix][2]][0], ico[face[ix][2]][1], ico[face[ix][2]][2]); - - QVector2D t0(tex[ix][0][0], tex[ix][0][1]); - QVector2D t1(tex[ix][1][0], tex[ix][1][1]); - QVector2D t2(tex[ix][2][0], tex[ix][2][1]); - - // scale up and flip to draw the texture - QVector2D tv0 = t0 * static_cast<float>(imgSize); - QVector2D tv1 = t1 * static_cast<float>(imgSize); - QVector2D tv2 = t2 * static_cast<float>(imgSize); - - painter.setPen(QColor("darkblue")); - painter.drawLine(tv0.toPointF(), tv1.toPointF()); - painter.drawLine(tv1.toPointF(), tv2.toPointF()); - painter.drawLine(tv2.toPointF(), tv0.toPointF()); - QTriangle3D tri(tv0, tv1, tv2); - QVector3D cen = tri.center(); - QString n = QString::number(ix+1); - - painter.setPen(QColor("darkgreen")); - painter.drawText(QPointF(cen.x() - metrics.width(n) / 2.0, cen.y() + 3.0), n); - - // Qt's coordinate system is upside down. I'm ok with that. - t0.setY(1.0f - t0.y()); - t1.setY(1.0f - t1.y()); - t2.setY(1.0f - t2.y()); - - QGeometryData op; - op.appendVertex(v0, v1, v2); - op.appendTexCoord(t0, t1, t2); - b.addTriangles(op); - } - - painter.end(); - - QGLMaterial *mat = new QGLMaterial; - mat->setAmbientColor(QColor(32, 64, 196)); - mat->setDiffuseColor(QColor(32, 32, 32)); - - QGLTexture2D *texture = new QGLTexture2D(mat); - texture->setImage(uv); - mat->setTexture(texture); - - setMaterial(mat); - QGLSceneNode *n = b.finalizedSceneNode(); - addNode(n); -} diff --git a/examples/qt3d/geometry/geometry.desktop b/examples/qt3d/geometry/geometry.desktop deleted file mode 100644 index 62c79a41..00000000 --- a/examples/qt3d/geometry/geometry.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Type=Application -Name=D20 Qt3D -Icon=/usr/share/icons/hicolor/80x80/apps/qt3d.png -Exec=/usr/bin/invoker --type=e -s /usr/bin/geometry -fullscreen -OnlyShowIn=X-MeeGo; -X-MeeGo-Logical-Id=qtn_comm_appname_geometry diff --git a/examples/qt3d/geometry/geometry.h b/examples/qt3d/geometry/geometry.h deleted file mode 100644 index ff100449..00000000 --- a/examples/qt3d/geometry/geometry.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 GEOMETRY_H -#define GEOMETRY_H - -#include "qglbuilder.h" - -#include <QImage> - -QT_BEGIN_NAMESPACE -class QGLTexture2D; -QT_END_NAMESPACE - -class Geometry : public QGLSceneNode -{ -public: - Geometry(QObject *parent = 0, QGLMaterialCollection *materials = 0); -}; - -#endif // GEOMETRY_H diff --git a/examples/qt3d/geometry/geometry.pro b/examples/qt3d/geometry/geometry.pro deleted file mode 100644 index f2a8fbde..00000000 --- a/examples/qt3d/geometry/geometry.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = app -TARGET = geometry -CONFIG += qt warn_on - -CONFIG += qt3d_deploy_pkg -include(../../../pkg.pri) - -SOURCES = geometryview.cpp \ - main.cpp \ - geometry.cpp \ - quadplane.cpp -HEADERS = geometryview.h \ - geometry.h \ - quadplane.h -RESOURCES = geometry.qrc - -OTHER_FILES += \ - geometry.rc \ - geometry.desktop - -RC_FILE = geometry.rc - diff --git a/examples/qt3d/geometry/geometry.qrc b/examples/qt3d/geometry/geometry.qrc deleted file mode 100644 index 4599a46a..00000000 --- a/examples/qt3d/geometry/geometry.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/" > - <file>bullseye.png</file> - <file>EarthFlat_512x512.jpg</file> - </qresource> -</RCC> diff --git a/examples/qt3d/geometry/geometry.rc b/examples/qt3d/geometry/geometry.rc deleted file mode 100644 index b40ecdc1..00000000 --- a/examples/qt3d/geometry/geometry.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "qt3d.ico" diff --git a/examples/qt3d/geometry/geometryview.cpp b/examples/qt3d/geometry/geometryview.cpp deleted file mode 100644 index 762e56fc..00000000 --- a/examples/qt3d/geometry/geometryview.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 "geometryview.h" -#include "qray3d.h" - -#include <QImage> -#include <QPainter> -#include <QDir> -#include <QTimer> -#include <QWheelEvent> - -#include <math.h> - -#include "geometry.h" -#include "quadplane.h" -#include "qplane3d.h" -#include "qglmaterialcollection.h" -#include "qgraphicsscale3d.h" - -GeometryView::GeometryView(QWidget *parent) - : QGLView(parent) - , timer(new QTimer(this)) -{ - lp = new QGLLightParameters(this); - lp->setPosition(QVector3D(-3.0, 1.0, 15.0)); - lp->setSpotAngle(15.0); - lp->setSpotExponent(24); - lp->setSpotDirection(QVector3D(0.0, -1.0, -2.0)); - - palette = new QGLMaterialCollection(this); - - // first set up the geometry - an icosahedron - // this one handles all its own colors and textures - icosahedron = new Geometry(this, palette); - - // now a generic flat floor plane which will be painted grey - // and textured the same as the icosahedron - floor = new QuadPlane(this); - floor->setPalette(palette); - QGLMaterial *parms = new QGLMaterial; - parms->setAmbientColor(Qt::darkGray); - parms->setDiffuseColor(Qt::gray); - int m = palette->addMaterial(parms); - QGLTexture2D *tex = icosahedron->material()->texture(); - parms->setTexture(tex); - floor->setMaterialIndex(m); - floor->setPosition(QVector3D(0, 0, -5)); - QGraphicsScale3D *scale = new QGraphicsScale3D(floor); - scale->setScale(QVector3D(0.2, 0.2, 0.1)); - floor->addTransform(scale); - - mdl = new QGLLightModel(this); - mdl->setAmbientSceneColor(QColor(196,196,196)); -} - -GeometryView::~GeometryView() -{ - delete icosahedron; - delete floor; - delete timer; -} - -void GeometryView::initializeGL(QGLPainter *painter) -{ - painter->setLightModel(mdl); - - painter->setMainLight(lp); - - connect(timer, SIGNAL(timeout()), this, SLOT(rotate())); - timer->start(25); -} - -void GeometryView::paintGL(QGLPainter *painter) -{ - floor->draw(painter); - painter->modelViewMatrix().rotate(angle, 0.10f, 1.0f, 0.0f); - icosahedron->draw(painter); -} - -void GeometryView::rotate() -{ - angle = (angle + 2) % 360; - updateGL(); -} diff --git a/examples/qt3d/geometry/geometryview.h b/examples/qt3d/geometry/geometryview.h deleted file mode 100644 index e6cc33e4..00000000 --- a/examples/qt3d/geometry/geometryview.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 GEOMETRYVIEW_H -#define GEOMETRYVIEW_H - -#include "qglview.h" -#include "qgltexture2d.h" - -QT_BEGIN_NAMESPACE -class QTimer; -class QGLLightParameters; -class QGLMaterial; -class QGLLightModel; -class QGLMaterialCollection; -class QWheelEvent; -QT_END_NAMESPACE - -class QuadPlane; -class Geometry; - -class GeometryView : public QGLView -{ - Q_OBJECT -public: - GeometryView(QWidget *parent = 0); - ~GeometryView(); - -protected: - void initializeGL(QGLPainter *painter); - void paintGL(QGLPainter *painter); - -private slots: - void rotate(); - -private: - void makeTexture(); - - QGLTexture2D texture; - Geometry *icosahedron; - QuadPlane *floor; - QTimer *timer; - int angle; - QGLLightParameters *lp; - QGLMaterialCollection *palette; - QGLMaterial *mat1; - QGLMaterial *mat2; - QGLLightModel *mdl; -}; - -#endif // GEOMETRYVIEW_H diff --git a/examples/qt3d/geometry/main.cpp b/examples/qt3d/geometry/main.cpp deleted file mode 100644 index b2f2025f..00000000 --- a/examples/qt3d/geometry/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 <QApplication> -#include "geometryview.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - GeometryView view; -#ifdef Q_OS_SYMBIAN - view.setAttribute(Qt::WA_LockLandscapeOrientation, true); - view.showFullScreen(); -#else - if (view.stereoType() != QGLView::RedCyanAnaglyph) - view.camera()->setEyeSeparation(0.3f); - if (QApplication::arguments().contains(QLatin1String("-maximize"))) - view.showMaximized(); - else if (QApplication::arguments().contains(QLatin1String("-fullscreen"))) - view.showFullScreen(); - else - view.show(); -#endif - return app.exec(); -} diff --git a/examples/qt3d/geometry/qt3d.ico b/examples/qt3d/geometry/qt3d.ico Binary files differdeleted file mode 100644 index e6442baf..00000000 --- a/examples/qt3d/geometry/qt3d.ico +++ /dev/null diff --git a/examples/qt3d/geometry/qt3d.png b/examples/qt3d/geometry/qt3d.png Binary files differdeleted file mode 100644 index 21ec0176..00000000 --- a/examples/qt3d/geometry/qt3d.png +++ /dev/null diff --git a/examples/qt3d/geometry/quadplane.cpp b/examples/qt3d/geometry/quadplane.cpp deleted file mode 100644 index 3387002b..00000000 --- a/examples/qt3d/geometry/quadplane.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 "quadplane.h" - -/*! - \class QuadPlane - \brief The QuadPlane class holds a 3D model of a large flat plane. - When drawing a large flat plane, such as a wall or a floor, it is desirable - to decompose it into smaller units to make the shading effects look correct. - This class composes a plane out of a configurable number of quads. -*/ - -/*! - Construct a new QuadPlane with \a size, subdivided \a level times. By default - the plane is 100.0f x 100.0f, and is subdivided 3 times - that is into an - 8 x 8 grid. - - It is centered on the origin, and lies in the z = 0 plane. -*/ -QuadPlane::QuadPlane(QObject *parent, QSizeF size, int level) - : QGLSceneNode(parent) -{ - setObjectName(QLatin1String("QuadPlane")); - if (level > 8) - level = 8; - if (level < 1) - level = 1; - int divisions = 1; - for ( ; level--; divisions *= 2) {} // integer 2**n - QSizeF div = size / float(divisions); - QSizeF half = size / 2.0f; - QGLBuilder builder; - QGeometryData zip; - QGeometryData zip2; - for (int yy = 0; yy <= divisions; ++yy) - { - qreal y = half.height() - float(yy) * div.height(); - qreal texY = float(yy) / divisions; - for (int xx = 0; xx <= divisions; ++xx) - { - qreal x = half.width() - float(xx) * div.width(); - qreal texX = float(xx) / divisions; - zip.appendVertex(QVector3D(x, y, 0)); - zip.appendTexCoord(QVector2D(1.0f - texX, 1.0f - texY)); - } - if (yy > 0) - builder.addQuadsInterleaved(zip, zip2); - zip2 = zip; - zip2.detach(); - zip.clear(); - } - QGLSceneNode *n = builder.finalizedSceneNode(); - addNode(n); -} diff --git a/examples/qt3d/geometry/quadplane.h b/examples/qt3d/geometry/quadplane.h deleted file mode 100644 index e95d1907..00000000 --- a/examples/qt3d/geometry/quadplane.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D 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 Nokia Corporation 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 QUADPLANE_H -#define QUADPLANE_H - -#include "qglbuilder.h" - -#include <QSizeF> - -class QPlane3D; - -class QuadPlane : public QGLSceneNode -{ -public: - QuadPlane(QObject *parent = 0, - QSizeF size = QSizeF(100.0f, 100.0f), int level = 3); -}; - -#endif // QUADPLANE_H |