--MAXScript Tutorials --LESSON 01 --by Borislav Petrov [FA] --bobo@email.archlab.tuwien.ac.at ----------------------------------------------- --Visit --http://support.ktx.com/~10 --for more MAXScript information and resources. --Visit the Diner --http://support.ktx.com/~8 --for a public discussion on these Tutorials. ----------------------------------------------- --Open a New Max scene --Load the script --PRESS Ctrl+E to Evaluate work_bmp = openbitmap "c:\\mxstut\\m.tga" --open an existing TGA bitmap from the tutorials directory. --make sure to change the path if your path is different. bmp_w = work_bmp.width --read the width of the bitmap into a variable bmp_h = work_bmp.height --read the height of the bitmap into a variable progressstart "Generating Objects..." --display progress indicator for h = 1 to bmp_h do --loop through all rows in the image ( pixel_line = getpixels work_bmp [0,(h-1)] bmp_w --store a single row #h into an array progressupdate (h as float /bmp_h *100) --update the progress indicator for w = 1 to bmp_w do --loop through all pixels in the current row ( size_value = 100 + (pixel_line[w].r+pixel_line[w].g+pixel_line[w].b)/3 --calculate a value based on the luminosity (R+G+B)/3 of the pixel. new_object = box length:100 width:100 height:size_value --create a new box with height based on the pixel value above new_object.pos = [w*100, (-h*100), 0] --put the new object on a new position based on the pixel's coords. --NOTE that in MAX, 0,0 is lower left corner, in images the UPPER left --this explains the - sign in (-h*100) --100 is the distance between objects. new_material = standardmaterial diffuse:pixel_line[w] --create a new standard material with diffuse color taken from the pixel's color new_object.material = new_material --assign the new material to the new object )--end w loop )--end h loop progressend () --end of the progress display close work_bmp --close the bitmap