Change active camera

Change active camera

I have multiple cameras set up in a document. How can I toggle between them for rendering, i.e. how can you change the active camera in a script?

The manual documents doc.activeCamera(), but no method to actually set it.
 
hi.

To change active camera, you can directly set a boolean parameter named 'activeCamera' of camera object. Object browser is not updated correctly, but this code seems to work internally. :)

Code:
function makeActiveCamera( cam ) {
	var doc = cam.document();
	var active_cam = doc.activeCamera();
	
	if ( cam.type() == CAMERA && active_cam != cam ) {
		active_cam.setParameter("activeCamera", 0);
		cam.setParameter("activeCamera", 1);
		
		cam.update();
		active_cam.update();
	}
}

regards.

tg_jp, Hiroto.
 
hi.
To change active camera, you can directly set a boolean parameter named 'activeCamera' of camera object. Object browser is not updated correctly, but this code seems to work internally. :)

Indeed, wonderful :) Well, I have spotted the 'activeCamera' property in the JAS-file, but for some reason ALL camera objects have set this boolean value to 'true'. Calling update() seems to do the trick. The method is not documented though, is it?

Thank you.
 
Back
Top