Class CubeSphereCreator

java.lang.Object
gaiasky.render.gdx.creators.ModelCreator
gaiasky.render.gdx.creators.CubeSphereCreator

public class CubeSphereCreator extends ModelCreator
  • Constructor Details

    • CubeSphereCreator

      public CubeSphereCreator()
  • Method Details

    • create

      public CubeSphereCreator create(float radius, int divisions)
      Creates a cube-sphere model.
      Parameters:
      radius - The radius of the sphere.
      divisions - The number of subdivisions per face edge (must be > 0).
      Returns:
      This creator.
    • create

      public CubeSphereCreator create(float radius, int divisions, boolean flipNormals)
      Creates a cube-sphere model. Start with a cube where each face contains divisions x divisions quads, then project each vertex onto the sphere by normalizing its position and scaling by the radius.

      UVs are computed from the final spherical direction (longitude/colatitude), using the same convention as SphereCreator (u=1 at longitude 0, decreasing eastward; v=0 at the north pole, 1 at the south pole). This makes any standard equirectangular texture (e.g. a whole-Earth map) line up correctly, and lets a UV-sphere and cube-sphere share the same texture.

      Because a flat square face can span more than 180 degrees of longitude around the poles, three of the six faces (-X, +Y, -Y) cross the longitude seam (u wraps from ~1 back to ~0). Vertices along that seam are duplicated with u shifted by +-1 so no quad stretches across the whole texture.

      Parameters:
      radius - The radius of the sphere.
      divisions - The number of subdivisions per face edge (must be > 0).
      flipNormals - Whether to reverse triangle winding (flip normals).
      Returns:
      This creator.