diff options
Diffstat (limited to 'examples/qt3d/tutorials')
52 files changed, 2735 insertions, 0 deletions
diff --git a/examples/qt3d/tutorials/converting-rawgl/converting-rawgl.pro b/examples/qt3d/tutorials/converting-rawgl/converting-rawgl.pro new file mode 100644 index 000000000..8263b9a7d --- /dev/null +++ b/examples/qt3d/tutorials/converting-rawgl/converting-rawgl.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = converting-rawgl +CONFIG += qt warn_on +QT += opengl +VPATH += ../converting +SOURCES = converting-rawgl.cpp diff --git a/examples/qt3d/tutorials/converting/converting-rawgl.cpp b/examples/qt3d/tutorials/converting/converting-rawgl.cpp new file mode 100644 index 000000000..e65abd3a9 --- /dev/null +++ b/examples/qt3d/tutorials/converting/converting-rawgl.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +//! [class-defn] +#include <QApplication> +#include <QtOpenGL/qgl.h> + +class TutorialWidget : public QGLWidget +{ + Q_OBJECT +public: + TutorialWidget(QWidget *parent=0) : QGLWidget(parent) {} + +protected: + void resizeGL(int width, int height); + void paintGL(); +#if defined(QT_OPENGL_ES_2) + void initializeGL(); + +private: + GLuint program; + GLuint vertexAttr; + GLuint matrixUniform; + GLuint colorUniform; +#endif +}; +//! [class-defn] + +//! [set-viewport] +void TutorialWidget::resizeGL(int width, int height) +{ + glViewport(0, 0, width, height); +} +//! [set-viewport] + +#if !defined(QT_OPENGL_ES_2) + +//! [clear-window] +void TutorialWidget::paintGL() +{ + QColor clearColor(palette().color(backgroundRole())); + glClearColor(clearColor.redF(), clearColor.greenF(), + clearColor.blueF(), clearColor.alphaF()); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +//! [clear-window] + +//! [set-matrices] + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width(), height(), 0, -1.0f, 1.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +//! [set-matrices] + +//! [draw] + QColor color(170, 202, 0, 255); + glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF()); + + static GLfloat vertices[] = { + 60.0f, 10.0f, 0.0f, + 110.0f, 110.0f, 0.0f, + 10.0f, 110.0f, 0.0f + }; + + glVertexPointer(3, GL_FLOAT, 0, vertices); + glEnableClientState(GL_VERTEX_ARRAY); + glDrawArrays(GL_TRIANGLES, 0, 3); + glDisableClientState(GL_VERTEX_ARRAY); +//! [draw] +} + +#else // QT_OPENGL_ES_2 + +void TutorialWidget::initializeGL() +{ + GLuint vshader = glCreateShader(GL_VERTEX_SHADER); + const char *vsrc[1] = { + "attribute highp vec4 vertex;\n" + "uniform mediump mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + "}\n" + }; + glShaderSource(vshader, 1, vsrc, 0); + glCompileShader(vshader); + + GLuint fshader = glCreateShader(GL_FRAGMENT_SHADER); + const char *fsrc[1] = { + "uniform mediump vec4 color;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = color;\n" + "}\n" + }; + glShaderSource(fshader, 1, fsrc, 0); + glCompileShader(fshader); + + program = glCreateProgram(); + glAttachShader(program, vshader); + glAttachShader(program, fshader); + glLinkProgram(program); + + vertexAttr = glGetAttribLocation(program, "vertex"); + matrixUniform = glGetUniformLocation(program, "matrix"); + colorUniform = glGetUniformLocation(program, "color"); + + glUseProgram(program); +} + +void TutorialWidget::paintGL() +{ + QColor clearColor(palette().color(backgroundRole())); + glClearColor(clearColor.redF(), clearColor.greenF(), + clearColor.blueF(), clearColor.alphaF()); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + GLfloat width = this->width(); + GLfloat height = this->height(); + GLfloat left = 0.0f; + GLfloat right = width; + GLfloat top = 0.0f; + GLfloat bottom = height; + GLfloat nearPlane = -1.0f; + GLfloat farPlane = 1.0f; + GLfloat clip = farPlane - nearPlane; + GLfloat mat[4][4]; + mat[0][0] = 2.0f / width; + mat[1][0] = 0.0f; + mat[2][0] = 0.0f; + mat[3][0] = -(left + right) / width; + mat[0][1] = 0.0f; + mat[1][1] = 2.0f / -height; + mat[2][1] = 0.0f; + mat[3][1] = -(top + bottom) / -height; + mat[0][2] = 0.0f; + mat[1][2] = 0.0f; + mat[2][2] = -2.0f / clip; + mat[3][2] = -(nearPlane + farPlane) / clip; + mat[0][3] = 0.0f; + mat[1][3] = 0.0f; + mat[2][3] = 0.0f; + mat[3][3] = 1.0f; + glUniformMatrix4fv(matrixUniform, 1, GL_FALSE, mat[0]); + + QColor color(170, 202, 0, 255); + glUniform4f(colorUniform, color.redF(), color.greenF(), color.blueF(), color.alphaF()); + + static GLfloat vertices[] = { + 60.0f, 10.0f, 0.0f, + 110.0f, 110.0f, 0.0f, + 10.0f, 110.0f, 0.0f + }; + + glVertexAttribPointer(vertexAttr, 3, GL_FLOAT, GL_FALSE, 0, vertices); + glEnableVertexAttribArray(vertexAttr); + glDrawArrays(GL_TRIANGLES, 0, 3); + glDisableVertexAttribArray(vertexAttr); +} + +#endif // QT_OPENGL_ES_2 + +//! [main] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + TutorialWidget widget; + widget.show(); + return app.exec(); +} +//! [main] + +#include "converting-rawgl.moc" diff --git a/examples/qt3d/tutorials/converting/converting.cpp b/examples/qt3d/tutorials/converting/converting.cpp new file mode 100644 index 000000000..51c47ffa8 --- /dev/null +++ b/examples/qt3d/tutorials/converting/converting.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +//! [includes] +#include <QApplication> +#include <QtOpenGL/qgl.h> +#include "qglpainter.h" +//! [includes] + +//! [class-defn] +class TutorialWidget : public QGLWidget +{ + Q_OBJECT +public: + TutorialWidget(QWidget *parent=0) : QGLWidget(parent) {} + +protected: + void paintGL(); +}; +//! [class-defn] + +//! [paintGL] +//! [clear-window] +void TutorialWidget::paintGL() +{ + QGLPainter painter(this); + + painter.setClearColor(palette().color(backgroundRole())); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +//! [clear-window] + +//! [set-matrices] + QMatrix4x4 projm; + projm.ortho(rect()); + painter.projectionMatrix() = projm; + + painter.modelViewMatrix().setToIdentity(); +//! [set-matrices] + +//! [draw-all] +//! [set-effect] + painter.setStandardEffect(QGL::FlatColor); + painter.setColor(QColor(170, 202, 0, 255)); +//! [set-effect] + +//! [create-vertex-array] + QVector3DArray vertices; + vertices.append(60.0f, 10.0f, 0.0f); + vertices.append(110.0f, 110.0f, 0.0f); + vertices.append(10.0f, 110.0f, 0.0f); +//! [create-vertex-array] + +//! [draw] + painter.clearAttributes(); + painter.setVertexAttribute(QGL::Position, vertices); + painter.draw(QGL::Triangles, 3); +//! [draw] +//! [draw-all] +} +//! [paintGL] + +//! [main] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + TutorialWidget widget; + widget.show(); + return app.exec(); +} +//! [main] + +#include "converting.moc" diff --git a/examples/qt3d/tutorials/converting/converting.pro b/examples/qt3d/tutorials/converting/converting.pro new file mode 100644 index 000000000..b4febdaa5 --- /dev/null +++ b/examples/qt3d/tutorials/converting/converting.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +TARGET = converting +CONFIG += qt warn_on +QT += opengl +SOURCES = converting.cpp +LIBS += -L../../../lib -L../../../bin + +include(../../../src/threed/threed_dep.pri) diff --git a/examples/qt3d/tutorials/cube1/cube1.pro b/examples/qt3d/tutorials/cube1/cube1.pro new file mode 100644 index 000000000..51df0efe0 --- /dev/null +++ b/examples/qt3d/tutorials/cube1/cube1.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +TARGET = cube1 +CONFIG += qt warn_on qt3d +SOURCES = cubeview.cpp main.cpp +HEADERS = cubeview.h diff --git a/examples/qt3d/tutorials/cube1/cubeview.cpp b/examples/qt3d/tutorials/cube1/cubeview.cpp new file mode 100644 index 000000000..51e074f62 --- /dev/null +++ b/examples/qt3d/tutorials/cube1/cubeview.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" +#include "qglbuilder.h" +#include "qglcube.h" + +//! [1] +CubeView::CubeView(QWidget *parent) + : QGLView(parent) +{ + QGLBuilder builder; + builder << QGL::Faceted; + builder << QGLCube(); + + cube = builder.finalizedSceneNode(); +} +//! [1] + +CubeView::~CubeView() +{ + delete cube; +} + +//! [2] +void CubeView::paintGL(QGLPainter *painter) +{ + cube->draw(painter); +} +//! [2] diff --git a/examples/qt3d/tutorials/cube1/cubeview.h b/examples/qt3d/tutorials/cube1/cubeview.h new file mode 100644 index 000000000..04238f58d --- /dev/null +++ b/examples/qt3d/tutorials/cube1/cubeview.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 CUBEVIEW_H +#define CUBEVIEW_H + +#include "qglview.h" + +class QGLSceneNode; + +//! [1] +class CubeView : public QGLView +{ + Q_OBJECT +public: + CubeView(QWidget *parent = 0); + ~CubeView(); + +protected: + void paintGL(QGLPainter *painter); + +private: + QGLSceneNode *cube; +}; +//! [1] + +#endif diff --git a/examples/qt3d/tutorials/cube1/main.cpp b/examples/qt3d/tutorials/cube1/main.cpp new file mode 100644 index 000000000..28fc9bb15 --- /dev/null +++ b/examples/qt3d/tutorials/cube1/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CubeView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/cube2/cube2.pro b/examples/qt3d/tutorials/cube2/cube2.pro new file mode 100644 index 000000000..3bf258831 --- /dev/null +++ b/examples/qt3d/tutorials/cube2/cube2.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +TARGET = cube2 +CONFIG += qt warn_on qt3d +SOURCES = cubeview.cpp main.cpp +HEADERS = cubeview.h diff --git a/examples/qt3d/tutorials/cube2/cubeview.cpp b/examples/qt3d/tutorials/cube2/cubeview.cpp new file mode 100644 index 000000000..1dca459a8 --- /dev/null +++ b/examples/qt3d/tutorials/cube2/cubeview.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" +#include "qglbuilder.h" +#include "qglcube.h" + +CubeView::CubeView(QWidget *parent) + : QGLView(parent) +{ + QGLBuilder builder; + builder << QGL::Faceted; + builder << QGLCube(); + + cube = builder.finalizedSceneNode(); +} + +CubeView::~CubeView() +{ + delete cube; +} + +//! [2] +void CubeView::paintGL(QGLPainter *painter) +{ + painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f); + cube->draw(painter); +} +//! [2] diff --git a/examples/qt3d/tutorials/cube2/cubeview.h b/examples/qt3d/tutorials/cube2/cubeview.h new file mode 100644 index 000000000..04238f58d --- /dev/null +++ b/examples/qt3d/tutorials/cube2/cubeview.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 CUBEVIEW_H +#define CUBEVIEW_H + +#include "qglview.h" + +class QGLSceneNode; + +//! [1] +class CubeView : public QGLView +{ + Q_OBJECT +public: + CubeView(QWidget *parent = 0); + ~CubeView(); + +protected: + void paintGL(QGLPainter *painter); + +private: + QGLSceneNode *cube; +}; +//! [1] + +#endif diff --git a/examples/qt3d/tutorials/cube2/main.cpp b/examples/qt3d/tutorials/cube2/main.cpp new file mode 100644 index 000000000..28fc9bb15 --- /dev/null +++ b/examples/qt3d/tutorials/cube2/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CubeView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/cube3/cube3.pro b/examples/qt3d/tutorials/cube3/cube3.pro new file mode 100644 index 000000000..70b049fe2 --- /dev/null +++ b/examples/qt3d/tutorials/cube3/cube3.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +TARGET = cube3 +CONFIG += qt warn_on qt3d +SOURCES = cubeview.cpp main.cpp +HEADERS = cubeview.h diff --git a/examples/qt3d/tutorials/cube3/cubeview.cpp b/examples/qt3d/tutorials/cube3/cubeview.cpp new file mode 100644 index 000000000..80c3e0f1a --- /dev/null +++ b/examples/qt3d/tutorials/cube3/cubeview.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" +#include "qglbuilder.h" +#include "qglcube.h" + +CubeView::CubeView(QWidget *parent) + : QGLView(parent) +{ + QGLBuilder builder; + builder << QGL::Faceted; + builder << QGLCube(); + + cube = builder.finalizedSceneNode(); +} + +CubeView::~CubeView() +{ + delete cube; +} + +//! [2] +void CubeView::paintGL(QGLPainter *painter) +{ + painter->setStandardEffect(QGL::LitMaterial); + painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0)); + + painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f); + cube->draw(painter); +} +//! [2] diff --git a/examples/qt3d/tutorials/cube3/cubeview.h b/examples/qt3d/tutorials/cube3/cubeview.h new file mode 100644 index 000000000..04238f58d --- /dev/null +++ b/examples/qt3d/tutorials/cube3/cubeview.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 CUBEVIEW_H +#define CUBEVIEW_H + +#include "qglview.h" + +class QGLSceneNode; + +//! [1] +class CubeView : public QGLView +{ + Q_OBJECT +public: + CubeView(QWidget *parent = 0); + ~CubeView(); + +protected: + void paintGL(QGLPainter *painter); + +private: + QGLSceneNode *cube; +}; +//! [1] + +#endif diff --git a/examples/qt3d/tutorials/cube3/main.cpp b/examples/qt3d/tutorials/cube3/main.cpp new file mode 100644 index 000000000..28fc9bb15 --- /dev/null +++ b/examples/qt3d/tutorials/cube3/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CubeView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/cube4/cube.qml b/examples/qt3d/tutorials/cube4/cube.qml new file mode 100644 index 000000000..d4ba6d995 --- /dev/null +++ b/examples/qt3d/tutorials/cube4/cube.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +//! [1] +import Qt 4.7 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 + +Viewport { + width: 640; height: 480 + + Cube { + transform: Rotation3D { + angle: 45; axis: Qt.vector3d(1, 1, 1) + } + + effect: Effect { + color: "#aaca00"; + texture: "qtlogo.png" + decal: true + } + } +} +//! [1] diff --git a/examples/qt3d/tutorials/cube4/cube.qrc b/examples/qt3d/tutorials/cube4/cube.qrc new file mode 100644 index 000000000..70f5024d9 --- /dev/null +++ b/examples/qt3d/tutorials/cube4/cube.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>qtlogo.png</file> +</qresource> +</RCC> diff --git a/examples/qt3d/tutorials/cube4/cube4.pro b/examples/qt3d/tutorials/cube4/cube4.pro new file mode 100644 index 000000000..a2f4ba79c --- /dev/null +++ b/examples/qt3d/tutorials/cube4/cube4.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = cube4 +CONFIG += qt warn_on qt3d +SOURCES = cubeview.cpp main.cpp +HEADERS = cubeview.h +RESOURCES = cube.qrc diff --git a/examples/qt3d/tutorials/cube4/cubeview.cpp b/examples/qt3d/tutorials/cube4/cubeview.cpp new file mode 100644 index 000000000..e3045292b --- /dev/null +++ b/examples/qt3d/tutorials/cube4/cubeview.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" +#include "qglbuilder.h" +#include "qglcube.h" + +//! [1] +CubeView::CubeView(QWidget *parent) + : QGLView(parent) +{ +//! [1] + QGLBuilder builder; + builder << QGL::Faceted; + builder << QGLCube(); + + cube = builder.finalizedSceneNode(); + +//! [2] + logo.setImage(QImage(QLatin1String(":/qtlogo.png"))); +} +//! [2] + +CubeView::~CubeView() +{ + delete cube; +} + +//! [3] +void CubeView::paintGL(QGLPainter *painter) +{ + painter->setStandardEffect(QGL::LitDecalTexture2D); + painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0)); + logo.bind(); + + painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f); + cube->draw(painter); +} +//! [3] diff --git a/examples/qt3d/tutorials/cube4/cubeview.h b/examples/qt3d/tutorials/cube4/cubeview.h new file mode 100644 index 000000000..4f00216ca --- /dev/null +++ b/examples/qt3d/tutorials/cube4/cubeview.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 CUBEVIEW_H +#define CUBEVIEW_H + +#include "qglview.h" +#include "qgltexture2d.h" + +class QGLSceneNode; + +//! [1] +class CubeView : public QGLView +{ +//! [1] + Q_OBJECT +public: + CubeView(QWidget *parent = 0); + ~CubeView(); + +protected: + void paintGL(QGLPainter *painter); + +//! [2] +private: + QGLSceneNode *cube; + QGLTexture2D logo; +}; +//! [2] + +#endif diff --git a/examples/qt3d/tutorials/cube4/main.cpp b/examples/qt3d/tutorials/cube4/main.cpp new file mode 100644 index 000000000..28fc9bb15 --- /dev/null +++ b/examples/qt3d/tutorials/cube4/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "cubeview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CubeView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/cube4/qtlogo.png b/examples/qt3d/tutorials/cube4/qtlogo.png Binary files differnew file mode 100644 index 000000000..7d3e97eb3 --- /dev/null +++ b/examples/qt3d/tutorials/cube4/qtlogo.png diff --git a/examples/qt3d/tutorials/penguin/main.cpp b/examples/qt3d/tutorials/penguin/main.cpp new file mode 100644 index 000000000..e5c995db3 --- /dev/null +++ b/examples/qt3d/tutorials/penguin/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ModelView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/penguin/model.qrc b/examples/qt3d/tutorials/penguin/model.qrc new file mode 100644 index 000000000..2c330de09 --- /dev/null +++ b/examples/qt3d/tutorials/penguin/model.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>penguin.3ds</file> + </qresource> +</RCC> diff --git a/examples/qt3d/tutorials/penguin/modelview.cpp b/examples/qt3d/tutorials/penguin/modelview.cpp new file mode 100644 index 000000000..3ba6b7355 --- /dev/null +++ b/examples/qt3d/tutorials/penguin/modelview.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "modelview.h" +#include "qglabstractscene.h" + +ModelView::~ModelView() +{ + delete m_scene; +} + +//! [initialize] +void ModelView::initializeGL(QGLPainter *painter) +{ + Q_UNUSED(painter); + + m_scene = QGLAbstractScene::loadScene(QLatin1String(":/penguin.3ds")); +} +//! [initialize] + +//! [paint] +void ModelView::paintGL(QGLPainter *painter) +{ + QGLSceneNode *o = m_scene->mainNode(); + o->draw(painter); +} +//! [paint] diff --git a/examples/qt3d/tutorials/penguin/modelview.h b/examples/qt3d/tutorials/penguin/modelview.h new file mode 100644 index 000000000..978b185f8 --- /dev/null +++ b/examples/qt3d/tutorials/penguin/modelview.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 MODELVIEW_H +#define MODELVIEW_H + +//! [class-defn] +#include "qglview.h" + +class QGLAbstractScene; +class QGLSceneNode; + +class ModelView : public QGLView +{ + Q_OBJECT +public: + ModelView(QWidget *parent = 0) : QGLView(parent) {} + ~ModelView(); + +protected: + void initializeGL(QGLPainter *painter); + void paintGL(QGLPainter *painter); + +private: + QGLAbstractScene *m_scene; +}; +//! [class-defn] + +#endif diff --git a/examples/qt3d/tutorials/penguin/penguin.3ds b/examples/qt3d/tutorials/penguin/penguin.3ds Binary files differnew file mode 100644 index 000000000..26c09ac07 --- /dev/null +++ b/examples/qt3d/tutorials/penguin/penguin.3ds diff --git a/examples/qt3d/tutorials/penguin/penguin.pro b/examples/qt3d/tutorials/penguin/penguin.pro new file mode 100644 index 000000000..f35c1cd4e --- /dev/null +++ b/examples/qt3d/tutorials/penguin/penguin.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +TARGET = penguin +CONFIG += qt warn_on qt3d +SOURCES = modelview.cpp \ + main.cpp +HEADERS = modelview.h +RESOURCES = model.qrc diff --git a/examples/qt3d/tutorials/penguin_advanced/main.cpp b/examples/qt3d/tutorials/penguin_advanced/main.cpp new file mode 100644 index 000000000..e5c995db3 --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ModelView view; + view.show(); + return app.exec(); +} diff --git a/examples/qt3d/tutorials/penguin_advanced/model_advanced.qrc b/examples/qt3d/tutorials/penguin_advanced/model_advanced.qrc new file mode 100644 index 000000000..2c330de09 --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/model_advanced.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>penguin.3ds</file> + </qresource> +</RCC> diff --git a/examples/qt3d/tutorials/penguin_advanced/modelview.cpp b/examples/qt3d/tutorials/penguin_advanced/modelview.cpp new file mode 100644 index 000000000..a72495331 --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/modelview.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "modelview.h" +#include "qglabstractscene.h" +#include "qglscenenode.h" + +ModelView::ModelView(QWidget *parent) + : QGLView(parent) + , m_scene(0) + , m_main(0) +{ +} + +//! [initialize] +void ModelView::initializeGL(QGLPainter *painter) +{ + Q_UNUSED(painter); + camera()->setEye(QVector3D(0.0f, 2.0f, 25.0f)); + + m_scene = QGLAbstractScene::loadScene(QLatin1String(":/penguin.3ds")); + if (m_scene) + m_main = m_scene->mainNode(); + + QQuaternion xt = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f); + QQuaternion yt = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 30.0f); + m_pose = yt * xt; +} +//! [initialize] + +//! [paint] +void ModelView::paintGL(QGLPainter *painter) +{ + painter->modelViewMatrix().rotate(m_pose); + + if (m_main) + m_main->draw(painter); +} +//! [paint] diff --git a/examples/qt3d/tutorials/penguin_advanced/modelview.h b/examples/qt3d/tutorials/penguin_advanced/modelview.h new file mode 100644 index 000000000..38b4340cc --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/modelview.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 MODELVIEW_H +#define MODELVIEW_H + +#include "qglview.h" + +class QGLAbstractScene; +class QGLSceneNode; + +class ModelView : public QGLView +{ + Q_OBJECT +public: + ModelView(QWidget *parent = 0); + ~ModelView() {} + +protected: + void initializeGL(QGLPainter *painter); + void paintGL(QGLPainter *painter); + +private: + QGLAbstractScene *m_scene; + QGLSceneNode *m_main; + QQuaternion m_pose; +}; + +#endif diff --git a/examples/qt3d/tutorials/penguin_advanced/penguin.3ds b/examples/qt3d/tutorials/penguin_advanced/penguin.3ds Binary files differnew file mode 100644 index 000000000..26c09ac07 --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/penguin.3ds diff --git a/examples/qt3d/tutorials/penguin_advanced/penguin_advanced.pro b/examples/qt3d/tutorials/penguin_advanced/penguin_advanced.pro new file mode 100644 index 000000000..079c5f5b0 --- /dev/null +++ b/examples/qt3d/tutorials/penguin_advanced/penguin_advanced.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +TARGET = penguin +DESTDIR = ../../../bin +CONFIG += qt warn_on qt3d +SOURCES = modelview.cpp \ + main.cpp +HEADERS = modelview.h +RESOURCES = model_advanced.qrc diff --git a/examples/qt3d/tutorials/shaders/TutorialTeapot.qml b/examples/qt3d/tutorials/shaders/TutorialTeapot.qml new file mode 100644 index 000000000..5f2c29e08 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/TutorialTeapot.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Item3D { + mesh: Mesh { source: "meshes/teapot.bez" } + effect: Effect {} + property int xRotation : 0.0 + property int yRotation : 0.0 + property int zRotation : 0.0 + + transform: [ + Rotation3D { + angle: xRotation + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: yRotation + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: zRotation + axis: Qt.vector3d(0, 0, 1) + } + ] +} diff --git a/examples/qt3d/tutorials/shaders/meshes b/examples/qt3d/tutorials/shaders/meshes new file mode 120000 index 000000000..3bc225c36 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/meshes @@ -0,0 +1 @@ +../../../demos/declarative/meshes
\ No newline at end of file diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial-1-textures.qml b/examples/qt3d/tutorials/shaders/shader-tutorial-1-textures.qml new file mode 100644 index 000000000..081a94c0f --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial-1-textures.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + + TutorialTeapot { + effect: program + } + + ShaderProgram { + id: program + texture: "textures/qtlogo.png" + property real textureOffsetX : 1.0 + NumberAnimation on textureOffsetX + { + running: true; loops: Animation.Infinite + from: 0.0; to: 1.0; + duration: 1000 + } + + property string texture2: "textures/basket.jpg" + property real interpolationFactor : 1.0 + SequentialAnimation on interpolationFactor + { + running: true; loops: Animation.Infinite + NumberAnimation { from: 0.0; to: 1.0; duration: 2000 } + PauseAnimation { duration: 500 } + NumberAnimation { from: 1.0; to: 0.0; duration: 2000 } + PauseAnimation { duration: 500 } + } + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform mediump mat4 qt_ModelViewProjectionMatrix; + + attribute highp vec4 qt_MultiTexCoord0; + uniform mediump float textureOffsetX; + varying mediump vec4 texCoord; + + void main(void) + { + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + texCoord.st = vec2(-qt_MultiTexCoord0.s - textureOffsetX, + -qt_MultiTexCoord0.t); + texCoord.pq = vec2(-qt_MultiTexCoord0.s + textureOffsetX, + -qt_MultiTexCoord0.t); + } + " + fragmentShader: " + varying highp vec4 texCoord; + uniform sampler2D qt_Texture0; + uniform sampler2D texture2; + uniform mediump float interpolationFactor; + + void main(void) + { + mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st); + mediump vec4 texture2Color = texture2D(texture2, texCoord.pq); + mediump vec4 textureColor = mix(texture1Color, texture2Color, interpolationFactor); + gl_FragColor = textureColor; + } + " + } +} diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial-2-vertex-shader.qml b/examples/qt3d/tutorials/shaders/shader-tutorial-2-vertex-shader.qml new file mode 100644 index 000000000..37f9ddfde --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial-2-vertex-shader.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + + TutorialTeapot { + id: teapot + effect: program + xRotation: 30 + } + + ShaderProgram { + id: program + texture: "textures/qtlogo.png" + + property real textureOffsetX : 0.0 + property real squashFactor : 0.0 + NumberAnimation on textureOffsetX + { + running: true; loops: Animation.Infinite + from: 0.0; to: 1.0; + duration: 1000 + } + + SequentialAnimation on squashFactor + { + running: true; loops: Animation.Infinite + NumberAnimation { + from: 0.0; to: 1.0; duration: 1000 + easing.type: "InQuad" + } + PauseAnimation { + duration: 250 + } + NumberAnimation { + from: 1.0; to: 0.0; duration: 1000 + easing.type: "OutQuad" + } + } + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform mediump mat4 qt_ModelViewProjectionMatrix; + + attribute highp vec4 qt_MultiTexCoord0; + varying highp vec4 texCoord; + uniform mediump float textureOffsetX; + uniform mediump float squashFactor; + + void main(void) + { + const float modelSize = 2.0; + const float modelBottom = -1.0; + float newY = max(qt_Vertex.y - squashFactor * modelSize, + qt_Vertex.y * 0.01 + modelBottom); + gl_Position = qt_ModelViewProjectionMatrix * + vec4(qt_Vertex.x, newY, qt_Vertex.zw); + + texCoord = vec4(-qt_MultiTexCoord0.s + - textureOffsetX, + -qt_MultiTexCoord0.t, + qt_MultiTexCoord0.pq); + } + " + fragmentShader: " + varying highp vec4 texCoord; + uniform sampler2D qt_Texture0; + + void main(void) + { + mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); + gl_FragColor = textureColor; + } + " + } +} diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml b/examples/qt3d/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml new file mode 100644 index 000000000..6b3595c5d --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + + + Item3D { + z: -8.0 + transform: [ + Rotation3D { + NumberAnimation on angle { + running: true; loops: Animation.Infinite + from: 0; to: 360; duration: 5000 + } + axis: Qt.vector3d(0, 0, 1.0) + } + ] + + TutorialTeapot {id: teapot1; effect: program; y:2.0; x:0.0} + TutorialTeapot {id: teapot2; effect: program; y:-1.0; x:-1.732} + TutorialTeapot {id: teapot3; effect: program; y:-1.0; x:1.732} + } + + ShaderProgram { + id: program + texture: "textures/qtlogo.png" + + property real textureOffsetX : 0.0 + property real squashFactor : 0.0 + NumberAnimation on textureOffsetX + { + running: true; loops: Animation.Infinite + from: 0.0; to: 1.0; + duration: 1000 + } + + SequentialAnimation on squashFactor + { + running: true; loops: Animation.Infinite + NumberAnimation { + from: 0.0; to: 1.0; duration: 1000 + easing.type: "InQuad" + } + PauseAnimation { + duration: 250 + } + NumberAnimation { + from: 1.0; to: 0.0; duration: 1000 + easing.type: "OutQuad" + } + } + + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform mediump mat4 qt_ModelViewProjectionMatrix; + + attribute mediump vec4 qt_MultiTexCoord0; + varying mediump vec4 texCoord; + + void main(void) + { + const float modelBottom = -4.0; + + vec4 workingPosition = qt_ModelViewProjectionMatrix * qt_Vertex; + float newY = max(workingPosition.y, + workingPosition.y * 0.15 + modelBottom); + workingPosition.y = newY; + gl_Position = workingPosition; + + texCoord = -qt_MultiTexCoord0; + } + " + fragmentShader: " + varying mediump vec4 texCoord; + uniform sampler2D qt_Texture0; + + void main(void) + { + mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); + gl_FragColor = textureColor; + } + " + } +} diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial-lighting.qml b/examples/qt3d/tutorials/shaders/shader-tutorial-lighting.qml new file mode 100644 index 000000000..94bcee74d --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial-lighting.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 + +Viewport { + width: 640; height: 480 + + + Cube { + id: teapot + effect: program +// xRotation: 30 + } + + ShaderProgram { + id: program + texture: "textures/qtlogo.png" + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform highp mat4 qt_ModelViewProjectionMatrix; + + attribute highp vec4 qt_MultiTexCoord0; + varying highp vec4 texCoord; + + void main(void) + { + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; +// texCoord = -qt_MultiTexCoord0; + texCoord = qt_Vertex; + } + " + fragmentShader: " + varying highp vec4 texCoord; + uniform sampler2D qt_Texture0; + + void main(void) + { + mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); +// gl_FragColor = textureColor; + gl_FragColor = vec4(texCoord.xyz , 1.0); + } + " + } +} diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial-varying.qml b/examples/qt3d/tutorials/shaders/shader-tutorial-varying.qml new file mode 100644 index 000000000..3341bb7b5 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial-varying.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + + Pane { + effect: ShaderProgram { + id: program + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform mediump mat4 qt_ModelViewProjectionMatrix; + + attribute highp vec4 qt_MultiTexCoord0; + varying highp vec4 texCoord; + + void main(void) + { + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + texCoord = vec4(qt_MultiTexCoord0.st, 0, 0); + } + " + fragmentShader: " + varying highp vec4 texCoord; + + void main(void) + { + gl_FragColor = vec4(mod(texCoord.x, 1.0), + mod(texCoord.y, 1.0), + 0.0, + 1.0); + } + " + } + } +} diff --git a/examples/qt3d/tutorials/shaders/shader-tutorial.qml b/examples/qt3d/tutorials/shaders/shader-tutorial.qml new file mode 100644 index 000000000..37d379bb8 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shader-tutorial.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + + + TutorialTeapot { + id: teapot + effect: program + xRotation: 30 + } + + ShaderProgram { + id: program + texture: "textures/qtlogo.png" + + vertexShader: " + attribute highp vec4 qt_Vertex; + uniform highp mat4 qt_ModelViewProjectionMatrix; + + attribute highp vec4 qt_MultiTexCoord0; + varying highp vec4 texCoord; + + void main(void) + { + texCoord = qt_MultiTexCoord0; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + fragmentShader: " + varying highp vec4 texCoord; + uniform sampler2D qt_Texture0; + + void main(void) + { + mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); + gl_FragColor = textureColor; + } + " + } +} diff --git a/examples/qt3d/tutorials/shaders/shaders.pro b/examples/qt3d/tutorials/shaders/shaders.pro new file mode 100644 index 000000000..05755ad8a --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shaders.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +# These examples contain no C++ and can simply be copied +sources.files = . \ + +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials +INSTALLS += sources diff --git a/examples/qt3d/tutorials/shaders/shaders.qmlproject b/examples/qt3d/tutorials/shaders/shaders.qmlproject new file mode 100644 index 000000000..d4909f868 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/shaders.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/qt3d/tutorials/shaders/textures/basket.jpg b/examples/qt3d/tutorials/shaders/textures/basket.jpg new file mode 120000 index 000000000..b23d4eec4 --- /dev/null +++ b/examples/qt3d/tutorials/shaders/textures/basket.jpg @@ -0,0 +1 @@ +../../../../demos/declarative/textures/basket.jpg
\ No newline at end of file diff --git a/examples/qt3d/tutorials/shaders/textures/qtlogo.png b/examples/qt3d/tutorials/shaders/textures/qtlogo.png new file mode 120000 index 000000000..b8b931c8b --- /dev/null +++ b/examples/qt3d/tutorials/shaders/textures/qtlogo.png @@ -0,0 +1 @@ +../../../../demos/declarative/textures/qtlogo.png
\ No newline at end of file diff --git a/examples/qt3d/tutorials/teapot-qml/teapot-bounce.qml b/examples/qt3d/tutorials/teapot-qml/teapot-bounce.qml new file mode 100644 index 000000000..7a9e61e69 --- /dev/null +++ b/examples/qt3d/tutorials/teapot-qml/teapot-bounce.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import Qt3D 1.0 + +Viewport { + width: 640; height: 480 + +//! [1] + Item3D { + id: teapot + mesh: Mesh { source: "teapot.bez" } + + effect: Effect { + material: china + } + + Material { + id: china + ambientColor: "#c09680" + specularColor: "#3c3c3c" + shininess: 128 + } +//! [1] + +//! [3] + SequentialAnimation on y { + running: true + loops: Animation.Infinite + PauseAnimation { duration: 500 } + NumberAnimation { to : 1.0; duration: 300; easing.type: "OutQuad" } + NumberAnimation { to : 0.0; duration: 300; easing.type: "OutBounce" } + } +//! [3] +//! [2] + } +//! [2] +} diff --git a/examples/qt3d/tutorials/teapot-qml/teapot-qml.qmlproject b/examples/qt3d/tutorials/teapot-qml/teapot-qml.qmlproject new file mode 100644 index 000000000..d4909f868 --- /dev/null +++ b/examples/qt3d/tutorials/teapot-qml/teapot-qml.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/qt3d/tutorials/teapot-qml/teapot.bez b/examples/qt3d/tutorials/teapot-qml/teapot.bez new file mode 100644 index 000000000..02b2ac447 --- /dev/null +++ b/examples/qt3d/tutorials/teapot-qml/teapot.bez @@ -0,0 +1,340 @@ +32 +1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 +4,17,18,19,8,20,21,22,12,23,24,25,16,26,27,28 +19,29,30,31,22,32,33,34,25,35,36,37,28,38,39,40 +31,41,42,1,34,43,44,5,37,45,46,9,40,47,48,13 +13,14,15,16,49,50,51,52,53,54,55,56,57,58,59,60 +16,26,27,28,52,61,62,63,56,64,65,66,60,67,68,69 +28,38,39,40,63,70,71,72,66,73,74,75,69,76,77,78 +40,47,48,13,72,79,80,49,75,81,82,53,78,83,84,57 +57,58,59,60,85,86,87,88,89,90,91,92,93,94,95,96 +60,67,68,69,88,97,98,99,92,100,101,102,96,103,104,105 +69,76,77,78,99,106,107,108,102,109,110,111,105,112,113,114 +78,83,84,57,108,115,116,85,111,117,118,89,114,119,120,93 +121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136 +124,137,138,121,128,139,140,125,132,141,142,129,136,143,144,133 +133,134,135,136,145,146,147,148,149,150,151,152,69,153,154,155 +136,143,144,133,148,156,157,145,152,158,159,149,155,160,161,69 +162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177 +165,178,179,162,169,180,181,166,173,182,183,170,177,184,185,174 +174,175,176,177,186,187,188,189,190,191,192,193,194,195,196,197 +177,184,185,174,189,198,199,186,193,200,201,190,197,202,203,194 +204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,4 +204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,4 +204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,4 +204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,4 +212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245 +215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254 +222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263 +229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242 +270,270,270,270,279,280,281,282,275,276,277,278,271,272,273,274,4 +270,270,270,270,282,289,290,291,278,286,287,288,274,283,284,285,4 +270,270,270,270,291,298,299,300,288,295,296,297,285,292,293,294,4 +270,270,270,270,300,305,306,279,297,303,304,275,294,301,302,271,4 +306 +0.700000,0.450000,-0.000000 +0.700000,0.450000,0.392000 +0.392000,0.450000,0.700000 +0.000000,0.450000,0.700000 +0.668750,0.515625,-0.000000 +0.668750,0.515625,0.374500 +0.374500,0.515625,0.668750 +0.000000,0.515625,0.668750 +0.718750,0.515625,-0.000000 +0.718750,0.515625,0.402500 +0.402500,0.515625,0.718750 +0.000000,0.515625,0.718750 +0.750000,0.450000,-0.000000 +0.750000,0.450000,0.420000 +0.420000,0.450000,0.750000 +0.000000,0.450000,0.750000 +-0.392000,0.450000,0.700000 +-0.700000,0.450000,0.392000 +-0.700000,0.450000,-0.000000 +-0.374500,0.515625,0.668750 +-0.668750,0.515625,0.374500 +-0.668750,0.515625,-0.000000 +-0.402500,0.515625,0.718750 +-0.718750,0.515625,0.402500 +-0.718750,0.515625,-0.000000 +-0.420000,0.450000,0.750000 +-0.750000,0.450000,0.420000 +-0.750000,0.450000,-0.000000 +-0.700000,0.450000,-0.392000 +-0.392000,0.450000,-0.700000 +0.000000,0.450000,-0.700000 +-0.668750,0.515625,-0.374500 +-0.374500,0.515625,-0.668750 +0.000000,0.515625,-0.668750 +-0.718750,0.515625,-0.402500 +-0.402500,0.515625,-0.718750 +0.000000,0.515625,-0.718750 +-0.750000,0.450000,-0.420000 +-0.420000,0.450000,-0.750000 +0.000000,0.450000,-0.750000 +0.392000,0.450000,-0.700000 +0.700000,0.450000,-0.392000 +0.374500,0.515625,-0.668750 +0.668750,0.515625,-0.374500 +0.402500,0.515625,-0.718750 +0.718750,0.515625,-0.402500 +0.420000,0.450000,-0.750000 +0.750000,0.450000,-0.420000 +0.875000,0.187500,-0.000000 +0.875000,0.187500,0.490000 +0.490000,0.187500,0.875000 +0.000000,0.187500,0.875000 +1.000000,-0.075000,-0.000000 +1.000000,-0.075000,0.560000 +0.560000,-0.075000,1.000000 +0.000000,-0.075000,1.000000 +1.000000,-0.300000,-0.000000 +1.000000,-0.300000,0.560000 +0.560000,-0.300000,1.000000 +0.000000,-0.300000,1.000000 +-0.490000,0.187500,0.875000 +-0.875000,0.187500,0.490000 +-0.875000,0.187500,-0.000000 +-0.560000,-0.075000,1.000000 +-1.000000,-0.075000,0.560000 +-1.000000,-0.075000,-0.000000 +-0.560000,-0.300000,1.000000 +-1.000000,-0.300000,0.560000 +-1.000000,-0.300000,-0.000000 +-0.875000,0.187500,-0.490000 +-0.490000,0.187500,-0.875000 +0.000000,0.187500,-0.875000 +-1.000000,-0.075000,-0.560000 +-0.560000,-0.075000,-1.000000 +0.000000,-0.075000,-1.000000 +-1.000000,-0.300000,-0.560000 +-0.560000,-0.300000,-1.000000 +0.000000,-0.300000,-1.000000 +0.490000,0.187500,-0.875000 +0.875000,0.187500,-0.490000 +0.560000,-0.075000,-1.000000 +1.000000,-0.075000,-0.560000 +0.560000,-0.300000,-1.000000 +1.000000,-0.300000,-0.560000 +1.000000,-0.525000,-0.000000 +1.000000,-0.525000,0.560000 +0.560000,-0.525000,1.000000 +0.000000,-0.525000,1.000000 +0.750000,-0.637500,-0.000000 +0.750000,-0.637500,0.420000 +0.420000,-0.637500,0.750000 +0.000000,-0.637500,0.750000 +0.750000,-0.675000,-0.000000 +0.750000,-0.675000,0.420000 +0.420000,-0.675000,0.750000 +0.000000,-0.675000,0.750000 +-0.560000,-0.525000,1.000000 +-1.000000,-0.525000,0.560000 +-1.000000,-0.525000,-0.000000 +-0.420000,-0.637500,0.750000 +-0.750000,-0.637500,0.420000 +-0.750000,-0.637500,-0.000000 +-0.420000,-0.675000,0.750000 +-0.750000,-0.675000,0.420000 +-0.750000,-0.675000,-0.000000 +-1.000000,-0.525000,-0.560000 +-0.560000,-0.525000,-1.000000 +0.000000,-0.525000,-1.000000 +-0.750000,-0.637500,-0.420000 +-0.420000,-0.637500,-0.750000 +0.000000,-0.637500,-0.750000 +-0.750000,-0.675000,-0.420000 +-0.420000,-0.675000,-0.750000 +0.000000,-0.675000,-0.750000 +0.560000,-0.525000,-1.000000 +1.000000,-0.525000,-0.560000 +0.420000,-0.637500,-0.750000 +0.750000,-0.637500,-0.420000 +0.420000,-0.675000,-0.750000 +0.750000,-0.675000,-0.420000 +-0.800000,0.262500,-0.000000 +-0.800000,0.262500,0.150000 +-0.750000,0.375000,0.150000 +-0.750000,0.375000,-0.000000 +-1.150000,0.262500,-0.000000 +-1.150000,0.262500,0.150000 +-1.250000,0.375000,0.150000 +-1.250000,0.375000,-0.000000 +-1.350000,0.262500,-0.000000 +-1.350000,0.262500,0.150000 +-1.500000,0.375000,0.150000 +-1.500000,0.375000,-0.000000 +-1.350000,0.150000,-0.000000 +-1.350000,0.150000,0.150000 +-1.500000,0.150000,0.150000 +-1.500000,0.150000,-0.000000 +-0.750000,0.375000,-0.150000 +-0.800000,0.262500,-0.150000 +-1.250000,0.375000,-0.150000 +-1.150000,0.262500,-0.150000 +-1.500000,0.375000,-0.150000 +-1.350000,0.262500,-0.150000 +-1.500000,0.150000,-0.150000 +-1.350000,0.150000,-0.150000 +-1.350000,0.037500,-0.000000 +-1.350000,0.037500,0.150000 +-1.500000,-0.075000,0.150000 +-1.500000,-0.075000,-0.000000 +-1.250000,-0.187500,-0.000000 +-1.250000,-0.187500,0.150000 +-1.325000,-0.281250,0.150000 +-1.325000,-0.281250,-0.000000 +-1.000000,-0.300000,0.150000 +-0.950000,-0.450000,0.150000 +-0.950000,-0.450000,-0.000000 +-1.500000,-0.075000,-0.150000 +-1.350000,0.037500,-0.150000 +-1.325000,-0.281250,-0.150000 +-1.250000,-0.187500,-0.150000 +-0.950000,-0.450000,-0.150000 +-1.000000,-0.300000,-0.150000 +0.850000,-0.037500,-0.000000 +0.850000,-0.037500,0.330000 +0.850000,-0.450000,0.330000 +0.850000,-0.450000,-0.000000 +1.300000,-0.037500,-0.000000 +1.300000,-0.037500,0.330000 +1.550000,-0.337500,0.330000 +1.550000,-0.337500,-0.000000 +1.150000,0.300000,-0.000000 +1.150000,0.300000,0.125000 +1.200000,0.262500,0.125000 +1.200000,0.262500,-0.000000 +1.350000,0.450000,-0.000000 +1.350000,0.450000,0.125000 +1.650000,0.450000,0.125000 +1.650000,0.450000,-0.000000 +0.850000,-0.450000,-0.330000 +0.850000,-0.037500,-0.330000 +1.550000,-0.337500,-0.330000 +1.300000,-0.037500,-0.330000 +1.200000,0.262500,-0.125000 +1.150000,0.300000,-0.125000 +1.650000,0.450000,-0.125000 +1.350000,0.450000,-0.125000 +1.400000,0.487500,-0.000000 +1.400000,0.487500,0.125000 +1.762500,0.496875,0.125000 +1.762500,0.496875,-0.000000 +1.450000,0.487500,-0.000000 +1.450000,0.487500,0.075000 +1.725000,0.506250,0.075000 +1.725000,0.506250,-0.000000 +1.400000,0.450000,-0.000000 +1.400000,0.450000,0.075000 +1.600000,0.450000,0.075000 +1.600000,0.450000,-0.000000 +1.762500,0.496875,-0.125000 +1.400000,0.487500,-0.125000 +1.725000,0.506250,-0.075000 +1.450000,0.487500,-0.075000 +1.600000,0.450000,-0.075000 +1.400000,0.450000,-0.075000 +0.000000,0.825000,-0.000000 +0.000000,0.825000,0.001000 +0.001000,0.825000,-0.000000 +0.400000,0.825000,-0.000000 +0.400000,0.825000,0.225000 +0.225000,0.825000,0.400000 +0.000000,0.825000,0.400000 +0.000000,0.675000,-0.000000 +0.100000,0.600000,-0.000000 +0.100000,0.600000,0.056000 +0.056000,0.600000,0.100000 +0.000000,0.600000,0.100000 +-0.001000,0.825000,-0.000000 +-0.225000,0.825000,0.400000 +-0.400000,0.825000,0.225000 +-0.400000,0.825000,-0.000000 +-0.056000,0.600000,0.100000 +-0.100000,0.600000,0.056000 +-0.100000,0.600000,-0.000000 +0.000000,0.825000,-0.001000 +-0.400000,0.825000,-0.225000 +-0.225000,0.825000,-0.400000 +0.000000,0.825000,-0.400000 +-0.100000,0.600000,-0.056000 +-0.056000,0.600000,-0.100000 +0.000000,0.600000,-0.100000 +0.225000,0.825000,-0.400000 +0.400000,0.825000,-0.225000 +0.056000,0.600000,-0.100000 +0.100000,0.600000,-0.056000 +0.200000,0.525000,-0.000000 +0.200000,0.525000,0.112000 +0.112000,0.525000,0.200000 +0.000000,0.525000,0.200000 +0.650000,0.525000,-0.000000 +0.650000,0.525000,0.364000 +0.364000,0.525000,0.650000 +0.000000,0.525000,0.650000 +0.650000,0.450000,-0.000000 +0.650000,0.450000,0.364000 +0.364000,0.450000,0.650000 +0.000000,0.450000,0.650000 +-0.112000,0.525000,0.200000 +-0.200000,0.525000,0.112000 +-0.200000,0.525000,-0.000000 +-0.364000,0.525000,0.650000 +-0.650000,0.525000,0.364000 +-0.650000,0.525000,-0.000000 +-0.364000,0.450000,0.650000 +-0.650000,0.450000,0.364000 +-0.650000,0.450000,-0.000000 +-0.200000,0.525000,-0.112000 +-0.112000,0.525000,-0.200000 +0.000000,0.525000,-0.200000 +-0.650000,0.525000,-0.364000 +-0.364000,0.525000,-0.650000 +0.000000,0.525000,-0.650000 +-0.650000,0.450000,-0.364000 +-0.364000,0.450000,-0.650000 +0.000000,0.450000,-0.650000 +0.112000,0.525000,-0.200000 +0.200000,0.525000,-0.112000 +0.364000,0.525000,-0.650000 +0.650000,0.525000,-0.364000 +0.364000,0.450000,-0.650000 +0.650000,0.450000,-0.364000 +0.000000,-0.750000,-0.000000 +0.750000,-0.675000,-0.000000 +0.750000,-0.675000,-0.420000 +0.420000,-0.675000,-0.750000 +0.000000,-0.675000,-0.750000 +0.750000,-0.712500,-0.000000 +0.750000,-0.712500,-0.420000 +0.420000,-0.712500,-0.750000 +0.000000,-0.712500,-0.750000 +0.712500,-0.750000,-0.000000 +0.712500,-0.750000,-0.399000 +0.399000,-0.750000,-0.712500 +0.000000,-0.750000,-0.712500 +-0.420000,-0.675000,-0.750000 +-0.750000,-0.675000,-0.420000 +-0.750000,-0.675000,-0.000000 +-0.420000,-0.712500,-0.750000 +-0.750000,-0.712500,-0.420000 +-0.750000,-0.712500,-0.000000 +-0.399000,-0.750000,-0.712500 +-0.712500,-0.750000,-0.399000 +-0.712500,-0.750000,-0.000000 +-0.750000,-0.675000,0.420000 +-0.420000,-0.675000,0.750000 +0.000000,-0.675000,0.750000 +-0.750000,-0.712500,0.420000 +-0.420000,-0.712500,0.750000 +0.000000,-0.712500,0.750000 +-0.712500,-0.750000,0.399000 +-0.399000,-0.750000,0.712500 +0.000000,-0.750000,0.712500 +0.420000,-0.675000,0.750000 +0.750000,-0.675000,0.420000 +0.420000,-0.712500,0.750000 +0.750000,-0.712500,0.420000 +0.399000,-0.750000,0.712500 +0.712500,-0.750000,0.399000 diff --git a/examples/qt3d/tutorials/teapot-qml/teapot.qml b/examples/qt3d/tutorials/teapot-qml/teapot.qml new file mode 100644 index 000000000..97e0bdf56 --- /dev/null +++ b/examples/qt3d/tutorials/teapot-qml/teapot.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +//![1] +//![2] +import Qt 4.7 +import Qt3D 1.0 +//![2] + +//![3] +Viewport { + width: 640; height: 480 +//![3] +//![4] + Item3D { + id: teapot + mesh: Mesh { source: "teapot.bez" } + effect: Effect {} + } +//![4] +} +//![1] diff --git a/examples/qt3d/tutorials/tutorials.pro b/examples/qt3d/tutorials/tutorials.pro new file mode 100644 index 000000000..8c3fdf364 --- /dev/null +++ b/examples/qt3d/tutorials/tutorials.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += penguin penguin_advanced +SUBDIRS += cube1 cube2 cube3 cube4 |