From 1c359b169dd1c103420c8e8a8c31db4861929eff Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Tue, 24 Nov 2015 11:22:13 +0100 Subject: Add first version of indicies --- src/glsphere.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/glsphere.cpp b/src/glsphere.cpp index 15f745a..8fedd0e 100644 --- a/src/glsphere.cpp +++ b/src/glsphere.cpp @@ -35,6 +35,31 @@ void GLSphere::makeSurface(QVector *pointContainer, m_points->append(GLPoint(m_radius * southpol, southpol, t0, m_color)); m_nextPoint = m_points->size(); + + m_firstIndex = m_indices->size(); + + for (int slice = 1; slice < m_slices - 1; slice += 2) + { + m_indices->append(m_firstPoint); + + for (int stack = 0; stack < m_stacks - 1; stack++) + { + m_indices->append((m_firstPoint + 1) + stack + ((m_stacks - 1) * (slice - 1))); + m_indices->append((m_firstPoint + 1) + stack + ((m_stacks - 1) * slice)); + } + + m_indices->append(m_nextPoint - 1); + + for (int stack = m_stacks - 2; stack >= 0; stack--) + { + m_indices->append((m_firstPoint + 1) + stack + ((m_stacks - 1) * (slice + 1))); + m_indices->append((m_firstPoint + 1) + stack + ((m_stacks - 1) * slice)); + } + + m_indices->append(m_firstPoint); + } + + m_nextIndex = m_indices->size(); } QVector3D GLSphere::calculatePoint(double sliceRotation, double stackRotation) -- cgit v1.2.3-70-g09d2