#* #* Moonlight|3D #* Copyright (C) 2006 The Moonlight|3D team #* #* This library is free software; you can redistribute it and/or #* modify it under the terms of the GNU Lesser General Public #* License as published by the Free Software Foundation; either #* version 2.1 of the License, or (at your option) any later version. #* #* This library is distributed in the hope that it will be useful, #* but WITHOUT ANY WARRANTY; without even the implied warranty of #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #* Lesser General Public License for more details. #* #* You should have received a copy of the GNU Lesser General Public #* License along with this library; if not, write to the Free Software #* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #* #* Created on Jan 14, 2006 ########### # This script automatically renders all icons needed for the Moonlight|3D toolchest. # # It is a great example of how Moonlight|3D can be scripted to automate otherwise # tedious tasks. ########### import ml tools=ml.core.State.getInstance().getToolsManager().getToolList() def loadScene(filename): # clear operator graph and selections ml.core.State.getInstance().getDocumentManager().getMainDocument().getSelectionManager().clearSelections(); ml.core.State.getInstance().getDocumentManager().getMainDocument().getOGManager().clear(); # load file fileReader=ml.file.moonlight.FileReader(filename); fileReader.run(); ml.core.State.getInstance().getOGManager().update(); def renderScene(outputFilename): renderManager = ml.core.State.getInstance().getRendererManager(); yafray = renderManager.getRenderEngine("Sunflow"); framebuffer = yafray.renderCurrentOG(); formatManager=ml.core.State.getInstance().getFormatManager() formatManager.saveImage(framebuffer,outputFilename,"PNG"); def renderImage(filenameBase): inputFilename="icons/source/"+filenameBase+".ml" outputFilename="icons/"+filenameBase+".png" loadScene(inputFilename) renderScene(outputFilename) renderImage("createPolygon") renderImage("createPolyBox") renderImage("createPolyCone") renderImage("createPolyCylinder") renderImage("createPolySphere")