/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \title Applying Transformations and Materials
    \keyword Object Effects
    \example qt3d/cube4

    In this tutorial we will apply transformations and materials to a
    simple cube object to demonstrate how to modify the QGLPainter
    state to achieve different effects.

    \section2 Cube in QML

    It is quite simple to achieve these effects in \l{Qt 3D}:

    \snippet quick3d/cube/qml/Cube.qml 1

    \section2 Cube in C++

    In the C++ side of Qt 3D we start by declaring a view class to show our cube
    on the screen:

    \snippet qt3d/cube1/cubeview.h 1

    QGLView provides most of the logic for initializing the view,
    setting the camera position, and handling navigation via
    keyboard and mouse events.  In the constructor we use
    QGLBuilder to create the geometry for the cube object that
    we will be using in later steps:

    \snippet qt3d/cube1/cubeview.cpp 1

    Then it is a simple matter to draw the object in our \c{paintGL()}
    method:

    \snippet qt3d/cube1/cubeview.cpp 2

    If we run the program now, we get the following output, which isn't
    very cube-like:

    \image tutorials/cube1-screenshot.png

    The problem is that we are looking at the cube straight onto its
    front face.  So the rest of the cube is hidden from our view and
    it looks like a square.  Let's modify the modelview transformation
    matrix a little bit to apply a 45 degree rotation around the
    axis (1, 1, 1):

    \snippet qt3d/cube2/cubeview.cpp 2

    Now the results are a little better:

    \image tutorials/cube2-screenshot.png

    The cube is still a little odd-looking however.  This is because
    up until now we have been using the default flat color effect
    in QGLPainter that colors the faces with a uniform color
    (white in this case).  So let's change to a lit material effect
    with a nice green color:

    \snippet qt3d/cube3/cubeview.cpp 2

    That's much better; now it looks like a cube:

    \image tutorials/cube3-screenshot.png

    To complete this tutorial, let's make the cube a little more
    interesting by adding a texture to the side:

    \snippet qt3d/cube4/cubeview.h 1
    \dots
    \snippet qt3d/cube4/cubeview.h 2
    \snippet qt3d/cube4/cubeview.cpp 1
    \dots
    \snippet qt3d/cube4/cubeview.cpp 2
    \snippet qt3d/cube4/cubeview.cpp 3

    \image tutorials/cube4-screenshot.png

    \l{Qt 3D Tutorials and Examples}{Return to the main Tutorials page}.
*/
