summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-10-01 09:08:27 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-10-01 09:14:04 +0300
commit50ea77c890b3fd9b07a5d8ce57a44f4176e810da (patch)
tree14546f036b1303aa7d73dea8d08465d5253eacb6 /examples
parent0ca1f153007c1cce62f3ad5fd7b7ed1d10fa5b35 (diff)
Minor tweaks to surface example
Change-Id: Ia8ce37320ac4c61e4cd1e48631f09f321b9fb408 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/surfacechart/chartmodifier.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/surfacechart/chartmodifier.cpp b/examples/surfacechart/chartmodifier.cpp
index 3385f854..db242253 100644
--- a/examples/surfacechart/chartmodifier.cpp
+++ b/examples/surfacechart/chartmodifier.cpp
@@ -77,17 +77,17 @@ void ChartModifier::toggleSqrtSin(bool enable)
if (enable) {
qDebug() << "Create Sqrt&Sin surface, (" << m_xCount << ", " << m_zCount << ")";
- float stepZ = 16.0 / float(m_zCount);
- float stepX = 16.0 / float(m_xCount);
+ float stepZ = 16.0f / float(m_zCount);
+ float stepX = 16.0f / float(m_xCount);
QSurfaceDataArray *dataArray = new QSurfaceDataArray;
dataArray->reserve(m_zCount);
- for (float i = -8.0 + stepZ / 2.0 ; i < 8.0 ; i += stepZ) {
+ for (float i = -8.0f + stepZ / 2.0f ; i < 8.0f ; i += stepZ) {
QSurfaceDataRow *newRow = new QSurfaceDataRow(m_xCount);
int index = 0;
- for (float j = -8.0 + stepX / 2.0; j < 8.0; j += stepX) {
- float R = qSqrt(i*i + j*j) + 0.01;
- float y = (sin(R)/R + 0.24) * 1.61;
+ for (float j = -8.0f + stepX / 2.0f; j < 8.0f; j += stepX) {
+ float R = qSqrt(i * i + j * j) + 0.01f;
+ float y = (qSin(R) / R + 0.24f) * 1.61f;
(*newRow)[index++].setPosition(QVector3D(j, y, i));
}
*dataArray << newRow;
@@ -285,8 +285,12 @@ void ChartModifier::timeout()
// Induce minor random jitter to the existing plane array
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
+ (*m_planeArray->at(i))[j].setX(m_planeArray->at(i)->at(j).x()
+ * ((float((rand() % 10) + 5.0f) / 10000.0f) + 0.999f));
(*m_planeArray->at(i))[j].setY(m_planeArray->at(i)->at(j).y()
- * ((float((rand() % 10) + 4) / 1000.0f) + 0.99f) + 0.001f);
+ * ((float((rand() % 10) + 5.0f) / 1000.0f) + 0.99f) + 0.0001f);
+ (*m_planeArray->at(i))[j].setZ(m_planeArray->at(i)->at(j).z()
+ * ((float((rand() % 10) + 5.0f) / 10000.0f) + 0.999f));
}
}