update :
ik heb wat freebasic code vertaald
en wat python code toegevoegd
die ik op WWW gevonden heb
dit is een poging tot een supersphere
error :
de IDE herhenk utils niet
import utils
from math import pi , sin , cos , abs
verts = list()
faces = list()
def sphere_mesh( m , n , a , b ) :
for col in xrange( m ) :
for row in xrange( n ) :
i = row * pi * 2 / n
j = col * pi * 2 / m
x = sin( i ) * cos( j )
y = sin( j )
z = cos( i ) * cos( j )
point = ( abs( x ) ** da * sgn( x )
, abs( y ) ** db * sgn( y )
, abs( z ) ** da * sgn( z ) )
point = surface(u, v)
verts.append(point)
# Connect first and last
# vertices on the u and v axis
rowNext = (row + 1) % n
colNext = (col + 1) % m
# Indices for each qued
faces.append(((col*n) + rowNext,
(colNext*n) + rowNext,
(colNext*n) + row, (col*n) + row))
#print('verts : ' + str(len(verts)))
#print('faces : ' + str(len(faces)))
# Create mesh and object
mesh = bpy.data.meshes.new(name+'Mesh')
obj = bpy.data.objects.new(name, mesh)
obj.location = origin
# Link object to scene
bpy.context.scene.objects.link(obj)
# Create mesh from given verts and faces
mesh.from_pydata(verts, [], faces)
#Update mesh with new data
mesh.update(calc_edges=True)
return obj
if __name__ == '__main__' :
# Remove all elements
utils.removeAll()
# Create camera
bpy.ops.object.add(type='CAMERA',
location=(0, -3.5, 0))
cam = bpy.context.object
cam.rotation_euler = Euler((pi/2, 0, 0), 'XYZ')
# Make this the current camera
bpy.context.scene.camera = cam
# Create lamps
utils.rainbowLights()
# Create object and its material
sphere = sphere_mesh( 12 , 12 , 2 , 2 )
utils.setSmooth( sphere , 3 )
utils.renderToFolder( 'rendering' ,
'test_sphere' , 500 , 500 )