Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/sphere.cc')
-rw-r--r--src/render/sphere.cc132
1 files changed, 0 insertions, 132 deletions
diff --git a/src/render/sphere.cc b/src/render/sphere.cc
deleted file mode 100644
index d44c9e6..0000000
--- a/src/render/sphere.cc
+++ /dev/null
@@ -1,132 +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 "render/sphere.h"
-#include "render/render.h"
-#include "math/mathlib.h"
-
-using math::Vector3f;
-using math::Color;
-
-namespace render {
-
-const int segments = 33;
-
-Sphere::Sphere(float r)
-{
- radius = r;
-
- // TODO make global sine-cosine lists
- sintable = new float[segments];
- costable = new float[segments];
- float d = 2 * M_PI / (segments-1);
-
- 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)
-{
- sphere_color = other.sphere_color;
- radius = other.radius;
- return (*this);
-}
-
-void Sphere::draw()
-{
- using namespace gl;
-
- float r = radius*sintable[1];
- //float h = radius*costable[1];
-
- gl::color(sphere_color);
-
- /*
- // draw top
- begin(Polygon);
- normal(0, 1, 0);
- for (int i = segments-1; i >= 0; i--) {
- v = Vector3f(r*costable[i], h, r*sintable[i]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
- }
- end();
-
- // draw bottom
- begin(Polygon);
- normal(0, -1, 0);
- for (int i = 0; i< segments; i++) {
- //for (int i = segments-1; i >= 0; i--)
- v = Vector3f(r*costable[i], -h, r*sintable[i]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
- }
- end();
- */
-
- Vector3f v;
- Vector3f n;
-
- // draw body
- for (int j=0; j < segments-1; j++) {
- r = radius*sintable[j];
- float r1 = radius*sintable[j+1];
- // draw all vertexes
- if (r_drawwireframe && r_drawwireframe->value()) {
- gl::begin(gl::LineStrip);
- } else {
- gl::begin(gl::QuadStrip);
- }
- v = Vector3f(r, 0, radius*costable[j]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
-
- v = Vector3f(r1, 0, radius*costable[j+1]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
-
- for (int i = segments-1; i >= 0; i--) {
- v = Vector3f(r*costable[i], r*sintable[i], radius*costable[j]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
-
- v = Vector3f(r1*costable[i], r1*sintable[i], radius*costable[j+1]);
- n = v;
- n.normalize();
- normal(n);
- vertex(v);
- }
- end();
-
- }
-}
-
-
-}
-