Notifications
Clear all

[Closed] Assign an image sequence to and object sequence?

Hello,

Im wanting to find an easy way to assign an image sequence to a bunch of objects

One image per object:
001.jpg to object_001
002.jpg to object_002)

Thanks in advance people : )

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

what do you mean by ‘assigning an images to an object’?

 lo1
----USER VARIABLES----------------
thePath=@"C:\Your_folder\"
theKey="*.jpg"
objectPattern="object_*"
------------------------------------------

theFiles=getFiles (thePath+theKey)
theFileNums=#()
for i = 1 to theFiles.count do append theFileNums (substituteString (getfilenamefile theFiles[i]) (trimRight (getfilenamefile theFiles[i]) "0123456789") "")
for o in objects where (matchpattern (tolower o.name) pattern:objectPattern) do
(
	local oNum=formattedPrint ((substitutestring o.name (trimRight o.name "0123456789") "") as integer) format:"04d"
	local bIndex=finditem theFileNums oNum
	if  bIndex > 0 do o.material=standardMaterial diffusemap:(bitmapTexture filename:(theFiles[bIndex])) name:(o.name)	
)

here you go…
Fill out the info in the first 3 variables, should be rather self explanatory.
Haven’t tested it thoroughly, so let me know if it doesn’t work properly.

Here’s something I use for that sort of thing – it takes an array of images and creates a plane based on a few parameters- relative size, and which viewport to align to.

(
local PosOffset 	
	/*
	options 
	SizeRatio - a float value to size the plane as a multiplier of the original map height
	ViewportAlign - specify a number
	1-Top
	2-Front
	3-Left
	4-Right
	*/

	fn MakeFlatObjects FullMapPath SizeRatio ViewportAlign =
	(
	BMopen = openBitMap FullMapPath
	BMheight = BMopen.height
	BMwidth = BMopen.width 
	BitmapTextMap = Bitmaptexture fileName:FullMapPath
	MapName = getFilenameFile FullMapPath

	OMap = StandardMaterial ()
	OMap.name = MapName
	OMap.twoSided = on
	OMap.diffuseMap = BitmapTextMap
	OMap.diffuseMap.name = MapName + "_DiffuseMap"

	OMap.diffuseMap.monoOutput = 0
	OMap.diffuseMap.rgbOutput = 0
	OMap.diffuseMap.alphaSource = 2
	OMap.diffuseMap.preMultAlpha = off
	OMap.diffuseMap.coords.blur = 0.01
	
	Omap.selfIllumAmount = 100	
	Omap.diffusemap.coords.U_Tile = false
	Omap.diffusemap.coords.V_Tile = false

	if BMopen.hasalpha do
	(
	OpacityTextMap = Bitmaptexture fileName:FullMapPath
	OMap.opacityMap = OpacityTextMap
	OMap.opacityMap.name = MapName + "_OpacityMap"
	OMap.opacityMap.monoOutput = 1
	OMap.opacityMap.rgbOutput = 1
	OMap.opacityMap.alphaSource = 0
	OMap.opacityMap.preMultAlpha = off
	OMap.opacityMap.coords.blur = 0.01
	Omap.opacityMap.coords.U_Tile = false
	Omap.opacityMap.coords.V_Tile = false			
	)

	showTexturemap Omap true
	PlaneObj = Plane  length:((BMheight as float/100)*sizeratio) width:((BMwidth as float/100)*sizeratio)  mapcoords:false name:MapName motionblur:#object
	PlaneObj.showFrozenInGray = off
	PlaneObj.pos += [PosOffset+(PlaneObj.width/2),0,0]
	PosOffset +=planeobj.width
	PlaneObj.material = Omap

	case ViewportAlign of
	(
		1:()
		2:(in coordsys (transmatrix PlaneObj.transform.pos) PlaneObj.rotation = (eulerangles -90 0 0))
		3:(in coordsys (transmatrix PlaneObj.transform.pos) PlaneObj.rotation = (eulerangles -90 90 0))
		4:(in coordsys (transmatrix PlaneObj.transform.pos) PlaneObj.rotation = (eulerangles -90 -90 0))
	)

	local ratio  = BMwidth/BMheight as float
	paramWire.connect2Way PlaneObj.baseObject[#length] PlaneObj.baseObject[#width] ("Width / "+ratio as string) ("Length * " + ratio as string)
	max select all
	max zoomext sel
	clearselection()
	max views redraw

	close BMopen
	)
	
	PosOffset  = 0
	files = getfiles @"C:\Users\Public\Pictures\Sample Pictures\*.jpg"
	for o in files do MakeFlatObjects o 2. 1 

)

thanks people – I’ll try those scripts out!

denisT – I wanted the objects to use its corresponding .jpeg as its diffuse channel – could use materials ids etc – but I wasn’t sure a fast way

Thanks scripters – I will do my best to ‘understand’ the scripts too