BME_Mesh *BME_make_new_uvsphere(BME_Mesh *bm, float radius, int rings, int seg) { BME_Vert *v1, *v2; BME_Edge *e, *e_arr[2]; BME_Loop *l; BME_Poly *f; int i, j; float vec[3], rpos, rinc, rrad, spos, sinc; rpos = 0; /* ring position */ rinc = (float)M_PI/rings; /* ring increment */ sinc = (float)(2*M_PI/seg); /* segment increment */ vec[0] = 0.0; vec[1] = 0.0; vec[2] = radius; /* make pole verts */ v1 = BME_MV(bm,vec); /* top */ vec[2] = -vec[2]; v2 = BME_MV(bm,vec); /* bottom */ /* make segment edges */ for (i=0; iedge; iedge->loop; if (l->v != v2) { /* v2 (the "bottom") will be the "hub" */ l = l->next; /* make sure l->v is v2 */ } for (i=1/*we have one less ring edge than "rings"*/,l=v1->edge->loop; iprev->e,NULL); VECCOPY(v1->co,vec); rrad = vec[0]; /* this ring's radius */ spos = 0; /* segment position */ for (j=1; je,NULL); VECCOPY(v1->co,vec); f = BME_SFME(bm,l->f,l->next->v,l->prev->v,NULL); l = ((BME_Loop*)l->radial.next->data)->next; } f = BME_SFME(bm,l->f,l->next->v,l->prev->v,NULL); } return bm; }