# File: logspiral_colour.py # Author: Petr Sorfa # Desc: A log spiral shell based on work by # Oyvind Hammer (http://www.notam.uio.no/~oyvindha/loga.html) # Adds colour to the mesh rows and a single column. import math # import the math extension import am # import the Animation Master extension am.begin() # Initialize the AM session am.surface_begin() # Begin creating an AM surface for i in range(50): # For loop 0 to 49 theta = i/1.0 r=math.exp(theta*0.09) d=0.55*r row=[] # Initialize the current row of points to nothing for j in range(10): # Second loop 0 to 9 phi=2.*math.pi*j/7.999 x=d*math.cos(phi)*math.cos(theta) z=d*math.sin(phi) y=d*math.cos(phi)*math.sin(theta) x+=r*math.cos(theta) # Create the x position y+=r*math.sin(theta) # Create the y position z+=r*1.9 # Create the z position row+=[x,y,z] # Add the new position to the row am.surface_add(row); # At the end of the second loop, add the row of points to the surface for i in range(1,50): # Assign the different colour rows - bumble bee if i & 1 == 0: am.colour_diffuse(1.0, 0.0, 0.0) else: am.colour_diffuse(0.0, 1.0, 1.0) am.surface_attribute_row(i) # Assign a colour to a single column am.colour_diffuse(0.0, 1.0, 0.0) am.surface_attribute_column(7) am.surface_end() # End the surface and create it am.end() # Finish the AM session