From 42f09ac510d4f6d6f5641c9e1dc6fc5d87fe9c9f Mon Sep 17 00:00:00 2001 From: Sergey Dubitskiy Date: Wed, 25 Jan 2012 11:07:05 +1000 Subject: QTBUG-20443. Fixed Quad and Cube sizes and texcoords. Task-number: QTBUG-20443 Change-Id: Ief0b15f8ca07104936c2bf64f764e50b10a7e89c Reviewed-by: Danny Pope --- src/imports/shapes/cube.obj | 8 ++--- src/imports/shapes/quad.obj | 10 +++--- src/threed/geometry/qglcube.cpp | 52 ++++++++++++++++++++++++------- tests/auto/qml3d/picking/tst_picking.qml | 4 +-- tests/auto/threed/qglcube/tst_qglcube.cpp | 48 ++++++++++++++-------------- 5 files changed, 76 insertions(+), 46 deletions(-) diff --git a/src/imports/shapes/cube.obj b/src/imports/shapes/cube.obj index 03bded06d..7e0c3e0af 100644 --- a/src/imports/shapes/cube.obj +++ b/src/imports/shapes/cube.obj @@ -17,9 +17,9 @@ vt 1.0 0.0 vt 1.0 1.0 vt 0.0 1.0 vt 0.0 0.0 -f 1/1/1 2/2/1 3/3/1 4/4/1 -f 4/1/2 3/2/2 7/3/2 8/4/2 -f 8/1/3 7/2/3 6/3/3 5/4/3 +f 1/4/1 2/1/1 3/2/1 4/3/1 +f 4/3/2 3/4/2 7/1/2 8/2/2 +f 8/2/3 7/3/3 6/4/3 5/1/3 f 5/1/4 6/2/4 2/3/4 1/4/4 f 6/1/5 7/2/5 3/3/5 2/4/5 -f 8/1/6 5/2/6 1/3/6 4/4/6 +f 8/3/6 5/4/6 1/1/6 4/2/6 diff --git a/src/imports/shapes/quad.obj b/src/imports/shapes/quad.obj index 7ee54359a..a28dee25d 100644 --- a/src/imports/shapes/quad.obj +++ b/src/imports/shapes/quad.obj @@ -1,12 +1,12 @@ o Plane -v 1.000000 -0.000000 -1.000000 -v 1.000000 0.000000 1.000000 -v -1.000000 0.000000 1.000000 -v -1.000000 -0.000000 -1.000000 +v 0.500000 0.000000 -0.500000 +v 0.500000 0.000000 0.500000 +v -0.500000 0.000000 0.500000 +v -0.500000 0.000000 -0.500000 vt 1.000000 0.000000 vt 1.000000 1.000000 vt 0.000000 1.000000 vt 0.000000 0.000000 usemtl (null) s off -f 1/1 4/4 3/3 2/2 +f 1/2 4/3 3/4 2/1 diff --git a/src/threed/geometry/qglcube.cpp b/src/threed/geometry/qglcube.cpp index 6775dba95..a1932328c 100644 --- a/src/threed/geometry/qglcube.cpp +++ b/src/threed/geometry/qglcube.cpp @@ -93,44 +93,75 @@ QT_BEGIN_NAMESPACE static const int vertexDataLen = 6 * 4 * 3; static const float vertexData[vertexDataLen] = { + // +X + 0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, -0.5f, + // -X -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, + // +Y -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, - - 0.5f, 0.5f, -0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, -0.5f, - + // -Y 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, + // +Z 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, - + // -Z 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f }; -static const int texCoordDataLen = 4 * 2; +static const int texCoordDataLen = 6 * 4 * 2; static const float texCoordData[texCoordDataLen] = { + // +X + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + // -X + 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, - 0.0f, 0.0f + + // +Y + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + // -Y + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + + // +Z + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + // -Z + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, }; /*! @@ -158,8 +189,7 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCube& cube) QVector2DArray texx = QVector2DArray::fromRawData( reinterpret_cast(texCoordData), texCoordDataLen / 2); - for (int i = 0; i < 6; ++i) - op.appendTexCoordArray(texx); + op.appendTexCoordArray(texx); builder.addQuads(op); return builder; diff --git a/tests/auto/qml3d/picking/tst_picking.qml b/tests/auto/qml3d/picking/tst_picking.qml index 867b72f2a..94ee6553a 100644 --- a/tests/auto/qml3d/picking/tst_picking.qml +++ b/tests/auto/qml3d/picking/tst_picking.qml @@ -66,8 +66,8 @@ Rectangle angle: 90 }, Scale3D { - // a scale 2 quad will fill a square viewport - scale: 2 + // a scale 4 quad will fill a square viewport + scale: 4 } ] position: Qt.vector3d(0, 0, 0) diff --git a/tests/auto/threed/qglcube/tst_qglcube.cpp b/tests/auto/threed/qglcube/tst_qglcube.cpp index b63669f73..d43fb44c9 100644 --- a/tests/auto/threed/qglcube/tst_qglcube.cpp +++ b/tests/auto/threed/qglcube/tst_qglcube.cpp @@ -59,26 +59,26 @@ private slots: #define QGL_CUBE_SIZE (6 * 6 * (3 + 3 + 2)) static float const cubeVertices[QGL_CUBE_SIZE] = { - -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, - -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, - -0.5f, -0.5f, -0.5f, -1.0f, 0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0f, -1.0f, 0.0f, 1.0f, - -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f }; static int findVertex(const QGeometryData &ary, const QVector3D &v, const QVector3D &n) -- cgit v1.2.3