Cover
 This is the archive Discourse for the Processing (ALPHA) software. Please visit the new Processing forum for current information.
 Processing 1.0 _ALPHA_    Programming Questions & Help    Programs (Moderators: fry, REAS)    texture on a sphere « Previous topic | Next topic »

 Pages: 1
 Author Topic: texture on a sphere  (Read 457 times)
tobt

 texture on a sphere « on: Jul 20th, 2004, 5:21pm »

i would like to map a texture to a sphere.

in another thread i read about to draw a sphere by using the following method. (from toxi.)

but how can i put these two elements together?
(How works the texture() - there is no reference)

thanks, tobt.

CODE:

void xsphere(float r) {
if (g.sphere_detail == 0) {
sphereDetail(30);
}
int sd=g.sphere_detail;
float[] sx=g.sphereX;
float[] sy=g.sphereY;
float[] sz=g.sphereZ;
int v1,v2;
push();
// scale(r); // REMOVED!!!

// 1st ring from south pole
beginShape(TRIANGLE_STRIP);
for (int i = 0; i <= sd; i++) {
v2 = i % sd;
vertex(0, -r, 0);
vertex(sx[v2]*r, sy[v2]*r, sz[v2]*r);
}
endShape();

// middle rings
int voff = 0;
for(int i = 2; i < sd; i++) {
voff += sd;
beginShape(TRIANGLE_STRIP);
for (int j = 0; j <= sd; j++) {
v1 = voff - sd + j % sd;
v2 = voff + j % sd;
vertex(sx[v1]*r, sy[v1]*r, sz[v1]*r);
vertex(sx[v2]*r, sy[v2]*r, sz[v2]*r);
}
endShape();
}

beginShape(TRIANGLE_STRIP);
for (int i = 0; i <= sd; i++) {
v2 = voff + i % sd;
vertex(0, r, 0);
vertex(sx[v2]*r, sy[v2]*r, sz[v2]*r);
}
endShape();
pop();
}
}
 « Last Edit: Jul 20th, 2004, 5:21pm by tobt »
Koenie

 Re: texture on a sphere « Reply #1 on: Jul 20th, 2004, 9:32pm »