From d22799efdb445a120c636bfe27ab55c11dc0f43b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 Nov 2014 08:56:38 +0200 Subject: Some doc updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib4bb651877db4aa0dfd13cb8f1c08e786960a221 Reviewed-by: Tomi Korpipää --- src/datavisualization/doc/src/qtdatavisualization-index.qdoc | 2 ++ src/datavisualization/doc/src/qtdatavisualization.qdoc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/datavisualization') diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc index 711573c9..9170baeb 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc @@ -35,12 +35,14 @@ \list \li Control viewable data window with axis ranges \li Customize value axis grid lines and labels with axis formatters + \li Polar horizontal axes support for surface and scatter graphs \endlist \li Customizable input handling \li Customizable themes \li Custom items and labels can be added to any graph \li Ready-made data proxies to visualize data from Qt item models and height maps \li Perspective and orthographic projections + \li Volumetric custom items \endlist \section1 Getting Started diff --git a/src/datavisualization/doc/src/qtdatavisualization.qdoc b/src/datavisualization/doc/src/qtdatavisualization.qdoc index b6312060..ab245a88 100644 --- a/src/datavisualization/doc/src/qtdatavisualization.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization.qdoc @@ -192,7 +192,7 @@ \section1 Series - Series is combination of logically connected set of data items (handled by a data proxy) + A series is a combination of a logically connected set of data items (handled by a data proxy) and visual properties that describe how the data items should be rendered, such as item meshes and colors. Each visualization type has its own series type. For example, bar graphs use QBar3DSeries. All graphs can have multiple series added simultaneously. -- cgit v1.2.3 From 11ed44c13c227c73d9b2ec416aed54b00bda2a0a Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 Nov 2014 09:49:02 +0200 Subject: Support larger custom meshes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vertex index was limited to unsigned short, meaning even slightly complex meshes couldn't be used. Changed to unsigned int. Also removed unused vertex indexer methods. Change-Id: Iebe62bd3a501dc79ee2857cca28ac0d05bd4a55e Reviewed-by: Tomi Korpipää --- src/datavisualization/engine/bars3drenderer.cpp | 2 +- src/datavisualization/engine/drawer.cpp | 6 +- src/datavisualization/engine/scatter3drenderer.cpp | 6 +- src/datavisualization/engine/surface3drenderer.cpp | 3 +- .../utils/abstractobjecthelper.cpp | 5 -- .../utils/abstractobjecthelper_p.h | 3 - src/datavisualization/utils/objecthelper.cpp | 3 +- src/datavisualization/utils/objecthelper_p.h | 4 +- .../utils/scatterobjectbufferhelper.cpp | 3 +- .../utils/scatterpointbufferhelper.cpp | 1 - src/datavisualization/utils/surfaceobject.cpp | 1 - src/datavisualization/utils/vertexindexer.cpp | 85 ++-------------------- src/datavisualization/utils/vertexindexer_p.h | 26 +------ 13 files changed, 22 insertions(+), 126 deletions(-) (limited to 'src/datavisualization') diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index 5768cb1a..09b29173 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -1124,7 +1124,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, barObj->elementBuf()); // Draw the triangles - glDrawElements(GL_TRIANGLES, barObj->indexCount(), GL_UNSIGNED_SHORT, + glDrawElements(GL_TRIANGLES, barObj->indexCount(), GL_UNSIGNED_INT, (void *)0); // Free buffers diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp index 38ad4c1a..63bb2c69 100644 --- a/src/datavisualization/engine/drawer.cpp +++ b/src/datavisualization/engine/drawer.cpp @@ -142,7 +142,7 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf()); // Draw the triangles - glDrawElements(GL_TRIANGLES, object->indexCount(), object->indicesType(), (void*)0); + glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void*)0); // Free buffers glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -177,7 +177,7 @@ void Drawer::drawSelectionObject(ShaderHelper *shader, AbstractObjectHelper *obj glBindBuffer(GL_ARRAY_BUFFER, object->vertexBuf()); glVertexAttribPointer(shader->posAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void *)0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf()); - glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_SHORT, (void *)0); + glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void *)0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glDisableVertexAttribArray(shader->posAtt()); @@ -194,7 +194,7 @@ void Drawer::drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->gridElementBuf()); // Draw the lines - glDrawElements(GL_LINES, object->gridIndexCount(), object->indicesType(), (void*)0); + glDrawElements(GL_LINES, object->gridIndexCount(), GL_UNSIGNED_INT, (void*)0); // Free buffers glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index d0db28de..d58ca18e 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -641,8 +641,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dotObj->elementBuf()); // Draw the triangles - glDrawElements(GL_TRIANGLES, dotObj->indexCount(), GL_UNSIGNED_SHORT, - (void *)0); + glDrawElements(GL_TRIANGLES, dotObj->indexCount(), + GL_UNSIGNED_INT, (void *)0); // Free buffers glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -662,7 +662,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) // Draw the triangles glDrawElements(GL_TRIANGLES, object->indexCount(), - object->indicesType(), (void *)0); + GL_UNSIGNED_INT, (void *)0); // Free buffers glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 6f804d16..c09cc4e3 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -1216,8 +1216,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf()); // Draw the triangles - glDrawElements(GL_TRIANGLES, object->indexCount(), - object->indicesType(), (void *)0); + glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void *)0); } } diff --git a/src/datavisualization/utils/abstractobjecthelper.cpp b/src/datavisualization/utils/abstractobjecthelper.cpp index c3d0e7bb..245b77d1 100644 --- a/src/datavisualization/utils/abstractobjecthelper.cpp +++ b/src/datavisualization/utils/abstractobjecthelper.cpp @@ -74,9 +74,4 @@ GLuint AbstractObjectHelper::indexCount() return m_indexCount; } -GLuint AbstractObjectHelper::indicesType() -{ - return m_indicesType; -} - QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/abstractobjecthelper_p.h b/src/datavisualization/utils/abstractobjecthelper_p.h index bca765d7..b141a132 100644 --- a/src/datavisualization/utils/abstractobjecthelper_p.h +++ b/src/datavisualization/utils/abstractobjecthelper_p.h @@ -45,7 +45,6 @@ public: virtual GLuint uvBuf(); GLuint elementBuf(); GLuint indexCount(); - GLuint indicesType(); public: GLuint m_vertexbuffer; @@ -55,8 +54,6 @@ public: GLuint m_indexCount; GLboolean m_meshDataLoaded; - - GLuint m_indicesType; }; QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp index 0237708f..6441aae2 100644 --- a/src/datavisualization/utils/objecthelper.cpp +++ b/src/datavisualization/utils/objecthelper.cpp @@ -25,7 +25,6 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION ObjectHelper::ObjectHelper(const QString &objectFile) : m_objectFile(objectFile) { - m_indicesType = GL_UNSIGNED_SHORT; load(); } @@ -158,7 +157,7 @@ void ObjectHelper::load() glGenBuffers(1, &m_elementbuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(unsigned short), + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint), &m_indices.at(0), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/src/datavisualization/utils/objecthelper_p.h b/src/datavisualization/utils/objecthelper_p.h index 92de3838..7e13e2a3 100644 --- a/src/datavisualization/utils/objecthelper_p.h +++ b/src/datavisualization/utils/objecthelper_p.h @@ -48,7 +48,7 @@ public: static void releaseObjectHelper(const Abstract3DRenderer *cacheId, ObjectHelper *&obj); inline const QString &objectFile() { return m_objectFile; } - inline const QVector &indices() const { return m_indices; } + inline const QVector &indices() const { return m_indices; } inline const QVector &indexedvertices() const { return m_indexedVertices; } inline const QVector &indexedUVs() const { return m_indexedUVs; } inline const QVector &indexedNormals() const { return m_indexedNormals; } @@ -59,7 +59,7 @@ private: void load(); QString m_objectFile; - QVector m_indices; + QVector m_indices; QVector m_indexedVertices; QVector m_indexedUVs; QVector m_indexedNormals; diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp index faa3c164..99b17a96 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp +++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp @@ -29,7 +29,6 @@ const GLfloat itemScaler = 3.0f; ScatterObjectBufferHelper::ScatterObjectBufferHelper() : m_scaleY(0.0f) { - m_indicesType = GL_UNSIGNED_INT; } ScatterObjectBufferHelper::~ScatterObjectBufferHelper() @@ -64,7 +63,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal } // Index vertices - const QVector indices = dotObj->indices(); + const QVector indices = dotObj->indices(); const QVector indexed_vertices = dotObj->indexedvertices(); const QVector indexed_uvs = dotObj->indexedUVs(); const QVector indexed_normals = dotObj->indexedNormals(); diff --git a/src/datavisualization/utils/scatterpointbufferhelper.cpp b/src/datavisualization/utils/scatterpointbufferhelper.cpp index 08793fef..139d3fc9 100644 --- a/src/datavisualization/utils/scatterpointbufferhelper.cpp +++ b/src/datavisualization/utils/scatterpointbufferhelper.cpp @@ -27,7 +27,6 @@ ScatterPointBufferHelper::ScatterPointBufferHelper() : m_pointbuffer(0), m_oldRemoveIndex(-1) { - m_indicesType = GL_UNSIGNED_INT; } ScatterPointBufferHelper::~ScatterPointBufferHelper() diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp index 34f50bf1..6f9ace19 100644 --- a/src/datavisualization/utils/surfaceobject.cpp +++ b/src/datavisualization/utils/surfaceobject.cpp @@ -36,7 +36,6 @@ SurfaceObject::SurfaceObject(Surface3DRenderer *renderer) m_dataDimension(0), m_oldDataDimension(-1) { - m_indicesType = GL_UNSIGNED_INT; glGenBuffers(1, &m_vertexbuffer); glGenBuffers(1, &m_normalbuffer); glGenBuffers(1, &m_uvbuffer); diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp index c34203da..90528d05 100644 --- a/src/datavisualization/utils/vertexindexer.cpp +++ b/src/datavisualization/utils/vertexindexer.cpp @@ -24,45 +24,11 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION int unique_vertices = 0; -// Returns true if v1 can be considered equal to v2 -bool VertexIndexer::is_near(float v1, float v2) -{ - return qAbs(v1 - v2) < 0.01f; -} - -// Searches through all already exported vertices for a similar one. -// Similar = same position + same UVs + same normal -bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex, - const QVector2D &in_uv, - const QVector3D &in_normal, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals, - unsigned short &result) -{ - // Linear search - for (int i = 0; i < out_vertices.size(); i++) { - if (is_near(in_vertex.x() , out_vertices[i].x()) - && is_near(in_vertex.y() , out_vertices[i].y()) - && is_near(in_vertex.z() , out_vertices[i].z()) - && is_near(in_uv.x() , out_uvs [i].x()) - && is_near(in_uv.y() , out_uvs [i].y()) - && is_near(in_normal.x() , out_normals [i].x()) - && is_near(in_normal.y() , out_normals [i].y()) - && is_near(in_normal.z() , out_normals [i].z())) { - result = i; - return true; - } - } - // No other vertex could be used instead - return false; -} - bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed, - QMap &VertexToOutIndex, - unsigned short &result) + QMap &VertexToOutIndex, + GLuint &result) { - QMap::iterator it = VertexToOutIndex.find(packed); + QMap::iterator it = VertexToOutIndex.find(packed); if (it == VertexToOutIndex.end()) { return false; } else { @@ -74,20 +40,20 @@ bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed, void VertexIndexer::indexVBO(const QVector &in_vertices, const QVector &in_uvs, const QVector &in_normals, - QVector &out_indices, + QVector &out_indices, QVector &out_vertices, QVector &out_uvs, QVector &out_normals) { unique_vertices = 0; - QMap VertexToOutIndex; + QMap VertexToOutIndex; // For each input vertex for (int i = 0; i < in_vertices.size(); i++) { PackedVertex packed = {in_vertices[i], in_uvs[i], in_normals[i]}; // Try to find a similar vertex in out_XXXX - unsigned short index; + GLuint index; bool found = getSimilarVertexIndex_fast(packed, VertexToOutIndex, index); if (found) { @@ -97,48 +63,11 @@ void VertexIndexer::indexVBO(const QVector &in_vertices, out_vertices.append(in_vertices[i]); out_uvs.append(in_uvs[i]); out_normals.append(in_normals[i]); - unsigned short newindex = (unsigned short)out_vertices.size() - 1; + GLuint newindex = (GLuint)out_vertices.size() - 1; out_indices.append(newindex); VertexToOutIndex[packed] = newindex; } } } -void VertexIndexer::indexVBO_TBN(const QVector &in_vertices, - const QVector &in_uvs, - const QVector &in_normals, - const QVector &in_tangents, - const QVector &in_bitangents, - QVector &out_indices, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals, - QVector &out_tangents, - QVector &out_bitangents) -{ - unique_vertices = 0; - // For each input vertex - for (int i = 0; i < in_vertices.size(); i++) { - // Try to find a similar vertex in out_XXXX - unsigned short index; - bool found = getSimilarVertexIndex(in_vertices[i], in_uvs[i], in_normals[i], - out_vertices, out_uvs, out_normals, index); - - if (found) { - out_indices.append(index); - // Average the tangents and the bitangents - out_tangents[index] += in_tangents[i]; - out_bitangents[index] += in_bitangents[i]; - } else { - unique_vertices++; - out_vertices.append(in_vertices[i]); - out_uvs.append(in_uvs[i]); - out_normals.append(in_normals[i]); - out_tangents.append(in_tangents[i]); - out_bitangents.append(in_bitangents[i]); - out_indices.append((unsigned short)out_vertices.size() - 1); - } - } -} - QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/vertexindexer_p.h b/src/datavisualization/utils/vertexindexer_p.h index 2e878fbe..e2e7a7da 100644 --- a/src/datavisualization/utils/vertexindexer_p.h +++ b/src/datavisualization/utils/vertexindexer_p.h @@ -51,35 +51,15 @@ public: static void indexVBO(const QVector &in_vertices, const QVector &in_uvs, const QVector &in_normals, - QVector &out_indices, + QVector &out_indices, QVector &out_vertices, QVector &out_uvs, QVector &out_normals); - static void indexVBO_TBN(const QVector &in_vertices, - const QVector &in_uvs, - const QVector &in_normals, - const QVector &in_tangents, - const QVector &in_bitangents, - QVector &out_indices, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals, - QVector &out_tangents, - QVector &out_bitangents); - private: - static bool is_near(float v1, float v2); - static bool getSimilarVertexIndex(const QVector3D &in_vertex, - const QVector2D &in_uv, - const QVector3D &in_normal, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals, - unsigned short &result); static bool getSimilarVertexIndex_fast(const PackedVertex &packed, - QMap &VertexToOutIndex, - unsigned short &result); + QMap &VertexToOutIndex, + GLuint &result); }; QT_END_NAMESPACE_DATAVISUALIZATION -- cgit v1.2.3