Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

truncated Icosahedron

Discussion in 'Scripting' started by peepo12343, Jan 27, 2022.

  1. peepo12343

    peepo12343

    Joined:
    Jul 11, 2021
    Posts:
    12
    Hello, Im trying to make a hexasphere by making a Icosahedron and then subdividing it, but im not sure what to do next. I know i have to truncate it but Im not sure how to do this. What would be the easiest way to do this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    Wow, I know some of those words... but you're gonna have to help me with what on earth you might be trying to do.

    If you're making geometry within Unity, I assume you're doing so in ProBuilder??

    Another way to do it is make the geometry in Blender3D and export it into Unity... that's how I make my hexaspheres subdivided from icosahedrons. Just kidding... I do use Blender3D but I have never made a hexasphere or icosahedron, but perhaps you could tell us how such a thing works and we could offer you some tips on making it!

    Oh yeah: in probuilder (and Blender) there is something called CSG (Constructive solid Geometry) or "the boolean modifier" in Blender which you can use to combine and chop up geometry, such as lop shapes off one another, cut holes through stuff, etc.
     
  3. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    You can’t make a hexasphere.

    look at a English football or soccer ball.

    I made one recently, it was very hard to make. The ones you see on Google images are fake.

    a sphere containing hexagons also contains pentagons.
     

    Attached Files:

    Bunny83 likes this.
  4. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    The confusion is that you can make a hex grid, but that grid cannot be wrapped into a sphere without alternating pentagons.

    As it is possible to create a hex grid. It’s possible to wrap a texture of that hex grid around a true sphere. However there is a gaping seam that is always hidden from view. A very cruel trick indeed.
     
    Bunny83 likes this.
  5. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    To use what's already available. There is an Asset in the AssetStore named Hexasphere Grid system (Author is Kronnect IIRC). There are also some tutorials/blogposts about building those yourself. But this stuff is a little "complicated" so this would be the hard route.
    Also this might give some insights regarding the pentagon issue. Andy also had an Asset utilizing this but I don't know if it's still available. Another one of him (Make it Random) has been taken away from the store.
     
    Bunny83 likes this.
  6. peepo12343

    peepo12343

    Joined:
    Jul 11, 2021
    Posts:
    12
    I know you can't create a sphere completely out of hexagons as there will always be 12 pentagons. Im trying to achieve this by having the 12 pentagons as most of the shapes will be hexagons. How did you approach making yours?
    example of what im trying to achieve.
    https://github.com/arscan/hexasphere.js
     
  7. peepo12343

    peepo12343

    Joined:
    Jul 11, 2021
    Posts:
    12
    Im trying to make it completely in code without using blender or probuilder. I create a icosahedron and subdivide it to create a spherical shape made out of triangles. The issue is changing the triangles into hexagons. (shape can't work without 12 pentagons)
     
  8. peepo12343

    peepo12343

    Joined:
    Jul 11, 2021
    Posts:
    12
    I planned to do this by distorting the shapes afterwards but the issue is generating the pentagons/hexagons first as im not sure where to start.
     
  9. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    If you really want one why not use a fish eye camera on a hex grid? Or ; rotate the sphere and somehow hide or regenerate the pentagon position so that the closest surface to the camera is always a hexagon, or rather if it is involving a selected tile, the sphere is recreated with a hexagon in place of a pentagon at a pentagons normal position when focussed. But this is aside the request — how to subdivide into one. To subdivide into one; I think you’ll need to focus on the alternating pentagons in order produce the hexagons as a byproduct of the pentagons positionings


    So say you had a triangle, the top point of the triangle draw a pentagon. The bottom points of the triangle draw a pentagon. The biproduct is a hexagon in the middle
     
  10. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    You mean something like this?

    HexMesh.png

    Im currently working on a dot net version of CGAL. Its early days but I have code that can do that.

    The PolyhedronExample scene is the one with the code in it from the unity CGALDotNet examples.

    It is windows 64 bit only and the license is GPL which maybe a issue if you want to do this at run time. As a editor tool it will be fine.

    Code (CSharp):
    1.  
    2.  
    3. //Create a polyhedron mesh that can have polygonal faces.
    4. var poly = PolyhedronFactory<EEK>.CreateIcosahedron();
    5.  
    6. //Subdive twice
    7. poly.Subdivide(2);
    8.  
    9. //Create the dual mesh which its the hexagon/pentagon mesh you want.
    10. var dual = poly.CreateDualMesh();
    11.  
    12. //Triangulate and convert to a unity mesh for rendering.
    13. var mesh = dual.ToUnityMesh("Dual", material, true);
    14.  
    15.  
     
    Last edited: Jan 27, 2022