Generating an icosphere
Does anyone have any links for this? I used to but every time I google this I get stupid Photoshop, Blender, GIMP, or other tutorials for other apps that I could care less about.
I know I can start with a geometric primitive like a tetrahedron, dodecahedron, cube, etc, and recursively split it to arrive at my sphere but I forget exactly how to do that.
Something like that maybe?
void CIcoSphere::Split(Vertex &Result,Vertex v1,Vertex v2,Vertex v3)
I'm abandoning UV spheres in my game engine because texturing them is far too problematic.
I'm using an icosphere from Blender for my sphere and the texturing is still not working correctly. The only thing left for me is to render a skybox but use a cube texture to represent the environment or backdrop.
It is simply mathematically impossible to wrap a rectangular 2:1 texture to a sphere, be it icosphere (geodesic), or a simple UV sphere. Distortion happens at the same exact place on both spheres regardless of vertex location.
The singularities inherent in the trig functions and singularities at the poles of the sphere's is the problem.
For a good illustration of this in Blender:
- Create a UV sphere at 0,0,0
- Split the viewport with left side as 3D view and right side as UV Image editor
- Load your texture into the UV image editor
- Press 1 while in the 3D view window - right side view
- Switch to UV face select mode and press A to select all vertices.
- Face->Unwrap UVs->Sphere from view
- Zoom into the sphere and you will notice distortion at the poles.
- Look at the UV image editor and you can see where the triangles map in relation to the texture
If you are still interested in generating an icosphere instead of loading one, I wrote the following code back in the day. It's also tied into a heightmap (we wanted to wrap a planet around it). The heightmap section doesn't work quite right, because certain subdivided points won't line up, but if you replace heightmap[u][v] with 1, or just load an even heightmap, it will generate a perfect isosphere just fine.
Why don't you unwrap the mesh and paint the texture onto that instead?
Then you'll get rid of all apparent singularities that you get at the poles when you just apply a rectangular texture to a sphere. The problem is caused by the topology difference of the objects, there simply isn't a non-distorting way of mapping between a flat map and a sphere, but you can make the distortions arbitrarily small by increasing the tesselation.
The painted map will of course become distorted but it will look good when you render it instead (the same way as is usually done with faces in FPS, also because of the round nature of heads)
I've opted not to generate any texture coords or geometry. Instead I'm using an icosphere from Blender that has been cut apart at the equator. Then in GIMP I create a flat panorama of the system. The top half and bottom half are split and converted to polar coordinates. Then each half is placed on a new texture with a black background. This texture is then loaded into Blender and I place the two unwrapped portions of the sphere on the textured circles in the texture.
What I end up with is a nearly perfect seamless textured sphere as long as the textures and UV mapping end up being fairly accurate in relation to one another.
I have some other tricks I'd like to try as well that will place the poles or the most distortion of the spheres at the top and bottom of a spherical texture. Since this area will be very small on both spherical textures the resulting distortion will be minimal in the game world.
I'm using several programs now to generate all of the in-game data:
- GIMP 2
- Paint Shop Pro X
- SkyPaint Panorama Editor v1.10
Wings3D does not have a blender export nor does it have an X file export. So I export it as a Wavefront OBJ file, import OBJ into Blender, and export from there to X file.
I should have some in-game screenshots up soon. Modelling and texturing is the biggest obstacle to completing one complete sector for the demo. The code has been about 20% of the battle and the actual creation of game content has been the other 80%.
This is the only new screenshot I have which doesn't show much more than before. But be assured there have been huge changes to the core engine code, level loading code, 3D orientation system, resource management, and several other systems.
Also attached a model screenshot from Blender for a light fighter I'm working on.