2

Although I am quite experienced with most frameworks in iOS, I have no clue when it comes to 3D modelling. I even worked with SpriteKit, but never with something like SceneKit.

Now a customer wants a very ambitious menu involving a 3D object, an 'icosahedron' to be exact. I want it to look something like this:

Icosahedron shape example

So I just want to draw the lines, and grey out the 'see-through' lines on the back. Eventually I want the user to be able to freely rotate the object in 3D.

I already found this question with an example project attached, but this just draws a simple cube: Stroke Width with a SceneKit line primitive type

I have no clue how to approach a more complex shape.

Any help in the right direction would be appreciated! I don't even need to use SceneKit, but it seemed like the best approach to me. Any other suggestions are welcome.

Community
  • 1
  • 1
Tom van Zummeren
  • 9,130
  • 12
  • 52
  • 63

1 Answers1

3

to build an icosahedron you can use SCNSphere and set its geodesic property to YES.

Using shader modifiers to draw the wireframe (as described in Stroke Width with a SceneKit line primitive type) is a good idea.

But in your case lines are not always plain or dotted — it depends on the orientation of the icosahedron. To solve that you can rely on gl_FrontFacing to determine whether the edge belongs to a front-facing or back-facing triangle.

Community
  • 1
  • 1
mnuages
  • 13,049
  • 2
  • 23
  • 40
  • Wow thanks! I'm really impressed by your answer. It looks like you provided a solution for all my requirements! This week I am going to try this out myself to see if it really works. I will accept your answer as soon as I get it to work! – Tom van Zummeren Feb 27 '15 at 13:02
  • It looks like a SCNSphere is indeed the way to go! I accepted your answer. But can you maybe also explain how to use shader modifiers to draw the wireframe? – Tom van Zummeren Feb 28 '15 at 20:09