- Sat Aug 19, 2017 8:01 pm
#395125
How can I use script to render all cameras in the MXS ?
This is the script I used:
var inputFolder = "C:\input";
var outputFolder = "C:\output";
var engineVersion = Maxwell.getEngineVersion();
var mxsCount = FileManager.getNumberOfFilesInBranch( inputFolder, "*.mxs" );
var mxsList = FileManager.getFilesInBranch( inputFolder, "*.mxs" );
RenderEvents["renderFinished()"].connect(renderHasFinished);
var i = 0;
var isRendering = 0;
// to set the number of camera in the scene
var c = 5;
// to set each camera name
var k = ["From Yard","Living Room","Approach","Section Perspective","Kitchen"];
for( i = 0; i < c; i++ )
{
renderScene();
while( 1 )
{
if( isRendering == 0 )
{
break;
}
}
}
//////////////////////////////////////////////////////////////////
function renderScene()
{
var mxsFile = mxsList[0];
var imagePath = outputFolder + "\" + "%scenename%" + "_" + "%camera%" + ".png";
var mxiPath = outputFolder + "\" + "%scenename%" + "_" + "%camera%" + ".mxi";
Maxwell.print( "rendering Mxs file: " + mxsFile );
Maxwell.openMxs( mxsFile );
Mxi.setActiveCamera(k [ i ]);
Scene.setImagePath( imagePath );
Scene.setMxiPath( mxiPath );
Scene.setSamplingLevel( 4 );
Scene.setTime( 1 );
Scene.setAlphaChannelEnabled(1);
Scene.setMaterialIDChannelEnabled(1);
isRendering = 1;
Maxwell.startRender();
}
//////////////////////////////////////////////////////////////////
function renderHasFinished()
{
isRendering = 0;
Maxwell.print( "Render finished!!" );
}
//////////////////////////////////////////////////////////////////
The key issue for me is that using this script I always need to modify the number of camera or camera's name manually
Can anyone teach me how to improve this script? (The easy way to render all cameras in one MXS)
TKS!
This is the script I used:
var inputFolder = "C:\input";
var outputFolder = "C:\output";
var engineVersion = Maxwell.getEngineVersion();
var mxsCount = FileManager.getNumberOfFilesInBranch( inputFolder, "*.mxs" );
var mxsList = FileManager.getFilesInBranch( inputFolder, "*.mxs" );
RenderEvents["renderFinished()"].connect(renderHasFinished);
var i = 0;
var isRendering = 0;
// to set the number of camera in the scene
var c = 5;
// to set each camera name
var k = ["From Yard","Living Room","Approach","Section Perspective","Kitchen"];
for( i = 0; i < c; i++ )
{
renderScene();
while( 1 )
{
if( isRendering == 0 )
{
break;
}
}
}
//////////////////////////////////////////////////////////////////
function renderScene()
{
var mxsFile = mxsList[0];
var imagePath = outputFolder + "\" + "%scenename%" + "_" + "%camera%" + ".png";
var mxiPath = outputFolder + "\" + "%scenename%" + "_" + "%camera%" + ".mxi";
Maxwell.print( "rendering Mxs file: " + mxsFile );
Maxwell.openMxs( mxsFile );
Mxi.setActiveCamera(k [ i ]);
Scene.setImagePath( imagePath );
Scene.setMxiPath( mxiPath );
Scene.setSamplingLevel( 4 );
Scene.setTime( 1 );
Scene.setAlphaChannelEnabled(1);
Scene.setMaterialIDChannelEnabled(1);
isRendering = 1;
Maxwell.startRender();
}
//////////////////////////////////////////////////////////////////
function renderHasFinished()
{
isRendering = 0;
Maxwell.print( "Render finished!!" );
}
//////////////////////////////////////////////////////////////////
The key issue for me is that using this script I always need to modify the number of camera or camera's name manually
Can anyone teach me how to improve this script? (The easy way to render all cameras in one MXS)
TKS!