# File: cube5x5_new.py # Author: Petr Sorfa # Desc: This example is slightly different than the one printed in 3D Artist # Magazine #45. Version 0.1 of the A:M Python Script Plug-in had the # translate() function perform absolute transformations (i.e. a position # always from the centre of the universe. From version 0.2 the translate() # function is relative to any previous transformation. As a result, a # transform group is needed for each cube to mimic absolute translation. # Sure, the code could be rewritten, but then it would be a different # program, right? import am # import the Animation Master extension am.begin() # Initialize the AM session for x in range(5): # First loop 0 to 4 for the x position for y in range(5): # Second loop 0 to 4 for the y position for z in range(5): # Third loop 0 to 4 for the z position am.transform_begin() # Start a new transformation group am.translate(x*3,y*3,z*3) # Set the current position to x,y,z am.colour_diffuse (x/4.0, y/4.0, z/4.0) # Set the diffuse colour am.colour_specular (x/4.0, y/4.0, z/4.0) # Set the specular colour am.cube() # Create the cube at the current position am.transform_end() # end the current transformation group am.end() # Finish the AM session