Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/gl/sphere.cc')
-rw-r--r--src/gl/sphere.cc93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/gl/sphere.cc b/src/gl/sphere.cc
deleted file mode 100644
index e28e495..0000000
--- a/src/gl/sphere.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- gl/sphere.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
-*/
-
-#include "gl/sphere.h"
-#include "math/mathlib.h"
-
-using math::Vector3f;
-using math::Color;
-
-namespace gl {
-
-const int segments = 33;
-
-Sphere::Sphere(Vector3f p , float r)
-{
- position = p;
- radius = r;
-
- // TODO make global sine-cosine lists
- sintable = new float[segments];
- costable = new float[segments];
- float d = 2 * M_PI / segments;
-
- for (int i=0; i < segments; i++) {
- sintable[i] = sin( d * (float) i );
- costable[i] = cos ( d * (float) i );
- }
-}
-
-Sphere::~Sphere()
-{
- delete[] sintable;
- delete[] costable;
-}
-
-Sphere::Sphere(const Sphere &other)
-{
- (*this) = other;
-}
-
-Sphere& Sphere::operator=(const Sphere &other)
-{
- position = other.position;
- radius = other.radius;
- return (*this);
-}
-
-void Sphere::draw()
-{
- // draw top
- // TODO upside-down
- float r = radius*sintable[1];
- float h = radius*costable[1];
-
- begin(LineLoop);
- //begin(Polygon);
- for (int i = segments-1; i >= 0; i--)
- vertex(r*costable[i], h, r*sintable[i]);
- end();
-
- // draw bottom
- // TODO upside-down
- begin(LineLoop);
- for (int i = 0; i< segments; i++)
- vertex(r*costable[i], -h, r*sintable[i]);
- end();
-
- // draw body
- for (int j=1; j < segments-1; j++) {
- r = radius*sintable[j];
- float r1 = radius*sintable[j+1];
-
- begin(QuadStrip);
- vertex(r1, radius*costable[j+1], 0);
- vertex(r, radius*costable[j], 0);
-
- for (int i = segments-1; i >= 0; i--) {
- vertex(r1*costable[i], radius*costable[j+1], r1*sintable[i]);
- vertex(r*costable[i], radius*costable[j], r*sintable[i]);
- //vertex(r*costable[i-1], radius*costable[j], r*sintable[i-1]);
- //vertex(r1*costable[i-1], radius*costable[j+1], r1*sintable[i-1]);
- }
- end();
-
- }
-}
-
-
-} // namespace gl
-