From dd3049c6cd5dbd70839ceb9f2229fc03cf0e6107 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 16 Nov 2015 21:48:22 +0100 Subject: Add normals and color --- src/glsphere.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/glsphere.cpp') diff --git a/src/glsphere.cpp b/src/glsphere.cpp index 8b68b7c..84a2c59 100644 --- a/src/glsphere.cpp +++ b/src/glsphere.cpp @@ -12,45 +12,45 @@ void GLSphere::makeSurface(QVector *pointContainer, { GLBody::makeSurface(pointContainer, indexContainer); - QVector3D n0 = v_XYZ; //dummy normal QVector3D t0 = QVector3D(0.0, 0.0, 0.0); //dummy texture QVector3D northpol = v_Y * m_radius; QVector3D southpol = -v_Y * m_radius; + QVector3D point1; + QVector3D point2; + m_firstPoint = m_points->size(); for (int slice = 1; slice < m_slices; slice += 2) - { - m_points->append(GLPoint(northpol, n0, t0, GLColorRgba::clMagenta)); - - for (int stack = 1; stack < m_stacks; stack++) - { - m_points->append(GLPoint(calculatePoint(2 * M_PI * slice / m_slices, - stack * M_PI / m_stacks), n0, t0, - m_color)); - - m_points->append(GLPoint(calculatePoint(2 * M_PI * (slice - 1) / m_slices, - stack * M_PI / m_stacks), n0, t0, - m_color)); + { + m_points->append(GLPoint(northpol, northpol.normalized(), t0, m_color)); - } + for (int stack = 1; stack < m_stacks; stack++) + { + point1 = calculatePoint(2 * M_PI * slice / m_slices, stack * M_PI / m_stacks); + m_points->append(GLPoint(point1, point1.normalized(), t0, m_color)); - m_points->append(GLPoint(southpol, n0, t0, GLColorRgba::clMagenta)); + point2 = calculatePoint(2 * M_PI * (slice - 1) / m_slices, + stack * M_PI / m_stacks); + m_points->append(GLPoint(point2, point2.normalized(), t0, m_color)); + } - for (int stack = m_stacks - 1; stack > 1; stack--) - { - m_points->append(GLPoint(calculatePoint(2 * M_PI * slice / m_slices, - stack * M_PI / m_stacks), n0, t0, - m_color)); + m_points->append(GLPoint(southpol, n0, t0, m_color)); - m_points->append(GLPoint(calculatePoint(2 * M_PI * (slice + 1) / m_slices, - stack * M_PI / m_stacks), n0, t0, - m_color)); + for (int stack = m_stacks - 1; stack > 1; stack--) + { + point1 = calculatePoint(2 * M_PI * slice / m_slices, stack * M_PI / m_stacks); + m_points->append(GLPoint(point1, point1.normalized(), t0, m_color)); - } + point2 = calculatePoint(2 * M_PI * (slice + 1) / m_slices, + stack * M_PI / m_stacks); + m_points->append(GLPoint(point2, point3.normalized(), t0, m_color)); } + m_points->append(GLPoint(southpol, southpol.normalized(), t0, m_color)); + } + m_nextPoint = m_points->size(); } -- cgit v1.2.3-70-g09d2