summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-11-24 10:16:04 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-11-24 10:16:04 +0100
commit5c3f1612edc6cc19de2d56132b98be67102cb78a (patch)
tree2e9fd24c7c5130a5405350ef2262fb4ab9fc0d6f /src
parentdddffcb89a3e53a6945698c0dcc769b4c3f8542b (diff)
downloadMultimedia-5c3f1612edc6cc19de2d56132b98be67102cb78a.tar.gz
Multimedia-5c3f1612edc6cc19de2d56132b98be67102cb78a.zip
Revert "Merge branch 'sphereTriangleStrip'"
This reverts commit dddffcb89a3e53a6945698c0dcc769b4c3f8542b, reversing changes made to 4db18dc608b6739c90b76166d2560fbd7013832c.
Diffstat (limited to 'src')
-rw-r--r--src/glsphere.cpp60
-rw-r--r--src/glsphere.h3
-rw-r--r--src/mmscene.cpp2
3 files changed, 11 insertions, 54 deletions
diff --git a/src/glsphere.cpp b/src/glsphere.cpp
index 77cb7f7..1a40540 100644
--- a/src/glsphere.cpp
+++ b/src/glsphere.cpp
@@ -3,9 +3,8 @@
GLSphere::GLSphere(double radius, int stacks, int slices)
: GLBody(radius)
{
- // Force an even number
- m_stacks = stacks / 2 * 2;
- m_slices = slices / 2 * 2;
+ m_stacks = stacks;
+ m_slices = slices;
}
void GLSphere::makeSurface(QVector<GLPoint> *pointContainer,
@@ -18,70 +17,31 @@ void GLSphere::makeSurface(QVector<GLPoint> *pointContainer,
QVector3D northpol = v_Y;
QVector3D southpol = -v_Y;
- QVector<QVector3D> firstPointRow = calculateRow(0);
-
- QVector<QVector3D> sliceA = firstPointRow;
- QVector<QVector3D> sliceB;
+ QVector3D point1;
+ QVector3D point2;
m_firstPoint = m_points->size();
for (int slice = 1; slice < m_slices; slice += 2)
{
- sliceB = calculateRow(slice);
-
m_points->append(GLPoint(m_radius * northpol, northpol, t0, m_color));
- for (int i = 0; i < m_stacks - 1; i++)
+ for (int stack = 1; stack < m_stacks; stack++)
{
- m_points->append(GLPoint(m_radius * sliceA[i], sliceA[i],
- t0, m_color));
-
- m_points->append(GLPoint(m_radius * sliceB[i], sliceB[i],
- t0, m_color));
- }
-
- m_points->append(GLPoint(m_radius * southpol, southpol, t0, m_color));
+ point1 = calculatePoint(2 * M_PI * slice / m_slices, stack * M_PI / m_stacks);
+ m_points->append(GLPoint(m_radius * point1, point1, t0, m_color));
- sliceA = calculateRow(slice + 1);
+ point2 = calculatePoint(2 * M_PI * (slice - 1) / m_slices, stack * M_PI / m_stacks);
+ m_points->append(GLPoint(m_radius * point2, point2, t0, m_color));
- for (int i = m_stacks - 2; i >= 0; i--)
- {
- m_points->append(GLPoint(m_radius * sliceA[i], sliceA[i],
- t0, m_color));
-
- m_points->append(GLPoint(m_radius * sliceB[i], sliceB[i],
- t0, m_color));
}
- m_points->append(GLPoint(m_radius * northpol, northpol, t0, m_color));
+ m_points->append(GLPoint(m_radius * southpol, southpol, t0, m_color));
}
m_nextPoint = m_points->size();
}
-QVector<QVector3D> GLSphere::calculateRow(int slice)
-{
- if(slice == m_stacks)
- {
- return firstRow;
- }
-
- QVector<QVector3D> longitude;
-
- for (int stack = 1; stack < m_stacks; stack++)
- {
- longitude.append(calculatePoint(2 * M_PI * slice / m_slices,
- stack * M_PI / m_stacks));
- }
-
- if (slice == 0)
- {
- firstRow = longitude;
- }
-
- return longitude;
-}
-
QVector3D GLSphere::calculatePoint(double sliceRotation, double stackRotation)
{
double x = sin(stackRotation) * sin(sliceRotation);
diff --git a/src/glsphere.h b/src/glsphere.h
index f884117..9aae032 100644
--- a/src/glsphere.h
+++ b/src/glsphere.h
@@ -22,11 +22,8 @@ private:
*/
QVector3D calculatePoint(double sliceRotation, double stackRotation);
- QVector<QVector3D> calculateRow(int slice);
-
int m_stacks;
int m_slices;
- QVector<QVector3D> firstRow;
};
#endif // GLSPHERE_H
diff --git a/src/mmscene.cpp b/src/mmscene.cpp
index 8de2c87..f199563 100644
--- a/src/mmscene.cpp
+++ b/src/mmscene.cpp
@@ -96,7 +96,7 @@ void MMScene::createSphere()
{
m_sphere = new GLSphere();
- m_sphere->setDrawingMode(GL_TRIANGLE_STRIP);
+ m_sphere->setDrawingMode(GL_POINTS);
m_sphere->makeSurface(&m_points, &m_indices);
}