diff options
Diffstat (limited to 'model.cpp')
-rw-r--r-- | model.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -5,7 +5,7 @@ #include <QTextStream> #include <QVarLengthArray> -#include "GL/gl.h" +#include <QtOpenGL> struct Edge { @@ -36,8 +36,8 @@ Model::Model(const QString &filename) // use a set to avoid duplicate edges QSet<Edge> edges; - Point3d min( 1e9, 1e9, 1e9); - Point3d max(-1e9,-1e9,-1e9); + Point3d boundsMin( 1e9, 1e9, 1e9); + Point3d boundsMax(-1e9,-1e9,-1e9); QTextStream in(&file); while (!in.atEnd()) { @@ -57,8 +57,8 @@ Model::Model(const QString &filename) m_points << p; for (int i = 0; i < 3; ++i) { - min[i] = qMin(min[i], p[i]); - max[i] = qMax(max[i], p[i]); + boundsMin[i] = qMin(boundsMin[i], p[i]); + boundsMax[i] = qMax(boundsMax[i], p[i]); } } else if (id == "f" || id == "fo") { QVarLengthArray<int, 4> p; @@ -86,10 +86,10 @@ Model::Model(const QString &filename) } } - const Point3d bounds = max - min; + const Point3d bounds = boundsMax - boundsMin; const qreal scale = 1 / qMax(bounds.x, qMax(bounds.y, bounds.z)); for (int i = 0; i < m_points.size(); ++i) - m_points[i] = (m_points[i] - (min + bounds * 0.5)) * scale; + m_points[i] = (m_points[i] - (boundsMin + bounds * 0.5)) * scale; m_normals.resize(m_points.size()); for (int i = 0; i < m_pointIndices.size(); i += 3) { @@ -144,7 +144,7 @@ void Model::render(bool wireframe, bool normals) const glBegin(GL_LINES); for (int i = 0; i < m_normals.size(); ++i) { Point3d a = m_points.at(i); - Point3d b = m_points.at(i) + m_normals.at(i) * 0.02; + Point3d b = m_points.at(i) + m_normals.at(i) * 0.02f; glVertex3f(a.x, a.y, a.z); glVertex3f(b.x, b.y, b.z); } |