Notifications
Clear all

[Closed] how to write a loop for a series of actions

Hi,
I have 1000 photos and want to map one by one into a 3d cube and save the result as an image by writing a loop using scripting, one sample photo will look like this:
http://www.canvasondemand.com/canvas-gallery.asp?cid=2&sid=123

Is this poosible? if yes really apprecite any sample code or directions.
thx

2 Replies

Here is some help to get you started.

Well commented


(
	local lastBox = undefined	-- remembers the last box you created
		
	-- Put all your pictures in the directory below, or modify to suit your needs, this function does not search recursively
	thePictures = getFiles "C:\\My Documents\\My Pictures\\*.jpg"
	
	for pic in thePictures do (
		-- create the Material
		local theMaterial = standard name:pic diffuseMap:(BitmapTexture filename:pic)
		showTextureMap theMaterial theMaterial.diffuseMap on
		-- create the Box
		if lastBox != undefined then ( local thebox = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:1 width:10 height:10 mapcoords:on pos:[(lastBox.pos.x + (lastBox.width+5)),0,0] material:theMaterial )
		else local thebox = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:1 width:10 height:10 mapcoords:on material:theMaterial
		
		-- show the diffusemap in viewport
		theBox.material.diffuseMap.viewImage()
		
		lastBox = theBox
	)
)

 

Some issues are, if the picture is not a square, it will not appear correct, also a boxes default mapping is on a per-face basis, judging from your link, it appears you want to to look like it’s stretched around a canvas. I’ll let you figure them out

Best of luck, ask away.
Colin

This would be infinitely easier with a single grayscale render from max for the lighting and perspective and a photoshop batch script.

-Create photoshop file with proper masks for two sides of cube.

create batch script:

  • Transform perspective.
  • Apply Mask.
  • Set transfer mode to multiply.

Run batch script on folder of images.