Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-25 15:06:09 +0000
committerStijn Buys <ingar@osirion.org>2008-05-25 15:06:09 +0000
commit36e52bc178b2ba25ecc1b3fc13e03f2aee1e8efa (patch)
treecae74734b43253360e716cb0ad91aba29fa9757e /src/model/vertexarray.cc
parent210a3278e709b3cbbf2fdd6ef21a2150485b9d97 (diff)
planet updates
Diffstat (limited to 'src/model/vertexarray.cc')
-rw-r--r--src/model/vertexarray.cc55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc
index d13fc0c..da9c3d2 100644
--- a/src/model/vertexarray.cc
+++ b/src/model/vertexarray.cc
@@ -74,47 +74,45 @@ void VertexArray::add_sphere()
math::Color white(1.0f, 1.0f, 1.0f);
math::Vector3f v;
math::Vector3f n;
+ math::Vector3f tex;
int count;
- for (int j=0; j < SPHERESEGMENTS-1; j++) {
+ //float h = (float) (SPHERESEGMENTS-1) / 2 -1;
+ for (int j=0; j < (SPHERESEGMENTS-1) / 2; j++) {
+
float r = sintable[j];
float r1 = sintable[j+1];
- // glBegin
- v = math::Vector3f(r, 0, costable[j]);
+/* v.assign(r, 0, costable[j]);
n = v;
n.normalize();
- //normal(n);
- //vertex(v);
- add_vertex(v, n, white);
+ 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();
- //normal(n);
- //vertex(v);
- add_vertex(v, n, white);
+ tex.assign(1, (float) (SPHERESEGMENTS-2-j) / (float)(SPHERESEGMENTS-1), 0 );
+ add_vertex(v, n, white, tex);
count =2;
-
- for (int i = SPHERESEGMENTS-1; i >= 0; i--) {
+*/
+ for (int i = 0; i < SPHERESEGMENTS; i++) {
v = math::Vector3f(r*costable[i], r*sintable[i], costable[j]);
n = v;
n.normalize();
- //normal(n);
- //vertex(v);
- add_vertex(v, n, white);
+ //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);
v = math::Vector3f(r1*costable[i], r1*sintable[i], costable[j+1]);
n = v;
- n.normalize();
- //normal(n);
- //vertex(v);
- add_vertex(v, n, white);
+ n.normalize();
+ tex.assign((float)i/(float)(SPHERESEGMENTS-1), -costable[j+1]/2 + 0.5f, 0);
+ add_vertex(v, n, white, tex);
count +=2;
}
- // glEnd
}
@@ -140,5 +138,24 @@ void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, m
vertex_index += 3;
}
+void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, math::Vector3f const &tex) {
+ if (vertex_index + 3 >= vertex_size) {
+ con_warn << "VertexArray overflow!" << std::endl;
+ return;
+ }
+
+ for (int i = 0; i < 3; i ++) {
+ vertex_vertex[vertex_index+i] = v[i];
+ vertex_normal[vertex_index+i] = n[i];
+ vertex_texture[vertex_index+i] = tex[i];
+ }
+
+ vertex_color[vertex_index] = color.r;
+ vertex_color[vertex_index+1] = color.g;
+ vertex_color[vertex_index+2] = color.b;
+
+ vertex_index += 3;
+}
+
}