Octohedron style icosphere ... does it exist?

Hi! I’ve been working on a game that has a procedurally generated world. I store it in 2 square arrays and project each half on to an octohedron internally. Poles are at the center equator around the edge. There is no ui yet other than a canvas app that dumps of the 2-d image (to-be used as atexture) so i know things wrap around the edges correctly that i would use for a texture.

ex:

I would like to give a visual to the users using some out of the box stuff. but i’m completely new to babylon js and open gl in general (though i’m old hat at most things web/server related) and haven’t found a good way to do this.

I found the Create Polyhedra - Babylon.js Documentation and the fantastic transformation of a d-20 into a sphere https://www.babylonjs-playground.com/#E3TVT#1 with the subdividing… if i could do that with an 8 sided polyhedron that would be perfect. I guess i could try building my own mesh (but again completely new to this) but i was trying not to. It feels like something that should already exist. does it?

I’ve looked everywhere via google and other than some one sharing some python code ( Octahedron Subdivision they have a working example which is nice ) and maybe something in unity (maybe not relevant Octahedron Sphere, a Unity C# Tutorial ) but I haven’t found anything in babylon js (or three js or even plain open gl) … If the answer is, “it doesn’t exist” that’s cool was just hoping to hear from those who know better beore i try reinventing the wheel. thanks!

maybe @JohnK or @jerome could help

Hi @James_Scheibel and welcome from me.

It is stiil fairly straight forward to build one Babylon.js Playground

4 Likes

wow thanks so much! Just now trying to understand how it works. increaseVertices (something i didnt know existed…again, i’m new here) and how you deal with the verticies… i didnt know that’s how it worked or that you could move the length of each with a normalize and set the values back. very nice! you saved me probably 12 hours of trying to understand waht to do. not to mention taught me a lot in this little example. again thanks! I’ll be sure and pop back when i’ve finished the final result (just so you can see for fun)

1 Like

here is the final product if you are curious.

https://www.babylonjs-playground.com/#ADLTV8#1

I’ll probably do some rotating/positioning changes to the base texture so i don’t have the “cracks” between hemispheres… and so that i dont have so much conditional logic to get the orientation of each texture right. but the point is this seems to work great! I’m pleased with the result. thanks again for your help!

(now to go write my blog :smiley: and actually have something other than a 2d image to show :smile: )

@JohnK always impessed by your answers :slight_smile:

1 Like