Camera Aspect Ratio Script

The new version of my book is well under way.

By the way, here's a useful method:

Code:
function searchChildren(obj, callback, found){
    found || (found = []);
    for(var i = 0; i < obj.childCount(); i++){
        var child = obj.childAtIndex(i);
        if(callback(child)){
            found.push(child);
        }
        searchChildren(child, callback, found);
    }
    return found;
}

// which lets you write a one-liner like this
var cameras = searchChildren(doc.root(), function(obj){ return obj.type() === CAMERA; });

This would make it easy to set all cameras. The current camera is doc.activeCamera() so that's already easy.
 
Hi,
this code snippet shows how to set the renderer resolution in v7.

Code:
var renderer = doc.currentRenderer();
if(renderer != null)	renderer.setParameter("resolution",new Vec2D(resX,resY));
else	                print("camera is null");
 
Thanks pod, a lot of that code goes way over my head, but I'll see if I can decipher it.

Thanks Martin! That works perfectly. I'll post the updated script so if anyone else wants to use it they can.

I appreciate both of you helping with this. Maybe one day I'll get better at this stuff.
 
Ah right — the camera resolution stuff is legacy cruft now :)

Yep! That was part of my confusion. I wasn't sure if it was being passed through the camera maybe to the renderer. Clearly though now it is going straight through. The renderer(s) aren't objects though, so a little difficult (at my pay grade anyway) to point at and interrogate them with a script.

Thanks again for the help and good luck on new edition book! Looking forward to it coming out when you publish.

:cool:
 
Back
Top