# File: attribute_spheres.py # Author: Petr Sorfa # Desc: Several spheres demonstrating the # different colour attributes. import am import math #----------------------------------------------------------------------------- # make_sphere function that makes a unit sphere of radius 1.0 #----------------------------------------------------------------------------- def make_sphere(): sphere_res = 6 am.surface_begin() for angle0 in range(sphere_res): ang0 = math.pi*angle0/(sphere_res-1) + math.pi/2.0 x0 = math.cos (ang0) y0 = math.sin (ang0) row = [] for angle1 in range(sphere_res): ang1 = math.pi*2*angle1/(sphere_res) x1 = x0*math.cos (ang1) y1 = x0*math.sin (ang1) row += [x1, y0, y1] am.surface_add_row (row) am.surface_set_closed () am.surface_end() #----------------------------------------------------------------------------- # Main program bit #----------------------------------------------------------------------------- space = 2.2 am.begin() #----------------------------------------------------------------------------- # Create a background surface #----------------------------------------------------------------------------- am.transform_begin() am.colour_diffuse (1.0, 1.0, 1.0) am.translate (0,0,-1) am.surface_begin ("background") am.surface_add_row([0,2,0,25,2,0]) am.surface_add_row([0,-32,0,25,-32,0]) am.surface_end () am.transform_end() #----------------------------------------------------------------------------- # Set general sphere colour #----------------------------------------------------------------------------- am.colour_diffuse (0, 0, 1) #----------------------------------------------------------------------------- # Diffuse fall off iteration #----------------------------------------------------------------------------- am.translate (0,-1,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_diffuse_fall_off (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Ambiance iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_ambiance (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() am.colour_specular (0, 1, 0) #----------------------------------------------------------------------------- # Specular size iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_specular_size (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Specular intensity iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_specular_size (1.0) for i in range(10): am.colour_specular_intensity (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Roughness iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_roughness (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Roughness scale iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_roughness (1.0) for i in range(10): am.colour_roughness_scale (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Transparency iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_transparency (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Density iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_transparency (0.7) for i in range(10): am.colour_density (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Refraction iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_transparency (0.7) for i in range(10): am.colour_refraction (1.0 + i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Translucency iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_transparency (0.7) for i in range(10): am.colour_translucency (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Reflectivity iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_transparency (0.7) for i in range(10): am.colour_reflectivity (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Reflectivity fall off iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_transparency (0.7) am.colour_reflectivity (0.8) for i in range(10): am.colour_reflectivity_fall_off (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Radiance iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() for i in range(10): am.colour_radiance (i/9.0) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() #----------------------------------------------------------------------------- # Glow radius iteration #----------------------------------------------------------------------------- am.translate (0,-space,0) am.transform_begin() am.attribute_begin() am.colour_radiance (1) for i in range(10): am.colour_glow_radius (10*i) am.translate (space, 0, 0) make_sphere() am.attribute_end() am.transform_end() am.end()