# File: surface_colour.py # Author: Petr Sorfa # Desc: This example creates a simple 9x9 grid with some semi-random # surface protrusions. A Python function is used to create the # surface. Each cell of the mesh is assigned a different colour. import am import math #----------------------------------------------------------------------------- # make_surface function for creating a simple surface grid with semi-random # surface bumps and different cell colours. #----------------------------------------------------------------------------- def make_surface (): am.surface_begin() for i in range(1, 10): # Loop value from 1 to 9 row = [] for j in range(1, 10): # Loop value from 1 to 9 k = math.sin(i*j)/2.0 # Calculate the height row += [j, k, i] am.surface_add(row) # Assign the different colour cells for i in range(1, 9): for j in range(1, 9): am.colour_diffuse(i/8.0, j/8.0, (i+j)/16.0) am.surface_attribute_cell(i, j) am.surface_end() #----------------------------------------------------------------------------- # Main program #----------------------------------------------------------------------------- am.begin() make_surface() am.end()