[Closed] Render – Different cameras per frame
hi everybody,
i am working on this small script which …
- enables me to render all my 9 cameras per frame and places the rendered images in the respective folders:
global myCams=#("Camera01","Camera02","Camera03","Camera04","Camera05","Camera06","Camera07","Camera08","Camera09");
global renCam;
-- animationrange.end
for t = animationrange.start to 9 do
(
sliderTime=t;
print (t as string +"Frame
");
for c = 1 to myCams.count do
(
makeDir ("D:\\TestRenders\\"+(myCams[c]) as string);
print ("camera "+c as string);
renCam=getnodebyname (myCams[c]) exact:true
render camera:renCam frame:t vfb:false outputheight:250 outputwidth:250 outputfile:("d:\\TestRenders\\"+(myCams[c]) as string+"\\"+t as string+c as string+".jpg")
)
)
- now i’ve also the need that i need to combine (stitch) all these images – 9 images into one image at the end and delete those 9 images. i’ll need to automate it as i might end up with thousands of renders.
but i was wondering how i can merge these two steps into one : say i render each camera’s image into a single image (region render ?) and i keep filling the whole image , which is like 100 in height and (250 * 9 cameras) in width ? this will merge the above 2 steps into one right ?
i have some thing like : (i’m missing and pls correct me …)
global myCams=#("Camera01","Camera02","Camera03","Camera04","Camera05","Camera06","Camera07","Camera08","Camera09");
global renCam;
-- animationrange.end
for t = animationrange.start to 9 do
(
sliderTime=t;
print (t as string +"Frame
");
for c = 1 to myCams.count do
(
makeDir ("D:\\TestRenders\\"+(myCams[c]) as string);
print ("camera "+c as string);
renCam=getnodebyname (myCams[c]) exact:true
rw=900 -- the overall width of the rendered image
rh=200 -- the height of the cropped row (ie 50 pixels high)
leftP=0
rightP=(leftP * c)
fname="d://TestRenders//bow.jpg" -- the filename of the output
------------------------------------------------------------
render camera:renCam frame:t rendertype:#region region:[(leftP*c),(leftP*c),(rightP+100),(rh)] outputfile:fname
-- render camera:renCam frame:t vfb:false outputheight:250 outputwidth:250 rendertype:#normal region:[0,0,20,20] outputfile:("d:\\TestRenders\\"+(myCams[c]) as string+"\\"+t as string+c as string+".jpg")
)
)
but i get – Runtime error: Region rendering only available on active view >> then how do i use the renderType:region option ? and what does it mean by ’ active view ‘?
can anybody guide me how to go about it ? how do i fill a image in blocks, each black -a render of each of my camera ?
rgds,
The active view is the one with the yellow highlight around it – the CURRENT view.
You can set the view to your current camera using
viewport.setCamera renCam
Then, do not specify the camera in the render() method, which will render the current view.
Still, I would say it is smarter to render to separate images and then stich together.
One of the reasons is that you might want to play with the stitching parameters and perform the operation multple times from the same source files.
The Avguard DLX Extensions plugin by Larry Minton available from www.scriptspot.com contains a fast bitmap copy function that lets you copy a portion of a bitmap (or a whole image) into a specified location of a target bitmap. This should speed up the stitching alot. Otherwise, you would have to loop through pixel lines with getPixels and paste with setPixels calls…
hello BOBO, the savier !
thanx for ur tips…
i’m new to using extensions and is there a tutorial on how to use the installed .dlx extensions ? and how do i connect to the extension through max script ?
and rethinking of my idea, i think it wont work… i’m trying to render a region of the viewport with the ’ renderType:region ’ but how does max know that each of the render needs to be put into a ‘particular region’ into the target image ? i think i dont need the region render …but can i tell max to put renders of different cams into particular regions of a target image at render time ?
but s, i agree with u… rendering separatly and then stitching is what i ‘ll need to do…
i’ve been studying region net render where in this render.ms script, he has a function called sewit :
......
b_out = bitmap dat.imgw dat.imgh
........
for i in 1 to slice_y do
for j in 1 to slice_x do
(
pos_y = r_size_y[i]
if x < 10 then x_txt = ("000" + x as string) else x_txt = ("00" + x as string)
b = openbitmap (filespath + "\\" + (getfilenamefile dat.maxfname) + x_txt + ".tga")
for k in 1 to (dat.sliceh + 1) do
(
row = [b]getpixels b [r_size_x[j],pos_y] dat.slicew[/b]
[b]setpixels b_out [r_size_x[j],pos_y] row[/b]
pos_y +=1
)
deletefile (filespath + "\\" + (getfilenamefile dat.maxfname) + x_txt + ".tga")
progressupdate ((x*100/slice_y/slice_x))
close b
gc()
x += 1
)
save b_out
in this, can u tell me what does this : “b_out = bitmap dat.imgw dat.imgh” < i’ve checked in help and couldnt find what imgw and imgh do ? how do i load and image into a variable so i can use the ‘save b_out’ command , since it doesnt work with images loaded thru openBitmaps command ?
and i guess the lines in bold… is what u were mentioning about reading and setting pixels in a loop right ?
about the stitching, BoBo, i need them to all sit one-beside each other like say : [A] + [B] > [AB] they just have to be sitting next to each other finally.
-rgds,