Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import bmesh
- import math
- n = 1000 # number of points
- c = 0.1 # scale factor
- mesh = bpy.data.meshes.new(name="Spiral")
- bm = bmesh.new()
- for i in range(0, n):
- theta = i * math.radians(137.5)
- r = c * math.sqrt(i)
- bm.verts.new((math.cos(theta) * r, math.sin(theta) * r, 0.0))
- bm.to_mesh(mesh)
- mesh.update()
- from bpy_extras import object_utils
- object_utils.object_data_add(bpy.context, mesh)
- import bpy
- import math
- import mathutils
- from mathutils import Euler
- # make sure 3d cursor is at the center of the scene
- num_items_in_spiral = 13
- num_spiral_arms = 29
- z_rotation = 2.0 * math.pi / num_spiral_arms
- # add cone, modify the mesh,
- bpy.ops.mesh.primitive_cone_add(vertices=12, radius1=0.354406, depth=0.901211)
- obj = bpy.context.active_object
- obj.data.transform(mathutils.Matrix.Translation((-0.5, 0, 0)))
- # add empty for spiral arm
- bpy.ops.object.empty_add()
- obj = bpy.context.active_object
- obj.name = "Empty_spiral"
- obj.location = (-0.8, 0, 0)
- obj.rotation_euler = Euler((0, 0, 0.179609), 'XYZ')
- # add empty for radial array
- bpy.ops.object.empty_add()
- obj = bpy.context.active_object
- obj.name = "Empty_radial_array"
- obj.rotation_euler = Euler((0, 0, z_rotation), 'XYZ')
- # add modifiers to the cone
- obj = bpy.data.objects["Cone"]
- mod = obj.modifiers.new(name="Array_1", type='ARRAY')
- mod.use_relative_offset = False
- mod.use_object_offset = True
- mod.offset_object = bpy.data.objects["Empty_spiral"]
- mod.count = num_items_in_spiral
- mod = obj.modifiers.new(name="Array_2", type='ARRAY')
- mod.use_relative_offset = False
- mod.use_object_offset = True
- mod.offset_object = bpy.data.objects["Empty_radial_array"]
- mod.count = num_spiral_arms
- function sflo1 ( N:float,k:int):Vector3{//phi based pylospiral
- //N=numpts k=currentpt
- k=k;
- var inc = Mathf.PI * ( 3 - Mathf.Sqrt ( 5 ) );
- var off = 2 / N;
- var y = k * off - 1 + (off / 2);
- var r = Mathf.Sqrt (Mathf.Abs(y)) ;
- var phi = k * inc;
- return Vector3(-Mathf.Cos(phi)*r, 0, -Mathf.Sin(phi)*r);
- };
- function sflo ( N:float,k:int):Vector3{//easy formula based on 137.5 pylospiral
- var n = k;
- var r=Mathf.Sqrt (n)*1/(Mathf.Sqrt (N));;
- var t=137.5*pi/180*n;
- return Vector3(r*Mathf.Cos(t),0, r*Mathf.Sin(t));
- }
- function sflosq ( N:float,k:int):Vector3{//my own version it's stupid!
- //N=numpts k=currentpt
- var inc = Mathf.PI * ( 3 - Mathf.Sqrt ( 5 ) );
- var off = 2 / N;
- var y = k * off - 1 + (off / 2);
- var r = Mathf.Sqrt (Mathf.Abs(y)) * Mathf.Sign(y) ;
- var phi = k * inc;
- return Vector3(Mathf.Asin(Mathf.Cos(phi))*r, 0, (-Mathf.Acos(Mathf.Sin(phi))+pi/2)*r);
- };
- import bpy
- import bmesh
- import math
- from mathutils import Vector
- n = 400 # number of points
- r = 3 #radius
- ob = bpy.context.object
- obs = []
- sce = bpy.context.scene
- for i in range(1, n):
- theta = i * math.radians(137.5)#degrees
- phi = (math.radians(180)/n) * i
- x = r*math.sin(phi)*math.cos(theta)
- y = r*math.sin(phi)*math.sin(theta)
- z = r*math.cos(phi)
- if x<0:
- a = x*(-1)
- else:
- a = x
- if y < 0:
- b = y*(-1)
- else:
- b = y
- c = math.sqrt((a*a)+(b*b))
- size = 0.06+(c*0.09) #This can be messed about with to get the right size
- copy = ob.copy()
- copy.location = (x,y,z)
- copy.scale = (size,size,size)
- copy.rotation_euler=(phi,math.radians(0),theta+math.radians(90))
- copy.data = copy.data.copy()
- obs.append(copy)
- for ob in obs:
- sce.objects.link(ob)
- sce.update() # don't place this in either of the above loops!
- import bpy
- import bmesh
- import math
- from mathutils import Vector
- # prepare a scene
- scn = bpy.context.scene
- ob = bpy.context.object
- #number of frames
- n = 143
- #degrees to rotate
- d = 0 #Change to apply spin
- for i in range(0, n):
- bpy.context.scene.frame_set(i)
- # do something with the object. A rotation, in this case
- ob.rotation_euler=(0.0,0.0,math.radians(d))
- d = (d + 137.5) #Change to subtract to change direction of appeared flow
- # create keyframe
- bpy.ops.anim.keyframe_insert_menu(type='Rotation')
Add Comment
Please, Sign In to add comment