Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/vertexarray.cc42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc
index da9c3d2..b0da6ab 100644
--- a/src/model/vertexarray.cc
+++ b/src/model/vertexarray.cc
@@ -75,34 +75,18 @@ void VertexArray::add_sphere()
math::Vector3f v;
math::Vector3f n;
math::Vector3f tex;
-
int count;
- //float h = (float) (SPHERESEGMENTS-1) / 2 -1;
+ // add sphere
for (int j=0; j < (SPHERESEGMENTS-1) / 2; j++) {
float r = sintable[j];
float r1 = sintable[j+1];
-/* v.assign(r, 0, costable[j]);
- n = v;
- n.normalize();
- tex.assign(1, (float)(SPHERESEGMENTS-1-j) / (float)(SPHERESEGMENTS-1), 0);
- add_vertex(v, n, white, tex);
-
- v = math::Vector3f(r1, 0, costable[j+1]);
- n = v;
- n.normalize();
- tex.assign(1, (float) (SPHERESEGMENTS-2-j) / (float)(SPHERESEGMENTS-1), 0 );
- add_vertex(v, n, white, tex);
-
- count =2;
-*/
for (int i = 0; i < SPHERESEGMENTS; i++) {
v = math::Vector3f(r*costable[i], r*sintable[i], costable[j]);
n = v;
n.normalize();
- //tex.assign((float)i/(float)(SPHERESEGMENTS), (float) (j) / h, 0);
tex.assign((float)i/(float)(SPHERESEGMENTS-1), -costable[j]/2 + 0.5f , 0);
add_vertex(v, n, white, tex);
@@ -116,6 +100,30 @@ void VertexArray::add_sphere()
}
+ // add inside-out sphere
+ for (int j=0; j < (SPHERESEGMENTS-1) / 2; j++) {
+
+ float r = sintable[j];
+ float r1 = sintable[j+1];
+
+
+ for (int i = SPHERESEGMENTS -1 ; i >= 0; i--) {
+ v = math::Vector3f(r*costable[i], r*sintable[i], costable[j]);
+ n = v;
+ n.normalize();
+ tex.assign(1-(float)i/(float)(SPHERESEGMENTS-1), -costable[j]/2 + 0.5f , 0);
+ add_vertex(v, n, white, tex);
+
+ v = math::Vector3f(r1*costable[i], r1*sintable[i], costable[j+1]);
+ n = v;
+ n.normalize();
+ tex.assign(1-(float)i/(float)(SPHERESEGMENTS-1), -costable[j+1]/2 + 0.5f, 0);
+ add_vertex(v, n, white, tex);
+ count +=2;
+ }
+
+ }
+
delete[] sintable;
delete[] costable;
}