summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Dubitskiy <sergey.dubitskiy@nokia.com>2012-01-25 11:07:05 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-25 04:36:53 +0100
commite92cfb37d49b187c38016f6c1d268b8e000ee7d9 (patch)
tree25ac03feda7e0f5fec88792b4ac54d479d9f4763
parent4f3b9edab3b59b6ea150d65c5357f50174cbdd73 (diff)
QTBUG-20443. Fixed Quad and Cube sizes and texcoords.
Task-number: QTBUG-20443 Change-Id: Ief0b15f8ca07104936c2bf64f764e50b10a7e89c Reviewed-by: Sergey Dubitskiy <sergey.dubitskiy@nokia.com> Reviewed-by: Christopher Ham <christopher.ham@nokia.com> Reviewed-by: Danny Pope <daniel.pope@nokia.com>
-rw-r--r--src/imports/shapes/cube.obj8
-rw-r--r--src/imports/shapes/quad.obj10
-rw-r--r--src/threed/geometry/qglcube.cpp52
-rw-r--r--tests/auto/qml3d/picking/tst_picking.qml4
-rw-r--r--tests/auto/threed/qglcube/tst_qglcube.cpp48
5 files changed, 76 insertions, 46 deletions
diff --git a/src/imports/shapes/cube.obj b/src/imports/shapes/cube.obj
index 03bded06..7e0c3e0a 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 7ee54359..a28dee25 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 6775dba9..a1932328 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<const QVector2D *>(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 867b72f2..94ee6553 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 b63669f7..d43fb44c 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.0f, 0.0f, 1.0f, 0.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.0f, 0.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ -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, 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, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 0.5f, 0.5f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0f, 0.0f, 1.0f, 1.0f,
@@ -94,12 +94,12 @@ static float const cubeVertices[QGL_CUBE_SIZE] = {
-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, 1.0f, 1.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, 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)