Wednesday, December 10, 2008

More space rocks!


Here's more tinkering with procedurally generated objects in Python.

Here's the key part of the code:

for i in range(0, n, 1):
    for j in range(0, n, 1):
        x = sin(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*(radius+2*random())
        y = cos(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))* (radius+2*random())
        z = sin(-pi/2+i*pi/(n-1))*(radius+.0*random())
        v=NMesh.Vert( x , y , z )
        me.verts.append(v)

No comments: