#Creat 12 vertices of a icosahedron
surfTool.add_vertex(Vector3(-1,t,0))
surfTool.add_vertex(Vector3(1,t,0))
surfTool.add_vertex(Vector3(-1,-t,0))
surfTool.add_vertex(Vector3(1,-t,0))
…etc
I’m trying to convert this python script
which was derived from this page There is another version of this script in python in the comments by Miles Marx 5 months ago. That’s the script I started to use.
I’m just a beginner so translating the code is rather difficult for me. I’m getting stuck on how to convert the classes and functions to work in gdscript I was looking for a hexagonal sphere but this was the next best thing. Then I have to figure out how to map it so that i can randomly generate nodes( or points of interest) on the surface. (it’s going to be a planet that will only be viewed from afar) I’m almost wondering if there is a way to do this in blender and if that would be easier. Any help would be appreciated.
And you can review it’s source if you want specific examples of how to use the SurfaceTool.
I suppose I don’t have to do it dynamically. I could always create 3 or 4 different sizes of the sphere. Is there a way to plot several points on a sphere mesh at random?
CraftyManiac | 2017-01-08 05:57
Nothing that I know of built-in.
The solution you’re looking for is in 3D math.
The simplest one I can think of is generating a random 3D vector, normalizing it, and then multiplying it by the sphere’s radius. Then add the vector to the center position of the sphere, and it should be a point on the surface. I would test that though, that’s just off the top of my head.
If it has to be something that matches some blocky sphere’s collision bounds, then you may have to use a random raycast from center to find the surface point.
avencherus | 2017-01-08 06:14
Ok I will see what I can come up with. Thank’s for your help!
CraftyManiac | 2017-01-08 06:20
No problem. X)
I tested it, it works.
The code is something like:
var rand_vec = Vector3(rand_range(-1,1), rand_range(-1,1), rand_range(-1,1))
var rand_surface_point = sphere_position + rand_vec.normalized() * radius
Ahh I see what you mean. I kind of meant how would i plot points on to the face of the icoscphere. like the black dots in the center of the faces in the image. Only populating some points at random not all.