Given an MXS which contains several cameras, the below script will render each one in succession without revoxelization. The cameras need to be named in such a way that the script can automatically build the name of each one. So for example, this was written to be used with SketchUp, which follows the naming convention:
Scene 1,
Scene 2,
Scene 3, etc.
You can see near the top of the script the three main variables:
firstFrame,
lastFrame, and
baseName. These are the only variables you will need to customize, and the way of doing so should be somewhat self-explanatory; given an MXS containing cameras named
Camera.1,
Camera.2,
Camera.3, and
Camera.4, you would set the script up like this:
Code: Select allvar firstFrame = 1;
var lastFrame = 4;
var baseName = "Camera.";
And here is the script; to use it, paste into the script window in Maxwell Render, then hit the
Run Script button (you can also save it to file for later use):
Code: Select all// This script loops through a set of cameras, specified by name and
// index. It must be customized to fit the characteristics of the given
// MXS file. As set up, it expects to find the MXS filled with cameras
// whose names begin with 'Scene '. This base name is stored below
// in the 'baseName' variable. It expects the scene numbers to begin
// at 1 and to end at 3, with these limits being stored below in the
// 'firstFrame' and 'lastFrame' variables. It will loop through the frame
// range looking for cameras which fit the pattern 'Scene 1', rendering
// each one as it is found.
var firstFrame = 1;
var lastFrame = 3;
var baseName = "Scene ";
// internal vars & events
var isRendering = 0;
var currentFrame = firstFrame;
var outputFolder = FileManager.getFileFolder(Scene.mxsPath);
RenderEvents["renderFinished()"].connect(renderHasFinished);
// render loop
while (currentFrame <= lastFrame)
{
renderCamera(currentFrame);
while(1)
{
if(isRendering == 0)
{
break;
}
}
currentFrame++;
}
// functions
function renderCamera(frameNumber)
{
var sceneName = baseName + frameNumber;
Scene.setActiveCamera(sceneName);
if (Scene.activeCameraName != sceneName)
{
Maxwell.print("The MXS contains no camera named '" + sceneName + "'!");
}
else
{
Maxwell.print("rendering Scene: " + sceneName);
Scene.setMxiPath(outputFolder + "\" + sceneName + ".mxi");
Scene.setImagePath(outputFolder + "\" + sceneName + ".png");
isRendering = 1;
Maxwell.startRender();
}
}
function renderHasFinished()
{
isRendering = 0;
Maxwell.print("Render finished!!");
}