diff --git a/sandbox/extras/maya/README.txt b/sandbox/extras/maya/README.txt index 6b81f17bb8..7f846536d6 100644 --- a/sandbox/extras/maya/README.txt +++ b/sandbox/extras/maya/README.txt @@ -2,4 +2,15 @@ Mayaseed is a Maya plugin for exporting camera, material and geometry data to th Mayaseed documentation is available here: http://appleseedhq.net/documentation/mayaseed. +Features +======== + ++ material auto translation ++ spot light, point light and area light translation ++ native appleseed materials ++ auto-conversion of maya lambertian, phong and surface shaders ++ environment, physical environment ++ auto-convert textures to .exr ++ transformation, deformation and camera blur export + Mayaseed is released under the MIT licence. \ No newline at end of file diff --git a/sandbox/extras/maya/plugins/mayaseed.py b/sandbox/extras/maya/plugins/mayaseed.py index abf436c3c0..2bff83b625 100644 --- a/sandbox/extras/maya/plugins/mayaseed.py +++ b/sandbox/extras/maya/plugins/mayaseed.py @@ -53,13 +53,13 @@ def ms_renderSettings_nodeCreator(): def ms_renderSettings_nodeInitializer(): # define attributes - # output directory + # output directory output_dir_string = OpenMaya.MFnStringData().create(os.path.join("Mayaseed", "")) output_dir_Attr = OpenMaya.MFnTypedAttribute() ms_renderSettings.output_dir = output_dir_Attr.create("output_directory", "out_dir", OpenMaya.MFnData.kString, output_dir_string) ms_renderSettings.addAttribute(ms_renderSettings.output_dir) - # output file + # output file output_file_string = OpenMaya.MFnStringData().create(".#.appleseed") output_file_Attr = OpenMaya.MFnTypedAttribute() ms_renderSettings.output_file = output_file_Attr.create("output_file", "out_file", OpenMaya.MFnData.kString, output_file_string) @@ -80,12 +80,12 @@ def ms_renderSettings_nodeInitializer(): ms_renderSettings.convert_shading_nodes_to_textures = convert_shading_nodes_to_textures_nAttr.create("convert_shading_nodes_to_textures", "convert_shading_nodes", OpenMaya.MFnNumericData.kBoolean, True) ms_renderSettings.addAttribute(ms_renderSettings.convert_shading_nodes_to_textures) - # overwrite existing textures + # overwrite existing textures overwrite_existing_textures_nAttr = OpenMaya.MFnNumericAttribute() ms_renderSettings.overwrite_existing_textures = overwrite_existing_textures_nAttr.create("overwrite_existing_textures", "overwrite_exrs", OpenMaya.MFnNumericData.kBoolean, True) ms_renderSettings.addAttribute(ms_renderSettings.overwrite_existing_textures) - # overwrite existing geometry + # overwrite existing geometry overwrite_existing_geometry_nAttr = OpenMaya.MFnNumericAttribute() ms_renderSettings.overwrite_existing_geometry = overwrite_existing_geometry_nAttr.create("overwrite_existing_geometry", "overwrite_geo", OpenMaya.MFnNumericData.kBoolean, True) ms_renderSettings.addAttribute(ms_renderSettings.overwrite_existing_geometry) @@ -156,6 +156,11 @@ def ms_renderSettings_nodeInitializer(): ms_renderSettings.environment = environment_msgAttr.create("environment", "env") ms_renderSettings.addAttribute(ms_renderSettings.environment) + # render_sky + render_skynAttr = OpenMaya.MFnNumericAttribute() + ms_renderSettings.render_sky = render_skynAttr.create("render_sky", "render_sky", OpenMaya.MFnNumericData.kBoolean, True) + ms_renderSettings.addAttribute(ms_renderSettings.render_sky) + # cameras -------------------------------------------------- # export all cameras as thin lens bool attribute export_all_cameras_as_thin_lens_nAttr = OpenMaya.MFnNumericAttribute() @@ -280,6 +285,13 @@ def ms_renderSettings_nodeInitializer(): pt_environment_samples_AttrFloat.setKeyable(True) ms_renderSettings.addAttribute(ms_renderSettings.pt_environment_samples) + # pt_max_ray_intensity + pt_max_ray_intensity_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_renderSettings.pt_max_ray_intensity = pt_max_ray_intensity_AttrFloat.create("pt_max_ray_intensity", "pt_max_ray_intensity", OpenMaya.MFnNumericData.kFloat, 0) + pt_max_ray_intensity_AttrFloat.setHidden(False) + pt_max_ray_intensity_AttrFloat.setKeyable(True) + ms_renderSettings.addAttribute(ms_renderSettings.pt_max_ray_intensity) + # profile export profile_export_nAttr = OpenMaya.MFnNumericAttribute() ms_renderSettings.profile_export = profile_export_nAttr.create("profile_export", "profile_export", OpenMaya.MFnNumericData.kBoolean, False) @@ -318,6 +330,8 @@ def initializePlugin(obj): cmds.loadPlugin('ms_appleseed_shading_node.py') if not cmds.pluginInfo('ms_environment_node.py', query=True, loaded=True): cmds.loadPlugin('ms_environment_node.py') + if not cmds.pluginInfo('ms_physical_environment_node.py', query=True, loaded=True): + cmds.loadPlugin('ms_physical_environment_node.py') except: print 'objExport plugin could not be loaded, cannot load mayaseed' diff --git a/sandbox/extras/maya/plugins/ms_physical_environment_node.py b/sandbox/extras/maya/plugins/ms_physical_environment_node.py new file mode 100644 index 0000000000..27b69b89cd --- /dev/null +++ b/sandbox/extras/maya/plugins/ms_physical_environment_node.py @@ -0,0 +1,321 @@ + +# +# Copyright (c) 2012-2013 Jonathan Topf +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + + +import sys +import maya.OpenMaya as OpenMaya +import maya.OpenMayaMPx as OpenMayaMPx +import maya.OpenMayaRender as OpenMayaRender +import maya.OpenMayaUI as OpenMayaUI +import maya.cmds as cmds +import inspect +import os +import os.path + +#-------------------------------------------------------------------------------------------------- +# ms_physical_environment node. +#-------------------------------------------------------------------------------------------------- + +ms_physical_environment_nodeTypeName = "ms_physical_environment" +ms_physical_environment_nodeTypeId = OpenMaya.MTypeId(0x00336) + +glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer() +glFT = glRenderer.glFunctionTable() + +class ms_physical_environment(OpenMayaMPx.MPxLocatorNode): + def __init__(self): + OpenMayaMPx.MPxLocatorNode.__init__(self) + + def draw(self, view, path, style, status): + view.beginGL() + + glFT.glEnable(OpenMayaRender.MGL_BLEND) + + # draw sphere + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(3.06161699787e-16, 5.0, -8.04061324838e-16) + glFT.glVertex3f(-1.91341716183, 4.61939766256, -7.42855800902e-16) + glFT.glVertex3f(-3.53553390593, 3.53553390593, -5.68557215283e-16) + glFT.glVertex3f(-4.61939766256, 1.91341716183, -3.07700947621e-16) + glFT.glVertex3f(-5.0, -2.48949812526e-16, 4.00341832155e-32) + glFT.glVertex3f(-4.61939766256, -1.91341716183, 3.07700947621e-16) + glFT.glVertex3f(-3.53553390593, -3.53553390593, 5.68557215283e-16) + glFT.glVertex3f(-1.91341716183, -4.61939766256, 7.42855800902e-16) + glFT.glVertex3f(5.26505568682e-16, -5.0, 8.04061324838e-16) + glFT.glVertex3f(1.91341716183, -4.61939766256, 7.42855800902e-16) + glFT.glVertex3f(3.53553390593, -3.53553390593, 5.68557215283e-16) + glFT.glVertex3f(4.61939766256, -1.91341716183, 3.07700947621e-16) + glFT.glVertex3f(5.0, 1.08161708099e-15, -1.73937292622e-31) + glFT.glVertex3f(4.61939766256, 1.91341716183, -3.07700947621e-16) + glFT.glVertex3f(3.53553390593, 3.53553390593, -5.68557215283e-16) + glFT.glVertex3f(1.91341716183, 4.61939766256, -7.42855800902e-16) + glFT.glVertex3f(-1.63672859331e-15, 5.0, -8.04061324838e-16) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(-2.19184010562e-15, 5.0, -3.06161699787e-16) + glFT.glVertex3f(-2.237428191e-15, 4.61939766256, 1.91341716183) + glFT.glVertex3f(-1.94238811663e-15, 3.53553390593, 3.53553390593) + glFT.glVertex3f(-1.3516370593e-15, 1.91341716183, 4.61939766256) + glFT.glVertex3f(-5.55111512313e-16, -5.26505568682e-16, 5.0) + glFT.glVertex3f(3.25924730327e-16, -1.91341716183, 4.61939766256) + glFT.glVertex3f(1.15734188729e-15, -3.53553390593, 3.53553390593) + glFT.glVertex3f(1.81256423324e-15, -4.61939766256, 1.91341716183) + glFT.glVertex3f(2.19184010562e-15, -5.0, -5.26505568682e-16) + glFT.glVertex3f(2.237428191e-15, -4.61939766256, -1.91341716183) + glFT.glVertex3f(1.94238811663e-15, -3.53553390593, -3.53553390593) + glFT.glVertex3f(1.3516370593e-15, -1.91341716183, -4.61939766256) + glFT.glVertex3f(5.55111512313e-16, 1.35917283715e-15, -5.0) + glFT.glVertex3f(-3.25924730327e-16, 1.91341716183, -4.61939766256) + glFT.glVertex3f(-1.15734188729e-15, 3.53553390593, -3.53553390593) + glFT.glVertex3f(-1.81256423324e-15, 4.61939766256, -1.91341716183) + glFT.glVertex3f(-2.19184010562e-15, 5.0, 1.63672859331e-15) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(3.06161699787e-16, 3.06161699787e-16, -5.0) + glFT.glVertex3f(-1.91341716183, 2.82856528072e-16, -4.61939766256) + glFT.glVertex3f(-3.53553390593, 2.16489014059e-16, -3.53553390593) + glFT.glVertex3f(-4.61939766256, 1.17163010133e-16, -1.91341716183) + glFT.glVertex3f(-5.0, -1.52437795529e-32, 2.48949812526e-16) + glFT.glVertex3f(-4.61939766256, -1.17163010133e-16, 1.91341716183) + glFT.glVertex3f(-3.53553390593, -2.16489014059e-16, 3.53553390593) + glFT.glVertex3f(-1.91341716183, -2.82856528072e-16, 4.61939766256) + glFT.glVertex3f(5.26505568682e-16, -3.06161699787e-16, 5.0) + glFT.glVertex3f(1.91341716183, -2.82856528072e-16, 4.61939766256) + glFT.glVertex3f(3.53553390593, -2.16489014059e-16, 3.53553390593) + glFT.glVertex3f(4.61939766256, -1.17163010133e-16, 1.91341716183) + glFT.glVertex3f(5.0, 6.62299448072e-32, -1.08161708099e-15) + glFT.glVertex3f(4.61939766256, 1.17163010133e-16, -1.91341716183) + glFT.glVertex3f(3.53553390593, 2.16489014059e-16, -3.53553390593) + glFT.glVertex3f(1.91341716183, 2.82856528072e-16, -4.61939766256) + glFT.glVertex3f(-1.63672859331e-15, 3.06161699787e-16, -5.0) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) # Axis + glFT.glVertex3f(0.0, 0.0, 2.0) + glFT.glVertex3f(0.0, 0.0, 0.0) + glFT.glVertex3f(2.0, 0.0, 0.0) + glFT.glVertex3f(0.0, 0.0, 0.0) + glFT.glVertex3f(0.0, 2.0, 0.0) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) # X + glFT.glVertex3f(2.5, 0.5, 0.0) + glFT.glVertex3f(3.5, -0.5, 0.0) + glFT.glVertex3f(3.0, 0.0, 0.0) + glFT.glVertex3f(3.5, 0.5, 0.0) + glFT.glVertex3f(2.5, -0.5, 0.0) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) # Y + glFT.glVertex3f(-0.5, 3.5, 0.0) + glFT.glVertex3f(0.0, 3.0, 0.0) + glFT.glVertex3f(0.0, 2.5, 0.0) + glFT.glVertex3f(0.0, 3.0, 0.0) + glFT.glVertex3f(0.5, 3.5, 0.0) + glFT.glEnd() + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) # Z + glFT.glVertex3f(-0.5, 0.5, 3.0) + glFT.glVertex3f(0.5, 0.5, 3.0) + glFT.glVertex3f(-0.5, -0.5, 3.0) + glFT.glVertex3f(0.5, -0.5, 3.0) + glFT.glEnd() + + # appleseed logo + + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(4.99999602985, 6.24639415266, 0.0) + glFT.glVertex3f(4.84344021397, 5.95478169919, 0.0) + glFT.glVertex3f(4.77695111567, 5.74857723447, 0.0) + glFT.glVertex3f(4.75097549437, 5.54600980644, 0.0) + glFT.glVertex3f(4.78516283497, 5.37147218711, 0.0) + glFT.glVertex3f(4.87062698707, 5.26346158765, 0.0) + glFT.glVertex3f(4.99999602985, 5.21958256572, 0.0) + glFT.glVertex3f(5.12488923665, 5.25780446049, 0.0) + glFT.glVertex3f(5.21482963071, 5.37147218711, 0.0) + glFT.glVertex3f(5.24875492795, 5.54682314909, 0.0) + glFT.glVertex3f(5.22313636337, 5.74836664521, 0.0) + glFT.glVertex3f(5.15665391004, 5.95474029648, 0.0) + glFT.glVertex3f(4.99999643583, 6.24639415266, 0.0) + glFT.glEnd() + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(6.18539005392, 5.3851607507, 0.0) + glFT.glVertex3f(5.85967172213, 5.44394097566, 0.0) + glFT.glVertex3f(5.64301336096, 5.44345518195, 0.0) + glFT.glVertex3f(5.44233338012, 5.40556268809, 0.0) + glFT.glVertex3f(5.28690270915, 5.3191135045, 0.0) + glFT.glVertex3f(5.21058840012, 5.20445515493, 0.0) + glFT.glVertex3f(5.20883420315, 5.06785852031, 0.0) + glFT.glVertex3f(5.28377950862, 4.96088923718, 0.0) + glFT.glVertex3f(5.41967705096, 4.91047609857, 0.0) + glFT.glVertex3f(5.59692921938, 4.9323976508, 0.0) + glFT.glVertex3f(5.78069190285, 5.01904271899, 0.0) + glFT.glVertex3f(5.95642070078, 5.14604425488, 0.0) + glFT.glVertex3f(6.18539017937, 5.38516036459, 0.0) + glFT.glEnd() + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(5.7326153134, 3.9916482824, 0.0) + glFT.glVertex3f(5.68786612947, 4.31958891277, 0.0) + glFT.glVertex3f(5.62045299662, 4.52549314046, 0.0) + glFT.glVertex3f(5.52240156891, 4.70464171936, 0.0) + glFT.glVertex3f(5.39215279075, 4.82575080494, 0.0) + glFT.glVertex3f(5.25952380184, 4.86289864727, 0.0) + glFT.glVertex3f(5.12907060571, 4.82235630626, 0.0) + glFT.glVertex3f(5.05049614498, 4.71802375876, 0.0) + glFT.glVertex3f(5.04454505108, 4.573198999, 0.0) + glFT.glVertex3f(5.1201676185, 4.41139630138, 0.0) + glFT.glVertex3f(5.25935776733, 4.26340240236, 0.0) + glFT.glVertex3f(5.43444659058, 4.1355200169, 0.0) + glFT.glVertex3f(5.73261498495, 3.99164804378, 0.0) + glFT.glEnd() + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(4.26739111044, 3.99164361521, 0.0) + glFT.glVertex3f(4.56545292559, 4.13554184611, 0.0) + glFT.glVertex3f(4.74044767937, 4.26328345096, 0.0) + glFT.glVertex3f(4.88052854524, 4.41189585562, 0.0) + glFT.glVertex3f(4.95546104432, 4.57319457044, 0.0) + glFT.glVertex3f(4.9498061303, 4.71081154918, 0.0) + glFT.glVertex3f(4.87093581813, 4.82235163907, 0.0) + glFT.glVertex3f(4.74742882528, 4.86483986171, 0.0) + glFT.glVertex3f(4.60785330464, 4.82574637638, 0.0) + glFT.glVertex3f(4.4773384532, 4.70382525755, 0.0) + glFT.glVertex3f(4.37960001261, 4.52571492964, 0.0) + glFT.glVertex3f(4.3120820585, 4.31967773297, 0.0) + glFT.glVertex3f(4.267390782, 3.99164385384, 0.0) + glFT.glEnd() + glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP) + glFT.glVertex3f(3.8146074924, 5.38515319902, 0.0) + glFT.glVertex3f(4.04356900883, 5.14614656628, 0.0) + glFT.glVertex3f(4.21913484737, 5.01919099216, 0.0) + glFT.glVertex3f(4.40376101137, 4.93188993049, 0.0) + glFT.glVertex3f(4.58032062081, 4.91046893301, 0.0) + glFT.glVertex3f(4.70945468066, 4.95837306097, 0.0) + glFT.glVertex3f(4.79116334317, 5.06785096864, 0.0) + glFT.glVertex3f(4.79340628446, 5.19844268185, 0.0) + glFT.glVertex3f(4.71309496261, 5.31910633894, 0.0) + glFT.glVertex3f(4.55680978096, 5.40555764117, 0.0) + glFT.glVertex3f(4.35721395384, 5.4434733038, 0.0) + glFT.glVertex3f(4.1403967401, 5.44401769877, 0.0) + glFT.glVertex3f(3.81460761785, 5.38515358513, 0.0) + glFT.glEnd() + + glFT.glDisable(OpenMayaRender.MGL_BLEND) + + view.endGL() + +def ms_physical_environment_nodeCreator(): + return OpenMayaMPx.asMPxPtr(ms_physical_environment()) + +def ms_physical_environment_nodeInitializer(): + # environment type + model_enumAttr = OpenMaya.MFnEnumAttribute() + ms_physical_environment.model = model_enumAttr.create("model", "model") + model_enumAttr.addField("Hosek", 0) + model_enumAttr.addField("Preetham", 1) + ms_physical_environment.addAttribute(ms_physical_environment.model) + + # sun_phi + sun_phi_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.sun_phi = sun_phi_AttrFloat.create("sun_phi", "sun_phi", OpenMaya.MFnNumericData.kFloat, 0) + sun_phi_AttrFloat.setHidden(False) + sun_phi_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.sun_phi) + + # sun_theta + sun_theta_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.sun_theta = sun_theta_AttrFloat.create("sun_theta", "sun_theta", OpenMaya.MFnNumericData.kFloat, 45) + sun_theta_AttrFloat.setHidden(False) + sun_theta_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.sun_theta) + + # turbidity + turbidity_nAttr = OpenMaya.MFnNumericAttribute() + ms_physical_environment.turbidity = turbidity_nAttr.createColor("turbidity", "turbidity") + turbidity_nAttr.setDefault(4.0, 4.0, 4.0) + turbidity_nAttr.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.turbidity) + + # turbidity_multiplier + turbidity_multiplier_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.turbidity_multiplier = turbidity_multiplier_AttrFloat.create("turbidity_multiplier", "turbidity_multiplier", OpenMaya.MFnNumericData.kFloat, 1) + turbidity_multiplier_AttrFloat.setHidden(False) + turbidity_multiplier_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.turbidity_multiplier) + + # luminance_multiplier + luminance_multiplier_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.luminance_multiplier = luminance_multiplier_AttrFloat.create("luminance_multiplier", "luminance_multiplier", OpenMaya.MFnNumericData.kFloat, 1) + luminance_multiplier_AttrFloat.setHidden(False) + luminance_multiplier_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.luminance_multiplier) + + # luminance_gamma + luminance_gamma_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.luminance_gamma = luminance_gamma_AttrFloat.create("luminance_gamma", "luminance_gamma", OpenMaya.MFnNumericData.kFloat, 1) + luminance_gamma_AttrFloat.setHidden(False) + luminance_gamma_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.luminance_gamma) + + # saturation_multiplier + saturation_multiplier_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.saturation_multiplier = saturation_multiplier_AttrFloat.create("saturation_multiplier", "saturation_multiplier", OpenMaya.MFnNumericData.kFloat, 1) + saturation_multiplier_AttrFloat.setHidden(False) + saturation_multiplier_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.saturation_multiplier) + + # ground_albedo + ground_albedo_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.ground_albedo = ground_albedo_AttrFloat.create("ground_albedo", "ground_albedo", OpenMaya.MFnNumericData.kFloat, 1) + ground_albedo_AttrFloat.setHidden(False) + ground_albedo_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.ground_albedo) + + # horizon_shift + horizon_shift_AttrFloat = OpenMaya.MFnNumericAttribute() + ms_physical_environment.horizon_shift = horizon_shift_AttrFloat.create("horizon_shift", "horizon_shift", OpenMaya.MFnNumericData.kFloat, 0) + horizon_shift_AttrFloat.setHidden(False) + horizon_shift_AttrFloat.setKeyable(True) + ms_physical_environment.addAttribute(ms_physical_environment.horizon_shift) + + +#-------------------------------------------------------------------------------------------------- +# node initialization . +#-------------------------------------------------------------------------------------------------- + +def initializePlugin(obj): + plugin = OpenMayaMPx.MFnPlugin(obj) + + try: + plugin.registerNode(ms_physical_environment_nodeTypeName, ms_physical_environment_nodeTypeId, ms_physical_environment_nodeCreator, ms_physical_environment_nodeInitializer, OpenMayaMPx.MPxNode.kLocatorNode) + except: + sys.stderr.write("Failed to register node: %s" % ms_physical_environment_nodeTypeName) + +def uninitializePlugin(obj): + plugin = OpenMayaMPx.MFnPlugin(obj) + + try: + plugin.deregisterNode(ms_physical_environment_nodeTypeId) + except: + sys.stderr.write("Failed to deregister node: %s" % ms_physical_environment_nodeTypeName) diff --git a/sandbox/extras/maya/scripts/AEms_physical_environmentTemplate.mel b/sandbox/extras/maya/scripts/AEms_physical_environmentTemplate.mel new file mode 100644 index 0000000000..53f5cb397f --- /dev/null +++ b/sandbox/extras/maya/scripts/AEms_physical_environmentTemplate.mel @@ -0,0 +1,113 @@ + +// +// Copyright (c) 2012-2013 Jonathan Topf +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + + +global proc AEms_physical_environmentTemplate(string $nodeName) { + editorTemplate -beginScrollLayout; + editorTemplate -beginLayout "environment settings" -collapse false; + editorTemplate -addControl "model"; + editorTemplate -addSeparator; + editorTemplate -addControl "sun_phi"; + editorTemplate -addControl "sun_theta"; + editorTemplate -addSeparator; + editorTemplate -addControl "turbidity"; + editorTemplate -addControl "turbidity_multiplier"; + editorTemplate -addSeparator; + editorTemplate -addControl "luminance_multiplier"; + editorTemplate -addControl "luminance_gamma"; + editorTemplate -addControl "saturation_multiplier"; + editorTemplate -addSeparator; + editorTemplate -addControl "horizon_shift"; + editorTemplate -addControl "ground_albedo"; + editorTemplate -endLayout; + + AEdependNodeTemplate $nodeName; + + editorTemplate -addExtraControls; + editorTemplate -suppress "renderInfo"; + editorTemplate -suppress "renderLayerInfo"; + editorTemplate -suppress "drawOverride"; + editorTemplate -suppress "compInstObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + editorTemplate -suppress "instObjGroups"; + + editorTemplate -suppress blackBox; + editorTemplate -suppress rmbCommand; + editorTemplate -suppress templateName; + editorTemplate -suppress templatePath; + editorTemplate -suppress viewName; + editorTemplate -suppress iconName; + editorTemplate -suppress viewMode; + editorTemplate -suppress templateVersion; + editorTemplate -suppress uiTreatment; + editorTemplate -suppress customTreatment; + editorTemplate -suppress creator; + editorTemplate -suppress creationDate; + editorTemplate -suppress containerType; + editorTemplate -suppress localScale; + + editorTemplate -suppress version; + editorTemplate -suppress caching; + editorTemplate -suppress nodeState; + editorTemplate -suppress visibility; + editorTemplate -suppress intermediateObject; + editorTemplate -suppress template; + editorTemplate -suppress ghosting; + editorTemplate -suppress instObjGroups; + editorTemplate -suppress useObjectColor; + editorTemplate -suppress objectColor; + editorTemplate -suppress drawOverride; + editorTemplate -suppress lodVisibility; + editorTemplate -suppress renderInfo; + editorTemplate -suppress ghostingControl; + editorTemplate -suppress ghostCustomSteps; + editorTemplate -suppress ghostFrames; + editorTemplate -suppress ghostRangeStart; + editorTemplate -suppress ghostRangeEnd; + editorTemplate -suppress ghostDriver; + editorTemplate -suppress motionBlur; + editorTemplate -suppress visibleInReflections; + editorTemplate -suppress visibleInRefractions; + editorTemplate -suppress castsShadows; + editorTemplate -suppress receiveShadows; + editorTemplate -suppress maxVisibilitySamplesOverride; + editorTemplate -suppress maxVisibilitySamples; + editorTemplate -suppress geometryAntialiasingOverride; + editorTemplate -suppress antialiasingLevel; + editorTemplate -suppress shadingSamplesOverride; + editorTemplate -suppress shadingSamples; + editorTemplate -suppress maxShadingSamples; + editorTemplate -suppress volumeSamplesOverride; + editorTemplate -suppress volumeSamples; + editorTemplate -suppress depthJitter; + editorTemplate -suppress ignoreSelfShadowing; + editorTemplate -suppress primaryVisibility; + editorTemplate -suppress compInstObjGroups; + editorTemplate -suppress localPosition; + editorTemplate -endScrollLayout; +} diff --git a/sandbox/extras/maya/scripts/AEms_renderSettingsTemplate.mel b/sandbox/extras/maya/scripts/AEms_renderSettingsTemplate.mel index 73f57298d0..6b02c99785 100644 --- a/sandbox/extras/maya/scripts/AEms_renderSettingsTemplate.mel +++ b/sandbox/extras/maya/scripts/AEms_renderSettingsTemplate.mel @@ -76,17 +76,19 @@ global proc AEcustomEnvironmentMenuCreate(string $attr) { string $currentEnvironmentConnection = $currentEnvironmentConnectionTransformRelatives[0]; optionMenuGrp -label "Environment" -cc ("setEnvironmentConnection " + $nodeName) customEnvironmentMenu; + string $physical_environments[] = `ls -type "ms_physical_environment"`; + for ($item in $physical_environments) { + menuItem -label $item; + } string $environments[] = `ls -type "ms_environment"`; - menuItem -label ""; for ($item in $environments) { menuItem -label $item; } - print ($currentEnvironmentConnection + "****\n\n"); + menuItem -label ""; if ($currentEnvironmentConnection != "") { optionMenuGrp -e -v $currentEnvironmentConnection customEnvironmentMenu; } button -l " select " -h 20 -w 50 -c ("AEselecConnectedEnvironmentNode " + $nodeName) -p customEnvironmentMenu; - button -l " + " -h 20 -c ("createMsEnvironmentNode " + $nodeName ) -p customEnvironmentMenu; } global proc AEselecConnectedEnvironmentNode(string $nodeName) { @@ -115,11 +117,6 @@ global proc setEnvironmentConnection(string $nodeName) { } } -global proc createMsEnvironmentNode(string $nodeName) { - string $node = `createNode "ms_environment"`; - connectAttr -f ($node + ".nodeState") ($nodeName + ".environment"); -} - //-------------------------------------------------------------------------------------------------- // Camera picker. @@ -222,6 +219,7 @@ global proc AEms_renderSettingsTemplate(string $nodeName) { editorTemplate -beginLayout "Environment Settings" -collapse true; editorTemplate -callCustom "AEcustomEnvironmentMenuCreate" "AEcustomEnvironmentMenuEdit" "environment"; + editorTemplate -addControl "render_sky"; editorTemplate -endLayout; editorTemplate -beginLayout "Camera Settings" -collapse true;; @@ -250,6 +248,7 @@ global proc AEms_renderSettingsTemplate(string $nodeName) { editorTemplate -addControl "pt_max_bounces"; editorTemplate -addControl "pt_light_samples"; editorTemplate -addControl "pt_environment_samples"; + editorTemplate -addControl "pt_max_ray_intensity"; editorTemplate -endLayout; editorTemplate -beginLayout "Advanced Settings" -collapse true; diff --git a/sandbox/extras/maya/scripts/appleseedEntityDefs.xml b/sandbox/extras/maya/scripts/appleseedEntityDefs.xml index bbc190d586..a8f5dd99aa 100644 --- a/sandbox/extras/maya/scripts/appleseedEntityDefs.xml +++ b/sandbox/extras/maya/scripts/appleseedEntityDefs.xml @@ -1,12 +1,12 @@ - - + + - + + - @@ -15,17 +15,17 @@ + - - + + - @@ -34,8 +34,8 @@ + - @@ -43,26 +43,53 @@ + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -71,8 +98,8 @@ + - @@ -80,16 +107,16 @@ + - + - @@ -97,8 +124,8 @@ + - @@ -106,10 +133,10 @@ - + + - @@ -118,8 +145,8 @@ + - @@ -127,10 +154,10 @@ - + + - @@ -139,17 +166,17 @@ + - - + + - @@ -157,22 +184,26 @@ + + + - + + + - - + + - @@ -181,8 +212,8 @@ + - @@ -192,29 +223,38 @@ + - - + - - - + + + + - + + + + + + + + + - + + - @@ -223,8 +263,8 @@ + - @@ -232,8 +272,8 @@ + - @@ -241,10 +281,10 @@ - + + - @@ -253,8 +293,8 @@ + - @@ -262,10 +302,10 @@ - + + - @@ -274,17 +314,17 @@ + - - + + - @@ -293,8 +333,8 @@ + - @@ -302,140 +342,142 @@ + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - - + @@ -445,95 +487,152 @@ + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - + + + + + + + + + + + + - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - @@ -543,76 +642,90 @@ + + + - + + + - - + + - - + - + + + + - - - - - - - + + + - + + + + + + + + + + + - + + + - + - - - + + + - - + + - @@ -620,32 +733,36 @@ + + + - + + + - - - + + + - - + + - @@ -655,116 +772,156 @@ + + + - + + + - - + + - - + - + + + + - - - - - - - + + + + + + + + + + + - + + + - + - + - - - + + + - - + + + + + + + + + + + + + + + + - - - + + + - - + + + + + + + + + + + + + + + + - - - + + + - - + + - @@ -772,27 +929,45 @@ + + + - + + + - + + + + + + + + + + + + + + + - + - @@ -800,26 +975,40 @@ + - - + + + + + + + + + + + + + + + + - + - - + @@ -827,22 +1016,22 @@ + - + - - + + - @@ -851,9 +1040,9 @@ + - - + @@ -861,8 +1050,8 @@ + - @@ -870,8 +1059,8 @@ + - @@ -882,9 +1071,9 @@ + - - + @@ -909,44 +1098,50 @@ + - + + + - + + + - + + + - + - + - - + + - @@ -955,22 +1150,22 @@ + - + - + - @@ -978,28 +1173,49 @@ + + + + + + + + + + - + + + + + + + + + + + + + - - + - + + - @@ -1007,14 +1223,14 @@ + - + - @@ -1023,8 +1239,8 @@ + - @@ -1032,8 +1248,8 @@ + - @@ -1041,8 +1257,8 @@ + - @@ -1050,8 +1266,8 @@ + - @@ -1059,8 +1275,8 @@ + - @@ -1068,8 +1284,8 @@ + - @@ -1077,8 +1293,8 @@ + - @@ -1086,8 +1302,8 @@ + - @@ -1101,22 +1317,21 @@ + - + - - + - - + \ No newline at end of file diff --git a/sandbox/extras/maya/scripts/maya_area_light.obj b/sandbox/extras/maya/scripts/maya_area_light.obj new file mode 100644 index 0000000000..44254330b4 --- /dev/null +++ b/sandbox/extras/maya/scripts/maya_area_light.obj @@ -0,0 +1,13 @@ +v -1.000000 1.000000 0.000000 +v 1.000000 1.000000 0.000000 +v -1.000000 -1.000000 -0.000000 +v 1.000000 -1.000000 -0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 0.000000 -1.000000 +f 1/1/1 2/2/2 4/4/3 3/3/4 diff --git a/sandbox/extras/maya/scripts/mayaseed.ui b/sandbox/extras/maya/scripts/mayaseed.ui deleted file mode 100644 index 475c8b2fd9..0000000000 --- a/sandbox/extras/maya/scripts/mayaseed.ui +++ /dev/null @@ -1,1876 +0,0 @@ - - - msDial - - - - 0 - 0 - 694 - 873 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 99999 - 99999 - - - - Mayaseed - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - mayaseed.png - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 1 - - - Qt::ElideLeft - - - false - - - false - - - false - - - - Main Settings - - - - - - - - - 150 - 0 - - - - Output directory - - - - - - - - - - - - - - - 150 - 0 - - - - choose directory - - - "mayaseed.getDir(\'ms_outputDir\')" - - - - - - - - - - - - 150 - 0 - - - - File name - - - - - - - mayaScene.appleseed - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Advanced settings - - - - - - true - - - - - 0 - 0 - 607 - 1169 - - - - - - - scene - - - - - - environment - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Environment node - - - - - - - - 150 - 0 - - - - - 150 - 0 - - - - - - - - - 0 - 0 - - - - + - - - "mayaseed.addEnvironmentNode()" - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - cameras - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Export all cameras - - - - - - - - - - true - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - - 9999 - 16777215 - - - - Export all as 'thin lens' - - - - - - - - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - NOTE: cameras with DOF switched on will always default to 'thin lens' - - - - - - - - - - assemblies - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Interpret sets as assemblies - - - - - - - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - materials - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Shader interpretation - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Lambert -> - - - - - - - - 100 - 0 - - - - BSDF - - - - - - - - 100 - 0 - - - - EDF - - - - - - - - 100 - 0 - - - - Surface shader - - - - - - - - 100 - 0 - - - - - Physical - - - - - Constant - - - - - - - - - 100 - 0 - - - - - None - - - - - Diffuse - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Blinn -> - - - - - - - - 100 - 0 - - - - - Ashikhmin-Shirley - - - - - Kelemen - - - - - Lambertian - - - - - Specular_BRDF - - - - - None - - - - - - - - - 100 - 0 - - - - - None - - - - - Diffuse - - - - - - - - - 100 - 0 - - - - - Physical - - - - - Constant - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Phong -> - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Surface shader -> - - - - - - - - 100 - 0 - - - - - Ashikhmin-Shirley - - - - - Lambertian - - - - - Kelemen - - - - - Specular_BRDF - - - - - None - - - - - - - - - 100 - 0 - - - - - None - - - - - Diffuse - - - - - - - - - 100 - 0 - - - - - Physical - - - - - Constant - - - - - - - - - 100 - 0 - - - - - Constant - - - - - Physical - - - - - - - - - 100 - 0 - - - - - Diffuse - - - - - None - - - - - - - - - 100 - 0 - - - - - None - - - - - Ashikhmin-Shirley - - - - - Lambertian - - - - - Kelemen - - - - - Specular_BRDF - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Default -> - - - - - - - - 100 - 0 - - - - - Lambertian - - - - - Ashikhmin-Shirley - - - - - Kelemen - - - - - Specular_BRDF - - - - - None - - - - - - - - - 100 - 0 - - - - - None - - - - - Diffuse - - - - - - - - - 100 - 0 - - - - - Physical - - - - - Constant - - - - - - - - - 100 - 0 - - - - - Lambertian - - - - - Ashikhmin-Shirley - - - - - Kelemen - - - - - Specular_BRDF - - - - - None - - - - - - - - - - - - - 150 - 0 - - - - - 99999 - 16777215 - - - - Double sided shading - - - - - - - - - - true - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - - Output - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Camera - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Color space - - - - - - - - srgb - - - - - linear_rgb - - - - - spectral - - - - - ciexyz - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Resolution - - - - - - - width - - - - - - - - 50 - 0 - - - - - 40 - 16777215 - - - - Qt::ImhNone - - - - - - 1920 - - - - - - - height - - - - - - - - 50 - 0 - - - - - 40 - 16777215 - - - - 1080 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Configurations - - - - - - - 150 - 0 - - - - Customise 'interactive' config - - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Lighting engine - - - - - - - - Path Tracing - - - - - Distributed Ray Tracing - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Samples - - - - - - - min - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - Qt::ImhNone - - - - - - 1 - - - - - - - max - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 4 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Max ray depth - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 4 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Light samples - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 16 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - - - Customise 'final' config - - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Lighting engine - - - - - - - - Path Tracing - - - - - Distributed Ray Tracing - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Samples - - - - - - - min - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - Qt::ImhNone - - - - - - 1 - - - - - - - max - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 4 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Max ray depth - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 4 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 150 - 0 - - - - Light samples - - - - - - - - 40 - 0 - - - - - 40 - 16777215 - - - - 16 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - 0 - 150 - - - - - 16777215 - 150 - - - - - 0 - 150 - - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> - - - - - - - - - - 100 - 0 - - - - Hide log - - - "mayaseed.toggleLog()" - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 0 - - - - Export - - - "mayaseed.export()" - - - - - - - - - - - - - - diff --git a/sandbox/extras/maya/scripts/ms_commands.py b/sandbox/extras/maya/scripts/ms_commands.py index 7623911694..863191680d 100644 --- a/sandbox/extras/maya/scripts/ms_commands.py +++ b/sandbox/extras/maya/scripts/ms_commands.py @@ -38,7 +38,7 @@ # Constants. #-------------------------------------------------------------------------------------------------- -MAYASEED_VERSION = '0.4.0' +MAYASEED_VERSION = '0.5.0' MAYASEED_URL = 'https://github.com/jupiter-jazz/Mayaseed' APPLESEED_URL = 'http://appleseedhq.net/' ROOT_DIRECTORY = os.path.split((os.path.dirname(inspect.getfile(inspect.currentframe()))))[0] @@ -227,6 +227,8 @@ def convert_texture_to_exr(file_path, export_root, texture_dir, overwrite=True, def transform_is_visible(node_name): + """ Returns the visibility state of a transform for the current frame, this visibility state may change over time """ + # check if the node exists if not cmds.objExists(node_name): return False @@ -244,6 +246,17 @@ def transform_is_visible(node_name): if cmds.getAttr(node_name + '.intermediateObject'): return False + return True + + +#-------------------------------------------------------------------------------------------------- +# Check if an object is visible for the current frame. +#-------------------------------------------------------------------------------------------------- + +def transform_is_renderable(node_name): + + """ Returns the renderability state of a transform, this value will not change over time """ + # check if it is a hidden display layer if cmds.attributeQuery('overrideEnabled', node=node_name, exists=True) and cmds.getAttr(node_name + '.overrideEnabled'): if not cmds.getAttr(node_name + '.overrideVisibility'): @@ -253,7 +266,7 @@ def transform_is_visible(node_name): #-------------------------------------------------------------------------------------------------- -# check if a transform or any of its parents are set as visible +# check if a transform or any of its parents are set as visible. #-------------------------------------------------------------------------------------------------- def visible_in_hierarchy(parent): @@ -349,7 +362,7 @@ def __init__(self, name): if param.nodeName == 'parameter': name = param.getAttribute('name') value = param.getAttribute('value') - if name == 'widget': + if name == 'type': nodes[entity_model].attributes[child_name].type = value elif name == 'default': nodes[entity_model].attributes[child_name].default_value = value @@ -417,15 +430,18 @@ def create_shading_node(model, name=None, entity_defs_obj=False): cmds.addAttr(shading_node_name, longName='node_type', dt="string") cmds.setAttr(shading_node_name + '.node_type', entity_defs[model].type, type="string", lock=True) - + + cmds.addAttr(shading_node_name, longName='render_layer', dt="string") + cmds.setAttr(shading_node_name + '.render_layer', '', type="string") + for entity_key in entity_defs.keys(): if entity_key == model: for attr_key in entity_defs[entity_key].attributes.keys(): attr = entity_defs[entity_key].attributes[attr_key] - if attr.type == 'text_box' or attr.type == 'dropdown_list': + if attr.type == 'text' or attr.type == 'enumeration' or attr.type == 'boolean': cmds.addAttr(shading_node_name, longName=attr_key, dt="string") cmds.setAttr(shading_node_name + '.' + attr_key, attr.default_value, type="string") - elif attr.type == 'entity_picker': + elif (attr.type == 'colormap') or (attr.type == 'entity'): # if there is a default value, use it if attr.default_value: default_value = float(attr.default_value) @@ -647,12 +663,12 @@ def convert_phong_blinn_material(material): # glossy component glossy_brdf = create_shading_node('microfacet_brdf', name=(material + '_blinn_brdf')) - cmds.setAttr(glossy_brdf + '.mdf', 'blinn', type='string') + cmds.setAttr(glossy_brdf + '.glossiness', 'blinn', type='string') if cmds.nodeType(material) == 'phong': - mdf_param = cmds.getAttr(material + '.cosinePower') * 1.3 + glossy_param = ((cmds.getAttr(material + '.cosinePower') - 2) / 98) * -1 + 1 else: - mdf_param = 10.0 - cmds.setAttr(glossy_brdf + '.mdf_parameter', mdf_param, mdf_param, mdf_param, type='float3') + glossy_param = 0.5 + cmds.setAttr(glossy_brdf + '.mdf_parameter', glossy_param, glossy_param, glossy_param, type='float3') assign_connection_or_color(glossy_brdf + '.reflectance', material + '.specularColor', material + '.specularColor') # mix diffuse and glossy diff --git a/sandbox/extras/maya/scripts/ms_export.py b/sandbox/extras/maya/scripts/ms_export.py index a31a2e58f9..6484892c91 100644 --- a/sandbox/extras/maya/scripts/ms_export.py +++ b/sandbox/extras/maya/scripts/ms_export.py @@ -33,9 +33,12 @@ reload(ms_commands) import ms_export_obj import time +import inspect +import shutil INCH_TO_METER = 0.02539999983236 - +GEO_DIR = '_geometry' +TEXTURE_DIR = '_textures' #-------------------------------------------------------------------------------------------------- # WriteXml class. @@ -83,8 +86,9 @@ def indentation_string(self): def check_export_cancelled(): if cmds.progressWindow(query=True, isCancelled=True): cmds.progressWindow(endProgress=1) - raise RuntimeError('Export Cancelled.') - + ms_commands.warning("Export cancelled") + sys.exit() + #-------------------------------------------------------------------------------------------------- # get_maya_params function. @@ -129,6 +133,8 @@ def get_maya_params(render_settings_node): else: params['environment'] = False + params['render_sky'] = cmds.getAttr(render_settings_node + '.render_sky') + # Cameras. # params['sceneCameraExportAllCameras'] = cmds.checkBox('ms_sceneCameraExportAllCameras', query=True, value=True) params['export_all_cameras_as_thin_lens'] = cmds.getAttr(render_settings_node + '.export_all_cameras_as_thin_lens') @@ -175,6 +181,7 @@ def get_maya_params(render_settings_node): params['pt_max_bounces'] = cmds.getAttr(render_settings_node + '.pt_max_bounces') params['pt_light_samples'] = cmds.getAttr(render_settings_node + '.pt_light_samples') params['pt_environment_samples'] = cmds.getAttr(render_settings_node + '.pt_environment_samples') + params['pt_max_ray_intensity'] = cmds.getAttr(render_settings_node + '.pt_max_ray_intensity') # Select obj exporter. if cmds.pluginInfo('ms_export_obj_' + str(int(mel.eval('getApplicationVersionAsFloat()'))), query=True, r=True): @@ -197,7 +204,10 @@ def get_maya_scene(params): """ Parses the Maya scene and returns a list of root transforms with the relevant children """ - ms_commands.info("Caching Maya scene data...") + info_message = "Caching Maya transform data..." + ms_commands.info(info_message) + cmds.progressWindow(e=True, status=info_message, progress=0, max=1) + cmds.refresh(cv=True) start_time = cmds.currentTime(query=True) @@ -207,7 +217,10 @@ def get_maya_scene(params): # find all root transforms and create Mtransforms from them for maya_transform in cmds.ls(tr=True, long=True): if not cmds.listRelatives(maya_transform, ap=True, fullPath=True): - maya_root_transforms.append(MTransform(params, maya_transform, None)) + if ms_commands.transform_is_renderable(maya_transform): + maya_root_transforms.append(MTransform(params, maya_transform, None)) + + cmds.progressWindow(e=True, progress=1) start_frame = int(start_time) end_frame = start_frame @@ -231,23 +244,33 @@ def get_maya_scene(params): params['output_directory'] = params['output_directory'].replace("", project_directory) params['output_directory'] = params['output_directory'].replace("", scene_basename) - texture_dir = '_textures' - ms_commands.create_dir(os.path.join(params['output_directory'], texture_dir)) - geo_dir = '_geometry' - ms_commands.create_dir(os.path.join(params['output_directory'], geo_dir)) + ms_commands.create_dir(os.path.join(params['output_directory'], TEXTURE_DIR)) + ms_commands.create_dir(os.path.join(params['output_directory'], GEO_DIR)) # get environment environment = None if params['environment']: - environment = MMsEnvironment(params, params['environment']) - environment.add_environment_sample(params['output_directory'], texture_dir, 0) + if cmds.nodeType(params['environment']) == 'ms_physical_environment': + environment = MMsPhysicalEnvironment(params, params['environment']) + else: + environment = MMsEnvironment(params, params['environment']) + + environment.add_environment_sample(params['output_directory'], 0) # add motion samples current_frame = start_frame frame_sample_number = 1 + + cmds.progressWindow(edit=True, progress=0, status='Adding motion samples', max=end_frame - start_frame + 1) + cmds.refresh(cv=True) while current_frame <= end_frame: - ms_commands.info("Adding motion samples, frame {0}...".format(current_frame)) + + info_message = "Adding motion samples, frame {0}...".format(current_frame) + ms_commands.info(info_message) + + cmds.progressWindow(e=True, status=info_message) + cmds.refresh(cv=True) cmds.currentTime(current_frame) @@ -255,7 +278,7 @@ def get_maya_scene(params): initial_sample = (frame_sample_number == 1) for transform in maya_root_transforms: - add_scene_sample(transform, params['export_transformation_blur'], params['export_deformation_blur'], params['export_camera_blur'], current_frame, start_frame, frame_sample_number, initial_sample, params['output_directory'], geo_dir, texture_dir) + add_scene_sample(transform, params['export_transformation_blur'], params['export_deformation_blur'], params['export_camera_blur'], current_frame, start_frame, frame_sample_number, initial_sample, params['output_directory']) frame_sample_number += 1 if frame_sample_number == params['motion_samples']: @@ -263,11 +286,15 @@ def get_maya_scene(params): current_frame += sample_increment - # TODO: add code to export textures here + cmds.progressWindow(e=True, progress=current_frame - start_frame) + cmds.refresh(cv=True) # return to pre-export time cmds.currentTime(start_time) + cmds.progressWindow(e=True, progress=end_frame - start_frame) + cmds.refresh(cv=True) + return maya_root_transforms, environment @@ -276,7 +303,9 @@ def get_maya_scene(params): # TODO: needs mechanism to sample frames for camera and transforms on whole frame numbers for non mb scenes #-------------------------------------------------------------------------------------------------- -def add_scene_sample(m_transform, transform_blur, deform_blur, camera_blur, current_frame, start_frame, frame_sample_number, initial_sample, export_root, geo_dir, tex_dir): +def add_scene_sample(m_transform, transform_blur, deform_blur, camera_blur, current_frame, start_frame, frame_sample_number, initial_sample, export_root): + + check_export_cancelled() if transform_blur or initial_sample: m_transform.add_transform_sample() @@ -288,23 +317,23 @@ def add_scene_sample(m_transform, transform_blur, deform_blur, camera_blur, curr # Only add a sample if this is the first frame to be exported or if it has some deformation if mesh.has_deformation or (current_frame == start_frame): if initial_sample: - mesh.add_deform_sample(export_root, geo_dir, current_frame) + mesh.add_deform_sample(export_root, current_frame) for mesh in m_transform.child_meshes: if (frame_sample_number == 1) or initial_sample: for material in mesh.ms_materials: for texture in material.textures: if texture.is_animated or initial_sample: - texture.add_image_sample(export_root, tex_dir, current_frame) + texture.add_image_sample(export_root, current_frame) for material in mesh.generic_materials: for texture in material.textures: if texture.is_animated or initial_sample: - texture.add_image_sample(export_root, tex_dir, current_frame) + texture.add_image_sample(export_root, current_frame) for light in m_transform.child_lights: if light.color.__class__.__name__ == 'MFile': if light.color.is_animated or initial_sample: - light.color.add_image_sample(export_root, tex_dir, current_frame) + light.color.add_image_sample(export_root, current_frame) for camera in m_transform.child_cameras: if camera_blur or initial_sample or (frame_sample_number == 1): @@ -313,7 +342,7 @@ def add_scene_sample(m_transform, transform_blur, deform_blur, camera_blur, curr camera.add_focal_distance_sample() for transform in m_transform.child_transforms: - add_scene_sample(transform, transform_blur, deform_blur, camera_blur, current_frame, start_frame, frame_sample_number, initial_sample, export_root, geo_dir, tex_dir) + add_scene_sample(transform, transform_blur, deform_blur, camera_blur, current_frame, start_frame, frame_sample_number, initial_sample, export_root) #-------------------------------------------------------------------------------------------------- @@ -373,14 +402,15 @@ def __init__(self, params, maya_transform_name, parent): if mesh_names is not None: self.has_children = True for mesh_name in mesh_names: - if ms_commands.transform_is_visible(mesh_name): - self.child_meshes.append(MMesh(params, mesh_name, self)) + if ms_commands.transform_is_renderable(mesh_name): + if ms_commands.transform_is_visible(mesh_name): + self.child_meshes.append(MMesh(params, mesh_name, self)) light_names = cmds.listRelatives(self.name, type='light', fullPath=True) if light_names is not None: self.has_children = True for light_name in light_names: - if (cmds.nodeType(light_name) == 'pointLight') or (cmds.nodeType(light_name) == 'spotLight'): + if cmds.nodeType(light_name) == 'pointLight' or cmds.nodeType(light_name) == 'spotLight' or cmds.nodeType(light_name) == 'areaLight': self.child_lights.append(MLight(params, light_name, self)) camera_names = cmds.listRelatives(self.name, type='camera', fullPath=True) @@ -454,12 +484,12 @@ def __init__(self, params, maya_mesh_name, MTransform_object): else: self.generic_materials.append(MGenericMaterial(self.params, material_name)) - def add_deform_sample(self, export_root, geo_dir, time): + def add_deform_sample(self, export_root, time): # if the shape current transform is visible, export; # otherwise skip export and just append a null if ms_commands.visible_in_hierarchy(self.transform.name): file_name = '%s_%i_%i.obj' % (self.safe_short_name, self.id, time) - output_file_path = os.path.join(geo_dir, file_name) + output_file_path = os.path.join(GEO_DIR, file_name) # set file path as relative value self.mesh_file_names.append(output_file_path) @@ -468,6 +498,7 @@ def add_deform_sample(self, export_root, geo_dir, time): absolute_file_path = os.path.join(export_root, output_file_path) if not os.path.exists(absolute_file_path) or self.params['overwrite_existing_geometry']: self.params['obj_exporter'](self.name, absolute_file_path, overwrite=True) + else: self.mesh_file_names.append(None) @@ -575,16 +606,16 @@ def __init__(self, params, maya_file_node, source_node=False, attribute=False): self.alpha_is_luminance = False self.has_uv_placement = False - def add_image_sample(self, export_root, texture_dir, time): + def add_image_sample(self, export_root, time): if self.node_type == 'file': image_name = ms_commands.get_file_texture_name(self.name, time) else: - image_name = ms_commands.convert_connection_to_image(self.source_node, self.attribute, os.path.join(export_root, texture_dir, ('{0}_{1}.iff'.format(self.name, time)))) + image_name = ms_commands.convert_connection_to_image(self.source_node, self.attribute, os.path.join(export_root, TEXTURE_DIR, ('{0}_{1}.iff'.format(self.name, time)))) if self.params['convert_textures_to_exr']: if image_name not in self.converted_images: self.converted_images.add(image_name) - converted_image_name = ms_commands.convert_texture_to_exr(image_name, export_root, texture_dir, overwrite=self.params['overwrite_existing_textures'], pass_through=False) + converted_image_name = ms_commands.convert_texture_to_exr(image_name, export_root, TEXTURE_DIR, overwrite=self.params['overwrite_existing_textures'], pass_through=False) self.image_file_names.append(converted_image_name) else: self.image_file_names.append(image_name) @@ -636,11 +667,57 @@ def get_connections(self, attr_name): return None - def add_environment_sample(self, export_root, texture_dir, time): + def add_environment_sample(self, export_root, time): if self.latitude_longitude_exitance is not None: - self.latitude_longitude_exitance.add_image_sample(export_root, texture_dir, time) + self.latitude_longitude_exitance.add_image_sample(export_root, time) if self.mirrorball_exitance is not None: - self.mirrorball_exitance.add_image_sample(export_root, texture_dir, time) + self.mirrorball_exitance.add_image_sample(export_root, time) + +#-------------------------------------------------------------------------------------------------- +# MMsPhysicalEnvironment class. +#-------------------------------------------------------------------------------------------------- + +class MMsPhysicalEnvironment(): + + """ Lightweight class representing Maya ms_physical_environment nodes """ + + def __init__(self, params, maya_ms_environment_node): + self.params = params + self.name = maya_ms_environment_node + self.safe_name = ms_commands.legalize_name(self.name) + + self.model = cmds.getAttr(self.name + '.model') + + # ********** key ************* + # hosek_environment_edf = 0 + # preetham_environment_edf = 1 + + if self.model == 0: + self.model = "hosek_environment_edf" + elif self.model == 1: + self.model = "preetham_environment_edf" + + self.ground_albedo = cmds.getAttr(self.name + '.ground_albedo') + self.horizon_shift = cmds.getAttr(self.name + '.horizon_shift') + self.luminance_multiplier = cmds.getAttr(self.name + '.luminance_multiplier') + self.saturation_multiplier = cmds.getAttr(self.name + '.saturation_multiplier') + self.luminance_gamma = cmds.getAttr(self.name + '.luminance_gamma') + self.sun_phi = cmds.getAttr(self.name + '.sun_phi') + self.sun_theta = cmds.getAttr(self.name + '.sun_theta') + self.turbidity = self.get_connections(self.name + '.turbidity') + self.turbidity_multiplier = cmds.getAttr(self.name + '.turbidity_multiplier') + + def get_connections(self, attr_name): + connection = MColorConnection(self.params, attr_name) + if connection.connected_node is not None: + return m_file_from_color_connection(self.params, connection) + + return connection + + def add_environment_sample(self, export_root, time): + if self.turbidity is not None: + if self.turbidity.__class__.__name__ == 'MFile': + self.turbidity.add_image_sample(export_root, time) #-------------------------------------------------------------------------------------------------- @@ -656,15 +733,21 @@ def __init__(self, params, color_connection): self.safe_name = ms_commands.legalize_name(self.name) self.color_value = cmds.getAttr(self.name) - if self.color_value.__class__.__name__ != 'float': + if self.color_value.__class__.__name__ == 'float': + self.normalized_color = ms_commands.normalizeRGB((self.color_value, self.color_value, self.color_value))[:3] + self.multiplier = ms_commands.normalizeRGB((self.color_value, self.color_value, self.color_value))[3] + else: self.normalized_color = ms_commands.normalizeRGB(self.color_value[0])[:3] self.multiplier = ms_commands.normalizeRGB(self.color_value[0])[3] - else: - self.normalized_color = ms_commands.normalizeRGB((self.color_value, self.color_value, self.color_value))[:3] - self.multiplier = ms_commands.normalizeRGB((self.color_value, self.color_value, self.color_value))[3] self.is_black = self.normalized_color == (0,0,0) self.connected_node = ms_commands.get_connected_node(self.name) + + if (self.normalized_color[0] == self.normalized_color[1]) and (self.normalized_color[0] == self.normalized_color[2]): + self.is_grey = True + else: + self.is_grey = False + if self.connected_node is not None: self.connected_node_type = cmds.nodeType(self.connected_node) @@ -768,7 +851,7 @@ def __init__(self, params, maya_material_name): self.diffuse = None self.alpha = None self.incandescence = None - self.specular_cosine_power = None + self.glossiness = None self.specular_color = None self.textures = [] @@ -788,21 +871,30 @@ def __init__(self, params, maya_material_name): # work out specular components if cmds.attributeQuery('cosinePower', node=self.name, exists=True): - self.specular_cosine_power = MColorConnection(self.params, self.name + '.cosinePower') - if self.specular_cosine_power.connected_node is not None: - self.specular_cosine_power = m_file_from_color_connection(self.params, self.specular_cosine_power) - self.textures.append(self.alpha) - elif self.specular_cosine_power.is_black: - self.specular_cosine_power = None + self.glossiness = MColorConnection(self.params, self.name + '.cosinePower') + self.glossiness.multiplier = ((self.glossiness.multiplier - 2) / 98) * -1 +1 + if self.glossiness.connected_node is not None: + self.glossiness = m_file_from_color_connection(self.params, self.glossiness) + self.textures.append(self.glossiness) + elif self.glossiness.is_black: + self.glossiness = None if cmds.attributeQuery('specularColor', node=self.name, exists=True): self.specular_color = MColorConnection(self.params, self.name + '.specularColor') if self.specular_color.connected_node is not None: self.specular_color = m_file_from_color_connection(self.params, self.specular_color) - self.textures.append(self.alpha) + self.textures.append(self.specular_color) elif self.specular_color.is_black: self.specular_color = None + if cmds.attributeQuery('reflectivity', node=self.name, exists=True): + self.reflectivity = MColorConnection(self.params, self.name + '.reflectivity') + if self.reflectivity.connected_node is not None: + self.reflectivity = m_file_from_color_connection(self.params, self.reflectivity) + self.textures.append(self.reflectivity) + elif self.reflectivity.is_black: + self.reflectivity = None + # work out alpha component if cmds.attributeQuery('transparency', node=self.name, exists=True): self.alpha = MColorConnection(self.params, self.name + '.transparency') @@ -854,12 +946,18 @@ def __init__(self, params, maya_ms_shading_node_name): self.type = cmds.getAttr(self.name + '.node_type') # bsdf, edf etc. self.model = cmds.getAttr(self.name + '.node_model') # lambertian etc. + self.render_layer = None self.child_shading_nodes = [] self.attributes = dict() self.colors = [] self.textures = [] + # add a render layer attribute if it's set + maya_render_layer = cmds.getAttr(self.name + '.render_layer') + if maya_render_layer is not '': + self.render_layer = maya_render_layer + # add the correct attributes based on the entity defs xml for attribute_key in params['entity_defs'][self.model].attributes.keys(): self.attributes[attribute_key] = '' @@ -868,7 +966,8 @@ def __init__(self, params, maya_ms_shading_node_name): maya_attribute = self.name + '.' + attribute_key # if the attribute is a color/entity - if params['entity_defs'][self.model].attributes[attribute_key].type == 'entity_picker': + entity_type = params['entity_defs'][self.model].attributes[attribute_key].type + if (entity_type == 'colormap') or (entity_type == 'entity'): color_connection = MColorConnection(self.params, maya_attribute) if color_connection.connected_node: @@ -1284,11 +1383,14 @@ def __init__(self): self.name = None self.model = None self.parameters = [] + self.render_layer = None def emit_xml(self, doc): doc.start_element('bsdf name="%s" model="%s"' % (self.name, self.model)) for parameter in self.parameters: parameter.emit_xml(doc) + if self.render_layer is not None: + self.render_layer.emit_xml(doc) doc.end_element('bsdf') @@ -1304,11 +1406,14 @@ def __init__(self): self.name = None self.model = None self.parameters = [] + self.render_layer = None def emit_xml(self, doc): doc.start_element('edf name="%s" model="%s"' % (self.name, self.model)) for parameter in self.parameters: parameter.emit_xml(doc) + if self.render_layer is not None: + self.render_layer.emit_xml(doc) doc.end_element('edf') @@ -1324,11 +1429,14 @@ def __init__(self): self.name = None self.model = None self.parameters = [] + self.render_layer = None def emit_xml(self, doc): doc.start_element('surface_shader name="%s" model="%s"' % (self.name, self.model)) for parameter in self.parameters: parameter.emit_xml(doc) + if self.render_layer is not None: + self.render_layer.emit_xml(doc) doc.end_element('surface_shader') @@ -1338,7 +1446,7 @@ def emit_xml(self, doc): class AsLight(): - """ Class representing appleseed Surface Shader entity """ + """ Class representing appleseed Light entity """ def __init__(self): self.name = None @@ -1707,7 +1815,13 @@ def translate_maya_scene(params, maya_scene, maya_environment): if params['export_animation']: frame_list = range(params['animation_start_frame'], params['animation_end_frame'] + 1) - for frame_number in frame_list: + cmds.progressWindow(e=True, status='Translating maya scene', progress=0, max=len(frame_list)) + cmds.refresh(cv=True) + + for i, frame_number in enumerate(frame_list): + + check_export_cancelled() + ms_commands.info("Exporting frame %i..." % frame_number) # mb_sample_number is list of indices that should be iterated over in the cached Maya scene for objects with motion blur @@ -1781,6 +1895,10 @@ def translate_maya_scene(params, maya_scene, maya_environment): pt_params.parameters.append(AsParameter('ibl_env_samples', params['pt_environment_samples'])) pt_params.parameters.append(AsParameter('max_path_length', params['pt_max_bounces'])) pt_params.parameters.append(AsParameter('next_event_estimation', params['pt_next_event_estimation'])) + + if params['pt_max_ray_intensity'] > 0: + pt_params.parameters.append(AsParameter('max_ray_intensity', params['pt_max_ray_intensity'])) + config.parameters.append(pt_params) # begin scene object @@ -1788,6 +1906,7 @@ def translate_maya_scene(params, maya_scene, maya_environment): # if present add the environment if maya_environment is not None: + environment = AsEnvironment() environment.name = maya_environment.safe_name @@ -1797,37 +1916,67 @@ def translate_maya_scene(params, maya_scene, maya_environment): environment.environment_edf = AsParameter('environment_edf', environment_edf.name) - if environment_edf.model == 'constant_environment_edf': - constant_environment_color = m_color_connection_to_as_color(maya_environment.constant_exitance, '_constant_exitance') - environment_edf.parameters.append(AsParameter('exitance', constant_environment_color.name)) - as_project.scene.colors.append(constant_environment_color) + if maya_environment.__class__.__name__ == 'MMsPhysicalEnvironment': + environment_edf.model = maya_environment.model + environment_edf.parameters.append(AsParameter('ground_albedo' , maya_environment.ground_albedo)) + environment_edf.parameters.append(AsParameter('horizon_shift' , maya_environment.horizon_shift)) + environment_edf.parameters.append(AsParameter('luminance_multiplier' , maya_environment.luminance_multiplier)) + environment_edf.parameters.append(AsParameter('saturation_multiplier' , maya_environment.saturation_multiplier)) + environment_edf.parameters.append(AsParameter('luminance_gamma' , maya_environment.luminance_gamma)) + environment_edf.parameters.append(AsParameter('sun_phi' , maya_environment.sun_phi)) + environment_edf.parameters.append(AsParameter('sun_theta' , maya_environment.sun_theta)) + environment_edf.parameters.append(AsParameter('turbidity_multiplier' , maya_environment.turbidity_multiplier)) + + if maya_environment.turbidity.__class__.__name__ == 'MFile': + turbidity_file, turbidity_file_instance = m_file_to_as_texture(params, maya_environment.turbidity, '_texture', non_mb_sample_number) + as_project.scene.textures.append(turbidity_file) + as_project.scene.texture_instances.append(turbidity_file_instance) + environment_edf.parameters.append(AsParameter('exitance', turbidity_file_instance.name)) + else: + turbidity_color = m_color_connection_to_as_color(maya_environment.turbidity, '_turbidity') + environment_edf.parameters.append(AsParameter('turbidity', turbidity_color.name)) + as_project.scene.colors.append(turbidity_color) - elif environment_edf.model == 'gradient_environment_edf': - gradient_horizon_exitance = m_color_connection_to_as_color(maya_environment.gradient_horizon_exitance, '_horizon_exitance') - environment_edf.parameters.append(AsParameter('horizon_exitance', gradient_horizon_exitance.name)) - as_project.scene.colors.append(gradient_horizon_exitance) + else: + # environment must be generic + if environment_edf.model == 'constant_environment_edf': + constant_environment_color = m_color_connection_to_as_color(maya_environment.constant_exitance, '_constant_exitance') + environment_edf.parameters.append(AsParameter('exitance', constant_environment_color.name)) + as_project.scene.colors.append(constant_environment_color) + + elif environment_edf.model == 'gradient_environment_edf': + gradient_horizon_exitance = m_color_connection_to_as_color(maya_environment.gradient_horizon_exitance, '_horizon_exitance') + environment_edf.parameters.append(AsParameter('horizon_exitance', gradient_horizon_exitance.name)) + as_project.scene.colors.append(gradient_horizon_exitance) + + zenith_horizon_exitance = m_color_connection_to_as_color(maya_environment.gradient_zenith_exitance, '_zenith_exitance') + environment_edf.parameters.append(AsParameter('zenith_exitance', zenith_horizon_exitance.name)) + as_project.scene.colors.append(zenith_horizon_exitance) + + elif environment_edf.model == 'latlong_map_environment_edf': + lat_long_map, lat_long_map_instance = m_file_to_as_texture(params, maya_environment.latitude_longitude_exitance, '_texture', non_mb_sample_number) + + as_project.scene.textures.append(lat_long_map) + as_project.scene.texture_instances.append(lat_long_map_instance) - zenith_horizon_exitance = m_color_connection_to_as_color(maya_environment.gradient_zenith_exitance, '_zenith_exitance') - environment_edf.parameters.append(AsParameter('zenith_exitance', zenith_horizon_exitance.name)) - as_project.scene.colors.append(zenith_horizon_exitance) + environment_edf.parameters.append(AsParameter('exitance', lat_long_map_instance.name)) - elif environment_edf.model == 'latlong_map_environment_edf': - lat_long_map, lat_long_map_instance = m_file_to_as_texture(params, maya_environment.latitude_longitude_exitance, '_texture', non_mb_sample_number) - - as_project.scene.textures.append(lat_long_map) - as_project.scene.texture_instances.append(lat_long_map_instance) - - environment_edf.parameters.append(AsParameter('exitance', lat_long_map_instance.name)) + elif environment_edf.model == 'mirrorball_map_environment_edf': + mirror_ball_map, mirror_ball_map_instance = m_file_to_as_texture(params, maya_environment.mirrorball_exitance, '_texture', non_mb_sample_number) + + as_project.scene.textures.append(mirror_ball_map) + as_project.scene.texture_instances.append(mirror_ball_map_instance) - elif environment_edf.model == 'mirrorball_map_environment_edf': - mirror_ball_map, mirror_ball_map_instance = m_file_to_as_texture(params, maya_environment.mirrorball_exitance, '_texture', non_mb_sample_number) - - as_project.scene.textures.append(mirror_ball_map) - as_project.scene.texture_instances.append(mirror_ball_map_instance) + environment_edf.parameters.append(AsParameter('exitance', mirror_ball_map_instance.name)) - environment_edf.parameters.append(AsParameter('exitance', mirror_ball_map_instance.name)) + environment_edf.parameters.append(AsParameter('exitance_multiplier', str(maya_environment.exitance_multiplier))) - environment_edf.parameters.append(AsParameter('exitance_multiplier', str(maya_environment.exitance_multiplier))) + if params['render_sky']: + environment_shader = AsEnvironmentShader() + environment_shader.name = maya_environment.safe_name + '_shader' + environment_shader.edf = AsParameter('environment_edf', environment_edf.name) + environment.environment_shader = AsParameter('environment_shader', environment_shader.name) + as_project.scene.environment_shaders.append(environment_shader) as_project.scene.environment = environment as_project.scene.environment_edfs.append(environment_edf) @@ -1904,6 +2053,16 @@ def translate_maya_scene(params, maya_scene, maya_environment): root_assembly.surface_shaders.append(default_surface_shader) root_assembly.materials.append(default_material) + # create default area light edf back material and surface shaders + default_invisible_surface_shader = AsSurfaceShader() + + default_invisible_material = AsMaterial() + default_invisible_material.name = 'as_default_invisible_material' + default_invisible_material.alpha_map = AsParameter('alpha_map', '0') + default_invisible_material.surface_shader = AsParameter('surface_shader', default_surface_shader.name) + + root_assembly.materials.append(default_invisible_material) + for transform in maya_scene: construct_transform_descendents(params, root_assembly, root_assembly, [], transform, mb_sample_number_list, non_mb_sample_number, params['export_camera_blur'], params['export_transformation_blur'], params['export_deformation_blur']) @@ -1915,6 +2074,8 @@ def translate_maya_scene(params, maya_scene, maya_environment): as_object_models.append((project_file_path, as_project)) + cmds.progressWindow(e=True, progress=i) + return as_object_models @@ -1954,33 +2115,73 @@ def construct_transform_descendents(params, root_assembly, parent_assembly, matr for light in maya_transform.child_lights: - new_light = AsLight() - new_light.name = light.safe_name - - new_light.exitance_multiplier.value = light.multiplier - + # create colour entites if light.color.__class__.__name__ == 'MFile': light_color_file, light_color = m_file_to_as_texture(params, light.color, '_light_color', non_mb_sample_number) current_assembly.textures.append(light_color_file) current_assembly.texture_instances.append(light_color) else: light_color = m_color_connection_to_as_color(light.color, '_light_color') - new_light.exitance_multiplier.value = new_light.exitance_multiplier.value * light_color.multiplier.value current_assembly.colors.append(light_color) - new_light.exitance = AsParameter('exitance', light_color.name) - new_light.transform = AsTransform() - if current_matrix_stack is not []: - new_light.transform.matrices = current_matrix_stack + if light.model == 'areaLight': + + # create new light mesh instance and material + light_mesh = AsObject() + light_mesh.name = light.safe_name + light_mesh.file_names = AsParameter('filename', GEO_DIR + '/maya_area_light.obj') + + light_mesh_transform = AsTransform() + if current_matrix_stack is not []: + light_mesh_transform.matrices = current_matrix_stack + + light_mesh_instance = light_mesh.instantiate() + light_mesh_instance.transforms.append(light_mesh_transform) + + light_material = AsMaterial() + light_material.name = light.safe_name + '_material' + + light_edf = AsEdf() + light_edf.name = light.safe_name + '_edf' + light_edf.model = 'diffuse_edf' + light_edf.render_layer = AsParameter('render_layer', light.safe_name) + light_edf.parameters.append(AsParameter('radiance', light_color.name)) + light_edf.parameters.append(AsParameter('radiance_multiplier', light.multiplier)) + current_assembly.edfs.append(light_edf) + + light_material.surface_shader = AsParameter('surface_shader', 'as_default_surface_shader') + light_material.edf = AsParameter('edf', light_edf.name) + light_material.alpha_map = AsParameter('alpha_map', '0') + current_assembly.materials.append(light_material) + + light_mesh_instance.material_assignments.append(AsObjectInstanceMaterialAssignment('0', 'front', light_material.name)) + light_mesh_instance.material_assignments.append(AsObjectInstanceMaterialAssignment('0', 'back', 'as_default_invisible_material')) + + current_assembly.objects.append(light_mesh) + current_assembly.object_instances.append(light_mesh_instance) - if light.model == 'spotLight': - new_light.model = 'spot_light' - new_light.inner_angle = AsParameter('inner_angle', light.inner_angle) - new_light.outer_angle = AsParameter('outer_angle', light.outer_angle) else: - new_light.model = 'point_light' + new_light = AsLight() + new_light.name = light.safe_name + + if light.color.__class__.__name__ == 'MFile': + new_light.exitance_multiplier.value = new_light.exitance_multiplier.value * light_color.multiplier.value + else: + new_light.exitance_multiplier.value = light.multiplier + + new_light.exitance = AsParameter('exitance', light_color.name) + new_light.transform = AsTransform() + if current_matrix_stack is not []: + new_light.transform.matrices = current_matrix_stack + + if light.model == 'spotLight': + new_light.model = 'spot_light' + new_light.inner_angle = AsParameter('inner_angle', light.inner_angle) + new_light.outer_angle = AsParameter('outer_angle', light.outer_angle) + else: + new_light.model = 'point_light' - current_assembly.lights.append(new_light) + current_assembly.lights.append(new_light) for mesh in maya_transform.child_meshes: # For now we won't be supporting instantiating objects. When the time comes I will add a function call here @@ -2059,47 +2260,74 @@ def convert_maya_generic_material(params, root_assembly, generic_material, non_m new_lambertian_bsdf.model = 'lambertian_brdf' root_assembly.bsdfs.append(new_lambertian_bsdf) + # material transparency + if generic_material.alpha is not None: + if generic_material.alpha.__class__.__name__ == 'MFile': + alpha_texture, alpha_texture_instance = m_file_to_as_texture(params, generic_material.alpha, '_alpha', non_mb_sample_number) + new_material.alpha_map = AsParameter('alpha_map', alpha_texture_instance.name) + if not get_from_list(root_assembly.textures, alpha_texture.name): + root_assembly.textures.append(alpha_texture) + root_assembly.texture_instances.append(alpha_texture_instance) + else: + # we invert the alpha color here to match the maya viewport behavior + new_material.alpha_map = AsParameter('alpha_map', generic_material.alpha.color_value[0][0] * -1) + # only use phong mix if the specular color is > 0 or exists - if generic_material.specular_color is not None: - if not generic_material.specular_color.is_black: + if (generic_material.specular_color is not None) and (generic_material.glossiness is not None): + + new_microfacet_bsdf = AsBsdf() + new_microfacet_bsdf.name = generic_material.safe_name + '_microfacet_brdf' + new_microfacet_bsdf.model = 'microfacet_brdf' + new_microfacet_bsdf.parameters.append(AsParameter('mdf', 'blinn')) + root_assembly.bsdfs.append(new_microfacet_bsdf) - new_microfacet_bsdf = AsBsdf() - new_microfacet_bsdf.name = generic_material.safe_name + '_microfacet_brdf' - new_microfacet_bsdf.model = 'microfacet_brdf' - new_microfacet_bsdf.parameters.append(AsParameter('mdf', 'blinn')) - root_assembly.bsdfs.append(new_microfacet_bsdf) + new_bsdf_blend_bsdf = AsBsdf() + new_bsdf_blend_bsdf.name = generic_material.safe_name + '_bsdf_blend_bsdf' + new_bsdf_blend_bsdf.model = 'bsdf_blend' + root_assembly.bsdfs.append(new_bsdf_blend_bsdf) - new_bsdf_mix_bsdf = AsBsdf() - new_bsdf_mix_bsdf.name = generic_material.safe_name + '_bsdf_mix_bsdf' - new_bsdf_mix_bsdf.model = 'bsdf_mix' - root_assembly.bsdfs.append(new_bsdf_mix_bsdf) + new_bsdf_blend_bsdf.parameters.append(AsParameter('bsdf0', new_microfacet_bsdf.name)) + new_bsdf_blend_bsdf.parameters.append(AsParameter('bsdf1', new_lambertian_bsdf.name)) - new_bsdf_mix_bsdf.parameters.append(AsParameter('bsdf0', new_lambertian_bsdf.name)) - new_bsdf_mix_bsdf.parameters.append(AsParameter('bsdf1', new_microfacet_bsdf.name)) - new_bsdf_mix_bsdf.parameters.append(AsParameter('weight0', '1.0')) - new_bsdf_mix_bsdf.parameters.append(AsParameter('weight1', '0.2')) + if generic_material.reflectivity.__class__.__name__ == 'MFile': + bsdf_reflectivity_texture, bsdf_reflectivity_texture_instance = m_file_to_as_texture(params, generic_material.reflectivity, '_reflectivity', non_mb_sample_number) + new_bsdf_blend_bsdf.parameters.append(AsParameter('weight', bsdf_reflectivity_texture_instance.name)) - new_material.bsdf = AsParameter('bsdf', new_bsdf_mix_bsdf.name) + if not get_from_list(root_assembly.textures, bsdf_reflectivity_texture.name): + root_assembly.textures.append(bsdf_reflectivity_texture) + root_assembly.texture_instances.append(bsdf_reflectivity_texture_instance) + else: + new_bsdf_blend_bsdf.parameters.append(AsParameter('weight', generic_material.reflectivity.color_value)) + new_material.bsdf = AsParameter('bsdf', new_bsdf_blend_bsdf.name) - if generic_material.specular_cosine_power.__class__.__name__ == 'MFile': - bsdf_specular_cosine_texture, bsdf_specular_cosine_texture_instance = m_file_to_as_texture(params, generic_material.specular_cosine_power, '_bsdf', non_mb_sample_number) - new_microfacet_bsdf.parameters.append(AsParameter('mdf_parameter', bsdf_specular_cosine_texture_instance.name)) - root_assembly.textures.append(bsdf_specular_cosine_texture) - root_assembly.texture_instances.append(bsdf_specular_cosine_texture_instance) + # glossiness parameter + if generic_material.glossiness.__class__.__name__ == 'MFile': + bsdf_glossiness_texture, bsdf_glossiness_texture_instance = m_file_to_as_texture(params, generic_material.glossiness, '_file', non_mb_sample_number) + new_microfacet_bsdf.parameters.append(AsParameter('glossiness', bsdf_glossiness_texture_instance.name)) + if not get_from_list(root_assembly.textures, bsdf_glossiness_texture.name): + root_assembly.textures.append(bsdf_glossiness_texture) + root_assembly.texture_instances.append(bsdf_glossiness_texture_instance) + else: + if generic_material.glossiness.is_grey: + new_microfacet_bsdf.parameters.append(AsParameter('glossiness', (generic_material.glossiness.color_value / 100) * 1.3)) else: - bsdf_specular_cosine_color = m_color_connection_to_as_color(generic_material.specular_cosine_power, '_bsdf') - bsdf_specular_cosine_color.multiplier.value = bsdf_specular_cosine_color.multiplier.value * 1.3 - new_microfacet_bsdf.parameters.append(AsParameter('mdf_parameter', bsdf_specular_cosine_color.name)) - root_assembly.colors.append(bsdf_specular_cosine_color) - - if generic_material.specular_color.__class__.__name__ == 'MFile': - bsdf_specular_color_texture, bsdf_specular_color_texture_instance = m_file_to_as_texture(params, generic_material.specular_color, '_bsdf', non_mb_sample_number) - new_microfacet_bsdf.parameters.append(AsParameter('reflectance', bsdf_specular_color_texture_instance.name)) + bsdf_glossiness_color = m_color_connection_to_as_color(generic_material.glossiness, '_color') + bsdf_glossiness_color.multiplier.value *= 1.3 + new_microfacet_bsdf.parameters.append(AsParameter('glossiness', bsdf_glossiness_color.name)) + root_assembly.colors.append(bsdf_glossiness_color) + + if generic_material.specular_color.__class__.__name__ == 'MFile': + bsdf_specular_color_texture, bsdf_specular_color_texture_instance = m_file_to_as_texture(params, generic_material.specular_color, '_file', non_mb_sample_number) + new_microfacet_bsdf.parameters.append(AsParameter('reflectance', bsdf_specular_color_texture_instance.name)) + if not get_from_list(root_assembly.textures, bsdf_specular_color_texture.name): root_assembly.textures.append(bsdf_specular_color_texture) root_assembly.texture_instances.append(bsdf_specular_color_texture_instance) + else: + if generic_material.specular_color.is_grey: + new_microfacet_bsdf.parameters.append(AsParameter('reflectance', generic_material.specular_color.color_value[0][0])) else: - bsdf_specular_color_color = m_color_connection_to_as_color(generic_material.specular_color, '_bsdf') + bsdf_specular_color_color = m_color_connection_to_as_color(generic_material.specular_color, '_color') if bsdf_specular_color_color.multiplier.value > 1 : bsdf_specular_color_color.multiplier.value = 1 new_microfacet_bsdf.parameters.append(AsParameter('reflectance', bsdf_specular_color_color.name)) root_assembly.colors.append(bsdf_specular_color_color) @@ -2107,49 +2335,69 @@ def convert_maya_generic_material(params, root_assembly, generic_material, non_m else: new_material.bsdf = AsParameter('bsdf', new_lambertian_bsdf.name) - + # reflectance parameter if generic_material.diffuse.__class__.__name__ == 'MFile': - bsdf_texture, bsdf_texture_instance = m_file_to_as_texture(params, generic_material.diffuse, '_bsdf', non_mb_sample_number) + bsdf_texture, bsdf_texture_instance = m_file_to_as_texture(params, generic_material.diffuse, '_file', non_mb_sample_number) new_lambertian_bsdf.parameters.append(AsParameter('reflectance', bsdf_texture_instance.name)) - root_assembly.textures.append(bsdf_texture) - root_assembly.texture_instances.append(bsdf_texture_instance) + + if not get_from_list(root_assembly.textures, bsdf_texture.name): + root_assembly.textures.append(bsdf_texture) + root_assembly.texture_instances.append(bsdf_texture_instance) else: - bsdf_color = m_color_connection_to_as_color(generic_material.diffuse, '_bsdf') + bsdf_color = m_color_connection_to_as_color(generic_material.diffuse, '_color') if bsdf_color.multiplier.value > 1 : bsdf_color.multiplier.value = 1 new_lambertian_bsdf.parameters.append(AsParameter('reflectance', bsdf_color.name)) root_assembly.colors.append(bsdf_color) - + # incandescence component if generic_material.incandescence is not None: new_edf = AsEdf() new_edf.name = generic_material.safe_name + '_edf' new_edf.model = 'diffuse_edf' + new_edf.parameters.append(AsParameter('render_layer', generic_material.safe_name + '_layer')) root_assembly.edfs.append(new_edf) new_material.edf = AsParameter('edf', new_edf.name) + # add a constant surface shader + new_surface_shader = AsSurfaceShader() + new_surface_shader.name = generic_material.safe_name + '_surface_shader' + new_surface_shader.model = 'constant_surface_shader' + root_assembly.surface_shaders.append(new_surface_shader) + new_material.surface_shader = AsParameter('surface_shader', new_surface_shader.name) + if generic_material.incandescence.__class__.__name__ == 'MFile': edf_texture, edf_texture_instance = m_file_to_as_texture(params, generic_material.incandescence, '_edf', non_mb_sample_number) new_edf.parameters.append(AsParameter('exitance', edf_texture_instance.name)) - root_assembly.textures.append(edf_texture) - root_assembly.texture_instances.append(edf_texture_instance) + if not get_from_list(root_assembly.textures, edf_texture.name): + root_assembly.textures.append(edf_texture) + root_assembly.texture_instances.append(edf_texture_instance) + + # attach edf texture to surface_shader color + new_surface_shader.parameters.append(AsParameter('color', edf_texture_instance.name)) else: edf_color = m_color_connection_to_as_color(generic_material.incandescence, '_edf') new_edf.parameters.append(AsParameter('exitance', edf_color.name)) root_assembly.colors.append(edf_color) + # attach edf color to surface_shader color + new_surface_shader.parameters.append(AsParameter('color', edf_color.name)) - new_surface_shader = AsSurfaceShader() - new_surface_shader.name = generic_material.safe_name + '_surface_shader' - new_surface_shader.model = 'physical_surface_shader' - root_assembly.surface_shaders.append(new_surface_shader) - new_material.surface_shader = AsParameter('surface_shader', new_surface_shader.name) + + else: + # add a physical surface shader + new_surface_shader = AsSurfaceShader() + new_surface_shader.name = generic_material.safe_name + '_surface_shader' + new_surface_shader.model = 'physical_surface_shader' + root_assembly.surface_shaders.append(new_surface_shader) + new_material.surface_shader = AsParameter('surface_shader', new_surface_shader.name) if generic_material.alpha is not None: if generic_material.alpha.__class__.__name__ == 'MFile': alpha_texture, alpha_texture_instance = m_file_to_as_texture(params, generic_material.alpha, '_alpha', non_mb_sample_number) new_surface_shader.parameters.append(AsParameter('exitance', alpha_texture_instance.name)) - root_assembly.textures.append(alpha_texture) - root_assembly.texture_instances.append(alpha_texture_instance) + if not get_from_list(root_assembly.textures, alpha_texture.name): + root_assembly.textures.append(alpha_texture) + root_assembly.texture_instances.append(alpha_texture_instance) else: alpha_color = m_color_connection_to_as_color(generic_material.alpha) new_surface_shader.parameters.append(AsParameter('exitance', alpha_color.name)) @@ -2222,7 +2470,6 @@ def convert_maya_ms_material_network(params, root_assembly, ms_material, non_mb_ texture_instance = existing_texture_instance front_material.displacement_map = AsParameter('displacement_map', texture_instance.name) - front_material.displacement_mode = displacement_mode front_material.bump_amplitude = bump_amplitude front_material.normal_map_up = normal_map_up @@ -2325,6 +2572,8 @@ def build_as_shading_nodes(params, root_assembly, current_maya_shading_node, non current_shading_node.name = current_maya_shading_node.safe_name current_shading_node.model = current_maya_shading_node.model + if current_shading_node.render_layer is not '': + current_shading_node.render_layer = AsParameter('render_layer', current_maya_shading_node.render_layer) for attrib_key in current_maya_shading_node.attributes: if current_maya_shading_node.attributes[attrib_key].__class__.__name__ == 'MMsShadingNode': @@ -2358,19 +2607,23 @@ def build_as_shading_nodes(params, root_assembly, current_maya_shading_node, non current_shading_node.parameters.append(new_shading_node_parameter) elif current_maya_shading_node.attributes[attrib_key].__class__.__name__ == 'MColorConnection': - new_color_entity = get_from_list(root_assembly.colors, current_maya_shading_node.attributes[attrib_key].safe_name) - - if new_color_entity is None: - new_color_entity = AsColor() - new_color_entity.name = current_maya_shading_node.attributes[attrib_key].safe_name - new_color_entity.RGB_color = current_maya_shading_node.attributes[attrib_key].normalized_color - new_color_entity.multiplier.value = current_maya_shading_node.attributes[attrib_key].multiplier - if params['force_linear_color_interpretation']: - new_color_entity.color_space.value = 'linear_rgb' - root_assembly.colors.append(new_color_entity) - new_shading_node_parameter = AsParameter(attrib_key, new_color_entity.name) - current_shading_node.parameters.append(new_shading_node_parameter) + if current_maya_shading_node.attributes[attrib_key].is_grey is True: + current_shading_node.parameters.append(AsParameter(attrib_key, current_maya_shading_node.attributes[attrib_key].normalized_color[0])) + else: + + new_color_entity = get_from_list(root_assembly.colors, current_maya_shading_node.attributes[attrib_key].safe_name) + + if new_color_entity is None: + new_color_entity = AsColor() + new_color_entity.name = current_maya_shading_node.attributes[attrib_key].safe_name + new_color_entity.RGB_color = current_maya_shading_node.attributes[attrib_key].normalized_color + new_color_entity.multiplier.value = current_maya_shading_node.attributes[attrib_key].multiplier + if params['force_linear_color_interpretation']: + new_color_entity.color_space.value = 'linear_rgb' + + root_assembly.colors.append(new_color_entity) + current_shading_node.parameters.append(AsParameter(attrib_key, new_color_entity.name)) elif current_maya_shading_node.attributes[attrib_key].__class__.__name__ == 'str': new_shading_node_parameter = AsParameter(attrib_key, current_maya_shading_node.attributes[attrib_key]) @@ -2389,18 +2642,37 @@ def export_container(render_settings_node): export_start_time = time.time() + cmds.progressWindow(title='Exporting ...', + min=0, + max=100, + progress=0, + status='Beginning export', + isInterruptable=True) + + # cache maya scene params = get_maya_params(render_settings_node) maya_scene, maya_environment = get_maya_scene(params) scene_cache_finish_time = time.time() ms_commands.info('Scene cached for translation in %.2f seconds.' % (scene_cache_finish_time - export_start_time)) + # copy area light primitives into export directory + current_script_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + obj_file_name = 'maya_area_light.obj' + obj_source_path = os.path.join(current_script_path, obj_file_name) + obj_dest_path = os.path.join(params['output_directory'], GEO_DIR, obj_file_name) + shutil.copy(obj_source_path, obj_dest_path) + + # translate maya scene as_object_models = translate_maya_scene(params, maya_scene, maya_environment) scene_translation_finish_time = time.time() ms_commands.info('Scene translated in %.2f seconds.' % (scene_translation_finish_time - scene_cache_finish_time)) - for as_object in as_object_models: + cmds.progressWindow(e=True, status='Writing scene files', progress=0, max=len(as_object_models)) + cmds.refresh(cv=True) + + for i, as_object in enumerate(as_object_models): ms_commands.info('Saving %s...' % as_object[0]) doc = WriteXml(as_object[0]) doc.append_line('') @@ -2408,8 +2680,13 @@ def export_container(render_settings_node): as_object[1].emit_xml(doc) doc.close() + cmds.progressWindow(e=True, progress=i) + cmds.refresh(cv=True) + export_finish_time = time.time() + cmds.progressWindow(endProgress=1) + completed_message = 'Export completed in %.2f seconds, see the script editor for details.' % (export_finish_time - export_start_time) ms_commands.info(completed_message) diff --git a/sandbox/extras/maya/scripts/ms_menu.py b/sandbox/extras/maya/scripts/ms_menu.py index 9553ab7ad5..7fadf4d8f4 100644 --- a/sandbox/extras/maya/scripts/ms_menu.py +++ b/sandbox/extras/maya/scripts/ms_menu.py @@ -49,8 +49,12 @@ def buildMenu(): # Add/Select Environment Node cmds.menuItem(divider=True, parent='ms_menu') + cmds.menuItem(label='Add Physical Environment Node', parent='ms_menu', command='import maya.cmds\nmaya.cmds.createNode("ms_physical_environment")') cmds.menuItem(label='Add Environment Node', parent='ms_menu', command='import maya.cmds\nmaya.cmds.createNode("ms_environment")') cmds.menuItem('menu_select_environment', subMenu=True, label='Select Environment Node', to=True, parent='ms_menu') + for environment in cmds.ls(type='ms_physical_environment'): + cmds.menuItem(label=environment, parent='menu_select_environment', command=('import maya.cmds as cmds\ncmds.select("{0}")'.format(environment))) + cmds.menuItem(divider=True, parent='menu_select_environment') for environment in cmds.ls(type='ms_environment'): cmds.menuItem(label=environment, parent='menu_select_environment', command=('import maya.cmds as cmds\ncmds.select("{0}")'.format(environment)))