# Icosphere Shape

I wrote some code to create an icosphere. It’s an interesting shape that has both benefits and drawbacks. Anyway - feel free to use it as you wish.

The image above shows the first six levels of recursion.

Useage:

``````Mesh icosphere = new Icosphere(int recursions, float size);
``````

15 Likes

no normals?

• could the position buffer be used, or are those no longer normalized after mult(size)?

So if you used the Vertex buffer for each point in the icosphere the point itself is the correct vertex for a normal.

One way (if you wanted to alter this code to add it) is to simply take the point, and normalize it a la

``````Vector3f myNormal = vertices.get(x).normalize();
``````

Add that into your normal array maintaining the same position as you got it from and that should do it.

But if you’re just doing a critique of this posted library… Then yes. I agree. The normals should’ve been added as well.

I kinda gave up with it when I posted it here. Mapping an icosphere is an art. Some people have come up with decent results, but unless you specifically want one, it’s far easier using a sphere.

I thought they were talking about face normal vectors, not uv coordinates.

yeah sorry i meant that was the point at which i stopped working on it.

not gonna pretend i knew the maths off the top of my head but here is the equation. i’ll update the gist when i get on my pc.

I don’t think you’d need any fancy math in this case since it’s basically a sphere. Adding up the three vertex vectors and normalizing the result should give the triangle center normal no?

The perils of not being educated in the field you love… big gaps in the horizon of things you should really know at this point my strong point is not maths, though i try to eradicate that with reading as time goes by. i have a soft spot for it these days.

Thank you for posting this algorithm.
An icosphere might make a nice replacement for com.jme3.scene.debug.WireSphere
I’ll probably add it to one of my libraries at some point.

For any sphere, if the mesh is radius 1 then the vertex positions are also the vertex normals.

…it’s only if you want a flat sided sphere that you need to average anything. But then you would also need to unshare the vertexes (I assume they are shared in this mesh).

2 Likes

I’ve started using this in my game so I’ve updated the code.

• use word “radius” as opposed to “size” for clarity.