Does anyone know what the algorithm is to generate the vertices for a soccer/foot ball shaped object, preferably with hexagons?

I believe that you should create the model in blender, or any 3D software program, and then you should export it out into OpenGL. Creating models in OpenGL is really a pain.

If its not for a project I seriously suggest doing it that way

Problem is I don’t know know how to use blender, nor do I have the time. If someone could be able to produce a vertices list of all the points to it, I’d greatly appreciate it.

I know an experienced person could easily produce it but I have about a week to do 100 other things so I don’t have time and this was going to be the center piece of my project.

So if some one could produce a simple mesh file with hexagons (or any shape with 5 or more corners) I would greatly appreciate it.

could i just give you the blend file, then you export it and stuff…cuz i am new to these things and don’t now how to export models.

so srry…

Ya, that could work. BTW, I think .obj should do the job and I believe blender has it. Thanks a whole lot!

A soccer ball is made up of patches, some of which resemble pentagons, and some of which look like hexagons. Even if someone gave you the vertices of all the hex’s and pent’s, you’d still be a long way from being able to display a decent soccer ball. They’d also have to tell you how to connect the vertices to make polygons. PLUS - hex’s and pent’s are 2D polygons, so you’d end up with a polydron (i.e. flat faces), not something that looked spherical. Each hex and pent has to be subdivided into lots of smaller polygons, the vertices of which are projected out to the surface of a sphere. So you see,it’s not trivial

Google for a project called HexPlanet. They use an icosahedron (a 12 sided die) and subdivide several times to create a sphere, made up of hexagons and 12 pentagons. The algorithm is quite simple, and you can do it in a couple of hours.

Somewhere in my archives I have a optimised version of the above code (different subdivision algorithm, segment the sphere into strips and I’ve batched the geometry for each strip). For a Civilization like game with a hex planet with 20K tiles, that was essential, but for a simple soccer ball, you won’t need to subdivide more than 3 times. It’s been over a year since I’ve looked at the code though, and it’s in my archives somewhere …

Here’s code I use to generate points for a geodesic sphere. (Made this awhile ago for some testing) If i remember correctly, it calculates half a sphere, and then just copies the top half onto the bottom with the meridian line of points omitted.

http://en.wikipedia.org/wiki/Geodesic_dome

if you draw this sphere using points in the _sphereArray (of size ‘size’) btw, the ‘pnt’ struct is just typedef struct{float x, y, z;}pnt;

DIVISIONS is a #define variable i had set at 16, pretty much it’s how many latitudinal divisions are along half a hemisphere.

```
static int x, y;
size = 2;
for (x = 4; x < (4 * DIVISIONS); x += 4)
{
size += x * 2;
}
size += x;
_sphereArray = new Pnt [size];
static GLfloat scaler, scaler2;
Pnt *_index, *_pointer;
_index = _sphereArray;
_index->x = 0.0f;
_index->y = 1.0f;
_index->z = 0.0f;
_index++;
for (x = 0; x <= DIVISIONS; x++)
{
scaler = (PI / 2.0f) * ((GLfloat)x / (GLfloat)DIVISIONS);
_pointer = _index + x;
for (y = 0; y < x; y++)
{
scaler2 = (PI / 2) * ((GLfloat)y / (GLfloat)(x));
_index->x = sin(scaler) * cos(scaler2);
_index->y = cos(scaler);
_index->z = sin(scaler) * sin(scaler2);
_pointer->x = -_index->z;
_pointer->y = _index->y;
_pointer->z = _index->x;
(_pointer + x)->x = _index->z;
(_pointer + x)->y = _index->y;
(_pointer + x)->z = -_index->x;
(_pointer + x * 2)->x = -_index->x;
(_pointer + x * 2)->y = _index->y;
(_pointer + x * 2)->z = -_index->z;
_index++;
_pointer++;
}
_index += x * 3;
}
//for (_pointer = _index - 1 - ((x-1) * 4); _pointer != points; _pointer--)
for (_pointer = _index - 1 - ((x-1) * 4); _pointer != _sphereArray; _pointer--)
{
_index->x = _pointer->x;
_index->y = -_pointer->y;
_index->z = _pointer->z;
_index++;
}
_index->x = _pointer->x;
_index->y = -_pointer->y;
_index->z = _pointer->z;
```

Following up on my previous post, the polyhedron on which a soccer ball’s patches

are based is called a “Truncated Icosahedron”. The Wikipedia link is:

http://en.wikipedia.org/wiki/Truncated_icosahedron

They give you formulas for generating the vertex coordinates. You’d have to work out how to connect them to get faces. That would only get you flat faces. These would have to be subdivided into smaller polygons with the vertices scaled out onto the surface of a sphere to get a soccer ball. Even then you’d end up with a simple looking soccer ball. The article has pictures of the polyhedron and its corresponding soccer ball.