diff --git a/.github/workflows/main/options.windows b/.github/workflows/main/options.windows index 5a7c3b3010..a7483e05da 100644 --- a/.github/workflows/main/options.windows +++ b/.github/workflows/main/options.windows @@ -47,10 +47,6 @@ USD_LIB_PATH = libs USD_LIB_PREFIX = "usd_" DOXYGEN = deps + "\\doxygen\\doxygen.exe" -# DCC Integrations -# ================ -NUKE_ROOT = "" - # Environment # =========== diff --git a/.gitignore b/.gitignore index 554f52231f..bbc7e6152f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ plugins lib build config.log -mayaLog projects test/IECore/IECoreTest test/*/results*.txt diff --git a/Changes b/Changes index dafed3ac37..f947b4d16a 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,13 @@ Fixes - Fixed writing of shutter values from cameras without a `shutter` parameter. The `shutter:open` and `shutter:close` attributes are now omitted instead of being written with Cortex's default -0.5, 0.5 shutter values. - Fixed reading of shutter values from cameras without `shutter:open` and `shutter:close` attributes. The `shutter` parameter is now omitted instead of being created with USD's default 0, 0 shutter values. +Breaking Changes +---------------- + +- IECoreHoudini : Removed. +- IECoreMaya : Removed. +- IECoreNuke : Removed. + 10.5.x.x (relative to 10.5.15.0) ======== diff --git a/README.md b/README.md index 1b11d10171..affcf08473 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,7 @@ # Cortex # -Cortex is a cross-application framework for computation, rendering, and file I/O that provides a set of high-quality C++ libraries and Python modules tailored for software development in the VFX industry. This project focuses on creating a set of practical and reusable modules for technical directors, CG supervisors, and programmers, freeing them to focus on innovation and new features in their software projects. - -Out of the box, Cortex has full support for the [Arnold](https://www.arnoldrenderer.com/arnold/) and [3Delight](https://www.3delight.com) renderers. It also has built-in integration with Maya, Houdini, and Nuke, with default user interfaces that provide for file I/O and live data manipulation. With its extensible API, Cortex’s DCC integration can be expanded to create custom tools to solve studio pipeline needs. +Cortex is a framework for computation, rendering, and file I/O that provides a set of high-quality C++ libraries and Python modules tailored for software development in the VFX industry. This project focuses on creating a set of practical and reusable modules for technical directors, CG supervisors, and programmers, freeing them to focus on innovation and new features in their software projects. You can find out more from our [introductory paper on Cortex](https://github.com/ImageEngine/cortex/wiki/pdfs/AnOpenSourceFrameworkForVisualEffectsSoftwareDevelopment.pdf) and the [Cortex presentations at SIGGRAPH 2011](https://vimeo.com/album/5504655). diff --git a/SConstruct b/SConstruct index 559099aabc..73cd2dc16e 100644 --- a/SConstruct +++ b/SConstruct @@ -339,27 +339,6 @@ o.Add( "", ) -# Nuke options - -o.Add( - "NUKE_ROOT", - "The directory in which Nuke is installed.", - "" -) - -o.Add( - "NUKE_LICENSE_FILE", - "The path to the FlexLM license file to use for Nuke. This is necessary to run the tests.", - "", -) - -o.Add( - "USG_SHIMLIB_PATH", - "The path to the FnUsdShim to use for Nuke. This may be necessary to run the tests.", - "", -) - - # OpenGL options try : @@ -391,82 +370,6 @@ o.Add( "", ) -# Maya options - -o.Add( - "MAYA_ROOT", - "The path to the root of the maya installation.", - "", -) - -o.Add( - "MAYA_LICENSE_FILE", - "The path to FlexLM license file to use for Maya.", - "", -) - -o.Add( - "MAYA_ADLM_ENV_FILE", - "The path to ADLM env xml file to use as of Maya 2010.", - "", -) - -try : - o.Add( - BoolVariable( - "WITH_MAYA_PLUGIN_LOADER", - "Set this to install the Maya plugin with a stub loader.", - False - ), - ) -except NameError : - # fallback for old scons versions - o.Add( - BoolOption( - "WITH_MAYA_PLUGIN_LOADER", - "Set this to install the Maya plugin with a stub loader.", - False - ), - ) - -# Houdini options - -o.Add( - "HOUDINI_ROOT", - "The path to the Houdini install.", - os.environ.get( "HFS", "" ), -) - -o.Add( - "HOUDINI_INCLUDE_PATH", - "The path to the Houdini include directory.", - "$HOUDINI_ROOT/toolkit/include", -) - -o.Add( - "HOUDINI_LIB_PATH", - "The path to the houdini lib directory.", - "$HOUDINI_ROOT/dsolib", -) - -o.Add( - "HOUDINI_BIN_PATH", - "The path to the houdini lib directory.", - "$HOUDINI_ROOT/bin", -) - -o.Add( - "HOUDINI_CXX_FLAGS", - "C++ Flags to pass to the Houdini compilation.", - "", -) - -o.Add( - "HOUDINI_LINK_FLAGS", - "Flags to pass to the Houdini linker.", - "", -) - # USD options o.Add( @@ -630,30 +533,6 @@ o.Add( "$INSTALL_PREFIX/lib/$IECORE_NAME", ) -o.Add( - "INSTALL_MAYALIB_NAME", - "The name under which to install the maya libraries. This " - "can be used to build and install the library for multiple " - "Maya versions.", - "$INSTALL_PREFIX/lib/$IECORE_NAME", -) - -o.Add( - "INSTALL_NUKELIB_NAME", - "The name under which to install the nuke libraries. This " - "can be used to build and install the library for multiple " - "Nuke versions.", - "$INSTALL_PREFIX/lib/$IECORE_NAME", -) - -o.Add( - "INSTALL_HOUDINILIB_NAME", - "The name under which to install the houdini libraries. This " - "can be used to build and install the library for multiple " - "Houdini versions.", - "$INSTALL_PREFIX/lib/$IECORE_NAME", -) - o.Add( "INSTALL_ALEMBICLIB_NAME", "The name under which to install the Alembic libraries. This " @@ -676,12 +555,6 @@ o.Add( "$INSTALL_PREFIX/lib/python$PYTHON_VERSION/site-packages", ) -o.Add( - "INSTALL_NUKEPYTHON_DIR", - "The directory in which to install the nuke python module.", - "$INSTALL_PREFIX/lib/python$PYTHON_VERSION/site-packages", -) - o.Add( "INSTALL_GLSL_HEADER_DIR", "The directory in which to install GLSL headers.", @@ -694,60 +567,6 @@ o.Add( "$INSTALL_PREFIX/glsl", ) -o.Add( - "INSTALL_MEL_DIR", - "The directory in which to install mel scripts.", - "$INSTALL_PREFIX/maya/mel/$IECORE_NAME", -) - -o.Add( - "INSTALL_HOUDINIICON_DIR", - "The directory under which to install houdini icons.", - "$INSTALL_PREFIX/houdini/icons", -) - -o.Add( - "INSTALL_HOUDINITOOLBAR_DIR", - "The directory under which to install houdini shelf files.", - "$INSTALL_PREFIX/houdini/toolbar", -) - -o.Add( - "INSTALL_HOUDINIMENU_DIR", - "The directory under which to install houdini menu files.", - "$INSTALL_PREFIX/houdini", -) - -o.Add( - "INSTALL_MAYAICON_DIR", - "The directory under which to install maya icons.", - "$INSTALL_PREFIX/maya/icons", -) - -o.Add( - "INSTALL_NUKEICON_DIR", - "The directory under which to install nuke icons.", - "$INSTALL_PREFIX/nuke/icons", -) - -o.Add( - "INSTALL_MAYAPLUGIN_NAME", - "The name under which to install maya plugins.", - "$INSTALL_PREFIX/maya/plugins/$IECORE_NAME", -) - -o.Add( - "INSTALL_HOUDINIPLUGIN_NAME", - "The name under which to install houdini plugins.", - "$INSTALL_PREFIX/houdini/dso/$IECORE_NAME", -) - -o.Add( - "INSTALL_NUKEPLUGIN_NAME", - "The name under which to install nuke plugins.", - "$INSTALL_PREFIX/nuke/plugins/$IECORE_NAME", -) - o.Add( "INSTALL_DOC_DIR", "The directory in which to install the documentation.", @@ -834,30 +653,6 @@ o.Add( "" ) -o.Add( - "INSTALL_COREMAYA_POST_COMMAND", - "A command which is run following a successful installation of " - "the CoreMaya library. This could be used to customise installation " - "further for a particular site.", - "" -) - -o.Add( - "INSTALL_CORENUKE_POST_COMMAND", - "A command which is run following a successful installation of " - "the CoreNuke library. This could be used to customise installation " - "further for a particular site.", - "" -) - -o.Add( - "INSTALL_COREHOUDINI_POST_COMMAND", - "A command which is run following a successful installation of " - "the CoreHoudini library. This could be used to customise installation " - "further for a particular site.", - "" -) - o.Add( BoolVariable( "INSTALL_CREATE_SYMLINKS", "Whether to create symlinks post install", True ) ) @@ -897,30 +692,6 @@ o.Add( "test/IECoreGL/All.py" ) -o.Add( - "TEST_MAYA_SCRIPT", - "The python script to run for the maya tests. The default will run all the tests, " - "but it can be useful to override this to run just the test for the functionality " - "you're working on.", - "test/IECoreMaya/All.py" -) - -o.Add( - "TEST_HOUDINI_SCRIPT", - "The python script to run for the houdini tests. The default will run all the tests, " - "but it can be useful to override this to run just the test for the functionality " - "you're working on.", - "test/IECoreHoudini/All.py" -) - -o.Add( - "TEST_NUKE_SCRIPT", - "The python script to run for the nuke tests. The default will run all the tests, " - "but it can be useful to override this to run just the test for the functionality " - "you're working on.", - "test/IECoreNuke/All.py" -) - o.Add( "TEST_ALEMBIC_SCRIPT", "The python script to run for the alembic tests. The default will run all the tests, " @@ -2290,711 +2061,6 @@ if env["WITH_GL"] and doConfigure : glTestEnv.Depends( glTest, glob.glob( "test/IECoreGL/*.py" ) ) glTestEnv.Alias( "testGL", glTest ) -########################################################################################### -# Build, install and test the coreMaya library and bindings -########################################################################################### - -mayaEnvSets = { - "IECORE_NAME" : "IECoreMaya", -} - -mayaEnv = env.Clone( **mayaEnvSets ) - -mayaEnvAppends = { - "CXXFLAGS" : [ - "-DIECoreMaya_EXPORTS", - ## \todo: remove once we've dropped all VP1 code - "-Wno-deprecated-declarations", - systemIncludeArgument, "$GLEW_INCLUDE_PATH", - systemIncludeArgument, "$MAYA_ROOT/include", - ], - "LIBS" : [ - "OpenMaya", - "OpenMayaUI", - "OpenMayaAnim", - "OpenMayaFX", - "boost_python" + boostPythonLibSuffix, - ], - "CPPFLAGS" : [ - "-D_BOOL", - "-DREQUIRE_IOSTREAM", - pythonEnv["PYTHON_INCLUDE_FLAGS"], - ], -} - -if env["PLATFORM"]=="posix" : - mayaEnvAppends["CPPFLAGS"] += ["-DLINUX"] - mayaEnvAppends["LIBPATH"] = ["$MAYA_ROOT/lib"] - if os.path.exists( mayaEnv.subst( "$MAYA_ROOT/lib/libOpenMayalib.a" ) ) : - mayaEnvAppends["LIBS"] += ["OpenMayalib"] - -elif env["PLATFORM"]=="darwin" : - mayaEnvAppends["CPPFLAGS"] += ["-DOSMac_","-DOSMac_MachO_"] - mayaEnvAppends["LIBPATH"] = ["$MAYA_ROOT/MacOS"] - mayaEnvAppends["CPPPATH"] = ["$MAYA_ROOT/../../devkit/include"] - mayaEnvAppends["LIBS"] += ["Foundation", "OpenMayaRender"] - mayaEnvAppends["FRAMEWORKS"] = ["AGL", "OpenGL"] - -mayaEnv.Append( **mayaEnvAppends ) - -mayaEnv.Append( SHLINKFLAGS = pythonEnv["PYTHON_LINK_FLAGS"].split() ) - -mayaPythonModuleEnv = pythonModuleEnv.Clone( **mayaEnvSets ) -mayaPythonModuleEnv.Append( **mayaEnvAppends ) - -mayaPluginEnv = mayaEnv.Clone( IECORE_NAME="ieCore" ) - -haveMaya = False - -if doConfigure : - - c = configureSharedLibrary( mayaEnv ) - - if not c.CheckCXXHeader( "maya/MVectorArray.h" ) : - - sys.stderr.write( "WARNING : no maya devkit found, not building IECoreMaya - check MAYA_ROOT.\n" ) - c.Finish() - - else : - - c.Finish() - - haveMaya = True - - mayaSources = sorted( glob.glob( "src/IECoreMaya/*.cpp" ) ) - mayaHeaders = glob.glob( "include/IECoreMaya/bindings/*.h" ) + glob.glob( "include/IECoreMaya/*.h" ) + glob.glob( "include/IECoreMaya/*.inl" ) - mayaBindingHeaders = glob.glob( "include/IECoreMaya/bindings/*.h" ) + glob.glob( "include/IECoreMaya/bindings/*.inl" ) - mayaPythonSources = sorted( glob.glob( "src/IECoreMaya/bindings/*.cpp" ) ) - mayaPythonScripts = glob.glob( "python/IECoreMaya/*.py" ) - mayaMel = glob.glob( "mel/IECoreMaya/*.mel" ) - mayaPluginSources = [ "src/IECoreMaya/plugin/Plugin.cpp" ] - - # we can't append this before configuring, as then it gets built as - # part of the configure process - mayaEnv.Append( LIBS = os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ) ) - mayaEnv.Append( LIBS = os.path.basename( imageEnv.subst( "$INSTALL_LIB_NAME" ) ) ) - mayaEnv.Append( LIBS = os.path.basename( glEnv.subst( "$INSTALL_LIB_NAME" ) ) ) - mayaEnv.Append( LIBS = os.path.basename( sceneEnv.subst( "$INSTALL_LIB_NAME" ) ) ) - mayaEnv.Append( LIBS = os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ) ) - - # maya library - mayaLibrary = mayaEnv.SharedLibrary( "lib/" + os.path.basename( mayaEnv.subst( "$INSTALL_MAYALIB_NAME" ) ), mayaSources ) - mayaLibraryInstall = mayaEnv.Install( os.path.dirname( mayaEnv.subst( "$INSTALL_MAYALIB_NAME" ) ), mayaLibrary ) - mayaEnv.NoCache( mayaLibraryInstall ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaEnv.AddPostAction( mayaLibraryInstall, lambda target, source, env : makeLibSymLinks( mayaEnv, "INSTALL_MAYALIB_NAME" ) ) - mayaEnv.Alias( "install", mayaLibraryInstall ) - mayaEnv.Alias( "installMaya", mayaLibraryInstall ) - mayaEnv.Alias( "installLib", [ mayaLibraryInstall ] ) - - # maya headers - mayaHeaderInstall = mayaEnv.Install( "$INSTALL_HEADER_DIR/IECoreMaya", mayaHeaders ) - mayaHeaderInstall += mayaEnv.Install( "$INSTALL_HEADER_DIR/IECoreMaya/bindings", mayaBindingHeaders ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaEnv.AddPostAction( "$INSTALL_HEADER_DIR/IECoreMaya", lambda target, source, env : makeSymLinks( mayaEnv, mayaEnv["INSTALL_HEADER_DIR"] ) ) - mayaEnv.Alias( "install", mayaHeaderInstall ) - mayaEnv.Alias( "installMaya", mayaHeaderInstall ) - - # maya mel - mayaMelInstall = mayaEnv.Install( "$INSTALL_MEL_DIR", mayaMel ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaEnv.AddPostAction( "$INSTALL_MEL_DIR", lambda target, source, env : makeSymLinks( mayaEnv, mayaEnv["INSTALL_MEL_DIR"] ) ) - mayaEnv.Alias( "install", mayaMelInstall ) - mayaEnv.Alias( "installMaya", mayaMelInstall ) - - # maya icons - mayaIcons = glob.glob( "icons/IECoreMaya/*.xpm" ) + glob.glob( "icons/IECoreMaya/*.png" ) - mayaIconInstall = mayaEnv.Install( "$INSTALL_MAYAICON_DIR", source=mayaIcons ) - mayaEnv.Alias( "install", mayaIconInstall ) - mayaEnv.Alias( "installMaya", mayaIconInstall ) - - # maya plugin - mayaPluginEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_MAYALIB_NAME" ) ), - os.path.basename( mayaEnv.subst( "$INSTALL_MAYALIB_NAME" ) ), - ] - ) - if env["PLATFORM"]=="darwin" : - mayaPluginEnv['SHLINKFLAGS'] = '$LINKFLAGS -bundle' - mayaPluginEnv['SHLIBSUFFIX'] = '.bundle' - - mayaPluginTarget = "plugins/maya/" + os.path.basename( mayaPluginEnv.subst( "$INSTALL_MAYAPLUGIN_NAME" ) ) - - if env["WITH_MAYA_PLUGIN_LOADER"] : - - mayaPluginLoaderSources = [ 'src/IECoreMaya/plugin/Loader.cpp' ] - - mayaPluginLoaderEnv = mayaPluginEnv.Clone() - mayaPluginLoaderEnv.Append( - LIBS = [ - "dl" - ] - ) - - mayaPluginLoader = mayaPluginLoaderEnv.SharedLibrary( mayaPluginTarget, mayaPluginLoaderSources, SHLIBPREFIX="" ) - mayaPluginLoaderInstall = mayaPluginLoaderEnv.InstallAs( mayaPluginLoaderEnv.subst( "$INSTALL_MAYAPLUGIN_NAME$SHLIBSUFFIX" ), mayaPluginLoader ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaPluginLoaderEnv.AddPostAction( mayaPluginLoaderInstall, lambda target, source, env : makeSymLinks( mayaPluginLoaderEnv, mayaPluginLoaderEnv["INSTALL_MAYAPLUGIN_NAME"] ) ) - mayaPluginLoaderEnv.Alias( "install", mayaPluginLoaderInstall ) - mayaPluginLoaderEnv.Alias( "installMaya", mayaPluginLoaderInstall ) - - Default( mayaPluginLoader ) - - mayaPluginEnv["INSTALL_MAYAPLUGIN_NAME"] = os.path.join( os.path.dirname( mayaPluginEnv["INSTALL_MAYAPLUGIN_NAME"] ), 'impl', os.path.basename( mayaPluginEnv["INSTALL_MAYAPLUGIN_NAME"] ) ) - mayaPluginTarget = "plugins/maya/impl/" + os.path.basename( mayaPluginEnv.subst( "$INSTALL_MAYAPLUGIN_NAME" ) ) - - mayaPlugin = mayaPluginEnv.SharedLibrary( mayaPluginTarget, mayaPluginSources, SHLIBPREFIX="" ) - mayaPluginInstall = mayaPluginEnv.Install( os.path.dirname( mayaPluginEnv.subst( "$INSTALL_MAYAPLUGIN_NAME" ) ), mayaPlugin ) - mayaPluginEnv.Depends( mayaPlugin, corePythonModule ) - - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaPluginEnv.AddPostAction( mayaPluginInstall, lambda target, source, env : makeSymLinks( mayaPluginEnv, mayaPluginEnv["INSTALL_MAYAPLUGIN_NAME"] ) ) - mayaPluginEnv.Alias( "install", mayaPluginInstall ) - mayaPluginEnv.Alias( "installMaya", mayaPluginInstall ) - - # maya python - mayaPythonModuleEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( mayaEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ), - ] - ) - mayaPythonModule = mayaPythonModuleEnv.SharedLibrary( "python/IECoreMaya/_IECoreMaya", mayaPythonSources ) - mayaPythonModuleEnv.Depends( mayaPythonModule, mayaLibrary ) - - mayaPythonModuleInstall = mayaPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreMaya", mayaPythonScripts + mayaPythonModule ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - mayaPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreMaya", lambda target, source, env : makeSymLinks( mayaPythonModuleEnv, mayaPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) - mayaPythonModuleEnv.Alias( "install", mayaPythonModuleInstall ) - mayaPythonModuleEnv.Alias( "installMaya", mayaPythonModuleInstall ) - - if coreEnv["INSTALL_COREMAYA_POST_COMMAND"]!="" : - # this is the only way we could find to get a post action to run for an alias - mayaPythonModuleEnv.Alias( "install", mayaPythonModuleInstall, "$INSTALL_COREMAYA_POST_COMMAND" ) - mayaPythonModuleEnv.Alias( "installMaya", mayaPythonModuleInstall, "$INSTALL_COREMAYA_POST_COMMAND" ) - - Default( [ mayaLibrary, mayaPlugin, mayaPythonModule ] ) - - mayaTestEnv = testEnv.Clone() - - mayaTestLibPaths = mayaEnv.subst( os.pathsep.join( mayaPythonModuleEnv["LIBPATH"] ) ) - mayaTestEnv["ENV"][mayaTestEnv["TEST_LIBRARY_PATH_ENV_VAR"]] += os.pathsep + mayaTestLibPaths - mayaTestEnv["ENV"][libraryPathEnvVar] += os.pathsep + mayaTestLibPaths - - mayaTestEnv["ENV"]["PATH"] = mayaEnv.subst( "$MAYA_ROOT/bin:" ) + mayaEnv["ENV"]["PATH"] - mayaTestEnv["ENV"]["MAYA_PLUG_IN_PATH"] = "./plugins/maya:./test/IECoreMaya/plugins" - mayaTestEnv["ENV"]["MAYA_SCRIPT_PATH"] = "./mel" - mayaTestEnv["ENV"]["PYTHONHOME"] = mayaTestEnv.subst( "$MAYA_ROOT" ) - mayaTestEnv["ENV"]["MAYA_LOCATION"] = mayaTestEnv.subst( "$MAYA_ROOT" ) - mayaTestEnv["ENV"]["LM_LICENSE_FILE"] = env["MAYA_LICENSE_FILE"] - mayaTestEnv["ENV"]["AUTODESK_ADLM_THINCLIENT_ENV"] = env["MAYA_ADLM_ENV_FILE"] - - mayaPythonTestEnv = mayaTestEnv.Clone() - - mayaTestEnv.Append( **mayaEnvAppends ) - mayaTestEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( mayaEnv.subst( "$INSTALL_LIB_NAME" ) ), - "OpenMayalib" - ] - ) - - mayaPythonTest = mayaPythonTestEnv.Command( "test/IECoreMaya/resultsPython.txt", mayaPythonModule, "mayapy $TEST_MAYA_SCRIPT" ) - NoCache( mayaPythonTest ) - mayaPythonTestEnv.Depends( mayaPythonTest, [ mayaPlugin, mayaPythonModule, mayaLibrary ] ) - mayaPythonTestEnv.Depends( mayaPythonTest, glob.glob( "test/IECoreMaya/*.py" ) ) - mayaPythonTestEnv.Depends( mayaPythonTest, glob.glob( "python/IECoreMaya/*.py" ) ) - if env["WITH_MAYA_PLUGIN_LOADER"] : - mayaPythonTestEnv.Depends( mayaPythonTest, mayaPluginLoader ) - if env["WITH_GL"] : - mayaPythonTestEnv.Depends( mayaPythonTest, [ glLibrary, glPythonModule ] ) - mayaPythonTestEnv.Alias( "testMaya", mayaPythonTest ) - mayaPythonTestEnv.Alias( "testMayaPython", mayaPythonTest ) - -########################################################################################### -# Build and install the coreNuke library, plugin, python module and headers -########################################################################################### - -nukeEnvSets = { - "IECORE_NAME" : "IECoreNuke" -} - -nukeEnv = env.Clone( **nukeEnvSets ) - -nukeEnvAppends = { - - "CPPFLAGS" : [ - pythonEnv["PYTHON_INCLUDE_FLAGS"], - ], - - "LINKFLAGS" : [ - "-Wl,-rpath-link=$NUKE_ROOT", - ], - - "LIBPATH" : [ - "$NUKE_ROOT", - ], - - "LIBS" : [ - "GLEW$GLEW_LIB_SUFFIX", - ], - - "CXXFLAGS" : [ - systemIncludeArgument, "$NUKE_ROOT/include", - systemIncludeArgument, "$GLEW_INCLUDE_PATH" - ] - -} - -if env["PLATFORM"] == "darwin" : - # FN_OS_MAC is required to work around isnan errors in DDImage/Matrix4.h - nukeEnvAppends["CPPFLAGS"].append( "-DFN_OS_MAC" ) - -nukeEnv.Append( **nukeEnvAppends ) -nukeEnv.Append( SHLINKFLAGS = pythonEnv["PYTHON_LINK_FLAGS"].split() ) -if env["PLATFORM"] == "darwin" : - nukeEnv.Append( FRAMEWORKS = [ "OpenGL" ] ) - -nukePythonModuleEnv = pythonModuleEnv.Clone( **nukeEnvSets ) -nukePythonModuleEnv.Append( **nukeEnvAppends ) - -nukePluginEnv = nukeEnv.Clone( IECORE_NAME="ieCore" ) - -nukeTestEnv = testEnv.Clone() -nukeTestEnv["ENV"]["LM_LICENSE_FILE"] = nukeTestEnv["NUKE_LICENSE_FILE"] -nukeTestEnv["ENV"]["foundry_LICENSE"] = nukeTestEnv["NUKE_LICENSE_FILE"] -nukeTestEnv["ENV"]["NUKE_PATH"] = "plugins/nuke" -nukeTestEnv["ENV"]["IECORE_OP_PATHS"] = "test/IECoreNuke/ops:test/IECore/ops" -# prepend OIIO LIB PATH to library path to support custom OIIO with specific dependencies -nukeTestEnv["ENV"][libraryPathEnvVar] = "{}:{}".format( nukeTestEnv.subst( "$OIIO_LIB_PATH" ), nukeTestEnv["ENV"][libraryPathEnvVar] ) -nukeTestEnv["ENV"]["USG_SHIMLIB_PATH"] = nukeTestEnv["USG_SHIMLIB_PATH"] - -if doConfigure : - - c = configureSharedLibrary( nukeEnv ) - - if not c.CheckHeader( "DDImage/Vector3.h", "\"\"", "CXX" ) : - - sys.stderr.write( "WARNING : no nuke devkit found, not building IECoreNuke - check NUKE_ROOT.\n" ) - c.Finish() - - else : - - # figure out the nuke version from the headers - nukeMajorVersion = None - nukeMinorVersion = None - nukeVersionHeader = env.FindFile( "DDImage/ddImageVersionNumbers.h", nukeEnv["CXXFLAGS"] ) - if nukeVersionHeader : - - for line in open( str( nukeVersionHeader ) ) : - w = line.split() - if len( w ) > 1 : - if w[0]=="#define" and w[1]=="kDDImageVersionMajorNum" : - nukeMajorVersion = int( w[2] ) - elif w[0]=="#define" and w[1]=="kDDImageVersionMinorNum" : - nukeMinorVersion = int( w[2] ) - - else : - - nukeMajorVersion = 4 - nukeMinorVersion = 8 - - if nukeMajorVersion is None or nukeMinorVersion is None : - - sys.stderr.write( "ERROR : unable to determine nuke version - not building IECoreNuke.\n" ) - - else : - - nukeEnv["NUKE_MAJOR_VERSION"] = nukeMajorVersion - nukeEnv["NUKE_MINOR_VERSION"] = nukeMinorVersion - - nukeTestEnv["NUKE_MAJOR_VERSION"] = nukeMajorVersion - nukeTestEnv["NUKE_MINOR_VERSION"] = nukeMinorVersion - - if nukeMajorVersion >=5 and nukeMinorVersion >=0 : - nukeLibName = "DDImage" - else : - nukeLibName = "DDImage%d.%d" % ( nukeMajorVersion, nukeMinorVersion ) - - if not c.CheckLibWithHeader( nukeLibName, "DDImage/Vector3.h", "CXX" ) : - - sys.stderr.write( "WARNING : no nuke libraries found, not building IECoreNuke - check NUKE_ROOT.\n" ) - c.Finish() - - else : - - c.Finish() - - # we can't add this earlier as then it's built during the configure stage, and that's no good - nukeEnv.Append( LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( imageEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ), - os.path.basename( glEnv.subst( "$INSTALL_LIB_NAME" ) ), - ] ) - - nukeEnv.Append( LIBS = [ nukeLibName, "boost_python" + boostPythonLibSuffix ] ) - - nukeEnv.Append( - CPPFLAGS = [ - "-DIECORENUKE_NUKE_MAJOR_VERSION=$NUKE_MAJOR_VERSION", - "-DIECORENUKE_NUKE_MINOR_VERSION=$NUKE_MINOR_VERSION", - "-DIECoreNuke_EXPORTS", - ] - ) - - nukePythonModuleEnv.Append( LIBS = [ - os.path.basename( nukeEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ), - ] ) - - nukeHeaders = glob.glob( "include/IECoreNuke/*.h" ) + glob.glob( "include/IECoreNuke/*.inl" ) - nukeSources = sorted( glob.glob( "src/IECoreNuke/*.cpp" ) ) - nukePythonSources = sorted( glob.glob( "src/IECoreNuke/bindings/*.cpp" ) ) - nukePythonScripts = glob.glob( "python/IECoreNuke/*.py" ) - nukePluginSources = sorted( glob.glob( "src/IECoreNuke/plugin/*.cpp" ) ) - nukeNodeNames = [ "ieObject", "ieOp", "ieDrawable", "ieDisplay", "ieLiveScene", "sccWriter" ] - - # nuke library - nukeLibrary = nukeEnv.SharedLibrary( "lib/" + os.path.basename( nukeEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), nukeSources ) - nukeLibraryInstall = nukeEnv.Install( os.path.dirname( nukeEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), nukeLibrary ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - nukeEnv.AddPostAction( nukeLibraryInstall, lambda target, source, env : makeLibSymLinks( nukeEnv, "INSTALL_NUKELIB_NAME" ) ) - nukeEnv.Alias( "install", nukeLibraryInstall ) - nukeEnv.Alias( "installNuke", nukeLibraryInstall ) - nukeEnv.Alias( "installLib", [ nukeLibraryInstall ] ) - - # nuke headers - - nukeHeaderInstall = nukeEnv.Install( "$INSTALL_HEADER_DIR/IECoreNuke", nukeHeaders ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - nukeEnv.AddPostAction( "$INSTALL_HEADER_DIR/IECoreNuke", lambda target, source, env : makeSymLinks( nukeEnv, nukeEnv["INSTALL_HEADER_DIR"] ) ) - nukeEnv.Alias( "installNuke", nukeHeaderInstall ) - nukeEnv.Alias( "install", nukeHeaderInstall ) - - # nuke python module - - nukePythonModule = nukePythonModuleEnv.SharedLibrary( "python/IECoreNuke/_IECoreNuke", nukePythonSources ) - nukePythonModuleInstall = nukePythonModuleEnv.Install( "$INSTALL_NUKEPYTHON_DIR/IECoreNuke", nukePythonScripts + nukePythonModule ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - nukePythonModuleEnv.AddPostAction( "$INSTALL_NUKEPYTHON_DIR/IECoreNuke", lambda target, source, env : makeSymLinks( nukePythonModuleEnv, nukePythonModuleEnv["INSTALL_NUKEPYTHON_DIR"] ) ) - nukePythonModuleEnv.Alias( "install", nukePythonModuleInstall ) - nukePythonModuleEnv.Alias( "installNuke", nukePythonModuleInstall ) - nukePythonModuleEnv.Depends( nukePythonModule, corePythonModule ) - - if coreEnv["INSTALL_CORENUKE_POST_COMMAND"]!="" : - # this is the only way we could find to get a post action to run for an alias - nukeEnv.Alias( "install", nukeLibraryInstall, "$INSTALL_CORENUKE_POST_COMMAND" ) - nukeEnv.Alias( "installNuke", nukeLibraryInstall, "$INSTALL_CORENUKE_POST_COMMAND" ) - - # nuke plugin - - nukePluginEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), - os.path.basename( nukeEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), - ] - ) - nukePluginTarget = "plugins/nuke/" + os.path.basename( nukePluginEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ) - nukePlugin = nukePluginEnv.SharedLibrary( nukePluginTarget, nukePluginSources, SHLIBPREFIX="" ) - nukePluginInstall = nukePluginEnv.Install( os.path.dirname( nukePluginEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ), nukePlugin ) - - if env[ "INSTALL_CREATE_SYMLINKS" ] : - nukePluginEnv.AddPostAction( nukePluginInstall, lambda target, source, env : makeSymLinks( nukePluginEnv, nukePluginEnv["INSTALL_NUKEPLUGIN_NAME"] ) ) - nukePluginEnv.Alias( "install", nukePluginInstall ) - nukePluginEnv.Alias( "installNuke", nukePluginInstall ) - - Default( [ nukeLibrary, nukePythonModule, nukePlugin ] ) - - # nuke menu - - nukeMenuInstall = nukePluginEnv.Install( os.path.dirname( nukePluginEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ), "src/IECoreNuke/plugin/menu.py" ) - nukePluginEnv.Alias( "install", nukeMenuInstall ) - - # stubs for each of the nodes within the plugin - - nukeStubs = [] - for nodeName in nukeNodeNames : - - nukeStubEnv = nukePluginEnv.Clone( IECORE_NAME=nodeName ) - # In order to have our custom file format (scc) displayed in the file_type knob of the WriteGeo node, we need to install - # a dummy library with "[fileExtension]Writer" - if nodeName == "sccWriter": - nukeStubName = "plugins/nuke/" + os.path.basename( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME$SHLIBSUFFIX" ) ) - else: - nukeStubName = "plugins/nuke/" + os.path.basename( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ) + ".tcl" - nukeStub = nukePluginEnv.Command( nukeStubName, nukePlugin, "echo 'load ieCore' > $TARGET" ) - nukeStubInstall = nukeStubEnv.Install( os.path.dirname( nukeStubEnv.subst( "$INSTALL_NUKEPLUGIN_NAME" ) ), nukeStub ) - nukeStubEnv.Alias( "install", nukeStubInstall ) - nukeStubEnv.Alias( "installNuke", nukeStubInstall ) - nukeStubs.append( nukeStub ) - Default( [ nukeStub ] ) - - # nuke icons - nukeIcons = glob.glob( "icons/IECoreNuke/*.png" ) - nukeIconInstall = nukeEnv.Install( "$INSTALL_NUKEICON_DIR", source=nukeIcons ) - nukeEnv.Alias( "install", nukeIconInstall ) - nukeEnv.Alias( "installNuke", nukeIconInstall ) - - # nuke tests - - nukeTest = nukeTestEnv.Command( "test/IECoreNuke/resultsPython.txt", nukeLibrary, "$NUKE_ROOT/Nuke${NUKE_MAJOR_VERSION}.${NUKE_MINOR_VERSION} -t $TEST_NUKE_SCRIPT" ) - NoCache( nukeTest ) - nukeTestEnv.Depends( nukeTest, glob.glob( "test/IECoreNuke/*.py" ) ) - nukeTestEnv.Depends( nukeTest, nukePythonModule ) - nukeTestEnv.Depends( nukeTest, nukePlugin ) - nukeTestEnv.Depends( nukeTest, nukeStubs ) - nukeTestEnv.Alias( "testNuke", nukeTest ) - -########################################################################################### -# Build, install and test the coreHoudini library and bindings -########################################################################################### - -houdiniEnvSets = { - "IECORE_NAME" : "IECoreHoudini", -} - -houdiniEnv = env.Clone( **houdiniEnvSets ) - -houdiniEnvAppends = { - "CXXFLAGS" : [ - "$HOUDINI_CXX_FLAGS", - "-DMAKING_DSO", - "-DIECoreHoudini_EXPORTS", - systemIncludeArgument, "$HOUDINI_INCLUDE_PATH" - ], - - "CPPFLAGS" : [ - ## \todo: libIECoreHoudini should not use python. - ## Remove it from the src and then remove these flags. - pythonEnv["PYTHON_INCLUDE_FLAGS"], - ], - "LIBPATH" : [ - "$HOUDINI_LIB_PATH", - "$GLEW_LIB_PATH", - ], - "LIBS" : [ - "HoudiniUI", - "HoudiniOPZ", - "HoudiniOP3", - "HoudiniOP2", - "HoudiniOP1", - "HoudiniSIM", - "HoudiniGEO", - "HoudiniPRM", - "HoudiniUT", - "HoudiniRAY", - "HoudiniAPPS3", - ## \todo: libIECoreHoudini should not use python. - ## Remove it from the src and then remove this lib. - "boost_python" + boostPythonLibSuffix, - "GLEW$GLEW_LIB_SUFFIX" - ] -} - -if env["WITH_GL"] : - houdiniEnvAppends["CXXFLAGS"].append( [ systemIncludeArgument, "$GLEW_INCLUDE_PATH" ] ) - houdiniEnvAppends["LIBPATH"].append( "$GLEW_LIB_PATH" ) - houdiniEnvAppends["LIBS"].append( "GLEW$GLEW_LIB_SUFFIX" ) - -if env["PLATFORM"]=="posix" : - houdiniEnvAppends["CPPFLAGS"] += ["-DLINUX"] -elif env["PLATFORM"]=="darwin" : - houdiniEnvAppends["CPPFLAGS"] += ["-D__APPLE__"] - houdiniEnvAppends["FRAMEWORKS"] = ["OpenGL"] - houdiniEnvAppends["LIBS"] += [ "GR"] - -houdiniEnv.Append( **houdiniEnvAppends ) - -houdiniEnv.Append( SHLINKFLAGS = pythonEnv["PYTHON_LINK_FLAGS"].split() ) -houdiniEnv.Prepend( SHLINKFLAGS = "$HOUDINI_LINK_FLAGS" ) -# Prepend OIIO path for houdini to allow for non-namespaced includes to be used -# Houdini ships with a namespaced OpenImageIO (HOIIO) as part of $HOUDINI_INCLUDE_PATH. -# If you do want to use it, set OIIO_INCLUDE_PATH to that. -houdiniEnv.Prepend( CXXFLAGS = [ systemIncludeArgument, "$OIIO_INCLUDE_PATH"] ) - -houdiniPythonModuleEnv = pythonModuleEnv.Clone( **houdiniEnvSets ) -houdiniPythonModuleEnv.Append( **houdiniEnvAppends ) -if env["PLATFORM"] == "posix" : - ## We really want to not have the -Wno-strict-aliasing flag, but it's necessary to stop boost - # python warnings that don't seem to be prevented by including boost via -isystem even. Better to - # be able to have -Werror but be missing one warning than to have no -Werror. - ## \todo This is probably only necessary for specific gcc versions where -isystem doesn't - # fully work. Reenable when we encounter versions that work correctly. - houdiniPythonModuleEnv.Append( CXXFLAGS = [ "-Wno-strict-aliasing" ] ) - -houdiniPluginEnv = houdiniEnv.Clone( IECORE_NAME="ieCoreHoudini" ) - -if doConfigure : - - c = configureSharedLibrary( houdiniEnv ) - - if not c.CheckLibWithHeader( "HoudiniGEO", "SOP/SOP_API.h", "CXX" ) : - - sys.stderr.write( "WARNING : no houdini devkit found, not building IECoreHoudini - check HOUDINI_ROOT.\n" ) - c.Finish() - - else : - - # Houdini 16.0 and beyond can optionally ship using Qt5. - # Since IECoreHoudini makes some UI related calls, we add - # a custom define so we can change the logic as needed. - if os.path.exists( os.path.join( houdiniEnv.subst( "$HOUDINI_LIB_PATH" ), "libQt5Core.so" ) ) : - houdiniPythonModuleEnv.Append( CXXFLAGS = "-DIECOREHOUDINI_WITH_QT5" ) - - c.Finish() - - #===== - # glob the files - #===== - houdiniSources = sorted( glob.glob( "src/IECoreHoudini/*.cpp" ) ) - houdiniHeaders = glob.glob( "include/IECoreHoudini/*.h" ) + glob.glob( "include/IECoreHoudini/*.inl" ) - houdiniBindingHeaders = glob.glob( "include/IECoreHoudini/bindings/*.h" ) + glob.glob( "include/IECoreHoudini/bindings/*.inl" ) - houdiniPythonSources = sorted( glob.glob( "src/IECoreHoudini/bindings/*.cpp" ) ) - houdiniPythonScripts = glob.glob( "python/IECoreHoudini/*.py" ) - houdiniPluginSources = [ "src/IECoreHoudini/plugin/Plugin.cpp" ] - if not env['WITH_GL'] : - houdiniSources.remove( "src/IECoreHoudini/GR_CortexPrimitive.cpp" ) - houdiniSources.remove( "src/IECoreHoudini/GUI_CortexPrimitiveHook.cpp" ) - else: - houdiniEnv.Append( CPPFLAGS = '-DIECOREHOUDINI_WITH_GL' ) - - # we can't append this before configuring, as then it gets built as - # part of the configure process - houdiniEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( sceneEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ), - ] - ) - if env['WITH_GL'] : - houdiniEnv.Append( LIBS = os.path.basename( glEnv.subst( "$INSTALL_LIB_NAME" ) ) ) - - #===== - # build library - #===== - houdiniLib = houdiniEnv.SharedLibrary( "lib/" + os.path.basename( houdiniEnv.subst( "$INSTALL_HOUDINILIB_NAME" ) ), houdiniSources ) - houdiniLibInstall = houdiniEnv.Install( os.path.dirname( houdiniEnv.subst( "$INSTALL_HOUDINILIB_NAME" ) ), houdiniLib ) - houdiniEnv.NoCache( houdiniLibInstall ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - houdiniEnv.AddPostAction( houdiniLibInstall, lambda target, source, env : makeLibSymLinks( houdiniEnv, "INSTALL_HOUDINILIB_NAME" ) ) - houdiniEnv.Alias( "install", houdiniLibInstall ) - houdiniEnv.Alias( "installHoudini", houdiniLibInstall ) - houdiniEnv.Alias( "installLib", [ houdiniLibInstall ] ) - - #===== - # install headers - #===== - houdiniHeaderInstall = houdiniEnv.Install( "$INSTALL_HEADER_DIR/IECoreHoudini", houdiniHeaders ) - houdiniHeaderInstall += houdiniEnv.Install( "$INSTALL_HEADER_DIR/IECoreHoudini/bindings", houdiniBindingHeaders ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - houdiniEnv.AddPostAction( "$INSTALL_HEADER_DIR/IECoreHoudini", lambda target, source, env : makeSymLinks( houdiniEnv, houdiniEnv["INSTALL_HEADER_DIR"] ) ) - houdiniEnv.Alias( "install", houdiniHeaderInstall ) - houdiniEnv.Alias( "installHoudini", houdiniHeaderInstall ) - - #===== - # build houdini plugin - #===== - houdiniPluginEnv.Append( - LIBS=[ - os.path.basename( houdiniEnv.subst( "$INSTALL_HOUDINILIB_NAME" ) ), - ], - ) - houdiniPluginTarget = "plugins/houdini/" + os.path.basename( houdiniPluginEnv.subst( "$INSTALL_HOUDINIPLUGIN_NAME" ) ) - houdiniPlugin = houdiniPluginEnv.SharedLibrary( houdiniPluginTarget, houdiniPluginSources, SHLIBPREFIX="" ) - houdiniPluginInstall = houdiniPluginEnv.Install( os.path.dirname( houdiniPluginEnv.subst( "$INSTALL_HOUDINIPLUGIN_NAME" ) ), houdiniPlugin ) - houdiniPluginEnv.Depends( houdiniPlugin, corePythonModule ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - houdiniPluginEnv.AddPostAction( houdiniPluginInstall, lambda target, source, env : makeSymLinks( houdiniPluginEnv, houdiniPluginEnv["INSTALL_HOUDINIPLUGIN_NAME"] ) ) - houdiniPluginEnv.Alias( "install", houdiniPluginInstall ) - houdiniPluginEnv.Alias( "installHoudini", houdiniPluginInstall ) - - #===== - # build python module - #===== - houdiniPythonModuleEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( sceneEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( houdiniEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( corePythonEnv.subst( "$INSTALL_PYTHONLIB_NAME" ) ), - ] - ) - houdiniPythonModule = houdiniPythonModuleEnv.SharedLibrary( "python/IECoreHoudini/_IECoreHoudini", houdiniPythonSources ) - houdiniPythonModuleEnv.Depends( houdiniPythonModule, houdiniLib ) - houdiniPythonModuleInstall = houdiniPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreHoudini", houdiniPythonScripts + houdiniPythonModule ) - if env[ "INSTALL_CREATE_SYMLINKS" ] : - houdiniPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreHoudini", lambda target, source, env : makeSymLinks( houdiniPythonModuleEnv, houdiniPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) - houdiniPythonModuleEnv.Alias( "install", houdiniPythonModuleInstall ) - houdiniPythonModuleEnv.Alias( "installHoudini", houdiniPythonModuleInstall ) - - #===== - # install icons - #===== - houdiniIcons = glob.glob( "icons/IECoreHoudini/*.svg" ) + glob.glob( "graphics/CortexLogo*.svg" ) - houdiniIconInstall = houdiniPluginEnv.Install( "$INSTALL_HOUDINIICON_DIR", source=houdiniIcons ) - houdiniPluginEnv.Alias( "install", houdiniIconInstall ) - houdiniPluginEnv.Alias( "installHoudini", houdiniIconInstall ) - - #===== - # install toolbar - #===== - houdiniToolbars = glob.glob( "menus/IECoreHoudini/*.shelf" ) - houdiniToolbarInstall = houdiniPluginEnv.Install( "$INSTALL_HOUDINITOOLBAR_DIR", source=houdiniToolbars ) - houdiniPluginEnv.Alias( "install", houdiniToolbarInstall ) - houdiniPluginEnv.Alias( "installHoudini", houdiniToolbarInstall ) - - if coreEnv["INSTALL_COREHOUDINI_POST_COMMAND"] != "" : - # this is the only way we could find to get a post action to run for an alias - houdiniPythonModuleEnv.Alias( "install", houdiniPythonModuleInstall, "$INSTALL_COREHOUDINI_POST_COMMAND" ) - houdiniPythonModuleEnv.Alias( "installHoudini", houdiniPythonModuleInstall, "$INSTALL_COREHOUDINI_POST_COMMAND" ) - - Default( [ houdiniLib, houdiniPlugin, houdiniPythonModule ] ) - - #===== - # Houdini tests - #===== - houdiniTestEnv = testEnv.Clone() - - houdiniTestLibPaths = houdiniEnv.subst( os.pathsep.join( houdiniPythonModuleEnv["LIBPATH"] ) ) - houdiniTestEnv["ENV"][houdiniTestEnv["TEST_LIBRARY_PATH_ENV_VAR"]] += os.pathsep + houdiniTestLibPaths - houdiniTestEnv["ENV"][libraryPathEnvVar] += os.pathsep + houdiniTestLibPaths - - houdiniTestEnv["ENV"]["PATH"] = houdiniEnv.subst( "$HOUDINI_ROOT/bin:" ) + houdiniEnv["ENV"]["PATH"] - - houdiniTestEnv.Append( **houdiniEnvAppends ) - houdiniTestEnv.Append( - LIBS = [ - os.path.basename( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), - os.path.basename( houdiniEnv.subst( "$INSTALL_LIB_NAME" ) ), - ] - ) - - houdiniTestEnv["ENV"]["PYTHONPATH"] += ":./python" - if distutils.version.LooseVersion( pythonEnv["PYTHON_VERSION"] ) > distutils.version.LooseVersion( "2.7" ) : - houdiniTestEnv["ENV"]["PYTHONHOME"] = houdiniTestEnv.subst( "$HOUDINI_ROOT/python" ) - houdiniTestEnv["ENV"]["HOUDINI_DSO_PATH"] = "./plugins/houdini:&" - houdiniTestEnv["ENV"]["HOUDINI_OTLSCAN_PATH"] = "./plugins/houdini:&" - - houdiniTestEnv["ENV"]["IECORE_OP_PATHS"] = "./test/IECoreHoudini/ops" - - houdiniPythonExecutable = "hython" - - houdiniPythonTest = houdiniTestEnv.Command( "test/IECoreHoudini/resultsPython.txt", houdiniPythonModule, houdiniPythonExecutable + " $TEST_HOUDINI_SCRIPT" ) - NoCache( houdiniPythonTest ) - houdiniTestEnv.Depends( houdiniPythonTest, [ houdiniLib, houdiniPlugin, houdiniPythonModule ] ) - houdiniTestEnv.Depends( houdiniPythonTest, glob.glob( "test/IECoreHoudini/*.py" ) ) - houdiniTestEnv.Depends( houdiniPythonTest, glob.glob( "python/IECoreHoudini/*.py" ) ) - if env["WITH_GL"] : - houdiniTestEnv.Depends( houdiniPythonTest, [ glLibrary, glPythonModule ] ) - houdiniTestEnv.Alias( "testHoudini", houdiniPythonTest ) - houdiniTestEnv.Alias( "testHoudiniPython", houdiniPythonTest ) - ########################################################################################### # Build, install and test the IECoreUSD library and bindings ########################################################################################### @@ -3329,7 +2395,7 @@ if doConfigure : docs = docEnv.Command( "doc/html/index.html", "doc/config/Doxyfile", "$DOXYGEN $SOURCE") docEnv.NoCache( docs ) - for modulePath in ( "python/IECore", "python/IECoreGL", "python/IECoreNuke", "python/IECoreMaya", "python/IECoreHoudini" ) : + for modulePath in ( "python/IECore", "python/IECoreGL" ) : module = os.path.basename( modulePath ) mungedModule = docEnv.Command( "doc/python/" + module, modulePath + "/__init__.py", createDoxygenPython ) diff --git a/contrib/IECoreHoudini/CMakeLists.txt b/contrib/IECoreHoudini/CMakeLists.txt deleted file mode 100644 index 166a037182..0000000000 --- a/contrib/IECoreHoudini/CMakeLists.txt +++ /dev/null @@ -1,152 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -cmake_minimum_required( VERSION 2.8 ) -project( IECoreHoudini ) - -# where to find our cmake modules -set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/config/cmake ) - -# find our library dependencies -find_package( Houdini REQUIRED ) -find_package( Cortex REQUIRED ) -find_package( TBB REQUIRED ) -find_package( Boost 1.33 REQUIRED COMPONENTS python ) -find_package( PythonLibs 2.5 REQUIRED ) - -# this stops the HDK causing a backwards include warning -add_definitions( -D_BACKWARD_BACKWARD_WARNING_H ) - -# our include directories -include_directories( - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/include/bindings - ${PYTHON_INCLUDE_PATH} - ${Boost_INCLUDE_DIRS} - ${Houdini_INCLUDE_DIR} - ${Cortex_INCLUDE_DIR} - ${TBB_INCLUDE_DIR} - $ENV{ILMBASE_ROOT}/include - $ENV{ILMBASE_ROOT}/include/OpenEXR - $ENV{OPENEXR_ROOT}/include - $ENV{OPENEXR_ROOT}/include/OpenEXR - $ENV{GLEW_ROOT}/include/GL - ) - -#===== -# create library -#===== -add_library( houdini_lib - SHARED - ${CMAKE_SOURCE_DIR}/src/CoreHoudini.cpp - ${CMAKE_SOURCE_DIR}/src/FnProceduralHolder.cpp - ${CMAKE_SOURCE_DIR}/src/FnParameterisedHolder.cpp - ${CMAKE_SOURCE_DIR}/src/FromHoudiniSopConverter.cpp - ${CMAKE_SOURCE_DIR}/src/SOP_ParameterisedHolder.cpp - ${CMAKE_SOURCE_DIR}/src/SOP_ProceduralHolder.cpp - ) - -set_target_properties( houdini_lib - PROPERTIES - OUTPUT_NAME "IECoreHoudini" - PREFIX "lib" - LIBRARY_OUTPUT_DIRECTORY "lib" - COMPILE_FLAGS "-O0 -ggdb ${Houdini_COMPILE_FLAGS}" - LINK_FLAGS "${Houdini_LINK_FLAGS}" - ) - -target_link_libraries( houdini_lib - ${Houdini_LIBRARIES} - ${Cortex_LIBRARY} - ${Boost_LIBRARIES} - ${TBB_LIBRARIES} - ) - -#===== -# create houdini plugin -#===== -add_library( houdini_plugin - SHARED - ${CMAKE_SOURCE_DIR}/src/plugin/Plugin.cpp - ${CMAKE_SOURCE_DIR}/src/GR_Procedural.cpp - ) - -set_target_properties( houdini_plugin - PROPERTIES - OUTPUT_NAME "ieCoreHoudini" - PREFIX "" - LIBRARY_OUTPUT_DIRECTORY "houdini/dso" - COMPILE_FLAGS "-O0 -ggdb ${Houdini_COMPILE_FLAGS}" - LINK_FLAGS "${Houdini_LINK_FLAGS}" - ) - -target_link_libraries( houdini_plugin - ${Houdini_LIBRARIES} - ${Cortex_LIBRARY} - IECoreGL - ${Boost_LIBRARIES} - ${PYTHON_LIBRARIES} - houdini_lib - ) - -#===== -# create python bindings -#===== -add_library( houdini_binding - SHARED - ${CMAKE_SOURCE_DIR}/src/bindings/IECoreHoudiniModule.cpp - ${CMAKE_SOURCE_DIR}/src/bindings/FnProceduralHolderBinding.cpp - ${CMAKE_SOURCE_DIR}/src/bindings/FromHoudiniSopConverterBinding.cpp - ) - -set_target_properties( houdini_binding - PROPERTIES - OUTPUT_NAME "_IECoreHoudini" - PREFIX "" - LIBRARY_OUTPUT_DIRECTORY "lib/python2.5/site-packages/IECoreHoudini" - SUFFIX ".so" - COMPILE_FLAGS "-O0 -ggdb ${Houdini_COMPILE_FLAGS}" - LINK_FLAGS "${Houdini_LINK_FLAGS}" - ) - -target_link_libraries( houdini_binding - ${Boost_LIBRARIES} - ${PYTHON_LIBRARIES} - ${Houdini_LIBRARIES} - ${Cortex_LIBRARY} - IECorePython - houdini_lib - houdini_plugin - ) diff --git a/contrib/IECoreHoudini/config/cmake/FindCortex.cmake b/contrib/IECoreHoudini/config/cmake/FindCortex.cmake deleted file mode 100644 index 5795898ff6..0000000000 --- a/contrib/IECoreHoudini/config/cmake/FindCortex.cmake +++ /dev/null @@ -1,68 +0,0 @@ -#========== -# -# Copyright (c) 2010, Dan Bethell. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Dan Bethell nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -#========== -# -# Variables defined by this module: -# Cortex_FOUND -# Cortex_INCLUDE_DIR -# Cortex_LIBRARIES -# -# Usage: -# FIND_PACKAGE( Cortex ) -# FIND_PACKAGE( Cortex REQUIRED ) -# -# Todo: add support for finding additional components -# (more than just IECore) using a mechanism similar to Boost's -# cmake module. -# -#========== - -# try to find header -FIND_PATH( Cortex_INCLUDE_DIR IECore/IECore.h - ${Cortex_INSTALL_PATH}/include - $ENV{CORTEX_ROOT}/include - ) - -# try to find libs -FIND_LIBRARY( Cortex_LIBRARY IECore - ${Cortex_INSTALL_PATH}/lib - $ENV{CORTEX_ROOT}/lib - ) - -# did we find everything? -INCLUDE( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Cortex" DEFAULT_MSG - Cortex_INCLUDE_DIR - Cortex_LIBRARY - ) diff --git a/contrib/IECoreHoudini/config/cmake/FindHoudini.cmake b/contrib/IECoreHoudini/config/cmake/FindHoudini.cmake deleted file mode 100644 index 873a9926d3..0000000000 --- a/contrib/IECoreHoudini/config/cmake/FindHoudini.cmake +++ /dev/null @@ -1,147 +0,0 @@ -#========== -# -# Copyright (c) 2010, Dan Bethell. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Dan Bethell nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -#========== -# -# Variables defined by this module: -# Houdini_FOUND -# Houdini_INCLUDE_DIR -# Houdini_COMPILE_FLAGS -# Houdini_LINK_FLAGS -# Houdini_LIBRARIES -# Houdini_LIBRARY_DIR -# -# Usage: -# FIND_PACKAGE( Houdini ) -# FIND_PACKAGE( Houdini REQUIRED ) -# -# Note: -# You can tell the module where Houdini is installed by setting -# the Houdini_INSTALL_PATH (or setting the HFS environment -# variable before calling FIND_PACKAGE. -# -# E.g. -# SET( Houdini_INSTALL_PATH "/opt/hfs10.0.430" ) -# FIND_PACKAGE( Houdini REQUIRED ) -# -#========== - -# our includes -FIND_PATH( Houdini_INCLUDE_DIR UT/UT_DSOVersion.h - $ENV{HFS}/toolkit/include - ${Houdini_INSTALL_PATH}/toolkit/include - /Library/Frameworks/Houdini.framework/Resources/toolkit/include/ - ) - -# our libraries -SET( __Houdini_LIBS - HoudiniUI - HoudiniOPZ - HoudiniOP3 - HoudiniOP2 - HoudiniOP1 - HoudiniSIM - HoudiniGEO - HoudiniPRM - HoudiniUT - GLU - GL - X11 - Xext - Xi - dl - pthread - ) - -# Some libs only required on OSX -IF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - SET( __Houdini_LIBS - ${__Houdini_LIBS} - GR - ) -ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - -# here we loop over the libraries try to find them -SET( __Houdini_LIBPATHS "" ) -FOREACH( __Houdini_LIB ${__Houdini_LIBS} ) - SET( LIBVAR_NAME "H_LIB_${__Houdini_LIB}" ) - FIND_LIBRARY( ${LIBVAR_NAME} ${__Houdini_LIB} - $ENV{HFS}/dsolib - ${Houdini_INSTALL_PATH}/dsolib - /Library/Frameworks/Houdini.framework/Libraries - ) - IF( ${${LIBVAR_NAME}} MATCHES "${LIBVAR_NAME}-NOTFOUND" ) - MESSAGE( WARNING "Could not find Houdini library: ${__Houdini_LIB}" ) - UNSET( __Houdini_LIBPATHS ) - BREAK() - ENDIF( ${${LIBVAR_NAME}} MATCHES "${LIBVAR_NAME}-NOTFOUND" ) - SET( __Houdini_LIBPATHS ${__Houdini_LIBPATHS} ${${LIBVAR_NAME}} ) -ENDFOREACH( __Houdini_LIB "${__Houdini_LIBS}" ) -SET( Houdini_LIBRARIES ${__Houdini_LIBPATHS} ) -UNSET( __Houdini_LIBPATHS ) -UNSET( __Houdini_LIBS ) - -# find out where our Houdini libraries are -LIST( GET Houdini_LIBRARIES 0 H_SRC_LIB ) -GET_FILENAME_COMPONENT( Houdini_LIBRARY_DIR ${H_SRC_LIB} PATH ) -UNSET( H_SRC_LIB ) - -# mac osx -IF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - SET( Houdini_COMPILE_FLAGS "-DSIZEOF_VOID_P=8 -DMBSD -DMBSD_COCOA -D__APPLE__ -arch x86_64" ) - SET( Houdini_LINK_FLAGS "-Wl,-rpath,${Houdini_LIBRARY_DIR} -arch x86_64" ) -ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - -# linux -IF( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) - IF( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) - SET( Houdini_COMPILE_FLAGS "-DSIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P} -m64 -fPIC -DAMD64 -DLINUX -D__LINUX__" ) - ELSE() - SET( Houdini_COMPILE_FLAGS "-DSIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P} -march=i686 -march=pentium3 -msse -mmmx -Di386 -D__LINUX__" ) - ENDIF( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) -ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) - -# compilation flags -SET( Houdini_COMPILE_FLAGS "${Houdini_COMPILE_FLAGS} -O2 -DDLLEXPORT=\"\" -DMAKING_DSO -D_GNU_SOURCE -DSESI_LITTLE_ENDIAN -DENABLE_THREADS -DUSE_PTHREADS -DENABLE_UI_THREADS -DGCC3 -DGCC4" ) - -# linker flags -SET( Houdini_LINK_FLAGS "${Houdini_LINK_FLAGS} -Wall -W -Wno-parentheses -Wno-sign-compare -Wno-reorder -Wno-uninitialized -Wunused -Wno-unused-parameter -Wno-deprecated" ) - -# did we find everything? -INCLUDE( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Houdini" DEFAULT_MSG - Houdini_INCLUDE_DIR - Houdini_COMPILE_FLAGS - Houdini_LINK_FLAGS - Houdini_LIBRARIES - ) diff --git a/contrib/IECoreHoudini/config/cmake/FindTBB.cmake b/contrib/IECoreHoudini/config/cmake/FindTBB.cmake deleted file mode 100644 index 5106464d59..0000000000 --- a/contrib/IECoreHoudini/config/cmake/FindTBB.cmake +++ /dev/null @@ -1,64 +0,0 @@ -#========== -# -# Copyright (c) 2010, Dan Bethell. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Dan Bethell nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -#========== -# -# Variables defined by this module: -# TBB_FOUND -# TBB_INCLUDE_DIR -# TBB_LIBRARIES -# -# Usage: -# FIND_PACKAGE( TBB ) -# FIND_PACKAGE( TBB REQUIRED ) -# -#========== - -# try to find header -FIND_PATH( TBB_INCLUDE_DIR tbb/tbb.h - ${TBB_INSTALL_PATH}/include - $ENV{TBB_ROOT}/include - ) - -# try to find libs -FIND_LIBRARY( TBB_LIBRARY tbb - ${TBB_INSTALL_PATH}/lib - $ENV{TBB_ROOT}/lib - ) - -# did we find everything? -INCLUDE( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( "TBB" DEFAULT_MSG - TBB_INCLUDE_DIR - TBB_LIBRARY - ) diff --git a/contrib/cmake/CMakeLists.txt b/contrib/cmake/CMakeLists.txt deleted file mode 100644 index 9869f95129..0000000000 --- a/contrib/cmake/CMakeLists.txt +++ /dev/null @@ -1,411 +0,0 @@ -# CMake version required -cmake_minimum_required( VERSION 2.8 ) - -# Declare a Cortex Project -project( Cortex ) - -set (CMAKE_CXX_STANDARD 11) - -# Declare the version - -set( CORTEX_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../.. ) - -file( READ ${CORTEX_SOURCE_DIR}/SConstruct SCONSTRUCT ) - -string( REGEX MATCH "ieCoreMilestoneVersion=([0-9]+)" ${SCONSTRUCT} ) -set( IECORE_MILESTONE_VERSION ${CMAKE_MATCH_1} ) - -string( REGEX MATCH "ieCoreMajorVersion=([0-9]+)" ${SCONSTRUCT} ) -set( IECORE_MAJOR_VERSION ${CMAKE_MATCH_1} ) - -string( REGEX MATCH "ieCoreMinorVersion=([0-9]+)" ${SCONSTRUCT} ) -set( IECORE_MINOR_VERSION ${CMAKE_MATCH_1} ) - -string( REGEX MATCH "ieCorePatchVersion=([0-9]+)" ${SCONSTRUCT} ) -set( IECORE_PATCH_VERSION ${CMAKE_MATCH_1} ) - -string( REGEX MATCH "ieCoreVersionSuffix=\"([a-zA-Z0-9]+)\"" ${SCONSTRUCT} ) -set( IECORE_VERSION_SUFFIX ${CMAKE_MATCH_1} ) - -message( STATUS "Configuring Cortex : " ${IECORE_MILESTONE_VERSION}.${IECORE_MAJOR_VERSION}.${IECORE_MINOR_VERSION}.${IECORE_PATCH_VERSION}-${IECORE_VERSION_SUFFIX} ) - -add_definitions( -DIE_CORE_MILESTONEVERSION=${IECORE_MILESTONE_VERSION} - -DIE_CORE_MAJORVERSION=${IECORE_MAJOR_VERSION} - -DIE_CORE_MINORVERSION=${IECORE_MINOR_VERSION} - -DIE_CORE_PATCHVERSION=${IECORE_PATCH_VERSION} ) - -option( WITH_TESTS "Compile tests" OFF ) -option( WITH_IECORE_PYTHON "Compile IECorePython" ON ) -option( WITH_IECORE_GL "Compile IECoreGL" ON ) -option( WITH_IECORE_IMAGE "Compile IECoreImage" ON ) -option( WITH_IECORE_SCENE "Compile IECoreScene" ON ) -option( WITH_IECORE_ALEMBIC "Compile IECoreAlembic" ON ) -option( WITH_IECORE_VDB "Compile IECoreVDB" ON) -option( WITH_IECORE_ARNOLD "Compile IECoreArnold" ON ) -option( WITH_IECORE_USD "Compile IECoreUSD" ON ) - -option( WITH_IECORE_HOUDINI "Compile IECoreHoudini" OFF ) -option( WITH_IECORE_MAYA "Compile IECoreMaya" OFF ) -option( WITH_IECORE_NUKE "Compile IECoreNuke" OFF ) - -#-****************************************************************************** -#-****************************************************************************** -# PLATFORM SPECIFIC -#-****************************************************************************** -#-****************************************************************************** - -# Windows flag -set( WINDOWS FALSE ) -if( "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" ) - set( WINDOWS TRUE ) -endif() - -set( DARWIN FALSE ) -if( "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" ) - set( DARWIN TRUE ) - if( ${CMAKE_SYSTEM_VERSION} MATCHES "13." ) - add_definitions( "-std=c++11" ) - endif() -endif() - -set( LINUX FALSE ) -if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux" ) - set( LINUX TRUE ) -endif() - -# Set some debug vs opt flags -if( "${CMAKE_BUILD_TYPE}" MATCHES "Debug" ) - add_definitions( -DDEBUG=1 -UNDEBUG ) - if( NOT WINDOWS ) - add_definitions( -pipe -Wall -O0 -Wno-unused-local-typedefs -Wno-deprecated -D_GLIBCXX_USE_CXX11_ABI=0) - endif() -elseif ( "${CMAKE_BUILD_TYPE}" MATCHES "Release" ) - add_definitions( -DNDEBUG=1 -UDEBUG ) - if ( NOT WINDOWS ) - add_definitions( -pipe -Wall -O3 -DNDEBUG -DBOOST_DISABLE_ASSERTS -Wno-unused-local-typedefs -Wno-deprecated -D_GLIBCXX_USE_CXX11_ABI=0) - endif() -endif() - -if( ${WINDOWS} ) - add_definitions( -DOPENEXR_DLL -DNOMINMAX -D__PRETTY_FUNCTION__=__FUNCSIG__ -DBOOST_ALL_DYN_LINK ) - set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} /MP ) - set( PLATFORM_LIBS winmm.lib ) -endif() - - -#-****************************************************************************** -#-****************************************************************************** -# GLOBAL PACKAGE & INCLUDE/LINK DEPENDENCY -#-****************************************************************************** -#-****************************************************************************** - -# check in the source directory -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/ ) - -# Boost definitions -add_definitions( -DBOOST_FILESYSTEM_VERSION=3 ) -add_definitions( -DBOOST_FILESYSTEM_NO_DEPRICATED ) -add_definitions( -DBOOST_SIGNALS_NO_DEPRECATION_WARNING ) -add_definitions( -DBOOST_PYTHON_MAX_ARITY=20 ) - -# Find packages -find_package( Threads REQUIRED ) -find_package( ZLIB REQUIRED ) -find_package( TBB REQUIRED ) -find_package( PythonLibs 2.7 REQUIRED ) -find_package( Boost REQUIRED COMPONENTS signals iostreams filesystem date_time wave regex system chrono python ) -find_package( IlmBase REQUIRED ) -find_package( OpenEXR REQUIRED ) -find_package( Freetype REQUIRED ) -find_package( Blosc REQUIRED ) -find_package( PNG REQUIRED ) # For freetype linking - -# Include directories -include_directories( ${CORTEX_SOURCE_DIR}/include ) -include_directories( ${TBB_INCLUDE_DIRS} ) -include_directories( ${PYTHON_INCLUDE_DIRS} ) -include_directories( ${Boost_INCLUDE_DIRS} ) -include_directories( ${ILMBASE_INCLUDE_DIR} ) -include_directories( ${OPENEXR_INCLUDE_DIRS} ) -include_directories( ${FREETYPE_INCLUDE_DIRS} ) -include_directories( ${BLOSC_INCLUDE_DIR} ) - -# Link directories -link_directories( ${TBB_LIBRARY_DIRS} ) -link_directories( ${Boost_LIBRARY_DIRS} ) - -# Base libs to link to -set( BASE_LIBS - ${Boost_SIGNALS_LIBRARY} - ${Boost_IOSTREAMS_LIBRARY} - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_DATE_TIME_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${Boost_WAVE_LIBRARY} - ${Boost_REGEX_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_CHRONO_LIBRARY} - ${TBB_LIBRARIES} - ${Ilmbase_HALF_LIBRARY} - ${Ilmbase_IEX_LIBRARY} - ${Ilmbase_IEXMATH_LIBRARY} - ${Ilmbase_ILMTHREAD_LIBRARY} - ${Ilmbase_IMATH_LIBRARY} - ${Openexr_ILMIMF_LIBRARY} - ${ZLIB_LIBRARIES} - ${BLOSC_blosc_LIBRARY} ) - -# Python base libs to link to -set( BASE_PYTHON_LIBS - ${PYTHON_LIBRARIES} - ${Boost_PYTHON_LIBRARY} - IECorePython ) - -# IECore -file( GLOB IECORE_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECore/*.cpp ) -file( GLOB IECORE_H_FILES ${CORTEX_SOURCE_DIR}/include/IECore/*.h ${CORTEX_SOURCE_DIR}/include/IECore/*.inl ) -file( GLOB IECORE_PY_FILES ${CORTEX_SOURCE_DIR}/python/IECore/*.py ) -add_library( IECore SHARED ${IECORE_CXX_FILES} ${IECORE_H_FILES} ) -target_link_libraries( IECore ${BASE_LIBS} ) -# Install -install( TARGETS IECore DESTINATION lib/ ) -install( FILES ${IECORE_H_FILES} DESTINATION include/IECore ) - -# IECorePython -if( ${WITH_IECORE_PYTHON} ) - file( GLOB IECOREPYTHON_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECorePython/*.cpp ) - file( GLOB IECOREPYTHON_H_FILES ${CORTEX_SOURCE_DIR}/include/IECorePython/*.h ${CORTEX_SOURCE_DIR}/include/IECorePython/*.inl ) - add_library( IECorePython SHARED ${IECOREPYTHON_CXX_FILES} ${IECOREPYTHON_H_FILES} ) - target_link_libraries( IECorePython IECore ${BASE_LIBS} ${PYTHON_LIBRARIES} ${Boost_PYTHON_LIBRARY} ) - add_dependencies( IECorePython IECore ) - install( TARGETS IECorePython DESTINATION lib/ ) - install( FILES ${IECOREPYTHON_H_FILES} DESTINATION include/IECorePython ) - # IECorePythonModule - add_library( _IECore MODULE ${CORTEX_SOURCE_DIR}/src/IECorePythonModule/IECore.cpp ) - target_link_libraries( _IECore IECorePython ) - add_dependencies( _IECore IECore IECorePython ) - if ( WIN32 ) - set_target_properties( _IECore PROPERTIES SUFFIX ".pyd" ) - endif() - # Install - install( TARGETS _IECore DESTINATION python/IECore ) - install( FILES ${IECORE_PY_FILES} DESTINATION python/IECore ) -endif() - -# IECoreGL -if( ${WITH_IECORE_GL} ) - find_package( OpenGL REQUIRED ) - find_package( GLEW REQUIRED ) - # Library - file( GLOB IECOREGL_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECoreGL/*.cpp ) - file( GLOB IECOREGL_H_FILES ${CORTEX_SOURCE_DIR}/include/IECoreGL/*.h ${CORTEX_SOURCE_DIR}/include/IECoreGL/*.inl ) - file( GLOB IECOREGL_PY_FILES ${CORTEX_SOURCE_DIR}/python/IECoreGL/*.py ) - add_library( IECoreGL SHARED ${IECOREGL_CXX_FILES} ${IECOREGL_H_FILES} ) - target_link_libraries( IECoreGL IECore IECoreScene IECoreImage ${BASE_LIBS} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ) - add_dependencies( IECoreGL IECore ) - install( TARGETS IECoreGL DESTINATION lib/ ) - install( FILES ${IECOREGL_H_FILES} DESTINATION include/IECoreGL ) - install( DIRECTORY ${CORTEX_SOURCE_DIR}/glsl DESTINATION . ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECOREGL_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/src/IECoreGL/bindings/*.cpp ) - file( GLOB IECOREGL_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/include/IECoreGL/bindings/*.h ${CORTEX_SOURCE_DIR}/include/IECoreGL/bindings/*.inl ) - add_library( _IECoreGL MODULE ${IECOREGL_CXX_MODULE_FILES} ${IECOREGL_H_MODULE_FILES} ) - target_link_libraries( _IECoreGL IECore ${BASE_LIBS} ${BASE_PYTHON_LIBS} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} IECoreGL ) - add_dependencies( _IECoreGL IECore IECorePython IECoreGL ) - if ( WIN32 ) - set_target_properties( _IECoreGL PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreGL DESTINATION python/IECoreGL ) - install( FILES ${IECOREGL_PY_FILES} DESTINATION python/IECoreGL ) - endif() -endif() - -# IECoreImage -if( ${WITH_IECORE_IMAGE} ) - find_package( OSL REQUIRED ) - find_package( OpenImageIO REQUIRED ) - # Library - file( GLOB IECOREIMAGE_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECoreImage/*.cpp ) - file( GLOB IECOREIMAGE_H_FILES ${CORTEX_SOURCE_DIR}/include/IECoreImage/*.h ${CORTEX_SOURCE_DIR}/include/IECoreImage/*.inl ) - file( GLOB IECOREIMAGE_PY_FILES ${CORTEX_SOURCE_DIR}/python/IECoreImage/*.py ) - add_library( IECoreImage SHARED ${IECOREIMAGE_CXX_FILES} ${IECOREIMAGE_H_FILES} ) - target_link_libraries( IECoreImage IECore ${BASE_LIBS} ${OPENIMAGEIO_LIBRARIES} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ) - add_dependencies( IECoreImage IECore ) - install( TARGETS IECoreImage DESTINATION lib/ ) - install( FILES ${IECOREIMAGE_H_FILES} DESTINATION include/IECoreImage ) - - if( ${WITH_IECORE_PYTHON} ) - # Bindings - file( GLOB IECOREIMAGEBINDINGS_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECoreImageBindings/*.cpp ) - file( GLOB IECOREIMAGEBINDINGS_H_FILES ${CORTEX_SOURCE_DIR}/include/IECoreImageBindings/*.h ) - # Module - add_library( _IECoreImage MODULE ${CORTEX_SOURCE_DIR}/src/IECoreImageModule/IECoreImageModule.cpp ${IECOREIMAGEBINDINGS_CXX_FILES} ${IECOREIMAGEBINDINGS_H_FILES} ) - target_link_libraries( _IECoreImage IECore ${BASE_LIBS} ${BASE_PYTHON_LIBS} ${OPENIMAGEIO_LIBRARIES} IECoreImage ) - add_dependencies( _IECoreImage IECore IECorePython IECoreImage ) - if ( WIN32 ) - set_target_properties( _IECoreImage PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreImage DESTINATION python/IECoreImage ) - install( FILES ${IECOREIMAGE_PY_FILES} DESTINATION python/IECoreImage ) - install( FILES ${IECOREIMAGEBINDINGS_H_FILES} DESTINATION include/IECoreImageBindings ) - endif() -endif() - -# IECoreScene -if( ${WITH_IECORE_SCENE} ) - # Library - file( GLOB IECORESCENE_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECoreScene/*.cpp ) - file( GLOB IECORESCENE_H_FILES ${CORTEX_SOURCE_DIR}/include/IECoreScene/*.h ${CORTEX_SOURCE_DIR}/include/IECoreScene/*.inl ) - file( GLOB IECORESCENE_PY_FILES ${CORTEX_SOURCE_DIR}/python/IECoreScene/*.py ) - add_library( IECoreScene SHARED ${IECORESCENE_CXX_FILES} ${IECORESCENE_H_FILES} ) - target_link_libraries( IECoreScene IECore ${BASE_LIBS} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ) - add_dependencies( IECoreScene IECore ) - install( TARGETS IECoreScene DESTINATION lib/ ) - install( FILES ${IECORESCENE_H_FILES} DESTINATION include/IECoreScene ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECORESCENE_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/src/IECoreScene/bindings/*.cpp ) - file( GLOB IECORESCENE_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/src/IECoreScene/bindings/*.h ${CORTEX_SOURCE_DIR}/src/IECoreScene/bindings/*.inl ) - add_library( _IECoreScene MODULE ${IECORESCENE_CXX_MODULE_FILES} ${IECORESCENE_H_MODULE_FILES} ) - target_link_libraries( _IECoreScene IECore ${BASE_LIBS} ${BASE_PYTHON_LIBS} IECoreScene ) - add_dependencies( _IECoreScene IECore IECorePython IECoreScene ) - if ( WIN32 ) - set_target_properties( _IECoreScene PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreScene DESTINATION python/IECoreScene ) - install( FILES ${IECORESCENE_PY_FILES} DESTINATION python/IECoreScene ) - endif() -endif() - -# IECoreAlembic -if( ${WITH_IECORE_ALEMBIC} ) - #find_package( HDF5 REQUIRED ) - find_package( Alembic REQUIRED ) - include_directories( ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/include ) - # Library - file( GLOB IECOREALEMBIC_CXX_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/src/IECoreAlembic/*.cpp ) - file( GLOB IECOREALEMBIC_H_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/include/IECoreAlembic/*.h ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/include/IECoreAlembic/*.inl ) - file( GLOB IECOREALEMBIC_PY_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/python/IECoreAlembic/*.py ) - add_library( IECoreAlembic SHARED ${IECOREALEMBIC_CXX_FILES} ${IECOREALEMBIC_H_FILES} ) - target_link_libraries( IECoreAlembic IECore IECoreScene ${BASE_LIBS} ${ALEMBIC_LIBRARY} ) - add_dependencies( IECoreAlembic IECore ) - install( TARGETS IECoreAlembic DESTINATION lib/ ) - install( FILES ${IECOREALEMBIC_H_FILES} DESTINATION include/IECoreAlembic ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECOREALEMBIC_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/src/IECoreAlembic/bindings/*.cpp ) - file( GLOB IECOREALEMBIC_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreAlembic/include/IECoreAlembic/bindings/*.h ) - add_library( _IECoreAlembic MODULE ${IECOREALEMBIC_CXX_MODULE_FILES} ${IECOREALEMBIC_H_MODULE_FILES} ) - target_link_libraries( _IECoreAlembic IECore ${BASE_LIBS} ${BASE_PYTHON_LIBS} IECoreScene IECoreAlembic ) - add_dependencies( _IECoreAlembic IECore IECorePython IECoreAlembic ) - if ( WIN32 ) - set_target_properties( _IECoreAlembic PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreAlembic DESTINATION python/IECoreAlembic ) - install( FILES ${IECOREALEMBIC_PY_FILES} DESTINATION python/IECoreAlembic ) - endif() -endif() - -# IECoreVDB -if( ${WITH_IECORE_VDB} ) - find_package( OpenVDB REQUIRED ) - include_directories( ${OpenVDB_INCLUDE_DIR} ) - # Library - file( GLOB IECOREVDB_CXX_FILES ${CORTEX_SOURCE_DIR}/src/IECoreVDB/*.cpp ) - file( GLOB IECOREVDB_H_FILES ${CORTEX_SOURCE_DIR}/include/IECoreVDB/*.h ${CORTEX_SOURCE_DIR}/include/IECoreVDB/*.inl ) - file( GLOB IECOREVDB_PY_FILES ${CORTEX_SOURCE_DIR}/python/IECoreVDB/*.py ) - add_library( IECoreVDB SHARED ${IECOREVDB_CXX_FILES} ${IECOREVDB_H_FILES} ) - target_link_libraries( IECoreVDB IECore IECoreScene ${BASE_LIBS} ${OpenVDB_LIBRARIES} ) - target_compile_options( IECoreVDB PRIVATE ) - add_dependencies( IECoreVDB IECore ) - install( TARGETS IECoreVDB DESTINATION lib/ ) - install( FILES ${IECOREVDB_H_FILES} DESTINATION include/IECoreVDB ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECOREVDB_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/src/IECoreVDB/bindings/*.cpp ) - file( GLOB IECOREVDB_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/src/IECoreVDB/bindings/*.h ) - add_library( _IECoreVDB MODULE ${IECOREVDB_CXX_MODULE_FILES} ${IECOREVDB_H_MODULE_FILES} ) - target_link_libraries( _IECoreVDB IECore IECorePython IECoreVDB IECoreScene ${BASE_LIBS} ${BASE_PYTHON_LIBS} ) - target_compile_options( _IECoreVDB PRIVATE ) - add_dependencies( _IECoreVDB IECoreVDB IECoreScene IECore IECorePython ) - if ( WIN32 ) - set_target_properties( _IECoreVDB PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreVDB DESTINATION python/IECoreVDB ) - install( FILES ${IECOREVDB_PY_FILES} DESTINATION python/IECoreVDB ) - endif() -endif() - -# IECoreArnold -if( ${WITH_IECORE_ARNOLD} ) - find_package( Arnold REQUIRED ) - include_directories( BEFORE ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/include ) - include_directories( ${CORTEX_ARNOLD_INCLUDE_PATH} ) - # Library - file( GLOB IECOREARNOLD_CXX_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/src/IECoreArnold/*.cpp ) - file( GLOB IECOREARNOLD_H_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/include/IECoreArnold/*.h ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/include/IECoreArnold/*.inl ) - file( GLOB IECOREARNOLD_PY_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/python/IECoreArnold/*.py ) - add_library( IECoreArnold SHARED ${IECOREARNOLD_CXX_FILES} ${IECOREARNOLD_H_FILES} ) - target_link_libraries( IECoreArnold IECore IECoreScene ${BASE_LIBS} ${CORTEX_ARNOLD_LIBS} ) - add_dependencies( IECoreArnold IECore ) - install( TARGETS IECoreArnold DESTINATION lib/ ) - install( FILES ${IECOREARNOLD_H_FILES} DESTINATION include/IECoreArnold ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECOREARNOLD_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/src/IECoreArnold/bindings/*.cpp ) - file( GLOB IECOREARNOLD_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/include/IECoreArnold/bindings/*.h ) - add_library( _IECoreArnold MODULE ${IECOREARNOLD_CXX_MODULE_FILES} ${IECOREARNOLD_H_MODULE_FILES} ) - target_link_libraries( _IECoreArnold IECore ${BASE_LIBS} ${BASE_PYTHON_LIBS} IECoreScene IECoreArnold ) - add_dependencies( _IECoreArnold IECore IECorePython IECoreArnold ) - if ( WIN32 ) - set_target_properties( _IECoreArnold PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreArnold DESTINATION python/IECoreArnold ) - install( FILES ${IECOREARNOLD_PY_FILES} DESTINATION python/IECoreArnold ) - endif() - - # Display driver - add_library( arnoldOutputDriver MODULE ${CORTEX_SOURCE_DIR}/contrib/IECoreArnold/src/IECoreArnold/outputDriver/OutputDriver.cpp ) - target_link_libraries( arnoldOutputDriver IECore IECoreImage IECoreArnold ) - add_dependencies( arnoldOutputDriver IECore IECoreImage IECoreArnold ) - set_target_properties( arnoldOutputDriver PROPERTIES OUTPUT_NAME ieOutputDriver ) - set_target_properties( arnoldOutputDriver PROPERTIES PREFIX "" ) - install( TARGETS arnoldOutputDriver DESTINATION arnold/plugins ) -endif() - -# IECoreUSD -if( ${WITH_IECORE_USD} ) - find_package( USD REQUIRED ) - include_directories( ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/include ) - include_directories( ${USD_INCLUDE_DIR} ) - link_directories( ${USD_LIBRARY_DIR} ) - # Library - file( GLOB IECOREUSD_CXX_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/src/IECoreUSD/*.cpp ) - file( GLOB IECOREUSD_H_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/include/IECoreUSD/*.h ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/include/IECoreUSD/*.inl ) - file( GLOB IECOREUSD_PY_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/python/IECoreUSD/*.py ) - add_library( IECoreUSD SHARED ${IECOREUSD_CXX_FILES} ${IECOREUSD_H_FILES} ) - target_link_libraries( IECoreUSD IECore IECoreScene ${BASE_LIBS} ${USD_LIBRARIES} usdGeom ) - add_dependencies( IECoreUSD IECore ) - install( TARGETS IECoreUSD DESTINATION lib/ ) - install( FILES ${IECOREUSD_H_FILES} DESTINATION include/IECoreUSD ) - - if( ${WITH_IECORE_PYTHON} ) - # Module/Bindings - file( GLOB IECOREUSD_CXX_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/src/IECoreUSD/bindings/*.cpp ) - file( GLOB IECOREUSD_H_MODULE_FILES ${CORTEX_SOURCE_DIR}/contrib/IECoreUSD/include/IECoreUSD/bindings/*.h ) - add_library( _IECoreUSD SHARED ${IECOREUSD_CXX_MODULE_FILES} ${IECOREUSD_H_MODULE_FILES} ) - target_link_libraries( _IECoreUSD IECore IECoreScene IECoreUSD ${BASE_LIBS} ${BASE_PYTHON_LIBS} ) - add_dependencies( _IECoreUSD IECore IECorePython IECoreUSD ) - if ( WIN32 ) - set_target_properties( _IECoreUSD PROPERTIES SUFFIX ".pyd" ) - endif() - install( TARGETS _IECoreUSD DESTINATION python/IECoreUSD ) - install( FILES ${IECOREUSD_PY_FILES} DESTINATION python/IECoreUSD ) - endif() -endif() diff --git a/contrib/cmake/README.md b/contrib/cmake/README.md deleted file mode 100644 index 316fcec07f..0000000000 --- a/contrib/cmake/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# CMake - -This is an alternative build system for Cortex which is placed here unsupported. -It is recommended to use the SCons build system on Linux/macOS, but this could be used to build a Windows version. -Currently IECoreMaya, IECoreHoudini and IECoreNuke are not supported. - - -## Instructions developing the CMake Build scripts - -You can use the gaffer [dependencies project](https://github.com/GafferHQ/dependencies/releases) for all the dependant libraries & headers. - - - -If you use bash: - -**Create directory for gaffer development** - -~~~ -mkdir dev-cortex -cd dev-cortex -~~~ - -**Download Gaffer Dependencies** -~~~ -wget https://github.com/GafferHQ/dependencies/releases/download/0.54.2.0/gafferDependencies-0.54.2.0-linux.tar.gz -~~~ - -**Extract** -~~~ -tar xvf gafferDependencies-0.45.0.0-linux.tar.gz -~~~ - -**Set root env var for build** -``` -export GAFFER_DEPENDENCIES_ROOT=$PWD/gafferDependencies-0.54.2.0-linux -export ILMBASE_ROOT=$GAFFER_DEPENDENCIES_ROOT -export OPENEXR_ROOT=$GAFFER_DEPENDENCIES_ROOT -export FREETYPE_DIR=$GAFFER_DEPENDENCIES_ROOT -``` - -**Clone git repo and create a directory called .build** - -~~~ -git clone https://github.com/ImageEngine/cortex.git -cd cortex -mkdir .build -cd .build -~~~ - - -**Configure** -``` -cmake ../contrib/cmake -DTBB_INSTALL_DIR=${GAFFER_DEPENDENCIES_ROOT} -DBOOST_ROOT=${GAFFER_DEPENDENCIES_ROOT} -DILMBASE_ROOT=${GAFFER_DEPENDENCIES_ROOT} -DOPENEXR_ROOT=${GAFFER_DEPENDENCIES_ROOT} -DBLOSC_LOCATION=${GAFFER_DEPENDENCIES_ROOT} -DOPENVDB_LOCATION=${GAFFER_DEPENDENCIES_ROOT} -DCMAKE_PREFIX_PATH=${GAFFER_DEPENDENCIES_ROOT} -DARNOLD_ROOT=${GAFFER_DEPENDENCIES_ROOT}/Arnold-5.4.0.2-linux -DILMBASE_NAMESPACE_VERSIONING=OFF -DOPENEXR_NAMESPACE_VERSIONING=OFF -DWITH_IECORE_IMAGE=ON -DWITH_IECORE_SCENE=ON -DWITH_IECORE_ALEMBIC=ON -DWITH_IECORE_USD=ON -DWITH_IECORE_VDB=ON -DWITH_IECORE_ARNOLD=ON -DCMAKE_INSTALL_PREFIX=${GAFFER_DEPENDENCIES_ROOT} -``` - -**Build** -``` -make install -j4 -``` - -### Build Flags - -- WITH_IECORE_PYTHON=1 : Build IECorePython -- WITH_IECORE_GL=1 : Build IECoreGL -- WITH_IECORE_IMAGE=1 : Build IECoreImage -- WITH_IECORE_SCENE=1 : Build IECoreScene -- WITH_IECORE_ARNOLD=1 : Build IECoreArnold -- WITH_IECORE_ALEMBIC=1 : Build IECoreAlembic -- WITH_IECORE_USD=1 : Build IECoreUSD diff --git a/contrib/cmake/buildCortexWindows.bat b/contrib/cmake/buildCortexWindows.bat deleted file mode 100644 index 9afb9bac58..0000000000 --- a/contrib/cmake/buildCortexWindows.bat +++ /dev/null @@ -1,47 +0,0 @@ -rem We hide the CMakeLists.txt here and copy it to root so it works correctly -set ROOT_DIR=%~dp0%..\.. - -mkdir %BUILD_DIR%\doc\licenses -copy LICENSE %BUILD_DIR%\doc\licenses\cortex - -mkdir %ROOT_DIR%\gafferBuild -cd %ROOT_DIR%\gafferBuild -del /f CMakeCache.txt - -set ARNOLD_OPTIONS= -set USE_ARNOLD=0 -if "%ARNOLD_ROOT%" NEQ "" ( - set USE_ARNOLD=1 -) - -set CMAKE_GENERATOR="Visual Studio 15 2017 Win64" - -if not "%1" == "" ( - set BUILD_TYPE=%1 -) else ( - set BUILD_TYPE=RELEASE -) - -cmake -Wno-dev -G %CMAKE_GENERATOR% ^ --DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^ --DCMAKE_INSTALL_PREFIX=%BUILD_DIR% ^ --DBOOST_LOCATION=%BUILD_DIR% ^ --DPYTHON_LIBRARY=%BUILD_DIR%\lib ^ --DPYTHON_INCLUDE_DIR=%BUILD_DIR%\include ^ --DILMBASE_LOCATION=%BUILD_DIR% ^ --DOPENEXR_LOCATION=%BUILD_DIR% ^ --DWITH_IECORE_GL=1 -DWITH_IECORE_IMAGE=1 ^ --DWITH_IECORE_SCENE=1 ^ --DWITH_IECORE_VDB=1 ^ --DOPENVDB_ROOT=%BUILD_DIR% ^ --DWITH_IECORE_ALEMBIC=1 ^ --DALEMBIC_ROOT=%BUILD_DIR% ^ --DOPENVDB_LOCATION=%BUILD_DIR% ^ --DBLOSC_LOCATION=%BUILD_DIR% ^ --DWITH_IECORE_ARNOLD=%USE_ARNOLD% ^ --DARNOLD_ROOT=%ARNOLD_ROOT% ^ -%ROOT_DIR%\contrib\cmake - -if %ERRORLEVEL% NEQ 0 (exit /b %ERRORLEVEL%) -cmake --build . --config %BUILD_TYPE% --target install -if %ERRORLEVEL% NEQ 0 (exit /b %ERRORLEVEL%) \ No newline at end of file diff --git a/contrib/cmake/cmake/FindAlembic.cmake b/contrib/cmake/cmake/FindAlembic.cmake deleted file mode 100644 index 83aa58045c..0000000000 --- a/contrib/cmake/cmake/FindAlembic.cmake +++ /dev/null @@ -1,148 +0,0 @@ -#============================================================================= -# Copyright 2011, Ivan Busquets. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Ivan Busquets nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -#============================================================================= -# -# The module defines the following variables: -# ALEMBIC_INCLUDE_DIR - path to Alembic headers -# ALEMBIC_LIBRARY_DIR - path to Alembic static libs -# ALEMBIC_FOUND - true if the Alembic was found -# -# Example usage: -# find_package(ALEMBIC) -# if(ALEMBIC_FOUND) -# message("ALEMBIC found: ${ALEMBIC_LIBRARY_DIR}") -# endif() -# -#============================================================================= - -set(LIBRARY_PATHS - /usr/lib - /usr/local/lib - /sw/lib - /opt/local/lib - ${ALEMBIC_DIR}/lib/ - ${ALEMBIC_DIR}/lib/static) - -# Find Alembic libs - -# First look for single Alembic library, -# as shipped in versions >= 1.6.0 -find_library(ALEMBIC_LIBRARY - NAMES Alembic - PATHS ${LIBRARY_PATHS} - ) - -# If single library is not found, look for legacy Alembic libraries. -if(NOT ALEMBIC_LIBRARY) - message(STATUS "Single Alembic library not found; looking for legacy libs") - - find_library(ALEMBIC_ABC_LIBRARY - NAMES AlembicAbc - PATHS ${LIBRARY_PATHS} - ) - - find_library(ALEMBIC_ABCGEOM_LIBRARY - NAMES AlembicAbcGeom - PATHS ${LIBRARY_PATHS} - ) - - if (PXR_ENABLE_MULTIVERSE_SUPPORT) - find_library(ALEMBIC_ABCCOREGIT_LIBRARY - NAMES AlembicAbcCoreGit - PATHS ${LIBRARY_PATHS} - ) - else() - set(ALEMBIC_ABCCOREGIT_LIBRARY "") - endif() - - find_library(ALEMBIC_ABCCOREHDF5_LIBRARY - NAMES AlembicAbcCoreHDF5 - PATHS ${LIBRARY_PATHS} - ) - - find_library(ALEMBIC_ABCCOREOGAWA_LIBRARY - NAMES AlembicAbcCoreOgawa - PATHS ${LIBRARY_PATHS} - ) - - find_library(ALEMBIC_ABCCOREABSTRACT_LIBRARY - NAMES AlembicAbcCoreAbstract - PATHS ${LIBRARY_PATHS} - ) - - find_library(ALEMBIC_UTIL_LIBRARY - NAMES AlembicUtil - PATHS ${LIBRARY_PATHS} - ) - - find_library(ALEMBIC_OGAWA_LIBRARY - NAMES AlembicOgawa - PATHS ${LIBRARY_PATHS} - ) - - set (ALEMBIC_LIBRARIES - ${ALEMBIC_ABCGEOM_LIBRARY} - ${ALEMBIC_ABC_LIBRARY} - ${ALEMBIC_ABCCOREHDF5_LIBRARY} - ${ALEMBIC_ABCCOREOGAWA_LIBRARY} - ${ALEMBIC_ABCCOREGIT_LIBRARY} - ${ALEMBIC_ABCCOREABSTRACT_LIBRARY} - ${ALEMBIC_UTIL_LIBRARY} - ${ALEMBIC_OGAWA_LIBRARY} - ) - - get_filename_component(ALEMBIC_LIBRARY_DIR ${ALEMBIC_ABC_LIBRARY} PATH) -else() - set (ALEMBIC_LIBRARIES - ${ALEMBIC_LIBRARY} - ) - - get_filename_component(ALEMBIC_LIBRARY_DIR ${ALEMBIC_LIBRARY} PATH) -endif() - - -# Find Alembic include dir -find_path (ALEMBIC_INCLUDE_DIR Alembic/Abc/All.h - ${ALEMBIC_DIR}/include -) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( "Alembic" - DEFAULT_MSG - ALEMBIC_LIBRARIES - ALEMBIC_LIBRARY_DIR - ALEMBIC_INCLUDE_DIR -) -if(NOT ALEMBIC_FOUND) - message(WARNING "Try using -D ALEMBIC_DIR=/path/to/alembic") -endif() diff --git a/contrib/cmake/cmake/FindArnold.cmake b/contrib/cmake/cmake/FindArnold.cmake deleted file mode 100644 index 000bf28563..0000000000 --- a/contrib/cmake/cmake/FindArnold.cmake +++ /dev/null @@ -1,229 +0,0 @@ -##-***************************************************************************** -## -## Copyright (c) 2009-2013, -## Sony Pictures Imageworks Inc. and -## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. -## -## All rights reserved. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above -## copyright notice, this list of conditions and the following disclaimer -## in the documentation and/or other materials provided with the -## distribution. -## * Neither the name of Industrial Light & Magic nor the names of -## its contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -## -##-***************************************************************************** - - -# We shall worry about windowsification later. - -#-****************************************************************************** -#-****************************************************************************** -# FIRST, ARNOLD STUFF -#-****************************************************************************** -#-****************************************************************************** - -# If ARNOLD_ROOT not set, use predefined paths -IF(NOT DEFINED ARNOLD_ROOT) - IF ( ${CMAKE_HOST_UNIX} ) - IF( ${DARWIN} ) - # TODO: set to default install path when shipping out - SET( CORTEX_ARNOLD_ROOT NOTFOUND ) - ELSE() - # TODO: set to default install path when shipping out - SET( CORTEX_ARNOLD_ROOT "/sww/tools/arnold" ) - ENDIF() - ELSE() - IF ( ${WINDOWS} ) - # TODO: set to 32-bit or 64-bit path - SET( CORTEX_ARNOLD_ROOT NOTFOUND ) - ELSE() - SET( CORTEX_ARNOLD_ROOT NOTFOUND ) - ENDIF() - ENDIF() -ELSE() - # Prefer ARNOLD_ROOT set from the CMakeCache'd variable than default paths - SET( CORTEX_ARNOLD_ROOT ${ARNOLD_ROOT}) -ENDIF() - -# Prefer ARNOLD_ROOT set from the environment over the CMakeCache'd variable -IF(NOT $ENV{ARNOLD_ROOT}x STREQUAL "x") - SET( CORTEX_ARNOLD_ROOT $ENV{ARNOLD_ROOT}) -ENDIF() - - -FIND_PATH( CORTEX_ARNOLD_INCLUDE_PATH ai.h - PATHS - "${CORTEX_ARNOLD_ROOT}/include" - NO_DEFAULT_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_CMAKE_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - DOC "The directory where ai.h resides" ) - -SET( CORTEX_ARNOLD_LIBARNOLD CORTEX_ARNOLD_LIBARNOLD-NOTFOUND ) -FIND_LIBRARY( CORTEX_ARNOLD_LIBARNOLD ai - PATHS - "${CORTEX_ARNOLD_ROOT}/lib/" - "${CORTEX_ARNOLD_ROOT}/bin/" - NO_DEFAULT_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_CMAKE_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - DOC "The ai library" ) - - -IF( ${WINDOWS} ) - SET( ARNOLD_COMPILE_FLAGS "/c /nologo /MT /TP /DWIN32" ) - SET( ARNOLD_LINK_FLAGS "/nologo /dll /LIBPATH:\"%RMANTREE%\\lib\" ai.lib" ) -ELSEIF( ${DARWIN} ) - SET( ARNOLD_COMPILE_FLAGS "-c" ) - SET( ARNOLD_LINK_FLAGS "-bundle -undefined dynamic_lookup" ) -ELSEIF( ${LINUX} ) - SET( ARNOLD_COMPILE_FLAGS "-c -fPIC" ) - SET( ARNOLD_LINK_FLAGS "-shared" ) -ENDIF() - -IF ( ( ${CORTEX_ARNOLD_INCLUDE_PATH} STREQUAL "CORTEX_ARNOLD_INCLUDE_PATH-NOTFOUND" ) OR - ( ${CORTEX_ARNOLD_LIBARNOLD} STREQUAL "CORTEX_ARNOLD_LIBARNOLD-NOTFOUND" ) ) - MESSAGE( STATUS "Arnold not found" ) - SET( CORTEX_ARNOLD_FOUND FALSE ) -ELSE() - MESSAGE( STATUS "ARNOLD INCLUDE PATH: ${CORTEX_ARNOLD_INCLUDE_PATH}" ) - MESSAGE( STATUS "libai: ${CORTEX_ARNOLD_LIBARNOLD}" ) - SET( CORTEX_ARNOLD_FOUND TRUE ) - SET( CORTEX_ARNOLD_LIBS ${CORTEX_ARNOLD_LIBARNOLD} ) -ENDIF() - -##-***************************************************************************** -##-***************************************************************************** -# Macro for making arnold plugins -##-***************************************************************************** -##-***************************************************************************** -MACRO(ADD_ARNOLD_CXX_PLUGIN PluginName SourceFile1 ) - - IF( NOT ${CORTEX_ARNOLD_FOUND} ) - MESSAGE( FATAL_ERROR "Arnold is not found. :(" ) - ENDIF() - - GET_FILENAME_COMPONENT( PluginNameNoDirectory ${PluginName} NAME ) - GET_FILENAME_COMPONENT( PluginNameFullPath ${PluginName} ABSOLUTE ) - - SET( TMP_SOURCES ${SourceFile1} ${ARGN} ) - SET( ${PluginName}_SOURCES ${TMP_SOURCES} ) - - INCLUDE_DIRECTORIES( ${CORTEX_ARNOLD_INCLUDE_PATH} ) - - ADD_LIBRARY( ${PluginName} MODULE ${TMP_SOURCES} ) - - SET_TARGET_PROPERTIES( ${PluginName} - PROPERTIES - COMPILE_FLAGS ${ARNOLD_COMPILE_FLAGS} - LINK_FLAGS ${ARNOLD_LINK_FLAGS} - PREFIX "" ) - - TARGET_LINK_LIBRARIES ( ${PluginName} ${CORTEX_ARNOLD_LIBARNOLD} ) - -ENDMACRO(ADD_ARNOLD_CXX_PLUGIN) - - -#-****************************************************************************** -#-****************************************************************************** -# MtoA -#-****************************************************************************** -#-****************************************************************************** - -# If MTOA_ROOT not set, use predefined paths -IF(NOT DEFINED MTOA_ROOT) - IF ( ${CMAKE_HOST_UNIX} ) - IF( ${DARWIN} ) - # TODO: set to default install path when shipping out - SET( CORTEX_MTOA_ROOT NOTFOUND ) - ELSE() - # TODO: set to default install path when shipping out - SET( CORTEX_MTOA_ROOT "/opt/solidangle/mtoa/2014" ) - ENDIF() - ELSE() - IF ( ${WINDOWS} ) - # TODO: set to 32-bit or 64-bit path - SET( CORTEX_MTOA_ROOT NOTFOUND ) - ELSE() - SET( CORTEX_MTOA_ROOT NOTFOUND ) - ENDIF() - ENDIF() -ELSE() - # Prefer MTOA_ROOT set from the CMakeCache'd variable than default paths - SET( CORTEX_MTOA_ROOT ${MTOA_ROOT}) -ENDIF() - -# Prefer MTOA_ROOT set from the environment over the CMakeCache'd variable -IF(NOT $ENV{MTOA_ROOT}x STREQUAL "x") - SET( CORTEX_MTOA_ROOT $ENV{MTOA_ROOT}) -ENDIF() - -#SET( CORTEX_MTOA_INCLUDE_PATH ${CORTEX_MTOA_ROOT}/include ) -FIND_PATH( CORTEX_MTOA_INCLUDE_PATH utils/Version.h - PATHS - "${CORTEX_MTOA_ROOT}/include" - NO_DEFAULT_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_CMAKE_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - DOC "The directory where ai.h resides" ) - -SET( CORTEX_MTOA_LIBMTOA CORTEX_MTOA_LIBMTOA-NOTFOUND ) -FIND_LIBRARY( CORTEX_MTOA_LIBMTOA mtoa_api - PATHS - "${CORTEX_MTOA_ROOT}/lib/" - "${CORTEX_MTOA_ROOT}/bin/" - NO_DEFAULT_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_CMAKE_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - DOC "The mtoa library" ) - - -IF( ${WINDOWS} ) - SET( MTOA_COMPILE_FLAGS "/c /nologo /MT /TP /DWIN32" ) - SET( MTOA_LINK_FLAGS "/nologo /dll /LIBPATH:\"%RMANTREE%\\lib\" mtoa_api.lib" ) -ELSEIF( ${DARWIN} ) - SET( MTOA_COMPILE_FLAGS "-c" ) - SET( MTOA_LINK_FLAGS "-bundle -undefined dynamic_lookup" ) -ELSEIF( ${LINUX} ) - SET( MTOA_COMPILE_FLAGS "-c -fPIC" ) - SET( MTOA_LINK_FLAGS "-shared" ) -ENDIF() - -IF ( ( ${CORTEX_MTOA_INCLUDE_PATH} STREQUAL "CORTEX_MTOA_INCLUDE_PATH-NOTFOUND" ) OR - ( ${CORTEX_MTOA_LIBMTOA} STREQUAL "CORTEX_MTOA_LIBMTOA-NOTFOUND" ) ) - MESSAGE( STATUS "MtoA not found" ) - SET( CORTEX_MTOA_FOUND FALSE ) -ELSE() - MESSAGE( STATUS "MtoA INCLUDE PATH: ${CORTEX_MTOA_INCLUDE_PATH}" ) - MESSAGE( STATUS "mtoa_api: ${CORTEX_MTOA_LIBMTOA}" ) - SET( CORTEX_MTOA_FOUND TRUE ) - SET( CORTEX_ARNOLD_LIBS ${CORTEX_MTOA_LIBMTOA} ) -ENDIF() diff --git a/contrib/cmake/cmake/FindBlosc.cmake b/contrib/cmake/cmake/FindBlosc.cmake deleted file mode 100644 index 8a402a4077..0000000000 --- a/contrib/cmake/cmake/FindBlosc.cmake +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright (c) 2012-2016 DreamWorks Animation LLC -# -# All rights reserved. This software is distributed under the -# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) -# -# Redistributions of source code must retain the above copyright -# and license notice and the following restrictions and disclaimer. -# -# * Neither the name of DreamWorks Animation nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE -# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. -# - -# -*- cmake -*- -# - Find Blosc -# -# Author : Nicholas Yue yue.nicholas@gmail.com -# -# BLOSC_FOUND set if Blosc is found. -# BLOSC_INCLUDE_DIR Blosc's include directory -# BLOSC_LIBRARYDIR Blosc's library directory -# BLOSC_LIBRARIES all Blosc libraries - -FIND_PACKAGE ( PackageHandleStandardArgs ) - -FIND_PATH( BLOSC_LOCATION include/blosc.h - "$ENV{BLOSC_ROOT}" - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS ( Blosc - REQUIRED_VARS BLOSC_LOCATION - ) - -IF ( BLOSC_FOUND ) - - SET ( BLOSC_LIBRARYDIR ${BLOSC_LOCATION}/lib - CACHE STRING "Blosc library directories") - - SET ( _blosc_library_name "blosc" ) - - # Static library setup - IF (Blosc_USE_STATIC_LIBS) - SET(CMAKE_FIND_LIBRARY_SUFFIXES_BACKUP ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF (WIN32) - SET ( _blosc_library_name "libblosc" ) - ELSE () - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - ENDIF () - ENDIF() - - FIND_LIBRARY ( BLOSC_blosc_LIBRARY ${_blosc_library_name} - PATHS ${BLOSC_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - - # Static library tear down - IF (Blosc_USE_STATIC_LIBS) - SET( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BACKUP} ) - ENDIF() - - SET( BLOSC_INCLUDE_DIR "${BLOSC_LOCATION}/include" CACHE STRING "Blosc include directory" ) - -ENDIF ( BLOSC_FOUND ) \ No newline at end of file diff --git a/contrib/cmake/cmake/FindIlmBase.cmake b/contrib/cmake/cmake/FindIlmBase.cmake deleted file mode 100644 index 2d51af22f6..0000000000 --- a/contrib/cmake/cmake/FindIlmBase.cmake +++ /dev/null @@ -1,188 +0,0 @@ -# Copyright (c) 2012-2016 DreamWorks Animation LLC -# -# All rights reserved. This software is distributed under the -# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) -# -# Redistributions of source code must retain the above copyright -# and license notice and the following restrictions and disclaimer. -# -# * Neither the name of DreamWorks Animation nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE -# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. -# - -#-*-cmake-*- -# - Find ILMBase -# -# Author : Nicholas Yue yue.nicholas@gmail.com -# -# This auxiliary CMake file helps in find the ILMBASE headers and libraries -# -# ILMBASE_FOUND set if ILMBASE is found. -# ILMBASE_INCLUDE_DIR ILMBASE's include directory -# ILMBASE_LIBRARYDIR ILMBASE's include directory -# Ilmbase_HALF_LIBRARY ILMBASE's Half libraries -# Ilmbase_IEX_LIBRARY ILMBASE's Iex libraries -# Ilmbase_IEXMATH_LIBRARY ILMBASE's IexMath libraries -# Ilmbase_ILMTHREAD_LIBRARY ILMBASE's IlmThread libraries -# Ilmbase_IMATH_LIBRARY ILMBASE's Imath libraries - -FIND_PACKAGE ( PackageHandleStandardArgs ) - -FIND_PATH ( ILMBASE_LOCATION include/OpenEXR/IlmBaseConfig.h - "$ENV{ILMBASE_ROOT}" - ${ILMBASE_ROOT} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS ( ILMBase - REQUIRED_VARS ILMBASE_LOCATION - ) - -OPTION ( ILMBASE_NAMESPACE_VERSIONING "Namespace versioning of libraries" ON ) - -IF ( ILMBASE_FOUND ) - - FILE ( STRINGS "${ILMBASE_LOCATION}/include/OpenEXR/IlmBaseConfig.h" _ilmbase_version_major_string REGEX "#define ILMBASE_VERSION_MAJOR ") - STRING ( REGEX REPLACE "#define ILMBASE_VERSION_MAJOR" "" _ilmbase_version_major_unstrip "${_ilmbase_version_major_string}") - STRING ( STRIP ${_ilmbase_version_major_unstrip} ILMBASE_VERSION_MAJOR ) - - FILE ( STRINGS "${ILMBASE_LOCATION}/include/OpenEXR/IlmBaseConfig.h" _ilmbase_version_minor_string REGEX "#define ILMBASE_VERSION_MINOR ") - STRING ( REGEX REPLACE "#define ILMBASE_VERSION_MINOR" "" _ilmbase_version_minor_unstrip "${_ilmbase_version_minor_string}") - STRING ( STRIP ${_ilmbase_version_minor_unstrip} ILMBASE_VERSION_MINOR ) - - IF ( ILMBASE_NAMESPACE_VERSIONING ) - SET ( IEX_LIBRARY_NAME Iex-${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR} ) - SET ( IEXMATH_LIBRARY_NAME IexMath-${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR} ) - SET ( ILMTHREAD_LIBRARY_NAME IlmThread-${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR} ) - SET ( IMATH_LIBRARY_NAME Imath-${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR} ) - ELSE ( ILMBASE_NAMESPACE_VERSIONING ) - SET ( IEX_LIBRARY_NAME Iex ) - SET ( IEXMATH_LIBRARY_NAME IexMath ) - SET ( ILMTHREAD_LIBRARY_NAME IlmThread ) - SET ( IMATH_LIBRARY_NAME Imath ) - ENDIF ( ILMBASE_NAMESPACE_VERSIONING ) - - SET ( ILMBASE_INCLUDE_DIRS - ${ILMBASE_LOCATION}/include - ${ILMBASE_LOCATION}/include/OpenEXR - CACHE STRING "ILMBase include directories") - SET ( ILMBASE_LIBRARYDIR ${ILMBASE_LOCATION}/lib - CACHE STRING "ILMBase library directories") - SET ( ILMBASE_FOUND TRUE ) - - SET ( ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF (Ilmbase_USE_STATIC_LIBS) - IF (APPLE) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY Iex PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY IlmThread PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY Imath PATHS ${ILMBASE_LIBRARYDIR} ) - ELSEIF (WIN32) - # Link library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half_static PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY Iex_static PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY IlmThread_static PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY Imath_static PATHS ${ILMBASE_LIBRARYDIR} ) - ELSE (APPLE) - SET ( CMAKE_FIND_LIBRARY_SUFFIXES ".a") - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY Iex PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY IlmThread PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY Imath PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - ENDIF (APPLE) - ELSE (Ilmbase_USE_STATIC_LIBS) - IF (APPLE) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib") - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY Iex PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY IlmThread PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY Imath PATHS ${ILMBASE_LIBRARYDIR} ) - ELSEIF (WIN32) - # Link library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY ${IEX_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IEXMATH_LIBRARY ${IEXMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY ${ILMTHREAD_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY ${IMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} ) - # Load library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") - FIND_LIBRARY ( Ilmbase_HALF_DLL Half PATHS ${ILMBASE_LOCATION}/bin - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IEX_DLL ${IEX_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IEXMATH_DLL ${IEXMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_DLL ${ILMTHREAD_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IMATH_DLL ${IMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - ELSE (APPLE) - FIND_LIBRARY ( Ilmbase_HALF_LIBRARY Half PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IEX_LIBRARY ${IEX_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IEXMATH_LIBRARY ${IEXMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_ILMTHREAD_LIBRARY ${ILMTHREAD_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - FIND_LIBRARY ( Ilmbase_IMATH_LIBRARY ${IMATH_LIBRARY_NAME} PATHS ${ILMBASE_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - ENDIF (APPLE) - ENDIF () - # MUST reset - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES}) - -ELSE ( ILMBASE_FOUND ) - MESSAGE ( FATAL_ERROR "Unable to find ILMBase, ILMBASE_ROOT = $ENV{ILMBASE_ROOT}") -ENDIF ( ILMBASE_FOUND ) diff --git a/contrib/cmake/cmake/FindOSL.cmake b/contrib/cmake/cmake/FindOSL.cmake deleted file mode 100644 index 272f8dba1a..0000000000 --- a/contrib/cmake/cmake/FindOSL.cmake +++ /dev/null @@ -1,80 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit http://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2013-2016 Esteban Tovagliari, The appleseedhq Organization -# -# 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. -# - - -# -# Find OSL headers and libraries. -# -# This module defines the following variables: -# -# OSL_FOUND True if OSL was found -# OSL_INCLUDE_DIRS Where to find OSL header files -# OSL_LIBRARIES List of OSL libraries to link against -# OSL_COMPILER Path to oslc binary -# OSL_QUERY_INFO Path to oslinfo binary -# OSL_MAKETX Path to OpenImageIO's maketx binary -# - -include (FindPackageHandleStandardArgs) - -find_path (OSL_INCLUDE_DIR NAMES OSL/oslexec.h) - -find_library (OSL_EXEC_LIBRARY NAMES oslexec) -find_library (OSL_COMP_LIBRARY NAMES oslcomp) -find_library (OSL_QUERY_LIBRARY NAMES oslquery) - -find_program (OSL_COMPILER NAMES oslc) -find_program (OSL_QUERY_INFO NAMES oslinfo) -find_program (OSL_MAKETX NAMES maketx) - -# Handle the QUIETLY and REQUIRED arguments and set OSL_FOUND. -find_package_handle_standard_args (OSL DEFAULT_MSG - OSL_INCLUDE_DIR - OSL_EXEC_LIBRARY - OSL_COMP_LIBRARY - OSL_QUERY_LIBRARY - OSL_COMPILER - OSL_QUERY_INFO - OSL_MAKETX -) - -# Set the output variables. -if (OSL_FOUND) - set (OSL_INCLUDE_DIRS ${OSL_INCLUDE_DIR}) - set (OSL_LIBRARIES ${OSL_EXEC_LIBRARY} ${OSL_COMP_LIBRARY} ${OSL_QUERY_LIBRARY}) -else () - set (OSL_INCLUDE_DIRS) - set (OSL_LIBRARIES) -endif () - -mark_as_advanced ( - OSL_INCLUDE_DIR - OSL_EXEC_LIBRARY - OSL_COMP_LIBRARY - OSL_QUERY_LIBRARY -) diff --git a/contrib/cmake/cmake/FindOpenColorIO.cmake b/contrib/cmake/cmake/FindOpenColorIO.cmake deleted file mode 100644 index 64cf5150a7..0000000000 --- a/contrib/cmake/cmake/FindOpenColorIO.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit http://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2013-2016 Esteban Tovagliari, The appleseedhq Organization -# -# 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. -# - - -# -# Find OpenImageIO headers and libraries. -# -# This module defines the following variables: -# -# OPENCOLORIO_FOUND True if OpenImageIO was found -# OPENCOLORIO_INCLUDE_DIR Where to find OpenImageIO header files -# OPENCOLORIO_LIBRARIES List of OpenImageIO libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (OPENCOLORIO_INCLUDE_DIR NAMES OpenColorIO/OpenColorIO.h) - -find_library (OPENCOLORIO_LIBRARY NAMES OpenColorIO) - -# Handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND. -find_package_handle_standard_args (OPENCOLORIO DEFAULT_MSG - OPENCOLORIO_INCLUDE_DIR - OPENCOLORIO_LIBRARY -) - -# Set the output variables. -if (OPENCOLORIO_FOUND) - set (OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_INCLUDE_DIR}) - set (OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARY}) -else () - set (OPENCOLORIO_INCLUDE_DIRS) - set (OPENCOLORIO_LIBRARIES) -endif () - -mark_as_advanced ( - OPENCOLORIO_INCLUDE_DIR - OPENCOLORIO_LIBRARY -) diff --git a/contrib/cmake/cmake/FindOpenEXR.cmake b/contrib/cmake/cmake/FindOpenEXR.cmake deleted file mode 100644 index 409b2d1560..0000000000 --- a/contrib/cmake/cmake/FindOpenEXR.cmake +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright (c) 2012-2016 DreamWorks Animation LLC -# -# All rights reserved. This software is distributed under the -# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) -# -# Redistributions of source code must retain the above copyright -# and license notice and the following restrictions and disclaimer. -# -# * Neither the name of DreamWorks Animation nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE -# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. -# - -# -*- cmake -*- -# - Find OpenEXR -# -# Author : Nicholas Yue yue.nicholas@gmail.com -# -# This module will define the following variables: -# OPENEXR_INCLUDE_DIRS - Location of the openexr includes -# OPENEXR_LIBRARIES - [TODO] Required libraries for all requested bindings -# OPENEXR_FOUND - true if OPENEXR was found on the system -# OPENEXR_LIBRARYDIR - the full set of library directories - -FIND_PACKAGE ( PackageHandleStandardArgs ) - -FIND_PATH ( OPENEXR_LOCATION include/OpenEXR/OpenEXRConfig.h - ENV OPENEXR_ROOT - ${OPENEXR_ROOT} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS ( OpenEXR - REQUIRED_VARS OPENEXR_LOCATION - ) - -OPTION ( OPENEXR_NAMESPACE_VERSIONING "Namespace versioning of libraries" ON ) - -IF ( OPENEXR_FOUND ) - - FILE ( STRINGS "${OPENEXR_LOCATION}/include/OpenEXR/OpenEXRConfig.h" _openexr_version_major_string REGEX "#define OPENEXR_VERSION_MAJOR ") - STRING ( REGEX REPLACE "#define OPENEXR_VERSION_MAJOR" "" _openexr_version_major_unstrip "${_openexr_version_major_string}") - STRING ( STRIP ${_openexr_version_major_unstrip} OPENEXR_VERSION_MAJOR ) - - FILE ( STRINGS "${OPENEXR_LOCATION}/include/OpenEXR/OpenEXRConfig.h" _openexr_version_minor_string REGEX "#define OPENEXR_VERSION_MINOR ") - STRING ( REGEX REPLACE "#define OPENEXR_VERSION_MINOR" "" _openexr_version_minor_unstrip "${_openexr_version_minor_string}") - STRING ( STRIP ${_openexr_version_minor_unstrip} OPENEXR_VERSION_MINOR ) - - MESSAGE ( STATUS "Found OpenEXR v${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR} at ${OPENEXR_LOCATION}" ) - - IF ( OPENEXR_NAMESPACE_VERSIONING ) - SET ( ILMIMF_LIBRARY_NAME IlmImf-${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR} ) - ELSE ( OPENEXR_NAMESPACE_VERSIONING ) - SET ( ILMIMF_LIBRARY_NAME IlmImf ) - ENDIF ( OPENEXR_NAMESPACE_VERSIONING ) - - SET ( OPENEXR_INCLUDE_DIRS - ${OPENEXR_LOCATION}/include - ${OPENEXR_LOCATION}/include/OpenEXR - CACHE STRING "Openexr include directories") - SET ( OPENEXR_LIBRARYDIR ${OPENEXR_LOCATION}/lib - CACHE STRING "Openexr library directories") - SET ( OPENEXR_FOUND TRUE ) - - - IF (Openexr_USE_STATIC_LIBS) - IF (APPLE) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} ) - ELSEIF (WIN32) - # Link library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} ) - ELSE (APPLE) - # MESSAGE ( "CMAKE_FIND_LIBRARY_SUFFIXES = " ${CMAKE_FIND_LIBRARY_SUFFIXES}) - SET ( ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - SET ( CMAKE_FIND_LIBRARY_SUFFIXES ".a") - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - SET ( CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF (APPLE) - ELSE () - IF (APPLE) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib") - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} ) - ELSEIF (WIN32) - # Link library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} ) - # Load library - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") - FIND_LIBRARY ( Openexr_ILMIMF_DLL ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LOCATION}/bin ) - # MUST reset - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") - ELSE (APPLE) - FIND_LIBRARY ( Openexr_ILMIMF_LIBRARY ${ILMIMF_LIBRARY_NAME} PATHS ${OPENEXR_LIBRARYDIR} - NO_DEFAULT_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_CMAKE_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - ) - ENDIF (APPLE) - ENDIF () - - # SET( Openexr_ILMIMF_LIBRARY ${OPENEXR_ILMIMF_LIBRARY_PATH} CACHE STRING "Openexr's IlmImf library") - -ENDIF ( OPENEXR_FOUND ) - diff --git a/contrib/cmake/cmake/FindOpenImageIO.cmake b/contrib/cmake/cmake/FindOpenImageIO.cmake deleted file mode 100644 index 165378b857..0000000000 --- a/contrib/cmake/cmake/FindOpenImageIO.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit http://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2013-2016 Esteban Tovagliari, The appleseedhq Organization -# -# 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. -# - - -# -# Find OpenImageIO headers and libraries. -# -# This module defines the following variables: -# -# OPENIMAGEIO_FOUND True if OpenImageIO was found -# OPENIMAGEIO_INCLUDE_DIRS Where to find OpenImageIO header files -# OPENIMAGEIO_LIBRARIES List of OpenImageIO libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (OPENIMAGEIO_INCLUDE_DIR NAMES OpenImageIO/imageio.h) - -find_library (OPENIMAGEIO_LIBRARY NAMES OpenImageIO) - -# Handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND. -find_package_handle_standard_args (OPENIMAGEIO DEFAULT_MSG - OPENIMAGEIO_INCLUDE_DIR - OPENIMAGEIO_LIBRARY -) - -# Set the output variables. -if (OPENIMAGEIO_FOUND) - set (OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR}) - set (OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY}) -else () - set (OPENIMAGEIO_INCLUDE_DIRS) - set (OPENIMAGEIO_LIBRARIES) -endif () - -mark_as_advanced ( - OPENIMAGEIO_INCLUDE_DIR - OPENIMAGEIO_LIBRARY -) diff --git a/contrib/cmake/cmake/FindOpenVDB.cmake b/contrib/cmake/cmake/FindOpenVDB.cmake deleted file mode 100644 index 3c1223bc8f..0000000000 --- a/contrib/cmake/cmake/FindOpenVDB.cmake +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2012-2016 DreamWorks Animation LLC -# -# All rights reserved. This software is distributed under the -# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) -# -# Redistributions of source code must retain the above copyright -# and license notice and the following restrictions and disclaimer. -# -# * Neither the name of DreamWorks Animation nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE -# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. -# - -# -*- cmake -*- -# - Find OpenVDB -# -# Author : Fredrik Salomonsson fredriks@d2.com -# -# OpenVDB_FOUND Set if OpenVDB is found. -# OpenVDB_INCLUDE_DIR OpenVDB's include directory -# OpenVDB_LIBRARY_DIR OpenVDB's library directory -# OpenVDB__LIBRARY Specific openvdb library ( is upper-case) -# OpenVDB_LIBRARIES All openvdb libraries -# OpenVDB_MAJOR_VERSION Major version number -# OpenVDB_MINOR_VERSION Minor version number -# OpenVDB_PATCH_VERSION Patch version number -# -# This module read hints about search locations from variables:: -# -# OPENVDB_ROOT Preferred installtion prefix - -FIND_PACKAGE( PackageHandleStandardArgs ) - -FIND_PATH( OPENVDB_LOCATION include/openvdb/version.h - "$ENV{OPENVDB_ROOT}" - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS( OpenVDB - REQUIRED_VARS OPENVDB_LOCATION - ) - -IF( OpenVDB_FOUND ) - SET( OpenVDB_INCLUDE_DIR ${OPENVDB_LOCATION}/include - CACHE PATH "OpenVDB include directory") - - SET( OpenVDB_LIBRARY_DIR ${OPENVDB_LOCATION}/lib - CACHE PATH "OpenVDB library directory" ) - - FIND_LIBRARY( OpenVDB_OPENVDB_LIBRARY openvdb - PATHS ${OpenVDB_LIBRARY_DIR} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) - - SET( OpenVDB_LIBRARIES "") - LIST( APPEND OpenVDB_LIBRARIES ${OpenVDB_OPENVDB_LIBRARY} ) - - SET( OPENVDB_VERSION_FILE ${OpenVDB_INCLUDE_DIR}/openvdb/version.h ) - - FILE( STRINGS "${OPENVDB_VERSION_FILE}" openvdb_major_version_str - REGEX "^#define[\t ]+OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER[\t ]+.*") - FILE( STRINGS "${OPENVDB_VERSION_FILE}" openvdb_minor_version_str - REGEX "^#define[\t ]+OPENVDB_LIBRARY_MINOR_VERSION_NUMBER[\t ]+.*") - FILE( STRINGS "${OPENVDB_VERSION_FILE}" openvdb_patch_version_str - REGEX "^#define[\t ]+OPENVDB_LIBRARY_PATCH_VERSION_NUMBER[\t ]+.*") - - STRING( REGEX REPLACE "^.*OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER[\t ]+([0-9]*).*$" "\\1" - _openvdb_major_version_number "${openvdb_major_version_str}") - STRING( REGEX REPLACE "^.*OPENVDB_LIBRARY_MINOR_VERSION_NUMBER[\t ]+([0-9]*).*$" "\\1" - _openvdb_minor_version_number "${openvdb_minor_version_str}") - STRING( REGEX REPLACE "^.*OPENVDB_LIBRARY_PATCH_VERSION_NUMBER[\t ]+([0-9]*).*$" "\\1" - _openvdb_patch_version_number "${openvdb_patch_version_str}") - - SET( OpenVDB_MAJOR_VERSION ${_openvdb_major_version_number} - CACHE STRING "OpenVDB major version number" ) - SET( OpenVDB_MINOR_VERSION ${_openvdb_minor_version_number} - CACHE STRING "OpenVDB minor version number" ) - SET( OpenVDB_PATCH_VERSION ${_openvdb_patch_version_number} - CACHE STRING "OpenVDB patch version number" ) - -ENDIF( OpenVDB_FOUND ) diff --git a/contrib/cmake/cmake/FindTBB.cmake b/contrib/cmake/cmake/FindTBB.cmake deleted file mode 100644 index e5ca100391..0000000000 --- a/contrib/cmake/cmake/FindTBB.cmake +++ /dev/null @@ -1,283 +0,0 @@ -# Locate Intel Threading Building Blocks include paths and libraries -# FindTBB.cmake can be found at https://code.google.com/p/findtbb/ -# Written by Hannes Hofmann -# Improvements by Gino van den Bergen , -# Florian Uhlig , -# Jiri Marsik - -# The MIT License -# -# Copyright (c) 2011 Hannes Hofmann -# -# 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. - -# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler. -# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21" -# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found -# in the TBB installation directory (TBB_INSTALL_DIR). -# -# GvdB: Mac OS X distribution places libraries directly in lib directory. -# -# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER. -# TBB_ARCHITECTURE [ ia32 | em64t | itanium ] -# which architecture to use -# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9 -# which compiler to use (detected automatically on Windows) - -# This module respects -# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR} - -# This module defines -# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc. -# TBB_LIBRARY_DIRS, where to find libtbb, libtbbmalloc -# TBB_DEBUG_LIBRARY_DIRS, where to find libtbb_debug, libtbbmalloc_debug -# TBB_INSTALL_DIR, the base TBB install directory -# TBB_LIBRARIES, the libraries to link against to use TBB. -# TBB_DEBUG_LIBRARIES, the libraries to link against to use TBB with debug symbols. -# TBB_FOUND, If false, don't try to use TBB. -# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h - - -if (WIN32) - # has em64t/vc8 em64t/vc9 - # has ia32/vc7.1 ia32/vc8 ia32/vc9 - set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB") - set(_TBB_LIB_NAME "tbb") - set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc") - set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug") - set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug") - if (MSVC71) - set (_TBB_COMPILER "vc7.1") - endif(MSVC71) - if (MSVC80) - set(_TBB_COMPILER "vc8") - endif(MSVC80) - if (MSVC90) - set(_TBB_COMPILER "vc9") - endif(MSVC90) - if(MSVC10) - set(_TBB_COMPILER "vc10") - endif(MSVC10) - # Todo: add other Windows compilers such as ICL. - set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE}) -endif (WIN32) - -if (UNIX) - if (APPLE) - # MAC - set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions") - # libs: libtbb.dylib, libtbbmalloc.dylib, *_debug - set(_TBB_LIB_NAME "tbb") - set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc") - set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug") - set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug") - # default flavor on apple: ia32/cc4.0.1_os10.4.9 - # Jiri: There is no reason to presume there is only one flavor and - # that user's setting of variables should be ignored. - if(NOT TBB_COMPILER) - set(_TBB_COMPILER "cc4.0.1_os10.4.9") - elseif (NOT TBB_COMPILER) - set(_TBB_COMPILER ${TBB_COMPILER}) - endif(NOT TBB_COMPILER) - if(NOT TBB_ARCHITECTURE) - set(_TBB_ARCHITECTURE "ia32") - elseif(NOT TBB_ARCHITECTURE) - set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE}) - endif(NOT TBB_ARCHITECTURE) - else (APPLE) - # LINUX - set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include") - set(_TBB_LIB_NAME "tbb") - set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc") - set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug") - set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug") - # has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21 - # has ia32/* - # has itanium/* - set(_TBB_COMPILER ${TBB_COMPILER}) - set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE}) - endif (APPLE) -endif (UNIX) - -if (CMAKE_SYSTEM MATCHES "SunOS.*") -# SUN -# not yet supported -# has em64t/cc3.4.3_kernel5.10 -# has ia32/* -endif (CMAKE_SYSTEM MATCHES "SunOS.*") - - -#-- Clear the public variables -set (TBB_FOUND "NO") - - -#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR} -# first: use CMake variable TBB_INSTALL_DIR -if (TBB_INSTALL_DIR) - set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR}) -endif (TBB_INSTALL_DIR) -# second: use environment variable -if (NOT _TBB_INSTALL_DIR) - if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "") - set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR}) - endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "") - # Intel recommends setting TBB21_INSTALL_DIR - if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "") - set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR}) - endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "") - if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "") - set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR}) - endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "") - if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "") - set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR}) - endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "") -endif (NOT _TBB_INSTALL_DIR) -# third: try to find path automatically -if (NOT _TBB_INSTALL_DIR) - if (_TBB_DEFAULT_INSTALL_DIR) - set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR}) - endif (_TBB_DEFAULT_INSTALL_DIR) -endif (NOT _TBB_INSTALL_DIR) -# sanity check -if (NOT _TBB_INSTALL_DIR) - message ("ERROR: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}") -else (NOT _TBB_INSTALL_DIR) -# finally: set the cached CMake variable TBB_INSTALL_DIR -if (NOT TBB_INSTALL_DIR) - set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory") - mark_as_advanced(TBB_INSTALL_DIR) -endif (NOT TBB_INSTALL_DIR) - - -#-- A macro to rewrite the paths of the library. This is necessary, because -# find_library() always found the em64t/vc9 version of the TBB libs -macro(TBB_CORRECT_LIB_DIR var_name) -# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t") - string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}}) -# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t") - string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}}) - string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}}) - string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}}) - string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}}) - string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}}) -endmacro(TBB_CORRECT_LIB_DIR var_content) - - -#-- Look for include directory and set ${TBB_INCLUDE_DIR} -set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include) -# Jiri: tbbvars now sets the CPATH environment variable to the directory -# containing the headers. -find_path(TBB_INCLUDE_DIR - tbb/task_scheduler_init.h - PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH -) -mark_as_advanced(TBB_INCLUDE_DIR) - - -#-- Look for libraries -# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh] -if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "") - set (_TBB_LIBRARY_DIR - ${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM} - ${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib - ) -endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "") -# Jiri: This block isn't mutually exclusive with the previous one -# (hence no else), instead I test if the user really specified -# the variables in question. -if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL "")) - # HH: deprecated - message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).") - # Jiri: It doesn't hurt to look in more places, so I store the hints from - # ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER - # variables and search them both. - set (_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR}) -endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL "")) - -# GvdB: Mac OS X distribution places libraries directly in lib directory. -list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib) - -# Jiri: No reason not to check the default paths. From recent versions, -# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH -# variables, which now point to the directories of the lib files. -# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS -# argument instead of the implicit PATHS as it isn't hard-coded -# but computed by system introspection. Searching the LIBRARY_PATH -# and LD_LIBRARY_PATH environment variables is now even more important -# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates -# the use of TBB built from sources. -find_library(TBB_LIBRARY ${_TBB_LIB_NAME} HINTS ${_TBB_LIBRARY_DIR} - PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) -find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME} HINTS ${_TBB_LIBRARY_DIR} - PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) - -#Extract path from TBB_LIBRARY name -get_filename_component(TBB_LIBRARY_DIR ${TBB_LIBRARY} PATH) - -#TBB_CORRECT_LIB_DIR(TBB_LIBRARY) -#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY) -mark_as_advanced(TBB_LIBRARY TBB_MALLOC_LIBRARY) - -#-- Look for debug libraries -# Jiri: Changed the same way as for the release libraries. -find_library(TBB_LIBRARY_DEBUG ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR} - PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) -find_library(TBB_MALLOC_LIBRARY_DEBUG ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR} - PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) - -# Jiri: Self-built TBB stores the debug libraries in a separate directory. -# Extract path from TBB_LIBRARY_DEBUG name -get_filename_component(TBB_LIBRARY_DEBUG_DIR ${TBB_LIBRARY_DEBUG} PATH) - -#TBB_CORRECT_LIB_DIR(TBB_LIBRARY_DEBUG) -#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY_DEBUG) -mark_as_advanced(TBB_LIBRARY_DEBUG TBB_MALLOC_LIBRARY_DEBUG) - - -if (TBB_INCLUDE_DIR) - if (TBB_LIBRARY) - set (TBB_FOUND "YES") - set (TBB_LIBRARIES ${TBB_LIBRARY} ${TBB_MALLOC_LIBRARY} ${TBB_LIBRARIES}) - set (TBB_DEBUG_LIBRARIES ${TBB_LIBRARY_DEBUG} ${TBB_MALLOC_LIBRARY_DEBUG} ${TBB_DEBUG_LIBRARIES}) - set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE) - set (TBB_LIBRARY_DIRS ${TBB_LIBRARY_DIR} CACHE PATH "TBB library directory" FORCE) - # Jiri: Self-built TBB stores the debug libraries in a separate directory. - set (TBB_DEBUG_LIBRARY_DIRS ${TBB_LIBRARY_DEBUG_DIR} CACHE PATH "TBB debug library directory" FORCE) - mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARY_DIRS TBB_DEBUG_LIBRARY_DIRS TBB_LIBRARIES TBB_DEBUG_LIBRARIES) - message(STATUS "Found Intel TBB") - endif (TBB_LIBRARY) -endif (TBB_INCLUDE_DIR) - -if (NOT TBB_FOUND) - message("ERROR: Intel TBB NOT found!") - message(STATUS "Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}") - # do only throw fatal, if this pkg is REQUIRED - if (TBB_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find TBB library.") - endif (TBB_FIND_REQUIRED) -endif (NOT TBB_FOUND) - -endif (NOT _TBB_INSTALL_DIR) - -if (TBB_FOUND) - set(TBB_INTERFACE_VERSION 0) - FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS) - STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}") - set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}") -endif (TBB_FOUND) diff --git a/contrib/cmake/cmake/FindUSD.cmake b/contrib/cmake/cmake/FindUSD.cmake deleted file mode 100644 index 0b5354f5c6..0000000000 --- a/contrib/cmake/cmake/FindUSD.cmake +++ /dev/null @@ -1,75 +0,0 @@ -# Simple module to find USD. - -set(USD_LIB_NAME "libusd.so") -if( "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" ) - set(USD_LIB_NAME "usd.lib") -elseif( "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" ) - set(USD_LIB_NAME "libusd.dynlib") -endif() - -if (EXISTS "$ENV{USD_ROOT}") - set(USD_ROOT $ENV{USD_ROOT}) -endif () - -find_path(USD_INCLUDE_DIR pxr/pxr.h - PATHS ${USD_ROOT}/include - DOC "USD Include directory") - -find_path(USD_LIBRARY_DIR ${USD_LIB_NAME} - PATHS ${USD_ROOT}/lib - DOC "USD Libraries directory") - -#find_file(USD_GENSCHEMA -# names usdGenSchema -# PATHS ${USD_ROOT}/bin -# DOC "USD Gen schema application") - -if(USD_INCLUDE_DIR AND EXISTS "${USD_INCLUDE_DIR}/pxr/pxr.h") - foreach(_usd_comp MAJOR MINOR PATCH) - file(STRINGS - "${USD_INCLUDE_DIR}/pxr/pxr.h" - _usd_tmp - REGEX "#define PXR_${_usd_comp}_VERSION .*$") - string(REGEX MATCHALL "[0-9]+" USD_${_usd_comp}_VERSION ${_usd_tmp}) - endforeach() - set(USD_VERSION ${USD_MAJOR_VERSION}.${USD_MINOR_VERSION}.${USD_PATCH_VERSION}) -endif() - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - USD - REQUIRED_VARS - USD_INCLUDE_DIR - USD_LIBRARY_DIR -# USD_GENSCHEMA - VERSION_VAR - USD_VERSION) - -# USD libs -set( USD_LIBRARIES - ar - arch - gf - js - kind - pcp - plug - sdf - tf - trace - usd - vt -) - -# USD schema libs -set( USD_SCHEMA_LIBRARIES - usdGeom - usdHydra - usdLux - usdRi - usdShade - usdSkel - usdUI - usdUtils -) \ No newline at end of file diff --git a/contrib/for_review/MayaOp/publishCamera-1.py b/contrib/for_review/MayaOp/publishCamera-1.py deleted file mode 100644 index 33aa7546fe..0000000000 --- a/contrib/for_review/MayaOp/publishCamera-1.py +++ /dev/null @@ -1,123 +0,0 @@ -import os -import subprocess - -import IECore - -class MayaOp( IECore.Op ) : - - def __init__( self, description ) : - - IECore.Op.__init__( self, description, IECore.IntParameter( "result", "The return status.", 0 ) ) - - if self.mayaModule() is None : - - self.parameters().addParameters( - - [ - - IECore.FileNameParameter( - name = "mayaFile", - description = "The file to perform the publish from", - defaultValue = "", - check = IECore.FileNameParameter.CheckType.MustExist, - extensions = "ma mb", - ) - - ] - ) - - def doOperation( self, args ) : - - if self.mayaModule() is None : - - # really we'd expect a maya wrapper to take care of this, - # but just in case it isn't, make sure maya doesn't get - # launched with the wrong version of python. - env = os.environ.copy() - del env["PYTHONHOME"] - - serialisedArgs = IECore.ParameterParser().serialise( self.parameters() ) - # remove the mayaFile argument - del serialisedArgs[:2] - - pythonCommands = [ - "import IECore", - "op = IECore.ClassLoader.defaultLoader( 'IECORE_OP_PATHS' ).load( '%s', %d )" % ( self.path, self.version ), - "opInstance = op()", - "IECore.ParameterParser().parse( %s, opInstance.parameters() )" % str( serialisedArgs ), - "opInstance()", - ] - - melCommand = ";\n".join( [ "python( \"%s\" )" % c for c in pythonCommands ] ) - melCommand += ";\nquit -force;" - - f = open( "/tmp/test.mel", "w" ) - f.write( melCommand + "\n" ) - f.close() - - subprocess.check_call( [ "/software/maya/linux.centos6.x86_64/2012/bin/maya", "-batch", "-file", args["mayaFile"].value, "-script", "/tmp/test.mel" ], env = env ) - - return IECore.IntData( 0 ) - - else : - - return self.doMayaOperation( args ) - - def doMayaOperation( self, args ) : - - raise NotImplementedError - - __mayaModule = False - @classmethod - def mayaModule( cls ) : - - if cls.__mayaModule is False : - try : - cls.__mayaModule = __import__( "maya" ) - except ImportError : - cls.__mayaModule = None - - return cls.__mayaModule - -IECore.registerRunTimeTyped( MayaOp ) - - - - - - - - - - -class publishCamera( MayaOp ) : - - def __init__( self ) : - - MayaOp.__init__( self, "I publish cameras" ) - - self.parameters().addParameters( - - [ - - IECore.FileNameParameter( - name = "outputFile", - description = "Where the camera will be published", - defaultValue = "", - allowEmptyString = False, - ), - - ] - - ) - - def doMayaOperation( self, args ) : - - maya = self.mayaModule() - camera = maya.cmds.ls( type="camera" ) - maya.cmds.select( camera, replace=True ) - maya.cmds.file( args["outputFile"].value, exportSelected=True, typ="mayaAscii" ) - - return IECore.IntData( 0 ) - -IECore.registerRunTimeTyped( publishCamera ) diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/SkeletonPrimitive.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/SkeletonPrimitive.h deleted file mode 100644 index 1399405889..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/SkeletonPrimitive.h +++ /dev/null @@ -1,216 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORE_SKELETONPRIMITIVE_H -#define IECORE_SKELETONPRIMITIVE_H - -#include -#include - -#include "IECore/Primitive.h" -#include "IECore/TypedData.h" -#include "IECore/VectorTypedData.h" -#include "IECore/SimpleTypedData.h" - -#include "OpenEXR/ImathMatrixAlgo.h" - - -namespace IECore -{ - -IE_CORE_FORWARDDECLARE( SkeletonPrimitive ) - -/** Class that represent an entire skeletal structure. - * - * Internally this class stores two M44fVectorData, the first vector of matrices contains what I called @b default @b matrices - * and the second vector of matrices contained what I called @b local @b matrices. - * The default pose stores any pose required, often this is the bind pose or any other pose wanted for reference. - * Changing the local matrix over time will produce an animation. - * SkeletonPrimitive stores also a StringVectorData (the name of each joint) and an IntVectorData which containes all the parents id for each joint. - * For example a simple structure like this one: - * joint0 -> joint1 -> joint2, where "->" represent hierarchical relationship, the parent ids are -1, 0, 1 (-1 means no parent). - */ -class SkeletonPrimitive : public Primitive -{ - - public: - IE_CORE_DECLAREOBJECT( SkeletonPrimitive, Primitive ); - - /** Spaces that is possible to work in */ - enum Space { Local = 0, - World = 2 }; - - /** Generates an empty Skeleton */ - SkeletonPrimitive(); - /** Generates a copy of the given SkeletonPrimitivePtr */ - SkeletonPrimitive( ConstSkeletonPrimitivePtr other ); - /** Generates a new SkeletonPrimitive. - * - * @param poses - * a M44fVectorDataPtr containing the poses of each joint. - * These poses can be in Reference, Local or Global space (see below). - * @param parentIds - * The parents indices - * @param space - * Describe the space in which the given poses will be stored. - * If its value is Reference than the internal M44fVectorData that describes the reference poses will be set - * with these values and theM44fVectorData that represents the local poses will be set with identity matrices, - * if its value is Local, then the opposite of the previous operation will be performed. - * If its value is Global the Reference matrices will be all identity and the local ones will have an opportune value. */ - SkeletonPrimitive( ConstM44fVectorDataPtr poses, ConstIntVectorDataPtr parentIds, Space space=World); - - virtual void render( Renderer *renderer ) const; - virtual Imath::Box3f bound() const; - virtual size_t variableSize( PrimitiveVariable::Interpolation interpolation ) const; - - /** makes this SkeletonPrimitive a copy of the given one */ - void setAsCopyOf( ConstSkeletonPrimitivePtr other ); - /** Checks this SkeletonPrimitive's data is @b almost similar to the given SkeletonPrimitive's data, within an approximation of 1e-06f*/ - bool isSimilarTo( ConstObjectPtr other ) const; - - /** Adds another joint to this SkeletonPrimitive. - * - * @param parentId - * The id of the new joint's parent (-1 if there's no parent) - * @param name - * A name for this new joint */ - void addJoint(int parentId, std::string name="joint"); - /** Returns the number of joints contained in this SkeletonPrimitive */ - unsigned int numJoints() const { return m_defaultPose->readable().size(); } - - /** Sets the matrices of all the joints in this SkeletonPrimitive. - * - * @param poses - * a M44fVectorDataPtr containing the poses of each joint. - * These poses can be in Reference, Local or Global space - * @param space - * Describe the space in which the given poses will be stored. */ - - // TODO: should just be "setPose", as a pose is defined as an array of matrices in cortex - void setJointPoses( ConstM44fVectorDataPtr poses, Space space=World ); - /** Sets one single joint's matrix. - * - * @param jointId - * The Id of the joint is going to be changed - * @param pose - * The new "pose" for the joint. It can be in Reference, Local or World space. - * @param space - * Describe the space in which the given pose will be stored.*/ - void setJointPose( unsigned int jointId, ConstM44fDataPtr pose, Space space=World ); - - /** Gets all the joint's matrices in the specified space */ - // TODO: should just be "getPose", see above - M44fVectorDataPtr getJointPoses( Space space=World ); - /** Gets the matrix of one sigle joint in the specified space */ - M44fDataPtr getJointPose( unsigned int jointId, Space space=World ); - - // TODO: should just be "setDefaultPose", seeAbove - void setDefaultPoses( ConstM44fVectorDataPtr poses ); - // TODO: should just be "getDefaultPose", seeAbove - M44fVectorDataPtr getDefaultPoses(); - void applyDefaultPose(); - - IntVectorDataPtr getParentIds() const; - int getParentId( unsigned int jointId ) const; - IntVectorDataPtr getChildrenIds(unsigned int jointId) const; - - void setJointNames( const StringVectorDataPtr names ); - void setJointName( unsigned int jointId, const std::string &name ); - StringVectorDataPtr getJointNames() const; - std::string getJointName( unsigned int jointId ) const; - - /** Shares the Reference matrices with the given SkeletonPrimitive. - * This makes possible to have two or more SkeletonPrimitve with the same rest pose but different animation */ - void shareStaticData( SkeletonPrimitivePtr other ); - /** Shares the Local matrices with the given SkeletonPrimitive. - * This makes possible to have two or more SkeletonPrimitve with different rest pose but same animation */ - void shareAnimatableData( SkeletonPrimitivePtr other ); - - /** Recomputes the internal @b global matrices @b pulling the process from the joint with the given id @b up to the hierarchy structure. */ - void pullUpdate( unsigned int jointId ); - /** Recomputes the internal @b global matrices @b pushing the process from the joint with the given id @b down to the hierarchy structure. */ - void pushUpdate( unsigned int jointId ); - /** Searchs the hierarchy structure and find the root joint's id. The search starts form the joint with the given Id */ - int getRootJointId( unsigned int fromId=0 ) const; - - /** Recomputes the internal @b global matrices for the entire hierachycal structure. - * This is equivalent to call getRootJoint first and then use the id returned to call pushUpadate.*/ - void update(); - - /** Set the joints radius. - * @note: Only useful to render the joints */ - // TODO: should just be "setJointRadius", seeAbove - void setRadius(float radius); - /** Activate or deactivate an internal debug flag. - * @note: Only useful to render the joints, for example when this flag is set to true, it can display each joint axis */ - // TODO: should be a better name like, "glDisplayJointAxis" or something - void setDebug(bool debug); - // TODO: should be a better name like, "getJointRadius" or something - float getRadius(); - bool getDebug(); - - /** Generates a SkeletonPrimitives to represent a very simple and rough human skeleton. Particularly useful in quick tests */ - static SkeletonPrimitivePtr createHuman(); - - private: - static const unsigned int m_ioVersion; - - // ******* the hierarchy vectors ******* // - StringVectorDataPtr m_jointNames; - IntVectorDataPtr m_parentIds; - - // ******* a whole pose that acts as default pose for the character ******* // - M44fVectorDataPtr m_defaultPose; - - // ******* the matrix that represent the animation part ******* // - M44fVectorDataPtr m_localMatrices; - - // ******* internal storaged data for easy access ******* // - std::vector< std::vector > m_childrenIds; - M44fVectorDataPtr m_globalMatrices; - - // ******* useful to render the joints ******* // - bool m_jointsAxis; - float m_jointsRadius; - - void computeGlobalTransform(int jointId); - void setFromGlobalMatrices(int jointId, ConstM44fVectorDataPtr matrices); - - void synchVectorIds(); -}; - -} - -#endif // IECORE_SKELETONPRIMITIVE_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/TypeIds.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/TypeIds.h deleted file mode 100644 index a6ecb7fe42..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECore/TypeIds.h +++ /dev/null @@ -1,434 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORE_TYPEIDS_H -#define IE_CORE_TYPEIDS_H - -namespace IECore -{ - -enum TypeId -{ - InvalidTypeId = 0, - ObjectTypeId = 1, - DataTypeId = 2, - FloatVectorDataTypeId = 3, - DoubleVectorDataTypeId = 4, - IntVectorDataTypeId = 5, - UIntVectorDataTypeId = 6, - CharVectorDataTypeId = 7, - UCharVectorDataTypeId = 8, - V2fVectorDataTypeId = 9, - V2dVectorDataTypeId = 10, - V3fVectorDataTypeId = 11, - V3dVectorDataTypeId = 12, - Box3fVectorDataTypeId = 13, - Box3dVectorDataTypeId = 14, - M33fVectorDataTypeId = 15, - M33dVectorDataTypeId = 16, - M44fVectorDataTypeId = 17, - M44dVectorDataTypeId = 18, - QuatfVectorDataTypeId = 19, - QuatdVectorDataTypeId = 20, - StringVectorDataTypeId = 21, - FloatDataTypeId = 22, - DoubleDataTypeId = 23, - IntDataTypeId = 24, - LongDataTypeId = 25, /// Obsolete: LongData has been removed. The typeId remains for compatibility with old files, which now load as IntData - UIntDataTypeId = 26, - CharDataTypeId = 27, - UCharDataTypeId = 28, - StringDataTypeId = 29, - LongVectorDataTypeId = 30, /// Obsolete: LongVectorData has been removed. The typeId remains for compatibility with old files, which now load as IntVectorData - CompoundDataTypeId = 31, - V2fDataTypeId = 32, - V3fDataTypeId = 33, - V2dDataTypeId = 34, - V3dDataTypeId = 35, - Box2fDataTypeId = 36, - Box3fDataTypeId = 37, - Box2dDataTypeId = 38, - Box3dDataTypeId = 39, - M44fDataTypeId = 40, - M44dDataTypeId = 41, - QuatfDataTypeId = 42, - QuatdDataTypeId = 43, - Color3fDataTypeId = 44, - Color4fDataTypeId = 45, - Color3dDataTypeId = 46, - Color4dDataTypeId = 47, - Color3fVectorDataTypeId = 48, - Color4fVectorDataTypeId = 49, - Color3dVectorDataTypeId = 50, - Color4dVectorDataTypeId = 51, - BlindDataHolderTypeId = 52, - RenderableTypeId = 53, - ParameterListTypeId = 54, // Obsolete - CompoundObjectTypeId = 55, - M33fDataTypeId = 56, - M33dDataTypeId = 57, - Box2fVectorDataTypeId = 58, - Box2dVectorDataTypeId = 59, - BoolDataTypeId = 60, - PrimitiveTypeId = 61, - PointsPrimitiveTypeId = 62, - ImagePrimitiveTypeId = 63, - Box2iDataTypeId = 64, - HalfVectorDataTypeId = 65, - V2iDataTypeId = 66, - MeshPrimitiveTypeId = 67, - ShaderTypeId = 68, - RunTimeTypedTypeId = 69, - ParameterTypeId = 70, - CompoundParameterTypeId = 71, - StringParameterTypeId = 72, - ValidatedStringParameterTypeId = 73, - FileNameParameterTypeId = 74, - IntParameterTypeId = 75, - FloatParameterTypeId = 76, - DoubleParameterTypeId = 77, - BoolParameterTypeId = 78, - V2fParameterTypeId = 79, - V3fParameterTypeId = 80, - V2dParameterTypeId = 81, - V3dParameterTypeId = 82, - Color3fParameterTypeId = 83, - Color4fParameterTypeId = 84, - Box2iParameterTypeId = 85, - Box2fParameterTypeId = 86, - Box3fParameterTypeId = 87, - Box2dParameterTypeId = 88, - Box3dParameterTypeId = 89, - M44fParameterTypeId = 90, - M44dParameterTypeId = 91, - IntVectorParameterTypeId = 92, - FloatVectorParameterTypeId = 93, - DoubleVectorParameterTypeId = 94, - StringVectorParameterTypeId = 95, - V2fVectorParameterTypeId = 96, - V3fVectorParameterTypeId = 97, - V2dVectorParameterTypeId = 98, - V3dVectorParameterTypeId = 99, - Box3fVectorParameterTypeId = 100, - Box3dVectorParameterTypeId = 101, - M33fVectorParameterTypeId = 102, - M44fVectorParameterTypeId = 103, - M33dVectorParameterTypeId = 104, - M44dVectorParameterTypeId = 105, - QuatfVectorParameterTypeId = 106, - QuatdVectorParameterTypeId = 107, - Color3fVectorParameterTypeId = 108, - Color4fVectorParameterTypeId = 109, - NullObjectTypeId = 110, - ParameterisedTypeId = 111, - OpTypeId = 112, - ReaderTypeId = 113, - WriterTypeId = 114, - ImageReaderTypeId = 115, - ImageWriterTypeId = 116, - CINImageReaderTypeId = 117, - CINImageWriterTypeId = 118, - EXRImageReaderTypeId = 119, - EXRImageWriterTypeId = 120, - JPEGImageReaderTypeId = 121, - JPEGImageWriterTypeId = 122, - TIFFImageReaderTypeId = 123, - TIFFImageWriterTypeId = 124, - ObjectReaderTypeId = 125, - ObjectWriterTypeId = 126, - PDCParticleReaderTypeId = 127, - PDCParticleWriterTypeId = 128, - PathParameterTypeId = 129, - DirNameParameterTypeId = 130, - V3iDataTypeId = 131, - RendererTypeId = 132, - Box3iDataTypeId = 133, - ObjectParameterTypeId = 134, - ModifyOpTypeId = 135, - ImageOpTypeId = 136, - PrimitiveOpTypeId = 137, - ProceduralTypeId = 138, // Obsolete - Box3iParameterTypeId = 139, - V2iParameterTypeId = 140, - V3iParameterTypeId = 141, - ParticleReaderTypeId = 142, - ParticleWriterTypeId = 143, - MotionPrimitiveTypeId = 144, - DPXImageReaderTypeId = 145, - TransformTypeId = 146, - MatrixTransformTypeId = 147, - MotionTransformTypeId = 148, - MatrixMotionTransformTypeId = 149, - GroupTypeId = 150, - AttributeStateTypeId = 151, - VisibleRenderableTypeId = 152, - StateRenderableTypeId = 153, - OBJReaderTypeId = 154, - TransformationMatrixfDataTypeId = 155, - TransformationMatrixdDataTypeId = 156, - PointNormalsOpTypeId = 157, - PointDensitiesOpTypeId = 158, - DPXImageWriterTypeId = 159, - BoolVectorDataTypeId = 160, - VectorDataFilterOpTypeId = 161, - RenderableParameterTypeId = 162, - StateRenderableParameterTypeId = 163, - AttributeStateParameterTypeId = 164, - ShaderParameterTypeId = 165, - TransformParameterTypeId = 166, - MatrixMotionTransformParameterTypeId = 167, - MatrixTransformParameterTypeId = 168, - VisibleRenderableParameterTypeId = 169, - GroupParameterTypeId = 170, - MotionPrimitiveParameterTypeId = 171, - PrimitiveParameterTypeId = 172, - ImagePrimitiveParameterTypeId = 173, - MeshPrimitiveParameterTypeId = 174, - PointsPrimitiveParameterTypeId = 175, - PreWorldRenderableTypeId = 176, - CameraTypeId = 177, - NURBSPrimitiveTypeId = 178, - DataCastOpTypeId = 179, - DataPromoteOpTypeId = 180, - MatrixMultiplyOpTypeId = 181, - PointBoundsOpTypeId = 182, - RandomRotationOpTypeId = 183, - V2iVectorDataTypeId = 184, - V3iVectorDataTypeId = 185, - PointMeshOpTypeId = 186, - ParticleMeshOpTypeId = 187, - HalfDataTypeId = 188, - MeshPrimitiveOpTypeId = 189, - PrimitiveEvaluatorTypeId = 190, - MeshPrimitiveEvaluatorTypeId = 191, - MeshPrimitiveImplicitSurfaceOpTypeId = 192, - TriangulateOpTypeId = 193, - SpherePrimitiveEvaluatorTypeId = 194, - SpherePrimitiveTypeId = 195, - ConverterTypeId = 196, - ToCoreConverterTypeId = 197, - ImageCropOpTypeId = 198, - MeshPrimitiveShrinkWrapOpTypeId = 199, - ImagePrimitiveEvaluatorTypeId = 200, - FromCoreConverterTypeId = 201, - ShortDataTypeId = 202, - UShortDataTypeId = 203, - ShortVectorDataTypeId = 204, - UShortVectorDataTypeId = 205, - PathVectorParameterTypeId = 206, - ColorTransformOpTypeId = 207, - TransformOpTypeId = 208, - ImageDiffOpTypeId = 209, - CurvesPrimitiveTypeId = 210, - CoordinateSystemTypeId = 211, - MeshNormalsOpTypeId = 212, - MeshMergeOpTypeId = 213, - FontTypeId = 214, - UniformRandomPointDistributionOpTypeId = 215, - Int64DataTypeId = 216, - UInt64DataTypeId = 217, - Int64VectorDataTypeId = 218, - UInt64VectorDataTypeId = 219, - MappedRandomPointDistributionOpTypeId = 220, - PointRepulsionOpTypeId = 221, - LuminanceOpTypeId = 222, - ImagePrimitiveOpTypeId = 223, - ChannelOpTypeId = 224, - SummedAreaOpTypeId = 225, - GradeTypeId = 226, - Box2iVectorDataTypeId = 227, - Box3iVectorDataTypeId = 228, - MedianCutSamplerTypeId = 229, - EnvMapSamplerTypeId = 230, - MeshVertexReorderOpTypeId = 231, - SplineffDataTypeId = 232, - SplineddDataTypeId = 233, - SplinefColor3fDataTypeId = 234, - SplinefColor4fDataTypeId = 235, - SplineffParameterTypeId = 236, - SplineddParameterTypeId = 237, - SplinefColor3fParameterTypeId = 238, - SplinefColor4fParameterTypeId = 239, - CompoundObjectParameterTypeId = 240, - DisplayDriverTypeId = 241, - DisplayDriverCreatorTypeId = 242, - ImageDisplayDriverTypeId = 243, - DisplayDriverServerTypeId = 244, - ClientDisplayDriverTypeId = 245, - SplineToImageTypeId = 246, - DisplayTypeId = 247, - MeshTangentsOpTypeId = 248, - WarpOpTypeId = 249, - UVDistortOpTypeId = 250, - LinearToSRGBOpTypeId = 251, - SRGBToLinearOpTypeId = 252, - LinearToCineonOpTypeId = 253, - CineonToLinearOpTypeId = 254, - CubeColorTransformOpTypeId = 255, - CubeColorLookupfDataTypeId = 256, - CubeColorLookupdDataTypeId = 257, - CubeColorLookupfParameterTypeId = 258, - CubeColorLookupdParameterTypeId = 259, - BoolVectorParameterTypeId = 260, - LinearToRec709OpTypeId = 261, - Rec709ToLinearOpTypeId = 262, - ObjectVectorTypeId = 263, - ObjectVectorParameterTypeId = 264, - YUVImageWriterTypeId = 265, - ImageCompositeOpTypeId = 266, - ImagePremultiplyOpTypeId = 267, - ImageUnpremultiplyOpTypeId = 268, - DateTimeDataTypeId = 269, - DateTimeParameterTypeId = 270, - SGIImageReaderTypeId = 271, - TimeDurationDataTypeId = 272, - TimeDurationParameterTypeId = 273, - TimePeriodDataTypeId = 274, - TimePeriodParameterTypeId = 275, - PatchMeshPrimitiveTypeId = 276, - CurvesPrimitiveParameterTypeId = 277, - CurveExtrudeOpTypeId = 278, - FrameListTypeId = 279, - EmptyFrameListTypeId = 280, - FrameRangeTypeId = 281, - CompoundFrameListTypeId = 282, - ReorderedFrameListTypeId = 283, - BinaryFrameListTypeId = 284, - ReversedFrameListTypeId = 285, - ExclusionFrameListTypeId = 286, - FrameListParameterTypeId = 287, - FileSequenceTypeId = 288, - FileSequenceParameterTypeId = 289, - FileSequenceVectorParameterTypeId = 290, - ParameterisedProceduralTypeId = 291, - ColorSpaceTransformOpTypeId = 292, - TGAImageReaderTypeId = 293, - TGAImageWriterTypeId = 294, - BINParticleReaderTypeId = 295, - BINParticleWriterTypeId = 296, - BINMeshReaderTypeId = 297, - BGEOParticleReaderTypeId = 298, - NParticleReaderTypeId = 299, - IFFImageReaderTypeId = 300, - IFFHairReaderTypeId = 301, - FaceAreaOpTypeId = 302, - CurvesMergeOpTypeId = 303, - CurvesPrimitiveOpTypeId = 304, - CurvesPrimitiveEvaluatorTypeId = 305, - HdrMergeOpTypeId = 306, - HitMissTransformTypeId = 307, - CurveTracerTypeId = 308, - ImageThinnerTypeId = 309, - CurveLineariserTypeId = 310, - CompoundDataBaseTypeId = 311, - ImageConvolveOpTypeId = 312, - ClassParameterTypeId = 313, - ClassVectorParameterTypeId = 314, - CurveTangentsOpTypeId = 315, - MarschnerParameterTypeId = 316, - MarschnerLookupTableOpTypeId = 317, - SmoothSkinningDataTypeId = 318, - FaceVaryingPromotionOpTypeId = 319, - MeshDistortionsOpTypeId = 320, - PointVelocityDisplaceOpTypeId = 321, - SmoothSkinningDataParameterTypeId = 322, - CompressSmoothSkinningDataOpTypeId = 323, - DecompressSmoothSkinningDataOpTypeId = 324, - NormalizeSmoothSkinningWeightsOpTypeId = 325, - ReorderSmoothSkinningInfluencesOpTypeId = 326, - RemoveSmoothSkinningInfluencesOpTypeId = 327, - SmoothSmoothSkinningWeightsOpTypeId = 328, - MixSmoothSkinningWeightsOpTypeId = 329, - PointSmoothSkinningOpTypeId = 330, - - // Skeleton Primitive - SkeletonPrimitiveTypeId = 331, - SkeletonPrimitiveParameterTypeId = 332, - SkeletonPrimitiveOpTypeId = 333, - MatrixModifyOpTypeId = 334, - - MeshPrimitiveSmoothSkinningOpTypeId = 335, - - AddSmoothSkinningInfluencesOpTypeId = 336, - LimitSmoothSkinningInfluencesOpTypeId = 337, - PointsPrimitiveEvaluatorTypeId = 338, - TransformationMatrixfParameterTypeId = 339, - TransformationMatrixdParameterTypeId = 340, - // Remember to update TypeIdBinding.cpp !!! - - // If we ever get this far then the core library is too big. - LastCoreTypeId = 99999, - // All RunTimeTyped derived classes in extension - // libraries should use a TypeId in the following range. - // Don't put the TypeId in here. For python derived classes use - // the registerTypeId function in RunTimeTypedUtil.py to register the - // TypeId into the python TypeId enum and check for conflicts. - FirstExtensionTypeId = 100000, - - FirstCoreDynamicsTypeId = 104000, - LastCoreDynamicsTypeId = 104999, - - FirstCoreGLTypeId = 105000, - LastCoreGLTypeId = 105999, - - FirstCoreRITypeId = 106000, - LastCoreRITypeId = 106999, - - FirstCoreNukeTypeId = 107000, - LastCoreNukeTypeId = 107999, - - FirstCoreTruelightTypeId = 108000, - LastCoreTruelightTypeId = 108999, - - FirstCoreMayaTypeId = 109000, - LastCoreMayaTypeId = 109999, - - FirstIERenderTypeId = 110000, - LastIERenderTypeId = 110499, - - // TypeIds dynamically allocated by registerRunTimeTyped (IECore Python) - FirstDynamicTypeId = 300000, - LastDynamicTypeId = 399999, - - LastExtensionTypeId = 399999, - // Any TypeIds beyond this point can be considered safe for private internal use. - -}; - -} // namespace IECore - -#endif // IE_CORE_TYPEIDS_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/ConePrimitive.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/ConePrimitive.h deleted file mode 100644 index e9ac44531e..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/ConePrimitive.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREGL_CONEPRIMITIVE_H -#define IECOREGL_CONEPRIMITIVE_H - -#include "IECoreGL/Primitive.h" - -namespace IECoreGL -{ - -class ConePrimitive : public Primitive -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( IECoreGL::ConePrimitive, ConePrimitiveTypeId, Primitive ); - - ConePrimitive( float height = 1, float radius = .5, float thetaMax = 360 ); - virtual ~ConePrimitive(); - - void setRadius( float radius ){ m_radius = radius; } - float getRadius() const { return m_radius; } - - void setHeight( float height ){ m_height = height; } - float getHeight() const { return m_height; } - - void setThetaMax( float thetaMax ){ m_thetaMax = thetaMax; } - float getThetaMax() const { return m_thetaMax; } - - virtual Imath::Box3f bound() const; - - protected : - - virtual void render( ConstStatePtr state, IECore::TypeId style ) const; - - private : - - float m_radius; - float m_height; - float m_thetaMax; - - // So SkeletonPrimitive can use the protected render() - friend class SkeletonPrimitive; - -}; - -IE_CORE_DECLAREPTR( ConePrimitive ); - -} // namespace IECoreGL - -#endif // IECOREGL_CONEPRIMITIVE_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/JointPrimitive.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/JointPrimitive.h deleted file mode 100644 index 37d0b72261..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/JointPrimitive.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREGL_JOINTRIMITIVE_H -#define IECOREGL_JOINTPRIMITIVE_H - -#include "OpenEXR/ImathVec.h" -#include "IECoreGL/Primitive.h" - -namespace IECoreGL -{ - -class JointPrimitive : public Primitive -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( IECoreGL::JointPrimitive, JointPrimitiveTypeId, Primitive ); - - - JointPrimitive( float radius = 1.0, float length = 1.0 ); - virtual ~JointPrimitive(); - - void setRadius( float radius ); - float getRadius() const; - - void setLength( float length ); - float getLength() const; - - virtual Imath::Box3f bound() const; - virtual void addPrimitiveVariable( const std::string &name, const IECore::PrimitiveVariable &primVar ); - - protected : - - virtual void render( const State *state, IECore::TypeId style ) const; - - private : - - Imath::V3f p0 , p1, p2, p3, p4, p5; - - - friend class SkeletonPrimitive; - -}; - -IE_CORE_DECLAREPTR( JointPrimitive ); - -} // namespace IECoreGL - -#endif // IECOREGL_JOINTPRIMITIVE_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/SkeletonPrimitive.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/SkeletonPrimitive.h deleted file mode 100644 index 6fd02f75fb..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/SkeletonPrimitive.h +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREGL_SKELETONPRIMITIVE_H -#define IECOREGL_SKELETONPRIMITIVE_H - -#include "IECoreGL/Primitive.h" -#include "IECoreGL/JointPrimitive.h" -#include "IECore/TypedData.h" -#include "IECore/VectorTypedData.h" -#include "IECore/SimpleTypedData.h" - - -namespace IECoreGL -{ - -class SkeletonPrimitive : public Primitive -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( IECoreGL::SkeletonPrimitive, SkeletonPrimitiveTypeId, Primitive ); - - SkeletonPrimitive(); - SkeletonPrimitive( - IECore::ConstM44fVectorDataPtr globalMatrices, IECore::ConstIntVectorDataPtr parentIds, - bool displayAxis, float jointsSize, - const IECore::PrimitiveVariableMap &primVars); - virtual ~SkeletonPrimitive(); - - virtual Imath::Box3f bound() const; - virtual void addPrimitiveVariable( const std::string &name, const IECore::PrimitiveVariable &primVar ); - - protected : - - virtual void render( const State *state, IECore::TypeId style ) const; - - private : - std::vector< std::vector > m_childrenIds; - - IECore::IntVectorDataPtr m_parentIds; - IECore::M44fVectorDataPtr m_globalMatrices; - - Imath::Box3f m_bound; - - bool m_jointsAxis; - float m_jointsRadius; - - void synchVectorIds(); -}; - -IE_CORE_DECLAREPTR( SkeletonPrimitive ); - -} // namespace IECoreGL - -#endif // IECOREGL_SKELETONPRIMITIVE_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/TypeIds.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/TypeIds.h deleted file mode 100644 index 82a16f754b..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/TypeIds.h +++ /dev/null @@ -1,122 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREGL_TYPEIDS_H -#define IE_COREGL_TYPEIDS_H - -namespace IECoreGL -{ - -enum TypeId -{ - StateTypeId = 105000, - StateComponentTypeId = 105001, - PrimitiveBoundTypeId = 105002, - PrimitiveWireframeTypeId = 105003, - PrimitiveSolidTypeId = 105004, - PrimitiveOutlineTypeId = 105005, - RenderableTypeId = 105006, - BindableTypeId = 105007, - TextureTypeId = 105008, - RendererTypeId = 105009, - ShaderTypeId = 105010, - PrimitiveTypeId = 105011, - PointsPrimitiveTypeId = 105012, - DiskPrimitiveTypeId = 105013, - MeshPrimitiveTypeId = 105014, - QuadPrimitiveTypeId = 105015, - SpherePrimitiveTypeId = 105016, - BoxPrimitiveTypeId = 105017, - RendererImplementationTypeId = 105018, - DeferredRendererImplementationTypeId = 105019, - PrimitiveWireframeWidthTypeId = 105020, - PrimitiveOutlineWidthTypeId = 105021, - PrimitivePointsTypeId = 105022, - PrimitivePointWidthTypeId = 105023, - ColorTypeId = 105024, - ShaderStateComponentTypeId = 105025, - FrameBufferTypeId = 105026, - DepthTextureTypeId = 105027, - ColorTextureTypeId = 105028, - ImmediateRendererImplementationTypeId = 105029, - BlendFuncStateComponentTypeId = 105030, - BlendColorStateComponentTypeId = 105031, - BlendEquationStateComponentTypeId = 105032, - TransparentShadingStateComponentTypeId = 105033, - PrimitiveTransparencySortStateComponentTypeId = 105034, - BoundColorStateComponentTypeId = 105035, - WireframeColorStateComponentTypeId = 105036, - OutlineColorStateComponentTypeId = 105037, - PointColorStateComponentTypeId = 105038, - CameraTypeId = 105039, - OrthographicCameraTypeId = 105040, - PerspectiveCameraTypeId = 105041, - PointsPrimitiveUseGLPointsTypeId = 105042, - PointsPrimitiveGLPointWidthTypeId = 105043, - NameStateComponentTypeId = 105044, - ToGLConverterTypeId = 105045, - ToGLCameraConverterTypeId = 105046, - DoubleSidedStateComponentTypeId = 105047, - RightHandedOrientationStateComponentTypeId = 105048, - CurvesPrimitiveTypeId = 105049, - CurvesPrimitiveGLLineWidthTypeId = 105050, - CurvesPrimitiveUseGLLinesTypeId = 105051, - CurvesPrimitiveIgnoreBasisTypeId = 105052, - ToGLMeshConverterTypeId = 105053, - FontTypeId = 105054, - TextPrimitiveTypeId = 105055, - PointSmoothingStateComponentTypeId = 105056, - LineSmoothingStateComponentTypeId = 105057, - PolygonSmoothingStateComponentTypeId = 105058, - LuminanceTextureTypeId = 105059, - AlphaTextureTypeId = 105060, - GroupTypeId = 105061, - SceneTypeId = 105062, - TextPrimitiveTypeTypeId = 105063, - ToGLCurvesConverterTypeId = 105064, - ToGLTextureConverterTypeId = 105065, - SplineToGLTextureConverterTypeId = 105066, - CullingSpaceStateComponentTypeId = 105067, - CullingBoxStateComponentTypeId = 105068, - ToGLPointsConverterTypeId = 105069, - ProceduralThreadingStateComponentTypeId = 105070, - SkeletonPrimitiveTypeId = 105071, - ConePrimitiveTypeId = 105072, - JointPrimitiveTypeId = 105073, - LastCoreGLTypeId = 105999, -}; - -} // namespace IECoreGL - -#endif // IE_COREGL_TYPEIDS_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/bindings/JointPrimitiveBinding.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/bindings/JointPrimitiveBinding.h deleted file mode 100644 index 001298c711..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECoreGL/bindings/JointPrimitiveBinding.h +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREGL_JOINTPRIMITIVEBINDING_H -#define IE_COREGL_JOINTPRIMITIVEBINDING_H - -#include "IECoreGL/JointPrimitive.h" - -namespace IECoreGL -{ - -void bindJointPrimitive(); - -} - -#endif // IE_COREGL_JOINTPRIMITIVEBINDING_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/include/IECorePython/SkeletonPrimitiveBinding.h b/contrib/for_review/SkeletonPrimitive_DrD/include/IECorePython/SkeletonPrimitiveBinding.h deleted file mode 100644 index ff8b8a23e3..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/include/IECorePython/SkeletonPrimitiveBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREPYTHON_SKELETONPRIMITIVEBINDING_H -#define IE_COREPYTHON_SKELETONPRIMITIVEBINDING_H - -#include "IECore/Interpolator.h" - -namespace IECorePython { - void bindSkeletonPrimitive(); -} - -#endif // IE_COREPYTHON_SKELETONPRIMITIVEBINDING_H diff --git a/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/exportSkeletonFromMaya.py b/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/exportSkeletonFromMaya.py deleted file mode 100644 index 69d49a8540..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/exportSkeletonFromMaya.py +++ /dev/null @@ -1,44 +0,0 @@ -########################################################################## -# -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - - def exportSekelton(self): - self.skeleton = skeletonPrimitiveIO.generateCrowdSkeletonFromMayaSkeleton(skeletonPrimitiveIO.autoSearchMayaMainJoint()) - skeletonPrimitiveIO.saveSkeletonPrimitive(self.skeleton, path.join(self.commonDir, "skeleton", self.charName + ".skel.cob")) - - -#TODO: would be nice if this was a proper FromMayaConverter (that would probably take the root joint as an argument) -# -# \ No newline at end of file diff --git a/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/skeletonPrimitivesUtilities/__init__.py b/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/skeletonPrimitivesUtilities/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/skeletonPrimitivesUtilities/skeletonPrimitiveIO.py b/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/skeletonPrimitivesUtilities/skeletonPrimitiveIO.py deleted file mode 100644 index f77255b1fb..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/py_SkeletonPrimitiveIO/skeletonPrimitivesUtilities/skeletonPrimitiveIO.py +++ /dev/null @@ -1,96 +0,0 @@ -import os, sys, math -import IECore - -isRunningInMaya = True -try: - from maya import cmds, OpenMaya -except: - isRunningInMaya = False - - -def autoSearchMayaMainJoint(): - if not isRunningInMaya: - sys.stderr.write('WARNING: the function autoSearchMayaMainJoint cannot be called, because maya is not available in the environment this script is running into') - return - - skeletonGroup = 'C_grp_rig_0|C_grp_skeleton_0' - if not cmds.objExists(skeletonGroup): - raise Exception, 'object %s not present in scene. you can still passing by hand a valid maya\'s joint name' %skeletonGroup - - children = cmds.listRelatives(skeletonGroup, typ='joint', fullPath=True) - if not children: - raise Exception, 'a joint couldn\'t be found in C_grp_rig_0|C_grp_skeleton_0' - else: - return children[0] - - -def generateCrowdSkeletonFromMayaSkeleton(mainMayaJoint, shortNames=True): - if not isRunningInMaya: - sys.stderr.write('WARNING: the function generateCrowdSkeletonFromMayaSkeleton cannot be called, because maya is not available in the environment this script is running into') - return - - data = {'parentIdsList' : IECore.IntVectorData(), - 'localMatList' : IECore.M44fVectorData(), - 'names' : IECore.StringVectorData()} - - def populateData(mayaJoint, jointId, parentId, data): - data['parentIdsList'].append( parentId ) - data['names'].append(cmds.ls(mayaJoint, sn = shortNames)[0]) - - data['localMatList'].append( IECore.M44f( cmds.getAttr(mayaJoint+'.m', t=0) ) ) - - children = cmds.listRelatives(mayaJoint, allDescendents=False, fullPath=True, typ='joint') - if children: - for child in children: - populateData(child, data['parentIdsList'].size(), jointId, data) - - if not mainMayaJoint: - mainMayaJoint = autoSearchMayaMainJoint() - populateData(mainMayaJoint, 0, -1, data) - skeleton = IECore.SkeletonPrimitive(data['localMatList'], data['parentIdsList'], IECore.SkeletonPrimitive.Space.Local) - skeleton.setJointNames(data['names']) - - skeleton.update() - - return skeleton - - -def saveSkeletonPrimitive(skelPrim, filePath): - writer = IECore.Writer.create(skelPrim, filePath) - writer.write() - -def loadSkeletonPrimitive(filePath): - reader = IECore.Reader.create(filePath) - return reader.read() - - -def saveAnimationFromMaya(topJoint, fromFrame, toFrame, outputPath, fileName, toCache=True): - if not isRunningInMaya: - sys.stderr.write('WARNING: the function saveAnimationFromMaya cannot be called, because maya is not available in the environment this script is running into') - return - - def populateData(mayaJoint, jointId, parentId, data, frame): - data.append( IECore.M44f( cmds.getAttr(mayaJoint+'.m', t=frame) ) ) - children = cmds.listRelatives(mayaJoint, allDescendents=False, fullPath=True, typ='joint') - if children: - for child in children: - populateData(child, data.size(), jointId, data, frame) - - for i in range(fromFrame, toFrame+1): - cmds.currentTime(i) - data = IECore.M44fVectorData() - - populateData(topJoint, 0, -1, data, i) - - # two possible file format, depends by the final use. maybe will be useful to expand cortex to provide one single file format that can be use - # with caching and interpolation - if toCache: - ac = IECore.ObjectWriter(data, os.path.join(outputPath, fileName)+".%04d.anim" %i ) - ac.write( ) - del ac - else: - ac = IECore.AttributeCache( os.path.join(outputPath, fileName)+".%04d.anim" %ii, IECore.IndexedIOOpenMode.Write ) - ac.write( "our_object", "our_attribute", data ) - del ac - - diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECore/SkeletonPrimitive.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECore/SkeletonPrimitive.cpp deleted file mode 100644 index e79ecf0cf8..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECore/SkeletonPrimitive.cpp +++ /dev/null @@ -1,666 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/SkeletonPrimitive.h" -#include "IECore/Renderer.h" - -#include -#include - -using namespace std; -using namespace IECore; -using namespace Imath; -using namespace boost; - -const unsigned int SkeletonPrimitive::m_ioVersion = 0; -IE_CORE_DEFINEOBJECTTYPEDESCRIPTION(SkeletonPrimitive); - - -SkeletonPrimitive::SkeletonPrimitive() : - m_jointNames(new StringVectorData), m_parentIds(new IntVectorData), - m_defaultPose(new M44fVectorData), m_localMatrices(new M44fVectorData), m_globalMatrices(new M44fVectorData) -{ - m_jointsAxis = false; - m_jointsRadius = 1.0; -} - - -SkeletonPrimitive::SkeletonPrimitive( ConstSkeletonPrimitivePtr other ) : - m_jointNames(new StringVectorData), m_parentIds(new IntVectorData), - m_defaultPose(new M44fVectorData), m_localMatrices(new M44fVectorData), m_globalMatrices(new M44fVectorData) -{ - m_jointNames = other->m_jointNames->copy(); - m_parentIds = other->m_parentIds->copy(); - - m_defaultPose = other->m_defaultPose->copy(); - m_localMatrices = other->m_localMatrices->copy(); - m_globalMatrices = other->m_globalMatrices->copy(); - - synchVectorIds(); - update(); - - m_jointsAxis = false; - m_jointsRadius = 1.0; -} - - -SkeletonPrimitive::SkeletonPrimitive( ConstM44fVectorDataPtr poses, ConstIntVectorDataPtr parentIds, Space space) : - m_jointNames(new StringVectorData), m_parentIds(new IntVectorData), - m_defaultPose(new M44fVectorData), m_localMatrices(new M44fVectorData), m_globalMatrices(new M44fVectorData) -{ - if ( poses->readable().size() != parentIds->readable().size() ) - throw Exception( "Bad topology - skeleton parents must equal bones!" ); - - m_parentIds = parentIds->copy(); - - int newSize = poses->readable().size(); - - m_jointNames->writable().resize(newSize); - - synchVectorIds(); - - std::stringstream ss; - for (int i=0; iwritable()[i] = "joint"+ss.str(); - } - - switch(space) - { - case SkeletonPrimitive::Local : - m_localMatrices = poses->copy(); - m_defaultPose = m_localMatrices->copy(); - break; - - case SkeletonPrimitive::World : - m_localMatrices->writable().resize(newSize); - m_globalMatrices->writable().resize(newSize); - for (int i=0; iwritable()[i].makeIdentity(); - } - - int rootId = getRootJointId(0); - setFromGlobalMatrices(rootId, poses); - m_defaultPose = m_localMatrices->copy(); - break; - } - update(); - - m_jointsAxis = false; - m_jointsRadius = 1.0; -} - - -void SkeletonPrimitive::setRadius(float radius) -{ - m_jointsRadius = radius; -} - -void SkeletonPrimitive::setDebug(bool debug) -{ - m_jointsAxis = debug; -} - -float SkeletonPrimitive::getRadius() -{ - return m_jointsRadius; -} - -bool SkeletonPrimitive::getDebug() -{ - return m_jointsAxis; -} - -/** @note: remember to call update before any call to this one */ -Imath::Box3f SkeletonPrimitive::bound() const -{ - Imath::Box3f bbox; - for (unsigned int i=0; ireadable()[i].translation() ); - } - - return bbox; -} - -size_t SkeletonPrimitive::variableSize( PrimitiveVariable::Interpolation interpolation ) const -{ - switch(interpolation) - { - case PrimitiveVariable::Constant : - return 1; - - case PrimitiveVariable::Uniform : - return 1; - - case PrimitiveVariable::Vertex : - return numJoints(); - - case PrimitiveVariable::Varying: - return numJoints(); - - case PrimitiveVariable::FaceVarying: - return numJoints(); - - default : - return 0; - } -} - - - -/** @note: remember to call update before any call to this one */ -void SkeletonPrimitive::render( Renderer *renderer ) const -{ - renderer->skeleton( m_globalMatrices, m_parentIds, m_jointsAxis, m_jointsRadius, variables ); -} - - -void SkeletonPrimitive::copyFrom( const Object *other, IECore::Object::CopyContext *context ) -{ - Primitive::copyFrom( other, context ); - const SkeletonPrimitive *tOther = static_cast( other ); - - m_jointNames = tOther->m_jointNames->copy(); - m_parentIds = tOther->m_parentIds->copy(); - - m_defaultPose = tOther->m_defaultPose->copy(); - m_localMatrices = tOther->m_localMatrices->copy(); - m_globalMatrices = tOther->m_globalMatrices->copy(); - - synchVectorIds(); -} - - -void SkeletonPrimitive::setAsCopyOf( ConstSkeletonPrimitivePtr other ) -{ - m_jointNames = other->m_jointNames->copy(); - m_parentIds = other->m_parentIds->copy(); - - m_defaultPose = other->m_defaultPose->copy(); - m_localMatrices = other->m_localMatrices->copy(); - m_globalMatrices = other->m_globalMatrices->copy(); - - synchVectorIds(); -} - -void SkeletonPrimitive::save( IECore::Object::SaveContext *context ) const -{ - Primitive::save(context); - IndexedIOInterfacePtr container = context->container( staticTypeName(), m_ioVersion ); - context->save( m_jointNames, container, "names" ); - context->save( m_parentIds, container, "parentIds" ); - context->save( m_defaultPose, container, "defaultPose" ); - context->save( m_localMatrices, container, "localMatrices" ); -} - - -void SkeletonPrimitive::load( IECore::Object::LoadContextPtr context ) -{ - Primitive::load(context); - unsigned int v = m_ioVersion; - - IndexedIOInterfacePtr container = context->container( staticTypeName(), v ); - - m_jointNames = context->load( container, "names" ); - m_parentIds = context->load( container, "parentIds" ); - - m_localMatrices = context->load( container, "localMatrices" ); - - try // try to load new SkeletonPrimitives - { - m_defaultPose = context->load( container, "defaultPose" ); - } - catch(Exception) { - m_defaultPose = m_localMatrices->copy(); - } - - - int newSize = numJoints(); - m_globalMatrices->writable().resize(newSize); - - synchVectorIds(); - update(); -} - - -bool SkeletonPrimitive::isSimilarTo( ConstObjectPtr other ) const -{ - if( !Primitive::isEqualTo( other ) ) - { - return false; - } - - const SkeletonPrimitive *tOther = static_cast( other.get() ); - - if (numJoints() != tOther->numJoints()) - { - return false; - } - - float eps = 1e-06f; - for (unsigned int i=0; ireadable()[i] != tOther->m_jointNames->readable()[i]) return false; - - if (m_parentIds->readable()[i] != tOther->m_parentIds->readable()[i]) return false; - - for (unsigned int row=0; row<4; row++) - { - for (unsigned int col=0; col<4; col++) - { - float val0 = Imath::abs(m_defaultPose->readable()[i].x[row][col]) - - Imath::abs(tOther->m_defaultPose->readable()[i].x[row][col]); - - float val1 = Imath::abs(m_localMatrices->readable()[i].x[row][col]) - - Imath::abs(tOther->m_localMatrices->readable()[i].x[row][col]); - - if ( val0>eps || val1>eps ) return false; - } - } - } - - return true; -} - -bool SkeletonPrimitive::isEqualTo( const Object *other ) const -{ - - if( !Primitive::isEqualTo( other ) ) - { - return false; - } - - const SkeletonPrimitive *tOther = static_cast( other ); - - if (numJoints() != tOther->numJoints()) - { - return false; - } - - for (unsigned int i=0; ireadable()[i] != tOther->m_jointNames->readable()[i]) return false; - - if (m_parentIds->readable()[i] != tOther->m_parentIds->readable()[i]) return false; - - for (unsigned int row=0; row<4; row++) - { - for (unsigned int col=0; col<4; col++) - { - if (m_defaultPose->readable()[i].x[row][col] != tOther->m_defaultPose->readable()[i].x[row][col]) - return false; - - if (m_localMatrices->readable()[i].x[row][col] != tOther->m_localMatrices->readable()[i].x[row][col]) - return false; - } - } - } - - return true; -} - - -void SkeletonPrimitive::memoryUsage( Object::MemoryAccumulator &a ) const -{ - Primitive::memoryUsage( a ); - a.accumulate( m_jointNames ); - a.accumulate( m_parentIds ); - a.accumulate( m_defaultPose ); - a.accumulate( m_localMatrices ); -} - -void SkeletonPrimitive::addJoint(int parentId, string name) -{ - m_jointNames->writable().push_back(name); - m_parentIds->writable().push_back(parentId); - - Imath::M44f mat; - mat.makeIdentity(); - - m_defaultPose->writable().push_back(mat); - m_localMatrices->writable().push_back(mat); - - synchVectorIds(); -} - - -void SkeletonPrimitive::setJointPoses( ConstM44fVectorDataPtr poses, Space space ) -{ - if ( poses->readable().size() != numJoints() ) - throw Exception( "Bad topology - skeleton parents must equal bones!" ); - - - switch(space) - { - case SkeletonPrimitive::Local : - m_localMatrices = poses->copy(); - break; - - case SkeletonPrimitive::World : - int rootId = getRootJointId(0); - setFromGlobalMatrices(rootId, poses); - break; - } -} - -void SkeletonPrimitive::setJointPose( unsigned int jointId, ConstM44fDataPtr pose, Space space ) -{ - switch(space) - { - case SkeletonPrimitive::Local : - m_localMatrices->writable()[jointId] = pose->readable(); - break; - - case SkeletonPrimitive::World : - int parentId = m_parentIds->readable()[jointId]; - - if (parentId == -1) - { - m_localMatrices->writable()[jointId] = pose->readable(); - m_globalMatrices->writable()[jointId] = pose->readable(); - } - else - { - M44fDataPtr parentGlobalMatrix = getJointPose(parentId, SkeletonPrimitive::World); - m_localMatrices->writable()[jointId] = pose->readable() * parentGlobalMatrix->readable().inverse(); - } - break; - } -} - -M44fVectorDataPtr SkeletonPrimitive::getJointPoses( Space space ) -{ - switch(space) - { - case SkeletonPrimitive::Local : - return m_localMatrices; - break; - - case SkeletonPrimitive::World: - update(); - return m_globalMatrices; - break; - } -} - -M44fDataPtr SkeletonPrimitive::getJointPose( unsigned int jointId, Space space ) -{ - M44fDataPtr ret = new M44fData(); - switch(space) - { - case SkeletonPrimitive::Local : - ret->writable() = m_localMatrices->readable()[jointId]; - break; - - case SkeletonPrimitive::World: - pullUpdate(jointId); - ret->writable() = m_globalMatrices->readable()[jointId]; - break; - } - return ret; -} - - -void SkeletonPrimitive::setDefaultPoses( ConstM44fVectorDataPtr poses ) -{ - if ( poses->readable().size() != numJoints() ) - throw Exception( "Bad topology - The number of given matrices is different than the number of joints in this SkeletonPrimitive" ); - - m_defaultPose = poses->copy(); -} - -M44fVectorDataPtr SkeletonPrimitive::getDefaultPoses() -{ - return m_defaultPose; -} - -void SkeletonPrimitive::applyDefaultPose() -{ - m_localMatrices = m_defaultPose->copy(); - update(); -} - -IntVectorDataPtr SkeletonPrimitive::getParentIds() const -{ - return m_parentIds->copy(); -} - -int SkeletonPrimitive::getParentId( unsigned int jointId ) const -{ - return m_parentIds->readable()[jointId]; -} - -IntVectorDataPtr SkeletonPrimitive::getChildrenIds( unsigned int jointId ) const -{ - IntVectorDataPtr childrenIds = new IntVectorData(m_childrenIds[jointId]); - return childrenIds; -} - -void SkeletonPrimitive::setJointNames( const StringVectorDataPtr names ) -{ - if ( names->readable().size() != numJoints() ) - throw Exception( "Wrong number of names" ); - m_jointNames = names->copy(); -} - -void SkeletonPrimitive::setJointName( unsigned int jointId, const std::string &name ) -{ - m_jointNames->writable()[jointId] = name; -} - -StringVectorDataPtr SkeletonPrimitive::getJointNames() const -{ - return m_jointNames->copy(); -} - -std::string SkeletonPrimitive::getJointName( unsigned int jointId ) const -{ - return m_jointNames->readable()[jointId]; -} - -void SkeletonPrimitive::shareStaticData( SkeletonPrimitivePtr other ) -{ - other->m_jointNames = m_jointNames; - other->m_defaultPose = m_defaultPose; - other->m_parentIds = m_parentIds; - other->synchVectorIds(); -} - -void SkeletonPrimitive::shareAnimatableData( SkeletonPrimitivePtr other ) -{ - other->m_localMatrices = m_localMatrices; -} - -void SkeletonPrimitive::pullUpdate(unsigned int jointId) -{ - int parentId = m_parentIds->readable()[jointId]; - if (parentId != -1) - { - pullUpdate(parentId); - } - computeGlobalTransform(jointId); -} - - -void SkeletonPrimitive::pushUpdate(unsigned int jointId) -{ - computeGlobalTransform(jointId); - for (unsigned int i=0; ireadable().at(fromId) != -1) - { - fromId = m_parentIds->readable().at(fromId); - count += 1; - if (count == maximumRecursion) - throw Exception( "Was impossible to find a root joint. At least one joint as to have parent index equal to -1 (no parent at all)" ); - } - - return fromId; -} - - -void SkeletonPrimitive::update() -{ - unsigned int size = numJoints(); - - m_globalMatrices->writable().resize(size); - - pushUpdate( getRootJointId(0) ); -} - - -void SkeletonPrimitive::computeGlobalTransform( int jointId ) -{ - int parentId = m_parentIds->readable()[jointId]; - - if (parentId == -1) - { - m_globalMatrices->writable()[jointId] = m_localMatrices->readable()[jointId]; - } - else - { - m_globalMatrices->writable()[jointId] = m_localMatrices->readable()[jointId] * m_globalMatrices->readable()[parentId]; - } -} - - -/* - * IntermediatePose = GlobalPose * InverseParentGlobalPose - * LocalPose = IntermediatePose * InverseReferencePose - */ -void SkeletonPrimitive::setFromGlobalMatrices(int jointId, ConstM44fVectorDataPtr matrices) -{ - m_globalMatrices->writable()[jointId] = matrices->readable()[jointId]; - int parentId = m_parentIds->readable()[jointId]; - - if (parentId == -1) - { - m_localMatrices->writable()[jointId] = m_globalMatrices->readable()[jointId]; - } - else - { - Imath::M44f parentGlobalMatrix = matrices->readable()[parentId]; - - m_localMatrices->writable()[jointId] = m_globalMatrices->readable()[jointId] * parentGlobalMatrix.inverse(); - } - - for (unsigned int i=0; ireadable().size() ); - - for (unsigned int i=0; ireadable().size(); i++) - { - int thisParentId = m_parentIds->readable()[i]; - if ( thisParentId >= 0) - { - m_childrenIds[ thisParentId ].push_back( i ); - } - } -} - - -SkeletonPrimitivePtr SkeletonPrimitive::createHuman() -{ - M44fVectorDataPtr matrices = new M44fVectorData(); - IntVectorDataPtr parentIds = new IntVectorData(); - - parentIds->writable().push_back(-1); - parentIds->writable().push_back(0); - parentIds->writable().push_back(1); - parentIds->writable().push_back(2); - parentIds->writable().push_back(3); - parentIds->writable().push_back(4); - parentIds->writable().push_back(5); - parentIds->writable().push_back(6); - parentIds->writable().push_back(7); - parentIds->writable().push_back(5); - parentIds->writable().push_back(9); - parentIds->writable().push_back(10); - parentIds->writable().push_back(11); - parentIds->writable().push_back(5); - parentIds->writable().push_back(13); - parentIds->writable().push_back(14); - parentIds->writable().push_back(15); - parentIds->writable().push_back(0); - parentIds->writable().push_back(17); - parentIds->writable().push_back(18); - parentIds->writable().push_back(0); - parentIds->writable().push_back(20); - parentIds->writable().push_back(21); - - matrices->writable().push_back( Imath::M44f(2.2204460492503131e-16, 0.99423389712372556, 0.10723319360239569, 0.0, -0.99999999999999989, 2.2204460492503131e-16, 0.0, 0.0, -2.0816681711721685e-17, -0.10723319360239569, 0.99423389712372567, 0.0, 0.0, 7.4654297985666869, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.98203960772693566, 0.0, -0.18867487605806552, 0.0, 0.0, 1.0, 0.0, 0.0, 0.18867487605806552, 0.0, 0.98203960772693566, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.96824884464617145, 0.0, -0.24998834941123571, 0.0, 0.0, 1.0, 0.0, 0.0, 0.24998834941123571, 0.0, 0.96824884464617145, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.99316879236364553, 0.0, 0.11668654538950909, 0.0, -0.0, 1.0, 0.0, 0.0, -0.11668654538950909, -0.0, 0.99316879236364553, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.97534811557415679, 0.0, 0.22067182295422608, 0.0, -0.0, 1.0, 0.0, 0.0, -0.22067182295422608, -0.0, 0.97534811557415679, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.96023488953606984, 0.0, 0.27919340414424509, 0.0, -0.0, 1.0, 0.0, 0.0, -0.27919340414424509, -0.0, 0.96023488953606984, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(2.2204460492503131e-16, -1.0, -0.0, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 0.0, 0.0, -0.0, 1.0, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.0, 0.9589928569026932, -0.28343023905294706, 0.0, -1.0, 0.0, 0.0, 0.0, 2.7755575615628914e-17, 0.28343023905294712, 0.95899285690269309, 0.0, 1.6260470003868648e-17, 0.96517555562964752, -0.089505324154478316, 1.0) ); - matrices->writable().push_back( Imath::M44f(2.2204460492503131e-16, -1.0, -0.0, 0.0, 1.0, 2.2204460492503131e-16, 0.0, 0.0, 0.0, -0.0, 1.0, 0.0, 2.0, 4.4408920985006262e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.0, 0.99999999999999978, 2.7755575615628907e-17, 0.0, 0.95899285690269298, 2.2204460492503131e-16, -0.2834302390529469, 0.0, -0.2834302390529469, -2.7755575615628907e-17, -0.95899285690269309, 0.0, 0.79140231856104748, 1.0000000000000002, 0.30395991058622451, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.29715689821363533, -0.89147069464090656, 0.34202014332566877, 0.0, 0.94868329805051399, 0.31622776601683777, 2.7755575615628914e-17, 0.0, -0.10815626585663497, 0.32446879756990488, 0.93969262078590843, 0.0, 1.0, 0.0, -1.2246467991473532e-16, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.86602540378443871, 0.0, -0.49999999999999994, 0.0, 0.0, 1.0, 0.0, 0.0, 0.49999999999999994, 0.0, 0.86602540378443871, 0.0, 2.6191653120576799, -8.8817841970012523e-16, -1.224646799147353e-16, 1.0) ); - matrices->writable().push_back( Imath::M44f(-0.316227766016838, -0.94868329805051366, -1.224646799147353e-16, 0.0, -0.94868329805051366, 0.31622776601683811, 0.0, 0.0, 3.8726732145403892e-17, 1.1618019643621161e-16, -1.0, 0.0, 2.6854914710480733, 4.4408920985006262e-15, -1.2246467991473495e-16, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.0, -1.0, 0.0, 0.0, 0.9589928569026932, 0.0, -0.28343023905294706, 0.0, 0.28343023905294706, 5.5511151231257827e-17, 0.95899285690269309, 0.0, 0.79140231856104748, -0.99999999999999989, 0.30395991058622451, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.29715689821363533, -0.89147069464090656, -0.34202014332566877, 0.0, 0.94868329805051399, 0.31622776601683777, -2.7755575615628914e-17, 0.0, 0.10815626585663497, -0.32446879756990488, 0.93969262078590843, 0.0, 1.0, 0.0, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.86602540378443871, 0.0, 0.49999999999999994, 0.0, -0.0, 1.0, 0.0, 0.0, -0.49999999999999994, -0.0, 0.86602540378443871, 0.0, 2.6191653120576799, -8.8817841970012523e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.31622776601683789, 0.94868329805051388, 0.0, 0.0, -0.94868329805051388, 0.31622776601683789, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.6854914710480742, 1.7763568394002505e-15, 9.8607613152626476e-32, 1.0) ); - matrices->writable().push_back( Imath::M44f(-0.94511204731701848, -0.16881626495434912, 0.27975754985897555, 0.0, 0.1705291427993407, -0.98518096292376045, -0.018392437270097019, 0.0, 0.27871675491860232, 0.030323901125603691, 0.95989448979987813, 0.0, -0.33944620949534787, -1.0000000000000002, 0.036611003915393847, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.91772761356451982, 0.0, -0.39721030613665032, 0.0, 0.0, 1.0, 0.0, 0.0, 0.39721030613665032, 0.0, 0.91772761356451982, 0.0, 3.6933553329544622, -8.8817841970012523e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(2.2204460492503131e-16, 1.0, 0.0, 0.0, -1.0, 2.2204460492503131e-16, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 3.6933553329544622, -8.8817841970012523e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(-0.94353025296907878, 0.17771269443522297, 0.27958694527584749, 0.0, -0.17951583903834623, -0.98356453177948699, 0.019361698266358748, 0.0, 0.27843262248965228, -0.031921937002193507, 0.95992513493061671, 0.0, -0.33944620949534787, 1.0, 0.036611003915393847, 1.0) ); - matrices->writable().push_back( Imath::M44f(0.91772761356451982, 0.0, -0.39721030613665032, 0.0, 0.0, 1.0, 0.0, 0.0, 0.39721030613665032, 0.0, 0.91772761356451982, 0.0, 3.6933553329544622, -8.8817841970012523e-16, 0.0, 1.0) ); - matrices->writable().push_back( Imath::M44f(2.2204460492503131e-16, 1.0, 0.0, 0.0, -1.0, 2.2204460492503131e-16, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 3.6933553329544622, -8.8817841970012523e-16, 0.0, 1.0) ); - - return new SkeletonPrimitive(matrices, parentIds); -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/ConePrimitive.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/ConePrimitive.cpp deleted file mode 100644 index b768638231..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/ConePrimitive.cpp +++ /dev/null @@ -1,115 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreGL/ConePrimitive.h" -#include "IECoreGL/GL.h" - -#include "OpenEXR/ImathMath.h" -#include "OpenEXR/ImathFun.h" - -#include - -using namespace IECoreGL; -using namespace Imath; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( ConePrimitive ); - -ConePrimitive::ConePrimitive( float height, float radius, float thetaMax ) : - m_radius( radius ), - m_height( height ), - m_thetaMax( thetaMax ) -{ -} - -ConePrimitive::~ConePrimitive() -{ - -} - -void ConePrimitive::render( ConstStatePtr state, IECore::TypeId style ) const -{ - GLUquadricObj *quadric = gluNewQuadric(); - gluCylinder( quadric, m_radius, 0.0, m_height, 4u, 4u ); - gluDeleteQuadric( quadric ); - - /* - float oMin = Math::asin( m_zMin ); - float oMax = Math::asin( m_zMax ); - const unsigned int nO = max( 4u, (unsigned int)( 20.0f * m_radius * (oMax - oMin) / M_PI ) ); - - float thetaMax = m_thetaMax/180.0f * M_PI; - const unsigned int nT = max( 7u, (unsigned int)( m_radius * 40.0f * thetaMax / (M_PI*2) ) ); - - for( unsigned int i=0; i::sin( o0 ); - float z1 = m_radius * Math::sin( o1 ); - float r0 = m_radius * Math::cos( o0 ); - float r1 = m_radius * Math::cos( o1 ); - glBegin( GL_TRIANGLE_STRIP ); - for( unsigned int j=0; j::sin( t ); - float ct = Math::cos( t ); - V3f p0( r0 * ct, r0 * st, z0 ); - V3f p1( r1 * ct, r1 * st, z1 ); - glTexCoord2f( u, v1 ); - glNormal3f( p1.x, p1.y, p1.z ); - glVertex3f( p1.x, p1.y, p1.z ); - glTexCoord2f( u, v0 ); - glNormal3f( p0.x, p0.y, p0.z ); - glVertex3f( p0.x, p0.y, p0.z ); - } - glEnd(); - } - */ -} - -Imath::Box3f ConePrimitive::bound() const -{ - //float thetaMax = m_thetaMax/180.0f * M_PI; - //float minX = -m_radius;// * ( thetaMax < M_PI ? Math::cos( thetaMax ) : -1.0f ); - //float maxY = m_radius;// * ( thetaMax < M_PI/2 ? Math::sin( thetaMax ) : 1.0f ); - //float minY = m_radius * ( thetaMax > 3 * M_PI/2 ? -1.0f : min( 0.0f, Math::sin( thetaMax ) ) ); - - return Imath::Box3f( V3f( -m_radius, 0.f, -m_radius ), V3f( m_radius, m_height, m_radius ) ); -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/JointPrimitive.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/JointPrimitive.cpp deleted file mode 100644 index 13dc5441bd..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/JointPrimitive.cpp +++ /dev/null @@ -1,164 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// -#include "IECoreGL/JointPrimitive.h" -#include "IECoreGL/GL.h" - -#include "OpenEXR/ImathMath.h" -#include "OpenEXR/ImathFun.h" - -#include - -using namespace IECoreGL; - -IE_CORE_DEFINERUNTIMETYPED( JointPrimitive ); - -JointPrimitive::JointPrimitive( float radius, float length ) -{ - float h = radius*0.75; - p0.setValue(0.0, 0.0, 0.0); - p1.setValue( radius, radius, h); - p2.setValue(-radius, radius, h); - p3.setValue(-radius, -radius, h); - p4.setValue( radius, -radius, h); - p5.setValue(0.0f, 0.0f, length); -} - -JointPrimitive::~JointPrimitive() -{} - -void JointPrimitive::setRadius( float radius ) -{ - float h = radius*0.75; - p1.setValue( radius, radius, h); - p2.setValue(-radius, radius, h); - p3.setValue(-radius, -radius, h); - p4.setValue( radius, -radius, h); -} - -float JointPrimitive::getRadius() const -{ - return p1.x; -} - -void JointPrimitive::setLength( float length ) -{ - p5.z = length; -} - -float JointPrimitive::getLength() const -{ - return p5.z; -} - -void getNormal(const Imath::V3f &vec1, const Imath::V3f &vec2, const Imath::V3f &vec3, Imath::V3f &retNormal) -{ - retNormal = ( vec2-vec1 ).cross( vec3-vec1 ); - retNormal .normalize(); -} - -void JointPrimitive::render( const State *state, IECore::TypeId style ) const -{ - Imath::V3f n; - glBegin( GL_TRIANGLES ); - ///// The top small pyramid ///// - getNormal(p0, p4, p3, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p0.x, p0.y, p0.z); - glVertex3f(p4.x, p4.y, p4.z); - glVertex3f(p3.x, p3.y, p3.z); - - getNormal(p0, p3, p2, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p0.x, p0.y, p0.z); - glVertex3f(p3.x, p3.y, p3.z); - glVertex3f(p2.x, p2.y, p2.z); - - getNormal(p0, p2, p1, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p0.x, p0.y, p0.z); - glVertex3f(p2.x, p2.y, p2.z); - glVertex3f(p1.x, p1.y, p1.z); - - getNormal(p0, p1, p4, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p0.x, p0.y, p0.z); - glVertex3f(p1.x, p1.y, p1.z); - glVertex3f(p4.x, p4.y, p4.z); - - ///// The body long pyramid ///// - getNormal(p5, p1, p2, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p5.x, p5.y, p5.z); - glVertex3f(p1.x, p1.y, p1.z); - glVertex3f(p2.x, p2.y, p2.z); - - getNormal(p5, p2, p3, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p5.x, p5.y, p5.z); - glVertex3f(p2.x, p2.y, p2.z); - glVertex3f(p3.x, p3.y, p3.z); - - getNormal(p5, p3, p4, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p5.x, p5.y, p5.z); - glVertex3f(p3.x, p3.y, p3.z); - glVertex3f(p4.x, p4.y, p4.z); - - getNormal(p5, p4, p1, n); - glNormal3f(n.x, n.y, n.z); - glVertex3f(p5.x, p5.y, p5.z); - glVertex3f(p4.x, p4.y, p4.z); - glVertex3f(p1.x, p1.y, p1.z); - glEnd(); -} - -Imath::Box3f JointPrimitive::bound() const -{ - return Imath::Box3f( Imath::V3f( p1.x, 0.0f, p1.x ), Imath::V3f( -p1.x, p5.z, -p1.x ) ); -} - - -void JointPrimitive::addPrimitiveVariable( const std::string &name, const IECore::PrimitiveVariable &primVar ) -{ - if ( primVar.interpolation==IECore::PrimitiveVariable::Constant ) - { - addUniformAttribute( name, primVar.data ); - } - if ( primVar.interpolation==IECore::PrimitiveVariable::Uniform ) - { - addUniformAttribute( name, primVar.data ); - } -} - diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/Renderer.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/Renderer.cpp deleted file mode 100644 index 69d7161e1d..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/Renderer.cpp +++ /dev/null @@ -1,1885 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreGL/Renderer.h" -#include "IECoreGL/State.h" -#include "IECoreGL/PointsPrimitive.h" -#include "IECoreGL/MeshPrimitive.h" -#include "IECoreGL/QuadPrimitive.h" -#include "IECoreGL/SpherePrimitive.h" -#include "IECoreGL/ColorTexture.h" -#include "IECoreGL/LuminanceTexture.h" -#include "IECoreGL/Scene.h" -#include "IECoreGL/Group.h" -#include "IECoreGL/GL.h" -#include "IECoreGL/private/DeferredRendererImplementation.h" -#include "IECoreGL/private/ImmediateRendererImplementation.h" -#include "IECoreGL/private/Display.h" -#include "IECoreGL/TypedStateComponent.h" -#include "IECoreGL/ShaderManager.h" -#include "IECoreGL/Shader.h" -#include "IECoreGL/ShaderStateComponent.h" -#include "IECoreGL/TextureLoader.h" -#include "IECoreGL/PerspectiveCamera.h" -#include "IECoreGL/OrthographicCamera.h" -#include "IECoreGL/NameStateComponent.h" -#include "IECoreGL/ToGLCameraConverter.h" -#include "IECoreGL/CurvesPrimitive.h" -#include "IECoreGL/ToGLMeshConverter.h" -#include "IECoreGL/Font.h" -#include "IECoreGL/TextPrimitive.h" -#include "IECoreGL/DiskPrimitive.h" -#include "IECoreGL/ToGLCurvesConverter.h" -#include "IECoreGL/ToGLTextureConverter.h" -#include "IECoreGL/ToGLPointsConverter.h" -#include "IECoreGL/SkeletonPrimitive.h" - -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/BoxOps.h" -#include "IECore/Camera.h" -#include "IECore/Transform.h" -#include "IECore/MatrixAlgo.h" -#include "IECore/MeshPrimitive.h" -#include "IECore/MeshNormalsOp.h" -#include "IECore/SplineData.h" -#include "IECore/SplineToImage.h" -#include "IECore/CurvesPrimitive.h" -#include "IECore/PointsPrimitive.h" -#include "IECore/SkeletonPrimitive.h" - -#include "OpenEXR/ImathBoxAlgo.h" - -#include - -using namespace IECore; -using namespace IECoreGL; -using namespace Imath; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( IECoreGL::Renderer ); - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// static utility functions -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -template -typename T::ConstPtr castWithWarning( ConstDataPtr data, const std::string &name, const std::string &context ) -{ - typename T::ConstPtr c = runTimeCast( data ); - if( !c ) - { - msg( Msg::Warning, context, boost::format( "Expected \"%s\" to be of type \"%s\"." ) % name % T::staticTypeName() ); - } - return c; -} - -template -T parameterValue( const char *name, const CompoundDataMap ¶meters, T defaultValue ) -{ - CompoundDataMap::const_iterator it = parameters.find( name ); - if( it!=parameters.end() ) - { - typename TypedData::ConstPtr p = runTimeCast >( it->second ); - if( p ) - { - return p->readable(); - } - } - return defaultValue; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// member data held in a single structure -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -struct IECoreGL::Renderer::MemberData -{ - enum Mode - { - Immediate, - Deferred - }; - - struct - { - Mode mode; - V2f shutter; - IECore::CompoundDataMap user; - string fontSearchPath; - string shaderSearchPath; - string shaderSearchPathDefault; - string shaderIncludePath; - string shaderIncludePathDefault; - string textureSearchPath; - string textureSearchPathDefault; - vector cameras; - vector displays; - bool drawCoordinateSystems; - } options; - - /// This is used only before worldBegin, so we can correctly get the transforms for cameras. - /// After worldBegin the transform stack is taken care of by the backend implementations. - std::stack transformStack; - - bool inWorld; - RendererImplementationPtr implementation; - ShaderManagerPtr shaderManager; - TextureLoaderPtr textureLoader; - - typedef std::map InstanceMap; - InstanceMap instances; - Group *currentInstance; - -#ifdef IECORE_WITH_FREETYPE - typedef std::map FontMap; - FontMap fonts; -#endif // IECORE_WITH_FREETYPE - -}; - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// structors -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -IECoreGL::Renderer::Renderer() -{ - m_data = new MemberData; - - m_data->options.mode = MemberData::Immediate; - m_data->options.shutter = V2f( 0 ); - - const char *fontPath = getenv( "IECORE_FONT_PATHS" ); - m_data->options.fontSearchPath = fontPath ? fontPath : ""; - const char *shaderPath = getenv( "IECOREGL_SHADER_PATHS" ); - m_data->options.shaderSearchPath = m_data->options.shaderSearchPathDefault = shaderPath ? shaderPath : ""; - const char *shaderIncludePath = getenv( "IECOREGL_SHADER_INCLUDE_PATHS" ); - m_data->options.shaderIncludePath = m_data->options.shaderIncludePathDefault = shaderIncludePath ? shaderIncludePath : ""; - const char *texturePath = getenv( "IECOREGL_TEXTURE_PATHS" ); - m_data->options.textureSearchPath = m_data->options.textureSearchPathDefault = texturePath ? texturePath : ""; - m_data->options.drawCoordinateSystems = false; - - m_data->transformStack.push( M44f() ); - - m_data->inWorld = false; - m_data->currentInstance = 0; - m_data->implementation = 0; - m_data->shaderManager = 0; -} - -IECoreGL::Renderer::~Renderer() -{ - delete m_data; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// options etc -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -typedef void (*OptionSetter)( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ); -typedef std::map OptionSetterMap; - -typedef IECore::DataPtr (*OptionGetter)( const std::string &name, IECoreGL::Renderer::MemberData *memberData ); -typedef std::map OptionGetterMap; - -static void modeOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstStringDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - if( s->readable()=="immediate" ) - { - memberData->options.mode = IECoreGL::Renderer::MemberData::Immediate; - } - else if( s->readable()=="deferred" ) - { - memberData->options.mode = IECoreGL::Renderer::MemberData::Deferred; - } - else - { - msg( Msg::Warning, "Renderer::setOption", boost::format( "Unsuppported mode value \"%s\"." ) % s->readable() ); - } - } - return; -} - -static IECore::DataPtr modeOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - switch( memberData->options.mode ) - { - case IECoreGL::Renderer::MemberData::Immediate : - return new StringData( "immediate" ); - default : - return new StringData( "deferred" ); - } -} - -static void shutterOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstV2fDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.shutter = s->readable(); - } -} - -static IECore::DataPtr shutterOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new V2fData( memberData->options.shutter ); -} - -static void fontSearchPathOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstStringDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.fontSearchPath = s->readable(); - } -} - -static IECore::DataPtr fontSearchPathOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new StringData( memberData->options.fontSearchPath ); -} - -static void shaderSearchPathOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstStringDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.shaderSearchPath = s->readable(); - } -} - -static IECore::DataPtr shaderSearchPathOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new StringData( memberData->options.shaderSearchPath ); -} - -static void shaderIncludePathOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstStringDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.shaderIncludePath = s->readable(); - } -} - -static IECore::DataPtr shaderIncludePathOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new StringData( memberData->options.shaderIncludePath ); -} - -static void textureSearchPathOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstStringDataPtr s = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.textureSearchPath = s->readable(); - } -} - -static IECore::DataPtr textureSearchPathOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new StringData( memberData->options.textureSearchPath ); -} - -static void drawCoordinateSystemsOptionSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - if( ConstBoolDataPtr b = castWithWarning( value, name, "Renderer::setOption" ) ) - { - memberData->options.drawCoordinateSystems = b->readable(); - } -} - -static IECore::DataPtr drawCoordinateSystemsOptionGetter( const std::string &name, IECoreGL::Renderer::MemberData *memberData ) -{ - return new BoolData( memberData->options.drawCoordinateSystems ); -} - -static const OptionSetterMap *optionSetters() -{ - static OptionSetterMap *o = new OptionSetterMap; - if( !o->size() ) - { - (*o)["gl:mode"] = modeOptionSetter; - (*o)["shutter"] = shutterOptionSetter; - (*o)["searchPath:font"] = fontSearchPathOptionSetter; - (*o)["gl:searchPath:shader"] = shaderSearchPathOptionSetter; - (*o)["searchPath:shader"] = shaderSearchPathOptionSetter; - (*o)["gl:searchPath:shaderInclude"] = shaderIncludePathOptionSetter; - (*o)["searchPath:shaderInclude"] = shaderIncludePathOptionSetter; - (*o)["gl:searchPath:texture"] = textureSearchPathOptionSetter; - (*o)["searchPath:texture"] = textureSearchPathOptionSetter; - (*o)["gl:drawCoordinateSystems"] = drawCoordinateSystemsOptionSetter; - } - return o; -} - -static const OptionGetterMap *optionGetters() -{ - static OptionGetterMap *o = new OptionGetterMap; - if( !o->size() ) - { - (*o)["gl:mode"] = modeOptionGetter; - (*o)["shutter"] = shutterOptionGetter; - (*o)["searchPath:font"] = fontSearchPathOptionGetter; - (*o)["gl:searchPath:shader"] = shaderSearchPathOptionGetter; - (*o)["searchPath:shader"] = shaderSearchPathOptionGetter; - (*o)["gl:searchPath:shaderInclude"] = shaderIncludePathOptionGetter; - (*o)["searchPath:shaderInclude"] = shaderIncludePathOptionGetter; - (*o)["gl:searchPath:texture"] = textureSearchPathOptionGetter; - (*o)["searchPath:texture"] = textureSearchPathOptionGetter; - (*o)["gl:drawCoordinateSystems"] = drawCoordinateSystemsOptionGetter; - } - return o; -} - -void IECoreGL::Renderer::setOption( const std::string &name, IECore::ConstDataPtr value ) -{ - if( m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::setOption", "Cannot call setOption after worldBegin()." ); - return; - } - - const OptionSetterMap *o = optionSetters(); - OptionSetterMap::const_iterator it = o->find( name ); - if( it!=o->end() ) - { - it->second( name, value, m_data ); - } - else if( name.compare( 0, 5, "user:" )==0 ) - { - m_data->options.user[name] = value->copy(); - } - else if( name.compare( 0, 3, "gl:" )==0 || name.find( ':' )==string::npos ) - { - msg( Msg::Warning, "Renderer::setOption", boost::format( "Unsuppported option \"%s\"." ) % name ); - return; - } -} - -IECore::ConstDataPtr IECoreGL::Renderer::getOption( const std::string &name ) const -{ - const OptionGetterMap *o = optionGetters(); - OptionGetterMap::const_iterator it = o->find( name ); - if( it!=o->end() ) - { - return it->second( name, m_data ); - } - else if( name.compare( 0, 5, "user:" )==0 ) - { - IECore::CompoundDataMap::const_iterator it = m_data->options.user.find( name ); - if( it!=m_data->options.user.end() ) - { - return it->second; - } - else - { - return 0; - } - } - else if( name.compare( 0, 3, "gl:" )==0 || name.find( ':' )==string::npos ) - { - msg( Msg::Warning, "Renderer::getOption", boost::format( "Unsuppported option \"%s\"." ) % name ); - return 0; - } - - return 0; -} - - -void IECoreGL::Renderer::camera( const std::string &name, const IECore::CompoundDataMap ¶meters ) -{ - if( m_data->inWorld ) - { - msg( Msg::Warning, "IECoreGL::Renderer::camera", "Cameras can not be specified after worldBegin." ); - return; - } - if ( m_data->currentInstance ) - { - msg( Msg::Warning, "IECoreGL::Renderer::camera", "Cameras can not be specified during instance definition." ); - return; - } - - try - { - IECore::CameraPtr coreCamera = new IECore::Camera( name, 0, new CompoundData( parameters ) ); - IECoreGL::CameraPtr camera = IECore::runTimeCast( ToGLCameraConverter( coreCamera ).convert() ); - // we have to store these till worldBegin, as only then are we sure what sort of renderer backend we have - if( camera ) - { - camera->setTransform( m_data->transformStack.top() ); - m_data->options.cameras.push_back( camera ); - } - } - catch( const std::exception &e ) - { - msg( Msg::Error, "IECoreGL::Renderer::camera", e.what() ); - return; - } -} - - -void IECoreGL::Renderer::display( const std::string &name, const std::string &type, const std::string &data, const IECore::CompoundDataMap ¶meters ) -{ - // we store displays till worldbegin, as until that point we don't have a renderer implementation to pass - // them to - if( m_data->inWorld ) - { - msg( Msg::Warning, "IECoreGL::Renderer::display", "Displays can not be specified after worldBegin." ); - return; - } - if ( m_data->currentInstance ) - { - msg( Msg::Warning, "IECoreGL::Renderer::display", "Displays can not be specified during instance definition." ); - return; - } - m_data->options.displays.push_back( new Display( name, type, data, parameters ) ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// world begin/end -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -void IECoreGL::Renderer::worldBegin() -{ - if( m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::worldBegin", "Cannot call worldBegin() again before worldEnd()." ); - return; - } - if ( m_data->currentInstance ) - { - msg( Msg::Warning, "IECoreGL::Renderer::worldBegin", "worldBegin can not be called during instance definition." ); - return; - } - - m_data->inWorld = true; - - if( m_data->options.mode==MemberData::Deferred ) - { - m_data->implementation = new DeferredRendererImplementation; - } - else - { - m_data->implementation = new ImmediateRendererImplementation; - } - - if( m_data->options.shaderSearchPath==m_data->options.shaderSearchPathDefault && m_data->options.shaderIncludePath==m_data->options.shaderIncludePathDefault ) - { - // use the shared default cache if we can - m_data->shaderManager = ShaderManager::defaultShaderManager(); - } - else - { - IECore::SearchPath includePaths( m_data->options.shaderIncludePath ); - m_data->shaderManager = new ShaderManager( IECore::SearchPath( m_data->options.shaderSearchPath ), &includePaths ); - } - - if( m_data->options.textureSearchPath==m_data->options.textureSearchPathDefault ) - { - // use the shared default cache if we can - m_data->textureLoader = TextureLoader::defaultTextureLoader(); - } - else - { - m_data->textureLoader = new TextureLoader( IECore::SearchPath( m_data->options.textureSearchPath ) ); - } - - if( m_data->options.cameras.size() ) - { - for( unsigned int i=0; ioptions.cameras.size(); i++ ) - { - m_data->implementation->addCamera( m_data->options.cameras[i] ); - } - } - else - { - // specify the default camera - IECore::CameraPtr defaultCamera = new IECore::Camera(); - defaultCamera->addStandardParameters(); - IECoreGL::CameraPtr camera = IECore::runTimeCast( ToGLCameraConverter( defaultCamera ).convert() ); - m_data->implementation->addCamera( camera ); - } - - for( unsigned int i=0; ioptions.displays.size(); i++ ) - { - m_data->implementation->addDisplay( m_data->options.displays[i] ); - } - m_data->implementation->worldBegin(); -} - -void IECoreGL::Renderer::worldEnd() -{ - if( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::worldEnd", "Cannot call worldEnd() before worldBegin()." ); - return; - } - if ( m_data->currentInstance ) - { - msg( Msg::Warning, "IECoreGL::Renderer::worldEnd", "worldEnd can not be called during instance definition." ); - return; - } - m_data->implementation->worldEnd(); - m_data->inWorld = false; -} - -ScenePtr IECoreGL::Renderer::scene() -{ - DeferredRendererImplementationPtr r = runTimeCast( m_data->implementation ); - if( r ) - { - return r->scene(); - } - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// transforms -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -void IECoreGL::Renderer::transformBegin() -{ - if( m_data->inWorld ) - { - m_data->implementation->transformBegin(); - } - else - { - m_data->transformStack.push( m_data->transformStack.top() ); - } -} - -void IECoreGL::Renderer::transformEnd() -{ - if( m_data->inWorld ) - { - bool wasRight = ( determinant( m_data->implementation->getTransform() ) >= 0 ); - m_data->implementation->transformEnd(); - bool isRight = ( determinant( m_data->implementation->getTransform() ) >= 0 ); - - if ( wasRight != isRight ) - { - bool l = m_data->implementation->getState()->value(); - m_data->implementation->addState( new RightHandedOrientationStateComponent( !l ) ); - } - } - else - { - if( m_data->transformStack.size() ) - { - m_data->transformStack.pop(); - } - else - { - msg( Msg::Error, "IECoreGL::Renderer::transformEnd", "Bad nesting detected." ); - } - } -} - -void IECoreGL::Renderer::setTransform( const Imath::M44f &m ) -{ - if( m_data->inWorld ) - { - m_data->implementation->setTransform( m ); - - if( determinant( m ) < 0.0f ) - { - bool l = m_data->implementation->getState()->value(); - m_data->implementation->addState( new RightHandedOrientationStateComponent( !l ) ); - } - } - else - { - m_data->transformStack.top() = m; - } -} - -void IECoreGL::Renderer::setTransform( const std::string &coordinateSystem ) -{ - msg( Msg::Warning, "Renderer::setTransform", "Not implemented" ); -} - -Imath::M44f IECoreGL::Renderer::getTransform() const -{ - if( m_data->inWorld ) - { - return m_data->implementation->getTransform(); - } - else - { - return m_data->transformStack.top(); - } -} - -Imath::M44f IECoreGL::Renderer::getTransform( const std::string &coordinateSystem ) const -{ - msg( Msg::Warning, "Renderer::getTransform", "Not implemented" ); - return M44f(); -} - -void IECoreGL::Renderer::concatTransform( const Imath::M44f &m ) -{ - if( m_data->inWorld ) - { - m_data->implementation->concatTransform( m ); - if( determinant( m ) < 0.0f ) - { - bool l = m_data->implementation->getState()->value(); - m_data->implementation->addState( new RightHandedOrientationStateComponent( !l ) ); - } - } - else - { - m_data->transformStack.top() = m * m_data->transformStack.top(); - } -} - -void IECoreGL::Renderer::coordinateSystem( const std::string &name ) -{ - if( m_data->options.drawCoordinateSystems ) - { - IntVectorDataPtr numVerticesData = new IntVectorData; - std::vector &numVertices = numVerticesData->writable(); - numVertices.push_back( 2 ); - numVertices.push_back( 2 ); - numVertices.push_back( 2 ); - - V3fVectorDataPtr pointsData = new V3fVectorData(); - std::vector &points = pointsData->writable(); - points.push_back( V3f( 0 ) ); - points.push_back( V3f( 1, 0, 0 ) ); - points.push_back( V3f( 0 ) ); - points.push_back( V3f( 0, 1, 0 ) ); - points.push_back( V3f( 0 ) ); - points.push_back( V3f( 0, 0, 1 ) ); - - PrimitiveVariableMap primVars; - primVars["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, pointsData ); - - attributeBegin(); - setAttribute( "name", new StringData( "coordinateSystem:" + name ) ); - setAttribute( "gl:curvesPrimitive:useGLLines", new BoolData( true ) ); - setAttribute( "gl:curvesPrimitive:glLineWidth", new FloatData( 2 ) ); - curves( CubicBasisf::linear(), false, numVerticesData, primVars ); - attributeEnd(); - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// attribute state -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -typedef void (*AttributeSetter)( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ); -typedef std::map AttributeSetterMap; -typedef IECore::ConstDataPtr (*AttributeGetter)( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ); -typedef std::map AttributeGetterMap; - -template -static void typedAttributeSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - typedef IECore::TypedData DataType; - typename DataType::ConstPtr d = runTimeCast( value ); - if( !d ) - { - msg( Msg::Warning, "Renderer::setAttribute", boost::format( "Expected data of type \"%s\" for attribute \"%s\"." ) % DataType::staticTypeName() % name ); - return; - } - memberData->implementation->addState( new T( d->readable() ) ); -} - -template -static IECore::ConstDataPtr typedAttributeGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - typedef IECore::TypedData DataType; - const T *a = memberData->implementation->template getState(); - return new DataType( a->value() ); -} - -static void colorAttributeSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstColor3fDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( d ) - { - Color::ConstPtr c = memberData->implementation->getState(); - Color4f cc = c->value(); - cc[0] = d->readable()[0]; - cc[1] = d->readable()[1]; - cc[2] = d->readable()[2]; - memberData->implementation->addState( new Color( cc ) ); - } -} - -static IECore::ConstDataPtr colorAttributeGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const IECoreGL::Color *a = memberData->implementation->getState(); - Color4f c = a->value(); - return new Color3fData( Color3f( c[0], c[1], c[2] ) ); -} - -static IECore::ConstDataPtr opacityAttributeGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const IECoreGL::Color *a = memberData->implementation->getState(); - Color4f c = a->value(); - return new Color3fData( Color3f( c[3] ) ); -} - -static void opacityAttributeSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstColor3fDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( d ) - { - const Color *c = memberData->implementation->getState(); - Color4f cc = c->value(); - cc[3] = (d->readable()[0] + d->readable()[1] + d->readable()[2]) / 3.0f; - memberData->implementation->addState( new Color( cc ) ); - } -} - -static IECore::ConstDataPtr blendFactorGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const BlendFuncStateComponent *b = memberData->implementation->getState(); - GLenum f = name=="gl:blend:srcFactor" ? b->value().src : b->value().dst; - switch( f ) - { - case GL_ZERO : - return new StringData( "zero" ); - case GL_ONE : - return new StringData( "one" ); - case GL_SRC_COLOR : - return new StringData( "srcColor" ); - case GL_ONE_MINUS_SRC_COLOR : - return new StringData( "oneMinusSrcColor" ); - case GL_DST_COLOR : - return new StringData( "dstColor" ); - case GL_ONE_MINUS_DST_COLOR : - return new StringData( "oneMinusDstColor" ); - case GL_SRC_ALPHA : - return new StringData( "srcAlpha" ); - case GL_ONE_MINUS_SRC_ALPHA : - return new StringData( "oneMinusSrcAlpha" ); - case GL_DST_ALPHA : - return new StringData( "dstAlpha" ); - case GL_ONE_MINUS_DST_ALPHA : - return new StringData( "oneMinusDstAlpha" ); - case GL_CONSTANT_COLOR : - return new StringData( "constantColor" ); - case GL_ONE_MINUS_CONSTANT_COLOR : - return new StringData( "oneMinusConstantColor" ); - case GL_CONSTANT_ALPHA : - return new StringData( "constantAlpha" ); - case GL_ONE_MINUS_CONSTANT_ALPHA : - return new StringData( "oneMinusConstantAlpha" ); - default : - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Invalid state for \"%s\"." ) % name ); - return new StringData( "invalid" ); - } -} - -static void blendFactorSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - - GLenum f; - const std::string &v = d->readable(); - if( v=="zero" ) - { - f = GL_ZERO; - } - else if( v=="one" ) - { - f = GL_ONE; - } - else if( v=="srcColor" ) - { - f = GL_SRC_COLOR; - } - else if( v=="oneMinusSrcColor" ) - { - f = GL_ONE_MINUS_SRC_COLOR; - } - else if( v=="dstColor" ) - { - f = GL_DST_COLOR; - } - else if( v=="oneMinusDstColor" ) - { - f = GL_ONE_MINUS_DST_COLOR; - } - else if( v=="srcAlpha" ) - { - f = GL_SRC_ALPHA; - } - else if( v=="oneMinusSrcAlpha" ) - { - f = GL_ONE_MINUS_SRC_ALPHA; - } - else if( v=="dstAlpha" ) - { - f = GL_DST_ALPHA; - } - else if( v=="oneMinusDstAlpha" ) - { - f = GL_ONE_MINUS_DST_ALPHA; - } - else if( v=="constantColor" ) - { - f = GL_CONSTANT_COLOR; - } - else if( v=="oneMinusConstantColor" ) - { - f = GL_ONE_MINUS_CONSTANT_COLOR; - } - else if( v=="constantAlpha" ) - { - f = GL_CONSTANT_ALPHA; - } - else if( v=="oneMinusConstantAlpha" ) - { - f = GL_ONE_MINUS_CONSTANT_ALPHA; - } - else - { - msg( Msg::Error, "Renderer::setAttribute", boost::format( "Unsupported value \"%s\" for attribute \"%s\"." ) % v % name ); - return; - } - const BlendFuncStateComponent *b = memberData->implementation->getState(); - BlendFactors bf = b->value(); - if( name=="gl:blend:srcFactor" ) - { - bf.src = f; - } - else - { - bf.dst = f; - } - memberData->implementation->addState( new BlendFuncStateComponent( bf ) ); -} - -static IECore::ConstDataPtr blendEquationGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const BlendEquationStateComponent *b = memberData->implementation->getState(); - switch( b->value() ) - { - case GL_FUNC_ADD : - return new StringData( "add" ); - case GL_FUNC_SUBTRACT : - return new StringData( "subtract" ); - case GL_FUNC_REVERSE_SUBTRACT : - return new StringData( "reverseSubtract" ); - case GL_MIN : - return new StringData( "min" ); - case GL_MAX : - return new StringData( "max" ); - default : - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Invalid state for \"%s\"." ) % name ); - return new StringData( "invalid" ); - } -} - -static void blendEquationSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - - GLenum f; - const std::string &v = d->readable(); - if( v=="add" ) - { - f = GL_FUNC_ADD; - } - else if( v=="subtract" ) - { - f = GL_FUNC_SUBTRACT; - } - else if( v=="reverseSubtract" ) - { - f = GL_FUNC_REVERSE_SUBTRACT; - } - else if( v=="min" ) - { - f = GL_MIN; - } - else if( v=="max" ) - { - f = GL_MAX; - } - else - { - msg( Msg::Error, "Renderer::setAttribute", boost::format( "Unsupported value \"%s\" for attribute \"%s\"." ) % v % name ); - return; - } - - memberData->implementation->addState( new BlendEquationStateComponent( f ) ); -} - -static IECore::ConstDataPtr pointsPrimitiveUseGLPointsGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const IECoreGL::PointsPrimitive::UseGLPoints *b = memberData->implementation->getState(); - switch( b->value() ) - { - case ForPointsOnly : - return new StringData( "forGLPoints" ); - case ForPointsAndDisks : - return new StringData( "forParticlesAndDisks" ); - case ForAll : - return new StringData( "forAll" ); - default : - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Invalid state for \"%s\"." ) % name ); - return new StringData( "invalid" ); - } - -} - -static void pointsPrimitiveUseGLPointsSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - GLPointsUsage u; - const std::string &v = d->readable(); - if( v=="forGLPoints" ) - { - u = ForPointsOnly; - } - else if( v=="forParticlesAndDisks" ) - { - u = ForPointsAndDisks; - } - else if( v=="forAll" ) - { - u = ForAll; - } - else - { - msg( Msg::Error, "Renderer::setAttribute", boost::format( "Unsupported value \"%s\" for attribute \"%s\"." ) % v % name ); - return; - } - memberData->implementation->addState( new IECoreGL::PointsPrimitive::UseGLPoints( u ) ); -} - -static IECore::ConstDataPtr nameGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - const NameStateComponent *n = memberData->implementation->getState(); - return new StringData( n->name() ); -} - -static void nameSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - memberData->implementation->addState( new NameStateComponent( d->readable() ) ); -} - -static IECore::ConstDataPtr textPrimitiveTypeGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - -#ifdef IECORE_WITH_FREETYPE - - const TextPrimitive::Type *b = memberData->implementation->getState(); - switch( b->value() ) - { - case TextPrimitive::Mesh : - return new StringData( "mesh" ); - case TextPrimitive::Sprite : - return new StringData( "sprite" ); - default : - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Invalid state for \"%s\"." ) % name ); - return new StringData( "invalid" ); - } - -#else - - IECore::msg( IECore::Msg::Warning, "Renderer::getAttribute", "IECore was not built with FreeType support." ); - return 0; - -#endif // IECORE_WITH_FREETYPE - -} - -static void textPrimitiveTypeSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - -#ifdef IECORE_WITH_FREETYPE - - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - TextPrimitive::RenderType t; - const std::string &v = d->readable(); - if( v=="mesh" ) - { - t = TextPrimitive::Mesh; - } - else if( v=="sprite" ) - { - t = TextPrimitive::Sprite; - } - else - { - msg( Msg::Error, "Renderer::setAttribute", boost::format( "Unsupported value \"%s\" for attribute \"%s\"." ) % v % name ); - return; - } - memberData->implementation->addState( new TextPrimitive::Type( t ) ); - -#else - - IECore::msg( IECore::Msg::Warning, "Renderer::setAttribute", "IECore was not built with FreeType support." ); - -#endif // IECORE_WITH_FREETYPE - -} - -template -static IECore::ConstDataPtr rendererSpaceGetter( const std::string &name, const IECoreGL::Renderer::MemberData *memberData ) -{ - typename T::ConstPtr b = memberData->implementation->getState< T >(); - switch( b->value() ) - { - case ObjectSpace : - return new StringData( "object" ); - case WorldSpace : - return new StringData( "world" ); - default : - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Invalid state for \"%s\"." ) % name ); - return new StringData( "invalid" ); - } -} - -template -static void rendererSpaceSetter( const std::string &name, IECore::ConstDataPtr value, IECoreGL::Renderer::MemberData *memberData ) -{ - ConstStringDataPtr d = castWithWarning( value, name, "Renderer::setAttribute" ); - if( !d ) - { - return; - } - RendererSpace s; - const std::string &v = d->readable(); - if( v=="object" ) - { - s = ObjectSpace; - } - else if ( v == "world" ) - { - s = WorldSpace; - } - else - { - msg( Msg::Error, "Renderer::setAttribute", boost::format( "Unsupported value \"%s\" for attribute \"%s\"." ) % v % name ); - return; - } - memberData->implementation->addState( new T( s ) ); -} - -static const AttributeSetterMap *attributeSetters() -{ - static AttributeSetterMap *a = new AttributeSetterMap; - if( !a->size() ) - { - (*a)["gl:primitive:wireframe"] = typedAttributeSetter; - (*a)["gl:primitive:wireframeWidth"] = typedAttributeSetter; - (*a)["gl:primitive:bound"] = typedAttributeSetter; - (*a)["gl:primitive:solid"] = typedAttributeSetter; - (*a)["gl:primitive:outline"] = typedAttributeSetter; - (*a)["gl:primitive:outlineWidth"] = typedAttributeSetter; - (*a)["gl:primitive:points"] = typedAttributeSetter; - (*a)["gl:primitive:pointWidth"] = typedAttributeSetter; - (*a)["gl:primitive:sortForTransparency"] = typedAttributeSetter; - (*a)["gl:primitive:wireframeColor"] = typedAttributeSetter; - (*a)["gl:primitive:boundColor"] = typedAttributeSetter; - (*a)["gl:primitive:outlineColor"] = typedAttributeSetter; - (*a)["gl:primitive:pointColor"] = typedAttributeSetter; - (*a)["gl:color"] = typedAttributeSetter; - (*a)["color"] = colorAttributeSetter; - (*a)["opacity"] = opacityAttributeSetter; - (*a)["gl:blend:color"] = typedAttributeSetter; - (*a)["gl:blend:srcFactor"] = blendFactorSetter; - (*a)["gl:blend:dstFactor"] = blendFactorSetter; - (*a)["gl:blend:equation"] = blendEquationSetter; - (*a)["gl:shade:transparent"] = typedAttributeSetter; - (*a)["gl:pointsPrimitive:useGLPoints"] = pointsPrimitiveUseGLPointsSetter; - (*a)["gl:pointsPrimitive:glPointWidth"] = typedAttributeSetter; - (*a)["name"] = nameSetter; - (*a)["doubleSided"] = typedAttributeSetter; - (*a)["rightHandedOrientation"] = typedAttributeSetter; - (*a)["gl:curvesPrimitive:useGLLines"] = typedAttributeSetter; - (*a)["gl:curvesPrimitive:glLineWidth"] = typedAttributeSetter; - (*a)["gl:curvesPrimitive:ignoreBasis"] = typedAttributeSetter; - (*a)["gl:smoothing:points"] = typedAttributeSetter; - (*a)["gl:smoothing:lines"] = typedAttributeSetter; - (*a)["gl:smoothing:polygons"] = typedAttributeSetter; - (*a)["gl:textPrimitive:type"] = textPrimitiveTypeSetter; - (*a)["gl:cullingSpace"] = rendererSpaceSetter; - (*a)["gl:cullingBox"] = typedAttributeSetter; - (*a)["gl:procedural:reentrant"] = typedAttributeSetter; - } - return a; -} - -static const AttributeGetterMap *attributeGetters() -{ - static AttributeGetterMap *a = new AttributeGetterMap; - if( !a->size() ) - { - (*a)["gl:primitive:wireframe"] = typedAttributeGetter; - (*a)["gl:primitive:wireframeWidth"] = typedAttributeGetter; - (*a)["gl:primitive:bound"] = typedAttributeGetter; - (*a)["gl:primitive:solid"] = typedAttributeGetter; - (*a)["gl:primitive:outline"] = typedAttributeGetter; - (*a)["gl:primitive:outlineWidth"] = typedAttributeGetter; - (*a)["gl:primitive:points"] = typedAttributeGetter; - (*a)["gl:primitive:pointWidth"] = typedAttributeGetter; - (*a)["gl:primitive:sortForTransparency"] = typedAttributeGetter; - (*a)["gl:primitive:wireframeColor"] = typedAttributeGetter; - (*a)["gl:primitive:boundColor"] = typedAttributeGetter; - (*a)["gl:primitive:outlineColor"] = typedAttributeGetter; - (*a)["gl:primitive:pointColor"] = typedAttributeGetter; - (*a)["gl:color"] = typedAttributeGetter; - (*a)["color"] = colorAttributeGetter; - (*a)["opacity"] = opacityAttributeGetter; - (*a)["gl:blend:color"] = typedAttributeGetter; - (*a)["gl:blend:srcFactor"] = blendFactorGetter; - (*a)["gl:blend:dstFactor"] = blendFactorGetter; - (*a)["gl:blend:equation"] = blendEquationGetter; - (*a)["gl:shade:transparent"] = typedAttributeGetter; - (*a)["gl:pointsPrimitive:useGLPoints"] = pointsPrimitiveUseGLPointsGetter; - (*a)["gl:pointsPrimitive:glPointWidth"] = typedAttributeGetter; - (*a)["name"] = nameGetter; - (*a)["doubleSided"] = typedAttributeGetter; - (*a)["rightHandedOrientation"] = typedAttributeGetter; - (*a)["gl:curvesPrimitive:useGLLines"] = typedAttributeGetter; - (*a)["gl:curvesPrimitive:glLineWidth"] = typedAttributeGetter; - (*a)["gl:curvesPrimitive:ignoreBasis"] = typedAttributeGetter; - (*a)["gl:smoothing:points"] = typedAttributeGetter; - (*a)["gl:smoothing:lines"] = typedAttributeGetter; - (*a)["gl:smoothing:polygons"] = typedAttributeGetter; - (*a)["gl:textPrimitive:type"] = textPrimitiveTypeGetter; - (*a)["gl:cullingSpace"] = rendererSpaceGetter; - (*a)["gl:cullingBox"] = typedAttributeGetter; - (*a)["gl:procedural:reentrant"] = typedAttributeGetter; - } - return a; -} - -void IECoreGL::Renderer::attributeBegin() -{ - if ( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::attributeBegin", "Unsupported attributeBegin outside world begin/end blocks." ); - return; - } - m_data->implementation->attributeBegin(); -} - -void IECoreGL::Renderer::attributeEnd() -{ - if ( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::attributeBegin", "Unsupported attributeBegin outside world begin/end blocks." ); - return; - } - m_data->implementation->attributeEnd(); -} - -void IECoreGL::Renderer::setAttribute( const std::string &name, IECore::ConstDataPtr value ) -{ - if ( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::setAttribute", "Unsupported setAttribute outside world begin/end blocks." ); - return; - } - const AttributeSetterMap *s = attributeSetters(); - AttributeSetterMap::const_iterator it = s->find( name ); - if( it!=s->end() ) - { - it->second( name, value, m_data ); - } - else if( name.compare( 0, 5, "user:" )==0 ) - { - m_data->implementation->addUserAttribute( name, value->copy() ); - } - else if( name.find_first_of( ":" )!=string::npos ) - { - // prefixed for some other renderer, so we can ignore it - } - else - { - msg( Msg::Warning, "Renderer::setAttribute", boost::format( "Unsupported attribute \"%s\"." ) % name ); - } -} - -IECore::ConstDataPtr IECoreGL::Renderer::getAttribute( const std::string &name ) const -{ - if ( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::getAttribute", "Unsupported getAttribute outside world begin/end blocks." ); - return 0; - } - - const AttributeGetterMap *g = attributeGetters(); - AttributeGetterMap::const_iterator it = g->find( name ); - if( it!=g->end() ) - { - return it->second( name, m_data ); - } - else if( name.compare( 0, 5, "user:" )==0 ) - { - return m_data->implementation->getUserAttribute( name ); - } - else if( name.find_first_of( ":" )!=string::npos ) - { - // prefixed for some other renderer, so we can ignore it - return 0; - } - else - { - msg( Msg::Warning, "Renderer::getAttribute", boost::format( "Unsupported attribute \"%s\"." ) % name ); - } - return 0; -} - -void IECoreGL::Renderer::shader( const std::string &type, const std::string &name, const IECore::CompoundDataMap ¶meters ) -{ - if ( !m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::shader", "Unsupported shader call outside world begin/end blocks." ); - return; - } - - if( type=="surface" || type=="gl:surface" ) - { - if ( !m_data->shaderManager ) - { - msg( Msg::Warning, "Renderer::shader", "Shader specification before world begin ignored. No ShaderManager defined yet." ); - return; - } - string vertexSource = parameterValue( "gl:vertexSource", parameters, "" ); - string fragmentSource = parameterValue( "gl:fragmentSource", parameters, "" ); - - if ( vertexSource == "" && fragmentSource == "" ) - { - m_data->shaderManager->loadShaderCode( name, vertexSource, fragmentSource ); - } - - // validate the parameter types and load any texture parameters. - ShaderStateComponentPtr shaderState = new ShaderStateComponent( m_data->shaderManager, m_data->textureLoader, vertexSource, fragmentSource ); - for( CompoundDataMap::const_iterator it=parameters.begin(); it!=parameters.end(); it++ ) - { - if( it->first!="gl:fragmentSource" && it->first!="gl:vertexSource" ) - { - shaderState->addShaderParameterValue( it->first.value(), it->second ); - } - } - m_data->implementation->addState( shaderState ); - } - else - { - msg( Msg::Warning, "Renderer::shader", boost::format( "Unsupported shader type \"%s\"." ) % type ); - } -} - -void IECoreGL::Renderer::light( const std::string &name, const std::string &handle, const IECore::CompoundDataMap ¶meters ) -{ - msg( Msg::Warning, "Renderer::light", "Not implemented" ); -} - -void IECoreGL::Renderer::illuminate( const std::string &lightHandle, bool on ) -{ - msg( Msg::Warning, "Renderer::illuminate", "Not implemented" ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// motion -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -void IECoreGL::Renderer::motionBegin( const std::set × ) -{ - msg( Msg::Warning, "Renderer::motionBegin", "Not implemented" ); -} - -void IECoreGL::Renderer::motionEnd() -{ - msg( Msg::Warning, "Renderer::motionEnd", "Not implemented" ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// primitives -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -template< typename T > -static bool checkCulling( RendererImplementation *r, const T *p ) -{ - const Imath::Box3f &cullBox = r->getState()->value(); - if ( cullBox.isEmpty() ) - { - // culling is disabled... p should be rendered. - return true; - } - - Imath::Box3f b = p->bound(); - switch( r->getState()->value() ) - { - case ObjectSpace : - // if in local space we don't have to transform bounding box of p. - break; - case WorldSpace : - // transform procedural bounding box to world space to match culling box space. - b = Imath::transform( b, r->getTransform() ); - break; - default : - msg( Msg::Warning, "Renderer::checkCulling", "Unnexpected culling space!" ); - return true; - } - return cullBox.intersects( b ); -} - -static void addPrimVarsToPrimitive( IECoreGL::PrimitivePtr primitive, const IECore::PrimitiveVariableMap &primVars ) -{ - // add primVars to the gl primitive - for( IECore::PrimitiveVariableMap::const_iterator it=primVars.begin(); it!=primVars.end(); it++ ) - { - try - { - primitive->addPrimitiveVariable( it->first, it->second ); - } - catch( const std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "Renderer::addPrimitive", boost::format( "Failed to add primitive variable %s (%s)." ) % it->first % e.what() ); - } - } -} - -static void addCurrentInstanceChild( IECoreGL::Renderer::MemberData *data, IECoreGL::Renderable *child ) -{ - IECoreGL::GroupPtr childGroup = new IECoreGL::Group(); - childGroup->setTransform( data->transformStack.top() ); - childGroup->addChild( child ); - data->currentInstance->addChild( childGroup ); -} - -void IECoreGL::Renderer::points( size_t numPoints, const IECore::PrimitiveVariableMap &primVars ) -{ - try - { - IECore::PointsPrimitivePtr p = new IECore::PointsPrimitive( numPoints ); - p->variables = primVars; - IECoreGL::PointsPrimitivePtr prim = IECore::staticPointerCast( ToGLPointsConverter( p ).convert() ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling< IECoreGL::Primitive >( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } - } - catch( const std::exception &e ) - { - msg( Msg::Warning, "Renderer::points", e.what() ); - return; - } -} - -void IECoreGL::Renderer::disk( float radius, float z, float thetaMax, const IECore::PrimitiveVariableMap &primVars ) -{ - DiskPrimitivePtr prim = new DiskPrimitive( radius, z, thetaMax ); - addPrimVarsToPrimitive( prim, primVars ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling< IECoreGL::Primitive >( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } -} - -void IECoreGL::Renderer::curves( const IECore::CubicBasisf &basis, bool periodic, IECore::ConstIntVectorDataPtr numVertices, const IECore::PrimitiveVariableMap &primVars ) -{ - try - { - IECore::CurvesPrimitivePtr c = new IECore::CurvesPrimitive( numVertices, basis, periodic ); - c->variables = primVars; - CurvesPrimitivePtr prim = IECore::staticPointerCast( ToGLCurvesConverter( c ).convert() ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling< IECoreGL::Primitive >( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } - } - catch( const std::exception &e ) - { - msg( Msg::Warning, "Renderer::curves", e.what() ); - return; - } -} - -void IECoreGL::Renderer::text( const std::string &font, const std::string &text, float kerning, const IECore::PrimitiveVariableMap &primVars ) -{ - -#ifdef IECORE_WITH_FREETYPE - FontPtr f = 0; - MemberData::FontMap::const_iterator it = m_data->fonts.find( font ); - if( it!=m_data->fonts.end() ) - { - f = it->second; - } - else - { - IECore::SearchPath s( m_data->options.fontSearchPath ); - string file = s.find( font ).string(); - if( file!="" ) - { - try - { - IECore::FontPtr cf = new IECore::Font( file ); - cf->setResolution( 128 ); // makes for better texture resolutions - maybe it could be an option? - f = new Font( cf ); - } - catch( const std::exception &e ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::text", e.what() ); - } - } - m_data->fonts[font] = f; - } - - if( !f ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::text", boost::format( "Font \"%s\" not found." ) % font ); - return; - } - - f->coreFont()->setKerning( kerning ); - - TextPrimitivePtr prim = new TextPrimitive( text, f ); - addPrimVarsToPrimitive( prim, primVars ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling< IECoreGL::Primitive >( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } -#else - IECore::msg( IECore::Msg::Warning, "Renderer::text", "IECore was not built with FreeType support." ); -#endif // IECORE_WITH_FREETYPE -} - -void IECoreGL::Renderer::sphere( float radius, float zMin, float zMax, float thetaMax, const IECore::PrimitiveVariableMap &primVars ) -{ - SpherePrimitivePtr prim = new SpherePrimitive( radius, zMin, zMax, thetaMax ); - addPrimVarsToPrimitive( prim, primVars ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling< IECoreGL::Primitive >( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } -} - -static const std::string &imageFragmentShader() -{ - // fragment shader - static const std::string shaderCode = - "uniform sampler2D texture;" - "" - "void main()" - "{" - " gl_FragColor = texture2D( texture, gl_TexCoord[0].xy );" - "}"; - return shaderCode; -} - -/// \todo This positions images incorrectly when dataWindow!=displayWindow. This is because the texture -/// contains only the dataWindow contents, but we've positioned the card as if it will contain the whole -/// displayWindow. -void IECoreGL::Renderer::image( const Imath::Box2i &dataWindow, const Imath::Box2i &displayWindow, const IECore::PrimitiveVariableMap &primVars ) -{ - if ( m_data->currentInstance ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::image", "Images currently not supported inside instances." ); - return; - } - - ImagePrimitivePtr image = new ImagePrimitive( dataWindow, displayWindow ); - - if ( !checkCulling( m_data->implementation, image ) ) - { - return; - } - - image->variables = primVars; - - IECore::CompoundObjectPtr params = new IECore::CompoundObject(); - params->members()[ "texture" ] = image; - - ShaderStateComponentPtr shaderState = new ShaderStateComponent( m_data->shaderManager, m_data->textureLoader, "", imageFragmentShader(), params ); - - m_data->implementation->transformBegin(); - - Box3f bound = image->bound(); - V3f center = bound.center(); - - M44f xform; - xform[3][0] = center.x; - xform[3][1] = center.y; - xform[3][2] = center.z; - - xform[0][0] = boxSize( bound ).x ; - xform[1][1] = boxSize( bound ).y ; - xform[2][2] = 1.0; - - m_data->implementation->concatTransform( xform ); - m_data->implementation->attributeBegin(); - m_data->implementation->addState( shaderState ); - QuadPrimitivePtr quad = new QuadPrimitive( 1.0, 1.0 ); - m_data->implementation->addPrimitive( quad ); - m_data->implementation->attributeEnd(); - - m_data->implementation->transformEnd(); -} - -void IECoreGL::Renderer::mesh( IECore::ConstIntVectorDataPtr vertsPerFace, IECore::ConstIntVectorDataPtr vertIds, const std::string &interpolation, const IECore::PrimitiveVariableMap &primVars ) -{ - try - { - IECore::MeshPrimitivePtr m = new IECore::MeshPrimitive( vertsPerFace, vertIds, interpolation ); - m->variables = primVars; - - if( interpolation!="linear" ) - { - // it's a subdivision mesh. in the absence of a nice subdivision algorithm to display things with, - // we can at least make things look a bit nicer by calculating some smooth shading normals. - // if interpolation is linear and no normals are provided then we assume the faceted look is intentional. - if( primVars.find( "N" )==primVars.end() ) - { - MeshNormalsOpPtr normalOp = new MeshNormalsOp(); - normalOp->inputParameter()->setValue( m ); - normalOp->copyParameter()->setTypedValue( false ); - normalOp->operate(); - } - } - - ToGLMeshConverterPtr meshConverter = new ToGLMeshConverter( m ); - MeshPrimitivePtr prim = IECore::staticPointerCast( meshConverter->convert() ); - if ( m_data->currentInstance ) - { - addCurrentInstanceChild( m_data, prim ); - } - else if ( checkCulling( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } - } - catch( const std::exception &e ) - { - msg( Msg::Warning, "Renderer::mesh", e.what() ); - return; - } -} - -void IECoreGL::Renderer::skeleton( - IECore::ConstM44fVectorDataPtr globalMatrices, IECore::ConstIntVectorDataPtr parentIds, - bool displayAxis, float jointsSize, - const PrimitiveVariableMap &primVars ) -{ - SkeletonPrimitivePtr prim = new SkeletonPrimitive(globalMatrices, parentIds, displayAxis, jointsSize, primVars); - // m->variables = primVars; - if ( checkCulling( m_data->implementation, prim ) ) - { - m_data->implementation->addPrimitive( prim ); - } -} - -void IECoreGL::Renderer::nurbs( int uOrder, IECore::ConstFloatVectorDataPtr uKnot, float uMin, float uMax, int vOrder, IECore::ConstFloatVectorDataPtr vKnot, float vMin, float vMax, const IECore::PrimitiveVariableMap &primVars ) -{ - msg( Msg::Warning, "Renderer::nurbs", "Not implemented" ); -} - -void IECoreGL::Renderer::patchMesh( const IECore::CubicBasisf &uBasis, const IECore::CubicBasisf &vBasis, int nu, bool uPeriodic, int nv, bool vPeriodic, const IECore::PrimitiveVariableMap &primVars ) -{ - msg( Msg::Warning, "Renderer::patchMesh", "Not implemented" ); -} - -void IECoreGL::Renderer::geometry( const std::string &type, const IECore::CompoundDataMap &topology, const IECore::PrimitiveVariableMap &primVars ) -{ - if( type=="sphere" ) - { - float radius = parameterValue( "radius", topology, 1 ); - float zMin = parameterValue( "zMin", topology, -1 ); - float zMax = parameterValue( "zMax", topology, 1 ); - float thetaMax = parameterValue( "thetaMax", topology, 360 ); - sphere( radius, zMin, zMax, thetaMax, primVars ); - } - else - { - msg( Msg::Warning, "Renderer::geometry", boost::format( "Geometry type \"%s\" not implemented." ) % type ); - } -} - -void IECoreGL::Renderer::procedural( IECore::Renderer::ProceduralPtr proc ) -{ - if ( m_data->currentInstance ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::procedural", "Procedurals currently not supported inside instances." ); - return; - } - if ( checkCulling( m_data->implementation, proc ) ) - { - m_data->implementation->addProcedural( proc, this ); - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// instancing -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -void IECoreGL::Renderer::instanceBegin( const std::string &name, const IECore::CompoundDataMap ¶meters ) -{ - if ( m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::instanceBegin", "Unsupported instanceBegin call after worldBegin." ); - return; - } - if ( m_data->currentInstance ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::instanceBegin", "Instance already being defined!" ); - return; - } - MemberData::InstanceMap::const_iterator it = m_data->instances.find( name ); - if ( it != m_data->instances.end() ) - { - msg( Msg::Warning, "Renderer::instance", boost::format( "Overwriting instance named \"%s\"." ) % name ); - return; - } - m_data->currentInstance = new Group(); - m_data->instances[ name ] = m_data->currentInstance; -} - -void IECoreGL::Renderer::instanceEnd() -{ - if ( m_data->inWorld ) - { - msg( Msg::Warning, "Renderer::instanceEnd", "Unsupported instanceEnd call after worldBegin." ); - return; - } - if ( !m_data->currentInstance ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::instanceEnd", "instanceEnd called when no instances are being defined!" ); - return; - } - m_data->currentInstance = 0; -} - -void IECoreGL::Renderer::instance( const std::string &name ) -{ - MemberData::InstanceMap::iterator it = m_data->instances.find( name ); - if ( it == m_data->instances.end() ) - { - msg( Msg::Warning, "Renderer::instance", boost::format( "No instance named \"%s\" was found." ) % name ); - return; - } - if ( m_data->currentInstance ) - { - // instance called within another instance - addCurrentInstanceChild( m_data, it->second ); - } - else if ( m_data->inWorld ) - { - m_data->implementation->addInstance( it->second ); - } - else - { - msg( Msg::Warning, "Renderer::instance", "Unsupported call to instance outside world and instance block!" ); - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// commands -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -typedef IECore::DataPtr (*Command)( const std::string &name, const IECore::CompoundDataMap ¶meters, IECoreGL::Renderer::MemberData *memberData ); -typedef std::map CommandMap; - -bool removeObjectWalk( IECoreGL::GroupPtr parent, IECoreGL::GroupPtr child, const std::string &objectName ) -{ - ConstNameStateComponentPtr stateName = child->getState()->get(); - if( stateName && stateName->name()==objectName ) - { - if( parent ) - { - IECoreGL::Group::Mutex::scoped_lock lock( parent->mutex() ); - parent->removeChild( child ); - } - else - { - // no parent, ie we're at the root of the Scene. just remove all the children. - IECoreGL::Group::Mutex::scoped_lock lock( child->mutex() ); - child->clearChildren(); - } - return true; - } - - bool result = false; - IECoreGL::Group::Mutex::scoped_lock lock( child->mutex() ); - IECoreGL::Group::ChildContainer::const_iterator it = child->children().begin(); - while( it!=child->children().end() ) - { - IECoreGL::GroupPtr g = IECore::runTimeCast( *it ); - it++; - if( g ) - { - result = result | removeObjectWalk( child, g, objectName ); - } - } - if ( result && child->children().size() == 0 && parent ) - { - // group after removal became empty, remove it too. - IECoreGL::Group::Mutex::scoped_lock lock( parent->mutex() ); - parent->removeChild( child ); - } - return result; -} - -IECore::DataPtr removeObjectCommand( const std::string &name, const IECore::CompoundDataMap ¶meters, IECoreGL::Renderer::MemberData *memberData ) -{ - DeferredRendererImplementationPtr r = runTimeCast( memberData->implementation ); - if( !r ) - { - msg( Msg::Warning, "Renderer::command", "removeObject command operates only in deferred mode" ); - return 0; - } - - string objectName = parameterValue( "name", parameters, "" ); - if( objectName=="" ) - { - msg( Msg::Warning, "Renderer::command", "removeObject command expects StringData parameter \"name\"" ); - return 0; - } - - ScenePtr scene = r->scene(); - bool result = removeObjectWalk( 0, r->scene()->root(), objectName ); - - return new IECore::BoolData( result ); -} - -IECore::DataPtr editBeginCommand( const std::string &name, const IECore::CompoundDataMap ¶meters, IECoreGL::Renderer::MemberData *memberData ) -{ - DeferredRendererImplementationPtr r = runTimeCast( memberData->implementation ); - if( !r ) - { - msg( Msg::Warning, "Renderer::command", "editBeginCommand command operates only in deferred mode" ); - return 0; - } - - memberData->inWorld = true; - return new IECore::BoolData( true ); -} - -IECore::DataPtr editEndCommand( const std::string &name, const IECore::CompoundDataMap ¶meters, IECoreGL::Renderer::MemberData *memberData ) -{ - DeferredRendererImplementationPtr r = runTimeCast( memberData->implementation ); - if( !r ) - { - msg( Msg::Warning, "Renderer::command", "editEndCommand command operates only in deferred mode" ); - return 0; - } - - memberData->inWorld = false; - return new IECore::BoolData( true ); -} - -static const CommandMap &commands() -{ - static CommandMap c; - if( !c.size() ) - { - c["removeObject"] = removeObjectCommand; - c["editBegin"] = editBeginCommand; - c["editEnd"] = editEndCommand; - } - return c; -} - -IECore::DataPtr IECoreGL::Renderer::command( const std::string &name, const IECore::CompoundDataMap ¶meters ) -{ - if ( m_data->currentInstance ) - { - IECore::msg( IECore::Msg::Warning, "Renderer::command", "Commands not supported inside instances." ); - return 0; - } - const CommandMap &c = commands(); - CommandMap::const_iterator it = c.find( name ); - if( it!=c.end() ) - { - return it->second( name, parameters, m_data ); - } - - if( name.compare( 0, 3, "gl:" )==0 || name.find( ':' )==string::npos ) - { - msg( Msg::Warning, "Renderer::command", boost::format( "Unsuppported command \"%s\"." ) % name ); - return 0; - } - - return 0; -} - -IECoreGL::ShaderManager *IECoreGL::Renderer::shaderManager() -{ - return m_data->shaderManager; -} - -IECoreGL::TextureLoader *IECoreGL::Renderer::textureLoader() -{ - return m_data->textureLoader; -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/SkeletonPrimitive.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/SkeletonPrimitive.cpp deleted file mode 100644 index 155cd4d849..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/SkeletonPrimitive.cpp +++ /dev/null @@ -1,233 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreGL/GL.h" -#include "IECoreGL/State.h" -#include "IECoreGL/SpherePrimitive.h" -#include "IECoreGL/ConePrimitive.h" -#include "IECore/PrimitiveVariable.h" -#include "IECoreGL/SkeletonPrimitive.h" - -#include "OpenEXR/ImathMatrixAlgo.h" - -using namespace IECoreGL; -using namespace Imath; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( SkeletonPrimitive ); - - -SkeletonPrimitive::SkeletonPrimitive() : - m_parentIds( new IECore::IntVectorData ), - m_globalMatrices( new IECore::M44fVectorData ) -{ - m_jointsAxis = false; - m_jointsRadius = 1.0; -} - -SkeletonPrimitive::SkeletonPrimitive( - IECore::ConstM44fVectorDataPtr globalMatrices, IECore::ConstIntVectorDataPtr parentIds, - bool displayAxis, float jointsSize, const IECore::PrimitiveVariableMap &primVars) -{ - m_parentIds = parentIds->copy(); - m_globalMatrices = globalMatrices->copy(); - - IECore::PrimitiveVariableMap primVarsCopy = primVars; - - m_jointsAxis = displayAxis; - m_jointsRadius = jointsSize; - - synchVectorIds(); -} - -SkeletonPrimitive::~SkeletonPrimitive() -{ - -} - -void SkeletonPrimitive::addPrimitiveVariable( const std::string &name, const IECore::PrimitiveVariable &primVar ) -{ - if ( primVar.interpolation==IECore::PrimitiveVariable::Constant ) - { - addUniformAttribute( name, primVar.data ); - } - if ( primVar.interpolation==IECore::PrimitiveVariable::Uniform ) - { - addUniformAttribute( name, primVar.data ); - } - if ( primVar.interpolation==IECore::PrimitiveVariable::Vertex ) - { - addVertexAttribute( name, primVar.data ); - } - if ( primVar.interpolation==IECore::PrimitiveVariable::FaceVarying ) - { - addVertexAttribute( name, primVar.data ); - } -} - -void SkeletonPrimitive::render( const State *state, IECore::TypeId style ) const -{ - Imath::V3f from_vec(0.0, 0.0, 1.0), up(0.0, 1.0, 0.0); - JointPrimitive jointPrimitive( m_jointsRadius, 1.0 ); - - // loop over global transforms - for (unsigned int i=0; ireadable().size(); i++) - { - Imath::M44f child_mtx; - - unsigned int numChildren = m_childrenIds[i].size(); - if (numChildren > 0) - { - for (unsigned int j=0; j< numChildren; j++ ) - { - child_mtx = m_globalMatrices->readable()[ m_childrenIds[i][j] ]; - - Imath::V3f aim_vec = child_mtx.translation() - m_globalMatrices->readable()[i].translation(); - float bone_length = aim_vec.length(); - jointPrimitive.setLength( bone_length ); - - Imath::V3f up_vec = up*m_globalMatrices->readable()[i] - m_globalMatrices->readable()[i].translation(); - - Imath::M44f bone_mtx = Imath::rotationMatrixWithUpDir( from_vec, aim_vec.normalize(), up_vec ); - Imath::M44f bone_offset_mtx; - bone_offset_mtx.translate( m_globalMatrices->readable()[i].translation() ); - - // draw the jointPrimitive - glPushMatrix(); - glMultMatrixf( bone_offset_mtx.getValue() ); - glMultMatrixf( bone_mtx.getValue() ); - jointPrimitive.render( state, style ); - glPopMatrix(); - } - } - else - { - // a Null or Locator shape when the joint has no children - glPushMatrix(); - Imath::M44f mat = m_globalMatrices->readable()[i]; - Imath::removeScaling(mat, false); - glMultMatrixf( mat.getValue() ); - glBegin( GL_LINES ); - glVertex3f(-m_jointsRadius, 0.0, 0.0); - glVertex3f( m_jointsRadius, 0.0, 0.0); - glEnd(); - glBegin( GL_LINES ); - glVertex3f(0.0, -m_jointsRadius, 0.0); - glVertex3f(0.0, m_jointsRadius, 0.0); - glEnd(); - glBegin( GL_LINES ); - glVertex3f(0.0, 0.0, -m_jointsRadius); - glVertex3f(0.0, 0.0, m_jointsRadius); - glEnd(); - glPopMatrix(); - } - - if ( m_jointsAxis == true) - { - float l = m_jointsRadius*3.0; - - //// draw the axis lines for debug porpose ///// - glPushMatrix(); - Imath::M44f matNoSCale = m_globalMatrices->readable()[i]; - Imath::removeScaling(matNoSCale, false); - glMultMatrixf( matNoSCale.getValue() ); - - ///// store the current color and lighting mode ///// - GLboolean light; - float color[4]; - glGetBooleanv(GL_LIGHTING, &light); - glGetFloatv(GL_CURRENT_COLOR, color); - - glDisable(GL_LIGHTING); - glBegin( GL_LINES ); - glColor3ub(255, 0, 0); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(l, 0.0, 0.0); - glEnd(); - glBegin( GL_LINES ); - glColor3ub(0, 255, 0); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(0.0, l, 0.0); - glEnd(); - glBegin( GL_LINES ); - glColor3ub(0, 0, 255); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(0.0, 0.0, l); - glEnd(); - - //// restore the color and the lighting modo to their initial state ///// - glColor4f(color[0], color[1], color[2], color[3]); - if (light==true) { glEnable(GL_LIGHTING); } - glPopMatrix(); - } - } -} - -Imath::Box3f SkeletonPrimitive::bound() const -{ - Imath::Box3f bbox; - for (unsigned int i=0; ireadable().size(); i++) - { - bbox.extendBy( m_globalMatrices->readable()[i].translation() ); - } - - //std::cerr << bbox.min << ", " << bbox.max << std::endl; - - // add a little on for joint radius - bbox.extendBy( bbox.max + Imath::V3f(1,1,1) ); - bbox.extendBy( bbox.min - Imath::V3f(1,1,1) ); - - //std::cerr << bbox.min << ", " << bbox.max << std::endl; - - return bbox; -} - -void SkeletonPrimitive::synchVectorIds() -{ - m_childrenIds.resize( m_parentIds->readable().size() ); - - for (unsigned int i=0; ireadable().size(); i++) - { - int thisParentId = m_parentIds->readable()[i]; - if ( thisParentId >= 0) - { - m_childrenIds[ thisParentId ].push_back( i ); - } - } -} - - diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/bindings/JointPrimitiveBinding.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/bindings/JointPrimitiveBinding.cpp deleted file mode 100644 index 40ab14a85d..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECoreGL/bindings/JointPrimitiveBinding.cpp +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreGL/bindings/JointPrimitiveBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; - -namespace IECoreGL -{ - -void bindJointPrimitive() -{ - IECorePython::RunTimeTypedClass() - .def( init( (arg( "radius" ) = 1.0, arg( "length" ) = 1.0) ) ) - .def( "setRadius", &JointPrimitive::setRadius ) - .def( "getRadius", &JointPrimitive::getRadius ) - .def( "setLength", &JointPrimitive::setLength ) - .def( "getLength", &JointPrimitive::getLength ) - .def( "bound", &JointPrimitive::bound ) - //.def( "render", &JointPrimitive::render ) - ; -} - -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/SkeletonPrimitiveBinding.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/SkeletonPrimitiveBinding.cpp deleted file mode 100644 index aebd6f6af8..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/SkeletonPrimitiveBinding.cpp +++ /dev/null @@ -1,106 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECore/SkeletonPrimitive.h" -#include "IECorePython/SkeletonPrimitiveBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECore; - -namespace IECorePython -{ - void bindSkeletonPrimitive() - { - RunTimeTypedClass skeletonPrimitiveWrap = RunTimeTypedClass(); - - scope skeletonPrimitiveScope(skeletonPrimitiveWrap); - - enum_("Space") - .value("Local", SkeletonPrimitive::Local) - .value("Reference", SkeletonPrimitive::Reference) - .value("World", SkeletonPrimitive::World) - ; - - skeletonPrimitiveWrap - .def( init<>() ) - .def( init< ConstSkeletonPrimitivePtr >() ) - .def( init< ConstM44fVectorDataPtr, ConstIntVectorDataPtr, SkeletonPrimitive::Space >() ) - - .def( "isEqualTo", &SkeletonPrimitive::isEqualTo ) - .def( "bound", &SkeletonPrimitive::bound ) - .def( "variableSize", &SkeletonPrimitive::variableSize ) - - .def( "setAsCopyOf", &SkeletonPrimitive::setAsCopyOf ) - .def( "isSimilarTo", &SkeletonPrimitive::isSimilarTo ) - - .def( "addJoint", make_function(&SkeletonPrimitive::addJoint, default_call_policies(), (arg("parentId"), arg("name")="joint")) ) - .def( "numJoints", &SkeletonPrimitive::numJoints ) - - .def( "setJointPoses", make_function(&SkeletonPrimitive::setJointPoses, default_call_policies(), (arg("poses"), arg("space")=SkeletonPrimitive::World) ) ) - .def( "setJointPose", make_function(&SkeletonPrimitive::setJointPose, default_call_policies(), (arg("jointId"), arg("pose"), arg("space")=SkeletonPrimitive::World) ) ) - - .def( "getJointPoses", make_function(&SkeletonPrimitive::getJointPoses, default_call_policies(), arg("space")=SkeletonPrimitive::World) ) - .def( "getJointPose", make_function(&SkeletonPrimitive::getJointPose, default_call_policies(), (arg("jointId"), arg("space")=SkeletonPrimitive::World) ) ) - - .def( "getParentIds", &SkeletonPrimitive::getParentIds ) - .def( "getParentId", &SkeletonPrimitive::getParentId ) - .def( "getChildrenIds", &SkeletonPrimitive::getChildrenIds ) - - .def( "setJointNames", &SkeletonPrimitive::setJointNames ) - .def( "setJointName", &SkeletonPrimitive::setJointName ) - .def( "getJointNames", &SkeletonPrimitive::getJointNames ) - .def( "getJointName", &SkeletonPrimitive::getJointName ) - - .def( "shareStaticData", &SkeletonPrimitive::shareStaticData ) - .def( "shareAnimatableData", &SkeletonPrimitive::shareAnimatableData ) - - .def( "pullUpdate", &SkeletonPrimitive::pullUpdate ) - .def( "pushUpdate", &SkeletonPrimitive::pushUpdate ) - .def( "getRootJointId", make_function(&SkeletonPrimitive::getRootJointId, default_call_policies(), arg("fromId")=0) ) - .def( "update", &SkeletonPrimitive::update ) - - .def( "setRadius", &SkeletonPrimitive::setRadius ) - .def( "setDebug", &SkeletonPrimitive::setDebug ) - .def( "getRadius", &SkeletonPrimitive::getRadius ) - .def( "getDebug", &SkeletonPrimitive::getDebug ) - - .def( "createHuman", &SkeletonPrimitive::createHuman ).staticmethod( "createHuman" ) - ; - } - -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/TypeIdBinding.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/TypeIdBinding.cpp deleted file mode 100644 index ae5b29d599..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePython/TypeIdBinding.cpp +++ /dev/null @@ -1,379 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECore/TypeIds.h" -#include "IECorePython/TypeIdBinding.h" - -using namespace boost::python; -using namespace IECore; - -namespace IECorePython -{ - -void bindTypeId() -{ - enum_( "TypeId") - .value( "Invalid", InvalidTypeId ) - .value( "Object", ObjectTypeId ) - .value( "Data", DataTypeId ) - .value( "FloatVectorData", FloatVectorDataTypeId ) - .value( "DoubleVectorData", DoubleVectorDataTypeId ) - .value( "IntVectorData", IntVectorDataTypeId ) - .value( "UIntVectorData", UIntVectorDataTypeId ) - .value( "CharVectorData", CharVectorDataTypeId ) - .value( "UCharVectorData", UCharVectorDataTypeId ) - .value( "V2fVectorData", V2fVectorDataTypeId ) - .value( "V2dVectorData", V2dVectorDataTypeId ) - .value( "V3fVectorData", V3fVectorDataTypeId ) - .value( "V3dVectorData", V3dVectorDataTypeId ) - .value( "Box3fVectorData", Box3fVectorDataTypeId ) - .value( "Box3dVectorData", Box3dVectorDataTypeId ) - .value( "M33fVectorData", M33fVectorDataTypeId ) - .value( "M33dVectorData", M33dVectorDataTypeId ) - .value( "M44fVectorData", M44fVectorDataTypeId ) - .value( "M44dVectorData", M44dVectorDataTypeId ) - .value( "QuatfVectorData", QuatfVectorDataTypeId ) - .value( "QuatdVectorData", QuatdVectorDataTypeId ) - .value( "StringVectorData", StringVectorDataTypeId ) - .value( "FloatData", FloatDataTypeId ) - .value( "DoubleData", DoubleDataTypeId ) - .value( "IntData", IntDataTypeId ) - .value( "UIntData", UIntDataTypeId ) - .value( "CharData", CharDataTypeId ) - .value( "UCharData", UCharDataTypeId ) - .value( "StringData",StringDataTypeId ) - .value( "CompoundData", CompoundDataTypeId ) - .value( "V2iData", V2iDataTypeId ) - .value( "V2fData", V2fDataTypeId ) - .value( "V3fData", V3fDataTypeId ) - .value( "V2dData", V2dDataTypeId ) - .value( "V3dData", V3dDataTypeId ) - .value( "Box2fData", Box2fDataTypeId ) - .value( "Box3fData", Box3fDataTypeId ) - .value( "Box2dData", Box2dDataTypeId ) - .value( "Box3dData", Box3dDataTypeId ) - .value( "M44fData", M44fDataTypeId ) - .value( "M44dData", M44dDataTypeId ) - .value( "QuatfData", QuatfDataTypeId ) - .value( "QuatdData", QuatdDataTypeId ) - .value( "Color3fData", Color3fDataTypeId ) - .value( "Color4fData", Color4fDataTypeId ) - .value( "Color3dData", Color3dDataTypeId ) - .value( "Color4dData", Color4dDataTypeId ) - .value( "Color3fVectorData", Color3fVectorDataTypeId ) - .value( "Color4fVectorData", Color4fVectorDataTypeId ) - .value( "Color3dVectorData", Color3dVectorDataTypeId ) - .value( "Color4dVectorData", Color4dVectorDataTypeId ) - .value( "BlindDataHolder", BlindDataHolderTypeId ) - .value( "Renderable", RenderableTypeId ) - .value( "CompoundObject", CompoundObjectTypeId ) - .value( "M33fData", M33fDataTypeId ) - .value( "M33dData", M33dDataTypeId ) - .value( "Box2fVectorData", Box2fVectorDataTypeId ) - .value( "Box2dVectorData", Box2dVectorDataTypeId ) - .value( "BoolData", BoolDataTypeId ) - .value( "Primitive", PrimitiveTypeId ) - .value( "PointsPrimitive", PointsPrimitiveTypeId ) - .value( "ImagePrimitive", ImagePrimitiveTypeId ) - .value( "MeshPrimitive", MeshPrimitiveTypeId ) - .value( "Box2iData", Box2iDataTypeId ) - .value( "HalfVectorData", HalfVectorDataTypeId ) - .value( "Shader", ShaderTypeId ) - .value( "RunTimeTyped", RunTimeTypedTypeId ) - .value( "Parameter", ParameterTypeId ) - .value( "CompoundParameter", CompoundParameterTypeId ) - .value( "StringParameter", StringParameterTypeId ) - .value( "ValidatedStringParameter", ValidatedStringParameterTypeId ) - .value( "FileNameParameter", FileNameParameterTypeId ) - .value( "IntParameter", IntParameterTypeId ) - .value( "FloatParameter", FloatParameterTypeId ) - .value( "DoubleParameter", DoubleParameterTypeId ) - .value( "BoolParameter", BoolParameterTypeId ) - .value( "V2fParameter", V2fParameterTypeId ) - .value( "V3fParameter", V3fParameterTypeId ) - .value( "V2dParameter", V2dParameterTypeId ) - .value( "V3dParameter", V3dParameterTypeId ) - .value( "Color3fParameter", Color3fParameterTypeId ) - .value( "Color4fParameter", Color4fParameterTypeId ) - .value( "Box2iParameter", Box2iParameterTypeId ) - .value( "Box2fParameter", Box2fParameterTypeId ) - .value( "Box3fParameter", Box3fParameterTypeId ) - .value( "Box2dParameter", Box2dParameterTypeId ) - .value( "Box3dParameter", Box3dParameterTypeId ) - .value( "M44fParameter", M44fParameterTypeId ) - .value( "M44dParameter", M44dParameterTypeId ) - .value( "IntVectorParameter", IntVectorParameterTypeId ) - .value( "FloatVectorParameter", FloatVectorParameterTypeId ) - .value( "DoubleVectorParameter", DoubleVectorParameterTypeId ) - .value( "StringVectorParameter", StringVectorParameterTypeId ) - .value( "V2fVectorParameter", V2fVectorParameterTypeId ) - .value( "V3fVectorParameter", V3fVectorParameterTypeId ) - .value( "V2dVectorParameter", V2dVectorParameterTypeId ) - .value( "V3dVectorParameter", V3dVectorParameterTypeId ) - .value( "Box3fVectorParameter", Box3fVectorParameterTypeId ) - .value( "Box3dVectorParameter", Box3dVectorParameterTypeId ) - .value( "M33fVectorParameter", M33fVectorParameterTypeId ) - .value( "M44fVectorParameter", M44fVectorParameterTypeId ) - .value( "M33dVectorParameter", M33dVectorParameterTypeId ) - .value( "M44dVectorParameter", M44dVectorParameterTypeId ) - .value( "QuatfVectorParameter", QuatfVectorParameterTypeId ) - .value( "QuatdVectorParameter", QuatdVectorParameterTypeId ) - .value( "Color3fVectorParameter", Color3fVectorParameterTypeId ) - .value( "Color4fVectorParameter", Color4fVectorParameterTypeId ) - .value( "NullObject", NullObjectTypeId ) - .value( "Parameterised", ParameterisedTypeId ) - .value( "Op", OpTypeId ) - .value( "Reader", ReaderTypeId ) - .value( "Writer", WriterTypeId ) - .value( "ImageReader", ImageReaderTypeId ) - .value( "ImageWriter", ImageWriterTypeId ) - .value( "CINImageReader", CINImageReaderTypeId ) - .value( "CINImageWriter", CINImageWriterTypeId ) - .value( "DPXImageReader", DPXImageReaderTypeId ) - .value( "DPXImageWriter", DPXImageWriterTypeId ) - .value( "EXRImageReader", EXRImageReaderTypeId ) - .value( "EXRImageWriter", EXRImageWriterTypeId ) - .value( "JPEGImageReader", JPEGImageReaderTypeId ) - .value( "JPEGImageWriter", JPEGImageWriterTypeId ) - .value( "TIFFImageReader", TIFFImageReaderTypeId ) - .value( "TIFFImageWriter", TIFFImageWriterTypeId ) - .value( "ObjectReader", ObjectReaderTypeId ) - .value( "ObjectWriter", ObjectWriterTypeId ) - .value( "PDCParticleReader", PDCParticleReaderTypeId ) - .value( "PDCParticleWriter", PDCParticleWriterTypeId ) - .value( "PathParameter", PathParameterTypeId ) - .value( "DirNameParameter", DirNameParameterTypeId ) - .value( "V3iData", V3iDataTypeId ) - .value( "Renderer", RendererTypeId ) - .value( "Box3iData", Box3iDataTypeId ) - .value( "ObjectParameter", ObjectParameterTypeId ) - .value( "ModifyOp", ModifyOpTypeId ) - .value( "ImageOp", ImageOpTypeId ) - .value( "PrimitiveOp", PrimitiveOpTypeId ) - .value( "Procedural", ProceduralTypeId ) - .value( "Box3iParameter", Box3iParameterTypeId ) - .value( "V2iParameter", V2iParameterTypeId ) - .value( "V3iParameter", V3iParameterTypeId ) - .value( "ParticleReader", ParticleReaderTypeId ) - .value( "ParticleWriter", ParticleWriterTypeId ) - .value( "MotionPrimitive", MotionPrimitiveTypeId ) - .value( "Transform", TransformTypeId ) - .value( "MatrixTransform", MatrixTransformTypeId ) - .value( "MotionTransform", MotionTransformTypeId ) - .value( "MatrixMotionTransform", MatrixMotionTransformTypeId ) - .value( "Group", GroupTypeId ) - .value( "AttributeState", AttributeStateTypeId ) - .value( "VisibleRenderable", VisibleRenderableTypeId ) - .value( "StateRenderable", StateRenderableTypeId ) - .value( "OBJReader", OBJReaderTypeId ) - .value( "TransformationMatrixfData", TransformationMatrixfDataTypeId ) - .value( "TransformationMatrixdData", TransformationMatrixdDataTypeId ) - .value( "PointNormalsOp", PointNormalsOpTypeId ) - .value( "PointDensitiesOp", PointDensitiesOpTypeId ) - .value( "BoolVectorData", BoolVectorDataTypeId ) - .value( "VectorDataFilterOp", VectorDataFilterOpTypeId ) - .value( "RenderableParameter", RenderableParameterTypeId ) - .value( "StateRenderableParameter", StateRenderableParameterTypeId ) - .value( "AttributeStateParameter", AttributeStateParameterTypeId ) - .value( "ShaderParameter", ShaderParameterTypeId ) - .value( "TransformParameter", TransformParameterTypeId ) - .value( "MatrixMotionTransformParameter", MatrixMotionTransformParameterTypeId ) - .value( "MatrixTransformParameter", MatrixTransformParameterTypeId ) - .value( "VisibleRenderableParameter", VisibleRenderableParameterTypeId ) - .value( "GroupParameter", GroupParameterTypeId ) - .value( "MotionPrimitiveParameter", MotionPrimitiveParameterTypeId ) - .value( "PrimitiveParameter", PrimitiveParameterTypeId ) - .value( "ImagePrimitiveParameter", ImagePrimitiveParameterTypeId ) - .value( "MeshPrimitiveParameter", MeshPrimitiveParameterTypeId ) - .value( "PointsPrimitiveParameter", PointsPrimitiveParameterTypeId ) - .value( "PreWorldRenderable", PreWorldRenderableTypeId ) - .value( "Camera", CameraTypeId ) - .value( "NURBSPrimitive", NURBSPrimitiveTypeId ) - .value( "DataCastOp", DataCastOpTypeId ) - .value( "DataPromoteOp", DataPromoteOpTypeId ) - .value( "MatrixMultiplyOp", MatrixMultiplyOpTypeId ) - .value( "PointBoundsOp", PointBoundsOpTypeId ) - .value( "RandomRotationOp", RandomRotationOpTypeId ) - .value( "V2iVectorData", V2iVectorDataTypeId ) - .value( "V3iVectorData", V3iVectorDataTypeId ) - .value( "PointMeshOp", PointMeshOpTypeId ) - .value( "ParticleMeshOp", ParticleMeshOpTypeId ) - .value( "HalfData", HalfDataTypeId ) - .value( "MeshPrimitiveOp", MeshPrimitiveOpTypeId ) - .value( "PrimitiveEvaluator", PrimitiveEvaluatorTypeId ) - .value( "MeshPrimitiveEvaluator", MeshPrimitiveEvaluatorTypeId ) - .value( "MeshPrimitiveImplicitSurfaceOp", MeshPrimitiveImplicitSurfaceOpTypeId ) - .value( "TriangulateOp", TriangulateOpTypeId ) - .value( "SpherePrimitiveEvaluator", SpherePrimitiveEvaluatorTypeId ) - .value( "SpherePrimitive", SpherePrimitiveTypeId ) - .value( "Converter", ConverterTypeId ) - .value( "ToCoreConverter", ToCoreConverterTypeId ) - .value( "ImageCropOp", ImageCropOpTypeId ) - .value( "MeshPrimitiveShrinkWrapOp", MeshPrimitiveShrinkWrapOpTypeId ) - .value( "ImagePrimitiveEvaluator", ImagePrimitiveEvaluatorTypeId ) - .value( "FromCoreConverter", FromCoreConverterTypeId ) - .value( "ShortData", ShortDataTypeId ) - .value( "UShortData", UShortDataTypeId ) - .value( "ShortVectorData", ShortVectorDataTypeId ) - .value( "UShortVectorData", UShortVectorDataTypeId ) - .value( "PathVectorParameter", PathVectorParameterTypeId ) - .value( "TransformOp", TransformOpTypeId ) - .value( "CurvesPrimitive", CurvesPrimitiveTypeId ) - .value( "ImageDiffOp", ImageDiffOpTypeId ) - .value( "MeshNormalsOp", MeshNormalsOpTypeId ) - .value( "Font", FontTypeId ) - .value( "MeshMergeOp", MeshMergeOpTypeId ) - .value( "UniformRandomPointDistributionOp", UniformRandomPointDistributionOpTypeId ) - .value( "Int64Data", Int64DataTypeId ) - .value( "UInt64Data", UInt64DataTypeId ) - .value( "Int64VectorData", Int64VectorDataTypeId ) - .value( "UInt64VectorData", UInt64VectorDataTypeId ) - .value( "MappedRandomPointDistributionOp", MappedRandomPointDistributionOpTypeId ) - .value( "PointRepulsionOp", PointRepulsionOpTypeId ) - .value( "LuminanceOp", LuminanceOpTypeId ) - .value( "ImagePrimitiveOp", ImagePrimitiveOpTypeId ) - .value( "ChannelOp", ChannelOpTypeId ) - .value( "SummedAreaOp", SummedAreaOpTypeId ) - .value( "Box2iVectorData", Box2iVectorDataTypeId ) - .value( "Box3iVectorData", Box3iVectorDataTypeId ) - .value( "MedianCutSampler", MedianCutSamplerTypeId ) - .value( "EnvMapSampler", EnvMapSamplerTypeId ) - .value( "MeshVertexReorderOp", MeshVertexReorderOpTypeId ) - .value( "SplineffData", SplineffDataTypeId ) - .value( "SplineddData", SplineddDataTypeId ) - .value( "SplinefColor3fData", SplinefColor3fDataTypeId ) - .value( "SplinefColor4fData", SplinefColor4fDataTypeId ) - .value( "SplineffParameter", SplineffParameterTypeId ) - .value( "SplineddParameter", SplineddParameterTypeId ) - .value( "SplinefColor3fParameter", SplinefColor3fParameterTypeId ) - .value( "SplinefColor4fParameter", SplinefColor4fParameterTypeId ) - .value( "CompoundObjectParameter", CompoundObjectParameterTypeId ) - .value( "DisplayDriver", DisplayDriverTypeId ) - .value( "DisplayDriverCreator", DisplayDriverCreatorTypeId ) - .value( "ImageDisplayDriver", ImageDisplayDriverTypeId ) - .value( "ClientDisplayDriver", ClientDisplayDriverTypeId ) - .value( "DisplayDriverServer", DisplayDriverServerTypeId ) - .value( "CoordinateSystem", CoordinateSystemTypeId ) - .value( "SplineToImage", SplineToImageTypeId ) - .value( "Display", DisplayTypeId ) - .value( "MeshTangentsOp", MeshTangentsOpTypeId ) - .value( "WarpOp", WarpOpTypeId ) - .value( "UVDistortOp", UVDistortOpTypeId ) - .value( "BoolVectorParameter", BoolVectorParameterTypeId ) - .value( "ObjectVector", ObjectVectorTypeId ) - .value( "ObjectVectorParameter", ObjectVectorParameterTypeId ) - .value( "YUVImageWriter", YUVImageWriterTypeId ) - .value( "ImageCompositeOp", ImageCompositeOpTypeId ) - .value( "ImagePremultiplyOp", ImagePremultiplyOpTypeId ) - .value( "ImageUnpremultiplyOp", ImageUnpremultiplyOpTypeId ) - .value( "DateTimeData", DateTimeDataTypeId ) - .value( "DateTimeParameter", DateTimeParameterTypeId ) - .value( "SGIImageReader", SGIImageReaderTypeId ) - .value( "TimeDurationData", TimeDurationDataTypeId ) - .value( "TimeDurationParameter", TimeDurationParameterTypeId ) - .value( "TimePeriodData", TimePeriodDataTypeId ) - .value( "TimePeriodParameter", TimePeriodParameterTypeId ) - .value( "PatchMeshPrimitive", PatchMeshPrimitiveTypeId ) - .value( "CurvesPrimitiveParameter", CurvesPrimitiveParameterTypeId ) - .value( "CurveExtrudeOp", CurveExtrudeOpTypeId ) - .value( "FrameList", FrameListTypeId ) - .value( "EmptyFrameList", EmptyFrameListTypeId ) - .value( "FrameRange", FrameRangeTypeId ) - .value( "CompoundFrameList", CompoundFrameListTypeId ) - .value( "ReorderedFrameList", ReorderedFrameListTypeId ) - .value( "BinaryFrameList", BinaryFrameListTypeId ) - .value( "ReversedFrameList", ReversedFrameListTypeId ) - .value( "ExclusionFrameList", ExclusionFrameListTypeId ) - .value( "FrameListParameter", FrameListParameterTypeId ) - .value( "FileSequence", FileSequenceTypeId ) - .value( "FileSequenceParameter", FileSequenceParameterTypeId ) - .value( "FileSequenceVectorParameter", FileSequenceVectorParameterTypeId ) - .value( "ParameterisedProcedural", ParameterisedProceduralTypeId ) - .value( "TGAImageReader", TGAImageReaderTypeId ) - .value( "TGAImageWriter", TGAImageWriterTypeId ) - .value( "BINParticleReader", BINParticleReaderTypeId ) - .value( "BINParticleWriter", BINParticleWriterTypeId ) - .value( "BINMeshReader", BINMeshReaderTypeId ) - .value( "BGEOParticleReader", BGEOParticleReaderTypeId ) - .value( "NParticleReader", NParticleReaderTypeId ) - .value( "IFFImageReader", IFFImageReaderTypeId ) - .value( "IFFHairReader", IFFHairReaderTypeId ) - .value( "FaceAreaOp", FaceAreaOpTypeId ) - .value( "CurvesMergeOp", CurvesMergeOpTypeId ) - .value( "CurvesPrimitiveOp", CurvesPrimitiveOpTypeId ) - .value( "CurvesPrimitiveEvaluator", CurvesPrimitiveEvaluatorTypeId ) - .value( "HdrMergeOp", HdrMergeOpTypeId ) - .value( "HitMissTransform", HitMissTransformTypeId ) - .value( "CurveTracer", CurveTracerTypeId ) - .value( "ImageThinner", ImageThinnerTypeId ) - .value( "CurveLineariser", CurveLineariserTypeId ) - .value( "CompoundDataBase", CompoundDataBaseTypeId ) - .value( "ImageConvolveOp", ImageConvolveOpTypeId ) - .value( "ClassParameter", ClassParameterTypeId ) - .value( "ClassVectorParameter", ClassVectorParameterTypeId ) - .value( "CurveTangentsOp", CurveTangentsOpTypeId ) - .value( "MarschnerParameter", MarschnerParameterTypeId ) - .value( "MarschnerLookupTableOp", MarschnerLookupTableOpTypeId ) - .value( "SmoothSkinningData", SmoothSkinningDataTypeId ) - .value( "FaceVaryingPromotionOp", FaceVaryingPromotionOpTypeId ) - .value( "MeshDistortionsOp", MeshDistortionsOpTypeId ) - .value( "PointVelocityDisplaceOp", PointVelocityDisplaceOpTypeId ) - .value( "SmoothSkinningDataParameter", SmoothSkinningDataParameterTypeId ) - .value( "CompressSmoothSkinningDataOp", CompressSmoothSkinningDataOpTypeId ) - .value( "DecompressSmoothSkinningDataOp", DecompressSmoothSkinningDataOpTypeId ) - .value( "NormalizeSmoothSkinningWeightsOp", NormalizeSmoothSkinningWeightsOpTypeId ) - .value( "ReorderSmoothSkinningInfluencesOp", ReorderSmoothSkinningInfluencesOpTypeId ) - .value( "RemoveSmoothSkinningInfluencesOp", RemoveSmoothSkinningInfluencesOpTypeId ) - .value( "SmoothSmoothSkinningWeightsOp", SmoothSmoothSkinningWeightsOpTypeId ) - .value( "MixSmoothSkinningWeightsOp", MixSmoothSkinningWeightsOpTypeId ) - .value( "PointSmoothSkinningOp", PointSmoothSkinningOpTypeId ) - .value( "AddSmoothSkinningInfluencesOp", AddSmoothSkinningInfluencesOpTypeId ) - .value( "LimitSmoothSkinningInfluencesOp", LimitSmoothSkinningInfluencesOpTypeId ) - .value( "PointsPrimitiveEvaluator", PointsPrimitiveEvaluatorTypeId ) - .value( "SkeletonPrimitive", SkeletonPrimitiveTypeId ) - .value( "SkeletonPrimitiveParameter", SkeletonPrimitiveParameterTypeId ) - .value( "SkeletonPrimitiveOp", SkeletonPrimitiveOpTypeId ) - .value( "MatrixModifyOp", MatrixModifyOpTypeId ) - .value( "MeshPrimitiveSmoothSkinningOp", MeshPrimitiveSmoothSkinningOpTypeId ) - .value( "TransformationMatrixfParameter", TransformationMatrixfParameterTypeId ) - .value( "TransformationMatrixdParameter", TransformationMatrixdParameterTypeId ) - ; -} - -} diff --git a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePythonModule/IECore.cpp b/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePythonModule/IECore.cpp deleted file mode 100644 index f3eb1f10b9..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/src/IECorePythonModule/IECore.cpp +++ /dev/null @@ -1,560 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/RefCountedBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" -#include "IECorePython/ExceptionBinding.h" -#include "IECorePython/ImathBinding.h" -#include "IECorePython/KDTreeBinding.h" -#include "IECorePython/IndexedIOInterfaceBinding.h" -#include "IECorePython/DataBinding.h" -#include "IECorePython/SimpleTypedDataBinding.h" -#include "IECorePython/VectorTypedDataBinding.h" -#include "IECorePython/ObjectBinding.h" -#include "IECorePython/TypeIdBinding.h" -#include "IECorePython/CompoundDataBinding.h" -#include "IECorePython/MessageHandlerBinding.h" -#include "IECorePython/AttributeCacheBinding.h" -#include "IECorePython/ReaderBinding.h" -#include "IECorePython/ParticleReaderBinding.h" -#include "IECorePython/PDCParticleReaderBinding.h" -#include "IECorePython/BlindDataHolderBinding.h" -#include "IECorePython/RenderableBinding.h" -#include "IECorePython/VisibleRenderableBinding.h" -#include "IECorePython/StateRenderableBinding.h" -#include "IECorePython/RendererBinding.h" -#include "IECorePython/WriterBinding.h" -#include "IECorePython/ParticleWriterBinding.h" -#include "IECorePython/PDCParticleWriterBinding.h" -#include "IECorePython/ParameterBinding.h" -#include "IECorePython/NumericParameterBinding.h" -#include "IECorePython/SimpleTypedParameterBinding.h" -#include "IECorePython/VectorTypedParameterBinding.h" -#include "IECorePython/SplineParameterBinding.h" -#include "IECorePython/DateTimeParameterBinding.h" -#include "IECorePython/TimePeriodParameterBinding.h" -#include "IECorePython/TimeDurationParameterBinding.h" -#include "IECorePython/CompoundParameterBinding.h" -#include "IECorePython/ValidatedStringParameterBinding.h" -#include "IECorePython/PathParameterBinding.h" -#include "IECorePython/FileNameParameterBinding.h" -#include "IECorePython/DirNameParameterBinding.h" -#include "IECorePython/CompoundObjectBinding.h" -#include "IECorePython/ObjectReaderBinding.h" -#include "IECorePython/ObjectWriterBinding.h" -#include "IECorePython/PrimitiveBinding.h" -#include "IECorePython/PrimitiveVariableBinding.h" -#include "IECorePython/PointsPrimitiveBinding.h" -#include "IECorePython/TimerBinding.h" -#include "IECorePython/TurbulenceBinding.h" -#include "IECorePython/ShaderBinding.h" -#include "IECorePython/SearchPathBinding.h" -#include "IECorePython/CachedReaderBinding.h" -#include "IECorePython/ParameterisedBinding.h" -#include "IECorePython/OpBinding.h" -#include "IECorePython/ObjectParameterBinding.h" -#include "IECorePython/ModifyOpBinding.h" -#include "IECorePython/PrimitiveOpBinding.h" -#include "IECorePython/ImagePrimitiveBinding.h" -#include "IECorePython/ImageReaderBinding.h" -#include "IECorePython/ImageWriterBinding.h" -#include "IECorePython/PerlinNoiseBinding.h" -#include "IECorePython/EXRImageReaderBinding.h" -#include "IECorePython/EXRImageWriterBinding.h" -#include "IECorePython/HalfBinding.h" -#include "IECorePython/TIFFImageReaderBinding.h" -#include "IECorePython/TIFFImageWriterBinding.h" -#include "IECorePython/CINImageReaderBinding.h" -#include "IECorePython/CINImageWriterBinding.h" -#include "IECorePython/DPXImageReaderBinding.h" -#include "IECorePython/DPXImageWriterBinding.h" -#include "IECorePython/JPEGImageReaderBinding.h" -#include "IECorePython/JPEGImageWriterBinding.h" -#include "IECorePython/TGAImageReaderBinding.h" -#include "IECorePython/TGAImageWriterBinding.h" -#include "IECorePython/MeshPrimitiveBinding.h" -#include "IECorePython/MotionPrimitiveBinding.h" -#include "IECorePython/TransformBinding.h" -#include "IECorePython/MatrixTransformBinding.h" -#include "IECorePython/GroupBinding.h" -#include "IECorePython/AttributeStateBinding.h" -#include "IECorePython/MatrixMotionTransformBinding.h" -#include "IECorePython/OBJReaderBinding.h" -#include "IECorePython/NullObjectBinding.h" -#include "IECorePython/ObjectInterpolatorBinding.h" -#include "IECorePython/PointNormalsOpBinding.h" -#include "IECorePython/PointDensitiesOpBinding.h" -#include "IECorePython/InterpolatedCacheBinding.h" -#include "IECorePython/TransformationMatrixBinding.h" -#include "IECorePython/TransformationMatrixDataBinding.h" -#include "IECorePython/HierarchicalCacheBinding.h" -#include "IECorePython/BoundedKDTreeBinding.h" -#include "IECorePython/VectorDataFilterOpBinding.h" -#include "IECorePython/TypedObjectParameterBinding.h" -#include "IECorePython/TypedPrimitiveParameterBinding.h" -#include "IECorePython/HeaderGeneratorBinding.h" -#include "IECorePython/PreWorldRenderableBinding.h" -#include "IECorePython/CameraBinding.h" -#include "IECorePython/NURBSPrimitiveBinding.h" -#include "IECorePython/DataCastOpBinding.h" -#include "IECorePython/DataPromoteOpBinding.h" -#include "IECorePython/MatrixMultiplyOpBinding.h" -#include "IECorePython/PointBoundsOpBinding.h" -#include "IECorePython/PointVelocityDisplaceOpBinding.h" -#include "IECorePython/ImathRandomBinding.h" -#include "IECorePython/RandomRotationOpBinding.h" -#include "IECorePython/ImplicitSurfaceFunctionBinding.h" -#include "IECorePython/CachedImplicitSurfaceFunctionBinding.h" -#include "IECorePython/MeshPrimitiveBuilderBinding.h" -#include "IECorePython/MarchingCubesBinding.h" -#include "IECorePython/PointMeshOpBinding.h" -#include "IECorePython/CSGImplicitSurfaceFunctionBinding.h" -#include "IECorePython/SphereImplicitSurfaceFunctionBinding.h" -#include "IECorePython/PlaneImplicitSurfaceFunctionBinding.h" -#include "IECorePython/BlobbyImplicitSurfaceFunctionBinding.h" -#include "IECorePython/ZhuBridsonImplicitSurfaceFunctionBinding.h" -#include "IECorePython/ParticleMeshOpBinding.h" -#include "IECorePython/TypedPrimitiveOpBinding.h" -#include "IECorePython/PrimitiveEvaluatorBinding.h" -#include "IECorePython/MeshPrimitiveEvaluatorBinding.h" -#include "IECorePython/PrimitiveImplicitSurfaceFunctionBinding.h" -#include "IECorePython/MeshPrimitiveImplicitSurfaceFunctionBinding.h" -#include "IECorePython/MeshPrimitiveImplicitSurfaceOpBinding.h" -#include "IECorePython/TriangulateOpBinding.h" -#include "IECorePython/InternedBinding.h" -#include "IECorePython/SpherePrimitiveBinding.h" -#include "IECorePython/SpherePrimitiveEvaluatorBinding.h" -#include "IECorePython/InverseDistanceWeightedInterpolationBinding.h" -#include "IECorePython/ImageCropOpBinding.h" -#include "IECorePython/MeshPrimitiveShrinkWrapOpBinding.h" -#include "IECorePython/ImagePrimitiveEvaluatorBinding.h" -#include "IECorePython/ScopedMessageHandlerBinding.h" -#include "IECorePython/MathBinding.h" -#include "IECorePython/CameraControllerBinding.h" -#include "IECorePython/PathVectorParameterBinding.h" -#include "IECorePython/TriangleAlgoBinding.h" -#include "IECorePython/ConverterBinding.h" -#include "IECorePython/FromCoreConverterBinding.h" -#include "IECorePython/TransformOpBinding.h" -#include "IECorePython/LineSegmentBinding.h" -#include "IECorePython/CubicBasisBinding.h" -#include "IECorePython/CurvesPrimitiveBinding.h" -#include "IECorePython/ImageDiffOpBinding.h" -#include "IECorePython/TriangulatorBinding.h" -#include "IECorePython/BezierAlgoBinding.h" -#include "IECorePython/ToCoreConverterBinding.h" -#include "IECorePython/MeshNormalsOpBinding.h" -#include "IECorePython/PolygonAlgoBinding.h" -#include "IECorePython/MeshMergeOpBinding.h" -#include "IECorePython/FontBinding.h" -#include "IECorePython/UniformRandomPointDistributionOpBinding.h" -#include "IECorePython/UnicodeToStringBinding.h" -#include "IECorePython/MappedRandomPointDistributionOpBinding.h" -#include "IECorePython/RadixSortBinding.h" -#include "IECorePython/PointRepulsionOpBinding.h" -#include "IECorePython/AngleConversionBinding.h" -#include "IECorePython/LuminanceOpBinding.h" -#include "IECorePython/ChannelOpBinding.h" -#include "IECorePython/SummedAreaOpBinding.h" -#include "IECorePython/MedianCutSamplerBinding.h" -#include "IECorePython/EnvMapSamplerBinding.h" -#include "IECorePython/MeshVertexReorderOpBinding.h" -#include "IECorePython/SplineBinding.h" -#include "IECorePython/SplineDataBinding.h" -#include "IECorePython/DisplayDriverBinding.h" -#include "IECorePython/ImageDisplayDriverBinding.h" -#include "IECorePython/CoordinateSystemBinding.h" -#include "IECorePython/ClientDisplayDriverBinding.h" -#include "IECorePython/DisplayDriverServerBinding.h" -#include "IECorePython/SplineToImageBinding.h" -#include "IECorePython/DisplayBinding.h" -#include "IECorePython/MeshTangentsOpBinding.h" -#include "IECorePython/WarpOpBinding.h" -#include "IECorePython/UVDistortOpBinding.h" -#include "IECorePython/ObjectVectorBinding.h" -#include "IECorePython/HenyeyGreensteinBinding.h" -#include "IECorePython/YUVImageWriterBinding.h" -#include "IECorePython/ImageCompositeOpBinding.h" -#include "IECorePython/ImagePremultiplyOpBinding.h" -#include "IECorePython/ImageUnpremultiplyOpBinding.h" -#include "IECorePython/OversamplesCalculatorBinding.h" -#include "IECorePython/DateTimeDataBinding.h" -#include "IECorePython/SGIImageReaderBinding.h" -#include "IECorePython/TimeDurationDataBinding.h" -#include "IECorePython/TimePeriodBinding.h" -#include "IECorePython/TimePeriodDataBinding.h" -#include "IECorePython/PatchMeshPrimitiveBinding.h" -#include "IECorePython/CurveExtrudeOpBinding.h" -#include "IECorePython/FrameListBinding.h" -#include "IECorePython/EmptyFrameListBinding.h" -#include "IECorePython/FrameRangeBinding.h" -#include "IECorePython/CompoundFrameListBinding.h" -#include "IECorePython/ReorderedFrameListBinding.h" -#include "IECorePython/BinaryFrameListBinding.h" -#include "IECorePython/ReversedFrameListBinding.h" -#include "IECorePython/ExclusionFrameListBinding.h" -#include "IECorePython/FrameListParameterBinding.h" -#include "IECorePython/FileSequenceBinding.h" -#include "IECorePython/FileSequenceFunctionsBinding.h" -#include "IECorePython/FileSequenceParameterBinding.h" -#include "IECorePython/FileSequenceVectorParameterBinding.h" -#include "IECorePython/ParameterisedProceduralBinding.h" -#include "IECorePython/LevenbergMarquardtBinding.h" -#include "IECorePython/BINParticleWriterBinding.h" -#include "IECorePython/BINMeshReaderBinding.h" -#include "IECorePython/BGEOParticleReaderBinding.h" -#include "IECorePython/NParticleReaderBinding.h" -#include "IECorePython/IFFHairReaderBinding.h" -#include "IECorePython/FaceAreaOpBinding.h" -#include "IECorePython/CurvesMergeOpBinding.h" -#include "IECorePython/CurvesPrimitiveEvaluatorBinding.h" -#include "IECorePython/HdrMergeOpBinding.h" -#include "IECorePython/PointDistributionBinding.h" -#include "IECorePython/HitMissTransformBinding.h" -#include "IECorePython/CurveTracerBinding.h" -#include "IECorePython/ImageThinnerBinding.h" -#include "IECorePython/CurveLineariserBinding.h" -#include "IECorePython/ImageConvolveOpBinding.h" -#include "IECorePython/CurveTangentsOpBinding.h" -#include "IECorePython/MarschnerParameterBinding.h" -#include "IECorePython/MarschnerLookupTableOpBinding.h" -#include "IECorePython/SmoothSkinningDataBinding.h" -#include "IECorePython/FaceVaryingPromotionOpBinding.h" -#include "IECorePython/MeshDistortionsOpBinding.h" -#include "IECorePython/PointVelocityDisplaceOpBinding.h" -#include "IECorePython/HexConversionBinding.h" -#include "IECorePython/CompressSmoothSkinningDataOpBinding.h" -#include "IECorePython/DecompressSmoothSkinningDataOpBinding.h" -#include "IECorePython/ReorderSmoothSkinningInfluencesOpBinding.h" -#include "IECorePython/NormalizeSmoothSkinningWeightsOpBinding.h" -#include "IECorePython/LimitSmoothSkinningInfluencesOpBinding.h" -#include "IECorePython/MixSmoothSkinningWeightsOpBinding.h" -#include "IECorePython/SmoothSmoothSkinningWeightsOpBinding.h" -#include "IECorePython/PointSmoothSkinningOpBinding.h" -#include "IECorePython/AddSmoothSkinningInfluencesOpBinding.h" -#include "IECorePython/RemoveSmoothSkinningInfluencesOpBinding.h" -#include "IECorePython/LookupBinding.h" -#include "IECorePython/PointsPrimitiveEvaluatorBinding.h" -#include "IECorePython/SkeletonPrimitiveBinding.h" -#include "IECorePython/MatrixModifyOpBinding.h" -#include "IECorePython/MeshPrimitiveSmoothSkinningOpBinding.h" -#include "IECore/IECore.h" - -using namespace IECorePython; -using namespace boost::python; - -// Module declaration - -BOOST_PYTHON_MODULE(_IECore) -{ - bindRefCounted(); - bindRunTimeTyped(); - bindException(); - bindImath(); - bindKDTree(); - bindObject(); - bindCompoundObject(); - bindTypeId(); - bindData(); - bindAllSimpleTypedData(); - bindAllVectorTypedData(); - bindCompoundData(); - bindIndexedIO(); - bindMessageHandler(); - bindAttributeCache(); - bindParameterised(); - bindOp(); - bindReader(); - bindParticleReader(); - bindPDCParticleReader(); - bindBlindDataHolder(); - bindRenderable(); - bindStateRenderable(); - bindVisibleRenderable(); - bindRenderer(); - bindWriter(); - bindParticleWriter(); - bindPDCParticleWriter(); - bindObjectReader(); - bindObjectWriter(); - bindParameter(); - bindNumericParameter(); - bindSimpleTypedParameter(); - bindVectorTypedParameter(); - bindSplineParameter(); - bindDateTimeParameter(); - bindTimePeriodParameter(); - bindTimeDurationParameter(); - bindCompoundParameter(); - bindValidatedStringParameter(); - bindPathParameter(); - bindFileNameParameter(); - bindDirNameParameter(); - bindPrimitive(); - bindPrimitiveVariable(); - bindPointsPrimitive(); - bindPerlinNoise(); - bindHalf(); - bindTimer(); - bindTurbulence(); - bindShader(); - bindSearchPath(); - bindCachedReader(); - bindObjectParameter(); - bindModifyOp(); - bindPrimitiveOp(); - bindImagePrimitive(); - bindImageReader(); - bindImageWriter(); - bindEXRImageReader(); - bindEXRImageWriter(); - -#ifdef IECORE_WITH_TIFF - bindTIFFImageReader(); - bindTIFFImageWriter(); -#endif - - bindCINImageReader(); - bindCINImageWriter(); - bindDPXImageReader(); - bindDPXImageWriter(); - -#ifdef IECORE_WITH_JPEG - bindJPEGImageReader(); - bindJPEGImageWriter(); -#endif - - bindTGAImageReader(); - bindTGAImageWriter(); - - bindMeshPrimitive(); - bindMotionPrimitive(); - bindTransform(); - bindMatrixTransform(); - bindMatrixMotionTransform(); - bindGroup(); - bindAttributeState(); - bindNullObject(); - bindObjectInterpolator(); - bindPointNormalsOp(); - bindPointDensitiesOp(); - bindOversamplesCalculator(); - bindInterpolatedCache(); - bindTransformationMatrix(); - bindTransformationMatrixData(); - bindHierarchicalCache(); - bindBoundedKDTree(); - bindVectorDataFilterOp(); - bindTypedObjectParameter(); - bindTypedPrimitiveParameter(); - bindHeaderGenerator(); - bindPreWorldRenderable(); - bindCamera(); - bindNURBSPrimitive(); - bindDataCastOp(); - bindDataPromoteOp(); - bindMatrixMultiplyOp(); - bindPointBoundsOp(); - bindImathRandom(); - bindRandomRotationOp(); - bindImplicitSurfaceFunction(); - bindCachedImplicitSurfaceFunction(); - bindMeshPrimitiveBuilder(); - bindMarchingCubes(); - bindPointMeshOp(); - bindCSGImplicitSurfaceFunction(); - bindSphereImplicitSurfaceFunction(); - bindPlaneImplicitSurfaceFunction(); - bindBlobbyImplicitSurfaceFunction(); - bindZhuBridsonImplicitSurfaceFunction(); - bindParticleMeshOp(); - bindTypedPrimitiveOp(); - bindPrimitiveEvaluator(); - bindMeshPrimitiveEvaluator(); - bindPrimitiveImplicitSurfaceFunction(); - bindMeshPrimitiveImplicitSurfaceFunction(); - bindMeshPrimitiveImplicitSurfaceOp(); - bindTriangulateOp(); - bindInterned(); - bindSpherePrimitive(); - bindSpherePrimitiveEvaluator(); - bindInverseDistanceWeightedInterpolation(); - bindImageCropOp(); - bindMeshPrimitiveShrinkWrapOp(); - bindImagePrimitiveEvaluator(); - bindScopedMessageHandler(); - bindMath(); - bindCameraController(); - bindPathVectorParameter(); - bindTriangleAlgo(); - bindConverter(); - bindFromCoreConverter(); - bindTransformOp(); - bindLineSegment(); - bindCubicBasis(); - bindCurvesPrimitive(); - bindImageDiffOp(); - bindTriangulator(); - bindBezierAlgo(); - bindToCoreConverter(); - bindMeshNormalsOp(); - bindPolygonAlgo(); - bindMeshMergeOp(); - -#ifdef IECORE_WITH_FREETYPE - - bindFont(); - -#endif - - bindUniformRandomPointDistributionOp(); - bindUnicodeToString(); - bindMappedRandomPointDistributionOp(); - bindRadixSort(); - bindPointRepulsionOp(); - bindAngleConversion(); - bindLuminanceOp(); - bindChannelOp(); - bindSummedAreaOp(); - bindMedianCutSampler(); - bindEnvMapSampler(); - bindMeshVertexReorderOp(); - bindSpline(); - bindSplineData(); - bindCoordinateSystem(); - -#ifdef IECORE_WITH_ASIO - - bindDisplayDriver(); - bindImageDisplayDriver(); - bindClientDisplayDriver(); - bindDisplayDriverServer(); - // see note in Sconstruct re IECORE_WITH_ASIO and OBJReader - bindOBJReader(); - -#endif - - bindSplineToImage(); - bindDisplay(); - bindMeshTangentsOp(); - bindWarpOp(); - bindUVDistortOp(); - bindObjectVector(); - bindHenyeyGreenstein(); - bindYUVImageWriter(); - bindImagePremultiplyOp(); - bindImageUnpremultiplyOp(); - bindImageCompositeOp(); - bindDateTimeData(); - bindSGIImageReader(); - bindTimeDurationData(); - bindTimePeriod(); - bindTimePeriodData(); - bindPatchMeshPrimitive(); - bindCurveExtrudeOp(); - bindFrameList(); - bindEmptyFrameList(); - bindFrameRange(); - bindCompoundFrameList(); - bindReorderedFrameList(); - bindBinaryFrameList(); - bindReversedFrameList(); - bindExclusionFrameList(); - bindFrameListParameter(); - bindFileSequence(); - bindFileSequenceFunctions(); - bindFileSequenceParameter(); - bindFileSequenceVectorParameter(); - bindParameterisedProcedural(); - bindLevenbergMarquardt(); - bindBINParticleWriter(); - bindBINMeshReader(); - bindBGEOParticleReader(); - bindNParticleReader(); - bindIFFHairReader(); - bindFaceAreaOp(); - bindCurvesMergeOp(); - bindCurvesPrimitiveEvaluator(); - bindHdrMergeOp(); - bindPointDistribution(); - bindHitMissTransform(); - bindCurveTracer(); - bindImageThinner(); - bindCurveLineariser(); - bindCurveTangentsOp(); - bindMarschnerParameter(); - bindMarschnerLookupTableOp(); - bindSmoothSkinningData(); - bindFaceVaryingPromotionOp(); - bindPointVelocityDisplaceOp(); - bindSkeletonPrimitive(); - bindMatrixModifyOp(); - bindMeshPrimitiveSmoothSkinningOp(); - -#ifdef IECORE_WITH_BOOSTFACTORIAL - - bindImageConvolveOp(); - -#endif - - bindMeshDistortionsOp(); - bindPointVelocityDisplaceOp(); - bindHexConversion(); - bindCompressSmoothSkinningDataOp(); - bindDecompressSmoothSkinningDataOp(); - bindReorderSmoothSkinningInfluencesOp(); - bindNormalizeSmoothSkinningWeightsOp(); - bindLimitSmoothSkinningInfluencesOp(); - bindMixSmoothSkinningWeightsOp(); - bindSmoothSmoothSkinningWeightsOp(); - bindPointSmoothSkinningOp(); - bindAddSmoothSkinningInfluencesOp(); - bindRemoveSmoothSkinningInfluencesOp(); - bindLookup(); - bindPointsPrimitiveEvaluator(); - - def( "majorVersion", &IECore::majorVersion ); - def( "minorVersion", &IECore::minorVersion ); - def( "patchVersion", &IECore::patchVersion ); - def( "versionString", &IECore::versionString, return_value_policy() ); - def( "withASIO", &IECore::withASIO ); - def( "withFreeType", &IECore::withFreeType ); - -} - diff --git a/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/All.py b/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/All.py deleted file mode 100644 index 918891014b..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/All.py +++ /dev/null @@ -1,256 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import warnings -import sys - -import IECore - -warnings.simplefilter( "error", DeprecationWarning ) - -from ClassLoader import * -from AttributeCache import * -from HierarchicalCache import * -from BlindDataHolder import * -from CompoundData import * -from CompoundObject import * -from Imath import * -from ImathVectorData import * -from IndexedIO import * -from KDTree import * -from BoundedKDTree import * -from MessageHandler import * -from ObjectIO import * -from Object import * -from ObjectReader import * -from ObjectWriter import * -from ParameterParser import * -from Parameterised import * -from Parameters import * -from PDCReader import * -from PDCWriter import * -from SimpleTypedData import * -from TypedDataAsObject import * -from VectorData import * -from FileSequence import * -from EXRImageReader import * -from EXRImageWriter import * -from PointsPrimitive import * -from ImagePrimitive import * -from PerlinNoise import * -from Turbulence import * -from MeshPrimitive import * -from Shader import * -from SearchPath import * -from CachedReader import * -from Reader import * -from RunTimeTyped import * -from Op import * -from MemoryUsage import * -from FileSequenceParameter import * -from WrapperToPython import * -from RemovePrimitiveVariables import * -from RenamePrimitiveVariables import * -from WrapperGarbageCollection import * -from FormattedParameterHelp import * -from MotionPrimitive import * -from Transform import * -from Group import * -from NamespacePollution import * -from OptionalCompoundParameter import * -from ObjectInterpolation import * -from InterpolatedCache import * -from TransformationMatrixData import * -from ReversedFrameList import * -from BinaryFrameList import * -from PointsExpressionOp import * -from FrameList import * -from FrameListParameter import * -from Struct import * -from Enum import * -from HeaderGenerator import * -from Camera import * -from NURBS import * -from Curry import * -from Menus import * -from DataCastOp import * -from DataPromoteOp import * -from MatrixMultiplyOp import * -from PointBoundsOp import * -from PointVelocityDisplaceOp import * -from ImplicitSurfaceFunction import * -from CachedImplicitSurfaceFunction import * -from MarchingCubes import * -from PointMeshOp import * -from CSGImplicitSurfaceFunction import * -from ParticleMeshOp import * -from PrimitiveEvaluator import * -from MeshPrimitiveEvaluator import * -from PrimitiveImplicitSurfaceFunction import * -from MeshPrimitiveImplicitSurfaceOp import * -from Interned import * -from Writer import * -from TriangulateOp import * -from SpherePrimitiveEvaluator import * -from SearchReplaceOp import * -from CINImageReader import * -from CINImageWriter import * -from DPXImageReader import * -from DPXImageWriter import * -from InverseDistanceWeightedInterpolation import * -from ImageCropOp import * -from MeshPrimitiveShrinkWrapOp import * -from ImagePrimitiveEvaluator import * -from CapturingMessageHandler import * -from FileExaminer import * -from Math import * -from FileSequenceVectorParameter import * -from TriangleAlgoTest import * -from TransformOpTest import * -from LineSegmentTest import * -from CubicBasisTest import * -from CurvesPrimitiveTest import * -from ImageDiffOp import * -from TriangulatorTest import * -from BezierAlgoTest import * -from MeshNormalsOpTest import * -from PrimitiveTest import * -from MeshMergeOpTest import * -from UniformRandomPointDistributionOpTest import * -from UnicodeToStringTest import * -from MappedRandomPointDistributionOpTest import * -from RadixSortTest import * -from ImathRootsTest import * -from AngleConversionTest import * -from LuminanceOpTest import * -from SummedAreaOpTest import * -from MedianCutSamplerTest import * -from EnvMapSamplerTest import * -from RandomTest import * -from MeshVertexReorderOpTest import * -from SplineTest import * -from SplineDataTest import * -from TypeIdTest import * -from LayeredDictTest import * -from SplineParameterTest import * -from AttributeStateTest import * -from CoordinateSystemTest import * -from SplineToImageTest import * -from DisplayTest import * -from MeshTangentsOpTest import * -from CompoundVectorParameterTest import * -from UVDistortOpTest import * -from ObjectVectorTest import * -from ImagePremultiplyOpTest import * -from ImageUnpremultiplyOpTest import * -from ImageCompositeOpTest import * -from ImageSequenceCompositeOpTest import * -from YUVImageWriter import * -from OversamplesCalculatorTest import * -from DateTimeDataTest import * -from DateTimeParameterTest import * -from SequenceLsOpTest import * -from SGIImageReaderTest import * -from TimeDurationDataTest import * -from TimePeriodDataTest import * -from PatchMeshPrimitiveTest import * -from CurveExtrudeOp import * -from ParameterisedProceduralTest import * -from LevenbergMarquardtTest import * -from TypedDataTest import * -from DataTraitsTest import * -from TGAImageReaderTest import * -from TGAImageWriterTest import * -from BINParticleWriterTest import * -from BINMeshReaderTest import * -from BGEOParticleReader import * -from NParticleReader import * -from IFFHairReader import * -from FaceAreaOpTest import FaceAreaOpTest -from CurvesMergeOpTest import CurvesMergeOpTest -from CurvesPrimitiveEvaluatorTest import CurvesPrimitiveEvaluatorTest -from SubstitutedDictTest import SubstitutedDictTest -from PointDistributionTest import PointDistributionTest -from HitMissTransformTest import HitMissTransformTest -from CurveTracerTest import CurveTracerTest -from ImageThinnerTest import ImageThinnerTest -from CurveLineariserTest import CurveLineariserTest -from IDXReaderTest import IDXReaderTest -from ThreadingTest import ThreadingTest -from ImageConvolveOpTest import * -from StringUtilTest import * -from ClassParameterTest import ClassParameterTest -from ClassVectorParameterTest import ClassVectorParameterTest -from CurveTangentsOpTest import CurveTangentsOpTest -from MarschnerLookupTableOpTest import MarschnerLookupTableOpTest -from SmoothSkinningDataTest import * -from IgnoredExceptionsTest import IgnoredExceptionsTest -from PrimitiveVariableTest import PrimitiveVariableTest -from FaceVaryingPromotionOpTest import FaceVaryingPromotionOpTest -from MeshDistortionsOpTest import TestMeshDistortionsOp -from PointVelocityDisplaceOp import * -from HexConversionTest import HexConversionTest -from CompressAndDecompressSmoothSkinningDataOpsTest import CompressAndDecompressSmoothSkinningDataOpsTest -from BasicPreset import TestBasicPreset -from ReorderSmoothSkinningInfluencesOpTest import ReorderSmoothSkinningInfluencesOpTest -from NormalizeSmoothSkinningWeightsOpTest import NormalizeSmoothSkinningWeightsOpTest -from LimitSmoothSkinningInfluencesOpTest import LimitSmoothSkinningInfluencesOpTest -from MixSmoothSkinningWeightsOpTest import MixSmoothSkinningWeightsOpTest -from SmoothSmoothSkinningWeightsOpTest import SmoothSmoothSkinningWeightsOpTest -from SkeletonPrimitiveTest import SkeletonPrimitiveTests -from PointSmoothSkinningOpTest import TestPointSmoothSkinningOpTest -from AddAndRemoveSmoothSkinningInfluencesOpTest import AddAndRemoveSmoothSkinningInfluencesOpTest -from LookupTest import LookupTest -from ParameterAlgoTest import ParameterAlgoTest -from PointsPrimitiveEvaluatorTest import PointsPrimitiveEvaluatorTest - - -if IECore.withASIO() : - from DisplayDriverTest import * - -if IECore.withFreeType() : - from FontTest import * - -unittest.TestProgram( - testRunner = unittest.TextTestRunner( - stream = IECore.CompoundStream( - [ - sys.stderr, - open( "test/IECore/resultsPython.txt", "w" ) - ] - ), - verbosity = 2 - ) -) diff --git a/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/SkeletonPrimitiveTest.py b/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/SkeletonPrimitiveTest.py deleted file mode 100644 index 6d72a2c100..0000000000 --- a/contrib/for_review/SkeletonPrimitive_DrD/test/IECore/SkeletonPrimitiveTest.py +++ /dev/null @@ -1,150 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - - -import unittest -import os -import IECore - -class SkeletonPrimitiveTests(unittest.TestCase): - def setUp(self): - mts = IECore.M44fVectorData() - mts.resize(10) - - ids = IECore.IntVectorData() - ids.resize(10) - - for i in range(0, 10): - ids[i] = i-1 - vec = IECore.V3f(0-i, i+1, 2*i) - mts[i] = mts[i].setTranslation(vec) - - self.skeletonPrimitive = IECore.SkeletonPrimitive(mts, ids, IECore.SkeletonPrimitive.Space.World) - - def testDefaultInitialisation(self): - sp = IECore.SkeletonPrimitive() - self.assertTrue( sp.numJoints()==0 ) # check we have no joints - self.assertEqual( sp.getJointNames(), IECore.StringVectorData() ) - self.assertTrue( sp.isEqualTo(sp) ) - self.assertTrue( sp.isSimilarTo(sp.copy()) ) - - def testCopyConstractor(self): - sp = IECore.SkeletonPrimitive(self.skeletonPrimitive) - self.assertTrue( sp.isSimilarTo(self.skeletonPrimitive) ) - - def testMatricesInitialisation(self): - mts = IECore.M44fVectorData() - mts.resize(10) - - ids = IECore.IntVectorData() - ids.resize(10) - - for i in range(0, 10): - ids[i] = i-1 - mts[i] = mts[i].setTranslation(IECore.V3f(0, i+10, 0)) - - # In World space - sp = IECore.SkeletonPrimitive(mts, ids, IECore.SkeletonPrimitive.Space.World) - assert sp.numJoints() == 10 - for i in range(0, 10): - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.World).value.translation().y - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Reference).value.translation().y - if i == 0: - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Local).value.translation().y - else: - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Local).value.translation().y - - # In Reference space - sp = IECore.SkeletonPrimitive(mts, ids, IECore.SkeletonPrimitive.Space.Reference) - assert sp.numJoints() == 10 - for i in range(0, 10): - if i==0: - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.World).value.translation().y - else: - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.World).value.translation().y - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Reference).value.translation().y - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Local).value.translation().y - - # In Local space - sp = IECore.SkeletonPrimitive(mts, ids, IECore.SkeletonPrimitive.Space.Local) - assert sp.numJoints() == 10 - for i in range(0, 10): - if i==0: - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.World).value.translation().y - else: - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.World).value.translation().y - assert mts[i].translation().y != sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Reference).value.translation().y - assert mts[i].translation().y == sp.getJointPose(i, IECore.SkeletonPrimitive.Space.Local).value.translation().y - - def testSaveLoad(self): - tempFile = os.tempnam()+".cob" - writer = IECore.Writer.create(self.skeletonPrimitive, tempFile) - writer.write() - - reader = IECore.Reader.create(tempFile) - otherSp = reader.read() - - self.assertTrue( self.skeletonPrimitive.isSimilarTo(otherSp) ) - - def testExtractingParentIds(self): - self.assertTrue( self.skeletonPrimitive.getParentId(0)==-1 ) # check the parent id of joint 0 is -1 - self.assertTrue( len( self.skeletonPrimitive.getParentIds() )==10 ) # check we get a list of 10 ids - - def testExtractingMatrices(self): - self.assertTrue( self.skeletonPrimitive.getJointPoses(IECore.SkeletonPrimitive.Space.World).size()==10 ) - self.assertTrue( self.skeletonPrimitive.getJointPoses(IECore.SkeletonPrimitive.Space.Local).size()==10 ) - self.assertTrue( self.skeletonPrimitive.getJointPoses(IECore.SkeletonPrimitive.Space.Reference).size()==10 ) - - testedMat = self.skeletonPrimitive.getJointPoses()[4] # default for getTransforms is world space - testerMat = IECore.M44f().setTranslation( IECore.V3f(-4, 5, 8) ) - # check the matrix returned - for i in range(0, 4): - for j in range(0, 4): - self.assertEqual(testedMat[i,j], testerMat[i,j]) - - def testCopy(self): - s = IECore.SkeletonPrimitive() - s.setAsCopyOf(self.skeletonPrimitive) - - s.isSimilarTo(self.skeletonPrimitive) - - -if __name__ == "__main__": - print 'Testing SkeletonPrimitive\n----------------------------------------------------------------------\n' - import sys - t = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) - unittest.main(testRunner=t) diff --git a/contrib/for_review/build_configurations/osx/SConstruct.patch b/contrib/for_review/build_configurations/osx/SConstruct.patch deleted file mode 100644 index 40fd52890c..0000000000 --- a/contrib/for_review/build_configurations/osx/SConstruct.patch +++ /dev/null @@ -1,248 +0,0 @@ -Index: SConstruct -=================================================================== ---- SConstruct (revision 4265) -+++ SConstruct (working copy) -@@ -433,6 +433,12 @@ - ) - - o.Add( -+ "INSTALL_TYPE", -+ "The host application that will be used (maya, houdini, nuke)", -+ "", -+) -+ -+o.Add( - "INSTALL_HEADER_DIR", - "The directory in which to install headers.", - "$INSTALL_PREFIX/include", -@@ -1137,7 +1143,85 @@ - - outFile.write( "\n" ) - -+ - ########################################################################################### -+ -+def update_lib_id(fname): -+ cmd ="install_name_tool -id %(fname)s %(fname)s " % locals() -+ print cmd -+ os.system(cmd) -+ -+def update_lib_ref(fname, old, new): -+ cmd ="install_name_tool -change %(old)s %(new)s %(fname)s " % locals() -+ print cmd -+ os.system(cmd) -+ -+def get_lib_references(fname): -+ p = subprocess.Popen(["otool", "-L", fname] , stdout=subprocess.PIPE ) -+ command_result = p.stdout.readlines() -+ result = {} -+ if command_result: -+ result['id'] = command_result.pop(0).strip()[:-1] -+ libs = [] -+ for lib in command_result: -+ lib = lib.strip() -+ if lib: -+ libs.append(lib.split()[0]) -+ result['refs'] = libs -+ -+ return result -+ -+def get_installed_libname(lib, env): -+ if "libboost" in lib: -+ return os.path.join(env["INSTALL_PREFIX"], "lib", lib ) -+ elif "libtbb" in lib: -+ return os.path.join( env["TBB_LIB_PATH"], lib) -+ elif "lib3delight" in lib: -+ return os.path.join( env["RMAN_ROOT"], "lib", lib) -+ elif "lib3delight" in lib: -+ return os.path.join( env["RMAN_ROOT"], "lib", lib) -+ elif "libIECore" in lib: -+ return os.path.join( env["INSTALL_PREFIX"], "lib", lib) -+ -+ elif lib == "Python": -+ if env['INSTALL_TYPE'] == "maya": -+ return os.path.join( env["MAYA_ROOT"], "Frameworks/Python.framework/Versions/2.6/Python") -+ -+ -+def fix_osx_library_references(source=None, target=None, env=None, **kwargs): -+ -+ for libfile in target: -+ fname = libfile.get_path() -+ -+ if fname.endswith(".so") or fname.endswith(".dylib") or fname.endswith(".bundle"): -+ print "processing library " + fname +" : " -+ update_lib_id(fname) -+ libinfo = get_lib_references(fname) -+ for lib in libinfo['refs']: -+ lib_basename = os.path.basename(lib) -+ if "libboost" in lib_basename: -+ target_name = get_installed_libname( lib_basename , env ) -+ if not os.path.exists( target_name ): -+ print "copying boost library", target_name -+ shutil.copy( os.path.join( env["BOOST_LIB_PATH"], lib_basename ), target_name ) -+ boost_libinfo = get_lib_references(target_name) -+ for b_lib in boost_libinfo['refs']: -+ update_lib_id( target_name ) -+ new_libname = get_installed_libname( os.path.basename(b_lib), env ) -+ if new_libname: -+ update_lib_ref(target_name, b_lib, new_libname) -+ -+ new_libname = get_installed_libname( lib_basename , env ) -+ if new_libname: -+ update_lib_ref(fname, lib, new_libname) -+ -+def run_libinstall_postactions(source=None, target=None, env=None, **kwargs): -+ if env["PLATFORM"]=="darwin" : -+ fix_osx_library_references(source=source, target=target, env=env, **kwargs) -+ -+########################################################################################### -+ -+########################################################################################### - # Build, install and test the core library and bindings - ########################################################################################### - -@@ -1231,6 +1315,7 @@ - coreLibraryInstall = coreEnv.Install( os.path.dirname( coreEnv.subst( "$INSTALL_LIB_NAME" ) ), coreLibrary ) - coreEnv.NoCache( coreLibraryInstall ) - coreEnv.AddPostAction( coreLibraryInstall, lambda target, source, env : makeLibSymLinks( coreEnv ) ) -+coreEnv.AddPostAction( coreLibraryInstall, run_libinstall_postactions ) - coreEnv.Alias( "install", [ coreLibraryInstall ] ) - coreEnv.Alias( "installCore", [ coreLibraryInstall ] ) - coreEnv.Alias( "installLib", [ coreLibraryInstall ] ) -@@ -1247,6 +1332,7 @@ - corePythonLibraryInstall = corePythonEnv.Install( os.path.dirname( corePythonEnv.subst( "$INSTALL_LIB_NAME" ) ), corePythonLibrary ) - corePythonEnv.NoCache( corePythonLibraryInstall ) - corePythonEnv.AddPostAction( corePythonLibraryInstall, lambda target, source, env : makeLibSymLinks( corePythonEnv, libNameVar="INSTALL_PYTHONLIB_NAME" ) ) -+corePythonEnv.AddPostAction( corePythonLibraryInstall , run_libinstall_postactions ) - corePythonEnv.Alias( "install", [ corePythonLibraryInstall ] ) - corePythonEnv.Alias( "installCore", [ corePythonLibraryInstall ] ) - corePythonEnv.Alias( "installLib", [ corePythonLibraryInstall ] ) -@@ -1264,6 +1350,8 @@ - - corePythonModuleInstall = corePythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECore", corePythonScripts + corePythonModule ) - corePythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECore", lambda target, source, env : makeSymLinks( corePythonEnv, corePythonEnv["INSTALL_PYTHON_DIR"] ) ) -+corePythonModuleEnv.AddPostAction( corePythonModuleInstall , run_libinstall_postactions ) -+ - corePythonModuleEnv.Alias( "install", corePythonModuleInstall ) - corePythonModuleEnv.Alias( "installCore", corePythonModuleInstall ) - -@@ -1414,6 +1502,7 @@ - riLibraryInstall = riEnv.Install( os.path.dirname( riEnv.subst( "$INSTALL_LIB_NAME" ) ), riLibrary ) - riEnv.NoCache( riLibraryInstall ) - riEnv.AddPostAction( riLibraryInstall, lambda target, source, env : makeLibSymLinks( riEnv ) ) -+ riEnv.AddPostAction( riLibraryInstall, run_libinstall_postactions ) - riEnv.Alias( "install", riLibraryInstall ) - riEnv.Alias( "installRI", riLibraryInstall ) - riEnv.Alias( "installLib", [ riLibraryInstall ] ) -@@ -1429,6 +1518,7 @@ - riPythonProceduralInstall = riEnv.Install( os.path.dirname( riPythonProceduralEnv.subst( "$INSTALL_RMANPROCEDURAL_NAME" ) ), riPythonProcedural ) - riPythonProceduralEnv.NoCache( riPythonProceduralInstall ) - riPythonProceduralEnv.AddPostAction( riPythonProceduralInstall, lambda target, source, env : makeLibSymLinks( riPythonProceduralEnv, libNameVar="INSTALL_RMANPROCEDURAL_NAME" ) ) -+ riPythonProceduralEnv.AddPostAction( riPythonProceduralInstall, run_libinstall_postactions ) - riPythonProceduralEnv.Alias( "install", riPythonProceduralInstall ) - riPythonProceduralEnv.Alias( "installRI", riPythonProceduralInstall ) - riPythonProceduralForTest = riPythonProceduralEnv.Command( "src/rmanProcedurals/python/python.so", riPythonProcedural, Copy( "$TARGET", "$SOURCE" ) ) -@@ -1438,6 +1528,7 @@ - riDisplayDriverInstall = riEnv.Install( os.path.dirname( riDisplayDriverEnv.subst( "$INSTALL_RMANDISPLAY_NAME" ) ), riDisplayDriver ) - riDisplayDriverEnv.NoCache( riDisplayDriverInstall ) - riDisplayDriverEnv.AddPostAction( riDisplayDriverInstall, lambda target, source, env : makeLibSymLinks( riDisplayDriverEnv, libNameVar="INSTALL_RMANDISPLAY_NAME" ) ) -+ riDisplayDriverEnv.AddPostAction( riDisplayDriverInstall, run_libinstall_postactions ) - riDisplayDriverEnv.Alias( "install", riDisplayDriverInstall ) - riDisplayDriverEnv.Alias( "installRI", riDisplayDriverInstall ) - riDisplayDriverForTest = riDisplayDriverEnv.Command( "src/rmanDisplays/ieDisplay/ieTestDisplay.so", riDisplayDriver, Copy( "$TARGET", "$SOURCE" ) ) -@@ -1461,6 +1552,7 @@ - - riPythonModuleInstall = riPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreRI", riPythonScripts + riPythonModule ) - riPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreRI", lambda target, source, env : makeSymLinks( riPythonModuleEnv, riPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) -+ riPythonModuleEnv.AddPostAction(riPythonModuleInstall, run_libinstall_postactions ) - riPythonModuleEnv.Alias( "install", riPythonModuleInstall ) - riPythonModuleEnv.Alias( "installRI", riPythonModuleInstall ) - -@@ -1559,6 +1651,7 @@ - glLibraryInstall = glEnv.Install( os.path.dirname( glEnv.subst( "$INSTALL_LIB_NAME" ) ), glLibrary ) - glEnv.NoCache( glLibraryInstall ) - glEnv.AddPostAction( glLibraryInstall, lambda target, source, env : makeLibSymLinks( glEnv ) ) -+ glEnv.AddPostAction( glLibraryInstall, run_libinstall_postactions ) - glEnv.Alias( "install", glLibraryInstall ) - glEnv.Alias( "installGL", glLibraryInstall ) - glEnv.Alias( "installLib", [ glLibraryInstall ] ) -@@ -1598,6 +1691,7 @@ - glPythonScripts = glob.glob( "python/IECoreGL/*.py" ) - glPythonModuleInstall = glPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreGL", glPythonScripts + glPythonModule ) - glPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreGL", lambda target, source, env : makeSymLinks( glPythonModuleEnv, glPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) -+ glPythonModuleEnv.AddPostAction(glPythonModuleInstall, run_libinstall_postactions ) - glPythonModuleEnv.Alias( "install", glPythonModuleInstall ) - glPythonModuleEnv.Alias( "installGL", glPythonModuleInstall ) - -@@ -1713,6 +1807,7 @@ - mayaLibraryInstall = mayaEnv.Install( os.path.dirname( mayaEnv.subst( "$INSTALL_MAYALIB_NAME" ) ), mayaLibrary ) - mayaEnv.NoCache( mayaLibraryInstall ) - mayaEnv.AddPostAction( mayaLibraryInstall, lambda target, source, env : makeLibSymLinks( mayaEnv, "INSTALL_MAYALIB_NAME" ) ) -+ mayaEnv.AddPostAction( mayaLibraryInstall, run_libinstall_postactions ) - mayaEnv.Alias( "install", mayaLibraryInstall ) - mayaEnv.Alias( "installMaya", mayaLibraryInstall ) - mayaEnv.Alias( "installLib", [ mayaLibraryInstall ] ) -@@ -1763,6 +1858,7 @@ - mayaPluginLoader = mayaPluginLoaderEnv.SharedLibrary( mayaPluginTarget, mayaPluginLoaderSources, SHLIBPREFIX="" ) - mayaPluginLoaderInstall = mayaPluginLoaderEnv.InstallAs( mayaPluginLoaderEnv.subst( "$INSTALL_MAYAPLUGIN_NAME$SHLIBSUFFIX" ), mayaPluginLoader ) - mayaPluginLoaderEnv.AddPostAction( mayaPluginLoaderInstall, lambda target, source, env : makeSymLinks( mayaPluginLoaderEnv, mayaPluginLoaderEnv["INSTALL_MAYAPLUGIN_NAME"] ) ) -+ mayaPluginLoaderEnv.AddPostAction( mayaPluginLoaderInstall, run_libinstall_postactions ) - mayaPluginLoaderEnv.Alias( "install", mayaPluginLoaderInstall ) - mayaPluginLoaderEnv.Alias( "installMaya", mayaPluginLoaderInstall ) - -@@ -1776,6 +1872,7 @@ - mayaPluginEnv.Depends( mayaPlugin, corePythonModule ) - - mayaPluginEnv.AddPostAction( mayaPluginInstall, lambda target, source, env : makeSymLinks( mayaPluginEnv, mayaPluginEnv["INSTALL_MAYAPLUGIN_NAME"] ) ) -+ mayaPluginEnv.AddPostAction( mayaPluginInstall, run_libinstall_postactions ) - mayaPluginEnv.Alias( "install", mayaPluginInstall ) - mayaPluginEnv.Alias( "installMaya", mayaPluginInstall ) - -@@ -1792,6 +1889,7 @@ - - mayaPythonModuleInstall = mayaPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreMaya", mayaPythonScripts + mayaPythonModule ) - mayaPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreMaya", lambda target, source, env : makeSymLinks( mayaPythonModuleEnv, mayaPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) -+ mayaPythonModuleEnv.AddPostAction(mayaPythonModuleInstall, run_libinstall_postactions ) - mayaPythonModuleEnv.Alias( "install", mayaPythonModuleInstall ) - mayaPythonModuleEnv.Alias( "installMaya", mayaPythonModuleInstall ) - -@@ -1964,6 +2062,7 @@ - nukeLibrary = nukeEnv.SharedLibrary( "lib/" + os.path.basename( nukeEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), nukeSources ) - nukeLibraryInstall = nukeEnv.Install( os.path.dirname( nukeEnv.subst( "$INSTALL_NUKELIB_NAME" ) ), nukeLibrary ) - nukeEnv.AddPostAction( nukeLibraryInstall, lambda target, source, env : makeLibSymLinks( nukeEnv, "INSTALL_NUKELIB_NAME" ) ) -+ nukeEnv.AddPostAction( nukeLibraryInstall, run_libinstall_postactions ) - nukeEnv.Alias( "install", nukeLibraryInstall ) - nukeEnv.Alias( "installNuke", nukeLibraryInstall ) - nukeEnv.Alias( "installLib", [ nukeLibraryInstall ] ) -@@ -1980,6 +2079,7 @@ - nukePythonModule = nukePythonModuleEnv.SharedLibrary( "python/IECoreNuke/_IECoreNuke", nukePythonSources ) - nukePythonModuleInstall = nukePythonModuleEnv.Install( "$INSTALL_NUKEPYTHON_DIR/IECoreNuke", nukePythonScripts + nukePythonModule ) - nukePythonModuleEnv.AddPostAction( "$INSTALL_NUKEPYTHON_DIR/IECoreNuke", lambda target, source, env : makeSymLinks( nukePythonModuleEnv, nukePythonModuleEnv["INSTALL_NUKEPYTHON_DIR"] ) ) -+ nukePythonModuleEnv.AddPostAction(nukePythonModuleInstall , run_libinstall_postactions ) - nukePythonModuleEnv.Alias( "install", nukePythonModuleInstall ) - nukePythonModuleEnv.Alias( "installNuke", nukePythonModuleInstall ) - nukePythonModuleEnv.Depends( nukePythonModule, corePythonModule ) -@@ -2156,6 +2256,7 @@ - houdiniPluginInstall = houdiniPluginEnv.Install( os.path.dirname( houdiniPluginEnv.subst( "$INSTALL_HOUDINIPLUGIN_NAME" ) ), houdiniPlugin ) - houdiniPluginEnv.Depends( houdiniPlugin, corePythonModule ) - houdiniPluginEnv.AddPostAction( houdiniPluginInstall, lambda target, source, env : makeSymLinks( houdiniPluginEnv, houdiniPluginEnv["INSTALL_HOUDINIPLUGIN_NAME"] ) ) -+ houdiniPluginEnv.AddPostAction( houdiniPluginInstall, run_libinstall_postactions ) - houdiniPluginEnv.Alias( "install", houdiniPluginInstall ) - houdiniPluginEnv.Alias( "installHoudini", houdiniPluginInstall ) - -@@ -2173,6 +2274,7 @@ - houdiniPythonModuleEnv.Depends( houdiniPythonModule, houdiniLib ) - houdiniPythonModuleInstall = houdiniPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreHoudini", houdiniPythonScripts + houdiniPythonModule ) - houdiniPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreHoudini", lambda target, source, env : makeSymLinks( houdiniPythonModuleEnv, houdiniPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) -+ houdiniPythonModuleEnv.AddPostAction( houdiniPythonModuleInstall , run_libinstall_postactions ) - houdiniPythonModuleEnv.Alias( "install", houdiniPythonModuleInstall ) - houdiniPythonModuleEnv.Alias( "installHoudini", houdiniPythonModuleInstall ) - -@@ -2320,6 +2422,7 @@ - - truelightPythonModuleInstall = truelightPythonModuleEnv.Install( "$INSTALL_PYTHON_DIR/IECoreTruelight", truelightPythonScripts + truelightPythonModule ) - truelightPythonModuleEnv.AddPostAction( "$INSTALL_PYTHON_DIR/IECoreTruelight", lambda target, source, env : makeSymLinks( truelightPythonModuleEnv, truelightPythonModuleEnv["INSTALL_PYTHON_DIR"] ) ) -+ truelightPythonModuleEnv.AddPostAction( truelightPythonModuleInstall , run_libinstall_postactions ) - truelightPythonModuleEnv.Alias( "install", truelightPythonModuleInstall ) - truelightPythonModuleEnv.Alias( "installTruelight", truelightPythonModuleInstall ) - diff --git a/contrib/for_review/build_configurations/osx/options-maya2011.txt b/contrib/for_review/build_configurations/osx/options-maya2011.txt deleted file mode 100644 index 4513b3d6b5..0000000000 --- a/contrib/for_review/build_configurations/osx/options-maya2011.txt +++ /dev/null @@ -1,27 +0,0 @@ -# TYPE/VERSION -INSTALL_TYPE="maya" -INSTALL_VERSION="${IECORE_MAJOR_VERSION}.${IECORE_MINOR_VERSION}.${IECORE_PATCH_VERSION}" - -INSTALL_PREFIX="/opt/cortex/maya" - -CC="/usr/bin/gcc-4.0" -CXX="/usr/bin/g++-4.0 -arch x86_64 -I/opt/boost_1_42_0/include" -CXXFLAGS = ['-pipe', '-Wall', '-O2', '-DNDEBUG', '-DBOOST_DISABLE_ASSERTS', '-D__USE_ISOC99', "-D__x86_64__", "-pthread"] -TESTCXXFLAGS = ['-pipe', '-Wall', '-O0'] -PYTHONCXXFLAGS = CXXFLAGS -LINKFLAGS = ["-R"+INSTALL_PREFIX+'/lib', "-R/opt/boost_1_42_0/stage/lib", "-R/opt/tbb_2.2/lib", "-headerpad_max_install_names"] - -TBB_INCLUDE_PATH = '/opt/tbb_2.2/include' -TBB_LIB_PATH = '/opt/tbb_2.2/lib' -BOOST_INCLUDE_PATH = '/opt/boost_1_42_0' -BOOST_LIB_PATH = '/opt/boost_1_42_0/lib' -BOOST_LIB_SUFFIX = '' -MAYA_ROOT="/Applications/Autodesk/maya2011/Maya.app/Contents" -RMAN_ROOT="/Applications/Graphics/3Delight-9.0.105" -WITH_GL=1 -GLEW_LIB_PATH="/usr/lib" -GLEW_INCLUDE_PATH="/usr/include/GL" -PYTHON="/Applications/Autodesk/maya2011/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python" -PYTHON_CONFIG="/Applications/Autodesk/maya2011/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/bin/python-config" -PYTHON_INCLUDE_PATH=["/Applications/Autodesk/maya2011/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/include/python2.6"] -PYTHON_LINK_FLAGS='-L/Applications/Autodesk/maya2011/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config -ldl -lpython2.6' diff --git a/contrib/for_review/build_configurations/osx/readme.txt b/contrib/for_review/build_configurations/osx/readme.txt deleted file mode 100644 index a383a9ef2e..0000000000 --- a/contrib/for_review/build_configurations/osx/readme.txt +++ /dev/null @@ -1,67 +0,0 @@ -This is an options file to build cortex with maya 2011 on osx 10.6. -This is tested with maya2011 and 3Delight-9.0.105 - -Addionally there is a patch for the SConcstruct to fix -the references of the installed libraries by -inspection with otool -L and changing references with install_name_tool - -To build in cortex root: - -1. $ patch -p0 < contrib/for_review/build_configurations/osx/SConstruct.patch - -2. $ cp contrib/for_review/build_configurations/osx/options-maya2011.txt . - -3. Edit options-maya2011.txt and adapt the installed locations of the required software: - - * Install boost 1.42 to /opt/boost_1_42_0 (or some other location, but then you need to change BOOST_INCLUDE_PATH and BOOST_LIB_PATH) - - * Install TBB 2.2 to /opt/tbb_2.2 (or some other location, but then you need to change the TBB_INCLUDE_PATH and TBB_LIB_PATH ) - - * Change RMAN_ROOT in the options file to the location where 3Delight is installed. - -2. Build cortex - - $ scons OPTIONS=options-maya2011.txt - -3. Install cortex, if you do not change INSTALL_PREFIX it will be installed to /opt/cortex/maya - - $ sudo scons OPTIONS=options-maya2011.txt install - -4. Add cortex python module to Maya. The easiest way is to create a .pth file. - - * Create The file /Applications/Autodesk/maya2011/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cortex.pth - * Enter the path to you cortex installation, if you haven't changed the INSTALL_PREFIX option this will be - - /opt/cortex/maya/lib/python2.6/site-packages - - -5. Locate your Maya.env file (should be ~/Library/Preferences/Autodesk/maya/2011-x64/Maya.env ) and set - - MAYA_PLUG_IN_PATH=/opt/cortex/maya/maya/plugins - MAYA_SCRIPT_PATH=/opt/cortex/maya/maya/mel - MAYA_ICON_PATH=/opt/cortex/maya/maya/icons - IECORE_OP_PATHS=/opt/cortex/maya/ops - IECORE_PROCEDURAL_PATHS=/path/to/your/procedurals - - Adapt again MAYA_PLUG_IN_PATH, MAYA_SCRIPT_PATH and MAYA_ICON_PATH to your INSTALL_PREFIX - Set IECORE_PROCEDURAL_PATHS to the location where you want to keep your Cortex Procedurals - - -6. There is a problem with exposed boost symbols in Maya 2011 which results in a crash of Maya under some conditions. - The workaround is to launch Maya from the terminal and to preload libboost_regex.dylib - - $ export DYLD_INSERT_LIBRARIES=/opt/cortex/maya/lib/libboost_regex.dylib - - $ export LC_ALL="C" - Note: - If Maya does not start properly and you get an error like - "/Applications/Autodesk/maya2011/Maya.app/Contents/scripts/startup/layerEditor.mel line 268: Value must be greater than 0" - you must also set your locale properly by running this command (i.e. on non-english systems) - - $ /Applications/Autodesk/maya2011/Maya.app/Contents/MacOS/Maya - - -7. Load the Cortex Plugin with the Plug-in Manager (should be listed there) - -8. A new Cortex Menu should appear that lists your installed Ops and Procedurals - diff --git a/contrib/scripts/fixIncludes.py b/contrib/scripts/fixIncludes.py index b8dfaff55e..17be004717 100644 --- a/contrib/scripts/fixIncludes.py +++ b/contrib/scripts/fixIncludes.py @@ -87,9 +87,6 @@ "GafferBindings", "GafferTest", "Gaffer", - "IECoreMaya", - "IECoreHoudini", - "IECoreNuke", "IECoreArnold", "IECoreGL", "IECoreAlembic", @@ -97,7 +94,6 @@ "IECoreImage", "IECorePython", "IECore", - "maya", "DDImage", "pxr", "openvdb", diff --git a/doc/config/Doxyfile.in b/doc/config/Doxyfile.in index 74f7bf1978..d9e4bb8236 100644 --- a/doc/config/Doxyfile.in +++ b/doc/config/Doxyfile.in @@ -636,14 +636,8 @@ INPUT = include/IECore \ doc/python/IECore \ include/IECoreRI \ doc/python/IECoreRI \ - include/IECoreNuke \ include/IECoreGL \ - doc/python/IECoreGL \ - include/IECoreMaya \ - doc/python/IECoreMaya \ - mel/IECoreMaya \ - include/IECoreHoudini \ - doc/python/IECoreHoudini + doc/python/IECoreGL # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -865,13 +859,13 @@ HTML_FILE_EXTENSION = .html # each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to @@ -880,7 +874,7 @@ HTML_FOOTER = # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images diff --git a/include/IECore/IECore.h b/include/IECore/IECore.h index 6f610d149d..c545beb56f 100644 --- a/include/IECore/IECore.h +++ b/include/IECore/IECore.h @@ -66,7 +66,6 @@ IECORE_API bool withFreeType(); /// \ref mainPageRenderingSection
/// \ref mainPageAlgorithmsSection
/// \ref mainPagePythonSection
-/// \ref mainPageApplicationSupportSection
/// \ref mainPageThreadingSection
/// /// \section mainPageMathSection Math @@ -232,11 +231,6 @@ IECORE_API bool withFreeType(); /// All of the IECore C++ classes are bound into Python using the boost::python framework. /// Many can actually be subclassed in python, making it very quick to implement a new Op for instance. /// -/// \section mainPageApplicationSupportSection Application support -/// -/// The generic functionality contained within IECore is interfaced with specific 3rd party applications and frameworks using additional -/// libraries. These libraries include \ref IECoreMaya, IECoreHoudini, IECoreNuke and IECoreGL. -/// /// \section mainPageThreadingSection Threading /// /// Much of the library is not threadsafe. In general it's best to assume that thread safety doesn't exist unless specified otherwise - diff --git a/include/IECoreHoudini/Convert.h b/include/IECoreHoudini/Convert.h deleted file mode 100644 index 06fa10f967..0000000000 --- a/include/IECoreHoudini/Convert.h +++ /dev/null @@ -1,132 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_CONVERT_H -#define IE_COREHOUDINI_CONVERT_H - -#include "IECoreHoudini/Export.h" - -#include "IECore/Convert.h" -#include "IECore/Data.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathBox.h" -#include "Imath/ImathColor.h" -#include "Imath/ImathEuler.h" -#include "Imath/ImathMatrix.h" -#include "Imath/ImathQuat.h" -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -#include "UT/UT_BoundingBox.h" -#include "UT/UT_Color.h" -#include "UT/UT_Matrix4.h" -#include "UT/UT_Vector3.h" - -#include - -/// Specialising in the IECore namespace. This is OK because the Houdini types -/// will never be referenced in IECore -namespace IECore -{ - -template<> -IECOREHOUDINI_API UT_Vector3 convert( const Imath::V3f &from ); - -template<> -IECOREHOUDINI_API Imath::V3f convert( const UT_Vector3 &from ); - -template<> -IECOREHOUDINI_API UT_Vector3 convert( const Imath::V3d &from ); - -template<> -IECOREHOUDINI_API Imath::V3d convert( const UT_Vector3 &from ); - -template<> -IECOREHOUDINI_API UT_Vector4 convert( const Imath::V3f &from ); - -template<> -IECOREHOUDINI_API Imath::V3f convert( const UT_Vector4 &from ); - -template<> -IECOREHOUDINI_API UT_Vector4 convert( const Imath::V3d &from ); - -template<> -IECOREHOUDINI_API Imath::V3d convert( const UT_Vector4 &from ); - -template<> -IECOREHOUDINI_API Imath::Color3f convert( const UT_Color &from ); - -template<> -IECOREHOUDINI_API UT_Color convert( const Imath::Color3f &from ); - -template<> -IECOREHOUDINI_API Imath::Color4f convert( const UT_Color &from ); - -template<> -IECOREHOUDINI_API UT_Color convert( const Imath::Color4f &from ); - -template<> -IECOREHOUDINI_API UT_BoundingBox convert( const Imath::Box3f &from ); - -template<> -IECOREHOUDINI_API Imath::Box3f convert( const UT_BoundingBox &from ); - -template<> -IECOREHOUDINI_API UT_BoundingBox convert( const Imath::Box3d &from ); - -template<> -IECOREHOUDINI_API Imath::Box3d convert( const UT_BoundingBox &from ); - -template<> -IECOREHOUDINI_API UT_Matrix4T convert( const Imath::M44d &from ); - -template<> -IECOREHOUDINI_API Imath::M44d convert( const UT_Matrix4T &from ); - -template<> -IECOREHOUDINI_API Imath::M44f convert( const UT_Matrix4T &from ); - -template<> -IECOREHOUDINI_API UT_Matrix4T convert( const Imath::M44f &from ); - -template<> -IECOREHOUDINI_API Imath::M44f convert( const UT_Matrix4T &from ); - -template<> -IECOREHOUDINI_API Imath::M44d convert( const UT_Matrix4T &from ); - -} // namespace IECore - -#endif // IE_COREHOUDINI_CONVERT_H diff --git a/include/IECoreHoudini/CoreHoudini.h b/include/IECoreHoudini/CoreHoudini.h deleted file mode 100644 index 4bd4a911ea..0000000000 --- a/include/IECoreHoudini/CoreHoudini.h +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2011-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_COREHOUDINI_H -#define IECOREHOUDINI_COREHOUDINI_H - -// \todo: libIECoreHoudini should not use python. Move any use case to the IECoreHoudini bindings -#include "boost/python.hpp" - -#include "IECoreHoudini/Export.h" - -#include "IECore/Object.h" - -#include "GU/GU_DetailHandle.h" - -#include -#include - -/// The IECoreHoudini namespace holds all the functionality of libIECoreHoudini. -namespace IECoreHoudini -{ - -class IECOREHOUDINI_API CoreHoudini -{ - public: - - /// This loads hou into the global context - static void initPython(); - /// Used to cleanup any python globals during module shutdown - static void cleanupPython(); - - /// Utility method to import a python module into the global context - static void import( const std::string &module ); - - /// Utility method for getting the global python context - static boost::python::object &globalContext() - { - return g_globalContext; - } - - /// Run misc python command - static boost::python::object evalPython( const std::string &cmd ); - - private: - /// our global context - static boost::python::object g_globalContext; - - /// initialized - static bool g_initialized; -}; - -} - -#endif // IECOREHOUDINI_COREHOUDINI_H diff --git a/include/IECoreHoudini/CoreHoudiniVersion.h b/include/IECoreHoudini/CoreHoudiniVersion.h deleted file mode 100644 index afcb4942c5..0000000000 --- a/include/IECoreHoudini/CoreHoudiniVersion.h +++ /dev/null @@ -1,42 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2017, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_COREHOUDINIVERSION_H -#define IECOREHOUDINI_COREHOUDINIVERSION_H - -#include "UT/UT_Version.h" - -#define MIN_HOU_VERSION(MAJOR, MINOR, PATCH) ( UT_VERSION_INT >= ( ( MAJOR << 24 ) | ( MINOR << 16 ) | PATCH << 0 ) ) - -#endif //IECOREHOUDINI_COREHOUDINIVERSION_H diff --git a/include/IECoreHoudini/DetailSplitter.h b/include/IECoreHoudini/DetailSplitter.h deleted file mode 100644 index e5a4e89e5a..0000000000 --- a/include/IECoreHoudini/DetailSplitter.h +++ /dev/null @@ -1,126 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_DETAILSPLITTER_H -#define IECOREHOUDINI_DETAILSPLITTER_H - -#include "IECoreScene/SceneInterface.h" - -#include "IECore/PathMatcherData.h" -#include "IECore/RefCounted.h" - -#include "GU/GU_DetailHandle.h" -#include "OBJ/OBJ_Node.h" - -#include -#include -#include - -namespace IECoreHoudini -{ - - - -/// DetailSplitter is a convenience class for extracting select bits of geometry -/// from a GU_Detail. It is intended to improve performance when making multiple -/// calls to split the same detail. The default use is splitting based on the name -/// attribute, but any primitive string attribute could be used. -class DetailSplitter : public IECore::RefCounted -{ - public : - - typedef std::vector Names; - - IE_CORE_DECLAREMEMBERPTR( DetailSplitter ); - - - /// Create a DetailSplitter which will split the handle by the given key. - /// @param key The name of a primitive string attribute on the GU_Detail. - DetailSplitter( const GU_DetailHandle &handle, const std::string &key = "name", bool useHoudiniSegment = true ); - - /// - DetailSplitter( OBJ_Node *objNode, double time, const std::string &key = "name", bool useHoudiniSegment = true ); - virtual ~DetailSplitter(); - - /// Creates and returns a handle to a new GU_Detail which contains only - /// the primitives that match the value requested. - const GU_DetailHandle split( const std::string &value ); - - /// Retrieve the locally split object if possible - /// Can be null and split which returns the detail handle - /// should be used to convert the geometry. - IECore::ObjectPtr splitObject( const std::string& value ); - - /// Fills the result vector with all valid values in the GU_Detail - void values( std::vector &result ); - - /// Returns the handle held by the splitter - const GU_DetailHandle &handle() const; - - // Returns the child names for a given path - Names getNames(const std::vector& path); - - bool hasPath( const IECoreScene::SceneInterface::Path& path, bool isExplicit = true ); - - bool hasPaths(); - - bool update( OBJ_Node *objNode, double time ) ; - private : - - bool validate(); - - - typedef std::map Cache; - - double m_time; - OBJ_Node* m_objNode; - - int m_lastMetaCount; - const std::string m_key; - OP_Context m_context; - GU_DetailHandle m_handle; - Cache m_cache; - IECore::PathMatcherDataPtr m_pathMatcher; - - std::unordered_map m_segmentMap; - Names m_names; - bool m_useHoudiniSegment; - -}; - -IE_CORE_DECLAREPTR( DetailSplitter ); - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_DETAILSPLITTER_H diff --git a/include/IECoreHoudini/Export.h b/include/IECoreHoudini/Export.h deleted file mode 100644 index 71f27931af..0000000000 --- a/include/IECoreHoudini/Export.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2019, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_EXPORT_H -#define IECOREHOUDINI_EXPORT_H - -#include "IECore/Export.h" - -#ifdef IECoreHoudini_EXPORTS - #define IECOREHOUDINI_API IECORE_EXPORT -#else - #define IECOREHOUDINI_API IECORE_IMPORT -#endif - -#endif // #ifndef IECOREHOUDINI_EXPORT_H diff --git a/include/IECoreHoudini/FromHoudiniCompoundObjectConverter.h b/include/IECoreHoudini/FromHoudiniCompoundObjectConverter.h deleted file mode 100644 index 8b2b657b25..0000000000 --- a/include/IECoreHoudini/FromHoudiniCompoundObjectConverter.h +++ /dev/null @@ -1,78 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTER_H -#define IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTER_H - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/Object.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from a Houdini GU_Detail to an IECore::CompoundObject, -/// maintaining the name mappings of the various GU_CortexPrimitives held by the detail. -/// The converter is exclusive for details that contain GU_CortexPrimitives only. -class IECOREHOUDINI_API FromHoudiniCompoundObjectConverter : public IECoreHoudini::FromHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniCompoundObjectConverter, FromHoudiniCompoundObjectConverterTypeId, IECore::ToCoreConverter ); - - FromHoudiniCompoundObjectConverter( const GU_DetailHandle &handle ); - FromHoudiniCompoundObjectConverter( const SOP_Node *sop ); - - virtual ~FromHoudiniCompoundObjectConverter(); - - /// Determines if the given GU_Detail can be converted - static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo ); - - protected : - - /// performs conversion to an IECore::Object - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const; - - private : - - static FromHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( FromHoudiniCompoundObjectConverter ); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniConverter.h b/include/IECoreHoudini/FromHoudiniConverter.h deleted file mode 100644 index 9733149fc9..0000000000 --- a/include/IECoreHoudini/FromHoudiniConverter.h +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINICONVERTER_H -#define IE_COREHOUDINI_FROMHOUDINICONVERTER_H - -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/ToCoreConverter.h" - -namespace IECoreHoudini -{ - -/// The FromHoudiniConverter class forms an abstract base class for -/// all classes able to perform some kind of conversion -/// from a Houdini datatype to an IECore datatype. -class IECOREHOUDINI_API FromHoudiniConverter : public IECore::ToCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniConverter, FromHoudiniConverterTypeId, IECore::ToCoreConverter ); - - protected: - - FromHoudiniConverter( const std::string &description ); - - virtual ~FromHoudiniConverter(); - -}; - -IE_CORE_DECLAREPTR( FromHoudiniConverter ); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINICONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniCortexObjectConverter.h b/include/IECoreHoudini/FromHoudiniCortexObjectConverter.h deleted file mode 100644 index a80242737b..0000000000 --- a/include/IECoreHoudini/FromHoudiniCortexObjectConverter.h +++ /dev/null @@ -1,80 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTER_H -#define IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTER_H - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/Object.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from a Houdini GU_Detail to an IECore::Object. This converter -/// extracts only a single IECore::Object from a single GU_CortexPrimitive in the detail. -class IECOREHOUDINI_API FromHoudiniCortexObjectConverter : public IECoreHoudini::FromHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniCortexObjectConverter, FromHoudiniCortexObjectConverterTypeId, IECore::ToCoreConverter ); - - FromHoudiniCortexObjectConverter( const GU_DetailHandle &handle ); - FromHoudiniCortexObjectConverter( const SOP_Node *sop ); - - virtual ~FromHoudiniCortexObjectConverter(); - - /// Determines if the given GU_Detail can be converted - static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo ); - - protected : - - /// performs conversion to an IECore::Object - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const; - - private : - - IECore::ObjectPtr filterAttribs( const IECore::Object *object, const char *filter ) const; - - static FromHoudiniGeometryConverter::Description m_description; - static FromHoudiniGeometryConverter::Description m_universalDescription; -}; - -// register our converter -IE_CORE_DECLAREPTR( FromHoudiniCortexObjectConverter ); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniCurvesConverter.h b/include/IECoreHoudini/FromHoudiniCurvesConverter.h deleted file mode 100644 index 70642d39fd..0000000000 --- a/include/IECoreHoudini/FromHoudiniCurvesConverter.h +++ /dev/null @@ -1,99 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICURVESCONVERTER_H -#define IECOREHOUDINI_FROMHOUDINICURVESCONVERTER_H - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/CurvesPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from a Houdini GU_Detail to an IECore::CurvesPrimitive. -class IECOREHOUDINI_API FromHoudiniCurvesConverter : public IECoreHoudini::FromHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniCurvesConverter, FromHoudiniCurvesConverterTypeId, IECoreHoudini::FromHoudiniGeometryConverter ); - - FromHoudiniCurvesConverter( const GU_DetailHandle &handle ); - FromHoudiniCurvesConverter( const SOP_Node *sop ); - - virtual ~FromHoudiniCurvesConverter(); - - /// Determines if the given GU_Detail can be converted - static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo ); - - protected : - - /// performs conversion to an IECore::CurvesPrimitive - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const; - - private : - - static FromHoudiniGeometryConverter::Description m_description; - - /// Utility struct for duplicating curve end points using DespatchedTypedData - struct DuplicateEnds - { - typedef void ReturnType; - - DuplicateEnds( const std::vector &vertsPerCurve ); - - template - ReturnType operator()( T *data ) const; - - const std::vector &m_vertsPerCurve; - }; - - static bool compatiblePrimitive( GA_PrimitiveTypeId type ) - { - if ( ( type == GEO_PRIMNURBCURVE ) || ( type == GEO_PRIMBEZCURVE ) || (type == GEO_PRIMPOLY )) - { - return true; - } - - return false; - }; -}; - -// register our converter -IE_CORE_DECLAREPTR( FromHoudiniCurvesConverter ); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICURVESCONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniGeometryConverter.h b/include/IECoreHoudini/FromHoudiniGeometryConverter.h deleted file mode 100644 index f86486bf20..0000000000 --- a/include/IECoreHoudini/FromHoudiniGeometryConverter.h +++ /dev/null @@ -1,215 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_H -#define IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_H - -#include "IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/Primitive.h" - -#include "IECore/InternedString.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/SimpleTypedParameter.h" -#include "IECore/VectorTypedData.h" - -#include "GA/GA_AttributeRef.h" -#include "GU/GU_Detail.h" -#include "GU/GU_DetailHandle.h" -#include "SOP/SOP_Node.h" -#include "UT/UT_StringMMPattern.h" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( FromHoudiniGeometryConverter ); - -/// The FromHoudiniGeometryConverter class forms a base class for all classes able to perform -/// some kind of conversion from a Houdini GU_Detail to an IECore::Object. The most common use -/// is conversion to an IECore::Primitive, but any Object could be supported. -class IECOREHOUDINI_API FromHoudiniGeometryConverter : public FromHoudiniConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniGeometryConverter, FromHoudiniGeometryConverterTypeId, IECore::ToCoreConverter ); - - //! @name Factory - ////////////////////////////////////////////////////////////////////////////////////////// - //@{ - /// Creates a converter which will convert the given Houdini GU_Detail to an IECore::Primitive. - /// If resultType is specified then only converters which create objects of that type will - /// be returned - the default value allows any suitable converter to be created. If no - /// matching converters exist then returns 0. If a null handle is provided, any suitable - /// converter will be returned. This may be useful to access parameters of a derived - /// converter before the geometry exists. See SOP_ParameterisedHolder for an example. - static FromHoudiniGeometryConverterPtr create( const GU_DetailHandle &handle, IECore::TypeId resultType=IECore::InvalidTypeId ); - static FromHoudiniGeometryConverterPtr create( const GU_DetailHandle &handle, const std::set &resultTypes ); - - // This extra factory function is provided for the python bindings - static FromHoudiniGeometryConverterPtr create( const SOP_Node *sop, const std::string &nameFilter = "", IECore::TypeId resultType=IECore::InvalidTypeId ); - //@} - - /// Fills the passed vector with all the IECore::TypeIds for which - /// a FromHoudiniGeometryConverter is available. - static void supportedTypes( std::set &types ); - - /// Convenience function to extract the named shapes from the given GU_Detail. This can be used before - /// calling the factory create mechanism, when only the named portion of the detail is of interest. - static GU_DetailHandle extract( const GU_Detail *geo, const UT_StringMMPattern &nameFilter ); - - enum Convertability - { - Inapplicable = 0, - Ideal, - Suitable, - Admissible, - InvalidValue, - }; - - protected : - - FromHoudiniGeometryConverter( const GU_DetailHandle &handle, const std::string &description ); - FromHoudiniGeometryConverter( const SOP_Node *sop, const std::string &description ); - - virtual ~FromHoudiniGeometryConverter(); - - /// Implemented to aquire the read lock on the GU_Detail held by the GU_DetailHandle, - /// call doDetailConversion(), and finally unlock the GU_Detail. Derived classes need - /// not reimplement this function, but should instead implement doDetailConversion(). - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - /// Must be implemented by derived classes to return an IECore::Object created to represent the specified GU_Detail. - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const = 0; - - typedef FromHoudiniGeometryConverterPtr (*CreatorFn)( const GU_DetailHandle &handle ); - typedef Convertability (*ConvertabilityFn)( const GU_DetailHandle &handle ); - - static void registerConverter( IECore::TypeId resultType, CreatorFn creator, ConvertabilityFn canConvert ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class Description - { - public : - Description( IECore::TypeId resultType ); - private : - static FromHoudiniGeometryConverterPtr creator( const GU_DetailHandle &handle ); - static Convertability canConvert( const GU_DetailHandle &handle ); - }; - - /// returns a reference to the GU_DetailHandle - const GU_DetailHandle &handle() const; - /// extracts the GU_DetailHandle from a SOP_Node - static const GU_DetailHandle handle( const SOP_Node *sop ); - - /// Extracts position and attribs from the GU_Detail and stores them as primitive variables on the IECore::Primitive provided. - /// In most cases, this is the only transfer function that derived classes will need to use - void transferAttribs( - const GU_Detail *geo, IECoreScene::Primitive *result, const IECore::CompoundObject *operands, - IECoreScene::PrimitiveVariable::Interpolation vertexInterpolation = IECoreScene::PrimitiveVariable::FaceVarying, - IECoreScene::PrimitiveVariable::Interpolation primitiveInterpolation = IECoreScene::PrimitiveVariable::Uniform, - IECoreScene::PrimitiveVariable::Interpolation pointInterpolation = IECoreScene::PrimitiveVariable::Vertex, - IECoreScene::PrimitiveVariable::Interpolation detailInterpolation = IECoreScene::PrimitiveVariable::Constant - ) const; - - /// Utility functions for transfering each attrib type from Houdini onto the IECore::Primitive provided - void transferDetailAttribs( - const GU_Detail *geo, const IECore::CompoundObject *operands, const UT_StringMMPattern &attribFilter, - IECoreScene::Primitive *result, IECoreScene::PrimitiveVariable::Interpolation interpolation - ) const; - void transferElementAttribs( - const GU_Detail *geo, const GA_Range &range, const IECore::CompoundObject *operands, - const GA_AttributeDict &attribs, const UT_StringMMPattern &attribFilter, - IECoreScene::Primitive *result, IECoreScene::PrimitiveVariable::Interpolation interpolation - ) const; - void transferElementAttrib( - const GU_Detail *geo, const GA_Range &range, const IECore::CompoundObject *operands, - const GA_Attribute *attr, IECoreScene::PrimitiveVariable &result, std::string &resultName - ) const; - void transferAttribData( - IECoreScene::PrimitiveVariable &result, std::string &resultName, - const GA_ROAttributeRef &attrRef, const GA_Range &range - ) const; - - /// Utility functions for extracting attrib data from Houdini and storing it as a DataPtr of type T - /// @parm index allows a single component to be extracted from a larger container - template - typename T::Ptr extractData( const GA_Attribute *attr, const GA_Range &range, int elementIndex = -1 ) const; - - template - typename T::Ptr extractData( const GA_Attribute *attr ) const; - - IECore::DataPtr extractStringVectorData( const GA_Attribute *attr, const GA_Range &range, IECore::IntVectorDataPtr &indexData ) const; - IECore::DataPtr extractStringData( const GU_Detail *geo, const GA_Attribute *attr ) const; - - bool static hasOnlyOpenPolygons( const GU_Detail *geo ); - - private : - - void constructCommon(); - - void transferTags( const GU_Detail *geo, IECoreScene::Primitive *result ) const; - - // function to map standard Houdini names to IECore PrimitiveVariable names - const std::string processPrimitiveVariableName( const std::string &name ) const; - - // the handle to the GU_Detail - GU_DetailHandle m_geoHandle; - IECore::StringParameterPtr m_attributeFilterParameter; - IECore::BoolParameterPtr m_convertStandardAttributesParameter; - IECore::BoolParameterPtr m_preserveNameParameter; - IECore::BoolParameterPtr m_weldUVsParameter; - - struct Types - { - Types( IECore::TypeId result ); - IECore::TypeId resultType; - bool operator < ( const Types &other ) const; - }; - - typedef std::map > TypesToFnsMap; - static TypesToFnsMap *typesToFns(); -}; - -} - -#include "FromHoudiniGeometryConverter.inl" - -#endif // IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniGeometryConverter.inl b/include/IECoreHoudini/FromHoudiniGeometryConverter.inl deleted file mode 100644 index 8e1cd96545..0000000000 --- a/include/IECoreHoudini/FromHoudiniGeometryConverter.inl +++ /dev/null @@ -1,153 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_INL -#define IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_INL - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" - -#include "IECore/DespatchTypedData.h" -#include "IECore/VectorTraits.h" - -#include "GEO/GEO_Vertex.h" - -namespace IECoreHoudini -{ - -template -FromHoudiniGeometryConverter::Description::Description( IECore::TypeId resultType ) -{ - FromHoudiniGeometryConverter::registerConverter( resultType, creator, canConvert ); -} - -template -FromHoudiniGeometryConverterPtr FromHoudiniGeometryConverter::Description::creator( const GU_DetailHandle &handle ) -{ - return new T( handle ); -} - -template -FromHoudiniGeometryConverter::Convertability FromHoudiniGeometryConverter::Description::canConvert( const GU_DetailHandle &handle ) -{ - GU_DetailHandleAutoReadLock readHandle( handle ); - - const GU_Detail *geo = readHandle.getGdp(); - if ( !geo ) - { - return Inapplicable; - } - - return T::canConvert( geo ); -} - -struct SetInterpretation -{ - typedef void ReturnType; - - GA_TypeInfo m_type; - - template - void operator() ( T *data ) - { - assert( data ); - - if ( m_type == GA_TYPE_POINT ) - { - data->setInterpretation( IECore::GeometricData::Point ); - } - else if ( m_type == GA_TYPE_NORMAL ) - { - data->setInterpretation( IECore::GeometricData::Normal ); - } - else if ( m_type == GA_TYPE_VECTOR ) - { - data->setInterpretation( IECore::GeometricData::Vector ); - } - else if ( m_type == GA_TYPE_COLOR ) - { - data->setInterpretation( IECore::GeometricData::Color ); - } - } -}; - -template -typename T::Ptr FromHoudiniGeometryConverter::extractData( const GA_Attribute *attr, const GA_Range &range, int elementIndex ) const -{ - typedef typename T::BaseType BaseType; - - typename T::Ptr data = new T(); - data->writable().resize( range.getEntries() ); - BaseType *dest = data->baseWritable(); - - if ( elementIndex == -1 ) - { - attr->getAIFTuple()->getRange( attr, range, dest ); - } - else - { - attr->getAIFTuple()->getRange( attr, range, dest, elementIndex, 1 ); - } - - // set the geometric interpretation if it exists - SetInterpretation func = { attr->getTypeInfo() }; - IECore::despatchTypedData< SetInterpretation, IECore::TypeTraits::IsGeometricTypedData, IECore::DespatchTypedDataIgnoreError >( data.get(), func ); - - return data; -} - -template <> -IECore::QuatfVectorDataPtr FromHoudiniGeometryConverter::extractData( const GA_Attribute *attr, const GA_Range &range, int elementIndex ) const; - -template -typename T::Ptr FromHoudiniGeometryConverter::extractData( const GA_Attribute *attr ) const -{ - typedef typename T::BaseType BaseType; - typedef typename T::ValueType ValueType; - - typename T::Ptr data = new T(); - BaseType *dest = data->baseWritable(); - - unsigned dimensions = sizeof(ValueType) / sizeof(BaseType); - attr->getAIFTuple()->get( attr, 0, dest, dimensions ); - - // set the geometric interpretation if it exists - SetInterpretation func = { attr->getTypeInfo() }; - IECore::despatchTypedData< SetInterpretation, IECore::TypeTraits::IsGeometricTypedData, IECore::DespatchTypedDataIgnoreError >( data.get(), func ); - - return data; -} - -} - -#endif // IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTER_INL diff --git a/include/IECoreHoudini/FromHoudiniPointsConverter.h b/include/IECoreHoudini/FromHoudiniPointsConverter.h deleted file mode 100644 index c33001a9e8..0000000000 --- a/include/IECoreHoudini/FromHoudiniPointsConverter.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTER_H -#define IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTER_H - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/PointsPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from a Houdini GU_Detail to an IECore::PointsPrimitive -class IECOREHOUDINI_API FromHoudiniPointsConverter : public IECoreHoudini::FromHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniPointsConverter, FromHoudiniPointsConverterTypeId, IECore::ToCoreConverter ); - - FromHoudiniPointsConverter( const GU_DetailHandle &handle ); - FromHoudiniPointsConverter( const SOP_Node *sop ); - - virtual ~FromHoudiniPointsConverter(); - - /// Determines if the given GU_Detail can be converted - static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo ); - - protected : - - /// performs conversion to a IECore::PointsPrimitive - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const; - - private : - - static FromHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( FromHoudiniPointsConverter ); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTER_H diff --git a/include/IECoreHoudini/FromHoudiniPolygonsConverter.h b/include/IECoreHoudini/FromHoudiniPolygonsConverter.h deleted file mode 100644 index 2a4a544f6a..0000000000 --- a/include/IECoreHoudini/FromHoudiniPolygonsConverter.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTER_H -#define IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTER_H - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/MeshPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from a Houdini GU_Detail to an IECore::MeshPrimitive -class IECOREHOUDINI_API FromHoudiniPolygonsConverter : public IECoreHoudini::FromHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniPolygonsConverter, FromHoudiniPolygonsConverterTypeId, IECore::ToCoreConverter ); - - FromHoudiniPolygonsConverter( const GU_DetailHandle &handle ); - FromHoudiniPolygonsConverter( const SOP_Node *sop ); - - virtual ~FromHoudiniPolygonsConverter(); - - /// Determines if the given GU_Detail can be converted - static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo ); - - protected : - - /// performs conversion to a IECore::MeshPrimitive - virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const; - - bool static hasOpenAndClosedPolygons( const GU_Detail *geo ); - private : - - IECore::CompoundObjectPtr transferMeshInterpolation( const GU_Detail *geo, const IECore::CompoundObject *operands, IECoreScene::MeshPrimitive *mesh ) const; - - void convertCorners( IECoreScene::MeshPrimitive *mesh ) const; - void convertCreases( IECoreScene::MeshPrimitive *mesh, const std::vector &vertIds, size_t numEdges ) const; - - static FromHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( FromHoudiniPolygonsConverter ); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTER_H diff --git a/include/IECoreHoudini/GEO_CobIOTranslator.h b/include/IECoreHoudini/GEO_CobIOTranslator.h deleted file mode 100644 index 5cfcc07e6b..0000000000 --- a/include/IECoreHoudini/GEO_CobIOTranslator.h +++ /dev/null @@ -1,96 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_GEOCOBIOTRANSLATOR_H -#define IECOREHOUDINI_GEOCOBIOTRANSLATOR_H - -#include "IECoreHoudini/Export.h" - -#include "GA/GA_Stat.h" -#include "GEO/GEO_IOTranslator.h" -#include "GU/GU_Detail.h" -#include "UT/UT_IStream.h" - -#include - -namespace IECoreHoudini -{ - -/// An IO Translator for saving and loading .cob files using a Houdini File SOP -class IECOREHOUDINI_API GEO_CobIOTranslator : public GEO_IOTranslator -{ - - public : - - GEO_CobIOTranslator(); - virtual ~GEO_CobIOTranslator(); - - virtual GEO_IOTranslator *duplicate() const; - - virtual const char *formatName() const; - - virtual int checkExtension( const char *fileName ); - virtual int checkMagicNumber( unsigned magic ); - - /// This is the Houdini 14 interface - //////////////////////////////////////////////////////////// - //@{ - /// Loads a cob if the content of the cob has a registered ToHoudiniGeometryConverter - virtual GA_Detail::IOStatus fileLoad( GEO_Detail *geo, UT_IStream &is, bool ate_magic ); - /// Implemented to return false, since we don't have access to the expected file, we can't use the ObjectWriter. - virtual GA_Detail::IOStatus fileSave( const GEO_Detail *geo, std::ostream &os ); - /// Saves a cob by attempting to find a FromHoudiniGeometryConverter matching the given GEO_Detail - virtual GA_Detail::IOStatus fileSaveToFile( const GEO_Detail *geo, const char *fileName ); - //@} - - /// This is the Houdini 13 interface - // \todo: remove when we drop support for Houdini 13 and older. - //////////////////////////////////////////////////////////// - //@{ - /// Loads a cob if the content of the cob has a registered ToHoudiniGeometryConverter - virtual GA_Detail::IOStatus fileLoad( GEO_Detail *geo, UT_IStream &is, int ate_magic ); - /// Saves a cob by attempting to find a FromHoudiniGeometryConverter matching the given GEO_Detail - virtual GA_Detail::IOStatus fileSaveToFile( const GEO_Detail *geo, std::ostream &os, const char *fileName ); - //@} - - //@{ - /// Reads only header of the file, - virtual bool fileStat( const char *fileName, GA_Stat &stat, uint level ); - //@} - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_GEOCOBIOTRANSLATOR_H diff --git a/include/IECoreHoudini/GEO_CortexPrimitive.h b/include/IECoreHoudini/GEO_CortexPrimitive.h deleted file mode 100644 index 87446f1635..0000000000 --- a/include/IECoreHoudini/GEO_CortexPrimitive.h +++ /dev/null @@ -1,205 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_GEOCORTEXPRIMITIVE_H -#define IECOREHOUDINI_GEOCORTEXPRIMITIVE_H - -#include "IECoreHoudini/CoreHoudiniVersion.h" -#include "IECoreHoudini/Export.h" - -#include "IECore/Object.h" - -#include "GA/GA_Defines.h" -#include "GA/GA_LoadMap.h" -#include "GA/GA_Primitive.h" -#include "GEO/GEO_Point.h" -#include "GEO/GEO_Primitive.h" -#include "GU/GU_Detail.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef GEO_ConvertParms ConvertParms; - -#else - -#include "GU/GU_Prim.h" - -typedef GU_Primitive::NormalComp NormalComp; -typedef GU_ConvertParms ConvertParms; - -#endif - - -#include "OP/OP_Context.h" -#include "OP/OP_NodeInfoParms.h" -#include "UT/UT_ParallelUtil.h" -#include "UT/UT_Version.h" - -namespace IECoreHoudini -{ - -/// Wrapper for hosting IECore::Objects natively in Houdini -class IECOREHOUDINI_API GEO_CortexPrimitive : public GEO_Primitive -{ - public : - - GEO_CortexPrimitive( GA_Detail *detail, GA_Offset offset = GA_INVALID_OFFSET ); - GEO_CortexPrimitive( GEO_Detail *detail, GA_Offset offset = GA_INVALID_OFFSET ); -#if UT_MAJOR_VERSION_INT < 16 - GEO_CortexPrimitive( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ); -#endif - virtual ~GEO_CortexPrimitive(); - -#if UT_MAJOR_VERSION_INT < 16 - virtual void swapVertexOffsets( const GA_Defragment &defrag ); - virtual GA_Size getVertexCount() const; - virtual GA_Offset getVertexOffset( GA_Size index ) const; -#endif - virtual GA_DereferenceStatus dereferencePoint( GA_Offset point, bool dry_run = false ); - virtual GA_DereferenceStatus dereferencePoints( const GA_RangeMemberQuery &pt_q, bool dry_run = false ); - -#if UT_MAJOR_VERSION_INT >= 13 - - virtual void stashed( bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET ); - -#endif - - // \todo: This signature is for Houdini 12.5 and earlier. Remove when we drop support - virtual void stashed( int onoff, GA_Offset offset=GA_INVALID_OFFSET ); - virtual void clearForDeletion(); - virtual bool isDegenerate() const; - virtual void copyUnwiredForMerge( const GA_Primitive *src, const GA_MergeMap &map ); -#if UT_MAJOR_VERSION_INT >= 18 - virtual void copySubclassData(const GA_Primitive *source); -#endif - virtual void transform( const UT_Matrix4 &xform ); - virtual const GA_PrimitiveJSON* getJSON() const; - virtual void reverse(); - - virtual GEO_Primitive * copy( int preserve_shared_pts ) const; - virtual void copyPrimitive( const GEO_Primitive *src, GEO_Point **ptredirect ); -#if MIN_HOU_VERSION( 19, 5, 0 ) - virtual bool getBBox( UT_BoundingBox *bbox ) const; -#else - virtual int getBBox( UT_BoundingBox *bbox ) const; -#endif - virtual void enlargePointBounds( UT_BoundingBox &box ) const; - virtual UT_Vector3 computeNormal() const; -#if MIN_HOU_VERSION( 19, 5, 0 ) - virtual UT_Vector3D computeNormalD() const; -#endif - virtual int detachPoints( GA_PointGroup &grp ); -#if UT_MAJOR_VERSION_INT >= 16 - - bool saveVertexArray( UT_JSONWriter &w, const GA_SaveMap &map ) const; - bool loadVertexArray( UT_JSONParser &p, const GA_LoadMap &map ); - -#endif - - static const char *typeName; - -#if MIN_HOU_VERSION(16, 5, 0) - static void create(GA_Primitive **new_prims, GA_Size nprimitives, GA_Detail &detail, GA_Offset start_offset, const GA_PrimitiveDefinition &def, bool allowed_to_parallelize); -#elif UT_MAJOR_VERSION_INT >=16 - static void create(GA_Primitive **new_prims, GA_Size nprimitives, GA_Detail &detail, GA_Offset start_offset, const GA_PrimitiveDefinition &def); -#elif UT_MAJOR_VERSION_INT >= 14 - - static GA_Primitive *create( GA_Detail &detail, GA_Offset offset, const GA_PrimitiveDefinition &definition ); - // merge constructor - static GA_Primitive *create( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ); - -#endif - - // factory - static GEO_CortexPrimitive *build( GU_Detail *geo, const IECore::Object *object ); - - virtual int64 getMemoryUsage() const; - virtual void countMemory( UT_MemoryCounter &counter ) const; - virtual void copyPrimitive( const GEO_Primitive *src ); - - virtual const GA_PrimitiveDefinition &getTypeDef() const; - static void registerDefinition(GA_PrimitiveFactory *factory); - static GA_PrimitiveTypeId typeId(); - - virtual GEO_Primitive *convert( ConvertParms &parms, GA_PointGroup *usedpts = 0 ); - virtual GEO_Primitive *convertNew( ConvertParms &parms ); - virtual void normal( NormalComp &output ) const; -#if MIN_HOU_VERSION( 19, 5, 0 ) - virtual void normal( NormalCompD &output ) const; -#endif - virtual int intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1 ) const; - - /// Set the IECore::Object contained by this GEO_Primitive. Note that in most situations - /// this method takes a copy of the object. - void setObject( const IECore::Object *object ); - /// Get the IECore::Object contained by this GEO_Primitive - const IECore::Object *getObject() const; - /// Allowing non-const access to the IECore::Object so it can be updated in-place. - /// Most users should prefer the const method above. - IECore::Object *getObject(); - - /// Convenience method to inspect a GU_Detail and return some information about - /// the GU_CortexPrimitives within, if there are any. - static void infoText( const GU_Detail *geo, OP_Context &context, OP_NodeInfoParms &parms ); - - protected : - -#if (UT_VERSION_INT >= 0x0c050132) // 12.5.306 or later - virtual void copyOffsetPrimitive( const GEO_Primitive *src, GA_Index basept ); -#else - virtual void copyOffsetPrimitive( const GEO_Primitive *src, int basept ); -#endif - - virtual bool evaluatePointRefMap( GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0 ) const; - - IECore::ObjectPtr m_object; -#if UT_MAJOR_VERSION_INT < 16 - // offset for the representative vertex - GA_Offset m_offset; -#endif - - private : - - class geo_CortexPrimitiveJSON; - - GEO_Primitive *doConvert( ConvertParms &parms ); - - static GA_PrimitiveDefinition *m_definition; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_GEOCORTEXPRIMITIVE_H - diff --git a/include/IECoreHoudini/GR_CortexPrimitive.h b/include/IECoreHoudini/GR_CortexPrimitive.h deleted file mode 100644 index ab681ef043..0000000000 --- a/include/IECoreHoudini/GR_CortexPrimitive.h +++ /dev/null @@ -1,126 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_GRCORTEXPRIMITIVE_H -#define IECOREHOUDINI_GRCORTEXPRIMITIVE_H - -#include "IECoreHoudini/CoreHoudiniVersion.h" -#include "IECoreHoudini/Export.h" - -#include "IECoreScene/Renderable.h" - -#include "GR/GR_Primitive.h" -#include "UT/UT_Version.h" - -// We can't include any IECoreGL files here, because it -// causes an issue with gl/glew initialization order. -namespace IECoreGL -{ - -IE_CORE_FORWARDDECLARE( Scene ); -IE_CORE_FORWARDDECLARE( State ); - -} - -namespace IECoreHoudini -{ - -/// Wrapper for drawing GU_CortexPrimitives in OpenGL -class IECOREHOUDINI_API GR_CortexPrimitive : public GR_Primitive -{ - public : - - GR_CortexPrimitive( const GR_RenderInfo *info, const char *cache_name, const GEO_Primitive *prim ); - virtual ~GR_CortexPrimitive(); - - virtual const char *className() const - { - return "GR_CortexPrimitive"; - }; - - virtual GR_PrimAcceptResult acceptPrimitive( GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim ); - virtual void resetPrimitives(); - - protected : - -#if MIN_HOU_VERSION( 20, 0, 0 ) - virtual void update( RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p ); -#else - virtual void update( RE_Render *r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p ); -#endif - - -#if MIN_HOU_VERSION( 20, 0, 0 ) - virtual void render( RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms parms); -#elif UT_MAJOR_VERSION_INT >= 16 - virtual void render( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms parms); -#else - virtual void render( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, const GR_DisplayOption *opt, const UT_Array *materials ); -#endif - -#if MIN_HOU_VERSION( 20, 0, 0 ) - virtual int renderPick( RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map ); -#else - virtual void renderInstances( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, const GR_DisplayOption *opt, const UT_Array *materials, int render_instance ); - virtual int renderPick( RE_Render *r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map ); -#endif - - private : - - GA_Index m_primId; - IECoreGL::ScenePtr m_scene; - const IECoreScene::Renderable *m_renderable; - - IECoreGL::State *getState( GR_RenderMode mode, GR_RenderFlags flags, const GR_DisplayOption *opt ); - - const std::string &pickFragmentSource(); - - static IECoreGL::StatePtr g_lit; - static IECoreGL::StatePtr g_shaded; - static IECoreGL::StatePtr g_wire; - static IECoreGL::StatePtr g_wireLit; - static IECoreGL::StatePtr g_wireShaded; - static IECoreGL::StatePtr g_wireConstGhost; - static IECoreGL::StatePtr g_wireConstBG; - static IECoreGL::StatePtr g_pick; - static IECoreGL::StatePtr g_selected; - static IECoreGL::StatePtr g_wireSelected; - static IECoreGL::StatePtr g_wireConstBGSelected; - static IECoreGL::StatePtr g_wireConstGhostSelected; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_GRCORTEXPRIMITIVE_H diff --git a/include/IECoreHoudini/GUI_CortexPrimitiveHook.h b/include/IECoreHoudini/GUI_CortexPrimitiveHook.h deleted file mode 100644 index d663fb53e1..0000000000 --- a/include/IECoreHoudini/GUI_CortexPrimitiveHook.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_GUICORTEXPRIMITIVEHOOK_H -#define IECOREHOUDINI_GUICORTEXPRIMITIVEHOOK_H - -#include "IECoreHoudini/Export.h" - -#include "GUI/GUI_PrimitiveHook.h" - -namespace IECoreHoudini -{ - -/// Hook for drawing GU_CortexPrimitives in OpenGL -class IECOREHOUDINI_API GUI_CortexPrimitiveHook : public GUI_PrimitiveHook -{ - public : - - GUI_CortexPrimitiveHook(); - virtual ~GUI_CortexPrimitiveHook(); - - virtual GR_Primitive *createPrimitive( const GT_PrimitiveHandle >_prim, const GEO_Primitive *geo_prim, const GR_RenderInfo *info, const char *cache_name, GR_PrimAcceptResult &processed ); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_GUICORTEXPRIMITIVEHOOK_H diff --git a/include/IECoreHoudini/GU_CortexPrimitive.h b/include/IECoreHoudini/GU_CortexPrimitive.h deleted file mode 100644 index 376c3a536f..0000000000 --- a/include/IECoreHoudini/GU_CortexPrimitive.h +++ /dev/null @@ -1,106 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "UT/UT_Version.h" -#if UT_MAJOR_VERSION_INT < 14 - -#ifndef IECOREHOUDINI_GUCORTEXPRIMITIVE_H -#define IECOREHOUDINI_GUCORTEXPRIMITIVE_H - -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#include "IECore/Object.h" - -#include "GU/GU_Detail.h" -#include "GU/GU_Prim.h" -#include "OP/OP_Context.h" -#include "OP/OP_NodeInfoParms.h" - -namespace IECoreHoudini -{ - -/// Wrapper for hosting IECore::Objects natively in Houdini -class GU_CortexPrimitive : public GEO_CortexPrimitive, GU_Primitive -{ - public : - - GU_CortexPrimitive( GU_Detail *gdp, GA_Offset offset = GA_INVALID_OFFSET ); - GU_CortexPrimitive( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ); - virtual ~GU_CortexPrimitive(); - - static const char *typeName; - -#if UT_MAJOR_VERSION_INT >= 13 - - static GA_Primitive *create( GA_Detail &detail, GA_Offset offset, const GA_PrimitiveDefinition &definition ); -#else - - static GA_Primitive *create( GA_Detail &detail, GA_Offset offset ); - -#endif - - // merge constructor - static GA_Primitive *create( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ); - - virtual int64 getMemoryUsage() const; - -#if UT_MAJOR_VERSION_INT >= 13 - - virtual void countMemory( UT_MemoryCounter &counter ) const; - virtual void copyPrimitive( const GEO_Primitive *src ); - -#endif - - virtual const GA_PrimitiveDefinition &getTypeDef() const; - - virtual GEO_Primitive *convert( GU_ConvertParms &parms, GA_PointGroup *usedpts = 0 ); - virtual GEO_Primitive *convertNew( GU_ConvertParms &parms ); - virtual void *castTo() const; - virtual const GEO_Primitive *castToGeo() const; - virtual void normal( NormalComp &output ) const; - virtual int intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1 ) const; - -#if UT_MAJOR_VERSION_INT < 13 - - virtual GU_RayIntersect *createRayCache( int &persistent ); - -#endif - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_GUCORTEXPRIMITIVE_H - -#endif // excluded in Houdini 14 and newer diff --git a/include/IECoreHoudini/LiveScene.h b/include/IECoreHoudini/LiveScene.h deleted file mode 100644 index 9959d454ec..0000000000 --- a/include/IECoreHoudini/LiveScene.h +++ /dev/null @@ -1,213 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_LIVESCENE_H -#define IECOREHOUDINI_LIVESCENE_H - -#include "IECoreHoudini/DetailSplitter.h" -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/SceneInterface.h" - -#include "OP/OP_Node.h" -#include "UT/UT_String.h" - -#include "boost/function.hpp" -#include "boost/shared_ptr.hpp" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( LiveScene ); - -/// A read-only class for representing a live Houdini scene as an IECore::SceneInterface -/// Note that this class treats time by SceneInterface standards, starting at Frame 0, -/// as opposed to Houdini standards, which start at Frame 1. -class IECOREHOUDINI_API LiveScene : public IECoreScene::SceneInterface -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( LiveScene, LiveSceneTypeId, IECoreScene::SceneInterface ); - - LiveScene(); - LiveScene( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, double defaultTime = std::numeric_limits::infinity() ); - ~LiveScene() = default; - - std::string fileName() const override; - - Name name() const override; - void path( Path &p ) const override; - - Imath::Box3d readBound( double time ) const override; - void writeBound( const Imath::Box3d &bound, double time ) override; - - IECore::ConstDataPtr readTransform( double time ) const override; - Imath::M44d readTransformAsMatrix( double time ) const override; - /// \todo: consider making these methods of SceneInterface itself - IECore::ConstDataPtr readWorldTransform( double time ) const; - Imath::M44d readWorldTransformAsMatrix( double time ) const; - void writeTransform( const IECore::Data *transform, double time ) override; - - bool hasAttribute( const Name &name ) const override; - void attributeNames( NameList &attrs ) const override; - IECore::ConstObjectPtr readAttribute( const Name &name, double time ) const override; - void writeAttribute( const Name &name, const IECore::Object *attribute, double time ) override; - - bool hasTag( const Name &name, int filter = SceneInterface::LocalTag ) const override; - void readTags( NameList &tags, int filter = SceneInterface::LocalTag ) const override; - void writeTags( const NameList &tags ) override; - - NameList setNames( bool includeDescendantSets = true ) const override; - IECore::PathMatcher readSet( const Name &name, bool includeDescendantSets = true, const IECore::Canceller *canceller = nullptr ) const override; - void writeSet( const Name &name, const IECore::PathMatcher &set ) override; - void hashSet( const Name& setName, IECore::MurmurHash &h ) const override; - - bool hasObject() const override; - IECore::ConstObjectPtr readObject( double time, const IECore::Canceller *canceller = nullptr ) const override; - IECoreScene::PrimitiveVariableMap readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const override; - void writeObject( const IECore::Object *object, double time ) override; - - void childNames( NameList &childNames ) const override; - bool hasChild( const Name &name ) const override; - IECoreScene::SceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - IECoreScene::ConstSceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - IECoreScene::SceneInterfacePtr createChild( const Name &name ) override; - - IECoreScene::SceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - IECoreScene::ConstSceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - - /// Currently raises an exception - void hash( HashType hashType, double time, IECore::MurmurHash &h ) const override; - - /// Convenience method to access the Houdini node this scene refers to - const OP_Node *node() const; - - /// Convenience method to determine if this scene refers to hierarchy embedded inside a SOP - bool embedded() const; - - /// These methods provide a default cooking time for methods that do not accept time - /// as an argument (e.g. hasObject or childNames). In a LiveScene which points at - /// a SOP, it is necessary to use time in these methods. The default time will pass - /// through to children automatically. If left unset, CHgetEvalTime() will be used - /// for these queries. See ROP_SceneCacheWriter for a use case. - double getDefaultTime() const; - void setDefaultTime( double time ); - - /// The parameter name used to identify user defined tags on any OBJ node. This will be accessed - /// by hasTag and readTags as a string parameter, and will be split on spaces to separate tags. - static PRM_Name pTags; - - typedef boost::function HasFn; - typedef boost::function ReadFn; - typedef boost::function ReadAttrFn; - typedef boost::function HasTagFn; - typedef boost::function ReadTagsFn; - typedef boost::function ReadNamesFn; - - // Register callbacks for custom named attributes. - // The names function will be called during attributeNames and hasAttribute. - // The read method is called if the names method returns the expected attribute, so it should return a valid Object pointer or raise an Exception. - static void registerCustomAttributes( ReadNamesFn namesFn, ReadAttrFn readFn, bool callEmbedded ); - static void clearCustomAttributeReaders(); - - // Register callbacks for nodes to define custom tags - // The functions will be called during hasTag and readTags. - // readTags will return the union of all custom ReadTagsFns. - static void registerCustomTags( HasTagFn hasFn, ReadTagsFn readFn, bool callEmbedded ); - static void clearCustomTagReaders(); - - protected : - - LiveScene( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, const LiveScene& parent); - - virtual LiveScenePtr create() const; - virtual LiveScenePtr duplicate( const UT_String &nodePath, const Path &contentPath, const Path &rootPath) const; - - private : - - void constructCommon( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, DetailSplitter *splitter ); - - OP_Node *retrieveNode( bool content = false, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const; - OP_Node *locateContent( OP_Node *node ) const; - OP_Node *retrieveChild( const Name &name, Path &contentPath, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const; - IECoreScene::SceneInterfacePtr retrieveScene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const; - bool hasInput( const OP_Node *node ) const; - // We need to adjust the time internally, because SceneInterfaces treat time - // starting at Frame 0, while Houdini treats time starting at Frame 1. - double adjustTime( double time ) const; - double adjustedDefaultTime() const; - - void calculatePath( const Path &contentPath, const Path &rootPath ); - const char *matchPath( const char *value ) const; - bool matchPattern( const char *value, const char *pattern ) const; - std::pair nextWord( const char *value ) const; - void relativeContentPath( IECoreScene::SceneInterface::Path &path ) const; - GU_DetailHandle contentHandle() const; - - /// Struct for registering readers for custom Attributes. - struct CustomAttributeReader - { - ReadNamesFn m_names; - ReadAttrFn m_read; - bool m_callEmbedded; - }; - - /// Struct for registering readers for custom Tags. - struct CustomTagReader - { - HasTagFn m_has; - ReadTagsFn m_read; - bool m_callEmbedded; - }; - - static std::vector &customAttributeReaders(); - static std::vector &customTagReaders(); - - UT_String m_nodePath; - size_t m_rootIndex; - size_t m_contentIndex; - IECoreScene::SceneInterface::Path m_path; - - // used by instances which track the hierarchy inside a SOP - mutable DetailSplitterPtr m_splitter; - - // used as the default cook time for methods that do not accept a time - double m_defaultTime; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_LIVESCENE_H diff --git a/include/IECoreHoudini/MessageHandler.h b/include/IECoreHoudini/MessageHandler.h deleted file mode 100644 index b80e37b147..0000000000 --- a/include/IECoreHoudini/MessageHandler.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_MESSAGEHANDLER_H -#define IECOREHOUDINI_MESSAGEHANDLER_H - -#include "IECoreHoudini/Export.h" - -#include "IECore/MessageHandler.h" - -#include "boost/function.hpp" - -namespace IECoreHoudini -{ - -/// A generic MessageHandler for Houdini. -/// \todo: make this threadsafe -class IECOREHOUDINI_API MessageHandler : public IECore::MessageHandler -{ - - public : - - IE_CORE_DECLAREMEMBERPTR( MessageHandler ); - - typedef boost::function HandlerFn; - - MessageHandler( HandlerFn errorFn = 0, HandlerFn warningFn = 0, HandlerFn infoFn = 0, HandlerFn debugFn = 0 ); - virtual ~MessageHandler(); - - virtual void handle( Level level, const std::string &context, const std::string &message ); - - private : - - HandlerFn m_errorFn; - HandlerFn m_warningFn; - HandlerFn m_infoFn; - HandlerFn m_debugFn; - -}; - -IE_CORE_DECLAREPTR( MessageHandler ); - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_MESSAGEHANDLER_H diff --git a/include/IECoreHoudini/NodeHandle.h b/include/IECoreHoudini/NodeHandle.h deleted file mode 100644 index 90144577e8..0000000000 --- a/include/IECoreHoudini/NodeHandle.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_NODEHANDLE_H -#define IE_COREHOUDINI_NODEHANDLE_H - -#include "IECoreHoudini/Export.h" - -#include "HOM/HOM_Node.h" -#include "OP/OP_Node.h" - -#include "boost/shared_ptr.hpp" - -namespace IECoreHoudini -{ - -/// The NodeHandle is a class that may be used to verify the existence of an OP_Node. -/// Use a NodeHandle if you want a raw pointer to an OP_Node, but are concerned about -/// the lifespan of that OP_Node. -class IECOREHOUDINI_API NodeHandle -{ - - public : - - NodeHandle(); - NodeHandle( const OP_Node *node ); - - virtual ~NodeHandle(); - - /// Returns True if the OP_Node represented by this handle is still alive - bool alive() const; - - /// Returns a pointer to the OP_Node represented by this handle, or 0 if alive is false. - OP_Node *node() const; - - private : - - // we are using a HOM_Node because it lets us know if the OP_Node has been deleted - boost::shared_ptr m_homNode; - -}; - -} // namespace IECoreHoudini - -#endif // IE_COREHOUDINI_NODEHANDLE_H diff --git a/include/IECoreHoudini/OBJ_SceneCacheGeometry.h b/include/IECoreHoudini/OBJ_SceneCacheGeometry.h deleted file mode 100644 index c6bf20571c..0000000000 --- a/include/IECoreHoudini/OBJ_SceneCacheGeometry.h +++ /dev/null @@ -1,84 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_OBJSCENECACHEGEOMETRY_H -#define IECOREHOUDINI_OBJSCENECACHEGEOMETRY_H - -#include "IECoreHoudini/OBJ_SceneCacheNode.h" - -#include "OBJ/OBJ_Geometry.h" - -namespace IECoreHoudini -{ - -/// OBJ for loading a single transform and leaf Objects from an IECore::SceneCache -class IECOREHOUDINI_API OBJ_SceneCacheGeometry : public OBJ_SceneCacheNode -{ - public : - - OBJ_SceneCacheGeometry( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~OBJ_SceneCacheGeometry(); - - static const char *typeName; - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - static OP_TemplatePair *buildParameters(); - - virtual bool runCreateScript(); - - /// Implemented to expand the SceneCache using a SOP_SceneCacheSource. Derived classes - /// should re-implement doExpandGeometry() if specialized behaviour is necessary. - /// \todo: do we need this extra abstraction? - virtual void expandHierarchy( const IECoreScene::SceneInterface *scene ); - /// Implemented to push the GeometryType and attribute filter values to the sop below. - virtual void pushToHierarchy(); - - protected : - - /// Called by expandHierarchy() to load the SceneCache. The Space parameter will - /// determine what settings are used. World and Path will load all descedants, - /// while Local and Object will load the immediate child object only. - virtual void doExpandGeometry( const IECoreScene::SceneInterface *scene ); - - virtual int *getIndirect() const; - - private : - - static int *g_indirection; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_OBJSCENECACHEGEOMETRY_H diff --git a/include/IECoreHoudini/OBJ_SceneCacheNode.h b/include/IECoreHoudini/OBJ_SceneCacheNode.h deleted file mode 100644 index 0424f737ff..0000000000 --- a/include/IECoreHoudini/OBJ_SceneCacheNode.h +++ /dev/null @@ -1,101 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_OBJSCENECACHENODE_H -#define IECOREHOUDINI_OBJSCENECACHENODE_H - -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECoreScene/SceneCache.h" - -#include "OBJ/OBJ_Node.h" -#include "OP/OP_Node.h" - -namespace IECoreHoudini -{ - -/// Abstract base class for all OBJ SceneCacheNodes. -/// See OBJ_SceneCacheGeometry or OBJ_SceneCacheTransform for specific implementations. -template -class IECOREHOUDINI_API OBJ_SceneCacheNode : public SceneCacheNode -{ - public : - - OBJ_SceneCacheNode( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~OBJ_SceneCacheNode(); - - static PRM_Template *buildParameters( OP_TemplatePair *extraParameters = 0 ); - - static PRM_Name pMainSwitcher; - static PRM_Name pExpand; - static PRM_Name pPush; - static PRM_Name pCollapse; - static PRM_Name pExpanded; - static PRM_Name pOverrideTransform; - static PRM_Name pOutTranslate; - static PRM_Name pOutRotate; - static PRM_Name pOutScale; - - static int expandButtonCallback( void *data, int index, float time, const PRM_Template *tplate ); - static int pushButtonCallback( void *data, int index, float time, const PRM_Template *tplate ); - static int collapseButtonCallback( void *data, int index, float time, const PRM_Template *tplate ); - - /// Derived classes should define this function to expand the hierarchy contained in the SceneCache. - virtual void expandHierarchy( const IECoreScene::SceneInterface *scene ) = 0; - // Derived classes should define this function to update the hierarchy based on relevant parameter values. - virtual void pushToHierarchy() = 0; - /// Implemented to destroy all child nodes - virtual void collapseHierarchy(); - - protected : - - virtual void sceneChanged(); - - virtual OP_ERROR cookMyObj( OP_Context &context ); - virtual bool getParmTransform( OP_Context &context, UT_DMatrix4 &xform ); - virtual bool updateParmsFlags(); - void updateState(); - - UT_Matrix4D m_xform; - - private : - - static OP_TemplatePair *buildExpansionParameters(); - static OP_TemplatePair *buildOutputParameters(); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_OBJSCENECACHENODE_H diff --git a/include/IECoreHoudini/OBJ_SceneCacheTransform.h b/include/IECoreHoudini/OBJ_SceneCacheTransform.h deleted file mode 100644 index 447988c2b5..0000000000 --- a/include/IECoreHoudini/OBJ_SceneCacheTransform.h +++ /dev/null @@ -1,150 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_OBJSCENECACHETRANSFORM_H -#define IECOREHOUDINI_OBJSCENECACHETRANSFORM_H - -#include "IECoreHoudini/LiveScene.h" -#include "IECoreHoudini/OBJ_SceneCacheNode.h" - -#include "IECoreScene/LinkedScene.h" - -#include "OBJ/OBJ_SubNet.h" -#include "UT/UT_StringMMPattern.h" - -namespace IECoreHoudini -{ - -/// OBJ for loading a transform or expanding a hierarchy from an IECore::SceneCache -class IECOREHOUDINI_API OBJ_SceneCacheTransform : public OBJ_SceneCacheNode -{ - public : - - OBJ_SceneCacheTransform( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~OBJ_SceneCacheTransform(); - - static const char *typeName; - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - static OP_TemplatePair *buildParameters(); - - static PRM_Name pHierarchy; - static PRM_Name pDepth; - - static PRM_Default hierarchyDefault; - static PRM_Default depthDefault; - - static PRM_ChoiceList hierarchyList; - static PRM_ChoiceList depthList; - - enum Hierarchy - { - SubNetworks, - Parenting, - FlatGeometry - }; - - enum Depth - { - AllDescendants, - Children - }; - - /// Implemented to expand the SceneCache using a combination of OBJ_SceneCacheTransform - /// and/or OBJ_SceneCacheGeometry nodes depending on the settings for pHierarchy and pDepth. - /// Derived classes should re-implement doExpandObject() and doExpandChild() if specialized - /// behaviour is necessary. - virtual void expandHierarchy( const IECoreScene::SceneInterface *scene ); - /// Implemented to push the GeometryType and attribute filter values through the hierarchy, - /// and to update the visibility flags based on the tag filter. - virtual void pushToHierarchy(); - - protected : - - struct Parameters - { - Parameters(); - Parameters( const Parameters &other ); - - GeometryType geometryType; - Hierarchy hierarchy; - Depth depth; - UT_String attributeFilter; - UT_String attributeCopy; - UT_String shapeFilter; - UT_String tagFilterStr; - UT_StringMMPattern tagFilter; - UT_String fullPathName; - bool tagGroups; - bool visibilityFilter; - }; - - /// Called by expandHierarchy() and doExpandChildren() when the SceneCache contains an object. - /// Implemented to expand the specific object using an OBJ_SceneCacheGeometry node. - virtual OBJ_Node *doExpandObject( const IECoreScene::SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ); - - /// Called by doExpandChildren() when the SceneCache contains a child. - /// Implemented to expand the current cache path using an OBJ_SceneCacheTransform or - /// OBJ_SceneCacheGeometry node depending on the settings for hierarchy and depth. - virtual OBJ_Node *doExpandChild( const IECoreScene::SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ); - - /// Called by expandHierarchy() to expand the children of the SceneCache. - /// This will be called recursively for each child when Depth is AllDescenants. - virtual void doExpandChildren( const IECoreScene::SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ); - - static OP_TemplatePair *buildExtraParameters(); - - virtual int *getIndirect() const; - - private : - - /// functions registered in LiveScene as custom attributes - struct LiveSceneAddOn - { - LiveSceneAddOn(); - }; - static LiveSceneAddOn g_liveSceneAddOn; - - static void attributeNames( const OP_Node *node, IECoreScene::SceneInterface::NameList &attrs ); - static IECore::ConstObjectPtr readAttribute( const OP_Node *node, const IECoreScene::SceneInterface::Name &name, double time ); - static bool hasTag( const OP_Node *node, const IECoreScene::SceneInterface::Name &tag, int filter ); - static void readTags( const OP_Node *node, IECoreScene::SceneInterface::NameList &tags, int filter ); - - static int *g_indirection; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_OBJSCENECACHETRANSFORM_H diff --git a/include/IECoreHoudini/ParameterisedHolder.h b/include/IECoreHoudini/ParameterisedHolder.h deleted file mode 100644 index 023d93f1e1..0000000000 --- a/include/IECoreHoudini/ParameterisedHolder.h +++ /dev/null @@ -1,177 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_PARAMETERISEDHOLDER_H -#define IECOREHOUDINI_PARAMETERISEDHOLDER_H - -#include "IECoreHoudini/MessageHandler.h" -#include "IECoreHoudini/ParameterisedHolderInterface.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/Parameter.h" - -#include "OP/OP_Network.h" - -namespace IECoreHoudini -{ - -/// Class representing an OP node acting as a holder for the abstract Parameterised class. -template -class IECOREHOUDINI_API ParameterisedHolder : public BaseType, public ParameterisedHolderInterface -{ - public : - - ParameterisedHolder( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~ParameterisedHolder(); - - static PRM_Template parameters[]; - static CH_LocalVariable variables[]; - - static PRM_Name pParameterisedClassCategory; - static PRM_Name pParameterisedClassName; - static PRM_Name pParameterisedVersion; - static PRM_Name pParameterisedSearchPathEnvVar; - static PRM_Name pMatchString; - static PRM_Name pReloadButton; - static PRM_Name pEvaluateParameters; - static PRM_Name pSwitcher; - - static PRM_Default matchStringDefault; - static PRM_Default switcherDefaults[]; - - static PRM_ChoiceList classCategoryMenu; - static PRM_ChoiceList classNameMenu; - static PRM_ChoiceList classVersionMenu; - - //! @name className/version UI functions - /// Dynamic menus, callbacks, and helper functions for the className/version parameters. - ///////////////////////////////////////////////////////////////////////////////////////// - //@{ - /// \todo: the concept of class category is a hack to make the UI usable. remove this when - /// Houdini supports cascading menus for parameters. - static void buildClassCategoryMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - static void buildClassNameMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - static void buildVersionMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - static int reloadClassCallback( void *data, int index, float time, const PRM_Template *tplate ); - static int reloadButtonCallback( void *data, int index, float time, const PRM_Template *tplate ); - static void classNames( const std::string searchPathEnvVar, const std::string &matchString, std::vector &names ); - static void classVersions( const std::string className, const std::string searchPathEnvVar, std::vector &versions ); - static int defaultClassVersion( const std::string className, const std::string searchPathEnvVar ); - //@} - - virtual const char *inputLabel( unsigned pos ) const; - virtual unsigned minInputs() const; - virtual unsigned maxInputs() const; - - //! @name ParameterisedHolderInterface implementation - ///////////////////////////////////////////////////////////////////////////////////////// - //@{ - /// Set the node to hold a particular Parameterised object. When using this version - /// of setParameterised the node will not be able to preserve the object across scene - /// save/load - this becomes your responsibility if it's necessary. - virtual void setParameterised( IECore::RunTimeTypedPtr p ); - virtual void setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ); - virtual bool hasParameterised(); - virtual IECore::RunTimeTypedPtr getParameterised(); - /// \todo: actually implement this once parameter handling is in c++ - virtual bool setNodeValues(); - virtual void setParameterisedValues( double time ); - //@} - - protected : - - /// Load the node from disk. It checks for className/version/searchPath values on the node - /// and attempts to reload the parameterised class from disk - virtual bool load( UT_IStream &is, const char *ext, const char *path ); - - virtual IECore::MessageHandler *getMessageHandler(); - virtual void setMessageHandler( IECore::MessageHandler *handler ); - - /// Update a specific Cortex parameter using values from the corresponding Houdini node parameter. - /// @param prefix A string prefix for the houdini parameter name - /// @param top_level This should be true if you know the parm is the top-level CompoundParameter - void updateParameter( IECore::ParameterPtr parm, float now, std::string prefix="", bool top_level=false ); - - /// Pushes the data from the incomming connections into the associated Cortex parameters. - /// Derived classes should implement this method in a way appropriate to the context. - virtual void setInputParameterValues( float now ) = 0; - - /// updates the input connections to match the current loaded parameters - virtual void refreshInputConnections() = 0; - - /// A vector of IECore::Parameters which are passed through node inputs rather than PRM_Templates - /// Should be filled by refreshInputConnections() if input parameters make sense for this context. - IECore::CompoundParameter::ParameterVector m_inputParameters; - - /// Determines if the node is dirty - bool m_dirty; - - private : - - /// creates and sets a particular type/version of class on this node - void load( const std::string &className, int classVersion, const std::string &searchPathEnvVar, bool updateGUI=true ); - - /// Method for loading a Parameterised object from disk - IECore::RunTimeTypedPtr loadParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ); - - /// Checks for changes in parameter values and marks the node as dirty - template - void checkForUpdate( bool do_update, T val, IECore::ParameterPtr parm ) - { - if ( do_update ) - { - typename U::Ptr data = IECore::runTimeCast( parm->getValue() ); - if ( val != data->readable() ) - { - m_dirty = true; - } - } - } - - IECore::RunTimeTypedPtr m_parameterised; - - // stores the className of the currently loaded parameterised object (if any) - std::string m_loadedClassName; - - IECore::MessageHandlerPtr m_messageHandler; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_PARAMETERISEDHOLDER_H diff --git a/include/IECoreHoudini/ParameterisedHolderInterface.h b/include/IECoreHoudini/ParameterisedHolderInterface.h deleted file mode 100644 index 659afb2c71..0000000000 --- a/include/IECoreHoudini/ParameterisedHolderInterface.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_PARAMETERISEDHOLDERINTERFACE_H -#define IECOREHOUDINI_PARAMETERISEDHOLDERINTERFACE_H - -#include "IECoreHoudini/Export.h" - -#include "IECore/Parameter.h" -#include "IECore/Parameterised.h" - -namespace IECoreHoudini -{ - -/// A base class from which nodes to hold IECore::ParameterisedInterface objects -/// should multiply inherit (for example, ParameterisedHolder). -class IECOREHOUDINI_API ParameterisedHolderInterface -{ - - public : - - ParameterisedHolderInterface(); - virtual ~ParameterisedHolderInterface(); - - /// Sets the Parameterised object this node is holding. An IECore.ClassLoader object will be - /// used with searchpaths obtained from the specified environment variable to actually load - /// the Parameterised object. This mechanism is used rather than passing a ParameterisedPtr - /// as it allows the Parameterised object to be loaded again when a houdini scene is opened. - virtual void setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ) = 0; - /// Sets the Parameterised object this node is holding, directly. - virtual void setParameterised( IECore::RunTimeTypedPtr p ) = 0; - - /// Returns whether or not this node is holding a valid parameterised object - virtual bool hasParameterised() = 0; - - /// Returns the parameterised object held by this node - virtual IECore::RunTimeTypedPtr getParameterised() = 0; - - /// Convenience method to return dynamic_cast( getParameterised().get() ) - IECore::ParameterisedInterface *getParameterisedInterface(); - - /// Sets the attributes of the node to reflect the current values of the parameters in the held - /// Parameterised object. Performs validation of the parameter values and will return false if - //// any one is not valid. - virtual bool setNodeValues() = 0; - - /// Sets the values of the parameters of the held Parameterised object to reflect the values - // of the attributes of the node. - virtual void setParameterisedValues( double time ) = 0; - -}; - -} - -#endif // IECOREHOUDINI_PARAMETERISEDHOLDERINTERFACE_H diff --git a/include/IECoreHoudini/ROP_SceneCacheWriter.h b/include/IECoreHoudini/ROP_SceneCacheWriter.h deleted file mode 100644 index 6501400565..0000000000 --- a/include/IECoreHoudini/ROP_SceneCacheWriter.h +++ /dev/null @@ -1,108 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_ROPSCENECACHEWRITER_H -#define IECOREHOUDINI_ROPSCENECACHEWRITER_H - -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/LiveScene.h" -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECoreScene/SceneInterface.h" - -#include "ROP/ROP_Node.h" - -namespace IECoreHoudini -{ - -/// Class for writing SceneCache files based on an existing Houdini hierarchy -class IECOREHOUDINI_API ROP_SceneCacheWriter : public ROP_Node -{ - public : - - ROP_SceneCacheWriter( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~ROP_SceneCacheWriter(); - - static const char *typeName; - - static PRM_Name pFile; - static PRM_Name pRootObject; - static PRM_Name pForceObjects; - - static PRM_Default fileDefault; - static PRM_Default rootObjectDefault; - static PRM_SpareData forceObjectsSpareData; - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - static OP_TemplatePair *buildParameters(); - - protected : - - virtual int startRender( int nframes, fpreal s, fpreal e ); - virtual ROP_RENDER_CODE renderFrame( fpreal time, UT_Interrupt *boss ); - virtual ROP_RENDER_CODE endRender(); - - virtual bool updateParmsFlags(); - - /// Called recursively to traverse the IECoreHoudini::LiveScene, starting with the Root Object, - /// and write the hierarchy to the output file. - virtual ROP_RENDER_CODE doWrite( const IECoreScene::SceneInterface *liveScene, IECoreScene::SceneInterface *outScene, double time, UT_Interrupt *progress ); - - private : - - static const IECoreScene::SceneInterface::Name &changingHierarchyAttribute; - - bool linked( const std::string &file ) const; - - enum Mode - { - NaturalLink = 0, - ForcedLink, - NaturalExpand, - ForcedExpand - }; - - IECoreHoudini::LiveScenePtr m_liveHoudiniScene; - IECoreScene::ConstSceneInterfacePtr m_liveScene; - IECoreScene::SceneInterfacePtr m_outScene; - UT_StringMMPattern *m_forceFilter; - - double m_startTime; - double m_endTime; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_ROPSCENECACHEWRITER_H diff --git a/include/IECoreHoudini/SOP_CortexConverter.h b/include/IECoreHoudini/SOP_CortexConverter.h deleted file mode 100644 index 249c5a71fd..0000000000 --- a/include/IECoreHoudini/SOP_CortexConverter.h +++ /dev/null @@ -1,96 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2011-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SOPCORTEXCONVERTER_H -#define IECOREHOUDINI_SOPCORTEXCONVERTER_H - -#include "IECoreHoudini/Export.h" - -#include "PRM/PRM_Name.h" -#include "SOP/SOP_Node.h" - -namespace IECoreHoudini -{ - -/// SOP class for converting between GU_CortexPrimitives and native Houdini geometry. -class IECOREHOUDINI_API SOP_CortexConverter : public SOP_Node -{ - public : - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - - static const char *typeName; - - static PRM_Template parameters[]; - static CH_LocalVariable variables[]; - - enum ResultType - { - Cortex = 0, - Houdini - }; - - static PRM_Name pNameFilter; - static PRM_Name pAttributeFilter; - static PRM_Name pResultType; - static PRM_Name pConvertStandardAttributes; - - static PRM_Default convertStandardAttributesDefault; - static PRM_Default filterDefault; - static PRM_Default resultTypeDefault; - - static PRM_ChoiceList resultTypeList; - - virtual void getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ); - - protected : - - SOP_CortexConverter( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_CortexConverter(); - - virtual OP_ERROR cookMySop( OP_Context &context ); - - private : - - void doConvert( const GU_DetailHandle &handle, const std::string &name, ResultType type, const std::string &attributeFilter, bool convertStandardAttributes ); - void doPassThrough( const GU_DetailHandle &handle, const std::string &name ); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPCORTEXCONVERTER_H diff --git a/include/IECoreHoudini/SOP_OpHolder.h b/include/IECoreHoudini/SOP_OpHolder.h deleted file mode 100644 index eece693bfb..0000000000 --- a/include/IECoreHoudini/SOP_OpHolder.h +++ /dev/null @@ -1,80 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SOPOPHOLDER_H -#define IECOREHOUDINI_SOPOPHOLDER_H - -#include "IECoreHoudini/SOP_ParameterisedHolder.h" - -#include "IECore/Op.h" - -namespace IECoreHoudini -{ - -/// SOP class for representing an IECore::Op in Houdini. The held op will operate multiple times -/// over its primary input, splitting by name. Each operation adds a single GU_CortexPrimitive -/// to the output geometry. The held op will operate on any named shaped in the primary input -/// which matches the nameFilter. Non-matching shapes will be passed through without modification. -/// The other inputs will be treated as they normally would by SOP_ParameterisedHolder. -class IECOREHOUDINI_API SOP_OpHolder : public SOP_ParameterisedHolder -{ - public : - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - - protected : - - SOP_OpHolder( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_OpHolder(); - - virtual OP_ERROR cookMySop( OP_Context &context ); - - /// Overridden for the primary input since that value is used during cook to control - /// the number of operations. Falls back to default implementation for all other inputs. - virtual void setInputParameterValue( IECore::Parameter *parameter, const GU_DetailHandle &handle, unsigned inputIndex ); - - /// Run the op once all parameters have been set. This may be called several times - /// when using a nameFilter on the primary input. - virtual void doOperation( IECore::Op *op, const GU_DetailHandle &handle, const std::string &name ); - /// Pass-through the primary input shapes that do not match the nameFilter. - virtual void doPassThrough( const GU_DetailHandle &handle, const std::string &name ); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPOPHOLDER_H diff --git a/include/IECoreHoudini/SOP_ParameterisedHolder.h b/include/IECoreHoudini/SOP_ParameterisedHolder.h deleted file mode 100644 index adb1932d00..0000000000 --- a/include/IECoreHoudini/SOP_ParameterisedHolder.h +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SOPPARAMETERISEDHOLDER_H -#define IECOREHOUDINI_SOPPARAMETERISEDHOLDER_H - -#include "IECoreHoudini/ParameterisedHolder.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/ObjectParameter.h" - -#include "SOP/SOP_Node.h" -#include "UT/UT_StringMMPattern.h" - -namespace IECoreHoudini -{ - -/// Class representing a SOP node acting as a holder for the abstract Parameterised class. -class IECOREHOUDINI_API SOP_ParameterisedHolder : public ParameterisedHolder -{ - public : - - SOP_ParameterisedHolder( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_ParameterisedHolder(); - - virtual void getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ); - - protected : - - /// Pushes the geometry data from the incomming connections into the associated Cortex parameters. - /// This method will cook the incomming nodes. If the input node derives from SOP_ParameterisedHolder, - /// it's Cortex output will be passed through. If it is a native Houdini node, it will be converted - /// using the appropriate FromHoudiniGeometryConverter. - virtual void setInputParameterValues( float now ); - - /// Used by setInputParameterValues to set the value on each individual input parameter. Providing a - /// null handle will result in the default behaviour of using the filteredInputValue for this input. - virtual void setInputParameterValue( IECore::Parameter *parameter, const GU_DetailHandle &handle, unsigned inputIndex ); - - /// Used to pre-filter the input geometry during setInputParameterValue. It checks for the existance of - /// a nameFilter parm cooresponding to the input parameter, and uses FromHoudiniGeometryConverter::extract - /// to limit the input geometry based on that filter. - GU_DetailHandle filteredInputValue( const IECore::Parameter *parameter, unsigned inputIndex ); - - /// Used to find and evaluate the nameFilter, if it is enabled. - bool getNameFilter( const IECore::Parameter *parameter, UT_StringMMPattern &filter ); - - /// Updates the input connections for parameters relevant to FromHoudiniGeometryConverters - virtual void refreshInputConnections(); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPPARAMETERISEDHOLDER_H diff --git a/include/IECoreHoudini/SOP_SceneCacheSource.h b/include/IECoreHoudini/SOP_SceneCacheSource.h deleted file mode 100644 index 0fd53a13fc..0000000000 --- a/include/IECoreHoudini/SOP_SceneCacheSource.h +++ /dev/null @@ -1,126 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SOPSCENECACHESOURCE_H -#define IECOREHOUDINI_SOPSCENECACHESOURCE_H - -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECoreScene/MatrixTransform.h" -#include "IECoreScene/SceneCache.h" - -#include "SOP/SOP_Node.h" -#include "UT/UT_StringMMPattern.h" - -namespace IECoreHoudini -{ - -/// SOP for loading an IECore::SceneCache from disk -class IECOREHOUDINI_API SOP_SceneCacheSource : public SceneCacheNode -{ - public : - - SOP_SceneCacheSource( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_SceneCacheSource(); - - static const char *typeName; - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - static OP_TemplatePair *buildParameters(); - - static PRM_Name pObjectOnly; - - bool getObjectOnly() const; - void setObjectOnly( bool objectOnly ); - - virtual void getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ); - - protected : - - virtual OP_ERROR cookMySop( OP_Context &context ); - - virtual void sceneChanged(); - - private : - - struct Parameters - { - GeometryType geometryType; - std::string attributeFilter; - std::string attributeCopy; - std::string fullPathName; - UT_StringMMPattern shapeFilter; - UT_StringMMPattern tagFilter; - bool tagGroups; - bool hasAnimatedTopology; - bool hasAnimatedPrimVars; - bool visibilityFilter; - bool inheritedVisibility; - std::vector animatedPrimVars; - std::map namedRanges; - }; - - // Modify the object according the parameters, copying if neccessary. - IECore::ConstObjectPtr modifyObject( const IECore::Object *object, Parameters ¶ms ); - // Transform the object, copying if neccessary. Transforms Primitives (using IECore::TransformOp), - // Groups, and CoordinateSystems. Updates animatedTopology and animatedPrimVars if appropriate. - IECore::ConstObjectPtr transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters ¶ms ); - // Convert the object to Houdini, optimizing for animated primitive variables if possible. - bool convertObject( const IECore::Object *object, const std::string &name, const IECoreScene::SceneInterface *scene, Parameters ¶ms ); - - void loadObjects( const IECoreScene::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters ¶ms, size_t rootSize, std::string currentPath ); - IECoreScene::MatrixTransformPtr matrixTransform( Imath::M44d t ); - std::string relativePath( const IECoreScene::SceneInterface *scene, size_t rootSize ); - - struct InternedStringSort - { - bool operator() ( const IECoreScene::SceneInterface::Name &i, const IECoreScene::SceneInterface::Name &j ); - }; - - /// Utility for detecting geometric primitive variables that need transforming - struct TransformGeometricData - { - typedef bool ReturnType; - - template - ReturnType operator()( const T *data ) const; - }; - - IECore::ConstObjectPtr buildTransformPointCloud( const IECoreScene::SceneInterface *scene,const Imath::M44d &transform,const double time, Parameters ¶ms,const bool hasObject ); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPSCENECACHESOURCE_H diff --git a/include/IECoreHoudini/SOP_SceneCacheTransform.h b/include/IECoreHoudini/SOP_SceneCacheTransform.h deleted file mode 100644 index e2a9ad2b70..0000000000 --- a/include/IECoreHoudini/SOP_SceneCacheTransform.h +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SOPSCENECACHETRANSFORM_H -#define IECOREHOUDINI_SOPSCENECACHETRANSFORM_H - -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECoreScene/SceneCache.h" - -#include "SOP/SOP_Node.h" - -namespace IECoreHoudini -{ - -/// SOP for loading an IECore::SceneCache from disk -class IECOREHOUDINI_API SOP_SceneCacheTransform : public SceneCacheNode -{ - public : - - SOP_SceneCacheTransform( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SOP_SceneCacheTransform(); - - static const char *typeName; - - enum Mode - { - Name = 0, - Root - }; - - static PRM_Name pMode; - static PRM_Name pInvert; - - static PRM_Default modeDefault; - - static PRM_ChoiceList modeList; - - static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op ); - static OP_TemplatePair *buildParameters(); - - virtual void getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ); - - protected : - - virtual OP_ERROR cookMySop( OP_Context &context ); - - virtual void sceneChanged(); - - private : - - void transformByName( const IECoreScene::SceneInterface *scene, double time, Space space, bool invert ); - UT_Matrix4 getTransform( const IECoreScene::SceneInterface *rootScene, const IECoreScene::SceneInterface *scene, double time, Space space, bool invert ); - Imath::M44d relativeTransform( const IECoreScene::SceneInterface *rootScene, const IECoreScene::SceneInterface *scene, double time ); - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SOPSCENECACHETRANSFORM_H diff --git a/include/IECoreHoudini/SceneCacheNode.h b/include/IECoreHoudini/SceneCacheNode.h deleted file mode 100644 index 621e1ffdd5..0000000000 --- a/include/IECoreHoudini/SceneCacheNode.h +++ /dev/null @@ -1,193 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_SCENECACHENODE_H -#define IECOREHOUDINI_SCENECACHENODE_H - -#include "IECoreHoudini/Export.h" - -#include "IECoreScene/SceneCache.h" - -#include "IECore/LRUCache.h" - -#include "OP/OP_Operator.h" -#include "PRM/PRM_Name.h" - -#include "boost/logic/tribool.hpp" - -#include "tbb/mutex.h" - -namespace IECoreHoudini -{ - -/// Abstract class for using an IECore::SceneCache in Houdini. -/// Derived nodes will do something useful with the data. -template -class IECOREHOUDINI_API SceneCacheNode : public BaseType -{ - public : - - SceneCacheNode( OP_Network *net, const char *name, OP_Operator *op ); - virtual ~SceneCacheNode(); - - static PRM_Name pFile; - static PRM_Name pRoot; - static PRM_Name pSpace; - static PRM_Name pReload; - static PRM_Name pGeometryType; - static PRM_Name pAttributeFilter; - static PRM_Name pAttributeCopy; - static PRM_Name pTagFilter; - static PRM_Name pTagGroups; - static PRM_Name pShapeFilter; - static PRM_Name pFullPathName; - static PRM_Name pVisibilityFilter; - - static PRM_Default rootDefault; - static PRM_Default spaceDefault; - static PRM_Default filterDefault; - static PRM_Default geometryTypeDefault; - - static PRM_ChoiceList rootMenu; - static PRM_ChoiceList spaceList; - static PRM_ChoiceList geometryTypeList; - static PRM_ChoiceList attributeCopyMenu; - static PRM_ChoiceList tagFilterMenu; - static PRM_ChoiceList shapeFilterMenu; - - static int sceneParmChangedCallback( void *data, int index, float time, const PRM_Template *tplate ); - static int reloadButtonCallback( void *data, int index, float time, const PRM_Template *tplate ); - static void buildRootMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - static void buildTagFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - static void buildShapeFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ); - - enum Space - { - World, - Path, - Local, - Object - }; - - enum GeometryType - { - Cortex, - Houdini, - BoundingBox, - PointCloud, - TransformPointCloud - }; - - /// convenience methods for the common parameters; - std::string getFile() const; - void setFile( std::string file ); - std::string getPath() const; - void setPath( const IECoreScene::SceneInterface *scene ); - Space getSpace() const; - void setSpace( Space space ); - GeometryType getGeometryType() const; - void setGeometryType( GeometryType type ); - void getAttributeFilter( UT_String &filter ) const; - void getAttributeFilter( UT_StringMMPattern &filter ) const; - void setAttributeFilter( const UT_String &filter ); - void getAttributeCopy( UT_String &value ) const; - void setAttributeCopy( const UT_String &value ); - void getTagFilter( UT_String &filter ) const; - void getTagFilter( UT_StringMMPattern &filter ) const; - void setTagFilter( const UT_String &filter ); - bool getVisibilityFilter() const; - void setVisibilityFilter( bool visibilityFilter ); - void setVisibilityExpression(); - void clearVisibilityExpression(); - bool getTagGroups() const; - void setTagGroups( bool tagGroups ); - void getShapeFilter( UT_String &filter ) const; - void getShapeFilter( UT_StringMMPattern &filter ) const; - void setShapeFilter( const UT_String &filter ); - void getFullPathName( UT_String &name ) const; - void setFullPathName( const UT_String &name ); - void referenceParent( const char *parmName ); - - /// Access point to the actual SceneCache. All users should only access the cache - /// using this method, in order to avoid re-opening existing files. - IECoreScene::ConstSceneInterfacePtr scene() const; - - /// Return the SceneCache time represented by this Houdini Context. This is not a - /// simple getTime() call, because Houdini treats time starting at Frame 1, while - /// SceneCaches treat time starting at Frame 0. Note that this function should - /// really be adjusting time by 1/fps used at cache time, but we don't have access - /// to that, so we assume that Houdini's current frame rate is representative. - double time( OP_Context context ) const; - - /// Determine if the given scene has any tag matching the filter - static bool tagged( const IECoreScene::SceneInterface *scene, const UT_StringMMPattern &filter ); - - bool visibility( double frame ) const; - - protected : - - /// Access point to the actual SceneCache. All derived classes should only access the cache - /// using this method, in order to avoid re-opening existing files. - static IECoreScene::ConstSceneInterfacePtr scene( const std::string &fileName, const std::string &path ); - - /// Computes the worldTransform for the specified path - Imath::M44d worldTransform( const std::string &fileName, const std::string &path, double time ); - - /// Called from setFile, setPath, and when either the file or path parameters are changed. - /// The default implementation sets m_loaded false. Derived nodes may override this if convenient. - virtual void sceneChanged(); - /// get the file and ensure it is a valid SCC - bool ensureFile( std::string &file ); - - /// get a breadth first list of all descendant paths - void descendantNames( const IECoreScene::SceneInterface *scene, std::vector &descendants ); - /// get a depth first list of all object names - void objectNames( const IECoreScene::SceneInterface *scene, std::vector &objects ); - /// get the full path to a scene including the name - static std::string getFullScenePath( const IECoreScene::SceneInterface *scene ); - /// utility method to build a UI menu from one of the previous lists - void createMenu( PRM_Name *menu, const std::vector &values ); - - static OP_TemplatePair *buildMainParameters(); - static OP_TemplatePair *buildOptionParameters(); - - bool m_loaded; - boost::tribool m_static; - IECore::MurmurHash m_hash; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_SCENECACHENODE_H diff --git a/include/IECoreHoudini/ToHoudiniAttribConverter.h b/include/IECoreHoudini/ToHoudiniAttribConverter.h deleted file mode 100644 index 4481884888..0000000000 --- a/include/IECoreHoudini/ToHoudiniAttribConverter.h +++ /dev/null @@ -1,116 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_H -#define IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_H - -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/ToHoudiniConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/Data.h" - -#include "GA/GA_AttributeRef.h" -#include "GU/GU_Detail.h" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( ToHoudiniAttribConverter ); - -/// The ToHoudiniAttribConverter class forms an abstract base class for all classes -/// able to perform some kind of conversion from IECore::Data to a Houdini GB_Attribute. -/// The resulting GB_Attribute will be transferred onto the provided GU_Detail. -class IECOREHOUDINI_API ToHoudiniAttribConverter : public ToHoudiniConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniAttribConverter, ToHoudiniAttribConverterTypeId, ToHoudiniConverter ); - - /// Converts the IECore::Data into a GB_Attribute on the given GU_Detail and returns the - /// associated GA_RWAttributeRef. It is assumed that the user has aquired the write lock - /// for the given GU_Detail. - GA_RWAttributeRef convert( std::string name, GU_Detail *geo ) const; - GA_RWAttributeRef convert( std::string name, GU_Detail *geo, const GA_Range &range ) const; - - /// Creates a converter which will convert the given IECore::Data to a Houdini GB_Attribute. - /// Returns 0 if no such converter can be found. - static ToHoudiniAttribConverterPtr create( const IECore::Data *data ); - - protected : - - ToHoudiniAttribConverter( const IECore::Data *data, const std::string &description ); - - virtual ~ToHoudiniAttribConverter(); - - /// Must be implemented by derived classes to create a GB_Attribute on the given GU_Detail and fill it with the IECore::Data - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const = 0; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const = 0; - - typedef ToHoudiniAttribConverterPtr (*CreatorFn)( const IECore::Data *data ); - - static void registerConverter( IECore::TypeId fromType, CreatorFn creator ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class Description - { - public : - Description( IECore::TypeId fromType ); - private : - static ToHoudiniAttribConverterPtr creator( const IECore::Data *data ); - }; - - private : - - /// Struct for maintaining the registered derived classes - struct Types - { - Types( IECore::TypeId from ); - IECore::TypeId fromType; - bool operator < ( const Types &other ) const; - }; - - typedef std::map TypesToFnsMap; - static TypesToFnsMap *typesToFns(); - -}; - -} // namespace IECoreHoudini - -#include "ToHoudiniAttribConverter.inl" - -#endif // IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniAttribConverter.inl b/include/IECoreHoudini/ToHoudiniAttribConverter.inl deleted file mode 100644 index 1a2578f236..0000000000 --- a/include/IECoreHoudini/ToHoudiniAttribConverter.inl +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_INL -#define IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_INL - -#include "IECoreHoudini/ToHoudiniAttribConverter.h" - -#include "IECore/CompoundData.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -namespace IECoreHoudini -{ - -template -ToHoudiniAttribConverter::Description::Description( IECore::TypeId fromType ) -{ - ToHoudiniAttribConverter::registerConverter( fromType, creator ); -} - -template -ToHoudiniAttribConverterPtr ToHoudiniAttribConverter::Description::creator( const IECore::Data *data ) -{ - return new T( data ); -} - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDINIATTRIBCONVERTER_INL diff --git a/include/IECoreHoudini/ToHoudiniCompoundObjectConverter.h b/include/IECoreHoudini/ToHoudiniCompoundObjectConverter.h deleted file mode 100644 index 008e1d2298..0000000000 --- a/include/IECoreHoudini/ToHoudiniCompoundObjectConverter.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTER_H -#define IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTER_H - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from an IECore::CompoundObject to a Houdini GU_Detail. This converter -/// unpacks the CompoundObject, creating a GU_CortexPrimitive for each member and naming it accordingly. -class IECOREHOUDINI_API ToHoudiniCompoundObjectConverter : public IECoreHoudini::ToHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniCompoundObjectConverter, ToHoudiniCompoundObjectConverterTypeId, IECoreHoudini::ToHoudiniGeometryConverter ); - - ToHoudiniCompoundObjectConverter( const IECore::Object *object ); - - virtual ~ToHoudiniCompoundObjectConverter(); - - /// We don't actually transfer any attribs in this case, so overriding as a no-op - virtual void transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const; - - protected : - - /// performs conversion from the IECore::CompoundObject into the given GU_Detail - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const; - - private : - - static ToHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( ToHoudiniCompoundObjectConverter ); - -} - -#endif // IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniConverter.h b/include/IECoreHoudini/ToHoudiniConverter.h deleted file mode 100644 index 148b86a907..0000000000 --- a/include/IECoreHoudini/ToHoudiniConverter.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICONVERTER_H -#define IECOREHOUDINI_TOHOUDINICONVERTER_H - -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/FromCoreConverter.h" - -namespace IECoreHoudini -{ - -/// A base class for all classes which convert from an IECore datatype -/// to a Houdini datatype. -class IECOREHOUDINI_API ToHoudiniConverter : public IECore::FromCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniConverter, ToHoudiniConverterTypeId, IECore::FromCoreConverter ); - - protected: - - ToHoudiniConverter( const std::string &description, IECore::TypeId supportedType ); - - virtual ~ToHoudiniConverter(); - -}; - -IE_CORE_DECLAREPTR( ToHoudiniConverter ); - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDINICONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniCortexObjectConverter.h b/include/IECoreHoudini/ToHoudiniCortexObjectConverter.h deleted file mode 100644 index 22ee6fc723..0000000000 --- a/include/IECoreHoudini/ToHoudiniCortexObjectConverter.h +++ /dev/null @@ -1,80 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTER_H -#define IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTER_H - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from an IECore::Object to a Houdini GU_Detail. This converter -/// creates a single GU_CortexPrimitive containing the Object, and adds it to the detail. -class IECOREHOUDINI_API ToHoudiniCortexObjectConverter : public IECoreHoudini::ToHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniCortexObjectConverter, ToHoudiniCortexObjectConverterTypeId, IECoreHoudini::ToHoudiniGeometryConverter ); - - ToHoudiniCortexObjectConverter( const IECore::Object *object ); - - virtual ~ToHoudiniCortexObjectConverter(); - - /// We don't actually transfer any attribs during conversion, but this method can be used to - /// transfer PrimitiveVariables from the source Object, provided it is an IECore::Primitive, - /// the GA_Range contains a GU_CortexPrimitive which also holds an IECore::Primitive, and both - /// Primitives have the same variable sizes. - virtual void transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const; - - protected : - - /// performs conversion from the IECore::Object into the given GU_Detail - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const; - - private : - - // Used to apply the attributeFilter to the Object, if it is a Primitive - IECore::ConstObjectPtr filterAttribs( const IECore::Object *object ) const; - - static ToHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( ToHoudiniCortexObjectConverter ); - -} - -#endif // IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniCurvesConverter.h b/include/IECoreHoudini/ToHoudiniCurvesConverter.h deleted file mode 100644 index 4e4d82b590..0000000000 --- a/include/IECoreHoudini/ToHoudiniCurvesConverter.h +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICURVESCONVERTER_H -#define IECOREHOUDINI_TOHOUDINICURVESCONVERTER_H - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/CurvesPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from an IECore::CurvesPrimitive to a Houdini GU_Detail -class IECOREHOUDINI_API ToHoudiniCurvesConverter : public IECoreHoudini::ToHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniCurvesConverter, ToHoudiniCurvesConverterTypeId, IECoreHoudini::ToHoudiniGeometryConverter ); - - ToHoudiniCurvesConverter( const IECore::Object *object ); - - virtual ~ToHoudiniCurvesConverter(); - - /// Transfers the primitive variables from the IECore::Primitive to the GU_Detail. - virtual void transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const; - - protected : - - /// performs conversion from the IECore::CurvesPrimitive into the given GU_Detail - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const; - - /// Implemented to adjust Vertex interpolated PrimitiveVariables for de-duplicated end points - virtual IECoreScene::PrimitiveVariable processPrimitiveVariable( const IECoreScene::Primitive *primitive, const IECoreScene::PrimitiveVariable &primVar ) const; - - private : - - static ToHoudiniGeometryConverter::Description m_description; - - /// Utility struct for removing duplicated curve end points using DespatchedTypedData - struct RemoveDuplicateEnds - { - typedef IECore::DataPtr ReturnType; - - RemoveDuplicateEnds( const std::vector &vertsPerCurve ); - - template - ReturnType operator()( const T *data ) const; - - const std::vector &m_vertsPerCurve; - }; -}; - -// register our converter -IE_CORE_DECLAREPTR( ToHoudiniCurvesConverter ); - -} - -#endif // IECOREHOUDINI_TOHOUDINICURVESCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniGeometryConverter.h b/include/IECoreHoudini/ToHoudiniGeometryConverter.h deleted file mode 100644 index e9ffe09f93..0000000000 --- a/include/IECoreHoudini/ToHoudiniGeometryConverter.h +++ /dev/null @@ -1,165 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_H -#define IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_H - -#include "IECoreHoudini/ToHoudiniConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/Primitive.h" -#include "IECoreScene/VisibleRenderable.h" - -#include "IECore/SimpleTypedParameter.h" -#include "IECore/VectorTypedData.h" - -#include "GU/GU_Detail.h" -#include "GU/GU_DetailHandle.h" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( ToHoudiniGeometryConverter ); - -/// The ToHoudiniGeometryConverter class forms a base class for all classes able to perform -/// some kind of conversion from an IECore::Object to a Houdini GU_Detail. -class IECOREHOUDINI_API ToHoudiniGeometryConverter : public ToHoudiniConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniGeometryConverter, ToHoudiniGeometryConverterTypeId, ToHoudiniConverter ); - - /// Converts the IECore::Object into the given GU_Detail and returns true if successful - /// and false otherwise. Implemented to aquire the write lock on the GU_Detail held by the - /// GU_DetailHandle, call doConversion(), and finally unlock the GU_Detail. - bool convert( GU_DetailHandle handle ) const; - - /// Transfers the primitive variables from the IECore::Primitive to the GU_Detail. This is - /// usually called by convert(), but is also provided here so attribs may be transfered onto - /// existing topology. - virtual void transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const; - - /// Creates a converter which will convert the given IECore::Object to a Houdini GU_Detail. - /// Returns 0 if no such converter can be found. - static ToHoudiniGeometryConverterPtr create( const IECore::Object *object ); - - /// Fills the passed vector with all the IECore::TypeIds for which - /// a ToHoudiniGeometryConverter is available. - static void supportedTypes( std::set &types ); - - IECore::StringParameter *nameParameter(); - const IECore::StringParameter *nameParameter() const; - - IECore::StringParameter *attributeFilterParameter(); - const IECore::StringParameter *attributeFilterParameter() const; - - IECore::BoolParameter *convertStandardAttributesParameter(); - const IECore::BoolParameter *convertStandardAttributesParameter() const; - - protected : - - ToHoudiniGeometryConverter( const IECore::Object *object, const std::string &description ); - - virtual ~ToHoudiniGeometryConverter(); - - /// Must be implemented by derived classes to fill the given GU_Detail with data from the IECore::Object - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const = 0; - - /// Utility to name the primitives based on the name parameter. This is called by the default - /// implementation of transferAttribs(), and should be called by any overriding implementation. - void setName( GU_Detail *geo, const GA_Range &prims ) const; - - /// May be implemented by derived classes to pre-process PrimitiveVariables before conversion. - /// Default implementation simply returns a shallow copy of the input variable. - virtual IECoreScene::PrimitiveVariable processPrimitiveVariable( const IECoreScene::Primitive *primitive, const IECoreScene::PrimitiveVariable &primVar ) const; - - typedef ToHoudiniGeometryConverterPtr (*CreatorFn)( const IECore::Object *object ); - - static void registerConverter( IECore::TypeId fromType, CreatorFn creator ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class Description - { - public : - Description( IECore::TypeId fromType ); - private : - static ToHoudiniGeometryConverterPtr creator( const IECore::Object *object ); - }; - - /// Appends points to the GA_Detail. Returns a GA_Range containing the GA_Offsets for the newly added points. - GA_Range appendPoints( GA_Detail *geo, size_t numPoints ) const; - - /// Transfers the primitive variables from the IECore::Primitive to the GU_Detail. In most cases, - /// derived classes will implement transferAttribs to call this method with the appropriate arguments. - void transferAttribValues( - const IECoreScene::Primitive *primitive, GU_Detail *geo, const GA_Range &points, const GA_Range &prims, - IECoreScene::PrimitiveVariable::Interpolation vertexInterpolation = IECoreScene::PrimitiveVariable::FaceVarying, - IECoreScene::PrimitiveVariable::Interpolation primitiveInterpolation = IECoreScene::PrimitiveVariable::Uniform, - IECoreScene::PrimitiveVariable::Interpolation pointInterpolation = IECoreScene::PrimitiveVariable::Vertex, - IECoreScene::PrimitiveVariable::Interpolation detailInterpolation = IECoreScene::PrimitiveVariable::Constant - ) const; - - private : - - IECore::StringParameterPtr m_nameParameter; - IECore::StringParameterPtr m_attributeFilterParameter; - IECore::BoolParameterPtr m_convertStandardAttributesParameter; - - // function to handle the special case for P - void transferP( const IECore::V3fVectorData *positions, GU_Detail *geo, const GA_Range &points ) const; - - // function to map standard IECore PrimitiveVariable names to Houdini names - const std::string processPrimitiveVariableName( const std::string &name ) const; - - /// Struct for maintaining the registered derived classes - struct Types - { - Types( IECore::TypeId from ); - IECore::TypeId fromType; - bool operator < ( const Types &other ) const; - }; - - typedef std::map TypesToFnsMap; - static TypesToFnsMap *typesToFns(); - -}; - -} // namespace IECoreHoudini - -#include "ToHoudiniGeometryConverter.inl" - -#endif // IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniGeometryConverter.inl b/include/IECoreHoudini/ToHoudiniGeometryConverter.inl deleted file mode 100644 index 852513b5a4..0000000000 --- a/include/IECoreHoudini/ToHoudiniGeometryConverter.inl +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_INL -#define IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_INL - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" - -namespace IECoreHoudini -{ - -template -ToHoudiniGeometryConverter::Description::Description( IECore::TypeId fromType ) -{ - ToHoudiniGeometryConverter::registerConverter( fromType, creator ); -} - -template -ToHoudiniGeometryConverterPtr ToHoudiniGeometryConverter::Description::creator( const IECore::Object *object ) -{ - return new T( object ); -} - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTER_INL diff --git a/include/IECoreHoudini/ToHoudiniNumericAttribConverter.h b/include/IECoreHoudini/ToHoudiniNumericAttribConverter.h deleted file mode 100644 index 9cdaad7bce..0000000000 --- a/include/IECoreHoudini/ToHoudiniNumericAttribConverter.h +++ /dev/null @@ -1,123 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_H -#define IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_H - -#include "IECoreHoudini/Export.h" -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/VectorTypedData.h" - -namespace IECoreHoudini -{ - -/// This template class can convert from various numeric IECore VectorTypeData types -/// to a Houdini GA_Attribute on the provided GU_Detail. -template -class IECOREHOUDINI_API ToHoudiniNumericVectorAttribConverter : public ToHoudiniAttribConverter -{ - - public : - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( ToHoudiniNumericVectorAttribConverter, ToHoudiniAttribConverter ); - - ToHoudiniNumericVectorAttribConverter( const IECore::Data *data ); - - virtual ~ToHoudiniNumericVectorAttribConverter(); - - protected : - - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const; - - private : - - static ToHoudiniAttribConverter::Description m_description; - -}; - -/// This template class can convert from various numeric IECore SimpleTypedData types -/// to a Houdini GA_Attribute on the provided GU_Detail. -template -class IECOREHOUDINI_API ToHoudiniNumericDetailAttribConverter : public ToHoudiniAttribConverter -{ - - public : - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( ToHoudiniNumericDetailAttribConverter, ToHoudiniAttribConverter ); - - ToHoudiniNumericDetailAttribConverter( const IECore::Data *data ); - - virtual ~ToHoudiniNumericDetailAttribConverter(); - - protected : - - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const; - - private : - - static ToHoudiniAttribConverter::Description m_description; - -}; - -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniFloatVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniV2fVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniV3fVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniColor3fVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniIntVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniV2iVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniV3iVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniM33fVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniM44fVectorAttribConverter; -typedef ToHoudiniNumericVectorAttribConverter ToHoudiniM44dVectorAttribConverter; - -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniFloatDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniV2fDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniV3fDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniColor3fDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniIntDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniV2iDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniV3iDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniM33fDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniM44fDetailAttribConverter; -typedef ToHoudiniNumericDetailAttribConverter ToHoudiniM44dDetailAttribConverter; - -} // namespace IECoreHoudini - -#include "ToHoudiniNumericAttribConverter.inl" - -#endif // IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniNumericAttribConverter.inl b/include/IECoreHoudini/ToHoudiniNumericAttribConverter.inl deleted file mode 100644 index 340614d5b4..0000000000 --- a/include/IECoreHoudini/ToHoudiniNumericAttribConverter.inl +++ /dev/null @@ -1,223 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_INL -#define IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_INL - -#include "IECoreHoudini/ToHoudiniNumericAttribConverter.h" -#include "IECoreHoudini/TypeTraits.h" - -#include "IECore/DespatchTypedData.h" -#include "IECore/VectorTraits.h" - -#include "boost/format.hpp" - -namespace IECoreHoudini -{ - -template -ToHoudiniAttribConverter::Description > ToHoudiniNumericVectorAttribConverter::m_description( T::staticTypeId() ); - -template -ToHoudiniNumericVectorAttribConverter::ToHoudiniNumericVectorAttribConverter( const IECore::Data *data ) : - ToHoudiniAttribConverter( data, "Converts numeric IECore VectorTypedData to a GA_Attribute on the provided GU_Detail." ) -{ -} - -template -ToHoudiniNumericVectorAttribConverter::~ToHoudiniNumericVectorAttribConverter() -{ -} - -template -GA_RWAttributeRef ToHoudiniNumericVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const -{ - throw IECore::Exception( "ToHoudiniNumericVectorAttribConverter does not support Detail attributes." ); -} - -struct GetInterpretation -{ - typedef void ReturnType; - - GA_RWAttributeRef m_attrRef; - - template - ReturnType operator() ( T *data ) - { - assert( data ); - - IECore::GeometricData::Interpretation interp = data->getInterpretation(); - - if ( interp == IECore::GeometricData::Point ) - { - m_attrRef.setTypeInfo( GA_TYPE_POINT ); - } - else if ( interp == IECore::GeometricData::Normal ) - { - m_attrRef.setTypeInfo( GA_TYPE_NORMAL ); - } - else if ( interp == IECore::GeometricData::Vector ) - { - m_attrRef.setTypeInfo( GA_TYPE_VECTOR ); - } - else if ( interp == IECore::GeometricData::Color ) - { - m_attrRef.setTypeInfo( GA_TYPE_COLOR ); - } - else if ( interp == IECore::GeometricData::UV ) - { - m_attrRef.setTypeInfo( GA_TYPE_TEXTURE_COORD ); - } - } -}; - -template -GA_RWAttributeRef ToHoudiniNumericVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - assert( data ); - - typedef typename T::BaseType BaseType; - typedef typename T::ValueType::value_type ValueType; - - unsigned dimensions = sizeof( ValueType ) / sizeof( BaseType ); - - GA_RWAttributeRef attrRef; - - if ( IECoreHoudini::TypeTraits::IsVectorAttribFloatTypedData::value ) - { - attrRef = geo->addFloatTuple( range.getOwner(), name.c_str(), dimensions ); - } - else if ( IECoreHoudini::TypeTraits::IsVectorAttribIntTypedData::value ) - { - attrRef = geo->addIntTuple( range.getOwner(), name.c_str(), dimensions ); - } - else - { - throw IECore::Exception( ( boost::format( "ToHoudiniNumericVectorAttribConverter::doConversion: PrimitiveVariable \"%s\" is not of a supported data type." ) % name ).str() ); - } - - if ( attrRef.isInvalid() ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniNumericVectorAttribConverter::doConversion: Invalid GA_RWAttributeRef returned for PrimitiveVariable \"%s\"." ) % name ).str() ); - } - - if ( IECoreHoudini::TypeTraits::IsAttribColorTypedData::value ) - { - attrRef.setTypeInfo( GA_TYPE_COLOR ); - } - - typename T::ConstPtr dataPtr = IECore::runTimeCast( data ); - const BaseType *src = dataPtr->baseReadable(); - - GA_Attribute *attr = attrRef.getAttribute(); - attr->getAIFTuple()->setRange( attr, range, src ); - - // set the geometric interpretation if it exists - GetInterpretation func = { attrRef }; - IECore::despatchTypedData< GetInterpretation, IECore::TypeTraits::IsGeometricTypedData, IECore::DespatchTypedDataIgnoreError >( const_cast( data ), func ); - - return attrRef; -} - -template -ToHoudiniAttribConverter::Description > ToHoudiniNumericDetailAttribConverter::m_description( T::staticTypeId() ); - -template -ToHoudiniNumericDetailAttribConverter::ToHoudiniNumericDetailAttribConverter( const IECore::Data *data ) : - ToHoudiniAttribConverter( data, "Converts numeric IECore SimpleTypedData to a GA_Attribute on the provided GU_Detail." ) -{ -} - -template -ToHoudiniNumericDetailAttribConverter::~ToHoudiniNumericDetailAttribConverter() -{ -} - -template -GA_RWAttributeRef ToHoudiniNumericDetailAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const -{ - assert( data ); - - typedef typename T::BaseType BaseType; - typedef typename T::ValueType ValueType; - - unsigned dimensions = sizeof( ValueType ) / sizeof( BaseType ); - - GA_RWAttributeRef attrRef; - - if ( IECoreHoudini::TypeTraits::IsDetailAttribFloatTypedData::value ) - { - attrRef = geo->addFloatTuple( GA_ATTRIB_DETAIL, name.c_str(), dimensions ); - } - else if ( IECoreHoudini::TypeTraits::IsDetailAttribIntTypedData::value ) - { - attrRef = geo->addIntTuple( GA_ATTRIB_DETAIL, name.c_str(), dimensions ); - } - else - { - throw IECore::Exception( ( boost::format( "ToHoudiniNumericDetailAttribConverter::doConversion: PrimitiveVariable \"%s\" is not of a supported data type." ) % name ).str() ); - } - - if ( attrRef.isInvalid() ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniNumericDetailAttribConverter::doConversion: Invalid GA_RWAttributeRef returned for PrimitiveVariable \"%s\"." ) % name ).str() ); - } - - if ( IECoreHoudini::TypeTraits::IsAttribColorTypedData::value ) - { - attrRef.setTypeInfo( GA_TYPE_COLOR ); - } - - typename T::ConstPtr dataPtr = IECore::runTimeCast( data ); - const BaseType *src = dataPtr->baseReadable(); - - GA_Attribute *attr = attrRef.getAttribute(); - attr->getAIFTuple()->setRange( attr, geo->getGlobalRange(), src ); - - // set the geometric interpretation if it exists - GetInterpretation func = { attrRef }; - IECore::despatchTypedData< GetInterpretation, IECore::TypeTraits::IsGeometricTypedData, IECore::DespatchTypedDataIgnoreError >( const_cast( data ), func ); - - return attrRef; -} - -template -GA_RWAttributeRef ToHoudiniNumericDetailAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - throw IECore::Exception( "ToHoudiniNumericDetailAttribConverter does not support Element attributes." ); -} - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDININUMERICATTRIBCONVERTER_INL diff --git a/include/IECoreHoudini/ToHoudiniPointsConverter.h b/include/IECoreHoudini/ToHoudiniPointsConverter.h deleted file mode 100644 index d59b3f9dce..0000000000 --- a/include/IECoreHoudini/ToHoudiniPointsConverter.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIPOINTSCONVERTER_H -#define IECOREHOUDINI_TOHOUDINIPOINTSCONVERTER_H - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/PointsPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from an IECore::PointsPrimitive to a Houdini GU_Detail -class IECOREHOUDINI_API ToHoudiniPointsConverter : public IECoreHoudini::ToHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniPointsConverter, ToHoudiniPointsConverterTypeId, IECoreHoudini::ToHoudiniGeometryConverter ); - - ToHoudiniPointsConverter( const IECore::Object *object ); - - virtual ~ToHoudiniPointsConverter(); - - /// Transfers the primitive variables from the IECore::Primitive to the GU_Detail. - virtual void transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const; - - protected : - - /// performs conversion from the IECore::PointsPrimitive into the given GU_Detail - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const; - - private : - - static ToHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( ToHoudiniPointsConverter ); - -} - -#endif // IECOREHOUDINI_TOHOUDINIPOINTSCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniPolygonsConverter.h b/include/IECoreHoudini/ToHoudiniPolygonsConverter.h deleted file mode 100644 index feae64cd80..0000000000 --- a/include/IECoreHoudini/ToHoudiniPolygonsConverter.h +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTER_H -#define IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTER_H - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECoreScene/MeshPrimitive.h" - -namespace IECoreHoudini -{ - -/// Converter which converts from an IECore::MeshPrimitive to a Houdini GU_Detail -class IECOREHOUDINI_API ToHoudiniPolygonsConverter : public IECoreHoudini::ToHoudiniGeometryConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniPolygonsConverter, ToHoudiniPolygonsConverterTypeId, IECoreHoudini::ToHoudiniGeometryConverter ); - - ToHoudiniPolygonsConverter( const IECore::Object *object ); - - virtual ~ToHoudiniPolygonsConverter(); - - protected : - - /// performs conversion from the IECore::MeshPrimitive into the given GU_Detail - virtual bool doConversion( const IECore::Object *object, GU_Detail *geo ) const; - - private : - - static ToHoudiniGeometryConverter::Description m_description; -}; - -// register our converter -IE_CORE_DECLAREPTR( ToHoudiniPolygonsConverter ); - -} - -#endif // IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniQuatAttribConverter.h b/include/IECoreHoudini/ToHoudiniQuatAttribConverter.h deleted file mode 100644 index 6ac27c2b94..0000000000 --- a/include/IECoreHoudini/ToHoudiniQuatAttribConverter.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIQUATATTRIBCONVERTER_H -#define IECOREHOUDINI_TOHOUDINIQUATATTRIBCONVERTER_H - -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/VectorTypedParameter.h" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( ToHoudiniQuatVectorAttribConverter ); - -/// A ToHoudiniQuatVectorAttribConverter can convert from IECore::QuatfVectorData -/// to a Houdini GA_Attribute on the provided GU_Detail. -class IECOREHOUDINI_API ToHoudiniQuatVectorAttribConverter : public ToHoudiniAttribConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniQuatVectorAttribConverter, ToHoudiniQuatVectorAttribConverterTypeId, ToHoudiniAttribConverter ); - - ToHoudiniQuatVectorAttribConverter( const IECore::Data *data ); - - virtual ~ToHoudiniQuatVectorAttribConverter(); - - protected : - - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const; - - private : - - static ToHoudiniAttribConverter::Description m_description; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDINIQUATATTRIBCONVERTER_H diff --git a/include/IECoreHoudini/ToHoudiniStringAttribConverter.h b/include/IECoreHoudini/ToHoudiniStringAttribConverter.h deleted file mode 100644 index f9c12ab6d3..0000000000 --- a/include/IECoreHoudini/ToHoudiniStringAttribConverter.h +++ /dev/null @@ -1,109 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINISTRINGATTRIBCONVERTER_H -#define IECOREHOUDINI_TOHOUDINISTRINGATTRIBCONVERTER_H - -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/TypeIds.h" - -#include "IECore/VectorTypedParameter.h" - -namespace IECoreHoudini -{ - -IE_CORE_FORWARDDECLARE( ToHoudiniStringVectorAttribConverter ); - -/// A ToHoudiniStringVectorAttribConverter can convert from IECore::StringVectorData -/// to a Houdini GA_Attribute on the provided GU_Detail. -class IECOREHOUDINI_API ToHoudiniStringVectorAttribConverter : public ToHoudiniAttribConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniStringVectorAttribConverter, ToHoudiniStringVectorAttribConverterTypeId, ToHoudiniAttribConverter ); - - ToHoudiniStringVectorAttribConverter( const IECore::Data *data ); - - virtual ~ToHoudiniStringVectorAttribConverter(); - - IECore::IntVectorParameterPtr indicesParameter(); - IECore::ConstIntVectorParameterPtr indicesParameter() const; - - /// Utility method to set a single string for all elements in the given range - static GA_RWAttributeRef convertString( std::string name, std::string value, GU_Detail *geo, GA_Range range ); - - protected : - - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const; - - private : - - static ToHoudiniAttribConverter::Description m_description; - - /// \todo: replace this parameter with IECore::IndexedData once it exists... - IECore::IntVectorParameterPtr m_indicesParameter; - -}; - -IE_CORE_FORWARDDECLARE( ToHoudiniStringDetailAttribConverter ); - -/// A ToHoudiniStringDetailAttribConverter can convert from IECore::StringData -/// to a Houdini GA_Attribute on the provided GU_Detail. -class IECOREHOUDINI_API ToHoudiniStringDetailAttribConverter : public ToHoudiniAttribConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToHoudiniStringDetailAttribConverter, ToHoudiniStringDetailAttribConverterTypeId, ToHoudiniAttribConverter ); - - ToHoudiniStringDetailAttribConverter( const IECore::Data *data ); - - virtual ~ToHoudiniStringDetailAttribConverter(); - - protected : - - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const; - virtual GA_RWAttributeRef doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const; - - private : - - static ToHoudiniAttribConverter::Description m_description; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TOHOUDINISTRINGATTRIBCONVERTER_H diff --git a/include/IECoreHoudini/TypeIds.h b/include/IECoreHoudini/TypeIds.h deleted file mode 100644 index dd17cc49aa..0000000000 --- a/include/IECoreHoudini/TypeIds.h +++ /dev/null @@ -1,96 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TYPEIDS_H -#define IECOREHOUDINI_TYPEIDS_H - -namespace IECoreHoudini -{ - - /// Define Cortex Type Ids for our converter class. - enum TypeId - { - FromHoudiniConverterTypeId = 111000, - FromHoudiniGeometryConverterTypeId = 111001, - FromHoudiniPointsConverterTypeId = 111002, - FromHoudiniPolygonsConverterTypeId = 111003, - ToHoudiniConverterTypeId = 111004, - ToHoudiniGeometryConverterTypeId = 111005, - ToHoudiniPointsConverterTypeId = 111006, - ToHoudiniPolygonsConverterTypeId = 111007, - FromHoudiniCurvesConverterTypeId = 111008, - ToHoudiniCurvesConverterTypeId = 111009, - ToHoudiniAttribConverterTypeId = 111010, - ToHoudiniFloatDetailAttribConverterTypeId = 111011, - ToHoudiniV2fDetailAttribConverterTypeId = 111012, - ToHoudiniV3fDetailAttribConverterTypeId = 111013, - ToHoudiniColor3fDetailAttribConverterTypeId = 111014, - ToHoudiniIntDetailAttribConverterTypeId = 111015, - ToHoudiniV2iDetailAttribConverterTypeId = 111016, - ToHoudiniV3iDetailAttribConverterTypeId = 111017, - ToHoudiniFloatVectorAttribConverterTypeId = 111018, - ToHoudiniV2fVectorAttribConverterTypeId = 111019, - ToHoudiniV3fVectorAttribConverterTypeId = 111020, - ToHoudiniColor3fVectorAttribConverterTypeId = 111021, - ToHoudiniIntVectorAttribConverterTypeId = 111022, - ToHoudiniV2iVectorAttribConverterTypeId = 111023, - ToHoudiniV3iVectorAttribConverterTypeId = 111024, - FromHoudiniGroupConverterTypeId = 111025, - ToHoudiniGroupConverterTypeId = 111026, - ToHoudiniStringDetailAttribConverterTypeId = 111027, - ToHoudiniStringVectorAttribConverterTypeId = 111028, - RATDeepImageReaderTypeId = 111029, // obsolete - available for reuse - RATDeepImageWriterTypeId = 111030, // obsolete - available for reuse - LiveSceneTypeId = 111031, - FromHoudiniCortexObjectConverterTypeId = 111032, - ToHoudiniCortexObjectConverterTypeId = 111033, - FromHoudiniCompoundObjectConverterTypeId = 111034, - ToHoudiniCompoundObjectConverterTypeId = 111035, - ToHoudiniQuatVectorAttribConverterTypeId = 111036, - ToHoudiniM33fDetailAttribConverterTypeId = 111037, - ToHoudiniM44fDetailAttribConverterTypeId = 111038, - ToHoudiniM33fVectorAttribConverterTypeId = 111039, - ToHoudiniM44fVectorAttribConverterTypeId = 111040, - ToHoudiniM44dDetailAttribConverterTypeId = 111041, - ToHoudiniM44dVectorAttribConverterTypeId = 111042, - // remember to update TypeIdBinding.cpp - LastTypeId = 111999, - }; - -} // namespace IECoreHoudini - -#endif /* IECOREHOUDINI_TYPEIDS_H */ diff --git a/include/IECoreHoudini/TypeTraits.h b/include/IECoreHoudini/TypeTraits.h deleted file mode 100644 index 3efb320338..0000000000 --- a/include/IECoreHoudini/TypeTraits.h +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TYPETRAITS_H -#define IECOREHOUDINI_TYPETRAITS_H - -#include "IECore/SimpleTypedData.h" -#include "IECore/TypeTraits.h" -#include "IECore/VectorTypedData.h" - -namespace IECoreHoudini -{ - -namespace TypeTraits -{ - -/// IsDetailAttribFloatTypedData -template struct IsDetailAttribFloatTypedData : public boost::false_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::FloatData > : public boost::true_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::V2fData > : public boost::true_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::V3fData > : public boost::true_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::Color3fData > : public boost::true_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::M33fData > : public boost::true_type {}; -template<> struct IsDetailAttribFloatTypedData< IECore::M44fData > : public boost::true_type {}; - -/// IsDetailAttribIntTypedData -template struct IsDetailAttribIntTypedData : public boost::false_type {}; -template<> struct IsDetailAttribIntTypedData< IECore::IntData > : public boost::true_type {}; -template<> struct IsDetailAttribIntTypedData< IECore::V2iData > : public boost::true_type {}; -template<> struct IsDetailAttribIntTypedData< IECore::V3iData > : public boost::true_type {}; - -/// IsVectorAttribFloatTypedData -template struct IsVectorAttribFloatTypedData : public boost::false_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::FloatVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::V2fVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::V3fVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::Color3fVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::M33fVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::M44fVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribFloatTypedData< IECore::M44dVectorData > : public boost::true_type {}; - -/// IsVectorAttribIntTypedData -template struct IsVectorAttribIntTypedData : public boost::false_type {}; -template<> struct IsVectorAttribIntTypedData< IECore::IntVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribIntTypedData< IECore::V2iVectorData > : public boost::true_type {}; -template<> struct IsVectorAttribIntTypedData< IECore::V3iVectorData > : public boost::true_type {}; - -/// IsDetailAttribTypedData -template struct IsDetailAttribTypedData : boost::mpl::or_< IsDetailAttribFloatTypedData, IsDetailAttribIntTypedData > {}; - -/// IsVectorAttribTypedData -template struct IsVectorAttribTypedData : boost::mpl::or_< IsVectorAttribFloatTypedData, IsVectorAttribIntTypedData > {}; - -/// IsAttribColorTypedData -template struct IsAttribColorTypedData : public boost::false_type {}; -template<> struct IsAttribColorTypedData< IECore::Color3fData > : public boost::true_type {}; -template<> struct IsAttribColorTypedData< IECore::Color3fVectorData > : public boost::true_type {}; - -} // namespace TypeTraits - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_TYPETRAITS_H diff --git a/include/IECoreHoudini/UT_ObjectPoolCache.h b/include/IECoreHoudini/UT_ObjectPoolCache.h deleted file mode 100644 index d2ff8c76f6..0000000000 --- a/include/IECoreHoudini/UT_ObjectPoolCache.h +++ /dev/null @@ -1,78 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_UTOBJECTPOOLCACHE_H -#define IECOREHOUDINI_UTOBJECTPOOLCACHE_H - -#include "IECoreHoudini/Export.h" - -#include "IECore/ObjectPool.h" - -#include "UT/UT_Cache.h" - -namespace IECoreHoudini -{ - -/// Registers an IECore::ObjectPool with Houdini's Cache Manager. -/// This allows users to manipulate Cortex memory consumption using -/// the standard Houdini UI. The default UT_ObjectPoolCache is created -/// automatically using the default ObjectPool; -class IECOREHOUDINI_API UT_ObjectPoolCache : public UT_Cache -{ - - public : - - UT_ObjectPoolCache( const std::string &name, IECore::ObjectPoolPtr objectPool ); - virtual ~UT_ObjectPoolCache(); - - virtual const char *utGetCacheName() const; - virtual int64 utGetCurrentSize() const; - virtual int64 utReduceCacheSizeBy( int64 amount ); - virtual bool utHasMaxSize() const; - virtual int64 utGetMaxSize() const; - virtual void utSetMaxSize( int64 amount ); - virtual bool utHasMinSize() const; - - static UT_ObjectPoolCache *defaultObjectPoolCache(); - - private : - - const std::string m_name; - IECore::ObjectPoolPtr m_pool; - -}; - -} // namespace IECoreHoudini - -#endif // IECOREHOUDINI_UTOBJECTPOOLCACHE_H diff --git a/include/IECoreHoudini/bindings/FnParameterisedHolderBinding.h b/include/IECoreHoudini/bindings/FnParameterisedHolderBinding.h deleted file mode 100644 index 545fb93005..0000000000 --- a/include/IECoreHoudini/bindings/FnParameterisedHolderBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FNPARAMETERISEDHOLDERBINDING_H -#define IECOREHOUDINI_FNPARAMETERISEDHOLDERBINDING_H - -namespace IECoreHoudini -{ - void bindFnParameterisedHolder(); -} - -#endif // IECOREHOUDINI_FNPARAMETERISEDHOLDERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.h deleted file mode 100644 index 3197a6cd30..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H -#define IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniCompoundObjectConverter(); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniConverterBinding.h deleted file mode 100644 index bedfcbfc35..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINICONVERTERBINDING_H -#define IE_COREHOUDINI_FROMHOUDINICONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniConverter(); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINICONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.h deleted file mode 100644 index 25bdfdf0d3..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTERBINDING_H -#define IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniCortexObjectConverter(); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICORTEXOBJECTCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.h deleted file mode 100644 index 3399397100..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINICURVESCONVERTERBINDING_H -#define IECOREHOUDINI_FROMHOUDINICURVESCONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniCurvesConverter(); - -} - -#endif // IECOREHOUDINI_FROMHOUDINICURVESCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h deleted file mode 100644 index 17f33cf8f1..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTERBINDING_H -#define IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindFromHoudiniGeometryConverter(); -} - -#endif // IECOREHOUDINI_FROMHOUDINIGEOMETRYCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.h deleted file mode 100644 index d194b74eb9..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTERBINDING_H -#define IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniPointsConverter(); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINIPOINTSCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.h b/include/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.h deleted file mode 100644 index 587a0b6dbb..0000000000 --- a/include/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTERBINDING_H -#define IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindFromHoudiniPolygonsConverter(); - -} - -#endif // IE_COREHOUDINI_FROMHOUDINIPOLYGONSCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/LiveSceneBinding.h b/include/IECoreHoudini/bindings/LiveSceneBinding.h deleted file mode 100644 index 09dd0c121b..0000000000 --- a/include/IECoreHoudini/bindings/LiveSceneBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_LIVESCENEBINDING_H -#define IECOREHOUDINI_LIVESCENEBINDING_H - -namespace IECoreHoudini -{ - -void bindLiveScene(); - -} - -#endif // IECOREHOUDINI_LIVESCENEBINDING_H diff --git a/include/IECoreHoudini/bindings/SceneCacheNodeBinding.h b/include/IECoreHoudini/bindings/SceneCacheNodeBinding.h deleted file mode 100644 index a9ec9e914e..0000000000 --- a/include/IECoreHoudini/bindings/SceneCacheNodeBinding.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_MODELCACHENODEBINDING_H -#define IECOREHOUDINI_SCENECACHENODEBINDING_H - -namespace IECoreHoudini -{ - -void bindSceneCacheNode(); - -} - -#endif // IECOREHOUDINI_SCENECACHENODEBINDING_H - diff --git a/include/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.h deleted file mode 100644 index 6d4d1fb413..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniCompoundObjectConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINICOMPOUNDOBJECTCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniConverterBinding.h deleted file mode 100644 index 1206cce1f6..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINICONVERTERBINDING_H - -namespace IECoreHoudini -{ - -void bindToHoudiniConverter(); - -} - -#endif // IECOREHOUDINI_TOHOUDINICONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.h deleted file mode 100644 index aaa7bc8966..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniCortexObjectConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINICORTEXOBJECTCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.h deleted file mode 100644 index 98595a6021..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINICURVESCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINICURVESCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniCurvesConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINICURVESCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniGeometryConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniGeometryConverterBinding.h deleted file mode 100644 index d6b4c2d954..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniGeometryConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniGeometryConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINIGEOMETRYCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniGroupConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniGroupConverterBinding.h deleted file mode 100644 index 6757a79d92..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniGroupConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIGROUPCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINIGROUPCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniGroupConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINIGROUPCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.h deleted file mode 100644 index 7db5377686..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIPOINTSCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINIPOINTSCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniPointsConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINIPOINTSCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.h b/include/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.h deleted file mode 100644 index 6211378891..0000000000 --- a/include/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTERBINDING_H -#define IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTERBINDING_H - -namespace IECoreHoudini -{ - void bindToHoudiniPolygonsConverter(); -} - -#endif // IECOREHOUDINI_TOHOUDINIPOLYGONSCONVERTERBINDING_H diff --git a/include/IECoreHoudini/bindings/TypeIdBinding.h b/include/IECoreHoudini/bindings/TypeIdBinding.h deleted file mode 100644 index 830a1a8191..0000000000 --- a/include/IECoreHoudini/bindings/TypeIdBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREHOUDINI_TYPEIDBINDING_H -#define IECOREHOUDINI_TYPEIDBINDING_H - -namespace IECoreHoudini -{ -void bindTypeId(); -} - -#endif // IECOREHOUDINI_TYPEIDBINDING_H diff --git a/include/IECoreMaya/BoolParameterHandler.h b/include/IECoreMaya/BoolParameterHandler.h deleted file mode 100644 index 393db0069d..0000000000 --- a/include/IECoreMaya/BoolParameterHandler.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_BOOLPARAMETERHANDLER_H -#define IE_COREMAYA_BOOLPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with booleans -class IECOREMAYA_API BoolParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_BOOLPARAMETERHANDLER_H diff --git a/include/IECoreMaya/BoxParameterHandler.h b/include/IECoreMaya/BoxParameterHandler.h deleted file mode 100644 index 529fd01049..0000000000 --- a/include/IECoreMaya/BoxParameterHandler.h +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_BOXPARAMETERHANDLER_H -#define IE_COREMAYA_BOXPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with a variety of Imath::Box types -template -class IECOREMAYA_API BoxParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_BOXPARAMETERHANDLER_H diff --git a/include/IECoreMaya/BoxTraits.h b/include/IECoreMaya/BoxTraits.h deleted file mode 100644 index a53fa55f26..0000000000 --- a/include/IECoreMaya/BoxTraits.h +++ /dev/null @@ -1,128 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_BOXTRAITS_H -#define IE_COREMAYA_BOXTRAITS_H - -#include "IECore/BoxTraits.h" -#include "IECoreMaya/VectorTraits.h" - -#include "maya/MBoundingBox.h" - -namespace IECore -{ - -template<> -struct BoxTraits -{ - typedef MPoint BaseType; - - /// Create a box from the minimum and maximum corner points - static MBoundingBox create( const MPoint &min, const MPoint &max ) - { - return MBoundingBox( min, max ); - } - - /// Return the box's minimum corner point - static MPoint min( const MBoundingBox& box ) - { - return box.min(); - } - - /// Return the box's maximum corner point - static MPoint max( const MBoundingBox& box ) - { - return box.max(); - } - - /// Return the dimensions of the box - static MPoint size( const MBoundingBox& box ) - { - return MPoint( box.width(), box.height(), box.depth() ); - } - - /// Return the center point of the box - static MPoint center( const MBoundingBox& box ) - { - return box.center(); - } - - /// Return true if the box is considered to be empty - static bool isEmpty( const MBoundingBox& box ) - { - return box.width() * box.height() * box.depth() <= std::numeric_limits::epsilon() ; - } - - /// Modify the box such that it is considered to be empty - static void makeEmpty( MBoundingBox& box ) - { - box.clear(); - - assert( isEmpty(box) ); - } - - /// Enlarge the box to include the given point - static void extendBy( MBoundingBox& box, const MPoint& p ) - { - box.expand( p ); - - assert( intersects( box, p ) ); - } - - /// Enlarge the box to include the given box - static void extendBy( MBoundingBox& box, const MBoundingBox& box2 ) - { - box.expand( box2 ); - - assert( intersects( box, box2 ) ); - } - - /// Return true if the box contains the given box - static bool intersects( const MBoundingBox& box, const MPoint& p ) - { - return box.contains( p ); - } - - /// Return true if the two boxes intersect - static bool intersects( const MBoundingBox& box, const MBoundingBox& box2 ) - { - assert( box.intersects( box2 ) == box2.intersects( box ) ); - - return box.intersects( box2 ); - } -}; - -} // namespace IECore - -#endif // IE_COREMAYA_BOXTRAITS_H diff --git a/include/IECoreMaya/CacheSet.h b/include/IECoreMaya/CacheSet.h deleted file mode 100644 index 184ef79140..0000000000 --- a/include/IECoreMaya/CacheSet.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_CACHESET_H -#define IE_COREMAYA_CACHESET_H - -#include "maya/MPxObjectSet.h" -#include "maya/MStringArray.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ -/// A Maya set base node which encapsulates basic funtionality required of -/// cache sets. -/// \todo This is an IE specific base class - remove from Cortex -class IECOREMAYA_API CacheSet : public MPxObjectSet -{ - public: - CacheSet(); - virtual ~CacheSet(); - - static void *creator(); - - static MStatus initialize(); - - virtual bool isAbstractClass() const; - - static MTypeId id; - - static MObject aActive; - static MObject aFrameRate; - static MObject aOversamples; - static MObject aOutFrameMel; - - protected: - - /// A simple helper function to translate an MStringArray into - /// the MEL representation of the same data. - MString melFromStringArray(const MStringArray &a) const; - -}; -} - -#endif // IE_COREMAYA_CACHESET_H diff --git a/include/IECoreMaya/CallbackId.h b/include/IECoreMaya/CallbackId.h deleted file mode 100644 index c6bec94696..0000000000 --- a/include/IECoreMaya/CallbackId.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_CALLBACKID_H -#define IECOREMAYA_CALLBACKID_H - -#include "maya/MMessage.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// A class to help with deregistering maya MMessage callbacks -/// at the appropriate time. -class IECOREMAYA_API CallbackId -{ - - public : - - CallbackId(); - /// Stores the specified CallbackId id, calling MMessage::removeCallback() - /// for it on destruction. - CallbackId( MCallbackId id ); - /// Calls MMessage::removeCallback() for the currently held callback. - ~CallbackId(); - - /// Calls MMessage::removeCallback() for the currently held callback, and - /// stores the new callback for later removal. - const CallbackId &operator = ( MCallbackId id ); - - private : - - /// No sensible semantics for this. - CallbackId( const CallbackId &other ); - - MCallbackId m_id; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_CALLBACKID_H diff --git a/include/IECoreMaya/ClassParameterHandler.h b/include/IECoreMaya/ClassParameterHandler.h deleted file mode 100644 index 9e61311e7d..0000000000 --- a/include/IECoreMaya/ClassParameterHandler.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_CLASSPARAMETERHANDLER_H -#define IECOREMAYA_CLASSPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with ClassParameters. Note that no attempt is made to represent the child -/// parameters - separate calls to other parameter handlers should be used to do that. -class IECOREMAYA_API ClassParameterHandler : public ParameterHandler -{ - - public : - - /// Convenience function for setting the class held by parameter. This makes no changes to the maya representation - /// of the parameter whatsoever. - static MStatus setClass( IECore::ParameterPtr parameter, const MString &className, int classVersion, const MString &searchPathEnvVar ); - /// Convenience function for getting the class held by parameter. This has nothing to do with the maya - /// representation of the class whatsoever - see below for that. - static MStatus getClass( IECore::ConstParameterPtr parameter, MString &className, int &classVersion, MString &searchPathEnvVar ); - - /// Can be used to query the details of the class currently being held by the parameter represented - /// by the specified plug. Note that this returns the class currently being represented in maya, - /// which may not be the same as the class on the parameter if the two have not been synchronised by a call - /// to ParameterisedHolderInterface::updateParameterised. - /// This function typically shouldn't be called directly, as a combination of direct access - /// to parameters and IECoreMaya.FnParameterisedHolder should be enough to achieve most things. - static void currentClass( const MPlug &plug, MString &className, int &classVersion, MString &searchPathEnvVar ); - - protected: - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - virtual MStatus doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private : - - static MStatus storeClass( IECore::ConstParameterPtr parameter, MPlug &plug ); - - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_CLASSPARAMETERHANDLER_H diff --git a/include/IECoreMaya/ClassVectorParameterHandler.h b/include/IECoreMaya/ClassVectorParameterHandler.h deleted file mode 100644 index fc9fe8b630..0000000000 --- a/include/IECoreMaya/ClassVectorParameterHandler.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_CLASSVECTORPARAMETERHANDLER_H -#define IECOREMAYA_CLASSVECTORPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with ClassVectorParameters. Note that no attempt is made to represent the child -/// parameters - separate calls to other parameter handlers should be used to do that. -class IECOREMAYA_API ClassVectorParameterHandler : public ParameterHandler -{ - - public : - - - /// Convenience function for setting the class held by parameter. This makes no changes to the maya representation - /// of the parameter whatsoever. - static MStatus setClasses( IECore::ParameterPtr parameter, const MStringArray ¶meterNames, const MStringArray &classNames, const MIntArray &classVersions ); - /// Convenience function for getting the classes held by parameter. This has nothing to do with the maya - /// representation of the classes whatsoever - see below for that. - static MStatus getClasses( IECore::ConstParameterPtr parameter, MStringArray ¶meterNames, MStringArray &classNames, MIntArray &classVersions ); - /// Can be used to query the details of the classes currently being held by the parameter represented - /// by the specified plug. Note that this returns the classes currently being represented in maya, - /// which may not be the same as the classes on the parameter if the two have not been synchronised. - /// Again, this function typically shouldn't be called directly, as a combination of direct access - /// to parameters and IECoreMaya.FnParameterisedHolder should be enough to achieve most things. - static void currentClasses( const MPlug &plug, MStringArray ¶meterNames, MStringArray &classNames, MIntArray &classVersions ); - - protected: - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - virtual MStatus doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private : - - static MStatus storeClasses( IECore::ConstParameterPtr parameter, MPlug &plug ); - - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_CLASSVECTORPARAMETERHANDLER_H diff --git a/include/IECoreMaya/ColorSplineParameterHandler.h b/include/IECoreMaya/ColorSplineParameterHandler.h deleted file mode 100644 index 46356d50ea..0000000000 --- a/include/IECoreMaya/ColorSplineParameterHandler.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_COLORSPLINEPARAMETERHANDLER_H -#define IE_COREMAYA_COLORSPLINEPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with color splines, templated on the Spline type itself -template< typename S > -class IECOREMAYA_API ColorSplineParameterHandler : public ParameterHandler -{ - protected : - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private : - - static Description< ColorSplineParameterHandler > g_registrar; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_COLORSPLINEPARAMETERHANDLER_H diff --git a/include/IECoreMaya/CompoundNumericParameterHandler.h b/include/IECoreMaya/CompoundNumericParameterHandler.h deleted file mode 100644 index 2d80cb9508..0000000000 --- a/include/IECoreMaya/CompoundNumericParameterHandler.h +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_COMPOUNDNUMERICPARAMETERHANDLER_H -#define IE_COREMAYA_COMPOUNDNUMERICPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with compound numerics, e.g. points, vectors, colors -template -class IECOREMAYA_API CompoundNumericParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_COMPOUNDNUMERICPARAMETERHANDLER_H diff --git a/include/IECoreMaya/CompoundParameterHandler.h b/include/IECoreMaya/CompoundParameterHandler.h deleted file mode 100644 index 09edf896f1..0000000000 --- a/include/IECoreMaya/CompoundParameterHandler.h +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_COMPOUNDPARAMETERHANDLER_H -#define IECOREMAYA_COMPOUNDPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with CompoundParameters, representing them as simple -/// message attributes. Note that no attempt is made to represent the children of the compound - separate -/// calls to other parameter handlers should be used to do that. -class IECOREMAYA_API CompoundParameterHandler : public ParameterHandler -{ - - protected: - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_COMPOUNDPARAMETERHANDLER_H diff --git a/include/IECoreMaya/Convert.h b/include/IECoreMaya/Convert.h deleted file mode 100644 index 5695de1b79..0000000000 --- a/include/IECoreMaya/Convert.h +++ /dev/null @@ -1,250 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_CONVERT_H -#define IE_COREMAYA_CONVERT_H - -#include "IECoreMaya/Export.h" - -#include "IECore/Convert.h" -#include "IECore/Data.h" -#include "IECore/TransformationMatrix.h" - -#include "Imath/ImathVec.h" -#include "Imath/ImathColor.h" -#include "Imath/ImathBox.h" -#include "Imath/ImathQuat.h" -#include "Imath/ImathMatrix.h" -#include "Imath/ImathEuler.h" - -#include "maya/MString.h" -#include "maya/MBoundingBox.h" -#include "maya/MPoint.h" -#include "maya/MVector.h" -#include "maya/MMatrix.h" -#include "maya/MFloatPoint.h" -#include "maya/MFloatVector.h" -#include "maya/MColor.h" -#include "maya/MQuaternion.h" -#include "maya/MTransformationMatrix.h" -#include "maya/MCommandResult.h" -#include "maya/MEulerRotation.h" -#include "maya/MDistance.h" -#include "maya/MAngle.h" -#include "maya/MTime.h" - -#include - -/// Specialising in the IECore namespace. This is OK because the Maya types -/// will never be referenced in IECore -namespace IECore -{ - -template<> -IECOREMAYA_API std::string convert( const MString &from ); - -template<> -IECOREMAYA_API MString convert( const std::string &from ); - -template<> -IECOREMAYA_API Imath::V3f convert( const MVector &from ); - -template<> -IECOREMAYA_API Imath::V3f convert( const MFloatVector &from ); - -template<> -IECOREMAYA_API Imath::V3d convert( const MVector &from ); - -template<> -IECOREMAYA_API Imath::V3d convert( const MFloatVector &from ); - -template<> -IECOREMAYA_API Imath::V3f convert( const MPoint &from ); - -template<> -IECOREMAYA_API Imath::V3f convert( const MFloatPoint &from ); - -template<> -IECOREMAYA_API Imath::V3d convert( const MPoint &from ); - -template<> -IECOREMAYA_API Imath::V3d convert( const MFloatPoint &from ); - -template<> -IECOREMAYA_API MVector convert( const Imath::V3f &from ); - -template<> -IECOREMAYA_API MVector convert( const Imath::V3d &from ); - -template<> -IECOREMAYA_API MVector convert( const Imath::Color3f &from ); - -template<> -IECOREMAYA_API MFloatVector convert( const Imath::V3f &from ); - -template<> -IECOREMAYA_API MFloatVector convert( const Imath::V3d &from ); - -template<> -IECOREMAYA_API MFloatVector convert( const Imath::Color3f &from ); - -template<> -IECOREMAYA_API MPoint convert( const Imath::V3f &from ); - -template<> -IECOREMAYA_API MPoint convert( const Imath::V3d &from ); - -template<> -IECOREMAYA_API MFloatPoint convert( const Imath::V3f &from ); - -template<> -IECOREMAYA_API MFloatPoint convert( const Imath::V3d &from ); - -template<> -IECOREMAYA_API Imath::Color3f convert( const MVector &from ); - -template<> -IECOREMAYA_API Imath::Color3f convert( const MColor &from ); - -template<> -IECOREMAYA_API Imath::Color4f convert( const MColor &from ); - -template<> -IECOREMAYA_API MColor convert( const Imath::Color3f &from ); - -template<> -IECOREMAYA_API MColor convert( const Imath::Color4f &from ); - -template<> -IECOREMAYA_API MBoundingBox convert( const Imath::Box3f &from ); - -template<> -IECOREMAYA_API Imath::Box3f convert( const MBoundingBox &from ); - -template<> -IECOREMAYA_API MBoundingBox convert( const Imath::Box3d &from ); - -template<> -IECOREMAYA_API Imath::Box3d convert( const MBoundingBox &from ); - -template<> -IECOREMAYA_API Imath::Quatf convert( const MQuaternion &from ); - -template<> -IECOREMAYA_API MQuaternion convert( const Imath::Quatf &from ); - -template<> -IECOREMAYA_API Imath::Quatd convert( const MQuaternion &from ); - -template<> -IECOREMAYA_API MQuaternion convert( const Imath::Quatd &from ); - -template<> -IECOREMAYA_API Imath::M44f convert( const MMatrix &from ); - -template<> -IECOREMAYA_API Imath::M44d convert( const MMatrix &from ); - -template<> -IECOREMAYA_API MMatrix convert( const Imath::M44f &from ); - -template<> -IECOREMAYA_API MMatrix convert( const Imath::M44d &from ); - -template<> -IECOREMAYA_API Imath::Eulerf convert( const MEulerRotation &from ); - -template<> -IECOREMAYA_API MEulerRotation convert( const Imath::Eulerf &from ); - -template<> -IECOREMAYA_API Imath::Eulerd convert( const MEulerRotation &from ); - -template<> -IECOREMAYA_API MEulerRotation convert( const Imath::Eulerd &from ); - -template<> -IECOREMAYA_API IECore::TransformationMatrixf convert( const MTransformationMatrix &from ); - -template<> -IECOREMAYA_API MTransformationMatrix convert( const IECore::TransformationMatrixf &from ); - -template<> -IECOREMAYA_API IECore::TransformationMatrixd convert( const MTransformationMatrix &from ); - -template<> -IECOREMAYA_API MTransformationMatrix convert( const IECore::TransformationMatrixd &from ); - -template<> -IECOREMAYA_API IECore::DataPtr convert( const MCommandResult &from ); - -template<> -IECOREMAYA_API MDistance convert( const double &from ); - -template<> -IECOREMAYA_API double convert( const MDistance &from ); - -template<> -IECOREMAYA_API MAngle convert( const double &from ); - -template<> -IECOREMAYA_API double convert( const MAngle &from ); - -template<> -IECOREMAYA_API MTime convert( const double &from ); - -template<> -IECOREMAYA_API double convert( const MTime &from ); - -template<> -IECOREMAYA_API MDistance convert( const float &from ); - -template<> -IECOREMAYA_API float convert( const MDistance &from ); - -template<> -IECOREMAYA_API MAngle convert( const float &from ); - -template<> -IECOREMAYA_API float convert( const MAngle &from ); - -template<> -IECOREMAYA_API MTime convert( const float &from ); - -template<> -IECOREMAYA_API float convert( const MTime &from ); - -} // namespace IECore - -#endif // IE_COREMAYA_CONVERT_H diff --git a/include/IECoreMaya/ConverterHolder.h b/include/IECoreMaya/ConverterHolder.h deleted file mode 100644 index 966c5307f2..0000000000 --- a/include/IECoreMaya/ConverterHolder.h +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_CONVERTERHOLDER_H -#define IECOREMAYA_CONVERTERHOLDER_H - -#include "IECoreMaya/ParameterisedHolder.h" - -namespace IECoreMaya -{ - -/// The ConverterHolder class connects to a maya node and use the Converter classes -/// to perform conversions to IECore datatypes. -/// \ingroup conversionGroup -class IECOREMAYA_API ConverterHolder : public ParameterisedHolderNode -{ - - public : - - ConverterHolder(); - virtual ~ConverterHolder(); - - static void *creator(); - static MStatus initialize(); - static MTypeId id; - - virtual MStatus connectionMade( const MPlug &plug, const MPlug &otherPlug, bool asSrc ); - virtual MStatus connectionBroken( const MPlug &plug, const MPlug &otherPlug, bool asSrc ); - - static MObject aIn; - static MObject aFileName; - - private : - - - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_CONVERTERHOLDER_H diff --git a/include/IECoreMaya/CurveCombiner.h b/include/IECoreMaya/CurveCombiner.h deleted file mode 100644 index 1b991c3512..0000000000 --- a/include/IECoreMaya/CurveCombiner.h +++ /dev/null @@ -1,69 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_CURVECOMBINER_H -#define IECOREMAYA_CURVECOMBINER_H - -#include "maya/MPxNode.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// The CurveCombiner node takes multiple maya nurbsCurve inputs and -/// combines them into a single IECore::CurvesPrimitive output. -class IECOREMAYA_API CurveCombiner : public MPxNode -{ - - public : - - CurveCombiner(); - virtual ~CurveCombiner(); - - static void *creator(); - static MStatus initialize(); - static const MTypeId id; - static const MString typeName; - - virtual MStatus compute( const MPlug &plug, MDataBlock &dataBlock ); - - static MObject aInputCurves; - static MObject aOutputCurves; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_CURVECOMBINER_H diff --git a/include/IECoreMaya/DateTimeParameterHandler.h b/include/IECoreMaya/DateTimeParameterHandler.h deleted file mode 100644 index 81bd58d9cb..0000000000 --- a/include/IECoreMaya/DateTimeParameterHandler.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_DATETIMEPARAMETERHANDLER_H -#define IE_COREMAYA_DATETIMEPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler for DateTimeParameters. -class IECOREMAYA_API DateTimeParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_DATETIMEPARAMETERHANDLER_H diff --git a/include/IECoreMaya/DisplayStyle.h b/include/IECoreMaya/DisplayStyle.h deleted file mode 100644 index 01ea6eeb84..0000000000 --- a/include/IECoreMaya/DisplayStyle.h +++ /dev/null @@ -1,78 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_DISPLAYSTYLE_H -#define IECOREMAYA_DISPLAYSTYLE_H - -#include "boost/noncopyable.hpp" - -#include "maya/M3dView.h" - -#include "IECoreGL/State.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// Maya specifies how things should be drawn using the M3dView::DisplayStyle -/// enum, whereas IECoreGL uses State objects to specify the equivalent things -/// (and more). When using IECoreGL to draw within maya nodes it then becomes -/// necessary to translate from the maya definition into an IECoreGL::State -/// object. This class performs that translation. Typically one would be held as -/// member data in a node and baseState() would be called upon in the draw() method. -class IECOREMAYA_API DisplayStyle : public boost::noncopyable -{ - - public : - - DisplayStyle(); - ~DisplayStyle(); - - /// Returns a base state suitable for representing objects in the the style specified - /// by maya. If setCurrentColor is true then the current gl color is also translated - /// appropriately into the State (for bounding box, wireframe and points modes only). - IECoreGL::State *baseState( M3dView::DisplayStyle style, M3dView::LightingMode lightingMode=M3dView::kLightDefault, bool transferCurrentColor=true ); - - private : - - struct Data; - - Data *m_data; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_DISPLAYSTYLE_H diff --git a/include/IECoreMaya/DrawableHolder.h b/include/IECoreMaya/DrawableHolder.h deleted file mode 100644 index 1a94e13f77..0000000000 --- a/include/IECoreMaya/DrawableHolder.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_DRAWABLEHOLDER_H -#define IECOREMAYA_DRAWABLEHOLDER_H - -#include "maya/MPxSurfaceShape.h" - -#include "IECoreGL/IECoreGL.h" - -#include "IECoreMaya/ParameterisedHolder.h" -#include "IECoreMaya/MayaTypeIds.h" - -namespace IECoreGL -{ -IE_CORE_FORWARDDECLARE( Scene ); -} - -namespace IECoreMaya -{ - -class IECOREMAYA_API DrawableHolder : public ParameterisedHolderSurfaceShape -{ - public : - - DrawableHolder(); - virtual ~DrawableHolder(); - - static void *creator(); - static MStatus initialize(); - static const MTypeId id; - static const MString typeName; - - virtual bool isBounded() const; - virtual MBoundingBox boundingBox() const; - virtual MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ); - - /// Returns an up to date scene created by calling draw() on the held class. - IECoreGL::ConstScenePtr scene(); - - static MObject aDraw; - - private : - - IECoreGL::ScenePtr m_scene; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_DRAWABLEHOLDER_H diff --git a/include/IECoreMaya/DrawableHolderUI.h b/include/IECoreMaya/DrawableHolderUI.h deleted file mode 100644 index 45963e4c7f..0000000000 --- a/include/IECoreMaya/DrawableHolderUI.h +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_DRAWABLEHOLDERUI_H -#define IECOREMAYA_DRAWABLEHOLDERUI_H - -#include "maya/MDrawInfo.h" -#include "maya/MDrawRequestQueue.h" -#include "maya/MSelectInfo.h" -#include "maya/MPxSurfaceShapeUI.h" - -#include "IECoreMaya/DisplayStyle.h" - -namespace IECoreGL -{ -IE_CORE_FORWARDDECLARE( State ); -IE_CORE_FORWARDDECLARE( Group ); -IE_CORE_FORWARDDECLARE( StateComponent ); -} - -namespace IECoreMaya -{ - -class IECOREMAYA_API DrawableHolderUI : public MPxSurfaceShapeUI -{ - - public : - - DrawableHolderUI(); - virtual ~DrawableHolderUI(); - - virtual void getDrawRequests( const MDrawInfo &info, bool objectAndActiveOnly, MDrawRequestQueue &requests ); - virtual void draw( const MDrawRequest &request, M3dView &view ) const; - virtual bool select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const; - - static void *creator(); - - private : - - mutable DisplayStyle m_displayStyle; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_DRAWABLEHOLDERUI_H diff --git a/include/IECoreMaya/Export.h b/include/IECoreMaya/Export.h deleted file mode 100644 index 07e529e99a..0000000000 --- a/include/IECoreMaya/Export.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_EXPORT_H -#define IECOREMAYA_EXPORT_H - -#include "IECore/Export.h" - -#ifdef IECoreMaya_EXPORTS - #define IECOREMAYA_API IECORE_EXPORT -#else - #define IECOREMAYA_API IECORE_IMPORT -#endif - -#endif // #ifndef IECOREMAYA_EXPORT_H diff --git a/include/IECoreMaya/FloatSplineParameterHandler.h b/include/IECoreMaya/FloatSplineParameterHandler.h deleted file mode 100644 index 2e075d58aa..0000000000 --- a/include/IECoreMaya/FloatSplineParameterHandler.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FLOATSPLINEPARAMETERHANDLER_H -#define IE_COREMAYA_FLOATSPLINEPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with color splines, templated in the same manner as the Spline itself -template< typename S > -class IECOREMAYA_API FloatSplineParameterHandler : public ParameterHandler -{ - protected : - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private : - - static Description< FloatSplineParameterHandler > g_registrar; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FLOATSPLINEPARAMETERHANDLER_H diff --git a/include/IECoreMaya/FromMayaArrayDataConverter.h b/include/IECoreMaya/FromMayaArrayDataConverter.h deleted file mode 100644 index ad03c9f6a0..0000000000 --- a/include/IECoreMaya/FromMayaArrayDataConverter.h +++ /dev/null @@ -1,85 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAARRAYDATACONVERTER_H -#define IE_COREMAYA_FROMMAYAARRAYDATACONVERTER_H - -#include "maya/MIntArray.h" -#include "maya/MDoubleArray.h" -#include "maya/MStringArray.h" -#include "maya/MVectorArray.h" -#include "maya/MPointArray.h" - -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/FromMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from various maya array data types -/// into various IECore TypedVectorData types. -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaArrayDataConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaArrayDataConverter( const MObject &object ); - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaArrayDataConverter, FromMayaObjectConverter ) - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - static FromMayaObjectConverterDescription m_description; - -}; - -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterii; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterib; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterdd; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterdf; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterss; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterVV3f; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterVV3d; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterPV3f; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterPV3d; -typedef FromMayaArrayDataConverter FromMayaArrayDataConverterVC3f; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAARRAYDATACONVERTER_H diff --git a/include/IECoreMaya/FromMayaCameraConverter.h b/include/IECoreMaya/FromMayaCameraConverter.h deleted file mode 100644 index 9dd71f7d36..0000000000 --- a/include/IECoreMaya/FromMayaCameraConverter.h +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYACAMERACONVERTER_H -#define IE_COREMAYA_FROMMAYACAMERACONVERTER_H - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -#include "IECore/TypedParameter.h" -#include "IECore/NumericParameter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaCameraConverter : public FromMayaDagNodeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaCameraConverter, FromMayaCameraConverterTypeId, FromMayaDagNodeConverter ); - - FromMayaCameraConverter( const MDagPath &dagPath ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaDagNodeConverter::Description m_description; - - -}; - -IE_CORE_DECLAREPTR( FromMayaCameraConverter ) - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYACAMERACONVERTER_H diff --git a/include/IECoreMaya/FromMayaCompoundNumericPlugConverter.h b/include/IECoreMaya/FromMayaCompoundNumericPlugConverter.h deleted file mode 100644 index a841e96b97..0000000000 --- a/include/IECoreMaya/FromMayaCompoundNumericPlugConverter.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTER_H - -#include "IECore/SimpleTypedData.h" - -#include "IECoreMaya/FromMayaPlugConverter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaCompoundNumericPlugConverter : public FromMayaPlugConverter -{ - - public : - - FromMayaCompoundNumericPlugConverter( const MPlug &plug ); - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaCompoundNumericPlugConverter, FromMayaPlugConverter ) - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static Description m_description; - -}; - -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2fV2i; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2fV2f; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2fV2d; - -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2dV2i; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2dV2f; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV2dV2d; - -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3fV3i; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3fV3f; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3fV3d; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3fC3f; - -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3dV3i; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3dV3f; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3dV3d; -typedef FromMayaCompoundNumericPlugConverter FromMayaCompoundNumericPlugConverterV3dC3f; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaConverter.h b/include/IECoreMaya/FromMayaConverter.h deleted file mode 100644 index a23b150f8e..0000000000 --- a/include/IECoreMaya/FromMayaConverter.h +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYACONVERTER_H -#define IE_COREMAYA_FROMMAYACONVERTER_H - -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/Export.h" - -#include "IECore/ToCoreConverter.h" - -namespace IECoreMaya -{ - -/// The FromMayaConverter class forms an abstract base class for -/// all classes able to perform some kind of conversion -/// from a Maya datatype to an IECore datatype. -class IECOREMAYA_API FromMayaConverter : public IECore::ToCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaConverter, FromMayaConverterTypeId, IECore::ToCoreConverter ); - - protected: - - FromMayaConverter( const std::string &description ); - - virtual ~FromMayaConverter(); - -}; - -IE_CORE_DECLAREPTR( FromMayaConverter ); - -} - -#endif // IE_COREMAYA_FROMMAYACONVERTER_H diff --git a/include/IECoreMaya/FromMayaCurveConverter.h b/include/IECoreMaya/FromMayaCurveConverter.h deleted file mode 100644 index 0ef3fcfe64..0000000000 --- a/include/IECoreMaya/FromMayaCurveConverter.h +++ /dev/null @@ -1,84 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYACURVECONVERTER_H -#define IECOREMAYA_FROMMAYACURVECONVERTER_H - -#include "IECoreMaya/FromMayaShapeConverter.h" - -#include "IECore/TypedParameter.h" - -class MFnNurbsCurve; - -namespace IECoreMaya -{ - -/// Converts maya curveShape objects into IECore::CurvesPrimitive objects. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaCurveConverter : public FromMayaShapeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaCurveConverter, FromMayaCurveConverterTypeId, FromMayaShapeConverter ); - - FromMayaCurveConverter( const MObject &object ); - FromMayaCurveConverter( const MDagPath &dagPath ); - - IECore::BoolParameterPtr linearParameter(); - IECore::ConstBoolParameterPtr linearParameter() const; - - protected : - - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - void constructCommon(); - - IECoreScene::PrimitivePtr doPrimitiveConversion( MFnNurbsCurve &fnCurve ) const; - - static Description m_description; - static Description m_dataDescription; - - IECore::BoolParameterPtr m_linearParameter; - -}; - -IE_CORE_DECLAREPTR( FromMayaCurveConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYACURVECONVERTER_H diff --git a/include/IECoreMaya/FromMayaDagNodeConverter.h b/include/IECoreMaya/FromMayaDagNodeConverter.h deleted file mode 100644 index 9493252cf1..0000000000 --- a/include/IECoreMaya/FromMayaDagNodeConverter.h +++ /dev/null @@ -1,112 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYADAGNODECONVERTER_H -#define IECOREMAYA_FROMMAYADAGNODECONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "maya/MDagPath.h" -#include "maya/MTypeId.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaDagNodeConverter ); - -/// The FromMayaDagNodeConverter class forms an abstract base class for converting -/// maya dag node objects into IECore objects. -class IECOREMAYA_API FromMayaDagNodeConverter : public FromMayaObjectConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaDagNodeConverter, FromMayaDagNodeConverterTypeId, FromMayaObjectConverter ); - - //! @name Factory - ///////////////////////////////////////////////////////////////////////////////// - //@{ - /// Creates a converter which will convert the given object to an IECore::Object - /// of the type requested in resultType - the default value specifies that any result type - /// will do. Returns 0 if no suitable converter can be found. - static FromMayaDagNodeConverterPtr create( const MDagPath &dagPath, IECore::TypeId resultType=IECore::InvalidTypeId ); - //@} - - protected : - - FromMayaDagNodeConverter( const std::string &description, const MDagPath &dagPath ); - - /// No need to override this in derived classes - override the function below instead. - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - /// Must be implemented by derived classes. Will only be called if dagPath is valid. - virtual IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const = 0; - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class Description - { - public : - - /// use this constructor to register a converter for a native maya node: - Description( MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion ); - - /// use this constructor to register a converter for a plugin maya node: - Description( MTypeId fromType, IECore::TypeId resultType, bool defaultConversion ); - - private : - static FromMayaDagNodeConverterPtr creator( const MDagPath &dagPath ); - }; - - private : - - MDagPath m_dagPath; - - typedef FromMayaDagNodeConverterPtr (*CreatorFn)( const MDagPath &dagPath ); - typedef std::pair MayaType; - typedef std::pair< MayaType, IECore::TypeId > Types; - typedef std::map< Types, CreatorFn > TypesToFnsMap; - typedef std::map< MayaType, TypesToFnsMap::const_iterator> DefaultConvertersMap; - - static TypesToFnsMap &typesToFns(); - static DefaultConvertersMap &defaultConverters(); - static void registerConverter( const MayaType fromType, IECore::TypeId resultType, bool defaultConverter, CreatorFn creator ); - -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/FromMayaDagNodeConverter.inl" - -#endif // IECOREMAYA_FROMMAYADAGNODECONVERTER_H diff --git a/include/IECoreMaya/FromMayaDagNodeConverter.inl b/include/IECoreMaya/FromMayaDagNodeConverter.inl deleted file mode 100644 index 70a379e72b..0000000000 --- a/include/IECoreMaya/FromMayaDagNodeConverter.inl +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYADAGNODECONVERTER_INL -#define IECOREMAYA_FROMMAYADAGNODECONVERTER_INL - -namespace IECoreMaya -{ - -template -FromMayaDagNodeConverter::Description::Description( const MFn::Type fromType, const IECore::TypeId resultType, bool defaultConversion ) -{ - FromMayaDagNodeConverter::registerConverter( MayaType( fromType, 0 ), resultType, defaultConversion, creator ); -} - -template -FromMayaDagNodeConverter::Description::Description( const MTypeId fromType, const IECore::TypeId resultType, bool defaultConversion ) -{ - FromMayaDagNodeConverter::registerConverter( MayaType( MFn::kInvalid, fromType.id() ), resultType, defaultConversion, creator ); -} - -template -FromMayaDagNodeConverterPtr FromMayaDagNodeConverter::Description::creator( const MDagPath &dagPath ) -{ - return new T( dagPath ); -} - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYADAGNODECONVERTER_INL diff --git a/include/IECoreMaya/FromMayaEnumPlugConverter.h b/include/IECoreMaya/FromMayaEnumPlugConverter.h deleted file mode 100644 index 667a41f507..0000000000 --- a/include/IECoreMaya/FromMayaEnumPlugConverter.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2019, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAENUMPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYAENUMPLUGCONVERTER_H - -#include "IECoreMaya/FromMayaPlugConverter.h" - -#include "IECore/SimpleTypedData.h" - - -namespace IECoreMaya -{ - -template -class IECOREMAYA_API FromMayaEnumPlugConverter : public FromMayaPlugConverter -{ - - public : - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaEnumPlugConverter, FromMayaPlugConverter ) - - FromMayaEnumPlugConverter( const MPlug &plug ); - - // Attribute category we can add to an enum, so it automatically - // converts the enum field to StringData (without having to specify the resultType) - static const MString convertToStringCategory; - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static Description m_description; - -}; - -typedef FromMayaEnumPlugConverter FromMayaEnumPlugConverterst; -typedef FromMayaEnumPlugConverter FromMayaEnumPlugConvertersh; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAENUMPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaFluidConverter.h b/include/IECoreMaya/FromMayaFluidConverter.h deleted file mode 100644 index 5257740a03..0000000000 --- a/include/IECoreMaya/FromMayaFluidConverter.h +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAFLUIDCONVERTER_H -#define IE_COREMAYA_FROMMAYAFLUIDCONVERTER_H - -#include "IECore/TypedParameter.h" -#include "IECoreScene/Primitive.h" - -#include "IECoreMaya/FromMayaShapeConverter.h" - -class MFnFluid; - -namespace IECoreMaya -{ - -/// Converts a Maya Fluid to an IECore::PointsPrimitive with appropriate primitive variables -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaFluidConverter : public FromMayaShapeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaFluidConverter, FromMayaFluidConverterTypeId, FromMayaShapeConverter ); - - FromMayaFluidConverter( const MObject &object ); - FromMayaFluidConverter( const MDagPath &dagPath ); - - virtual ~FromMayaFluidConverter(); - - protected : - - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - void constructCommon(); - - IECoreScene::PrimitivePtr doPrimitiveConversion( MFnFluid &fnFluid ) const; - void addPrimVar( IECoreScene::PrimitivePtr primitive, const std::string &name, size_t numPoints, MFnFluid &fnFluid, float *(MFnFluid::*fn)( MStatus * ) ) const; - - IECore::BoolParameterPtr m_velocityParameter; - IECore::BoolParameterPtr m_densityParameter; - IECore::BoolParameterPtr m_pressureParameter; - IECore::BoolParameterPtr m_temperatureParameter; - IECore::BoolParameterPtr m_fuelParameter; - IECore::BoolParameterPtr m_falloffParameter; - IECore::BoolParameterPtr m_colorParameter; - IECore::BoolParameterPtr m_textureCoordinatesParameter; - - static Description m_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaFluidConverter ) - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAFLUIDCONVERTER_H diff --git a/include/IECoreMaya/FromMayaGroupConverter.h b/include/IECoreMaya/FromMayaGroupConverter.h deleted file mode 100644 index 785443f11c..0000000000 --- a/include/IECoreMaya/FromMayaGroupConverter.h +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAGROUPCONVERTER_H -#define IE_COREMAYA_FROMMAYAGROUPCONVERTER_H - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -#include "IECore/CompoundParameter.h" - -namespace IECoreMaya -{ - -/// The FromMayaGroupConverter converts types compatible with -/// MFnDagNode into IECore::Group objects. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaGroupConverter : public FromMayaDagNodeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaGroupConverter, FromMayaGroupConverterTypeId, FromMayaDagNodeConverter ); - - FromMayaGroupConverter( const MDagPath &object ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - IECore::CompoundParameterPtr m_meshParameters; - - private : - - static FromMayaDagNodeConverter::Description m_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaGroupConverter ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAGROUPCONVERTER_H diff --git a/include/IECoreMaya/FromMayaImageConverter.h b/include/IECoreMaya/FromMayaImageConverter.h deleted file mode 100644 index fde00d17fd..0000000000 --- a/include/IECoreMaya/FromMayaImageConverter.h +++ /dev/null @@ -1,95 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAIMAGECONVERTER_H -#define IE_COREMAYA_FROMMAYAIMAGECONVERTER_H - -#include -#include - -#include "IECoreMaya/FromMayaConverter.h" - -#include "IECore/Object.h" -#include "IECore/SimpleTypedParameter.h" - -#include "IECoreImage/ImagePrimitive.h" - -#include "maya/MImage.h" - - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaImageConverter ); - -/// The FromMayaImageConverter class allows conversion from MImages to an IECore::ImagePrimitive -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaImageConverter : public FromMayaConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaImageConverter, FromMayaImageConverterTypeId, FromMayaConverter ); - - FromMayaImageConverter( MImage &image ); - - /// The MImage which will be converted by the convert() function. - const MImage &image() const; - - IECore::BoolParameterPtr depthParameter(); - IECore::BoolParameterPtr depthParameter() const; - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - IECore::BoolParameterPtr m_depthParameter; - - private : - - /// This is mutable here because Maya isn't const-correct. It's not a copy because it appears that the default assignment/copy operators for - /// MImage can create two instances which reference the same data. When one of them dies, the other is then in an invalid state which can - /// crash Maya. - MImage &m_image; - - template - void writeChannels( IECoreImage::ImagePrimitivePtr target, const std::vector< std::string > &channelNames ) const; - - void writeDepth( IECoreImage::ImagePrimitivePtr target, const float *depth ) const; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAIMAGECONVERTER_H diff --git a/include/IECoreMaya/FromMayaInstancerConverter.h b/include/IECoreMaya/FromMayaInstancerConverter.h deleted file mode 100644 index 99ecc7442f..0000000000 --- a/include/IECoreMaya/FromMayaInstancerConverter.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAINSTANCECONVERTER_H -#define IE_COREMAYA_FROMMAYAINSTANCECONVERTER_H - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/NumericParameter.h" -#include "IECore/TypedParameter.h" -#include "IECore/Object.h" - -#include "IECoreScene/Primitive.h" - -#include "maya/MString.h" - - -class MFnMesh; - -namespace IECoreMaya -{ - -class IECOREMAYA_API FromMayaInstancerConverter : public FromMayaDagNodeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaInstancerConverter, FromMayaInstancerConverterTypeId, FromMayaDagNodeConverter ); - - FromMayaInstancerConverter( const MDagPath &dagPath ); - - virtual ~FromMayaInstancerConverter(); - - protected : - - IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const override; - - private : - - static FromMayaDagNodeConverter::Description m_description; - - -}; - -IE_CORE_DECLAREPTR( FromMayaInstancerConverter ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAINSTANCECONVERTER_H diff --git a/include/IECoreMaya/FromMayaLocatorConverter.h b/include/IECoreMaya/FromMayaLocatorConverter.h deleted file mode 100644 index 00778a3f8c..0000000000 --- a/include/IECoreMaya/FromMayaLocatorConverter.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYALOCATORCONVERTER_H -#define IE_COREMAYA_FROMMAYALOCATORCONVERTER_H - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaLocatorConverter : public FromMayaDagNodeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaLocatorConverter, FromMayaLocatorConverterTypeId, FromMayaDagNodeConverter ); - - FromMayaLocatorConverter( const MDagPath &dagPath ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaDagNodeConverter::Description m_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaLocatorConverter ) - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYALOCATORCONVERTER_H diff --git a/include/IECoreMaya/FromMayaMatrixDataConverter.h b/include/IECoreMaya/FromMayaMatrixDataConverter.h deleted file mode 100644 index 45836d3188..0000000000 --- a/include/IECoreMaya/FromMayaMatrixDataConverter.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAMATRIXDATACONVERTER_H -#define IECOREMAYA_FROMMAYAMATRIXDATACONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from the maya MFn::kMatrixData type to the IECore::M44*Data types. -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaMatrixDataConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaMatrixDataConverter( const MObject &object ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - static FromMayaObjectConverterDescription m_description; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYAMATRIXDATACONVERTER_H diff --git a/include/IECoreMaya/FromMayaMatrixVectorDataConverter.h b/include/IECoreMaya/FromMayaMatrixVectorDataConverter.h deleted file mode 100644 index 4bbd85d59b..0000000000 --- a/include/IECoreMaya/FromMayaMatrixVectorDataConverter.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAMATRIXVECTORDATACONVERTER_H -#define IECOREMAYA_FROMMAYAMATRIXVECTORDATACONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from the maya MFn::kDoubleArrayData type to the IECore::M44*VectorData types. -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaMatrixVectorDataConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaMatrixVectorDataConverter( const MObject &object ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - static FromMayaObjectConverterDescription m_description; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYAMATRIXVECTORDATACONVERTER_H diff --git a/include/IECoreMaya/FromMayaMeshConverter.h b/include/IECoreMaya/FromMayaMeshConverter.h deleted file mode 100644 index f273be454a..0000000000 --- a/include/IECoreMaya/FromMayaMeshConverter.h +++ /dev/null @@ -1,120 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAMESHCONVERTER_H -#define IE_COREMAYA_FROMMAYAMESHCONVERTER_H - -#include "IECoreMaya/FromMayaShapeConverter.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/NumericParameter.h" -#include "IECore/TypedParameter.h" - -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/Primitive.h" - -#include "maya/MString.h" - -class MFnMesh; - -namespace IECoreMaya -{ - -/// The FromMayaMeshConverter converts types compatible with -/// MFnMesh into IECore::MeshPrimitive objects. -/// \todo Vertex color support. Blind data support? -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaMeshConverter : public FromMayaShapeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaMeshConverter, FromMayaMeshConverterTypeId, FromMayaShapeConverter ); - - FromMayaMeshConverter( const MObject &object ); - FromMayaMeshConverter( const MDagPath &dagPath ); - - virtual ~FromMayaMeshConverter(); - - //! @name Parameter accessors - ////////////////////////////////////////////////////////// - //@{ - IECore::StringParameter *interpolationParameter(); - const IECore::StringParameter *interpolationParameter() const; - - IECore::BoolParameter *colorsParameter(); - const IECore::BoolParameter *colorsParameter() const; - - IECore::BoolParameter *extraColorsParameter(); - const IECore::BoolParameter *extraColorsParameter() const; - - IECore::BoolParameter *normalsParameter(); - const IECore::BoolParameter *normalsParameter() const; - - IECore::BoolParameter *uvParameter(); - const IECore::BoolParameter *uvParameter() const; - - IECore::BoolParameter *creasesParameter(); - const IECore::BoolParameter *creasesParameter() const; - - //@} - - protected : - - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - void constructCommon(); - - IECoreScene::PrimitiveVariable points() const; - IECoreScene::PrimitiveVariable normals() const; - IECoreScene::PrimitiveVariable uvs( const MString &uvSet, const std::vector &vertsPerFace ) const; - IECoreScene::PrimitiveVariable colors( const MString &colorSet="", bool forceRgb = false ) const; - void corners( IECoreScene::MeshPrimitive *mesh ) const; - void creases( IECoreScene::MeshPrimitive *mesh ) const; - - IECoreScene::PrimitivePtr doPrimitiveConversion( MFnMesh &fnMesh ) const; - - static Description m_description; - static Description m_dataDescription; - -}; - -IE_CORE_DECLAREPTR( FromMayaMeshConverter ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAMESHCONVERTER_H diff --git a/include/IECoreMaya/FromMayaNumericDataConverter.h b/include/IECoreMaya/FromMayaNumericDataConverter.h deleted file mode 100644 index 000b56e81a..0000000000 --- a/include/IECoreMaya/FromMayaNumericDataConverter.h +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYANUMERICDATACONVERTER_H -#define IE_COREMAYA_FROMMAYANUMERICDATACONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "IECore/VectorTypedData.h" - -#include "maya/MString.h" - -namespace IECoreMaya -{ - -/// The FromMayaNumericDataConverter converts types compatible with -/// MFnNumericData into IECore::Objects. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaNumericDataConverter : public FromMayaObjectConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaNumericDataConverter, FromMayaNumericDataConverterTypeId, FromMayaObjectConverter ); - - FromMayaNumericDataConverter( const MObject &object ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaObjectConverterDescription g_3Double; - static FromMayaObjectConverterDescription g_3Float; - static FromMayaObjectConverterDescription g_3Int; - static FromMayaObjectConverterDescription g_3Short; - static FromMayaObjectConverterDescription g_2Double; - static FromMayaObjectConverterDescription g_2Float; - static FromMayaObjectConverterDescription g_2Int; - static FromMayaObjectConverterDescription g_2Short; -}; - -IE_CORE_DECLAREPTR( FromMayaNumericDataConverter ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYANUMERICDATACONVERTER_H diff --git a/include/IECoreMaya/FromMayaNumericPlugConverter.h b/include/IECoreMaya/FromMayaNumericPlugConverter.h deleted file mode 100644 index d5e9a74305..0000000000 --- a/include/IECoreMaya/FromMayaNumericPlugConverter.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYANUMERICPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYANUMERICPLUGCONVERTER_H - -#include "IECore/SimpleTypedData.h" - -#include "IECoreMaya/FromMayaPlugConverter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaNumericPlugConverter : public FromMayaPlugConverter -{ - - public : - - FromMayaNumericPlugConverter( const MPlug &plug ); - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaNumericPlugConverter, FromMayaPlugConverter ) - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static Description m_description; - -}; - -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterbb; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterbi; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterii; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterif; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterid; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterfi; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterff; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterfd; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterdi; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterdf; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterdd; -typedef FromMayaNumericPlugConverter FromMayaNumericPlugConverterss; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYANUMERICPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaObjectConverter.h b/include/IECoreMaya/FromMayaObjectConverter.h deleted file mode 100644 index 6c1b788865..0000000000 --- a/include/IECoreMaya/FromMayaObjectConverter.h +++ /dev/null @@ -1,141 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAOBJECTCONVERTER_H -#define IE_COREMAYA_FROMMAYAOBJECTCONVERTER_H - -#include "IECoreMaya/FromMayaConverter.h" - -#include "IECore/Object.h" -#include "IECore/SimpleTypedParameter.h" - -#include "maya/MObjectHandle.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaObjectConverter ); - -/// The FromMayaConverter class forms an abstract base class for -/// all classes able to perform some kind of conversion -/// from a Maya datatype to an IECore datatype. -class IECOREMAYA_API FromMayaObjectConverter : public FromMayaConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaObjectConverter, FromMayaObjectConverterTypeId, FromMayaConverter ); - - /// The MObject which will be converted by the convert() function. - /// Will return MObject::kNullObj if objectIsAlive() is false. - const MObject &object() const; - /// If you allow the MObject passed to the constructor or create() - /// call to die then the Converter is unable to convert it and return - /// 0 from convert(). This function tells you if the object is still - /// alive or not, and therefore what return value you can expect. - bool objectIsAlive() const; - - //! @name Parameters - /// Parameters which affect the conversion process. - ///////////////////////////////////////////////////////////////////////////////// - //@{ - IECore::StringParameterPtr blindDataAttrPrefixParameter(); - IECore::ConstStringParameterPtr blindDataAttrPrefixParameter() const; - IECore::BoolParameterPtr blindDataRemoveNamespaceParameter(); - IECore::ConstBoolParameterPtr blindDataRemoveNamespaceParameter() const; - //@} - - //! @name Factory - ///////////////////////////////////////////////////////////////////////////////// - //@{ - /// Creates a converter which will convert the given object to an IECore::Object. - /// If resultType is specified then only converters which create objects of that - /// type will be returned - the default value allows any suitable converter to be - /// created. If no matching converters exist then returns 0. - static FromMayaObjectConverterPtr create( const MObject &object, IECore::TypeId resultType=IECore::InvalidTypeId ); - //@} - - protected : - - FromMayaObjectConverter( const std::string &description, const MObject &object ); - - /// Implemented to call doConversion as defined below only if object() has a suitable - /// value - otherwise returns 0. - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - /// Must be implemented by subclasses. Is guaranteed only to be called when object() - /// returns a valid MObject of a type specified when the converter was registered. - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const = 0; - - typedef FromMayaObjectConverterPtr (*CreatorFn)( const MObject &object ); - - static void registerConverter( const MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion, CreatorFn creator ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class FromMayaObjectConverterDescription - { - public : - /// \param fromType The maya type which can be converted. - /// \param resultType The cortex type which will result from the conversion. - /// \param defaultConversion Should be true if this conversion is the "best" for a given fromType. If - /// this is true then this is the converter that will be used when create() is called without specifying - /// a resultType. - FromMayaObjectConverterDescription( MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion ); - private : - static FromMayaObjectConverterPtr creator( const MObject &object ); - }; - - private : - - void addBlindData( const MObject &object, IECore::ObjectPtr convertedObject ) const; - - MObjectHandle m_objectHandle; - IECore::StringParameterPtr m_blindDataAttrPrefixParameter; - IECore::BoolParameterPtr m_blindDataRemoveNamespaceParameter; - - typedef std::pair Types; - typedef std::map TypesToFnsMap; - typedef std::map DefaultConvertersMap; - - static TypesToFnsMap &typesToFns(); - static DefaultConvertersMap &defaultConverters(); - -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/FromMayaObjectConverter.inl" - -#endif // IE_COREMAYA_FROMMAYACONVERTER_H diff --git a/include/IECoreMaya/FromMayaObjectConverter.inl b/include/IECoreMaya/FromMayaObjectConverter.inl deleted file mode 100644 index 170d37f6b1..0000000000 --- a/include/IECoreMaya/FromMayaObjectConverter.inl +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAOBJECTCONVERTER_INL -#define IE_COREMAYA_FROMMAYAOBJECTCONVERTER_INL - -#include "IECoreMaya/FromMayaObjectConverter.h" - -namespace IECoreMaya -{ - - -template -FromMayaObjectConverter::FromMayaObjectConverterDescription::FromMayaObjectConverterDescription( MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion ) -{ - FromMayaObjectConverter::registerConverter( fromType, resultType, defaultConversion, creator ); - /// \todo Derive FromMayaObjectConverterDescription from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -FromMayaObjectConverterPtr FromMayaObjectConverter::FromMayaObjectConverterDescription::creator( const MObject &object ) -{ - return new T( object ); -} - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAOBJECTCONVERTER_INL diff --git a/include/IECoreMaya/FromMayaObjectDataConverter.h b/include/IECoreMaya/FromMayaObjectDataConverter.h deleted file mode 100644 index b516daa9ec..0000000000 --- a/include/IECoreMaya/FromMayaObjectDataConverter.h +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAOBJECTDATACONVERTER_H -#define IECOREMAYA_FROMMAYAOBJECTDATACONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/TransformationMatrixData.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaObjectDataConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaObjectDataConverter( const MObject &object ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaObjectConverterDescription g_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaObjectDataConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYAOBJECTDATACONVERTER_H diff --git a/include/IECoreMaya/FromMayaParticleConverter.h b/include/IECoreMaya/FromMayaParticleConverter.h deleted file mode 100644 index c7e9b26523..0000000000 --- a/include/IECoreMaya/FromMayaParticleConverter.h +++ /dev/null @@ -1,84 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAPARTICLECONVERTER_H -#define IECOREMAYA_FROMMAYAPARTICLECONVERTER_H - -#include "IECoreMaya/FromMayaShapeConverter.h" - -#include "IECore/VectorTypedParameter.h" - -class MFnParticleSystem; - -namespace IECoreMaya -{ - -/// Converts Maya particleShape objects into IECore::PointsPrimitive objects. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaParticleConverter : public FromMayaShapeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaParticleConverter, FromMayaParticleConverterTypeId, FromMayaShapeConverter ); - - FromMayaParticleConverter( const MObject &object ); - FromMayaParticleConverter( const MDagPath &dagPath ); - - IECore::StringVectorParameterPtr attributeNamesParameter(); - IECore::ConstStringVectorParameterPtr attributeNamesParameter() const; - - protected : - - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - IECore::StringVectorParameterPtr m_attributeNamesParameter; - - private : - - void constructCommon(); - - IECoreScene::PrimitivePtr doPrimitiveConversion( MFnParticleSystem &fnParticle ) const; - - static Description m_kNParticleDescription; - static Description m_kParticleDescription; - -}; - -IE_CORE_DECLAREPTR( FromMayaParticleConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYAPARTICLECONVERTER_H diff --git a/include/IECoreMaya/FromMayaPlugConverter.h b/include/IECoreMaya/FromMayaPlugConverter.h deleted file mode 100644 index 3d437dbc1c..0000000000 --- a/include/IECoreMaya/FromMayaPlugConverter.h +++ /dev/null @@ -1,126 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYAPLUGCONVERTER_H - -#include "IECoreMaya/FromMayaConverter.h" - -#include "IECore/Object.h" - -#include "maya/MPlug.h" -#include "maya/MFnNumericData.h" -#include "maya/MFnUnitAttribute.h" - -#include - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaPlugConverter ); - -/// The FromMayaPlugConverter class allows conversion from MPlug values to -/// an IECore Object. -class IECOREMAYA_API FromMayaPlugConverter : public FromMayaConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaPlugConverter, FromMayaPlugConverterTypeId, FromMayaConverter ); - - /// The MPlug which will be converted by the convert() function. - const MPlug &plug() const; - - /// Creates a converter to convert the plug value to the an IECore - /// type. If resultType is specified then only converters which would create that type - /// will be considered. May return 0 if no converter can be found. Note that this returns a generic - /// FromMayaConverterPtr rather than a FromMayaPlugConverterPtr so that a - /// FromMayaObjectConverterPtr may be returned for the case of a plug holding an MObject. - static FromMayaConverterPtr create( const MPlug &plug, IECore::TypeId resultType=IECore::InvalidTypeId ); - - protected : - - FromMayaPlugConverter( const MPlug &plug ); - - /// Creating a static instance of one of these (templated on your converter type) - /// within your class will register your converter with the factory mechanism. - /// - /// The default constructor will perform type registration but will not register - /// the converter with the factory mechanism (this is needed for enum plugs) - template - class Description - { - public : - Description(); - Description( MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ); - Description( MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ); - Description( MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ); - private : - static FromMayaPlugConverterPtr creator( const MPlug &object ); - }; - - private : - - typedef FromMayaPlugConverterPtr (*CreatorFn)( const MPlug &plug ); - static void registerConverter( MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ); - static void registerConverter( MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ); - static void registerConverter( MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ); - - typedef std::pair NumericTypePair; - typedef std::map NumericTypesToFnsMap; - typedef std::map NumericDefaultConvertersMap; - static NumericTypesToFnsMap &numericTypesToFns(); - static NumericDefaultConvertersMap &numericDefaultConverters(); - - typedef std::pair TypedTypePair; - typedef std::map TypedTypesToFnsMap; - typedef std::map TypedDefaultConvertersMap; - static TypedTypesToFnsMap &typedTypesToFns(); - static TypedDefaultConvertersMap &typedDefaultConverters(); - - typedef std::pair UnitTypePair; - typedef std::map UnitTypesToFnsMap; - typedef std::map UnitDefaultConvertersMap; - static UnitTypesToFnsMap &unitTypesToFns(); - static UnitDefaultConvertersMap &unitDefaultConverters(); - - MPlug m_plug; - -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/FromMayaPlugConverter.inl" - -#endif // IE_COREMAYA_FROMMAYAPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaPlugConverter.inl b/include/IECoreMaya/FromMayaPlugConverter.inl deleted file mode 100644 index 4622477ca1..0000000000 --- a/include/IECoreMaya/FromMayaPlugConverter.inl +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAPLUGCONVERTER_INL -#define IE_COREMAYA_FROMMAYAPLUGCONVERTER_INL - -#include "IECoreMaya/FromMayaPlugConverter.h" - -namespace IECoreMaya -{ - -template -FromMayaPlugConverter::Description::Description() -{ - /// \todo Derive FromMayaPlugConverter::Description from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -FromMayaPlugConverter::Description::Description( MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ) -{ - FromMayaPlugConverter::registerConverter( fromType, resultType, isDefaultConverter, creator ); - /// \todo Derive FromMayaPlugConverter::Description from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -FromMayaPlugConverter::Description::Description( MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ) -{ - FromMayaPlugConverter::registerConverter( fromType, resultType, isDefaultConverter, creator ); - /// \todo Derive FromMayaPlugConverter::Description from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -FromMayaPlugConverter::Description::Description( MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter ) -{ - FromMayaPlugConverter::registerConverter( fromType, resultType, isDefaultConverter, creator ); - /// \todo Derive FromMayaPlugConverter::Description from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -FromMayaPlugConverterPtr FromMayaPlugConverter::Description::creator( const MPlug &plug ) -{ - return new T( plug ); -} - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAPLUGCONVERTER_INL diff --git a/include/IECoreMaya/FromMayaPluginDataPlugConverter.h b/include/IECoreMaya/FromMayaPluginDataPlugConverter.h deleted file mode 100644 index f1bbeb0e54..0000000000 --- a/include/IECoreMaya/FromMayaPluginDataPlugConverter.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAPLUGINDATAPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYAPLUGINDATAPLUGCONVERTER_H - -#include "IECoreMaya/FromMayaPlugConverter.h" - -namespace IECoreMaya -{ - -class IECOREMAYA_API FromMayaPluginDataPlugConverter : public FromMayaPlugConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaPluginDataPlugConverter, FromMayaPluginDataPlugConverterTypeId, FromMayaPlugConverter ); - - FromMayaPluginDataPlugConverter( const MPlug &plug ); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static Description m_description; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYAPLUGINDATAPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaShapeConverter.h b/include/IECoreMaya/FromMayaShapeConverter.h deleted file mode 100644 index 128f9762ad..0000000000 --- a/include/IECoreMaya/FromMayaShapeConverter.h +++ /dev/null @@ -1,164 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASHAPECONVERTER_H -#define IECOREMAYA_FROMMAYASHAPECONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "IECore/NumericParameter.h" - -#include "maya/MDagPath.h" - -namespace IECoreScene -{ - -IE_CORE_FORWARDDECLARE( Primitive ); - -} // namespace IECoreScene - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaShapeConverter ); - -/// The FromMayaShapeConverter class forms an abstract base class for converting -/// maya shape objects into IECoreScene::Primitive objects. Note that Maya is -/// quite restrictive when it comes to surface variation, so by default only a few -/// PrimitiveVariables are exported: generally P, N, and any uv sets. Users can -/// customize the export to generate extra PrimitiveVarialbes using dynamic attributes -/// on the shape node in Maya. Any attribute names beginning with "iePrimVar" are -/// considered to represent PrimitiveVariables and are converted as such. The -/// interpolation type of the variable is guessed, unless the attribute name begins -/// with iePrimVar_?_, in which case the ? is used to specify interpolation type: -/// C for Constant -/// U for Uniform -/// V for Vertex -/// Y for Varying -/// F for FaceVarying -class IECOREMAYA_API FromMayaShapeConverter : public FromMayaObjectConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaShapeConverter, FromMayaShapeConverterTypeId, FromMayaObjectConverter ); - - enum Space - { - Object = 0, - World = 1 - }; - - IECore::IntParameterPtr spaceParameter(); - IECore::ConstIntParameterPtr spaceParameter() const; - - //! @name Factory - /// These functions allow the creation of a specific converter subclass appropriate - /// to a particular MDagPath instance. - ///////////////////////////////////////////////////////////////////////////////// - //@{ - /// Creates a converter which will convert the given object to an IECore::Object - /// of the type specified by resultType - the default value specifies that any result - /// will do. Returns 0 if no suitable converter can be found. Where possible this should be used in - /// preference to the FromMayaObjectConverter factory function, as constructing - /// a converter from an MDagPath provides additional functionality (for instance - /// correct world space queries). - static FromMayaShapeConverterPtr create( const MDagPath &dagPath, IECore::TypeId resultType=IECore::InvalidTypeId ); - //@} - - protected : - - FromMayaShapeConverter( const std::string &description, const MObject &object ); - /// This form is necessary if people want to get the shape in world space - world space queries only ever - /// work with an MDagPath. - FromMayaShapeConverter( const std::string &description, const MDagPath &dagPath ); - - /// Implemented to call doPrimitiveConversion(), and then add on primitive variables specified as dynamic attributes - /// on the object begin converted. Derived classes need not reimplement this function, but should instead - /// implement doPrimitiveConversion(). - IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const override; - /// Must be implemented by derived classes to return a Primitive created to represent the specified object. - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const = 0; - /// Must be implemented by derived classes to return a Primitive created to represent the specified object. - virtual IECoreScene::PrimitivePtr doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const = 0; - - /// The space in which derived classes should convert the object. - MSpace::Space space() const; - /// Returns the dag path for the shape to be converted. This may return false, in which case object() should - /// be converted instead. Generally derived classes shouldn't need this method as they can just implement - /// the two doPrimitiveConversion() methods above, and this class will call the appropriate one. If emitSpaceWarnings - /// is true, then a warning is emitted if there is no valid dag path available and the space parameter is set to world. - const MDagPath *dagPath( bool emitSpaceWarnings=false ) const; - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class Description - { - public : - /// \param fromType The maya type which can be converted. - /// \param resultType The cortex type which will result from the conversion. - /// \param defaultConversion Should be true if this conversion is the "best" for a given fromType. If - /// this is true then this is the converter that will be used when create() is called without specifying - /// a resultType. - Description( MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion ); - private : - static FromMayaShapeConverterPtr creator( const MDagPath &dagPath ); - }; - - private : - - void constructCommon(); // does stuff both constructors need. - void addPrimVars( const MObject &object, IECoreScene::PrimitivePtr primitive ) const; - - MDagPath m_dagPath; - - IECore::IntParameterPtr m_spaceParameter; - - typedef FromMayaShapeConverterPtr (*ShapeCreatorFn)( const MDagPath &dagPath ); - typedef std::pair ShapeTypes; - typedef std::map ShapeTypesToFnsMap; - typedef std::map DefaultConvertersMap; - - static ShapeTypesToFnsMap &shapeTypesToFns(); - static DefaultConvertersMap &defaultConverters(); - static void registerShapeConverter( const MFn::Type fromType, IECore::TypeId resultType, bool defaultConverter, ShapeCreatorFn creator ); - -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/FromMayaShapeConverter.inl" - -#endif // IECOREMAYA_FROMMAYASHAPECONVERTER_H diff --git a/include/IECoreMaya/FromMayaShapeConverter.inl b/include/IECoreMaya/FromMayaShapeConverter.inl deleted file mode 100644 index 4fdd880c2c..0000000000 --- a/include/IECoreMaya/FromMayaShapeConverter.inl +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASHAPECONVERTER_INL -#define IECOREMAYA_FROMMAYASHAPECONVERTER_INL - -#include "IECoreMaya/FromMayaObjectConverter.h" - -namespace IECoreMaya -{ - -template -FromMayaShapeConverter::Description::Description( MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion ) -{ - // first register with the object converter - FromMayaObjectConverter::FromMayaObjectConverterDescription c( fromType, resultType, defaultConversion ); - // then register with the shape converter - FromMayaShapeConverter::registerShapeConverter( fromType, resultType, defaultConversion, creator ); -} - -template -FromMayaShapeConverterPtr FromMayaShapeConverter::Description::creator( const MDagPath &dagPath ) -{ - return new T( dagPath ); -} - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYASHAPECONVERTER_INL diff --git a/include/IECoreMaya/FromMayaSkinClusterConverter.h b/include/IECoreMaya/FromMayaSkinClusterConverter.h deleted file mode 100644 index 37d7ac7d98..0000000000 --- a/include/IECoreMaya/FromMayaSkinClusterConverter.h +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASKINCLUSTERCONVERTER_H -#define IECOREMAYA_FROMMAYASKINCLUSTERCONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECoreMaya/FromMayaDagNodeConverter.h" -#include "IECore/NumericParameter.h" -#include "IECore/TypedParameter.h" - - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaSkinClusterConverter ); - -/// The FromMayaSkinClusterConverter converts the smooth bind data on a maya skinCluster node -/// into IECore::SmoothSkinningData. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaSkinClusterConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaSkinClusterConverter( const MObject &object ); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaSkinClusterConverter, FromMayaSkinClusterConverterTypeId, FromMayaObjectConverter ); - - enum InfluenceName - { - Partial = 0, - Full = 1 - }; - - IECore::IntParameterPtr influenceNameParameter(); - IECore::ConstIntParameterPtr influenceNameParameter() const; - - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - IECore::IntParameterPtr m_influenceNameParameter; - - static FromMayaObjectConverterDescription m_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaSkinClusterConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYASKINCLUSTERCONVERTER_H diff --git a/include/IECoreMaya/FromMayaSkinClusterWeightsConverter.h b/include/IECoreMaya/FromMayaSkinClusterWeightsConverter.h deleted file mode 100644 index 4a06ae4d55..0000000000 --- a/include/IECoreMaya/FromMayaSkinClusterWeightsConverter.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTER_H -#define IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECore/NumericParameter.h" - - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( FromMayaSkinClusterWeightsConverter ); - -/// The FromMayaSkinClusterWeightsConverter converts skinCluster weigths from maya skinCluster nodes -class IECOREMAYA_API FromMayaSkinClusterWeightsConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaSkinClusterWeightsConverter( const MObject &object ); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaSkinClusterWeightsConverter, FromMayaSkinClusterWeightsConverterTypeId, FromMayaObjectConverter ); - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaObjectConverterDescription m_description; - IECore::BoolParameterPtr m_useCompression; - IECore::FloatParameterPtr m_compressionThreshold; - -}; - -IE_CORE_DECLAREPTR( FromMayaSkinClusterWeightsConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTER_H diff --git a/include/IECoreMaya/FromMayaStringPlugConverter.h b/include/IECoreMaya/FromMayaStringPlugConverter.h deleted file mode 100644 index 4c437f17b9..0000000000 --- a/include/IECoreMaya/FromMayaStringPlugConverter.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYASTRINGPLUGCONVERTER_H -#define IE_COREMAYA_FROMMAYASTRINGPLUGCONVERTER_H - -#include "IECoreMaya/FromMayaPlugConverter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaStringPlugConverter : public FromMayaPlugConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaStringPlugConverter, FromMayaStringPlugConverterTypeId, FromMayaPlugConverter ); - - FromMayaStringPlugConverter( const MPlug &plug ); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static Description m_description; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_FROMMAYASTRINGPLUGCONVERTER_H diff --git a/include/IECoreMaya/FromMayaTransformConverter.h b/include/IECoreMaya/FromMayaTransformConverter.h deleted file mode 100644 index 1e240ca103..0000000000 --- a/include/IECoreMaya/FromMayaTransformConverter.h +++ /dev/null @@ -1,95 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYATRANSFORMCONVERTER_H -#define IECOREMAYA_FROMMAYATRANSFORMCONVERTER_H - -#include "maya/MEulerRotation.h" - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -#include "IECore/NumericParameter.h" -#include "IECore/TypedParameter.h" - -namespace IECoreMaya -{ - -/// The FromMayaTransformationMatrixConverter extracts transforms from DAG nodes. -/// \ingroup conversionGroup -class IECOREMAYA_API FromMayaTransformConverter : public FromMayaDagNodeConverter -{ - - public : - - FromMayaTransformConverter( const MDagPath &dagPath ); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaTransformConverter, FromMayaTransformConverterTypeId, FromMayaDagNodeConverter ); - - enum Space - { - Local = 0, - World = 1, - Custom = 2 - }; - - IECore::IntParameterPtr spaceParameter(); - IECore::ConstIntParameterPtr spaceParameter() const; - - IECore::BoolParameterPtr eulerFilterParameter(); - IECore::ConstBoolParameterPtr eulerFilterParameter() const; - - IECore::BoolParameterPtr zeroPivotsParameter(); - IECore::ConstBoolParameterPtr zeroPivotsParameter() const; - - protected : - - virtual IECore::ObjectPtr doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - IECore::IntParameterPtr m_spaceParameter; - mutable MEulerRotation m_lastRotation; - mutable bool m_lastRotationValid; - IECore::BoolParameterPtr m_eulerFilterParameter; - IECore::BoolParameterPtr m_zeroPivotsParameter; - - static Description g_description; - -}; - -IE_CORE_DECLAREPTR( FromMayaTransformConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYATRANSFORMCONVERTER_H diff --git a/include/IECoreMaya/FromMayaTransformationMatrixConverter.h b/include/IECoreMaya/FromMayaTransformationMatrixConverter.h deleted file mode 100644 index f3db50b154..0000000000 --- a/include/IECoreMaya/FromMayaTransformationMatrixConverter.h +++ /dev/null @@ -1,78 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTER_H -#define IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTER_H - -#include "IECoreMaya/FromMayaObjectConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/TransformationMatrixData.h" - -namespace IECoreMaya -{ - -/// The FromMayaTransformationMatrixConverter converts types compatible with -/// MFnMatrixData into IECore::TransformationMatrixData. -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaTransformationMatrixConverter : public FromMayaObjectConverter -{ - - public : - - FromMayaTransformationMatrixConverter( const MObject &object ); - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaTransformationMatrixConverter, FromMayaObjectConverter ) - - protected : - - virtual IECore::ObjectPtr doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static FromMayaObjectConverterDescription g_description; - static FromMayaObjectConverterDescription g_dataDescription; - -}; - -typedef FromMayaTransformationMatrixConverter FromMayaTransformationMatrixfConverter; -typedef FromMayaTransformationMatrixConverter FromMayaTransformationMatrixdConverter; - -IE_CORE_DECLAREPTR( FromMayaTransformationMatrixfConverter ); -IE_CORE_DECLAREPTR( FromMayaTransformationMatrixdConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTER_H diff --git a/include/IECoreMaya/FromMayaUnitPlugConverter.h b/include/IECoreMaya/FromMayaUnitPlugConverter.h deleted file mode 100644 index 55e44d64b2..0000000000 --- a/include/IECoreMaya/FromMayaUnitPlugConverter.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAUNITPLUGCONVERTER_H -#define IECOREMAYA_FROMMAYAUNITPLUGCONVERTER_H - -#include "IECoreMaya/FromMayaPlugConverter.h" - -#include "IECore/NumericParameter.h" - -namespace IECoreMaya -{ - -/// \ingroup conversionGroup -template -class IECOREMAYA_API FromMayaUnitPlugConverter : public FromMayaPlugConverter -{ - - public : - - FromMayaUnitPlugConverter( const MPlug &plug ); - - IECORE_RUNTIMETYPED_DECLARETEMPLATE( FromMayaUnitPlugConverter, FromMayaPlugConverter ) - - IECore::IntParameterPtr angleUnitParameter(); - IECore::ConstIntParameterPtr angleUnitParameter() const; - - IECore::IntParameterPtr distanceUnitParameter(); - IECore::ConstIntParameterPtr distanceUnitParameter() const; - - IECore::IntParameterPtr timeUnitParameter(); - IECore::ConstIntParameterPtr timeUnitParameter() const; - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - IECore::IntParameterPtr m_angleUnitParameter; - IECore::IntParameterPtr m_distanceUnitParameter; - IECore::IntParameterPtr m_timeUnitParameter; - - static Description m_angleDescription; - static Description m_distanceDescription; - static Description m_timeDescription; - -}; - -typedef FromMayaUnitPlugConverter FromMayaUnitPlugConverterf; -typedef FromMayaUnitPlugConverter FromMayaUnitPlugConverterd; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_FROMMAYAUNITPLUGCONVERTER_H diff --git a/include/IECoreMaya/IECoreMaya.h b/include/IECoreMaya/IECoreMaya.h deleted file mode 100644 index f9af57bbf9..0000000000 --- a/include/IECoreMaya/IECoreMaya.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_COREMAYA_H -#define IE_COREMAYA_COREMAYA_H - -#include "maya/MFnPlugin.h" - -#include "IECoreMaya/Export.h" - -/// The IECoreMaya namespace holds all the functionality of libIECoreMaya. -namespace IECoreMaya -{ - -IECOREMAYA_API MStatus initialize( MFnPlugin &plugin ); -IECOREMAYA_API MStatus uninitialize( MFnPlugin &plugin ); - -} - -//! \page IECoreMaya -/// -/// The IECoreMaya library provides the core C++ framework for all Maya development -/// within Cortex. Wherever possible, Maya-specific routines should be implemented -/// within this library rather than within their respective tools. Code which is -/// truly generic and unrelated to Maya should be placed in the main IECore library. -/// -/// \section mainPageDependencies Dependencies -/// -/// \subsection IECore -/// -/// \subsection Maya -/// -///
- -/// \addtogroup environmentGroup -/// -/// IECOREMAYA_DISABLEOUTPUTREDIRECTION
-/// By default all python output and IECore::MessageHandler output are redirected through -/// the appropriate MGlobal::display*() functions, so that they appear in the script editor. -/// Setting this environment variable disables this redirection, causing the messages to appear -/// in the shell. - -#endif // IE_COREMAYA_COREMAYA_H diff --git a/include/IECoreMaya/ImageFile.h b/include/IECoreMaya/ImageFile.h deleted file mode 100644 index 9187c8fe98..0000000000 --- a/include/IECoreMaya/ImageFile.h +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_IMAGEFILE_H -#define IE_COREMAYA_IMAGEFILE_H - -#include "maya/MPxImageFile.h" - -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -class IECOREMAYA_API ImageFile : public MPxImageFile -{ - public: - ImageFile(); - virtual ~ImageFile(); - - static void* creator(); - - virtual MStatus open( MString pathname, MImageFileInfo* info ); - virtual MStatus load( MImage& image, unsigned int idx ); - virtual MStatus glLoad( const MImageFileInfo& info, unsigned int imageNumber ); - - protected: - - void populateImage( float* pixels ) const; - - IECore::FloatVectorDataPtr m_rData, m_gData, m_bData, m_aData; - unsigned int m_numChannels; - unsigned int m_width, m_height; - - struct ChannelConverter; -}; - -} - -#endif // IE_COREMAYA_IMAGEFILE_H diff --git a/include/IECoreMaya/ImagePlaneHolder.h b/include/IECoreMaya/ImagePlaneHolder.h deleted file mode 100644 index 399c9ad054..0000000000 --- a/include/IECoreMaya/ImagePlaneHolder.h +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_IMAGEPLANEHOLDER_H -#define IECOREMAYA_IMAGEPLANEHOLDER_H - -#include "IECore/Op.h" - -#include "IECoreMaya/ParameterisedHolder.h" - -#include "maya/MPxImagePlane.h" - -namespace IECoreMaya -{ - -/// A class which holds an Op, expected to return an ImagePrimitive, which is then placed onto an ImagePlane. -class IECOREMAYA_API ImagePlaneHolder : public ParameterisedHolderImagePlane -{ - public : - - ImagePlaneHolder(); - virtual ~ImagePlaneHolder(); - - virtual void postConstructor(); - - static void *creator(); - static MStatus initialize(); - static MTypeId id; - - virtual MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ); - virtual MStatus loadImageMap ( const MString &fileName, int frame, MImage &image ); - - /// Calls setParameterised( className, classVersion, "IECORE_OP_PATHS" ). - MStatus setOp( const std::string &className, int classVersion ); - /// Returns runTimeCast( getParameterised( className, classVersion ) ). - IECore::OpPtr getOp( std::string *className = 0, int *classVersion = 0 ); - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_IMAGEPLANEHOLDER_H diff --git a/include/IECoreMaya/ImageViewportPostProcess.h b/include/IECoreMaya/ImageViewportPostProcess.h deleted file mode 100644 index 4c538c7273..0000000000 --- a/include/IECoreMaya/ImageViewportPostProcess.h +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_IMAGEVIEWPORTPOSTPROCESS_H -#define IE_COREMAYA_IMAGEVIEWPORTPOSTPROCESS_H - -#include - -#include "maya/MString.h" -#include "maya/MImage.h" - -#include "IECoreImage/ImagePrimitive.h" - -#include "IECoreMaya/ViewportPostProcess.h" - -namespace IECoreMaya -{ - -/// An abstract ViewportPostProcess suitable for subclassing in Python which operates on ImagePrimitive objects. This is much -/// slower than ViewportPostProcess due to the MImage<->ImagePrimitive conversions which need to occur. -class IECOREMAYA_API ImageViewportPostProcess : public ViewportPostProcess -{ - public: - - IE_CORE_DECLAREMEMBERPTR( ImageViewportPostProcess ) - - ImageViewportPostProcess(); - virtual ~ImageViewportPostProcess(); - - protected: - - /// Performs in-place modification of the given ImagePrimitive. Derived classes need to implement this. - virtual void postRender( const std::string &panelName, IECoreImage::ImagePrimitivePtr image ) = 0; - - private : - - /// Performs the appropriate MImage<->ImagePrimitive conversions around call through to abstract ImageViewportPostProcess::postRender() - virtual void postRender( const std::string &panelName, MImage &image ); -}; - - -IE_CORE_DECLAREPTR( ImageViewportPostProcess ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_IMAGEVIEWPORTPOSTPROCESS_H diff --git a/include/IECoreMaya/LineSegmentParameterHandler.h b/include/IECoreMaya/LineSegmentParameterHandler.h deleted file mode 100644 index a594ce1b20..0000000000 --- a/include/IECoreMaya/LineSegmentParameterHandler.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_LINESEGMENTPARAMETERHANDLER_H -#define IECOREMAYA_LINESEGMENTPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -namespace IECoreMaya -{ - -template -class IECOREMAYA_API LineSegmentParameterHandler : public ParameterHandler -{ - - protected : - - typedef typename T::ValueType LineSegment; - typedef typename LineSegment::Point Point; - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - -}; - - -} // namespace IECoreMaya - -#endif // IECOREMAYA_LINESEGMENTPARAMETERHANDLER_H diff --git a/include/IECoreMaya/LiveScene.h b/include/IECoreMaya/LiveScene.h deleted file mode 100644 index 87db282946..0000000000 --- a/include/IECoreMaya/LiveScene.h +++ /dev/null @@ -1,287 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_LIVESCENE_H -#define IECOREMAYA_LIVESCENE_H - -#include "boost/function.hpp" -#include "tbb/mutex.h" - -#include "IECoreScene/SceneInterface.h" -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/Export.h" - -#include "maya/MDagPath.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( LiveScene ); - -/// A class for navigating a maya scene. -/// Each LiveScene instance maps to a specific transform in a scene, uniquely identified by it's dag path. -/// Shapes are interpreted as objects living on their parent - eg a scene with the objects |pSphere1 and -/// |pSphere1|pSphereShape1 in it will map to a LiveScene at "/", with a child called "pSphere1", with a -/// MeshPrimitive as its object, and no children. -/// This interface currently only supports read operations, which can only be called with the current maya -/// time in seconds. For example, if you're currently on frame 1 in your maya session, your scene's frame rate -/// is 24 fps, and you want to read an object from your LiveScene instance, you must call -/// LiveSceneInstance.readObject( 1.0 / 24 ), or it will throw an exception. - -class IECOREMAYA_API LiveScene : public IECoreScene::SceneInterface -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( LiveScene, LiveSceneTypeId, IECoreScene::SceneInterface ); - - LiveScene(); - ~LiveScene() = default; - - std::string fileName() const override; - - /// Returns the name of the scene location which this instance is referring to. The root path returns "/". - Name name() const override; - /// Returns the tokenized dag path this instance is referring to. - void path( Path &p ) const override; - - /// Name of maya attribute overriding `IECoreScene::SceneInterface::visibilityName` - static IECoreScene::SceneInterface::Name visibilityOverrideName; - - /* - * Bounding box - */ - - /// Returns the local bounding box of this node at the - /// specified point in time, which must be equal to the current maya time in seconds. - Imath::Box3d readBound( double time ) const override; - /// Not currently supported - will throw an exception. - void writeBound( const Imath::Box3d &bound, double time ) override; - - /* - * Transform - */ - - /// Returns the local transform of this node at the specified - /// point in time, which must be equal to the current maya time in seconds. - IECore::ConstDataPtr readTransform( double time ) const override; - /// Returns the transform of this node at the specified - /// point in time as a matrix. - Imath::M44d readTransformAsMatrix( double time ) const override; - /// Not currently supported - will throw an exception. - void writeTransform( const IECore::Data *transform, double time ) override; - - /* - * Attributes - */ - - bool hasAttribute( const Name &name ) const override; - /// Fills attrs with the names of all attributes available in the current directory - void attributeNames( NameList &attrs ) const override; - /// Returns the attribute value at the given time, which must be equal to the current maya time in seconds. - IECore::ConstObjectPtr readAttribute( const Name &name, double time ) const override; - /// Not currently supported - will throw an exception. - void writeAttribute( const Name &name, const IECore::Object *attribute, double time ) override; - - /* - * Tags - */ - - /// Uses the custom registered tags to return whether a given tag is present in the scene location or not. - bool hasTag( const Name &name, int filter = SceneInterface::LocalTag ) const override; - /// Uses the custom registered tags to list all the tags present in the scene location. - void readTags( NameList &tags, int filter = SceneInterface::LocalTag ) const override; - /// Not currently supported - will throw an exception. - void writeTags( const NameList &tags ) override; - - /* - * Sets - */ - - /// Returns the names of all sets containing objects in this location and all of its descendants. - NameList setNames( bool includeDescendantSets = true ) const override; - /// Reads the named set. All paths returned are relative to the current location. - IECore::PathMatcher readSet( const Name &name, bool includeDescendantSets = true, const IECore::Canceller *canceller = nullptr ) const override; - /// Writes a set at the current location. All paths are specified relative to the current location. - void writeSet( const Name &name, const IECore::PathMatcher &set ) override; - /// Hash a named set at the current location. - void hashSet( const Name& setName, IECore::MurmurHash &h ) const override; - - /* - * Object - */ - - /// Checks if there are objects in the scene (convertible from Maya or registered as custom objects) - bool hasObject() const override; - /// Reads the object stored at this path in the scene at the given time - may - /// return 0 when no object has been stored. Time must be equal to the current maya time in seconds - IECore::ConstObjectPtr readObject( double time, const IECore::Canceller *canceller = nullptr ) const override; - /// Reads primitive variables from the object of type Primitive stored at this path in the scene at the given time. - /// Raises exception if it turns out not to be a Primitive object. - IECoreScene::PrimitiveVariableMap readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const override; - /// Not currently supported - will throw an exception. - void writeObject( const IECore::Object *object, double time ) override; - - /* - * Hierarchy - */ - - /// Queries the names of any existing children of path() within - /// the scene. - void childNames( NameList &childNames ) const override; - /// Queries weather the named child exists. - bool hasChild( const Name &name ) const override; - /// Returns an object for the specified child location in the scene. - /// If the child does not exist then it will behave according to the - /// missingBehavior parameter. May throw and exception, may return a NULL pointer, - /// or may create the child (if that is possible). - /// Bounding boxes will be automatically propagated up from the children - /// to the parent as it is written. - IECoreScene::SceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - /// Returns a read-only interface for a child location in the scene. - IECoreScene::ConstSceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - /// Returns a writable interface to a new child. Throws an exception if it already exists. - /// Bounding boxes will be automatically propagated up from the children - /// to the parent as it is written. - IECoreScene::SceneInterfacePtr createChild( const Name &name ) override; - - - /// Returns an object for querying the scene at the given path (full path). - IECoreScene::SceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - - /// Returns an object for querying the scene at the given path (full path). - IECoreScene::ConstSceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - - /// Currently raises an exception - void hash( HashType hashType, double time, IECore::MurmurHash &h ) const override; - - /* - * Utility functions - */ - - /// Returns the MDagPath object to the scene node - MDagPath dagPath() const; - - /// Returns the scene path corresponding to the maya dag path - static void dagPathToPath( MDagPath dagPath, IECoreScene::SceneInterface::Path &path ); - - /// Returns the maya dag path corresponding to the scene path - static void pathToDagPath( const IECoreScene::SceneInterface::Path &path, MDagPath &dagPath ); - - /// Translates cortex attribute name to maya attribute name - /// Returns an empty string if there are no valid mappings - static Name toMayaAttributeName( const Name &name ); - - /// Translates maya attribute name to cortex attribute name - /// Returns an empty string if there are no valid mappings - static Name fromMayaAttributeName( const Name &name ); - - typedef boost::function HasFn; - typedef boost::function ReadFn; - typedef boost::function ReadAttrFn; - typedef boost::function HasTagFn; - typedef boost::function ReadTagsFn; - typedef boost::function NamesFn; - typedef boost::function MightHaveFn; - - /// Register callbacks for custom objects. - /// The has function will be called during hasObject and it stops in the first one that returns true. - /// The read method is called if the has method returns true, so it should return a valid Object pointer or raise an Exception. - static void registerCustomObject( HasFn hasFn, ReadFn readFn ); - - /// Register callbacks for custom attributes. - /// The names function will be called during attributeNames and hasAttribute. - /// The readAttr method is called if the names method returns the expected attribute, so it should return a valid Object pointer or raise an Exception. - /// If the mightHave function is specified, it will be called before names function for early out, to see if the names function can return the expected attribute. - static void registerCustomAttributes( NamesFn namesFn, ReadAttrFn readFn ); - static void registerCustomAttributes( NamesFn namesFn, ReadAttrFn readFn, MightHaveFn mightHaveFn); - - /// Register callbacks for nodes to define custom tags - /// The functions will be called during hasTag and readTags. - /// readTags will return the union of all custom ReadTagsFns. - static void registerCustomTags( HasTagFn hasFn, ReadTagsFn readFn ); - - private : - - IECoreScene::SceneInterfacePtr retrieveScene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const; - IECoreScene::SceneInterfacePtr retrieveChild( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const; - IECoreScene::SceneInterfacePtr retrieveParent() const; - - void getChildDags( const MDagPath& dagPath, MDagPathArray& paths ) const; - - /// Struct for registering readers for custom Object. - struct CustomReader - { - HasFn m_has; - ReadFn m_read; - }; - - /// Struct for registering readers for custom Tags. - struct CustomTagReader - { - HasTagFn m_has; - ReadTagsFn m_read; - }; - - /// Struct for registering readers for custom Attributes. - struct CustomAttributeReader - { - NamesFn m_names; - ReadAttrFn m_read; - MightHaveFn m_mightHave; - }; - - static std::vector< CustomReader > &customObjectReaders(); - static std::vector< CustomAttributeReader > &customAttributeReaders(); - static std::vector< CustomTagReader > &customTagReaders(); - - protected: - - /// constructor for a specific dag path: - LiveScene( const MDagPath& p, bool isRoot = false ); - - MDagPath m_dagPath; - bool m_isRoot; - - /// calls the constructor for a specific dag path. Derived classes can override this so their child() and scene() methods can - /// return instances of the derived class - virtual LiveScenePtr duplicate( const MDagPath& p, bool isRoot = false ) const; - - typedef tbb::mutex Mutex; - static Mutex s_mutex; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_LIVESCENE_H diff --git a/include/IECoreMaya/MArrayIter.h b/include/IECoreMaya/MArrayIter.h deleted file mode 100644 index 854fa9c6d2..0000000000 --- a/include/IECoreMaya/MArrayIter.h +++ /dev/null @@ -1,162 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_MAYACORE_MARRAYITER_H -#define IE_MAYACORE_MARRAYITER_H - -#include "IECoreMaya/MArrayTraits.h" - -#include "maya/MStringArray.h" -#include "maya/MString.h" - -#include -#include - -namespace IECoreMaya -{ - -/// The MArrayIter struct provides typedefs and functions for -/// stl compatible iterator access to the maya array types. -template -struct MArrayIter -{ - - typedef typename MArrayTraits::ValueType *Iterator; - typedef const typename MArrayTraits::ValueType *ConstIterator; - typedef std::reverse_iterator ReverseIterator; - typedef std::reverse_iterator ConstReverseIterator; - - static inline Iterator begin( T &array ); - static inline ConstIterator begin( const T &array ); - static inline Iterator end( T &array ); - static inline ConstIterator end( const T &array ); - - static inline ReverseIterator reverseBegin( T &array ); - static inline ConstReverseIterator reverseBegin( const T &array ); - static inline ReverseIterator reverseEnd( T &array ); - static inline ConstReverseIterator reverseEnd( const T &array ); - -}; - -/// An iterator to allow use of Maya arrays with certain STL algorithms, e.g. set_union -/// \todo Should this be a member of MArrayIter? -template -class MayaAppendIterator : public std::iterator< std::output_iterator_tag, void, void, void, void> -{ - - public: - - typedef T ContainerType; - - explicit MayaAppendIterator(T& x) : m_container(&x) {} - - MayaAppendIterator& operator=(const typename IECoreMaya::MArrayTraits::ValueType &v) - { - m_container->append(v); - return *this; - } - - MayaAppendIterator& operator*() - { - return *this; - } - - MayaAppendIterator& operator++() - { - return *this; - } - - MayaAppendIterator operator++(int) - { - return *this; - } - - protected: - T* m_container; -}; - -/// MStringArray specialisation to allow operation with std::string -template<> -class MayaAppendIterator : public std::iterator< std::output_iterator_tag, void, void, void, void> -{ - - public: - - typedef MStringArray ContainerType; - - explicit MayaAppendIterator(MStringArray& x) : m_container(&x) {} - - MayaAppendIterator& operator=(const MString &v) - { - m_container->append(v); - return *this; - } - - MayaAppendIterator& operator=(const std::string &v) - { - m_container->append(v.c_str()); - return *this; - } - - MayaAppendIterator& operator*() - { - return *this; - } - - MayaAppendIterator& operator++() - { - return *this; - } - - MayaAppendIterator operator++(int) - { - return *this; - } - - protected: - MStringArray* m_container; - -}; - -template -inline MayaAppendIterator MArrayInserter(T& x) -{ - return MayaAppendIterator(x); -} - -} // namespace IECoreMaya - -#include "IECoreMaya/MArrayIter.inl" - -#endif // IE_MAYACORE_MARRAYITER_H diff --git a/include/IECoreMaya/MArrayIter.inl b/include/IECoreMaya/MArrayIter.inl deleted file mode 100644 index 5f1b2367a7..0000000000 --- a/include/IECoreMaya/MArrayIter.inl +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_MAYACORE_MARRAYITER_INL -#define IE_MAYACORE_MARRAYITER_INL - -namespace IECoreMaya -{ - -template -inline typename MArrayIter::Iterator MArrayIter::begin( T &array ) -{ - return &array[0]; -} - -template -inline typename MArrayIter::ConstIterator MArrayIter::begin( const T &array ) -{ - return &array[0]; -} - -template -inline typename MArrayIter::Iterator MArrayIter::end( T &array ) -{ - return &array[array.length()]; -} - -template -inline typename MArrayIter::ConstIterator MArrayIter::end( const T &array ) -{ - return &array[array.length()]; -} - -template -inline typename MArrayIter::ReverseIterator MArrayIter::reverseBegin( T &array ) -{ - return ReverseIterator( end( array ) ); -} - -template -inline typename MArrayIter::ConstReverseIterator MArrayIter::reverseBegin( const T &array ) -{ - return ConstReverseIterator( end( array ) ); -} - -template -inline typename MArrayIter::ReverseIterator MArrayIter::reverseEnd( T &array ) -{ - return ReverseIterator( begin( array ) ); -} - -template -inline typename MArrayIter::ConstReverseIterator MArrayIter::reverseEnd( const T &array ) -{ - return ConstReverseIterator( begin( array ) ); -} - -} // namespace IECoreMaya - -#endif // IE_MAYACORE_MARRAYITER_INL diff --git a/include/IECoreMaya/MArrayTraits.h b/include/IECoreMaya/MArrayTraits.h deleted file mode 100644 index 40a9a1f19c..0000000000 --- a/include/IECoreMaya/MArrayTraits.h +++ /dev/null @@ -1,251 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_MAYACORE_MARRAYTRAITS_H -#define IE_MAYACORE_MARRAYTRAITS_H - -#include "maya/MUintArray.h" -#include "maya/MUint64Array.h" -#include "maya/MStringArray.h" -#include "maya/MTimeArray.h" -#include "maya/MPlugArray.h" -#include "maya/MObjectArray.h" -#include "maya/MIntArray.h" -#include "maya/MFloatArray.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPathArray.h" -#include "maya/MColorArray.h" -#include "maya/MVectorArray.h" -#include "maya/MFloatVectorArray.h" -#include "maya/MPointArray.h" -#include "maya/MFloatPointArray.h" -#include "maya/MFnUInt64ArrayData.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MFnIntArrayData.h" -#include "maya/MFnDoubleArrayData.h" -#include "maya/MFnVectorArrayData.h" -#include "maya/MFnPointArrayData.h" - -namespace IECoreMaya -{ - -/// This traits class is useful for determining various bits -/// of information about the maya array types, for use in template -/// code. -template -struct MArrayTraits -{ - /// The type held in the array. - typedef void ValueType; - /// The type of the function set that - /// operates on the associated arraydata type. - /// Will be void if no such function set exists. - typedef void DataFn; - /// Returns the maya api type of the associated - /// arraydata type. Returns MFn::kInvalid if - /// no associated type exists. - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef unsigned int ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MUint64 ValueType; - typedef MFnUInt64ArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kUInt64ArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MString ValueType; - typedef MFnStringArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kStringArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MTime ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MPlug ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MObject ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef int ValueType; - typedef MFnIntArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kIntArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef float ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef double ValueType; - typedef MFnDoubleArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kDoubleArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MDagPath ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MColor ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MVector ValueType; - typedef MFnVectorArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kVectorArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MFloatVector ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MPoint ValueType; - typedef MFnPointArrayData DataFn; - static MFn::Type dataType() - { - return MFn::kPointArrayData; - }; -}; - -template<> -struct MArrayTraits -{ - typedef MFloatPoint ValueType; - typedef void DataFn; - static MFn::Type dataType() - { - return MFn::kInvalid; - }; -}; - -} // namespace IECoreMaya - -#endif // IE_MAYACORE_MARRAYTRAITS_H diff --git a/include/IECoreMaya/MDataHandleAccessor.h b/include/IECoreMaya/MDataHandleAccessor.h deleted file mode 100644 index 30bbc3c7c1..0000000000 --- a/include/IECoreMaya/MDataHandleAccessor.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MDATAHANDLEACCESSOR_H -#define IE_COREMAYA_MDATAHANDLEACCESSOR_H - -#include "boost/static_assert.hpp" - -#include "maya/MDataHandle.h" - -namespace IECoreMaya -{ - -/// A templated class to allow straight-forward access to data stored in MDataHandle objects. -/// The class is templated on the "raw" type of the data returned, e.g. "float", but in additional -/// the ReturnType typedef can be used to find out the exact type with any qualifiers on it. So, using -/// the same example, MDataHandleAccessor::ReturnType is "float&". This allows simplicity -/// of use, but also permits compatibility with boost::type_traits::is_reference, for more flexible -/// template code. -template< typename T > -struct MDataHandleAccessor -{ - BOOST_STATIC_ASSERT( sizeof( T ) == 0 ); - - typedef void ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - } -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/MDataHandleAccessor.inl" - -#endif // IE_COREMAYA_MDATAHANDLEACCESSOR_H diff --git a/include/IECoreMaya/MDataHandleAccessor.inl b/include/IECoreMaya/MDataHandleAccessor.inl deleted file mode 100644 index 2e8e8db254..0000000000 --- a/include/IECoreMaya/MDataHandleAccessor.inl +++ /dev/null @@ -1,342 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MDATAHANDLEACCESSOR_INL -#define IE_COREMAYA_MDATAHANDLEACCESSOR_INL - -#include "maya/MDataHandle.h" -#include "maya/MVector.h" -#include "maya/MFloatVector.h" -#include "maya/MMatrix.h" -#include "maya/MFloatMatrix.h" -#include "maya/MObject.h" -#include "maya/MTime.h" -#include "maya/MDistance.h" -#include "maya/MAngle.h" -#include "maya/MString.h" - -/// Specialisations of MDataHandleAccessor for the various return types -namespace IECoreMaya -{ - -template<> -struct MDataHandleAccessor< MObject > -{ - typedef MObject ReturnType; - - static ReturnType get( MDataHandle &h ) - { - return h.data(); - } -}; - -template<> -struct MDataHandleAccessor< bool > -{ - typedef bool &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asBool(); - } -}; - -template<> -struct MDataHandleAccessor< char > -{ - typedef char &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asChar(); - } -}; - -template<> -struct MDataHandleAccessor< unsigned char > -{ - typedef unsigned char &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asUChar(); - } -}; - -template<> -struct MDataHandleAccessor< short > -{ - typedef short &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asShort(); - } -}; - -template<> -struct MDataHandleAccessor< int > -{ - typedef int &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asInt(); - } -}; - -template<> -struct MDataHandleAccessor< void* > -{ - typedef void *&ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asAddr(); - } -}; - -template<> -struct MDataHandleAccessor< float > -{ - typedef float &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asFloat(); - } -}; - -template<> -struct MDataHandleAccessor< double > -{ - typedef double &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asDouble(); - } -}; - -template<> -struct MDataHandleAccessor< MDistance > -{ - typedef MDistance ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asDistance(); - } -}; - -template<> -struct MDataHandleAccessor< MAngle > -{ - typedef MAngle ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asAngle(); - } -}; - -template<> -struct MDataHandleAccessor< MTime > -{ - typedef MTime ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asTime(); - } -}; - -template<> -struct MDataHandleAccessor< short2 > -{ - typedef short2 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asShort2(); - } -}; - -template<> -struct MDataHandleAccessor< int2 > -{ - typedef int2 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asInt2(); - } -}; - -template<> -struct MDataHandleAccessor< float2 > -{ - typedef float2 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asFloat2(); - } -}; - -template<> -struct MDataHandleAccessor< double2 > -{ - typedef double2 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asDouble2(); - } -}; - -template<> -struct MDataHandleAccessor< short3 > -{ - typedef short3 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asShort3(); - } -}; - -template<> -struct MDataHandleAccessor< int3 > -{ - typedef int3 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asInt3(); - } -}; - -template<> -struct MDataHandleAccessor< float3 > -{ - typedef float3 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asFloat3(); - } -}; - -template<> -struct MDataHandleAccessor< double3 > -{ - typedef double3 &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asDouble3(); - } -}; - -template<> -struct MDataHandleAccessor< MVector > -{ - typedef MVector &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asVector(); - } -}; - -template<> -struct MDataHandleAccessor< MFloatVector > -{ - typedef MFloatVector &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asFloatVector(); - } -}; - -template<> -struct MDataHandleAccessor< MMatrix > -{ - typedef MMatrix &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asMatrix(); - } -}; - -template<> -struct MDataHandleAccessor< MFloatMatrix > -{ - typedef MFloatMatrix &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asFloatMatrix(); - } -}; - -template<> -struct MDataHandleAccessor< MString > -{ - typedef MString &ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asString(); - } -}; - -template<> -struct MDataHandleAccessor< MPxData * > -{ - typedef MPxData *ReturnType; - - static ReturnType get( const MDataHandle &h ) - { - return h.asPluginData(); - } -}; - -} // namespace IECoreMaya - - -#endif // IE_COREMAYA_MDATAHANDLEACCESSOR_INL diff --git a/include/IECoreMaya/MFloatPointTree.h b/include/IECoreMaya/MFloatPointTree.h deleted file mode 100644 index 1b261cfc37..0000000000 --- a/include/IECoreMaya/MFloatPointTree.h +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MFLOATPOINTTREE_H -#define IE_COREMAYA_MFLOATPOINTTREE_H - -#include "IECore/KDTree.h" - -#include "IECoreMaya/VectorTraits.h" - -#include "maya/MFloatPoint.h" - -namespace IECoreMaya -{ - -/// A KDTree typedef for use with the MFloatPoint point type. -typedef KDTree MPointTree; - -} // namespace IECoreMaya - - -#endif // IE_COREMAYA_MFLOATPOINTTREE_H diff --git a/include/IECoreMaya/MFloatVectorTree.h b/include/IECoreMaya/MFloatVectorTree.h deleted file mode 100644 index ead171347e..0000000000 --- a/include/IECoreMaya/MFloatVectorTree.h +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MFLOATVECTORTREE_H -#define IE_COREMAYA_MFLOATVECTORTREE_H - -#include "IECore/KDTree.h" - -#include "IECoreMaya/VectorTraits.h" - -#include "maya/MFloatVector.h" - -namespace IECoreMaya -{ - -/// A KDTree typedef for use with the MFloatVector point type. -typedef KDTree MFloatVectorTree; - -} // namespace IECoreMaya - - - -#endif // IE_COREMAYA_MFLOATVECTORTREE_H diff --git a/include/IECoreMaya/MFnDataTypeTraits.h b/include/IECoreMaya/MFnDataTypeTraits.h deleted file mode 100644 index aa644e270e..0000000000 --- a/include/IECoreMaya/MFnDataTypeTraits.h +++ /dev/null @@ -1,160 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_MAYACORE_MFNDATATYPETRAITS_H -#define IE_MAYACORE_MFNDATATYPETRAITS_H - -#include "maya/MFnData.h" - -#include "maya/MUintArray.h" -#include "maya/MUint64Array.h" -#include "maya/MStringArray.h" -#include "maya/MTimeArray.h" -#include "maya/MPlugArray.h" -#include "maya/MObjectArray.h" -#include "maya/MIntArray.h" -#include "maya/MFloatArray.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPathArray.h" -#include "maya/MColorArray.h" -#include "maya/MVectorArray.h" -#include "maya/MFloatVectorArray.h" -#include "maya/MPointArray.h" -#include "maya/MFloatPointArray.h" -#include "maya/MFnUInt64ArrayData.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MFnIntArrayData.h" -#include "maya/MFnDoubleArrayData.h" -#include "maya/MFnVectorArrayData.h" -#include "maya/MFnPointArrayData.h" - -namespace IECoreMaya -{ - -/// This traits class is useful for determining various bits -/// of information about the simple MFnData types, for use in template -/// code. -template -struct MFnDataTypeTraits -{ - /// The Maya value type - typedef void ValueType; - - /// The Dependecny Graph data type - static MFn::Type dataType() - { - return MFn::kInvalid; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MMatrix ValueType; - - static MFn::Type dataType() - { - return MFn::kMatrixData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MString ValueType; - - static MFn::Type dataType() - { - return MFn::kStringData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MStringArray ValueType; - - static MFn::Type dataType() - { - return MFn::kStringArrayData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MVectorArray ValueType; - - static MFn::Type dataType() - { - return MFn::kVectorArrayData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MPointArray ValueType; - - static MFn::Type dataType() - { - return MFn::kPointArrayData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MIntArray ValueType; - - static MFn::Type dataType() - { - return MFn::kIntArrayData; - } -}; - -template<> -struct MFnDataTypeTraits -{ - typedef MDoubleArray ValueType; - - static MFn::Type dataType() - { - return MFn::kDoubleArrayData; - } -}; - -} // namespace IECoreMaya - -#endif // IE_MAYACORE_MFNDATATYPETRAITS_H diff --git a/include/IECoreMaya/MImageAccessor.h b/include/IECoreMaya/MImageAccessor.h deleted file mode 100644 index 9a51090427..0000000000 --- a/include/IECoreMaya/MImageAccessor.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MIMAGEACCESSOR_H -#define IE_COREMAYA_MIMAGEACCESSOR_H - -#include "boost/static_assert.hpp" - -#include "maya/MImage.h" - -namespace IECoreMaya -{ - -/// A templated class to allow straight-forward access to pixel data stored in MImage instances. -/// The class is templated on the "raw" type of the data returned, e.g. "float", to retrieve -/// pixel data from an MImage of type MImage::kFloat, or "unsigned char" to retrieve pixel -/// data from an MImage of type MImage::kByte; -template< typename T > -struct MImageAccessor -{ - BOOST_STATIC_ASSERT( sizeof( T ) == 0 ); - - typedef void ReturnType; - - static ReturnType getPixels( MImage &i ) - { - } -}; - -} - -#include "IECoreMaya/MImageAccessor.inl" - -#endif // IE_COREMAYA_MIMAGEACCESSOR_H diff --git a/include/IECoreMaya/MImageAccessor.inl b/include/IECoreMaya/MImageAccessor.inl deleted file mode 100644 index 4e28fb8d10..0000000000 --- a/include/IECoreMaya/MImageAccessor.inl +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_IMAGEACCESSOR_INL -#define IE_COREMAYA_IMAGEACCESSOR_INL - -#include "maya/MDataHandle.h" -#include "maya/MVector.h" -#include "maya/MFloatVector.h" -#include "maya/MMatrix.h" -#include "maya/MFloatMatrix.h" -#include "maya/MObject.h" -#include "maya/MTime.h" -#include "maya/MDistance.h" -#include "maya/MAngle.h" -#include "maya/MString.h" - -/// Specialisations of MImageAccesor for the various pixel types -namespace IECoreMaya -{ - -template<> -struct MImageAccessor< float > -{ - typedef float* ReturnType; - - static ReturnType getPixels( MImage &i ) - { - return i.floatPixels(); - } -}; - -template<> -struct MImageAccessor< unsigned char > -{ - typedef unsigned char* ReturnType; - - static ReturnType getPixels( MImage &i ) - { - return i.pixels(); - } -}; - -} - -#endif // IE_COREMAYA_IMAGEACCESSOR_INL diff --git a/include/IECoreMaya/MPointTree.h b/include/IECoreMaya/MPointTree.h deleted file mode 100644 index 4850699932..0000000000 --- a/include/IECoreMaya/MPointTree.h +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MPOINTTREE_H -#define IE_COREMAYA_MPOINTTREE_H - -#include "IECore/KDTree.h" - -#include "IECoreMaya/VectorTraits.h" -#include "IECoreMaya/MArrayIter.h" - -namespace IECoreMaya -{ - -/// A KDTree typedef for use with the MPoint point type. -typedef IECore::KDTree::ConstIterator> MPointTree; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_MPOINTTREE_H diff --git a/include/IECoreMaya/MStringLess.h b/include/IECoreMaya/MStringLess.h deleted file mode 100644 index 78275ecda9..0000000000 --- a/include/IECoreMaya/MStringLess.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MSTRINGLESS_H -#define IE_COREMAYA_MSTRINGLESS_H - -#include "maya/MString.h" - -namespace std -{ - -/// A specialisation of less<> for MString, allowing it to be easily -/// used as the key in std::map (and a bunch of other places too no doubt). -/// Doing things in the std namespace does seem a little iffy but we're only -/// specialising for a type which has nothing to do with the std, so I -/// don't see how it can be bad. -template<> -struct less : binary_function -{ - bool operator()( const MString &a, const MString &b ) const - { - return strcmp( a.asChar(), b.asChar() ) < 0; - } -}; - -} // namespace std - -#endif // IE_COREMAYA_MSTRINGLESS_H diff --git a/include/IECoreMaya/MVectorTree.h b/include/IECoreMaya/MVectorTree.h deleted file mode 100644 index 376f02d633..0000000000 --- a/include/IECoreMaya/MVectorTree.h +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MVECTORTREE_H -#define IE_COREMAYA_MVECTORTREE_H - -#include "IECore/KDTree.h" - -#include "IECoreMaya/VectorTraits.h" -#include "IECoreMaya/MArrayIter.h" - -namespace IECoreMaya -{ - -/// A KDTree typedef for use with the MVector point type. -typedef IECore::KDTree::ConstIterator> MVectorTree; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_MVECTORTREE_H diff --git a/include/IECoreMaya/MatrixTraits.h b/include/IECoreMaya/MatrixTraits.h deleted file mode 100644 index b24093fc0e..0000000000 --- a/include/IECoreMaya/MatrixTraits.h +++ /dev/null @@ -1,66 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MATRIXTRAITS_H -#define IE_COREMAYA_MATRIXTRAITS_H - -#include "IECore/MatrixTraits.h" - -#include "maya/MMatrix.h" -#include "maya/MFloatMatrix.h" - -namespace IECore -{ - -template<> -struct MatrixTraits -{ - typedef double BaseType; - static unsigned int dimensions() { return 4; }; - static BaseType get( const MMatrix &v, unsigned int i, unsigned int j ) { return v[i][j]; }; - static void set( MMatrix &v, unsigned int i, unsigned int j, BaseType x ) { v[i][j] = x; }; -}; - -template<> -struct MatrixTraits -{ - typedef float BaseType; - static unsigned int dimensions() { return 4; }; - static BaseType get( const MFloatMatrix &v, unsigned int i, unsigned int j ) { return v[i][j]; }; - static void set( MFloatMatrix &v, unsigned int i, unsigned int j, BaseType x ) { v[i][j] = x; }; -}; - -} // namespace IECore - -#endif // IE_COREMAYA_MATRIXTRAITS_H diff --git a/include/IECoreMaya/MayaMeshBuilder.h b/include/IECoreMaya/MayaMeshBuilder.h deleted file mode 100644 index 96ce6a8e9f..0000000000 --- a/include/IECoreMaya/MayaMeshBuilder.h +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -#ifndef IE_COREMAYA_MAYAMESHBUILDER_H -#define IE_COREMAYA_MAYAMESHBUILDER_H - -#include - -#include "maya/MObject.h" -#include "maya/MFnMesh.h" - -#include "IECore/RefCounted.h" -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// MayaMeshBuilder is a class which allows construction of Maya mesh data, templated -/// on the base type of the resulting point/normal data (e.g. float or double). -template -class IECOREMAYA_API MayaMeshBuilder : public IECore::RefCounted -{ - public: - - typedef T BaseType; - - IE_CORE_DECLAREMEMBERPTR( MayaMeshBuilder ) - - MayaMeshBuilder( MObject parentOrOwner ); - virtual ~MayaMeshBuilder(); - - /// Add a vertex position and normal - void addVertex( const Imath::Vec3 &p, const Imath::Vec3 &n ); - - /// Construct a triangle from the 3 specified vertex indices - void addTriangle( int v0, int v1, int v2 ); - - /// Retrieve the resultant mesh as MFnMeshData - MObject mesh() const; - - protected: - MObject m_parentOrOwner; - - struct Data; - - Data *m_data; - -}; - -} - -#include "IECoreMaya/MayaMeshBuilder.inl" - -#endif // IE_COREMAYA_MAYAMESHBUILDER_H diff --git a/include/IECoreMaya/MayaMeshBuilder.inl b/include/IECoreMaya/MayaMeshBuilder.inl deleted file mode 100644 index 798cbb98a0..0000000000 --- a/include/IECoreMaya/MayaMeshBuilder.inl +++ /dev/null @@ -1,141 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MPointArray.h" -#include "maya/MVectorArray.h" -#include "maya/MIntArray.h" -#include "maya/MFloatPointArray.h" -#include "maya/MFloatVectorArray.h" -#include "maya/MFnMesh.h" -#include "maya/MFnMeshData.h" - -#include "IECoreMaya/StatusException.h" - -namespace IECoreMaya -{ -template<> -struct MayaMeshBuilder::Data -{ - MPointArray m_P; - MVectorArray m_N; - MIntArray m_verticesPerFace; - MIntArray m_vertexIds; -}; - -template<> -struct MayaMeshBuilder::Data -{ - MFloatPointArray m_P; - MVectorArray m_N; - MIntArray m_verticesPerFace; - MIntArray m_vertexIds; -}; - -template -MayaMeshBuilder::MayaMeshBuilder( MObject parentOrOwner ) : m_parentOrOwner( parentOrOwner ) -{ - m_data = new Data(); - -} - -template -MayaMeshBuilder::~MayaMeshBuilder() -{ - delete m_data; -} - - -template<> -inline void MayaMeshBuilder::addVertex( const Imath::V3f &p, const Imath::V3f &n ) -{ - m_data->m_P.append( MFloatPoint( p.x, p.y, p.z ) ); - m_data->m_N.append( MFloatVector( n.x, n.y, n.z ) ); -} - -template<> -inline void MayaMeshBuilder::addVertex( const Imath::V3d &p, const Imath::V3d &n ) -{ - m_data->m_P.append( MPoint( p.x, p.y, p.z ) ); - m_data->m_N.append( MVector( n.x, n.y, n.z ) ); -} - -template -inline void MayaMeshBuilder::addTriangle( int v0, int v1, int v2 ) -{ - m_data->m_verticesPerFace.append( 3 ); - - m_data->m_vertexIds.append( v0 ); - m_data->m_vertexIds.append( v1 ); - m_data->m_vertexIds.append( v2 ); -} - -template -inline MObject MayaMeshBuilder::mesh() const -{ - MStatus s; - MFnMesh fnMesh; - - MObject result = fnMesh.create( - m_data->m_P.length(), - m_data->m_verticesPerFace.length(), - m_data->m_P, - m_data->m_verticesPerFace, - m_data->m_vertexIds, - m_parentOrOwner, - &s - ); - - if (!s) - { - throw StatusException( s ); - } - assert( result != MObject::kNullObj ); - - MIntArray vertexList; - for (unsigned i = 0; i < m_data->m_N.length(); ++i) - { - vertexList.append( i ); - } - - fnMesh.setVertexNormals( - m_data->m_N, - vertexList - ); - - return m_parentOrOwner; -} - -} diff --git a/include/IECoreMaya/MayaTime.h b/include/IECoreMaya/MayaTime.h deleted file mode 100644 index 30738be3e5..0000000000 --- a/include/IECoreMaya/MayaTime.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MAYATIME_H -#define IE_COREMAYA_MAYATIME_H - -#include "maya/MTime.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ -/// A convertion class for Maya MTime::Unit to/from FPS. -class IECOREMAYA_API MayaTime -{ - public: - static double fps( MTime::Unit unit ); - static MTime::Unit unit( double fps ); - - private: - - typedef struct { - MTime::Unit unit; - double fps; - } TimeTable; - - static TimeTable m_table[]; -}; -} - -#endif // IE_COREMAYA_MAYATIME_H diff --git a/include/IECoreMaya/MayaTypeIds.h b/include/IECoreMaya/MayaTypeIds.h deleted file mode 100644 index 82223ab78e..0000000000 --- a/include/IECoreMaya/MayaTypeIds.h +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MAYATYPEIDS_H -#define IECOREMAYA_MAYATYPEIDS_H - -namespace IECoreMaya -{ - -/// An enum for all the MTypeId values used by -/// the nodes and datatypes of IECoreMaya. Note that these -/// are maya type ids and are distinct from the IECore::TypeId -/// enumeration. The range here was obtained by Andrew Chapman -/// and is set aside specifically for the Cortex project. -enum MayaTypeId -{ - - CacheSetId = 0x00110DC0, - ObjectDataId = 0x00110DC1, - ParameterisedHolderLocatorId = 0x00110DC2, - ParameterisedHolderDeformerId = 0x00110DC3, - ParameterisedHolderFieldId = 0x00110DC4, - ParameterisedHolderSetId = 0x00110DC5, - OpHolderNodeId = 0x00110DC6, - ConverterHolderId = 0x00110DC7, - ParameterisedHolderSurfaceShapeId = 0x00110DC8, - ParameterisedHolderComponentShapeId = 0x00110DC9, - ParameterisedHolderNodeId = 0x00110DCA, - ProceduralHolderId = 0x00110DCB, // Obsolete - TransientParameterisedHolderNodeId = 0x00110DCC, - ParameterisedHolderImagePlaneId = 0x00110DCD, - ImagePlaneHolderId = 0x00110DCE, - CurveCombinerId = 0x00110DCF, - DummyDataId = 0x00110DD0, - DrawableHolderId = 0x00110DD1, - GeometryCombinerId = 0x00110DD2, - SceneShapeId = 0x00110DD3, - SceneShapeInterfaceId = 0x00110DD4, - SceneShapeProxyId = 0x00110DD5, - /// Don't forget to update MayaTypeIdsBinding.cpp - - LastId = 0x00110E3F, - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_MAYATYPEIDS_H diff --git a/include/IECoreMaya/MeshParameterHandler.h b/include/IECoreMaya/MeshParameterHandler.h deleted file mode 100644 index 5be12d8845..0000000000 --- a/include/IECoreMaya/MeshParameterHandler.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MESHPARAMETERHANDLER_H -#define IE_COREMAYA_MESHPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with polygon meshes -class IECOREMAYA_API MeshParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_MESHPARAMETERHANDLER_H diff --git a/include/IECoreMaya/MessageHandler.h b/include/IECoreMaya/MessageHandler.h deleted file mode 100644 index 4ee8e540e3..0000000000 --- a/include/IECoreMaya/MessageHandler.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MESSAGEHANDLER_H -#define IE_COREMAYA_MESSAGEHANDLER_H - -#include "IECore/MessageHandler.h" - -#include "IECoreMaya/Export.h" - -#include - -namespace IECoreMaya -{ - -class IECOREMAYA_API MessageHandler : public IECore::MessageHandler -{ - - public : - - IE_CORE_DECLAREMEMBERPTR( MessageHandler ); - - virtual void handle( Level level, const std::string &context, const std::string &message ); - - private : - - typedef std::mutex MsgMutex; - mutable MsgMutex m_mutex; - -}; - -IE_CORE_DECLAREPTR( MessageHandler ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_MESSAGEHANDLER_H diff --git a/include/IECoreMaya/NumericParameterHandler.h b/include/IECoreMaya/NumericParameterHandler.h deleted file mode 100644 index d0edcfc974..0000000000 --- a/include/IECoreMaya/NumericParameterHandler.h +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_NUMERICPARAMETERHANDLER_H -#define IE_COREMAYA_NUMERICPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with simple numeric types; int, float, double -template -class IECOREMAYA_API NumericParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_NUMERICPARAMETERHANDLER_H diff --git a/include/IECoreMaya/NumericTraits.h b/include/IECoreMaya/NumericTraits.h deleted file mode 100644 index 799be3e6a6..0000000000 --- a/include/IECoreMaya/NumericTraits.h +++ /dev/null @@ -1,129 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_NUMERICTRAITS_H -#define IE_COREMAYA_NUMERICTRAITS_H - -#include "boost/static_assert.hpp" - -#include "maya/MFnNumericData.h" -#include "Imath/ImathVec.h" -#include "Imath/ImathColor.h" - -namespace IECoreMaya -{ - -/// This traits class is useful for determining the appropriate maya -/// types to use for the basic numeric types in different contexts. -template -struct NumericTraits -{ - /// Returns the maya data type suitable for representing this type of number. - static MFnNumericData::Type dataType() - { - BOOST_STATIC_ASSERT( sizeof(T) == 0 ); - return MFnNumericData::kInvalid; - } - - /// For compound numeric types, returns the maya data type suitable for representing - /// a single element of the compound. - static MFnNumericData::Type baseDataType() - { - BOOST_STATIC_ASSERT( sizeof(T) == 0 ); - return MFnNumericData::kInvalid; - } - - /// Returns whether or not the maya useAsColor() flag should be set on attributes - /// representing this kind of data. - static bool isColor() - { - return false; - } -}; - -template<> -MFnNumericData::Type NumericTraits::dataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); - -template<> -MFnNumericData::Type NumericTraits::dataType(); -template<> -MFnNumericData::Type NumericTraits::baseDataType(); -template<> -bool NumericTraits::isColor(); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_NUMERICTRAITS_H diff --git a/include/IECoreMaya/ObjectData.h b/include/IECoreMaya/ObjectData.h deleted file mode 100644 index 153cba6240..0000000000 --- a/include/IECoreMaya/ObjectData.h +++ /dev/null @@ -1,112 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_OBJECTDATA_H -#define IE_COREMAYA_OBJECTDATA_H - -#include "IECore/Object.h" - -#include "IECoreMaya/Export.h" - -#include "maya/MArgList.h" -#include "maya/MPxData.h" -#include "maya/MString.h" -#include "maya/MTypeId.h" - -namespace IECoreMaya -{ - -/// A Maya data type to hold IECore::Objects, allowing them to participate in the Dependency Graph. -/// \todo Perhaps offer this as a template instead, to allow specific classes of objects to be held -/// in their own data type entirely. Maya would then prevent connection between incompatible -/// types. -class IECOREMAYA_API ObjectData : public MPxData -{ - public: - - enum CopyMode - { - Shallow, - Deep - }; - - ObjectData(); - virtual ~ObjectData(); - - static void* creator(); - - virtual MStatus readASCII( const MArgList &argList, unsigned int &endOfTheLastParsedElement ); - virtual MStatus readBinary( istream &in, unsigned length ); - virtual MStatus writeASCII( ostream &out ); - virtual MStatus writeBinary( ostream &out ); - - /// The behaviour of this function is defined by the current copy mode of source. - virtual void copy( const MPxData &source ); - virtual MTypeId typeId() const; - virtual MString name() const; - - static const MString typeName; - static const MTypeId id; - - /// Controls how the copy() method behaves when this object is the source - /// for the copy. When in Shallow mode - /// an ObjectData copy will point to the same Object that the original - /// pointed to. When in Deep mode, the copy will point to a copy() of - /// the original Object. The copied ObjectData inherits the copy mode - /// from the original. The default copy mode for all new instances of - /// ObjectData is Deep. - void setCopyMode( CopyMode mode ); - /// Returns the current copy mode. - CopyMode getCopyMode() const; - - /// Returns the object held by this instance - note that this is not - /// a copy so you should be careful not to cause unwanted side effects - /// through modification. - IECore::ObjectPtr getObject(); - IECore::ConstObjectPtr getObject() const; - /// Sets the object held by this instance - note that a copy is not - /// taken, so any subsequent modification of object directly affects this - /// ObjectData. - void setObject( IECore::ObjectPtr object ); - - protected: - - CopyMode m_copyMode; - IECore::ObjectPtr m_object; - -}; - -} - -#endif // IE_COREMAYA_OBJECTDATA_H diff --git a/include/IECoreMaya/ObjectMFnDataParameterHandler.h b/include/IECoreMaya/ObjectMFnDataParameterHandler.h deleted file mode 100644 index 429b5e5ce0..0000000000 --- a/include/IECoreMaya/ObjectMFnDataParameterHandler.h +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_OBJECTMFNDATAPARAMETERHANDLER_H -#define IE_COREMAYA_OBJECTMFNDATAPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MPlug.h" -#include "maya/MFnData.h" - -namespace IECoreMaya -{ - -/// An ObjectParameterHandler which deals with types supported by MFnData -/// Template parameter T represents the Parameter type (e.g V3fVectorParameter) -/// Template parameter D represents the MFnData::Type (e.g. MFnData::kVectorArray) -template -class IECOREMAYA_API ObjectMFnDataParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_OBJECTMFNDATAPARAMETERHANDLER_H diff --git a/include/IECoreMaya/ObjectParameterHandler.h b/include/IECoreMaya/ObjectParameterHandler.h deleted file mode 100644 index 7cc9d1eb7b..0000000000 --- a/include/IECoreMaya/ObjectParameterHandler.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_OBJECTPARAMETERHANDLER_H -#define IE_COREMAYA_OBJECTPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -class IECOREMAYA_API ObjectParameterHandler : public ParameterHandler -{ - - public : - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_OBJECTPARAMETERHANDLER_H diff --git a/include/IECoreMaya/ObjectVectorParameterHandler.h b/include/IECoreMaya/ObjectVectorParameterHandler.h deleted file mode 100644 index 8bf9d474bc..0000000000 --- a/include/IECoreMaya/ObjectVectorParameterHandler.h +++ /dev/null @@ -1,58 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_OBJECTVECTORPARAMETERHANDLER_H -#define IECOREMAYA_OBJECTVECTORPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler for the ObjectVectorParameter. -class IECOREMAYA_API ObjectVectorParameterHandler : public ParameterHandler -{ - - protected: - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_OBJECTVECTORPARAMETERHANDLER_H diff --git a/include/IECoreMaya/OpHolder.h b/include/IECoreMaya/OpHolder.h deleted file mode 100644 index d945f2f2cf..0000000000 --- a/include/IECoreMaya/OpHolder.h +++ /dev/null @@ -1,85 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_OPHOLDER_H -#define IE_COREMAYA_OPHOLDER_H - -#include "IECore/Op.h" - -#include "IECoreMaya/ParameterisedHolder.h" - -namespace IECoreMaya -{ - -/// The OpHolder class presents op parameters as maya attributes, evaluating the result -/// of the Op within compute() when appropriate. -template< typename BaseType > -class IECOREMAYA_API OpHolder : public ParameterisedHolder -{ - - public: - - OpHolder(); - virtual ~OpHolder(); - - static void *creator(); - static MStatus initialize(); - static MTypeId id; - - virtual MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ); - - virtual MStatus compute( const MPlug &plug, MDataBlock &block ); - - virtual MStatus setParameterised( IECore::RunTimeTypedPtr p ); - virtual IECore::RunTimeTypedPtr getParameterised( std::string *className = 0, int *classVersion = 0, std::string *searchPathEnvVar = 0 ); - - virtual MStatus setOp( const std::string &className, int classVersion ); - virtual IECore::OpPtr getOp( std::string *className = 0, int *classVersion = 0, std::string *searchPathEnvVar = 0 ); - - private : - - static MObject aResultDependency; - - IE_CORE_FORWARDDECLARE( PostLoadCallback ); - PostLoadCallbackPtr m_postLoadCallback; - - MStatus createResultAttribute(); - -}; - -typedef OpHolder OpHolderNode; - -} - -#endif // IE_COREMAYA_OPHOLDER_H diff --git a/include/IECoreMaya/ParameterHandler.h b/include/IECoreMaya/ParameterHandler.h deleted file mode 100644 index b06a8fa76c..0000000000 --- a/include/IECoreMaya/ParameterHandler.h +++ /dev/null @@ -1,140 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_PARAMETERHANDLER_H -#define IE_COREMAYA_PARAMETERHANDLER_H - -#include - -#include "IECore/RefCounted.h" -#include "IECore/TypeIds.h" -#include "IECore/Object.h" -#include "IECore/Parameter.h" - -#include "IECoreMaya/Export.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -class ParameterHandler; -IE_CORE_DECLAREPTR( ParameterHandler ); - -/// The ParameterHandler class provides a mapping between IECore::Parameters and maya attributes. It -/// is used by the IECoreMaya::ParameterisedHolder classes. -class IECOREMAYA_API ParameterHandler : public IECore::RefCounted -{ - - public : - - /// Creates and returns an MPlug capable of representing the specified parameter. - /// The plug will have the specified name and be added to the specified node. - /// In the case of a failure MPlug::isNull() will be true for the return value. - /// \todo: return an MStatus like the other methods, and pass a plug reference as an argument (Cortex 8) - static MPlug create( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ); - /// Updates a previously created plug to reflect changes on the specified parameter. - /// Returns MStatus::kFailure if the plug is not suitable for the parameter. - /// \bug Maya doesn't seem to correctly store default values for dynamic string attributes - /// when saving the scene - so this method doesn't set the default value appropriately for - /// StringParameter and its derived classes (tested in maya 7.0.1). - static MStatus update( IECore::ConstParameterPtr parameter, MPlug &plug ); - /// Sets the value of plug to reflect the value of parameter. - static MStatus setValue( IECore::ConstParameterPtr parameter, MPlug &plug ); - /// Sets the value of parameter to reflect the value of plug. - static MStatus setValue( const MPlug &plug, IECore::ParameterPtr parameter ); - /// Called to restore a parameter's properties when a file is loaded or the version of a held class - /// has been updated. - static MStatus restore( const MPlug &plug, IECore::ParameterPtr parameter ); - - virtual ~ParameterHandler(); - - template - struct Description - { - /// Declare a static instance to register a parameter handler. Pass the type of parameter handled and, - /// optionally, the type of the data contained within the parameter. This allows, for example, ObjectParameter - /// to find handlers based on the typeIds of objects it can contain. - Description( IECore::TypeId parameterType, IECore::TypeId dataType = IECore::InvalidTypeId); - }; - - protected: - - friend class ObjectParameterHandler; - - /// Return a handler which can deal with the given parameter - static ConstParameterHandlerPtr create( IECore::ConstParameterPtr parameter ); - /// Return a handler which can deal with the given object - static ConstParameterHandlerPtr create( IECore::ConstObjectPtr object ); - /// Return a handler which can deal with an object or parameter of the given type id - static ConstParameterHandlerPtr create( IECore::TypeId id ); - - /// Performs common actions which all handlers should apply to newly created plugs, including - /// creating any default connections requested in the parameter userData. This function should - /// be called at the end of all doCreate() implementations. - MPlug finishCreating( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - /// An overload for the above function which accepts an attribute for which a plug needs to be made. - MPlug finishCreating( IECore::ConstParameterPtr parameter, MObject &attribute, MObject &node ) const; - - /// Performs common actions which all handlers should apply to updated plugs, including - /// the setting of any Attribute properties as requested in the parameter userData. - /// Currently, only 'storable' is supported. - /// This function should be called at the end of all doUpdate() implementations, and doCreate() - /// if doUpdate() isn't called as part of doCreate() - MStatus finishUpdating( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - /// An overload for the above function which accepts an attribute for which a plug needs to be made. - MStatus finishUpdating( IECore::ConstParameterPtr parameter, MObject &attribute, MObject &node ) const; - - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const = 0; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const = 0; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const = 0; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const = 0; - virtual MStatus doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private: - - static void registerHandler( IECore::TypeId parameterType, IECore::TypeId dataType, ConstParameterHandlerPtr handler ); - - typedef std::map HandlerMap; - - static HandlerMap &handlers(); -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/ParameterHandler.inl" - -#endif // IE_COREMAYA_PARAMETERHANDLER_H diff --git a/include/IECoreMaya/ParameterHandler.inl b/include/IECoreMaya/ParameterHandler.inl deleted file mode 100644 index 0bf121fced..0000000000 --- a/include/IECoreMaya/ParameterHandler.inl +++ /dev/null @@ -1,44 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -namespace IECoreMaya -{ - -template -ParameterHandler::Description::Description( IECore::TypeId parameterType, IECore::TypeId dataType ) -{ - ParameterHandler::registerHandler( parameterType, dataType, new T() ); -} - -} // namespace IECoreMaya diff --git a/include/IECoreMaya/ParameterManipContainer.h b/include/IECoreMaya/ParameterManipContainer.h deleted file mode 100644 index 81f296397c..0000000000 --- a/include/IECoreMaya/ParameterManipContainer.h +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_PARAMETERMANIPCONTAINER_H -#define IECOREMAYA_PARAMETERMANIPCONTAINER_H - -#include -#include -#include - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// This class should be used as a base class for any custom -/// manipulators designed to operate on IECore::Parameters. -/// When used in conjunction with the ParameterisedHolderManipContext, -/// it ensures that the manipulator knows which MPlug it is meant -/// to target, and any Parameter defined labeling is also -/// transferred. -class IECOREMAYA_API ParameterManipContainer : public MPxManipContainer -{ - public: - - ParameterManipContainer(); - - /// Called by ParameterisedHolderManipContext right before - /// connectToDependNode(), to set the MPlug that the user is - /// wishing to manipulate. - void setPlug( MPlug &plug ); - - /// \return The MPlug that the manipulator is currently set - /// to operate on. - MPlug getPlug(); - - /// Called by ParameterisedHolderManipContext right before - /// connectToDependNode() if a custom manipulator label has - /// been defined in the Parameters userData(). - void setLabel( MString &label ); - - /// \return The custom label for the manipulator, if one has - /// been set. - MString getLabel(); - - protected: - - /// To be used in derived classes to determine which plug - /// the user is interested in manipulating. - MPlug m_plug; - - /// This label may be set by certain parameters, it is up to - /// the derived classes to display it, or not... - MString m_label; -}; - -} - -#endif // IECOREMAYA_PARAMETERMANIPCONTAINER_H diff --git a/include/IECoreMaya/ParameterisedHolder.h b/include/IECoreMaya/ParameterisedHolder.h deleted file mode 100644 index 816b958aa4..0000000000 --- a/include/IECoreMaya/ParameterisedHolder.h +++ /dev/null @@ -1,192 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_PARAMETERISEDHOLDER_H -#define IE_COREMAYA_PARAMETERISEDHOLDER_H - -#include - -#if MAYA_API_VERSION >= 201800 -#else -class MPxNode; -class MPxLocatorNode; -class MPxDeformerNode; -class MPxObjectSet; -class MPxFieldNode; -class MPxSurfaceShape; -class MPxComponentShape; -class MPxImagePlane; -#endif - -#include "IECore/Parameterised.h" - -#include "IECoreMaya/Export.h" -#include "IECoreMaya/ParameterisedHolderInterface.h" -#include "IECoreMaya/MStringLess.h" -#include "IECoreMaya/PostLoadCallback.h" - -namespace IECoreMaya -{ - -/// A base class from which nodes to hold IECore::Parameterised objects -/// should derive (for example, Maya RI procedurals). It's templated -/// to allow inheritance from any Maya proxy. -/// -/// This class represents the hierarchy of parameters in a flattened form -/// using name munging to generate unique names for the maya attributes. We -/// would much rather it used maya compound attributes to maintain the hierarchy -/// but this is problematic - it seems the maya api doesn't implement the -/// on the fly modification of compound attributes after they've been added to a -/// node, and that is required by a series of changing calls to setParameterised(). -/// Maya also requires the names of children of nested compounds to be unique to -/// the node anyway, forcing a name munging approach even in the case that compound -/// usage was possible. -template< typename BaseType > -class IECOREMAYA_API ParameterisedHolder : public BaseType, public ParameterisedHolderInterface -{ - - public: - - ParameterisedHolder(); - virtual ~ParameterisedHolder(); - - static void *creator(); - static MStatus initialize(); - - /// This is a template class instantiated into many different - /// classes, so we specialise these in the implementation. - static MTypeId id; - static MString typeName; - - void postConstructor() override; - MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) override; - MStatus shouldSave( const MPlug &plug, bool &isSaving ) override; - - //! @name ParameterisedHolderInterface implementation - ///////////////////////////////////////////////////////////////////////////////////////// - //@{ - /// Set the node to hold a particular Parameterised object. When using this version - /// of setParameterised the node will not be able to preserve the object across scene - /// save/load - this becomes your responsibility if it's necessary. - virtual MStatus setParameterised( IECore::RunTimeTypedPtr p ); - virtual MStatus setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ); - virtual MStatus updateParameterised(); - virtual IECore::RunTimeTypedPtr getParameterised( std::string *className = 0, int *classVersion = 0, std::string *searchPathEnvVar = 0 ); - virtual MStatus setNodeValues(); - virtual MStatus setNodeValue( IECore::ParameterPtr pa ); - virtual MStatus setParameterisedValues(); - virtual MStatus setParameterisedValue( IECore::ParameterPtr pa ); - virtual MPlug parameterPlug( IECore::ConstParameterPtr parameter ); - virtual IECore::ParameterPtr plugParameter( const MPlug &plug ); - //@} - - //! @name Attributes - ///////////////////////////////////////////////////////////////////////////////////////// - static MObject aParameterisedClassName; - static MObject aParameterisedVersion; - static MObject aParameterisedSearchPathEnvVar; - //@} - - protected : - - /// As for setParameterisedValues(), but when lazy==true, the work is only done for parameters whose - /// plug value has changed since the last time the value was set. - MStatus setParameterisedValues( bool lazy ); - /// Creates an attribute to represent the specified parameter, or updates an existing attribute. - MStatus createOrUpdateAttribute( IECore::ParameterPtr parameter, const MString &attributeName, bool callRestore=false ); - - private: - - IECore::RunTimeTypedPtr loadClass( const MString &className, int classVersion, const MString &searchPathEnvVar ); - - /// Creates (or updates existing) attributes for each parameter. Removes any old attributes no longer - /// needed. - MStatus createAndRemoveAttributes( bool callRestore = false ); - // Makes (or updates existing) attributes for each parameter. Also fills in the two maps below. - // This method is called by getParameterised(), so you should call that before expecting the maps - // to be up to date. - MStatus createAttributesWalk( IECore::ConstCompoundParameterPtr parameter, const std::string &rootName, bool callRestore ); - typedef std::map ParameterToAttributeNameMap; - ParameterToAttributeNameMap m_parametersToAttributeNames; - typedef std::map AttributeNameToParameterMap; - AttributeNameToParameterMap m_attributeNamesToParameters; - - MStatus removeUnecessaryAttributes(); - - void nonNetworkedConnections( const MPlug &plug, MPlugArray &connectionsFromPlug, MPlugArray &connectionsToPlug ) const; - - typedef std::set ParameterSet; - /// Parameters for which the node value has changed since the last time they were set. - ParameterSet m_dirtyParameters; - - bool setParameterisedValuesWalk( bool lazy, IECore::ParameterPtr parameter, MStatus &status ); - - // We use this callback to instantiate the held Parameterised object once a scene had loaded. - // We need to do it at this point as things like the OpHolder need it in place before compute() - // is called (we can't instantiate it during compute as it may mean adding or removing attributes). - class PLCB : public PostLoadCallback - { - public: - PLCB( ParameterisedHolder *node ); - protected: - - ParameterisedHolder *m_node; - - void postLoad(); - }; - IE_CORE_DECLAREPTR( PLCB ); - - PLCBPtr m_plcb; - - protected : - - IECore::RunTimeTypedPtr m_parameterised; - bool m_failedToLoad; // to avoid constantly trying to reload things that aren't there - - static const std::string g_attributeNamePrefix; // a prefix used to denote attributes that represent parameters - -}; - -typedef ParameterisedHolder ParameterisedHolderNode; -typedef ParameterisedHolder ParameterisedHolderLocator; -typedef ParameterisedHolder ParameterisedHolderDeformer; -typedef ParameterisedHolder ParameterisedHolderField; -typedef ParameterisedHolder ParameterisedHolderSet; -typedef ParameterisedHolder ParameterisedHolderSurfaceShape; -typedef ParameterisedHolder ParameterisedHolderComponentShape; -typedef ParameterisedHolder ParameterisedHolderImagePlane; - -} - -#endif // IE_COREMAYA_PARAMETERISEDHOLDERNODE_H diff --git a/include/IECoreMaya/ParameterisedHolderInterface.h b/include/IECoreMaya/ParameterisedHolderInterface.h deleted file mode 100644 index a5b0e99c31..0000000000 --- a/include/IECoreMaya/ParameterisedHolderInterface.h +++ /dev/null @@ -1,107 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_PARAMETERISEDHOLDERINTERFACE_H -#define IE_COREMAYA_PARAMETERISEDHOLDERINTERFACE_H - -#include "maya/MPxNode.h" - -#include "IECore/Parameterised.h" -#include "IECore/Parameter.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// A base class from which nodes to hold IECore::ParameterisedInterface objects -/// should multiply inherit (for example, Maya RI procedurals). -class IECOREMAYA_API ParameterisedHolderInterface -{ - - public: - - ParameterisedHolderInterface(); - virtual ~ParameterisedHolderInterface(); - - /// Sets the Parameterised object this node is holding. An IECore.ClassLoader object will be - /// used with searchpaths obtained from the specified environment variable to actually load - /// the Parameterised object. This mechanism is used rather than passing a ParameterisedPtr - /// as it allows the Parameterised object to be loaded again when a maya scene is opened. - virtual MStatus setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ) = 0; - /// Sets the Parameterised object this node is holding, directly. - virtual MStatus setParameterised( IECore::RunTimeTypedPtr p ) = 0; - /// Updates this object to represent any changes in the held parameters. It is the responsibility of the caller - /// to ensure that there is some means of preserving these changes across file save/open if this is desired - the - /// ClassParameterHandler provides an example of doing this. - virtual MStatus updateParameterised() = 0; - /// Returns the held Parameterised object, loading it if necessary. May return 0 if loading - /// fails. Note that this doesn't update the values of the parameters - you can use the - /// separate setParameterisedValues() call for that. If provided, the optional className, - /// classVersion and searchPathEnvVar are updated to reflect the last values passed to - /// setParameterised - in the case of a 0 return value these values are left unchanged. - virtual IECore::RunTimeTypedPtr getParameterised( std::string *className = 0, int *classVersion = 0, std::string *searchPathEnvVar = 0 ) = 0; - /// Convenience method to return dynamic_cast( getParameterised().get() ) - IECore::ParameterisedInterface *getParameterisedInterface(); - /// \todo Remove version with no arguments and default className to 0 as well. - IECore::ParameterisedInterface *getParameterisedInterface( std::string *className, int *classVersion = 0, std::string *searchPathEnvVar = 0 ); - /// Sets the attributes of the node to reflect the current values - /// of the parameters in the held Parameterised object. Performs validation - /// of the parameter values and will return kFailure if any one is not valid. - virtual MStatus setNodeValues() = 0; - /// Sets the attribute of the node to reflect the current value - /// of the specified parameter in the held Parameterised object. Performs validation - /// of the parameter values and will return kFailure if any one is not valid. - virtual MStatus setNodeValue( IECore::ParameterPtr pa ) = 0; - /// Sets the values of the parameters of the held Parameterised object - /// to reflect the values of the attributes of the node. Performs validation - /// of the parameter values and will return kFailure if any one in not valid. - virtual MStatus setParameterisedValues() = 0; - /// Sets the value of the specified parameter of the held Parameterised object - /// to reflect the value of the corresponding attribute on the node. Performs validation - /// of the parameter values and will return kFailure if any one in not valid. - virtual MStatus setParameterisedValue( IECore::ParameterPtr pa ) = 0; - /// Returns the plug used to represent the specified parameter, which should - /// be a child of getParameterised()->parameters(). On failure returns a plug - /// for which plug.isNull() returns true. - virtual MPlug parameterPlug( IECore::ConstParameterPtr parameter ) = 0; - /// Returns the parameter represented by the specified plug, returning 0 - /// if no such parameter exists. - virtual IECore::ParameterPtr plugParameter( const MPlug &plug ) = 0; - -}; - -} - -#endif // IE_COREMAYA_PARAMETERISEDHOLDERINTERFACE_H diff --git a/include/IECoreMaya/ParameterisedHolderManipContext.h b/include/IECoreMaya/ParameterisedHolderManipContext.h deleted file mode 100644 index 5792234556..0000000000 --- a/include/IECoreMaya/ParameterisedHolderManipContext.h +++ /dev/null @@ -1,140 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_PARAMETERISEDHOLDERMANIPCONTEXT_H -#define IECOREMAYA_PARAMETERISEDHOLDERMANIPCONTEXT_H - -#include -#include -#include -#include -#include -#include - -#include "IECore/Parameter.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// This Class provides a generic manipulator context, that allows -/// Parameters on any node derived from IECore::ParameterisedHolder -/// to be manipulated. -/// -/// When a node is in the selection, and this context is used as a tool, -/// the selection is recursively walked for supported dependency/DAG nodes. -/// When one is found, its parameters are traversed, and depending on the -/// mode, one or more manipulators are created. -/// -/// In order for a parameter to display controls, a suitable manipulator -/// must first be registered. This is done in a way similar to Maya's -/// 'Show Manipulator Tool'. The name of registered manipulator should -/// take the following form: -/// -/// ie[]ParameterManipulator -/// -/// The optional manipulatorTypeHint, used for specialisation, -/// is read from the StringData member "manipTypeHint" in the the "UI" -/// CompoundObject of the Parameters userData(), if present. -/// -/// If the manipulator derives from IECore::ParameterManipulatorContainer -/// then two additional methods are called after creation to specify -/// which parameter the manipulator should target, and wether a label has -/// been specified by the optional StringData member "manipLabel" in -/// the "UI" CompoundObject in the Parameters userData(). -/// -/// \see ParameterisedManipContainer for more information. -/// -/// Because it may not be desirable to have all manipulatable parameters -/// display, you may set parameter->userData()["UI"]["disableManip"] to -/// BoolData( true ), and the context will skip that Parameter. - -class IECOREMAYA_API ParameterisedHolderManipContext : public MPxSelectionContext -{ - public: - - /// The context supports three modes of operation. These can be - /// managed by the ParameterisedHolderManipContextCmd - /// \see ParameterisedHolderManipContextCmd - enum Mode { - /// All Parameters with registered manipulators will display. - All, - /// The first supported Parameter that is encountered is drawn. (Default) - First, - /// The attribute name set in the context is drawn, if present. - Targeted - }; - - /// Used to set the target plug name for the context when in Targeted mode. - /// \param plugName The Maya attribute name, without the node prefix. This - /// should be the name of the Parameter plug itself, rather than any children. - void setTarget( MString &plugName ); - /// \return The Maya attribute name the context is currently operating on. - MString getTarget(); - - /// Sets the Context's mode to one of the above. - void setMode( Mode m ); - /// \return The Context's current mode. - Mode getMode(); - - - ParameterisedHolderManipContext(); - - virtual void toolOnSetup( MEvent &event ); - virtual void toolOffCleanup(); - - static void updateManipulators( void *blindData ); - - private: - - MCallbackId selectionChangeCallback; - - bool m_toolOn; - Mode m_mode; - MString m_targetPlugPath; - - void updateManipulators(); - - void dagWalk( MObject &node ); - void processNode( MObject &node ); - MPxManipContainer *createManipulatorWalk( IECore::ParameterPtr parameter, MFnDependencyNode &nodeFn ); - MPxManipContainer *createAndConnectManip( IECore::ParameterPtr parameter, MFnDependencyNode &nodeFn ); - - void updateHelpString(); -}; - -} - -#endif diff --git a/include/IECoreMaya/ParameterisedHolderManipContextCommand.h b/include/IECoreMaya/ParameterisedHolderManipContextCommand.h deleted file mode 100644 index ee9ec7e910..0000000000 --- a/include/IECoreMaya/ParameterisedHolderManipContextCommand.h +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_PARAMETERISEDHOLDERMANIPCONTEXTCOMMAND_H -#define IECOREMAYA_PARAMETERISEDHOLDERMANIPCONTEXTCOMMAND_H - -#include - -#include "IECoreMaya/ParameterisedHolderManipContext.h" - -#define kModeFlag "-m" -#define kModeFlagLong "-mode" - -#define kTargetFlag "-t" -#define kTargetFlagLong "-targetPlug" - -namespace IECoreMaya -{ - - -/// This Command class provides control over the \ref ParameterisedHolderManipContext. -/// It allows editing and query of the current mode, and target parameter. -/// -/// Usage: -/// -/// ieParameterisedHolderManipContext [-mode string] [-targetPlug string] contexName -/// -/// Flags: -/// -/// -mode (-m) [E][Q]: "all", "first" or "targeted" -/// -targetPlug (-t) [E][Q]: The desired attribute, without a leading node name. - -class IECOREMAYA_API ParameterisedHolderManipContextCommand : public MPxContextCommand -{ - public: - - ParameterisedHolderManipContextCommand(); - - virtual MStatus doEditFlags(); - virtual MStatus doQueryFlags(); - - virtual MPxContext* makeObj(); - - virtual MStatus appendSyntax(); - - static void* creator(); - - protected: - - ParameterisedHolderManipContext *m_context; -}; - -} - -#endif //IECOREMAYA_PARAMETERISEDHOLDERMANIPCONTEXTCOMMAND_H - diff --git a/include/IECoreMaya/ParameterisedHolderModificationCmd.h b/include/IECoreMaya/ParameterisedHolderModificationCmd.h deleted file mode 100644 index 1817a4943e..0000000000 --- a/include/IECoreMaya/ParameterisedHolderModificationCmd.h +++ /dev/null @@ -1,124 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_PARAMETERISEDHOLDERMODIFICATIONCMD_H -#define IECOREMAYA_PARAMETERISEDHOLDERMODIFICATIONCMD_H - -#include - -#include "maya/MPxCommand.h" -#include "maya/MSyntax.h" -#include "maya/MStringArray.h" - -#include "IECore/CompoundData.h" - -#include "IECoreMaya/ParameterisedHolderInterface.h" -#include "IECoreMaya/MArrayIter.h" - -namespace IECoreMaya -{ - -// This class has two purposes : -// -// 1) It is used by FnParameterisedHolder.setParameterised() to implement -// changing of the held class in an undoable way. -// -// 2) It is used by FnParameterisedHolder.parameterModificationContext() -// for the changing of the classes held by ClassParameter and ClassVectorParameter, -// and the setting of Parameter values. It must be implemented here as a command -// so that we can support undo for these operations. -// -// Under no circumstances should this class or the command it creates be -// used directly - it should be considered to be a private implementation -// detail of FnParameterisedHolder. -class IECOREMAYA_API ParameterisedHolderModificationCmd : public MPxCommand -{ - - public : - - ParameterisedHolderModificationCmd(); - virtual ~ParameterisedHolderModificationCmd(); - - static void *creator(); - - virtual bool isUndoable() const; - virtual bool hasSyntax() const; - - virtual MStatus doIt( const MArgList &argList ); - virtual MStatus undoIt(); - virtual MStatus redoIt(); - - private : - - void restoreClassParameterStates( const IECore::CompoundData *classes, IECore::Parameter *parameter, const std::string &parentParameterPath ); - void storeParametersWithNewValues( const IECore::Object *originalValue, const IECore::Object *newValue, const std::string ¶meterPath ); - void setNodeValuesForParametersWithNewValues() const; - void setNodeValue( IECore::Parameter *parameter ) const; - void despatchSetParameterisedCallbacks() const; - void despatchClassSetCallbacks() const; - IECore::Parameter *parameterFromPath( IECore::ParameterisedInterface *parameterised, const std::string &path ) const; - - MObject m_node; - ParameterisedHolderInterface *m_parameterisedHolder; - - IECore::ConstCompoundDataPtr m_originalClasses; - IECore::ConstCompoundDataPtr m_newClasses; - - IECore::ConstObjectPtr m_originalValues; - IECore::ConstObjectPtr m_newValues; - std::set m_parametersWithNewValues; - - bool m_changingClass; - MString m_originalClassName; - int m_originalClassVersion; - MString m_originalSearchPathEnvVar; - - MString m_newClassName; - int m_newClassVersion; - MString m_newSearchPathEnvVar; - - // When using FnParameterisedHolder.classParameterModificationContext(), it is too late - // to calculate the state to undo back to in this command, so that state - // is passed in from the context manager instead. we also pass in the new values and - // classes for simplicity. - static IECore::ConstObjectPtr g_originalValue; - static IECore::ConstCompoundDataPtr g_originalClasses; - static IECore::ConstObjectPtr g_newValue; - static IECore::ConstCompoundDataPtr g_newClasses; - friend void parameterisedHolderAssignModificationState( IECore::ObjectPtr originalValue, IECore::CompoundDataPtr originalClasses, IECore::ObjectPtr newValue, IECore::CompoundDataPtr newClasses ); -}; - -} - -#endif // IECOREMAYA_PARAMETERISEDHOLDERMODIFICATIONCMD_H diff --git a/include/IECoreMaya/ParameterisedHolderSetValueCmd.h b/include/IECoreMaya/ParameterisedHolderSetValueCmd.h deleted file mode 100644 index 179e8d7e0d..0000000000 --- a/include/IECoreMaya/ParameterisedHolderSetValueCmd.h +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_PARAMETERISEDHOLDERSETVALUECMD_H -#define IECOREMAYA_PARAMETERISEDHOLDERSETVALUECMD_H - -#include "maya/MPxCommand.h" -#include "maya/MSyntax.h" - -#include "IECoreMaya/ParameterisedHolderInterface.h" - -namespace IECoreMaya -{ - -/// This command is used to implement the IECoreMaya.FnParameterisedHolder -/// setNodeValue and setNodeValues methods in a way which supports undo. It's better -/// to use those methods than call this directly. -class IECOREMAYA_API ParameterisedHolderSetValueCmd : public MPxCommand -{ - - public : - - ParameterisedHolderSetValueCmd(); - virtual ~ParameterisedHolderSetValueCmd(); - - static void *creator(); - static MSyntax newSyntax(); - - virtual bool isUndoable() const; - - virtual MStatus doIt( const MArgList &argList ); - virtual MStatus undoIt(); - virtual MStatus redoIt(); - - private : - - ParameterisedHolderInterface *m_parameterisedHolder; - IECore::ParameterPtr m_parameter; // only set if we're setting a specific parameter rather than all of them - IECore::ObjectPtr m_originalValue; - IECore::ObjectPtr m_newValue; -}; - -} - -#endif // IECOREMAYA_PARAMETERISEDHOLDERSETVALUECMD_H diff --git a/include/IECoreMaya/PlaybackFrameList.h b/include/IECoreMaya/PlaybackFrameList.h deleted file mode 100644 index 232b387ccf..0000000000 --- a/include/IECoreMaya/PlaybackFrameList.h +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_PLAYBACKFRAMELIST_H -#define IE_COREMAYA_PLAYBACKFRAMELIST_H - -#include "IECore/FrameList.h" - -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// The PlaybackFrameList implements an IECore.FrameList which -/// represents the playback ranges queryable using the maya -/// playbackOptions command. -class IECOREMAYA_API PlaybackFrameList : public IECore::FrameList -{ - public: - - typedef enum - { - Animation, - Playback, - } Range; - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( PlaybackFrameList, PlaybackFrameListTypeId, IECore::FrameList ); - - PlaybackFrameList( Range r ); - - virtual ~PlaybackFrameList(); - - Range getRange() const; - void setRange( Range r ); - - virtual void asList( std::vector &frames ) const ; - virtual std::string asString() const; - virtual bool isEqualTo( IECore::ConstFrameListPtr other ) const ; - virtual IECore::FrameListPtr copy() const ; - - static IECore::FrameListPtr parse( const std::string &frameList ); - - protected : - - Range m_range; - - private : - - static IECore::FrameList::Parser< PlaybackFrameList > g_parserRegistrar; -}; - -IE_CORE_DECLAREPTR( PlaybackFrameList ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_PLAYBACKFRAMELIST_H diff --git a/include/IECoreMaya/PostLoadCallback.h b/include/IECoreMaya/PostLoadCallback.h deleted file mode 100644 index f078bde3c1..0000000000 --- a/include/IECoreMaya/PostLoadCallback.h +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_POSTLOADCALLBACK_H -#define IE_COREMAYA_POSTLOADCALLBACK_H - -#include "IECore/RefCounted.h" - -#include "IECoreMaya/Export.h" - -#include "maya/MCallbackIdArray.h" - -namespace IECoreMaya -{ - -/// A base class which executes a callback whenever a Maya scene is opened, referenced, or imported. In the case -/// of opening a scene with many references, care is taken that only one callback is made once the entire scene -/// is loaded, rather than a whole series of callbacks with the scene in various stages of validity. -/// User-defined classes should derive from this, and implement any custom behaviour in the postLoad() method. -/// All Maya callbacks are removed when the instance is deleted. -class IECOREMAYA_API PostLoadCallback : public IECore::RefCounted -{ - friend class PostLoadCallbackData; - - public: - - /// Construct a new callback instance - PostLoadCallback(); - virtual ~PostLoadCallback(); - - protected: - - /// To be overridden by derived classes to implement custom behaviour - virtual void postLoad() = 0; - - class PostLoadCallbackData; - PostLoadCallbackData* m_data; - - -}; - -IE_CORE_DECLAREPTR( PostLoadCallback ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_POSTLOADCALLBACK_H diff --git a/include/IECoreMaya/PythonCmd.h b/include/IECoreMaya/PythonCmd.h deleted file mode 100644 index 5a0ed5094a..0000000000 --- a/include/IECoreMaya/PythonCmd.h +++ /dev/null @@ -1,106 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_PYTHONCMD_H -#define IE_COREMAYA_PYTHONCMD_H - -#include - -#include -#include - -#include "maya/MPxCommand.h" - -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// A Maya plugin command to allow execution of Python statements/files under -/// specific named contexts. Provides methods for creating and deleting contexts. -/// Flags:
-///
    -///
  • -cmd / -command <string> : Execute an explicit python command string
  • -///
  • -f / -file <string> : Execute python commands from the given file
  • -///
  • -e / -eval <string> : Evaluate a line of python and return the result in string form
  • -///
  • -ctx / -context <string> : Execute python under the named context
  • -///
  • -cctx / -createContext <string> : Create a new python context
  • -///
  • -dctx / -deleteContext <string> : Remove a python context
  • -///
-/// If a context for execution is not specified then a default global one is used.
-/// Examples: -///

-/// python -command "print(str(dir()))"
-/// python -createContext "myContext" -command "i = 3";
-/// python -context "myContext" -command "print(i)";
-/// python -createContext "anotherContext" -command "print(i)";
-/// python -createContext "moreContext";;
-/// python -file "/tmp/somePython.py";
-/// python -eval "10 * 10";
-/// \todo Support the conversion of -eval results into the most appropriate mel form based on type -/// \todo Split the management of python contexts and all the evaluation code into a Python object -/// defined in an IECorePython library. Then we can use that object in a Nuke python plugin and -/// wherever else we want. And this command becomes a lot smaller and easier to maintain. Nice. -class IECOREMAYA_API PythonCmd : public MPxCommand -{ - public: - PythonCmd(); - virtual ~PythonCmd(); - - static void* creator(); - static MSyntax newSyntax(); - - MStatus doIt( const MArgList & args ); - - static void import( const std::string &moduleName ); - - static void initialize(); - static void uninitialize(); - - /// Returns the python context used for commands not specifying a context. - /// This may be useful for executing python code from c++ elsewhere. - static boost::python::object &globalContext(); - - private: - static bool g_initialized; - static boost::python::object g_globalContext; - - typedef std::map< std::string, boost::python::dict> ContextMap; - - static ContextMap g_contextMap; -}; - -} - -#endif // IE_COREMAYA_PYTHONCMD_H diff --git a/include/IECoreMaya/SceneShape.h b/include/IECoreMaya/SceneShape.h deleted file mode 100644 index 2446cda5db..0000000000 --- a/include/IECoreMaya/SceneShape.h +++ /dev/null @@ -1,112 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_SCENESHAPE_H -#define IE_COREMAYA_SCENESHAPE_H - -#include "IECoreScene/SceneInterface.h" -#include "IECoreMaya/SceneShapeInterface.h" - -namespace IECore -{ -IE_CORE_FORWARDDECLARE( Object ); -} - -namespace IECoreMaya -{ - -/// A shape derived from a SceneShapeInterface which implements -/// a shape which can read an IECore::SceneInterface using a file (.scc) and a root path -/// It also registers itself in the LiveScene class so that the node is seen as a link to -/// an external file through the LinkedScene mechanism. -class IECOREMAYA_API SceneShape : public SceneShapeInterface -{ - public : - - SceneShape(); - virtual ~SceneShape(); - - /* - * For Maya - */ - - virtual void postConstructor(); - static void *creator(); - static MStatus initialize(); - MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ); - MStatus preEvaluation( const MDGContext& context, const MEvaluationNode& evaluationNode ) override; - - static MTypeId id; - - /* - * Custom - */ - - /// \todo Perhaps getSceneInterface() should return a raw pointer? - /// Also perhaps it shouldn't be prefixed with "get" since there is no - /// corresponding set. - virtual IECoreScene::ConstSceneInterfacePtr getSceneInterface(); - - private : - - static MObject aSceneFilePlug; - static MObject aSceneRootPlug; - - bool m_sceneDirty; - IECoreScene::ConstSceneInterfacePtr m_scene; - - - static SceneShape *findScene( const MDagPath &p, bool noIntermediate, MDagPath *dagPath = nullptr ); - - /// functions registered in LiveScene as custom object and custom attributes - struct LiveSceneAddOn - { - LiveSceneAddOn(); - }; - static LiveSceneAddOn g_liveSceneAddon; - - static bool hasSceneShapeLink( const MDagPath &p ); - static IECore::ConstObjectPtr readSceneShapeLink( const MDagPath &p ); - static bool hasSceneShapeObject( const MDagPath &p ); - static IECore::ConstObjectPtr readSceneShapeObject( const MDagPath &p ); - static void sceneShapeAttributeNames( const MDagPath &p, IECoreScene::SceneInterface::NameList &attributeNames ); - static IECore::ConstObjectPtr readSceneShapeAttribute( const MDagPath &p, IECoreScene::SceneInterface::Name attributeName ); - static bool hasTag( const MDagPath &p, const IECoreScene::SceneInterface::Name &tag, int filter ); - static void readTags( const MDagPath &p, IECoreScene::SceneInterface::NameList &tags, int filter ); - -}; - -} - -#endif // IE_COREMAYA_SCENESHAPE_H diff --git a/include/IECoreMaya/SceneShapeInterface.h b/include/IECoreMaya/SceneShapeInterface.h deleted file mode 100644 index b16a863fb6..0000000000 --- a/include/IECoreMaya/SceneShapeInterface.h +++ /dev/null @@ -1,258 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_SCENESHAPEINTERFACE_H -#define IE_COREMAYA_SCENESHAPEINTERFACE_H - -#include "IECore/CompoundParameter.h" -#include "IECoreScene/SceneInterface.h" -#include "IECoreMaya/Export.h" - -#include -#include "Imath/ImathMatrix.h" -#include "IECoreGL/IECoreGL.h" -#include "maya/MPxComponentShape.h" - - -namespace IECoreGL -{ -IE_CORE_FORWARDDECLARE( Scene ); -IE_CORE_FORWARDDECLARE( State ); -IE_CORE_FORWARDDECLARE( BoxPrimitive ); -IE_CORE_FORWARDDECLARE( Primitive ); -IE_CORE_FORWARDDECLARE( Group ); -IE_CORE_FORWARDDECLARE( NameStateComponent ); -IE_CORE_FORWARDDECLARE( Renderer ); -} - -namespace IECoreMaya -{ - -/// A base class for a maya shape that can read an IECore::SceneInterface. -/// getSceneInterface should be implemented by any derived class -/// Builds a glScene for preview, which can draw all geometry in the hierarchy and the child bounds -/// Can be used as objectOnly, in which case the glScene will only represent the current path of the sceneInterface -/// or not objectOnly in which case the entire hierarchy starting from the current path is represented. -/// Computes queries on paths to get transforms, bounds and objects as outputs, as well as attributes. -/// The query paths are relative to the current sceneInterface path. -/// Queries can be accessed in local space or world space (starting from the current path). -/// -class IECOREMAYA_API SceneShapeInterface: public MPxComponentShape -{ - friend class SceneShapeInterfaceComponentBoundIterator; - - public: - - SceneShapeInterface(); - virtual ~SceneShapeInterface(); - - /* - * For Maya - */ - - virtual void postConstructor(); - static void *creator(); - static MStatus initialize(); - - virtual bool isBounded() const; - virtual MBoundingBox boundingBox() const; - virtual MStatus setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ); - virtual MStatus compute( const MPlug &plug, MDataBlock &dataBlock ); - - MatchResult matchComponent( const MSelectionList &item, const MAttributeSpecArray &spec, MSelectionList &list ) override; - MSelectionMask getShapeSelectionMask() const override; - MSelectionMask getComponentSelectionMask() const override; - -#if MAYA_API_VERSION >= 201600 - - virtual MStatus preEvaluation( const MDGContext &context, const MEvaluationNode &evaluationNode ); - -#endif - - /// This method is overridden to supply a geometry iterator, which maya uses to work out - /// the bounding boxes of the components you've selected in the viewport - virtual MPxGeometryIterator* geometryIteratorSetup( MObjectArray&, MObject&, bool ); - - /// This is a blank override, to stop maya offering you a rotation manipulator for the - /// procedural components, then crashing when you try and use it (maya 2013) - virtual void transformUsing( const MMatrix &mat, const MObjectArray &componentList, MPxSurfaceShape::MVertexCachingMode cachingMode, MPointArray *pointCache ); - - static MTypeId id; - - // Public variables because plugs need to be accessed by the UI creator which implements the drawing/selection - static MObject aObjectOnly; - static MObject aDrawGeometry; - static MObject aDrawRootBound; - static MObject aDrawChildBounds; - static MObject aDrawTagsFilter; - - /* - * Custom - */ - - /// Returns the sceneInterface for this node. Needs to be implemented by derived classes. - virtual IECoreScene::ConstSceneInterfacePtr getSceneInterface(); - - /// \todo: Move this IECoreGL functionality to SceneShapeUI. It should not be used by clients of the node, nor VP2 codepaths. - /// Returns the GL Scene representing the sceneInterface for the preview plug values ( objectOnly, drawGeometry, drawLocators, drawChildBounds ) - IECoreGL::ConstScenePtr glScene(); - /// Returns GL Group matching the given path name. - IECoreGL::GroupPtr glGroup( const IECore::InternedString &name ); - - /// Returns the internal index stored for the given path - int selectionIndex( const IECore::InternedString &name ); - /// Returns the path name for the given index - IECore::InternedString selectionName( int index ); - /// Returns all component names currently existing in the shape - const std::vector< IECore::InternedString > & componentNames() const; - /// Return the value of the time plug for the SceneShape. - double time() const; - /// Determines scene visibility while accounting for ancestral visibility overrides - static bool isVisible( const MDagPath &dagPath ); - - protected : - - // protected variables, used by derived classes to set attribute dependencies - static MObject aTime; - static MObject aOutTime; - static MObject aOutputObjects; - static MObject aObjectDependency; - static MObject aAttributes; - static MObject aTransform; - static MObject aBound; - - /// Flags the GL scene as dirty, for use by derived classes - void setDirty(); - - private : - - static MObject aQuerySpace; - static MObject aSceneQueries; - static MObject aAttributeQueries; - /// Read convert parameters. - /** - Some ToMaya*Converters have parameters to be used when converting objects. - In case of ToMayaCurveConverter, it takes an int parameter "index" that controls which one of curves it should convert to Maya nurbs curve. - queryConvertParameters lets you specify some of these paramters. - Converter parameters are updated with a string value held in aConvertParamQueries with IECore.ParameterParser. - **/ - static MObject aConvertParamQueries; - - static MObject aAttributeValues; - - static MObject aTranslate; - static MObject aTranslateX; - static MObject aTranslateY; - static MObject aTranslateZ; - static MObject aRotate; - static MObject aRotateX; - static MObject aRotateY; - static MObject aRotateZ; - static MObject aScale; - static MObject aScaleX; - static MObject aScaleY; - static MObject aScaleZ; - - static MObject aBoundMin; - static MObject aBoundMinX; - static MObject aBoundMinY; - static MObject aBoundMinZ; - static MObject aBoundMax; - static MObject aBoundMaxX; - static MObject aBoundMaxY; - static MObject aBoundMaxZ; - static MObject aBoundCenter; - static MObject aBoundCenterX; - static MObject aBoundCenterY; - static MObject aBoundCenterZ; - - /// Available modes for querySpace: Local space or World space (starts at sceneInterface path) - enum Space - { - World, - Local - }; - - bool m_sceneInterfaceDirty; - bool m_previewSceneDirty; - - IECoreGL::ScenePtr m_scene; - - /// Uses the sceneInterface hierarchy to build a GL Scene matching the preview plug values - void buildScene( IECoreGL::RendererPtr renderer, IECoreScene::ConstSceneInterfacePtr subSceneInterface ); - - /// Recursively parses the sceneInterface hierarchy to build a GL Scene matching the preview plug values - void recurseBuildScene( IECoreGL::Renderer * renderer, const IECoreScene::SceneInterface *subSceneInterface, double time, bool drawBounds, bool drawGeometry, bool objectOnly, const IECoreScene::SceneInterface::NameList &drawTags ); - - void createInstances(); - - /// Recursively parses glScene to store GL Groups matching path names - void buildGroups( IECoreGL::ConstNameStateComponentPtr nameState, IECoreGL::GroupPtr subScene ); - - void registerGroup( const std::string &name, IECoreGL::GroupPtr &group ); - - std::string relativePathName( IECoreScene::SceneInterface::Path path ); - IECoreScene::SceneInterface::Path fullPathName( std::string relativeName ); - /// Returns concatenated matrix from current sceneInterface path to given scene - Imath::M44d worldTransform( IECoreScene::ConstSceneInterfacePtr scene, double time ); - /// Returns bound for the component matching the given index - Imath::Box3d componentBound( int idx ); - bool animatedScene(); - - void recurseCopyGroup( const IECoreGL::Group *srcGroup, IECoreGL::Group *trgGroup, const std::string &namePrefix ); - - bool readConvertParam( IECore::CompoundParameterPtr parameters, int attrIndex ) const; - - MStatus computeOutputPlug( const MPlug &plug, const MPlug &topLevelPlug, MDataBlock &dataBlock, const IECoreScene::SceneInterface *scene, int topLevelIndex, int querySpace, MTime &time ); - - typedef std::map< IECore::InternedString, std::pair< unsigned int, IECoreGL::GroupPtr> > NameToGroupMap; - typedef std::vector< IECore::InternedString > IndexToNameMap; - typedef std::map< IECore::MurmurHash, IECore::InternedString > HashToName; - typedef std::pair< IECore::InternedString, IECore::InternedString > InstanceInfo; - typedef std::vector< InstanceInfo > InstanceArray; - - IndexToNameMap m_indexToNameMap; - NameToGroupMap m_nameToGroupMap; - HashToName m_hashToName; - InstanceArray m_instances; - - IE_CORE_FORWARDDECLARE( PostLoadCallback ); - PostLoadCallbackPtr m_postLoadCallback; - -}; - -} - -#endif // IE_COREMAYA_SCENESHAPEINTERFACE_H - diff --git a/include/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.h b/include/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.h deleted file mode 100644 index f82dcbad5a..0000000000 --- a/include/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.h +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_SCENESHAPEINTERFACECOMPONENTBOUNDITERATOR_H -#define IECOREMAYA_SCENESHAPEINTERFACECOMPONENTBOUNDITERATOR_H - -#include "maya/MPxGeometryIterator.h" -#include "maya/MPoint.h" -#include "maya/MBoundingBox.h" -#include "maya/MObjectArray.h" - -#include "Imath/ImathBox.h" - -#include "IECoreMaya/SceneShapeInterface.h" - -namespace IECoreMaya -{ - -/// The SceneShapeInterfaceComponentBoundIterator allows maya to iterate over the bounding box corners of -/// the SceneShapeInterface components. It's currently used so you can frame scene shape components -/// in the maya viewport. -class IECOREMAYA_API SceneShapeInterfaceComponentBoundIterator : public MPxGeometryIterator -{ - - public: - - SceneShapeInterfaceComponentBoundIterator( void *userGeometry, MObjectArray &components ); - SceneShapeInterfaceComponentBoundIterator( void *userGeometry, MObject &components ); - ~SceneShapeInterfaceComponentBoundIterator() override = default; - - bool isDone() const override; - -#if MAYA_API_VERSION < 202200 - void next() override; -#else - MStatus next() override; -#endif - - void reset() override; - void component( MObject &component ) override; - bool hasPoints() const override; - int iteratorCount() const override; - MPoint point() const override; - void setPoint(const MPoint &) const override; - int setPointGetNext(MPoint &) override; - int index() const override; - bool hasNormals() const override; - int indexUnsimplified() const override; - - private: - - void computeNumComponents(); - - SceneShapeInterface* m_sceneShapeInterface; - unsigned m_idx; - MObjectArray m_components; - unsigned m_numComponents; - -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_SCENESHAPEINTERFACECOMPONENTBOUNDITERATOR_H diff --git a/include/IECoreMaya/SceneShapeProxy.h b/include/IECoreMaya/SceneShapeProxy.h deleted file mode 100644 index e56ba90812..0000000000 --- a/include/IECoreMaya/SceneShapeProxy.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_SCENESHAPEPROXY_H -#define IE_COREMAYA_SCENESHAPEPROXY_H - -#include "IECoreMaya/SceneShape.h" - -namespace IECoreMaya -{ - -/// A proxy derived from the SceneShape which exposes the same functionality as the base clase -/// with the exception, that we never register it as a maya SubSceneOverride. The reasoning -/// behind this is that the SubSceneOverride does not take into account the visibility state of the shape. -/// During an update loop of the SubSceneOverride, all SceneShapes will be queried for their update state, -/// regardless their visibility in the scene. This query is slow and we get a huge drop in performance -/// when having a huge amount of SceneShapes in the scene. -/// This is considered to be a bug in the ViewPort 2 API. Our attempts to rewrite the code to use -/// "MPxGeometryOverride" or "MPxDrawOverride" prove themselves as unstable or not suitable for our -/// use case, why we decided to use this "hackery" and not register a proxy of the SceneShape for -/// drawing at all -class IECOREMAYA_API SceneShapeProxy : public SceneShape -{ - public : - - SceneShapeProxy(); - virtual ~SceneShapeProxy(); - - static void *creator(); - static MStatus initialize(); - static MTypeId id; -}; - -} - -#endif // IE_COREMAYA_SCENESHAPEPROXY_H diff --git a/include/IECoreMaya/SceneShapeProxyUI.h b/include/IECoreMaya/SceneShapeProxyUI.h deleted file mode 100644 index 8ed06afc05..0000000000 --- a/include/IECoreMaya/SceneShapeProxyUI.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_SCENESHAPEPROXYUI_H -#define IECOREMAYA_SCENESHAPEPROXYUI_H - -#include "maya/MPxSurfaceShapeUI.h" -#include "maya/MTypes.h" -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// The SceneShapeProxyUI is required for the registration of the SceneShapeProxy and we just make it a NoOp -/// TODO: It might be worth to see if the SceneShapeUI has any dependencies on the drawing capabilities of the -/// shape and if that's not the case, register SceneShapeProxy with the original implementation of SceneShapeUI -class IECOREMAYA_API SceneShapeProxyUI : public MPxSurfaceShapeUI -{ - - public : - - SceneShapeProxyUI(); - static void *creator(); -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_SCENESHAPEPROXYUI_H diff --git a/include/IECoreMaya/SceneShapeSubSceneOverride.h b/include/IECoreMaya/SceneShapeSubSceneOverride.h deleted file mode 100644 index 960d933d96..0000000000 --- a/include/IECoreMaya/SceneShapeSubSceneOverride.h +++ /dev/null @@ -1,196 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// -#ifndef IE_COREMAYA_SCENESHAPESUBSCENEOVERRIDE_H -#define IE_COREMAYA_SCENESHAPESUBSCENEOVERRIDE_H - -#include "IECoreMaya/Export.h" -#include "IECoreMaya/SceneShape.h" - -#include "IECoreScene/Primitive.h" -#include "IECoreScene/SceneInterface.h" - -#include "IECore/InternedString.h" - -#include "maya/MPxSubSceneOverride.h" - -#include "boost/signals2.hpp" -#include "boost/variant.hpp" - -#include -#include -#include -#include - -namespace IECoreMaya -{ - -using VertexBufferPtr = std::shared_ptr; -using IndexBufferPtr = std::shared_ptr; - -using Buffer = boost::variant; -using BufferPtr = std::shared_ptr; - -class IECOREMAYA_API SceneShapeSubSceneOverride : public MHWRender::MPxSubSceneOverride -{ - public : - - static MString& drawDbClassification(); - static MString& drawDbId(); - static MHWRender::MPxSubSceneOverride* Creator( const MObject& obj ); - - ~SceneShapeSubSceneOverride() override; - - // Maya calls this to determine if `update` needs to be called at all for this refresh. Gets called a lot. - bool requiresUpdate(const MHWRender::MSubSceneContainer& container, const MHWRender::MFrameContext& frameContext) const override; - - // Performing the actual updating. Needs to fill given container with MRenderItem objects for drawing. - void update(MHWRender::MSubSceneContainer& container, const MHWRender::MFrameContext& frameContext) override; - - // We are responsible for drawing all instances. Maya therefore refers to - // us for figuring out which instance was selected when the user clicks - // on one of our MRenderItems. - #if MAYA_API_VERSION > 201650 - bool getInstancedSelectionPath( const MHWRender::MRenderItem &renderItem, const MHWRender::MIntersection &intersection, MDagPath &dagPath ) const override; - #endif - - // Maya allows us to switch between object and component selection by changing the MSelectionContext. - void updateSelectionGranularity( const MDagPath &path, MHWRender::MSelectionContext &selectionContext ) override; - - MHWRender::DrawAPI supportedDrawAPIs() const override; - - protected : - - explicit SceneShapeSubSceneOverride( const MObject& obj ); - - private : - - class ComponentConverter; - - using IndexMap = std::map >; - using RenderItemMap = std::map >; - class RenderItemUserData; - using RenderItemUserDataPtr = std::shared_ptr; - using StyleMask = std::bitset<3>; - - enum class RenderStyle - { - BoundingBox, - Wireframe, - Solid, - Textured - }; - - const std::vector &supportedRenderStyles(); - - struct Instance - { - Instance( const MMatrix &transformation, bool selected, bool componentMode, const MDagPath &path, bool visible ) - : transformation( transformation ), selected( selected ), componentMode( componentMode ), path( path ), visible( visible ) - { - } - - bool operator==( const Instance &rhs ) const - { - return transformation == rhs.transformation && selected == rhs.selected && path == rhs.path && componentMode == rhs.componentMode && visible == rhs.visible; - } - - MMatrix transformation; - bool selected; - bool componentMode; - MDagPath path; - bool visible; - }; - - using Instances = std::vector; - - // Traverse the scene and create MRenderItems as necessary while collecting all matrices to be associated with them. - void visitSceneLocations( const IECoreScene::SceneInterface *sceneInterface, RenderItemMap &renderItems, MHWRender::MSubSceneContainer &container, const MMatrix &matrix, std::string relativeLocation, bool isRoot ); - - // Provide information about the instances that need drawing as - // SubSceneOverrides are responsible for drawing all instances of the - // shape, which is different to how things were handled in Maya's VP1. - void collectInstances( Instances &instances ) const; - - // Retrieve global display settings (can be locally overridden by instances) - void checkDisplayOverrides( MFrameContext::DisplayStyle displayStyle, StyleMask &mask ) const; - - RenderItemUserDataPtr acquireUserData( int componentIndex ); - void selectedComponentIndices( IndexMap &indexMap ) const; - MRenderItem *acquireRenderItem( - MSubSceneContainer &container, const IECore::Object *object, - const Instance &instance, const std::string &relativeLocation, - const MBoundingBox &bound, const MString &name, RenderStyle style - ); - void updateShaders( MRenderItem *renderItem, const Instance &instance, const std::string &relativeLocation, RenderStyle style ); - void setBuffersForRenderItem( const IECoreScene::Primitive *primitive, MHWRender::MRenderItem *renderItem, bool wireframe, const MBoundingBox &bound ); - - void bufferEvictedCallback( const BufferPtr &buffer ); - - SceneShape *m_sceneShape; - - std::string m_drawTagsFilter; - double m_time; - - StyleMask m_styleMask; // \todo: now that things are simpler, consider replacing this with three bools. - Instances m_instances; - - bool m_drawRootBounds; - bool m_drawChildBounds; - MPlug m_shaderOutPlug; - bool m_instancedRendering; - IECoreScene::ConstSceneInterfacePtr m_sceneInterface; - IECoreScene::SceneInterface::Path m_rootPath; - std::string m_rootLocation; - bool m_geometryVisible; - bool m_objectOnly; - - std::map m_renderItemNameToDagPath; - IndexMap m_selectedComponents; - std::map m_userDataMap; - std::vector m_markedForDeletion; - using RenderItemNames = std::vector; - std::unordered_map m_bufferToRenderItems; - std::unordered_set m_renderItemsToEnable; - - struct AllShaders; - using AllShadersPtr = std::shared_ptr; - - AllShadersPtr m_allShaders; - boost::signals2::scoped_connection m_evictionConnection; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_SCENESHAPESUBSCENEOVERRIDE_H diff --git a/include/IECoreMaya/SceneShapeUI.h b/include/IECoreMaya/SceneShapeUI.h deleted file mode 100644 index 541bccc6a9..0000000000 --- a/include/IECoreMaya/SceneShapeUI.h +++ /dev/null @@ -1,115 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_SCENESHAPEUI_H -#define IECOREMAYA_SCENESHAPEUI_H - -#include "maya/MPxSurfaceShapeUI.h" -#include "maya/MTypes.h" - -#include "IECore/Object.h" - -#include "IECoreMaya/SceneShape.h" -#include "IECoreMaya/DisplayStyle.h" - -namespace IECoreGL -{ -IE_CORE_FORWARDDECLARE( State ); -IE_CORE_FORWARDDECLARE( Group ); -IE_CORE_FORWARDDECLARE( StateComponent ); -} - - -namespace IECoreMaya -{ - -class IECOREMAYA_API SceneShapeUI : public MPxSurfaceShapeUI -{ - - public : - - SceneShapeUI(); - virtual ~SceneShapeUI(); - - virtual void getDrawRequests( const MDrawInfo &info, bool objectAndActiveOnly, MDrawRequestQueue &requests ); - virtual void draw( const MDrawRequest &request, M3dView &view ) const; - virtual bool select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const; - - /// If the maya version is greater or equal to 2013 then add support for snapping geometry to the SceneShape. - #if MAYA_API_VERSION >= 201300 - virtual bool snap( MSelectInfo &snapInfo ) const; - #endif - - static void *creator(); - - private : - - typedef std::map< IECoreGL::GroupPtr, IECoreGL::StatePtr > StateMap; - - void hiliteGroups( IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr hilite, IECoreGL::StateComponentPtr base ) const; - void unhiliteGroupChildren( const std::string &name, IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr base ) const; - void resetHilites() const; - - /// A useful method that calculates the world space position of the selection ray when given a camera and depth. The result is returned in worldIntersectionPoint. - void selectionRayToWorldSpacePoint( const MDagPath &camera, const MSelectInfo &selectInfo, float depth, MPoint &worldIntersectionPoint ) const; - - /// Returns the concatenated object transforms of the SceneInterface. - Imath::M44d worldTransform( const IECoreScene::SceneInterface *scene, double time ) const; - - mutable StateMap m_stateMap; - mutable DisplayStyle m_displayStyle; - - enum DrawMode - { - SceneDrawMode, - BoundDrawMode, - }; - - static void setWireFrameColors( MDrawRequest &request, M3dView::DisplayStatus status ); - - struct LightingState { - unsigned int numMayaLights; - unsigned int numGlLights; - std::vector diffuses; - std::vector specs; - std::vector ambients; - }; - - bool cleanupLights( const MDrawRequest &request, M3dView &view, LightingState *s ) const; - void restoreLights( LightingState *s ) const; -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_SCENESHAPEUI_H diff --git a/include/IECoreMaya/StatusException.h b/include/IECoreMaya/StatusException.h deleted file mode 100644 index 7c88095525..0000000000 --- a/include/IECoreMaya/StatusException.h +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_STATUSEXCEPTION_H -#define IE_COREMAYA_STATUSEXCEPTION_H - -#include "IECore/Exception.h" - -#include "IECoreMaya/Export.h" - -#include "maya/MStatus.h" - -namespace IECoreMaya -{ - -/// This class provides a means of representing -/// MStatus objects as exceptions, which might -/// make for easier programming at times. In particular -/// it can be thrown in python bindings and it'll be -/// picked up and turned into a python exception. -class IECOREMAYA_API StatusException : public IECore::Exception -{ - - public : - - /// Constructs an exception to represent - /// the given maya status code. It might be daft - /// to make one representing MStatus::kSuccess, - /// but no attempt is made to prevent that. - StatusException( const MStatus &status ); - - virtual const char *type() const throw(); - - /// If status represents an error, throws StatusException( status ), - /// otherwise does nothing and returns. - static void throwIfError( const MStatus &status ); - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_STATUSEXCEPTION_H diff --git a/include/IECoreMaya/StringParameterHandler.h b/include/IECoreMaya/StringParameterHandler.h deleted file mode 100644 index 1ad3333f00..0000000000 --- a/include/IECoreMaya/StringParameterHandler.h +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_STRINGPARAMETERHANDLER_H -#define IE_COREMAYA_STRINGPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with strings. -class IECOREMAYA_API StringParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private: - - enum ValueProvider { - InvalidValueProvider = 0, - NodeNameValueProvider = 1, - ConnectedNodeNameValueProvider = 2 - }; - - MStatus getPlugValue( const MPlug &plug, IECore::ConstStringParameterPtr parameter, MString &value ) const; - static MStatus getPathOrNameFromNode( const MObject &node, MString &name ); - static ValueProvider getValueProvider( const IECore::ConstParameterPtr parameter ); -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_STRINGPARAMETERHANDLER_H diff --git a/include/IECoreMaya/StringVectorParameterHandler.h b/include/IECoreMaya/StringVectorParameterHandler.h deleted file mode 100644 index 58fd302f2e..0000000000 --- a/include/IECoreMaya/StringVectorParameterHandler.h +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_STRINGVECTORPARAMETERHANDLER_H -#define IE_COREMAYA_STRINGVECTORPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with arrays of strings -class IECOREMAYA_API StringVectorParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_STRINGVECTORPARAMETERHANDLER_H diff --git a/include/IECoreMaya/ToMayaArrayDataConverter.h b/include/IECoreMaya/ToMayaArrayDataConverter.h deleted file mode 100644 index 2dc8f52801..0000000000 --- a/include/IECoreMaya/ToMayaArrayDataConverter.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAARRAYDATACONVERTER_H -#define IE_COREMAYA_TOMAYAARRAYDATACONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from various IECore TypedVectorData types -/// into various maya array types. -/// \ingroup conversionGroup -template -class IECOREMAYA_API ToMayaArrayDataConverter : public ToMayaObjectConverter -{ - public: - - ToMayaArrayDataConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} - -#endif // IE_COREMAYA_TOMAYAARRAYDATACONVERTER_H diff --git a/include/IECoreMaya/ToMayaCameraConverter.h b/include/IECoreMaya/ToMayaCameraConverter.h deleted file mode 100644 index 314cbb778c..0000000000 --- a/include/IECoreMaya/ToMayaCameraConverter.h +++ /dev/null @@ -1,69 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012 Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYACAMERACONVERTER_H -#define IECOREMAYA_TOMAYACAMERACONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// Converts an IECore::Camera to a Maya camera. -/// Converting to an existing cameraShape or parent of a cameraShape will alter -/// the camera settings without renaming the shape. Converting to a transform -/// that doesn't contain a cameraShape will create a new cameraShape parented -/// under that transform and named according to camera->getName() -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaCameraConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaCameraConverter, ToMayaCameraConverterTypeId, ToMayaObjectConverter ); - - ToMayaCameraConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - private: - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYACAMERACONVERTER_H diff --git a/include/IECoreMaya/ToMayaConverter.h b/include/IECoreMaya/ToMayaConverter.h deleted file mode 100644 index c0d7421bf0..0000000000 --- a/include/IECoreMaya/ToMayaConverter.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYACONVERTER_H -#define IECOREMAYA_TOMAYACONVERTER_H - -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/Export.h" - -#include "IECore/FromCoreConverter.h" - -namespace IECoreMaya -{ - -/// A base class for all classes which convert from an IECore datatype -/// to a Maya datatype. -class IECOREMAYA_API ToMayaConverter : public IECore::FromCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaConverter, ToMayaConverterTypeId, IECore::FromCoreConverter ); - - protected: - - ToMayaConverter( const std::string &description, IECore::TypeId supportedType ); - - virtual ~ToMayaConverter(); - -}; - -IE_CORE_DECLAREPTR( ToMayaConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYACONVERTER_H diff --git a/include/IECoreMaya/ToMayaCurveConverter.h b/include/IECoreMaya/ToMayaCurveConverter.h deleted file mode 100644 index 7b1f59088f..0000000000 --- a/include/IECoreMaya/ToMayaCurveConverter.h +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYACURVECONVERTER_H -#define IE_COREMAYA_TOMAYACURVECONVERTER_H - -#include "IECore/NumericParameter.h" -#include "IECoreScene/CurvesPrimitive.h" - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -class ToMayaCurveConverter; -IE_CORE_DECLAREPTR( ToMayaCurveConverter ); - -/// This class converts IECore::CurvesPrimitives to maya curve objects. -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaCurveConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaCurveConverter, ToMayaCurveConverterTypeId, ToMayaObjectConverter ); - - ToMayaCurveConverter( IECore::ConstObjectPtr object ); - - IECore::IntParameterPtr indexParameter(); - IECore::ConstIntParameterPtr indexParameter() const; - - protected: - - /// Converts one of the curves in srcParameter() to a maya curve. The curve it converts - /// is specified by indexParameter() (named "index") - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_curvesDataDescription; - static Description g_curvesDescription; - - private: - - IECore::IntParameterPtr m_indexParameter; -}; - -} - -#endif // IE_COREMAYA_TOMAYACURVECONVERTER_H diff --git a/include/IECoreMaya/ToMayaGroupConverter.h b/include/IECoreMaya/ToMayaGroupConverter.h deleted file mode 100644 index fcdf1fdd25..0000000000 --- a/include/IECoreMaya/ToMayaGroupConverter.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAGROUPCONVERTER_H -#define IECOREMAYA_TOMAYAGROUPCONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This class converts IECore::Group hierarchies to Maya DAG hierarchies. -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaGroupConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaGroupConverter, ToMayaGroupConverterTypeId, ToMayaObjectConverter ); - - ToMayaGroupConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - static ToMayaObjectConverterDescription g_registrar; - -}; - -IE_CORE_DECLAREPTR( ToMayaGroupConverter ); - -} - -#endif // IECOREMAYA_TOMAYAGROUPCONVERTER_H diff --git a/include/IECoreMaya/ToMayaImageConverter.h b/include/IECoreMaya/ToMayaImageConverter.h deleted file mode 100644 index 3205c7e94d..0000000000 --- a/include/IECoreMaya/ToMayaImageConverter.h +++ /dev/null @@ -1,96 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAIMAGECONVERTER_H -#define IE_COREMAYA_TOMAYAIMAGECONVERTER_H - -#include - -#include "IECoreMaya/ToMayaConverter.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/NumericParameter.h" - -#include "IECoreImage/ImagePrimitive.h" - -#include "maya/MImage.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( ToMayaImageConverter ); - -/// The ToMayaImageConverter class allows conversion from an IECore::ImagePrimitive to MImage values. -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaImageConverter : public ToMayaConverter -{ - - public : - - ToMayaImageConverter( IECoreImage::ConstImagePrimitivePtr image ); - - typedef enum - { - Float, - Byte, - } Type; - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaImageConverter, ToMayaImageConverterTypeId, ToMayaConverter ); - - /// Converts the srcParameter() value to an MImage value. - MStatus convert( MImage &image ) const; - - IECore::IntParameterPtr typeParameter(); - IECore::ConstIntParameterPtr typeParameter() const; - - private : - - IECore::IntParameterPtr m_typeParameter; - - template - struct ChannelConverter; - - template - void writeChannel( MImage &image, typename IECore::TypedData< std::vector >::Ptr channelData, unsigned channelOffset, unsigned numChannels ) const; - - template - void writeAlpha( MImage &image, const T &alpha ) const; - - void writeDepth( MImage &image, IECore::FloatVectorDataPtr channelData ) const; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TOMAYAIMAGECONVERTER_H diff --git a/include/IECoreMaya/ToMayaLocatorConverter.h b/include/IECoreMaya/ToMayaLocatorConverter.h deleted file mode 100644 index 82ad096d7d..0000000000 --- a/include/IECoreMaya/ToMayaLocatorConverter.h +++ /dev/null @@ -1,69 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013 Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYALOCATORCONVERTER_H -#define IECOREMAYA_TOMAYALOCATORCONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// Converts an IECore::CoordinateSystem to a Maya locator. -/// Converting to an existing locator or parent of a locator will alter -/// the locator without renaming the locator. Converting to a transform -/// that doesn't contain a locator will create a new locator parented -/// under that transform and named according to coordinateSystem->getName() -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaLocatorConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaLocatorConverter, ToMayaLocatorConverterTypeId, ToMayaObjectConverter ); - - ToMayaLocatorConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - private: - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYALOCATORCONVERTER_H diff --git a/include/IECoreMaya/ToMayaMatrixDataConverter.h b/include/IECoreMaya/ToMayaMatrixDataConverter.h deleted file mode 100644 index c5e915edcd..0000000000 --- a/include/IECoreMaya/ToMayaMatrixDataConverter.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAMATRIXDATACONVERTER_H -#define IECOREMAYA_TOMAYAMATRIXDATACONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from the IECore::M44*Data types to the MFn::kMatrixData type. -/// \ingroup conversionGroup -template -class IECOREMAYA_API ToMayaMatrixDataConverter : public ToMayaObjectConverter -{ - public: - - ToMayaMatrixDataConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} - -#endif // IECOREMAYA_TOMAYAMATRIXDATACONVERTER_H diff --git a/include/IECoreMaya/ToMayaMatrixVectorDataConverter.h b/include/IECoreMaya/ToMayaMatrixVectorDataConverter.h deleted file mode 100644 index 3cc038a6e5..0000000000 --- a/include/IECoreMaya/ToMayaMatrixVectorDataConverter.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAMATRIXVECTORDATACONVERTER_H -#define IECOREMAYA_TOMAYAMATRIXVECTORDATACONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// This template class can convert from the IECore::M44*VectorData types to the MFn::kDoubleArrayData type. -/// \ingroup conversionGroup -template -class IECOREMAYA_API ToMayaMatrixVectorDataConverter : public ToMayaObjectConverter -{ - public: - - ToMayaMatrixVectorDataConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} - -#endif // IECOREMAYA_TOMAYAMATRIXVECTORDATACONVERTER_H diff --git a/include/IECoreMaya/ToMayaMeshConverter.h b/include/IECoreMaya/ToMayaMeshConverter.h deleted file mode 100644 index f2f6feb14d..0000000000 --- a/include/IECoreMaya/ToMayaMeshConverter.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAMESHCONVERTER_H -#define IE_COREMAYA_TOMAYAMESHCONVERTER_H - -#include "maya/MFnMesh.h" - -#include "IECoreScene/MeshPrimitive.h" - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -class ToMayaMeshConverter; -IE_CORE_DECLAREPTR( ToMayaMeshConverter ); - -/// This class converts IECore::MeshPrimitives to maya mesh objects. -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaMeshConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaMeshConverter, ToMayaMeshConverterTypeId, ToMayaObjectConverter ); - - ToMayaMeshConverter( IECore::ConstObjectPtr object ); - - /// creates the standard attribute ieMeshInterpolation plug in the given Mesh object (it expects to be a MFnMesh bindable object). - /// \param defaultInterpolation - only accept values listed in the presets (keys or values) of FromMayaMeshConverter.interpolationParameter(). - static bool setMeshInterpolationAttribute( MObject &object, std::string interpolation = "linear" ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_meshDataDescription; - static Description g_meshDescription; - - private: - - void assignDefaultShadingGroup( MObject &shape ) const; - void addUVSet( MFnMesh &fnMesh, const MIntArray &polygonCounts, const IECoreScene::MeshPrimitive *mesh, IECoreScene::PrimitiveVariableMap::const_iterator &uvIt ) const; - -}; - -} - -#endif // IE_COREMAYA_TOMAYAMESHCONVERTER_H diff --git a/include/IECoreMaya/ToMayaNumericDataConverter.h b/include/IECoreMaya/ToMayaNumericDataConverter.h deleted file mode 100644 index 8f083ca592..0000000000 --- a/include/IECoreMaya/ToMayaNumericDataConverter.h +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYANUMERICDATACONVERTER_H -#define IE_COREMAYA_TOMAYANUMERICDATACONVERTER_H - -#include "IECoreMaya/ToMayaObjectConverter.h" - -#include "IECore/VectorTypedData.h" - -#include "maya/MString.h" - -namespace IECoreMaya -{ - -/// The ToMayaNumericDataConverter converts numeric IECore types into compatible MObjects -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaNumericDataConverter : public ToMayaObjectConverter -{ - - public : - - ToMayaNumericDataConverter( IECore::ConstObjectPtr object ); - - protected : - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - private : - - static ToMayaObjectConverterDescription g_3Double; - static ToMayaObjectConverterDescription g_3Float; - static ToMayaObjectConverterDescription g_3Int; - static ToMayaObjectConverterDescription g_3Short; - static ToMayaObjectConverterDescription g_2Double; - static ToMayaObjectConverterDescription g_2Float; - static ToMayaObjectConverterDescription g_2Int; - static ToMayaObjectConverterDescription g_2Short; -}; - -IE_CORE_DECLAREPTR( ToMayaNumericDataConverter ); - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TOMAYANUMERICDATACONVERTER_H diff --git a/include/IECoreMaya/ToMayaObjectConverter.h b/include/IECoreMaya/ToMayaObjectConverter.h deleted file mode 100644 index 25dd0988af..0000000000 --- a/include/IECoreMaya/ToMayaObjectConverter.h +++ /dev/null @@ -1,117 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAOBJECTCONVERTER_H -#define IE_COREMAYA_TOMAYAOBJECTCONVERTER_H - -#include "IECoreMaya/ToMayaConverter.h" - -#include "IECore/Object.h" - -#include "maya/MObjectHandle.h" - -namespace IECoreMaya -{ - -class ToMayaObjectConverter; -IE_CORE_DECLAREPTR( ToMayaObjectConverter ); - -/// The ToMayaObjectConverter class forms a base class for -/// convertions to MObject datatype. -class IECOREMAYA_API ToMayaObjectConverter : public ToMayaConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaObjectConverter, ToMayaObjectConverterTypeId, ToMayaConverter ); - - /// Converts the IECore::Object into the given MObject and returns True if successful and false otherwise. - /// \todo Define the meaning of object. Some derived classes seem to modify it, others seem to create a - /// new one and assign it. I think if a valid object is passed then it should be edited, and if a null object - /// is passed then a new one should be created. We also probably need a ToMayaShapeConverter base class with - /// some parentOrOwner type semantics. - bool convert( MObject &object ) const; - - /// Creates a converter which will convert the given IECore::Object to a maya object - /// of any relevant type. Returns 0 if no such converter can be found. - static ToMayaObjectConverterPtr create( IECore::ConstObjectPtr object ); - /// Creates a converter which will convert the given IECore::Object to a MObject - /// of the specified type. Returns 0 if no such converter can be found. - static ToMayaObjectConverterPtr create( IECore::ConstObjectPtr object, MFn::Type resultType ); - - protected : - - ToMayaObjectConverter( const std::string &description, IECore::ConstObjectPtr object ); - - /// Must be implemented by subclasses. Is guaranteed only to be called when object() - /// returns a valid IECore::Object of a type specified when the converter was registered. - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const = 0; - - typedef ToMayaObjectConverterPtr (*CreatorFn)( IECore::ConstObjectPtr object ); - - static void registerConverter( IECore::TypeId fromType, const MFn::Type resultType, CreatorFn creator ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class ToMayaObjectConverterDescription - { - public : - /// \todo Constructors allowing more complex mappings of types (multiple fromTypes - /// and resultTypes). - ToMayaObjectConverterDescription( IECore::TypeId fromType, const MFn::Type resultType ); - private : - static ToMayaObjectConverterPtr creator( IECore::ConstObjectPtr object ); - }; - - private : - - struct Types - { - Types( IECore::TypeId from, MFn::Type result ); - IECore::TypeId fromType; - MFn::Type resultType; - bool operator < ( const Types &other ) const; - }; - - typedef std::map TypesToFnsMap; - static TypesToFnsMap *typesToFns(); - -}; - -} // namespace IECoreMaya - -#include "IECoreMaya/ToMayaObjectConverter.inl" - -#endif // IE_COREMAYA_TOMAYACONVERTER_H diff --git a/include/IECoreMaya/ToMayaObjectConverter.inl b/include/IECoreMaya/ToMayaObjectConverter.inl deleted file mode 100644 index 7596d60fba..0000000000 --- a/include/IECoreMaya/ToMayaObjectConverter.inl +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAOBJECTCONVERTER_INL -#define IE_COREMAYA_TOMAYAOBJECTCONVERTER_INL - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -template -ToMayaObjectConverter::ToMayaObjectConverterDescription::ToMayaObjectConverterDescription( IECore::TypeId fromType, const MFn::Type resultType ) -{ - ToMayaObjectConverter::registerConverter( fromType, resultType, creator ); - /// \todo Derive ToMayaObjectConverterDescription from RunTimeTyped::TypeDescription instead of calling this manually. - IECore::RunTimeTyped::registerType( T::staticTypeId(), T::staticTypeName(), T::baseTypeId() ); -} - -template -ToMayaObjectConverterPtr ToMayaObjectConverter::ToMayaObjectConverterDescription::creator( IECore::ConstObjectPtr object ) -{ - return new T( object ); -} - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TOMAYAOBJECTCONVERTER_INL diff --git a/include/IECoreMaya/ToMayaParticleConverter.h b/include/IECoreMaya/ToMayaParticleConverter.h deleted file mode 100644 index 30c9b02314..0000000000 --- a/include/IECoreMaya/ToMayaParticleConverter.h +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011 Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAPARTICLECONVERTER_H -#define IECOREMAYA_TOMAYAPARTICLECONVERTER_H - -#include "maya/MFnParticleSystem.h" - -#include "IECore/Data.h" - -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -/// \todo Could we make a ToMayaShapeConverter base class to provide utilities for this and the ToMayaMeshConverter etc? -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaParticleConverter : public ToMayaObjectConverter -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaParticleConverter, ToMayaParticleConverterTypeId, ToMayaObjectConverter ); - - ToMayaParticleConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - private: - - void addAttribute( const IECore::Data *data, MFnParticleSystem &fnPS, const MString &attrName ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_description; -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYAPARTICLECONVERTER_H diff --git a/include/IECoreMaya/ToMayaPlugConverter.h b/include/IECoreMaya/ToMayaPlugConverter.h deleted file mode 100644 index 9f29e976ba..0000000000 --- a/include/IECoreMaya/ToMayaPlugConverter.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TOMAYAPLUGCONVERTER_H -#define IE_COREMAYA_TOMAYAPLUGCONVERTER_H - -#include "IECoreMaya/ToMayaConverter.h" - -#include "IECore/Object.h" -#include "IECore/TypedData.h" - -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( ToMayaPlugConverter ); - -/// The ToMayaPlugConverter class allows conversion from an IECore Object to MPlug values. -/// \ingroup conversionGroup -class IECOREMAYA_API ToMayaPlugConverter : public ToMayaConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaPlugConverter, ToMayaPlugConverterTypeId, ToMayaConverter ); - - /// Converts the srcParameter() value to an MPlug value. - /// \todo Replace this function with one that calls a pure virtual doConversion - /// function taking the contents of parameters(), like the other converters. Also - /// consider that MStatus might be a better return type, and that we might also - /// want a converter to create a new plug rather than just fill an existing one. - virtual bool convert( MPlug &plug ) const; - - /// \todo Implement this as a genuine factory which creates subclasses. - /// \todo Should be ConstPtr not const Ptr. - static ToMayaPlugConverterPtr create( const IECore::ObjectPtr src ); - - - private : - - ToMayaPlugConverter( IECore::ConstObjectPtr obj ); - template static MStatus setPlugValue(MPlug &plug, const DataType &data); - template MStatus convertAttr(MPlug &plug) const; - -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TOMAYAPLUGCONVERTER_H diff --git a/include/IECoreMaya/ToMayaSkinClusterConverter.h b/include/IECoreMaya/ToMayaSkinClusterConverter.h deleted file mode 100644 index e775c92ee4..0000000000 --- a/include/IECoreMaya/ToMayaSkinClusterConverter.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYASKINCLUSTERCONVERTER_H -#define IECOREMAYA_TOMAYASKINCLUSTERCONVERTER_H - -#include "IECore/SimpleTypedParameter.h" -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( ToMayaSkinClusterConverter ); - -/// The ToMayaSkinClusterConverter converts IECore::SmoothSkinningData to the smooth bind data for a maya skinCluster node -/// and sets the data on the given skinCluster -/// \ingroup conversionGroup. -class IECOREMAYA_API ToMayaSkinClusterConverter : public ToMayaObjectConverter -{ - public: - - ToMayaSkinClusterConverter( IECore::ConstObjectPtr object ); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaSkinClusterConverter, ToMayaSkinClusterConverterTypeId, ToMayaObjectConverter ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_skinClusterDescription; - - private : - - IECore::BoolParameterPtr m_ignoreMissingInfluencesParameter; - IECore::BoolParameterPtr m_ignoreBindPoseParameter; - -}; - -IE_CORE_DECLAREPTR( ToMayaSkinClusterConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYASKINCLUSTERCONVERTER_H diff --git a/include/IECoreMaya/ToMayaSkinClusterWeightsConverter.h b/include/IECoreMaya/ToMayaSkinClusterWeightsConverter.h deleted file mode 100644 index 2c3c0ca686..0000000000 --- a/include/IECoreMaya/ToMayaSkinClusterWeightsConverter.h +++ /dev/null @@ -1,70 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTER_H -#define IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTER_H - -#include "IECore/SimpleTypedParameter.h" -#include "IECoreMaya/ToMayaObjectConverter.h" - -namespace IECoreMaya -{ - -IE_CORE_FORWARDDECLARE( ToMayaSkinClusterWeightsConverter ); - -/// The ToMayaSkinClusterWeightsConverter converts IECore::SmoothSkinningData to the smooth bind data for a maya skinCluster node -/// and sets the data on the given skinCluster -/// \ingroup conversionGroup. -class IECOREMAYA_API ToMayaSkinClusterWeightsConverter : public ToMayaObjectConverter -{ - public: - - ToMayaSkinClusterWeightsConverter( IECore::ConstObjectPtr object ); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToMayaSkinClusterWeightsConverter, ToMayaSkinClusterWeightsConverterTypeId, ToMayaObjectConverter ); - - protected: - - virtual bool doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const; - - typedef ToMayaObjectConverterDescription Description; - static Description g_skinClusterDescription; - -}; - -IE_CORE_DECLAREPTR( ToMayaSkinClusterWeightsConverter ); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTER_H diff --git a/include/IECoreMaya/TransformationMatrixParameterHandler.h b/include/IECoreMaya/TransformationMatrixParameterHandler.h deleted file mode 100644 index 211a2dda31..0000000000 --- a/include/IECoreMaya/TransformationMatrixParameterHandler.h +++ /dev/null @@ -1,70 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TRANSFORMATIONMATRIXPARAMETERHANDLER_H -#define IE_COREMAYA_TRANSFORMATIONMATRIXPARAMETERHANDLER_H - -#include "IECoreMaya/ParameterHandler.h" - -#include "maya/MObject.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -namespace IECoreMaya -{ - -/// A ParameterHandler which deals with IECore::TransformationMatrixes -/// \todo Expose and add support for other rotation orders supported by Imath::Euler -template -class IECOREMAYA_API TransformationMatrixParameterHandler : public ParameterHandler -{ - protected: - virtual MPlug doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const; - virtual MStatus doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const; - virtual MStatus doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const; - - private: - - static MString g_attributeNames[]; - - MStatus setVecValues( MPlug vecPlug, Imath::Vec3 &values ) const; - MStatus getVecValues( MPlug vecPlug, Imath::Vec3 &values ) const; - MStatus setVecDefaultValues( MPlug vecPlug, Imath::Vec3 &values ) const; - MStatus setUnitVecDefaultValues( MPlug vecPlug, Imath::Vec3 &values ) const; -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TRANSFORMATIONMATRIXPARAMETERHANDLER_H diff --git a/include/IECoreMaya/TransientParameterisedHolderNode.h b/include/IECoreMaya/TransientParameterisedHolderNode.h deleted file mode 100644 index 976760d61c..0000000000 --- a/include/IECoreMaya/TransientParameterisedHolderNode.h +++ /dev/null @@ -1,69 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TRANSIENTPARAMETERISEDHOLDERNODE_H -#define IE_COREMAYA_TRANSIENTPARAMETERISEDHOLDERNODE_H - -#include "IECore/Parameterised.h" -#include "IECore/Parameter.h" -#include "IECore/Object.h" - -#include "IECoreMaya/ParameterisedHolder.h" -#include "IECoreMaya/Export.h" - -namespace IECoreMaya -{ - -/// The TransientParameterisedHolderNode is a special type of ParameterisedHolderNode which only exists for the purposes of being -/// able to create Attribute Editor panels out of "thin air". One of thse node types can be created temporarily for this purpose, -/// having the same lifespan as the UI's containing layout. -class IECOREMAYA_API TransientParameterisedHolderNode : public ParameterisedHolderNode -{ - public: - - TransientParameterisedHolderNode(); - virtual ~TransientParameterisedHolderNode(); - - static void *creator(); - static MStatus initialize(); - - /// This is a template class instantiated into many different - /// classes, so we specialise these in the implementation. - static MTypeId id; - static MString typeName; -}; - -} - -#endif // IE_COREMAYA_TRANSIENTPARAMETERISEDHOLDERNODE_H diff --git a/include/IECoreMaya/TypeIds.h b/include/IECoreMaya/TypeIds.h deleted file mode 100644 index d1b758f037..0000000000 --- a/include/IECoreMaya/TypeIds.h +++ /dev/null @@ -1,138 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2014, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TYPEIDS_H -#define IECOREMAYA_TYPEIDS_H - -namespace IECoreMaya -{ - -enum TypeId -{ - - FromMayaConverterTypeId = 109000, - FromMayaObjectConverterTypeId = 109001, - FromMayaPlugConverterTypeId = 109002, - FromMayaMeshConverterTypeId = 109003, - FromMayaCameraConverterTypeId = 109004, - FromMayaGroupConverterTypeId = 109005, - FromMayaNumericDataConverterTypeId = 109006, - FromMayaNumericPlugConverterTypeId = 109007, - FromMayaFluidConverterTypeId = 109008, - FromMayaStringPlugConverterTypeId = 109009, - FromMayaShapeConverterTypeId = 109010, - FromMayaCurveConverterTypeId = 109011, - FromMayaParticleConverterTypeId = 109012, - FromMayaDagNodeConverterTypeId = 109013, - ToMayaConverterTypeId = 109014, - ToMayaObjectConverterTypeId = 109015, - ToMayaNumericDataConverterTypeId = 109016, - ToMayaMeshConverterTypeId = 109017, - ToMayaArrayDataConverterTypeId = 109018, - ToMayaPlugConverterTypeId = 109019, - FromMayaPluginDataPlugConverterTypeId = 109020, - FromMayaTransformConverterTypeId = 109021, - FromMayaImageConverterTypeId = 109022, - ToMayaImageConverterTypeId = 109023, - PlaybackFrameListTypeId = 109024, - FromMayaUnitPlugConverterfTypeId = 109025, - FromMayaUnitPlugConverterdTypeId = 109026, - FromMayaNumericPlugConverterbbTypeId = 109027, - FromMayaNumericPlugConverterbiTypeId = 109028, - FromMayaNumericPlugConverteriiTypeId = 109029, - FromMayaNumericPlugConverterifTypeId = 109030, - FromMayaNumericPlugConverteridTypeId = 109031, - FromMayaNumericPlugConverterfiTypeId = 109032, - FromMayaNumericPlugConverterffTypeId = 109033, - FromMayaNumericPlugConverterfdTypeId = 109034, - FromMayaNumericPlugConverterdiTypeId = 109035, - FromMayaNumericPlugConverterdfTypeId = 109036, - FromMayaNumericPlugConverterddTypeId = 109037, - FromMayaArrayDataConverteriiTypeId = 109038, - FromMayaArrayDataConverterddTypeId = 109039, - FromMayaArrayDataConverterdfTypeId = 109040, - FromMayaArrayDataConverterssTypeId = 109041, - FromMayaArrayDataConverterVV3fTypeId = 109042, - FromMayaArrayDataConverterVV3dTypeId = 109043, - FromMayaArrayDataConverterVC3fTypeId = 109044, - FromMayaCompoundNumericPlugConverterV2fV2iTypeId = 109045, - FromMayaCompoundNumericPlugConverterV2fV2fTypeId = 109046, - FromMayaCompoundNumericPlugConverterV2fV2dTypeId = 109047, - FromMayaCompoundNumericPlugConverterV2dV2iTypeId = 109048, - FromMayaCompoundNumericPlugConverterV2dV2fTypeId = 109049, - FromMayaCompoundNumericPlugConverterV2dV2dTypeId = 109050, - FromMayaCompoundNumericPlugConverterV3fV3iTypeId = 109051, - FromMayaCompoundNumericPlugConverterV3fV3fTypeId = 109052, - FromMayaCompoundNumericPlugConverterV3fV3dTypeId = 109053, - FromMayaCompoundNumericPlugConverterV3fC3fTypeId = 109054, - FromMayaCompoundNumericPlugConverterV3dV3iTypeId = 109055, - FromMayaCompoundNumericPlugConverterV3dV3fTypeId = 109056, - FromMayaCompoundNumericPlugConverterV3dV3dTypeId = 109057, - FromMayaCompoundNumericPlugConverterV3dC3fTypeId = 109058, - FromMayaTransformationMatrixfConverterTypeId = 109059, - FromMayaTransformationMatrixdConverterTypeId = 109060, - Box3ManipulatorTypeId = 109061, - FromMayaSkinClusterConverterTypeId = 109062, - ToMayaSkinClusterConverterTypeId = 109063, - FromMayaArrayDataConverteribTypeId = 109064, - FromMayaMatrixVectorDataConverterTypeId = 109065, - ToMayaMatrixVectorDataConverterTypeId = 109066, - TransformationMatrixManipulatorTypeId = 109067, - ToMayaGroupConverterTypeId = 109068, - ToMayaParticleConverterTypeId = 109069, - V3ManipulatorTypeId = 109070, - ToMayaCameraConverterTypeId = 109071, - LiveSceneTypeId = 109072, - FromMayaProceduralHolderConverterTypeId = 109073, // Obsolete - FromMayaLocatorConverterTypeId = 109074, - ToMayaLocatorConverterTypeId = 109075, - ToMayaCurveConverterTypeId = 109076, - FromMayaArrayDataConverterPV3fTypeId = 109077, - FromMayaArrayDataConverterPV3dTypeId = 109078, - FromMayaInstancerConverterTypeId = 109079, - FromMayaNumericPlugConverterssTypeId = 109080, - FromMayaSkinClusterWeightsConverterTypeId = 109081, - ToMayaSkinClusterWeightsConverterTypeId = 109082, - FromMayaEnumPlugConverterstTypeId = 109083, - FromMayaEnumPlugConvertershTypeId = 109084, - // Remember to update TypeIdBinding.cpp - LastTypeId = 109999 -}; - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TYPEIDS_H diff --git a/include/IECoreMaya/TypeTraits.h b/include/IECoreMaya/TypeTraits.h deleted file mode 100644 index 13be33bb74..0000000000 --- a/include/IECoreMaya/TypeTraits.h +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_TYPETRAITS_H -#define IE_COREMAYA_TYPETRAITS_H - -#include "IECore/TypeTraits.h" - -namespace IECoreMaya -{ - -namespace TypeTraits -{ - -/// IsUnit -template struct IsUnit : public boost::false_type {}; -template<> struct IsUnit< MAngle > : public boost::true_type {}; -template<> struct IsUnit< MTime > : public boost::true_type {}; -template<> struct IsUnit< MDistance > : public boost::true_type {}; - -BOOST_STATIC_ASSERT( (IsUnit::value) ); -BOOST_STATIC_ASSERT( (IsUnit::value) ); -BOOST_STATIC_ASSERT( (IsUnit::value) ); -BOOST_STATIC_ASSERT( (boost::mpl::not_< IsUnit< float > >::value) ); - -} // namespace TypeTraits - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_TYPETRAITS_H diff --git a/include/IECoreMaya/UnitTraits.h b/include/IECoreMaya/UnitTraits.h deleted file mode 100644 index 881a68d4e5..0000000000 --- a/include/IECoreMaya/UnitTraits.h +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_UNITTRAITS_H -#define IE_COREMAYA_UNITTRAITS_H - -#include "maya/MFnUnitAttribute.h" -#include "maya/MDistance.h" -#include "maya/MAngle.h" -#include "maya/MTime.h" - -namespace IECoreMaya -{ - -template -struct UnitTraits -{ - typedef void UnitType; - - static MFnUnitAttribute::Type unitType() - { - return MFnUnitAttribute::kInvalid; - } -}; - -template<> -struct UnitTraits -{ - typedef MTime UnitType; - - static MFnUnitAttribute::Type unitType() - { - return MFnUnitAttribute::kTime; - } -}; - -template<> -struct UnitTraits -{ - typedef MAngle UnitType; - - static MFnUnitAttribute::Type unitType() - { - return MFnUnitAttribute::kAngle; - } -}; - -template<> -struct UnitTraits -{ - typedef MDistance UnitType; - - static MFnUnitAttribute::Type unitType() - { - return MFnUnitAttribute::kDistance; - } -}; - -} // namespace IECoreMaya - -#endif // IE_COREMAYA_UNITTRAITS_H diff --git a/include/IECoreMaya/V3Manipulator.h b/include/IECoreMaya/V3Manipulator.h deleted file mode 100644 index 5c798a2f28..0000000000 --- a/include/IECoreMaya/V3Manipulator.h +++ /dev/null @@ -1,100 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IEMAYAFUR_V3MANIPULATOR_H -#define IEMAYAFUR_V3MANIPULATOR_H - -#include "IECoreMaya/ParameterManipContainer.h" -#include "IECoreMaya/Export.h" - -#include -#include -#include -#include -#include - -#include - -namespace IECoreMaya -{ - -/// This class provides a manipulator for V3f and V3d Parameters. -/// Curently the node is only tested/registered for V3f Parameter types. -/// -/// Behavior can be further customised by adding the StringData member -/// "manipSpace" to the "UI" CompoundObject in there Parameters userData(). -/// If this member exists, valid values are "world" and "object". When using -/// object space (default), on-screen controls are transformed along with the node. -/// -class IECOREMAYA_API V3Manipulator : public ParameterManipContainer -{ - public: - - V3Manipulator(); - virtual ~V3Manipulator(); - - static void *creator(); - static MStatus initialize(); - - virtual MStatus createChildren(); - virtual MStatus connectToDependNode( const MObject &node); - - virtual void draw( M3dView & view, - const MDagPath & path, - M3dView::DisplayStyle style, - M3dView::DisplayStatus status ); - - MManipData vectorPlugToManipConversion( unsigned int manipIndex ); - MManipData vectorManipToPlugConversion( unsigned int plugIndex ); - - static MTypeId id; - - private: - - MPoint getPlugValues( MPlug &plug ); - void getPlugValues( MPlug &plug, double *values ); - void getPlugValues( MPlug &plug, MFnNumericData &data ); - - void readParameterOptions( MFnDagNode &nodeFn ); - bool m_worldSpace; - - MDagPath m_translateManip; - MPlug m_translatePlug; - MMatrix m_localMatrix; - MMatrix m_localMatrixInv; -}; - - -} -#endif // IEMAYAFUR_V3MANIPULATOR_H diff --git a/include/IECoreMaya/VectorTraits.h b/include/IECoreMaya/VectorTraits.h deleted file mode 100644 index b9e5efcac2..0000000000 --- a/include/IECoreMaya/VectorTraits.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_VECTORTRAITS_H -#define IE_COREMAYA_VECTORTRAITS_H - -#include "IECore/VectorTraits.h" - -#include "maya/MPoint.h" -#include "maya/MFloatPoint.h" -#include "maya/MVector.h" -#include "maya/MFloatVector.h" - -namespace IECore -{ - -template<> -struct VectorTraits -{ - typedef double BaseType; - static unsigned int dimensions() { return 4; }; - static double get( const MPoint &v, unsigned int i ) { return v[i]; }; - static void set( MPoint &v, unsigned int i, double x ) { v[i] = x; }; -}; - -template<> -struct VectorTraits -{ - typedef double BaseType; - static unsigned int dimensions() { return 4; }; - static float get( const MFloatPoint &v, unsigned int i ) { return v[i]; }; - static void set( MFloatPoint &v, unsigned int i, float x ) { v[i] = x; }; -}; - -template<> -struct VectorTraits -{ - typedef double BaseType; - static unsigned int dimensions() { return 3; }; - static double get( const MVector &v, unsigned int i ) { return v[i]; }; - static void set( MVector &v, unsigned int i, double x ) { v[i] = x; }; -}; - -template<> -struct VectorTraits -{ - typedef float BaseType; - static unsigned int dimensions() { return 3; }; - static float get( const MFloatVector &v, unsigned int i ) { return v[i]; }; - static void set( MFloatVector &v, unsigned int i, float x ) { v[i] = x; }; -}; - -} // namespace IECore - -#endif // IE_COREMAYA_VECTORTRAITS_H diff --git a/include/IECoreMaya/ViewportPostProcess.h b/include/IECoreMaya/ViewportPostProcess.h deleted file mode 100644 index 74384e7eb8..0000000000 --- a/include/IECoreMaya/ViewportPostProcess.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_VIEWPORTPOSTPROCESS_H -#define IE_COREMAYA_VIEWPORTPOSTPROCESS_H - -#include - -#include "IECore/RefCounted.h" - -#include "IECoreMaya/Export.h" - -#include "maya/MString.h" -#include "maya/MImage.h" -#include "maya/M3dView.h" - -namespace IECoreMaya -{ - -/// A class which defines a post-process on a viewport. -class IECOREMAYA_API ViewportPostProcess : public IECore::RefCounted -{ - - public: - - IE_CORE_DECLAREMEMBERPTR( ViewportPostProcess ); - - ViewportPostProcess(); - virtual ~ViewportPostProcess(); - - virtual bool needsDepth() const; - - protected: - - virtual void preRender( const std::string &panelName ); - - /// Derived classes should implement this, and modify the image in-place. - virtual void postRender( const std::string &panelName, MImage &image ) = 0; - - private : - - ViewportPostProcess( const ViewportPostProcess &other ); - ViewportPostProcess& operator =( const ViewportPostProcess &other ); -}; - - -IE_CORE_DECLAREPTR( ViewportPostProcess ); - -} - -#endif diff --git a/include/IECoreMaya/bindings/CallbackIdBinding.h b/include/IECoreMaya/bindings/CallbackIdBinding.h deleted file mode 100644 index 49692d97a2..0000000000 --- a/include/IECoreMaya/bindings/CallbackIdBinding.h +++ /dev/null @@ -1,40 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -namespace IECoreMaya -{ - -void bindCallbackId(); - -} // namespace IECoreMaya diff --git a/include/IECoreMaya/bindings/FnParameterisedHolderBinding.h b/include/IECoreMaya/bindings/FnParameterisedHolderBinding.h deleted file mode 100644 index 42e6788b89..0000000000 --- a/include/IECoreMaya/bindings/FnParameterisedHolderBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYAPYTHON_FNPARAMETERISEDHOLDERBINDING_H -#define IE_COREMAYAPYTHON_FNPARAMETERISEDHOLDERBINDING_H - -namespace IECoreMaya -{ - -void bindFnParameterisedHolder(); - -} // namespace IECoreMaya - -#endif // IE_COREMAYAPYTHON_FNPARAMETERISEDHOLDERBINDING_H diff --git a/include/IECoreMaya/bindings/FnSceneShapeBinding.h b/include/IECoreMaya/bindings/FnSceneShapeBinding.h deleted file mode 100644 index 6e12face0e..0000000000 --- a/include/IECoreMaya/bindings/FnSceneShapeBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYAPYTHON_FNSCENESHAPEBINDING_H -#define IECOREMAYAPYTHON_FNSCENESHAPEBINDING_H - -namespace IECoreMaya -{ - -void bindFnSceneShape(); - -} // namespace IECoreMaya - -#endif // IECOREMAYAPYTHON_FNSCENESHAPEBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.h b/include/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.h deleted file mode 100644 index cbea830a31..0000000000 --- a/include/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAARRAYDATACONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAARRAYDATACONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaArrayDataConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAARRAYDATACONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaCameraConverterBinding.h b/include/IECoreMaya/bindings/FromMayaCameraConverterBinding.h deleted file mode 100644 index 780671125d..0000000000 --- a/include/IECoreMaya/bindings/FromMayaCameraConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYACAMERACONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYACAMERACONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaCameraConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYACAMERACONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.h deleted file mode 100644 index 772cb4e272..0000000000 --- a/include/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaCompoundNumericPlugConverter(); - -} - -#endif // IECOREMAYA_FROMMAYACOMPOUNDNUMERICPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaConverterBinding.h b/include/IECoreMaya/bindings/FromMayaConverterBinding.h deleted file mode 100644 index df3ec2bf79..0000000000 --- a/include/IECoreMaya/bindings/FromMayaConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYACONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYACONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYACONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaCurveConverterBinding.h b/include/IECoreMaya/bindings/FromMayaCurveConverterBinding.h deleted file mode 100644 index 4cf0d26145..0000000000 --- a/include/IECoreMaya/bindings/FromMayaCurveConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYACURVECONVERTERBINDING_H -#define IECOREMAYA_FROMMAYACURVECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaCurveConverter(); - -} - -#endif // IECOREMAYA_FROMMAYACURVECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.h b/include/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.h deleted file mode 100644 index a0de6f5108..0000000000 --- a/include/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYADAGNODECONVERTERBINDING_H -#define IECOREMAYA_FROMMAYADAGNODECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaDagNodeConverter(); - -} - -#endif // IECOREMAYA_FROMMAYADAGNODECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.h deleted file mode 100644 index 016ba82f63..0000000000 --- a/include/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2019, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAENUMPLUGCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAENUMPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaEnumPlugConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAENUMPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaGroupConverterBinding.h b/include/IECoreMaya/bindings/FromMayaGroupConverterBinding.h deleted file mode 100644 index 7ed0b69373..0000000000 --- a/include/IECoreMaya/bindings/FromMayaGroupConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAGROUPCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAGROUPCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaGroupConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAGROUPCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaImageConverterBinding.h b/include/IECoreMaya/bindings/FromMayaImageConverterBinding.h deleted file mode 100644 index 51d3888f6f..0000000000 --- a/include/IECoreMaya/bindings/FromMayaImageConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAIMAGECONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAIMAGECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaImageConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAIMAGECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaInstancerConverterBinding.h b/include/IECoreMaya/bindings/FromMayaInstancerConverterBinding.h deleted file mode 100644 index 7b8e68e0d7..0000000000 --- a/include/IECoreMaya/bindings/FromMayaInstancerConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAINSTANCERCONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYAINSTANCERCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaInstancerConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYAINSTANCERCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaLocatorConverterBinding.h b/include/IECoreMaya/bindings/FromMayaLocatorConverterBinding.h deleted file mode 100644 index 860838dc84..0000000000 --- a/include/IECoreMaya/bindings/FromMayaLocatorConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYALOCATORCONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYALOCATORCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaLocatorConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYALOCATORCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaMeshConverterBinding.h b/include/IECoreMaya/bindings/FromMayaMeshConverterBinding.h deleted file mode 100644 index 478dc175e8..0000000000 --- a/include/IECoreMaya/bindings/FromMayaMeshConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAMESHCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAMESHCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaMeshConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAMESHCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaNumericPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaNumericPlugConverterBinding.h deleted file mode 100644 index e1babbee3f..0000000000 --- a/include/IECoreMaya/bindings/FromMayaNumericPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYANUMERICTPLUGCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYANUMERICTPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaNumericPlugConverter(); - -} - -#endif // IECOREMAYA_FROMMAYANUMERICTPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaObjectConverterBinding.h b/include/IECoreMaya/bindings/FromMayaObjectConverterBinding.h deleted file mode 100644 index c9c9ff2900..0000000000 --- a/include/IECoreMaya/bindings/FromMayaObjectConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAOBJECTCONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYAOBJECTCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaObjectConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYAOBJECTCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaParticleConverterBinding.h b/include/IECoreMaya/bindings/FromMayaParticleConverterBinding.h deleted file mode 100644 index 87609bfe5e..0000000000 --- a/include/IECoreMaya/bindings/FromMayaParticleConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAPARTICLECONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAPARTICLECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaParticleConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAPARTICLECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaPlugConverterBinding.h deleted file mode 100644 index 6b35cc83cd..0000000000 --- a/include/IECoreMaya/bindings/FromMayaPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_FROMMAYAPLUGCONVERTERBINDING_H -#define IE_COREMAYA_FROMMAYAPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaPlugConverter(); - -} - -#endif // IE_COREMAYA_FROMMAYAPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaShapeConverterBinding.h b/include/IECoreMaya/bindings/FromMayaShapeConverterBinding.h deleted file mode 100644 index dbb4dbe434..0000000000 --- a/include/IECoreMaya/bindings/FromMayaShapeConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASHAPECONVERTERBINDING_H -#define IECOREMAYA_FROMMAYASHAPECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaShapeConverter(); - -} - -#endif // IECOREMAYA_FROMMAYASHAPECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.h b/include/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.h deleted file mode 100644 index 1b9ec3f89f..0000000000 --- a/include/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.h +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASKINCLUSTERCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYASKINCLUSTERCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaSkinClusterConverter(); - -} - -#endif // IECOREMAYA_FROMMAYASKINCLUSTERCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.h b/include/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.h deleted file mode 100644 index fd18934f6d..0000000000 --- a/include/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.h +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaSkinClusterWeightsConverter(); - -} - -#endif // IECOREMAYA_FROMMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.h deleted file mode 100644 index 58f4864b66..0000000000 --- a/include/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYASTRINGPLUGCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYASTRINGPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaStringPlugConverter(); - -} - -#endif // IECOREMAYA_FROMMAYASTRINGPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaTransformConverterBinding.h b/include/IECoreMaya/bindings/FromMayaTransformConverterBinding.h deleted file mode 100644 index 9828f1eab2..0000000000 --- a/include/IECoreMaya/bindings/FromMayaTransformConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYATRANSFORMCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYATRANSFORMCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaTransformConverter(); - -} - -#endif // IECOREMAYA_FROMMAYATRANSFORMCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.h b/include/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.h deleted file mode 100644 index e217bd7f7c..0000000000 --- a/include/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaTransformationMatrixConverter(); - -} - -#endif // IECOREMAYA_FROMMAYATRANSFORMATIONMATRIXCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.h b/include/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.h deleted file mode 100644 index b3485c83ed..0000000000 --- a/include/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_FROMMAYAUNITPLUGCONVERTERBINDING_H -#define IECOREMAYA_FROMMAYAUNITPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindFromMayaUnitPlugConverter(); - -} - -#endif // IECOREMAYA_FROMMAYAUNITPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ImageViewportPostProcessBinding.h b/include/IECoreMaya/bindings/ImageViewportPostProcessBinding.h deleted file mode 100644 index 72b72e3e12..0000000000 --- a/include/IECoreMaya/bindings/ImageViewportPostProcessBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_IMAGEVIEWPORTPOSTPROCESSBINDING_H -#define IECOREMAYA_IMAGEVIEWPORTPOSTPROCESSBINDING_H - -namespace IECoreMaya -{ - -void bindImageViewportPostProcess(); - -} - -#endif // IECOREMAYA_IMAGEVIEWPORTPOSTPROCESSBINDING_H diff --git a/include/IECoreMaya/bindings/LiveSceneBinding.h b/include/IECoreMaya/bindings/LiveSceneBinding.h deleted file mode 100644 index c70f80b02c..0000000000 --- a/include/IECoreMaya/bindings/LiveSceneBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_LIVESCENEBINDING_H -#define IECOREMAYA_LIVESCENEBINDING_H - -namespace IECoreMaya -{ - -void bindLiveScene(); - -} - -#endif // IECOREMAYA_LIVESCENEBINDING_H diff --git a/include/IECoreMaya/bindings/MDagPathFromPython.h b/include/IECoreMaya/bindings/MDagPathFromPython.h deleted file mode 100644 index 5beadc7754..0000000000 --- a/include/IECoreMaya/bindings/MDagPathFromPython.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MDAGPATHFROMPYTHON_H -#define IECOREMAYA_MDAGPATHFROMPYTHON_H - -namespace IECoreMaya -{ -void bindMDagPathFromPython(); -} - -#endif // IECOREMAYA_MDAGPATHFROMPYTHON_H diff --git a/include/IECoreMaya/bindings/MObjectFromPython.h b/include/IECoreMaya/bindings/MObjectFromPython.h deleted file mode 100644 index 51318be17e..0000000000 --- a/include/IECoreMaya/bindings/MObjectFromPython.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MOBJECTFROMPYTHON_H -#define IECOREMAYA_MOBJECTFROMPYTHON_H - -namespace IECoreMaya -{ -void bindMObjectFromPython(); -} - -#endif // IECOREMAYA_MOBJECTFROMPYTHON_H diff --git a/include/IECoreMaya/bindings/MPlugFromPython.h b/include/IECoreMaya/bindings/MPlugFromPython.h deleted file mode 100644 index 692c3f05c4..0000000000 --- a/include/IECoreMaya/bindings/MPlugFromPython.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MPLUGFROMPYTHON_H -#define IECOREMAYA_MPLUGFROMPYTHON_H - -namespace IECoreMaya -{ -void bindMPlugFromPython(); -} - -#endif // IECOREMAYA_MPLUGFROMPYTHON_H diff --git a/include/IECoreMaya/bindings/MStringFromPython.h b/include/IECoreMaya/bindings/MStringFromPython.h deleted file mode 100644 index 38e3b2fcd6..0000000000 --- a/include/IECoreMaya/bindings/MStringFromPython.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MSTRINGFROMPYTHON_H -#define IECOREMAYA_MSTRINGFROMPYTHON_H - -namespace IECoreMaya -{ -void bindMStringFromPython(); -} - -#endif // IECOREMAYA_MSTRINGFROMPYTHON_H diff --git a/include/IECoreMaya/bindings/MayaMeshBuilderBinding.h b/include/IECoreMaya/bindings/MayaMeshBuilderBinding.h deleted file mode 100644 index c466de0dea..0000000000 --- a/include/IECoreMaya/bindings/MayaMeshBuilderBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_MAYAMESHBUILDERBINDING_H -#define IE_COREMAYA_MAYAMESHBUILDERBINDING_H - -namespace IECoreMaya -{ -void bindMayaMeshBuilder(); -} - -#endif // IE_COREMAYA_MAYAMESHBUILDERBINDING_H diff --git a/include/IECoreMaya/bindings/MayaTypeIdBinding.h b/include/IECoreMaya/bindings/MayaTypeIdBinding.h deleted file mode 100644 index fc1d9aff6e..0000000000 --- a/include/IECoreMaya/bindings/MayaTypeIdBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MAYATYPEIDBINDING_H -#define IECOREMAYA_MAYATYPEIDBINDING_H - -namespace IECoreMaya -{ -void bindMayaTypeId(); -} - -#endif // IECOREMAYA_MAYATYPEIDBINDING_H diff --git a/include/IECoreMaya/bindings/MessageHandlerBinding.h b/include/IECoreMaya/bindings/MessageHandlerBinding.h deleted file mode 100644 index 537dac5797..0000000000 --- a/include/IECoreMaya/bindings/MessageHandlerBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_MESSAGEHANDLERBINDING_H -#define IECOREMAYA_MESSAGEHANDLERBINDING_H - -namespace IECoreMaya -{ - -void bindMessageHandler(); - -} - -#endif // IECOREMAYA_MESSAGEHANDLERBINDING_H diff --git a/include/IECoreMaya/bindings/PlaybackFrameListBinding.h b/include/IECoreMaya/bindings/PlaybackFrameListBinding.h deleted file mode 100644 index 1ac6c55dd8..0000000000 --- a/include/IECoreMaya/bindings/PlaybackFrameListBinding.h +++ /dev/null @@ -1,40 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -namespace IECoreMaya -{ - -void bindPlaybackFrameList(); - -} // namespace IECoreMaya diff --git a/include/IECoreMaya/bindings/StandaloneBinding.h b/include/IECoreMaya/bindings/StandaloneBinding.h deleted file mode 100644 index 81b5d2353c..0000000000 --- a/include/IECoreMaya/bindings/StandaloneBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREMAYA_STANDALONEBINDING_H -#define IE_COREMAYA_STANDALONEBINDING_H - -namespace IECoreMaya -{ -void bindStandalone(); -} - -#endif // IE_COREMAYA_STANDALONEBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaCameraConverterBinding.h b/include/IECoreMaya/bindings/ToMayaCameraConverterBinding.h deleted file mode 100644 index a13762b26e..0000000000 --- a/include/IECoreMaya/bindings/ToMayaCameraConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYACAMERACONVERTERBINDING_H -#define IECOREMAYA_TOMAYACAMERACONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaCameraConverter(); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYACAMERACONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaConverterBinding.h b/include/IECoreMaya/bindings/ToMayaConverterBinding.h deleted file mode 100644 index 37469c1eb2..0000000000 --- a/include/IECoreMaya/bindings/ToMayaConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYACONVERTERBINDING_H -#define IECOREMAYA_TOMAYACONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaConverter(); - -} - -#endif // IECOREMAYA_TOMAYACONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaCurveConverterBinding.h b/include/IECoreMaya/bindings/ToMayaCurveConverterBinding.h deleted file mode 100644 index c9b4aaceb3..0000000000 --- a/include/IECoreMaya/bindings/ToMayaCurveConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYACURVECONVERTERBINDING_H -#define IECOREMAYA_TOMAYACURVECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaCurveConverter(); - -} - -#endif // IECOREMAYA_TOMAYACURVECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaGroupConverterBinding.h b/include/IECoreMaya/bindings/ToMayaGroupConverterBinding.h deleted file mode 100644 index 053f4f34c0..0000000000 --- a/include/IECoreMaya/bindings/ToMayaGroupConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAGROUPCONVERTERBINDING_H -#define IECOREMAYA_TOMAYAGROUPCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaGroupConverter(); - -} - -#endif // IECOREMAYA_TOMAYAGROUPCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaImageConverterBinding.h b/include/IECoreMaya/bindings/ToMayaImageConverterBinding.h deleted file mode 100644 index d665dc2da3..0000000000 --- a/include/IECoreMaya/bindings/ToMayaImageConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAIMAGECONVERTERBINDING_H -#define IECOREMAYA_TOMAYAIMAGECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaImageConverter(); - -} - -#endif // IECOREMAYA_TOMAYAIMAGECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaLocatorConverterBinding.h b/include/IECoreMaya/bindings/ToMayaLocatorConverterBinding.h deleted file mode 100644 index 5025fd84e8..0000000000 --- a/include/IECoreMaya/bindings/ToMayaLocatorConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYALOCATORCONVERTERBINDING_H -#define IECOREMAYA_TOMAYALOCATORCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaLocatorConverter(); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYALOCATORCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaMeshConverterBinding.h b/include/IECoreMaya/bindings/ToMayaMeshConverterBinding.h deleted file mode 100644 index ff86cd8bc6..0000000000 --- a/include/IECoreMaya/bindings/ToMayaMeshConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAMESHCONVERTERBINDING_H -#define IECOREMAYA_TOMAYAMESHCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaMeshConverter(); - -} - -#endif // IECOREMAYA_TOMAYAMESHCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaObjectConverterBinding.h b/include/IECoreMaya/bindings/ToMayaObjectConverterBinding.h deleted file mode 100644 index 9150560ace..0000000000 --- a/include/IECoreMaya/bindings/ToMayaObjectConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAOBJECTCONVERTERBINDING_H -#define IECOREMAYA_TOMAYAOBJECTCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaObjectConverter(); - -} - -#endif // IECOREMAYA_TOMAYAOBJECTCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaParticleConverterBinding.h b/include/IECoreMaya/bindings/ToMayaParticleConverterBinding.h deleted file mode 100644 index 5df6986f68..0000000000 --- a/include/IECoreMaya/bindings/ToMayaParticleConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAPARTICLECONVERTERBINDING_H -#define IECOREMAYA_TOMAYAPARTICLECONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaParticleConverter(); - -} // namespace IECoreMaya - -#endif // IECOREMAYA_TOMAYAPARTICLECONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaPlugConverterBinding.h b/include/IECoreMaya/bindings/ToMayaPlugConverterBinding.h deleted file mode 100644 index 4d7a9429f1..0000000000 --- a/include/IECoreMaya/bindings/ToMayaPlugConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYAPLUGCONVERTERBINDING_H -#define IECOREMAYA_TOMAYAPLUGCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaPlugConverter(); - -} - -#endif // IECOREMAYA_TOMAYAPLUGCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.h b/include/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.h deleted file mode 100644 index 9af95be6ec..0000000000 --- a/include/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYASKINCLUSTERCONVERTERBINDING_H -#define IECOREMAYA_TOMAYASKINCLUSTERCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaSkinClusterConverter(); - -} - -#endif // IECOREMAYA_TOMAYASKINCLUSTERCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.h b/include/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.h deleted file mode 100644 index bce5a5eaac..0000000000 --- a/include/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H -#define IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H - -namespace IECoreMaya -{ - -void bindToMayaSkinClusterWeightsConverter(); - -} - -#endif // IECOREMAYA_TOMAYASKINCLUSTERWEIGHTSCONVERTERBINDING_H diff --git a/include/IECoreMaya/bindings/TypeIdBinding.h b/include/IECoreMaya/bindings/TypeIdBinding.h deleted file mode 100644 index 107824e48c..0000000000 --- a/include/IECoreMaya/bindings/TypeIdBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_TYPEIDBINDING_H -#define IECOREMAYA_TYPEIDBINDING_H - -namespace IECoreMaya -{ -void bindTypeId(); -} - -#endif // IECOREMAYA_TYPEIDBINDING_H diff --git a/include/IECoreMaya/bindings/ViewportPostProcessBinding.h b/include/IECoreMaya/bindings/ViewportPostProcessBinding.h deleted file mode 100644 index 1e5707ff7b..0000000000 --- a/include/IECoreMaya/bindings/ViewportPostProcessBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREMAYA_VIEWPORTPOSTPROCESSBINDING_H -#define IECOREMAYA_VIEWPORTPOSTPROCESSBINDING_H - -namespace IECoreMaya -{ - -void bindViewportPostProcess(); - -} - -#endif // IECOREMAYA_VIEWPORTPOSTPROCESSBINDING_H diff --git a/include/IECoreNuke/BoolParameterHandler.h b/include/IECoreNuke/BoolParameterHandler.h deleted file mode 100644 index b8f37902e1..0000000000 --- a/include/IECoreNuke/BoolParameterHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_BOOLPARAMETERHANDLER_H -#define IECORENUKE_BOOLPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API BoolParameterHandler : public ParameterHandler -{ - - public : - - BoolParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - bool m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_BOOLPARAMETERHANDLER_H diff --git a/include/IECoreNuke/Box3ParameterHandler.h b/include/IECoreNuke/Box3ParameterHandler.h deleted file mode 100644 index 28dc055da1..0000000000 --- a/include/IECoreNuke/Box3ParameterHandler.h +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_BOX3PARAMETERHANDLER_H -#define IECORENUKE_BOX3PARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -#include "Imath/ImathBox.h" - -namespace IECoreNuke -{ - -template -class IECORENUKE_API Box3ParameterHandler : public ParameterHandler -{ - - public : - - Box3ParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - Imath::Box3f m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_BOX3PARAMETERHANDLER_H diff --git a/include/IECoreNuke/ClassParameterHandler.h b/include/IECoreNuke/ClassParameterHandler.h deleted file mode 100644 index eeaf096ce5..0000000000 --- a/include/IECoreNuke/ClassParameterHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_CLASSPARAMETERHANDLER_H -#define IECORENUKE_CLASSPARAMETERHANDLER_H - -#include "IECoreNuke/CompoundParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API ClassParameterHandler : public CompoundParameterHandler -{ - - public : - - ClassParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setState( IECore::Parameter *parameter, const IECore::Object *state ); - virtual IECore::ObjectPtr getState( const IECore::Parameter *parameter ); - - private : - - void classChooserKnob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_CLASSPARAMETERHANDLER_H diff --git a/include/IECoreNuke/ClassVectorParameterHandler.h b/include/IECoreNuke/ClassVectorParameterHandler.h deleted file mode 100644 index 272502dd48..0000000000 --- a/include/IECoreNuke/ClassVectorParameterHandler.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_CLASSVECTORPARAMETERHANDLER_H -#define IECORENUKE_CLASSVECTORPARAMETERHANDLER_H - -#include "IECoreNuke/CompoundParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API ClassVectorParameterHandler : public CompoundParameterHandler -{ - - public : - - ClassVectorParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setState( IECore::Parameter *parameter, const IECore::Object *state ); - virtual IECore::ObjectPtr getState( const IECore::Parameter *parameter ); - - private : - - void addEditKnobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - void buildAddMenu( DD::Image::Knob *knob, const IECore::Parameter *parameter, const std::string ¶meterPath ); - void buildRemoveMenu( DD::Image::Knob *knob, const IECore::Parameter *parameter, const std::string ¶meterPath ); - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_CLASSVECTORPARAMETERHANDLER_H diff --git a/include/IECoreNuke/Color3fParameterHandler.h b/include/IECoreNuke/Color3fParameterHandler.h deleted file mode 100644 index f6d8fbbdfb..0000000000 --- a/include/IECoreNuke/Color3fParameterHandler.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_COLOR3FPARAMETERHANDLER_H -#define IECORENUKE_COLOR3FPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -#include "Imath/ImathColor.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API Color3fParameterHandler : public ParameterHandler -{ - - public : - - Color3fParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - Imath::Color3f m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_COLOR3FPARAMETERHANDLER_H diff --git a/include/IECoreNuke/CompoundParameterHandler.h b/include/IECoreNuke/CompoundParameterHandler.h deleted file mode 100644 index 880d11011e..0000000000 --- a/include/IECoreNuke/CompoundParameterHandler.h +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_COMPOUNDPARAMETERHANDLER_H -#define IECORENUKE_COMPOUNDPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API CompoundParameterHandler : public ParameterHandler -{ - - public : - - CompoundParameterHandler(); - - virtual int minimumInputs( const IECore::Parameter *parameter ); - virtual int maximumInputs( const IECore::Parameter *parameter ); - virtual bool testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ); - virtual void setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - virtual void setState( IECore::Parameter *parameter, const IECore::Object *state ); - virtual IECore::ObjectPtr getState( const IECore::Parameter *parameter ); - - protected : - - void beginGroup( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - void childKnobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - void endGroup( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - std::string knobLabel( const IECore::Parameter *parameter ) const; - - private : - - enum ContainerType - { - Collapsible, - Tab, - Toolbar - }; - ContainerType containerType( const IECore::Parameter *parameter ); - - void inputs( const IECore::Parameter *parameter, int &minimum, int &maximum, bool &error ); - - ParameterHandlerPtr handler( const IECore::Parameter *child, bool createIfMissing ); - typedef std::map HandlerMap; - HandlerMap m_handlers; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_COMPOUNDPARAMETERHANDLER_H diff --git a/include/IECoreNuke/Convert.h b/include/IECoreNuke/Convert.h deleted file mode 100644 index d1308a9219..0000000000 --- a/include/IECoreNuke/Convert.h +++ /dev/null @@ -1,137 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_CONVERT_H -#define IECORENUKE_CONVERT_H - -#include "IECoreNuke/Export.h" - -#include "IECore/Convert.h" - -#include "DDImage/Box.h" -#include "DDImage/Box3.h" -#include "DDImage/Matrix4.h" -#include "DDImage/Vector2.h" -#include "DDImage/Vector3.h" -#include "DDImage/Vector4.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathBox.h" -#include "Imath/ImathColor.h" -#include "Imath/ImathMatrix.h" -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -/// Specialising in the IECore namespace. This is OK because the Nuke types -/// will never be referenced in IECore. And it means that all the convert<> -/// functions are in one namespace. -namespace IECore -{ - -template<> -IECORENUKE_API Imath::V2f convert( const DD::Image::Vector2 &from ); - -template<> -IECORENUKE_API Imath::V2d convert( const DD::Image::Vector2 &from ); - -/// Discards from.z -template<> -IECORENUKE_API Imath::V2f convert( const DD::Image::Vector3 &from ); - -/// Discards from.z -template<> -IECORENUKE_API Imath::V2d convert( const DD::Image::Vector3 &from ); - -template<> -IECORENUKE_API Imath::V3f convert( const DD::Image::Vector3 &from ); - -template<> -IECORENUKE_API Imath::V3d convert( const DD::Image::Vector3 &from ); - -template<> -IECORENUKE_API Imath::Color3f convert( const DD::Image::Vector3 &from ); - -template<> -IECORENUKE_API DD::Image::Vector3 convert( const Imath::V3f &from ); - -template<> -IECORENUKE_API DD::Image::Vector3 convert( const Imath::V3d &from ); - -/// Discards from.z and from.w -template<> -IECORENUKE_API Imath::V2f convert( const DD::Image::Vector4 &from ); - -/// Discards from.z and from.w -template<> -IECORENUKE_API Imath::V2d convert( const DD::Image::Vector4 &from ); - -/// Discards from.w -template<> -IECORENUKE_API Imath::V3f convert( const DD::Image::Vector4 &from ); - -/// Discards from.w -template<> -IECORENUKE_API Imath::Color3f convert( const DD::Image::Vector4 &from ); - -template<> -IECORENUKE_API Imath::Color4f convert( const DD::Image::Vector4 &from ); - -/// Discards from.w -template<> -IECORENUKE_API Imath::V3d convert( const DD::Image::Vector4 &from ); - -template<> -IECORENUKE_API Imath::M44f convert( const DD::Image::Matrix4 &from ); - -template<> -IECORENUKE_API Imath::M44d convert( const DD::Image::Matrix4 &from ); - -template<> -IECORENUKE_API DD::Image::Matrix4 convert( const Imath::M44d &from ); - -template<> -IECORENUKE_API Imath::Box2i convert( const DD::Image::Box &from ); - -template<> -IECORENUKE_API DD::Image::Box3 convert( const Imath::Box3f &from ); - -template<> -IECORENUKE_API Imath::Box3f convert( const DD::Image::Box3 &from ); - -template<> -IECORENUKE_API Imath::Box3d convert( const DD::Image::Box3 &from ); - -} // namespace IECore - -#endif // IECORENUKE_CONVERT_H diff --git a/include/IECoreNuke/CurveLookup.h b/include/IECoreNuke/CurveLookup.h deleted file mode 100644 index 464b5e2958..0000000000 --- a/include/IECoreNuke/CurveLookup.h +++ /dev/null @@ -1,134 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_CURVELOOKUP_H -#define IECORENUKE_CURVELOOKUP_H - -#include "IECoreNuke/Export.h" - -#include "DDImage/Description.h" -#if ( DD_IMAGE_VERSION_MAJOR >= 5 && DD_IMAGE_VERSION_MINOR > 0 ) || DD_IMAGE_VERSION_MAJOR >= 6 -#define IECORENUKE_NO_ANIMATION -#endif - -#ifdef IECORENUKE_NO_ANIMATION -#include "DDImage/LookupCurves.h" -#else -#include "DDImage/Animation.h" -#endif - -#include "DDImage/Knobs.h" - -#include - -namespace IECoreNuke -{ - -/// The CurveLookup class provides a useful wrapper around a bunch of DD::Image::Animation pointers, -/// which can be used to provide lookup curves to a node. It contains everything necessary to declare -/// the interface, sample the curve in _evaluate(), and then interpolate those sample values -/// to perform quick evaluations in engine(). It's templated on the type you want to be returned -/// from the evaluate() method. It also deals with the fact that the API for using curve lookups -/// changed completely between Nuke5 and Nuke5.1. -template -class IECORENUKE_API CurveLookup -{ - - public : - - typedef T BaseType; - - CurveLookup( const std::string &name, const std::string &label, const std::string &toolTip = "" ); - ~CurveLookup(); - /// Call this in the constructor for a node, to add as many curves as required. Returns the index - /// which should be passed to the validate and evaluate calls below, but this is guaranteed to - /// be 0 for the first curve, 1 for the second etc. You cannot add more curves once knobs() - /// has been called. - int addCurve( const std::string &name, const std::string &defaultCurve = "y C 0 1" ); - /// Call this in the knobs() method for a node, to build the interface for the curves. - void knob( DD::Image::Knob_Callback f ); - /// Call this in the _validate method for a node, to sample the curves into a lookup - /// which can be evaluated quickly in engine(). - void validate( T xMin = 0, T xMax = 1, unsigned numSamples=100 ); - /// Append all the curves to the specified Hash. - void append( DD::Image::Hash &hash ) const; - /// Append an individual curve to the specified Hash. - void append( unsigned curveIndex, DD::Image::Hash &hash ) const; - /// As above, but samples just one curve - this can be used if you wish to sample different - /// curves over different ranges. curveIndex is 0 for the first curve added, and increments - /// by 1 for each subsequent curve. - void validate( unsigned curveIndex, T xMin = 0, T xMax = 1, unsigned numSamples=100 ); - /// Calculate the y value for the specified curve at the specified position. - /// validate() must have been called for that curve before this method is called. - inline T evaluate( unsigned curveIndex, T x ) const; - - private : - - /// No copying please - CurveLookup( const CurveLookup &other ); - const CurveLookup &operator=( const CurveLookup &other ); - - unsigned numCurves() const; - - std::string m_name; - std::string m_label; - std::string m_toolTip; - -#ifdef IECORENUKE_NO_ANIMATION - std::vector *m_namesAndDefaultsStrings; - std::vector *m_curveDescriptions; - DD::Image::LookupCurves *m_curves; -#else - std::vector m_namesAndDefaultsStrings; - std::vector m_namesAndDefaultsPtrs; - std::vector m_curves; -#endif - - struct Lookup - { - std::vector values; - float xMin; - float xMax; - float xMult; - }; - - std::vector m_lookups; - -}; - -} // namespace IECoreNuke - -#include "IECoreNuke/CurveLookup.inl" - -#endif // IECORENUKE_CURVELOOKUP_H diff --git a/include/IECoreNuke/CurveLookup.inl b/include/IECoreNuke/CurveLookup.inl deleted file mode 100644 index 20c52f56dd..0000000000 --- a/include/IECoreNuke/CurveLookup.inl +++ /dev/null @@ -1,228 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_CURVELOOKUP_INL -#define IECORENUKE_CURVELOOKUP_INL - -#include "Imath/ImathFun.h" - -#include -#include - -namespace IECoreNuke -{ - -template -CurveLookup::CurveLookup( const std::string &name, const std::string &label, const std::string &toolTip ) - : m_name( name ), m_label( label ), m_toolTip( toolTip ) -{ -#ifdef IECORENUKE_NO_ANIMATION - m_namesAndDefaultsStrings = new std::vector; - m_curveDescriptions = new std::vector; - m_curves = 0; -#endif -} - -template -CurveLookup::~CurveLookup() -{ -#ifdef IECORENUKE_NO_ANIMATION - delete m_curves; - // Note that we're deliberately not deleting m_namesAndDefaultsStrings - // or m_curveDescriptions - the nuke docs say that they have to remain forever, so - // we're effectively forced into leaking memory here. -#endif -} - -template -CurveLookup::CurveLookup( const CurveLookup &other ) -{ - assert( 0 ); -} - -template -const CurveLookup &CurveLookup::operator=( const CurveLookup &other ) -{ - assert( 0 ); - return *this; -} - -template -int CurveLookup::addCurve( const std::string &name, const std::string &defaultCurve ) -{ -#ifdef IECORENUKE_NO_ANIMATION - m_namesAndDefaultsStrings->push_back( name ); - m_namesAndDefaultsStrings->push_back( defaultCurve ); - return m_namesAndDefaultsStrings->size()/2 - 1; -#else - m_namesAndDefaultsStrings.push_back( name ); - m_namesAndDefaultsStrings.push_back( defaultCurve ); - return m_namesAndDefaultsStrings.size()/2 - 1; -#endif -} - -template -void CurveLookup::knob( DD::Image::Knob_Callback f ) -{ -#ifdef IECORENUKE_NO_ANIMATION - if( !m_curves ) - { - for( unsigned i=0; isize(); i+=2 ) - { - DD::Image::CurveDescription d = DD::Image::CurveDescription(); - d.name = (*m_namesAndDefaultsStrings)[i].c_str(); - d.defaultValue = (*m_namesAndDefaultsStrings)[i+1].c_str(); - d.flags = 0; - m_curveDescriptions->push_back( d ); - } - DD::Image::CurveDescription endMarker = { 0 }; - m_curveDescriptions->push_back( endMarker ); - m_curves = new DD::Image::LookupCurves( &*(m_curveDescriptions->begin()) ); - } - LookupCurves_knob( f, m_curves, m_name.c_str(), m_label.c_str() ); -#else - if( !m_namesAndDefaultsPtrs.size() ) - { - for( std::vector::const_iterator it=m_namesAndDefaultsStrings.begin(); it!=m_namesAndDefaultsStrings.end(); it++ ) - { - m_namesAndDefaultsPtrs.push_back( it->c_str() ); - } - m_curves.resize( m_namesAndDefaultsPtrs.size()/2 ); - m_namesAndDefaultsPtrs.push_back( 0 ); - m_namesAndDefaultsPtrs.push_back( 0 ); - } - Animation_knob( f, &(m_curves[0]), &(m_namesAndDefaultsPtrs[0]), m_name.c_str(), m_label.c_str() ); -#endif - Tooltip( f, m_toolTip.c_str() ); -} - -template -unsigned CurveLookup::numCurves() const -{ -#ifdef IECORENUKE_NO_ANIMATION - return m_curves->size(); -#else - return m_curves.size(); -#endif -} - -template -void CurveLookup::validate( T xMin, T xMax, unsigned numSamples ) -{ - for( unsigned i=0; i -void CurveLookup::validate( unsigned curveIndex, T xMin, T xMax, unsigned numSamples ) -{ - assert( numSamples>=2 ); - assert( curveIndexgetValue( curveIndex, x ); -#else - lookup.values[i] = m_curves[curveIndex]->evaluate( x ); -#endif - x += xStep; - } - lookup.xMin = xMin; - lookup.xMax = xMax; - lookup.xMult = (numSamples - 1) / (xMax - xMin); -} - -template -void CurveLookup::append( DD::Image::Hash &hash ) const -{ -#ifdef IECORENUKE_NO_ANIMATION - m_curves->append( hash ); -#else - for( unsigned i=0; i -void CurveLookup::append( unsigned curveIndex, DD::Image::Hash &hash ) const -{ -#ifdef IECORENUKE_NO_ANIMATION - // we can't do them one by one with the new nuke version. - m_curves->append( hash ); -#else - m_curves[curveIndex]->append( hash ); -#endif -} - -template -inline T CurveLookup::evaluate( unsigned curveIndex, T x ) const -{ - const Lookup &lookup = m_lookups[curveIndex]; - x = Imath::clamp( x, lookup.xMin, lookup.xMax ); - T f = (x - lookup.xMin) * lookup.xMult; - int fi = fast_floor( f ); - T ff; - if( fi<0 ) - { - ff = f; - fi = 0; - } - else if( fi>(int)lookup.values.size()-2) - { - fi = lookup.values.size()-2; - ff = f - fi; - } - else - { - ff = f - fi; - } - - assert( fi >= 0 ); - assert( fi + 1 < (int)lookup.values.size() ); - return Imath::lerp( lookup.values[fi], lookup.values[fi+1], ff ); -} - -} // namespace IECoreNuke - -#endif // IECORENUKE_CURVELOOKUP_INL diff --git a/include/IECoreNuke/DisplayIop.h b/include/IECoreNuke/DisplayIop.h deleted file mode 100644 index e434513a82..0000000000 --- a/include/IECoreNuke/DisplayIop.h +++ /dev/null @@ -1,93 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, J3P LLC. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_DISPLAYIOP_H -#define IECORENUKE_DISPLAYIOP_H - -#include "IECoreNuke/Export.h" - -#include "IECoreImage/DisplayDriverServer.h" - -#include "DDImage/Iop.h" - -namespace IECoreNuke -{ - -IE_CORE_FORWARDDECLARE( NukeDisplayDriver ); - -class IECORENUKE_API DisplayIop : public DD::Image::Iop -{ - - public : - - DisplayIop( Node *node ); - virtual ~DisplayIop(); - - virtual const char *Class() const; - virtual const char *node_help() const; - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual int knob_changed( DD::Image::Knob *knob ); - virtual void append( DD::Image::Hash &hash ); - virtual void _validate( bool forReal ); - virtual void engine( int y, int x, int r, const DD::Image::ChannelSet &channels, DD::Image::Row &row ); - - private : - - static const Description g_description; - static DD::Image::Op *build( Node *node ); - - DisplayIop *firstDisplayIop(); - void driverCreated( NukeDisplayDriver *driver ); - void connectToDriver( NukeDisplayDriver *driver ); - void driverDataReceived( NukeDisplayDriver *driver, const Imath::Box2i &box ); - - int m_portNumber; - - DD::Image::Format m_format; - DD::Image::Format m_fullSizeFormat; - - IECoreImage::DisplayDriverServerPtr m_server; - // we only bother updating these for firstDisplayIop(), - // and then refer to them from all other instances. this - // avoids problems where nuke might make new ops mid render - // and those ops would have missed the display driver creation. - unsigned int m_updateCount; - IECoreNuke::NukeDisplayDriverPtr m_driver; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_DISPLAYIOP_H diff --git a/include/IECoreNuke/DrawableHolder.h b/include/IECoreNuke/DrawableHolder.h deleted file mode 100644 index cdfd4ed25d..0000000000 --- a/include/IECoreNuke/DrawableHolder.h +++ /dev/null @@ -1,96 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_DRAWABLEHOLDER_H -#define IECORENUKE_DRAWABLEHOLDER_H - -#include "IECoreNuke/ParameterisedHolder.h" - -#include "IECoreGL/Scene.h" - -#include "IECore/Export.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathMatrix.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// This class allows IECore::ParameterisedProcedural objects -/// with a draw() method to be displayed in Nuke. -class IECORENUKE_API DrawableHolder : public ParameterisedHolderOp -{ - - public : - - DrawableHolder( Node *node ); - virtual ~DrawableHolder(); - - //! @name Reimplementation of Nuke methods. - ///////////////////////////////////////////////////////////////////// - //@{ - virtual void knobs( DD::Image::Knob_Callback f ); - virtual const char *Class() const; - virtual const char *node_help() const; - //@} - - /// Returns the scene created by the draw() method of the held class, - /// in a form suitable for OpenGL rendering. - IECoreGL::ConstScenePtr scene(); - /// Returns the transform for the drawable. - Imath::M44f transform(); - - protected : - - /// Implemented to do the drawing - virtual void build_handles( DD::Image::ViewerContext *ctx ); - virtual void draw_handle( DD::Image::ViewerContext *ctx ); - - private : - - static const Description g_description; - static DD::Image::Op *build( Node *node ); - - IECoreGL::ScenePtr m_scene; - DD::Image::Hash m_sceneHash; - - DD::Image::Matrix4 m_transform; - DD::Image::Knob *m_transformKnob; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_DRAWABLEHOLDER_H diff --git a/include/IECoreNuke/Export.h b/include/IECoreNuke/Export.h deleted file mode 100644 index a0196aceb5..0000000000 --- a/include/IECoreNuke/Export.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_EXPORT_H -#define IECORENUKE_EXPORT_H - -#include "IECore/Export.h" - -#ifdef IECoreNuke_EXPORTS - #define IECORENUKE_API IECORE_EXPORT -#else - #define IECORENUKE_API IECORE_IMPORT -#endif - -#endif // #ifndef IECORENUKE_EXPORT_H diff --git a/include/IECoreNuke/FloatParameterHandler.h b/include/IECoreNuke/FloatParameterHandler.h deleted file mode 100644 index d3c77410a2..0000000000 --- a/include/IECoreNuke/FloatParameterHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FLOATPARAMETERHANDLER_H -#define IECORENUKE_FLOATPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API FloatParameterHandler : public ParameterHandler -{ - - public : - - FloatParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - float m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_FLOATPARAMETERHANDLER_H diff --git a/include/IECoreNuke/FromNukeCameraConverter.h b/include/IECoreNuke/FromNukeCameraConverter.h deleted file mode 100644 index f47d4a2682..0000000000 --- a/include/IECoreNuke/FromNukeCameraConverter.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FROMNUKECAMERACONVERTER_H -#define IECORENUKE_FROMNUKECAMERACONVERTER_H - -#include "IECoreNuke/FromNukeConverter.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/CameraOp.h" - -namespace IECoreNuke -{ - -/// This class converts DD::Image::CameraOps into IECore::Cameras. -/// \ingroup conversionGroup. -class IECORENUKE_API FromNukeCameraConverter : public FromNukeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromNukeCameraConverter, FromNukeCameraConverterTypeId, FromNukeConverter ); - - /// The caller is responsible for ensuring that camera is alive - /// for as long as the converter is. - FromNukeCameraConverter( const DD::Image::CameraOp *camera ); - virtual ~FromNukeCameraConverter(); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - const DD::Image::CameraOp *m_camera; - -}; - -IE_CORE_DECLAREPTR( FromNukeCameraConverter ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_FROMNUKECAMERACONVERTER_H diff --git a/include/IECoreNuke/FromNukeConverter.h b/include/IECoreNuke/FromNukeConverter.h deleted file mode 100644 index 3802e5408a..0000000000 --- a/include/IECoreNuke/FromNukeConverter.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FROMNUKECONVERTER_H -#define IECORENUKE_FROMNUKECONVERTER_H - -#include "IECoreNuke/Export.h" -#include "IECoreNuke/TypeIds.h" - -#include "IECore/ToCoreConverter.h" - -namespace IECoreNuke -{ - -/// The FromNukeConverter forms a base class for all Converters which -/// convert from Nuke datatypes to IECore datatypes. -class IECORENUKE_API FromNukeConverter : public IECore::ToCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromNukeConverter, FromNukeConverterTypeId, IECore::ToCoreConverter ); - - protected : - - FromNukeConverter( const std::string &description ); - virtual ~FromNukeConverter(); - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_FROMNUKECONVERTER_H diff --git a/include/IECoreNuke/FromNukePointsConverter.h b/include/IECoreNuke/FromNukePointsConverter.h deleted file mode 100644 index 92eb064ea1..0000000000 --- a/include/IECoreNuke/FromNukePointsConverter.h +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FROMNUKEPOINTSCONVERTER_H -#define IECORENUKE_FROMNUKEPOINTSCONVERTER_H - -#include "IECoreNuke/FromNukeConverter.h" - -#include "DDImage/GeoInfo.h" - -namespace IECoreNuke -{ - -/// The FromNukePointsConverter class converts Nuke GeoInfo objects -/// into IECore::PointsPrimitive objects. -/// \todo Might be good to have a FromNukeGeometryConverter as a base -/// class of this and MeshFromNuke. -/// \ingroup conversionGroup. -class IECORENUKE_API FromNukePointsConverter : public FromNukeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromNukePointsConverter, FromNukePointsConverterTypeId, FromNukePointsConverter ); - - /// The caller is responsible for ensuring that geo is alive - /// for as long as the converter is. - FromNukePointsConverter( const DD::Image::GeoInfo *geo, DD::Image::Op* op ); - virtual ~FromNukePointsConverter(); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - const DD::Image::GeoInfo *m_geo; - DD::Image::Op* m_op; - -}; - -IE_CORE_DECLAREPTR( FromNukePointsConverter ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_FROMNUKEPOINTSCONVERTER_H diff --git a/include/IECoreNuke/FromNukeTileConverter.h b/include/IECoreNuke/FromNukeTileConverter.h deleted file mode 100644 index ab4264f8d4..0000000000 --- a/include/IECoreNuke/FromNukeTileConverter.h +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FROMNUKETILECONVERTER_H -#define IECORENUKE_FROMNUKETILECONVERTER_H - -#include "IECoreNuke/FromNukeConverter.h" - -#include "DDImage/Tile.h" - -namespace IECoreNuke -{ - -/// The FromNukeTileConverter converts DD::Image::Tiles into IECore::ImagePrimitives. -/// \ingroup conversionGroup. -class IECORENUKE_API FromNukeTileConverter : public FromNukeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromNukeTileConverter, FromNukeTileConverterTypeId, FromNukeConverter ); - - /// The caller is responsible for ensuring that tile is alive - /// for as long as the converter is. - FromNukeTileConverter( const DD::Image::Tile *tile ); - virtual ~FromNukeTileConverter(); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - const DD::Image::Tile *m_tile; - -}; - -IE_CORE_DECLAREPTR( FromNukeTileConverter ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_FROMNUKETILECONVERTER_H diff --git a/include/IECoreNuke/Hash.h b/include/IECoreNuke/Hash.h deleted file mode 100644 index 553109c3f1..0000000000 --- a/include/IECoreNuke/Hash.h +++ /dev/null @@ -1,80 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_HASH_H -#define IECORENUKE_HASH_H - -#include "IECore/Export.h" - -#include "DDImage/Hash.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathBox.h" -#include "Imath/ImathColor.h" -#include "Imath/ImathMatrix.h" -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// Appends the contents of an Imath::Vec2 to a hash -template -void append( DD::Image::Hash &hash, const Imath::Vec2 &v ); - -/// Appends the contents of an Imath::Vec3 to a hash -template -void append( DD::Image::Hash &hash, const Imath::Vec3 &v ); - -/// Appends the contents of an Imath::Color4 to a hash -template -void append( DD::Image::Hash &hash, const Imath::Color4 &c ); - -/// Appends the contents of an Imath::Box to a hash -template -void append( DD::Image::Hash &hash, const Imath::Box &b ); - -/// Appends the contents of an Imath::Matrix33 to a hash -template -void append( DD::Image::Hash &hash, const Imath::Matrix33 &m ); - -/// Appends the contents of an Imath::Matrix44 to a hash -template -void append( DD::Image::Hash &hash, const Imath::Matrix44 &m ); - -} // namespace IECoreNuke - -#include "IECoreNuke/Hash.inl" - -#endif // IECORENUKE_HASH_H diff --git a/include/IECoreNuke/Hash.inl b/include/IECoreNuke/Hash.inl deleted file mode 100644 index 93f18030d6..0000000000 --- a/include/IECoreNuke/Hash.inl +++ /dev/null @@ -1,95 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_HASH_INL -#define IECORENUKE_HASH_INL - -namespace IECoreNuke -{ - -template -void append( DD::Image::Hash &hash, const Imath::Vec2 &v ) -{ - for( unsigned i=0; i -void append( DD::Image::Hash &hash, const Imath::Vec3 &v ) -{ - for( unsigned i=0; i -void append( DD::Image::Hash &hash, const Imath::Color4 &v ) -{ - for( unsigned i=0; i -void append( DD::Image::Hash &hash, const Imath::Box &b ) -{ - append( hash, b.min ); - append( hash, b.max ); -} - -template -void append( DD::Image::Hash &hash, const Imath::Matrix33 &m ) -{ - for( int i=0; i<9; i++ ) - { - hash.append( m.getValue()[i] ); - } -} - -template -void append( DD::Image::Hash &hash, const Imath::Matrix44 &m ) -{ - for( int i=0; i<16; i++ ) - { - hash.append( m.getValue()[i] ); - } -} - -} // namespace IECoreNuke - -#endif // IECORENUKE_HASH_INL diff --git a/include/IECoreNuke/ImagePrimitiveParameterHandler.h b/include/IECoreNuke/ImagePrimitiveParameterHandler.h deleted file mode 100644 index 84b4aa9367..0000000000 --- a/include/IECoreNuke/ImagePrimitiveParameterHandler.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_IMAGEPRIMITIVEPARAMETERHANDLER_H -#define IECORENUKE_IMAGEPRIMITIVEPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API ImagePrimitiveParameterHandler : public ParameterHandler -{ - - public : - - ImagePrimitiveParameterHandler(); - - virtual int minimumInputs( const IECore::Parameter *parameter ); - virtual int maximumInputs( const IECore::Parameter *parameter ); - virtual bool testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ); - virtual void setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ); - - protected : - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_IMAGEPRIMITIVEPARAMETERHANDLER_H diff --git a/include/IECoreNuke/IntParameterHandler.h b/include/IECoreNuke/IntParameterHandler.h deleted file mode 100644 index 1ea1654761..0000000000 --- a/include/IECoreNuke/IntParameterHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_INTPARAMETERHANDLER_H -#define IECORENUKE_INTPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API IntParameterHandler : public ParameterHandler -{ - - public : - - IntParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - int m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_INTPARAMETERHANDLER_H diff --git a/include/IECoreNuke/LensDistort.h b/include/IECoreNuke/LensDistort.h deleted file mode 100644 index cf518d32ee..0000000000 --- a/include/IECoreNuke/LensDistort.h +++ /dev/null @@ -1,195 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Weta Digital Limited. All rights reserved. -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LENSDISTORT_H -#define IECORENUKE_LENSDISTORT_H - -#include "IECoreNuke/Export.h" - -#include "IECore/LensModel.h" - -#include "DDImage/Filter.h" -#include "DDImage/Iop.h" -#include "DDImage/Knobs.h" -#include "DDImage/Row.h" -#include "DDImage/Thread.h" - -namespace IECoreNuke -{ - -/// LensDistort -/// Uses the IECore::LensModel libraries to distort or undistort a plate or sequence. -/// The LensDistort node provides a nuke interface to the IECore::LensDistort libraries. -/// It queries any registered lens models, displaying them within the pull-down menu of the "lens model" -/// knob. When a lens model is selected the node will dynamically create the required knobs on the -/// UI panel. An additional knob has been added to allow the input of a sequence of lens models -/// which have been serialized into .cob files. -/// -/// Weta Digitals LensDistortion node was referenced when designing this node. -/// Their source code is available freely at: https://github.com/wetadigital/lensDistortion_3de -class IECORENUKE_API LensDistort : public DD::Image::Iop -{ - /// PluginAttribute - /// A small struct for maintaining a list of the knobs on the UI and their values. - struct PluginAttribute - { - public: - - PluginAttribute( std::string name, double defaultValue = 0. ) : - m_name( name ), - m_knob( NULL ), - m_value( defaultValue ), - m_low( 0. ), - m_high( 1. ) - {}; - - PluginAttribute() : - m_name( "Unused" ), - m_knob( NULL ), - m_value( 0. ), - m_low( 0. ), - m_high( 1. ) - {}; - - std::string m_name; - DD::Image::Knob *m_knob; - std::string m_script; - double m_value; - double m_low; - double m_high; - }; - - typedef std::vector< PluginAttribute > PluginAttributeList; - - public: - - enum - { - Distort, - Undistort - }; - - LensDistort( Node* node ); - - inline int getLensModel() const { return (int)knob("model")->get_value(); }; - inline PluginAttributeList &attributeList() { return m_pluginAttributes; }; - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual int knob_changed( DD::Image::Knob* k ); - virtual void append( DD::Image::Hash &hash ); - virtual void _request( int x, int y, int r, int t, DD::Image::ChannelMask channels, int count ); - virtual const char *Class() const; - virtual const char *node_help() const; - virtual void _validate( bool for_real ); - virtual void engine( int y, int x, int r, DD::Image::ChannelMask channels, DD::Image::Row & outrow ); - - static void buildDynamicKnobs( void*, DD::Image::Knob_Callback f ); - static void addDynamicKnobs( void*, DD::Image::Knob_Callback f ); - static const Iop::Description m_description; - static DD::Image::Op *build( Node *node ); - - private: - - /// Returns an array of const char* which is populated with the available lens models. - static const char ** modelNames(); - static int indexFromModelName( const char *name ); - - /// Sets the lens model to use by calling the appropriate creators.. - void setLensModel( IECore::ConstCompoundObjectPtr parameters ); - void setLensModel( std::string modelName ); - - /// Updates the internal list of lens parameters (and their associated knobs) to those defined within the current lens models. - /// This method should only be called at the end of setLensModel. - /// @param updateKnobsFromParameters If this value is true then all knobs will be updated to the new lens model's parameters and any existing knob values. - /// will be discarded. If this value is false then the values of common parameters between the current and new lens model will be copied across. - void updateLensModel( bool updateKnobsFromParameters = false ); - - /// Returns true if there is text in the file sequence knob. The contents of the knob are returned in the attribute 'path'. - bool getFileSequencePath( std::string& path ); - - /// Checks that the file sequence is valid and then loads the required file from it. File sequences of the format path.#.ext and path.%0Xd.ext will have their - /// wild card characters replaced and set to the current frame. - /// @param returnPath The path of the file that has been loaded. - /// @return Whether or not the file path was successful. - bool setLensFromFile( std::string &returnPath ); - - /// Iterates over all of the lens model's attributes and if they are associated with a knob, retrieves the information from the knob. - void updatePluginAttributesFromKnobs(); - - /// Updates the dynamic knobs. This method should be called whenever a knob is changed or an event happens that requires - /// the dynamic knobs to be recreated or their enabled state changed. - void updateUI(); - - /// The maximum number of threads that we are going to use in parallel. - const int m_nThreads; - - /// Plugin loaders. We need one of these per threads to make the lens lib thread safe. - std::vector< IECore::LensModelPtr > m_model; - - /// locks for each LensModel object - DD::Image::Lock* m_locks; - - /// A list of the attributes that the plugin uses. - PluginAttributeList m_pluginAttributes; - - /// Which lens model we are currently using. - int m_lensModel; - - /// Used to track the number of knobs created by the previous pass, so that the same number can be deleted next time. - int m_numNewKnobs; - - /// The method of filtering. Defined by the 'filter' knob. - DD::Image::Filter m_filter; - - /// Pointer to the 'mode' knob. - DD::Image::Knob *m_kModel; - - /// Distort or undistort. - int m_mode; - - /// All knobs below this one are dynamic. - DD::Image::Knob* m_lastStaticKnob; - - /// Path that holds the file sequence information. - const char *m_assetPath; - - /// Set within the knob_changed method to indicate whether a valid file sequence has been entered. - bool m_hasValidFileSequence; - bool m_useFileSequence; -}; - -}; - -#endif diff --git a/include/IECoreNuke/LineSegment3ParameterHandler.h b/include/IECoreNuke/LineSegment3ParameterHandler.h deleted file mode 100644 index 2c8b162f40..0000000000 --- a/include/IECoreNuke/LineSegment3ParameterHandler.h +++ /dev/null @@ -1,69 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LINESEGMENT3PARAMETERHANDLER_H -#define IECORENUKE_LINESEGMENT3PARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -#include "IECore/LineSegment.h" - -namespace IECoreNuke -{ - -template -class IECORENUKE_API LineSegment3ParameterHandler : public ParameterHandler -{ - - public : - - LineSegment3ParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - IECore::LineSegment3f m_storage; - DD::Image::Knob *m_startKnob; - DD::Image::Knob *m_endKnob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_LINESEGMENT3PARAMETERHANDLER_H diff --git a/include/IECoreNuke/LiveScene.h b/include/IECoreNuke/LiveScene.h deleted file mode 100644 index 4b6be321d1..0000000000 --- a/include/IECoreNuke/LiveScene.h +++ /dev/null @@ -1,144 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LIVESCENE_H -#define IECORENUKE_LIVESCENE_H - -#include "DDImage/GeoOp.h" -#include "DDImage/GeometryList.h" - -#include "IECore/PathMatcher.h" - -#include "IECoreScene/SceneInterface.h" - -#include "IECoreNuke/Export.h" -#include "IECoreNuke/TypeIds.h" - -namespace IECoreNuke -{ - -IE_CORE_FORWARDDECLARE( LiveScene ); - -/// A read-only class for representing a live Nuke scene as an IECore::SceneInterface -class IECORENUKE_API LiveScene : public IECoreScene::SceneInterface -{ - public : - - static const std::string& nameAttribute; - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( LiveScene, LiveSceneTypeId, IECoreScene::SceneInterface ); - - LiveScene(); - LiveScene( DD::Image::GeoOp *op, const IECoreScene::SceneInterface::Path& rootPath=IECoreScene::SceneInterface::rootPath ); - - ~LiveScene() override; - - std::string fileName() const override; - - Name name() const override; - void path( Path &p ) const override; - - Imath::Box3d readBound( double time ) const override; - void writeBound( const Imath::Box3d &bound, double time ); - - IECore::ConstDataPtr readTransform( double time ) const override; - Imath::M44d readTransformAsMatrix( double time ) const override; - IECore::ConstDataPtr readWorldTransform( double time ) const; - Imath::M44d readWorldTransformAsMatrix( double time ) const; - void writeTransform( const IECore::Data *transform, double time ) override; - - bool hasAttribute( const Name &name ) const override; - void attributeNames( NameList &attrs ) const override; - IECore::ConstObjectPtr readAttribute( const Name &name, double time ) const override; - void writeAttribute( const Name &name, const IECore::Object *attribute, double time ) override; - - bool hasTag( const Name &name, int filter = SceneInterface::LocalTag ) const override; - void readTags( NameList &tags, int filter = SceneInterface::LocalTag ) const override; - void writeTags( const NameList &tags ) override; - - NameList setNames( bool includeDescendantSets = true ) const override; - IECore::PathMatcher readSet( const Name &name, bool includeDescendantSets = true, const IECore::Canceller *canceller = nullptr ) const override; - void writeSet( const Name &name, const IECore::PathMatcher &set ) override; - void hashSet( const Name& setName, IECore::MurmurHash &h ) const override; - - bool hasObject() const override; - IECore::ConstObjectPtr readObject( double time, const IECore::Canceller *canceller = nullptr ) const override; - IECoreScene::PrimitiveVariableMap readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const override; - void writeObject( const IECore::Object *object, double time ) override; - - void childNames( NameList &childNames ) const override; - bool hasChild( const Name &name ) const override; - IECoreScene::SceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - IECoreScene::ConstSceneInterfacePtr child( const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - IECoreScene::SceneInterfacePtr createChild( const Name &name ) override; - - IECoreScene::SceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) override; - IECoreScene::ConstSceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing ) const override; - - void hash( HashType hashType, double time, IECore::MurmurHash &h ) const override; - - static double timeToFrame( const double& time ); - static double frameToTime( const int& frame ); - - typedef std::map FrameGeometryCache; - typedef std::map OpGeometryCache; - typedef std::map LiveSceneGeometryCache; - - void setOp( DD::Image::GeoOp* op ); - const DD::Image::GeoOp *getOp() const; - - private: - - DD::Image::GeometryList geometryList( const double& frame ) const; - DD::Image::GeometryList geometryList( DD::Image::Op* op, const double& frame ) const; - unsigned objectNum( const double* time=nullptr ) const; - DD::Image::GeoInfo* object( const unsigned& index, const double* time=nullptr ) const; - - std::string geoInfoPath( const int& index ) const; - - DD::Image::GeoOp *m_op; - //std::string m_rootPath; - IECoreScene::SceneInterface::Path m_rootPath; - IECore::PathMatcher m_pathMatcher; - typedef std::map objectPathMap; - mutable objectPathMap m_objectPathMap; - - void cacheGeometryList( const double& frame ) const; -}; - -IE_CORE_DECLAREPTR( LiveScene ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_LIVESCENE_H diff --git a/include/IECoreNuke/LiveSceneHolder.h b/include/IECoreNuke/LiveSceneHolder.h deleted file mode 100644 index 15022d9c3a..0000000000 --- a/include/IECoreNuke/LiveSceneHolder.h +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LIVESCENEHOLDER_H -#define IECORENUKE_LIVESCENEHOLDER_H - -#include "DDImage/GeoOp.h" - -#include "IECoreNuke/Export.h" -#include "IECoreNuke/LiveScene.h" - - -namespace IECoreNuke -{ - -/// This Op does no processing, but simply provides a single LiveSceneKnob. -/// This is mainly used for the LiveSceneKnob test cases. -class IECORENUKE_API LiveSceneHolder : public DD::Image::GeoOp -{ - - public : - - LiveSceneHolder( Node *node ); - virtual ~LiveSceneHolder(); - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual const char *Class() const; - virtual const char *node_help() const; - IECoreNuke::LiveScenePtr liveScene(); - - private : - - static const Description g_description; - static DD::Image::Op *build( Node *node ); - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_LIVESCENEHOLDER_H diff --git a/include/IECoreNuke/LiveSceneKnob.h b/include/IECoreNuke/LiveSceneKnob.h deleted file mode 100644 index e5ed2716d8..0000000000 --- a/include/IECoreNuke/LiveSceneKnob.h +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LIVESCENEKNOB_H -#define IECORENUKE_LIVESCENEKNOB_H - -#include "IECoreNuke/Export.h" - -#include "IECoreNuke/LiveSceneHolder.h" -#include "IECoreNuke/LiveScene.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "DDImage/Knobs.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// A nuke knob capable of holding arbitrary IECore::LiveScenes. -class IECORENUKE_API LiveSceneKnob : public DD::Image::Knob -{ - - public : - - IECoreNuke::LiveScenePtr getValue(); - - /// Call this from an Op::knobs() implementation to create an LiveSceneKnob. - static LiveSceneKnob *sceneKnob( DD::Image::Knob_Callback f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label ); - - protected : - - LiveSceneKnob( DD::Image::Knob_Closure *f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label = 0 ); - virtual ~LiveSceneKnob(); - - virtual const char *Class() const; - - private : - - IECoreNuke::LiveScenePtr m_value; - IECoreNuke::LiveSceneHolder* m_op; - -}; - -namespace Detail -{ - -// Used to implement the python binding -struct PythonLiveSceneKnob : public IECore::RefCounted -{ - - IE_CORE_DECLAREMEMBERPTR( PythonLiveSceneKnob ); - - LiveSceneKnob *sceneKnob; - -}; - -IE_CORE_DECLAREPTR( PythonLiveSceneKnob ); - -} // namespace Detail - -} // namespace IECoreNuke - -#endif // IECORENUKE_LIVESCENEKNOB_H diff --git a/include/IECoreNuke/MeshFromNuke.h b/include/IECoreNuke/MeshFromNuke.h deleted file mode 100644 index 8cc07d0bea..0000000000 --- a/include/IECoreNuke/MeshFromNuke.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_MESHFROMNUKE_H -#define IECORENUKE_MESHFROMNUKE_H - -#include "IECoreNuke/FromNukeConverter.h" - -#include "DDImage/GeoInfo.h" - -namespace IECoreNuke -{ - -/// The MeshFromNuke class converts Nuke GeoInfo objects -/// into IECore::MeshPrimitive objects. -/// \todo Sort out the naming of this and other converters so they follow the convention used -/// elsewhere in cortex - particularly IECoreMaya. -class IECORENUKE_API MeshFromNuke : public FromNukeConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( MeshFromNuke, MeshFromNukeTypeId, FromNukeConverter ); - - /// The caller is responsible for ensuring that geo is alive - /// for as long as the converter is. - MeshFromNuke( const DD::Image::GeoInfo *geo ); - virtual ~MeshFromNuke(); - - protected : - - virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const; - - private : - - const DD::Image::GeoInfo *m_geo; - -}; - -IE_CORE_DECLAREPTR( MeshFromNuke ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_MESHFROMNUKE_H diff --git a/include/IECoreNuke/MeshPrimitiveParameterHandler.h b/include/IECoreNuke/MeshPrimitiveParameterHandler.h deleted file mode 100644 index fa0fc7f574..0000000000 --- a/include/IECoreNuke/MeshPrimitiveParameterHandler.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_MESHPRIMITIVEPARAMETERHANDLER_H -#define IECORENUKE_MESHPRIMITIVEPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API MeshPrimitiveParameterHandler : public ParameterHandler -{ - - public : - - MeshPrimitiveParameterHandler(); - - virtual int minimumInputs( const IECore::Parameter *parameter ); - virtual int maximumInputs( const IECore::Parameter *parameter ); - virtual bool testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ); - virtual void setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ); - - protected : - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_MESHPRIMITIVEPARAMETERHANDLER_H diff --git a/include/IECoreNuke/MeshToNukeGeometryConverter.h b/include/IECoreNuke/MeshToNukeGeometryConverter.h deleted file mode 100644 index 3acf70fdbf..0000000000 --- a/include/IECoreNuke/MeshToNukeGeometryConverter.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_MESHTONUKEGEOMETRYCONVERTER_H -#define IECORENUKE_MESHTONUKEGEOMETRYCONVERTER_H - -#include "IECoreNuke/ToNukeGeometryConverter.h" - - -namespace IECoreNuke -{ - -/// This class converts IECore.MeshPrimitive objects to geometry in a Nuke GeometryList object. -/// \todo Sort out the naming of this and other converters so they follow the convention used -/// elsewhere in cortex - particularly IECoreMaya. -/// \ingroup conversionGroup. -class IECORENUKE_API MeshToNukeGeometryConverter : public ToNukeGeometryConverter -{ - public: - - MeshToNukeGeometryConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual void doConversion( const IECore::Object *from, DD::Image::GeometryList &to, int objIndex, const IECore::CompoundObject *operands ) const; - - typedef ToNukeGeometryConverterDescription Description; - static Description g_description; -}; - -} - -#endif // IECORENUKE_MESHTONUKEGEOMETRYCONVERTER_H diff --git a/include/IECoreNuke/ObjectHolder.h b/include/IECoreNuke/ObjectHolder.h deleted file mode 100644 index d016a02036..0000000000 --- a/include/IECoreNuke/ObjectHolder.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_OBJECTHOLDER_H -#define IECORENUKE_OBJECTHOLDER_H - -#include "IECoreNuke/Export.h" - -#include "IECore/Object.h" - -#include "DDImage/Op.h" - -namespace IECoreNuke -{ - -/// This Op does no processing, but simply provides a single ObjectKnob. -/// This is mainly used for the ObjectKnob test cases, but may also be of use -/// for storing arbitrary cortex data in a script. -class IECORENUKE_API ObjectHolder : public DD::Image::Op -{ - - public : - - ObjectHolder( Node *node ); - virtual ~ObjectHolder(); - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual const char *Class() const; - virtual const char *node_help() const; - - private : - - static const Description g_description; - static DD::Image::Op *build( Node *node ); - - // class specification - IECore::ObjectPtr m_object; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_OBJECTHOLDER_H diff --git a/include/IECoreNuke/ObjectKnob.h b/include/IECoreNuke/ObjectKnob.h deleted file mode 100644 index 08c72852ea..0000000000 --- a/include/IECoreNuke/ObjectKnob.h +++ /dev/null @@ -1,104 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_OBJECTKNOB_H -#define IECORENUKE_OBJECTKNOB_H - -#include "IECoreNuke/Export.h" - -#include "IECore/Object.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "DDImage/Knobs.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// A nuke knob capable of holding arbitrary IECore::Objects. -class IECORENUKE_API ObjectKnob : public DD::Image::Knob -{ - - public : - - /// A copy of the value is taken. Returns true if the new value is different - /// to the old value and false otherwise. - bool setValue( IECore::ConstObjectPtr value ); - IECore::ConstObjectPtr getValue() const; - - /// Call this from an Op::knobs() implementation to create an ObjectKnob. The value placed in storage by the knob - /// must be treated as read only. - static ObjectKnob *objectKnob( DD::Image::Knob_Callback f, IECore::ObjectPtr *storage, const char *name, const char *label ); - - protected : - - ObjectKnob( DD::Image::Knob_Closure *f, IECore::ObjectPtr *storage, const char *name, const char *label = 0 ); - virtual ~ObjectKnob(); - - virtual const char *Class() const; - - virtual void to_script( std::ostream &os, const DD::Image::OutputContext *context, bool quote ) const; - virtual bool from_script( const char *value ); - virtual bool not_default() const; - virtual void store( DD::Image::StoreType storeType, void *storage, DD::Image::Hash &hash, const DD::Image::OutputContext &context ); - - private : - - bool valuesEqual( const IECore::Object *value1, const IECore::Object *value2 ) const; - - IECore::ObjectPtr m_defaultValue; - IECore::ObjectPtr m_value; - -}; - -namespace Detail -{ - -// Used to implement the python binding -struct PythonObjectKnob : public IECore::RefCounted -{ - - IE_CORE_DECLAREMEMBERPTR( PythonObjectKnob ); - - ObjectKnob *objectKnob; - -}; - -IE_CORE_DECLAREPTR( PythonObjectKnob ); - -} // namespace Detail - -} // namespace IECoreNuke - -#endif // IECORENUKE_OBJECTKNOB_H diff --git a/include/IECoreNuke/ObjectVectorParameterHandler.h b/include/IECoreNuke/ObjectVectorParameterHandler.h deleted file mode 100644 index eb6186e998..0000000000 --- a/include/IECoreNuke/ObjectVectorParameterHandler.h +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_OBJECTVECTORPARAMETERHANDLER_H -#define IECORENUKE_OBJECTVECTORPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API ObjectVectorParameterHandler : public ParameterHandler -{ - - public : - - ObjectVectorParameterHandler(); - - virtual int minimumInputs( const IECore::Parameter *parameter ); - virtual int maximumInputs( const IECore::Parameter *parameter ); - virtual bool testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ); - virtual void setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ); - - protected : - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_OBJECTVECTORPARAMETERHANDLER_H diff --git a/include/IECoreNuke/OpHolder.h b/include/IECoreNuke/OpHolder.h deleted file mode 100644 index 3eff69356b..0000000000 --- a/include/IECoreNuke/OpHolder.h +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_OPHOLDER_H -#define IECORENUKE_OPHOLDER_H - -#include "IECoreNuke/ParameterisedHolder.h" - -#include "IECore/Op.h" - -#include "DDImage/Executable.h" -#include "DDImage/Op.h" - -namespace IECoreNuke -{ - -/// This class allows IECore::Op objects to be executed by nodes in Nuke. -class IECORENUKE_API OpHolder : public ParameterisedHolderOp, public DD::Image::Executable -{ - - public : - - OpHolder( Node *node ); - virtual ~OpHolder(); - - //! @name Reimplementation of Nuke methods. - ///////////////////////////////////////////////////////////////////// - //@{ - virtual const char *Class() const; - virtual const char *node_help() const; - virtual DD::Image::Executable *executable(); - virtual void execute(); - /// \todo We /are/ threadsafe, but Nuke doesn't release the - /// GIL when calling through to here from nuke.execute(). - /// We therefore have to pretend not to be threadsafe - if - /// they fix this we can return true from this instead of false. - virtual bool isExecuteThreadSafe() const; - virtual bool isWrite(); - //@} - - /// Executes the held IECore::Op and returns the result. - virtual IECore::ObjectPtr engine(); - - private : - - static const Description g_description; - static DD::Image::Op *build( Node *node ); - - IECore::ObjectPtr m_result; - DD::Image::Hash m_resultHash; - - static IECore::ObjectPtr executeResult(); - - friend void bindFnOpHolder(); - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_OPHOLDER_H diff --git a/include/IECoreNuke/ParameterHandler.h b/include/IECoreNuke/ParameterHandler.h deleted file mode 100644 index 6c4020280c..0000000000 --- a/include/IECoreNuke/ParameterHandler.h +++ /dev/null @@ -1,143 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_PARAMETERHANDLER_H -#define IECORENUKE_PARAMETERHANDLER_H - -#include "IECoreNuke/Export.h" - -#include "IECore/Parameter.h" - -#include "DDImage/Op.h" - -namespace IECoreNuke -{ - -IE_CORE_FORWARDDECLARE( ParameterHandler ) - -/// ParameterHandlers are responsible for mapping between IECore::Parameters -/// and DD::Image::Knobs and DD::Image::Op inputs. -class IECORENUKE_API ParameterHandler : public IECore::RefCounted -{ - - public : - - enum ValueSource - { - Knob, - Storage - }; - - typedef std::vector::const_iterator InputIterator; - - /// Returns the minimum number of inputs this Parameter needs to represent itself. - /// Defaults to 0, as most ParameterHandlers will instead use the knobs() mechanism - /// below. - virtual int minimumInputs( const IECore::Parameter *parameter ); - /// Returns the maximum number of inputs this Parameter needs to represent itself, also - /// defaulting to 0. Please note that it is only possible for the last Parameter on - /// any given node to have min!=max - warnings will be issued if this is not the case. - virtual int maximumInputs( const IECore::Parameter *parameter ); - /// Returns true if the specified op is suitable for connection for the specified input. - /// Here the input number is relative to the ParameterHandler rather than being absolute for - /// the Node. Default implementation returns false. - virtual bool testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ); - /// Sets the value of the parameter from the inputs created based on the result of minimumInputs() - /// and maximumInputs(). - virtual void setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ); - - /// Declares knobs to represent the Parameter. - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - /// Transfers the value from Nuke onto the Parameter. ValueSource may be passed - /// a value of Knob if it is known that Nuke hasn't stored knob - /// values yet - for instance in a knob_changed() method with - /// a KNOB_CHANGED_ALWAYS knob. This causes the value to be retrieved - /// directly from the knob at the current time, rather than from the - /// value stored by the knob. - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - /// Transfers the value from the Parameter back onto the nuke knob at the current time. - virtual void setKnobValue( const IECore::Parameter *parameter ); - /// ParameterHandlers may need to store state separately from the knobs they create, - /// so that it is available to the first knobs() call when scripts are loaded. This - /// function may be implemented to return such state, and the client must make sure - /// it is restored via setState() before knobs() is called. - virtual IECore::ObjectPtr getState( const IECore::Parameter *parameter ); - /// Restore state previously retrieved by getState(). - virtual void setState( IECore::Parameter *parameter, const IECore::Object *state ); - - /// Factory function to create a ParameterHandler suitable for a given Parameter. - static ParameterHandlerPtr create( const IECore::Parameter *parameter ); - - protected : - - ParameterHandler(); - - /// Should be called by derived classes to get a good label for the main knob - std::string knobLabel( const IECore::Parameter *parameter ) const; - /// Should be called by derived classes to set the properties for the main knob based - /// on userData on the parameter. This sets visibility and tooltip and applies any default - /// expressions. - void setKnobProperties( const IECore::Parameter *parameter, DD::Image::Knob_Callback f, DD::Image::Knob *knob ) const; - - template - class Description - { - public : - - Description( IECore::TypeId parameterType ) - { - creatorFns()[parameterType] = creator; - } - - private : - - static ParameterHandlerPtr creator() - { - return new T(); - } - - }; - - private : - - typedef ParameterHandlerPtr (*CreatorFn)(); - - typedef std::map CreatorFnMap; - static CreatorFnMap &creatorFns(); - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_PARAMETERHANDLER_H diff --git a/include/IECoreNuke/ParameterisedHolder.h b/include/IECoreNuke/ParameterisedHolder.h deleted file mode 100644 index db9cc2e13e..0000000000 --- a/include/IECoreNuke/ParameterisedHolder.h +++ /dev/null @@ -1,135 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_PARAMETERISEDHOLDER_H -#define IECORENUKE_PARAMETERISEDHOLDER_H - -#include "IECoreNuke/ObjectKnob.h" -#include "IECoreNuke/ParameterHandler.h" - -#include "IECore/Parameter.h" -#include "IECore/Parameterised.h" - -namespace IECoreNuke -{ - -template -class IECORENUKE_API ParameterisedHolder : public BaseType -{ - - public : - - ParameterisedHolder( Node *node ); - virtual ~ParameterisedHolder(); - - //! @name Reimplementation of functions defined by the Nuke BaseType. - ///////////////////////////////////////////////////////////////////// - //@{ - /// Uses a ParameterHandler to define the number of inputs. - virtual int minimum_inputs() const; - virtual int maximum_inputs() const; - virtual bool test_input( int input, DD::Image::Op *op ) const; - /// Calls knobs() on a ParameterHandler to represent the Parameters. - virtual void knobs( DD::Image::Knob_Callback f ); - /// Implemented to load the Parameterised class. - virtual int knob_changed( DD::Image::Knob *knob ); - /// Implemented to store the knob values into the held Parameters. - virtual void _validate( bool forReal ); - //@} - - /// Returns the class instance held by this DD::Image::Op instance. - /// Note that this is not a copy as with FnParameterisedHolder::getParameterised but is - /// instead the internal class ready for use in processing in c++. - /// If validate() has been called the parameter values will be up to date - /// with respect to the knob values. - IECore::ConstRunTimeTypedPtr parameterised(); - /// Convenience method to return dynamic_cast( parameterised().get() ) - const IECore::ParameterisedInterface *parameterisedInterface(); - - protected : - - void setParameterValuesFromInputs(); - void setParameterValues(); - void setKnobValues(); - - /// Equivalent to DD::Image::Op::build_knob_handles(), but only processes - /// knobs that represent parameters. - void buildParameterKnobHandles( DD::Image::ViewerContext *ctx ) const; - - private : - - // class specification - //////////////////////////////////////////////////// - ObjectKnob *m_classSpecifierKnob; - DD::Image::Knob *m_versionChooserKnob; // for display of class name and user selection of version - DD::Image::Knob *m_classReloadKnob; // for user to trigger reloading - DD::Image::Knob *m_classDividerKnob; - void updateVersionChooser(); - - // class loading - //////////////////////////////////////////////////// - IECore::RunTimeTypedPtr m_parameterised; - IECore::ConstObjectPtr m_currentClassSpecification; // contents of m_classSpecifierKnob last time we updated - // loads and returns an instance of the class specified by m_classSpecifierKnob. - // this does not set m_parameterised. - IECore::RunTimeTypedPtr loadClass( bool refreshLoader ); - // makes sure that m_parameterised is up to date with the class and state dictated by - // m_classSpecifierKnob, and also makes sure that m_parameterHandler is valid. - void updateParameterised( bool reload ); - - // knob creation - //////////////////////////////////////////////////// - ParameterHandlerPtr m_parameterHandler; - size_t m_numParameterKnobs; - void replaceKnobs(); - static void parameterKnobs( void *that, DD::Image::Knob_Callback f ); - - // FnParameterisedHolder support - //////////////////////////////////////////////////// - - DD::Image::Knob *m_getParameterisedKnob; // this knob triggers a simulated getParameterised function. - static IECore::RunTimeTypedPtr getParameterisedResult(); // and this function retrieves the result - - DD::Image::Knob *m_modifiedParametersKnob; // this knob triggers a simulated function call to do the work of FnParameterisedHolder.parameterModificationContext() - static void setModifiedParametersInput( IECore::RunTimeTypedPtr parameterised ); // and this function specifies the parameter values to set the knobs from - - friend void bindFnParameterisedHolder(); - -}; - -typedef ParameterisedHolder ParameterisedHolderOp; - -} // namespace IECoreNuke - -#endif // IECORENUKE_PARAMETERISEDHOLDER_H diff --git a/include/IECoreNuke/PathParameterHandler.h b/include/IECoreNuke/PathParameterHandler.h deleted file mode 100644 index dfd783254b..0000000000 --- a/include/IECoreNuke/PathParameterHandler.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_PATHPARAMETERHANDLER_H -#define IECORENUKE_PATHPARAMETERHANDLER_H - -#include "IECoreNuke/StringParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API PathParameterHandler : public StringParameterHandler -{ - - public : - - PathParameterHandler(); - - protected : - - virtual DD::Image::Knob *knob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f, const char **storage ); - - private : - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_PATHPARAMETERHANDLER_H diff --git a/include/IECoreNuke/PointToNukeGeometryConverter.h b/include/IECoreNuke/PointToNukeGeometryConverter.h deleted file mode 100644 index 53876fb7af..0000000000 --- a/include/IECoreNuke/PointToNukeGeometryConverter.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_POINTTONUKEGEOMETRYCONVERTER_H -#define IECORENUKE_POINTTONUKEGEOMETRYCONVERTER_H - -#include "IECoreNuke/ToNukeGeometryConverter.h" - - -namespace IECoreNuke -{ - -/// This class converts IECore.PointPrimitive objects to geometry in a Nuke GeometryList object. -/// \todo Sort out the naming of this and other converters so they follow the convention used -/// elsewhere in cortex - particularly IECoreMaya. -/// \ingroup conversionGroup. -class IECORENUKE_API PointToNukeGeometryConverter : public ToNukeGeometryConverter -{ - public: - - PointToNukeGeometryConverter( IECore::ConstObjectPtr object ); - - protected: - - virtual void doConversion( const IECore::Object *from, DD::Image::GeometryList &to, int objIndex, const IECore::CompoundObject *operands ) const; - - typedef ToNukeGeometryConverterDescription Description; - static Description g_description; -}; - -} - -#endif // IECORENUKE_POINTTONUKEGEOMETRYCONVERTER_H diff --git a/include/IECoreNuke/PresetsOnlyParameterHandler.h b/include/IECoreNuke/PresetsOnlyParameterHandler.h deleted file mode 100644 index c2bf76cbe9..0000000000 --- a/include/IECoreNuke/PresetsOnlyParameterHandler.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_PRESETSONLYPARAMETERHANDLER_H -#define IECORENUKE_PRESETSONLYPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API PresetsOnlyParameterHandler : public ParameterHandler -{ - - public : - - PresetsOnlyParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - int m_storage; - DD::Image::Knob *m_knob; - std::vector m_names; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_PRESETSONLYPARAMETERHANDLER_H diff --git a/include/IECoreNuke/SceneCacheReader.h b/include/IECoreNuke/SceneCacheReader.h deleted file mode 100644 index 68758dafb4..0000000000 --- a/include/IECoreNuke/SceneCacheReader.h +++ /dev/null @@ -1,182 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IENUKE_SCENECACHEREADER_H -#define IENUKE_SCENECACHEREADER_H - -#include "IECoreNuke/Export.h" - -#include "IECoreGL/Renderer.h" -#include "IECoreGL/Scene.h" - -#include "IECoreScene/SceneInterface.h" - -#include "IECore/Export.h" -#include "IECore/LensModel.h" - -#include "DDImage/Filter.h" -#include "DDImage/Knobs.h" -#include "DDImage/Matrix4.h" -#include "DDImage/Op.h" -#include "DDImage/Row.h" -#include "DDImage/SourceGeo.h" -#include "DDImage/ViewerContext.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathMatrix.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// Loads and displays geometry from a scene cache file. -class IECORENUKE_API SceneCacheReader : public DD::Image::SourceGeo -{ - public : - - SceneCacheReader( Node *node ); - ~SceneCacheReader(); - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual const char *Class() const; - virtual const char *node_help() const; - - protected : - - virtual void _validate( bool forReal ); - virtual void append( DD::Image::Hash &hash ); - virtual void get_geometry_hash(); - virtual void geometry_engine( DD::Image::Scene& scene, DD::Image::GeometryList &out ); - virtual void create_geometry( DD::Image::Scene &scene, DD::Image::GeometryList &out ); - virtual int knob_changed( DD::Image::Knob* k); - - private : - - static const DD::Image::Op::Description m_description; - static DD::Image::Op *build( Node *node ); - virtual void build_handles( DD::Image::ViewerContext* ctx); - - //! @name Accessors - /// These methods return useful information about the state of the item and - /// the items that it represents. - ////////////////////////////////////////////////////////////// - //@{ - /// Returns the name of the currently selected tag filter. - void tagSelection( std::string &selection ) const; - // Returns whether the item at index itemIndex is selected in the SceneView_knob. - inline bool itemSelected( int itemIndex ) const; - // Returns the name of the item at index itemIndex in the SceneView_knob. - const std::string &itemName( int itemIndex ) const; - // Returns a SceneInterface for the root item. - IECoreScene::ConstSceneInterfacePtr getSceneInterface(); - // Returns a SceneInterface for the item at path. - IECoreScene::ConstSceneInterfacePtr getSceneInterface( const std::string &path ); - //@} - - //! @name Methods which control the SceneView_knob - /// These methods populate the SceneView_knob with the names or the items - /// taken from the SceneCache, filter and select them. They are called - /// from the knob_changed() method to synchronize the SceneView_knob and - /// the internal lists of selected and filtered items. - /// These methods should only be called from the firstReader() returned instance. - ////////////////////////////////////////////////////////////// - //@{ - /// Loads the internal data structures from the knobs and set up the - /// SceneView_knob. This method is called when a item is loaded from a script - /// or pasted. - void loadAllFromKnobs(); - /// Rebuilds the SceneView_knob from the file and root specified in the knobs. - /// If the file or root have not changed then the no work is done. If the scene - /// is rebuilt then the selection will be lost. The filterScene() method must - /// be called immediately afterwards. - void rebuildSceneView(); - /// Rebuilds the sceneView to show only items which are already selected or have - /// names that matches filterText and a tag which matches tagText. - /// Passing an empty string to either filterText or tagText will disable the - /// filtering of the names and tags respectively. This should be called - /// immediately after any call to rebuildSceneView(). - void filterScene( const std::string &filterText, const std::string &tagText, bool keepSelection = true ); - /// Clear any selected geometry from the SceneView_knob. - void clearSceneViewSelection(); - //@} - - /// Updates the Enumeration_knob of available tags from the internal list of tags - /// and updates the currently selected tag to ensure that it is valid. - void updateTagFilterKnob(); - /// Loads a primitive from the scene cache and adds it to the GeometryList. - void loadPrimitive( DD::Image::GeometryList &out, const std::string &path ); - /// Get the hash of the file path and root knob. - DD::Image::Hash sceneHash() const; - /// Get the hash of the SceneView knob (the default hash implementation of that knob returns a constant hash...) - DD::Image::Hash selectionHash( bool force = false ) const; - - Imath::M44d worldTransform( IECoreScene::ConstSceneInterfacePtr scene, IECoreScene::SceneInterface::Path root, double time ); - - // uses firstOp to return the Op that has the up-to-date private data - SceneCacheReader *firstReader(); - const SceneCacheReader *firstReader() const; - - class SharedData; - - // this function should only be called from the firstReader() object. - SharedData *sharedData(); - const SharedData *sharedData() const; - - // Knob Members. - const char *m_filePath; // Holds the raw SceneCache file path. - std::string m_root; // Holds the root item in the SceneCache. - std::string m_filter; // The text to filter the scene with. - bool m_worldSpace; // Set to ignore local transforms.. - DD::Image::Matrix4 m_baseParentMatrix; // The global matrix that is applied to the geo. - bool m_visibilityFilter; - - // Pointers to various knobs. - DD::Image::Knob *m_filePathKnob; - DD::Image::Knob *m_baseParentMatrixKnob; - DD::Image::Knob *m_sceneKnob; - DD::Image::Knob *m_tagFilterKnob; - DD::Image::Knob *m_sceneFilterKnob; - DD::Image::Knob *m_rootKnob; - DD::Image::Knob *m_visibilityFilterKnob; - - // only the first reader allocates the shared data - SharedData *m_data; - - std::map m_indexToWorldTransform; -}; - -} // namespace IECoreNuke - -#endif // IENUKE_SCENECACHEREADER_H - diff --git a/include/IECoreNuke/SceneCacheWriter.h b/include/IECoreNuke/SceneCacheWriter.h deleted file mode 100644 index ebc7aaa550..0000000000 --- a/include/IECoreNuke/SceneCacheWriter.h +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_SCENECACHE_WRITER_H -#define IECORENUKE_SCENECACHE_WRITER_H - -#include "IECoreNuke/Export.h" -#include "IECoreNuke/LiveScene.h" - -#include "DDImage/GeoWriter.h" -#include "DDImage/Scene.h" - -namespace IECoreNuke -{ - -/// A class to support writing SceneCache supported files out of Nuke using the WriteGeo node. -class IECORENUKE_API SceneCacheWriter : public DD::Image::GeoWriter -{ - public : - - SceneCacheWriter( DD::Image::WriteGeo* writeNode ); - - void execute( DD::Image::Scene& scene ) override; - bool open(); - - static DD::Image::GeoWriter* Build( DD::Image::WriteGeo* readNode ); - static DD::Image::GeoWriter::Description description; - - bool animation() const override; - - private : - - void writeLocation( IECoreScene::ConstSceneInterfacePtr inScene, IECoreScene::SceneInterfacePtr outScene, const IECore::InternedString& childName ); - - IECoreNuke::LiveScenePtr m_liveScene; - IECoreScene::SceneInterfacePtr m_writer; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_SCENECACHE_WRITER_H diff --git a/include/IECoreNuke/StringParameterHandler.h b/include/IECoreNuke/StringParameterHandler.h deleted file mode 100644 index 2215615b35..0000000000 --- a/include/IECoreNuke/StringParameterHandler.h +++ /dev/null @@ -1,70 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_STRINGPARAMETERHANDLER_H -#define IECORENUKE_STRINGPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -class IECORENUKE_API StringParameterHandler : public ParameterHandler -{ - - public : - - StringParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - protected : - - /// May be overridden by derived classes to define the main knob. Defaults to calling String_knob(). - virtual DD::Image::Knob *knob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f, const char **storage ); - - private : - - const char *m_storage; - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_STRINGPARAMETERHANDLER_H diff --git a/include/IECoreNuke/ToNukeConverter.h b/include/IECoreNuke/ToNukeConverter.h deleted file mode 100644 index 4250b0e7bc..0000000000 --- a/include/IECoreNuke/ToNukeConverter.h +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_TONUKECONVERTER_H -#define IECORENUKE_TONUKECONVERTER_H - -#include "IECoreNuke/Export.h" -#include "IECoreNuke/TypeIds.h" - -#include "IECore/FromCoreConverter.h" - -/// The IECoreNuke namespace holds all the functionality of libIECoreNuke. -namespace IECoreNuke -{ - -/// A base class for all classes which convert from an IECore datatype -/// to a Nuke datatype. -class IECORENUKE_API ToNukeConverter : public IECore::FromCoreConverter -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToNukeConverter, ToNukeConverterTypeId, IECore::FromCoreConverter ); - - protected: - - ToNukeConverter( const std::string &description, IECore::TypeId supportedType ); - - virtual ~ToNukeConverter(); - -}; - -IE_CORE_DECLAREPTR( ToNukeConverter ); - -} // namespace IECoreNuke - -#endif // IECORENUKE_TONUKECONVERTER_H diff --git a/include/IECoreNuke/ToNukeGeometryConverter.h b/include/IECoreNuke/ToNukeGeometryConverter.h deleted file mode 100644 index 576b825e54..0000000000 --- a/include/IECoreNuke/ToNukeGeometryConverter.h +++ /dev/null @@ -1,109 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORENUKE_TONUKEGEOMETRYCONVERTER_H -#define IE_CORENUKE_TONUKEGEOMETRYCONVERTER_H - -#include "IECoreNuke/ToNukeConverter.h" - -#include "IECore/NumericParameter.h" -#include "IECore/Object.h" -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/GeometryList.h" - -namespace IECoreNuke -{ - -IE_CORE_FORWARDDECLARE( ToNukeGeometryConverter ); - -/// The ToNukeGeometryConverter class allows conversion from an IECore Object to a Nuke geometry within the given GeometryList. -class IECORENUKE_API ToNukeGeometryConverter : public ToNukeConverter -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ToNukeGeometryConverter, ToNukeGeometryConverterTypeId, ToNukeConverter ); - - /// Converts the srcParameter() value to a geometry within the given GeometryList. - void convert( DD::Image::GeometryList &geoList ) const; - - /// Creates a converter which will convert the given IECore::Object to a Nuke geometry - /// of any relevant type. Returns 0 if no such converter can be found. - static ToNukeGeometryConverterPtr create( IECore::ConstObjectPtr src ); - - protected : - - ToNukeGeometryConverter( const std::string &description, IECore::TypeId fromType, IECore::ConstObjectPtr object ); - - /// Must be implemented by subclasses. Is guaranteed only to be called when object() - /// returns a valid IECore::Object of a type specified when the converter was registered. - virtual void doConversion( const IECore::Object *from, DD::Image::GeometryList &to, int objIndex, const IECore::CompoundObject *operands ) const = 0; - - typedef ToNukeGeometryConverterPtr (*CreatorFn)( IECore::ConstObjectPtr object ); - - static void registerConverter( IECore::TypeId fromType, CreatorFn creator ); - - /// Creating a static instance of one of these (templated on your Converter type) - /// within your class will register your converter with the factory mechanism. - template - class ToNukeGeometryConverterDescription - { - public : - ToNukeGeometryConverterDescription( IECore::TypeId fromType ); - private : - static ToNukeGeometryConverterPtr creator( IECore::ConstObjectPtr object ); - }; - - private : - - struct Types - { - Types( IECore::TypeId from ); - IECore::TypeId fromType; - bool operator < ( const Types &other ) const; - }; - - typedef std::map TypesToFnsMap; - static TypesToFnsMap *typesToFns(); - - IECore::IntParameterPtr m_objIndexParameter; - IECore::StringParameterPtr m_pathParameter; - -}; - -} // namespace IECoreNuke - -#include "IECoreNuke/ToNukeGeometryConverter.inl" - -#endif // IE_CORENUKE_TONUKEGEOMETRYCONVERTER_H diff --git a/include/IECoreNuke/ToNukeGeometryConverter.inl b/include/IECoreNuke/ToNukeGeometryConverter.inl deleted file mode 100644 index a324dca54a..0000000000 --- a/include/IECoreNuke/ToNukeGeometryConverter.inl +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORENUKE_TONUKEGEOMETRY_INL -#define IE_CORENUKE_TONUKEGEOMETRY_INL - -namespace IECoreNuke -{ - -template -ToNukeGeometryConverter::ToNukeGeometryConverterDescription::ToNukeGeometryConverterDescription( IECore::TypeId fromType ) -{ - ToNukeGeometryConverter::registerConverter( fromType, creator ); -} - -template -ToNukeGeometryConverterPtr ToNukeGeometryConverter::ToNukeGeometryConverterDescription::creator( IECore::ConstObjectPtr object ) -{ - return new T( object ); -} - -} // namespace IECoreNuke - -#endif // IE_CORENUKE_TONUKEGEOMETRY_INL diff --git a/include/IECoreNuke/TypeIds.h b/include/IECoreNuke/TypeIds.h deleted file mode 100644 index 84ecedb260..0000000000 --- a/include/IECoreNuke/TypeIds.h +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_TYPEIDS_H -#define IECORENUKE_TYPEIDS_H - -namespace IECoreNuke -{ - -enum TypeId -{ - FromNukeConverterTypeId = 107000, - MeshFromNukeTypeId = 107001, - ToNukeConverterTypeId = 107002, - ToNukeGeometryConverterTypeId = 107003, - FromNukePointsConverterTypeId = 107004, - FromNukeCameraConverterTypeId = 107005, - FromNukeTileConverterTypeId = 107006, - NukeDisplayDriverTypeId = 107007, - LiveSceneTypeId = 107008, - LastCoreNukeTypeId = 107999 -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_TYPEIDS_H diff --git a/include/IECoreNuke/VecParameterHandler.h b/include/IECoreNuke/VecParameterHandler.h deleted file mode 100644 index 48335057d4..0000000000 --- a/include/IECoreNuke/VecParameterHandler.h +++ /dev/null @@ -1,66 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_VECPARAMETERHANDLER_H -#define IECORENUKE_VECPARAMETERHANDLER_H - -#include "IECoreNuke/ParameterHandler.h" - -namespace IECoreNuke -{ - -template -class IECORENUKE_API VecParameterHandler : public ParameterHandler -{ - - public : - - VecParameterHandler(); - - virtual void knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ); - virtual void setParameterValue( IECore::Parameter *parameter, ValueSource valueSource = Storage ); - virtual void setKnobValue( const IECore::Parameter *parameter ); - - private : - - float m_storage[3]; // enough for either V2 or V3 - DD::Image::Knob *m_knob; - - static Description g_description; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_VECPARAMETERHANDLER_H diff --git a/include/IECoreNuke/Warp.h b/include/IECoreNuke/Warp.h deleted file mode 100644 index 3f22bee577..0000000000 --- a/include/IECoreNuke/Warp.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_WARPNODE_H -#define IECORENUKE_WARPNODE_H - -#include "IECoreNuke/Export.h" - -#include "IECore/Export.h" - -#include "DDImage/Iop.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -namespace IECoreNuke -{ - -/// A base class to simplify the implementation of Iops which apply an arbitrary -/// distortion to an image. -class IECORENUKE_API Warp : public DD::Image::Iop -{ - - public : - - Warp( Node *node ); - virtual ~Warp(); - - protected : - - /// Must be implemented by subclasses to return the pixel position from the - /// input that should be used to fill the outputPixel. This function will - /// be called from multiple threads. - virtual Imath::V2f warp( const Imath::V2f &outputPixel ) const = 0; - - virtual void knobs( DD::Image::Knob_Callback f ); - virtual void _validate( bool forReal ); - virtual void _request( int x, int y, int r, int t, const DD::Image::ChannelSet &channels, int count ); - virtual void engine( int y, int x, int r, const DD::Image::ChannelSet &channels, DD::Image::Row &out ); - - private : - - DD::Image::ChannelSet m_channels; - -}; - -} // namespace IECoreNuke - -#endif // IECORENUKE_WARPNODE_H diff --git a/include/IECoreNuke/bindings/FnOpHolderBinding.h b/include/IECoreNuke/bindings/FnOpHolderBinding.h deleted file mode 100644 index 06a7c547fe..0000000000 --- a/include/IECoreNuke/bindings/FnOpHolderBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FNOPHOLDERBINDING_H -#define IECORENUKE_FNOPHOLDERBINDING_H - -namespace IECoreNuke -{ - -void bindFnOpHolder(); - -} - -#endif // IECORENUKE_FNOPHOLDERBINDING_H diff --git a/include/IECoreNuke/bindings/FnParameterisedHolderBinding.h b/include/IECoreNuke/bindings/FnParameterisedHolderBinding.h deleted file mode 100644 index 28cbd75b59..0000000000 --- a/include/IECoreNuke/bindings/FnParameterisedHolderBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_FNPARAMETERISEDHOLDERBINDING_H -#define IECORENUKE_FNPARAMETERISEDHOLDERBINDING_H - -namespace IECoreNuke -{ - -void bindFnParameterisedHolder(); - -} - -#endif // IECORENUKE_FNPARAMETERISEDHOLDERBINDING_H diff --git a/include/IECoreNuke/bindings/LiveSceneBinding.h b/include/IECoreNuke/bindings/LiveSceneBinding.h deleted file mode 100644 index 0df2ed96a9..0000000000 --- a/include/IECoreNuke/bindings/LiveSceneBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LIVESCENEBINDING_H -#define IECORENUKE_LIVESCENEBINDING_H - -namespace IECoreNuke -{ - -void bindLiveScene(); - -} - -#endif // IECORENUKE_LIVESCENEBINDING_H diff --git a/include/IECoreNuke/bindings/LiveSceneKnobBinding.h b/include/IECoreNuke/bindings/LiveSceneKnobBinding.h deleted file mode 100644 index 245b132689..0000000000 --- a/include/IECoreNuke/bindings/LiveSceneKnobBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_LIVESCENEKNOBBINDING_H -#define IECORENUKE_LIVESCENEKNOBBINDING_H - -namespace IECoreNuke -{ - -void bindLiveSceneKnob(); - -} - -#endif // IECORENUKE_LIVESCENEKNOBBINDING_H diff --git a/include/IECoreNuke/bindings/ObjectKnobBinding.h b/include/IECoreNuke/bindings/ObjectKnobBinding.h deleted file mode 100644 index a9464cdaa4..0000000000 --- a/include/IECoreNuke/bindings/ObjectKnobBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORENUKE_OBJECTKNOBBINDING_H -#define IECORENUKE_OBJECTKNOBBINDING_H - -namespace IECoreNuke -{ - -void bindObjectKnob(); - -} - -#endif // IECORENUKE_OBJECTKNOBBINDING_H diff --git a/mel/IECoreMaya/IECoreMaya.mel b/mel/IECoreMaya/IECoreMaya.mel deleted file mode 100644 index 87fcf1e320..0000000000 --- a/mel/IECoreMaya/IECoreMaya.mel +++ /dev/null @@ -1,56 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// \defgroup melgroup MEL -/// -/// The core maya library comes with associated MEL files providing useful utility -/// functions and additional API related to the C++ nodes. - -source "IECoreMaya/ieParameterisedHolder.mel"; -source "IECoreMaya/ieNode.mel"; -source "IECoreMaya/ieAttr.mel"; - -source "IECoreMaya/ieParameterisedHolderUI.mel"; -source "IECoreMaya/ieOpHolderUI.mel"; -source "IECoreMaya/ieConverterHolderUI.mel"; -source "IECoreMaya/ieParameterPanel.mel"; -source "IECoreMaya/ieAttributeEditorControl.mel"; -source "IECoreMaya/iePanel.mel"; -source "IECoreMaya/ieImagePlaneHolderUI.mel"; -source "IECoreMaya/ieParameterisedHolderSetUI.mel"; -source "IECoreMaya/ieDrawableHolderUI.mel"; -source "IECoreMaya/ieGeometryCombinerUI.mel"; -source "IECoreMaya/ieCurveCombinerUI.mel"; -source "IECoreMaya/ieSceneShapeUI.mel"; -source "IECoreMaya/ieSceneShapeProxyUI.mel"; diff --git a/mel/IECoreMaya/ieAttr.mel b/mel/IECoreMaya/ieAttr.mel deleted file mode 100644 index 7ae753ac04..0000000000 --- a/mel/IECoreMaya/ieAttr.mel +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// \file ieAttr.mel -/// -/// This file defines useful functions for operating on attributes. The first argument -/// to each of these functions is a string in the form "node.attribute". -/// \ingroup melgroup - -/// Returns the node the attribute is on. -global proc string ieAttrNode( string $attr ) -{ - return `match "^[^.]*" $attr`; -} - -/// Returns the first available (i.e. empty) logical index -/// of an array attribute. -global proc int ieAttrNextIndex( string $attr ) -{ - int $next = 0; - - string $indices[] = `listAttr -m $attr`; - - string $idx; - for ($idx in $indices) - { - string $buf[]; - tokenize($idx, "[]", $buf); - - if (int($buf[1]) == $next) - { - $next = $next + 1; - } - else if (int($buf[1]) > $next) - { - return $next; - } - } - - return $next; -} diff --git a/mel/IECoreMaya/ieAttributeEditorControl.mel b/mel/IECoreMaya/ieAttributeEditorControl.mel deleted file mode 100644 index 45cf469556..0000000000 --- a/mel/IECoreMaya/ieAttributeEditorControl.mel +++ /dev/null @@ -1,52 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// Call this function from an attribute editor template to install a custom control -/// implemented as a python object. $pythonClassName is the name of a class derived -/// from IECoreMaya.AttributeEditorControl that will be used to represent the -/// attribute specified. See the python documentation for more details. -global proc ieAttributeEditorControl( string $pythonClassName, string $attribute ) -{ - editorTemplate -callCustom "ieAttributeEditorControlNew" "ieAttributeEditorControlReplace" $pythonClassName $attribute; -} - -global proc ieAttributeEditorControlNew( string $pythonClassName, string $attribute ) -{ - python( "IECoreMaya.AttributeEditorControl._new( \"" + $pythonClassName + "\", \"" + $attribute + "\" )" ); -} - -global proc ieAttributeEditorControlReplace( string $pythonClassName, string $attribute ) -{ - python( "IECoreMaya.AttributeEditorControl._replace( \"" + $attribute + "\" )" ); -} diff --git a/mel/IECoreMaya/ieConverterHolderUI.mel b/mel/IECoreMaya/ieConverterHolderUI.mel deleted file mode 100644 index e56f6f4649..0000000000 --- a/mel/IECoreMaya/ieConverterHolderUI.mel +++ /dev/null @@ -1,114 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -global proc AEieConverterHolderTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -addControl "in"; - - editorTemplate -callCustom "ieConverterHolderUIConversionNew" - "ieConverterHolderUIConversionReplace" - "fileName"; - - editorTemplate -beginLayout "Parameters"; - ieParameterisedHolderUIParametersControl(); - editorTemplate -endLayout; - - editorTemplate -beginLayout "Extra Attributes"; - ieParameterisedHolderUIExtraAttributesControl(); - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} - -global proc ieConverterHolderUIConversionNew( string $attrName ) -{ - setUITemplate -pushTemplate attributeEditorTemplate; - - rowLayout -nc 3 "fileName"; - - text -label "File Name"; - textField nameField; - symbolButton -image "navButtonBrowse.xpm" browserButton; - - setParent ..; - - rowLayout -nc 2; - - text -label ""; - button -label "Export" exportButton; - - setParent ..; - - ieConverterHolderUIConversionReplace( $attrName ); - - setUITemplate -popTemplate; -} - -global proc ieConverterHolderUIConversionReplace( string $attrName ) -{ - string $node = ieAttrNode( $attrName ); - - connectControl -fileName nameField $attrName; - button -e -c ("ieConverterHolderUIFileBrowser \"" + $attrName + "\"") browserButton; - button -e -c ("ieConverterHolderExportCallback \"" + $node + "\"") exportButton; -} - -global proc ieConverterHolderUIFileBrowser( string $attrName ) -{ - fileBrowser( "ieConverterHolderUIFileBrowserCallback \"" + $attrName + "\"", "Choose", "", 1 ); -} - -global proc int ieConverterHolderUIFileBrowserCallback( string $attrName, string $fileName, string $fileType ) -{ - setAttr -type "string" $attrName $fileName; - return 1; -} - -global proc ieConverterHolderExportCallback( string $node ) -{ - string $fileName = `getAttr ($node+".fileName")`; - if( `gmatch $fileName "*#*"` ) - { - int $start = `playbackOptions -q -min`; - int $end = `playbackOptions -q -max`; - iePython -cmd ("IECoreMaya.ConverterHolder( '" + $node + "' ).convertAtFrames( IECore.FrameRange( " + $start + ", " + $end + ") )"); - } - else - { - int $current = `currentTime -q`; - iePython -cmd ("IECoreMaya.ConverterHolder( '" + $node + "' ).convertAtFrame( " + $current + ")"); - } -} diff --git a/mel/IECoreMaya/ieCurveCombinerUI.mel b/mel/IECoreMaya/ieCurveCombinerUI.mel deleted file mode 100644 index 93f301ebdf..0000000000 --- a/mel/IECoreMaya/ieCurveCombinerUI.mel +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -global proc AEieCurveCombinerTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -addControl "inputCurves"; - - editorTemplate -beginLayout "Node Behaviour"; - - editorTemplate -addControl "caching"; - editorTemplate -addControl "nodeState"; - - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/ieDrawableHolderUI.mel b/mel/IECoreMaya/ieDrawableHolderUI.mel deleted file mode 100644 index c736b5a53d..0000000000 --- a/mel/IECoreMaya/ieDrawableHolderUI.mel +++ /dev/null @@ -1,58 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -global proc AEieDrawableTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Class"; - ieParameterisedHolderUIClassControl(); - ieParameterisedHolderUIParameterPresetsControl(); - editorTemplate -endLayout; - - editorTemplate -beginLayout "Display"; - editorTemplate -addControl "draw"; - editorTemplate -endLayout; - - editorTemplate -beginLayout "Parameters"; - ieParameterisedHolderUIParametersControl(); - editorTemplate -endLayout; - editorTemplate -endLayout; - - editorTemplate -beginLayout "Extra Attributes"; - ieParameterisedHolderUIExtraAttributesControl(); - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/ieGeometryCombinerUI.mel b/mel/IECoreMaya/ieGeometryCombinerUI.mel deleted file mode 100644 index 4f4ca33288..0000000000 --- a/mel/IECoreMaya/ieGeometryCombinerUI.mel +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -global proc AEieGeometryCombinerTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Conversion"; - - editorTemplate -addControl "convertPrimVars"; - editorTemplate -addControl "convertBlindData"; - editorTemplate -addControl "conversionSpace"; - - editorTemplate -endLayout; - - editorTemplate -addControl "inputGeometry"; - - editorTemplate -beginLayout "Node Behaviour"; - - editorTemplate -addControl "caching"; - editorTemplate -addControl "nodeState"; - - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/ieImagePlaneHolderUI.mel b/mel/IECoreMaya/ieImagePlaneHolderUI.mel deleted file mode 100644 index cb0ed1d143..0000000000 --- a/mel/IECoreMaya/ieImagePlaneHolderUI.mel +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -source "AEimagePlaneTemplate.mel"; - -global proc AEieImagePlaneHolderTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Class"; - ieParameterisedHolderUIClassControl(); - editorTemplate -endLayout; - - editorTemplate -beginLayout "Parameters"; - ieParameterisedHolderUIParametersControl(); - editorTemplate -endLayout; - editorTemplate -endLayout; - - - editorTemplate -beginLayout (uiRes("m_AEimagePlaneTemplate.kImagePlaneAttributes")) -collapse 0; - editorTemplate -callCustom "AEdisplayCurrentNew" - "AEdisplayCurrentReplace" - "displayOnlyIfCurrent"; - - editorTemplate -addControl "displayMode" "AEimagePlaneViewUpdateCallback"; - - editorTemplate -addControl "colorGain"; - editorTemplate -addControl "colorOffset"; - editorTemplate -addControl "alphaGain"; - editorTemplate -callCustom "AElockedToCameraNew" - "AElockedToCameraReplace" - "lockedToCamera"; - editorTemplate -endLayout; - - editorTemplate -beginLayout (uiRes("m_AEimagePlaneTemplate.kPlacement")) -collapse 0; - editorTemplate -addControl "fit" "AEimagePlaneFitUpdateCallback"; - editorTemplate -callCustom "AEfitGate" "AErepFitGate" "sizeX" "sizeY"; - editorTemplate -addControl "size"; - editorTemplate -addControl "squeezeCorrection"; - editorTemplate -addControl "offset"; - editorTemplate -addControl "depth"; - editorTemplate -addControl "rotate"; - editorTemplate -endLayout; - - editorTemplate -beginLayout (uiRes("m_AEimagePlaneTemplate.kPlacementExtras")) -collapse 0; - editorTemplate -addControl "coverageX"; - editorTemplate -addControl "coverageY"; - editorTemplate -addControl "coverageOriginX"; - editorTemplate -addControl "coverageOriginY"; - editorTemplate -addSeparator; - editorTemplate -addControl "center"; - editorTemplate -addControl "width"; - editorTemplate -addControl "height"; - editorTemplate -endLayout; - - editorTemplate -beginLayout "Extra Attributes"; - ieParameterisedHolderUIExtraAttributesControl(); - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/ieNode.mel b/mel/IECoreMaya/ieNode.mel deleted file mode 100644 index cc85066ac4..0000000000 --- a/mel/IECoreMaya/ieNode.mel +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// \file ieNode.mel -/// -/// This file defines useful functions for operating on nodes. The first argument -/// to each of these functions is the name of a node. -/// \ingroup melgroup - -/// Creates a node of type $type, parented to a transform with name $name, -/// or some unique name based on $name. Names the child node to match -/// the parent. i.e. $nameShapeN where N is a numerical suffix to keep -/// names unique. Returns the name of the child. -global proc string ieNodeCreateShapeWithParent( string $name, string $type ) -{ - string $parentNode = `createNode "transform" -name $name`; - string $parentShortName = shortNameOf( $parentNode ); - string $numbers = match( "[0-9]+$", $parentShortName ); - string $shapeName = substring( $parentShortName, 1, size( $parentShortName ) - size( $numbers ) ); - $shapeName = $shapeName + "Shape" + $numbers; - string $shapeNode = `createNode $type -name $shapeName -parent $parentNode`; - return $shapeNode; -} diff --git a/mel/IECoreMaya/ieOpHolderUI.mel b/mel/IECoreMaya/ieOpHolderUI.mel deleted file mode 100644 index 606efca360..0000000000 --- a/mel/IECoreMaya/ieOpHolderUI.mel +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -global proc AEieOpHolderNodeTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Class"; - ieParameterisedHolderUIClassControl(); - ieParameterisedHolderUIParameterPresetsControl(); - editorTemplate -endLayout; - - editorTemplate -beginLayout "Parameters"; - ieParameterisedHolderUIParametersControl(); - editorTemplate -endLayout; - editorTemplate -endLayout; - - editorTemplate -beginLayout "Extra Attributes"; - ieParameterisedHolderUIExtraAttributesControl(); - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/iePanel.mel b/mel/IECoreMaya/iePanel.mel deleted file mode 100644 index 6da2c882ab..0000000000 --- a/mel/IECoreMaya/iePanel.mel +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// \file iePanel.mel -/// This file just defines forwarding functions which invoke the -/// python implementations in IECoreMaya/Panel.py - -global proc iePanelCreate( string $panel ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__create( \"" + $panel + "\" )" ); -} - -global proc iePanelInit( string $panel ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__init( \"" + $panel + "\" )" ); -} - -global proc iePanelAdd( string $panel ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__add( \"" + $panel + "\" )" ); -} - -global proc iePanelRemove( string $panel ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__remove( \"" + $panel + "\" )" ); -} - -global proc string iePanelSave( string $panel ) -{ - return python( "import IECoreMaya; IECoreMaya.Panel._Panel__save( \"" + $panel + "\" )" ); -} - -global proc iePanelDelete( string $panel ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__delete( \"" + $panel + "\" )" ); -} - -global proc iePanelRestore( string $panel, string $state ) -{ - python( "import IECoreMaya; IECoreMaya.Panel._Panel__restore( \"" + $panel + "\", \"" + $state + "\" )" ); -} diff --git a/mel/IECoreMaya/ieParameterPanel.mel b/mel/IECoreMaya/ieParameterPanel.mel deleted file mode 100644 index 633e155a17..0000000000 --- a/mel/IECoreMaya/ieParameterPanel.mel +++ /dev/null @@ -1,84 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -if (!`scriptedPanelType -exists ieParameterPanel`) -{ - scriptedPanelType - -createCallback "ieParameterPanelCreate" - -initCallback "ieParameterPanelInit" - -addCallback "ieParameterPanelAdd" - -removeCallback "ieParameterPanelRemove" - -deleteCallback "ieParameterPanelDelete" - -saveStateCallback "ieParameterPanelSave" - -retainOnFileOpen 0 - -unique 0 - ieParameterPanel; -} - -global proc ieParameterPanelCreate(string $whichPanel) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.create('" + $whichPanel + "')"); -} - -global proc ieParameterPanelInit(string $whichPanel) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.init('" + $whichPanel + "')"); -} - -global proc ieParameterPanelAdd(string $whichPanel) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.add('" + $whichPanel + "')"); -} - -global proc ieParameterPanelRemove(string $whichPanel) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.remove('" + $whichPanel + "')"); -} - -global proc ieParameterPanelDelete(string $whichPanel) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.delete('" + $whichPanel + "')"); -} - -global proc string ieParameterPanelSave(string $whichPanel) -{ - iePython -command ("import IECoreMaya"); - string $s = `iePython -eval ("IECoreMaya.ParameterPanel.save('" + $whichPanel + "')")`; - return $s; -} - -global proc ieParameterPanelRestore(string $whichPanel, string $restoreData) -{ - iePython -command ("import IECoreMaya; IECoreMaya.ParameterPanel.restore('" + $whichPanel + "', \"" + $restoreData + "\")"); -} diff --git a/mel/IECoreMaya/ieParameterisedHolder.mel b/mel/IECoreMaya/ieParameterisedHolder.mel deleted file mode 100644 index 9acab9c12c..0000000000 --- a/mel/IECoreMaya/ieParameterisedHolder.mel +++ /dev/null @@ -1,109 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -/// \file ieParameterisedHolder.mel -/// -/// This file defines functions which can be used with any of the node types -/// instantiated from the template ParameterisedHolder class. -/// -/// \ingroup melgroup - -/// Returns the name of the class being held. -/// \todo Handle case where getParameterised() returns None -global proc string ieParameterisedHolderClassName( string $nodeName ) -{ - $className = `iePython -eval ("IECoreMaya.FnParameterisedHolder( '" + $nodeName + "' ).getParameterised()[1]")`; - if ( $className == "" ) - { - $className = `iePython -eval ("IECoreMaya.FnParameterisedHolder( '" + $nodeName + "' ).getParameterised()[0].typeName()")`; - } - - return $className; -} - -/// Returns the version of the class being held. -/// \todo Handle case where getParameterised() returns None -global proc int ieParameterisedHolderClassVersion( string $nodeName ) -{ - int $version = `iePython -eval ("IECoreMaya.FnParameterisedHolder( '" + $nodeName + "' ).getParameterised()[2]")`; - return $version; -} - -/// Returns the name of the environment variable which specifies the -/// searchpaths this node looks for classes on. -/// \todo Handle case where getParameterised() returns None -global proc string ieParameterisedHolderClassSearchPathEnvVar( string $nodeName ) -{ - return `iePython -eval ("IECoreMaya.FnParameterisedHolder( '" + $nodeName + "' ).getParameterised()[3]")`; -} - -/// Returns the description for the class being held. -global proc string ieParameterisedHolderClassDescription( string $nodeName ) -{ - return `iePython -eval ("IECoreMaya.FnParameterisedHolder( '" + $nodeName + "' ).getParameterised()[0].description")`; -} - -/// Returns an int array containing all the valid versions of the class -/// currently being held by $nodeName. -global proc int[] ieParameterisedHolderClassVersions( string $nodeName ) -{ - int $result[]; - string $class = ieParameterisedHolderClassName( $nodeName ); - string $searchPathEnvVar = ieParameterisedHolderClassSearchPathEnvVar( $nodeName ); - if ( $searchPathEnvVar == "" ) - { - return $result; - } - iePython -command "import os.path"; - string $versions = `iePython -eval ("IECore.ClassLoader.defaultLoader( '" + $searchPathEnvVar + "' ).versions( '" + $class + "' )" )`; - string $tokens[]; - tokenize $versions "[], " $tokens; - for( $i=0; $i= 0; $i = $i - 1 ) - { - /// Break the popupMenu into multiple cascading menus with 30 elements maximum in each, so that - /// we don't exceed the screen height - if ( $i != $latestVersionIdx && ( $i - $latestVersionIdx ) % 30 == 0 ) - { - menuItem -label "More..." -subMenu true; - } - menuItem -label ("v"+$versions[$i]) -command ("ieParameterisedHolderUIClassControlVersionCallback " + $node + " " + $versions[$i]); - } - } else { - text -align left -font boldLabelFont -label "Not Versioned"; - } - setParent ..; - setParent ..; -} - -global proc ieParameterisedHolderUIClassControlVersionCallback( string $node, string $versionStr ) -{ - int $versionInt = (int)$versionStr; - string $class = ieParameterisedHolderClassName( $node ); - string $sp = ieParameterisedHolderClassSearchPathEnvVar( $node ); - ieParameterisedHolderSetParameterised( $node, $class, $versionInt, $sp ); - - /// Now update the Attribute Editor. This needs to be deferred as it seems Maya doesn't - /// appreciate us doing this right in the middle of a menu callback. - evalDeferred( "AEbuildControls()" ); -} - -global proc ieParameterisedHolderUIParameterPresetsControl() -{ - editorTemplate -callCustom "ieParameterisedHolderUIParameterPresetsControlNewAndReplace" "ieParameterisedHolderUIParameterPresetsControlNewAndReplace" "iDontExist"; -} - -global proc ieParameterisedHolderUIParameterPresetsControlNewAndReplace( string $attrName ) -{ - string $node = ieAttrNode( $attrName ); - - string $controlName = "ieParameterisedHolderUIAEParameterPresetsControl"; - if( `control -exists $controlName` ) - { - deleteUI $controlName; - } - - string $searchPath = ieParameterisedHolderClassSearchPathEnvVar( $node ); - if ( $searchPath == "" ) - { - return; - } - - string $pyStub = "import IECoreMaya; IECoreMaya.PresetsUI( '" + $node + "' )"; - - columnLayout -adj 1 $controlName; - - separator -style "none" -h 3; - - rowLayout -nc 4 -adj 4 -cw 2 60 -cw 3 60; - - text -align right -label "Parameter Values" -ann "Load and Save presets for the node's parameters, or a sub-set of them."; - - button -label "Save..." -w 60 -command ( "python( \"" + $pyStub + ".save()\" );" ); - button -label "Load..." -w 60 -command ( "python( \"" + $pyStub + ".load()\" );" ); - - setParent ..; - - separator -style "none" -h 3; - - setParent ..; -} - - -global proc ieParameterisedHolderUIExtraAttributesControl() -{ - editorTemplate -callCustom "ieParameterisedHolderUIExtraAttributesNewAndReplace" "ieParameterisedHolderUIExtraAttributesNewAndReplace" "iDontExist"; - // maya hangs when trying to update the extra attributes when there are large numbers of them - which - // there often are with real world procedurals. we can't find a way to stop maya from wanting to draw them - // so the only thing we can do is hide them deep enough that only the determined user can get into trouble. as - // soon as the Open With Caution section has been opened, maya may hang at any future time when updating the - // attribute editor, even if you subsequently close that section. - editorTemplate -beginLayout "All Dynamic Attributes"; - editorTemplate -beginLayout "Open With Caution - Maya May Hang"; - editorTemplate -extraControlsLabel "Too Late Now!" -addExtraControls; - editorTemplate -endLayout; - editorTemplate -endLayout; -} - -global proc ieParameterisedHolderUIExtraAttributesNewAndReplace( string $attrName ) -{ - string $buf[2]; - tokenize( $attrName, ".", $buf); - - string $nodeName = $buf[0]; - - if (`control -exists ieParameterisedAEExtraAttributes`) - deleteUI ieParameterisedAEExtraAttributes; - - string $dynAttrs[] = `deleteAttr -q $nodeName`; - - columnLayout ieParameterisedAEExtraAttributes; - - string $dynAttr; - for ($dynAttr in $dynAttrs) - { - if( `attributeQuery -node $nodeName -hidden $dynAttr`==0 ) - { - string $attrType = ""; - string $dynAttrName = $nodeName + "." + $dynAttr; - if (`objExists $dynAttrName` ) - { - $attrType = `getAttr -type $dynAttrName`; - } - if (match("^parm_", $dynAttr) == "" && $dynAttr != "result" && $attrType != "message" ) - { - attrControlGrp -attribute $dynAttrName; - } - } - } - -} diff --git a/mel/IECoreMaya/ieSceneShapeProxyUI.mel b/mel/IECoreMaya/ieSceneShapeProxyUI.mel deleted file mode 100644 index 4164df0eea..0000000000 --- a/mel/IECoreMaya/ieSceneShapeProxyUI.mel +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -global proc AEieSceneShapeProxyTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Inputs"; - editorTemplate -annotation "Path to the scene interface file." -addControl "file" ; - editorTemplate -annotation "Path in the scene interface where you start reading." -addControl "root"; - editorTemplate -annotation "If on, only read the object at the root path." -addControl "objectOnly"; - editorTemplate -addControl "time"; - - editorTemplate -endLayout; - - editorTemplate -beginLayout "Queries"; - editorTemplate -addControl "querySpace"; - editorTemplate -addControl "queryPaths"; - editorTemplate -addControl "queryAttributes"; - editorTemplate -addControl "queryConvertParameters"; - - editorTemplate -endLayout; - - editorTemplate -beginLayout "All Dynamic Attributes"; - editorTemplate -beginLayout "Open With Caution - Maya May Hang"; - editorTemplate -extraControlsLabel "Too Late Now!" -addExtraControls; - editorTemplate -endLayout; - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} diff --git a/mel/IECoreMaya/ieSceneShapeUI.mel b/mel/IECoreMaya/ieSceneShapeUI.mel deleted file mode 100644 index aea84771af..0000000000 --- a/mel/IECoreMaya/ieSceneShapeUI.mel +++ /dev/null @@ -1,78 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -global proc AEieSceneShapeTemplate( string $nodeName ) -{ - editorTemplate -beginScrollLayout; - - editorTemplate -beginLayout "Inputs"; - editorTemplate -annotation "Path to the scene interface file." -addControl "file" ; - editorTemplate -annotation "Path in the scene interface where you start reading." -addControl "root"; - editorTemplate -annotation "If on, only read the object at the root path." -addControl "objectOnly"; - editorTemplate -addControl "time"; - - editorTemplate -endLayout; - - editorTemplate -beginLayout "Preview"; - editorTemplate -annotation "Draw all the geometry." -addControl "drawGeometry"; - editorTemplate -interruptOptimize; - editorTemplate -annotation "Draw the bound for the root path." -addControl "drawRootBound"; - editorTemplate -interruptOptimize; - editorTemplate -annotation "Draw the bounds of all the scene interface children." -addControl "drawChildBounds"; - editorTemplate -annotation "Only draw the elements that match those tags." -addControl "drawTagsFilter"; - editorTemplate -endLayout; - - editorTemplate -beginLayout "Queries"; - editorTemplate -addControl "querySpace"; - editorTemplate -addControl "queryPaths"; - editorTemplate -addControl "queryAttributes"; - editorTemplate -addControl "queryConvertParameters"; - - editorTemplate -endLayout; - - editorTemplate -beginLayout "All Dynamic Attributes"; - editorTemplate -beginLayout "Open With Caution - Maya May Hang"; - editorTemplate -extraControlsLabel "Too Late Now!" -addExtraControls; - editorTemplate -endLayout; - editorTemplate -endLayout; - - editorTemplate -endScrollLayout; -} - -global proc ieSceneShapeDagMenuProc( string $parent, string $child ) -{ - python( "import IECoreMaya; IECoreMaya.SceneShapeUI._dagMenu( '" + $parent + "', '" + $child + "' )" ); -} - diff --git a/menus/IECoreHoudini/cortex.shelf b/menus/IECoreHoudini/cortex.shelf deleted file mode 100644 index 0d915e17a5..0000000000 --- a/menus/IECoreHoudini/cortex.shelf +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - SOP - - Cortex - - - - - - - SOP - - Cortex - - - - - - - SOP - - Cortex - - - - - - - SOP - - Cortex - - - - - - - OBJ - - Cortex - - - - - - - OBJ - - Cortex - - - - - - - ROP - - Cortex - - - - - - - SOP - - Cortex - - - - diff --git a/python/IECoreHoudini/ActiveTake.py b/python/IECoreHoudini/ActiveTake.py deleted file mode 100644 index a42e819110..0000000000 --- a/python/IECoreHoudini/ActiveTake.py +++ /dev/null @@ -1,67 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou - -## A context object intended for use with python's "with" syntax. It ensures -# that all operations in the with block are performed in the given take, -# and that the previous take is restored if it still exists when the block exits. -class ActiveTake : - - def __init__( self, take ) : - - self.__take = take - self.__prevTake = ActiveTake.name() - - def __enter__( self ) : - - if self.__take in ActiveTake.ls() : - hou.hscript( "takeset %s" % self.__take ) - - def __exit__( self, type, value, traceBack ) : - - if self.__prevTake in ActiveTake.ls() : - hou.hscript( "takeset %s" % self.__prevTake ) - - ## \todo: remove this method when the hscript take commands are available in python - @staticmethod - def name() : - - return hou.hscript( "takeset" )[0].strip() - - ## \todo: remove this method when the hscript take commands are available in python - @staticmethod - def ls() : - - return [ x.strip() for x in hou.hscript( "takels" )[0].strip().split( "\n" ) ] diff --git a/python/IECoreHoudini/FnOpHolder.py b/python/IECoreHoudini/FnOpHolder.py deleted file mode 100644 index 93cda24d5f..0000000000 --- a/python/IECoreHoudini/FnOpHolder.py +++ /dev/null @@ -1,61 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou - -import IECore -import IECoreHoudini - -class FnOpHolder( IECoreHoudini.FnParameterisedHolder ) : - - _nodeType = "ieOpHolder" - - @staticmethod - # see FnParameterisedHolder for a description of the parameters - def create( name, type, version=None, path="IECORE_OP_PATHS", parent=None, contextArgs={} ) : - - return IECoreHoudini.FnParameterisedHolder._doCreate( FnOpHolder._nodeType, name, type, version, path, parent, contextArgs ) - - ## Convenience method to call setParameterised with the environment variable - # for the searchpaths set to "IECORE_OP_PATHS". - def setOp( self, className, classVersion=None, updateGui=True ) : - - self.setParameterised( className, classVersion, "IECORE_OP_PATHS", updateGui ) - - def getOp( self ) : - - return self.getParameterised() diff --git a/python/IECoreHoudini/FnParameterisedHolder.py b/python/IECoreHoudini/FnParameterisedHolder.py deleted file mode 100644 index a9dcde312d..0000000000 --- a/python/IECoreHoudini/FnParameterisedHolder.py +++ /dev/null @@ -1,233 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import warnings - -import hou -import toolutils - -import IECore -import IECoreHoudini - -class FnParameterisedHolder(): - - _nodeType = None - - # create our function set and stash which node we're looking at - def __init__(self, node=None): - self.__node = node - - # check this node is still valid - def nodeValid(self): - if not self.__node: - raise "FnParameterisedHolder does not have a node to operate on." - try: - p = self.__node.path() - return True - except hou.ObjectWasDeleted: - return False - - # return the node we're currently wrapping - def node(self): - - return self.__node if self.nodeValid() else None - - @staticmethod - # nodeType: type of node to create (str) - # name: desired node name (str) - # className: class path to op stub (str) - # version: op version, or None for latest (int) - # envVarName: environment variable to use as a search path for ops (str) - # parent: parent node, or None to create a new /obj geo. Ignored if contextArgs is used in UI mode (hou.Node) - # contextArgs: args related to the creation context, as would come from UI menu interactions (dict) - # If empty or not in UI mode, will create a top level OBJ to house the new holder - def _doCreate( nodeType, name, className, version=None, envVarName=None, parent=None, contextArgs={} ) : - - if hou.isUIAvailable() and contextArgs.get( "toolname", "" ) : - holder = toolutils.genericTool( contextArgs, nodeType, nodename = name ) - else : - parent = parent if parent else hou.node( "/obj" ).createNode( "geo", node_name=name, run_init_scripts=False ) - holder = parent.createNode( nodeType, node_name=name ) - - IECoreHoudini.FnParameterisedHolder( holder ).setParameterised( className, version, envVarName ) - - if contextArgs.get( "shiftclick", False ) : - converter = holder.parent().createNode( "ieCortexConverter", node_name = holder.name()+"Converter" ) - outputNode = hou.node( contextArgs.get( "outputnodename", "" ) ) - if hasattr(toolutils, "connectMultiInputsAndOutputs"): - toolutils.connectMultiInputsAndOutputs( converter, False, [( holder, 0, 0 )] if holder else None, [( outputNode, 0, 0 )] if outputNode else None ) - else: - toolutils.connectInputsAndOutputs( converter, False, holder, outputNode, 0, 0 ) - x, y = holder.position() - converter.setPosition( [x,y-1] ) - - return holder - - # do we have a valid parameterised instance? - def hasParameterised( self ) : - - return IECoreHoudini._IECoreHoudini._FnParameterisedHolder( self.node() ).hasParameterised() if self.nodeValid() else False - - # this sets a parameterised object on our node and then updates the parameters - def setParameterised( self, classNameOrParameterised, classVersion=None, envVarName=None, updateGui=True ) : - - if not self.nodeValid() : - return - - if isinstance( classNameOrParameterised, str ) : - if classVersion is None or classVersion < 0 : - classVersions = IECore.ClassLoader.defaultLoader( envVarName ).versions( classNameOrParameterised ) - classVersion = classVersions[-1] if classVersions else 0 - IECoreHoudini._IECoreHoudini._FnParameterisedHolder( self.node() ).setParameterised( classNameOrParameterised, classVersion, envVarName ) - else : - IECoreHoudini._IECoreHoudini._FnParameterisedHolder( self.node() ).setParameterised( classNameOrParameterised ) - - parameterised = self.getParameterised() - - if updateGui and parameterised : - self.updateParameters( parameterised ) - - # this returns the parameterised object our node is working with - def getParameterised( self ) : - - return IECoreHoudini._IECoreHoudini._FnParameterisedHolder( self.node() ).getParameterised() if self.hasParameterised() else None - - def setParameterisedValues( self, time = None ) : - - time = hou.time() if time is None else time - IECoreHoudini._IECoreHoudini._FnParameterisedHolder( self.node() ).setParameterisedValues( time ) - - # get our list of class names based on matchString - def classNames( self ) : - - if not self.nodeValid() : - return [] - - matchString = self.__node.parm( "__classMatchString" ).eval() - searchPathEnvVar = self.__node.parm( "__classSearchPathEnvVar" ).eval() - return IECore.ClassLoader.defaultLoader( searchPathEnvVar ).classNames( matchString ) - - # takes a snapshot of the parameter values & expressions on our node so - # that if we change the procedural/op we can restore the parameters afterwards. - def cacheParameters(self): - cached_parameters = {} - for p in self.__node.parmTuplesInFolder(['Parameters']): - if p.isSpare(): - data = {} - data['value'] = p.eval() - expressions = [] - for i in range(len(p)): - try: - expr = p[i].expression() - lang = p[i].expressionLanguage() - expressions.append( ( expr, lang ) ) - except: - expressions.append( ( None, None ) ) - data['expressions'] = expressions - cached_parameters[p.name()] = data - return cached_parameters - - # resores parameter values/expressions from those cached by cacheParameters - def restoreCachedParameters(self, cached): - for p in self.__node.parmTuplesInFolder(['Parameters']): - if p.name() in cached: - cached_data = cached[p.name()] - p.set( cached_data['value'] ) - for i in range(len(p)): - if cached_data['expressions'][i][0]: - expr = cached_data['expressions'][i][0] - lang = cached_data['expressions'][i][1] - p[i].setExpression( expr, lang ) - - # return the spare parameters under the "Parameters" tab - def spareParameters( self, tuples=True ) : - - result = [] - - for p in self.__node.spareParms() : - if "Parameters" in p.containingFolders() : - result.append( p.tuple() if tuples else p ) - - return result - - # this method removes all spare parameters from the "Parameters" folder - def removeParameters( self ) : - - if not self.nodeValid() : - return - - spareParms = self.spareParameters() - while spareParms : - self.__node.removeSpareParmTuple( spareParms[0] ) - # this is needed to account for parms removed by a containing folder - spareParms = self.spareParameters() - - # add/remove parameters on our node so we correctly reflect our Procedural - def updateParameters( self, parameterised ) : - if not self.nodeValid(): - return - - # cache parameters & then remove them - cached_parameters = self.cacheParameters() - self.removeParameters() - if not parameterised: - return - - # get a list of our parm templates by calling createParm on our top-level CompoundParameter - # and add them as spare parameter - parms = IECoreHoudini.ParmTemplates.createParm( parameterised.parameters(), top_level=True ) - parm_names = [] - for p in parms: - parm_names.append( p['name'] ) - parm = self.__node.addSpareParmTuple( p['tuple'], in_folder=p['folder'], create_missing_folders=True ) - parm.set( p['initialValue'] ) - - # restore our cached parameters - self.restoreCachedParameters( cached_parameters ) - - # update the nodes parameter evaluation expression - # this creates cook dependencies on the parameters - expr = "" - for p in parm_names: - expr += "if parmTuple('%s'):\n\t%s = evalParmTuple('%s')\n" % ( p, p, p ) - expr += "return 1" - if len(parm_names)==0: - expr = "1" - eval_parm = self.__node.parm( "__evaluateParameters" ) - eval_parm.lock(False) - eval_parm.setExpression( expr, language=hou.exprLanguage.Python, replace_expression=True ) - eval_parm.lock(True) diff --git a/python/IECoreHoudini/ParmTemplates.py b/python/IECoreHoudini/ParmTemplates.py deleted file mode 100644 index 3eb94e1a05..0000000000 --- a/python/IECoreHoudini/ParmTemplates.py +++ /dev/null @@ -1,443 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2011-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou, IECore, IECoreScene, IECoreHoudini -import string, math - -''' -This contains template methods for creating Houdini parameters. They are mainly used by IECoreHoudini -to create the interface for procedurals/ops. -''' - -# top-level parameter creation method -# takes a cortex parameter and creates a list of HOM parm tuples -def createParm( p, folders=None, parent=None, top_level=False ): - parm = None - results = [] - if not folders: - folders = [] - - # Compound Parameter - if p.isInstanceOf( IECore.TypeId.CompoundParameter ) : - if top_level==True: # this is our top-level CompoundParameter - sub_folder = ['Parameters'] - name = None - else: - label = parmLabel( p ) - sub_folder = folders + [label] - name = parmName( p.name, prefix=parent ) - - # recurse through children - for child in p.values(): - results += createParm( child, sub_folder, parent=name ) - - # int - if p.typeId()==IECore.TypeId.IntParameter: - parm = IECoreHoudini.ParmTemplates.intParm( p, parent=parent ) - if p.typeId()==IECore.TypeId.V2iParameter: - parm = IECoreHoudini.ParmTemplates.intParm( p, 2, parent=parent ) - if p.typeId()==IECore.TypeId.V3iParameter: - parm = IECoreHoudini.ParmTemplates.intParm( p, 3, parent=parent ) - - # float, V2f, V3f - if p.typeId()==IECore.TypeId.FloatParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, parent=parent ) - if p.typeId()==IECore.TypeId.V2fParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, 2, parent=parent ) - if p.typeId()==IECore.TypeId.V3fParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, 3, parent=parent ) - - # double - if p.typeId()==IECore.TypeId.DoubleParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, parent=parent ) - if p.typeId()==IECore.TypeId.V2dParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, 2, parent=parent ) - if p.typeId()==IECore.TypeId.V3dParameter: - parm = IECoreHoudini.ParmTemplates.floatParm( p, 3, parent=parent ) - - # bool - if p.typeId()==IECore.TypeId.BoolParameter: - parm = IECoreHoudini.ParmTemplates.boolParm( p, parent=parent ) - - # string - if p.typeId()==IECore.TypeId.StringParameter: - parm = IECoreHoudini.ParmTemplates.stringParm( p, parent=parent ) - - # validated string - if p.typeId()==IECore.TypeId.ValidatedStringParameter: - parm = IECoreHoudini.ParmTemplates.stringParm( p, parent=parent ) - - # path, dirname, filename, filesequence - if p.typeId()==IECore.TypeId.PathParameter: - parm = IECoreHoudini.ParmTemplates.pathParm( p, parent=parent ) - - if p.typeId()==IECore.TypeId.DirNameParameter: - parm = IECoreHoudini.ParmTemplates.pathParm( p, parent=parent ) - - if p.typeId()==IECore.TypeId.FileNameParameter: - parm = IECoreHoudini.ParmTemplates.pathParm( p, parent=parent ) - - if p.typeId()==IECore.TypeId.FileSequenceParameter: - parm = IECoreHoudini.ParmTemplates.pathParm( p, parent=parent ) - - # frame list - if p.typeId()==IECore.TypeId.FrameListParameter: - parm = IECoreHoudini.ParmTemplates.stringParm( p, parent=parent ) - - # color3f - if p.typeId()==IECore.TypeId.Color3fParameter: - parm = IECoreHoudini.ParmTemplates.colParm( p, 3, parent=parent ) - - # color4f - if p.typeId()==IECore.TypeId.Color4fParameter: - parm = IECoreHoudini.ParmTemplates.colParm( p, 4, parent=parent ) - - # M44f, M44d - if p.typeId()==IECore.TypeId.M44fParameter: - parm = IECoreHoudini.ParmTemplates.matrixParm( p, parent=parent ) - if p.typeId()==IECore.TypeId.M44dParameter: - parm = IECoreHoudini.ParmTemplates.matrixParm( p, parent=parent ) - - # Box2i, Box2f, Box2d - if p.typeId()==IECore.TypeId.Box2iParameter: - parm = IECoreHoudini.ParmTemplates.boxParmInt( p, 2, parent=parent ) - if p.typeId()==IECore.TypeId.Box2fParameter: - parm = IECoreHoudini.ParmTemplates.boxParmFloat( p, 2, parent=parent ) - if p.typeId()==IECore.TypeId.Box2dParameter: - parm = IECoreHoudini.ParmTemplates.boxParmFloat( p, 2, parent=parent ) - - # Box3i, Box3f, Box3d - if p.typeId()==IECore.TypeId.Box3iParameter: - parm = IECoreHoudini.ParmTemplates.boxParmInt( p, 3, parent=parent ) - if p.typeId()==IECore.TypeId.Box3fParameter: - parm = IECoreHoudini.ParmTemplates.boxParmFloat( p, 3, parent=parent ) - if p.typeId()==IECore.TypeId.Box3dParameter: - parm = IECoreHoudini.ParmTemplates.boxParmFloat( p, 3, parent=parent ) - - if p.isInstanceOf( IECore.TypeId.ObjectParameter ) : - # input connection parameter, may need to add conversion parameters - if set(p.validTypes()).intersection( set(IECoreHoudini.FromHoudiniGeometryConverter.supportedTypes()) ) : - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( p.validTypes() ) - sub_folder = folders + [ parmLabel( p ) ] - name = parmName( p.name, prefix=parent ) - ## \todo: set joinWithNext with userData if hou.ParmTemplate.setJoinWithNext() starts working - useNameFilterParm = IECore.BoolParameter( "useNameFilter", "Enables the nameFilter", True ) - results += createParm( useNameFilterParm, sub_folder, parent=name ) - useNameTuple = results[-1]["tuple"] - nameFilterParm = IECore.StringParameter( - "nameFilter", "A list of named shapes to convert. Uses Houdini matching syntax.", "*", - userData = { "houdini" : { "disableWhen" : IECore.StringData( "{ %s == 0 }" % useNameTuple.name() ) } } - ) - results += createParm( nameFilterParm, sub_folder, parent=name ) - for child in converter.parameters().values() : - results += createParm( child, sub_folder, parent=name ) - - if parm: - - with IECore.IgnoredExceptions( KeyError ) : - parm['tuple'].hide( not bool(p.userData()["UI"]['visible'].value) ) - - with IECore.IgnoredExceptions( KeyError ) : - parm['tuple'].setDisableWhen( p.userData()["houdini"]['disableWhen'].value ) - - # add our list of parent folders - parm['folder'] = folders - parm['cortex_name'] = p.name - - # add to our list of results - results.append(parm) - - # certain parameter types are ok to ignore - ignoredParameterTypes = ( - IECore.CompoundParameter, - IECore.ObjectParameter, - IECoreScene.PrimitiveParameter, - IECoreScene.GroupParameter, - ) - - if not parm and not isinstance( p, ignoredParameterTypes ) : - msg = "IECoreHoudini does not currently support parameters of type " + p.typeName() - - # hbatch/hython don't support ui.setStatusMessage() - ## \todo: remove this if the Houdini load errors stop masking the IECore warnings - if hou.isUIAvailable() : - hou.ui.setStatusMessage( msg, hou.severityType.Warning ) - - IECore.warning( msg ) - - # our parent folder list - return results - -# returns a houdini parameter name, give it's cortex name -def parmName( name, prefix=None ) : - if not prefix : - prefix = "parm" - - return "_".join( [ prefix, name ] ) - -# returns a parameter label -def parmLabel( p ) : - if 'UI' in p.userData() and 'label' in p.userData()['UI'] : - return p.userData()['UI']['label'].value - else : - return IECore.CamelCase.toSpaced( p.name ) - -# sets the parmTemplate menu arguments for preset parameters -def presetsMenuArgs( p ) : - menuLabels = p.presetNames() - menuItems = tuple( [ str(x.value) for x in p.presetValues() ] ) - menuType = hou.menuType.Normal - if not p.presetsOnly : - menuType = hou.menuType.StringReplace - - return { - "menu_items" : menuItems, - "menu_labels" : menuLabels, - "menu_type" : menuType - } - -#===== -# use the following to find out how to call template() -# n.parm("intparm").parmTemplate().asCode() -def intParm( p, dim=1, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - - # only simple floats have min/max values - if dim==1: - default = [(p.defaultValue.value)] - initialValue = [ p.getTypedValue() ] - min_val = 0 - max_val = 10 - min_lock = max_lock = False - naming = hou.parmNamingScheme.Base1 - if p.hasMinValue(): - min_val = p.minValue - min_lock = True - if p.hasMaxValue(): - max_val = p.maxValue - max_lock = True - - else: - default = list(p.defaultValue.value) - initialValue = list(p.getTypedValue()) - min_val = 0 - max_val = 10 - min_lock = max_lock = False - naming = hou.parmNamingScheme.XYZW - - # Houdini can only handle presets for dim 1 ints, and even then its quite messy... - if dim == 1 and p.presetsOnly : - parm = hou.MenuParmTemplate( - name, label, default_value=p.presetValues().index( p.defaultValue ), - help=p.description, - **presetsMenuArgs( p ) - ) - - initialValue = [ p.presetValues().index( p.getValue() ) ] - else : - parm = hou.IntParmTemplate( - name, label, dim, default_value=default, - min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, - naming_scheme=naming, help=p.description - ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : initialValue } - -#===== -# use the following to find out how to call template() -# n.parm("floatparm").parmTemplate().asCode() -def floatParm( p, dim=1, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - - # only simple floats have min/max values - if dim==1: - default = [(p.defaultValue.value)] - min_val = 0.0 - max_val = 10.0 - min_lock = max_lock = False - if p.hasMinValue(): - min_val = p.minValue - min_lock = True - if p.hasMaxValue(): - max_val = p.maxValue - max_lock = True - else: - default = list(p.defaultValue.value) - min_val = 0.0 - max_val = 10.0 - min_lock = max_lock = False - - naming = hou.parmNamingScheme.Base1 - if dim>1: - naming = hou.parmNamingScheme.XYZW - - parm = hou.FloatParmTemplate( - name, label, dim, default_value=default, - min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, - look=hou.parmLook.Regular, naming_scheme=naming, help=p.description - ) - - if dim == 1 : - initialValue = [ p.getTypedValue() ] - else : - initialValue = list(p.getTypedValue()) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : initialValue } - -#===== -# use the following to find out how to call template() -# n.parm("boolparm").parmTemplate().asCode() -def boolParm( p, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default = p.defaultValue.value - parm = hou.ToggleParmTemplate( name, label, default_value=default, disable_when="", help=p.description ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : [ p.getTypedValue() ] } - -def stringParm( p, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default = ([p.defaultValue.value]) - - parm = hou.StringParmTemplate( - name, label, 1, default_value=default, - naming_scheme = hou.parmNamingScheme.Base1, help=p.description, - **presetsMenuArgs( p ) - ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : [ p.getTypedValue() ] } - -def pathParm( p, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default = ([p.defaultValue.value]) - parm = hou.StringParmTemplate( - name, label, 1, default_value=default, - naming_scheme=hou.parmNamingScheme.Base1, - string_type=hou.stringParmType.FileReference, help=p.description, - **presetsMenuArgs( p ) - ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : [ p.getTypedValue() ] } - -def colParm( p, dim, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default = list(p.defaultValue.value) - parm = hou.FloatParmTemplate( - name, label, dim, default_value=default, - min=0, max=1, min_is_strict=False, max_is_strict=False, - look=hou.parmLook.ColorSquare, - naming_scheme=hou.parmNamingScheme.RGBA, help=p.description - ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : list(p.getTypedValue()) } - -def matrixParm( p, dim=16, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default_matrix = p.defaultValue.value - default = [] - dim_sqrt = int(math.sqrt(dim)) - for i in range(dim_sqrt): - for j in range(dim_sqrt): - default.append( default_matrix[(i,j)] ) - min_val = 0.0 - max_val = 10.0 - min_lock = max_lock = False - parm = hou.FloatParmTemplate( - name, label, dim, default_value=default, - min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, - look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.Base1, help=p.description - ) - - matrix = p.getTypedValue() - initialValue = [] - for i in range(dim_sqrt): - for j in range(dim_sqrt): - initialValue.append( matrix[(i,j)] ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : initialValue } - -def boxParmInt( p, dim, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default_box = p.defaultValue.value - default = [] - default = list(default_box.min) - default.extend( list(default_box.max) ) - - min_val = 0 - max_val = 10 - min_lock = max_lock = False - parm = hou.IntParmTemplate( - name, label, dim * 2, default_value=default, - min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, - naming_scheme=hou.parmNamingScheme.Base1, help=p.description - ) - - box = p.getTypedValue() - initialValue = list(box.min) - initialValue.extend( list(box.max) ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : initialValue } - -def boxParmFloat( p, dim, parent=None ): - name = parmName( p.name, prefix=parent ) - label = parmLabel( p ) - default_box = p.defaultValue.value - default = [] - default = list(default_box.min) - default.extend( list(default_box.max) ) - - min_val = 0.0 - max_val = 10.0 - min_lock = max_lock = False - parm = hou.FloatParmTemplate( - name, label, dim * 2, default_value=default, - min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, - look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.Base1, help=p.description - ) - - box = p.getTypedValue() - initialValue = list(box.min) - initialValue.extend( list(box.max) ) - - return { 'name' : name, 'tuple' : parm, 'initialValue' : initialValue } diff --git a/python/IECoreHoudini/TemporaryParameterValues.py b/python/IECoreHoudini/TemporaryParameterValues.py deleted file mode 100644 index a7371aab50..0000000000 --- a/python/IECoreHoudini/TemporaryParameterValues.py +++ /dev/null @@ -1,87 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou - -import IECore - -## A context manager for controlling houdini parameter values in with statements. -# It sets parameters to requested values on entering the block and resets them to -# their previous values on exiting the block. -class TemporaryParameterValues : - - def __init__( self, parametersAndValues = {}, **kw ) : - - self.__parametersAndValues = parametersAndValues - self.__parametersAndValues.update( kw ) - - def __enter__( self ) : - - handlers = { - "Int" : self.__simpleParmHandler, - "Float" : self.__simpleParmHandler, - "String" : self.__simpleParmHandler, - } - - self.__restoreCommands = [] - for parmName, value in self.__parametersAndValues.items() : - - # check we can handle this type - parm = hou.parm( parmName ) or hou.parmTuple( parmName ) - if not parm : - raise TypeError( "Parameter \"%s\" does not exist." % parmName ) - - parmType = parm.parmTemplate().dataType().name() - handler = handlers.get( parmType, None ) - if not handler : - raise TypeError( "Parameter \"%s\" has unsupported type \"%s\"." % ( parmName, parmType ) ) - - # store a command to restore the parameter value later - self.__restoreCommands.append( parm.asCode() ) - - # and change the parameter value - handler( parm, value ) - - def __exit__( self, type, value, traceBack ) : - - for command in self.__restoreCommands : - exec( command ) - - def __simpleParmHandler( self, parm, value ) : - - if isinstance( parm, hou.ParmTuple ) and not isinstance( value, tuple ) : - value = value, - - parm.deleteAllKeyframes() - parm.set( value ) diff --git a/python/IECoreHoudini/TestCase.py b/python/IECoreHoudini/TestCase.py deleted file mode 100644 index d9c3fbb841..0000000000 --- a/python/IECoreHoudini/TestCase.py +++ /dev/null @@ -1,61 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import unittest - -## A class to help implement unit tests for Houdini functionality. It -# implements setUp() to create a new houdini scene to perform the test in. -class TestCase( unittest.TestCase ) : - - ## Derived classes may override this, but they should call the - # base class implementation too. - def setUp( self ) : - self.__fileIndex = 0 - hou.hipFile.clear( True ) - - def checkPointHipFile( self, name = None ) : - """ - Utility function to dump a .hip file to the temp directory - It's useful to call this function during a test after the houdini nodes are setup, - you can load the file in houdini to visually see what the test is supposed to be testing. - """ - - if not name : - name = self.id() - - fileName = "/tmp/{0}.{1}.hip".format( name, self.__fileIndex ) - print(fileName) - hou.hipFile.save( fileName ) - self.__fileIndex += 1 diff --git a/python/IECoreHoudini/TestProgram.py b/python/IECoreHoudini/TestProgram.py deleted file mode 100644 index c9460d8abe..0000000000 --- a/python/IECoreHoudini/TestProgram.py +++ /dev/null @@ -1,52 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import sys -import unittest - -## A test program which initializes Houdini before running the test suite. -class TestProgram( unittest.TestProgram ) : - - def __init__( self, module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.defaultTestLoader ) : - - unittest.TestProgram.__init__( self, module, defaultTest, argv, testRunner, testLoader ) - - def runTests( self ) : - - if not self.testRunner : - self.testRunner = unittest.TextTestRunner( verbosity = 2 ) - - result = self.testRunner.run( self.test ) - - sys.exit( int( not result.wasSuccessful() ) ) diff --git a/python/IECoreHoudini/UpdateMode.py b/python/IECoreHoudini/UpdateMode.py deleted file mode 100644 index f88a86d15a..0000000000 --- a/python/IECoreHoudini/UpdateMode.py +++ /dev/null @@ -1,53 +0,0 @@ -########################################################################## -# -# Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou - -## A context object intended for use with python's "with" syntax. It ensures -# that all operations in the with block are performed in the given hou.updateMode, -# and that the updateMode is restored when the block exits. -class UpdateMode : - - def __init__( self, mode ) : - - self.__mode = mode - self.__prevMode = hou.updateModeSetting() - - def __enter__( self ) : - - hou.setUpdateMode( self.__mode ) - - def __exit__( self, type, value, traceBack ) : - - hou.setUpdateMode( self.__prevMode ) diff --git a/python/IECoreHoudini/Utils.py b/python/IECoreHoudini/Utils.py deleted file mode 100644 index 79b680daf5..0000000000 --- a/python/IECoreHoudini/Utils.py +++ /dev/null @@ -1,159 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou, IECore, IECoreHoudini - -''' -This contains utility methods for doing useful stuff in the IECoreHoudini -python module. -''' - -# returns an instance of an op loaded using the defaultOpLoader -def op(type, ver): - return IECore.ClassLoader.defaultOpLoader().load(type,ver)() - -# sets a houdini parameter based on the value from it's corresponding cortex parameter -def setHoudiniParm( node, p ): - value = p.getValue().value - - if p.typeId()==IECore.TypeId.IntParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - if p.typeId()==IECore.TypeId.V2iParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.V3iParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # float, V2f, V3f - if p.typeId()==IECore.TypeId.FloatParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - if p.typeId()==IECore.TypeId.V2fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.V3fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # double - if p.typeId()==IECore.TypeId.DoubleParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - if p.typeId()==IECore.TypeId.V2dParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.V3dParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # bool - if p.typeId()==IECore.TypeId.BoolParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - # string - if p.typeId()==IECore.TypeId.StringParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - # path, dirname, filename, filesequence - if p.typeId()==IECore.TypeId.PathParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - if p.typeId()==IECore.TypeId.DirNameParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - if p.typeId()==IECore.TypeId.FileNameParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - if p.typeId()==IECore.TypeId.FileSequenceParameter: - node.parmTuple( "parm_%s" % p.name ).set( [value] ) - - # color3f - if p.typeId()==IECore.TypeId.Color3fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # color4f - if p.typeId()==IECore.TypeId.Color4fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # M44f, M44d - if p.typeId()==IECore.TypeId.M44fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.M44dParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # Box2i, Box2f, Box2d - if p.typeId()==IECore.TypeId.Box2iParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.Box2fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.Box2dParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - - # Box3i, Box3f, Box3d - if p.typeId()==IECore.TypeId.Box3iParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.Box3fParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - if p.typeId()==IECore.TypeId.Box3dParameter: - node.parmTuple( "parm_%s" % p.name ).set( list(value) ) - -def syncSopParametersWithOp(n): - fn = IECoreHoudini.FnOpHolder( n ) - parms = fn.getParameterised().parameters().values() - for p in parms: - if n.parm("parm_%s"%p.name): - setHoudiniParm( n, p ) - -# reloads an op based on the values of the type/version parameters -def reloadOp(): - n = hou.node(".") - type = n.evalParm("__opType") - ver = n.evalParm("__opVersion") - if type=="" or ver=="": - return - ver = int(ver) - fn = IECoreHoudini.FnOpHolder(n) - IECore.ClassLoader.defaultOpLoader().refresh() - cl = IECoreHoudini.op( type, ver ) - - # cache our existing parameters - parms = fn.getParameterised().parameters().values() - saved_parms = {} - for p in parms: - saved_parms[p.name] = p.getValue().value - - # reload parameter interface - fn.setParameterised(cl) - - # restore parameter values - for p in saved_parms.keys(): - hparm = n.parm("parm_%s" % p) - if hparm: - hparm.set( saved_parms[p] ) - - diff --git a/python/IECoreHoudini/__init__.py b/python/IECoreHoudini/__init__.py deleted file mode 100644 index 4809ed00af..0000000000 --- a/python/IECoreHoudini/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -# require HOM -import hou - -# require IECore -import IECore -import IECoreScene -# our c++ module components -from ._IECoreHoudini import * - -# function sets -from .FnParameterisedHolder import FnParameterisedHolder -from .FnOpHolder import FnOpHolder - -# misc utility methods -from .TestCase import TestCase -from .TestProgram import TestProgram -from . import ParmTemplates -from . import Utils - -from .ActiveTake import ActiveTake -from .TemporaryParameterValues import TemporaryParameterValues -from .UpdateMode import UpdateMode - -## \todo: remove this hack if SideFx provides a swig-free method for sending a HOM_Node* to python -LiveScene.node = lambda x : hou.node( x._getNodePath() ) - -# this cleanup method is provided by _IECoreHoudini -__import__( "atexit" ).register( cleanup ) - -__import__( "IECore" ).loadConfig( "CORTEX_STARTUP_PATHS", subdirectory = "IECoreHoudini" ) diff --git a/python/IECoreMaya/AttributeEditorControl.py b/python/IECoreMaya/AttributeEditorControl.py deleted file mode 100644 index efe656fb10..0000000000 --- a/python/IECoreMaya/AttributeEditorControl.py +++ /dev/null @@ -1,109 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.mel - -## A base class to help in creating custom attribute editor controls -# in a nice object oriented manner. After deriving from this class you -# can instantiate a control from an attribute editor template using mel -# of the following form : -# -# ieAttributeEditorControl( "DerivedClassName", "attributeName" ) -class AttributeEditorControl : - - ## Derived classes should first call the base class __init__, before - # building their ui. - def __init__( self, attribute ) : - - self.__nodeName = attribute.split( "." )[0] - self.__attributeName = attribute - - ## Derived classes should first call the base class replace, before - # reattaching their ui to the new attribute. - def replace( self, attribute ) : - - self.__nodeName = attribute.split( "." )[0] - self.__attributeName = attribute - - ## Returns the name of the node this ui is used for. - def nodeName( self ) : - - return self.__nodeName - - ## Returns the name of the attribute this ui is used for. - def attributeName( self ) : - - return self.__attributeName - - @staticmethod - def _new( className, attribute ) : - - # we smuggle the class name as a fake attribute name so we - # need to get it back out now. - className = ".".join( className.split( "." )[1:] ) - - # the class name might also be in a namespace that isn't imported - # in this scope. so import it. - if not "." in className : - cls = eval( className ) - else : - names = className.split( "." ) - namespace = __import__( ".".join( names[:-1] ) ) - cls = getattr( namespace, names[-1] ) - - parent = maya.cmds.setParent( q=True ) - control = cls( attribute ) - maya.cmds.setParent( parent ) - - AttributeEditorControl.__instances[parent] = control - - # Script jobs aren't available from maya.cmds. Maya Python bindings generate swig warnings - # such as "swig/python detected a memory leak of type 'MCallbackId *', no destructor found" - maya.mel.eval( 'scriptJob -protected -uiDeleted "%s" "python \\"IECoreMaya.AttributeEditorControl._uiDeleted( \'%s\' )\\""' % ( parent, parent ) ) - - @staticmethod - def _replace( attribute ) : - - parent = maya.cmds.setParent( q=True ) - control = AttributeEditorControl.__instances[parent] - control.replace( attribute ) - - @staticmethod - def _uiDeleted( parent ) : - - del AttributeEditorControl.__instances[parent] - - # Maps from parent ui names to AttributeEditorControl instances - __instances = {} diff --git a/python/IECoreMaya/BakeTransform.py b/python/IECoreMaya/BakeTransform.py deleted file mode 100644 index 1301577742..0000000000 --- a/python/IECoreMaya/BakeTransform.py +++ /dev/null @@ -1,132 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from maya.OpenMaya import * -import maya.cmds -import math -import IECore -import IECoreMaya - -class BakeTransform( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, "Bakes transforms from one object onto another.", - IECoreMaya.DAGPathParameter( - name = "result", - description = "The name of the baked transform", - defaultValue = "", - allowEmptyString = True, - ) - ) - - self.parameters().addParameters( - [ - IECoreMaya.DAGPathParameter( - name = "src", - description = "The source transform node to bake from.", - defaultValue = "", - check = IECoreMaya.DAGPathParameter.CheckType.MustExist, - allowEmptyString = False, - ), - IECoreMaya.DAGPathParameter( - name = "dst", - description = "The destination transform node to apply the bake to. If this doesn't exist" - "then it'll be created for you.", - defaultValue = "", - check = IECoreMaya.DAGPathParameter.CheckType.DontCare, - allowEmptyString = False, - ), - IECore.FrameListParameter( - name = "frames", - description = "The frame range over which to perform the bake." - "Keyframes will be made at every frame in this range.", - defaultValue = IECoreMaya.PlaybackFrameList( IECoreMaya.PlaybackFrameList.Range.Playback ), - ), - IECore.BoolParameter( - name = "lock", - description = "If this is specified then the transform attributes which are" - "keyframed on the destination object are also locked.", - defaultValue = False, - ), - ] - ) - - @staticmethod - def transferTransform( src, dst, setKey=True ) : - - worldMatrixConverter = IECoreMaya.FromMayaPlugConverter.create( str(src.fullPathName()) + ".worldMatrix" ) - worldMatrix = worldMatrixConverter.convert().value - e = worldMatrix.rotate - maya.cmds.xform( dst.fullPathName(), translation=tuple( worldMatrix.translate ), rotation=[math.degrees(x) for x in e], scale=tuple( worldMatrix.scale ) ) - maya.cmds.setKeyframe( dst.fullPathName(), attribute=["translate", "rotate", "scale"] ) - - @staticmethod - def lockTransform( transform ) : - - transformName = transform.fullPathName() - maya.cmds.setAttr( str( transformName ) + ".translate", lock=True ) - maya.cmds.setAttr( str( transformName ) + ".rotate", lock=True ) - maya.cmds.setAttr( str( transformName ) + ".scale", lock=True ) - maya.cmds.setAttr( str( transformName ) + ".shear", lock=True ) - - def doOperation( self, operands ) : - - if maya.cmds.objExists( operands.dst.value ) : - dst = self.dst.getDAGPathValue() - else : - dst = maya.cmds.createNode( "transform", name=operands.dst.value, skipSelect=True ) - list = MSelectionList() - list.add( dst ) - dst = MDagPath() - list.getDagPath(0, dst) - - dstPath = str( dst.fullPathName() ) - - src = self.src.getDAGPathValue() - - for f in self.frames.getFrameListValue().asList() : - - maya.cmds.currentTime( float( f ) ) - self.transferTransform( src, dst, True ) - - # fix discontinuous rotations - maya.cmds.filterCurve( dstPath + ".rotateX", dstPath + ".rotateY", dstPath + ".rotateZ" ) - - if operands.lock.value : - self.lockTransform( dst ) - - return IECore.StringData( dstPath ) - -IECore.registerRunTimeTyped( BakeTransform ) diff --git a/python/IECoreMaya/BoolParameterUI.py b/python/IECoreMaya/BoolParameterUI.py deleted file mode 100644 index 1ebf8872c6..0000000000 --- a/python/IECoreMaya/BoolParameterUI.py +++ /dev/null @@ -1,77 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class BoolParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.rowLayout( - numberOfColumns = 2, - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex * 3 ] - ), - **kw - - ) - - maya.cmds.text( - label = "", - ) - - self.__checkBox = maya.cmds.checkBox( - annotation = self.description(), - label = self.label(), - align = "left", - ) - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - maya.cmds.connectControl( self.__checkBox, self.plugName() ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.BoolParameter, BoolParameterUI ) diff --git a/python/IECoreMaya/BoxParameterUI.py b/python/IECoreMaya/BoxParameterUI.py deleted file mode 100644 index 3a97d77d01..0000000000 --- a/python/IECoreMaya/BoxParameterUI.py +++ /dev/null @@ -1,123 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class BoxParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.columnLayout(), **kw ) - - self.__fields = [] - - self.__dim = parameter.getTypedValue().dimensions() - - plug = self.plug() - for childIndex in range( 0, 2 ) : - - if self.__dim == 2: - maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - elif self.__dim == 3: - maya.cmds.rowLayout( - numberOfColumns = 4, - columnWidth4 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - else: - raise RuntimeError("Unsupported vector dimension in BoxParameterUI") - - parameterLabel = self.label() - if childIndex==0 : - parameterLabel = parameterLabel + "Min" - else: - parameterLabel = parameterLabel + "Max" - - maya.cmds.text( - label = parameterLabel, - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - vectorPlug = plug.child( childIndex ) - - for i in range( 0, self.__dim ) : - - self.__fields.append( self.__fieldType()() ) - - maya.cmds.setParent("..") - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - fieldNum = 0 - plug = self.plug() - for childIndex in range( 0, 2 ) : - - vectorPlug = plug.child( childIndex ) - for i in range( 0, self.__dim ) : - - vectorPlugChild = vectorPlug.child( i ) - vectorPlugChildName = self.nodeName() + "." + vectorPlugChild.partialName() - maya.cmds.connectControl( self.__fields[ fieldNum ], vectorPlugChildName ) - self._addPopupMenu( parentUI = self.__fields[fieldNum], attributeName = vectorPlugChildName ) - - fieldNum += 1 - - def __fieldType( self ): - - if self.parameter.isInstanceOf( IECore.TypeId.Box2iParameter ) or self.parameter.isInstanceOf( IECore.TypeId.Box3iParameter ): - return maya.cmds.intField - else: - return maya.cmds.floatField - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box2iParameter, BoxParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box2fParameter, BoxParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box2dParameter, BoxParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box3iParameter, BoxParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box3fParameter, BoxParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Box3dParameter, BoxParameterUI ) - - diff --git a/python/IECoreMaya/ClassParameterUI.py b/python/IECoreMaya/ClassParameterUI.py deleted file mode 100644 index f4a77e84cf..0000000000 --- a/python/IECoreMaya/ClassParameterUI.py +++ /dev/null @@ -1,214 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import os.path - -import maya.cmds - -import IECore -import IECoreMaya - -class ClassParameterUI( IECoreMaya.CompoundParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - self.__menuParent = None - self.__currentClassInfo = parameter.getClass( True )[1:] - - # We have to do this after initialising self.__menuParent as - # CompoundParameterUI.__init__ will call _createHeader in this - # class, which populates self.__menuParent. - IECoreMaya.CompoundParameterUI.__init__( self, node, parameter, **kw ) - - def _createHeader( self, columnLayout, **kw ) : - - IECoreMaya.CompoundParameterUI._createHeader( self, columnLayout, **kw ) - - maya.cmds.rowLayout( numberOfColumns = 2, parent = columnLayout ) - - collapsable = True - with IECore.IgnoredExceptions( KeyError ) : - collapsable = self.parameter.userData()["UI"]["collapsable"].value - - lable = "Class" if collapsable else self.label() - font = "smallPlainLabelFont" if collapsable else "tinyBoldLabelFont" - - maya.cmds.text( - label = lable, - font = font, - align = "right", - annotation = self.description() - ) - - self.__menuParent = maya.cmds.iconTextStaticLabel( - image = "arrowDown.xpm", - font = "smallBoldLabelFont", - label = self.__menuParentLabel(), - style = "iconAndTextHorizontal", - height = 23, - ) - - # popup menu can be activated with either right or left buttons - IECoreMaya.Menu( self.__menuDefinition, self.__menuParent ) - IECoreMaya.Menu( self.__menuDefinition, self.__menuParent, button = 1 ) - - def replace( self, node, parameter ) : - - newClassInfo = parameter.getClass( True )[1:] - if newClassInfo != self.__currentClassInfo : - self._deleteChildParameterUIs() - - IECoreMaya.CompoundParameterUI.replace( self, node, parameter ) - - if self.__menuParent : - maya.cmds.iconTextStaticLabel( self.__menuParent, edit=True, label=self.__menuParentLabel() ) - - self.__currentClassInfo = newClassInfo - - ## We add support for the 'lazy' keyword argument. If True, then the layout - # will not expand if the parameter doesn't contain a class. - def setCollapsed( self, collapsed, propagateToChildren=0, **kw ) : - - lazy = kw["lazy"] if "lazy" in kw else False - - if not collapsed : - if lazy and not self.parameter.getClass( False ) : - collapsed = True - - IECoreMaya.CompoundParameterUI.setCollapsed( self, collapsed, propagateToChildren, **kw ) - - def __classNameFilter( self ) : - - with IECore.IgnoredExceptions( KeyError ) : - return self.parameter.userData()["UI"]["classNameFilter"].value - - return "*" - - def __menuParentLabel( self ) : - - classInfo = self.parameter.getClass( True ) - if classInfo[1] : - labelPathStart = max( 0, self.__classNameFilter().find( "*" ) ) - return "%s v%d" % ( classInfo[1][labelPathStart:], classInfo[2] ) - else : - return "Choose..." - - def __menuDefinition( self ) : - - result = IECore.MenuDefinition() - - menuPathStart = max( 0, self.__classNameFilter().find( "*" ) ) - - classInfo = self.parameter.getClass( True ) - - loader = IECore.ClassLoader.defaultLoader( classInfo[3] ) - for className in loader.classNames( self.__classNameFilter() ) : - classVersions = loader.versions( className ) - for classVersion in classVersions : - - menuPath = "/" + className[menuPathStart:] - if len( classVersions ) > 1 : - menuPath += "/v" + str( classVersion ) - - result.append( - - menuPath, - - IECore.MenuItemDefinition( - command = IECore.curry( self.__setClass, className, classVersion, classInfo[3] ), - active = className != classInfo[1] or classVersion != classInfo[2] - ) - - ) - - result.append( - "/RemoveDivider", - IECore.MenuItemDefinition( - divider = True - ) - ) - - result.append( - - "/Remove", - - IECore.MenuItemDefinition( - command = IECore.curry( self.__setClass, "", 0, classInfo[3] ), - active = classInfo[0] is not None - ) - - ) - - for cb in self.__classMenuCallbacks : - cb( result, self.parameter, self.node() ) - - return result - - def __setClass( self, className, classVersion, searchPathEnvVar ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - - # To stop maya crashing, we need to delete the UI for the existing class - # before we change it in C++, otherwise, an AE update gets triggered after - # we have removed the parameters, but before we have removed the UI. - self._deleteChildParameterUIs() - - with fnPH.parameterModificationContext() : - self.parameter.setClass( className, classVersion, searchPathEnvVar ) - - @staticmethod - def _classSetCallback( fnPH, parameter ) : - - for instance in IECoreMaya.UIElement.instances( ClassParameterUI ) : - if instance.parameter.isSame( parameter ) : - instance.replace( instance.node(), instance.parameter ) - - __classMenuCallbacks = [] - ## Registers a callback which is able to modify the popup menu used to choose - # the class held by this parameter. Callbacks should have the following signature : - # - # callback( menuDefinition, parameter, holderNode ). - @classmethod - def registerClassMenuCallback( cls, callback ) : - - cls.__classMenuCallbacks.append( callback ) - -IECoreMaya.FnParameterisedHolder.addSetClassParameterClassCallback( ClassParameterUI._classSetCallback ) - -IECoreMaya.ParameterUI.registerUI( IECore.ClassParameter.staticTypeId(), ClassParameterUI ) diff --git a/python/IECoreMaya/ClassVectorParameterUI.py b/python/IECoreMaya/ClassVectorParameterUI.py deleted file mode 100644 index 5ab8716573..0000000000 --- a/python/IECoreMaya/ClassVectorParameterUI.py +++ /dev/null @@ -1,1043 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import maya.cmds - -import IECore -import IECoreMaya - -## A ParameterUI for ClassVectorParameters. Supports the following Parameter userData entries : -# -# BoolData ["UI"]["collapsible"] -# Specifies if the UI may be collapsed or not - defaults to True. -# -# The icon used for a child UI can be overridden by setting the icon name, minus extension in either -# the child classes blindData, or its top level compound parameters userData() as follows: -# -# StringData ["UI"]["icon"] -# -# If a parameter of a class has one of the following userData elements set to True, a minimal version -# of the control for that parameter will be placed in the header row for the class entry, -# either before, or after the icon/name. -# -# BoolData ["UI"]["classVectorParameterPreHeader"] -# BoolData ["UI"]["classVectorParameterHeader"] -# -# \TODO See if there is a better way to deal with problematic UI elements (eg: spline) that crash -# when a redraw is called and constituent plugs no longer exist. This can happen when removing -# classes, or changing parameter types, as an AE redraw may happen before the related UI -# has been deleted. It seems for some parameter types, maya doesn't check to see if all -# the required plugs are there during a redraw, and consequently falls over. -# This behavior is currently compensated for by pre-updating the UI before removing a class -# or changing its version. -class ClassVectorParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.frameLayout( - labelVisible = False, - collapsable = False, - ), - **kw - - ) - - # passing borderVisible=False to the constructor does bugger all so we do it here instead. - maya.cmds.frameLayout( self._topLevelUI(), edit=True, borderVisible=False ) - - collapsible = self.__parameterIsCollapsible() - - self.__kw = kw.copy() - if collapsible : - self.__kw["hierarchyDepth"] = self.__kw.get( "hierarchyDepth", -1 ) + 1 - - collapsed = self._retrieveCollapsedState( collapsible ) - - self.__collapsible = IECoreMaya.Collapsible( - - annotation = self.description(), - label = self.label(), - labelFont = IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"] ), - labelIndent = IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ), - labelVisible = collapsible, - collapsed = collapsed, - expandCommand = self.__expand, - collapseCommand = self.__collapse, - - ) - - self.__formLayout = maya.cmds.formLayout( parent=self.__collapsible.frameLayout() ) - - self.__buttonRow = maya.cmds.rowLayout( nc=3, adj=3, cw3=( 25, 25, 40 ), parent=self.__formLayout ) - - self.__addButton = maya.cmds.picture( image="ie_addIcon_grey.xpm", parent=self.__buttonRow, width=21 ) - IECoreMaya.Menu( IECore.curry( self.__classMenuDefinition, None ), self.__addButton ) - IECoreMaya.Menu( IECore.curry( self.__classMenuDefinition, None ), self.__addButton, button=1 ) - - self.__toolsButton = maya.cmds.picture( image="ie_actionIcon_grey.xpm", parent=self.__buttonRow, width=21 ) - IECoreMaya.Menu( IECore.curry( self.__toolsMenuDefinition, None ), self.__toolsButton ) - IECoreMaya.Menu( IECore.curry( self.__toolsMenuDefinition, None ), self.__toolsButton, button=1 ) - - self.__classInfo = [] - self.__childUIs = {} # mapping from parameter name to ui name - - self.replace( node, parameter ) - - def replace( self, node, parameter ) : - - ## This is to catch the fact that self.node() will raise - # if the old node no longer exists. - nodeChanged = True - with IECore.IgnoredExceptions( RuntimeError ) : - nodeChanged = self.node() != node - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - if self.__parameterIsCollapsible() : - collapsed = self._retrieveCollapsedState( self.getCollapsed() ) - self.setCollapsed( collapsed, **self.__kw ) - - self.__updateChildUIs( startFromScratch=nodeChanged ) - - ## Gets the collapsed state for the frame holding the child parameter uis. - def getCollapsed( self ) : - - return self.__collapsible.getCollapsed() - - ## Sets the collapsed state for the frame holding the child parameter uis. - # In the case that this ui itself is not collapsible, it will still propagate - # \param propagateToChildren How many levels of hierarchy to propagate - # the new state to. If a Bool is passed, rather than an int, then - # 'all' or 'none' is assumed, for backwards compatibility - def setCollapsed( self, collapsed, propagateToChildren=0, **kw ) : - - if type(propagateToChildren) == bool : - propagateToChildren = 999 if propagateToChildren else 0 - - if self.__parameterIsCollapsible() : - self.__collapsible.setCollapsed( collapsed ) - self._storeCollapsedState( collapsed ) - - if propagateToChildren > 0 : - propagateToChildren = propagateToChildren - 1 - self.__propagateCollapsed( collapsed, propagateToChildren, **kw ) - - # This will retrieve the collapsedState from the parameters userData. It uses the - # default key if 'collapsedUserDataKey' was not provided in the UI constructor's **kw. - def _retrieveCollapsedState( self, default=True ) : - - key = self.__kw.get( "collapsedUserDataKey", IECoreMaya.CompoundParameterUI._collapsedUserDataKey ) - if "UI" in self.parameter.userData() and key in self.parameter.userData()["UI"] : - return self.parameter.userData()["UI"][ key ].value - else : - return default - - # This will store \param state in the parameters userData, under the default key, - # unless 'collapsedUserDataKey' was provided in the UI constructor's **kw. - def _storeCollapsedState( self, state ) : - - if "UI" not in self.parameter.userData() : - self.parameter.userData()["UI"] = IECore.CompoundObject() - - key = self.__kw.get( "collapsedUserDataKey", IECoreMaya.CompoundParameterUI._collapsedUserDataKey ) - self.parameter.userData()["UI"][key] = IECore.BoolData( state ) - - def __classMenuDefinition( self, parameterName ) : - - result = IECore.MenuDefinition() - - classNameFilter = "*" - try : - classNameFilter = self.parameter.userData()["UI"]["classNameFilter"].value - except : - pass - - ### \todo We can't assume that * is immediately after / - menuPathStart = max( 0, classNameFilter.find( "*" ) ) - - loader = IECore.ClassLoader.defaultLoader( self.parameter.searchPathEnvVar() ) - for className in loader.classNames( classNameFilter ) : - classVersions = loader.versions( className ) - for classVersion in classVersions : - - active = True - if parameterName : - active = self.parameter.getClass( parameterName, True )[1:] != ( className, classVersion ) - - menuPath = "/" + className[menuPathStart:] - if len( classVersions ) > 1 : - menuPath += "/v" + str( classVersion ) - - result.append( - - # applies interToUI to each component of the menu path individually, and then joings them back up again - "/".join( [ maya.mel.eval( "interToUI \"" + x + "\"" ) for x in menuPath.split( "/" ) ] ), - - IECore.MenuItemDefinition( - command = IECore.curry( self._setClass, parameterName, className, classVersion ), - active = active - ) - - ) - - for cb in self.__addClassMenuCallbacks : - cb( result, self.parameter, self.node() ) - - return result - - def __toolsMenuDefinition( self, parameterName ) : - - result = IECore.MenuDefinition() - - if not len( self.__toolsMenuCallbacks ) : - result.append( "/No tools available", { "active" : False } ) - - for cb in self.__toolsMenuCallbacks : - cb( result, self.parameter, self.node() ) - - return result - - def _removeClass( self, parameterName ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - - classes = [ c[1:] for c in self.parameter.getClasses( True ) if c[1] != parameterName ] - - # We have to do a pre-update here, to make sure we delete the UI for any classes we - # are going to remove, before we remove them in C++. See the notes at the top. - self.__updateChildUIs( classes ) - - with fnPH.parameterModificationContext() : - self.parameter.setClasses( classes ) - - def _setClass( self, parameterName, className, classVersion ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - - # We have to remove this class from the UI first, or, if the parameter list changes, - # maya can crash as it tries to redraw the AE. See the notes at the top. - classesWithoutThis = [ c[1:] for c in self.parameter.getClasses( True ) if c[1] != parameterName ] - self.__updateChildUIs( classesWithoutThis ) - - classes = [ c[1:] for c in self.parameter.getClasses( True ) ] - if parameterName : - foundParameter = False - for i in range( 0, len( classes ) ) : - if classes[i][0]==parameterName : - foundParameter = True - break - if not foundParameter : - raise RuntimeError( "Parameter \"%s\" not present" % parameterName ) - classes[i] = ( parameterName, className, classVersion ) - else : - # no parameter name - add a new parameter - parameterNames = set( [ c[0] for c in classes ] ) - for i in range( 0, len( classes ) + 1 ) : - parameterName = "p%d" % i - if parameterName not in parameterNames : - break - - classes.append( ( parameterName, className, classVersion ) ) - - with fnPH.parameterModificationContext() : - self.parameter.setClasses( classes ) - - # \param classes A sequence type based on the list comprehension: - # [ c[1:] for c in self.parameter.getClasses(True) ] - # - # \param startFromScratch If this is true, then all child uis are - # removed and rebuilt. - ## \todo If we could reuse child uis (because they had a replace() method) - # then we wouldn't need the startFromScratch argument. - def __updateChildUIs( self, classes=None, startFromScratch=False ) : - - if classes == None: - classes = [ c[1:] for c in self.parameter.getClasses( True ) ] - - # delete any uis for parameters which have disappeared - - parameterNamesSet = set( [ c[0] for c in classes ] ) - for parameterName in self.__childUIs.keys() : - if parameterName not in parameterNamesSet or startFromScratch : - maya.cmds.deleteUI( self.__childUIs[parameterName]._topLevelUI() ) - del self.__childUIs[parameterName] - - # and create or reorder uis for remaining parameters - - attachForm = [ - ( self.__buttonRow, "left", IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] + 1 ) ), - ( self.__buttonRow, "bottom", 5 ), - ] - attachControl = [] - attachNone = [] - prevChildUI = None - for i in range( 0, len( classes ) ) : - - parameterName = classes[i][0] - - longParameterName = self.__kw['longParameterName'] - if longParameterName : - # If we have a path already, we need a separator, otherwise, not - longParameterName += "." - longParameterName += parameterName - - visible = True - if 'visibleOnly' in self.__kw : - - visible = longParameterName in self.__kw['visibleOnly'] - - if not visible : - for i in self.__kw['visibleOnly'] : - if i.startswith( longParameterName + "." ) : - visible = True - break - - if not visible: - continue - - - childUI = self.__childUIs.get( parameterName, None ) - if childUI : - # delete it if it's not the right sort any more - if childUI.__className!=classes[i][1] or childUI.__classVersion!=classes[i][2] : - maya.cmds.deleteUI( childUI._topLevelUI() ) - childUI = None - - if not childUI : - with IECoreMaya.UITemplate( "attributeEditorTemplate" ) : - maya.cmds.setParent( self.__formLayout ) - - if "longParameterName" in self.__kw : - # We have to append our 'name' (as worked out above), otherwise, - # the parameter path misseses it out as the parameter were passing down - # has '' as a name. - kw = self.__kw.copy() - kw["longParameterName"] = longParameterName - childUI = ChildUI( self.parameter[parameterName], **kw ) - else: - childUI = ChildUI( self.parameter[parameterName], **self.__kw ) - - childUI.__className = classes[i][1] - childUI.__classVersion = classes[i][2] - self.__childUIs[parameterName] = childUI - - attachForm += [ - ( childUI._topLevelUI(), "left", 0 ), - ( childUI._topLevelUI(), "right", 0 ), - ] - - if i==0 : - attachForm.append( ( childUI._topLevelUI(), "top", 5 ) ) - else : - attachControl.append( ( childUI._topLevelUI(), "top", 0, prevChildUI._topLevelUI() ) ) - - attachNone.append( ( childUI._topLevelUI(), "bottom" ) ) - - prevChildUI = childUI - - if prevChildUI : - attachControl.append( ( self.__buttonRow, "top", 5, prevChildUI._topLevelUI() ) ) - else : - attachForm.append( ( self.__buttonRow, "top", 5 ) ) - - maya.cmds.formLayout( - self.__formLayout, - edit=True, - attachForm = attachForm, - attachControl = attachControl, - attachNone = attachNone - ) - - def __expand( self ) : - - self._storeCollapsedState( False ) - - modifiers = maya.cmds.getModifiers() - if modifiers & 1 : - # shift is held - self.__propagateCollapsed( False, 999, lazy=True ) - elif modifiers & 8 : - # ctrl is held - depth = 1; - with IECore.IgnoredExceptions( KeyError ) : - depth = self.parameter.userData()["UI"]["autoExpandDepth"].value - self.__propagateCollapsed( False, depth, lazy=True ) - - def __collapse(self): - - self._storeCollapsedState( True ) - - # \todo Store collapse state - modifiers = maya.cmds.getModifiers() - if modifiers & 1 : - # shift is held - self.__propagateCollapsed( True, 999 ) - elif modifiers & 8 : - # ctrl is held - depth = 1; - with IECore.IgnoredExceptions( KeyError ) : - depth = self.parameter.userData()["UI"]["autoExpandDepth"].value - self.__propagateCollapsed( True, depth ) - - def __propagateCollapsed( self, collapsed, propagateDepth=999, **kw ) : - - for ui in self.__childUIs.values() : - if hasattr( ui, "setCollapsed" ) : - ui.setCollapsed( collapsed, propagateDepth, **kw ) - - def __parameterIsCollapsible( self ) : - - collapsible = True - with IECore.IgnoredExceptions( KeyError ) : - collapsible = self.parameter.userData()["UI"]["collapsible"].value - with IECore.IgnoredExceptions( KeyError ) : - collapsible = self.parameter.userData()["UI"]["collapsable"].value - - return collapsible - - @staticmethod - def _classesSetCallback( fnPH, parameter ) : - - for instance in IECoreMaya.UIElement.instances( ClassVectorParameterUI ) : - if instance.parameter.isSame( parameter ) : - instance.__updateChildUIs() - - # only protected so it can be accessed by the ChildUI - _classMenuCallbacks = [] - ## Registers a callback which is able to modify the popup menu used to - # edit an individual class entry within the vector of classes. Callbacks - # should have the following signature : - # - # callback( menuDefinition, classVectorParameter, childParameter, holderNode ) - @classmethod - def registerClassMenuCallback( cls, callback ) : - - cls._classMenuCallbacks.append( callback ) - - __addClassMenuCallbacks = [] - ## Registers a callback which is able to modify the popup menu used - # to add class entries into the vector of classes. Callbacks should have - # the following signature : - # - # callback( menuDefinition, classVectorParameter, holderNode ) - @classmethod - def registerAddClassMenuCallback( cls, callback ) : - - cls.__addClassMenuCallbacks.append( callback ) - - __toolsMenuCallbacks = [] - ## Registers a callback which is able to modify the tools popup menu - # Callbacks should have the following signature : - # - # callback( menuDefinition, classVectorParameter, holderNode ) - @classmethod - def registerToolsMenuCallback( cls, callback ) : - - cls.__toolsMenuCallbacks.append( callback ) - -class ChildUI( IECoreMaya.UIElement ) : - - def __init__( self, parameter, **kw ) : - - IECoreMaya.UIElement.__init__( self, maya.cmds.columnLayout() ) - - if not isinstance( self.__vectorParent(), ClassVectorParameterUI ) : - raise RuntimeError( "Parent must be a ClassVectorParameterUI" ) - - self.__kw = kw.copy() - self.__kw["hierarchyDepth"] = self.__kw.get( "hierarchyDepth", -1 ) + 1 - - self.__parameter = parameter - - headerFormLayout = maya.cmds.formLayout() - attachForm = [] - attachControl = [] - - # triangle for expanding to view all parameters - - self.__parameterVisibilityIcon = maya.cmds.iconTextButton( - style="iconOnly", - height = 20, - width = 20, - image="arrowRight.xpm", - command = self._createCallback( self.__toggleParameterVisibility ), - annotation = "Show parameters", - visible = self.__parameterIsCollapsible(), - ) - - attachForm += [ - ( self.__parameterVisibilityIcon, "left", IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ) ), - ( self.__parameterVisibilityIcon, "top", 0 ), - ( self.__parameterVisibilityIcon, "bottom", 0 ), - ] - - lastControl = self.__buildOptionalPreHeaderUI( headerFormLayout, attachForm, attachControl, self.__parameterVisibilityIcon ) - - # layer icon - - layerIcon = maya.cmds.picture( - width = 20, - image = "%s.xpm" % self.__classIconName(), - annotation = IECore.StringUtil.wrap( - self.__class()[0].description + "\n\n" + "Click to reorder or remove.", - 48, - ) - ) - IECoreMaya.Menu( self.__layerMenu, layerIcon ) - IECoreMaya.Menu( self.__layerMenu, layerIcon, button=1 ) - - attachControl += [ - ( layerIcon, "left", 0, lastControl ), - ] - - attachForm += [ - ( layerIcon, "top", 0 ), - ( layerIcon, "bottom", 0 ), - ] - - # class specific fields - - self.__attributeChangedCallbackId = None - self.__presetParameters = [] - self.__presetUIs = [] - - self.__buildOptionalHeaderUI( headerFormLayout, attachForm, attachControl, layerIcon ) - - maya.cmds.formLayout( - headerFormLayout, - edit = True, - attachForm = attachForm, - attachControl = attachControl, - ) - - # CompoundParameterUI to hold child parameters - - maya.cmds.setParent( self._topLevelUI() ) - - self.__compoundParameterUI = IECoreMaya.CompoundParameterUI( self.__vectorParent().node(), parameter, labelVisible = False, **kw ) - - self.setCollapsed( self.getCollapsed(), False ) - - def getCollapsed( self ) : - - return self.__compoundParameterUI.getCollapsed() - - def setCollapsed( self, collapsed, propagateToChildren=False, **kw ) : - - self.__compoundParameterUI.setCollapsed( collapsed, propagateToChildren=propagateToChildren, **kw ) - - image = "arrowRight.xpm" if collapsed else "arrowDown.xpm" - annotation = "Show parameters" if collapsed else "Hide parameters" - maya.cmds.iconTextButton( - self.__parameterVisibilityIcon, - edit = True, - image = image, - annotation = annotation, - ) - - def __parameterIsCollapsible( self ) : - - collapsible = True - with IECore.IgnoredExceptions( KeyError ) : - collapsible = self.__parameter.userData()["UI"]["collapsible"].value - with IECore.IgnoredExceptions( KeyError ) : - collapsible = self.__parameter.userData()["UI"]["collapsable"].value - - return collapsible - - def _topLevelUIDeleted( self ) : - - self.__attributeChangedCallbackId = None - - def __class( self ) : - - classes = self.__vectorParent().parameter.getClasses( True ) - for c in classes : - if c[1] == self.__parameter.name : - return c - - raise RunTimeError( "Couldn't find class entry" ) - - def __classVersionAnnotation( self ) : - - c = self.__class() - - return "%s v%d" % ( c[2], c[3] ) + "\n\nClick to change version" - - def __classIconName( self ) : - - c = self.__class()[0] - - iconName = "out_displayLayer" - with IECore.IgnoredExceptions( KeyError ) : - iconName = self.__vectorParent().parameter.userData()["UI"]["defaultChildIcon"].value - - sources = [] - - if hasattr( c, "blindData" ): - sources.append( c.blindData() ) - - if hasattr( c, "parameters" ): - sources.append( c.parameters().userData() ) - - for data in sources: - with IECore.IgnoredExceptions( KeyError ) : - icon = data["UI"]["icon"].value - if icon : - return icon - - return iconName - - - def __versionMenuDefinition( self ) : - - c = self.__class() - - # make a menu with just the versions in - - loader = IECore.ClassLoader.defaultLoader( self.__vectorParent().parameter.searchPathEnvVar() ) - result = IECore.MenuDefinition() - for classVersion in loader.versions( c[2] ) : - - result.append( - - "/%d" % classVersion, - - IECore.MenuItemDefinition( - command = IECore.curry( self.__vectorParent()._setClass, self.__parameter.name, c[2], classVersion ), - active = c[3] != classVersion - ) - - ) - - return result - - def __toggleParameterVisibility( self ) : - - collapsed = not self.getCollapsed() - depth = 0 - - modifiers = maya.cmds.getModifiers() - if modifiers & 1 : - # shift is held - depth = 999 - elif modifiers & 8 : - # alt is held - depth = 1; - c = self.__class()[0] - if c and hasattr( c, "parameters" ): - with IECore.IgnoredExceptions( KeyError ) : - depth = c.parameters().userData()["UI"]["autoExpandDepth"].value - - if depth : - self.setCollapsed( collapsed, propagateToChildren=depth, lazy=True ) - else : - self.setCollapsed( collapsed, propogateToChildren=False ) - - def __layerMenu( self ) : - - result = IECore.MenuDefinition() - - layerNames = list(self.__vectorParent().parameter.keys()) - layerIndex = layerNames.index( self.__parameter.name ) - - result.append( - "/Move/To Top", - IECore.MenuItemDefinition( - command = IECore.curry( self.__moveLayer, layerIndex, 0 ), - active = layerIndex != 0 - ) - ) - - result.append( - "/Move/Up", - IECore.MenuItemDefinition( - command = IECore.curry( self.__moveLayer, layerIndex, layerIndex-1 ), - active = layerIndex >= 1 - ) - ) - - result.append( - "/Move/Down", - IECore.MenuItemDefinition( - command = IECore.curry( self.__moveLayer, layerIndex, layerIndex+1 ), - active = layerIndex < len( layerNames ) - 1 - ) - ) - - result.append( - "/Move/To Bottom", - IECore.MenuItemDefinition( - command = IECore.curry( self.__moveLayer, layerIndex, len( layerNames ) - 1 ), - active = layerIndex < len( layerNames ) - 1 - ) - ) - - result.append( - "/RemoveSeparator", - IECore.MenuItemDefinition( - divider = True, - ) - ) - - # This has to be deferred as we update the UI from within the _removeClass method. - # Unles it is, maya will crash as its still preoccupied with the popup menu. - result.append( - "/Remove", - IECore.MenuItemDefinition( - command = IECore.curry( maya.cmds.evalDeferred, IECore.curry( self.__vectorParent()._removeClass, self.__parameter.name ) ) - ) - ) - - result.append( - "/VersionSeparator", - IECore.MenuItemDefinition( - divider = True, - ) - ) - - result.append( - "/Change Version", - IECore.MenuItemDefinition( - subMenu = self.__versionMenuDefinition - ) - ) - - for cb in ClassVectorParameterUI._classMenuCallbacks : - cb( result, self.__vectorParent().parameter, self.__parameter, self.__vectorParent().node() ) - - return result - - def __moveLayer( self, oldIndex, newIndex ) : - - classes = [ c[1:] for c in self.__vectorParent().parameter.getClasses( True ) ] - cl = classes[oldIndex] - del classes[oldIndex] - classes[newIndex:newIndex] = [ cl ] - - fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() ) - with fnPH.parameterModificationContext() : - self.__vectorParent().parameter.setClasses( classes ) - - def __buildOptionalPreHeaderUI( self, formLayout, attachForm, attachControl, lastControl ) : - - return self.__drawHeaderParameterControls( formLayout, attachForm, attachControl, lastControl, "classVectorParameterPreHeader" ) - - def __buildOptionalHeaderUI( self, formLayout, attachForm, attachControl, lastControl ) : - - defaultLabel = "" - try : - parentUIUserData = self.__vectorParent().parameter.userData()["UI"] - defaultLabelStyle = parentUIUserData["defaultChildLabel"].value - - if 'classname' in defaultLabelStyle.lower() : - defaultLabel = self.__class()[2] - - if defaultLabelStyle.startswith( 'abbreviated' ) : - if "classNameFilter" in parentUIUserData : - classNameFilter = parentUIUserData["classNameFilter"].value - defaultLabel = defaultLabel.replace( classNameFilter.strip( '*' ), '' ) - - if defaultLabelStyle.endswith( 'ToUI' ) : - defaultLabel = maya.mel.eval( 'interToUI( "%s" )' % defaultLabel ) - - defaultDescription = self.__class()[0].description - except : - defaultLabel = "" - defaultDescription = "" - - labelPlugPath = self.__labelPlugPath() - if labelPlugPath or defaultLabel : - - label = maya.cmds.getAttr( labelPlugPath ) if labelPlugPath else defaultLabel - description = self.__parameter["label"].description if labelPlugPath else defaultDescription - - self.__label = maya.cmds.text( - parent = formLayout, - align = "left", - label = label, - font = IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"] ), - annotation = IECore.StringUtil.wrap( description, 48 ), - width = 190 - IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ), - recomputeSize = False, - ) - - if labelPlugPath : - - lockedLabel = False - with IECore.IgnoredExceptions( KeyError ) : - lockedLabel = self.__parameter["label"].userData()["UI"]["locked"] - - if not lockedLabel : - - renameMenu = IECore.MenuDefinition( - [ - ( "Change label...", { "command" : self.__changeLabel } ), - ] - ) - IECoreMaya.Menu( renameMenu, self.__label ) - IECoreMaya.Menu( renameMenu, self.__label, button = 1 ) - - attachForm += [ - ( self.__label, "top", 0 ), - ( self.__label, "bottom", 0 ), - ] - attachControl += [ - ( self.__label, "left", 4, lastControl ), - ] - - lastControl = self.__label - - return self.__drawHeaderParameterControls( formLayout, attachForm, attachControl, lastControl, "classVectorParameterHeader" ) - - - def __drawHeaderParameterControls( self, formLayout, attachForm, attachControl, lastControl, uiKey ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() ) - for parameter in self.__parameter.values() : - - forHeader = False - with IECore.IgnoredExceptions( KeyError ) : - forHeader = parameter.userData()["UI"][ uiKey ].value - - if forHeader : - - control = self.__drawHeaderParameterControl( parameter, fnPH ) - - if control : - - attachForm += [ - ( control, "top", 0 ), - ( control, "bottom", 0 ), - ] - attachControl += [ - ( control, "left", 0, lastControl ), - ] - - lastControl = control - - return lastControl - - - def __drawHeaderParameterControl( self, parameter, fnPH ) : - - ## \todo This would be so much easier if we could just use ParameterUI - # instances for each of the controls. We can't because they all do their - # own labelling and are layed out for an attribute editor. if we do the - # todo in ParameterUI to remove the labels and stuff then we can do the - # todo here. - - control = None - - parameterPlugPath = fnPH.parameterPlugPath( parameter ) - annotation = IECore.StringUtil.wrap( "%s\n\n%s" % ( parameterPlugPath.split( "." )[1], parameter.description ), 48 ) - if parameter.presetsOnly : - - control = maya.cmds.iconTextStaticLabel( - image = "arrowDown.xpm", - font = "smallBoldLabelFont", - style = "iconAndTextHorizontal", - height = 23, - width = 80, - annotation = annotation, - ) - IECoreMaya.Menu( IECore.curry( self.__presetsMenu, parameter ), control ) - IECoreMaya.Menu( IECore.curry( self.__presetsMenu, parameter ), control, button=1 ) - self.__presetParameters.append( parameter ) - self.__presetUIs.append( control ) - if self.__attributeChangedCallbackId is None : - self.__attributeChangedCallbackId = IECoreMaya.CallbackId( - maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.__vectorParent().node(), self.__attributeChanged ) - ) - - self.__updatePresetLabel( len( self.__presetUIs ) - 1 ) - - elif isinstance( parameter, IECore.BoolParameter ) : - - control = maya.cmds.checkBox( label="", annotation=annotation ) - maya.cmds.connectControl( control, parameterPlugPath ) - - elif isinstance( parameter, IECore.FloatParameter ) : - - control = maya.cmds.floatField( - annotation = annotation, - minValue = parameter.minValue, - maxValue = parameter.maxValue, - width = 45, - pre = 4 - ) - maya.cmds.connectControl( control, parameterPlugPath ) - - elif isinstance( parameter, IECore.IntParameter ) : - - kw = {} - if parameter.hasMinValue() : - kw["minValue"] = parameter.minValue - if parameter.hasMaxValue() : - kw["maxValue"] = parameter.maxValue - - control = maya.cmds.intField( - annotation = annotation, - width = 45, - **kw - ) - maya.cmds.connectControl( control, parameterPlugPath ) - - elif isinstance( parameter, IECore.Color3fParameter ) : - - control = maya.cmds.attrColorSliderGrp( - label = "", - columnWidth = ( ( 1, 1 ), ( 2, 30 ), ( 3, 1 ) ), - columnAttach = ( ( 1, "both", 0 ), ( 2, "both", 0 ), ( 3, "left", 0 ) ), - attribute = parameterPlugPath, - annotation = annotation, - showButton = False - ) - - elif isinstance( parameter, IECore.StringParameter ) : - - control = maya.cmds.textField( annotation = annotation, width = 150 ) - maya.cmds.connectControl( control, parameterPlugPath ) - - elif isinstance( parameter, IECore.V2fParameter ) : - - control = maya.cmds.rowLayout( nc=2, cw2=( 45, 45 ) ) - - column1 = maya.cmds.floatField( - annotation = annotation, - width = 45, - pre = 4, - parent = control - ) - - maya.cmds.connectControl( column1, parameterPlugPath + "X" ) - column2 = maya.cmds.floatField( - annotation = annotation, - width = 45, - pre = 4, - parent = control - ) - - maya.cmds.connectControl( column2, parameterPlugPath + "Y" ) - - else : - - IECore.msg( IECore.Msg.Level.Warning, "ClassVectorParameterUI", "Parameter \"%s\" has unsupported type for inclusion in header ( %s )." % ( parameter.name, parameter.typeName() ) ) - - return control - - def __labelPlugPath( self ) : - - if "label" in self.__parameter : - fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() ) - return fnPH.parameterPlugPath( self.__parameter["label"] ) - - return "" - - def __changeLabel( self ) : - - labelPlugPath = self.__labelPlugPath() - - result = maya.cmds.promptDialog( - title = "Change label", - message = "New label : ", - text = maya.cmds.getAttr( labelPlugPath ), - button = [ "Change", "Cancel" ], - defaultButton = "Change", - cancelButton = "Cancel", - ) - - if result == "Change" : - newLabel = maya.cmds.promptDialog( query=True, text=True ) - maya.cmds.setAttr( labelPlugPath, newLabel, type="string" ) - maya.cmds.text( - self.__label, - edit = True, - label = newLabel - ) - - def __presetsMenu( self, parameter ) : - - result = IECore.MenuDefinition() - for p in parameter.presetNames() : - result.append( "/" + p, { "command" : IECore.curry( self.__setPreset, parameter, p ) } ) - - return result - - def __setPreset( self, parameter, name ) : - - parameter.setValue( name ) - IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() ).setNodeValue( parameter ) - - def __attributeChanged( self, changeType, plug, otherPlug, userData ) : - - if not ( changeType & maya.OpenMaya.MNodeMessage.kAttributeSet ) : - return - - fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() ) - for index, parameter in enumerate( self.__presetParameters ) : - - try : - myPlug = fnPH.parameterPlug( parameter ) - except : - # this situation can occur when our parameter has been removed but the - # ui we represent is not quite yet dead - continue - - if plug == myPlug : - self.__updatePresetLabel( index ) - - def __updatePresetLabel( self, index ) : - - maya.cmds.iconTextStaticLabel( - self.__presetUIs[index], - edit = True, - label = self.__presetParameters[index].getCurrentPresetName() - ) - - ## Returns the ClassVectorParameterUI which this ChildUI is hosted in. - def __vectorParent( self ) : - - return self.parent().parent() - -IECoreMaya.FnParameterisedHolder.addSetClassVectorParameterClassesCallback( ClassVectorParameterUI._classesSetCallback ) - -IECoreMaya.ParameterUI.registerUI( IECore.ClassVectorParameter.staticTypeId(), ClassVectorParameterUI ) diff --git a/python/IECoreMaya/Collapsible.py b/python/IECoreMaya/Collapsible.py deleted file mode 100644 index fa40344fff..0000000000 --- a/python/IECoreMaya/Collapsible.py +++ /dev/null @@ -1,290 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya - -import IECoreMaya - -## In Maya 2011 and 2012, the collapsible frameLayout became rather ugly, -# and stopped indenting the arrow with the label. This made complex uis -# consisting of lots of ClassVectorParameters and ClassParameters somewhat -# unreadable. So we introduce this class to get back some control. Aside -# from spelling collapsible properly and being prettier, this class also -# has the advantage of supporting annotations which are displayed on the label. -# As with the maya frameLayout, the preExpandCommand, expandCommand and -# collapseCommand are only called as a result of user action, and never as -# a result of a call to setCollapsed or getCollapsed. There are separate -# implementations for maya before qt and maya after qt. - -class _CollapsibleMotif( IECoreMaya.UIElement ) : - - def __init__( self, - label="", - labelVisible=True, - labelIndent=0, - labelFont = "boldLabelFont", - annotation="", - collapsed = True, - preExpandCommand = None, - expandCommand = None, - collapseCommand = None, - ) : - - - kw = {} - if preExpandCommand is not None : - kw["preExpandCommand"] = preExpandCommand - if expandCommand is not None : - kw["expandCommand"] = expandCommand - if collapseCommand is not None : - kw["collapseCommand"] = collapseCommand - - # implementation for motif is pretty simple - just a frame layout - - IECoreMaya.UIElement.__init__( self, - maya.cmds.frameLayout( - - label = label, - labelVisible = labelVisible, - labelIndent = labelIndent, - labelAlign = "center", - font = labelFont, - borderVisible = False, - collapsable = True, - collapse = collapsed, - marginWidth = 0, - **kw - - ) - ) - - # can't display it but at least we can store it - self.__annotation = annotation - - self.__frameLayout = self._topLevelUI() - - ## The maya frameLayout whose collapsibility is controlled by this - # class. Add children by editing the contents of this layout. - def frameLayout( self ) : - - return self._topLevelUI() - - def setLabel( self, label ) : - - maya.cmds.frameLayout( self.frameLayout(), edit=True, label = label ) - - def getLabel( self ) : - - return maya.cmds.frameLayout( self.frameLayout(), query=True, label = True ) - - def setAnnotation( self, annotation ) : - - self.__annotation = annotation - - def getAnnotation( self ) : - - return self.__annotation - - def getCollapsed( self ) : - - return maya.cmds.frameLayout( self.frameLayout(), query=True, collapse=True ) - - def setCollapsed( self, collapsed ) : - - maya.cmds.frameLayout( self.frameLayout(), edit=True, collapse=collapsed ) - -class _CollapsibleQt( IECoreMaya.UIElement ) : - - def __init__( self, - label="", - labelVisible=True, - labelIndent=0, - labelFont = "boldLabelFont", - annotation="", - collapsed = True, - preExpandCommand = None, - expandCommand = None, - collapseCommand = None, - ) : - - IECoreMaya.UIElement.__init__( self, maya.cmds.formLayout() ) - - attachForm = [] - attachControl = [] - - # make the layout to put things in. this is actually a frameLayout, just - # with the ugly header bit we don't like hidden. - ######################################################################## - - self.__frameLayout = maya.cmds.frameLayout( - - labelVisible = False, - borderVisible = False, - collapsable = True, - collapse = collapsed, - marginWidth = 0, - - ) - - # passing borderVisible=False to the constructor does bugger all so we have to do it with - # an edit - maya.cmds.frameLayout( self.__frameLayout, edit=True, borderVisible=False, marginWidth=0 ) - - attachForm.append( ( self.__frameLayout, "left", 0 ) ) - attachForm.append( ( self.__frameLayout, "right", 0 ) ) - attachForm.append( ( self.__frameLayout, "bottom", 0 ) ) - - # optional header, with the triangle for expanding and collapsing - ######################################################################## - - self.__collapsibleIcon = None - self.__labelControl = None - if labelVisible : - - # have to make one button for the icon and one for the label - # because otherwise the icon size changes when we toggle - # the image, and the text moves. - self.__collapsibleIcon = maya.cmds.iconTextButton( - - parent = self._topLevelUI(), - height = 20, - width = 15, - image = "arrowRight.xpm", - command = self.__toggle, - annotation = annotation, - - ) - - self.__labelControl = maya.cmds.iconTextButton( - - parent = self._topLevelUI(), - height = 20, - label = label, - # the font flag appears to do nothing, but maybe it will - # miraculously be supported in the future? - font = labelFont, - style = "textOnly", - command = self.__toggle, - annotation = annotation, - - ) - - attachForm.append( ( self.__collapsibleIcon, "left", labelIndent ) ) - attachForm.append( ( self.__collapsibleIcon, "top", 0 ) ) - attachForm.append( ( self.__labelControl, "top", 0 ) ) - - attachControl.append( ( self.__labelControl, "left", 0, self.__collapsibleIcon ) ) - attachControl.append( ( self.__frameLayout, "top", 0, self.__labelControl ) ) - - else : - - attachForm.append( ( self.__frameLayout, "top", 0 ) ) - - maya.cmds.formLayout( - self._topLevelUI(), - edit = True, - attachForm = attachForm, - attachControl = attachControl, - ) - - maya.cmds.setParent( self.__frameLayout ) - - self.__annotation = annotation - self.__labelText = label - self.__preExpandCommand = preExpandCommand - self.__expandCommand = expandCommand - self.__collapseCommand = collapseCommand - - ## The maya frameLayout whose collapsibility is controlled by this - # class. Add children by editing the contents of this layout. - def frameLayout( self ) : - - return self.__frameLayout - - def setLabel( self, label ) : - - self.__labelText = label - if self.__labelControl is not None : - maya.cmds.iconTextButton( self.__labelControl, edit=True, label=label ) - - def getLabel( self ) : - - return self.__labelText - - def setAnnotation( self, annotation ) : - - self.__annotation = annotation - if self.__labelControl is not None : - maya.cmds.iconTextButton( self.__labelControl, edit=True, annotation=annotation ) - maya.cmds.iconTextButton( self.__collapsibleIcon, edit=True, annotation=annotation ) - - def getAnnotation( self ) : - - return self.__annotation - - def getCollapsed( self ) : - - return maya.cmds.frameLayout( self.__frameLayout, query=True, collapse=True ) - - def setCollapsed( self, collapsed ) : - - maya.cmds.frameLayout( self.__frameLayout, edit=True, collapse=collapsed ) - if self.__collapsibleIcon is not None : - maya.cmds.iconTextButton( - self.__collapsibleIcon, - edit = True, - image = "arrowRight.xpm" if collapsed else "arrowDown.xpm", - ) - - def __toggle( self ) : - - collapsed = not self.getCollapsed() - if not collapsed and self.__preExpandCommand is not None : - self.__preExpandCommand() - - self.setCollapsed( not self.getCollapsed() ) - - if collapsed : - if self.__collapseCommand is not None : - self.__collapseCommand() - else : - if self.__expandCommand is not None : - self.__expandCommand() - -# choose the right implementation based on the current maya version -if maya.OpenMaya.MGlobal.apiVersion() >= 201100 : - Collapsible = _CollapsibleQt -else : - Collapsible = _CollapsibleMotif diff --git a/python/IECoreMaya/ColorParameterUI.py b/python/IECoreMaya/ColorParameterUI.py deleted file mode 100644 index 0b69f87d99..0000000000 --- a/python/IECoreMaya/ColorParameterUI.py +++ /dev/null @@ -1,71 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class ColorParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.attrColorSliderGrp(), - **kw - - ) - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - maya.cmds.attrColorSliderGrp( - self._topLevelUI(), - edit = True, - attribute = self.plugName(), - annotation = self.description(), - label = self.label(), - showButton = False, - ) - - self._addPopupMenu( parentUI = self._topLevelUI(), attributeName = self.plugName() ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Color3fParameter, ColorParameterUI ) diff --git a/python/IECoreMaya/CompoundParameterUI.py b/python/IECoreMaya/CompoundParameterUI.py deleted file mode 100644 index 8f2d083d69..0000000000 --- a/python/IECoreMaya/CompoundParameterUI.py +++ /dev/null @@ -1,374 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import traceback - -import maya.cmds - -import IECore -import IECoreMaya - -class CompoundParameterUI( IECoreMaya.ParameterUI ) : - - _collapsedUserDataKey = "aeCollapsed" - - ## Supports the following keyword arguments : - # - # bool "withCompoundFrame" - # May be specified as True to force the creation of a - # frameLayout even when this parameter is the toplevel parameter - # for the node. - # - # list "visibleOnly" - # A list of strings specifying the full parameter paths for - # parameters which should be displayed. Any parameters not in - # this list will not be visible. - # - # bool "labelVisible" - # If not None, specifies whether or not the parameter label is visible. This - # is used by the ClassVectorParameterUI ChildUI class. - def __init__( self, node, parameter, labelVisible=None, **kw ) : - - self.__childUIs = {} - self.__headerCreated = False - self.__kw = kw.copy() - - self.__kw["hierarchyDepth"] = self.__kw.get( "hierarchyDepth", -1 ) + 1 - - originalParent = maya.cmds.setParent( query=True ) - - collapsible = self.__parameterIsCollapsible( node, parameter ) - collapsed = self._retrieveCollapsedState( collapsible, parameter ) - - # we always use a Collapsible ui to hold our children, and just hide - # the header if we don't actually want to collapse it ever. - - self.__collapsible = IECoreMaya.Collapsible( - - # need to specify a label on creation or maya gets the size wrong. - # we'll update the label below, once we can call the base class label() method. - label = "mustSpecifySomething", - labelFont = self._labelFont( self.__kw["hierarchyDepth"] ), - labelIndent = self._labelIndent( self.__kw["hierarchyDepth"] ), - labelVisible = labelVisible if labelVisible is not None else collapsible, - collapsed = collapsed, - expandCommand = self.__expand, - preExpandCommand = self.__preExpand, - collapseCommand = self.__collapse, - - ) - - IECoreMaya.ParameterUI.__init__( self, - - node, - parameter, - # stealing someone else's top level ui for use as your own is really breaking the rules. - # but we need to do it to reduce the nesting associated with making a new top level to put - # the Collapsible class in, because otherwise maya 2010 will crash with deeply nested - # hierarchies. we could stop doing this when we no longer need maya 2010 support. - self.__collapsible._topLevelUI(), - **kw - - ) - - self.__collapsible.setLabel( self.label() ) - self.__collapsible.setAnnotation( self.description() ) - - self.__columnLayout = maya.cmds.columnLayout( - parent = self.__collapsible.frameLayout(), - width = 381 - ) - - if not collapsed : - self.__preExpand() - - maya.cmds.setParent( originalParent ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - if self.__parameterIsCollapsible() : - collapsed = self._retrieveCollapsedState( self.getCollapsed() ) - self.setCollapsed( collapsed, **self.__kw ) - - if len( self.__childUIs ) : - - for pName in self.__childUIs.keys() : - - ui = self.__childUIs[pName] - p = self.parameter[pName] - - ui.replace( node, p ) - - else : - - if not self.getCollapsed() : - with IECoreMaya.UITemplate( "attributeEditorTemplate" ) : - self.__createChildUIs() - - ## Gets the collapsed state for the frame holding the child parameter uis. - def getCollapsed( self ) : - - return self.__collapsible.getCollapsed() - - ## Sets the collapsed state for the frame holding the child parameter uis. - # \param propagateToChildren How many levels of hierarchy to propagate - # the new state to. If a Bool is passed, rather than an int, then - # 'all' or 'none' is assumed, for backwards compatibility. - def setCollapsed( self, collapsed, propagateToChildren=0, **kw ) : - - if type(propagateToChildren) == bool : - propagateToChildren = 999 if propagateToChildren else 0 - - if not collapsed : - # maya only calls preexpand when the ui is expanded by user action, - # not by a script - how annoying. - self.__preExpand() - - if self.__parameterIsCollapsible() : - self.__collapsible.setCollapsed( collapsed ) - - self._storeCollapsedState( collapsed ) - - if propagateToChildren > 0 : - propagateToChildren = propagateToChildren - 1 - self.__propagateCollapsed( collapsed, propagateToChildren, **kw ) - - # This will retrieve the collapsedState from the parameters userData. It uses the - # default key if 'collapsedUserDataKey' was not provided in the UI constructor's **kw. - def _retrieveCollapsedState( self, default=True, parameter=None ) : - - if parameter is None : - parameter = self.parameter - - key = self.__kw.get( "collapsedUserDataKey", CompoundParameterUI._collapsedUserDataKey ) - if "UI" in parameter.userData() and key in parameter.userData()["UI"] : - return parameter.userData()["UI"][ key ].value - else : - return default - - # This will store \param state in the parameters userData, under the default key, - # unless 'collapsedUserDataKey' was provided in the UI constructor's **kw. - def _storeCollapsedState( self, state ) : - - if "UI" not in self.parameter.userData() : - self.parameter.userData()["UI"] = IECore.CompoundObject() - - key = self.__kw.get( "collapsedUserDataKey", CompoundParameterUI._collapsedUserDataKey ) - self.parameter.userData()["UI"][key] = IECore.BoolData( state ) - - # Returns True if the ui should be collapsible for this parameter, False - # otherwise. - def __parameterIsCollapsible( self, node=None, parameter=None ) : - - if node is None : - node = self.node() - if parameter is None : - parameter = self.parameter - - fnPH = IECoreMaya.FnParameterisedHolder( node ) - - collapsible = not parameter.isSame( fnPH.getParameterised()[0].parameters() ) - with IECore.IgnoredExceptions( KeyError ) : - collapsible = parameter.userData()["UI"]["collapsible"].value - with IECore.IgnoredExceptions( KeyError ) : - collapsible = parameter.userData()["UI"]["collapsable"].value - - collapsible = self.__kw.get( "withCompoundFrame", False ) or collapsible - - return collapsible - - @staticmethod - def _labelFont( hierarchyDepth ) : - - if hierarchyDepth == 2 : - return "smallBoldLabelFont" - elif hierarchyDepth >= 3 : - return "tinyBoldLabelFont" - else : - return "boldLabelFont" - - @staticmethod - def _labelIndent( hierarchyDepth ) : - - return 5 + ( 8 * max( 0, hierarchyDepth-1 ) ) - - ## May be implemented by derived classes to present some custom ui at the - # top of the list of child parameters. Implementations should first call the - # base class method and then perform their custom behaviour, placing ui elements - # into the provided columnLayout. - def _createHeader( self, columnLayout, **kw ) : - - draggable = False - try: - draggable = self.parameter.userData()['UI']['draggable'].value - except : - pass - - ## \todo Figure out what this draggable stuff is all about and document it. - # I think it's intended to allow parameters to be dragged and dropped onto - # an IECoreMaya.ParameterPanel but I can't get that to work right now. - if draggable : - - maya.cmds.rowLayout( - numberOfColumns = 2, - columnWidth2 = ( 361, 20 ), - parent = columnLayout - - ) - - maya.cmds.text( label = "" ) - - dragIcon = maya.cmds.iconTextStaticLabel( - image = "pick.xpm", - height = 20 - ) - self.addDragCallback( dragIcon, **kw ) - - self.__headerCreated = True - - ## May be called by derived classes if for any reason the child parameter - # uis are deemed invalid - for instance if the child parameters have changed. - # The uis will then be rebuilt during the next call to replace(). - def _deleteChildParameterUIs( self ) : - - maya.cmds.control( self.__columnLayout, edit=True, manage=False ) - - for ui in self.__childUIs.values() : - maya.cmds.deleteUI( ui.layout() ) - - self.__childUIs = {} - - maya.cmds.control( self.__columnLayout, edit=True, manage=True ) - - def __expand( self ) : - - self._storeCollapsedState( False ) - - modifiers = maya.cmds.getModifiers() - - if modifiers & 1 : - # shift is held - self.__propagateCollapsed( False, 999, lazy=True ) - elif modifiers & 8 : - # alt is held - depth = 1; - with IECore.IgnoredExceptions( KeyError ) : - depth = self.parameter.userData()["UI"]["autoExpandDepth"].value - self.__propagateCollapsed( False, depth, lazy=True ) - - def __collapse(self): - - self._storeCollapsedState( True ) - - # \todo Store collapse state - modifiers = maya.cmds.getModifiers() - - if modifiers & 1 : - # shift is held - self.__propagateCollapsed( True, 999 ) - elif modifiers & 8 : - # alt is held - depth = 1; - with IECore.IgnoredExceptions( KeyError ) : - depth = self.parameter.userData()["UI"]["autoExpandDepth"].value - self.__propagateCollapsed( True, depth ) - - def __preExpand( self ) : - - # this is the most common entry point into the ui - # creation code, and unfortunately it's called from - # a maya ui callback. maya appears to suppress all - # exceptions which occur in such callbacks, so we - # have to wrap with our own exception handling to - # make sure any errors become visible. - try : - with IECoreMaya.UITemplate( "attributeEditorTemplate" ) : - if not self.__headerCreated : - self._createHeader( self.__columnLayout, **self.__kw ) - if not len( self.__childUIs ) : - self.__createChildUIs() - except : - - IECore.msg( IECore.Msg.Level.Error, "IECoreMaya.ParameterUI", traceback.format_exc() ) - - def __propagateCollapsed( self, collapsed, propagateDepth=999, **kw ) : - - for ui in self.__childUIs.values() : - if hasattr( ui, "setCollapsed" ) : - ui.setCollapsed( collapsed, propagateDepth, **kw ) - - def __createChildUIs( self ) : - - self.__kw['labelWithNodeName'] = False - - for pName in self.parameter.keys(): - - p = self.parameter[pName] - - visible = True - try: - visible = p.userData()['UI']['visible'].value - except: - pass - - if 'visibleOnly' in self.__kw : - - fullChildName = self.__kw['longParameterName'] - if fullChildName : - fullChildName += "." - fullChildName += pName - - visible = fullChildName in self.__kw['visibleOnly'] - - if not visible and p.isInstanceOf( IECore.TypeId.CompoundParameter ) : - - for i in self.__kw['visibleOnly'] : - if i.startswith( fullChildName + "." ) : - visible = True - break - - if visible: - - maya.cmds.setParent( self.__columnLayout ) - - ui = IECoreMaya.ParameterUI.create( self.node(), p, **self.__kw ) - - if ui: - self.__childUIs[pName] = ui - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.CompoundParameter, CompoundParameterUI ) diff --git a/python/IECoreMaya/DAGPathParameter.py b/python/IECoreMaya/DAGPathParameter.py deleted file mode 100644 index 09bcdbcd3d..0000000000 --- a/python/IECoreMaya/DAGPathParameter.py +++ /dev/null @@ -1,170 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -from maya.OpenMaya import * -import re - -""" -Parameter class for specifying Maya DAG paths. -""" -## \todo Dervive from IECoreMaya.NodeParameter -class DAGPathParameter( IECore.StringParameter ): - - ## \todo Use Enum for this - class CheckType: - - DontCare = 0 - MustExist = 1 - MustNotExist = 2 - - """ - name - name of the parameter. - description - description of the parameter. - allowEmptyString - boolean that will accept the empty value even if the node should exist. - check - can be CheckType.DontCare, CheckType.MustExist or CheckType.MustNotExist. - typeRegex - regular expression used on parameter validation that validates based on the maya node type. Disable filtering using None. - typeRegexDescription - human readable description for the regular expression used to filter node types. It's used when the validation fails. - """ - def __init__( self, name, description, defaultValue = "", allowEmptyString = True, - check = CheckType.DontCare, typeRegex = None, typeRegexDescription = "", presets = (), presetsOnly = False, userData = IECore.CompoundObject() ) : - - IECore.StringParameter.__init__( self, name, description, defaultValue, presets, presetsOnly, userData ) - - self.__allowEmptyString = allowEmptyString - self.__mustExist = bool( check == DAGPathParameter.CheckType.MustExist ) - self.__mustNotExist = bool( check == DAGPathParameter.CheckType.MustNotExist ) - if typeRegex is None: - self.typeRegex = None - else: - self.typeRegex = re.compile( typeRegex ) - if typeRegexDescription == "": - self.typeRegexDesc = "Invalid type." - else: - self.typeRegexDesc = typeRegexDescription - - """ - Defines two attributes: mustExist and mustNotExist and allowEmptyString exactly like PathParameter class. - """ - def __getattr__( self, attrName ): - if attrName == "mustExist": - return self.__mustExist - elif attrName == "mustNotExist": - return self.__mustNotExist - elif attrName == "allowEmptyString": - return self.__allowEmptyString - else: - return self.__dict__[ attrName ] - - """ - Returns a regular expression that matches only valid Maya DAG paths. - """ - @staticmethod - def pathValidator(): - return re.compile( r"^(\|?[^\t\n\r\f\v|]+)+\|?$" ) - - """ - Returns (True, "") only if the value is a correct DAG path string and also checks that the DAG node exists or doesn't exist - based on the CheckType passed to the constructor. - Otherwise returns (False, errorMessage). - """ - def valueValid( self, value ) : - - v = IECore.StringParameter.valueValid( self, value ) - if not v[0] : - return v - - if self.allowEmptyString and value.value=="" : - return True, "" - - if not self.pathValidator().match( value.value ) : - return False, "Not a valid Maya DAG path." - - list = MSelectionList () - try: - list.add( value.value ) - except: - exist = False - else: - exist = True - - try: - dp = MDagPath() - list.getDagPath(0, dp) - depNode = MFnDagNode( dp ) - except: - IECore.debugException("failed to instantiate MDagPath from", value.value ) - return False, "'%s' is not a DAG node" % value.value - - if not self.typeRegex is None: - nodeType = str(depNode.typeName()) - if self.typeRegex.match( nodeType ) is None: - return False, ("Type '%s' not accepted: " % nodeType) + self.typeRegexDesc - - if self.mustExist : - - if not exist: - return False, "DAG node %s does not exist" % value.value - - elif self.mustNotExist : - - if exist: - return False, "DAG node %s already exists" % value.value - - return True, "" - - """ - Sets the internal StringData value from the given MDagPath object - """ - def setDAGPathValue( self, dagNode ) : - self.setValue( IECore.StringData( dagNode.fullPathName() ) ) - - """ - Returns a MDagPath for the current node. - Note that this can return None if check is DontCare and no matching node exists in Maya. - """ - def getDAGPathValue( self ) : - dagNodePath = self.getValue().value - try: - list = MSelectionList() - list.add( dagNodePath ) - dp = MDagPath() - list.getDagPath(0, dp) - return dp - except: - if self.mustExist : - raise Exception("Node '%s' does not exist!" % dagNodePath) - return None - -IECore.registerRunTimeTyped( DAGPathParameter ) diff --git a/python/IECoreMaya/DAGPathVectorParameter.py b/python/IECoreMaya/DAGPathVectorParameter.py deleted file mode 100644 index 984f4dc19d..0000000000 --- a/python/IECoreMaya/DAGPathVectorParameter.py +++ /dev/null @@ -1,179 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -from maya.OpenMaya import * -import re - -from .DAGPathParameter import DAGPathParameter - -""" -Parameter class for specifying a list of Maya DAG paths. -""" -class DAGPathVectorParameter( IECore.StringVectorParameter ): - - class CheckType: - - DontCare = 0 - MustExist = 1 - MustNotExist = 2 - - """ - name - name of the parameter. - description - description of the parameter. - allowEmptyList - boolean that will accept the empty list even if the nodes should exist. - check - can be CheckType.DontCare, CheckType.MustExist or CheckType.MustNotExist. - typeRegex - regular expression used on parameter validation that validates based on the maya node type. Disable filtering using None. - typeRegexDescription - human readable description for the regular expression used to filter node types. It's used when the validation fails. - """ - def __init__( self, name, description, defaultValue = IECore.StringVectorData(), allowEmptyList = True, - check = CheckType.DontCare, typeRegex = None, typeRegexDescription = "", - presets = (), presetsOnly = False, userData = IECore.CompoundObject() ) : - - IECore.StringVectorParameter.__init__( self, name, description, defaultValue, presets, presetsOnly, userData ) - - self.__allowEmptyList = allowEmptyList - self.__mustExist = bool( check == DAGPathVectorParameter.CheckType.MustExist ) - self.__mustNotExist = bool( check == DAGPathVectorParameter.CheckType.MustNotExist ) - if typeRegex is None: - self.typeRegex = None - else: - self.typeRegex = re.compile( typeRegex ) - if typeRegexDescription == "": - self.typeRegexDesc = "Invalid type." - else: - self.typeRegexDesc = typeRegexDescription - - """ - Defines two attributes: mustExist and mustNotExist and allowEmptyString exactly like PathParameter class. - """ - def __getattr__( self, attrName ): - if attrName == "mustExist": - return self.__mustExist - elif attrName == "mustNotExist": - return self.__mustNotExist - elif attrName == "allowEmptyList": - return self.__allowEmptyList - else: - return self.__dict__[ attrName ] - - """ - Returns a regular expression that matches only valid Maya DAG paths. - """ - @staticmethod - def pathValidator(): - return DAGPathParameter.pathValidator() - - """ - Returns (True, "") only if the value is a correct DAG path string and also checks that the DAG node exists or doesn't exist - based on the CheckType passed to the constructor. - Otherwise returns (False, errorMessage). - """ - def valueValid( self, value ) : - - v = IECore.StringVectorParameter.valueValid( self, value ) - if not v[0] : - return v - - if len( value ) == 0 and not self.allowEmptyList: - return False, "Empty list!" - - for item in value: - - if not self.pathValidator().match( item ) : - return False, "%s is not a valid Maya DAG path." % item - - list = MSelectionList () - try: - list.add( item ) - except: - exist = False - else: - exist = True - - try: - dp = MDagPath() - list.getDagPath(0, dp) - depNode = MFnDagNode( dp ) - except: - IECore.debugException("failed to instantiate MDagPath from", item ) - return False, "'%s' is not a DAG node" % item - - if not self.typeRegex is None: - nodeType = str(depNode.typeName()) - if self.typeRegex.match( nodeType ) is None: - return False, ("Type '%s' not accepted: " % nodeType) + self.typeRegexDesc - - if self.mustExist : - - if not exist: - return False, "DAG node %s does not exist" % item - - elif self.mustNotExist : - - if exist: - return False, "DAG node %s already exists" % item - - return True, "" - - """ - Sets the internal VectorStringData value from the given MDagPath list - """ - def setDAGPathVectorValue( self, dagNodeList ) : - l = [] - for dagNode in dagNodeList: - l.append( dagNode.fullPathName() ) - self.setValue( IECore.StringVectorData( l ) ) - - """ - Returns a list of MDagPath objects from the current selection. - """ - def getDAGPathVectorValue( self ) : - dagNodePathList = self.getValue().value - result = [] - for dagNodePath in dagNodePathList: - - try: - list = MSelectionList() - list.add( dagNodePath ) - dp = MDagPath() - list.getDagPath(0, dp) - result.append( dp ) - except: - if self.mustExist : - raise Exception("Node '%s' does not exist!" % dagNodePath) - - return result - -IECore.registerRunTimeTyped( DAGPathVectorParameter ) diff --git a/python/IECoreMaya/DirNameParameterUI.py b/python/IECoreMaya/DirNameParameterUI.py deleted file mode 100644 index 067e81d980..0000000000 --- a/python/IECoreMaya/DirNameParameterUI.py +++ /dev/null @@ -1,52 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os.path - -import IECore -import IECoreMaya - -class DirNameParameterUI( IECoreMaya.PathParameterUI ) : - - def __init__( self, node, parameter, **kw ): - - IECoreMaya.PathParameterUI.__init__( self, node, parameter, **kw ) - - def _fileDialog( self ) : - - IECoreMaya.PathParameterUI._fileDialog( self, - filter = IECoreMaya.FileBrowser.DirectoriesOnlyFilter().filter, - ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.DirNameParameter, DirNameParameterUI ) diff --git a/python/IECoreMaya/FileBrowser.py b/python/IECoreMaya/FileBrowser.py deleted file mode 100644 index d0051322ce..0000000000 --- a/python/IECoreMaya/FileBrowser.py +++ /dev/null @@ -1,889 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECoreMaya -import maya.cmds - -import os -import re, fnmatch - -__all__ = [ "FileBrowser" ] - -## The Browser class provides a file picker interface within a Maya formLayout. -## User actions cause several signals to be emitted, see the signals section. -## Behvaiour of the dialog can be modified by a variety of creation arguments: -## -## \param uiParent The name of a maya UI element to parent the browser layout -## -## \param options A callable or class with the signature ( instance, string uiParent ) -## that can be used to draw additional controls in the area below the list, above the -## path box. uiParent is an empty columnLayout. -## If the object passed has a method 'update' it will be connected to the pathChangedSignal -## of the brower instance. -## If the object passed has a method 'selectionChanged' it will be connected to the -## selectionChangedSignal of the browser instance. -## -## \param filter A callable with the signature ( string path, ( {}, ... ) items ), which -## is allowed to modify the items list however it sees fit. See the section below on the -## structure of the items list. The result of the filter will be used as the item list for -## display. -## -## \param validate A callable with the signature ( string path, ( {}, ... ) items ), which -## must return True of False as to wether the items in the supplied list are considered a -## valid 'selection'. -## -## \param showHidden (bool) Wether or not hidden files should be shown in the browser. -## -## \param buttonTitle (string) The label for the main button -## -## \param withCancel (bool) Wether or not a cancel button should be drawn -## -## \param cancelButtonTitle (string) The label for the cancel button. -## -## \param rightHanded (bool) The main button defaults to the left, to match Maya's -## look. If you prefer the other side, to match other environments, this can be set -## to True. -## -## \param allowMultiSelection (bool) Can the user select more than one item at once. -## -## \param saveMode (bool) When enabled, the user is allowed to choose paths to files -## that don't exist yet. Otherwise, the selection is always conformed to an item in the -## list, or the current directory itself if nothing is selected. -## -## The item list syntax: -## -## ( { -## "name" : (string) the name of the item as it will be displayed in the list, -## "path" : (string) the full path to the item, that will be returned when querying the users selection -## "mode" : as per os.stat() -## "uid" : as per os.stat() -## "gid" : as per os.stat() -## "size" : (bytes) as per os.stat() -## "atime" : (seconds) as per os.stat() -## "mtime" : (seconds) as per os.stat() -## "ctime" : (seconds) as per os.stat() -## }, ... ) -## -## NOTE: Neither 'path', nor 'name' must be valid filesystem entries. They can be modified to substitute -## variables or similar into the paths or item names. Validation and filtering functions are called -## with the 'real' working path of the browser, as well as the item list. It is up to these functions -## to valiate the 'correctness' of the result of the users selection. -## If a filter is modifying the items list, it is it's responsibility to ensure that the the relevant metadata -## is created for any 'synthesized' items. For example, when collapsing a file sequence into a single item, -## appropriate dates should be generated to permit 'by date' sorting. - -class FileBrowser( IECoreMaya.UIElement ) : - - - def __init__( - self, uiParent=None, - options=None, filter=None, validate=None, showHidden=False, - buttonTitle="Select", withCancel=True, cancelButtonTitle="Cancel", - allowMultiSelection=False, saveMode=False, rightHanded=False, - ): - - self.__path = None - - # For consistency, we're not exposing these are attributes - self.__filter = filter - self.__validate = validate - self.__showHidden = showHidden - self.__saveMode = saveMode - - self.__s_select = _Signal() - self.__s_cancel = _Signal() - self.__s_pathChanged = _Signal() - - if not uiParent: - uiParent = maya.cmds.setParent( q=True ) - - self.__layout = maya.cmds.formLayout( parent=uiParent ) - - IECoreMaya.UIElement.__init__( self, self.__layout ) - - self.__itemList = _FileList( self.__layout, allowMultiSelection=allowMultiSelection ) - self.__pathField = _PathField( self.__layout, height=25 ) - - listUI = self.__itemList._topLevelUI() - pathUI = self.__pathField._topLevelUI() - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( listUI, "left", 0 ), ( listUI, "top", 0 ), ( listUI, "right", 0 ), - ( pathUI, "left", 0 ), ( pathUI, "right", 0 ), - ), - attachControl = ( - ( listUI, "bottom", 2, pathUI ), - ) - ) - - self.__selectButton = maya.cmds.button( - label = buttonTitle, - command=self.__emitSelect, - parent = self.__layout, - width=200, height=30, - ) - - edge = "right" if rightHanded else "left" - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( self.__selectButton, edge, 4 ), ( self.__selectButton, "bottom", 4 ) - ), - attachControl = ( - ( pathUI, "bottom", 0, self.__selectButton ), - ) - ) - - if withCancel: - - edge = "left" if rightHanded else "right" - - self.__cancelButton = maya.cmds.button( - label = cancelButtonTitle, - command=self.__emitCancel, - width=200, height=30, - parent = self.__layout, - ) - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( self.__cancelButton, edge, 4 ), ( self.__cancelButton, "bottom", 4 ) - ), - ) - - else: - - self.__cancelButton = None - - if options : - - optionsColumn = maya.cmds.columnLayout( adj=True, parent=self.__layout ) - self.__optionsProcInstance = options( self, optionsColumn ) - - maya.cmds.separator( style="none", width=5, height=10 ) - - if hasattr( self.__optionsProcInstance, "update" ): - self.pathChangedSignal.connect( self.__optionsProcInstance.update ) - - if hasattr( self.__optionsProcInstance, "selectionChanged" ): - self.__itemList.selectionChangedSignal.connect( self.__optionsProcInstance.selectionChanged ) - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( optionsColumn, "left", 15 ), ( optionsColumn, "right", 15 ), - ), - attachControl = ( - ( optionsColumn, "bottom", 2, self.__selectButton ), - ( pathUI, "bottom", 6, optionsColumn ), - ) - ) - - # Listen for changes the user makes to the path field. True allows immediate entry - # in applicable modes. For 'type a name and hit enter to save'. - self.__pathField.valueChangedSignal.connect( lambda p: self.setPath( p, True ) ) - # When the main working path changes, we need to update the items in that path - self.pathChangedSignal.connect( self.__getItemsForPath ) - # When the selection in the list changes, we need to update the path/validate - self.__itemList.selectionChangedSignal.connect( self.__selectionChanged ) - # Handle the double-click situation - self.__itemList.itemChosenSignal.connect( self.__itemChosen ) - - ## Sets the working path for the file browser. - ## \param path If this is the path to a file, then the dialog will display - ## the parent directory and select the file. The pathChangedSignal is then emitted - ## with the path to the directory. If None is passed, the listing of the current path - ## will be refreshed. - ## \param allowImmediateSelection. When enabled, this allows a valid file name to be - ## set as the path, and immediately validated and used. It's off by default to allow - ## the dialogue opener to use the setPath method to set default name without thinking - ## about it too much. - def setPath( self, path=None, allowImmediateSelection=False ) : - - if not path: - path = self.__path - - path = os.path.expandvars( path ) - - item = "" - if not os.path.isdir( path ): - item = os.path.basename( path ) - path = os.path.dirname( path ) - - if not os.access( path, os.R_OK ) or not os.path.isdir( path ) : - if not self.__path: - path = os.getcwd() - else: - maya.cmds.evalDeferred( "import maya.cmds; maya.cmds.confirmDialog( b='OK', title='Error navigating...', message='Unable to read directory:\\n%s' )" % path ) - return - - self.__path = os.path.normpath(path) - self.__emitPathChanged() - - if item: - - self.__itemList.setSelection( item ) - - # If we in file creation mode (save), then we allow the user to enter - # a full path to a file, if this validates, we then potentially immediately - # choose that file. This is, essentially, to allow you to 'type a name and hit enter'. - if self.__saveMode: - - userItem = { - "name" : item, - "path" : "%s/%s" % ( self.__path, item ) - } - - itemList = (userItem,) - self.__selectionChanged( itemList ) - - if allowImmediateSelection: - if self._validate( itemList ) : - self.__itemChosen( userItem ) - - ## This function should be used to query the users selection in clases using an - ## instance of the FileDialog. - ## \return This returns a list of the items selected in the file browser. - ## Each item is specified by its full path. If items names have been modified by - ## filtering, the full path is returned with the filtered name instead of the - ## file name. If validation is setup, and fails, () is returned. - def getCurrentSelection( self ) : - - items = self.__getSelectedItems() - - if not self._validate( items ): - return () - - return [ i["path"] for i in items ] - - # See whats on disk... - def __getItemsForPath( self, path, *args ) : - - try: - fullDirContents = os.listdir( self.__path ) - except Exception as e : - print(e) - maya.cmds.evalDeferred( 'import maya.cmds; maya.cmds.confirmDialog( b="OK", title="Error retrieving file list...", message="%s" )' % e ) - return - - # We'll do basic hidden item filtering here - # to make life simpler in most common cases - items = [] - for f in fullDirContents: - - if f[0] == "." and not self.__showHidden: - continue - - items.append( self.__getItemInfo( self.__path, f ) ) - - # If a filter is registered, it can mess with the list - # and corresponding fileInfo as much as it likes. but it must - # also update fileInfo accordinly with some meaningfull data. - if self.__filter: - self.__filter( path, items ) - - self.__itemList.setItems( items ) - - # Populate the info entry for a specific file. This is called pre-filtering - # so item should always correspond to an actual file system entry. - # The 'path' field is what is actually returned by getCurrentSelection() - def __getItemInfo( self, path, item ) : - - info = {} - info["name"] = item - info["path"] = os.path.normpath( "%s/%s" % ( path, item ) ) - - stat = os.stat( info["path"] ) - info["mode"] = stat[0] - info["uid"] = stat[4] - info["gid"] = stat[5] - info["size"] = stat[6] - info["atime"] = stat[7] - info["mtime"] = stat[8] - info["ctime"] = stat[9] - - return info - - # This function returns an unvalidated list of items considered 'selected', along with - # their info. This is either the actual selection in the item list, or the current contents - # of the path field, if this has been modified by the user since the list was read. - def __getSelectedItems( self ) : - - selection = self.__itemList.getSelection() - - requestedPath = self.__pathField.value - requestedFile = os.path.basename( requestedPath ) - - items = [] - - # This allows 'save' behavoiur, where they might type a - # file name onto the current path. We may want to make it - # so that this behaviour is enabled only when saveMode is True - if ( requestedPath != self.__path and requestedFile not in selection - and requestedFile != "" ): - - # The user had modified the path by hand - userItem = { - "name" : requestedFile, - "path" : "%s/%s" % ( self.__path, requestedFile ), - } - items.append( userItem ) - - elif not selection: - - # The current path can be considered a selection in the case of - # directory picking. - cwdItem = { - "name" : os.path.basename( self.__path ), - "path" : self.__path, - } - items.append( cwdItem ) - - else : - - items.extend( selection ) - - return items - - def __selectionChanged( self, items ) : - - # Update the path field to reflect the changes in the selection - if not items: - val = self.__path - elif len(items) == 1 : - val = ( "%s/%s" % ( self.__path, items[0]["name"] ) ).replace( "//", "/" ) - else : - val = ( "%s/" % self.__path ).replace( "//", "/" ) - - self.__pathField.setValue( val, False ) - - itemsOk = self._validate( items ) - # If were in saveMode, we don't want to disable the button, otherwise - # they probably won't be able to press 'save' when validation is active. - if not self.__saveMode: - maya.cmds.button( self.__selectButton, edit=True, enable=itemsOk ) - - # Called to enforce selection of a particulat item - def __itemChosen( self, item ) : - - path = "%s/%s" % ( self.__path, item["name"] ) - - # If its a directory, we don't want to navigate, rather than - # 'choose' the item. - if os.path.isdir( path ) : - - path = os.path.normpath(path).replace( "//", "/" ) - self.setPath( path ) - - else: - - self.__emitSelect( items=(item,) ) - - def _validate( self, items ): - - if not self.__path: - return False - - if self.__validate: - return self.__validate( self.__path, items ) - - return True - - ##! \name Signals - ## These signals will be emitted in response to user actions. Classes using the FileDialog - ## should connect to these signals in order to act upon the user's selection. - ##! { - - @property - ## This will be called when the user has selected one or more items. By either: - ## - Making a selection in the file list, and clicking the main button. - ## - Double clicking on a file (directories cause navigation). - ## Connected callables will receive the following args: - ## - browserInstance - ## If validation has been setup, and the current selection fails validation, - ## the signal will not be emitted. - def selectSignal( self ): - return self.__s_select - - @property - ## This will be emitted if the user clicks the Cancel button. Connected callables - ## will receive the following args: - ## - browserInstance - def cancelSignal( self ): - return self.__s_cancel - - @property - ## This will be emitted whenever the current directory has changed as a result - ## of the user browsing around the file system. Connected callables will be called - ## with the following args: - ## - path - def pathChangedSignal( self ): - return self.__s_pathChanged - - ##! } - - def __emitSelect( self, *args, **kw ) : - - if "items" in kw: - items = kw["items"] - else: - items = self.__getSelectedItems() - - if self._validate( items ): - self.__s_select( self ) - - def __emitCancel( self, *args ) : - self.__s_cancel( self ) - - def __emitPathChanged( self, *args ) : - self.__s_pathChanged( self.__path ) - - ## Sets the title of the main button - def setButtonTitle( self, title ): - - maya.cmds.button( self.__selectButton, edit=True, label=title ) - - ## \return the title of the main button. - def getButtonTitle( self, title ): - - maya.cmds.button( self.__selectButton, query=True, label=True ) - - ## Sets the title of the Cancel button, if one exists - def setCancelButtonTitle( self, title ): - - if self.__cancelButton: - maya.cmds.button( self.__cancelButton, edit=True, label=title ) - - ## \return the title of the cancel button, else None if none exists. - def getCancelButtonTitle( self, title ): - - if self.__cancelButton: - return maya.cmds.button( self.__cancelButton, query=True, label=True ) - else: - return None - - ##! \name Filters - ## Filters and Validation for common customisations of the Browser. - ##! { - ## The FileExtensionFilter allows only certain extensions to be picked or - ## displayed. Register the appropriate method(s) depending on the desired - ## behaviour - class FileExtensionFilter(): - - ### \param extentions One or more extensions to allow, testing is case insensitive. - def __init__( self, extensions ) : - - if not isinstance( extensions, list ) and not isinstance( extensions, tuple ): - extensions = ( extensions, ) - - self.__exts = [] - - for e in extensions: - self.__exts.append( ( ".%s" % e.lower(), len(e) ) ) - - def filter( self, path, items ) : - - if not self.__exts: - return - - # Removal during the for loop fails, and re-assigning - # to 'items' fails as it just reassigns the pointer. - allItems = list(items) - del items[:] - - for i in allItems: - if os.path.isdir( "%s/%s" % ( path, i["name"] ) ) : - items.append( i ) - else: - if self.__check( i["name"] ) : - items.append( i ) - - def validate( self, path, items ) : - - if not items: - return False - - for i in items: - if os.path.isdir( "%s/%s" % ( path, i["name"] ) ) : - return False - elif not self.__check( i["name"] ): - return False - - return True - - def __check( self, itemName ) : - - if not self.__exts: - return True - - item = itemName.lower() - - for e in self.__exts: - if (".%s" % item[-e[1]:]) == e[0] : - return True - - return False - - ## A simple filter that only shows or validates directories. - class DirectoriesOnlyFilter(): - - def filter( self, path, items ) : - - allitems = list(items) - del items[:] - - for i in allitems: - if os.path.isdir( "%s/%s" % ( path, i["name"] ) ) : - items.append( i ) - - def validate( self, path, items ) : - - if not items: - return False - - for i in items: - if not os.path.isdir( "%s/%s" % ( path, i["name"] ) ) : - return False - - return True - - ## A filter that matches a pattern to the filenames - class FnMatchFilter() : - - def __init__( self, pattern ) : - - self.__reobj = re.compile( fnmatch.translate( pattern ) ) - - def filter( self, path, items ) : - - items[:] = [ i for i in items if self.__reobj.match( i["path"] ) or os.path.isdir( i["path"] ) ] - - def validate( self, path, items ) : - - if not items : - return False - - for i in items: - if not self.__reobj.match( i["path"] ) : - return False - - return True - ##! } - - -# A basic signal mechanism to allow arbitrary connections -# between objects. -class _Signal() : - - def __init__( self ) : - self.__slots = [] - - def __call__( self, *args, **kw ) : - for c in self.__slots : - c( *args, **kw ) - - def connect( self, callable ) : - self.__slots.append( callable ) - - def disconnect( self, callable ) : - self.__slots.remove( callable ) - - -class _PathField( IECoreMaya.UIElement ) : - - def __init__( self, uiParent=None, **kw ) : - - if not uiParent: - uiParent = maya.cmds.setParent( q=True ) - - self.__layout = maya.cmds.formLayout( parent = uiParent ) - IECoreMaya.UIElement.__init__( self, self.__layout ) - - self.__upButton = maya.cmds.button( label="Up", parent=self.__layout, command=self.up, width=50, height=30 ) - self.__field = maya.cmds.textField( changeCommand=self.__emitValueChanged, parent=self.__layout, **kw ) - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( self.__upButton, "left", 0 ), ( self.__upButton, "top", 0 ), - ( self.__field, "left", 54 ), ( self.__field, "right", 0 ), ( self.__field, "top", 0 ), - ), - ) - - self.__s_valueChanged = _Signal() - - def up( self, *args ) : - - path = self.value - if not os.path.isdir( path ): - path = os.path.dirname( path ) - path = os.path.dirname( path ) - - self.setValue( path, True ) - - def getValue( self ): - return str( maya.cmds.textField( self.__field, query=True, text=True ) ) - - def setValue( self, value, emit=True ): - maya.cmds.textField( self.__field, edit=True, text=value ) - if emit: - self.__emitValueChanged() - - value = property( getValue, setValue ) - - @property - def valueChangedSignal( self ): - return self.__s_valueChanged - - def __emitValueChanged( self, *args ) : - self.__s_valueChanged( self.value ) - - -class _FileList( IECoreMaya.UIElement ) : - - def __init__( self, uiParent=None, **kw ) : - - if not uiParent: - uiParent = maya.cmds.setParent( q=True ) - - self.__layout = maya.cmds.formLayout( parent=uiParent ) - IECoreMaya.UIElement.__init__( self, self.__layout ) - - self.__sort = _DefaultFileListSort( self.__layout ) - sortUI = self.__sort._topLevelUI() - - self.__list = maya.cmds.textScrollList( - parent = self.__layout, - selectCommand=self.__emitSelectionChanged, - doubleClickCommand=self.__emitItemChosen, - **kw - ) - - maya.cmds.formLayout( - self.__layout, edit=True, - attachForm = ( - ( sortUI, "left", 0 ), ( sortUI, "top", 0 ), ( sortUI, "right", 0 ), - ( self.__list, "left", 0 ), ( self.__list, "right", 0 ), ( self.__list, "bottom", 0 ), - ), - attachControl = ( - ( self.__list, "top", 0, sortUI ), - ) - ) - - self.__items = [] - - self.__s_selectionChanged = _Signal() - self.__s_itemsChanged = _Signal() - self.__s_itemChosen = _Signal() - - self.itemsChangedSignal.connect( self.sortItems ) - self.__sort.termsChangedSignal.connect( self.sortItems ) - - def setSelection( self, items, emit=True ): - - if not items: - maya.cmds.textScrollList( self.__list, edit=True, deselectAll=True ) - if emit: - self.__emitSelectionChanged() - return - - if not ( isinstance( items, list ) or isinstance( items, tuple ) ): - items = list((items,)) - - for i in items: - if self.hasItem( i ): - maya.cmds.textScrollList( self.__list, edit=True, selectItem=self.itemName(i) ) - - if emit: - self.__emitSelectionChanged() - - def getSelection( self ) : - - selected = maya.cmds.textScrollList( self.__list, query=True, si=True ) - if not selected : - return () - - items = [] - for s in selected: - items.append( self.getItem(s) ) - - return items - - def setItems( self, items, emit=True ) : - - self.__items = items - - # This is emited before we re-populate to allow sorting etc... to - # take place if need be. - if emit: - self.__emitItemsChanged() - - maya.cmds.textScrollList( self.__list, edit=True, removeAll=True ) - - for i in self.__items: - maya.cmds.textScrollList( self.__list, edit=True, append=self.itemName(i) ) - - if emit: - self.__emitSelectionChanged() - - def getItems( self ) : - - return list( self.__items ) - - # \arg item can be the item dictionary, or name - def hasItem( self, item ) : - - if isinstance( item, dict ) : - - for i in self.__items: - if i == item : - return True - - else: - - for i in self.__items: - if i["name"] == item : - return True - - return False - - def itemName( self, item ) : - - return item["name"] if isinstance( item, dict ) else item - - def getItem( self, itemName ) : - - for i in self.__items: - # itemName may be unicode. - if i["name"] == str(itemName) : - return i - - return {} - - - def sortItems( self, *args ): - - if not self.__sort: - return - - oldSelection = maya.cmds.textScrollList( self.__list, query=True, si=True ) - - self.__sort.sort( self.__items ) - - ## \todo This effectively calls setItems inside setItems - self.setItems( self.__items, False ) - - if oldSelection: - for i in oldSelection: - if str(i) in self.__items: - maya.cmds.textScrollList( self.__list, edit=True, si=oldSelection ) - - @property - def selectionChangedSignal( self ) : - return self.__s_selectionChanged - - def __emitSelectionChanged( self, *args ) : - - items = self.getSelection() - self.__s_selectionChanged( items ) - - @property - def itemsChangedSignal( self ): - return self.__s_itemsChanged - - def __emitItemsChanged( self, *args ) : - self.__s_itemsChanged( self.__items ) - - @property - def itemChosenSignal( self ): - return self.__s_itemChosen - - def __emitItemChosen( self, *args ) : - selection = maya.cmds.textScrollList( self.__list, query=True, si=True ) - self.__s_itemChosen( self.getItem( selection[0] ) ) - - -class _DefaultFileListSort( IECoreMaya.UIElement ) : - - def __init__( self, uiParent=None, **kw ) : - - if not uiParent: - uiParent = maya.cmds.setParent( q=True ) - - self.__layout = maya.cmds.rowLayout( parent = uiParent, nc=3, adj=3, cw3=( 50, 120, 100 ) ) - IECoreMaya.UIElement.__init__( self, self.__layout ) - - maya.cmds.text( label="Sort by:" ) - - self.__keyMenu = maya.cmds.optionMenu( - changeCommand = self.__emitTermsChanged, - parent=self.__layout, - ) - - self.__directionMenu = maya.cmds.optionMenu( - changeCommand = self.__emitTermsChanged, - parent=self.__layout, - ) - - maya.cmds.menuItem( label="Name", parent=self.__keyMenu ) - maya.cmds.menuItem( label="Date Modified", parent=self.__keyMenu ) - - maya.cmds.menuItem( label="Ascending", parent=self.__directionMenu ) - maya.cmds.menuItem( label="Descending", parent=self.__directionMenu ) - - self.__s_termsChanged = _Signal() - - @property - def termsChangedSignal( self ): - return self.__s_termsChanged - - def __emitTermsChanged( self, *args ) : - self.__s_termsChanged() - - def sort( self, items ) : - - key = maya.cmds.optionMenu( self.__keyMenu, query=True, value=True ) - direction = maya.cmds.optionMenu( self.__directionMenu, query=True, value=True ) - - if key == "Name" : - items.sort( key=lambda item: item["name"].lower() ) - else: - items.sort( key=lambda item: item["mtime"] ) - - if direction == "Descending" : - items.reverse() diff --git a/python/IECoreMaya/FileDialog.py b/python/IECoreMaya/FileDialog.py deleted file mode 100644 index c0f935248b..0000000000 --- a/python/IECoreMaya/FileDialog.py +++ /dev/null @@ -1,229 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya -import maya.OpenMayaUI -import maya.cmds - -import os - -### The FileDialog class provides an alternative to Maya's maya.cmds.fileDialog(). -## It is not a complete drop-in replacement, as, in order to have nice, resizable -## window functionality, it is not modal. Instead, a callback is registered, which -## will be called with the result of the users selection, which will be empty in -## the case of dismissal or cancellation. -## -## If effectively provides an instance of the IECoreMaya.FileBrowser class in a -## window, along with path history, and bookmarking facilities. -## -## \param key (string) This key is used to provide context specific path history -## and bookmarks. It can be None, in which case, the global history/bookmarks are used. -## -## \param callback Should be a callable with the signature f( result ). result will be -## a list of absolute paths to the seleceted items, or an empty list if the dialog was -## dismissed or cancelled. -## -## \prarm title (string) A title for the window. -## -## \param path (string) if specified, this path will be used as the initial path for -## the dialog. If the string "last" is passed, then the last path picked in an instance -## with a matching key will be used. If the argument is omitted, then the current working -## directory is used. -## -## Other kw arguments are passed to the FileBrowser constructor. \see IECoreMaya.FileBrowser -class FileDialog(): - - __pathPresets = {} - - def __init__( self, - key=None, - callback=None, - title="Choose a file", - path=None, - **kw - ) : - - self.__key = key if key else "__global" - - self.__callback = callback - - self.__window = maya.cmds.window( title=title, mb=True ) - self.__bookmarksMenu = maya.cmds.menu( parent=self.__window, label="Bookmarks", postMenuCommand=self.__buildBookmarksMenu ) - - # We need to turn the user closing the window into a 'cancel' event. - callback = maya.OpenMayaUI.MUiMessage.addUiDeletedCallback( self.__window, self.__cancelled ) - self.__deletionCallback = IECoreMaya.CallbackId( callback ) - - self.__browser = IECoreMaya.FileBrowser( self.__window, **kw ) - - if path == "last" : - path = FileDialog.__lastPath( self.__key ) - - self.__browser.setPath( path if path else os.getcwd() ) - - self.__browser.selectSignal.connect( self.__selected ) - self.__browser.cancelSignal.connect( self.__cancelled ) - - maya.cmds.showWindow( self.__window ) - - ## Can be called to set the path being displayed in the Dialog. - ## \see IECoreMaya.FileBrowser.setPath - def setPath( self, path, *args ) : - self.__browser.setPath( path ) - - def __selected( self, browser ) : - - selection = browser.getCurrentSelection() - - if selection: - self.__addToHistory( selection ) - - self.__exit( selection ) - - def __cancelled( self, *args ) : - self.__exit( () ) - - # Called to close the window if it exists, and run the callback. - def __exit( self, returnValue ) : - - if self.__deletionCallback: - del self.__deletionCallback - - if maya.cmds.window( self.__window, exists=True ): - maya.cmds.evalDeferred( "import maya.cmds; maya.cmds.deleteUI( '%s' )" % self.__window ) - - self.__window = None - - self.__callback( returnValue ) - - def __addToHistory( self, items ) : - - path = items[0] - if not os.path.isdir( path ): - path = os.path.dirname( path ) - - ## \todo Multiple item persistent history - maya.cmds.optionVar( sv=( "cortexFileBrowserLastPath_%s" % self.__key, path ) ) - - @staticmethod - def __lastPath( key ) : - - if maya.cmds.optionVar( exists = "cortexFileBrowserLastPath_%s" % key ) : - return str( maya.cmds.optionVar( query = "cortexFileBrowserLastPath_%s" % key ) ) - else: - return None - - - @staticmethod - ## Register a preset for the 'Bookmarks' menu. - ## \param The name (string) the name of the preset, as it will appear in the menu. - ## \pathOrProc (srting) or If a string, the path to go to when selected. - ## if a callable, it should return a tuple of ( name, path ) pairs. If the return - ## tuple has more than one item, a submenu will be created. - ## \param key (string) if specified, the preset will only be available for dialogs - ## with that ui key. - def registerPreset( name, pathOrProc, key=None ) : - - if not key: - key = "__global" - - if key not in FileDialog.__pathPresets: - FileDialog.__pathPresets[key] = [] - - FileDialog.__pathPresets[key].append( (name, pathOrProc) ) - - @staticmethod - ## Removes the named preset with the given key, or global preset if no key is specified. - def removePreset( name, key=None ): - - if not key : - key = "__global" - - if key in FileDialog.__pathPresets : - for p in FileDialog.__pathPresets[key] : - if p[0] == name : - FileDialog.__pathPresets[key].remove( p ) - - def __buildBookmarksMenu( self ) : - - menu = self.__bookmarksMenu - - ## \todo MenuDefinition here? Can we pickle the commands up as easily given the - ## references to self, etc... - - maya.cmds.menu( menu, edit=True, deleteAllItems=True ) - - self.__bookmarkMenuItemsForKey( "__global", menu ) - - if self.__key != "__global": - self.__bookmarkMenuItemsForKey( self.__key, menu ) - - lastPath = FileDialog.__lastPath( self.__key ) - if lastPath : - - maya.cmds.menuItem( divider=True, parent=menu ) - maya.cmds.menuItem( enable=False, label="Recent", parent=menu ) - maya.cmds.menuItem( label=lastPath, parent=menu, command=IECore.curry( self.setPath, lastPath ) ) - - if maya.cmds.menu( menu, numberOfItems=True, query=True ) == 0: - maya.cmds.menuItem( enable=False, parent=menu, label="No presets or history" ) - - - def __bookmarkMenuItemsForKey( self, key, menu ) : - - if key in FileDialog.__pathPresets : - - for p in FileDialog.__pathPresets[key] : - - if isinstance( p[1], str ) : - - maya.cmds.menuItem( parent=menu, label=p[0], command=IECore.curry( self.setPath, p[1] ) ) - - else: - - items = p[1]() - if not items: - continue - - if len(items) == 1: - maya.cmds.menuItem( parent=menu, label=items[0], command=IECore.curry( self.setPath, items[1] ) ) - else: - subMenu = maya.cmds.menuItem( parent=menu, label=p[0], subMenu=True ) - for i in items: - maya.cmds.menuItem( parent=subMenu, label=i[0], command=IECore.curry( self.setPath, i[1] ) ) - - - - diff --git a/python/IECoreMaya/FileNameParameterUI.py b/python/IECoreMaya/FileNameParameterUI.py deleted file mode 100644 index cb39b0b9e2..0000000000 --- a/python/IECoreMaya/FileNameParameterUI.py +++ /dev/null @@ -1,53 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya - -class FileNameParameterUI( IECoreMaya.PathParameterUI ) : - - def __init__( self, node, parameter, **kw ): - - IECoreMaya.PathParameterUI.__init__( self, node, parameter, **kw ) - - def _fileDialog( self ) : - - tools = IECoreMaya.FileBrowser.FileExtensionFilter( self.parameter.extensions ) - - IECoreMaya.PathParameterUI._fileDialog( self, - filter = tools.filter, - validate = tools.validate - ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.FileNameParameter, FileNameParameterUI ) diff --git a/python/IECoreMaya/FileSequenceParameterUI.py b/python/IECoreMaya/FileSequenceParameterUI.py deleted file mode 100644 index 6eff2f97e7..0000000000 --- a/python/IECoreMaya/FileSequenceParameterUI.py +++ /dev/null @@ -1,117 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os.path - -import IECore -import IECoreMaya - -class FileSequenceParameterUI( IECoreMaya.PathParameterUI ) : - - def __init__( self, node, parameter, **kw ): - - IECoreMaya.PathParameterUI.__init__( self, node, parameter, **kw ) - - def _fileDialog( self ) : - - tools = FileSequenceParameterUI.FileSequenceFilter( self.parameter.extensions ) - - IECoreMaya.PathParameterUI._fileDialog( self, - filter = tools.filter, - validate = tools.validate, - ) - - class FileSequenceFilter : - - def __init__( self, extensions=None ) : - - if extensions: - self.__extensions = IECore.StringVectorData( extensions ) - else: - self.__extensions = IECore.StringVectorData() - - def filter( self, path, items ) : - - fsOp = IECore.SequenceLsOp() - - oldItems = list( items ) - del items[:] - - for i in oldItems: - if os.path.isdir( i["path"] ) : - items.append( i ) - - sequences = fsOp( - dir=path, - type="files", - resultType="stringVector", - format="<#PADDING> ", - extensions=self.__extensions, - ) - - for s in sequences : - - firstFrame = IECore.FileSequence( s ).fileNames()[0] - stat = os.stat( firstFrame ) - - seqItem = { - "path" : s, - "name" : s.replace( "%s/" % path, "" ), - "mode" : stat[0], - "uid" : stat[4], - "gid" : stat[5], - "size" : stat[6], - "atime" : stat[7], - "mtime" : stat[8], - "ctime" : stat[9], - } - - items.append( seqItem ) - - # FileExtensionFilter will get confused by the extra info on - # the end of the sequence string. - def validate( self, path, items ): - - if not items: - return False - - for i in items: - if os.path.isdir( "%s/%s" % ( path, i["name"] ) ) : - return False - - return True - - - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.FileSequenceParameter, FileSequenceParameterUI ) diff --git a/python/IECoreMaya/FnConverterHolder.py b/python/IECoreMaya/FnConverterHolder.py deleted file mode 100644 index 85f608a117..0000000000 --- a/python/IECoreMaya/FnConverterHolder.py +++ /dev/null @@ -1,100 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import IECore -import IECoreMaya -import os.path - -class FnConverterHolder( IECoreMaya.FnParameterisedHolder ) : - - def __init__( self, node ) : - - IECoreMaya.FnParameterisedHolder.__init__( self, node ) - - if self.typeName()!="ieConverterHolder" : - - raise TypeError( "\"%s\" is not a ConverterHolder." ) - - ## Returns the converter held by this node - def converter( self ) : - - c = self.getParameterised() - c = c[0] - if not c or not c.isInstanceOf( IECoreMaya.Converter.staticTypeId() ) : - return None - - return c - - ## Performs a conversion at the specified frame - def convertAtFrame( self, frame ) : - - c = self.converter() - if not c : - raise RuntimeError( "No converter found on node \"%s\"." % self.name() ) - - fileName = str( maya.cmds.getAttr( self.name() + ".fileName", asString = True ) ) - try : - f = IECore.FileSequence( fileName, IECore.FrameRange( frame, frame ) ) - fileName = f.fileNameForFrame( frame ) - except : - pass - - if fileName=="" : - raise RuntimeError( "No filename specified on node \"%s\"." % self.name() ) - - maya.cmds.currentTime( frame ) - o = c.convert() - if not o : - raise RuntimeError( "Conversion failed for node \"%s\"." % self.name() ) - - w = IECore.Writer.create( o, fileName ) - if not w : - ext = os.path.splitext( fileName )[1] - raise RuntimeError( "Unable to create a Writer for object of type \"%s\" and file type \"%s\"." % ( o.typeName(), ext ) ) - - w.write() - - ## Performs a conversion for every frame in an IECore.FrameList object - def convertAtFrames( self, frameList ) : - - for f in frameList.asList() : - - self.convertAtFrame( f ) - - ## Returns the maya node type that this function set operates on - @classmethod - def _mayaNodeType( cls ): - - return "ieConverterHolder" diff --git a/python/IECoreMaya/FnDagNode.py b/python/IECoreMaya/FnDagNode.py deleted file mode 100644 index 48b5bca83c..0000000000 --- a/python/IECoreMaya/FnDagNode.py +++ /dev/null @@ -1,128 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import re - -import maya.OpenMaya -import maya.cmds - -import IECore -from . import StringUtil - -## This class extends Maya's MFnDagNode to add assorted helper functions. -class FnDagNode( maya.OpenMaya.MFnDagNode ) : - - ## \param obj - MObject, This can also be a string or an MObjectHandle. - def __init__( self, obj ) : - - if isinstance( obj, str ) : - - obj = StringUtil.dependencyNodeFromString( obj ) - - elif isinstance( obj, maya.OpenMaya.MObjectHandle ) : - - assert( obj.isValid() ) - obj = obj.object() - - maya.OpenMaya.MFnDagNode.__init__( self, obj ) - - ## Creates a shape node of the requested type under a transform with the - # requested name. If necessary a numeric suffix will be appended to the - # parent name to keep it unique. Returns a function set attached to the - # shape. - @staticmethod - def createShapeWithParent( parentName, shapeNodeType ) : - - parentNode = maya.cmds.createNode( "transform", name=parentName, skipSelect=True ) - - shapeName = FnDagNode.defaultShapeName( parentNode ) - shapeNode = maya.cmds.createNode( shapeNodeType, name=shapeName, parent=parentNode, skipSelect=True ) - - return FnDagNode( shapeNode ) - - ## Determines whether the DAG node is actually hidden in Maya. - # This includes the effect of any parents visibility. - # \return Bool - def isHidden( self ) : - - return bool( self.hiddenPathNames( True ) ) - - ## Retrieves the names of any part of the nodes parent hierarchy that is hidden. - # \param includeSelf - Bool, When True, the object itself will be listed if - # it is hidden. When False, only parents will be listed. Defaults to True. - # \return A list of hidden objects by name. - def hiddenPathNames( self, includeSelf=True ) : - - hidden = [] - - # Maya always returns a list from listRelatives. - parent = [] - - if includeSelf : - parent = [ self.fullPathName() ] - else : - parent = maya.cmds.listRelatives( self.fullPathName(), parent=True ) - - while parent : - - assert( len(parent) == 1 ) - - o = parent[0] - attr = "%s.visibility" % o - - if maya.cmds.objExists( attr ) and not maya.cmds.getAttr( attr ) : - hidden.append( o ) - - parent = maya.cmds.listRelatives( o, parent=True ) - - return hidden - - ## Returns the default shape name maya uses when creating a shape under a transform. - @staticmethod - def defaultShapeName( transformNode ): - - parentShort = transformNode.rpartition( "|" )[-1] - - numbersMatch = re.search( r"[0-9]+$", parentShort ) - if numbersMatch is not None : - numbers = numbersMatch.group() - shapeName = parentShort[:-len(numbers)] + "Shape" + numbers - else : - shapeName = parentShort + "Shape" - - return shapeName - - - - diff --git a/python/IECoreMaya/FnOpHolder.py b/python/IECoreMaya/FnOpHolder.py deleted file mode 100644 index 210a9cbcca..0000000000 --- a/python/IECoreMaya/FnOpHolder.py +++ /dev/null @@ -1,75 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from .FnParameterisedHolder import FnParameterisedHolder - -import maya.cmds - -class FnOpHolder( FnParameterisedHolder ) : - - def __init__( self, objectOrObjectName ) : - - FnParameterisedHolder.__init__( self, objectOrObjectName ) - - ## Creates a new node holding a new instance of the op of the specified - # type and version. Returns an FnOpHolder instance attached to this node. - @staticmethod - def create( nodeName, opType, opVersion=None ) : - - holder = maya.cmds.createNode( "ieOpHolderNode", name=nodeName, skipSelect=True ) - - fnOH = FnOpHolder( holder ) - # not asking for undo, as this way we end up with a single undo action which will - # delete the node. otherwise we get two undo actions, one to revert the setParameterised() - # one to revert the createNode(). - fnOH.setOp( opType, opVersion, undoable=False ) - - return fnOH - - ## Convenience function which calls setParameterised( opType, opVersion, "IECORE_OP_PATHS" ) - def setOp( self, opType, opVersion=None, undoable=True ) : - - self.setParameterised( opType, opVersion, "IECORE_OP_PATHS", undoable ) - - ## Convenience function which returns getParameterised()[0] - def getOp( self ) : - - return self.getParameterised()[0] - - - ## Returns the maya node type that this function set operates on - @classmethod - def _mayaNodeType( cls ): - - return "ieOpHolderNode" diff --git a/python/IECoreMaya/FnParameterisedHolder.py b/python/IECoreMaya/FnParameterisedHolder.py deleted file mode 100644 index cfcdd2cc8a..0000000000 --- a/python/IECoreMaya/FnParameterisedHolder.py +++ /dev/null @@ -1,375 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import warnings - -import maya.OpenMaya -import maya.cmds - -import IECore - -from . import _IECoreMaya -from . import StringUtil - -## A function set for operating on the various IECoreMaya::ParameterisedHolder -# types. This allows setting and getting of plug and parameter values, and -# setting and getting of the Parameterised object being held. -class FnParameterisedHolder( maya.OpenMaya.MFnDependencyNode ) : - - ## Initialise the function set for the given object, which may - # either be an MObject or a node name in string or unicode form. - def __init__( self, object ) : - - if isinstance( object, str ) : - object = StringUtil.dependencyNodeFromString( object ) - - maya.OpenMaya.MFnDependencyNode.__init__( self, object ) - - ## Sets the IECore.Parameterised object held by the node. This function can be called - # in two ways : - # - # setParameterised( Parameterised p ) - # Directly sets the held object to the Parameterised instance p. Note that this - # form doesn't provide enough information for the node to be reinstantiated - # after saving and reloading of the maya scene - see the form below for that. - # Also note that this form is not undoable, and that the undoable parameter will therefore - # be ignored. - # - # setParameterised( string className, int classVersion, string searchPathEnvVar, bool undoable ) - # Sets the held object by specifying a class that will be loaded using the IECore.ClassLoader. - # searchPathEnvVar specifies an environment variable which holds a colon separated search path for the - # ClassLoader. This form allows the held class to be reinstantiated across scene save/load, and is - # also undoable if requested using the undoable parameter. If classVersion is omitted, None, or negative, - # then the highest available version will be used. - def setParameterised( self, classNameOrParameterised, classVersion=None, envVarName=None, undoable=True ) : - - if isinstance( classNameOrParameterised, str ) : - if classVersion is None or classVersion < 0 : - classVersions = IECore.ClassLoader.defaultLoader( envVarName ).versions( classNameOrParameterised ) - classVersion = classVersions[-1] if classVersions else 0 - if undoable : - if self.getParameterised()[0] : - self.setParameterisedValues() - _IECoreMaya._parameterisedHolderAssignModificationState( - self.getParameterised()[0].parameters().getValue().copy(), - self._classParameterStates(), - None, - None - ) - else : - _IECoreMaya._parameterisedHolderAssignModificationState( None, None, None, None ) - maya.cmds.ieParameterisedHolderModification( self.fullPathName(), classNameOrParameterised, classVersion, envVarName ) - # no need to despatch callbacks as that is done by the command, so that the callbacks happen on undo and redo too. - else : - _IECoreMaya._parameterisedHolderSetParameterised( self, classNameOrParameterised, classVersion, envVarName ) - self._despatchSetParameterisedCallbacks( self.fullPathName() ) - else : - result = _IECoreMaya._parameterisedHolderSetParameterised( self, classNameOrParameterised ) - self._despatchSetParameterisedCallbacks( self.fullPathName() ) - - ## Returns a tuple of the form (parameterised, className, classVersion, searchPathEnvVar). - # The returned parameterised object is not guaranteed to be in sync with the plug values. - # Use setParameterisedValues function if you need that. - def getParameterised( self ) : - - return _IECoreMaya._parameterisedHolderGetParameterised( self ) - - ## Returns a context manager for use with the with statement. This can be used to - # scope edits to Parameter values (including the classes held by ClassParameters and - # ClassVectorParameters) in such a way that they are automatically transferred onto - # the maya attributes and furthermore in an undoable fashion. - def parameterModificationContext( self ) : - - return _ParameterModificationContext( self ) - - ## Sets the values of the plugs representing the parameterised object, - # using the current values of the parameters. If the undoable parameter is True - # then this method is undoable using the standard maya undo mechanism. - # \note If this is applied to a node in a reference, then reference edits will - # be produced for every parameter plug, even if the values are not changing. - # You may prefer to set parameter values within a parameterModificationContext() - # instead as this automatically transfers the values to maya, while also avoiding - # the reference edit problem. - def setNodeValues( self, undoable=True ) : - - if undoable : - maya.cmds.ieParameterisedHolderSetValue( self.fullPathName() ) - else : - _IECoreMaya._parameterisedHolderSetNodeValues( self ) - - ## Set the value for the plug representing parameter, using the current - # value of the parameter. If the undoable parameter is True - # then this method is undoable using the standard maya undo mechanism. - def setNodeValue( self, parameter, undoable=True ) : - - if undoable : - maya.cmds.ieParameterisedHolderSetValue( self.fullPathName(), plug=self.parameterPlug( parameter ).partialName() ) - else : - _IECoreMaya._parameterisedHolderSetNodeValue( self, parameter ) - - ## Transfers the values from the plugs of the node onto the - # parameters of the held Parameterised object. - def setParameterisedValues( self ) : - - return _IECoreMaya._parameterisedHolderSetParameterisedValues( self ) - - ## Sets the value of parameter from the value held by the plug representing it. - def setParameterisedValue( self, parameter ) : - - return _IECoreMaya._parameterisedHolderSetParameterisedValue( self, parameter ) - - ## Returns the OpenMaya.MPlug object responsible for representing the given parameter. - def parameterPlug( self, parameter ) : - - plugName = _IECoreMaya._parameterisedHolderParameterPlug( self, parameter ) - if plugName == "" : - return maya.OpenMaya.MPlug() - - return StringUtil.plugFromString( self.fullPathName() + "." + plugName ) - - ## Returns a string containing a full pathname for the plug representing the given parameter. - def parameterPlugPath( self, parameter ) : - - plugName = _IECoreMaya._parameterisedHolderParameterPlug( self, parameter ) - if not plugName : - return "" - - return self.fullPathName() + "." + plugName - - ## Returns the IECore.Parameter object being represented by the given fullPathName - # of the maya plug or its OpenMaya.MPlug instance. - def plugParameter( self, plug ) : - - if isinstance( plug, str ) : - plug = StringUtil.plugFromString( plug ) - - return _IECoreMaya._parameterisedHolderPlugParameter( self, plug ) - - ## Returns the full path name to this node. - def fullPathName( self ) : - - try : - f = maya.OpenMaya.MFnDagNode( self.object() ) - return f.fullPathName() - except : - pass - - return self.name() - - ## Add a callback which will be invoked whenever FnParameterisedHolder.setParameterised - # is called. The expected function signature is callback( FnParameterisedHolder ). - @classmethod - def addSetParameterisedCallback( cls, callback ) : - - cls.__setParameterisedCallbacks.add( callback ) - - ## Remove a previously added callback. - @classmethod - def removeSetParameterisedCallback( cls, callback ) : - - cls.__setParameterisedCallbacks.remove( callback ) - - __setParameterisedCallbacks = set() - @classmethod - def _despatchSetParameterisedCallbacks( cls, nodeName ) : - - fnPH = FnParameterisedHolder( nodeName ) - for c in cls.__setParameterisedCallbacks : - c( fnPH ) - - ## Adds a callback which will be invoked whenever FnParameterisedHolder.setClassVectorParameterClasses - # is called. The expected function signature is callback( FnParameterisedHolder, parameter ) - @classmethod - def addSetClassVectorParameterClassesCallback( cls, callback ) : - - cls.__setClassVectorParameterClassesCallbacks.add( callback ) - - ## Removes a callback added previously with addSetClassVectorParameterClassesCallback() - @classmethod - def removeSetClassVectorParameterClassesCallback( cls, callback ) : - - cls.__setClassVectorParameterClassesCallbacks.remove( callback ) - - __setClassVectorParameterClassesCallbacks = set() - - # Invoked by the ieParameterisedHolderModification MPxCommand. It must be invoked from there - # rather than the methods above so that callbacks get correctly despatched during undo and redo. - @classmethod - def _despatchSetClassVectorParameterClassesCallbacks( cls, plugPath ) : - - # This function gets called deferred (on idle) from ParameterisedHolderSetClassParameterCmd.cpp. - # Because of the deferred nature of the call, it's possible that the plug has been destroyed before - # we're called - in this case we just don't despatch callbacks. - ## \todo It might be better to not defer the call to this function, and have any callbacks which - # need deferred evaluation (the ui callbacks in ClassVectorParameterUI for instance) arrange for that - # themselves. - if not maya.cmds.objExists( plugPath ) : - return - - fnPH = FnParameterisedHolder( StringUtil.nodeFromAttributePath( plugPath ) ) - parameter = fnPH.plugParameter( plugPath ) - for c in cls.__setClassVectorParameterClassesCallbacks : - c( fnPH, parameter ) - - ## Adds a callback which will be invoked whenever FnParameterisedHolder.setClassParameterClass - # is called. The expected function signature is callback( FnParameterisedHolder, parameter ) - @classmethod - def addSetClassParameterClassCallback( cls, callback ) : - - cls.__setClassParameterClassCallbacks.add( callback ) - - ## Removes a callback added previously with addSetClassParameterClassCallback() - @classmethod - def removeSetClassParameterClassCallback( cls, callback ) : - - cls.__setClassParameterClassCallbacks.remove( callback ) - - __setClassParameterClassCallbacks = set() - - # Invoked by the ieParameterisedHolderModification MPxCommand. It must be invoked from there - # rather than the methods above so that callbacks get correctly despatched during undo and redo. - @classmethod - def _despatchSetClassParameterClassCallbacks( cls, plugPath ) : - - # See comment in _despatchSetClassVectorParameterClassesCallbacks - if not maya.cmds.objExists( plugPath ) : - return - - fnPH = FnParameterisedHolder( StringUtil.nodeFromAttributePath( plugPath ) ) - parameter = fnPH.plugParameter( plugPath ) - for c in cls.__setClassParameterClassCallbacks : - c( fnPH, parameter ) - - def _classParameterStates( self, parameter=None, parentParameterPath="", result=None ) : - - if result is None : - result = IECore.CompoundData() - - if parameter is None : - parameter = self.getParameterised()[0].parameters() - - parameterPath = parameter.name - if parentParameterPath : - parameterPath = parentParameterPath + "." + parameterPath - - if isinstance( parameter, IECore.ClassParameter ) : - - classInfo = parameter.getClass( True ) - result[parameterPath] = IECore.CompoundData( { - "className" : IECore.StringData( classInfo[1] ), - "classVersion" : IECore.IntData( classInfo[2] ), - "searchPathEnvVar" : IECore.StringData( classInfo[3] ), - } ) - - elif isinstance( parameter, IECore.ClassVectorParameter ) : - - classInfo = parameter.getClasses( True ) - if classInfo : - classInfo = list(zip( *classInfo )) - else : - classInfo = [ [], [], [], [] ] - - result[parameterPath] = IECore.CompoundData({ - "parameterNames" : IECore.StringVectorData( classInfo[1] ), - "classNames" : IECore.StringVectorData( classInfo[2] ), - "classVersions" : IECore.IntVectorData( classInfo[3] ), - } ) - - if isinstance( parameter, IECore.CompoundParameter ) : - - for c in parameter.values() : - - self._classParameterStates( c, parameterPath, result ) - - return result - - ## Returns the maya node type that this function set operates on - @classmethod - def _mayaNodeType( cls ): - - return "ieParameterisedHolderNode" - - ## Lists the ieParameterisedHolderNodes in the current scene. The keyword arguments operate as follows : - # - # selection : - # Only list holders in the current selection. Defaults to False - # - # fnSets : - # Returns a list of FnParameterisedHolder instances if True, otherwise returns node names. Defaults to True - # - # classType : - # Python class: if specified, only lists holders holding this class - # - @classmethod - def ls( cls, selection=False, fnSets=True, classType=None ) : - - nodeNames = maya.cmds.ls( sl=selection, leaf=True, type=cls._mayaNodeType() ) - matches = [] - for n in nodeNames : - fnH = cls( n ) - if classType is None or isinstance( fnH.getParameterised()[0], classType ) : - matches.append( fnH ) - - if fnSets : - return matches - else : - return [ x.fullPathName() for x in matches ] - -class _ParameterModificationContext : - - def __init__( self, fnPH ) : - - self.__fnPH = fnPH - - def __enter__( self ) : - - self.__fnPH.setParameterisedValues() - self.__originalValues = self.__fnPH.getParameterised()[0].parameters().getValue().copy() - self.__originalClasses = self.__fnPH._classParameterStates() - - return self.__fnPH.getParameterised()[0] - - def __exit__( self, type, value, traceBack ) : - - _IECoreMaya._parameterisedHolderAssignModificationState( - self.__originalValues, - self.__originalClasses, - self.__fnPH.getParameterised()[0].parameters().getValue().copy(), - self.__fnPH._classParameterStates(), - ) - - maya.cmds.ieParameterisedHolderModification( self.__fnPH.fullPathName() ) - diff --git a/python/IECoreMaya/FnParameterisedHolderSet.py b/python/IECoreMaya/FnParameterisedHolderSet.py deleted file mode 100644 index 7d039b0a12..0000000000 --- a/python/IECoreMaya/FnParameterisedHolderSet.py +++ /dev/null @@ -1,56 +0,0 @@ -########################################################################## -# -# Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECoreMaya - -## A function set for operating on ieParameterisedHolderSet node type. -class FnParameterisedHolderSet( IECoreMaya.FnParameterisedHolder ) : - - ## Initialise the function set for the given object, which may - # either be an MObject or a node name in string or unicode form. - def __init__( self, object ) : - - IECoreMaya.FnParameterisedHolder.__init__( self, object ) - - @staticmethod - def create( nodeName, className, classVersion, searchPathEnvVar ) : - - node = maya.cmds.createNode( "ieParameterisedHolderSet", name=nodeName ) - - fnSH = IECoreMaya.FnParameterisedHolderSet( node ) - fnSH.setParameterised( className, classVersion, searchPathEnvVar, undoable=False ) - - return fnSH diff --git a/python/IECoreMaya/FnSceneShape.py b/python/IECoreMaya/FnSceneShape.py deleted file mode 100644 index 8b302789ff..0000000000 --- a/python/IECoreMaya/FnSceneShape.py +++ /dev/null @@ -1,824 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import re -import traceback -from collections import namedtuple - -import maya.OpenMaya -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya -from . import StringUtil - -## A function set for operating on the IECoreMaya::SceneShape and IECoreMaya::SceneShapeProxy types. -class FnSceneShape( maya.OpenMaya.MFnDagNode ) : - __MayaAttributeDataType = namedtuple('__MayaAttributeDataType', 'namespace type') - - __childCreatedCallbacks = set() - - # These correspond to the hard-coded values which SceneShape.attributes.attributeValues can accept - # I'm duplicating them here since there is no way of directly querying them from MFnGenericAttribute - __cortexToMayaDataTypeMap = { - IECore.TypeId.BoolData: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kBoolean ), - IECore.TypeId.ShortData: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kShort ), - IECore.TypeId.IntData: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kInt ), - # Maya can create int64 plugs which you can read and set, but they cannot be connected int64 -> int64. - # They can, however, be connected as int64 -> int - # As it stands, we do not currently have a Maya plug converter which will author Int64Data, so if we want to promote - # an int64 attribute it is probably safe to do it as an int. I think it will be fairly obvious if we overflow. - IECore.TypeId.Int64Data: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kInt ), - IECore.TypeId.FloatData: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kFloat ), - IECore.TypeId.DoubleData: __MayaAttributeDataType( maya.OpenMaya.MFnNumericData, maya.OpenMaya.MFnNumericData.kDouble ), - IECore.TypeId.StringData: __MayaAttributeDataType( maya.OpenMaya.MFnData, maya.OpenMaya.MFnData.kString ), - IECore.TypeId.M44fData: __MayaAttributeDataType( maya.OpenMaya.MFnData, maya.OpenMaya.MFnData.kMatrix ), - IECore.TypeId.M44dData: __MayaAttributeDataType( maya.OpenMaya.MFnData, maya.OpenMaya.MFnData.kMatrix ), - } - - ## Initialise the function set for the given procedural object, which may - # either be an MObject or a node name in string or unicode form. - # Note: Most of the member functions assume that this function set is initialized with the full dag path. - def __init__( self, mayaObject ) : - - if isinstance( mayaObject, str ) : - mayaObject = StringUtil.dagPathFromString( mayaObject ) - maya.OpenMaya.MFnDagNode.__init__( self, mayaObject ) - - # We use pythons metaprogramming capabilities and dynamically change the object that is created based - # on the node type type that is passed in. We do this so that we can use FnSceneShape for two different - # node types, i.e. SceneShape and its derived proxy class SceneShapeProxy, without having to change huge - # parts of the codebase. SceneShape and SceneShapeProxy both provide the same core functionality of reading - # a SceneInterface, with the difference that SceneShapeProxy can't be drawn in the ViewPort and therefore - # drawing/selecting related methods in those class have no effect. See SceneShapeProxy.h for more information. - def __new__( cls, mayaObject ): - - if isinstance( mayaObject, str ) : - mayaObject = StringUtil.dagPathFromString( mayaObject ) - else: - dagPath = maya.OpenMaya.MDagPath() - maya.OpenMaya.MDagPath.getAPathTo(mayaObject, dagPath) - mayaObject = dagPath - - if maya.cmds.nodeType(mayaObject.fullPathName()) == "ieSceneShape": - return object.__new__(FnSceneShape) - if maya.cmds.nodeType(mayaObject.fullPathName()) == "ieSceneShapeProxy": - return object.__new__(_FnSceneShapeProxy) - - ## Creates a new node under a transform of the specified name. Returns a function set instance operating on this new node. - @classmethod - @IECoreMaya.UndoFlush() - def create( cls, parentName, transformParent = None, shadingEngine = None, shapeType=None ) : - try: - parentNode = maya.cmds.createNode( "transform", name=parentName, skipSelect=True, parent = transformParent ) - except: - # The parent name is supposed to be the children names in a sceneInterface, they could be numbers, maya doesn't like that. Use a prefix. - parentNode = maya.cmds.createNode( "transform", name="sceneShape_"+parentName, skipSelect=True, parent = transformParent ) - - return cls.createShape( parentNode, shadingEngine=shadingEngine, shapeType=shapeType ) - - ## Create a scene shape under the given node. Returns a function set instance operating on this shape. - @classmethod - @IECoreMaya.UndoFlush() - def createShape( cls, parentNode, shadingEngine = None, shapeType=None ) : - parentShort = parentNode.rpartition( "|" )[-1] - numbersMatch = re.search( r"[0-9]+$", parentShort ) - if numbersMatch is not None : - numbers = numbersMatch.group() - shapeName = parentShort[:-len(numbers)] + "SceneShape" + numbers - else : - shapeName = parentShort + "SceneShape" - - dagMod = maya.OpenMaya.MDagModifier() - shapeNode = dagMod.createNode( shapeType if shapeType else cls._mayaNodeType(), IECoreMaya.StringUtil.dependencyNodeFromString( parentNode ) ) - dagMod.renameNode( shapeNode, shapeName ) - dagMod.doIt() - - fnScS = cls( shapeNode ) - maya.cmds.sets( fnScS.fullPathName(), edit=True, forceElement=shadingEngine or "initialShadingGroup" ) - - fnScS.findPlug( "objectOnly" ).setLocked( True ) - - dgMod = maya.OpenMaya.MDGModifier() - outTime = IECoreMaya.StringUtil.plugFromString( "time1.outTime" ) - dgMod.connect( outTime, fnScS.findPlug( "time" ) ) - dgMod.doIt() - - return fnScS - - ## Registers a new callback triggered when a new child shape is created during geometry expansion. - # Signature: `callback( dagPath )` - @classmethod - def addChildCreatedCallback( cls, func ): - cls.__childCreatedCallbacks.add( func ) - - @classmethod - def __executeChildCreatedCallbacks( cls, dagPath ): - for callback in cls.__childCreatedCallbacks: - try: - callback( dagPath ) - except Exception as exc: - IECore.error( "IECoreMaya.FnSceneShape: Exception during 'ChildCreated' callback for path '{}':\n{}".format( dagPath, traceback.format_exc() ) ) - - ## Returns a set of the names of any currently selected components. - @IECoreMaya.UndoDisabled() - def selectedComponentNames( self ) : - result = set() - s = maya.OpenMaya.MSelectionList() - maya.OpenMaya.MGlobal.getActiveSelectionList( s ) - - allComponents = self.componentNames() - - for i in range( s.length() ) : - try : - p = maya.OpenMaya.MDagPath() - c = maya.OpenMaya.MObject() - s.getDagPath( i, p, c ) - - if p.node() == self.object() : - fnC = maya.OpenMaya.MFnSingleIndexedComponent( c ) - a = maya.OpenMaya.MIntArray() - fnC.getElements( a ) - - for j in range( a.length() ) : - result.add( allComponents[ a[j] ] ) - except : - pass - - return result - - ## Selects the components specified by the passed names. - def selectComponentNames( self, componentNames ) : - if not isinstance( componentNames, set ) : - if isinstance( componentNames, str ): - componentNames = set( (componentNames, ) ) - else: - componentNames = set( componentNames ) - - fullPathName = self.fullPathName() - allNames = self.componentNames() - toSelect = [] - for i, name in enumerate( allNames ): - if name in componentNames: - toSelect.append( fullPathName + ".f[" + str( i ) + "]" ) - - transform = maya.cmds.listRelatives( fullPathName, parent=True, fullPath=True )[0] - maya.cmds.hilite( transform ) - maya.cmds.select( clear=True ) - maya.cmds.selectType( allComponents=False, facet=True ) - if toSelect: - maya.cmds.select( toSelect, replace=True ) - - def sceneInterface( self ) : - return IECoreMaya._IECoreMaya._sceneShapeSceneInterface( self ) - - def componentNames( self ) : - return IECoreMaya._IECoreMaya._sceneShapeComponentNames( self ) - - ## Returns True if the scene shape can be expanded. - # We assume that if the objectOnly flag is on, it means the scene shape has already been expanded so return False. - # If the objectOnly flag is off, we can be expanded given that we have children to expand - def canBeExpanded( self ) : - if not maya.cmds.getAttr( self.fullPathName()+".objectOnly" ): - scene = self.sceneInterface() - if scene and scene.childNames(): - return True - return False - - ## Returns True if the scene shape can be collapsed. - # We assume that if the objectOnly flag is off, the scene shape is already collapsed. - def canBeCollapsed( self ) : - return maya.cmds.getAttr( self.fullPathName() + ".objectOnly" ) - - ## Helper method to disconnect a plug from a sceneShape - # The plug can be either singular or compound - @staticmethod - def __disconnectPlug( dgModifer, plug ): - plugs = [ plug ] - - if plug.isCompound(): - plugs.extend( [ plug.child(i) for i in range( plug.numChildren() ) ] ) - - for plug in plugs: - if plug.isConnected() : - connections = maya.OpenMaya.MPlugArray() - plug.connectedTo( connections, True, False ) - dgModifer.disconnect( connections[0], plug ) - - ## Returns the index of the query plug which matches the given value. - # If the value isn't already in the queries, add it and return the new index. - def __queryIndexForPlug( self, plugName, plugValue ): - # Try to locate the plug if it already exists - indices = maya.OpenMaya.MIntArray() - plug = self.findPlug( plugName ) - plug.getExistingArrayAttributeIndices( indices ) - for index in indices: - if plug.elementByLogicalIndex( index ).asString() == plugValue: - return index - - # The plug doesn't exist, so create it - index = max( indices ) + 1 if indices else 0 - plug.elementByLogicalIndex( index ).setString( plugValue ) - return index - - def __queryIndexForAttribute( self, attributeName ): - return self.__queryIndexForPlug( 'queryAttributes', attributeName ) - - def __queryIndexForPath( self, path ): - return self.__queryIndexForPlug( 'queryPaths', path ) - - ## create the given child for the scene shape - # Returns a the function set for the child scene shape. - def __createChild( self, childName, sceneFile, sceneRoot, drawGeo = False, drawChildBounds = False, drawRootBound = True, drawTagsFilter = "", namespace = "" ) : - if namespace: - namespace += ":" - - if not sceneRoot.endswith( '/' ): - sceneRoot += '/' - - # Construct the child sceneShapes's path - dag = maya.OpenMaya.MDagPath() - self.getPath( dag ) - dag.pop() - parentPath = dag.fullPathName() - childPath = parentPath + "|" + namespace + childName - - # get parent shadingGroup - shadingGroups = maya.cmds.listConnections( self.fullPathName(), type='shadingEngine' ) or [] - shadingGroup = shadingGroups[0] if shadingGroups else None - - # Create (or retrieve) the child sceneShape - if maya.cmds.objExists(childPath): - shape = maya.cmds.listRelatives( childPath, fullPath=True, type="ieSceneShape" ) - if shape: - fnChild = self.__class__( shape[0] ) - else: - fnChild = self.createShape( childPath, shadingEngine=shadingGroup ) - else: - fnChild = self.create( childName, transformParent=parentPath, shadingEngine=shadingGroup ) - - fnChildTransform = maya.OpenMaya.MFnDagNode( fnChild.parent( 0 ) ) - - # Set the child's sceneShapes plugs - dgMod = maya.OpenMaya.MDGModifier() - dgMod.newPlugValueString( fnChild.findPlug( "file" ), sceneFile ) - dgMod.newPlugValueString( fnChild.findPlug( "root" ), sceneRoot + childName ) - dgMod.newPlugValueBool( fnChild.findPlug( "drawGeometry" ), drawGeo ) - dgMod.newPlugValueBool( fnChild.findPlug( "drawChildBounds" ), drawChildBounds ) - dgMod.newPlugValueBool( fnChild.findPlug( "drawRootBound" ), drawRootBound ) - dgMod.doIt() - - # Set visible if I have any of the draw flags in my hierarchy, otherwise set hidden - if drawTagsFilter: - childTags = fnChild.sceneInterface().readTags( IECoreScene.SceneInterface.EveryTag ) - commonTags = [x for x in drawTagsFilter.split() if str(x) in childTags] - if not commonTags: - dgMod.newPlugValueBool( fnChildTransform.findPlug( "visibility" ), False ) - else: - dgMod.newPlugValueString( fnChild.findPlug( "drawTagsFilter" ), " ".join( commonTags ) ) - dgMod.newPlugValueBool( fnChildTransform.findPlug( "visibility" ), True ) - - # Drive the child's transforms through the parent sceneShapes plugs - index = self.__queryIndexForPath( "/" + childName ) - outTransform = self.findPlug( "outTransform" ).elementByLogicalIndex( index ) - - childTranslate = fnChildTransform.findPlug( "translate" ) - self.__disconnectPlug( dgMod, childTranslate ) - dgMod.connect( outTransform.child( self.attribute( "outTranslate" ) ), childTranslate ) - - childRotate = fnChildTransform.findPlug( "rotate" ) - self.__disconnectPlug( dgMod, childRotate) - dgMod.connect( outTransform.child( self.attribute( "outRotate" ) ), childRotate ) - - childScale = fnChildTransform.findPlug( "scale" ) - self.__disconnectPlug( dgMod, childScale ) - dgMod.connect( outTransform.child( self.attribute( "outScale" ) ), childScale ) - - childTime = fnChild.findPlug( "time" ) - self.__disconnectPlug( dgMod, childTime ) - dgMod.connect( self.findPlug( "outTime" ), childTime ) - - dgMod.doIt() - - self.__executeChildCreatedCallbacks( fnChild.fullPathName() ) - - return fnChild - - ## create the given child for the scene shape - # Returns a the function set for the child scene shape. - # If preserveNamespace is True, it creates the child with the same namespace as the one this sceneShape node has. - @IECoreMaya.UndoFlush() - def createChild( self, childName, sceneFile, sceneRoot, drawGeo = False, drawChildBounds = False, drawRootBound = True, drawTagsFilter = "", preserveNamespace=False) : - if preserveNamespace: - selfNamespaceList = self.fullPathName().split("|")[-1].split( ":" )[:-1] - selfNamespace = ":".join(selfNamespaceList) - - if selfNamespace: - originalNS = maya.cmds.namespaceInfo( cur=True, absoluteName=True ) - maya.cmds.namespace( set=":" + selfNamespace ) - - try: - return self.__createChild(childName, sceneFile, sceneRoot, drawGeo, drawChildBounds, drawRootBound, drawTagsFilter, selfNamespace) - finally: - maya.cmds.namespace( set=originalNS ) - - return self.__createChild(childName, sceneFile, sceneRoot, drawGeo, drawChildBounds, drawRootBound, drawTagsFilter) - - ## Expands the scene shape one level down if possible. - # Returns a list of function sets for the child scene shapes. - # Missing child transforms and shapes will be created, missing connections and attribute values will be reset. - # If preserveNamespace is True, it creates transforms and shapes with the same namespace as the one this sceneShape node has. - @IECoreMaya.UndoFlush() - def expandOnce( self, preserveNamespace=False ) : - scene = self.sceneInterface() - if not scene: - return [] - - # Since we are expanding, our queries paths should only be referencing our children - # For child query paths, the local and world space will always be the same - # We can early out of some extra computation by ensuring that this is set to local - querySpace = self.findPlug( "querySpace" ) - querySpace.setInt( 1 ) # Local - - # Expand to my children - sceneChildren = sorted( scene.childNames() ) - if not sceneChildren: - return [] - - sceneFile = self.findPlug( "file" ).asString() - sceneRoot = self.findPlug( "root" ).asString() - drawGeo = self.findPlug( "drawGeometry" ).asBool() - drawChildBounds = self.findPlug( "drawChildBounds" ).asBool() - drawRootBound = self.findPlug( "drawRootBound" ).asBool() - drawTagsFilter = self.findPlug( "drawTagsFilter" ).asString() - - newSceneShapeFns = [] - for child in sceneChildren: - fnChild = self.createChild( child, sceneFile, sceneRoot, drawGeo, drawChildBounds, drawRootBound, drawTagsFilter, preserveNamespace ) - newSceneShapeFns.append( fnChild ) - - # Mark myself 'objectOnly' indicating that I am now fully expanded - # I avoided doing this if I did not have children so that link attributes will be generated and exposed to LiveScene - objectOnlyPlug = self.findPlug( "objectOnly" ) - objectOnlyPlug.setLocked( False ) - objectOnlyPlug.setBool( True ) - objectOnlyPlug.setLocked( True ) - - return newSceneShapeFns - - ## Recursively expands all levels starting from the scene shape. - # Returns a list of function sets for all the child scene shapes. - # If preserveNamespace is True, it creates transforms and shapes with the same namespace as the one this sceneShape node has. - # If tagName is specified, each scene in the hierarchy expands only if at least one child has the tag - @IECoreMaya.UndoFlush() - def expandAll( self, preserveNamespace=False, tagName=None ): - newFn = [] - - def recursiveExpand( fnSceneShape ): - if tagName and str( tagName ) not in fnSceneShape.sceneInterface().readTags( IECoreScene.SceneInterface.DescendantTag ): - return - - new = fnSceneShape.expandOnce( preserveNamespace ) - newFn.extend( new ) - for n in new: - recursiveExpand( n ) - - if tagName: - self.findPlug( "drawTagsFilter" ).setString( tagName ) - - recursiveExpand( self ) - - return newFn - - ## Collapses all children up to this scene shape. - @IECoreMaya.UndoFlush() - def collapse( self ) : - # Delete my children (including any maya geo that this scene shape had expanded) - node = self.fullPathName() - transform = maya.cmds.listRelatives( node, parent=True, fullPath=True )[0] - children = maya.cmds.listRelatives( transform, fullPath=True ) - children.remove( node ) - - if children: - maya.cmds.delete( children ) - - # Turn off intermediate object (which would have been set if I was expanded as geo) - self.findPlug( "intermediateObject" ).setBool( False ) - - # Turn off objectOnly when collapsed (even in the case that I do not have any children - this ensure a link attribute will be generated for LiveScene) - objectOnlyPlug = self.findPlug( "objectOnly" ) - objectOnlyPlug.setLocked( False ) - objectOnlyPlug.setBool( False ) - objectOnlyPlug.setLocked( True ) - - ## Returns tuple of maya type and input plug name that match the object in the scene interface, by checking the objectType tags. - # Returns (None, None) if no object in the scene interface or the object isn't compatible with maya geometry we can create. - def __mayaCompatibleShapeAndPlug( self ) : - result = (None, None) - if self.sceneInterface().hasObject(): - tags = self.sceneInterface().readTags( IECoreScene.SceneInterface.LocalTag ) - if "ObjectType:MeshPrimitive" in tags: - result = ( "mesh", "inMesh" ) - elif "ObjectType:CurvesPrimitive" in tags: - result = ( "nurbsCurve", "create" ) - elif "ObjectType:CoordinateSystem" in tags: - result = ( "locator", "localPosition" ) - - return result - - ## Recursively converts all objects in the scene interface to compatible maya geometry - # All scene shape nodes which have an object are turned into intermediate objects - @IECoreMaya.UndoFlush() - def convertAllToGeometry( self, preserveNamespace=False, tagName=None ) : - sceneShapeFns = self.expandAll( preserveNamespace, tagName ) - - if not tagName or str( tagName ) in self.sceneInterface().readTags( IECoreScene.SceneInterface.LocalTag ): - sceneShapeFns.append( self ) - - for sceneShapeFn in sceneShapeFns: - scene = sceneShapeFn.sceneInterface() - if scene and scene.hasObject(): - sceneShapeFn.convertObjectToGeometry() - - ## Update parameters based on index'th element of queryConvertParameters. - def __readConvertParams( self, index, parameters ): - queryConvertParametersPlug = self.findPlug( "queryConvertParameters" ) - convertParamIndices = maya.OpenMaya.MIntArray() - queryConvertParametersPlug.getExistingArrayAttributeIndices( convertParamIndices ) - values = queryConvertParametersPlug.elementByLogicalIndex( index ).asString().split() - values = [ str(x) for x in values ] # unicode to str - IECore.ParameterParser().parse( values, parameters ) - - ## Set queryConvertParameters attribute from a parametrized object. - def __setConvertParams( self, index, parameters ): - paramsStr = " ".join( IECore.ParameterParser().serialise( parameters ) ) - queryConvertParameters = self.findPlug( "queryConvertParameters" ) - queryConvertParameters.elementByLogicalIndex( index ).setString( paramsStr ) - - def __findOrCreateShape( self, transformNode, shapeName, shapeType ): - pathToShape = transformNode + "|" + shapeName - - if maya.cmds.objExists( pathToShape ): - fnShape = maya.OpenMaya.MFnDagNode( IECoreMaya.StringUtil.dagPathFromString( pathToShape ) ) - else: - fnShape = None - - if fnShape and maya.cmds.nodeType( pathToShape ) != shapeType : - # Rename existing shape - newName = shapeName + "_orig" - maya.cmds.rename( pathToShape, newName ) - IECore.msg( IECore.Msg.Level.Warning, "FnSceneShape.__findOrCreateShape", "Renaming incompatible shape %s to %s." % ( pathToShape, newName ) ) - fnShape = None - - if not fnShape : - dagMod = maya.OpenMaya.MDagModifier() - shapeNode = dagMod.createNode( shapeType, IECoreMaya.StringUtil.dependencyNodeFromString( transformNode ) ) - dagMod.renameNode( shapeNode, shapeName ) - dagMod.doIt() - - fnShape = maya.OpenMaya.MFnDagNode( shapeNode ) - - if shapeType != "locator": - maya.cmds.sets( pathToShape, add="initialShadingGroup" ) - - if shapeType == "mesh": - object = self.sceneInterface().readObject(0.0) - interpolation = object.interpolation - shape = fnShape.fullPathName() - try: - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( shape, interpolation ) - except: - IECore.msg( IECore.Msg.Level.Warning, "FnSceneShape.__findOrCreateShape", "Failed to set interpolation on %s." % shape ) - - return fnShape - - def __findOrCreateShapes( self, transformNode ): - shapeType, plugStr = self.__mayaCompatibleShapeAndPlug() - if not (shapeType and plugStr): - raise Exception( "Scene interface at %s cannot be converted to Maya geometry." % self.sceneInterface().pathAsString() ) - - shapeName = IECoreMaya.FnDagNode.defaultShapeName( transformNode ) - - shapes = [] - - if shapeType == "nurbsCurve": - curvesPrimitive = self.sceneInterface().readObject( 0.0 ) - numShapes = curvesPrimitive.numCurves() - for shapeId in range( numShapes ): - nameId = '' if numShapes == 1 else str( shapeId ) # Do not add number to the name if there's only one curve, for backward compatibility. - shapes.append( self.__findOrCreateShape( transformNode, shapeName + nameId, shapeType ) ) - - shapes.append( self.__findOrCreateShape( transformNode, shapeName, shapeType ) ) - return shapes - - def __connectShape( self, pathToShape, plugStr, arrayIndex ): - fnShape = maya.OpenMaya.MFnDagNode( IECoreMaya.StringUtil.dagPathFromString( pathToShape ) ) - - plug = fnShape.findPlug( plugStr ) - if plug.isLocked() : - return - - connections = maya.OpenMaya.MPlugArray() - if plug.isConnected() : - plug.connectedTo( connections, True, False ) - if connections.length(): - return - - # Connect this node to the shape. - dgMod = maya.OpenMaya.MDGModifier() - dgMod.connect( self.findPlug( "outObjects" ).elementByLogicalIndex( arrayIndex ), plug ) - dgMod.doIt() - - def __connectShapes( self, transformNode = None ): - shapeType, plugStr = self.__mayaCompatibleShapeAndPlug() - if not (shapeType and plugStr): - return - - shapeName = IECoreMaya.FnDagNode.defaultShapeName( transformNode ) - pathToShape = transformNode + "|" + shapeName - - if shapeType == "nurbsCurve": - curvesPrimitive = self.sceneInterface().readObject( 0.0 ) - numShapes = curvesPrimitive.numCurves() - - # Connect this node to shapes. Set query attributes. - - queryPathsPlug = self.findPlug( "queryPaths" ) - validIndices = maya.OpenMaya.MIntArray() - queryPathsPlug.getExistingArrayAttributeIndices( validIndices ) - - # Find an unused query attributes array index for the time we need to make one. - if validIndices: - nextArrayIndex = max( validIndices ) + 1 - else: - nextArrayIndex = 0 - - parameters = IECoreMaya.ToMayaObjectConverter.create( curvesPrimitive ).parameters() - - # { "index" convert param value : queryPaths array index}, to be used to check if we can reuse existing query attributes element. - existingQueryIndices = {} - for i in validIndices: - if queryPathsPlug.elementByLogicalIndex( i ).asString() == "/": - self.__readConvertParams( i, parameters ) - existingQueryIndices[ parameters["index"].getTypedValue() ] = i - - for shapeId in range( numShapes ): - - # Set query attributes. - # We need multiple Maya shape nodes to fully convert a curvesPrimitive. - # To feed geometry data into multiple shapes, ieSceneShape node's "outObjects" attribute needs to output multiple geometries. - # This can be done using query attributes "queryConvertParameters". - # e.g. when you want outObjects[ i ] to output j's curve of the CurvesPrimitive, - # maya.cmds.setAttr( "mySceneShape.queryConvertParameters[ i ]", "-index %d" % j, type="string" ) - # You also need to set a valid path to the i'th queryPaths element. - attrIndex = existingQueryIndices.get( shapeId ) - if attrIndex is not None: - arrayIndex = attrIndex # Reuse an existing array element. - else: - arrayIndex = nextArrayIndex # Create a new array element. - nextArrayIndex += 1 - - queryPathsPlug.elementByLogicalIndex( arrayIndex ).setString( "/" ) - parameters[ "index" ].setTypedValue( shapeId ) - if "src" in parameters: - del parameters[ "src" ] - self.__setConvertParams( arrayIndex, parameters ) - - nameId = '' if numShapes == 1 else str( shapeId ) - self.__connectShape( pathToShape + nameId, plugStr, arrayIndex ) - - else: - # Connect this node to one shape. - arrayIndex = self.__queryIndexForPath( "/" ) - self.__connectShape( pathToShape, plugStr, arrayIndex ) - - ## Converts the object (if any) in the scene interface into maya geometry. - # If a shape with the expected name but incompatible type is found under the transform, we rename it and create a new proper shape. - # The shape is connected to the scene shape object output only if it isn't already connected or locked. - # transformNode parameter can be used to specify the parent of the geometry. If None, uses the transform of the scene shape. - @IECoreMaya.UndoFlush() - def convertObjectToGeometry( self, transformNode = None ): - # Check that we have a valid scene interface and an object - scene = self.sceneInterface() - if not scene or not scene.hasObject(): - return - - shapeType, plugStr = self.__mayaCompatibleShapeAndPlug() - - if not transformNode: - # No transform provided, use the transform of the reader - dag = maya.OpenMaya.MDagPath() - self.getPath( dag ) - dag.pop() - transformNode = dag.fullPathName() - - # Turn myself into an intermediate object since the maya shape will take my place - self.findPlug( "intermediateObject" ).setBool( True ) - - fnShapes = self.__findOrCreateShapes( transformNode ) - self.__connectShapes( transformNode ) - - # get shadingGroup - shadingGroups = maya.cmds.listConnections( self.fullPathName(), type='shadingEngine' ) - shadingGroup = shadingGroups[ 0 ] if shadingGroups else None - - # apply parent shader - if shapeType != 'locator' and shadingGroup: - for shape in fnShapes: - maya.cmds.sets( shape.fullPathName(), edit=True, forceElement=shadingGroup ) - - ## Creates a maya locator in the position and orientation of the scene path's transform. - # \param path Path to scene where the locator should be created - def createLocatorAtTransform( self, path ) : - node = self.fullPathName() - transform = maya.cmds.listRelatives( node, parent=True, f=True )[0] - locator = "|" + maya.cmds.spaceLocator( name = path.replace( "/", "_" ) + "Transform" )[0] - - index = self.__queryIndexForPath( path ) - outTransform = node + ".outTransform[" + str( index ) + "]" - maya.cmds.connectAttr( outTransform+".outTranslate", locator + ".translate" ) - maya.cmds.connectAttr( outTransform+".outRotate", locator + ".rotate" ) - maya.cmds.connectAttr( outTransform+".outScale", locator + ".scale" ) - locator = transform + "|" + maya.cmds.parent( locator, transform, relative=True )[0] - - return locator - - ## Creates a maya locator at the min, max, or center points of the scene path's bound. - # \param path Path to scene - # \param childPlugSuffixes List containing "Max", "Min", or "Center", the position where the locator should be created - def createLocatorAtPoints( self, path, childPlugSuffixes ) : - node = self.fullPathName() - transform = maya.cmds.listRelatives( node, parent=True, f=True )[0] - - locators = [] - for childPlugSuffix in childPlugSuffixes : - index = self.__queryIndexForPath( path ) - outBound = node + ".outBound[" + str( index ) + "]" - locator = "|" + maya.cmds.spaceLocator( name = path.replace( "/", "_" ) + childPlugSuffix )[0] - maya.cmds.connectAttr( outBound + ".outBound" + childPlugSuffix, locator + ".translate" ) - locators.append( transform + "|" + maya.cmds.parent( locator, transform, relative=True )[0] ) - - return locators - - def __sceneInterfaceFromQueryPath( self, queryPath='/' ): - scene = self.sceneInterface() - if not scene: - return - - fullQueryPath = scene.path() + scene.stringToPath( queryPath ) - queryScene = scene.scene( fullQueryPath, IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ) - if not queryScene: - return - - return queryScene - - def __cortexTypeToMayaType( self, querySceneInterface, attributeName ): - timePlug = self.findPlug( 'time', False ) - time = timePlug.asMTime().asUnits( maya.OpenMaya.MTime.kSeconds ) - cortexData = querySceneInterface.readAttribute( attributeName, time ) - return self.__cortexToMayaDataTypeMap.get( cortexData.typeId() ) - - ## Returns a list of attribute names which can be promoted to maya plugs. - # \param queryPath Path to the scene from which we want return attribute names. Defaults to root '/' - # \param blackListed List of attribute names which should not be included in the returned attribute names. - @IECoreMaya.UndoDisabled() - def promotableAttributeNames( self, queryPath='/', blackListed=None ): - if not blackListed: - blackListed = [] - - queryScene = self.__sceneInterfaceFromQueryPath( queryPath ) - if not queryScene: - return [] - - attrNames = queryScene.attributeNames() - - promotableAttrs = list() - for attrName in attrNames: - mayaAttrName = str( IECoreMaya.LiveScene.toMayaAttributeName( attrName ) ) - if not mayaAttrName or mayaAttrName in blackListed: - continue - - if self.__cortexTypeToMayaType( queryScene, attrName ): - promotableAttrs.append( attrName ) - - return promotableAttrs - - @IECoreMaya.UndoFlush() - ## Promotes an attribute from the sceneInterface onto a maya plug. - # \param attributeName Name of the attribute to promote - # \param queryPath Scene path from which to promote the attribute. Defaults to root ('/'). - # \param mayaAttributeName Name of the maya plug onto which the attribute should be promoted. If not supplied, - # defaults to the mapping specified in LiveScene - # \param keyable Should the maya plug be keyable. Defaults to keyable so that the value appears in the channel box. - def promoteAttribute( self, attributeName, queryPath='/', nodePath='', mayaAttributeName='', keyable=True ): - # Check the validity of the queryPath - queryScene = self.__sceneInterfaceFromQueryPath( queryPath ) - if not queryScene: - IECore.msg( IECore.Msg.Level.Warning, 'FnSceneShape.promoteAttribute', 'Unable to promote attribute "{}". "{}" in an invalid scene.'.format( attributeName, self.fullPathName() + queryPath ) ) - return - - # Check the validity of the attribute - if attributeName not in self.promotableAttributeNames( queryPath ): - IECore.msg( IECore.Msg.Level.Warning, 'FnSceneShape.promoteAttribute', '"{}" is not a promotable attribute of "{}".'.format( attributeName, self.fullPathName() + queryPath ) ) - return - - # The path and attribute exist, construct the appropriate query plugs on the SceneShape - queryPathIndex = self.__queryIndexForPath( queryPath ) - queryAttributeIndex = self.__queryIndexForAttribute( attributeName ) - attributePlugName = self.fullPathName() + '.attributes[{}].attributeValues[{}]'.format( queryPathIndex, queryAttributeIndex ) - - # Create the output plugs for the promoted attributes - # This will effectively override the attribute when viewed from LiveScene - if nodePath: - if maya.cmds.objExists( nodePath ): - nodePath = maya.cmds.ls( nodePath, long=True )[0] - else: - IECore.msg( IECore.Msg.Level.Warning, 'FnSceneShape.promoteAttribute', 'Unable to promote attribute "{0}" onto "{1}". "{1}" does not exist.'.format( attributeName, nodePath ) ) - return - else: - nodePath = maya.cmds.listRelatives( self.fullPathName(), parent=True, fullPath=True )[0] - - node = IECoreMaya.StringUtil.dependencyNodeFromString( nodePath ) - - if not mayaAttributeName: - mayaAttributeName = str( IECoreMaya.LiveScene.toMayaAttributeName( attributeName ) ) - - mayaAttributeType = self.__cortexTypeToMayaType( queryScene, attributeName ) - - dgMod = maya.OpenMaya.MDGModifier() - - if not maya.cmds.objExists( nodePath + '.' + mayaAttributeName ): - if mayaAttributeType.namespace == maya.OpenMaya.MFnData: - tAttr = maya.OpenMaya.MFnTypedAttribute() - attr = tAttr.create( mayaAttributeName, mayaAttributeName, mayaAttributeType.type ) - dgMod.addAttribute( node, attr ) - elif mayaAttributeType.namespace == maya.OpenMaya.MFnNumericData: - nAttr = maya.OpenMaya.MFnNumericAttribute() - attr = nAttr.create( mayaAttributeName, mayaAttributeName, mayaAttributeType.type ) - nAttr.setKeyable( keyable ) - dgMod.addAttribute( node, attr ) - else: - # Should not reach this line because we already checked if attributeName is a promotable attribute - IECore.msg( - IECore.Msg.Level.Warning, - 'FnSceneShape.promoteAttribute', - 'Unable to promote attribute "{}". Could not determine the attribute type of the plug to create on "{}".'.format( attributeName, nodePath ) - ) - return - - dgMod.doIt() - - # Connect the output plug to the promoted plug - dgMod.connect( IECoreMaya.StringUtil.plugFromString( attributePlugName ), IECoreMaya.StringUtil.plugFromString( nodePath + '.' + mayaAttributeName ) ) - dgMod.doIt() - - return mayaAttributeName - - ## Returns the maya node type that this function set operates on - @classmethod - def _mayaNodeType( cls ): - return "ieSceneShape" - - -# A derived function set for operating on the IECoreMaya::SceneShapeProxy type. -# It inherits all functionality from the base clase and we only override the `_mayaNodeType` method. -# This object is used in the __new__ method of FnSceneShape to create the correct object depending -# on the passed in node type -class _FnSceneShapeProxy( FnSceneShape ) : - - # Returns the maya node type that this function set operates on - @classmethod - def _mayaNodeType( cls ): - return "ieSceneShapeProxy" diff --git a/python/IECoreMaya/FnTransientParameterisedHolderNode.py b/python/IECoreMaya/FnTransientParameterisedHolderNode.py deleted file mode 100644 index 6508b83266..0000000000 --- a/python/IECoreMaya/FnTransientParameterisedHolderNode.py +++ /dev/null @@ -1,91 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import maya.OpenMaya -import maya.cmds -import IECoreMaya -from . import _IECoreMaya -from . import StringUtil - -class FnTransientParameterisedHolderNode( IECoreMaya.FnParameterisedHolder ) : - - def __init__( self, object ) : - - IECoreMaya.FnParameterisedHolder.__init__( self, object ) - - ## Creates a temporary TransientParameterisedHolderNode in order to present the UI for the specified - # parameterised object in the given layout. The node is automatically deleted when the holding - # layout is destroyed. Returns a FnTransientParameterisedHolderNode object operating on the new node. - @staticmethod - def create( layoutName, classNameOrParameterised, classVersion=None, envVarName=None ) : - - with IECoreMaya.UndoDisabled() : - - nodeName = maya.cmds.createNode( "ieTransientParameterisedHolderNode", skipSelect = True ) - - # Script jobs aren't available from maya.cmds. Maya Python bindings generate swig warnings - # such as "swig/python detected a memory leak of type 'MCallbackId *', no destructor found" - maya.mel.eval( 'scriptJob -uiDeleted "%s" "python( \\\"import IECoreMaya; IECoreMaya.FnTransientParameterisedHolderNode._deleteNode( \'%s\' )\\\" )" -protected' % ( layoutName, nodeName ) ) - - fnTPH = FnTransientParameterisedHolderNode( nodeName ) - - if isinstance( classNameOrParameterised, str ) : - fnTPH.setParameterised( classNameOrParameterised, classVersion, envVarName ) - else : - assert( not classVersion ) - assert( not envVarName ) - - fnTPH.setParameterised( classNameOrParameterised ) - - parameterised = fnTPH.getParameterised()[0] - - if parameterised : - maya.cmds.setParent( layoutName ) - IECoreMaya.ParameterUI.create( fnTPH.fullPathName(), parameterised.parameters() ) - maya.cmds.setParent( layoutName ) - - return fnTPH - - @staticmethod - def _deleteNode( nodeName ) : - - with IECoreMaya.UndoDisabled() : - - if maya.cmds.objExists( nodeName ) : - maya.cmds.delete( nodeName ) - - - diff --git a/python/IECoreMaya/GenericParameterUI.py b/python/IECoreMaya/GenericParameterUI.py deleted file mode 100644 index 9101cf81c2..0000000000 --- a/python/IECoreMaya/GenericParameterUI.py +++ /dev/null @@ -1,235 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.mel - -import IECore -import IECoreMaya.ParameterUI -import IECoreMaya.StringUtil - -class GenericParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.rowLayout( - numberOfColumns = 2, - columnWidth2 = [ self.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex * 3 + 25 + 25 ] - ), - **kw - - ) - - maya.cmds.text( label = self.label(), font="smallPlainLabelFont", align="right", annotation=self.description() ) - - self.__connectionsLayout = maya.cmds.columnLayout() - maya.cmds.setParent( ".." ) - - maya.cmds.setParent( ".." ) - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - self.__updateDisplay() - - self.__attributeChangedCallbackId = IECoreMaya.CallbackId( - maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.node(), self.__attributeChanged ) - ) - - def _topLevelUIDeleted( self ) : - - self.__attributeChangedCallbackId = None - - def _popupMenuDefinition( self, **kw ) : - - definition = IECoreMaya.ParameterUI._popupMenuDefinition( self, **kw ) - - acceptedConnectionTypes = None - with IECore.IgnoredExceptions( KeyError ) : - acceptedConnectionTypes = list( self.parameter.userData()["UI"]["acceptedNodeTypes"] ) - - if acceptedConnectionTypes : - nodeNames = maya.cmds.ls( long=True, type=acceptedConnectionTypes ) - if nodeNames : - definition.append( "/ConnectionsDivider", { "divider" : True } ) - for nodeName in nodeNames : - definition.append( "/Connect To/%s" % nodeName, { "command" : IECore.curry( self.__connectToNode, nodeName ) } ) - - return definition - - def __attributeChanged( self, changeType, plug, otherPlug, userData ) : - - if not ( - ( changeType & maya.OpenMaya.MNodeMessage.kConnectionMade ) - or ( changeType & maya.OpenMaya.MNodeMessage.kConnectionBroken ) - ) : - return - - try : - myPlug = self.plug() - except : - # this situation can occur when our parameter has been removed but the - # ui we represent is not quite yet dead - return - - if plug == myPlug : - maya.cmds.evalDeferred( self.__updateDisplay ) - - def __updateDisplay( self ) : - - if not maya.cmds.layout( self.__connectionsLayout, query=True, exists=True ) : - return - - currentParent = maya.cmds.setParent( query=True ) - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - plugPath = fnPH.parameterPlugPath( self.parameter ) - - connections = maya.cmds.listConnections( plugPath, source=True, plugs=True, skipConversionNodes=True ) - numConnections = 0 - if connections : - numConnections = len( connections ) - - old = maya.cmds.columnLayout( self.__connectionsLayout, query=True, childArray=True ) - if old : - for child in old : - maya.cmds.deleteUI( child ) - - maya.cmds.setParent( self.__connectionsLayout ) - - if numConnections == 0 : - - maya.cmds.rowLayout( - numberOfColumns = 2, - columnWidth2 = [ IECoreMaya.ParameterUI.singleWidgetWidthIndex * 3 - 40, 20 ], - ) - - text = maya.cmds.text( align="left", label="Not connected", font="tinyBoldLabelFont" ) - self._addPopupMenu( parentUI=text, attributeName = self.plugName() ) - self._addPopupMenu( parentUI=text, attributeName = self.plugName(), button1=True ) - - maya.cmds.iconTextButton( - annotation = "Clicking this takes you the connection editor for this connection.", - style = "iconOnly", - image = "viewList.xpm", - font = "boldLabelFont", - command = IECore.curry( self.__connectionEditor, leftHandNode = None ), - height = 20, - width = 20 - ) - - maya.cmds.setParent( ".." ) - - else : - - for i in range( numConnections ) : - - self.__drawConnection( connections[i] ) - - - maya.cmds.setParent( currentParent ) - - def __drawConnection( self, plugName ) : - - fieldWidth = IECoreMaya.ParameterUI.singleWidgetWidthIndex * 3 - 40 - - maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ fieldWidth , 20, 20 ] - ) - - name = maya.cmds.text( l=plugName, font="tinyBoldLabelFont", align="left", - width=fieldWidth, height = 20, ann=plugName ) - - self._addPopupMenu( parentUI=name, attributeName = self.plugName() ) - self._addPopupMenu( parentUI=name, attributeName = self.plugName(), button1=True ) - - maya.cmds.iconTextButton( - annotation = "Clicking this takes you the connection editor for this connection.", - style = "iconOnly", - image = "viewList.xpm", - font = "boldLabelFont", - command = IECore.curry( self.__connectionEditor, leftHandNode = plugName ), - height = 20, - width = 20 - ) - - maya.cmds.iconTextButton( - annotation = "Clicking this will take you to the node sourcing this connection.", - style = "iconOnly", - image = "navButtonConnected.xpm", - command = IECore.curry( self.__showEditor, plugName ), - height = 20, - ) - - maya.cmds.setParent( ".." ) - - def __connectionEditor( self, leftHandNode ) : - - maya.mel.eval( - - str( "ConnectionEditor;" + - "nodeOutliner -e -replace %(right)s connectWindow|tl|cwForm|connectWindowPane|rightSideCW;"+ - "connectWindowSetRightLabel %(right)s;") % { 'right' : self.nodeName() } - - ) - - if leftHandNode : - - maya.mel.eval( - - str("nodeOutliner -e -replace %(left)s connectWindow|tl|cwForm|connectWindowPane|leftSideCW;"+ - "connectWindowSetLeftLabel %(left)s;" ) % { 'left' : leftHandNode.split(".")[0] } - - ) - - def __showEditor( self, attributeName ) : - - maya.mel.eval( 'showEditor "' + IECoreMaya.StringUtil.nodeFromAttributePath( attributeName ) + '"' ) - - def __connectToNode( self, nodeName ) : - - maya.cmds.connectAttr( nodeName + ".message", self.plugName(), force=True ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Parameter, GenericParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Parameter, GenericParameterUI, 'generic' ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.StringParameter, GenericParameterUI, 'generic' ) diff --git a/python/IECoreMaya/GeometryCombinerUI.py b/python/IECoreMaya/GeometryCombinerUI.py deleted file mode 100644 index e19ddf16c0..0000000000 --- a/python/IECoreMaya/GeometryCombinerUI.py +++ /dev/null @@ -1,134 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import maya.cmds - -import IECore -import IECoreMaya - -# we don't want to export anything, we just want to register callbacks -__all__ = [] - -def __geometryCombiner( plugPath, createIfMissing=False ) : - - connections = maya.cmds.listConnections( plugPath, source=True, destination=False, type="ieGeometryCombiner" ) - - if connections : - return connections[0] - - if not createIfMissing : - return "" - - result = maya.cmds.createNode( "ieGeometryCombiner", skipSelect=True ) - maya.cmds.connectAttr( result + ".outputGroup", plugPath, force=True ) - maya.cmds.setAttr( result + ".convertPrimVars", 1 ) - maya.cmds.setAttr( result + ".convertBlindData", 1 ) - - return result - -def __selectedGeometry() : - - return maya.cmds.ls( selection=True, type=( "mesh", "nurbsCurve" ), noIntermediate=True, leaf=True, dag=True ) - -def __addSelected( plugPath ) : - - selection = __selectedGeometry() - if not selection : - return - - combiner = __geometryCombiner( plugPath, createIfMissing=True ) - existingInputs = __inputGeometry( plugPath ) - - for s in selection : - - if s in existingInputs : - continue - - if maya.cmds.nodeType( s )=="mesh" : - maya.cmds.connectAttr( s + ".worldMesh", combiner + ".inputGeometry", nextAvailable=True, force=True ) - if maya.cmds.nodeType( s )=="nurbsCurve" : - maya.cmds.connectAttr( s + ".worldSpace", combiner + ".inputGeometry", nextAvailable=True, force=True ) - -def __inputGeometry( plugPath, plugs=False ) : - - combiner = __geometryCombiner( plugPath ) - if not combiner : - return [] - - connections = maya.cmds.listConnections( combiner + ".inputGeometry", source=True, destination=False, shapes=True, plugs=plugs ) - if connections is None : - return [] - else : - return connections - -def __removeSelected( plugPath ) : - - combiner = __geometryCombiner( plugPath ) - if not combiner : - return - - inputPlugs = __inputGeometry( plugPath, plugs=True ) - inputNodes = [ IECoreMaya.StringUtil.nodeFromAttributePath( x ) for x in inputPlugs ] - - for s in __selectedGeometry() : - i = -1 - with IECore.IgnoredExceptions( ValueError ) : - i = inputNodes.index( s ) - if s != -1 : - maya.cmds.disconnectAttr( inputPlugs[i], combiner + ".inputGeometry", nextAvailable=True ) - -def __select( plugPath ) : - - maya.cmds.select( __inputGeometry( plugPath ), replace=True ) - -def __menuCallback( definition, parameter, node ) : - - active = False - with IECore.IgnoredExceptions( KeyError ) : - active = parameter.userData()["maya"]["useGeometryCombiner"].value - - if not active : - return - - definition.append( "/InputGeometryDivider", { "divider" : True } ) - - plugPath = IECoreMaya.FnParameterisedHolder( node ).parameterPlugPath( parameter ) - - definition.append( "/Input Geometry/Add Selected", { "command" : IECore.curry( __addSelected, plugPath ) } ) - definition.append( "/Input Geometry/Remove Selected", { "command" : IECore.curry( __removeSelected, plugPath ) } ) - definition.append( "/Input Geometry/Select", { "command" : IECore.curry( __select, plugPath ) } ) - -IECoreMaya.ParameterUI.registerPopupMenuCallback( __menuCallback ) diff --git a/python/IECoreMaya/LineSegmentParameterUI.py b/python/IECoreMaya/LineSegmentParameterUI.py deleted file mode 100644 index a24230e68c..0000000000 --- a/python/IECoreMaya/LineSegmentParameterUI.py +++ /dev/null @@ -1,118 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class LineSegmentParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.columnLayout(), **kw ) - - self.__fields = [] - - self.__dim = parameter.getTypedValue().dimensions() - - plug = self.plug() - for childIndex in range( 0, 2 ) : - - if self.__dim == 2: - maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - elif self.__dim == 3: - maya.cmds.rowLayout( - numberOfColumns = 4, - columnWidth4 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - else: - raise RuntimeError( "Unsupported vector dimension in LineSegmentParameterUI" ) - - parameterLabel = self.label() - if childIndex==0 : - parameterLabel = parameterLabel + "Start" - else: - parameterLabel = parameterLabel + "End" - - maya.cmds.text( - label = parameterLabel, - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - vectorPlug = plug.child( childIndex ) - - for i in range( 0, self.__dim ) : - - self.__fields.append( self.__fieldType()() ) - - maya.cmds.setParent("..") - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - fieldNum = 0 - plug = self.plug() - for childIndex in range( 0, 2 ) : - - vectorPlug = plug.child( childIndex ) - for i in range( 0, self.__dim ) : - - vectorPlugChild = vectorPlug.child( i ) - vectorPlugChildName = self.nodeName() + "." + vectorPlugChild.partialName() - maya.cmds.connectControl( self.__fields[ fieldNum ], vectorPlugChildName ) - self._addPopupMenu( parentUI = self.__fields[fieldNum], attributeName = vectorPlugChildName ) - - fieldNum += 1 - - def __fieldType( self ): - - if self.parameter.isInstanceOf( IECore.TypeId.Box2iParameter ) or self.parameter.isInstanceOf( IECore.TypeId.Box3iParameter ): - return maya.cmds.intField - else: - return maya.cmds.floatField - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.LineSegment3fParameter, LineSegmentParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.LineSegment3dParameter, LineSegmentParameterUI ) - diff --git a/python/IECoreMaya/ManipulatorUI.py b/python/IECoreMaya/ManipulatorUI.py deleted file mode 100644 index e80c242657..0000000000 --- a/python/IECoreMaya/ManipulatorUI.py +++ /dev/null @@ -1,102 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import IECore -import IECoreMaya - -import maya.cmds - -## The ManipulatorUI functions add a 'Manipulate' menu item to a parameter's -## context menu if a suitable manipulator type is registered. -## Suitable types are nodes registered with the classification: -## 'ieParameterManipulator', and a name that matches the convention -## ieParameterManipulator -## \see IECoreMaya::ParameterisedHolderManipContext -## \see IECoreMaya::ParameterisedHolderManipContextCommand - -__all__ = [ 'manipulateParameter' ] - -def __manupulateMenuModifier( menuDefinition, parameter, node, parent=None ) : - - with IECore.IgnoredExceptions( KeyError ) : - if not parameter.userData()['UI']['disableManip'].value : - return - - typeHint = "" - with IECore.IgnoredExceptions( KeyError ) : - typeHint = parameter.userData()['UI']['manipTypeHint'].value - - parameterManip = "ie%s%sManipulator" % ( typeHint, parameter.staticTypeName() ) - - if parameterManip not in maya.cmds.listNodeTypes( 'ieParameterManipulator' ) : - return - - if len( list(menuDefinition.items()) ): - menuDefinition.append( "/ManipulateDivider", { "divider" : True } ) - - menuDefinition.append( - "/Manipulate...", - { - "command" : IECore.curry( manipulateParameter, node, parameter ), - } - ) - -IECoreMaya.ParameterUI.registerPopupMenuCallback( __manupulateMenuModifier ) - -## Starts manipulation of the specified node and parameter,. -## \param node MObject or str. A parameterisedHolder node. -## \param parameter IECore.Parameter the parameter to manipulate -## \param contextName An optional context to use, if multiple manipulators -## need controlling simultaneously. -## If there is no manipulator registered for the specified parameter, -## the tool will be activated but no manipulator will show. -def manipulateParameter( node, parameter, contextName="ieParameterManipulatorContext" ) : - - fnPH = IECoreMaya.FnParameterisedHolder( node ) - plugPath = fnPH.parameterPlugPath( parameter ) - - if not maya.cmds.contextInfo( contextName, exists=True ) : - maya.cmds.ieParameterisedHolderManipContext( contextName ) - - maya.cmds.ieParameterisedHolderManipContext( - contextName, - edit=True, - mode="targeted", - targetPlug=plugPath.split(".")[-1] - ) - - maya.cmds.setToolTo( contextName ) - diff --git a/python/IECoreMaya/MayaTypeId.py b/python/IECoreMaya/MayaTypeId.py deleted file mode 100644 index cb99347530..0000000000 --- a/python/IECoreMaya/MayaTypeId.py +++ /dev/null @@ -1,51 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.OpenMaya -from . import _IECoreMaya - -class _MayaTypeIdMeta(type): - - def __getattr__( self, n ) : - - if not hasattr( _IECoreMaya._MayaTypeId, n ) : - - raise RuntimeError( "MayaTypeId '" + str(n) + "' has not been bound" ) - - return maya.OpenMaya.MTypeId( getattr( _IECoreMaya._MayaTypeId, n ) ) - -class MayaTypeId( metaclass = _MayaTypeIdMeta ) : - - pass - diff --git a/python/IECoreMaya/Menu.py b/python/IECoreMaya/Menu.py deleted file mode 100644 index ab60980115..0000000000 --- a/python/IECoreMaya/Menu.py +++ /dev/null @@ -1,181 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## -import functools -import maya.cmds -import maya.mel - -import IECore - -from .UIElement import UIElement - -## A class for making maya menus from an IECore.MenuDefinition. The menu is built dynamically when it's -# displayed, so the definition can be edited at any time to change the menu. -class Menu( UIElement ) : - - # Creates a menu defined by the specified definition. parent may be a - # window (in which case the menu is added to the menu bar), a menu (in which case a submenu is created) - # or a control (in which case a popup menu is created). The optional keyword arguments operate as follows : - # - # label : - # specifies a label for the submenu (if the parent is a menu) or menubar item (if the parent is a window). - # - # insertAfter : - # specifies the menu item the submenu should be inserted after (if the parent is a menu). - # - # radialPosition : - # specifies the radial position of the submenu (if the parent is a marking menu). - # - # button : - # specifies the mouse button which may be used to raise a popup menu, in the same format as - # expected by the maya.cmds.popupMenu() command. - # - # replaceExistingMenu : - # determines whether we add the menu as a submenu, or overwrite the contents of the existing menu - # (if the parent is a menu) - # - # keepCallback : - # For use in cases where we want to extend an existing menu without overriding the postMenu callback. - # Overriding the callback can break Maya in specific cases, such as the VP right click context menu. - def __init__( self, definition, parent, label="", insertAfter=None, radialPosition=None, button = 3, replaceExistingMenu = False, keepCallback=False ) : - - if maya.cmds.window( parent, query=True, exists=True ) or maya.cmds.menuBarLayout( parent, query=True, exists=True ) : - # parent is a window - we're sticking it in the menubar - menu = maya.cmds.menu( label=label, parent=parent, allowOptionBoxes=True, tearOff=True ) - elif maya.cmds.menu( parent, query=True, exists=True ) : - if keepCallback: - menu = parent - elif replaceExistingMenu : - # parent is a menu - we're appending to it: - menu = parent - self.__postMenu( menu, definition ) - else : - # parent is a menu - we're adding a submenu - kw = {} - if not (insertAfter is None) : - kw["insertAfter"] = insertAfter - if radialPosition : - kw["radialPosition"] = radialPosition - menu = maya.cmds.menuItem( label=label, parent=parent, tearOff=True, subMenu=True, allowOptionBoxes=True, **kw ) - else : - # assume parent is a control which can accept a popup menu - menu = maya.cmds.popupMenu( parent=parent, button=button, allowOptionBoxes=True ) - - UIElement.__init__( self, menu ) - - if not keepCallback: - maya.cmds.menu( menu, edit=True, postMenuCommand=functools.partial( self.__postMenu, menu, definition ) ) - else: - self._parseDefinition(parent, definition) - - def _parseDefinition( self, parent, definition ): - - if callable( definition ) : - definition = definition() - - if not isinstance( definition, IECore.MenuDefinition ): - raise IECore.Exception( "Definition is not a valid IECore.MenuDefinition object." ) - - allPaths = list(dict(definition.items()).keys()) - rootItemDefinitions = IECore.MenuDefinition( [] ) - - # scan definition once and get root item definitions - for path, item in definition.items(): - strippedPath = path.strip('/') - if '/' not in strippedPath: - rootItemDefinitions.append(path, item) - continue - - # Implicit root needed, create root item definition - superPath = "/{}".format(strippedPath.split("/")[0]) - if not superPath in allPaths: - rootItemDefinitions.append(superPath, {}) - - # iterate root definitions and create menu items - for path, item in rootItemDefinitions.items(): - name = path.strip('/') - - # merge items referencing this root item in their path string - subMenuDefinition = definition.reRooted("/" + name + "/") - if subMenuDefinition.size(): - if item.subMenu: - if callable(item.subMenu): - # force retrival of definition object now so we can merge menu items - item.subMenu = item.subMenu() - item.subMenu.update(subMenuDefinition) - else: - item.subMenu = subMenuDefinition - - # get Maya keyword args - kw = {} - - if getattr(item, "bold", False): - kw["boldFont"] = True - - if getattr(item, "italic", False): - kw["italicized"] = True - - if getattr(item, "blindData", {}): - mayaArgs = item.blindData.get("maya", {}) - kw.update(mayaArgs) - - # create UI - if item.divider: - menuItem = maya.cmds.menuItem(parent=parent, divider=True) - elif item.subMenu: - subMenu = maya.cmds.menuItem(label=name, subMenu=True, allowOptionBoxes=True, parent=parent, **kw) - maya.cmds.menu(subMenu, edit=True, postMenuCommand=functools.partial(self.__postMenu, subMenu, item.subMenu)) - else: - active = item.active - if callable(active): - active = active() - - checked = item.checkBox - if callable(checked): - checked = checked() - kw["checkBox"] = checked - - menuItem = maya.cmds.menuItem(label=name, parent=parent, enable=active, annotation=item.description, **kw) - if item.command: - maya.cmds.menuItem(menuItem, edit=True, command=self.__wrapCallback(item.command)) - if item.secondaryCommand: - optionBox = maya.cmds.menuItem(optionBox=True, enable=active, command=self.__wrapCallback(item.secondaryCommand), parent=parent) - - def __wrapCallback( self, cb ) : - - return self._createCallback( cb ) if callable( cb ) else cb - - def __postMenu( self, parent, definition, *args ) : - - maya.cmds.menu( parent, edit = True, deleteAllItems = True ) - self._parseDefinition( parent, definition ) diff --git a/python/IECoreMaya/Menus.py b/python/IECoreMaya/Menus.py deleted file mode 100644 index 3c9ec435cb..0000000000 --- a/python/IECoreMaya/Menus.py +++ /dev/null @@ -1,102 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011-2018, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os - -import maya.cmds - -import IECore -import IECoreMaya - -## \addtogroup environmentGroup -# -# IECOREMAYA_DISABLE_MAIN_MENU -# Set this to a value of 1 to disable the creation of the Cortex main menu -# in Maya. You can then use the helper functions in IECoreMaya.Menus -# to build your own site-specific menu structure. - -__cortexMenus = {} - -def createMenu( label, definition, parent ) : - - global __cortexMenus - __cortexMenus[label] = ( definition, IECoreMaya.Menu( definition, parent, label )._topLevelUI() ) - -def definition( label ) : - - global __cortexMenus - return __cortexMenus.get( label, [ None ] )[0] - -def createCortexMenu() : - - if os.environ.get( "IECOREMAYA_DISABLE_MAIN_MENU", "0" ) == "1" : - return - - m = IECore.MenuDefinition() - - m.append( - "/Create Op", - { - "subMenu" : opCreationMenuDefinition, - } - ) - - createMenu( "Cortex", m, "MayaWindow" ) - -def removeCortexMenu() : - - global __cortexMenus - if "Cortex" in __cortexMenus : - maya.cmds.deleteUI( __cortexMenus["Cortex"][1] ) - del __cortexMenus["Cortex"] - -def __createOp( className ) : - - fnOH = IECoreMaya.FnOpHolder.create( os.path.basename( className ), className ) - maya.cmds.select( fnOH.fullPathName() ) - -def opCreationMenuDefinition() : - - m = IECore.MenuDefinition() - loader = IECore.ClassLoader.defaultOpLoader() - for className in loader.classNames() : - m.append( - "/" + className, - { - "command" : IECore.curry( __createOp, className ), - } - ) - - return m - diff --git a/python/IECoreMaya/MeshOpHolderUtil.py b/python/IECoreMaya/MeshOpHolderUtil.py deleted file mode 100644 index f5ddffa968..0000000000 --- a/python/IECoreMaya/MeshOpHolderUtil.py +++ /dev/null @@ -1,382 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.OpenMaya as OpenMaya -import maya.cmds as cmds - -import IECoreMaya -import IECore - -def __getFloat3PlugValue(plug): - - # Retrieve the value as an MObject - object = plug.asMObject() - - # Convert the MObject to a float3 - numDataFn = OpenMaya.MFnNumericData(object) - xParam = OpenMaya.MScriptUtil() - xParam.createFromDouble(0.0) - xPtr = xParam.asFloatPtr() - yParam = OpenMaya.MScriptUtil() - yParam.createFromDouble(0.0) - yPtr = yParam.asFloatPtr() - zParam = OpenMaya.MScriptUtil() - zParam.createFromDouble(0.0) - zPtr = zParam.asFloatPtr() - numDataFn.getData3Float(xPtr, yPtr, zPtr) - return OpenMaya.MFloatVector( - OpenMaya.MScriptUtil(xPtr).asFloat(), - OpenMaya.MScriptUtil(yPtr).asFloat(), - OpenMaya.MScriptUtil(zPtr).asFloat() - ) - -def __hasTweaks( meshDagPath ): - - fnDN = OpenMaya.MFnDependencyNode( meshDagPath.node() ) - - # Tweaks exist only if the multi "pnts" attribute contains plugs - # which contain non-zero tweak values. - tweakPlug = fnDN.findPlug("pnts") - if not tweakPlug.isNull(): - - if not tweakPlug.isArray(): - raise RuntimeError( "tweakPlug is not an array plug" ) - - numElements = tweakPlug.numElements() - for i in range(numElements): - tweak = tweakPlug.elementByPhysicalIndex(i) - if not tweak.isNull(): - tweakData = __getFloat3PlugValue(tweak) - if 0 != tweakData.x or 0 != tweakData.y or 0 != tweakData.z: - return True - - return False - -def __hasHistory( meshDagPath ): - - fnDN = OpenMaya.MFnDependencyNode( meshDagPath.node() ) - - return fnDN.findPlug("inMesh").isConnected() - -def __processUpstreamNode(data, meshDagPath, dgModifier): - - if __hasHistory( meshDagPath ): - # Just swap the connections around - tempPlugArray = OpenMaya.MPlugArray() - data.meshNodeDestPlug.connectedTo(tempPlugArray, True, False) - assert( tempPlugArray.length() == 1 ) - - data.upstreamNodeSrcPlug = OpenMaya.MPlug( tempPlugArray[0] ) - - data.upstreamNodeShape = data.upstreamNodeSrcPlug.node() - - data.upstreamNodeSrcAttr = data.upstreamNodeSrcPlug.attribute() - - dgModifier.disconnect(data.upstreamNodeSrcPlug, data.meshNodeDestPlug) - dgModifier.doIt() - - else: - # Duplicate mesh, mark as "intermediate", and reconnect in the DAG - dagNodeFn = OpenMaya.MFnDagNode( data.meshNodeShape ) - meshNodeShapeName = dagNodeFn.name() - - data.upstreamNodeTransform = dagNodeFn.duplicate(False, False) - dagNodeFn.setObject(data.upstreamNodeTransform) - - fDagModifier = OpenMaya.MDagModifier() - - if dagNodeFn.childCount() < 1: - raise RuntimeError( "Duplicated mesh has no shape" ) - - data.upstreamNodeShape = dagNodeFn.child(0) - - fDagModifier.reparentNode(data.upstreamNodeShape, data.meshNodeTransform) - fDagModifier.renameNode( data.upstreamNodeShape, meshNodeShapeName+"Orig" ) - fDagModifier.doIt() - - dagNodeFn.setObject(data.upstreamNodeShape) - dagNodeFn.setIntermediateObject(True) - - data.upstreamNodeSrcAttr = dagNodeFn.attribute("outMesh") - data.upstreamNodeSrcPlug = dagNodeFn.findPlug("outMesh") - - fDagModifier.deleteNode(data.upstreamNodeTransform) - fDagModifier.doIt() - -def __processTweaks(data, dgModifier, modifierNode): - - tweakIndexArray = OpenMaya.MIntArray() - - fnDN = OpenMaya.MFnDependencyNode() - - tweakDataArray = OpenMaya.MObjectArray() - tweakSrcConnectionCountArray = OpenMaya.MIntArray() - tweakSrcConnectionPlugArray = OpenMaya.MPlugArray() - tweakDstConnectionCountArray = OpenMaya.MIntArray() - tweakDstConnectionPlugArray = OpenMaya.MPlugArray() - tempPlugArray = OpenMaya.MPlugArray() - - tweakNode = dgModifier.createNode("polyTweak") - fnDN.setObject(tweakNode) - tweakNodeSrcAttr = fnDN.attribute("output") - tweakNodeDestAttr = fnDN.attribute("inputPolymesh") - tweakNodeTweakAttr = fnDN.attribute("tweak") - - fnDN.setObject(data.meshNodeShape) - meshTweakPlug = fnDN.findPlug("pnts") - - if not meshTweakPlug.isArray() : - raise RuntimeError( "meshTweakPlug is not an array plug" ) - - numElements = meshTweakPlug.numElements() - for i in range(numElements): - tweak = meshTweakPlug.elementByPhysicalIndex(i) - - if not tweak.isNull(): - - tweakIndexArray.append( tweak.logicalIndex() ) - - tweakData = tweak.asMObject() - tweakDataArray.append(tweakData) - - if not tweak.isCompound(): - raise RuntimeError( "Element tweak plug is not a compound" ) - - numChildren = tweak.numChildren() - for j in range(numChildren): - tweakChild = tweak.child(j) - if tweakChild.isConnected(): - - tempPlugArray.clear() - if tweakChild.connectedTo(tempPlugArray, False, True): - numSrcConnections = tempPlugArray.length() - tweakSrcConnectionCountArray.append(numSrcConnections) - - for k in range(numSrcConnections): - tweakSrcConnectionPlugArray.append(tempPlugArray[k]) - dgModifier.disconnect(tweakChild, tempPlugArray[k]) - else: - tweakSrcConnectionCountArray.append(0) - - tempPlugArray.clear() - if tweakChild.connectedTo(tempPlugArray, True, False): - assert( tempPlugArray.length() == 1 ) - - tweakDstConnectionCountArray.append(1) - tweakDstConnectionPlugArray.append(tempPlugArray[0]) - dgModifier.disconnect(tempPlugArray[0], tweakChild) - else: - tweakDstConnectionCountArray.append(0) - else: - tweakSrcConnectionCountArray.append(0) - tweakDstConnectionCountArray.append(0) - - polyTweakPlug = OpenMaya.MPlug(tweakNode, tweakNodeTweakAttr) - numTweaks = tweakIndexArray.length() - srcOffset = 0 - dstOffset = 0 - for i in range(numTweaks): - - tweak = polyTweakPlug.elementByLogicalIndex(tweakIndexArray[i]) - tweak.setMObject(tweakDataArray[i]) - - if not tweak.isCompound(): - raise RuntimeError( "Element plug 'tweak' is not a compound" ) - - numChildren = tweak.numChildren() - for j in range(numChildren): - tweakChild = tweak.child(j) - - if 0 < tweakSrcConnectionCountArray[i*numChildren + j]: - k = 0 - while (k < tweakSrcConnectionCountArray[i*numChildren + j]): - dgModifier.connect(tweakChild, tweakSrcConnectionPlugArray[srcOffset]) - srcOffset += 1 - k += 1 - - if 0 < tweakDstConnectionCountArray[i*numChildren + j]: - dgModifier.connect(tweakDstConnectionPlugArray[dstOffset], tweakChild) - dstOffset += 1 - - tweakDestPlug = OpenMaya.MPlug( tweakNode, tweakNodeDestAttr ) - dgModifier.connect( data.upstreamNodeSrcPlug, tweakDestPlug ) - - tweakSrcPlug = OpenMaya.MPlug( tweakNode, tweakNodeSrcAttr) - modifierDestPlug = OpenMaya.MPlug( modifierNode, data.modifierNodeDestAttr ) - dgModifier.connect( tweakSrcPlug, modifierDestPlug ) - -def __connectNodes( modifierNode, meshDagPath ): - class MeshOpHolderData: - def __init__(self): - self.meshNodeTransform = OpenMaya.MObject() - self.meshNodeShape = OpenMaya.MObject() - self.meshNodeDestPlug = OpenMaya.MPlug() - self.meshNodeDestAttr = OpenMaya.MObject() - - self.upstreamNodeTransform = OpenMaya.MObject() - self.upstreamNodeShape = OpenMaya.MObject() - self.upstreamNodeSrcPlug = OpenMaya.MPlug() - self.upstreamNodeSrcAttr = OpenMaya.MObject() - - self.modifierNodeSrcAttr = OpenMaya.MObject() - self.modifierNodeDestAttr = OpenMaya.MObject() - - data = MeshOpHolderData() - - fnDN = OpenMaya.MFnDependencyNode( modifierNode ) - data.modifierNodeSrcAttr = fnDN.attribute("result") - data.modifierNodeDestAttr = fnDN.attribute("parm_input") - - data.meshNodeShape = meshDagPath.node() - dagNodeFn = OpenMaya.MFnDagNode( data.meshNodeShape ) - - if dagNodeFn.parentCount() == 0: - raise RuntimeError( "Mesh shape has no parent transform" ) - - data.meshNodeTransform = dagNodeFn.parent(0) - data.meshNodeDestPlug = dagNodeFn.findPlug("inMesh") - data.meshNodeDestAttr = data.meshNodeDestPlug.attribute() - - dgModifier = OpenMaya.MDGModifier() - __processUpstreamNode(data, meshDagPath, dgModifier) - - if __hasTweaks( meshDagPath ): - __processTweaks(data, dgModifier, modifierNode) - else: - modifierDestPlug = OpenMaya.MPlug(modifierNode, data.modifierNodeDestAttr) - dgModifier.connect(data.upstreamNodeSrcPlug, modifierDestPlug) - - modifierSrcPlug = OpenMaya.MPlug(modifierNode, data.modifierNodeSrcAttr) - meshDestAttr = OpenMaya.MPlug(data.meshNodeShape, data.meshNodeDestAttr) - - dgModifier.connect(modifierSrcPlug, meshDestAttr) - - dgModifier.doIt() - -def __setParameters( op, kw ): - - for paramName, paramValue in kw.items(): - op.parameters().setValidatedParameterValue( paramName, paramValue ) - - -def __createMeshOpNode( className, classVersion, **kw ): - - shortClassName = className.split( '/' ).pop() - - modifierNodeName = cmds.createNode( "ieOpHolderNode", name = shortClassName + "#" ) - - ph = IECoreMaya.FnParameterisedHolder( modifierNodeName ) - op = ph.setParameterised( className, classVersion, "IECORE_OP_PATHS" ) - - __setParameters( op, kw ) - - selList = OpenMaya.MSelectionList() - selList.add( modifierNodeName ) - modifierNode = OpenMaya.MObject() - s = selList.getDependNode( 0, modifierNode ) - - return modifierNode - -def __applyMeshOp( meshNode, className, classVersion, kw ): - - op = IECore.ClassLoader.defaultOpLoader().load( className, classVersion ) - - __setParameters( op, **kw ) - - # \todo Apply op and convert result back into original object - - -def create( meshDagPath, className, classVersion, **kw): - - if type(meshDagPath) is str: - sel = OpenMaya.MSelectionList() - sel.add( meshDagPath ) - meshDagPath = OpenMaya.MDagPath() - sel.getDagPath( 0, meshDagPath) - meshDagPath.extendToShape() - - constructionHistoryEnabled = maya.mel.eval("constructionHistory -q -tgl") - - if not __hasHistory( meshDagPath ) and constructionHistoryEnabled == 0: - - # \todo we can't actually do this right now because we're unable to convert the resultant MeshPrimitive - # back into the original meshNode MObject given to us - raise RuntimeError( "Currently unable to apply MeshOp in-place " ) - - meshNode = meshDagPath.node() - - __applyMeshOp(meshNode, className, classVersion, **kw ) - - return None - else: - modifierNode = __createMeshOpNode( className, classVersion, **kw ) - - __connectNodes( modifierNode, meshDagPath ) - - fnDN = OpenMaya.MFnDependencyNode( modifierNode ) - - return str( fnDN.name() ) - - -def createUI( className, classVersion, **kw ): - - # \todo This below selection determination code fails with an unclear error if - # a mesh component is currently selected - selectedTransforms = cmds.ls( selection = True, type = "transform" ) or [] - selectedTransformMeshShapes = cmds.listRelatives( selectedTransforms, type = "mesh" ) or [] - - selectedMeshes = cmds.ls( selection = True, type = "mesh" ) or [] - selectedMeshes += selectedTransformMeshShapes - - if not selectedMeshes: - raise RuntimeError( "No mesh selected" ) - - modifierNodes = [] - - for mesh in selectedMeshes: - - sel = OpenMaya.MSelectionList() - sel.add( mesh ) - meshDagPath = OpenMaya.MDagPath() - sel.getDagPath( 0, meshDagPath) - meshDagPath.extendToShape() - - modifierNode = create( meshDagPath, className, classVersion, **kw ) - - if modifierNode : - - modifierNodes += [ modifierNode ] - - - return modifierNodes diff --git a/python/IECoreMaya/ModalDialogue.py b/python/IECoreMaya/ModalDialogue.py deleted file mode 100644 index 6152c3a542..0000000000 --- a/python/IECoreMaya/ModalDialogue.py +++ /dev/null @@ -1,99 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya -import maya.cmds - -## This class provides a useful base for implementing modal dialogues in an -# object oriented manner. -class ModalDialogue( IECoreMaya.UIElement ) : - - ## Derived classes should call the base class __init__ before constructing - # their ui. The result of self._topLevelUI() will be a form layout in which - # the ui should be constructed. Clients shouldn't construct ModalDialogues - # directly but instead use the run() method documented below. - def __init__( self ) : - - IECoreMaya.UIElement.__init__( self, maya.cmds.setParent( query=True ) ) - ModalDialogue.__returnObject = None; - - ## Should be called by derived classes when they wish to close their dialogue. - # The result will be returned to the caller of the run() method. This differs - # from the default maya behaviour for a layoutDialog, as we allow any python - # type to be returned. If the dialog is dismissed directly with the maya.cmd - # then that value will be returned instead. - def _dismiss( self, result ) : - - ModalDialogue.__returnObject = result - maya.cmds.layoutDialog( dismiss = 'ModalDialogueReturnObject' ) - - ## Call this method to open a dialogue - the return value is the object supplied - # by the derived class, or the string supplied to layoutDialog( dismiss=%s ) if - # called directly. If the string 'None', 'True', or 'False' is passed to a - # direct call, then the equivalent python object is returned instead of a string. - @classmethod - def run( cls, *args, **kwargs ) : - - ModalDialogue.__toInstantiate = cls - ModalDialogue.__calltimeArgs = args - ModalDialogue.__calltimeKwargs = kwargs - - title = maya.mel.eval( 'interToUI( "%s" )' % cls.__name__ ) - mayaResult = maya.cmds.layoutDialog( ui = 'import IECoreMaya; IECoreMaya.ModalDialogue._ModalDialogue__instantiate()', title = title ) - - if mayaResult == 'ModalDialogueReturnObject' : - - stopMeLeaking = ModalDialogue.__returnObject - ModalDialogue.__returnObject = None - return stopMeLeaking - - elif mayaResult == 'None' : - return None - - elif mayaResult == 'True' : - return True - - elif mayaResult == 'False' : - return False - - return mayaResult - - @classmethod - def __instantiate( cls ) : - - ModalDialogue.__currentDialogue = cls.__toInstantiate( *ModalDialogue.__calltimeArgs, **ModalDialogue.__calltimeKwargs ) - ModalDialogue.__calltimeArgs = None - ModalDialogue.__calltimeKwargs = None - diff --git a/python/IECoreMaya/NodeParameter.py b/python/IECoreMaya/NodeParameter.py deleted file mode 100644 index cd92e10533..0000000000 --- a/python/IECoreMaya/NodeParameter.py +++ /dev/null @@ -1,163 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -from maya.OpenMaya import * -import re - -""" -Parameter class for specifying Maya dependency nodes. -""" -class NodeParameter( IECore.StringParameter ): - - ## \todo Use Enum for this - class CheckType: - - DontCare = 0 - MustExist = 1 - MustNotExist = 2 - - """ - name - name of the parameter. - description - description of the parameter. - allowEmptyString - boolean that will accept the empty value even if the node should exist. - check - can be CheckType.DontCare, CheckType.MustExist or CheckType.MustNotExist. - typeRegex - regular expression used on parameter validation that validates based on the maya node type. Disable filtering using None. - typeRegexDescription - human readable description for the regular expression used to filter node types. It's used when the validation fails. - """ - def __init__( self, name, description, defaultValue = "", allowEmptyString = True, - check = CheckType.DontCare, typeRegex = None, typeRegexDescription = "", presets = {}, presetsOnly = False, userData = IECore.CompoundObject() ) : - - IECore.StringParameter.__init__( self, name, description, defaultValue, presets, presetsOnly, userData ) - - self.allowEmptyString = allowEmptyString - self.mustExist = bool( check == NodeParameter.CheckType.MustExist ) - self.mustNotExist = bool( check == NodeParameter.CheckType.MustNotExist ) - if typeRegex is None: - self.typeRegex = None - else: - self.typeRegex = re.compile( typeRegex ) - if typeRegexDescription == "": - self.typeRegexDesc = "Invalid type." - else: - self.typeRegexDesc = typeRegexDescription - - """ - Defines two attributes: mustExist and mustNotExist and allowEmptyString exactly like PathParameter class. - """ - def __getattr__( self, attrName ): - if attrName == "mustExist": - return self.__mustExist - elif attrName == "mustNotExist": - return self.__mustNotExist - elif attrName == "allowEmptyString": - return self.__allowEmptyString - else: - return self.__dict__[ attrName ] - - """ - Returns a regular expression that matches only valid Maya dependency nodes - """ - @staticmethod - def pathValidator(): - return re.compile( r"^(\|?[^\t\n\r\f\v|]+)+\|?$" ) - - """ - Returns (True, "") only if the value is a correct dependency nodestring and also checks that the node exists or doesn't exist - based on the CheckType passed to the constructor. - Otherwise returns (False, errorMessage). - """ - def valueValid( self, value ) : - - v = IECore.StringParameter.valueValid( self, value ) - if not v[0] : - return v - - if self.allowEmptyString and value.value=="" : - return True, "" - - if not self.pathValidator().match( value.value ) : - return False, "Not a valid Maya dependency node." - - list = MSelectionList () - try: - list.add( value.value ) - except: - exist = False - else: - exist = True - - try: - obj = MObject() - list.getDependNode( 0, obj ) - depNode = MFnDependencyNode( obj ) - except: - IECore.debugException("failed to instantiate MObject from", value.value ) - return False, "'%s' is not a dependency node" % value.value - - if not self.typeRegex is None: - nodeType = str(depNode.typeName()) - if self.typeRegex.match( nodeType ) is None: - return False, ("Type '%s' not accepted: " % nodeType) + self.typeRegexDesc - - if self.mustExist : - - if not exist: - return False, "Node %s does not exist" % value.value - - elif self.mustNotExist : - - if exist: - return False, "Node %s already exists" % value.value - - return True, "" - - """ - Sets the internal StringData value from the given dependency node MObject - """ - def setNodeValue( self, node ) : - self.setValue( IECore.StringData( MFnDependencyNode( node ).name() ) ) - - """ - Returns an MObject that corresponds to the dependency node of the current value. - """ - def getNodeValue( self ) : - nodeName = self.getValidatedValue().value - list = MSelectionList () - list.add( nodeName ) - obj = MObject() - list.getDependNode( 0, obj ) - return obj - -IECore.registerRunTimeTyped( NodeParameter ) diff --git a/python/IECoreMaya/NoteParameterUI.py b/python/IECoreMaya/NoteParameterUI.py deleted file mode 100644 index 5f5c4a3d59..0000000000 --- a/python/IECoreMaya/NoteParameterUI.py +++ /dev/null @@ -1,138 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -## A UI for a StringParameters that uses the "note" type hint. -# -# This is for displaying user annotations - -class NoteParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ): - - - IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.rowLayout( numberOfColumns = 3, columnWidth3 = [ 30, 300, 30 ] ), **kw ) - - self.__editWindow = "" - - maya.cmds.text( label = "" ) - - self.__label = maya.cmds.text( - font = "smallPlainLabelFont", - align = "left", - annotation = "Notes", - ) - - maya.cmds.iconTextButton( - label = "", - image = "ie_editTextIcon.xpm", - command = self._launchEditWindow, - height = 23, - style = "iconOnly" - ) - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - maya.cmds.text( - self.__label, - e = True, - label = str( parameter.getValue() ), - ) - - def _launchEditWindow( self ): - - if not maya.cmds.window( self.__editWindow, exists=True ): - - self.__editWindow = maya.cmds.window( - title = "Edit Annotation", - iconName = "Edit Annotation", - width = 400, - height = 500 - ) - - form = maya.cmds.formLayout(numberOfDivisions=100) - - button = maya.cmds.button( - label='Edit', - command = self._editText, - ) - - self.__textField = maya.cmds.scrollField( - editable = True, - height = 50, - wordWrap = True, - text = str( self.parameter.getValue() ), - ) - - maya.cmds.formLayout( - form, - edit=True, - attachForm=[(self.__textField, 'top', 5), (self.__textField, 'left', 5), (self.__textField, 'right', 5), (button, 'left', 5), (button, 'bottom', 5), (button, 'right', 5) ], - attachControl=[ ( self.__textField, 'bottom', 5, button ) ], - #attachPosition=[ ( self.__textField, 'right', 5, 75 ) ], - attachNone=(button, 'top'), - ) - - maya.cmds.showWindow( self.__editWindow ) - - def _editText( self, state ): - - newStr = maya.cmds.scrollField( - self.__textField, - q = True, - text = True, - ) - - self.parameter.setValue( IECore.StringData( newStr ) ) - - maya.cmds.deleteUI( self.__editWindow , window=True ) - - maya.cmds.text( - self.__label, - e = True, - label = str( self.parameter.getValue() ), - ) - - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.StringParameter, NoteParameterUI, "note" ) diff --git a/python/IECoreMaya/NumericParameterUI.py b/python/IECoreMaya/NumericParameterUI.py deleted file mode 100644 index 7486624787..0000000000 --- a/python/IECoreMaya/NumericParameterUI.py +++ /dev/null @@ -1,150 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class NumericParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - if parameter.hasMinValue() and parameter.hasMaxValue(): - - layout = maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.sliderWidgetWidthIndex ] - ) - - else: - - layout = maya.cmds.rowLayout( - numberOfColumns = 2, - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - - IECoreMaya.ParameterUI.__init__( self, node, parameter, layout, **kw ) - - self.__field = None - self.__slider = None - - maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - kw = {} - - if parameter.hasMinValue(): - kw['minValue'] = parameter.minValue - - if parameter.hasMaxValue(): - kw['maxValue'] = parameter.maxValue - - - # We set the step size on int parameters to 1, because otherwise Maya will throw warnings if the difference between - # the min and max is less than the default step of 1. - # However Maya also complains when you set the step size on parameters without a min or max, so we need to check that - # as well. - if ( parameter.hasMinValue() or parameter.hasMaxValue() ) and self.parameter.isInstanceOf( IECore.TypeId.IntParameter ): - kw['step'] = 1 - - - # \todo Add a way of overriding precision for both float and double parameters, giving - # each a sensible (and probably different) default - if self.parameter.isInstanceOf( IECore.TypeId.DoubleParameter ) : - - kw['precision'] = 12 - - if 'UI' in parameter.userData() : - - if self.parameter.isInstanceOf( IECore.TypeId.DoubleParameter ) or self.parameter.isInstanceOf( IECore.TypeId.FloatParameter ): - precision = parameter.userData()['UI'].get( "precision", None ) - - if isinstance( precision, IECore.IntData ): - kw['precision'] = precision.value - - self.__field = self.__fieldType()( - value = parameter.getNumericValue(), - **kw - ) - - if parameter.hasMinValue() and parameter.hasMaxValue(): - - self.__slider = self.__sliderType()( - minValue = parameter.minValue, - maxValue = parameter.maxValue, - - value = parameter.getNumericValue(), - ) - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - maya.cmds.connectControl( self.__field, self.plugName() ) - self._addPopupMenu( parentUI = self.__field, attributeName = self.plugName() ) - - if self.__slider: - maya.cmds.connectControl( self.__slider, self.plugName() ) - - def __sliderType( self ): - - if self.parameter.isInstanceOf( IECore.TypeId.FloatParameter ) or self.parameter.isInstanceOf( IECore.TypeId.DoubleParameter ): - return maya.cmds.floatSlider - elif self.parameter.isInstanceOf( IECore.TypeId.IntParameter ): - return maya.cmds.intSlider - else: - raise RuntimeError("Invalid parameter type for NumericParameterUI") - - def __fieldType( self ): - - if self.parameter.isInstanceOf( IECore.TypeId.FloatParameter ) or self.parameter.isInstanceOf( IECore.TypeId.DoubleParameter ): - return maya.cmds.floatField - elif self.parameter.isInstanceOf( IECore.TypeId.IntParameter ): - return maya.cmds.intField - else: - raise RuntimeError("Invalid parameter type for NumericParameterUI") - - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.FloatParameter, NumericParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.DoubleParameter, NumericParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.IntParameter, NumericParameterUI ) diff --git a/python/IECoreMaya/NumericVectorParameterUI.py b/python/IECoreMaya/NumericVectorParameterUI.py deleted file mode 100644 index 83ca307001..0000000000 --- a/python/IECoreMaya/NumericVectorParameterUI.py +++ /dev/null @@ -1,216 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class NumericVectorParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - topLevelUI = maya.cmds.columnLayout() - IECoreMaya.ParameterUI.__init__( self, node, parameter, topLevelUI, **kw ) - - self.__column = maya.cmds.columnLayout( parent=topLevelUI ) - - row = maya.cmds.rowLayout( - parent = topLevelUI, - numberOfColumns = 2, - columnAlign = ( 1, "right" ), - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - - maya.cmds.text( - parent = row, - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - addButton = maya.cmds.button( parent=row, label='Add Item', command=self._createCallback( self.__addItem ) ) - - self.__fields = [] - - self.__attributeChangedCallbackId = IECoreMaya.CallbackId( - maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.node(), self.__attributeChanged ) - ) - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - # disabling copy/paste from the ParameterClipboardUI as the results will be misleading to users - parameter.userData().update( NumericVectorParameterUI.__disableCopyPaste ) - - vector = maya.cmds.getAttr( self.plugName() ) or [] - - # delete un-needed fields - self.__fields = self.__fields[:len(vector)] - rows = maya.cmds.columnLayout( self.__column, q=True, childArray=True ) or [] - rowsToKeep = rows[:len(vector)] - rowsToDelete = rows[len(vector):] - for row in rowsToDelete : - maya.cmds.deleteUI( row ) - - # create new fields - for i in range( len(rowsToKeep), len(vector) ) : - self.__createRow( self.label() + ": %d" % i ) - - self.__setUIFromPlug() - - def _topLevelUIDeleted( self ) : - - self.__attributeChangedCallbackId = None - - def __createRow( self, label ) : - - row = maya.cmds.rowLayout( - parent = self.__column, - numberOfColumns = 2, - columnAlign2 = ( "right", "left" ), - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - - ## \todo: there is a slight text misalignment if the window exists when __createRow is called - maya.cmds.text( - parent = row, - label = label, - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - width = IECoreMaya.ParameterUI.textColumnWidthIndex, - ) - - kw = {} - - # \todo Add a way of overriding precision for both float and double parameters, giving - # each a sensible (and probably different) default - if self.parameter.isInstanceOf( IECore.TypeId.DoubleParameter ) : - kw['precision'] = 12 - - self.__fields.append( - self.__fieldType()( - parent = row, - changeCommand = self._createCallback( self.__setPlugFromUI ), - width = IECoreMaya.ParameterUI.singleWidgetWidthIndex, - **kw - ) - ) - - i = len(self.__fields) - 1 - self._addPopupMenu( parentUI=self.__fields[i], index=i ) - - def _popupMenuDefinition( self, **kw ) : - - definition = IECore.MenuDefinition() - definition.append( "/Remove Item", { "command" : self._createCallback( IECore.curry( self.__removeItem, index=kw['index'] ) ) } ) - - return definition - - def __addItem( self ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - vector.append( 0 ) - - self.__setPlug( vector ) - self.replace( self.node(), self.parameter ) - - def __removeItem( self, index ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - vector = vector[:index] + vector[index+1:] - - self.__setPlug( vector ) - self.replace( self.node(), self.parameter ) - - def __attributeChanged( self, changeType, plug, otherPlug, userData ) : - - if not ( changeType & maya.OpenMaya.MNodeMessage.kAttributeSet ) : - return - - try : - myPlug = self.plug() - except : - # this situation can occur when our parameter has been removed but the - # ui we represent is not quite yet dead - return - - if not plug == myPlug : - return - - self.replace( self.node(), self.parameter ) - - def __setUIFromPlug( self ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - for i in range( 0, len(vector) ) : - self.__fieldType()( self.__fields[i], e=True, value=vector[i] ) - - def __setPlugFromUI( self ) : - - vector = [] - - for field in self.__fields : - vector.append( self.__fieldType()( field, q=True, value=True ) ) - - self.__setPlug( vector ) - - def __setPlug( self, value ) : - - plugType = maya.cmds.getAttr( self.plugName(), type=True ) - maya.cmds.setAttr( self.plugName(), value, type=plugType ) - - def __fieldType( self ) : - - if self.parameter.isInstanceOf( IECore.TypeId.FloatVectorParameter ) or self.parameter.isInstanceOf( IECore.TypeId.DoubleVectorParameter ) : - return maya.cmds.floatField - elif self.parameter.isInstanceOf( IECore.TypeId.IntVectorParameter ) : - return maya.cmds.intField - else: - raise RuntimeError("Invalid parameter type for NumericParameterUI") - - __disableCopyPaste = IECore.CompoundObject( { - "UI" : IECore.CompoundObject( { - "copyPaste" : IECore.BoolData( False ), - } ), - } ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.FloatVectorParameter, NumericVectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.DoubleVectorParameter, NumericVectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.IntVectorParameter, NumericVectorParameterUI ) diff --git a/python/IECoreMaya/OpWindow.py b/python/IECoreMaya/OpWindow.py deleted file mode 100644 index c5f5bfc0fb..0000000000 --- a/python/IECoreMaya/OpWindow.py +++ /dev/null @@ -1,143 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECoreMaya - -import maya.cmds -import traceback - -## This class creates a window holding an instance of IECore.Op, presenting a ui -# for the modification of it's parameters. The user can then execute the op interactively. -## \todo We need to close this window if the node is deleted - for instance when the user makes a fresh scene. -class OpWindow( IECoreMaya.UIElement ) : - - def __init__( self, op ) : - - window = maya.cmds.window( title="Op Settings" ) - - IECoreMaya.UIElement.__init__( self, window ) - - form = maya.cmds.formLayout() - - infoRow = maya.cmds.rowLayout() - maya.cmds.text( label = op.typeName(), annotation = op.description, font = "boldLabelFont" ) - - maya.cmds.setParent( form ) - - scrollLayout = maya.cmds.scrollLayout( horizontalScrollBarThickness=0 ) - column = maya.cmds.columnLayout() - maya.cmds.separator( parent=column, style="none" ) - maya.cmds.separator( parent=column, style="none" ) - - maya.cmds.setParent( form ) - - cancelButton = maya.cmds.button( label="Cancel", command="import maya.cmds; maya.cmds.deleteUI( \"%s\" )" % window ) - resetButton = maya.cmds.button( label="Reset", command=self._createCallback( self.__revertPressed ) ) - goButton = maya.cmds.button( label="Go!", command=self._createCallback( self.__goPressed ) ) - - self.__fnTPH = IECoreMaya.FnTransientParameterisedHolderNode.create( column, op ) - - maya.cmds.setParent( form ) - - maya.cmds.formLayout( - form, - edit = True, - attachForm = [ - ( infoRow, "top", 5 ), - ( infoRow, "left", 5 ), - ( infoRow, "right", 5 ), - ( scrollLayout, "left", 5 ), - ( scrollLayout, "right", 5 ), - ( cancelButton, "right", 5 ), - ( goButton, "left", 5 ), - ( cancelButton, "bottom", 5 ), - ( resetButton, "bottom", 5 ), - ( goButton, "bottom", 5 ), - ], - attachPosition = [ - ( cancelButton, "left", 5, 66 ), - ( goButton, "right", 5, 33 ), - ], - attachControl = [ - ( scrollLayout, "top", 5, infoRow ), - ( scrollLayout, "bottom", 5, cancelButton ), - ( resetButton, "left", 5, goButton ), - ( resetButton, "right", 5, cancelButton ), - ], - attachNone = [ - ( cancelButton, "top" ), - ( resetButton, "top" ), - ( goButton, "top" ), - ] - ) - - maya.cmds.showWindow( window ) - - def __revertPressed( self ) : - - op = self.__fnTPH.getParameterised()[0] - op.parameters().setValue( op.parameters().defaultValue ) - self.__fnTPH.setNodeValues() - - def __goPressed( self ) : - - self.__fnTPH.setParameterisedValues() - op = self.__fnTPH.getParameterised()[0] - - valid = op.parameters().valueValid() - if not valid[0] : - maya.cmds.confirmDialog( - title="Parameter Error", - message=valid[1], button="OK", - defaultButton="OK", - parent=self._topLevelUI() - ) - return - - result = None - try : - result = op() - except Exception as e : - buttonPressed = maya.cmds.confirmDialog( - title="Execution Error", - message="Error : " + e.message, - button=( "Print Details", "OK" ), - defaultButton="OK", - parent=self._topLevelUI() - ) - if buttonPressed=="Print Details" : - traceback.print_exc() - - if result is not None : - maya.cmds.deleteUI( self._topLevelUI() ) diff --git a/python/IECoreMaya/Panel.py b/python/IECoreMaya/Panel.py deleted file mode 100644 index 06a50ac8ac..0000000000 --- a/python/IECoreMaya/Panel.py +++ /dev/null @@ -1,198 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya - -import maya.cmds -import sys - -import pickle - -## The Panel class provides a handy base class for the implementation -# of maya scripted panels. It allows the panel to be represented as -# an object with member data, reduces the number of methods that must -# be implemented, and allows normal python objects to be used as the -# state persistence mechanism. -class Panel( IECoreMaya.UIElement ) : - - ## Derived classes must implement this to create their ui, calling - # Panel.__init__ with the top level of the ui. A new instance is - # made each time maya wishes to populate a ui with a panel (effectively - # this method implements the create, init and add callbacks of the - # maya scripted panel). - def __init__( self, topLevelUI ) : - - IECoreMaya.UIElement.__init__( self, topLevelUI ) - - ## Must be implemented by subclasses to return a python object - # representing their state. This is used for both persistence - # across scene save and load, but also for when a panel is torn - # off or reparented. - def _saveState( self ) : - - raise NotImplementedError - - ## Must be implemented to restore a state previously saved with - # _saveState. - def _restoreState( self, state ) : - - raise NotImplementedError - - ## Call this to instantiate a panel. Note that one panel instantiation - # as far as maya is concerned may result in multiple IECoreMaya.Panel instantiations - - # typically one for each time maya wishes to reparent or copy the panel. - @classmethod - def create( cls, label=None ) : - - typeName = cls.__name__ - panel = maya.cmds.scriptedPanel( unParent=True, type=typeName, label=typeName ) - if label : - maya.cmds.scriptedPanel( panel, edit=True, label=label ) - return panel - - ## Must be called to register all subclasses. This should - # typically be done during plugin initialisation. - @classmethod - def registerPanel( cls, subclass ) : - - typeName = subclass.__name__ - if not maya.cmds.scriptedPanelType( typeName, exists=True ) : - - # we have to implement the mel callbacks in iePanel.mel - # as maya doesn't implement python scripted panels. the mel - # methods we use call straight back to the implementations - # below. - t = maya.cmds.scriptedPanelType( - typeName, - createCallback="iePanelCreate", - initCallback="iePanelInit", - addCallback="iePanelAdd", - removeCallback="iePanelRemove", - saveStateCallback="iePanelSave", - deleteCallback="iePanelDelete", - ) - - # t=0 is always returned in batch mode, probably because - # batch mode can't handle UI callback creation - assert( t==typeName or t==0) - cls.__panelTypes[t] = subclass - - else : - - assert( cls.__panelTypes[typeName]==subclass ) - - # maps from the maya panel name to a record of the Panel instance and state for - # that panel - __panels = {} - # maps from the maya panel type to the Panel subclass for that type - __panelTypes = {} - - ## The methods below implement the callbacks maya requires by using the methods - ## defined above. - ############################################################################## - - @classmethod - def __create( cls, panelName ) : - - t = maya.cmds.scriptedPanel( panelName, query=True, type=True ) - panelType = cls.__panelTypes[t] - - panelRecord = IECore.Struct() - panelRecord.type = panelType - panelRecord.instance = None - panelRecord.state = None - Panel.__panels[panelName] = panelRecord - - @classmethod - def __init( cls, panelName ) : - - # we don't need to do anything here - pass - - @classmethod - def __add( cls, panelName ) : - - panelRecord = cls.__panels[panelName] - assert( not panelRecord.instance ) - - panelRecord.instance = panelRecord.type() - if panelRecord.state : - panelRecord.instance._restoreState( panelRecord.state ) - - @classmethod - def __remove( cls, panelName ) : - - panelRecord = cls.__panels[panelName] - assert( panelRecord.instance ) - - panelRecord.state = panelRecord.instance._saveState() - panelRecord.instance = None - - @classmethod - def __save( cls, panelName ) : - - panelRecord = cls.__panels[panelName] - if panelRecord.instance : - state = panelRecord.instance._saveState() - else : - state = panelRecord.state - - if not state : - return "" - - pickledState = pickle.dumps( state ) - encodedState = pickledState.encode( "hex" ) - return "iePanelRestore( \"%s\", \"%s\" )" % ( panelName, encodedState ) - - @classmethod - def __delete( cls, panelName ) : - - del cls.__panels[panelName] - - # This one isn't actually a required part of the maya protocol, but - # we call it in the saved state strings to restore layouts when files - # are opened. - @classmethod - def __restore( cls, panelName, encodedState ) : - - panelRecord = cls.__panels[panelName] - decodedState = encodedState.decode( "hex" ) - unpickledState = pickle.loads( decodedState ) - - panelRecord.state = unpickledState - if panelRecord.instance : - panelRecord.instance._restoreState( panelRecord.state ) - - __panelStates = {} diff --git a/python/IECoreMaya/ParameterClipboardUI.py b/python/IECoreMaya/ParameterClipboardUI.py deleted file mode 100644 index 302ec85eab..0000000000 --- a/python/IECoreMaya/ParameterClipboardUI.py +++ /dev/null @@ -1,336 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import IECore -import IECoreMaya - -import maya.cmds - -## The ParameterClipboardUI functions create menu items in relevant -## menus to allow the values of Parameterised object Parameters to be -## copied and pasted between nodes, or between different parameters on -## the same node. It currently does this using in-memory BasicPreset -## instances, held in a global variable. -## Pasting 'values' as a connection is also supported, though not using -## the basic preset mechanism. -__all__ = [ 'copy', 'copyClass', 'paste', 'pasteLinked', '_clearReferences' ] - -def __copyPasteMenuModifier( menuDefinition, parameter, node, parent=None ) : - - with IECore.IgnoredExceptions( KeyError ) : - if not parameter.userData()['UI']['copyPaste'].value : - return - - global _ieCoreParameterClipboardUIBuffer - - fnPh = IECoreMaya.FnParameterisedHolder( node ) - plugPath = fnPh.parameterPlugPath( parameter ) - - commandBase = 'import IECoreMaya; IECoreMaya.ParameterClipboardUI' - - copyString = '%s.copy( "%s" )' % ( commandBase, plugPath ) - copySomeString = '%s.copy( "%s", True )' % ( commandBase, plugPath ) - pasteString = '%s.paste( "%s" )' % ( commandBase, plugPath ) - pasteLinkedString = '%s.pasteLinked( "%s" )' % ( commandBase, plugPath ) - - if len( list(menuDefinition.items()) ): - menuDefinition.append( "/CopyPasteDivider", { "divider" : True } ) - - copyActive = True - - if isinstance( parameter, IECore.ClassParameter ) : - if parameter.getClass( False ) == None : - copyActive = False - - elif isinstance( parameter, IECore.ClassVectorParameter ) : - classes = parameter.getClasses( False ) - if not len(classes) : - copyActive = False - - # If we are actually a class in a vector, also give them an option - # to copy the class - if parent is not None and ( - isinstance( parent, IECore.ClassVectorParameter ) - or isinstance( parent, IECore.ClassParameter ) - ): - menuDefinition.append( - "/Copy Values", - { - "command" : IECore.curry( maya.cmds.evalDeferred, copyString ), - "secondaryCommand" : IECore.curry( maya.cmds.evalDeferred, copySomeString ), - "active" : copyActive, - } - ) - - parentPlugPath = fnPh.parameterPlugPath( parent ) - copyComponentString = '%s.copyClass( "%s", "%s" )' % ( commandBase, plugPath, parentPlugPath ) - - menuDefinition.append( - "/Copy Component", - { - "command" : IECore.curry( maya.cmds.evalDeferred, copyComponentString ), - "active" : copyActive, - } - ) - - else: - - menuDefinition.append( - "/Copy", - { - "command" : IECore.curry( maya.cmds.evalDeferred, copyString ), - "secondaryCommand" : IECore.curry( maya.cmds.evalDeferred, copySomeString ), - "active" : copyActive, - } - ) - - pasteActive = False - pasteLinkedActive = False - - if _ieCoreParameterClipboardUIBuffer and isinstance( _ieCoreParameterClipboardUIBuffer, IECore.Preset ) : - pasteActive = _ieCoreParameterClipboardUIBuffer.applicableTo( fnPh.getParameterised()[0], parameter ) - if pasteActive and _ieCoreParameterClipboardUILastNode and maya.cmds.objExists( _ieCoreParameterClipboardUILastNode ) : - pasteLinkedActive = True - - menuDefinition.append( - "/Paste", - { - "command" : IECore.curry( maya.cmds.evalDeferred, pasteString ), - "active" : pasteActive, - } - ) - - menuDefinition.append( - "/Paste Linked", - { - "command" : IECore.curry( maya.cmds.evalDeferred, pasteLinkedString ), - "active" : pasteLinkedActive, - } - ) - -def __copyPasteVectorMenuModifier( menuDefinition, parent, parameter, node ) : - __copyPasteMenuModifier( menuDefinition, parameter, node, parent=parent ) - -IECoreMaya.ParameterUI.registerPopupMenuCallback( __copyPasteMenuModifier ) -IECoreMaya.ClassParameterUI.registerClassMenuCallback( __copyPasteMenuModifier ) -IECoreMaya.ClassVectorParameterUI.registerClassMenuCallback( __copyPasteVectorMenuModifier ) -IECoreMaya.ClassVectorParameterUI.registerToolsMenuCallback( __copyPasteMenuModifier ) - -## The copy buffer -_ieCoreParameterClipboardUIBuffer = None -## These track the last node/parameters that were copied so we can potentially -## paste with connections. We still need the preset to be able to restore -## any missing classes contained within the preset. -_ieCoreParameterClipboardUILastParameterList = None -_ieCoreParameterClipboardUILastNode = None -_ieCoreParameterClipboardUILastRoot = None - -def copy( plugPath, showUI=False ) : - - global _ieCoreParameterClipboardUIBuffer - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - parts = plugPath.split( "." ) - fnPh = IECoreMaya.FnParameterisedHolder( parts[0] ) - parameter = fnPh.plugParameter( plugPath ) - - def copyCallback( node, rootParameter, parameters ): - - global _ieCoreParameterClipboardUIBuffer - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - fnPh = IECoreMaya.FnParameterisedHolder( node ) - preset = IECore.BasicPreset( fnPh.getParameterised()[0], rootParameter, parameters=parameters ) - - _ieCoreParameterClipboardUIBuffer = preset - _ieCoreParameterClipboardUILastParameterList = parameters - _ieCoreParameterClipboardUILastNode = node - _ieCoreParameterClipboardUILastRoot = rootParameter - - # We need to make sure that the values in the parameterised are in sync - fnPh.setParameterisedValues() - - if showUI : - - IECoreMaya.PresetsUI( parts[0], parameter ).selectParameters( copyCallback ) - - else : - - paramList = [] - __getParameters( parameter, paramList ) - - _ieCoreParameterClipboardUIBuffer = IECore.BasicPreset( fnPh.getParameterised()[0], parameter ) - _ieCoreParameterClipboardUILastParameterList = paramList - _ieCoreParameterClipboardUILastNode = fnPh.fullPathName() - _ieCoreParameterClipboardUILastRoot = parameter - -def copyClass( plugPath, parentPlugPath ) : - - global _ieCoreParameterClipboardUIBuffer - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - parts = plugPath.split( "." ) - fnPh = IECoreMaya.FnParameterisedHolder( parts[0] ) - parameter = fnPh.plugParameter( plugPath ) - parent = fnPh.plugParameter( parentPlugPath ) - - # We need to make sure that the values in the parameterised are in sync - fnPh.setParameterisedValues() - - # This bit is slightly irritating, but we have to get all - # The child parameters of the target class, so we only save that one - paramList = [] - __getParameters( parameter, paramList ) - _ieCoreParameterClipboardUIBuffer = IECore.BasicPreset( fnPh.getParameterised()[0], parent, paramList ) - - # For now, we only support pasting values linked. Otherwise, we'd have to go find - # any classes we instantiated to know their plug prefix... - _ieCoreParameterClipboardUILastParameterList = None - _ieCoreParameterClipboardUILastNode = None - _ieCoreParameterClipboardUILastRoot = None - -def paste( plugPath ) : - - global _ieCoreParameterClipboardUIBuffer - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - if not _ieCoreParameterClipboardUIBuffer or not isinstance( _ieCoreParameterClipboardUIBuffer, IECore.Preset ) : - return - - parts = plugPath.split( "." ) - fnPh = IECoreMaya.FnParameterisedHolder( parts[0] ) - parameter = fnPh.plugParameter( plugPath ) - - if not _ieCoreParameterClipboardUIBuffer.applicableTo( fnPh.getParameterised()[0], parameter ): - raise RuntimeError("The parameters on the clipboard are not applicable to '%s'" % plugPath) - - fnPh.setParameterisedValues() - - with fnPh.parameterModificationContext() : - _ieCoreParameterClipboardUIBuffer( fnPh.getParameterised()[0], parameter ) - -def pasteLinked( plugPath ) : - - global _ieCoreParameterClipboardUIBuffer - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - if not _ieCoreParameterClipboardUIBuffer or not isinstance( _ieCoreParameterClipboardUIBuffer, IECore.Preset ) : - return - - parts = plugPath.split( "." ) - fnPh = IECoreMaya.FnParameterisedHolder( parts[0] ) - parameter = fnPh.plugParameter( plugPath ) - - if not _ieCoreParameterClipboardUIBuffer.applicableTo( fnPh.getParameterised()[0], parameter ): - raise RuntimeError("The parameters on the clipboard are not applicable to '%s'" % plugPath) - - # Apply the preset to make sure that the children are there - fnPh.setParameterisedValues() - - with fnPh.parameterModificationContext() : - _ieCoreParameterClipboardUIBuffer( fnPh.getParameterised()[0], parameter ) - - # Connect up - if not maya.cmds.objExists( _ieCoreParameterClipboardUILastNode ) : - raise RuntimeError("The source node '%s' no longer exists." % _ieCoreParameterClipboardUILastNode) - - if not _ieCoreParameterClipboardUILastRoot : - raise RuntimeError("Unable to link, the source root parameter is not known." % _ieCoreParameterClipboardUILastNode) - - - sourceNodeHolder = IECoreMaya.FnParameterisedHolder( _ieCoreParameterClipboardUILastNode ) - sourceRootPlugPath = sourceNodeHolder.parameterPlugPath( _ieCoreParameterClipboardUILastRoot ) - - if sourceRootPlugPath == plugPath : - raise RuntimeError("The source and destination parameters are the same, unable to link.") - - for p in _ieCoreParameterClipboardUILastParameterList : - sourcePlugPath = sourceNodeHolder.parameterPlugPath( p ) - destPlugPath = sourcePlugPath.replace( sourceRootPlugPath, plugPath ) - if maya.cmds.objExists( sourcePlugPath ) and maya.cmds.objExists( destPlugPath ) : - maya.cmds.connectAttr( sourcePlugPath, destPlugPath, force=True ) - -def __getParameters( parameter, paramList=[] ) : - - if parameter.staticTypeId() == IECore.TypeId.CompoundParameter : - - for p in parameter.values(): - __getParameters( p, paramList ) - - elif isinstance( parameter, IECore.ClassParameter ) : - - c = parameter.getClass( False ) - if c: - paramList.append( parameter ) - __getParameters( c.parameters(), paramList ) - - elif isinstance( parameter, IECore.ClassVectorParameter ) : - - cl = parameter.getClasses( False ) - if cl : - paramList.append( parameter ) - for c in cl : - __getParameters( c.parameters(), paramList ) - - else : - paramList.append( parameter ) - -# We need to clear out the references we're holding on parameters when the scene changes -def _clearReferences( *args, **kwargs ) : - - global _ieCoreParameterClipboardUILastParameterList - global _ieCoreParameterClipboardUILastNode - global _ieCoreParameterClipboardUILastRoot - - _ieCoreParameterClipboardUILastParameterList = None - _ieCoreParameterClipboardUILastNode = None - _ieCoreParameterClipboardUILastRoot = None - -_ieCoreParameterClipboardCallbacks = [] -if hasattr( maya.cmds, "about" ) and not maya.cmds.about( batch=True ): - _ieCoreParameterClipboardCallbacks.append( IECoreMaya.CallbackId( maya.OpenMaya.MSceneMessage.addCallback( maya.OpenMaya.MSceneMessage.kBeforeNew, _clearReferences ) ) ) - _ieCoreParameterClipboardCallbacks.append( IECoreMaya.CallbackId( maya.OpenMaya.MSceneMessage.addCallback( maya.OpenMaya.MSceneMessage.kBeforeOpen, _clearReferences ) ) ) - diff --git a/python/IECoreMaya/ParameterPanel.py b/python/IECoreMaya/ParameterPanel.py deleted file mode 100644 index 7b90df70d5..0000000000 --- a/python/IECoreMaya/ParameterPanel.py +++ /dev/null @@ -1,349 +0,0 @@ - -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds as cmds -import maya.OpenMaya - -import IECore -import IECoreMaya - -## \todo Reimplement this in terms of the new Panel base class. -## \todo Prefix methods which aren't intended to be public to make them either private or protected. -class ParameterPanel : - - panels = {} - - @staticmethod - def trashDropCallback( dragControl, dropControl, messages, x, y, dragType, container ) : - - if len(messages) == 2 and messages.pop(0) == "ParameterUI" : - - argsDictStr = messages.pop() - argsDict = eval( argsDictStr ) - - container.removeControl( argsDict['nodeName'], argsDict['longParameterName'], deferredUIDeletion = True ) - - @staticmethod - def newControlDropCallback( dragControl, dropControl, messages, x, y, dragType, container ) : - - if len(messages) == 2 and messages.pop(0) == "ParameterUI" : - - argsDictStr = messages.pop() - argsDict = eval( argsDictStr ) - - container.addControl( argsDict['nodeName'], argsDict['longParameterName'] ) - - - class ParameterUIContainer : - - def __init__( self ) : - - self.formLayout = None - self.containerLayout = maya.cmds.setParent( query = True ) - self.parameters = [] - self.parameterLayouts = {} - - self.restoreParameters = [] - - def addControl( self, node, longParameterName ) : - - fnPH = IECoreMaya.FnParameterisedHolder( node ) - parameterised = fnPH.getParameterised()[0] - - parameter = parameterised.parameters() - - for p in longParameterName.split( '.' ) : - - if p : - - parameter = getattr( parameter, p ) - - assert( self.containerLayout ) - maya.cmds.setParent( self.containerLayout ) - - if not ( node, longParameterName ) in self.parameterLayouts: - - n = longParameterName.split(".") - - if type( n ) is list: - - # Take off the last element (to retrieve the parent parameter name), - # because ParameterUI.create will add it again. - n.pop() - parentParameterName = ".".join( n ) - - else : - - parentParameterName = longParameterName - - newLayout = IECoreMaya.ParameterUI.create( - node, - parameter, - labelWithNodeName = True, - longParameterName = parentParameterName, - withCompoundFrame = True - ).layout() - - self.parameters.append( ( node, longParameterName ) ) - self.parameterLayouts[ ( node, longParameterName ) ] = newLayout - - maya.cmds.file( - modified = True - ) - - - def removeControl( self, node, longParameterName, deferredUIDeletion = False ) : - - # In case another panel's control has been dropped onto our trash can - if not ( node, longParameterName ) in self.parameterLayouts : - - return - - layoutToDelete = self.parameterLayouts[ ( node, longParameterName ) ] - - if maya.cmds.layout( layoutToDelete, query = True, exists = True ) : - - if deferredUIDeletion : - - # We don't want to delete the UI in the middle of a drag'n'drop event, it crashes Maya - maya.cmds.evalDeferred( "import maya.cmds as cmds; cmds.deleteUI( '%s', layout = True)" % ( layoutToDelete ) ) - - else : - - maya.cmds.deleteUI( '%s' % ( layoutToDelete ), layout = True) - - del self.parameterLayouts[ ( node, longParameterName ) ] - - self.parameters.remove( ( node, longParameterName ) ) - - maya.cmds.file( - modified = True - ) - - # We have the "args" argument to allow use in a Maya UI callback, which passes us extra arguments that we don't need - def removeAllControls( self, args = None ) : - - toRemove = list( self.parameters ) - - for i in toRemove : - - self.removeControl( i[0], i[1] ) - - assert( len( self.parameters ) == 0 ) - assert( len( self.parameterLayouts ) == 0 ) - - - def add( self, panel ): - - try : - self.parameterLayouts = {} - - # If "add" has been called, and we already have some parameters, it means we're been torn-off and should - # recreate all our controls in the new window. - - if not self.restoreParameters and self.parameters : - - self.restoreParameters = list( self.parameters ) - - self.parameters = [] - - maya.cmds.waitCursor( state = True ) - - menuBar = maya.cmds.scriptedPanel( - panel, - query = True, - control = True - ) - - self.formLayout = maya.cmds.formLayout( - numberOfDivisions = 100 - ) - - maya.cmds.setParent( - menuBar - ) - - editMenu = maya.cmds.menu( - label = "Edit" - ) - - maya.cmds.menuItem( - label = "Remove All", - parent = editMenu, - command = IECore.curry( ParameterPanel.ParameterUIContainer.removeAllControls, self ) - ) - - maya.cmds.setParent( self.formLayout ) - - scrollPane = maya.cmds.scrollLayout( - dropCallback = IECore.curry( ParameterPanel.newControlDropCallback, container = self ), - parent = self.formLayout - ) - - trashCan = maya.cmds.iconTextStaticLabel( - image = "smallTrash.xpm", - label = "", - height = 20, - dropCallback = IECore.curry( ParameterPanel.trashDropCallback, container = self ), - parent = self.formLayout - ) - - maya.cmds.rowLayout( parent = scrollPane ) - - self.containerLayout = maya.cmds.columnLayout( - ) - - maya.cmds.formLayout( - self.formLayout, - edit=True, - attachForm = [ - ( trashCan, 'bottom', 5 ), - ( trashCan, 'right', 5 ), - - ( scrollPane, 'top', 5 ), - ( scrollPane, 'left', 5 ), - ( scrollPane, 'right', 5 ), - ( scrollPane, 'bottom', 25 ) - ], - - attachNone = [ - ( trashCan, 'left' ), - ( trashCan, 'top' ) - ] - ) - - for i in self.restoreParameters : - - self.addControl( i[0], i[1] ) - - self.restoreParameters = [] - - except : - - raise - - finally : - - maya.cmds.waitCursor( state = False ) - - def delete( self ) : - - self.removeAllControls() - - def init( self ) : - - # Called after a scene has been loaded (or after a "file | new" operation), and "add" has already been called. - - pass - - def remove( self ) : - - # Called before tearing-off - - pass - - def restoreData( self ) : - - version = 1 - - return repr( ( version, self.parameters ) ) - - def restore( self, data ) : - - self.removeAllControls() - - dataTuple = eval( data ) - - version = dataTuple[0] - - self.restoreParameters = dataTuple[1] - - if self.formLayout : - - for i in self.restoreParameters : - - self.addControl( i[0], i[1] ) - - self.restoreParameters = [] - - - @staticmethod - def create( panel ) : - - ParameterPanel.panels[ panel ] = ParameterPanel.ParameterUIContainer() - - - @staticmethod - def init( panel ) : - - assert( panel in ParameterPanel.panels ) - - ParameterPanel.panels[ panel ].init() - - - @staticmethod - def add( panel ) : - - assert( panel in ParameterPanel.panels ) - - ParameterPanel.panels[ panel ].add( panel ) - - @staticmethod - def remove( panel ) : - - assert( panel in ParameterPanel.panels ) - - ParameterPanel.panels[ panel ].remove() - - @staticmethod - def delete( panel ) : - - assert( panel in ParameterPanel.panels ) - - ParameterPanel.panels[ panel ].delete() - - @staticmethod - def save( panel ) : - - assert( panel in ParameterPanel.panels ) - - return 'ieParameterPanelRestore("%s", "%s")' % ( panel, ParameterPanel.panels[ panel ].restoreData() ) - - @staticmethod - def restore( panel, data ) : - - assert( panel in ParameterPanel.panels ) - - ParameterPanel.panels[ panel ].restore( data ) diff --git a/python/IECoreMaya/ParameterUI.py b/python/IECoreMaya/ParameterUI.py deleted file mode 100644 index a4bd7d38a2..0000000000 --- a/python/IECoreMaya/ParameterUI.py +++ /dev/null @@ -1,399 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds as cmds -import maya.mel -import maya.OpenMaya - -import IECore -import IECoreMaya - -## Base class for objects which are able to create an Attribute Editor widget for a single IECore.Parameter -# held on an IECoreMaya.ParameterisedHolder node. -# \todo Separate control drawing from labelling and layout, so these classes just create the right -# hand side of what they're doing at the moment. Then we can use them in different layouts like spreadsheets -# and wotnot. -class ParameterUI( IECoreMaya.UIElement ) : - - textColumnWidthIndex = 145 - singleWidgetWidthIndex = 70 - sliderWidgetWidthIndex = 2 * 70 - - handlers = {} - - ## The parameterisedHolderNode is an MObject specifying the node holding the specified IECore.Parameter. - # Derived class __init__ implementations must create a layout to hold all their contents and pass this - # in the topLevelUI parameter (as for all UIElement derived classes). - # \todo Document the meaning of the various keyword arguments - perhaps the names of these should be - # prefixed with the name of the class which implements each argument so as to make it easier to find - # the documentation too. - def __init__( self, parameterisedHolderNode, parameter, topLevelUI, **kw ) : - - IECoreMaya.UIElement.__init__( self, topLevelUI ) - - self.__node = maya.OpenMaya.MObjectHandle( parameterisedHolderNode ) - self.parameter = parameter #IECore.Parameter - - self.__labelWithNodeName = kw.get( "labelWithNodeName", False ) - self.__longParameterName = kw.get( "longParameterName", parameter.name ) - - ## Derived classes should override this method. The override should first call the base class method and - # then reconnect all created widgets to the new node/parameter. The node and parameter arguments are as - # for the __init__ function. - def replace( self, node, parameter ) : - - self.__node = maya.OpenMaya.MObjectHandle( node ) - self.parameter = parameter - - ## Returns the Maya node associated with this UI in the form of an OpenMaya.MObject - def node( self ) : - - if not self.__node.isValid() : - raise RuntimeError("IECoreMaya.ParameterUI.node(): The requested node is not valid") - - return self.__node.object() - - ## Returns an umambiguous full path for the Maya node associated with this UI. - def nodeName( self ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - return fnPH.fullPathName() - - ## Returns the Maya plug associated with this UI in the form an OpenMaya.MPlug - def plug( self ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - return fnPH.parameterPlug( self.parameter ) - - ## Returns an unambiguous full path to the plug this ui represents. - def plugName( self ) : - - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - plug = fnPH.parameterPlug( self.parameter ) - return str( fnPH.fullPathName() + "." + plug.partialName() ) - - def layout( self ) : - - return self._topLevelUI() - - ## Computes a nice label for the ui. - def label( self ): - - if self.__labelWithNodeName : - - n = self.nodeName() + "." + self.__longParameterName - if not self.__longParameterName : - # Top-level parameter comes through into here without a name - n = self.nodeName() + ".parameters" - - return maya.mel.eval( "interToUI(\"" + n + "\")" ) - - else : - - return maya.mel.eval( "interToUI(\"" + self.parameter.name + "\")" ) - - ## Computes a wrapped annotation/tooltip for the ui - def description( self ): - - extended = "%s\n\n%s" % ( self.plugName().split(".")[1], self.parameter.description ) - return IECore.StringUtil.wrap( extended, 48 ) - - @staticmethod - def _defaultDragCallback( dragControl, x, y, modifiers, **kw ): - - # Pass the dictionary of arguments as a string so that it can be captured and eval'ed in the drop callback - return [ 'ParameterUI', repr( kw ) ] - - def addDragCallback( self, ctrl, **kw ) : - - maya.cmds.control( - ctrl, - edit = True, - dragCallback = IECore.curry( ParameterUI._defaultDragCallback, nodeName = self.nodeName(), layoutName = self.layout(), **kw ) - ) - - ## Can be called by derived classes to add a useful popup menu to the specified ui element. This - # will replace any existing popup menus that are already there. - ## \todo Understand and document the available keyword arguments. I think the only one is "attributeName", - # which is used to allow the name of specific elements of compound plugs to be specified to improve the box - # and vector uis. That needs rethinking in any case, as we shouldn't be storing attribute names anywhere as it - # makes us vulnerable to the names changing behind our backs. - def _addPopupMenu( self, parentUI, **kw ) : - - existingMenus = maya.cmds.control( parentUI, query=True, popupMenuArray=True ) - if existingMenus : - for m in existingMenus : - maya.cmds.deleteUI( m, menu=True ) - - IECoreMaya.Menu( definition = IECore.curry( self.__popupMenuDefinition, **kw ), parent = parentUI ) - - if "button1" in kw and kw["button1"] : - IECoreMaya.Menu( definition = IECore.curry( self.__popupMenuDefinition, **kw ), parent = parentUI, button = 1 ) - - ## Returns an IECore.MenuDefinition used to create a popup menu for the ParameterUI. This may - # be overridden by derived classes to add their own menu items. In this case they should first - # call the base class implementation before adding their items to the result. - def _popupMenuDefinition( self, **kw ) : - - definition = IECore.MenuDefinition() - - if cmds.getAttr( kw['attributeName'], lock = True) == 0: - - settable = maya.cmds.getAttr( kw["attributeName"], settable=True ) - if settable : - - # make menu items for all presets and for the default value - - for k in self.parameter.presetNames() : - definition.append( "/" + k, { "command" : IECore.curry( self.__selectValue, selection = k ) } ) - - if len( self.parameter.presetNames() ) > 0 : - definition.append( "/PresetDivider", { "divider" : True } ) - - definition.append( "/Default", { "command" : IECore.curry( self.__selectValue, selection = self.parameter.defaultValue ) } ) - - definition.append( "/ValueDivider", { "divider" : True } ) - - attrType = cmds.getAttr( kw["attributeName"], type=True ) - if attrType in ( "float", "long" ) : - - if cmds.getAttr( kw['attributeName'], keyable=True) and settable : - definition.append( "/Set Key", { "command" : IECore.curry( self.__setKey, **kw ) } ) - - expressions = cmds.listConnections( - kw['attributeName'], - d = False, - s = True, - type = "expression" - ) - - if not expressions : - - hasConnections = self.__appendConnectionMenuDefinitions( definition, **kw ) - if not hasConnections and settable : - definition.append( "/Create New Expression...", { "command" : IECore.curry( self.__expressionEditor, **kw ) } ) - - else: - - definition.append( "/Edit Expression...", { "command" : IECore.curry( self.__expressionEditor, **kw ) } ) - definition.append( "/Delete Expression", { "command" : IECore.curry( self.__deleteNode, nodeName = expressions[0] ) } ) - - else : - - self.__appendConnectionMenuDefinitions( definition, **kw ) - - definition.append( "/ConnectionDivider", { "divider" : True } ) - - definition.append( "/Lock Attribute", { "command" : IECore.curry( self.__lock, **kw ) } ) - - else : - - definition.append( "/Unlock Attribute", { "command" : IECore.curry( self.__unlock, **kw ) } ) - - return definition - - def __appendConnectionMenuDefinitions( self, definition, **kw ) : - - connections = cmds.listConnections( - kw['attributeName'], - d = False, - s = True, - plugs = True, - connections = True, - skipConversionNodes = True - ) - - definition.append( "/Connection Editor...", { "command" : IECore.curry( self.__connectionEditor ) } ) - - if connections : - - definition.append( "/Open AE...", - { "command" : IECore.curry( self.__showEditor, attributeName = connections[1] ) } - ) - - definition.append( "/Break Connection", - { - "command" : IECore.curry( - self.__disconnect, - source = connections[1], - destination = connections[0], - refreshAE = self.nodeName() - ) - } - ) - - return True - - else: - - return False - - def __popupMenuDefinition( self, **kw ) : - - # call the protected function which can be overridden by - # derived classes. then let the callbacks do what they want. - definition = self._popupMenuDefinition( **kw ) - for cb in self.__popupMenuCallbacks : - cb( definition, self.parameter, self.node() ) - - return definition - - def __showEditor( self, attributeName ) : - - split = attributeName.split('.', 1 ) - node = split[0] - - melCmd = 'showEditor "' + node + '"' - - maya.mel.eval( melCmd.encode('ascii') ) - - def __deleteNode( self, nodeName = None ) : - - cmds.delete( nodeName ) - - def __expressionEditor( self, attributeName = None ) : - - split = attributeName.split('.', 1 ) - node = split[0] - attr = split[1] - - melCmd = 'expressionEditor EE "' + node + '" "' + attr + '"' - - maya.mel.eval( melCmd.encode('ascii') ) - - def __connectionEditor( self ) : - - maya.mel.eval( - str("ConnectionEditor;"+ - "nodeOutliner -e -replace %(right)s connectWindow|tl|cwForm|connectWindowPane|rightSideCW;"+ - "connectWindowSetRightLabel %(right)s;") % { 'right' : self.nodeName() } ) - - def __disconnect( self, source = None, destination = None, refreshAE = None ) : - - cmds.disconnectAttr( source, destination ) - - if refreshAE : - maya.mel.eval( 'evalDeferred( "updateAE %s;")' % refreshAE ) - - def __setKey( self, **kw ): - - cmds.setKeyframe( - kw['attributeName'] - ) - - def __lock( self, **kw ): - - cmds.setAttr( - kw['attributeName'], - lock = True - ) - - def __unlock( self, **kw ): - - cmds.setAttr( - kw['attributeName'], - lock = False - ) - - def __selectValue( self, selection = None): - - self.parameter.setValue( selection ) - IECoreMaya.FnParameterisedHolder( self.node() ).setNodeValue( self.parameter ) - - @staticmethod - def registerUI( parameterTypeId, handlerType, uiTypeHint = None ): - - key = (parameterTypeId, uiTypeHint) - if key in ParameterUI.handlers : - IECore.msg( IECore.Msg.Level.Warning, "ParameterUI.registerUI", "Handler for %s already registered." % str( key ) ) - - ParameterUI.handlers[key] = handlerType - - ## Returns a new ParameterUI instance suitable for representing - # the specified parameter on the specified parameterisedHolderNode. - # The node may either be specified as an OpenMaya.MObject or as - # a string or unicode object representing the node name. - @staticmethod - def create( parameterisedHolderNode, parameter, **kw ) : - - if not isinstance( parameterisedHolderNode, maya.OpenMaya.MObject ) : - parameterisedHolderNode = IECoreMaya.StringUtil.dependencyNodeFromString( parameterisedHolderNode ) - - if not parameter.isInstanceOf( IECore.Parameter.staticTypeId() ) : - raise TypeError( "Parameter argument must derive from IECore.Parameter." ) - - if parameter.presetsOnly and len( parameter.getPresets() ) : - return IECoreMaya.PresetsOnlyParameterUI( parameterisedHolderNode, parameter, **kw ) - - uiTypeHint = None - try: - uiTypeHint = parameter.userData()['UI']['typeHint'].value - except: - pass - - handlerType = None - typeId = parameter.typeId() - while typeId!=IECore.TypeId.Invalid : - handlerType = ParameterUI.handlers.get( ( typeId, uiTypeHint ), None ) - if handlerType is not None : - break - handlerType = ParameterUI.handlers.get( ( typeId, None ), None ) - if handlerType is not None : - break - typeId = IECore.RunTimeTyped.baseTypeId( typeId ) - - if handlerType is None : - IECore.msg( IECore.Msg.Level.Warning, "ParameterUI.create", "No UI registered for parameters of type \"%s\"" % parameter.typeName() ) - return None - - if 'longParameterName' in kw and len( kw['longParameterName'] ) : - kw['longParameterName'] += "." + parameter.name - else : - kw['longParameterName'] = parameter.name - - - parameterUI = handlerType( parameterisedHolderNode, parameter, **kw ) - - return parameterUI - - __popupMenuCallbacks = [] - ## Registers a callback which is able to modify the popup menus associated - # with ParameterUIs. The callback should have the following signature : - # - # callback( menuDefinition, parameter, holderNode ). - @classmethod - def registerPopupMenuCallback( cls, callback ) : - - cls.__popupMenuCallbacks.append( callback ) - diff --git a/python/IECoreMaya/PathParameterUI.py b/python/IECoreMaya/PathParameterUI.py deleted file mode 100644 index 4120562efe..0000000000 --- a/python/IECoreMaya/PathParameterUI.py +++ /dev/null @@ -1,142 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os.path -import warnings - -import maya.cmds - -import IECore -import IECoreMaya - -class PathParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex * 3, 26 ] - ), - **kw - - ) - - self.__label = maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - ) - - self.__textField = maya.cmds.textField() - - maya.cmds.iconTextButton( - label = "", - image = "fileOpen.xpm", - command = self._fileDialog, - height = 23, - style = "iconOnly" - ) - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - # We can't see the menu if its on the field... - self._addPopupMenu( parentUI=self.__label, attributeName = self.plugName() ) - maya.cmds.connectControl( self.__textField, self.plugName() ) - - ## This can be implemented in derived classes to show a customised file picker. - ## Typically, you would call the base class passing additional kw arguments, - ## which are passed to the FileDialog call. If omitted, "path", "key" and - ## "callback" will be set to appropriate values depending on the parameter. - def _fileDialog( self, **kw ) : - - # Allow a class to enforce a path if the default behaviour for - # using existing paths or the default userData path is not desired. - if "path" not in kw: - kw["path"] = self._initialPath() - - # Allow the parameter userData to override the key from the caller. - # This is a little different in concept to the path, but they key is - # never dynamic in terms of the parameter, so I think it makes sense. - uiUserData = self.parameter.userData().get( 'UI', {} ) - key = uiUserData.get( 'fileDialogKey', IECore.StringData() ).value - if key: - kw["key"] = key - - if "callback" not in kw: - kw["callback"] = self.__defaultFileDialogCallback - - IECoreMaya.FileDialog( **kw ) - - # Simply sets the parameter value - def __defaultFileDialogCallback( self, selection ) : - - if selection: - - self.parameter.setValue( IECore.StringData( selection[0] ) ) - fnPH = IECoreMaya.FnParameterisedHolder( self.node() ) - fnPH.setNodeValue( self.parameter ) - - ## Returns the initial path for a FileDialog, implied by the current - ## parameter value, and the status of the following userData["UI"] entries: - ## - defaultPath (IECore.StringData()) A path to use as a default. - ## - obeyDefaultPath (IECore.BoolData()) If True, the default path will - ## be used, regardless of the curent parameter value. Otherwise, the - ## parent directory of the current path is used. - def _initialPath( self, parameter=None ) : - - if not parameter: - parameter = self.parameter - - uiUserData = parameter.userData().get( 'UI', {} ) - dialogPath = uiUserData.get( 'defaultPath', IECore.StringData() ).value - obeyDefaultPath = uiUserData.get( 'obeyDefaultPath', IECore.BoolData( False ) ).value - currentPath = parameter.getTypedValue() - - if currentPath and not obeyDefaultPath : - dialogPath = os.path.dirname( currentPath ) - - return dialogPath - - diff --git a/python/IECoreMaya/PresetsOnlyParameterUI.py b/python/IECoreMaya/PresetsOnlyParameterUI.py deleted file mode 100644 index 4d45bd39c7..0000000000 --- a/python/IECoreMaya/PresetsOnlyParameterUI.py +++ /dev/null @@ -1,118 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMayaUI - -import IECoreMaya - -## A ui for any parameter for which parameter.presetsOnly is True. -class PresetsOnlyParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - IECoreMaya.ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.rowLayout( - numberOfColumns = 2, - ), - **kw - - ) - - maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - ) - - self.__popupControl = maya.cmds.iconTextStaticLabel( - image = "arrowDown.xpm", - font = "smallBoldLabelFont", - style = "iconAndTextHorizontal", - height = 23 - ) - - self.replace( node, parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - self.__updateLabel() - - self._addPopupMenu( parentUI=self.__popupControl, attributeName = self.plugName(), button1=True ) - - self.__attributeChangedCallbackId = IECoreMaya.CallbackId( - maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.node(), self.__attributeChanged ) - ) - - def _topLevelUIDeleted( self ) : - - self.__attributeChangedCallbackId = None - - def __attributeChanged( self, changeType, plug, otherPlug, userData ) : - - if not ( changeType & maya.OpenMaya.MNodeMessage.kAttributeSet ) : - return - - try : - myPlug = self.plug() - except : - # this situation can occur when our parameter has been removed but the - # ui we represent is not quite yet dead - return - - if plug == myPlug : - self.__updateLabel() - return - - if plug.isChild(): - if plug.parent() == myPlug : - self.__updateLabel() - return - - def __updateLabel( self ) : - - IECoreMaya.FnParameterisedHolder( self.node() ).setParameterisedValues() - - maya.cmds.iconTextStaticLabel( - self.__popupControl, - edit = True, - label = self.parameter.getCurrentPresetName(), - ) diff --git a/python/IECoreMaya/PresetsUI.py b/python/IECoreMaya/PresetsUI.py deleted file mode 100644 index 3cd9abda9c..0000000000 --- a/python/IECoreMaya/PresetsUI.py +++ /dev/null @@ -1,798 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -from __future__ import division -import os, re - -import maya.cmds - -import IECore - -from .UIElement import UIElement -from .FnParameterisedHolder import FnParameterisedHolder -from .ClassParameterUI import ClassParameterUI -from .ClassVectorParameterUI import ClassVectorParameterUI -from .FnTransientParameterisedHolderNode import FnTransientParameterisedHolderNode - -__all__ = [ 'PresetsUI', 'SavePresetUI', 'LoadPresetUI' ] - -def __savePresetMenuModifierVectorClass( menuDefinition, parent, parameter, node ) : - __savePresetMenuModifier( menuDefinition, parameter, node, parent=parent ) - -def __savePresetMenuModifier( menuDefinition, parameter, node, parent=None ) : - - fnPh = FnParameterisedHolder( node ) - plugPath = fnPh.parameterPlugPath( parameter ) - - if len( list(menuDefinition.items()) ): - menuDefinition.append( "/PresetsDivider", { "divider" : True } ) - - saveItemName = "/Presets/Save Preset..." - loadItemName = "/Presets/Load Preset..." - - # If we are actually a class in a vector, use slightly different names - # so that its more obvious whats going on - ## \todo Add an item to save the class as a preset, rather than its values. - if parent is not None and ( - isinstance( parent, IECore.ClassVectorParameter ) - or isinstance( parent, IECore.ClassParameter ) - ): - saveItemName = "/Presets/Save Parameter Values Preset..." - loadItemName = "/Presets/Load Parameter Values Preset..." - - menuDefinition.append( saveItemName, { "command" : IECore.curry( maya.cmds.evalDeferred, 'import IECoreMaya; IECoreMaya.SavePresetUI( "%s", "%s" )' % ( fnPh.fullPathName(), plugPath ) ) } ) - menuDefinition.append( loadItemName, { "command" : IECore.curry( maya.cmds.evalDeferred, 'import IECoreMaya; IECoreMaya.LoadPresetUI( "%s", "%s" )' % ( fnPh.fullPathName(), plugPath ) ) } ) - -ClassParameterUI.registerClassMenuCallback( __savePresetMenuModifier ) -ClassVectorParameterUI.registerClassMenuCallback( __savePresetMenuModifierVectorClass ) -ClassVectorParameterUI.registerToolsMenuCallback( __savePresetMenuModifier ) - -### @name Wrapper functions -### These wrappers take only string arguments, to allow the PresetsUI -### To be invoked from a evalDeferred call. This is needed to make sure that -### all the tasks performed internally by the UI undo in one step. -### @{ -def SavePresetUI( nodeName, attribute ) : - - fnPh = FnParameterisedHolder( nodeName ) - rootParam = fnPh.plugParameter( attribute ) - - PresetsUI( nodeName, rootParam ).save() - -def LoadPresetUI( nodeName, attribute ) : - - fnPh = FnParameterisedHolder( nodeName ) - rootParam = fnPh.plugParameter( attribute ) - - PresetsUI( nodeName, rootParam ).load() -### @} - -### This class provides a UI for loading and saving presets for nodes -### derived from the ParameterisedHolder class. Currently, it creates -### BasicPresets in one of the locations set in the relevant search -### paths for the Parameterised objects. Categories, and titles aren't -### yet implemented. -### -### \todo Currently, the LoadUI, has to instantiate every preset in the -### search path, and call 'applicableTo'. This is potentially a huge -### bottle neck, so, well see what happens when we use it in earnest... -class PresetsUI() : - - def __init__( self, node, rootParameter=None ) : - - try : - fn = FnParameterisedHolder( node ) - except: - raise ValueError('PresetsUI: "%s" is not a valid Parameterised object.' % node) - - self.__node = node - self.__rootParameter = rootParameter - - ### Call to save a preset. - def save( self ) : - SaveUI( self.__node, self.__rootParameter ) - - ### Call to copy a preset. - ## \param callback, f( preset ), A callable, that will be - ## called with the Preset instance after the user has selected - ## a number of prameters - def copy( self, callback ) : - CopyUI( self.__node, self.__rootParameter, callback ) - - ### Call to load a preset. - def load( self ) : - LoadUI( self.__node, self.__rootParameter ) - - ### Call to select parameters within the current rootParameter - ## \param callback, f( node, rootParameter, parameters ), A Callable, that will be - ## called with the node, and chosed parameters after the user has - ## made their selection. This can be usefull for a variety of cases where - ## it's needed for the user to select parameters within a hierarchy. - def selectParameters( self, callback ) : - SelectUI( self.__node, self.__rootParameter, callback ) - - -# Private implementation classes - -# This is a base class for all the UIs which need to display a list of available parameters -# and obtain a subset which the user is interested in. Thi takes care of drawing a list in -# a form layout. Derived classes can then edit/add to this layout to add additional controls. -# self._fnP will contain a parameterised holder around the node passed to the constructor. -# self._rootParamter will contain the rootParameter passed to the constructor. -# self._form is the main form layout -# self._scroll is the main scroll layout -# self._selector is the actual parameter list -class ParamSelectUI( UIElement ) : - - def __init__( self, node, rootParameter=None, buttonTitle="Select", autoCollapseDepth=2 ) : - - self._fnP = FnParameterisedHolder( node ) - - parameterised = self._fnP.getParameterised() - self._rootParameter = rootParameter if rootParameter else parameterised[0].parameters() - - self._window = maya.cmds.window( - title="%s: %s" % ( buttonTitle, node ), - width=500, - height=600 - ) - - UIElement.__init__( self, self._window ) - - self._form = maya.cmds.formLayout() - - self._scroll = maya.cmds.scrollLayout( parent=self._form ) - - self._selector = ParameterSelector( self._rootParameter, self._scroll, autoCollapseDepth=autoCollapseDepth ) - - maya.cmds.formLayout( self._form, edit=True, - - attachForm=[ ( self._scroll, "top", 0 ), - ( self._scroll, "left", 0 ), - ( self._scroll, "right", 0 ), - ( self._scroll, "bottom", 0 ), ], - ) - -# The SelectUI allows parameter selection, then calls the supplied callback with -# the node, rootParameter, and a list of chosen parameters. The button title can -# be customised with the label argument to the constructor. This may be useful -# outside this file, and can be accessed by the PresetUI.selectParameters() method -# which takes a callback. -class SelectUI( ParamSelectUI ) : - - def __init__( self, node, rootParameter=None, callback=None, label="Select" ) : - - self.__callback = callback - self.__node = node - - ParamSelectUI.__init__( self, node, rootParameter ) - - self.__button = maya.cmds.button( - l=label, - parent=self._form, - height=30, - c=self._createCallback( self.__doAction ) - ) - - maya.cmds.formLayout( self._form, edit=True, - - attachForm=[ ( self._scroll, "top", 0 ), - ( self._scroll, "left", 0 ), - ( self._scroll, "right", 0 ), - ( self.__button, "bottom", 0 ), - ( self.__button, "left", 0 ), - ( self.__button, "right", 0 ) ], - - attachControl=[ ( self._scroll, "bottom", 0, self.__button ), ], - ) - - maya.cmds.showWindow( self._window ) - - def __doAction( self ) : - - parameters = self._selector.getActiveParameters() - - if not parameters : - maya.cmds.confirmDialog( message="Please select at least one paremeter.", button="OK" ) - return - - maya.cmds.deleteUI( self._window ) - - if self.__callback: - self.__callback( self.__node, self._rootParameter, parameters ) - -# The CopyUI extends the selector to create a preset from the users selection, and call a callback -# passing that preset. -class CopyUI( SelectUI ) : - - def __init__( self, node, rootParameter=None, callback=None ) : - - self.__callback = callback - SelectUI.__init__( self, node, rootParameter, callback=self.__copyCallback, label="copy" ) - - # The copy callback simply creates a preset, then forwards this to whatever other callback was registered - def __copyCallback( self, node, rootParameter, parameters ) : - - preset = IECore.BasicPreset( self._fnP.getParameterised()[0], rootParameter, parameters=parameters ) - self.__callback( preset ) - -# The SaveUI extends the selector to add path selection, as well as description and name fields. -class SaveUI( ParamSelectUI ) : - - def __init__( self, node, rootParameter=None, autoCollapseDepth=2 ) : - - fnP = FnParameterisedHolder( node ) - parameterised = fnP.getParameterised() - - self.__envVar = parameterised[3].replace( "_PATHS", "_PRESET_PATHS" ) - - if self.__envVar not in os.environ : - maya.cmds.confirmDialog( message="Environment variable not set:\n\n$%s\n\nPlease set "%self.__envVar+\ - "this variable to point to one or more paths.\nPresets can then be saved to these "+\ - "locations.", button="OK" ) - return - - ParamSelectUI.__init__( self, node, rootParameter, autoCollapseDepth=autoCollapseDepth ) - - self.__location = SearchPathMenu( - os.getenv( self.__envVar ), - self._form, - label = "Save to:", - ann = self.__envVar, - cw = ( 1, 65 ), - adj = 2, - ) - - self.__name = maya.cmds.textFieldGrp( - parent = self._form, - label = "Name:", - adj = 2, - columnWidth = ( 1, 65 ) - ) - - descripLabel = maya.cmds.text( - parent = self._form, - label = "Description:", - align = "left", - ) - - self.__description = maya.cmds.scrollField( - parent = self._form, - numberOfLines = 5, - height = 100, - ) - - self.__saveButton = maya.cmds.button( - l = "Save", - parent = self._form, - height = 30, - c = self._createCallback( self.__doSave ) - ) - - maya.cmds.formLayout( self._form, edit=True, - - attachForm=[ ( self._scroll, "top", 0 ), - ( self._scroll, "left", 0 ), - ( self._scroll, "right", 0 ), - ( self.__location.menu(), "left", 10 ), - ( self.__location.menu(), "right", 10 ), - ( self.__name, "left", 10 ), - ( self.__name, "right", 10 ), - ( descripLabel, "left", 10 ), - ( descripLabel, "right", 10 ), - ( self.__description, "left", 10 ), - ( self.__description, "right", 10 ), - ( self.__saveButton, "bottom", 0 ), - ( self.__saveButton, "left", 0 ), - ( self.__saveButton, "right", 0 ) ], - - attachControl=[ ( self._scroll, "bottom", 5, self.__location.menu() ), - ( self.__location.menu(), "bottom", 3, self.__name ), - ( self.__name, "bottom", 5, descripLabel ), - ( descripLabel, "bottom", 5, self.__description ), - ( self.__description, "bottom", 5, self.__saveButton ), ] - ) - - - maya.cmds.showWindow( self._window ) - - def __doSave( self ) : - - name = maya.cmds.textFieldGrp( self.__name, query=True, text=True ) - if not name: - maya.cmds.confirmDialog( message="Please enter a name for the preset.", button="OK" ) - return - - # Sanitise the name a little - name = name.replace( " ", "_" ) - name = re.sub( '[^a-zA-Z0-9_]*', "", name ) - # We have to also make sure that the name doesnt begin with a number, - # as it wouldn't be a legal class name in the resulting py stub. - name = re.sub( '^[0-9]+', "", name ) - - description = maya.cmds.scrollField( self.__description, query=True, text=True ) - - parameters = self._selector.getActiveParameters() - - if not parameters : - maya.cmds.confirmDialog( message="Select at least one parameter to save.", button="OK" ) - return - - path = self.__location.getValue() - - self._fnP.setParameterisedValues() - - preset = IECore.BasicPreset( - self._fnP.getParameterised()[0], - self._rootParameter, - parameters = parameters - ) - - preset.save( - path, - name, - description = description, - ) - - maya.cmds.deleteUI( self._window ) - - -class LoadUI( UIElement ) : - - def __init__( self, node, rootParameter=None ) : - - fn = FnParameterisedHolder( node ) - parameterised = fn.getParameterised() - - self.__parameterised = parameterised - - # Just using 'not' on a ClassVector takes its length, which equates to False if its empty. - self.__rootParameter = rootParameter if rootParameter is not None else parameterised[0].parameters() - - self.__fnP = fn - self.__envVar = parameterised[3].replace( "_PATHS", "_PRESET_PATHS" ) - - if self.__envVar not in os.environ : - maya.cmds.confirmDialog( message="Environment variable not set:\n\n$%s\n\nPlease set "%self.__envVar+\ - "this variable to point to one or more paths.\nPresets can then be loaded from these "+\ - "locations.", button="OK" ) - return - - paths = os.environ[self.__envVar] - sp = IECore.SearchPath( os.path.expandvars( paths ) ) - self.__classLoader = IECore.ClassLoader( sp ) - - presets = self.__getPresets( parameterised[0], self.__rootParameter ) - if not presets: - maya.cmds.confirmDialog( message="No presets applicable to %s found in the current search paths ($%s)." % ( self.__rootParameter.name, self.__envVar ), button="OK" ) - return - - self.__loadedPresets = {} - - self.__window = maya.cmds.window( title="Load: %s" % node, width=300, height=500 ) - - UIElement.__init__( self, self.__window ) - - self.__form = maya.cmds.formLayout() - - self.__infoColumn = PresetInfo( parent=self.__form ) - self.__selector = PresetSelector( presets, self.__form, allowMultiSelection=True, selectCommand=self._createCallback( self.__selectionChanged ) ) - self.__loadButton = maya.cmds.button( l="Load", parent=self.__form, height=30, c=self._createCallback( self.__doLoad ) ) - - if not presets: - maya.cmds.control( self.__loadButton, edit=True, enable=False ) - - maya.cmds.formLayout( self.__form, edit=True, - - attachForm=[ ( self.__selector.list(), "top" , 0 ), - ( self.__selector.list(), "left" , 0 ), - ( self.__selector.list(), "right" , 0 ), - ( self.__infoColumn.layout(), "left" , 5 ), - ( self.__infoColumn.layout(), "right" , 0 ), - ( self.__loadButton, "bottom", 0 ), - ( self.__loadButton, "left" , 0 ), - ( self.__loadButton, "right" , 0 ) ], - - attachControl=[ ( self.__selector.list(), "bottom", 4, self.__infoColumn.layout() ), - ( self.__infoColumn.layout(), "bottom", 5, self.__loadButton ), ] - ) - - maya.cmds.showWindow( self.__window ) - - def __selectionChanged( self, *args ) : - - self.__loadedPresets = {} - - classNames = self.__classLoader.classNames() - selected = [ s for s in self.__selector.selected() if s in classNames ] - presets = [] - for s in selected: - self.__loadedPresets[s] = self.__classLoader.load( s )() - presets.append( self.__loadedPresets[s] ) - - self.__infoColumn.setPresets( presets ) - - def __doLoad( self ) : - - loaded = list(self.__loadedPresets.keys()) - selected = [ s for s in self.__selector.selected() if s in loaded ] - - if not selected : - maya.cmds.confirmDialog( message="Please select at least one preset to load.", button="OK" ) - return - - parameterised = self.__fnP.getParameterised()[0] - - # Make sure the any parameter changes get set back into - # the parameterised objects for each preset. - self.__infoColumn.commitParameters() - - # We need to make sure we have the right values in the first place. - self.__fnP.setParameterisedValues() - - with self.__fnP.parameterModificationContext() : - - for s in selected: - # These should have been loaded by the selectCommand callback - self.__loadedPresets[s]( self.__parameterised, self.__rootParameter ) - - maya.cmds.deleteUI( self.__window ) - self.__loadedPrestes = {} - - def __getPresets( self, parameterised, parameter ) : - - validPresets = [] - - self.__classLoader.refresh() - presets = self.__classLoader.classNames( "*" ) - - for name in presets: - p = self.__classLoader.load( name )() - if not isinstance( p, IECore.Preset ): - continue - if p.applicableTo( parameterised, parameter ): - validPresets.append( ( name, p ) ) - - return validPresets - -# Extracts metadata from a preset, and displays in a layout, complete -# with a UI for any parameters of the preset. Any selected presets -# are temporarily instantiated into a FnTransientParameterisedHolderNode. -class PresetInfo() : - - def __init__( self, parent=None ) : - - oldParent = maya.cmds.setParent( q=True ) - if not parent : - parent = oldParent - - maya.cmds.setParent( parent ) - - self.__parent = parent - self.__layout = maya.cmds.columnLayout( co=( "both", 5 ), adj=True ) - - maya.cmds.setParent( oldParent ) - - def layout( self ): - return self.__layout - - def setPresets( self, presets=() ) : - - children = maya.cmds.columnLayout( self.__layout, q=True, ca=True ) - if children : - for c in children: - maya.cmds.deleteUI( c ) - - self.__parameterHolders = {} - - for p in presets: - - meta = p.metadata() - - name = meta["title"] if "description" in meta else p.__class__ - - maya.cmds.text( - parent = self.__layout, - label = name, - font = "boldLabelFont", - recomputeSize = True, - align = "left" - ) - - wrapWidth = ( int(maya.cmds.layout( self.__parent, query=True, width=True )) - 5 ) // 5 - - if "description" in meta and meta["description"]: - descripWrap = IECore.StringUtil.wrap( meta["description"], wrapWidth ) - lines = descripWrap.split( "\n" ) - for l in lines: - maya.cmds.text( parent=self.__layout, label=l, font="smallPlainLabelFont", align="left" ) - - maya.cmds.separator( - parent = self.__layout, - width = 5, - height = 10, - style = "none", - ) - - if len( list(p.parameters().keys()) ) : - self.__parameterHolders[ name ] = FnTransientParameterisedHolderNode.create( self.__layout, p ) - - # This must be called before querying the parameters of any presets passed to this UI - # section, in order to update the Parameterised object with any changed made in the UI - def commitParameters( self ) : - - for s in self.__parameterHolders.keys(): - self.__parameterHolders[s].setParameterisedValues() - del self.__parameterHolders[s] - -# Provides an optionMenu to select from paths in the supplied search path string. -class SearchPathMenu() : - - # *args, **kwargs are passed to maya.cmds.optionMenuGrp on creation. - def __init__( self, searchPaths, parent=None, *args, **kwargs ) : - - oldParent = maya.cmds.setParent( q=True ) - if not parent : - parent = oldParent - - maya.cmds.setParent( parent ) - - self.__menu = maya.cmds.optionMenuGrp( *args, **kwargs ) - - for p in searchPaths.split( os.pathsep ) : - maya.cmds.menuItem( label = p ) - - maya.cmds.setParent( oldParent ) - - def setValue( self, value ) : - maya.cmds.optionMenuGrp( self.__menu, edit=True, value=value ) - - def getValue( self ) : - return maya.cmds.optionMenuGrp( self.__menu, query=True, value=True ) - - def menu( self ): - return self.__menu - -# Provides a simple list of the supplied presets -class PresetSelector( UIElement ) : - - # *args, **kwargs are passed to maya.cmds.textScrollList on creation. - def __init__( self, presets, parent=None, *args, **kwargs ) : - - oldParent = maya.cmds.setParent( q=True ) - if not parent : - parent = oldParent - - maya.cmds.setParent( parent ) - - self.__list = maya.cmds.textScrollList( *args, **kwargs ) - UIElement.__init__( self, self.__list ) - - if not presets: - - maya.cmds.textScrollList( - self.__list, - edit=True, - append="No presets found...", - enable=False - ) - - else : - presetsByPath = {} - for ( name, p ) in presets : - print(name, p) - path = os.path.dirname( p._cob ).rpartition( p.typeName() )[0] - if path not in presetsByPath : - presetsByPath[path] = [] - presetsByPath[path].append( name ) - - for ( path, names ) in presetsByPath.items() : - - maya.cmds.textScrollList( self.__list, edit=True, append=path ) - - for name in names : - - maya.cmds.textScrollList( self.__list, edit=True, append=name ) - - maya.cmds.textScrollList( self.__list, edit=True, append="" ) - - maya.cmds.setParent( oldParent ) - - # \return A list of selected names - def selected( self ) : - - selection = maya.cmds.textScrollList( self.__list, query=True, selectItem=True ) - if not selection: - return [] - else: - return selection - - # \return The Maya ELF handle for the list. - def list( self ) : - return self.__list - -# Provides a maya.cmds.columnLayout containing a hierarchical selection -# interface for the supplied parameter. Each parameter is presented with -# A checkbox to allow selection. -class ParameterSelector( UIElement ) : - - def __init__( self, parameter, parent=None, autoCollapseDepth=2 ) : - - oldParent = maya.cmds.setParent( query=True ) - - if not parent : - parent = oldParent - - self.__mainColumn = maya.cmds.columnLayout( adj=True, parent=parent ) - - if isinstance( parameter, IECore.CompoundParameter ) : - self.__controls = ParameterSelector.ParameterGroup( parameter, autoCollapseDepth=autoCollapseDepth ) - else : - self.__controls = ParameterSelector.Parameter( parameter ) - - maya.cmds.setParent( oldParent ) - - # \return A list of the selected parameters. - def getActiveParameters( self ) : - return self.__controls.getActiveParameters() - - # Provides an interface for selecting an individual parameter. - class Parameter() : - - def __init__( self, parameter, **kw ) : - - self.__depth = kw["depth"] if "depth" in kw else 0 - - self.__checkbox = maya.cmds.checkBox( label=parameter.name, align="left", value=True ) - self.__parameter = parameter - - # Sets the active state of the parameter - def setState( self, state ) : - maya.cmds.checkBox( self.__checkbox, edit=True, value=state ) - - # Returns the active state of the parameter - def getState( self ) : - - state = maya.cmds.checkBox( self.__checkbox, query=True, value=True ) - if state: - return True - else : - return False - - # \return the IECore Parameter represented by the control. - def parameter( self ) : - return self.__parameter - - # \return Either an empty list, or a list with the parameter, depending - # on its state. The list syntax is used for interchangeability with the - # ParameterGroup class. - def getActiveParameters( self ) : - if self.getState(): - return [ self.__parameter ] - else: - return [] - - # Provides a hierarchical interface for selecting parameters in a CompoundParameter - class ParameterGroup( UIElement ) : - - def __init__( self, compoundParameter, **kw ) : - - self.__depth = kw["depth"] if "depth" in kw else 0 - self.__autoCollapseDepth = kw["autoCollapseDepth"] if "autoCollapseDepth" in kw else 2 - self.__parameter = compoundParameter - - self.__row = maya.cmds.rowLayout( numberOfColumns = 2, columnWidth=( 1, 20 ) ) - - UIElement.__init__( self, self.__row ) - - self.__checkbox = maya.cmds.checkBox( label = "", cc=self._createCallback( self.syncState ), value=True ) - - name = compoundParameter.name if compoundParameter.name else "All Parameters" - if "label" in compoundParameter: - name = compoundParameter["label"].getTypedValue() - - collapsed = False if self.__depth < self.__autoCollapseDepth else True - - self.__frame = maya.cmds.frameLayout( - label = name, - labelIndent = 5, - marginWidth = 5, - borderVisible = False, - collapsable = True, - collapse = collapsed, - ) - - self.__column = maya.cmds.columnLayout( adj=True ) - - self.__children = {} - for p in compoundParameter.values() : - - if isinstance( p, IECore.CompoundParameter ) : - self.__children[ p.name ] = ParameterSelector.ParameterGroup( - p, - depth = self.__depth+1, - autoCollapseDepth = self.__autoCollapseDepth - ) - - else: - self.__children[ p.name ] = ParameterSelector.Parameter( p, depth=self.__depth+1 ) - - maya.cmds.setParent( ".." ) - maya.cmds.setParent( ".." ) - maya.cmds.setParent( ".." ) - - maya.cmds.separator( style="none", height=3 ) - - # Called by a callback or directly, to set the state of all child - # parameters of the CompundParameter. If a state is not provided - # then the curent checked state of the group is propogated - def syncState( self, state=None ): - - if state == None: - state = self.getState() - - for p in self.__children.values() : - p.setState( state ) - - # Can be called to set the state of the group and its children. - def setState( self, state ) : - maya.cmds.checkBox( self.__checkbox, edit=True, value=state ) - self.syncState( state ) - - # \return (Bool) The checked state of the group itself. Note, this does not - # take into account whether or not any children are checked. - def getState( self ) : - - state = maya.cmds.checkBox( self.__checkbox, query=True, value=True ) - if state == 1 : - return True - else : - return False - - # \return A list of active parameters in the group. - def getActiveParameters( self ) : - - params = [] - - if self.getState(): - params.append( self.__parameter ) - - for p in self.__children.values() : - params.extend( p.getActiveParameters() ) - - return params - - diff --git a/python/IECoreMaya/RefreshDisabled.py b/python/IECoreMaya/RefreshDisabled.py deleted file mode 100644 index 3d907c106a..0000000000 --- a/python/IECoreMaya/RefreshDisabled.py +++ /dev/null @@ -1,71 +0,0 @@ -########################################################################## -# -# Copyright (c) 2016, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools - -import maya.cmds - -# TODO: This can be simplified with contextlib.contextmanager in python3 -class RefreshDisabled( object ) : - """Context Manager / Decorator which disables maya's refresh - - This manager ensures that maya's display is suspended during the execution - of the block. The display will be restored upon exiting the block. - - Note: There is no way of detecting the current state of the display, so - upon exit, the display is always restored to on. - - .. code-block:: python - - @RefreshDisabled() - def doWork(): - pass - - with RefreshDisabled(): - pass - - """ - def __enter__( self ) : - maya.cmds.refresh( suspend=True ) - - def __exit__( self, type, value, traceBack ) : - maya.cmds.refresh( suspend=False ) - return False - - def __call__( self, callable ): - @functools.wraps( callable ) - def managed_callable( *args, **kwargs ): - with self: - return callable( *args, **kwargs ) - return managed_callable diff --git a/python/IECoreMaya/SceneShapeUI.py b/python/IECoreMaya/SceneShapeUI.py deleted file mode 100644 index f25ca61122..0000000000 --- a/python/IECoreMaya/SceneShapeUI.py +++ /dev/null @@ -1,429 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## -import functools - -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya - -__dagMenuCallbacks = [] -## Registers a callback to be used when creating the right click dag -# menu for scene shapes. Callbacks should have the following signature : -# -# callback( menuDefinition, sceneShape ). -def addDagMenuCallback( callback ) : - - if not callback in __dagMenuCallbacks : - __dagMenuCallbacks.append( callback ) - -## Removes a callback previously added with addDagMenuCallback. -def removeDagMenuCallback( callback ) : - IECore.warning("'SceneShapeUI.removeDagMenuCallback' has been deprecated. Menu callbacks cannot be removed anymore in the future.") - __dagMenuCallbacks.remove( callback ) - -def _menuDefinition( callbackShape ) : - sceneShapes = __selectedSceneShapes() - if not sceneShapes : - return - - mainDef = IECore.MenuDefinition() - - fnShapes = [ IECoreMaya.FnSceneShape( shape ) for shape in sceneShapes ] - - # INVALID SHAPES - invalidSceneShapes = __invalidSceneShapes( sceneShapes ) - if invalidSceneShapes : - mainDef.append( "/Invalid Inputs for selected SceneShapes!", { "blindData" : { "maya" : { "radialPosition" : "N" } } } ) - return mainDef - - # COMPONENT MODE - if fnShapes[ 0 ].selectedComponentNames() : - mainDef.append( "/Object", { "blindData" : { "maya" : { "radialPosition" : "N" } }, "command" : functools.partial( __objectCallback, sceneShapes[ 0 ] ) } ) - mainDef.append( "/Print Component Names", { "blindData" : { "maya" : { "radialPosition" : "NW" } }, "command" : functools.partial( __printComponents, sceneShapes[ 0 ] ) } ) - mainDef.append( "/Print Selected Component Names", { "blindData" : { "maya" : { "radialPosition" : "NE" } }, "command" : functools.partial( __printSelectedComponents, sceneShapes[ 0 ] ) } ) - - # EXPAND - expandDef = IECore.MenuDefinition( [ - ("/Expand to Selected Components", { "blindData" : { "maya" : { "radialPosition" : "S" } }, "command" : functools.partial( __expandToSelected, sceneShapes[ 0 ] ) }), - ] ) - mainDef.append( "/Expand...", { "blindData" : { "maya" : { "radialPosition" : "SE" } }, "subMenu" : expandDef } ) - - locatorDef = IECore.MenuDefinition( [ - ("/At Bound Min", { "blindData" : { "maya" : { "radialPosition" : "N" } }, "command" : functools.partial( __createLocatorAtPoints, sceneShapes[ 0 ], [ "Min" ] ) }), - ("/At Bound Max", { "blindData" : { "maya" : { "radialPosition" : "NE" } }, "command" : functools.partial( __createLocatorAtPoints, sceneShapes[ 0 ], [ "Max" ] ) }), - ("/At Bound Min And Max", { "blindData" : { "maya" : { "radialPosition" : "E" } }, "command" : functools.partial( __createLocatorAtPoints, sceneShapes[ 0 ], [ "Min", "Max" ] ) }), - ("/At Bound Centre", { "blindData" : { "maya" : { "radialPosition" : "SE" } }, "command" : functools.partial( __createLocatorAtPoints, sceneShapes[ 0 ], [ "Center" ] ) }), - ("/At Transform Origin", { "blindData" : { "maya" : { "radialPosition" : "S" } }, "command" : functools.partial( __createLocatorWithTransform, sceneShapes[ 0 ] ) }), - ] ) - mainDef.append( "/Create Locator", { "blindData" : { "maya" : { "radialPosition" : "SW" } }, "subMenu" : locatorDef } ) - - # OBJECT MODE - else : - # PREVIEW - if len( sceneShapes ) == 1 and (maya.cmds.getAttr( sceneShapes[ 0 ] + ".drawGeometry" ) or maya.cmds.getAttr( sceneShapes[ 0 ] + ".drawChildBounds" )) : - mainDef.append( "/Component", { "blindData" : { "maya" : { "radialPosition" : "N" } }, "command" : functools.partial( __componentCallback, sceneShapes[ 0 ] ) } ) - - previewDef = IECore.MenuDefinition( [ - ("/All Geometry On", { "blindData" : { "maya" : { "radialPosition" : "E" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawGeometry", True ) }), - ("/All Child Bounds On", { "blindData" : { "maya" : { "radialPosition" : "SE" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawChildBounds", True ) }), - ("/All Root Bound On", { "blindData" : { "maya" : { "radialPosition" : "NE" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawRootBound", True ) }), - ("/All Geometry Off", { "blindData" : { "maya" : { "radialPosition" : "W" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawGeometry", False ) }), - ("/All Child Bounds Off", { "blindData" : { "maya" : { "radialPosition" : "SW" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawChildBounds", False ) }), - ("/All Root Bound Off", { "blindData" : { "maya" : { "radialPosition" : "NE" } }, "command" : functools.partial( __setChildrenPreviewAttributes, sceneShapes, "drawRootBound", False ) }) - ] ) - - mainDef.append( "/Preview...", { "blindData" : { "maya" : { "radialPosition" : "NW" } }, "subMenu" : previewDef } ) - - # get all tags that are shared between all shapes - commonTags = None - for fn in fnShapes : - scene = fn.sceneInterface() - tmpTags = scene.readTags( IECoreScene.SceneInterface.EveryTag ) - if commonTags is None : - commonTags = set( tmpTags ) - else : - commonTags.intersection_update( set( tmpTags ) ) - - tagTree = dict() - if commonTags : - for tag in commonTags : - tag = str( tag ) - namespace, _, subTagsString = tag.partition( ':' ) - subTags = set( subTagsString.split( ':' ) ) - if not namespace in tagTree : - tagTree[ namespace ] = subTags - else : - tagTree[ namespace ].update( subTags ) - - # EXPAND - expandDef = IECore.MenuDefinition( - [ ("/Recursive Expand As Geometry", { "blindData" : { "maya" : { "radialPosition" : "W" } }, "command" : functools.partial( _expandAsGeometry, sceneShapes)})] ) - mainDef.append( "/Expand...", { "blindData" : { "maya" : { "radialPosition" : "SE" } }, "subMenu" : expandDef } ) - - if any( [x.canBeExpanded() for x in fnShapes] ) : - - expandDef.append( "/Expand One Level", { "blindData" : { "maya" : { "radialPosition" : "S" } }, "command" : functools.partial( __expandOnce, sceneShapes ) } ) - expandDef.append( "/Recursive Expand", { "blindData" : { "maya" : { "radialPosition" : "E" } }, "command" : functools.partial( _expandAll, sceneShapes)}) - - if len( sceneShapes ) == 1 and fnShapes[ 0 ].selectedComponentNames() : - expandDef.append( "/Expand to Selected Components", { "blindData" : { "maya" : { "radialPosition" : "S" } }, "command" : functools.partial( __expandToSelected, sceneShapes[ 0 ] ) } ) - - if tagTree : - tags = list(tagTree.keys()) - tags.sort() - - def addTagSubMenuItems( menuDef, command ) : - import copy - copiedTagTree = copy.deepcopy( tagTree ) - for tag in tags : - subtags = list( copiedTagTree[ tag ] ) - subtags.sort() - - for subtag in subtags : - if subtag == '' : - label = "/{}".format( tag ) - expandTag = tag - else : - label = "/{}/{}".format( tag, subtag ) - expandTag = "{}:{}".format( tag, subtag ) - menuDef.append( label, { "command" : functools.partial( command, sceneShapes, expandTag ) } ) - - filterDef = IECore.MenuDefinition( [ - ("/Display All", { "command" : functools.partial( _setTagsFilterPreviewAttributes, sceneShapes, "")}) - ] ) - expandTagDef = IECore.MenuDefinition() - expandTagGeoDef = IECore.MenuDefinition() - mainDef.append( "/Tags filter...", { "blindData" : { "maya" : { "radialPosition" : "S" } }, "subMenu" : filterDef } ) - - addTagSubMenuItems( filterDef, _setTagsFilterPreviewAttributes) - addTagSubMenuItems( expandTagDef, _expandAll) - addTagSubMenuItems( expandTagGeoDef, _expandAsGeometry) - - expandDef.append( "/Expand by Tag...", { "blindData" : { "maya" : { "radialPosition" : "SE" } }, "subMenu" : expandTagDef } ) - expandDef.append( "/Expand by Tag as Geo...", { "blindData" : { "maya" : { "radialPosition" : "SW" } }, "subMenu" : expandTagGeoDef } ) - - parentSceneShape = __parentSceneShape( sceneShapes ) - - # COLLAPSE - if any( [x.canBeCollapsed() for x in fnShapes] ) or (parentSceneShape and IECoreMaya.FnSceneShape( parentSceneShape ).canBeCollapsed()) : - - collapseDef = IECore.MenuDefinition() - - if parentSceneShape and IECoreMaya.FnSceneShape( parentSceneShape ).canBeCollapsed() : - parentName = maya.cmds.listRelatives( parentSceneShape, p = True )[ 0 ] - collapseDef.append( "/Collapse to Parent: {}".format( parentName ), - { "blindData" : { "maya" : { "radialPosition" : "N" } }, "command" : functools.partial( __collapseChildren, [ parentSceneShape ] ) } ) - - if any( [x.canBeCollapsed() for x in fnShapes] ) : - collapseDef.append( "/Collapse Children", { "blindData" : { "maya" : { "radialPosition" : "W" } }, "command" : functools.partial( __collapseChildren, sceneShapes ) } ) - - mainDef.append( "/Collapse...", { "blindData" : { "maya" : { "radialPosition" : "SW" } }, "subMenu" : collapseDef } ) - - return mainDef - - -## This is forwarded to by the ieSceneShapeDagMenuProc function in -# ieSceneShape.mel -def _dagMenu( parentMenu, sceneShape ) : - menuDef = _menuDefinition( sceneShape ) - if not menuDef : - return - - # Pass menu definition to registered callbacks to collect changes / additions - for callback in __dagMenuCallbacks : - callback( menuDef, sceneShape ) - - # build menu from menu definition - cortexMenu = IECoreMaya.Menu( menuDef, parentMenu, keepCallback = True ) - - -## Returns all the sceneShapes that do not have a valid scene interface -def __invalidSceneShapes( sceneShapes ): - - invalid = [] - for sceneShape in sceneShapes: - fn = IECoreMaya.FnSceneShape( sceneShape ) - if fn.sceneInterface() is None: - invalid.append( sceneShape ) - return invalid - -## Returns all the selected scene shapes -def __selectedSceneShapes() : - - allSceneShapes = set() - - for shape in maya.cmds.ls( sl=True, l=True ): - # Make sure we have the shape name, it could be a component - shapeName, _, _ = shape.partition(".f[") - if maya.cmds.objectType( shapeName ) == "ieSceneShape": - allSceneShapes.add( shapeName ) - else: - children = maya.cmds.listRelatives( shapeName, children=True, type="ieSceneShape", fullPath=True ) or [] - allSceneShapes.update(children) - return list(allSceneShapes) - -## Turns on child bounds and switches to component mode -def __componentCallback( sceneShape, *unused ) : - - parent = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True )[0] - maya.cmds.selectType( objectComponent=True, allComponents=False, facet=True ) - maya.cmds.hilite( parent ) - - maya.cmds.select( clear=True ) - -## Switches to object mode -def __objectCallback( sceneShape, *unused ) : - - parent = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True )[0] - maya.cmds.hilite( parent, unHilite=True ) - selection = maya.cmds.ls( selection=True ) - maya.cmds.selectMode( object=True ) - if selection : - maya.cmds.select( selection, replace=True ) - else : - maya.cmds.select( clear=True ) - -## Print the existing component names for the scene shape -def __printComponents( sceneShape, *unused ) : - - fnS = IECoreMaya.FnSceneShape( sceneShape ) - names = fnS.componentNames() - names.sort() - print("\n") - print(" ".join( names ), end=' ') - print("\n") - -## Print the selected component names for the scene shape -def __printSelectedComponents( sceneShape, *unused ) : - - fnS = IECoreMaya.FnSceneShape( sceneShape ) - selectedNames = fnS.selectedComponentNames() - if selectedNames: - selectedNames = list( selectedNames ) - selectedNames.sort() - print("\n") - print(" ".join( selectedNames ), end=' ') - print("\n") - -## Expand each scene shape one level down -def __expandOnce( sceneShapes, *unused ) : - - toSelect = [] - for sceneShape in sceneShapes: - fnS = IECoreMaya.FnSceneShape( sceneShape ) - new = fnS.expandOnce( preserveNamespace=True ) - toSelect.extend( [x.fullPathName() for x in new] ) - if toSelect: - maya.cmds.select( toSelect, replace=True ) - -## Recursively expand the scene shapes -def _expandAll( sceneShapes, tagName=None, *unused) : - - toSelect = [] - for sceneShape in sceneShapes: - fnS = IECoreMaya.FnSceneShape( sceneShape ) - newFn = fnS.expandAll( preserveNamespace=True, tagName=tagName ) - - toSelect.extend( [x.fullPathName() for x in newFn] ) - if toSelect: - maya.cmds.select( toSelect, replace=True ) - -## Recursively expand the scene shapes and converts objects to geometry -def _expandAsGeometry( sceneShapes, tagName=None, *unused) : - - for sceneShape in sceneShapes: - fnS = IECoreMaya.FnSceneShape( sceneShape ) - fnS.convertAllToGeometry( True, tagName ) - -## Expand the scene shape the minimal amount to reach the selected components -def __expandToSelected( sceneShape, *unused ) : - - fnScS = IECoreMaya.FnSceneShape( sceneShape ) - sceneShape = fnScS.fullPathName() - selectedNames = fnScS.selectedComponentNames() - if not selectedNames: - return - - if "/" in selectedNames: - selectedNames.remove("/") - - # Go back to object mode - parent = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True )[0] - maya.cmds.hilite( parent, unHilite=True ) - maya.cmds.selectMode( object=True ) - - if selectedNames == []: - return - - toSelect = [] - - for selected in selectedNames: - transformName = parent - transformNames = [ transformName ] - for item in selected.split("/")[1:-1]: - transformName = transformName + "|" + item - if not transformName in transformNames: - transformNames.append( transformName ) - - for transform in transformNames: - shape = maya.cmds.listRelatives( transform, fullPath=True, type = "ieSceneShape" )[0] - fnS = IECoreMaya.FnSceneShape( shape ) - fnS.expandOnce() - - toSelect.append( transformNames[-1] ) - if toSelect: - maya.cmds.select( toSelect, replace=True ) - -## Collapse all the children of the scene shapes -def __collapseChildren( sceneShapes, *unused ) : - - for sceneShape in sceneShapes: - fnS = IECoreMaya.FnSceneShape( sceneShape ) - fnS.collapse() - -## Returns the first common parent scene shape for the given scene shapes -# Returns None if no parent found. -def __parentSceneShape( sceneShapes ): - - def getParentShapes( transform, allParentShapes ): - parent = maya.cmds.listRelatives( transform, p=True, fullPath=True ) - if parent: - parentShape = maya.cmds.listRelatives( parent[0], fullPath=True, type = "ieSceneShape" ) - if parentShape: - allParentShapes.append( parentShape[0] ) - getParentShapes( parent[0], allParentShapes ) - - parents = None - for sceneShape in sceneShapes: - transform = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True ) - if transform: - allParentShapes = [] - getParentShapes( transform[0], allParentShapes ) - if parents is None: - parents = set( allParentShapes ) - else: - parents.intersection_update( set(allParentShapes) ) - if parents: - parent = "" - for p in parents: - if p.count("|") > parent.count("|"): - parent = p - return parent - - return None - -## Sets the given preview attribute on the scene shapes with the given boolean value -# Preview attributes can be drawGeometry, drawLocators, drawRootBound and drawChildBounds -def __setChildrenPreviewAttributes( sceneShapes, attributeName, value, *unused ) : - - for sceneShape in sceneShapes: - transform = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True ) - if transform: - allChildren = maya.cmds.listRelatives( transform[0], ad=True, fullPath=True, type = "ieSceneShape" ) or [] - for node in allChildren: - maya.cmds.setAttr( node+"."+attributeName, value ) - -## Sets the given tags filter attribute on the scene shapes with the given string value -def _setTagsFilterPreviewAttributes( sceneShapes, tagName, *unused) : - - for sceneShape in sceneShapes: - transform = maya.cmds.listRelatives( sceneShape, parent=True, fullPath=True ) - if transform: - allChildren = maya.cmds.listRelatives( transform[0], ad=False, fullPath=True, type = "ieSceneShape" ) or [] - for node in allChildren: - maya.cmds.setAttr( node+".drawTagsFilter", tagName, type = "string" ) - -def __createLocatorAtPoints( sceneShape, childPlugSuffixes, *unused ) : - - fnSc = IECoreMaya.FnSceneShape( sceneShape ) - selectedNames = fnSc.selectedComponentNames() - - locators = [] - for name in selectedNames : - locators.extend( fnSc.createLocatorAtPoints( name, childPlugSuffixes ) ) - - maya.cmds.select( locators, replace=True ) - -def __createLocatorWithTransform( sceneShape, *unused ) : - - fnSc = IECoreMaya.FnSceneShape( sceneShape ) - selectedNames = fnSc.selectedComponentNames() - - locators = [] - for name in selectedNames : - locators.append( fnSc.createLocatorAtTransform( name ) ) - - maya.cmds.select( locators, replace=True ) diff --git a/python/IECoreMaya/ScopedSelection.py b/python/IECoreMaya/ScopedSelection.py deleted file mode 100644 index e833adc667..0000000000 --- a/python/IECoreMaya/ScopedSelection.py +++ /dev/null @@ -1,60 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import weakref - -## It's common to need to save the current maya selection, change it, and restore -# the old selection afterwards. This is error prone, especially when taking exception -# handling into account. The ScopedSelection object saves the selection when it's -# created, and restores it when it dies. -## \todo Cope with objects changing names, being deleted etc - can probably do this -# by storing DagNode and Node objects. -## \todo This should be reimplemented as a context object called SelectionSaved to -# follow the model set by UndoDisabled. -class ScopedSelection : - - def __init__( self ) : - - selection = maya.cmds.ls( selection=True ) - ScopedSelection.__selections[weakref.ref(self, ScopedSelection.__weakRefCallback)] = selection - - @classmethod - def __weakRefCallback( cls, w ) : - - maya.cmds.select( cls.__selections[w], replace=True ) - del cls.__selections[w] - - __selections = {} - diff --git a/python/IECoreMaya/SplineParameterUI.py b/python/IECoreMaya/SplineParameterUI.py deleted file mode 100644 index 108d810f6d..0000000000 --- a/python/IECoreMaya/SplineParameterUI.py +++ /dev/null @@ -1,135 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya -import maya.cmds -from .ParameterUI import ParameterUI -import re - -class SplineParameterUI( ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - ParameterUI.__init__( - - self, - node, - parameter, - maya.cmds.rowLayout( - numberOfColumns = 3, - rowAttach = [ ( 1, "top", 0 ), ( 2, "both", 0 ), ( 3, "both", 0 ) ] - ), - **kw - - ) - - maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - ) - - self.__gradientControl = maya.cmds.gradientControl() - self.__button = maya.cmds.button( label = ">") - self.__editWindow = None - - self.replace( node, parameter ) - - def replace( self, node, parameter ) : - - if not parameter.isSame( self.parameter ) : - if self.__editWindow : - maya.cmds.deleteUI( self.__editWindow, window=True ) - self.__editWindow = None - - ParameterUI.replace( self, node, parameter ) - - maya.cmds.gradientControl( self.__gradientControl, edit=True, attribute=self.plugName() ) - maya.cmds.button( self.__button, edit=True, command=self.__openEditWindow ) - - ## Returns True if we're a color ramp and False if we're a greyscale curve. - def __colored( self ) : - - plugName = self.plugName() - attrName = plugName.split( "." )[-1] - return maya.cmds.objExists( plugName + "[0]." + attrName + "_ColorR" ) - - def __openEditWindow( self, unused ) : - - if not self.__editWindow : - - editWindowName = re.sub( r"[|.]" , "_", self.plugName() ) - if maya.cmds.window( editWindowName, q=True, exists=True ): - maya.cmds.deleteUI( editWindowName ) - - self.__editWindow = maya.cmds.window( editWindowName, title=self.nodeName() + " " + self.label(), retain=True, widthHeight=[ 600, 300 ] ) - - layout = maya.cmds.formLayout() - - positionControl = maya.cmds.attrFieldSliderGrp( label = "Selected position", columnWidth=[ ( 1, 100 ) ] ) - - if self.__colored() : - valueControl = maya.cmds.attrColorSliderGrp( label = "Selected colour", showButton=False, columnWidth=[ ( 1, 90 ) ] ) - else : - valueControl = maya.cmds.attrFieldSliderGrp( label = "Selected value", columnWidth=[ ( 1, 90 ) ] ) - - gradientControl = maya.cmds.gradientControl( - attribute=self.plugName(), - selectedColorControl=valueControl, - selectedPositionControl=positionControl - ) - - maya.cmds.formLayout( layout, - edit=True, - attachForm = [ - ( positionControl, "left", 5 ), - ( positionControl, "bottom", 15 ), - ( valueControl, "bottom", 15 ), - ( gradientControl, "top", 5 ), - ( gradientControl, "left", 5 ), - ( gradientControl, "right", 5 ), - ], - attachControl = [ - ( gradientControl, "bottom", 5, positionControl ), - ( valueControl, "left", 5, positionControl ), - ] - ) - maya.cmds.showWindow( self.__editWindow ) - -ParameterUI.registerUI( IECore.TypeId.SplinefColor3fParameter, SplineParameterUI ) -ParameterUI.registerUI( IECore.TypeId.SplinefColor4fParameter, SplineParameterUI ) -ParameterUI.registerUI( IECore.TypeId.SplineffParameter, SplineParameterUI ) -ParameterUI.registerUI( IECore.TypeId.SplineddParameter, SplineParameterUI ) diff --git a/python/IECoreMaya/StringParameterUI.py b/python/IECoreMaya/StringParameterUI.py deleted file mode 100644 index 23d2832e40..0000000000 --- a/python/IECoreMaya/StringParameterUI.py +++ /dev/null @@ -1,174 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import fnmatch -import re - -import maya.cmds - -import IECore -import IECoreMaya - -## A UI for StringParameters. Supports the following parameter user data : -# -# BoolData ["UI"]["acceptsNodeName"] False -# When true, menu items will be created to set the value to the name of -# a node in the scene. -# -# BoolData ["UI"]["acceptsNodeNames"] False -# When true, menu items will be created to set the value to the names of -# a number of nodes in the scene. -# -# StringVectorData ["UI"]["acceptedNodeTypes"] [] -# A list of node types to be considered by the "acceptsNodeName" and -# "acceptsNodeNames" features. -# -# StringData ["UI"]["acceptedNodeNameFormat"] "partial" -# Specifies either "partial" or "full", to define whether the shortest -# unique node name will be used for the features above, or whether -# the full path will be used. Specify "parent" or "parentPartial" or -# "parentFull" to get the direct transform parent node path. "parent" -# behaves the same as "parentPartial". -class StringParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ): - - IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.rowLayout( numberOfColumns = 2 ), **kw ) - - self.__label = maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - ) - - self.__textField = maya.cmds.textField() - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - maya.cmds.connectControl( self.__textField, self.plugName() ) - self._addPopupMenu( parentUI=self.__textField, attributeName = self.plugName() ) - - # The popup on the text field itself seems not to be working, so also add it to the - # label in the mean time. - self._addPopupMenu( parentUI=self.__label, attributeName = self.plugName(), button1 = True ) - - def _popupMenuDefinition( self, **kw ) : - - definition = IECoreMaya.ParameterUI._popupMenuDefinition( self, **kw ) - - if not maya.cmds.getAttr( self.plugName(), settable=True ) : - return definition - - wantsNodeName = False - with IECore.IgnoredExceptions( KeyError ) : - wantsNodeName = self.parameter.userData()["UI"]["acceptsNodeName"].value - - wantsNodeNames = False - with IECore.IgnoredExceptions( KeyError ) : - wantsNodeNames = self.parameter.userData()["UI"]["acceptsNodeNames"].value - - if wantsNodeName or wantsNodeNames : - - lskw = {} - with IECore.IgnoredExceptions( KeyError ) : - lskw["type"] = list( self.parameter.userData()["UI"]["acceptedNodeTypes"] ) - with IECore.IgnoredExceptions( KeyError ) : - if self.parameter.userData()["UI"]["acceptedNodeNameFormat"].value == "full" : - lskw["long"] = True - - nodeNames = maya.cmds.ls( **lskw ) - with IECore.IgnoredExceptions( KeyError ) : - if "parent" in self.parameter.userData()["UI"]["acceptedNodeNameFormat"].value : - for i in range( len( nodeNames ) ) : - nodeNames[i] = maya.cmds.listRelatives( - nodeNames[i], parent=True, path=True, - fullPath = (self.parameter.userData()["UI"]["acceptedNodeNameFormat"].value == "parentFull") - )[0] - - if nodeNames : - - definition.append( "/NodesDivider", { "divider" : True } ) - - if wantsNodeName : - - currentValue = maya.cmds.getAttr( self.plugName() ) - for nodeName in nodeNames : - if nodeName!=currentValue : - definition.append( "/Nodes/%s" % nodeName, { "command" : IECore.curry( self.__addNodeName, nodeName, clearFirst=True ) } ) - - elif wantsNodeNames : - - currentNodes = set( maya.cmds.getAttr( self.plugName() ).split() ) - for nodeName in nodeNames : - if nodeName in currentNodes : - definition.append( "/Nodes/Remove/%s" % nodeName, { "command" : IECore.curry( self.__removeNodeName, nodeName ) } ) - else : - definition.append( "/Nodes/Add/%s" % nodeName, { "command" : IECore.curry( self.__addNodeName, nodeName ) } ) - - return definition - - def __addNodeName( self, nodeName, clearFirst=False ) : - - names = set() - if not clearFirst : - names = set( maya.cmds.getAttr( self.plugName() ).split() ) - - names.add( nodeName ) - names = list( names ) - names.sort() - - maya.cmds.setAttr( self.plugName(), " ".join( names ), type="string" ) - - def __removeNodeName( self, nodeName ) : - - names = set( maya.cmds.getAttr( self.plugName() ).split() ) - names.remove( nodeName ) - names = list( names ) - names.sort() - - maya.cmds.setAttr( self.plugName(), " ".join( names ), type="string" ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.StringParameter, StringParameterUI ) diff --git a/python/IECoreMaya/StringUtil.py b/python/IECoreMaya/StringUtil.py deleted file mode 100644 index b6689906e3..0000000000 --- a/python/IECoreMaya/StringUtil.py +++ /dev/null @@ -1,108 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-9, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import maya.OpenMaya -import re - -__all__ = [ "dependencyNodeFromString", "dagPathFromString", "plugFromString" ] - -## Utility function to return a dependency node as an MObject when -# given it's name as a string. -def dependencyNodeFromString( s ) : - - sl = maya.OpenMaya.MSelectionList() - sl.add( s ) - - if sl.length() > 1 : - IECore.msg( IECore.Msg.Level.Warning, "IECoreMaya.dependencyNodeFromString", "Name \"%s\" is not unique." % s ) - - result = maya.OpenMaya.MObject() - sl.getDependNode( 0, result ) - return result - -## Utility function to return the parent string when -# given a UI or DAG node's full path name as a string. -def parentFromString( s ) : - - tokens = s.split('|') - tokens.pop() - parent = '|'.join( tokens ) - - return parent - -## Utility function to return an MDagPath when -# given it's name as a string. -def dagPathFromString( s ) : - - sl = maya.OpenMaya.MSelectionList() - sl.add( s ) - - if sl.length() > 1 : - IECore.msg( IECore.Msg.Level.Warning, "IECoreMaya.dagPathFromString", "Name \"%s\" is not unique." % s ) - - result = maya.OpenMaya.MDagPath() - sl.getDagPath( 0, result ) - return result - -## Utility function to return an MPlug when -# given it's name as a string. -def plugFromString( s ) : - - sl = maya.OpenMaya.MSelectionList() - sl.add( s ) - - if sl.length() > 1 : - IECore.msg( IECore.Msg.Level.Warning, "IECoreMaya.plugFromString", "Name \"%s\" is not unique." % s ) - - result = maya.OpenMaya.MPlug() - sl.getPlug( 0, result ) - return result - -## Returns a full path to an MPlug. -def pathFromPlug( p ) : - - try : - f = maya.OpenMaya.MFnDagNode( p.node() ) - nodePath = f.fullPathName() - except : - f = maya.OpenMaya.MFnDependencyNode( p.node() ) - nodePath = f.name() - - return nodePath + "." + p.partialName() - -## Extracts the node name from a full path to an attribute. -def nodeFromAttributePath( a ) : - - return re.match( r"^[^.]*", a ).group( 0 ) diff --git a/python/IECoreMaya/StringVectorParameterUI.py b/python/IECoreMaya/StringVectorParameterUI.py deleted file mode 100644 index f73d570245..0000000000 --- a/python/IECoreMaya/StringVectorParameterUI.py +++ /dev/null @@ -1,203 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -## \todo: this is incredibly similar to NumericVectorParameterUI. Is it possible to generalize -## a ParameterUI for all *VectorParameters? -class StringVectorParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - topLevelUI = maya.cmds.columnLayout() - IECoreMaya.ParameterUI.__init__( self, node, parameter, topLevelUI, **kw ) - - self.__column = maya.cmds.columnLayout( parent=topLevelUI ) - - row = maya.cmds.rowLayout( - parent = topLevelUI, - numberOfColumns = 2, - columnAlign = ( 1, "right" ), - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - - maya.cmds.text( - parent = row, - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - addButton = maya.cmds.button( parent=row, label='Add Item', command=self._createCallback( self.__addItem ) ) - - self.__fields = [] - - self.__attributeChangedCallbackId = IECoreMaya.CallbackId( - maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.node(), self.__attributeChanged ) - ) - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - # disabling copy/paste from the ParameterClipboardUI as the results will be misleading to users - parameter.userData().update( StringVectorParameterUI.__disableCopyPaste ) - - vector = maya.cmds.getAttr( self.plugName() ) or [] - - # delete un-needed fields - self.__fields = self.__fields[:len(vector)] - rows = maya.cmds.columnLayout( self.__column, q=True, childArray=True ) or [] - rowsToKeep = rows[:len(vector)] - rowsToDelete = rows[len(vector):] - for row in rowsToDelete : - maya.cmds.deleteUI( row ) - - # create new fields - for i in range( len(rowsToKeep), len(vector) ) : - self.__createRow( self.label() + ": %d" % i ) - - self.__setUIFromPlug() - - def _topLevelUIDeleted( self ) : - - self.__attributeChangedCallbackId = None - - def __createRow( self, label ) : - - row = maya.cmds.rowLayout( - parent = self.__column, - numberOfColumns = 2, - columnAlign2 = ( "right", "left" ), - columnWidth2 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ], - ) - - ## \todo: there is a slight text misalignment if the window exists when __createRow is called - maya.cmds.text( - parent = row, - label = label, - font = "smallPlainLabelFont", - align = "right", - annotation = self.description(), - width = IECoreMaya.ParameterUI.textColumnWidthIndex, - ) - - self.__fields.append( - maya.cmds.textField( - parent = row, - changeCommand = self._createCallback( self.__setPlugFromUI ), - width = IECoreMaya.ParameterUI.singleWidgetWidthIndex, - ) - ) - - i = len(self.__fields) - 1 - self._addPopupMenu( parentUI=self.__fields[i], index=i ) - - def _popupMenuDefinition( self, **kw ) : - - definition = IECore.MenuDefinition() - definition.append( "/Remove Item", { "command" : self._createCallback( IECore.curry( self.__removeItem, index=kw['index'] ) ) } ) - - return definition - - def __addItem( self ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - vector.append( "" ) - - self.__setPlug( vector ) - self.replace( self.node(), self.parameter ) - - def __removeItem( self, index ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - vector = vector[:index] + vector[index+1:] - - self.__setPlug( vector ) - self.replace( self.node(), self.parameter ) - - def __attributeChanged( self, changeType, plug, otherPlug, userData ) : - - if not ( changeType & maya.OpenMaya.MNodeMessage.kAttributeSet ) : - return - - try : - myPlug = self.plug() - except : - # this situation can occur when our parameter has been removed but the - # ui we represent is not quite yet dead - return - - if not plug == myPlug : - return - - self.replace( self.node(), self.parameter ) - - def __setUIFromPlug( self ) : - - vector = maya.cmds.getAttr( self.plugName() ) or [] - for i in range( 0, len(vector) ) : - maya.cmds.textField( self.__fields[i], e=True, text=vector[i] ) - - def __setPlugFromUI( self ) : - - vector = [] - - for field in self.__fields : - vector.append( maya.cmds.textField( field, q=True, text=True ) ) - - self.__setPlug( vector ) - - def __setPlug( self, value ) : - - ## \todo: do this in python if maya ever fixes the nonsense required to call setAttr on a stringArray - plugType = maya.cmds.getAttr( self.plugName(), type=True ) - cmd = 'setAttr %s -type %s %d' % ( self.plugName(), plugType, len(value) ) - for val in value : - cmd += ' "%s"' % val - maya.mel.eval( cmd ) - - __disableCopyPaste = IECore.CompoundObject( { - "UI" : IECore.CompoundObject( { - "copyPaste" : IECore.BoolData( False ), - } ), - } ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.StringVectorParameter, StringVectorParameterUI ) diff --git a/python/IECoreMaya/TemporaryAttributeValues.py b/python/IECoreMaya/TemporaryAttributeValues.py deleted file mode 100644 index 942481a650..0000000000 --- a/python/IECoreMaya/TemporaryAttributeValues.py +++ /dev/null @@ -1,108 +0,0 @@ -########################################################################## -# -# Copyright (c) 2009-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya - -import IECore - -from . import StringUtil - -## A context manager for controlling attribute values in with statements. It -# sets attributes to requested values on entering the block and resets them to -# their previous values on exiting the block. -class TemporaryAttributeValues : - - def __init__( self, attributeAndValues = {}, **kw ) : - - self.__attributesAndValues = attributeAndValues - self.__attributesAndValues.update( kw ) - - def __enter__( self ) : - - handlers = { - "enum" : self.__simpleAttrHandler, - "bool" : self.__simpleAttrHandler, - "float" : self.__simpleAttrHandler, - "long" : self.__simpleAttrHandler, - "short" : self.__simpleAttrHandler, - "float2" : IECore.curry( self.__numeric2AttrHandler, attributeType="float2" ), - "long2" : IECore.curry( self.__numeric2AttrHandler, attributeType="long2" ), - "short2" : IECore.curry( self.__numeric2AttrHandler, attributeType="short2" ), - "float3" : IECore.curry( self.__numeric3AttrHandler, attributeType="float3" ), - "long3" : IECore.curry( self.__numeric3AttrHandler, attributeType="long3" ), - "short3" : IECore.curry( self.__numeric3AttrHandler, attributeType="short3" ), - "string" : self.__stringAttrHandler, - } - - self.__restoreCommands = [] - for attr, value in self.__attributesAndValues.items() : - - # check we can handle this type - attrType = maya.cmds.getAttr( attr, type=True ) - handler = handlers.get( attrType, None ) - if not handler : - raise TypeError( "Attribute \"%s\" has unsupported type \"%s\"." % ( attr, attrType ) ) - - # store a command to restore the attribute value later - origValue = maya.cmds.getAttr( attr ) - if isinstance( origValue, list ) and isinstance( origValue[0], tuple ) : - origValue = origValue[0] - - self.__restoreCommands.append( IECore.curry( handler, attr, origValue ) ) - - # and change the attribute value - handler( attr, value ) - - def __exit__( self, type, value, traceBack ) : - - for cmd in self.__restoreCommands : - - cmd() - - def __simpleAttrHandler( self, attr, value ) : - - maya.cmds.setAttr( attr, value ) - - def __numeric2AttrHandler( self, attr, value, attributeType ) : - - maya.cmds.setAttr( attr, value[0], value[1], type=attributeType ) - - def __numeric3AttrHandler( self, attr, value, attributeType ) : - - maya.cmds.setAttr( attr, value[0], value[1], value[2], type=attributeType ) - - def __stringAttrHandler( self, attr, value ) : - - maya.cmds.setAttr( attr, value, type="string" ) diff --git a/python/IECoreMaya/TestCase.py b/python/IECoreMaya/TestCase.py deleted file mode 100644 index 86dae81d70..0000000000 --- a/python/IECoreMaya/TestCase.py +++ /dev/null @@ -1,49 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import maya.cmds - -## A class to help implement unit tests for maya functionality. It -# implements setUp() to create a new maya scene to perform the test in. -class TestCase( unittest.TestCase ) : - - ## Derived classes may override this, but they should call the - # base class implementation too. - def setUp( self ) : - - maya.cmds.file( new = True, force = True ) - maya.cmds.flushUndo() - diff --git a/python/IECoreMaya/TestProgram.py b/python/IECoreMaya/TestProgram.py deleted file mode 100644 index 89526e2601..0000000000 --- a/python/IECoreMaya/TestProgram.py +++ /dev/null @@ -1,79 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import sys -import unittest - -## A test program which initializes Maya standalone before running the test suite. -# The list of named plugins is also loaded. -class TestProgram( unittest.TestProgram ) : - - def __init__( self, module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.defaultTestLoader, plugins = [] ) : - - self.__plugins = plugins - - unittest.TestProgram.__init__( self, module, defaultTest, argv, testRunner, testLoader ) - - def runTests( self ) : - - try: - import maya.standalone - maya.standalone.initialize( name='IECoreMayaTest' ) - except: - sys.stderr.write( "Failed to initialize Maya standalone application" ) - raise - - import maya.cmds - for plugin in self.__plugins : - maya.cmds.loadPlugin( plugin ) - - if not self.testRunner : - self.testRunner = unittest.TextTestRunner( verbosity = 2 ) - - result = self.testRunner.run( self.test ) - - exitStatus = int( not result.wasSuccessful() ) - - try: - if hasattr( maya.standalone, "cleanup" ): - - maya.standalone.cleanup( exitStatus ) - else: - - import IECoreMaya - IECoreMaya.Standalone.cleanup( exitStatus ) - finally: - - # If cleanup fails for any reason, just exit. - sys.exit( exitStatus ) diff --git a/python/IECoreMaya/TransformationMatrixParameterUI.py b/python/IECoreMaya/TransformationMatrixParameterUI.py deleted file mode 100644 index a550235c68..0000000000 --- a/python/IECoreMaya/TransformationMatrixParameterUI.py +++ /dev/null @@ -1,141 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import maya.cmds - -import IECore -import IECoreMaya - -## The UI for the TransformationMatrixParameter supports the following -## userData() -## -## - "visibleFields" IECore.StringVectorData, A list of fields to -## display in the UI. Possible values are (D marks a default): -## "translate" D -## "rotate", D -## "scale" D -## "shear" D -## "rotatePivot", -## "rotatePivotTranslation", -## "scalePivot" -## "scalePivotTranslation" - -class TransformationMatrixParameterUI( IECoreMaya.ParameterUI ) : - - _allFields = ( "translate", "rotate", "scale", "shear", "scalePivot", "scalePivotTranslation", "rotatePivot", "rotatePivotTranslation" ) - - def __init__( self, node, parameter, **kw ) : - - self._outerColumn = maya.cmds.columnLayout( adj=True ) - - IECoreMaya.ParameterUI.__init__( self, node, parameter, self._outerColumn, **kw ) - - maya.cmds.rowLayout( numberOfColumns=2, parent=self._outerColumn ) - - self._label = maya.cmds.text( - label = self.label(), - font = "tinyBoldLabelFont", - align = "right", - annotation = self.description() - ) - - self._manip = maya.cmds.button( label="Manipulate" ) - - maya.cmds.setParent("..") - maya.cmds.setParent("..") - - self._fields = {} - self.__kw = kw.copy() - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - currentParent = maya.cmds.setParent( query=True ) - - visibleFields = IECore.StringVectorData( ( "translate", "rotate", "scale", "shear" ) ) - with IECore.IgnoredExceptions( KeyError ) : - userDataFields = parameter.userData()["UI"]["visibleFields"] - visibleFields = [] - for u in userDataFields : - if u not in TransformationMatrixParameterUI._allFields: - IECore.msg( - IECore.Msg.Level.Warning, - "TransformationMatrixParameterUI", - "Invalid field '%s' requested in UI userData for '%s'. Available fields are %s." - % ( u, parameter.name, TransformationMatrixParameterUI._allFields ) - ) - continue - visibleFields.append( u ) - - for f in self._fields.keys() : - if f not in visibleFields : - maya.cmds.deleteUI( self._fields[f][0] ) - del self._fields[f] - - fnPH = IECoreMaya.FnParameterisedHolder( node ) - baseName = fnPH.parameterPlugPath( parameter ) - - self._addPopupMenu( parentUI=self._label, attributeName=baseName ) - - for f in visibleFields : - - if f not in self._fields : - layout = maya.cmds.rowLayout( - numberOfColumns = 4, - parent = self._outerColumn, - columnWidth4 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - maya.cmds.text( label=f, font="smallPlainLabelFont", align="right" ) - self._fields[f] = ( layout, maya.cmds.floatField(), maya.cmds.floatField(), maya.cmds.floatField() ) - - maya.cmds.connectControl( self._fields[f][1], "%s%s%i" % ( baseName, f, 0 ) ) - maya.cmds.connectControl( self._fields[f][2], "%s%s%i" % ( baseName, f, 1 ) ) - maya.cmds.connectControl( self._fields[f][3], "%s%s%i" % ( baseName, f, 2 ) ) - - maya.cmds.button( - self._manip, - edit = True, - # The manip is currently only registered for float types - visible = isinstance( parameter, IECore.TransformationMatrixfParameter ), - command = self._createCallback( IECore.curry( IECoreMaya.ManipulatorUI.manipulateParameter, node, parameter ) ) - ) - - maya.cmds.setParent( currentParent ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.TransformationMatrixfParameter, TransformationMatrixParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.TransformationMatrixdParameter, TransformationMatrixParameterUI ) diff --git a/python/IECoreMaya/UIElement.py b/python/IECoreMaya/UIElement.py deleted file mode 100644 index b811fc9cf4..0000000000 --- a/python/IECoreMaya/UIElement.py +++ /dev/null @@ -1,144 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya - -import maya.cmds -import maya.mel -import maya.OpenMayaUI - -## The UIElement base class assists in implementing ui elements in an -# object oriented manner in python. -## \todo Preexisting ui elements should be rewritten to take -# advantage of this base class wherever possible. -class UIElement : - - __instances = {} - - ## Derived classes must create a ui element which is the parent of the - # rest of their ui, and call this init function passing it as the topLevelUI - # parameter. The base class will ensure that the UIElement instance is kept - # alive as long as the ui exists, and that it will be destroyed when the - # ui is destroyed. - def __init__( self, topLevelUI ) : - - instanceRecord = IECore.Struct() - instanceRecord.instance = self - instanceRecord.callbacks = [] - # Saves errors in batch if UI work is still done.... - if not maya.cmds.about( batch=True ): - instanceRecord.uiDeletedCallbackId = IECoreMaya.CallbackId( maya.OpenMayaUI.MUiMessage.addUiDeletedCallback( topLevelUI, self.__uiDeleted, topLevelUI ) ) - UIElement.__instances[topLevelUI] = instanceRecord - - self.__topLevelUI = topLevelUI - - ## Returns the UIElement which forms the parent for this one. - def parent( self ) : - - melUI = self._topLevelUI() - while 1 : - melUI = melUI.rpartition( "|" )[0] - if melUI in self.__instances : - return self.__instances[melUI].instance - if not melUI : - return None - - ## Returns the name of the top level ui element for this instance. - def _topLevelUI( self ) : - - return self.__topLevelUI - - ## It's very natural to assign member functions to ui callbacks. There is a problem - # with this however in that maya leaks references to any python callbacks passed - # to it (tested in maya 2008). This causes a reference to be held to the UIElement - # instance forever. This could be a real problem if the ui references significant amounts - # of memory, which it may well do. This class wraps a callback function in such a way - # that maya will not leak it. - # - # Example usage : maya.cmds.button( command=self._createCallback( self.__buttonPressed ) ) - # - # If the mel parameter is True then it causes the creation of a mel command to call back and - # invoke the python callback. This is useful for the cases where maya insists on treating callbacks as - # mel commands even when they're added from python - for instance the outlinerEditor selectCommand - # in maya 2008. - def _createCallback( self, function, mel=False ) : - - callbacks = self.__instances[self._topLevelUI()].callbacks - callbacks.append( function ) - - pythonCmd = "import IECoreMaya; IECoreMaya.UIElement._UIElement__invokeCallback( '%s', %d )" % ( self._topLevelUI(), len( callbacks ) - 1 ) - if not mel : - return pythonCmd - else : - return "python( \"%s\" )" % pythonCmd - - ## This is called when the maya ui element corresponding to this - # instance is deleted. It may be reimplemented by derived classes - # to perform any necessary cleanup. One item of cleanup that might be - # very important is to delete any IECoreMaya.CallbackId objects that - # may be linking a maya message to a method of the instance - if this - # is not done then a circular reference will prevent the instance from - # dying, and the callbacks will continue to be despatched despite the - # fact that the ui has long gone. - def _topLevelUIDeleted( self ) : - - pass - - ## Returns a list of all the active instances derived from the specified type. - @staticmethod - def instances( type = None ) : - - if type is None : - type = UIElement - - result = [] - for v in UIElement.__instances.values() : - instance = v.instance - if isinstance( instance, type ) : - result.append( instance ) - - return result - - @staticmethod - def __uiDeleted( topLevelUI ) : - - UIElement.__instances[topLevelUI].instance._topLevelUIDeleted() - del UIElement.__instances[topLevelUI] - - @staticmethod - def __invokeCallback( topLevelUI, callbackIndex, *args ) : - - callback = UIElement.__instances[topLevelUI].callbacks[callbackIndex] - callback( *args ) diff --git a/python/IECoreMaya/UITemplate.py b/python/IECoreMaya/UITemplate.py deleted file mode 100644 index dcf33dc0d7..0000000000 --- a/python/IECoreMaya/UITemplate.py +++ /dev/null @@ -1,52 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -## A context object for use with python's "with" syntax. This manages calls to maya.cmds.setUITemplate -# to ensure that everything in the with block is executed with the appropriate template, and the -# template is popped on exit from the block. -class UITemplate : - - def __init__( self, name ) : - - self.__name = name - - def __enter__( self ) : - - maya.cmds.setUITemplate( self.__name, pushTemplate=True ) - - def __exit__( self, type, value, traceBack) : - - maya.cmds.setUITemplate( self.__name, popTemplate=True ) diff --git a/python/IECoreMaya/UndoChunk.py b/python/IECoreMaya/UndoChunk.py deleted file mode 100644 index 13932d4186..0000000000 --- a/python/IECoreMaya/UndoChunk.py +++ /dev/null @@ -1,75 +0,0 @@ -########################################################################## -# -# Copyright (c) 2016, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools - -import maya.cmds - -# TODO: This can be simplified with contextlib.contextmanager in python3 -class UndoChunk( object ) : - """Context Manager / Decorator which performs all of its operations with an undo chuck - - This manager ensures that all operations in the block are performed within a new - undo chunk and that the chunk is closed when the block exits. - - .. code-block:: python - - @UndoChunk( 'Chunk' ) - def doWork(): - pass - - with UndoChunk( 'Chunk' ): - pass - - """ - def __init__( self, chunkName ): - super(UndoChunk, self).__init__() - self._chunkName = chunkName - - def __enter__( self ) : - self._prevState = maya.cmds.undoInfo( query=True, stateWithoutFlush=True ) - maya.cmds.undoInfo( stateWithoutFlush=True ) - maya.cmds.undoInfo( chunkName=self._chunkName, openChunk=True ) - - def __exit__( self, type, value, traceBack ) : - maya.cmds.undoInfo( chunkName=self._chunkName, closeChunk=True ) - maya.cmds.undoInfo( stateWithoutFlush=self._prevState ) - return False - - def __call__( self, callable ): - @functools.wraps( callable ) - def managed_callable( *args, **kwargs ): - with self: - return callable( *args, **kwargs ) - return managed_callable diff --git a/python/IECoreMaya/UndoDisabled.py b/python/IECoreMaya/UndoDisabled.py deleted file mode 100644 index e82f25ffdf..0000000000 --- a/python/IECoreMaya/UndoDisabled.py +++ /dev/null @@ -1,69 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools - -import maya.cmds - - -# TODO: This can be simplified with contextlib.contextmanager in python3 -class UndoDisabled( object ) : - """Context Manager / Decorator which disables the undo queue - - This manager ensures that the undo queue is disabled during the execution block. - This is useful for undoable code which will not leave the undo stack in a destructive state. - - .. code-block:: python - @UndoDisabled() - def doWork(): - pass - - with UndoDisabled(): - pass - - """ - def __enter__( self ) : - self._prevState = maya.cmds.undoInfo( query=True, stateWithoutFlush=False ) - maya.cmds.undoInfo( stateWithoutFlush=False ) - - def __exit__( self, type, value, traceBack ) : - maya.cmds.undoInfo( stateWithoutFlush=self._prevState ) - return False - - def __call__( self, callable ): - @functools.wraps( callable ) - def managed_callable( *args, **kwargs ): - with self: - return callable( *args, **kwargs ) - return managed_callable diff --git a/python/IECoreMaya/UndoFlush.py b/python/IECoreMaya/UndoFlush.py deleted file mode 100644 index 2a57242853..0000000000 --- a/python/IECoreMaya/UndoFlush.py +++ /dev/null @@ -1,72 +0,0 @@ -########################################################################## -# -# Copyright (c) 2020, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools - -import maya.cmds - - -# TODO: This can be simplified with contextlib.contextmanager in python3 -class UndoFlush( object ) : - """Context Manager / Decorator which flushes the undo queue - - This manager ensures that the undo queue is flushed when leaving the execution - block. This is useful for any code which may otherwise leave the undo stack in - a destructive state. - - .. code-block:: python - @UndoFlush() - def doWork(): - pass - - with UndoFlush(): - pass - - """ - def __enter__( self ) : - self._prevState = maya.cmds.undoInfo( query=True, state=True ) - self._prevLength = maya.cmds.undoInfo( query=True, length=True ) - self._prevInfinity = maya.cmds.undoInfo( query=True, infinity=True ) - maya.cmds.undoInfo( state=False ) - - def __exit__( self, type, value, traceBack ) : - maya.cmds.undoInfo( state=self._prevState, length=self._prevLength, infinity=self._prevInfinity ) - return False - - def __call__( self, callable ): - @functools.wraps( callable ) - def managed_callable( *args, **kwargs ): - with self: - return callable( *args, **kwargs ) - return managed_callable diff --git a/python/IECoreMaya/VectorParameterUI.py b/python/IECoreMaya/VectorParameterUI.py deleted file mode 100644 index 94994b0255..0000000000 --- a/python/IECoreMaya/VectorParameterUI.py +++ /dev/null @@ -1,106 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class VectorParameterUI( IECoreMaya.ParameterUI ) : - - def __init__( self, node, parameter, **kw ) : - - self.__dim = parameter.getTypedValue().dimensions() - if self.__dim == 2: - layout = maya.cmds.rowLayout( - numberOfColumns = 3, - columnWidth3 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - elif self.__dim == 3: - layout = maya.cmds.rowLayout( - numberOfColumns = 4, - columnWidth4 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ] - ) - else: - raise RuntimeError("Unsupported vector dimension in VectorParameterUI") - - IECoreMaya.ParameterUI.__init__( self, node, parameter, layout, **kw ) - - self.__fields = [] - - maya.cmds.text( - label = self.label(), - font = "smallPlainLabelFont", - align = "right", - annotation = self.description() - ) - - plug = self.plug() - for i in range(0, self.__dim) : - self.__fields.append( - self.__fieldType()( - value = parameter.getTypedValue()[i] - ) - ) - - maya.cmds.setParent("..") - - self.replace( self.node(), self.parameter ) - - def replace( self, node, parameter ) : - - IECoreMaya.ParameterUI.replace( self, node, parameter ) - - plug = self.plug() - for i in range(0, self.__dim): - - childPlugName = self.nodeName() + "." + plug.child(i).partialName() - maya.cmds.connectControl( self.__fields[i], childPlugName ) - self._addPopupMenu( parentUI = self.__fields[i], attributeName = childPlugName ) - - def __fieldType( self ): - - if self.parameter.isInstanceOf( IECore.TypeId.V2iParameter ) or self.parameter.isInstanceOf( IECore.TypeId.V3iParameter ): - return maya.cmds.intField - else: - return maya.cmds.floatField - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V2iParameter, VectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V3iParameter, VectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V2fParameter, VectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V2dParameter, VectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V3fParameter, VectorParameterUI ) -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.V3dParameter, VectorParameterUI ) - -IECoreMaya.ParameterUI.registerUI( IECore.TypeId.Color3fParameter, VectorParameterUI, "numeric" ) diff --git a/python/IECoreMaya/WaitCursor.py b/python/IECoreMaya/WaitCursor.py deleted file mode 100644 index d49dc51f8b..0000000000 --- a/python/IECoreMaya/WaitCursor.py +++ /dev/null @@ -1,69 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools - -import maya.cmds - - -# TODO: This can be simplified with contextlib.contextmanager in python3 -class WaitCursor( object ) : - """Context Manager / Decorator which enables the wait cursor - - This manager ensures that the wait cursor is displayed during the execution block. - When the block exits, the cursor's previous display state is restored. - - .. code-block:: python - @WaitCursor() - def doWork(): - pass - - with WaitCursor(): - pass - - """ - def __enter__( self ) : - self._prevCursorState = maya.cmds.waitCursor( query=True, state=True ) - maya.cmds.waitCursor( state=True ) - - def __exit__( self, type, value, traceBack ) : - maya.cmds.waitCursor( state=self._prevCursorState ) - return False - - def __call__( self, callable ): - @functools.wraps( callable ) - def managed_callable( *args, **kwargs ): - with self: - return callable( *args, **kwargs ) - return managed_callable diff --git a/python/IECoreMaya/__init__.py b/python/IECoreMaya/__init__.py deleted file mode 100644 index c5f39ab6fc..0000000000 --- a/python/IECoreMaya/__init__.py +++ /dev/null @@ -1,106 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -__import__( "IECoreScene" ) - -from ._IECoreMaya import * - -from .UIElement import UIElement -from .ParameterUI import ParameterUI -from .BoolParameterUI import BoolParameterUI -from .StringParameterUI import StringParameterUI -from .PathParameterUI import PathParameterUI -from .FileNameParameterUI import FileNameParameterUI -from .DirNameParameterUI import DirNameParameterUI -from .FileSequenceParameterUI import FileSequenceParameterUI -from .NumericParameterUI import NumericParameterUI -from .VectorParameterUI import VectorParameterUI -from .ColorParameterUI import ColorParameterUI -from .BoxParameterUI import BoxParameterUI -from .SplineParameterUI import SplineParameterUI -from .NoteParameterUI import NoteParameterUI -from .NodeParameter import NodeParameter -from .DAGPathParameter import DAGPathParameter -from .DAGPathVectorParameter import DAGPathVectorParameter -from .mayaDo import mayaDo -from .Menu import Menu -from .BakeTransform import BakeTransform -from .MeshOpHolderUtil import create -from .MeshOpHolderUtil import createUI -from .ScopedSelection import ScopedSelection -from .FnParameterisedHolder import FnParameterisedHolder -from .FnConverterHolder import FnConverterHolder -from .StringUtil import * -from .MayaTypeId import MayaTypeId -from .ParameterPanel import ParameterPanel -from .AttributeEditorControl import AttributeEditorControl -from .OpWindow import OpWindow -from .FnTransientParameterisedHolderNode import FnTransientParameterisedHolderNode -from .UndoDisabled import UndoDisabled -from .ModalDialogue import ModalDialogue -from .Panel import Panel -from .WaitCursor import WaitCursor -from .FnOpHolder import FnOpHolder -from .UITemplate import UITemplate -from .FnParameterisedHolderSet import FnParameterisedHolderSet -from .TemporaryAttributeValues import TemporaryAttributeValues -from .GenericParameterUI import GenericParameterUI -from .FnDagNode import FnDagNode -from .CompoundParameterUI import CompoundParameterUI -from .ClassParameterUI import ClassParameterUI -from .ClassVectorParameterUI import ClassVectorParameterUI -from .PresetsOnlyParameterUI import PresetsOnlyParameterUI -from .TestCase import TestCase -from .TestProgram import TestProgram -from .FileBrowser import FileBrowser -from .FileDialog import FileDialog -from .GeometryCombinerUI import * -from .PresetsUI import * -from .ParameterClipboardUI import * -from .NumericVectorParameterUI import NumericVectorParameterUI -from .StringVectorParameterUI import StringVectorParameterUI -from .ManipulatorUI import * -from .TransformationMatrixParameterUI import TransformationMatrixParameterUI -from .LineSegmentParameterUI import LineSegmentParameterUI -from .Collapsible import Collapsible -from .RefreshDisabled import RefreshDisabled -from .UndoChunk import UndoChunk -from .UndoFlush import UndoFlush - -from . import Menus -from . import SceneShapeUI -from .FnSceneShape import FnSceneShape -from .FnSceneShape import _FnSceneShapeProxy - -__import__( "IECore" ).loadConfig( "CORTEX_STARTUP_PATHS", subdirectory = "IECoreMaya" ) diff --git a/python/IECoreMaya/mayaDo.py b/python/IECoreMaya/mayaDo.py deleted file mode 100644 index 8507e7bddc..0000000000 --- a/python/IECoreMaya/mayaDo.py +++ /dev/null @@ -1,107 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import os, sys - -""" -Utility function that provides easy access to Ops inside maya using a similar interface as the DO command line. -It tries to find the actions in the following contexts: (1) maya//, (2) maya//*/, (3) maya/ and lastly, (4) */ -Returns the Op result if execution succeeds, and None if execution fails for any reason. -""" -def mayaDo( opName, opVersion = None, help = False, **opArgs ): - - loader = IECore.ClassLoader.defaultOpLoader() - - try: - - plugins = loader.classNames( "maya/%s/%s" % (os.environ["MAYA_MAJOR_VERSION"], opName) ) - if len( plugins ) == 0: - plugins = loader.classNames( "maya/%s/*/%s" % (os.environ["MAYA_MAJOR_VERSION"], opName) ) - if len( plugins ) == 0: - plugins = loader.classNames( "maya/%s" % (opName) ) - if len( plugins ) == 0: - plugins = loader.classNames( "*/%s" % opName ) - # eliminate actions in maya because they may be for other maya versions. - plugins = [x for x in plugins if not x.startswith( "maya/" )] - - if not len( plugins ) : - IECore.error( "Action \"%s\" does not exist.\n" % opName ) - return None - elif len( plugins )>1 : - IECore.error( "Action name \"%s\" is ambiguous - could be any of the following : \n\t%s" % ( opName, "\n\t".join( plugins ) ) ) - return None - - actionName = plugins[0] - - actionVersions = loader.versions( actionName ) - if opVersion is None : - opVersion = actionVersions[-1] - else: - if not opVersion in actionVersions : - IECore.error( "Version \"%s\" of action \"%s\" does not exist.\n" % (opVersion, actionName) ) - return None - - opType = loader.load( actionName, opVersion ) - myOp = opType() - - except Exception as e: - IECore.debugException( "Failed on trying to load ", opName ) - IECore.error( "Error loading", opName, ":", str(e) ) - return None - - if help: - formatter = IECore.WrappedTextFormatter( sys.stdout ) - formatter.paragraph( "Name : " + myOp.name + "\n" ) - formatter.paragraph( myOp.description + "\n" ) - formatter.heading( "Parameters" ) - formatter.indent() - for p in myOp.parameters().values() : - IECore.formatParameterHelp( p, formatter ) - formatter.unindent() - return None - - try: - res = myOp( **opArgs ) - except Exception as e: - IECore.error( 'Error executing Op', myOp.name, ':', str(e) ) - return None - else: - try: - if myOp.userData()['UI']['showResult'].value: - print(res) - except: - pass - - return res diff --git a/python/IECoreNuke/FnAxis.py b/python/IECoreNuke/FnAxis.py deleted file mode 100644 index d3328a03e2..0000000000 --- a/python/IECoreNuke/FnAxis.py +++ /dev/null @@ -1,96 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import nuke -import imath -import IECore -from .KnobAccessors import getKnobValue - -## This function set can be used to manipulate any nodes which have -# an axis knob. This includes the Axis, TransformGeo and Camera nodes. -## \todo Methods for dealing with TransformationMatrices, absolute transforms -# and for setting transforms. -class FnAxis : - - def __init__( self, node ) : - - if isinstance( node, str ) : - - axis = nuke.toNode( node ) - - self.__node = node - - ## Returns the transformation matrix for the local axis knob. - # This ignores any parent transforms. - def getLocalMatrix( self, resultType=imath.M44f ) : - - vectorType = imath.V3f - eulerType = imath.Eulerf - if resultType==imath.M44d : - vectorType = imath.V3d - eulerType = imath.Eulerd - - translate = getKnobValue( self.__node.knob( "translate" ), resultType=vectorType ) - translate = resultType().translate( translate ) - - pivot = getKnobValue( self.__node.knob( "pivot" ), resultType=vectorType ) - - rotate = getKnobValue( self.__node.knob( "rotate" ), resultType=vectorType ) - rotate *= math.pi / 180.0 - - rotOrderKnob = self.__node.knob( "rot_order" ) - rotateOrder = rotOrderKnob.enumName( int(rotOrderKnob.getValue()) ) - rotate = eulerType( rotate, getattr( eulerType.Order, rotateOrder ) ) - rotate = rotate.toMatrix44() - rotate = resultType().translate( -pivot ) * rotate * resultType().translate( pivot ) - - scale = getKnobValue( self.__node.knob( "scaling" ), resultType=vectorType ) - scale *= self.__node.knob( "uniform_scale" ).getValue() - scale = resultType().scale( scale ) - scale = resultType().translate( -pivot ) * scale * resultType().translate( pivot ) - - orderKnob = self.__node.knob( "xform_order" ) - order = orderKnob.enumName( int(orderKnob.getValue()) ) - matrices = { - "T" : translate, - "R" : rotate, - "S" : scale - } - - result = resultType() - for m in order : - result = result * matrices[m] - - return result diff --git a/python/IECoreNuke/FnOpHolder.py b/python/IECoreNuke/FnOpHolder.py deleted file mode 100644 index 3246004d61..0000000000 --- a/python/IECoreNuke/FnOpHolder.py +++ /dev/null @@ -1,70 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import nuke - -import IECoreNuke -from . import _IECoreNuke - -class FnOpHolder( IECoreNuke.FnParameterisedHolder ) : - - def __init__( self, node ) : - - IECoreNuke.FnParameterisedHolder.__init__( self, node ) - - def setOp( self, className, classVersion=None ) : - - self.setParameterised( className, classVersion, "IECORE_OP_PATHS" ) - - def getOp( self ) : - - return self.getParameterised()[0] - - ## Executes the node, returning the result of the Op. You may also - # use nuke.execute() directly on an OpHolder node, but in this case - # the result is not returned (which you might not need). - def execute( self ) : - - nuke.execute( self.node(), nuke.frame(), nuke.frame() ) - return _IECoreNuke._opHolderExecuteResult() - - @staticmethod - def create( nodeName, className, classVersion=None ) : - - node = nuke.createNode( "ieOp" ) - node.setName( nodeName ) - fnOH = FnOpHolder( node ) - fnOH.setOp( className, classVersion ) - - return fnOH diff --git a/python/IECoreNuke/FnParameterisedHolder.py b/python/IECoreNuke/FnParameterisedHolder.py deleted file mode 100644 index 46b9c1c370..0000000000 --- a/python/IECoreNuke/FnParameterisedHolder.py +++ /dev/null @@ -1,116 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import nuke - -import IECore -from ._IECoreNuke import _parameterisedHolderGetParameterisedResult -from ._IECoreNuke import _parameterisedHolderSetModifiedParametersInput - -class FnParameterisedHolder : - - def __init__( self, node ) : - - if isinstance( node, str ) : - self.__node = nuke.toNode( node ) - else : - self.__node = node - - def node( self ) : - - return self.__node - - def setParameterised( self, className, classVersion, searchPathEnvVar ) : - - if classVersion is None or classVersion < 0 : - classVersions = IECore.ClassLoader.defaultLoader( searchPathEnvVar ).versions( className ) - classVersion = classVersions[-1] if classVersions else 0 - - d = self.__node.knob( "classSpecifier" ).getValue() - if d is None : - d = IECore.CompoundObject() - - d["className"] = IECore.StringData( className ) - d["classVersion"] = IECore.IntData( classVersion ) - d["classSearchPathEnvVar"] = IECore.StringData( searchPathEnvVar ) - - self.__node.knob( "classSpecifier" ).setValue( d ) - - ## Returns a tuple of the form ( parameterised, className, classVersion, searchPathEnvVar ). - # Note that in Nuke a single node may hold many DD::Image::Ops, each for a different output - # context. Each of these will store a different Parameterised instance, so there's no such thing - # as a single instance to be returned. For this reason a brand new instance is returned, representing - # the current time. This can be manipulated as desired without affecting the instances held on the node. - # Please note that currently any Parameters which are represented as node inputs rather than as knobs - # will not have their values set by this function. - def getParameterised( self ) : - - self.__node.knob( "__getParameterised" ).execute() - p = _parameterisedHolderGetParameterisedResult() - - d = self.__node.knob( "classSpecifier" ).getValue() - return ( - p, - d["className"].value if d else "", - d["classVersion"].value if d else 0, - d["classSearchPathEnvVar"].value if d else "", - ) - - ## Returns a context manager for use with the with statement. This can be used to scope edits - # to Parameter values in such a way that they are automatically transferred onto the nuke - # knobs on exit from the with block. - def parameterModificationContext( self ) : - - return _ParameterModificationContext( self ) - -class _ParameterModificationContext : - - def __init__( self, fnPH ) : - - self.__fnPH = fnPH - - def __enter__( self ) : - - self.__parameterised = self.__fnPH.getParameterised()[0] - - nuke.Undo.begin() - - return self.__parameterised - - def __exit__( self, type, value, traceBack ) : - - _parameterisedHolderSetModifiedParametersInput( self.__parameterised ) - self.__fnPH.node().knob( "__modifiedParameters" ).execute() - - nuke.Undo.end() diff --git a/python/IECoreNuke/KnobAccessors.py b/python/IECoreNuke/KnobAccessors.py deleted file mode 100644 index 2fc31cd936..0000000000 --- a/python/IECoreNuke/KnobAccessors.py +++ /dev/null @@ -1,152 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import nuke -import imath -import IECore - -__getters = {} -__setters = {} - -########################################################################## -# public functions -########################################################################## - -def registerAccessors( knobType, get, set = None ) : - - assert( not knobType in __getters ) - __getters[knobType] = get - - if set : - assert( not knobType in __setters ) - __setters[knobType] = set - -## \todo Support more knob types -def getKnobValue( knob, **kwArgs ) : - - f = __getters.get( knob.__class__, None ) - if not f : - raise RuntimeError( "No get accessor registered for type %s", str( knob.__class__ ) ) - - return f( knob, **kwArgs ) - -def setKnobValue( knob, value, **kwArgs ) : - - f = __setters.get( knob.__class__, None ) - if not f : - raise RuntimeError( "No set accessor registered for type %s", str( knob.__class__ ) ) - - return f( knob, value, **kwArgs ) - -########################################################################## -# accessor implementations -########################################################################## - -# XY Knob - -def __getXY( knob, resultType=imath.V2f ) : - - return resultType( knob.getValue( 0 ), knob.getValue( 1 ) ) - -def __setXY( knob, value ) : - - knob.setValue( value[0], 0 ) - knob.setValue( value[1], 1 ) - -registerAccessors( nuke.XY_Knob, __getXY, __setXY ) - -# XYZ Knob - -def __getXYZ( knob, resultType=imath.V3f ) : - - return resultType( knob.getValue( 0 ), knob.getValue( 1 ), knob.getValue( 2 ) ) - -def __setXYZ( knob, value ) : - - knob.setValue( value[0], 0 ) - knob.setValue( value[1], 1 ) - knob.setValue( value[2], 2 ) - -registerAccessors( nuke.XYZ_Knob, __getXYZ, __setXYZ ) -registerAccessors( nuke.Scale_Knob, __getXYZ, __setXYZ ) - -# Color Knob - -def __getColor( knob, resultType=imath.Color3f ) : - - return resultType( knob.getValue( 0 ), knob.getValue( 1 ), knob.getValue( 2 ) ) - -def __setColor( knob, value ) : - - knob.setValue( value[0], 0 ) - knob.setValue( value[1], 1 ) - knob.setValue( value[2], 2 ) - -registerAccessors( nuke.Color_Knob, __getColor, __setColor ) - -# String Knob - -def __getString( knob, resultType=str ) : - - return resultType( knob.getText() ) - -def __setString( knob, value ) : - - knob.setValue( str( value ) ) - -registerAccessors( nuke.EvalString_Knob, __getString, __setString ) - -# Box3 Knob - -def __getBox3( knob, resultType=imath.Box3f ) : - - vectorType = imath.V3f - if resultType == imath.Box3d : - vectorType = imath.V3d - - value = knob.getValue() - return resultType( vectorType( *value[:3] ), vectorType( *value[3:] ) ) - -def __setBox3( knob, value ) : - - knob.setX( value.min[0] ) - knob.setY( value.min[1] ) - knob.setN( value.min[2] ) - - knob.setR( value.max[0] ) - knob.setT( value.max[1] ) - knob.setF( value.max[2] ) - -registerAccessors( nuke.Box3_Knob, __getBox3, __setBox3 ) - diff --git a/python/IECoreNuke/KnobConverters.py b/python/IECoreNuke/KnobConverters.py deleted file mode 100644 index 205299eaf5..0000000000 --- a/python/IECoreNuke/KnobConverters.py +++ /dev/null @@ -1,266 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement -import nuke -import IECore -from .StringUtil import nukeFileSequence, ieCoreFileSequence - -__parameterKnobConverters = [] - -## Registers knob converter functions for IECore data types. -# @param paramClass Parameter class type used on the following converters -# @param knobCreator Function that creates a knob. Function parameters: knobHolder, parameter, knobName, knobLabel -# @param toKnobConverter Function that sets the value of knobs for a given parameter. Function parameters: knobHolder, parameter, knobName -# @param fromKnobConverter Function that sets a Parameter value from it's knobs. Function parameters: knobHolder, parameter, knobName -def registerParameterKnobConverters( paramClass, knobCreator, toKnobConverter, fromKnobConverter ) : - __parameterKnobConverters.append( ( paramClass, knobCreator, toKnobConverter, fromKnobConverter ) ) - -## Create new knobs on a given knob holder for a given parameter. -# @param knobHolder The knob holder must support only two methods: knobs() and addKnob() -# @param parameter That's the IECore.Parameter object which you want a knob for. -# @param knobName Specifies the knob name for the given parameter object. Child parameters will have knobs named with that same prefix. -def createKnobsFromParameter( knobHolder, parameter, knobName = "parm" ) : - - if knobName: - knobLabel = IECore.CamelCase.toSpaced( parameter.name ) - - if parameter.presetsOnly : - - knob = nuke.Enumeration_Knob( knobName, knobLabel, [] ) - knob.setValues( parameter.presetNames() ) - knob.setValue( parameter.getCurrentPresetName() ) - knobHolder.addKnob( knob ) - - else : - - for (paramClass,knobCreator,toKnobConverter,fromKnobConverter) in __parameterKnobConverters : - - if isinstance( parameter, paramClass ) : - knob = knobCreator( knobHolder, parameter, knobName, knobLabel ) - if knob : - knobHolder.addKnob( knob ) - toKnobConverter( knobHolder, parameter, knobName ) - break - else : - - knob = nuke.Text_Knob( knobName, "Not implemented!" ) - knobHolder.addKnob( knob ) - -## Set knob values on a given knob holder for a given parameter. -# @param knobHolder The knob holder must support only two methods: knobs() and addKnob() -# @param parameter That's the IECore.Parameter object that contains the value to be set on the knob. -# @param knobName Specifies the knob name for the given parameter object. Child parameters will have knobs named with that same prefix. -def setKnobsFromParameter( knobHolder, parameter, knobName = "parm" ) : - - if parameter.presetsOnly : - - knobHolder.knobs()[ knobName ].setValue( parameter.getCurrentPresetName() ) - - else : - - for (paramClass,knobCreator,toKnobConverter,fromKnobConverter) in __parameterKnobConverters : - - if isinstance( parameter, paramClass ) : - toKnobConverter( knobHolder, parameter, knobName ) - break - - -## Set parameter values from knobs on a given knob holder. -# @param knobHolder The knob holder must support only two methods: knobs() and addKnob() -# @param parameter That's the IECore.Parameter object that will get the knob value. -# @param knobName Specifies the knob name for the given parameter object. Child parameters will have knobs named with that same prefix. -def setParameterFromKnobs( knobHolder, parameter, knobName = "parm" ) : - - if parameter.presetsOnly : - parameter.setValue( knobHolder.knobs()[ knobName ].value() ) - - else : - - for (paramClass,knobCreator,toKnobConverter,fromKnobConverter) in __parameterKnobConverters : - - if isinstance( parameter, paramClass ) : - fromKnobConverter( knobHolder, parameter, knobName ) - break - -def __createCompoundParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - if knobLabel: - knobHolder.addKnob( nuke.Tab_Knob( knobName, knobLabel, nuke.TABBEGINGROUP) ) - - for childName, child in parameter.items() : - createKnobsFromParameter( knobHolder, child, knobName + "_" + childName ) - - if knobLabel: - knobHolder.addKnob( nuke.Tab_Knob( knobName, knobLabel, nuke.TABENDGROUP) ) - - return None - -def __compoundParameterToKnob( knobHolder, parameter, knobName ) : - - with IECore.IgnoredExceptions( KeyError ): - collapsed = parameter.userData()["UI"]["collapsed"] - knob = knobHolder.knobs()[ knobName ] - knob.setValue( collapsed ) - - for childName, child in parameter.items() : - setKnobsFromParameter( knobHolder, child, knobName + "_" + childName ) - -def __compoundParameterFromKnob( knobHolder, parameter, knobName ) : - - with IECore.IgnoredExceptions( KeyError ): - knob = knobHolder.knobs()[ knobName ] - collapsed = bool(knob.getValue()) - if not "UI" in parameter.userData() : - parameter.userData()["UI"] = IECore.CompoundData() - parameter.userData()["UI"]["collapsed"] = IECore.BoolData(collapsed) - - for childName, child in parameter.items() : - setParameterFromKnobs( knobHolder, child, knobName + "_" + childName ) - -def __createPathParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - return nuke.File_Knob( knobName, knobLabel ) - -def __fileSequenceParameterToKnob( knobHolder, parameter, knobName ) : - - knob = knobHolder.knobs()[ knobName ] - seqPath = nukeFileSequence( parameter.getTypedValue() ) - knob.setValue( seqPath ) - -def __fileSequenceParameterFromKnob( knobHolder, parameter, knobName ) : - - seqPath = ieCoreFileSequence( knobHolder.knobs()[knobName].value() ) - parameter.setTypedValue( seqPath ) - -def __pathParameterToKnob( knobHolder, parameter, knobName ) : - - knob = knobHolder.knobs()[ knobName ] - knob.setValue( parameter.getTypedValue() ) - -def __typedParameterFromKnob( knobHolder, parameter, knobName ) : - - parameter.setTypedValue( knobHolder.knobs()[knobName].value() ) - -def __typedParameterToKnob( knobHolder, parameter, knobName ) : - - knob = knobHolder.knobs()[ knobName ] - knob.setValue( parameter.getTypedValue() ) - -def __numericParameterFromKnob( knobHolder, parameter, knobName ) : - - parameter.setNumericValue( knobHolder.knobs()[knobName].value() ) - -def __numericParameterToKnob( knobHolder, parameter, knobName ) : - - knob = knobHolder.knobs()[ knobName ] - knob.setValue( parameter.getNumericValue() ) - -def __createStringParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - return nuke.String_Knob( knobName, knobLabel ) - -def __stringParameterFromKnob( knobHolder, parameter, knobName ) : - - parameter.setTypedValue( knobHolder.knobs()[knobName].getText() ) - -def __createIntParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - return nuke.Int_Knob( knobName, knobLabel ) - -def __createBoolParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - knob = nuke.Boolean_Knob( knobName, knobLabel ) - knob.setFlag( nuke.STARTLINE ) - return knob - -def __createDoubleParameterKnob( knobHolder, parameter, knobName, knobLabel ) : - - knob = nuke.Double_Knob( knobName, knobLabel ) - knob.setValue( parameter.getNumericValue() ) - return knob - -def __createStringVectorParameterKnob( knobHolder, parameter, knobName, knobLabel ): - - return nuke.Multiline_Eval_String_Knob( knobName, knobLabel ) - -def __stringVectorParameterToKnob( knobHolder, parameter, knobName ): - - knob = knobHolder.knobs()[knobName] - knob.setValue( "\n".join( parameter.getValue() ) ) - -def __stringVectorParameterFromKnob( knobHolder, parameter, knobName ) : - txt = knobHolder.knobs()[knobName].getText() - if len(txt) : - values = txt.split("\n") - else: - values = [] - parameter.setValue( IECore.StringVectorData( values ) ) - -def __createNumericVectorParameterKnob( knobHolder, parameter, knobName, knobLabel ): - - knob = nuke.String_Knob( knobName, knobLabel + ' (space separated)' ) - return knob - -def __numericVectorParameterToKnob( knobHolder, parameter, knobName ): - - knob = knobHolder.knobs()[knobName] - knob.setValue( " ".join( [str(v) for v in parameter.getValue()] ) ) - -def __numericVectorParameterFromKnob( knobHolder, parameter, knobName ) : - - dataVectorType = type( parameter.getValue() ) - dataType = IECore.DataTraits.valueTypeFromSequenceType( dataVectorType ) - values = knobHolder.knobs()[knobName].getText().strip() - if len(values) : - dataValues = [dataType(v) for v in values.split()] - parameter.setValue( dataVectorType( dataValues ) ) - else : - parameter.setValue( dataVectorType() ) - -# \todo: Implement data types V2f, V3f, Color... -# \todo: Implement vector data types: V2f, V3f... -registerParameterKnobConverters( IECore.CompoundParameter, __createCompoundParameterKnob, __compoundParameterToKnob, __compoundParameterFromKnob ) -registerParameterKnobConverters( IECore.FileSequenceParameter, __createPathParameterKnob, __fileSequenceParameterToKnob, __fileSequenceParameterFromKnob ) -registerParameterKnobConverters( IECore.FileNameParameter, __createPathParameterKnob, __pathParameterToKnob, __stringParameterFromKnob ) -registerParameterKnobConverters( IECore.DirNameParameter, __createPathParameterKnob, __pathParameterToKnob, __stringParameterFromKnob ) -registerParameterKnobConverters( IECore.StringParameter, __createStringParameterKnob, __typedParameterToKnob, __stringParameterFromKnob ) -registerParameterKnobConverters( IECore.BoolParameter, __createBoolParameterKnob, __typedParameterToKnob, __typedParameterFromKnob ) -registerParameterKnobConverters( IECore.IntParameter, __createIntParameterKnob, __numericParameterToKnob, __numericParameterFromKnob ) -registerParameterKnobConverters( IECore.FloatParameter, __createDoubleParameterKnob, __numericParameterToKnob, __numericParameterFromKnob ) -registerParameterKnobConverters( IECore.DoubleParameter, __createDoubleParameterKnob, __numericParameterToKnob, __numericParameterFromKnob ) -registerParameterKnobConverters( IECore.StringVectorParameter, __createStringVectorParameterKnob, __stringVectorParameterToKnob, __stringVectorParameterFromKnob ) -registerParameterKnobConverters( IECore.IntVectorParameter, __createNumericVectorParameterKnob, __numericVectorParameterToKnob, __numericVectorParameterFromKnob ) -registerParameterKnobConverters( IECore.FloatVectorParameter, __createNumericVectorParameterKnob, __numericVectorParameterToKnob, __numericVectorParameterFromKnob ) -registerParameterKnobConverters( IECore.DoubleVectorParameter, __createNumericVectorParameterKnob, __numericVectorParameterToKnob, __numericVectorParameterFromKnob ) diff --git a/python/IECoreNuke/StringUtil.py b/python/IECoreNuke/StringUtil.py deleted file mode 100644 index 5559ba058a..0000000000 --- a/python/IECoreNuke/StringUtil.py +++ /dev/null @@ -1,66 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import re - -def __toFormatString( match ): - txt = match.group(0) - cc = len(txt) - if cc == 1 : - result = "%d" - else : - result = "%%0%dd" % cc - return result - -def __toNumberSign( match ): - txt = match.group(1) - cc = 1 - if len(txt) : - cc = int(txt) - if txt[0] != '0' and cc > 1 : - raise RuntimeError("Frame numbers padded with space is not supported!") - result = "" - for c in range( cc ) : - result = result + "#" - return result - -## Converts IECore standard file sequence path to Nuke's syntax -def nukeFileSequence( ieCorefs ) : - - return re.sub( r"#+", __toFormatString, ieCorefs ) - -## Converts Nuke standard file sequence path to IECore's syntax -def ieCoreFileSequence( nukefs ) : - - return re.sub( r"%([0-9]*)d", __toNumberSign, nukefs ) diff --git a/python/IECoreNuke/TestCase.py b/python/IECoreNuke/TestCase.py deleted file mode 100644 index 4ddad723af..0000000000 --- a/python/IECoreNuke/TestCase.py +++ /dev/null @@ -1,49 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import nuke - -## A class to help implement unit tests for nuke functionality. It -# implements setUp() to clear the nuke script and undo queue. -class TestCase( unittest.TestCase ) : - - ## Derived classes may override this, but they should call the - # base class implementation too. - def setUp( self ) : - - nuke.scriptClear() - nuke.Undo.undoTruncate( 0 ) - nuke.Undo.redoTruncate( 0 ) diff --git a/python/IECoreNuke/UndoManagers.py b/python/IECoreNuke/UndoManagers.py deleted file mode 100644 index b36266a6c2..0000000000 --- a/python/IECoreNuke/UndoManagers.py +++ /dev/null @@ -1,92 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import nuke - -## A context object intended for use with python's "with" block. It ensures -# that all operations in the block are performed with nuke's undo in a -# particular state (enabled or disabled) and that the previous state is correctly -# restored on exit from the block. -class UndoState : - - ## state should be True to enable undo, and False to disable it. - def __init__( self, state ) : - - self.__state = state - - def __enter__( self ) : - - self.__prevState = not nuke.Undo.disabled() - if self.__state : - nuke.Undo.enable() - else : - nuke.Undo.disable() - - def __exit__( self, type, value, traceBack ) : - - if self.__prevState : - nuke.Undo.enable() - else : - nuke.Undo.disable() - -## A context object intended for use with python's "with" block. It ensures -# that all operations in the block are performed with undo disabled, and that -# undo is reenabled if necessary upon exit from the block. -class UndoDisabled( UndoState ) : - - def __init__( self ) : - - UndoState.__init__( self, False ) - -## A context object intended for use with python's "with" block. It ensures -# that all operations in the block are performed with undo enabled, and that -# undo is disabled if necessary upon exit from the block. -class UndoEnabled( UndoState ) : - - def __init__( self ) : - - UndoState.__init__( self, True ) - -## A context object intended for use with python's "with" block. It groups a -# series of actions into a single Nuke undo. -class UndoBlock : - - def __enter__( self ) : - - nuke.Undo.begin() - - def __exit__( self, type, value, traceBack ) : - - nuke.Undo.end() - diff --git a/python/IECoreNuke/__init__.py b/python/IECoreNuke/__init__.py deleted file mode 100644 index 7fd11c4e81..0000000000 --- a/python/IECoreNuke/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -__import__( "IECore" ) - -# importing IECoreScene before _IECoreNuke required for LiveScene binding to work as we need the SceneInterface binding loading first. -import IECoreScene - -from ._IECoreNuke import * - -from .KnobAccessors import setKnobValue, getKnobValue -from .FnAxis import FnAxis -from .StringUtil import nukeFileSequence, ieCoreFileSequence -from .KnobConverters import registerParameterKnobConverters, createKnobsFromParameter, setKnobsFromParameter, setParameterFromKnobs -from .FnParameterisedHolder import FnParameterisedHolder -from .UndoManagers import UndoState, UndoDisabled, UndoEnabled, UndoBlock -from .TestCase import TestCase -from .FnOpHolder import FnOpHolder - -__import__( "IECore" ).loadConfig( "CORTEX_STARTUP_PATHS", subdirectory = "IECoreNuke" ) diff --git a/src/IECoreHoudini/Convert.cpp b/src/IECoreHoudini/Convert.cpp deleted file mode 100644 index 23835c1c94..0000000000 --- a/src/IECoreHoudini/Convert.cpp +++ /dev/null @@ -1,189 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/Convert.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/VectorTypedData.h" - -#include - -namespace IECore -{ - -template<> -UT_Vector3 convert( const Imath::V3f &from ) -{ - return UT_Vector3( from.x, from.y, from.z ); -} - -template<> -Imath::V3f convert( const UT_Vector3 &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -UT_Vector3 convert( const Imath::V3d &from ) -{ - return UT_Vector3( from.x, from.y, from.z ); -} - -template<> -Imath::V3d convert( const UT_Vector3 &from ) -{ - return Imath::V3d( from[0], from[1], from[2] ); -} - -template<> -UT_Vector4 convert( const Imath::V3f &from ) -{ - return UT_Vector4( from.x, from.y, from.z ); -} - -template<> -Imath::V3f convert( const UT_Vector4 &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -UT_Vector4 convert( const Imath::V3d &from ) -{ - return UT_Vector4( from.x, from.y, from.z ); -} - -template<> -Imath::V3d convert( const UT_Vector4 &from ) -{ - return Imath::V3d( from[0], from[1], from[2] ); -} - -template<> -Imath::Color3f convert( const UT_Color &from ) -{ - float r, g, b; - from.getRGB( &r, &g, &b ); - return Imath::Color3f( r, g, b ); -} - -template<> -UT_Color convert( const Imath::Color3f &from ) -{ - return UT_Color( UT_RGB, from[0], from[1], from[2] ); -} - -template<> -Imath::Color4f convert( const UT_Color &from ) -{ - float r, g, b; - from.getRGB( &r, &g, &b ); - return Imath::Color4f( r, g, b, 1 ); -} - -template<> -UT_Color convert( const Imath::Color4f &from ) -{ - return UT_Color( UT_RGB, from[0], from[1], from[2] ); -} - -template<> -UT_BoundingBox convert( const Imath::Box3f &from ) -{ - if( from.isEmpty() ) - { - return UT_BoundingBox(); - } - return UT_BoundingBox( convert( from.min ), convert( from.max ) ); -} - -template<> -Imath::Box3f convert( const UT_BoundingBox &from ) -{ - return Imath::Box3f( convert( from.minvec() ), convert( from.maxvec() ) ); -} - -template<> -UT_BoundingBox convert( const Imath::Box3d &from ) -{ - if( from.isEmpty() ) - { - return UT_BoundingBox(); - } - return UT_BoundingBox( convert( from.min ), convert( from.max ) ); -} - -template<> -Imath::Box3d convert( const UT_BoundingBox &from ) -{ - return Imath::Box3d( convert( from.minvec() ), convert( from.maxvec() ) ); -} - -template<> -UT_Matrix4T convert( const Imath::M44d &from ) -{ - return UT_Matrix4T( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -Imath::M44d convert( const UT_Matrix4T &from ) -{ - return Imath::M44d( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -Imath::M44f convert( const UT_Matrix4T &from ) -{ - return Imath::M44f( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -UT_Matrix4T convert( const Imath::M44f &from ) -{ - return UT_Matrix4T( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -Imath::M44f convert( const UT_Matrix4T &from ) -{ - return Imath::M44f( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -Imath::M44d convert( const UT_Matrix4T &from ) -{ - return Imath::M44d( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -} // namespace IECore diff --git a/src/IECoreHoudini/CoreHoudini.cpp b/src/IECoreHoudini/CoreHoudini.cpp deleted file mode 100644 index 3c885d2b92..0000000000 --- a/src/IECoreHoudini/CoreHoudini.cpp +++ /dev/null @@ -1,113 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/CoreHoudini.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/MessageHandler.h" - -#include "CH/CH_Manager.h" - -using namespace IECoreHoudini; -using namespace boost::python; - -boost::python::object CoreHoudini::g_globalContext; -bool CoreHoudini::g_initialized = false; - -void CoreHoudini::initPython() -{ - if (!g_initialized) - { - { - // the global dictionary - IECorePython::ScopedGILLock lock; - object main_module(( - handle<>(borrowed(PyImport_AddModule("__main__"))))); - g_globalContext = main_module.attr("__dict__"); - } - - // import our main modules - import( "hou" ); - import( "IECore" ); - import( "IECoreHoudini" ); - -#ifdef IECOREHOUDINI_WITH_GL - - import( "IECoreGL" ); - -#endif - - g_initialized = true; - } -} - -void CoreHoudini::cleanupPython() -{ - g_globalContext = object(); -} - -void CoreHoudini::import( const std::string &module ) -{ - IECorePython::ScopedGILLock lock; - try - { - boost::python::object pymodule( ( boost::python::handle<>(PyImport_ImportModule(module.c_str())) ) ); - g_globalContext[module] = pymodule; - } - catch( ... ) - { - PyErr_Print(); - } -} - -object CoreHoudini::evalPython( const std::string &cmd ) -{ - IECorePython::ScopedGILLock lock; - object result; - try - { - handle<> resultHandle( PyRun_String( cmd.c_str(), Py_eval_input, - CoreHoudini::globalContext().ptr(), CoreHoudini::globalContext().ptr() ) ); - result = object( resultHandle ); - } - catch( ... ) - { - PyErr_Print(); - } - return result; -} diff --git a/src/IECoreHoudini/DetailSplitter.cpp b/src/IECoreHoudini/DetailSplitter.cpp deleted file mode 100644 index 24a594276f..0000000000 --- a/src/IECoreHoudini/DetailSplitter.cpp +++ /dev/null @@ -1,611 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/DetailSplitter.h" - -#include "IECoreHoudini/FromHoudiniCurvesConverter.h" -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/FromHoudiniPointsConverter.h" -#include "IECoreHoudini/FromHoudiniPolygonsConverter.h" - -#include "IECoreScene/CurvesAlgo.h" -#include "IECoreScene/CurvesPrimitive.h" -#include "IECoreScene/MeshAlgo.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/PointsAlgo.h" -#include "IECoreScene/PointsPrimitive.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/DataAlgo.h" -#include "IECore/PathMatcher.h" -#include "IECore/VectorTypedData.h" - -#include "GA/GA_Names.h" -#include "GU/GU_Detail.h" -#include "OP/OP_Context.h" - -#include "boost/algorithm/string/join.hpp" -#include "boost/algorithm/string/replace.hpp" -#include "boost/regex.hpp" -#include "boost/container_hash/hash.hpp" - -#include "tbb/tbb.h" - -#include - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -namespace -{ - -InternedString g_meshInterpolation( "ieMeshInterpolation" ); -InternedString g_linear( "linear" ); -InternedString g_catmullClark( "catmullClark" ); -InternedString g_normals( "N" ); -IECore::InternedString g_Tags( "tags" ); -IECore::InternedString g_uniqueTags( "__uniqueTags" ); -static std::string attrName = "name"; - -GU_DetailHandle renderGeometryHandle( OBJ_Node* objNode, OP_Context context ) -{ -#if UT_MAJOR_VERSION_INT >= 18 - return objNode->getRenderGeometryHandle( context, false ); -#else - for (OP_Node *output : objNode->getOutputNodePtrs()) - { - if (output->whichOutputNode() == 0) - { - if( SOP_Node *sop = output->castToSOPNode() ) - { - return sop->getCookedGeoHandle( context, false ); - } - } - } - return objNode->getRenderGeometryHandle( context, false ); -#endif -} - -/// ensure we have a normalised path with leading '/' -/// examples: '///a/b/c//d' -> '/a/b/c/d' -/// 'e/f/g' -> '/e/f/g' -/// unlike a regular normalise it doesn't handle .. or . -std::string normalisePath(const std::string& str) -{ - std::string cleanedPath; - SceneInterface::Path p; - SceneInterface::stringToPath(str, p); - SceneInterface::pathToString(p, cleanedPath); - return cleanedPath; -} - -IntVectorDataPtr preprocessNames( PrimitiveVariable &primVar, int numIds ) -{ - // we want to segment on indices rather than strings. the results are the - // same but the comparison operations in the segment algorithm are quicker. - primVar.data = primVar.indices; - primVar.indices = nullptr; - IntVectorDataPtr uniqueIds = new IntVectorData; - auto &ids = uniqueIds->writable(); - ids.reserve( numIds ); - for( int i = 0; i < numIds; ++i ) - { - ids.push_back( i ); - } - - return uniqueIds; -} - -std::string postprocessNames( Primitive &primitive, const std::vector &segmentNames ) -{ - int id = runTimeCast( primitive.variables[attrName].data )->readable()[0]; - primitive.variables.erase( attrName ); - return segmentNames[id]; -} - -void processMeshInterpolation( MeshPrimitive &mesh, const std::string &name, CompoundData *blindData ) -{ - // Set mesh interpolation and prune N where appropriate. Subdivision meshes should not have normals. - // We assume this occurred because the geo contained both subdiv and linear meshes, inadvertantly - // extending the normals attribute to all meshes in the detail. - - if( auto meshTypeMap = blindData->member( g_meshInterpolation ) ) - { - if( auto *meshType = meshTypeMap->member( name ) ) - { - if( meshType->readable() ) - { - mesh.setInterpolation( g_catmullClark ); - mesh.variables.erase( g_normals ); - } - } - } -} - -void processTags( Primitive &primitive, const std::string &name, CompoundData *blindData ) -{ - if( auto tagMap = blindData->member( g_Tags ) ) - { - if( auto *uniqueTagData = tagMap->member( g_uniqueTags ) ) - { - if( auto *membershipData = tagMap->member( name ) ) - { - const auto &uniqueTags = uniqueTagData->readable(); - const auto &membership = membershipData->readable(); - - InternedStringVectorDataPtr tagData = new InternedStringVectorData; - auto &tags = tagData->writable(); - for( size_t i = 0; i < membership.size(); ++i ) - { - if( membership[i] ) - { - tags.emplace_back( uniqueTags[i] ); - } - } - - primitive.blindData()->writable()[g_Tags] = tagData; - } - } - } -} - -/// For a given detail get all the unique names -DetailSplitter::Names getNames( const GU_Detail *detail ) -{ - std::unordered_set uniqueNames; - DetailSplitter::Names allNames; - - GA_ROHandleS nameAttrib( detail, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( !nameAttrib.isValid() ) - { - return allNames; - } - - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - std::vector indexRemap; - /// \todo: replace with GA_ROHandleS somehow... its not clear how, there don't seem to be iterators. - const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); - indexRemap.resize( tuple->getTableEntries( nameAttr ), -1 ); - int i = 0; - for( GA_AIFSharedStringTuple::iterator it = tuple->begin( nameAttr ); !it.atEnd(); ++it, ++i ) - { - allNames.push_back( it.getString() ); - indexRemap[it.getIndex()] = i; - } - - GA_Offset start, end; - for( GA_Iterator it( detail->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - int index = nameAttrib.getIndex( offset ); - if( index < 0 ) - { - continue; - } - - uniqueNames.insert( allNames[indexRemap[index]] ); - } - } - - return DetailSplitter::Names( uniqueNames.begin(), uniqueNames.end() ); -} - -/// Generate a hash for Imath::V2f to allow it to be used in a std::unordered_map. -/// Accepted wisdom says we should define a template specialisation of hash in the std namespace -/// but perhaps that might be better done by the imath headers themselves? -class Hasher -{ - public: - - size_t operator()( const Imath::V2f &v ) const - { - size_t result = 0; - boost::hash_combine( result, v.x ); - boost::hash_combine( result, v.y ); - return result; - } -}; - -void weldUVs( std::vector &meshes ) -{ - std::vector uvVariables; - for( auto mesh : meshes ) - { - for( auto &kv : mesh->variables ) - { - if( const auto *input = runTimeCast( kv.second.data.get() ) ) - { - if( input->getInterpretation() == GeometricData::UV ) - { - uvVariables.push_back( &kv.second ); - } - } - } - } - - tbb::parallel_for( - tbb::blocked_range( 0, uvVariables.size() ), - [&uvVariables]( const tbb::blocked_range &r ) - { - for( auto i = r.begin(); i != r.end(); ++i ) - { - // \todo: this is largely duplicated from FromHoudiniGeometryConverter. should it be a MeshAlgo? - auto primVar = uvVariables[i]; - const auto *input = runTimeCast( primVar->data.get() ); - const auto &inUvs = input->readable(); - - V2fVectorDataPtr output = new V2fVectorData; - output->setInterpretation( GeometricData::UV ); - auto &outUVs = output->writable(); - // this is an overestimate but should be safe - outUVs.reserve( inUvs.size() ); - - IntVectorDataPtr indexData = new IntVectorData; - auto &indices = indexData->writable(); - - std::unordered_map uniqueUVs; - - for( const auto &inUV : inUvs ) - { - int newIndex = uniqueUVs.size(); - auto uvIt = uniqueUVs.insert( { inUV, newIndex } ); - if( uvIt.second ) - { - indices.push_back( newIndex ); - outUVs.push_back( inUV ); - } - else - { - indices.push_back( uvIt.first->second ); - } - } - - primVar->data = output; - primVar->indices = indexData; - } - } - ); -} - -} // namespace - -DetailSplitter::DetailSplitter( const GU_DetailHandle &handle, const std::string &key, bool useHoudiniSegment ) - : m_time( 0.0 ), m_objNode( nullptr ), m_lastMetaCount( -1 ), m_key( key ), m_handle( handle ), m_useHoudiniSegment( useHoudiniSegment ) -{ -} - -DetailSplitter::DetailSplitter( OBJ_Node *objNode, double time, const std::string &key , bool useHoudiniSegment ) - : m_time( time ), - m_objNode( objNode ), - m_lastMetaCount( -1 ), - m_key( key ), - m_useHoudiniSegment( useHoudiniSegment ), - m_context( time ), - m_handle( renderGeometryHandle( m_objNode, m_context ) ) -{ -} - -DetailSplitter::~DetailSplitter() -{ -} - -const GU_DetailHandle &DetailSplitter::handle() const -{ - return m_handle; -} - -const GU_DetailHandle DetailSplitter::split( const std::string &value ) -{ - if ( !validate() ) - { - return GU_DetailHandle(); - } - - Cache::const_iterator it = m_cache.find( value ); - if ( it != m_cache.end() ) - { - return it->second; - } - - return GU_DetailHandle(); -} - -IECore::ObjectPtr DetailSplitter::splitObject( const std::string& value) -{ - if ( !validate() ) - { - return nullptr; - } - - auto it = m_segmentMap.find( value ); - if ( it != m_segmentMap.end() ) - { - return it->second; - } - - return nullptr; -} - -bool DetailSplitter::validate() -{ - GU_DetailHandleAutoReadLock readHandle( m_handle ); - const GU_Detail *geo = readHandle.getGdp(); - if ( !geo ) - { - return false; - } - - if ( geo->getMetaCacheCount() == m_lastMetaCount ) - { - return true; - } - - m_names = ::getNames( geo ); - - if ( !m_pathMatcher ) - { - m_pathMatcher = new IECore::PathMatcherData(); - } - - IECore::PathMatcher &pathMatcher = m_pathMatcher->writable(); - pathMatcher.clear(); - - for( const auto &name : m_names ) - { - pathMatcher.addPath( name ); - } - - m_cache.clear(); - m_lastMetaCount = geo->getMetaCacheCount(); - - GA_ROHandleS attribHandle( geo, GA_ATTRIB_PRIMITIVE, m_key.c_str() ); - if( !attribHandle.isValid() ) - { - m_cache[""] = m_handle; - return true; - } - - m_segmentMap.clear(); - - if( !m_useHoudiniSegment ) - { - auto converter = FromHoudiniGeometryConverter::create( m_handle ); - - if ( converter ) - { - converter->parameters()->parameter( "preserveName" )->setTypedValue( true ); - // disable UV welding during conversion to improve performance of the named segmentation. - converter->parameters()->parameter( "weldUVs" )->setTypedValue( false ); - - if( runTimeCast( converter ) ) - { - ObjectPtr o = converter->convert(); - MeshPrimitive *mesh = runTimeCast( o.get() ); - - auto it = mesh->variables.find( attrName ); - if( it != mesh->variables.end() ) - { - if( const StringVectorDataPtr nameData = runTimeCast( it->second.data ) ) - { - const std::vector &segmentNames = nameData->readable(); - IntVectorDataPtr uniqueIds = ::preprocessNames( it->second, segmentNames.size() ); - std::vector segments = MeshAlgo::segment( mesh, it->second, uniqueIds.get() ); - // weld the mesh UVs to prevent discontinuity when subdivided - ::weldUVs( segments ); - for( size_t i = 0; i < segments.size(); ++i ) - { - std::string name = ::postprocessNames( *segments[i], segmentNames ); - ::processMeshInterpolation( *segments[i], name, mesh->blindData() ); - ::processTags( *segments[i], name, mesh->blindData() ); - m_segmentMap[normalisePath( name )] = segments[i]; - } - return true; - } - } - } - else if( runTimeCast( converter ) ) - { - ObjectPtr o = converter->convert(); - CurvesPrimitive *curves = runTimeCast( o.get() ); - - auto it = curves->variables.find( attrName ); - if( it != curves->variables.end() ) - { - if( const StringVectorDataPtr nameData = runTimeCast( it->second.data ) ) - { - const std::vector &segmentNames = nameData->readable(); - IntVectorDataPtr uniqueIds = ::preprocessNames( it->second, segmentNames.size() ); - std::vector segments = CurvesAlgo::segment( curves, it->second, uniqueIds.get() ); - for( size_t i = 0; i < segments.size(); ++i ) - { - std::string name = ::postprocessNames( *segments[i], segmentNames ); - ::processTags( *segments[i], name, curves->blindData() ); - m_segmentMap[normalisePath( name )] = segments[i]; - } - return true; - } - } - } - else if( runTimeCast( converter ) ) - { - ObjectPtr o = converter->convert(); - PointsPrimitive *points = runTimeCast( o.get() ); - - auto it = points->variables.find( attrName ); - if( it != points->variables.end() ) - { - if( const StringVectorDataPtr nameData = runTimeCast( it->second.data ) ) - { - const std::vector &segmentNames = nameData->readable(); - IntVectorDataPtr uniqueIds = ::preprocessNames( it->second, segmentNames.size() ); - std::vector segments = PointsAlgo::segment( points, it->second, uniqueIds.get() ); - for( size_t i = 0; i < segments.size(); ++i ) - { - std::string name = ::postprocessNames( *segments[i], segmentNames ); - ::processTags( *segments[i], name, points->blindData() ); - m_segmentMap[normalisePath( name )] = segments[i]; - } - return true; - } - } - } - } - } - - std::map offsets; - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - GA_StringIndexType currentHandle = attribHandle.getIndex( offset ); - - auto oIt = offsets.insert( { currentHandle, GA_OffsetList() } ).first; - oIt->second.append( offset ); - } - } - - const GA_Attribute *attr = attribHandle.getAttribute(); - const GA_AIFSharedStringTuple *tuple = attr->getAIFSharedStringTuple(); - for( const auto &kv : offsets ) - { - GU_Detail *newGeo = new GU_Detail(); - GA_Range matchPrims( geo->getPrimitiveMap(), kv.second ); - newGeo->mergePrimitives( *geo, matchPrims ); - newGeo->bumpAllDataIds(); - newGeo->incrementMetaCacheCount(); - - GU_DetailHandle handle; - handle.allocateAndSet( newGeo, true ); - - std::string current = ""; - if( const char *value = tuple->getTableString( attr, kv.first ) ) - { - current = value; - } - - m_cache[current] = handle; - } - - return !m_cache.empty(); -} - -void DetailSplitter::values( std::vector &result ) -{ - /// \todo: do we really want this method to create the cache? should it just look at the names instead? - if ( !validate() ) - { - return; - } - - result.clear(); - result.reserve( m_cache.size() ); - - for ( Cache::iterator it = m_cache.begin(); it != m_cache.end(); ++it ) - { - result.push_back( it->first ); - } -} - -DetailSplitter::Names DetailSplitter::getNames(const std::vector& path) -{ - Names names; - - if ( !validate()) - { - return names; - } - - IECore::PathMatcher subTree = m_pathMatcher->readable().subTree( path ); - for ( IECore::PathMatcher::RawIterator it = subTree.begin(); it != subTree.end(); ++it ) - { - if ( !it->empty() ) - { - names.push_back( *it->rbegin() ); - it.prune(); - } - } - - return names; -} - -bool DetailSplitter::hasPath( const IECoreScene::SceneInterface::Path& path, bool isExplicit ) -{ - if ( !validate() ) - { - return false; - } - - if ( isExplicit ) - { - PathMatcher::RawIterator rawIt = m_pathMatcher->readable().find( path ); - - return rawIt != m_pathMatcher->readable().end() && rawIt.exactMatch(); - } - - return m_pathMatcher->readable().find( path ) != m_pathMatcher->readable().end(); -} - -bool DetailSplitter::hasPaths() -{ - if ( !validate() ) - { - return false; - } - return m_pathMatcher && !m_pathMatcher->readable().isEmpty(); -} - -bool DetailSplitter::update( OBJ_Node *objNode, double time ) -{ - if ( m_objNode == objNode && time == m_time) - { - return false; - } - - m_time = time; - m_objNode = objNode; - m_lastMetaCount = -1; - m_context = OP_Context( time ); - m_handle = renderGeometryHandle( m_objNode, m_context ); - - m_pathMatcher.reset(); - m_names.clear(); - m_segmentMap.clear(); - m_cache.clear(); - - return true; -} diff --git a/src/IECoreHoudini/FromHoudiniCompoundObjectConverter.cpp b/src/IECoreHoudini/FromHoudiniCompoundObjectConverter.cpp deleted file mode 100644 index 1533ca36a1..0000000000 --- a/src/IECoreHoudini/FromHoudiniCompoundObjectConverter.cpp +++ /dev/null @@ -1,159 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniCompoundObjectConverter.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#include "IECore/CompoundObject.h" - -#include "GA/GA_Names.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniCompoundObjectConverter ); - -FromHoudiniGeometryConverter::Description FromHoudiniCompoundObjectConverter::m_description( CompoundObjectTypeId ); - -FromHoudiniCompoundObjectConverter::FromHoudiniCompoundObjectConverter( const GU_DetailHandle &handle ) : - FromHoudiniGeometryConverter( handle, "Converts a Houdini GU_Detail to an IECore::CompoundObject." ) -{ -} - -FromHoudiniCompoundObjectConverter::FromHoudiniCompoundObjectConverter( const SOP_Node *sop ) : - FromHoudiniGeometryConverter( sop, "Converts a Houdini GU_Detail to an IECore::CompoundObject." ) -{ -} - -FromHoudiniCompoundObjectConverter::~FromHoudiniCompoundObjectConverter() -{ -} - -FromHoudiniGeometryConverter::Convertability FromHoudiniCompoundObjectConverter::canConvert( const GU_Detail *geo ) -{ - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - // need multiple names - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if ( nameAttrib.isValid() ) - { - GA_StringTableStatistics stats; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); - tuple->getStatistics( nameAttr, stats ); - if ( stats.getEntries() < 2 ) - { - return Inapplicable; - } - } - else - { - return Inapplicable; - } - - // Need them all to be convertable as objects. Even then, if they're VisibleRenderable, - // then the FromHoudiniGroupConverter would be preferable. - bool nonRenderable = false; - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( prim->getTypeId() != CortexPrimitive::typeId() ) - { - return Inapplicable; - } - - if( !IECore::runTimeCast( ( (CortexPrimitive *) prim )->getObject() ) ) - { - nonRenderable = true; - } - } - } - - return ( nonRenderable ) ? Ideal : Suitable; -} - -ObjectPtr FromHoudiniCompoundObjectConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const -{ - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( nameAttrib.isInvalid() ) - { - throw std::runtime_error( "FromHoudiniCompoundObjectConverter: Can only convert named CortexObject primitives" ); - } - - CompoundObjectPtr result = new CompoundObject(); - - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - - if( prim->getTypeId() != CortexPrimitive::typeId() ) - { - throw std::runtime_error( "FromHoudiniCompoundObjectConverter: Geometry contains non-CortexObject primitives" ); - } - - std::string name = ""; - const char *tmp = nameAttrib.get( offset ); - if( tmp ) - { - name = tmp; - } - - ConstObjectPtr object = ( (CortexPrimitive *) prim )->getObject(); - - result->members()[name] = ( object ) ? object->copy() : nullptr; - } - } - - return result; -} diff --git a/src/IECoreHoudini/FromHoudiniConverter.cpp b/src/IECoreHoudini/FromHoudiniConverter.cpp deleted file mode 100644 index 660c6a23ef..0000000000 --- a/src/IECoreHoudini/FromHoudiniConverter.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniConverter.h" - -#include "IECore/CompoundParameter.h" - -using namespace IECoreHoudini; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniConverter ); - -FromHoudiniConverter::FromHoudiniConverter( const std::string &description ) - : ToCoreConverter( description ) -{ -} - -FromHoudiniConverter::~FromHoudiniConverter() -{ -} diff --git a/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp b/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp deleted file mode 100644 index 22dbabcaf9..0000000000 --- a/src/IECoreHoudini/FromHoudiniCortexObjectConverter.cpp +++ /dev/null @@ -1,147 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniCortexObjectConverter.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -#include "IECore/CompoundObject.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniCortexObjectConverter ); - -FromHoudiniGeometryConverter::Description FromHoudiniCortexObjectConverter::m_description( ObjectTypeId ); -FromHoudiniGeometryConverter::Description FromHoudiniCortexObjectConverter::m_universalDescription( InvalidTypeId ); - -FromHoudiniCortexObjectConverter::FromHoudiniCortexObjectConverter( const GU_DetailHandle &handle ) : - FromHoudiniGeometryConverter( handle, "Converts a Houdini GU_Detail to an IECore::Object." ) -{ -} - -FromHoudiniCortexObjectConverter::FromHoudiniCortexObjectConverter( const SOP_Node *sop ) : - FromHoudiniGeometryConverter( sop, "Converts a Houdini GU_Detail to an IECore::Object." ) -{ -} - -FromHoudiniCortexObjectConverter::~FromHoudiniCortexObjectConverter() -{ -} - -FromHoudiniGeometryConverter::Convertability FromHoudiniCortexObjectConverter::canConvert( const GU_Detail *geo ) -{ - size_t numPrims = geo->getNumPrimitives(); - if ( numPrims == 1 ) - { - const GA_Primitive *prim = geo->getPrimitiveList().get( geo->getPrimitiveRange().begin().getOffset() ); - - if ( prim->getTypeId() == CortexPrimitive::typeId() ) - { - return Ideal; - } - } - - return Inapplicable; -} - -ObjectPtr FromHoudiniCortexObjectConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const -{ - const GA_Primitive *prim = geo->getPrimitiveList().get( geo->getPrimitiveRange().begin().getOffset() ); - - if ( prim->getTypeId() != CortexPrimitive::typeId() ) - { - throw std::runtime_error( "FromHoudiniCortexObjectConverter: Geometry does not contain a single CortexObject primitive" ); - } - - ConstObjectPtr object = ((CortexPrimitive *)prim)->getObject(); - - ObjectPtr result = filterAttribs( object.get(), operands->member( "attributeFilter" )->readable().c_str() ); - - if ( result ) - { - return result; - } - - if ( object ) - { - return object->copy(); - } - - return 0; -} - -ObjectPtr FromHoudiniCortexObjectConverter::filterAttribs( const Object *object, const char *filter ) const -{ - const Primitive *primitive = IECore::runTimeCast( object ); - if ( !primitive ) - { - return 0; - } - - std::vector variablesToErase; - const PrimitiveVariableMap &variables = primitive->variables; - for ( PrimitiveVariableMap::const_iterator it = variables.begin(); it != variables.end(); ++it ) - { - if ( !UT_String( it->first ).multiMatch( filter ) ) - { - variablesToErase.push_back( it->first ); - } - } - - if ( variablesToErase.empty() ) - { - return 0; - } - - PrimitivePtr result = primitive->copy(); - PrimitiveVariableMap &resultVariables = result->variables; - for ( size_t i = 0; i < variablesToErase.size(); ++i ) - { - resultVariables.erase( variablesToErase[i] ); - } - - return result; -} diff --git a/src/IECoreHoudini/FromHoudiniCurvesConverter.cpp b/src/IECoreHoudini/FromHoudiniCurvesConverter.cpp deleted file mode 100644 index 17f7685574..0000000000 --- a/src/IECoreHoudini/FromHoudiniCurvesConverter.cpp +++ /dev/null @@ -1,278 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniCurvesConverter.h" -#include "IECoreHoudini/TypeTraits.h" - -#include "IECore/DespatchTypedData.h" - -#include "GA/GA_Names.h" -#include "GEO/GEO_Curve.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniCurvesConverter ); - -FromHoudiniGeometryConverter::Description FromHoudiniCurvesConverter::m_description( CurvesPrimitive::staticTypeId() ); - -FromHoudiniCurvesConverter::FromHoudiniCurvesConverter( const GU_DetailHandle &handle ) : - FromHoudiniGeometryConverter( handle, "Converts a Houdini GU_Detail to an IECoreScene::CurvesPrimitive." ) -{ -} - -FromHoudiniCurvesConverter::FromHoudiniCurvesConverter( const SOP_Node *sop ) : - FromHoudiniGeometryConverter( sop, "Converts a Houdini GU_Detail to an IECoreScene::CurvesPrimitive." ) -{ -} - -FromHoudiniCurvesConverter::~FromHoudiniCurvesConverter() -{ -} - -FromHoudiniGeometryConverter::Convertability FromHoudiniCurvesConverter::canConvert( const GU_Detail *geo ) -{ - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - unsigned numPrims = geo->getNumPrimitives(); - - if ( !numPrims ) - { - return Inapplicable; - } - - GA_Iterator firstPrim = geo->getPrimitiveRange().begin(); - GA_PrimitiveTypeId firstPrimitiveType = primitives.get( firstPrim.getOffset() )->getTypeId() ; - - if ( !compatiblePrimitive( firstPrimitiveType ) ) - { - return Inapplicable; - } - - if ( firstPrimitiveType != GEO_PRIMPOLY ) - { - const GEO_Curve *firstCurve = (const GEO_Curve*)primitives.get( firstPrim.getOffset() ); - bool periodic = firstCurve->isClosed(); - unsigned order = firstCurve->getOrder(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( !compatiblePrimitive( prim->getTypeId() ) ) - { - return Inapplicable; - } - - const GEO_Curve *curve = (const GEO_Curve *) prim; - if( curve->getOrder() != order ) - { - return Inapplicable; - } - - if( curve->isClosed() != periodic ) - { - return Inapplicable; - } - } - } - } - else - { - if ( hasOnlyOpenPolygons( geo) ) - { - return Ideal; - } - else - { - return Inapplicable; - } - } - - // is there a single named shape? - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( nameAttrib.isValid() ) - { - GA_StringTableStatistics stats; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); - tuple->getStatistics( nameAttr, stats ); - if ( stats.getEntries() < 2 ) - { - return Ideal; - } - } - - return Suitable; -} - -ObjectPtr FromHoudiniCurvesConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const -{ - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - CurvesPrimitivePtr result = new CurvesPrimitive(); - - GA_Iterator firstPrim = geo->getPrimitiveRange().begin(); - if ( !geo->getNumPrimitives() || !compatiblePrimitive( primitives.get( firstPrim.getOffset() )->getTypeId() ) ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry contains no curves or non-curve primitives" ); - } - - // set periodic based on the first curve - const GEO_Curve *firstCurve = (const GEO_Curve*)primitives.get( firstPrim.getOffset() ); - bool periodic = firstCurve->isClosed(); - - // set basis based on the first curve - bool duplicateEnds = false; - CubicBasisf basis = CubicBasisf::linear(); - unsigned order = firstCurve->getOrder(); - if ( order == 4 ) - { - basis = CubicBasisf::bSpline(); - - if ( !periodic ) - { - // there's an implicit duplication of the end points that we need to make explicit - duplicateEnds = true; - } - } - - std::vector origVertsPerCurve; - std::vector finalVertsPerCurve; - int totalVerts = 0; - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( !compatiblePrimitive( prim->getTypeId() ) ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry contains non-curve primitives" ); - } - - const GEO_Curve *curve = (const GEO_Curve *) prim; - if( curve->getOrder() != order ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry contains multiple curves with differing order. Set all curves to order 2 (linear) or 4 (cubic bSpline)" ); - } - - if( curve->isClosed() != periodic ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry contains both open and closed curves" ); - } - - size_t numPrimVerts = prim->getVertexCount(); - origVertsPerCurve.push_back( numPrimVerts ); - totalVerts += numPrimVerts; - - if( duplicateEnds && numPrimVerts ) - { - numPrimVerts += 4; - } - finalVertsPerCurve.push_back( numPrimVerts ); - } - } - - if ( geo->getPointRange().getEntries() > totalVerts ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry contains more points than curve vertices" ); - } - - if ( !origVertsPerCurve.size() ) - { - throw std::runtime_error( "FromHoudiniCurvesConverter: Geometry does not contain curve vertices" ); - } - - result->setTopology( new IntVectorData( origVertsPerCurve ), basis, periodic ); - transferAttribs( geo, result.get(), operands, PrimitiveVariable::Vertex ); - - if ( !duplicateEnds ) - { - return result; - } - - // adjust for duplicated end points - DuplicateEnds func( result->verticesPerCurve()->readable() ); - for ( PrimitiveVariableMap::const_iterator it=result->variables.begin() ; it != result->variables.end(); it++ ) - { - // only duplicate point and vertex attrib end points - if ( it->second.interpolation == IECoreScene::PrimitiveVariable::Vertex ) - { - IECore::Data *data = it->second.indices ? it->second.indices.get() : it->second.data.get(); - despatchTypedData( data, func ); - } - } - - result->setTopology( new IntVectorData( finalVertsPerCurve ), basis, periodic ); - - return result; -} - -FromHoudiniCurvesConverter::DuplicateEnds::DuplicateEnds( const std::vector &vertsPerCurve ) : m_vertsPerCurve( vertsPerCurve ) -{ -} - -template -FromHoudiniCurvesConverter::DuplicateEnds::ReturnType FromHoudiniCurvesConverter::DuplicateEnds::operator()( T *data ) const -{ - assert( data ); - - typedef typename T::ValueType::value_type ValueType; - - std::vector newValues; - const std::vector &origValues = data->readable(); - newValues.reserve( origValues.size() + m_vertsPerCurve.size()*4 ); - - size_t index = 0; - for ( size_t i=0; i < m_vertsPerCurve.size(); i++ ) - { - for ( size_t j=0; j < (size_t)m_vertsPerCurve[i]; j++, index++ ) - { - newValues.push_back( origValues[index] ); - - if ( j == 0 || j == (size_t)m_vertsPerCurve[i]-1 ) - { - newValues.push_back( origValues[index] ); - newValues.push_back( origValues[index] ); - } - } - } - - data->writable().swap( newValues ); -} diff --git a/src/IECoreHoudini/FromHoudiniGeometryConverter.cpp b/src/IECoreHoudini/FromHoudiniGeometryConverter.cpp deleted file mode 100644 index 9a37e30a91..0000000000 --- a/src/IECoreHoudini/FromHoudiniGeometryConverter.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" - -#include "IECoreHoudini/Convert.h" - -#include "IECoreScene/private/PrimitiveVariableAlgos.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" - -#include "CH/CH_Manager.h" -#include "GA/GA_Names.h" -#include "UT/UT_StdUtil.h" -#include "UT/UT_StringMMPattern.h" -#include "UT/UT_Version.h" -#include "UT/UT_WorkArgs.h" - -#include "boost/functional/hash.hpp" -#include "boost/lexical_cast.hpp" - -#include "tbb/tbb.h" - -#include - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniGeometryConverter ); - -namespace -{ - -/// Generate a hash for Imath::V2f to allow it to be used in a std::unordered_map. -/// Accepted wisdom says we should define a template specialisation of hash in the std namespace -/// but perhaps that might be better done by the imath headers themselves? -class Hasher -{ - public: - - size_t operator()( const Imath::V2f &v ) const - { - size_t result = 0; - boost::hash_combine( result, v.x ); - boost::hash_combine( result, v.y ); - return result; - } -}; - -const IECore::InternedString g_Tags( "tags" ); -IECore::InternedString g_uniqueTags( "__uniqueTags" ); -const UT_String g_tagGroupPrefix( "ieTag_" ); - -} // namepspace - -FromHoudiniGeometryConverter::FromHoudiniGeometryConverter( const GU_DetailHandle &handle, const std::string &description ) - : FromHoudiniConverter( description ), m_geoHandle( handle ) -{ - constructCommon(); -} - -FromHoudiniGeometryConverter::FromHoudiniGeometryConverter( const SOP_Node *sop, const std::string &description ) - : FromHoudiniConverter( description ) -{ - m_geoHandle = handle( sop ); - - constructCommon(); -} - -FromHoudiniGeometryConverter::~FromHoudiniGeometryConverter() -{ -} - -void FromHoudiniGeometryConverter::constructCommon() -{ - m_attributeFilterParameter = new StringParameter( - "attributeFilter", - "A list of attribute names to convert, if they exist. Uses Houdini matching syntax. P will always be converted", - "*" - ); - - m_convertStandardAttributesParameter = new BoolParameter( - "convertStandardAttributes", - "Performs automated conversion of Houdini Attributes to standard PrimitiveVariables (i.e. rest->Pref ; Cd->Cs)", - true - ); - - m_preserveNameParameter = new BoolParameter( - "preserveName", - "Keep the name attribute in conversion", - false - ); - - m_weldUVsParameter = new BoolParameter( - "weldUVs", - "Generate UV indices by de-duplicating identical values. This can be desirable for subdivision rendering or conversion to other DCCs (eg Maya).", - true - ); - - parameters()->addParameter( m_attributeFilterParameter ); - parameters()->addParameter( m_convertStandardAttributesParameter ); - parameters()->addParameter( m_preserveNameParameter ); - parameters()->addParameter( m_weldUVsParameter ); -} - -const GU_DetailHandle FromHoudiniGeometryConverter::handle( const SOP_Node *sop ) -{ - // create the work context - OP_Context context; - context.setTime( CHgetEvalTime() ); - - return ((SOP_Node*)sop)->getCookedGeoHandle( context ); -} - -const GU_DetailHandle &FromHoudiniGeometryConverter::handle() const -{ - return m_geoHandle; -} - -ObjectPtr FromHoudiniGeometryConverter::doConversion( ConstCompoundObjectPtr operands ) const -{ - GU_DetailHandleAutoReadLock readHandle( m_geoHandle ); - const GU_Detail *geo = readHandle.getGdp(); - if ( !geo ) - { - return 0; - } - - return doDetailConversion( geo, operands.get() ); -} - -void FromHoudiniGeometryConverter::transferAttribs( - const GU_Detail *geo, IECoreScene::Primitive *result, const CompoundObject *operands, - PrimitiveVariable::Interpolation vertexInterpolation, - PrimitiveVariable::Interpolation primitiveInterpolation, - PrimitiveVariable::Interpolation pointInterpolation, - PrimitiveVariable::Interpolation detailInterpolation -) const -{ - -#if UT_MAJOR_VERSION_INT < 15 - - // add position (this can't be done as a regular attrib because it would be V4fVectorData) - GA_Range pointRange = geo->getPointRange(); - std::vector pData( pointRange.getEntries() ); - for ( GA_Iterator it=pointRange.begin(); !it.atEnd(); ++it ) - { - pData[it.getIndex()] = IECore::convert( geo->getPos3( it.getOffset() ) ); - } - - result->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( pData, GeometricData::Point ) ); - -#endif - - // build the attribute filter - UT_String p( "P" ); - UT_String filter( operands->member( "attributeFilter" )->readable() ); - UT_StringMMPattern attribFilter; - // force P and optionally prevent name - if ( !operands->member("preserveName")->readable() ) - { - filter += " ^name"; - } - - if ( !p.match( filter ) ) - { - filter += " P"; - } - attribFilter.compile( filter ); - - // add detail attribs - if ( result->variableSize( detailInterpolation ) == 1 ) - { - transferDetailAttribs( geo, operands, attribFilter, result, detailInterpolation ); - } - - // add point attribs - if ( result->variableSize( pointInterpolation ) == (unsigned)geo->getNumPoints() ) - { - transferElementAttribs( geo, geo->getPointRange(), operands, geo->pointAttribs(), attribFilter, result, pointInterpolation ); - } - - // add primitive attribs - size_t numPrims = geo->getNumPrimitives(); - if ( result->variableSize( primitiveInterpolation ) == numPrims ) - { - transferElementAttribs( geo, geo->getPrimitiveRange(), operands, geo->primitiveAttribs(), attribFilter, result, primitiveInterpolation ); - } - - // add vertex attribs - size_t numVerts = geo->getNumVertices(); - if ( geo->vertexAttribs().entries() && result->variableSize( vertexInterpolation ) == numVerts ) - { - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_OffsetList offsets; - offsets.harden( numVerts ); - offsets.setEntries( numVerts ); - - size_t i = 0; - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - /// \todo: we shouldn't reverse winding for open polys (eg linear curves) - bool reverseWinding = ( prim->getTypeId() == GEO_PRIMPOLY ); - - size_t numPrimVerts = prim->getVertexCount(); - for ( size_t v=0; v < numPrimVerts; ++v, ++i ) - { - if( reverseWinding ) - { - offsets.set( i, prim->getVertexOffset( numPrimVerts - 1 - v ) ); - } - else - { - offsets.set( i, prim->getVertexOffset( v ) ); - } - } - } - } - - // \todo: Apparently the loop above could be more efficient using UT_Array if we didn't need the GA_Range. - // Consider changing the transferElementAttribs API to allow for that. - GA_Range vertRange( geo->getVertexMap(), offsets ); - transferElementAttribs( geo, vertRange, operands, geo->vertexAttribs(), attribFilter, result, vertexInterpolation ); - } - - transferTags( geo, result ); -} - -void FromHoudiniGeometryConverter::transferElementAttribs( const GU_Detail *geo, const GA_Range &range, const IECore::CompoundObject *operands, const GA_AttributeDict &attribs, const UT_StringMMPattern &attribFilter, Primitive *result, PrimitiveVariable::Interpolation interpolation ) const -{ - std::vector attrs; - for( GA_AttributeDict::iterator it=attribs.begin( GA_SCOPE_PUBLIC ); it != attribs.end(); ++it ) - { - const GA_Attribute *attr = it.attrib(); - if( !attr ) - { - continue; - } - - const GA_ROAttributeRef attrRef( attr ); - if ( attrRef.isInvalid() ) - { - continue; - } - - UT_String name( attr->getName() ); - if ( !name.multiMatch( attribFilter ) ) - { - continue; - } - - attrs.push_back( attr ); - } - - std::vector primVars; - primVars.resize( attrs.size() ); - - std::vector names; - names.resize( attrs.size() ); - - tbb::parallel_for( - tbb::blocked_range( 0, attrs.size() ), - [this, &geo, &range, &operands, &attrs, &primVars, &names]( const tbb::blocked_range &r ) - { - for( auto i = r.begin(); i != r.end(); ++i ) - { - transferElementAttrib( geo, range, operands, attrs[i], primVars[i], names[i] ); - } - } - ); - - for( size_t i = 0; i < attrs.size(); ++i ) - { - if( primVars[i].data ) - { - primVars[i].interpolation = interpolation; - result->variables[names[i]] = primVars[i]; - } - } -} - -void FromHoudiniGeometryConverter::transferElementAttrib( - const GU_Detail *geo, const GA_Range &range, const IECore::CompoundObject *operands, - const GA_Attribute *attr, PrimitiveVariable &result, std::string &resultName -) const -{ - // special case for uvs - if( attr->getOptions().typeInfo() == GA_TYPE_TEXTURE_COORD || attr->getName().equal( "uv" ) ) - { - // uvs are V3f in Houdini, so we must extract individual components - FloatVectorDataPtr uData = extractData( attr, range, 0 ); - FloatVectorDataPtr vData = extractData( attr, range, 1 ); - const std::vector &u = uData->readable(); - const std::vector &v = vData->readable(); - - IntVectorDataPtr indexData = nullptr; - V2fVectorDataPtr uvData = new V2fVectorData; - uvData->setInterpretation( GeometricData::UV ); - - std::vector &uvs = uvData->writable(); - uvs.reserve( u.size() ); - - if( operands->member("weldUVs")->readable() ) - { - indexData = new IntVectorData; - std::vector &indices = indexData->writable(); - - std::unordered_map uniqueUVs; - - for( size_t i = 0; i < u.size(); ++i ) - { - Imath::V2f uv( u[i], v[i] ); - - int newIndex = uniqueUVs.size(); - auto uvIt = uniqueUVs.insert( { uv, newIndex } ); - if( uvIt.second ) - { - indices.push_back( newIndex ); - uvs.push_back( uv ); - } - else - { - indices.push_back( uvIt.first->second ); - } - } - } - else - { - for( size_t i = 0; i < u.size(); ++i ) - { - uvs.emplace_back( u[i], v[i] ); - } - } - - result.data = uvData; - result.indices = indexData; - resultName = attr->getName().toStdString(); - - return; - } - - // check for remapping information for this attribute - const GA_ROAttributeRef attrRef( attr ); - transferAttribData( result, resultName, attrRef, range ); -} - -void FromHoudiniGeometryConverter::transferAttribData( - IECoreScene::PrimitiveVariable &result, std::string &resultName, - const GA_ROAttributeRef &attrRef, const GA_Range &range -) const -{ - DataPtr dataPtr = nullptr; - - // we use this initial value to indicate we don't have a remapping so just - // guess what destination type to use. - IECore::TypeId varType = IECore::InvalidTypeId; - - const GA_Attribute *attr = attrRef.getAttribute(); - - IntVectorDataPtr indices = nullptr; - - switch ( attrRef.getStorageClass() ) - { - case GA_STORECLASS_FLOAT : - { - if( !attr->getAIFTuple() ) - { - // not supporting variable lists - return; - } - switch ( attr->getTupleSize() ) - { - case 1 : - { - dataPtr = extractData( attr, range ); - break; - } - case 2 : - { - // it can be either a single float (sub-component), or (default) just a V2f - switch( varType ) - { - case FloatVectorDataTypeId : - { - dataPtr = extractData( attr, range ); - break; - } - default : - { - dataPtr = extractData( attr, range ); - break; - } - } - break; - } - case 3 : - { - // it can be either a single float (sub-component), Color3f or (default) just a V3f - switch( varType ) - { - case FloatVectorDataTypeId : - { - dataPtr = extractData( attr, range ); - break; - } - case Color3fVectorDataTypeId : - { - dataPtr = extractData( attr, range ); - break; - } - default : - { - switch( attr->getTypeInfo() ) - { - case GA_TYPE_COLOR : - { - dataPtr = extractData( attr, range ); - break; - } - default : - { - dataPtr = extractData( attr, range ); - -#if UT_MAJOR_VERSION_INT >= 15 - - // special case for rest/Pref since Houdini considers rest Numeric - // but Cortex is expecting it to be Point. - if ( attr->getName().equal( "rest" ) || attr->getName().equal( "Pref" ) ) - { - V3fVectorData *restData = IECore::runTimeCast( dataPtr.get() ); - restData->setInterpretation( IECore::GeometricData::Point ); - } - -#endif - break; - } - - } - break; - } - } - break; - } - case 4 : - { - if( attr->getTypeInfo() == GA_TYPE_QUATERNION || ( !strcmp( attr->getName(), "orient" ) && attr->getTypeInfo() == GA_TYPE_VOID ) ) - { - dataPtr = extractData( attr, range ); - } - break; - } - case 9 : - { - dataPtr = extractData( attr, range ); - break; - } - case 16 : - { - dataPtr = extractData( attr, range ); - break; - } - default : - { - break; - } - } - break; - } - case GA_STORECLASS_INT : - { - if( !attr->getAIFTuple() ) - { - // not supporting variable lists - return; - } - switch ( attr->getTupleSize() ) - { - case 1 : - { - dataPtr = extractData( attr, range ); - break; - } - case 2 : - { - dataPtr = extractData( attr, range ); - break; - } - case 3 : - { - dataPtr = extractData( attr, range ); - break; - } - default : - { - break; - } - } - break; - } - case GA_STORECLASS_STRING : - { - dataPtr = extractStringVectorData( attr, range, indices ); - break; - } - default : - { - break; - } - } - - if ( dataPtr ) - { - std::string varName( attr->getName() ); - if ( m_convertStandardAttributesParameter->getTypedValue() ) - { - varName = processPrimitiveVariableName( varName ); - } - - // add the primitive variable to our result - result.data = dataPtr; - result.indices = indices; - resultName = varName; - } -} - -void FromHoudiniGeometryConverter::transferDetailAttribs( const GU_Detail *geo, const IECore::CompoundObject *operands, const UT_StringMMPattern &attribFilter, Primitive *result, PrimitiveVariable::Interpolation interpolation ) const -{ - const GA_AttributeDict &attribs = geo->attribs(); - - for ( GA_AttributeDict::iterator it=attribs.begin(); it != attribs.end(); ++it ) - { - GA_Attribute *attr = it.attrib(); - if ( !attr ) - { - continue; - } - - const GA_ROAttributeRef attrRef( attr ); - if ( attrRef.isInvalid() ) - { - continue; - } - - UT_String name( attr->getName() ); - if ( !name.multiMatch( attribFilter ) ) - { - continue; - } - - DataPtr dataPtr = 0; - - switch ( attrRef.getStorageClass() ) - { - case GA_STORECLASS_FLOAT : - { - if( !attr->getAIFTuple() ) - { - // not supporting variable lists - continue; - } - switch ( attr->getTupleSize() ) - { - case 1 : - { - dataPtr = extractData( attr ); - break; - } - case 2 : - { - dataPtr = extractData( attr ); - break; - } - case 3 : - { - switch( attr->getTypeInfo() ) - { - case GA_TYPE_COLOR : - { - dataPtr = extractData( attr ); - break; - } - default : - { - dataPtr = extractData( attr ); - break; - } - - } - break; - } - case 9: - { - dataPtr = extractData( attr ); - break; - } - case 16: - { - dataPtr = extractData( attr ); - break; - } - default : - { - break; - } - } - break; - } - case GA_STORECLASS_INT : - { - if( !attr->getAIFTuple() ) - { - // not supporting variable lists - continue; - } - switch ( attr->getTupleSize() ) - { - case 1 : - { - dataPtr = extractData( attr ); - break; - } - case 2 : - { - dataPtr = extractData( attr ); - break; - } - case 3 : - { - dataPtr = extractData( attr ); - break; - } - default : - { - break; - } - } - break; - } - case GA_STORECLASS_STRING : - { - dataPtr = extractStringData( geo, attr ); - break; - } - default : - { - break; - } - } - - if ( dataPtr ) - { - result->variables[ std::string( attr->getName() ) ] = PrimitiveVariable( interpolation, dataPtr ); - } - } -} - -void FromHoudiniGeometryConverter::transferTags( const GU_Detail *geo, Primitive *result ) const -{ - // map ieTag_ primGroups to names as blind data on the mesh - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( !nameAttrib.isValid() ) - { - return; - } - - // assemble the unique tags and map them to PrimGroups - std::vector groups; - InternedStringVectorDataPtr uniqueTagsData = new InternedStringVectorData; - auto &uniqueTags = uniqueTagsData->writable(); - for( auto it = geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) - { - if( it.group()->getInternal() || it.group()->isEmpty() ) - { - continue; - } - - const UT_String groupName( it.group()->getName() ); - if( !groupName.startsWith( g_tagGroupPrefix ) ) - { - continue; - } - - UT_String tag; - groupName.substr( tag, g_tagGroupPrefix.length() ); - tag.substitute( "_", ":" ); - - groups.emplace_back( it.group() ); - uniqueTags.emplace_back( tag.toStdString() ); - } - - // no valid tags - if( uniqueTags.empty() ) - { - return; - } - - CompoundDataPtr tagMapData = new CompoundData; - auto &tagMap = tagMapData->writable(); - tagMap[g_uniqueTags] = uniqueTagsData; - - // assemble the unique locations and pre-allocate membership vectors per tag - std::vector indexRemap; - std::vector *> locationMembership; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - /// \todo: replace with GA_ROHandleS somehow... its not clear how, there don't seem to be iterators. - const GA_AIFSharedStringTuple *nameTuple = nameAttr->getAIFSharedStringTuple(); - indexRemap.resize( nameTuple->getTableEntries( nameAttr ), -1 ); - - int i = 0; - for( GA_AIFSharedStringTuple::iterator it = nameTuple->begin( nameAttr ); !it.atEnd(); ++it, ++i ) - { - BoolVectorDataPtr membershipData = new BoolVectorData; - tagMap.insert( { it.getString(), membershipData } ); - - auto &membership = membershipData->writable(); - membership.resize( uniqueTags.size(), false ); - - indexRemap[it.getIndex()] = i; - locationMembership.emplace_back( &membership ); - } - - // calculate the tag membership per location - for( size_t i = 0; i < groups.size(); ++i ) - { - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange( groups[i] ) ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - int id = nameAttrib.getIndex( offset ); - if( id < 0 ) - { - continue; - } - - (*locationMembership[indexRemap[id]])[i] = true; - } - } - } - - result->blindData()->writable()[g_Tags] = tagMapData; -} - -DataPtr FromHoudiniGeometryConverter::extractStringVectorData( const GA_Attribute *attr, const GA_Range &range, IntVectorDataPtr &indexData ) const -{ - StringVectorDataPtr data = new StringVectorData(); - if( range.empty() ) - { - // we return early in this case to avoid building invalid indices - return data; - } - - size_t numStrings = 0; - std::vector strings; - std::vector indexRemap; - const GA_AIFSharedStringTuple *tuple = attr->getAIFSharedStringTuple(); - indexRemap.resize( tuple->getTableEntries( attr ), -1 ); - int i = 0; - for ( GA_AIFSharedStringTuple::iterator it=tuple->begin( attr ); !it.atEnd(); ++it, ++i ) - { - strings.push_back( it.getString() ); - indexRemap[it.getIndex()] = i; - numStrings++; - } - - indexData = new IntVectorData(); - std::vector &indexContainer = indexData->writable(); - indexContainer.resize( range.getEntries() ); - int *indices = indexData->baseWritable(); - - UT_IntArray handles; - tuple->extractHandles( attr, handles ); - - i = 0; - bool adjustedDefault = false; - - GA_Offset start, end; - GA_ROHandleS attribHandle( attr ); - for( GA_Iterator it( range ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset, ++i ) - { - const int index = attribHandle.getIndex( offset ); - if( index < 0 ) - { - if( !adjustedDefault ) - { - strings.push_back( "" ); - adjustedDefault = true; - } - - indices[i] = numStrings; - } - else - { - indices[i] = indexRemap[index]; - } - } - } - - // The data table for string attributes may have - // values which are not indexed. We rebuild the primvar / indices to only included data which is - // actually indexed. - IECoreScene::PrimitiveVariableAlgos::IndexedPrimitiveVariableBuilder builder( strings.size(), indexContainer.size() ); - PrimitiveVariable::IndexedView indexedView( strings, &indexContainer ); - for( size_t i = 0, end = indexedView.size(); i < end; ++i ) - { - builder.addIndexedValue( indexedView, i ); - } - - indexData = builder.indexedData().indices; - indexContainer = indexData->writable(); - indices = indexData->baseWritable(); - strings = runTimeCast ( builder.indexedData().data )->readable(); - - // The order of "strings" is not guaranteed, and can be unstable - // from frame to frame in certain situations, so we sort them - // alphabetically and update the indices accordingly: - - // find a permutation that orders strings alphabetically: - std::vector alphabeticalOrdering; - for( size_t i=0; i < strings.size(); ++i ) - { - alphabeticalOrdering.push_back( i ); - } - struct Comparator - { - Comparator( const std::vector &s ) : strings( s ) - { - } - - const std::vector &strings; - bool operator()( int a, int b ) - { - return strings[a] < strings[b]; - } - }; - std::sort( - alphabeticalOrdering.begin(), - alphabeticalOrdering.end(), - Comparator(strings) - ); - - // find inverse: - std::vector inverseAlphabeticalOrdering( strings.size() ); - for( size_t i=0; i < alphabeticalOrdering.size(); ++i ) - { - inverseAlphabeticalOrdering[ alphabeticalOrdering[i] ] = i; - } - - // apply permutation: - for( size_t i=0; i < indexData->readable().size(); ++i ) - { - indices[i] = inverseAlphabeticalOrdering[ indices[i] ]; - } - std::vector &dest = data->writable(); - dest.resize( alphabeticalOrdering.size() ); - for( size_t i=0; i < alphabeticalOrdering.size(); ++i ) - { - dest[ i ] = strings[ alphabeticalOrdering[i] ]; - } - - return new IECore::StringVectorData( dest ); -} - -DataPtr FromHoudiniGeometryConverter::extractStringData( const GU_Detail *geo, const GA_Attribute *attr ) const -{ - if( const GA_AIFStringTuple *stringTuple = attr->getAIFStringTuple() ) - { - int tupleSize = stringTuple->getTupleSize( attr ); - UT_StringArray strings; - - if( stringTuple->getStrings( attr, 0, strings, tupleSize ) && strings.size() == 1) - { - StringDataPtr data = new StringData(); - data->writable() = strings[0].c_str(); - return data; - } - } - else if( const GA_AIFSharedStringArray *sharedStringArray = attr->getAIFSharedStringArray() ) - { - UT_StringArray strings; - if( sharedStringArray->get( attr, 0, strings ) ) - { - StringVectorDataPtr data = new StringVectorData(); - auto &writable = data->writable(); - writable.resize( strings.size() ); - for( int i = 0; i < strings.size(); ++i ) - { - writable[i] = strings[i].c_str(); - } - - return data; - } - } - - return new StringData(); -} - - -bool FromHoudiniGeometryConverter::hasOnlyOpenPolygons( const GU_Detail *geo ) -{ - GA_Iterator primIt = geo->getPrimitiveRange().begin(); - if( primIt.atEnd() ) - { - return false; - } - - // if we have all open polygons then export as linear curves. - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( prim->getTypeId() != GEO_PRIMPOLY ) - { - return false; - } - - // as per SideFx, this is the most efficient way to determine if the prim is closed - if( geo->getPrimitiveVertexList( offset ).getExtraFlag() ) - { - return false; - } - } - } - - return true; -} - -const std::string FromHoudiniGeometryConverter::processPrimitiveVariableName( const std::string &name ) const -{ - /// \todo: This should probably be some formal static map. Make sure to update ToHoudiniGeometryConverter as well. - if ( name == "Cd" ) - { - return "Cs"; - } - else if ( name == "Alpha" ) - { - return "Os"; - } - else if ( name == "rest" ) - { - return "Pref"; - } - else if ( name == "pscale" ) - { - return "width"; - } - - return name; -} - -GU_DetailHandle FromHoudiniGeometryConverter::extract( const GU_Detail *geo, const UT_StringMMPattern &nameFilter ) -{ - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if ( nameAttrib.isValid() ) - { - GA_OffsetList offsets; - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const char *currentName = nameAttrib.get( offset, 0 ); - if ( UT_String( currentName ).multiMatch( nameFilter ) ) - { - offsets.append( offset ); - } - } - } - - if ( offsets.entries() ) - { - GU_Detail *newGeo = new GU_Detail(); - GA_Range matchPrims( geo->getPrimitiveMap(), offsets ); - newGeo->mergePrimitives( *geo, matchPrims ); - newGeo->bumpAllDataIds(); - newGeo->incrementMetaCacheCount(); - GU_DetailHandle newHandle; - newHandle.allocateAndSet( newGeo ); - return newHandle; - } - } - - return GU_DetailHandle(); -} - -template <> -IECore::QuatfVectorDataPtr FromHoudiniGeometryConverter::extractData( const GA_Attribute *attr, const GA_Range &range, int elementIndex ) const -{ - QuatfVectorDataPtr data = new QuatfVectorData; - data->writable().resize( range.getEntries() ); - QuatfVectorData::BaseType *dest = data->baseWritable(); - - if ( elementIndex == -1 ) - { - attr->getAIFTuple()->getRange( attr, range, dest ); - } - else - { - attr->getAIFTuple()->getRange( attr, range, dest, elementIndex, 1 ); - } - - // rearrange quaternion components: houdini stores them as "i,j,k,s", Imath - // stores them as "s,i,j,k": - for( std::vector::iterator it = data->writable().begin(); it != data->writable().end(); ++it ) - { - *it = Imath::Quatf( (*it)[3], (*it)[0], (*it)[1], (*it)[2] ); - } - - return data; - -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -FromHoudiniGeometryConverterPtr FromHoudiniGeometryConverter::create( const GU_DetailHandle &handle, IECore::TypeId resultType ) -{ - std::set types; - types.insert( resultType ); - - return create( handle, types ); -} - -FromHoudiniGeometryConverterPtr FromHoudiniGeometryConverter::create( const GU_DetailHandle &handle, const std::set &resultTypes ) -{ - const TypesToFnsMap *m = typesToFns(); - - Convertability best = InvalidValue; - TypesToFnsMap::const_iterator bestIt = m->end(); - - for ( std::set::iterator typeIt=resultTypes.begin(); typeIt != resultTypes.end(); typeIt++ ) - { - const std::set &derivedTypes = RunTimeTyped::derivedTypeIds( *typeIt ); - // find the best possible converter - for ( TypesToFnsMap::const_iterator it=m->begin(); it != m->end(); it ++ ) - { - if ( *typeIt == IECore::InvalidTypeId || it->first.resultType == InvalidTypeId || *typeIt == it->first.resultType || find( derivedTypes.begin(), derivedTypes.end(), it->first.resultType ) != derivedTypes.end() ) - { - if ( handle.isNull() && it->first.resultType != InvalidTypeId ) - { - // it works, therfore its good enough, since we have no handle to judge Convertability - return it->second.first( GU_DetailHandle() ); - } - - Convertability current = it->second.second( handle ); - if ( current && current < best ) - { - best = current; - bestIt = it; - } - } - } - } - - // return the best converter if it was found - if ( bestIt != m->end() ) - { - return bestIt->second.first( handle ); - } - - // there were no suitable converters - return 0; -} - -FromHoudiniGeometryConverterPtr FromHoudiniGeometryConverter::create( const SOP_Node *sop, const std::string &nameFilter, IECore::TypeId resultType ) -{ - // try to reduce the geo to fit the name - GU_DetailHandleAutoReadLock readHandle( handle( sop ) ); - if ( const GU_Detail *geo = readHandle.getGdp() ) - { - UT_StringMMPattern filter; - filter.compile( nameFilter.c_str() ); - GU_DetailHandle newHandle = extract( geo, filter ); - if ( !newHandle.isNull() ) - { - return create( newHandle, resultType ); - } - } - - return create( handle( sop ), resultType ); -} - -void FromHoudiniGeometryConverter::registerConverter( IECore::TypeId resultType, CreatorFn creator, ConvertabilityFn canConvert ) -{ - TypesToFnsMap *m = typesToFns(); - m->insert( TypesToFnsMap::value_type( Types( resultType ), std::pair( creator, canConvert ) ) ); -} - -FromHoudiniGeometryConverter::TypesToFnsMap *FromHoudiniGeometryConverter::typesToFns() -{ - static TypesToFnsMap *m = new TypesToFnsMap; - return m; -} - -void FromHoudiniGeometryConverter::supportedTypes( std::set &types ) -{ - types.clear(); - - const TypesToFnsMap *m = typesToFns(); - for ( TypesToFnsMap::const_iterator it=m->begin(); it != m->end(); it ++ ) - { - types.insert( it->first.resultType ); - } -} - -///////////////////////////////////////////////////////////////////////////////// -// Implementation of nested Types class -///////////////////////////////////////////////////////////////////////////////// - -FromHoudiniGeometryConverter::Types::Types( IECore::TypeId result ) - : resultType( result ) -{ -} - -bool FromHoudiniGeometryConverter::Types::operator < ( const Types &other ) const -{ - return resultType < other.resultType; -} diff --git a/src/IECoreHoudini/FromHoudiniPointsConverter.cpp b/src/IECoreHoudini/FromHoudiniPointsConverter.cpp deleted file mode 100644 index ef41f3d506..0000000000 --- a/src/IECoreHoudini/FromHoudiniPointsConverter.cpp +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniPointsConverter.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniPointsConverter ); - -FromHoudiniGeometryConverter::Description FromHoudiniPointsConverter::m_description( PointsPrimitive::staticTypeId() ); - -FromHoudiniPointsConverter::FromHoudiniPointsConverter( const GU_DetailHandle &handle ) : - FromHoudiniGeometryConverter( handle, "Converts a Houdini GU_Detail to an IECoreScene::PointsPrimitive." ) -{ -} - -FromHoudiniPointsConverter::FromHoudiniPointsConverter( const SOP_Node *sop ) : - FromHoudiniGeometryConverter( sop, "Converts a Houdini GU_Detail to an IECoreScene::PointsPrimitive." ) -{ -} - -FromHoudiniPointsConverter::~FromHoudiniPointsConverter() -{ -} - -FromHoudiniGeometryConverter::Convertability FromHoudiniPointsConverter::canConvert( const GU_Detail *geo ) -{ - size_t numPrims = geo->getNumPrimitives(); - if ( !numPrims ) - { - /// \todo: An alternative to consider would be to register a `FromHoudiniNullConverter` as the `Ideal` - /// converter when there are also no points in the detail. - return Ideal; - } - - if ( numPrims == 1 ) - { - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - const GA_Primitive *prim = primitives.get( geo->getPrimitiveRange().begin().getOffset() ); - if ( prim->getTypeId() == GEO_PRIMPART ) - { - return Ideal; - } - } - - return Inapplicable; -} - -ObjectPtr FromHoudiniPointsConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const -{ - PointsPrimitivePtr result = new PointsPrimitive( geo->getNumPoints() ); - - transferAttribs( geo, result.get(), operands, PrimitiveVariable::Vertex ); - - return result; -} diff --git a/src/IECoreHoudini/FromHoudiniPolygonsConverter.cpp b/src/IECoreHoudini/FromHoudiniPolygonsConverter.cpp deleted file mode 100644 index f95b416d03..0000000000 --- a/src/IECoreHoudini/FromHoudiniPolygonsConverter.cpp +++ /dev/null @@ -1,436 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/FromHoudiniPolygonsConverter.h" - -#include "IECore/CompoundObject.h" - -#include "GA/GA_Names.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -namespace -{ - -const InternedString g_attributeFilter( "attributeFilter" ); -const InternedString g_interpolationAttrib( "ieMeshInterpolation" ); -const InternedString g_interpolationAttribNegated( " ^ieMeshInterpolation" ); -const InternedString g_linear( "linear" ); -const InternedString g_catmullClark( "catmullClark" ); -const InternedString g_poly( "poly" ); -const InternedString g_subdiv( "subdiv" ); -const InternedString g_cornerWeightAttrib( "cornerweight" ); -const InternedString g_creaseWeightAttrib( "creaseweight" ); - -} // namespace - -IE_CORE_DEFINERUNTIMETYPED( FromHoudiniPolygonsConverter ); - -FromHoudiniGeometryConverter::Description FromHoudiniPolygonsConverter::m_description( MeshPrimitive::staticTypeId() ); - -FromHoudiniPolygonsConverter::FromHoudiniPolygonsConverter( const GU_DetailHandle &handle ) : - FromHoudiniGeometryConverter( handle, "Converts a Houdini GU_Detail to an IECoreScene::MeshPrimitive." ) -{ -} - -FromHoudiniPolygonsConverter::FromHoudiniPolygonsConverter( const SOP_Node *sop ) : - FromHoudiniGeometryConverter( sop, "Converts a Houdini GU_Detail to an IECoreScene::MeshPrimitive." ) -{ -} - -FromHoudiniPolygonsConverter::~FromHoudiniPolygonsConverter() -{ -} - -bool FromHoudiniPolygonsConverter::hasOpenAndClosedPolygons( const GU_Detail *geo ) -{ - GA_Iterator primIt = geo->getPrimitiveRange().begin(); - if( primIt.atEnd() ) - { - return false; - } - - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - bool openPoly = false; - bool closedPoly = false; - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( prim->getTypeId() != GEO_PRIMPOLY ) - { - return false; - } - - // as per SideFx, this is the most efficient way to determine if the prim is closed - if( geo->getPrimitiveVertexList( offset ).getExtraFlag() ) - { - closedPoly = true; - } - else - { - openPoly = true; - } - if ( closedPoly && openPoly ) - { - return true; - } - } - } - - return openPoly && closedPoly; -} - -FromHoudiniGeometryConverter::Convertability FromHoudiniPolygonsConverter::canConvert( const GU_Detail *geo ) -{ - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( prim->getTypeId() != GEO_PRIMPOLY ) - { - return Inapplicable; - } - } - } - - if ( hasOnlyOpenPolygons( geo ) ) - { - return Suitable; - } - - // is there a single named shape? - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( nameAttrib.isValid() ) - { - GA_StringTableStatistics stats; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); - tuple->getStatistics( nameAttr, stats ); - if ( stats.getEntries() < 2 ) - { - return Ideal; - } - } - - if( hasOpenAndClosedPolygons( geo ) ) - { - return Inapplicable; - } - - return Suitable; -} - -ObjectPtr FromHoudiniPolygonsConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const -{ - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - MeshPrimitivePtr result = new MeshPrimitive(); - - size_t numEdges = 0; - std::vector vertIds; - std::vector vertsPerFace; - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - if( prim->getTypeId() != GEO_PRIMPOLY ) - { - throw std::runtime_error( "FromHoudiniPolygonsConverter: Geometry contains non-polygon primitives" ); - } - - size_t numPrimVerts = prim->getVertexCount(); - vertsPerFace.push_back( numPrimVerts ); - numEdges += numPrimVerts; - std::vector ids( numPrimVerts ); - for( size_t j = 0; j < numPrimVerts; j++ ) - { - vertIds.push_back( geo->pointIndex( prim->getPointOffset( numPrimVerts - 1 - j ) ) ); - } - } - } - - result->setTopology( new IntVectorData( vertsPerFace ), new IntVectorData( vertIds ) ); - - CompoundObjectPtr modifiedOperands = transferMeshInterpolation( geo, operands, result.get() ); - - if( geo->getNumVertices() ) - { - transferAttribs( geo, result.get(), modifiedOperands ? modifiedOperands.get() : operands ); - } - - // check for corners and creases, which would have been extracted via transferAttribs() - // as they are no different to standard attribs in Houdini. - convertCorners( result.get() ); - convertCreases( result.get(), vertIds, numEdges ); - - return result; -} - -CompoundObjectPtr FromHoudiniPolygonsConverter::transferMeshInterpolation( const GU_Detail *geo, const IECore::CompoundObject *operands, IECoreScene::MeshPrimitive *mesh ) const -{ - // We store mesh interpolation in Houdini as an indexed string Prim Attrib (eg Uniform PrimitiveVariable) - // but we don't want to extract it as such because it can be expensive to deal with indexed variables when - // many meshes are stored in a single SOP. Since we know there is a fixed number of valid values, and we - // only support a single value per mesh (rather than per polygon as its stored in Houdini), we can get - // better performance with a specific extraction process. - - GA_ROHandleS meshTypeAttrib( geo, GA_ATTRIB_PRIMITIVE, g_interpolationAttrib.c_str() ); - if( !meshTypeAttrib.isValid() ) - { - // The attrib isn't here, so everything stays at the default value of linear - return nullptr; - } - - // We're going to convert ieMeshInterpolation ourselves. Update the operands to - // filter out the attrib so it isn't transfered as a standard PrimitiveVariable. - CompoundObjectPtr modifiedOperands = operands->copy(); - std::string &attributeFilter = modifiedOperands->member( g_attributeFilter )->writable(); - attributeFilter += g_interpolationAttribNegated.c_str(); - - GA_Size polyId, subdivId = -1; - const GA_Attribute *meshTypeAttr = meshTypeAttrib.getAttribute(); - /// \todo: replace with GA_ROHandleS somehow... its not clear how, there don't seem to be iterators. - const GA_AIFSharedStringTuple *meshTypeTuple = meshTypeAttr->getAIFSharedStringTuple(); - for( GA_AIFSharedStringTuple::iterator it = meshTypeTuple->begin( meshTypeAttr ); !it.atEnd(); ++it ) - { - if( const char *value = it.getString() ) - { - if( !strcmp( value, g_subdiv.c_str() ) ) - { - subdivId = it.getIndex(); - } - else if( !strcmp( value, g_poly.c_str() ) ) - { - polyId = it.getIndex(); - } - } - } - - if( subdivId == -1 ) - { - // No faces were set as subdiv, so all meshes are linear. We still return - // the updated operands so ieMeshInterpolation is never converted. - return modifiedOperands; - } - - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( nameAttrib.isValid() ) - { - // Multiple names means we may need to collect the mesh interpolation for - // post-processing via the DetailSplitter. - - CompoundDataPtr meshTypeMapData = new CompoundData; - auto &meshTypeMap = meshTypeMapData->writable(); - - // Prepare the map of location to mesh type. We're going to store a - // bool because there are only 2 possible values (currently) and this - // is expected to be transient / never-serialized data. - std::vector locationMeshTypes; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - /// \todo: replace with GA_ROHandleS somehow... its not clear how, there don't seem to be iterators. - const GA_AIFSharedStringTuple *nameTuple = nameAttr->getAIFSharedStringTuple(); - std::vector indexRemap; - indexRemap.resize( nameTuple->getTableEntries( nameAttr ), -1 ); - int i = 0; - for( GA_AIFSharedStringTuple::iterator it = nameTuple->begin( nameAttr ); !it.atEnd(); ++it, ++i ) - { - BoolDataPtr meshTypeData = new BoolData( false ); - meshTypeMap.insert( { it.getString(), meshTypeData } ); - locationMeshTypes.emplace_back( &meshTypeData->writable() ); - indexRemap[it.getIndex()] = i; - } - - // Calculate the mesh type per location - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - int id = nameAttrib.getIndex( offset ); - if( id < 0 ) - { - continue; - } - - if( meshTypeAttrib.getIndex( offset ) == subdivId ) - { - ( *locationMeshTypes[indexRemap[id]] ) = true; - } - } - } - - mesh->blindData()->writable()[g_interpolationAttrib] = meshTypeMapData; - return modifiedOperands; - } - - // No name attrib means we have a single mesh, so we can fallback to - // simpler logic without worrying about the DetailSplitter. - - bool found = false; - GA_Offset start, end; - InternedString interpolation = g_linear; - - for( GA_Iterator it( geo->getPrimitiveRange() ); !found && it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; !found && offset < end; ++offset ) - { - GA_Size meshTypeId = meshTypeAttrib.getIndex( offset ); - if( meshTypeId == subdivId ) - { - interpolation = g_catmullClark; - // Subdiv meshes should not have normals. We assume this occurred because the geo contained - // both subdiv and linear meshes, inadvertantly extending the normals attribute to both. - attributeFilter += " ^N"; - found = true; - break; - } - else if( meshTypeId == polyId ) - { - interpolation = g_linear; - found = true; - break; - } - } - } - - mesh->setInterpolation( interpolation ); - return modifiedOperands; -} - -void FromHoudiniPolygonsConverter::convertCorners( MeshPrimitive *mesh ) const -{ - // Houdini stores corners via a Point Attrib (which has been converted to a Vertex PrimitiveVariable) - const auto *cornerWeightData = mesh->variableData( g_cornerWeightAttrib, PrimitiveVariable::Vertex ); - if( !cornerWeightData ) - { - return; - } - - IntVectorDataPtr cornerIdsData = new IntVectorData(); - auto &cornerIds = cornerIdsData->writable(); - - FloatVectorDataPtr cornerSharpnessesData = new FloatVectorData(); - auto &cornerSharpnesses = cornerSharpnessesData->writable(); - - const auto &cornerWeights = cornerWeightData->readable(); - for( size_t i = 0; i < cornerWeights.size(); ++i ) - { - if( cornerWeights[i] > 0.0f ) - { - cornerIds.push_back( i ); - cornerSharpnesses.push_back( cornerWeights[i] ); - } - } - - if( !cornerIds.empty() ) - { - mesh->setCorners( cornerIdsData.get(), cornerSharpnessesData.get() ); - mesh->variables.erase( g_cornerWeightAttrib ); - } -} - -void FromHoudiniPolygonsConverter::convertCreases( MeshPrimitive *mesh, const std::vector &vertIds, size_t numEdges ) const -{ - // Houdini stores creases via a Vertex Attrib (which has been converted to a FaceVarying PrimitiveVariable), - // with the first face-vert of each creased face-edge containing the sharpness, and all other face-verts set to 0. - const auto *creaseWeightData = mesh->variableData( g_creaseWeightAttrib, PrimitiveVariable::FaceVarying ); - if( !creaseWeightData ) - { - return; - } - - IntVectorDataPtr creaseLengthsData = new IntVectorData(); - auto &creaseLengths = creaseLengthsData->writable(); - - IntVectorDataPtr creaseIdsData = new IntVectorData(); - auto &creaseIds = creaseIdsData->writable(); - - FloatVectorDataPtr creaseSharpnessesData = new FloatVectorData(); - auto &creaseSharpnesses = creaseSharpnessesData->writable(); - - // Calculate face-edge offsets based on winding order in Houdini, - // which is opposite to that of Cortex. We need these to map from - // single face-vert crease weights and find both verts of the edge. - size_t faceOffset = 0; - std::vector windingOffsets; - // most face-vert offsets will be to use the previous face-vert - windingOffsets.resize( mesh->variableSize( PrimitiveVariable::FaceVarying ), -1 ); - for( auto numFaceVerts : mesh->verticesPerFace()->readable() ) - { - // but we need to mark a wraparound vert for each face - windingOffsets[faceOffset] = (numFaceVerts - 1); - faceOffset += numFaceVerts; - } - - const auto &creaseWeights = creaseWeightData->readable(); - for( int i = 0; i < creaseWeights.size(); ++i ) - { - // there is a crease at this face-edge - if( creaseWeights[i] > 0.0f ) - { - // locate the 2nd vert of this face-edge - int nextFaceVert = i + windingOffsets[i]; - - // Since Houdini will have stored the crease in both directions - // (once for each face-edge), we need to make sure we only record - // it once, so we enforce that the vertIds are increasing. - if( vertIds[i] < vertIds[nextFaceVert] ) - { - creaseLengths.push_back( 2 ); - creaseIds.push_back( vertIds[i] ); - creaseIds.push_back( vertIds[nextFaceVert] ); - creaseSharpnesses.push_back( creaseWeights[i] ); - } - } - } - - if( !creaseLengths.empty() ) - { - mesh->setCreases( creaseLengthsData.get(), creaseIdsData.get(), creaseSharpnessesData.get() ); - mesh->variables.erase( g_creaseWeightAttrib ); - } -} diff --git a/src/IECoreHoudini/GEO_CobIOTranslator.cpp b/src/IECoreHoudini/GEO_CobIOTranslator.cpp deleted file mode 100644 index 0aa1639285..0000000000 --- a/src/IECoreHoudini/GEO_CobIOTranslator.cpp +++ /dev/null @@ -1,190 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/GEO_CobIOTranslator.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/Reader.h" -#include "IECore/ObjectReader.h" -#include "IECore/TypeIds.h" -#include "IECore/Writer.h" - -#include "UT/UT_Version.h" - -#include - -using namespace IECore; -using namespace IECoreHoudini; - -GEO_CobIOTranslator::GEO_CobIOTranslator() -{ -} - -GEO_CobIOTranslator::~GEO_CobIOTranslator() -{ -} - -GEO_IOTranslator *GEO_CobIOTranslator::duplicate() const -{ - return new GEO_CobIOTranslator(); -} - -const char *GEO_CobIOTranslator::formatName() const -{ - return "Cortex Object Format"; -} - -int GEO_CobIOTranslator::checkExtension( const char *fileName ) -{ - UT_String sname( fileName ); - - return ( sname.fileExtension() && !strcmp( sname.fileExtension(), ".cob" ) ); -} - -int GEO_CobIOTranslator::checkMagicNumber( unsigned magic ) -{ - return 0; -} - -GA_Detail::IOStatus GEO_CobIOTranslator::fileLoad( GEO_Detail *geo, UT_IStream &is, bool ate_magic ) -{ - ((UT_IFStream&)is).close(); - - ConstObjectPtr object = nullptr; - try - { - ObjectReaderPtr reader = new ObjectReader( is.getLabel().toStdString() ); - if( !reader ) - { - return false; - } - - object = reader->read(); - } - catch( IECore::Exception &e ) - { - return false; - } - - if( !object ) - { - return false; - } - - ToHoudiniGeometryConverterPtr converter = ToHoudiniGeometryConverter::create( object.get() ); - if( !converter ) - { - return false; - } - - GU_DetailHandle handle; - handle.allocateAndSet( (GU_Detail*)geo, false ); - - return converter->convert( handle ); -} - -GA_Detail::IOStatus GEO_CobIOTranslator::fileLoad( GEO_Detail *geo, UT_IStream &is, int ate_magic ) -{ - return fileLoad( geo, is, (bool)ate_magic ); -} - -GA_Detail::IOStatus GEO_CobIOTranslator::fileSave( const GEO_Detail *geo, std::ostream &os ) -{ - return false; -} - -GA_Detail::IOStatus GEO_CobIOTranslator::fileSaveToFile( const GEO_Detail *geo, const char *fileName ) -{ - GU_DetailHandle handle; - handle.allocateAndSet( (GU_Detail*)geo, false ); - - FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( handle ); - if ( !converter ) - { - return false; - } - - ObjectPtr object = converter->convert(); - if ( !object ) - { - return false; - } - - try - { - WriterPtr writer = Writer::create( object, fileName ); - writer->write(); - } - catch ( IECore::Exception &e ) - { - return false; - } - - return true; -} - -GA_Detail::IOStatus GEO_CobIOTranslator::fileSaveToFile( const GEO_Detail *geo, std::ostream &os, const char *fileName ) -{ - ((std::ofstream&)os).close(); - - return fileSaveToFile( geo, fileName ); -} - -bool GEO_CobIOTranslator::fileStat( const char *fileName, GA_Stat &stat, uint level ) -{ - try - { - ReaderPtr reader = Reader::create( fileName ); - if ( !reader ) - { - return false; - } - - ConstCompoundObjectPtr header = reader->readHeader(); - - UT_BoundingBox bbox = convert( reader->readHeader()->member( "bound", true )->readable() ); - - stat.setBounds( bbox ); - } - catch ( ... ) - { - return false; - } - - return true; -} diff --git a/src/IECoreHoudini/GEO_CortexPrimitive.cpp b/src/IECoreHoudini/GEO_CortexPrimitive.cpp deleted file mode 100644 index 47149602c0..0000000000 --- a/src/IECoreHoudini/GEO_CortexPrimitive.cpp +++ /dev/null @@ -1,1129 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/CoreHoudiniVersion.h" - -#ifdef IECOREHOUDINI_WITH_GL -#include "IECoreHoudini/GUI_CortexPrimitiveHook.h" -#endif - -#include "IECoreHoudini/SOP_OpHolder.h" -#include "IECoreHoudini/ToHoudiniPolygonsConverter.h" -#include "IECoreHoudini/UT_ObjectPoolCache.h" - - -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/Group.h" -#include "IECoreScene/MatrixTransform.h" -#include "IECoreScene/Primitive.h" -#include "IECoreScene/TransformOp.h" -#include "IECoreScene/VisibleRenderable.h" - -#include "IECore/HexConversion.h" -#include "IECore/MemoryIndexedIO.h" - -#ifdef IECOREHOUDINI_WITH_GL -#include "DM/DM_RenderTable.h" -#endif - -#include "GA/GA_Defragment.h" -#include "GA/GA_ElementWrangler.h" -#include "GA/GA_IndexMap.h" -#include "GA/GA_MergeMap.h" -#include "GA/GA_Primitive.h" -#include "GA/GA_PrimitiveJSON.h" -#include "GA/GA_RangeMemberQuery.h" -#include "GA/GA_SaveMap.h" -#include "GEO/GEO_Detail.h" -#include "GU/GU_RayIntersect.h" -#include "UT/UT_JSONParser.h" -#include "UT/UT_JSONWriter.h" -#include "UT/UT_MemoryCounter.h" -#include "UT/UT_StringHolder.h" - -#if UT_MAJOR_VERSION_INT < 14 - - #include "GU/GU_ConvertParms.h" - #include "IECoreHoudini/GU_CortexPrimitive.h" - -#else - - #include "GEO/GEO_ConvertParms.h" - -#endif - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -GEO_CortexPrimitive::GEO_CortexPrimitive( GA_Detail *detail, GA_Offset offset ) - : GEO_Primitive( detail, offset ) -{ -#if UT_MAJOR_VERSION_INT < 16 - m_offset = allocateVertex(); -#endif - -} - -// \todo remove this in cortex 10 -GEO_CortexPrimitive::GEO_CortexPrimitive( GEO_Detail *detail, GA_Offset offset ) - : GEO_Primitive( detail, offset ) -{ -#if UT_MAJOR_VERSION_INT < 16 - m_offset = allocateVertex(); -#endif -} - -// in H16 and later vertex lists are managed by GA_Primitive, and merge constructor is no longer allowed, so these functions aren't necessary -#if UT_MAJOR_VERSION_INT < 16 -GEO_CortexPrimitive::GEO_CortexPrimitive( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ) - : GEO_Primitive( static_cast( &detail ), offset ) -{ - const GEO_CortexPrimitive *orig = static_cast( &src ); - - m_offset = ( map.isIdentityMap( GA_ATTRIB_VERTEX ) ) ? orig->m_offset : map.mapDestFromSource( GA_ATTRIB_VERTEX, orig->m_offset ); - - m_object = orig->m_object->copy(); -} -#endif - -GEO_CortexPrimitive::~GEO_CortexPrimitive() -{ -#if UT_MAJOR_VERSION_INT < 16 - if ( GAisValid( m_offset ) ) - { - destroyVertex( m_offset ); - } -#endif -} - -#if UT_MAJOR_VERSION_INT < 16 -void GEO_CortexPrimitive::swapVertexOffsets( const GA_Defragment &defrag ) -{ - if ( defrag.hasOffsetChanged( m_offset ) ) - { - m_offset = defrag.mapOffset( m_offset ); - } -} - -GA_Size GEO_CortexPrimitive::getVertexCount() const -{ - return GAisValid( m_offset ) ? 1 : 0; -} - -GA_Offset GEO_CortexPrimitive::getVertexOffset( GA_Size index ) const -{ - return ( index == 0 ) ? m_offset : GA_INVALID_OFFSET; -} -#endif - -GA_Primitive::GA_DereferenceStatus GEO_CortexPrimitive::dereferencePoint( GA_Offset point, bool dry_run ) -{ - if ( isDegenerate() ) - { - return GA_DEREFERENCE_DEGENERATE; - } - - return GA_DEREFERENCE_FAIL; -} - -GA_Primitive::GA_DereferenceStatus GEO_CortexPrimitive::dereferencePoints( const GA_RangeMemberQuery &pt_q, bool dry_run ) -{ - if ( isDegenerate() ) - { - return GA_DEREFERENCE_DEGENERATE; - } - - return GA_DEREFERENCE_FAIL; -} - -#if UT_MAJOR_VERSION_INT >= 13 - -void GEO_CortexPrimitive::stashed( bool beingstashed, GA_Offset offset ) -{ - GEO_Primitive::stashed( beingstashed, offset ); - // remove reference to the m_object when being stashed - m_object = 0; - -#if UT_MAJOR_VERSION_INT < 16 - if( beingstashed ) - { - m_offset = GA_INVALID_OFFSET; - } - else - { - m_offset = allocateVertex(); - } -#endif -} - -#endif - -// \todo remove in Cortex 10 -void GEO_CortexPrimitive::stashed( int onoff, GA_Offset offset ) -{ - GEO_Primitive::stashed( onoff, offset ); - - m_object = 0; -#if UT_MAJOR_VERSION_INT < 16 - if ( onoff ) - { - m_offset = GA_INVALID_OFFSET; - } - else - { - m_offset = allocateVertex(); - } -#endif -} - -void GEO_CortexPrimitive::clearForDeletion() -{ - m_object = 0; -#if UT_MAJOR_VERSION_INT < 16 - m_offset = GA_INVALID_OFFSET; -#endif - GEO_Primitive::clearForDeletion(); -} - -bool GEO_CortexPrimitive::isDegenerate() const -{ - return false; -} - -void GEO_CortexPrimitive::copyUnwiredForMerge( const GA_Primitive *src, const GA_MergeMap &map ) -{ - const GEO_CortexPrimitive *orig = static_cast( src ); - - m_object = orig->m_object->copy(); - -#if UT_MAJOR_VERSION_INT >= 16 - GEO_Primitive::copyUnwiredForMerge(src, map); -#else - if ( GAisValid( m_offset ) ) - { - destroyVertex( m_offset ); - } - - m_offset = ( map.isIdentityMap( GA_ATTRIB_VERTEX ) ) ? orig->m_offset : map.mapDestFromSource( GA_ATTRIB_VERTEX, orig->m_offset ); -#endif -} - -#if UT_MAJOR_VERSION_INT >= 18 -void GEO_CortexPrimitive::copySubclassData(const GA_Primitive *src) -{ - const GEO_CortexPrimitive *orig = static_cast( src ); - m_object = orig->m_object->copy(); -} -#endif - -void GEO_CortexPrimitive::transform( const UT_Matrix4 &xform ) -{ - if ( xform.isIdentity() ) - { - return; - } - - Imath::M44f transform = IECore::convert( xform ); - - if ( Primitive *primitive = IECore::runTimeCast( m_object.get() ) ) - { - TransformOpPtr transformer = new TransformOp(); - transformer->inputParameter()->setValue( primitive ); - transformer->copyParameter()->setTypedValue( false ); - transformer->matrixParameter()->setValue( new M44fData( transform ) ); - transformer->operate(); - } - else if ( Group *group = IECore::runTimeCast( m_object.get() ) ) - { - if ( MatrixTransform *matTransform = IECore::runTimeCast( group->getTransform() ) ) - { - matTransform->matrix = transform * matTransform->matrix; - } - } - else if ( CoordinateSystem *coord = IECore::runTimeCast( m_object.get() ) ) - { - if ( MatrixTransform *matTransform = IECore::runTimeCast( coord->getTransform() ) ) - { - matTransform->matrix = transform * matTransform->matrix; - } - } -} - -void GEO_CortexPrimitive::reverse() -{ -} - -#if MIN_HOU_VERSION( 19, 5, 0 ) -bool GEO_CortexPrimitive::getBBox( UT_BoundingBox *bbox ) const -#else -int GEO_CortexPrimitive::getBBox( UT_BoundingBox *bbox ) const -#endif -{ - if ( !m_object ) - { - return 0; - } - - const IECoreScene::VisibleRenderable *renderable = IECore::runTimeCast( m_object.get() ); - if ( !renderable ) - { - return 0; - } - - Imath::Box3f bound = renderable->bound(); - bbox->setBounds( bound.min.x, bound.min.y, bound.min.z, bound.max.x, bound.max.y, bound.max.z ); - - return 1; -} - -void GEO_CortexPrimitive::enlargePointBounds( UT_BoundingBox &box ) const -{ - UT_BoundingBox bounds; - if ( getBBox( &bounds ) ) - { - box.enlargeBounds( bounds ); - } - - GEO_Primitive::enlargePointBounds( box ); -} - -UT_Vector3 GEO_CortexPrimitive::computeNormal() const -{ - return UT_Vector3( 0, 0, 0 ); -} - -#if MIN_HOU_VERSION( 19, 5, 0 ) -UT_Vector3D GEO_CortexPrimitive::computeNormalD() const -{ - return UT_Vector3D( 0, 0, 0 ); -} -#endif - -int GEO_CortexPrimitive::detachPoints( GA_PointGroup &grp ) -{ -#if UT_MAJOR_VERSION_INT >= 16 - if ( grp.containsOffset( getPointOffset( 0 ) ) ) -#else - if ( grp.containsOffset( getDetail().vertexPoint( 0 ) ) ) -#endif - { - return -2; - } - - return 0; -} - -// \todo: remove this in Cortex 10, not used since H12 -void GEO_CortexPrimitive::copyPrimitive( const GEO_Primitive *src, GEO_Point **ptredirect ) -{ -#if UT_MAJOR_VERSION_INT < 16 - if ( src == this ) - { - return; - } - - const GEO_CortexPrimitive *orig = (const GEO_CortexPrimitive *)src; - - const GA_IndexMap &srcPoints = orig->getParent()->getPointMap(); - - /// \todo: should we make a shallow or a deep copy? - m_object = orig->m_object; - - GA_VertexWrangler vertexWrangler( *getParent(), *orig->getParent() ); - - GA_Offset v = m_offset; - -#if UT_MAJOR_VERSION_INT >= 14 - - GA_Offset p = srcPoints.offsetFromIndex( srcPoints.indexFromOffset( orig->getDetail().vertexPoint( 0 ) ) ); - wireVertex( v, p ); - -#else - - GEO_Point *point = ptredirect[ srcPoints.indexFromOffset( orig->getDetail().vertexPoint( 0 ) ) ]; - wireVertex( v, point ? point->getMapOffset() : GA_INVALID_OFFSET ); - -#endif - - vertexWrangler.copyAttributeValues( v, orig->m_offset ); - -#endif -} - -// \todo: remove this in Cortex 10, not used since H12 -#if (UT_VERSION_INT >= 0x0c050132) // 12.5.306 or later -void GEO_CortexPrimitive::copyOffsetPrimitive( const GEO_Primitive *src, GA_Index basept ) -#else -void GEO_CortexPrimitive::copyOffsetPrimitive( const GEO_Primitive *src, int basept ) -#endif -{ -#if UT_MAJOR_VERSION_INT < 16 - - if ( src == this ) - { - return; - } - - const GEO_CortexPrimitive *orig = (const GEO_CortexPrimitive *)src; - - const GA_IndexMap &points = getParent()->getPointMap(); - const GA_IndexMap &srcPoints = orig->getParent()->getPointMap(); - - /// \todo: should we make a shallow or a deep copy? - m_object = orig->m_object; - - GA_VertexWrangler vertexWrangler( *getParent(), *orig->getParent() ); - - GA_Offset v = m_offset; - GA_Offset point = points.offsetFromIndex( srcPoints.indexFromOffset( orig->getDetail().vertexPoint( 0 ) ) + basept ); - wireVertex( v, point ); - vertexWrangler.copyAttributeValues( v, orig->m_offset ); - -#endif -} - -bool GEO_CortexPrimitive::evaluatePointRefMap( GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v, uint du, uint dv ) const -{ - return false; -} - -IECore::Object *GEO_CortexPrimitive::getObject() -{ - return m_object.get(); -} - -const IECore::Object *GEO_CortexPrimitive::getObject() const -{ - return m_object.get(); -} - -void GEO_CortexPrimitive::setObject( const IECore::Object *object ) -{ - /// \todo: should this be a deep copy? - m_object = object->copy(); -} - -const char *GEO_CortexPrimitive::typeName = "CortexObject"; -GA_PrimitiveDefinition *GEO_CortexPrimitive::m_definition = 0; - -const GA_PrimitiveDefinition &GEO_CortexPrimitive::getTypeDef() const -{ - return *m_definition; -} - -GA_PrimitiveTypeId GEO_CortexPrimitive::typeId() -{ - // m_definition is set by calling setTypeDef above & this is performed by the houdiniPlugin. - // setting the id to -1 defines the GA_PrimitiveTypeId as invalid - if( !m_definition ) - { - return GA_PrimitiveTypeId( -1 ); - } - - return m_definition->getId(); -} - -#if UT_MAJOR_VERSION_INT >= 16 - -void GEO_CortexPrimitive::create( - GA_Primitive **newPrims, - GA_Size numPrimitives, - GA_Detail &detail, - GA_Offset startOffset, - const GA_PrimitiveDefinition &def -#if MIN_HOU_VERSION(16, 5, 0) - , bool allowed_to_parallelize -#endif - ) -{ - - // allocate all the points and vertices at the same time - GA_Offset pointBlock = detail.appendPointBlock( numPrimitives ); -#if MIN_HOU_VERSION(16, 5, 0) - if ( allowed_to_parallelize && numPrimitives >= 4*GA_PAGE_SIZE ) -#else - if ( numPrimitives >= 4*GA_PAGE_SIZE ) -#endif - { - // Allocate them in parallel if we're allocating many. - // This is using the C++11 lambda syntax to make a functor. - UTparallelForLightItems(UT_BlockedRange( startOffset, startOffset + numPrimitives ), - [ newPrims, &detail, startOffset, &pointBlock ]( const UT_BlockedRange &r ){ - GA_Offset primOffset( r.begin() ); - GA_Primitive **pprims = newPrims + ( primOffset - startOffset ); - GA_Offset endOffset( r.end() ); - for ( ; primOffset != endOffset; ++primOffset, ++pprims, ++pointBlock ) - { - GEO_CortexPrimitive * newPrim = new GEO_CortexPrimitive( &detail , primOffset ); - GA_Offset vertex = newPrim->allocateVertex( pointBlock ); - newPrim->myVertexList.setTrivial( vertex, 1 ); - *pprims = newPrim; - } - }); - } - else - { - // Allocate them serially if we're only allocating a few. - GA_Offset endOffset( startOffset + numPrimitives ); - for ( GA_Offset primOffset( startOffset ); primOffset != endOffset; ++primOffset, ++newPrims, ++pointBlock ) - { - GEO_CortexPrimitive * newPrim = new GEO_CortexPrimitive( &detail , primOffset ); - GA_Offset vertex = newPrim->allocateVertex( pointBlock ); - newPrim->myVertexList.setTrivial( vertex, 1 ); - *newPrims = newPrim; - } - } -} - -#elif UT_MAJOR_VERSION_INT >= 14 - -GA_Primitive *GEO_CortexPrimitive::create( GA_Detail &detail, GA_Offset offset, const GA_PrimitiveDefinition &definition ) -{ - return new GEO_CortexPrimitive( static_cast( &detail ), offset ); -} - -GA_Primitive *GEO_CortexPrimitive::create( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ) -{ - return new GEO_CortexPrimitive( map, detail, offset, src ); -} -#endif - -GEO_CortexPrimitive *GEO_CortexPrimitive::build( GU_Detail *geo, const IECore::Object *object ) -{ - GEO_CortexPrimitive *result = (GEO_CortexPrimitive *)geo->appendPrimitive( m_definition->getId() ); - -#if UT_MAJOR_VERSION_INT >= 16 - GA_Offset point = result->getPointOffset(0 ); -#else - GA_Offset point = geo->appendPointOffset(); - result->wireVertex( result->m_offset, point ); -#endif - - result->setObject( object ); - - if ( const IECoreScene::VisibleRenderable *renderable = IECore::runTimeCast( object ) ) - { - geo->setPos3( point, IECore::convert( renderable->bound().center() ) ); - return result; - } - - if ( const IECoreScene::CoordinateSystem *coord = IECore::runTimeCast( object ) ) - { - if ( const IECoreScene::Transform *transform = coord->getTransform() ) - { - geo->setPos3( point, IECore::convert( transform->transform().translation() ) ); - } - - return result; - } - - return result; -} - -int64 GEO_CortexPrimitive::getMemoryUsage() const -{ -#if UT_MAJOR_VERSION_INT >= 16 - size_t total = GEO_Primitive::getMemoryUsage(); -#else - size_t total = sizeof( this ); -#endif - - if ( m_object ) - { - total += m_object->memoryUsage(); - } - - return total; -} - -void GEO_CortexPrimitive::countMemory( UT_MemoryCounter &counter ) const -{ - /// \todo: its unclear how we're supposed to count objects which are held by multiple - /// GEO_CortexPrimitives, so we're just counting them every time for now. - counter.countUnshared( getMemoryUsage() ); -} - -void GEO_CortexPrimitive::copyPrimitive( const GEO_Primitive *src ) -{ - if ( src == this ) - { - return; - } - - const GEO_CortexPrimitive *orig = (const GEO_CortexPrimitive *)src; - - /// \todo: should we make a shallow or a deep copy? - m_object = orig->m_object; - -#if UT_MAJOR_VERSION_INT >= 16 - GEO_Primitive::copyPrimitive(src); -#else - // this will also copy the attribute versions, but according to the header, it shouldn't - const GA_IndexMap &srcPoints = orig->getParent()->getPointMap(); - - GA_VertexWrangler vertexWrangler( *getParent(), *orig->getParent() ); - - GA_Offset v = m_offset; - GA_Offset p = srcPoints.indexFromOffset( orig->getDetail().vertexPoint( 0 ) ); - - wireVertex( v, p ); - vertexWrangler.copyAttributeValues( v, orig->m_offset ); -#endif -} - -GEO_Primitive * GEO_CortexPrimitive::copy(int preserve_shared_pts) const -{ - GEO_CortexPrimitive *clone = static_cast( GEO_Primitive::copy( preserve_shared_pts ) ); - if( !clone ) - { - return nullptr; - } - - /// \todo: should we make a shallow or a deep copy? - clone->m_object = m_object; - - return clone; -} - -GEO_Primitive *GEO_CortexPrimitive::convert( ConvertParms &parms, GA_PointGroup *usedpts ) -{ - GEO_Primitive *prim = doConvert( parms ); - if ( !prim ) - { - return 0; - } - - if ( usedpts ) - { - addPointRefToGroup( *usedpts ); - } - - if ( GA_PrimitiveGroup *group = parms.getDeletePrimitives() ) - { - group->add( this ); - } - else - { - getParent()->deletePrimitive( *this, usedpts != NULL ); - } - - return prim; -} - -GEO_Primitive *GEO_CortexPrimitive::convertNew( ConvertParms &parms ) -{ - return doConvert( parms ); -} - -GEO_Primitive *GEO_CortexPrimitive::doConvert( ConvertParms &parms ) -{ - if ( !m_object ) - { - return 0; - } - - GA_PrimCompat::TypeMask type = parms.toType(); - - /// \todo: should the GEO_PrimTypeCompat be registered with the converters? - if ( m_object->isInstanceOf( IECoreScene::MeshPrimitive::staticTypeId() ) && type == GEO_PrimTypeCompat::GEOPRIMPOLY ) - { - GU_DetailHandle handle; - handle.allocateAndSet( (GU_Detail*)getParent(), false ); - ToHoudiniPolygonsConverterPtr converter = new ToHoudiniPolygonsConverter( IECore::runTimeCast( m_object.get() ) ); - if ( !converter->convert( handle ) ) - { - return 0; - } - } - - /// \todo: support for CurvesPrimitive, PointsPrimitive, and any other existing converters - - return 0; -} - -void GEO_CortexPrimitive::normal( NormalComp &output ) const -{ -} - -#if MIN_HOU_VERSION( 19, 5, 0 ) -void GEO_CortexPrimitive::normal( NormalCompD &output ) const -{ -} -#endif - -#ifdef GA_PRIMITIVE_VERTEXLIST - -bool GEO_CortexPrimitive::saveVertexArray( UT_JSONWriter &w, const GA_SaveMap &map ) const -{ - return myVertexList.jsonVertexArray( w, map ); -} - -bool GEO_CortexPrimitive::loadVertexArray( UT_JSONParser &p, const GA_LoadMap &map ) -{ - GA_Offset startVtxOff = map.getVertexOffset(); - - int64 vtxOffs[1]; - int nVertex = p.parseUniformArray( vtxOffs, 1 ); - if ( startVtxOff != GA_Offset( 0 ) ) - { - for ( int i = 0; i < nVertex; i++ ) - { - if ( vtxOffs[i] >= 0 ) - vtxOffs[i] += GA_Size( startVtxOff ); - } - } - for ( int i = nVertex; i < 1; ++i ) - { - vtxOffs[i] = GA_INVALID_OFFSET; - } - myVertexList.set( vtxOffs, 1, GA_Offset( 0 ) ); - if ( nVertex < 1 ) - { - return false; - } - return true; -} - -#endif - -/// \todo: build ray cache and intersect properly -int GEO_CortexPrimitive::intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax, float tol, float *distance, UT_Vector3 *pos, UT_Vector3 *nml, int accurate, float *u, float *v, int ignoretrim ) const -{ - UT_BoundingBox bbox; - getBBox( &bbox ); - - float dist; - int result = bbox.intersectRay( o, d, tmax, &dist, nml ); - if ( result ) - { - if ( distance ) - { - *distance = dist; - } - - if ( pos ) - { - *pos = o + dist * d; - } - } - - return result; -} - -void GEO_CortexPrimitive::infoText( const GU_Detail *geo, OP_Context &context, OP_NodeInfoParms &parms ) -{ - if ( !geo ) - { - return; - } - - std::map typeMap; - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - - if( prim->getTypeId() == GEO_CortexPrimitive::typeId() ) - { - if( const IECore::Object *object = ( (GEO_CortexPrimitive *) prim )->getObject() ) - { - typeMap[object->typeName()] += 1; - } - } - } - } - - if ( typeMap.empty() ) - { - return; - } - - parms.append( "Cortex Object Details:\n" ); - for ( std::map::iterator it = typeMap.begin(); it != typeMap.end(); ++it ) - { - parms.append( ( boost::format( " %d " + it->first + "s\n" ) % it->second ).str().c_str() ); - } - parms.append( "\n" ); -} - -namespace -{ - -static UT_StringHolder vertex_sh = "vertex"; -static UT_StringHolder cortex_sh = "cortex"; - -} // namespace - -class GEO_CortexPrimitive::geo_CortexPrimitiveJSON : public GA_PrimitiveJSON -{ - public : - - geo_CortexPrimitiveJSON() - { - } - - virtual ~geo_CortexPrimitiveJSON() - { - } - - enum - { - geo_TBJ_VERTEX, - geo_TBJ_CORTEX, - geo_TBJ_ENTRIES - }; - - const GEO_CortexPrimitive *object( const GA_Primitive *p ) const - { - return static_cast(p); - } - - GEO_CortexPrimitive *object( GA_Primitive *p ) const - { - return static_cast(p); - } - - virtual int getEntries() const - { - return geo_TBJ_ENTRIES; - } - - -#if UT_MAJOR_VERSION_INT < 17 - - virtual const char *getKeyword( int i ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { - return "vertex"; - } - case geo_TBJ_CORTEX : - { - return "cortex"; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - return 0; - } - -#else - - virtual const UT_StringHolder &getKeyword( int i ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { - return vertex_sh; - } - case geo_TBJ_CORTEX : - { - return cortex_sh; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - return UT_StringHolder::theEmptyString; - } - -#endif - - virtual bool shouldSaveField( const GA_Primitive *prim, int i, const GA_SaveMap &sm ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { - return true; - } - case geo_TBJ_CORTEX : - { - return true; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - return false; - } - - virtual bool saveField( const GA_Primitive *pr, int i, UT_JSONWriter &w, const GA_SaveMap &map ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { -#ifdef GA_PRIMITIVE_VERTEXLIST - - return object(pr)->saveVertexArray(w, map); - -#else - - GA_Offset offset = object( pr )->getVertexOffset( 0 ); - return w.jsonInt( int64( map.getVertexIndex( offset ) ) ); - -#endif - } - case geo_TBJ_CORTEX : - { - const IECore::Object *obj = object( pr )->getObject(); - if ( !obj ) - { - return false; - } - - try - { - IECore::MemoryIndexedIOPtr io = new IECore::MemoryIndexedIO( IECore::ConstCharVectorDataPtr(), IECore::IndexedIO::rootPath, IECore::IndexedIO::Exclusive | IECore::IndexedIO::Write ); - - obj->save( io, "object" ); - - IECore::ConstCharVectorDataPtr buf = io->buffer(); - const IECore::CharVectorData::ValueType &data = buf->readable(); - - if ( w.getBinary() ) - { - int64 length = data.size(); - w.jsonValue( length ); - - UT_JSONWriter::TiledStream out( w ); - out.write( &data[0], length ); - } - else - { - std::string str = IECore::decToHex( data.begin(), data.end() ); - w.jsonString( str.c_str(), str.size() ); - } - } - catch ( std::exception &e ) - { - std::cerr << e.what() << std::endl; - return false; - } - - return true; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - return false; - } - - virtual bool loadField( GA_Primitive *pr, int i, UT_JSONParser &p, const GA_LoadMap &map ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { -#ifdef GA_PRIMITIVE_VERTEXLIST - return object(pr)->loadVertexArray(p, map); -#else - int64 vId; - if ( !p.parseInt( vId ) ) - { - return false; - } - - GEO_CortexPrimitive *prim = object( pr ); - GA_Offset offset = map.getVertexOffset( GA_Index( vId ) ); - if ( prim->m_offset != offset ) - { - prim->destroyVertex( prim->m_offset ); - prim->m_offset = offset; - } - - return true; - -#endif - } - case geo_TBJ_CORTEX : - { - try - { - IECore::CharVectorDataPtr buf = new IECore::CharVectorData(); - - if ( p.getBinary() ) - { - int64 length; - if ( !p.parseValue( length ) ) - { - return false; - } - - UT_JSONParser::TiledStream in( p ); - buf->writable().resize( length ); - in.read( &buf->writable()[0], length ); - } - else - { - UT_WorkBuffer workBuffer; - if ( !p.parseString( workBuffer ) ) - { - return false; - } - - buf->writable().resize( workBuffer.length() / 2 ); - IECore::hexToDec( workBuffer.buffer(), workBuffer.buffer() + workBuffer.length(), buf->writable().begin() ); - } - - IECore::MemoryIndexedIOPtr io = new IECore::MemoryIndexedIO( buf, IECore::IndexedIO::rootPath, IECore::IndexedIO::Exclusive | IECore::IndexedIO::Read ); - object( pr )->setObject( IECore::Object::load( io, "object" ).get() ); - } - catch ( std::exception &e ) - { - std::cerr << e.what() << std::endl; - return false; - } - - return true; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - return false; - } - - virtual bool isEqual( int i, const GA_Primitive *p0, const GA_Primitive *p1 ) const - { - switch ( i ) - { - case geo_TBJ_VERTEX : - { - return ( p0->getVertexOffset( 0 ) == p1->getVertexOffset( 0 ) ); - } - case geo_TBJ_CORTEX : - { - /// \todo: should this be returning object( p0 )->getPrimitive()->isSame( object( p1 )->getPrimitive() )? - return false; - } - case geo_TBJ_ENTRIES : - { - break; - } - } - - UT_ASSERT(0); - return false; - } - -/// These methods were pure virtual in Houdini 12.1 -#if UT_MAJOR_VERSION_INT >= 12 && UT_MINOR_VERSION_INT <= 1 - - virtual bool saveField( const GA_Primitive *pr, int i, UT_JSONValue &val, const GA_SaveMap &map ) const - { - UT_AutoJSONWriter w( val ); - return saveField( pr, i, *w, map ); - } - - virtual bool loadField( GA_Primitive *pr, int i, UT_JSONParser &p, const UT_JSONValue &jval, const GA_LoadMap &map ) const - { - UT_AutoJSONParser parser( jval ); - bool ok = loadField( pr, i, *parser, map ); - p.stealErrors( *parser ); - return ok; - } - -#endif - -}; - -const GA_PrimitiveJSON *GEO_CortexPrimitive::getJSON() const -{ - static GA_PrimitiveJSON *jsonPrim = 0; - if ( !jsonPrim ) - { - jsonPrim = new geo_CortexPrimitiveJSON(); - } - - return jsonPrim; -} - -void GEO_CortexPrimitive::registerDefinition(GA_PrimitiveFactory *factory) { - GA_PrimitiveDefinition *primDef = factory->registerDefinition( - GEO_CortexPrimitive::typeName, GEO_CortexPrimitive::create, - GA_FAMILY_NONE, (std::string(GEO_CortexPrimitive::typeName ) + "s" ).c_str() - ); - - if ( !primDef ) - { - std::cerr << "Warning: Duplicate definition for CortexPrimitive. Make sure only 1 version of the ieCoreHoudini plugin is on your path." << std::endl; - return; - } - - // merge constructors removed in H16 -#if UT_MAJOR_VERSION_INT < 16 - primDef->setMergeConstructor( CortexPrimitive::create ); -#endif - primDef->setHasLocalTransform( true ); - - // this will put the proper cortex primitive type into the intrinsic attribute table - GEO_CortexPrimitive::registerIntrinsics(*primDef); - - m_definition = primDef; - - /// Create the default ObjectPool cache - UT_ObjectPoolCache::defaultObjectPoolCache(); - /// Declare our new Render Hook if IECoreGL is enabled. -#ifdef IECOREHOUDINI_WITH_GL - - DM_RenderTable::getTable()->registerGEOHook( new GUI_CortexPrimitiveHook, primDef->getId(), 0 ); - -#endif - -} diff --git a/src/IECoreHoudini/GR_CortexPrimitive.cpp b/src/IECoreHoudini/GR_CortexPrimitive.cpp deleted file mode 100644 index c756fdb36c..0000000000 --- a/src/IECoreHoudini/GR_CortexPrimitive.cpp +++ /dev/null @@ -1,497 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/GR_CortexPrimitive.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/GU_CortexPrimitive.h" - -#include "IECoreGL/Camera.h" -#include "IECoreGL/CurvesPrimitive.h" -#include "IECoreGL/IECoreGL.h" -#include "IECoreGL/PointsPrimitive.h" -#include "IECoreGL/Primitive.h" -#include "IECoreGL/Renderer.h" -#include "IECoreGL/Scene.h" -#include "IECoreGL/ShaderLoader.h" -#include "IECoreGL/ShaderStateComponent.h" -#include "IECoreGL/State.h" -#include "IECoreGL/TextureLoader.h" - -#include "IECoreScene/MeshPrimitive.h" - -#include "IECore/SimpleTypedData.h" - -#include "RE/RE_Render.h" -#if MIN_HOU_VERSION( 20, 0, 0 ) -#include "RE/RE_RenderContext.h" -#endif - -#include "UT/UT_Version.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -using namespace IECoreHoudini; - -GR_CortexPrimitive::GR_CortexPrimitive( const GR_RenderInfo *info, const char *cache_name, const GEO_Primitive *prim ) - : GR_Primitive( info, cache_name, GA_PrimCompat::TypeMask(0) ) -{ - IECoreGL::init( true ); - - if ( prim->getTypeDef().getId() == CortexPrimitive::typeId().get() ) - { - -#if UT_MAJOR_VERSION_INT < 14 - - m_primId = prim->getNum(); - -#else - - m_primId = prim->getMapIndex(); -#endif - - } - -} - -GR_CortexPrimitive::~GR_CortexPrimitive() -{ - m_renderable = 0; -} - -GR_PrimAcceptResult GR_CortexPrimitive::acceptPrimitive( GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim ) -{ - - if ( geo_type == CortexPrimitive::typeId().get() ) - { - -#if UT_MAJOR_VERSION_INT < 14 - - m_primId = prim->getNum(); - -#else - - m_primId = prim->getMapIndex(); - -#endif - - return GR_PROCESSED; - } - - return GR_NOT_PROCESSED; -} - -void GR_CortexPrimitive::resetPrimitives() -{ - m_primId = -1; - m_renderable = 0; -} - -#if MIN_HOU_VERSION( 20, 0, 0 ) -void GR_CortexPrimitive::update( RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p ) -#else -void GR_CortexPrimitive::update( RE_Render *r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p ) -#endif -{ - -#if UT_MAJOR_VERSION_INT >= 15 - - GU_DetailHandleAutoReadLock handle( p.geometry ); - if ( !handle.isValid() ) - { - m_scene = 0; - m_renderable = 0; - return; - } - - const GU_Detail *detail = handle.getGdp(); - -#else - - const GU_Detail *detail = &p.geometry; - -#endif - - GA_Offset offset = detail->primitiveOffset( m_primId ); - const CortexPrimitive *prim = dynamic_cast( detail->getGEOPrimitive( offset ) ); - if ( !prim ) - { - m_scene = 0; - m_renderable = 0; - return; - } - - m_renderable = IECore::runTimeCast( prim->getObject() ); - if ( !m_renderable ) - { - m_scene = 0; - return; - } - - IECoreGL::RendererPtr renderer = new IECoreGL::Renderer(); - renderer->setOption( "gl:mode", new IECore::StringData( "deferred" ) ); - renderer->setOption( "gl:drawCoordinateSystems", new IECore::BoolData( true ) ); - renderer->worldBegin(); - - if ( p.dopts.boundBox() ) - { - const IECoreScene::VisibleRenderable *visible = IECore::runTimeCast( m_renderable ); - if ( visible ) - { - IECoreScene::MeshPrimitive::createBox( visible->bound() )->render( renderer.get() ); - } - } - else - { - m_renderable->render( renderer.get() ); - } - - renderer->worldEnd(); - - m_scene = renderer->scene(); - m_scene->setCamera( 0 ); // houdini will be providing the camera -} - -#if MIN_HOU_VERSION( 20, 0, 0 ) -void GR_CortexPrimitive::render( RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp ) -#elif UT_MAJOR_VERSION_INT >= 16 -void GR_CortexPrimitive::render( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp ) -#else -void GR_CortexPrimitive::render( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, const GR_DisplayOption *opt, const UT_Array *materials ) -#endif -{ - if ( !m_scene ) - { - return; - } - - UT_Matrix4D transform; - memcpy( transform.data(), r->getUniform( RE_UNIFORM_OBJECT_MATRIX )->getValue(), sizeof(double) * 16 ); - - GLint currentProgram = 0; - glGetIntegerv( GL_CURRENT_PROGRAM, ¤tProgram ); - -#if UT_MAJOR_VERSION_INT >= 16 - - IECoreGL::State *state = getState( render_mode, flags, dp.opts ); - -#else - - IECoreGL::State *state = getState( render_mode, flags, opt ); - -#endif - - if ( render_mode == GR_RENDER_OBJECT_PICK ) - { - const IECoreGL::Shader *shader = state->get()->shaderSetup()->shader(); - glUseProgram( shader->program() ); - -#if UT_MAJOR_VERSION_INT < 14 - - glUniform1i( shader->uniformParameter( "objectPickId" )->location, r->getObjectPickID() ); - -#else - - /// \todo: this suggestion was provided by SideFx but does not seem to work, - // or at least, this change in itself does not enable object picking. I'm - // leaving it here for now so we don't lose track of their advice. - int *ids = (int*)r->getUniform( RE_UNIFORM_PICK_BASE_ID )->getValue( 0 ); - glUniform1i( shader->uniformParameter( "objectPickId" )->location, ids[1] ); - -#endif - - } - -#if UT_MAJOR_VERSION_INT < 14 - - r->pushMatrix(); - - r->multiplyMatrix( transform ); - m_scene->render( state ); - - r->popMatrix(); - -#else - - UT_Matrix4D proj, view; - - memcpy( proj.data(), r->getUniform( RE_UNIFORM_PROJECT_MATRIX )->getValue(), sizeof(double) * 16 ); - memcpy( view.data(), r->getUniform( RE_UNIFORM_VIEW_MATRIX )->getValue(), sizeof(double) * 16 ); - - glMatrixMode( GL_PROJECTION ); - glPushMatrix(); - - glLoadMatrixd( proj.data() ); - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - - glLoadMatrixd( (transform * view).data() ); - m_scene->render( state ); - - glPopMatrix(); - - glMatrixMode( GL_PROJECTION ); - glPopMatrix(); - -#endif - - if ( render_mode == GR_RENDER_OBJECT_PICK ) - { - glUseProgram( currentProgram ); - } -} - -#if MIN_HOU_VERSION( 20, 0, 0 ) -int GR_CortexPrimitive::renderPick( RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map ) -{ - // return 0 to indicate we don't support component picking - return 0; -} - -#else -void GR_CortexPrimitive::renderInstances( RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, const GR_DisplayOption *opt, const UT_Array *materials, int render_instance ) -{ - /// \todo: implement this to support instanced rendering. - /// renderInstances() is for doing instanced drawing of - /// your primitive, which will be called if it's instanced - /// at the object level, or contained in a packed primitive - /// which is copied multiple times. In those cases, update() - /// will be passed a non-NULL UT_Matrix4DArray and an instance - /// group to which they belong (in GR_UpdateParms). The - /// instance_group passed to renderInstances() is used to - /// indicate the group being rendered. -} - -int GR_CortexPrimitive::renderPick( RE_Render *r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map ) -{ - // return 0 to indicate we don't support component picking - return 0; -} -#endif - -IECoreGL::StatePtr GR_CortexPrimitive::g_lit = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_shaded = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wire = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireLit = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireShaded = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireConstGhost = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireConstBG = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_pick = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_selected = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireSelected = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireConstBGSelected = 0; -IECoreGL::StatePtr GR_CortexPrimitive::g_wireConstGhostSelected = 0; - -IECoreGL::State *GR_CortexPrimitive::getState( GR_RenderMode mode, GR_RenderFlags flags, const GR_DisplayOption *opt ) -{ - if ( !g_lit || !g_shaded || !g_wire || !g_wireLit || !g_wireShaded || !g_wireConstGhost || !g_wireConstBG || !g_pick || !g_selected || !g_wireSelected || !g_wireConstBGSelected || !g_wireConstGhostSelected ) - { - g_shaded = new IECoreGL::State( true ); - g_shaded->add( new IECoreGL::PointsPrimitive::UseGLPoints( IECoreGL::ForAll ) ); - g_shaded->add( new IECoreGL::PointsPrimitive::GLPointWidth( 3. ) ); - g_shaded->add( new IECoreGL::CurvesPrimitive::UseGLLines( true ) ); - - /// \todo: this doesn't seem to get the lights. maybe they aren't in the gl light list? - g_lit = new IECoreGL::State( *g_shaded ); - g_lit->add( - new IECoreGL::ShaderStateComponent( - IECoreGL::ShaderLoader::defaultShaderLoader(), - IECoreGL::TextureLoader::defaultTextureLoader(), - IECoreGL::Shader::defaultVertexSource(), - IECoreGL::Shader::defaultGeometrySource(), - IECoreGL::Shader::lambertFragmentSource(), - new IECore::CompoundObject() - ), - /// \todo: by setting true here, we are forcing an override of all other - /// ShaderStateComponents in the hierarhcy. Is this desirable in all cases? - true - ); - - g_wireShaded = new IECoreGL::State( *g_shaded ); - g_wireShaded->add( new IECoreGL::Primitive::DrawWireframe( true ) ); - g_wireShaded->add( new IECoreGL::WireframeColorStateComponent( IECore::convert( opt->common().getColor( GR_WIREFRAME_COLOR ) ) ) ); - - g_wire = new IECoreGL::State( *g_shaded ); - g_wire->add( new IECoreGL::Primitive::DrawSolid( false ) ); - g_wire->add( new IECoreGL::Primitive::DrawWireframe( true ) ); - g_wire->add( new IECoreGL::WireframeColorStateComponent( Imath::Color4f( 1 ) ) ); - - g_wireLit = new IECoreGL::State( *g_lit ); - g_wireLit->add( new IECoreGL::Primitive::DrawWireframe( true ) ); - g_wireLit->add( new IECoreGL::WireframeColorStateComponent( Imath::Color4f( 0.5, 0.5, 0.5, 1 ) ) ); - - g_wireConstBG = new IECoreGL::State( *g_wireShaded ); - g_wireConstBG->add( new IECoreGL::Color( IECore::convert( opt->common().getColor( GR_BACKGROUND_COLOR ) ) ) ); - g_wireConstBG->add( - new IECoreGL::ShaderStateComponent( - IECoreGL::ShaderLoader::defaultShaderLoader(), - IECoreGL::TextureLoader::defaultTextureLoader(), - IECoreGL::Shader::defaultVertexSource(), - IECoreGL::Shader::defaultGeometrySource(), - IECoreGL::Shader::constantFragmentSource(), - new IECore::CompoundObject() - ), - true - ); - - g_wireConstGhost = new IECoreGL::State( *g_wireConstBG ); - g_wireConstGhost->add( new IECoreGL::Color( IECore::convert( opt->common().getColor( GR_GHOST_FILL_COLOR ) ) ) ); - - g_pick = new IECoreGL::State( *g_shaded ); - g_pick->add( - new IECoreGL::ShaderStateComponent( - IECoreGL::ShaderLoader::defaultShaderLoader(), - IECoreGL::TextureLoader::defaultTextureLoader(), - IECoreGL::Shader::defaultVertexSource(), - IECoreGL::Shader::defaultGeometrySource(), - pickFragmentSource(), - new IECore::CompoundObject() - ), - true - ); - - g_selected = new IECoreGL::State( *g_shaded ); - g_selected->add( new IECoreGL::Primitive::DrawWireframe( true ) ); - IECoreGL::WireframeColorStateComponentPtr selectionColor = new IECoreGL::WireframeColorStateComponent( IECore::convert( opt->common().getColor( GR_OBJECT_SELECT_COLOR ) ) ); - g_selected->add( selectionColor.get() ); - - g_wireSelected = new IECoreGL::State( *g_wire ); - g_wireSelected->add( selectionColor.get() ); - - g_wireConstBGSelected = new IECoreGL::State( *g_wireConstBG ); - g_wireConstBGSelected->add( selectionColor.get() ); - - g_wireConstGhostSelected = new IECoreGL::State( *g_wireConstGhost ); - g_wireConstGhostSelected->add( selectionColor.get() ); - } - - switch ( mode ) - { - case GR_RENDER_BEAUTY : - case GR_RENDER_MATERIAL : - case GR_RENDER_MATERIAL_WIREFRAME : - { - if ( isObjectSelection() ) - { - return g_selected.get(); - } - - if ( flags & GR_RENDER_FLAG_WIRE_OVER ) - { - if ( flags & GR_RENDER_FLAG_UNLIT ) - { - return g_wireShaded.get(); - } - - return g_wireLit.get(); - } - - if ( flags & GR_RENDER_FLAG_UNLIT ) - { - return g_shaded.get(); - } - - return g_lit.get(); - } - case GR_RENDER_WIREFRAME : - { - if ( isObjectSelection() ) - { - return g_wireSelected.get(); - } - - return g_wire.get(); - } - case GR_RENDER_HIDDEN_LINE : - { - if ( isObjectSelection() ) - { - return g_wireConstBGSelected.get(); - } - - return g_wireConstBG.get(); - } - case GR_RENDER_GHOST_LINE : - { - if ( isObjectSelection() ) - { - return g_wireConstGhostSelected.get(); - } - - return g_wireConstGhost.get(); - } - // hovering on CortexPrimitives during GR_RENDER_OBJECT_PICK mode flips the mode - // to GR_RENDER_MATTE. Since we're not supporting that on its own, we'll consider it - // a continued pick for now. This avoids strange popping draws on hover. - case GR_RENDER_MATTE : - case GR_RENDER_OBJECT_PICK : - { - return g_pick.get(); - } - default : - { - break; - } - } - - return g_shaded.get(); -} - -const std::string &GR_CortexPrimitive::pickFragmentSource() -{ - static std::string s = - - "#version 150 compatibility\n" - "#extension GL_EXT_gpu_shader4 : enable\n" - "" - "uniform int objectPickId;" - "out ivec4 id;" - "" - "void main()" - "{" - " id = ivec4( objectPickId, 0, 0, 0 );" - "}"; - - return s; -} diff --git a/src/IECoreHoudini/GUI_CortexPrimitiveHook.cpp b/src/IECoreHoudini/GUI_CortexPrimitiveHook.cpp deleted file mode 100644 index cebf240ce9..0000000000 --- a/src/IECoreHoudini/GUI_CortexPrimitiveHook.cpp +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/GUI_CortexPrimitiveHook.h" - -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/GR_CortexPrimitive.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -using namespace IECoreHoudini; - -GUI_CortexPrimitiveHook::GUI_CortexPrimitiveHook() : GUI_PrimitiveHook( CortexPrimitive::typeName ) -{ -} - -GUI_CortexPrimitiveHook::~GUI_CortexPrimitiveHook() -{ -} - -GR_Primitive *GUI_CortexPrimitiveHook::createPrimitive( const GT_PrimitiveHandle >_prim, const GEO_Primitive *geo_prim, const GR_RenderInfo *info, const char *cache_name, GR_PrimAcceptResult &processed ) -{ - return new GR_CortexPrimitive( info, cache_name, geo_prim ); -} diff --git a/src/IECoreHoudini/GU_CortexPrimitive.cpp b/src/IECoreHoudini/GU_CortexPrimitive.cpp deleted file mode 100644 index 379f570988..0000000000 --- a/src/IECoreHoudini/GU_CortexPrimitive.cpp +++ /dev/null @@ -1,169 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "UT/UT_Version.h" -#if UT_MAJOR_VERSION_INT < 14 - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/GU_CortexPrimitive.h" -#include "IECoreHoudini/ToHoudiniPolygonsConverter.h" - -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/Transform.h" - -#include "IECore/Object.h" - -#include "GU/GU_ConvertParms.h" -#include "GU/GU_RayIntersect.h" -#include "UT/UT_MemoryCounter.h" - -using namespace IECoreHoudini; - -const char *GU_CortexPrimitive::typeName = "CortexObject"; - -GU_CortexPrimitive::GU_CortexPrimitive( GU_Detail *gdp, GA_Offset offset ) - : GEO_CortexPrimitive( gdp, offset ), GU_Primitive() -{ -} - -GU_CortexPrimitive::GU_CortexPrimitive( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ) - : GEO_CortexPrimitive( map, detail, offset, src ) -{ -} - -GU_CortexPrimitive::~GU_CortexPrimitive() -{ -} - -#if UT_MAJOR_VERSION_INT >= 13 - -GA_Primitive *GU_CortexPrimitive::create( GA_Detail &detail, GA_Offset offset, const GA_PrimitiveDefinition &definition ) -{ - return new GU_CortexPrimitive( static_cast( &detail ), offset ); -} - -#else - -GA_Primitive *GU_CortexPrimitive::create( GA_Detail &detail, GA_Offset offset ) -{ - return new GU_CortexPrimitive( static_cast( &detail ), offset ); -} - -#endif - -GA_Primitive *GU_CortexPrimitive::create( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src ) -{ - return new GU_CortexPrimitive( map, detail, offset, src ); -} - -const GA_PrimitiveDefinition &GU_CortexPrimitive::getTypeDef() const -{ - return GEO_CortexPrimitive::getTypeDef(); -} - -int64 GU_CortexPrimitive::getMemoryUsage() const -{ - return GEO_CortexPrimitive::getMemoryUsage(); -} - -#if UT_MAJOR_VERSION_INT >= 13 - -void GU_CortexPrimitive::countMemory( UT_MemoryCounter &counter ) const -{ - GEO_CortexPrimitive::countMemory( counter ); -} - -void GU_CortexPrimitive::copyPrimitive( const GEO_Primitive *src ) -{ - GEO_CortexPrimitive::copyPrimitive( src ); -} - -#endif - -GEO_Primitive *GU_CortexPrimitive::convert( GU_ConvertParms &parms, GA_PointGroup *usedpts ) -{ - return GEO_CortexPrimitive::convert( parms, usedpts ); -} - -GEO_Primitive *GU_CortexPrimitive::convertNew( GU_ConvertParms &parms ) -{ - return GEO_CortexPrimitive::convertNew( parms ); -} - -void *GU_CortexPrimitive::castTo() const -{ - return (GU_Primitive*)this; -} - -const GEO_Primitive *GU_CortexPrimitive::castToGeo() const -{ - return this; -} - -void GU_CortexPrimitive::normal( NormalComp &output ) const -{ - GEO_CortexPrimitive::normal( output ); -} - -/// \todo: build ray cache and intersect properly -int GU_CortexPrimitive::intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax, float tol, float *distance, UT_Vector3 *pos, UT_Vector3 *nml, int accurate, float *u, float *v, int ignoretrim ) const -{ - return GEO_CortexPrimitive::intersectRay( o, d, tmax, tol, distance, pos, nml, accurate, u, v, ignoretrim ); -} - -#if UT_MAJOR_VERSION_INT < 13 - -GU_RayIntersect *GU_CortexPrimitive::createRayCache( int &persistent ) -{ - GU_Detail *gdp = (GU_Detail *)getParent(); - - persistent = 0; - if ( gdp->cacheable() ) - { - buildRayCache(); - } - - GU_RayIntersect *intersect = getRayCache(); - if ( !intersect ) - { - intersect = new GU_RayIntersect( gdp, this ); - persistent = 1; - } - - return intersect; -} - -#endif - -#endif // excluded in Houdini 14 and newer diff --git a/src/IECoreHoudini/HoudiniHeaderGenerator.cpp b/src/IECoreHoudini/HoudiniHeaderGenerator.cpp deleted file mode 100644 index 93c92fa820..0000000000 --- a/src/IECoreHoudini/HoudiniHeaderGenerator.cpp +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/CoreHoudini.h" - -#include "IECore/CompoundData.h" -#include "IECore/HeaderGenerator.h" -#include "IECore/SimpleTypedData.h" - -#include "MOT/MOT_Director.h" -#include "OP/OP_Director.h" -#include "UT/UT_Version.h" - -using namespace IECore; - -namespace IECoreHoudini -{ - -static void houdiniHeaderGenerator( CompoundObjectPtr header ) -{ - CH_Manager *channelManager = OPgetDirector()->getChannelManager(); - MOT_Director *motDirector = dynamic_cast( OPgetDirector() ); - - CompoundDataPtr compound = new CompoundData(); - compound->writable()["houdiniVersion"] = new StringData( UTgetFullVersion() ); - compound->writable()["sceneFile"] = new StringData( motDirector->getFileName().toStdString() ); - compound->writable()["currentTime"] = new FloatData( channelManager->getSampleRaw( CHgetEvalTime() ) ); - compound->writable()["minTime"] = new FloatData( channelManager->getGlobalStartFrame() ); - compound->writable()["maxTime"] = new FloatData( channelManager->getGlobalEndFrame() ); - compound->writable()["frameRate"] = new FloatData( channelManager->getSamplesPerSec() ); - - header->members()["houdini"] = compound; -} - -static bool resIeCoreHoudini = HeaderGenerator::registerDataHeaderGenerator( &houdiniHeaderGenerator ); - -} diff --git a/src/IECoreHoudini/LiveScene.cpp b/src/IECoreHoudini/LiveScene.cpp deleted file mode 100644 index a27b551a1a..0000000000 --- a/src/IECoreHoudini/LiveScene.cpp +++ /dev/null @@ -1,1372 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/LiveScene.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" - -#include "IECoreScene/Group.h" - -#include "IECore/TransformationMatrixData.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathBoxAlgo.h" -#include "Imath/ImathMatrixAlgo.h" -IECORE_POP_DEFAULT_VISIBILITY - -#include "MGR/MGR_Node.h" -#include "MOT/MOT_Director.h" -#include "OBJ/OBJ_Node.h" -#include "OP/OP_Director.h" -#include "OP/OP_Input.h" -#include "UT/UT_Version.h" -#include "UT/UT_WorkArgs.h" - -#include "boost/algorithm/string/join.hpp" - -#include -#include -#include - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef GA_PrimitiveGroup GroupType; - -#else - -typedef GA_ElementGroup GroupType; - -#endif - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -static InternedString contentName( "geo" ); - -PRM_Name LiveScene::pTags( "ieTags", "ieTags" ); -static const UT_String tagGroupPrefix( "ieTag_" ); - -namespace -{ - -#if UT_MAJOR_VERSION_INT < 18 -SOP_Node* renderNode( OBJ_Node* objNode ) -{ - for (OP_Node *output : objNode->getOutputNodePtrs()) - { - if (output->whichOutputNode() == 0) - { - if ( SOP_Node *sop = output->castToSOPNode() ) - { - return sop; - } - } - } - return nullptr; -} -#endif - -IECore::InternedString g_Tags( "tags" ); - -IECore::ConstObjectPtr removeTagsBlindData( IECore::ConstObjectPtr obj ) -{ - if( auto blindDataHolder = IECore::runTimeCast( obj ) ) - { - auto blindDataHolderCopy = blindDataHolder->copy(); - blindDataHolderCopy->blindData()->writable().erase( g_Tags ); - return blindDataHolderCopy; - - } - return obj; -} - -void getUniquePrimitives(const GU_Detail *geo, std::set& uniquePrimTypes) -{ - uniquePrimTypes.clear(); - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - uniquePrimTypes.insert( prim->getTypeDef().getToken().toStdString() ); - } - } - -} -} // namespace - -LiveScene::LiveScene() : m_rootIndex( 0 ), m_contentIndex( 0 ), m_defaultTime( std::numeric_limits::infinity() ) -{ - MOT_Director *motDirector = dynamic_cast( OPgetDirector() ); - motDirector->getObjectManager()->getFullPath( m_nodePath ); - - Path contentPath, rootPath; - calculatePath( contentPath, rootPath ); -} - -LiveScene::LiveScene( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, double defaultTime ) - : m_rootIndex( 0 ), m_contentIndex( 0 ), m_defaultTime( defaultTime ) -{ - constructCommon( nodePath, contentPath, rootPath, nullptr ); -} - -LiveScene::LiveScene( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, const LiveScene& parent ) - : m_rootIndex( 0 ), m_contentIndex( 0 ), m_splitter( parent.m_splitter ), m_defaultTime( parent.m_defaultTime ) -{ - constructCommon( nodePath, contentPath, rootPath, m_splitter.get() ); -} - -void LiveScene::constructCommon( const UT_String &nodePath, const Path &contentPath, const Path &rootPath, DetailSplitter *splitter ) -{ - m_nodePath = nodePath; - m_nodePath.hardenIfNeeded(); - - if ( OP_Node *contentNode = locateContent( retrieveNode() ) ) - { - if ( !m_splitter ) - { - double adjustedTime = adjustedDefaultTime(); - m_splitter = new DetailSplitter( contentNode->castToOBJNode(), adjustedTime , /* key */ "name", /* useHoudiniSegment */ false); - } - } - - calculatePath( contentPath, rootPath ); -} - -const OP_Node *LiveScene::node() const -{ - return retrieveNode( false, NullIfMissing ); -} - -bool LiveScene::embedded() const -{ - return m_contentIndex; -} - -double LiveScene::adjustedDefaultTime() const -{ - if ( m_defaultTime == std::numeric_limits::infinity() ) - { - return adjustTime( CHgetEvalTime() ); - } - - return adjustTime( m_defaultTime ); -} - -double LiveScene::getDefaultTime() const -{ - return m_defaultTime; -} - -void LiveScene::setDefaultTime( double time ) -{ - m_defaultTime = time; -} - -std::string LiveScene::fileName() const -{ - throw Exception( "IECoreHoudini::LiveScene does not support fileName()." ); -} - -SceneInterface::Name LiveScene::name() const -{ - if ( m_path.empty() || m_rootIndex == m_path.size() ) - { - return SceneInterface::rootName; - } - - return *m_path.rbegin(); -} - -void LiveScene::path( Path &p ) const -{ - p.resize( m_path.size() - m_rootIndex ); - std::copy( m_path.begin() + m_rootIndex, m_path.end(), p.begin() ); -} - -void LiveScene::calculatePath( const Path &contentPath, const Path &rootPath ) -{ - OP_Node *node = retrieveNode(); - if ( node->isManager() ) - { - return; - } - - UT_String tmp( m_nodePath ); - UT_WorkArgs workArgs; - tmp.tokenize( workArgs, "/" ); - - OP_Node *current = dynamic_cast( OPgetDirector() )->getObjectManager(); - // skipping the token for the OBJ manager - for ( int i = 1; i < workArgs.getArgc(); ++i ) - { - current = current->getChild( workArgs[i] ); - - /// recursively collect all input connections - OP_Node *parent = current->getInput( 0 ); - UT_StringArray parentNames; - while ( parent ) - { - parentNames.append( parent->getName() ); - parent = parent->getInput( 0 ); - } - - // add them in reverse order - for ( int j = parentNames.entries() - 1; j >= 0; --j ) - { - m_path.push_back( Name( parentNames( j ) ) ); - } - - if ( ( i < workArgs.getArgc() - 1 ) || Name( workArgs[i] ) != contentName ) - { - m_path.push_back( Name( workArgs[i] ) ); - } - } - - if ( !contentPath.empty() ) - { - m_contentIndex = m_path.size(); - m_path.resize( m_path.size() + contentPath.size() ); - std::copy( contentPath.begin(), contentPath.end(), m_path.begin() + m_contentIndex ); - } - - if ( m_path.size() < rootPath.size() ) - { - std::string pStr, rStr; - pathToString( m_path, pStr ); - pathToString( rootPath, rStr ); - throw Exception( "IECoreHoudini::LiveScene: Path \"" + pStr + "\" is not a valid child of root \"" + rStr + "\"." ); - } - - for ( size_t i = 0; i < rootPath.size(); ++i ) - { - if ( rootPath[i] != m_path[i] ) - { - std::string pStr, rStr; - pathToString( m_path, pStr ); - pathToString( rootPath, rStr ); - throw Exception( "IECoreHoudini::LiveScene: Path \"" + pStr + "\" is not a valid child of root \"" + rStr + "\"." ); - } - } - - m_rootIndex = rootPath.size(); -} - -Imath::Box3d LiveScene::readBound( double time ) const -{ - OP_Node *node = retrieveNode( true ); - - Imath::Box3d bounds; - UT_BoundingBox box; - OP_Context context( adjustTime( time ) ); - /// \todo: this doesn't account for SOPs containing multiple shapes - /// if we fix it, we need to fix the condition below as well - if ( node->getBoundingBox( box, context ) ) - { - bounds = IECore::convert( box ); - } - - // paths embedded within a sop already have bounds accounted for - if ( m_contentIndex ) - { - return bounds; - } - - NameList children; - childNames( children ); - for ( NameList::iterator it=children.begin(); it != children.end(); ++it ) - { - ConstSceneInterfacePtr childScene = child( *it ); - Imath::Box3d childBound = childScene->readBound( time ); - if ( !childBound.isEmpty() ) - { - bounds.extendBy( Imath::transform( childBound, childScene->readTransformAsMatrix( time ) ) ); - } - } - - return bounds; -} - -void LiveScene::writeBound( const Imath::Box3d &bound, double time ) -{ - throw Exception( "IECoreHoudini::LiveScene is read-only" ); -} - -ConstDataPtr LiveScene::readTransform( double time ) const -{ - Imath::V3d s, h, r, t; - Imath::M44d matrix = readTransformAsMatrix( time ); - Imath::extractSHRT( matrix, s, h, r, t, true ); - - return new TransformationMatrixdData( TransformationMatrixd( s, r, t ) ); -} - -Imath::M44d LiveScene::readTransformAsMatrix( double time ) const -{ - OP_Node *node = retrieveNode(); - if ( node->isManager() ) - { - return Imath::M44d(); - } - - OBJ_Node *objNode = node->castToOBJNode(); - if ( !objNode ) - { - return Imath::M44d(); - } - - // paths embedded within a sop always have identity transforms - if ( m_contentIndex ) - { - return Imath::M44d(); - } - - UT_DMatrix4 matrix; - OP_Context context( adjustTime( time ) ); - if ( !objNode->getParmTransform( context, matrix ) ) - { - return Imath::M44d(); - } - - return IECore::convert( matrix ); -} - -ConstDataPtr LiveScene::readWorldTransform( double time ) const -{ - Imath::V3d s, h, r, t; - Imath::M44d matrix = readWorldTransformAsMatrix( time ); - Imath::extractSHRT( matrix, s, h, r, t, true ); - - return new TransformationMatrixdData( TransformationMatrixd( s, r, t ) ); -} - -Imath::M44d LiveScene::readWorldTransformAsMatrix( double time ) const -{ - OP_Node *node = retrieveNode(); - if ( node->isManager() ) - { - return Imath::M44d(); - } - - OBJ_Node *objNode = node->castToOBJNode(); - if ( !objNode ) - { - return Imath::M44d(); - } - - UT_DMatrix4 matrix; - OP_Context context( adjustTime( time ) ); - if ( !objNode->getWorldTransform( matrix, context ) ) - { - return Imath::M44d(); - } - - return IECore::convert( matrix ); -} - -void LiveScene::writeTransform( const Data *transform, double time ) -{ - throw Exception( "IECoreHoudini::LiveScene is read-only" ); -} - -bool LiveScene::hasAttribute( const Name &name ) const -{ - OP_Node *node = retrieveNode(); - - const std::vector &attributeReaders = customAttributeReaders(); - for ( std::vector::const_iterator it = attributeReaders.begin(); it != attributeReaders.end(); ++it ) - { - if ( embedded() && !it->m_callEmbedded ) - { - continue; - } - - NameList names; - it->m_names( node, names ); - if ( std::find( names.begin(), names.end(), name ) != names.end() ) - { - return true; - } - } - - return false; -} - -void LiveScene::attributeNames( NameList &attrs ) const -{ - attrs.clear(); - - OP_Node *node = retrieveNode(); - - const std::vector &attributeReaders = customAttributeReaders(); - for ( std::vector::const_iterator it = attributeReaders.begin(); it != attributeReaders.end(); ++it ) - { - NameList names; - if ( embedded() && !it->m_callEmbedded ) - { - continue; - } - - it->m_names( node, names ); - /// \todo: investigate using a set here if performance becomes an issue - for ( NameList::const_iterator nIt = names.begin(); nIt != names.end(); ++nIt ) - { - if ( std::find( attrs.begin(), attrs.end(), *nIt ) == attrs.end() ) - { - attrs.push_back( *nIt ); - } - } - } -} - -ConstObjectPtr LiveScene::readAttribute( const Name &name, double time ) const -{ - OP_Node *node = retrieveNode(); - - // iterate attribute readers in reverse order so the ones registered later take precedence: - const std::vector &attributeReaders = customAttributeReaders(); - for ( std::vector::const_reverse_iterator it = attributeReaders.rbegin(); it != attributeReaders.rend(); ++it ) - { - if ( embedded() && !it->m_callEmbedded ) - { - continue; - } - - if ( IECore::ConstObjectPtr object = it->m_read( node, name, time ) ) - { - return object; - } - } - - return nullptr; -} - -void LiveScene::writeAttribute( const Name &name, const Object *attribute, double time ) -{ - throw Exception( "IECoreHoudini::LiveScene is read-only" ); -} - -bool LiveScene::hasTag( const Name &name, int filter ) const -{ - const OP_Node *node = retrieveNode(); - if ( !node ) - { - return false; - } - - if ( filter & SceneInterface::LocalTag ) - { - // check for user supplied tags if we're not inside a SOP - if ( !m_contentIndex && node->hasParm( pTags.getToken() ) ) - { - UT_String parmTags; - node->evalString( parmTags, pTags.getToken(), 0, 0 ); - if ( UT_String( name.c_str() ).multiMatch( parmTags ) ) - { - return true; - } - } - } - - // check with the registered tag readers - std::vector &tagReaders = customTagReaders(); - for ( std::vector::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it ) - { - if ( embedded() && !it->m_callEmbedded ) - { - continue; - } - - if ( it->m_has( node, name, filter ) ) - { - return true; - } - } - - if ( filter & SceneInterface::LocalTag ) - { - // check tags based on primitive groups - OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode(); - if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY ) - { - std::string pathStr; - SceneInterface::Path path; - relativeContentPath( path ); - pathToString( path, pathStr ); - - if ( m_splitter ) - { - if( auto splitObject = runTimeCast( m_splitter->splitObject( pathStr ) ) ) - { - const auto &readableBlindData = splitObject->blindData()->readable(); - auto tagsIt = readableBlindData.find( g_Tags ); - if( tagsIt == readableBlindData.end() ) - { - return false; - } - const IECore::InternedStringVectorData *tagsVector = runTimeCast( tagsIt->second.get() ); - - if( !tagsVector ) - { - return false; - } - const auto &readableTagsVector = tagsVector->readable(); - - return std::find( readableTagsVector.begin(), readableTagsVector.end(), name ) != readableTagsVector.end(); - } - } - - GU_DetailHandle newHandle = contentHandle(); - if ( !newHandle.isNull() ) - { - GU_DetailHandleAutoReadLock readHandle( newHandle ); - if ( const GU_Detail *geo = readHandle.getGdp() ) - { - GA_Range prims = geo->getPrimitiveRange(); - - for ( GA_GroupTable::iterator it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) - { - GA_PrimitiveGroup *group = static_cast( it.group() ); - if ( group->getInternal() || group->isEmpty() ) - { - continue; - } - - const UT_String groupName = group->getName().c_str(); - if ( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) ) - { - UT_String tag; - groupName.substr( tag, tagGroupPrefix.length() ); - tag.substitute( "_", ":" ); - if ( tag.equal( name.c_str() ) ) - { - return true; - } - } - } - } - } - } - } - - return false; -} - -void LiveScene::readTags( NameList &tags, int filter ) const -{ - tags.clear(); - - const OP_Node *node = retrieveNode(); - - if ( !node ) - { - return; - } - - std::unordered_set< Name > uniqueTags; - - if ( filter & SceneInterface::LocalTag ) - { - // add user supplied tags if we're not inside a SOP - if ( !m_contentIndex && node->hasParm( pTags.getToken() ) ) - { - UT_String parmTagStr; - node->evalString( parmTagStr, pTags.getToken(), 0, 0 ); - if ( !parmTagStr.equal( UT_String::getEmptyString() ) ) - { - UT_WorkArgs tokens; - parmTagStr.tokenize( tokens, " " ); - for ( int i = 0; i < tokens.getArgc(); ++i ) - { - uniqueTags.insert( tokens[i] ); - } - } - } - } - - // add tags from the registered tag readers - std::vector &tagReaders = customTagReaders(); - for ( std::vector::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it ) - { - NameList values; - if ( embedded() && !it->m_callEmbedded ) - { - continue; - } - - it->m_read( node, values, filter ); - uniqueTags.insert( values.begin(), values.end() ); - } - - if ( filter & SceneInterface::LocalTag ) - { - - // add tags based on primitive groups - OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode(); - if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY && m_splitter ) - { - - std::string pathStr; - SceneInterface::Path path; - relativeContentPath( path ); - pathToString( path, pathStr ); - - if( auto splitObject = runTimeCast( m_splitter->splitObject( pathStr ) ) ) - { - const auto &readableBlindData = splitObject->blindData()->readable(); - auto tagsIt = readableBlindData.find( g_Tags ); - if( tagsIt != readableBlindData.end() ) - { - if( const IECore::InternedStringVectorData *tagsVector = runTimeCast( tagsIt->second.get() ) ) - { - const auto &readableTagsVector = tagsVector->readable(); - uniqueTags.insert( readableTagsVector.begin(), readableTagsVector.end() ); - } - } - } - else - { - GU_DetailHandle newHandle = contentHandle(); - if( !newHandle.isNull() ) - { - GU_DetailHandleAutoReadLock readHandle( newHandle ); - if( const GU_Detail *geo = readHandle.getGdp() ) - { - GA_Range prims = geo->getPrimitiveRange(); - - for( GA_GroupTable::iterator it = geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) - { - GA_PrimitiveGroup *group = static_cast( it.group() ); - if( group->getInternal() || group->isEmpty() ) - { - continue; - } - - const UT_String groupName( group->getName() ); - if( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) ) - { - UT_String tag; - groupName.substr( tag, tagGroupPrefix.length() ); - tag.substitute( "_", ":" ); - uniqueTags.insert( tag.buffer() ); - } - } - } - } - } - } - } - - tags.insert( tags.end(), uniqueTags.begin(), uniqueTags.end() ); -} - -void LiveScene::writeTags( const NameList &tags ) -{ - throw Exception( "IECoreHoudini::LiveScene::writeTags not supported" ); -} - - - -SceneInterface::NameList LiveScene::setNames( bool includeDescendantSets ) const -{ - return SceneInterface::NameList(); -} - -IECore::PathMatcher LiveScene::readSet( const Name &name, bool includeDescendantSets, const IECore::Canceller *canceller ) const -{ - throw Exception( "IECoreHoudini::LiveScene::readSet not supported" ); -} - -void LiveScene::writeSet( const Name &name, const IECore::PathMatcher &set ) -{ - throw Exception( "IECoreHoudini::LiveScene::writeSet not supported" ); -} - -void LiveScene::hashSet( const Name& setName, IECore::MurmurHash &h ) const -{ - SceneInterface::hashSet( setName, h ); -} - - -static const char *emptyString = ""; - -bool LiveScene::hasObject() const -{ - OP_Node *node = retrieveNode( true ); - if ( node->isManager() ) - { - return false; - } - - OBJ_Node *objNode = node->castToOBJNode(); - if ( !objNode ) - { - return false; - } - - OBJ_OBJECT_TYPE type = objNode->getObjectType(); - if ( type == OBJ_GEOMETRY ) - { - OP_Context context( adjustedDefaultTime() ); -#if UT_MAJOR_VERSION_INT >= 18 - const GU_Detail *geo = objNode->getRenderGeometry( context, false ); -#else - SOP_Node* sopNode = renderNode( objNode ); - const GU_Detail *geo = ( sopNode ) ? sopNode->getCookedGeo( context, false ) : objNode->getRenderGeometry( context, false ); -#endif - if ( !geo ) - { - return false; - } - - IECoreScene::SceneInterface::Path parentPath ( m_path.begin() + m_contentIndex, m_path.end()); - - const IECoreScene::SceneInterface::Path &path = m_contentIndex ? parentPath : IECoreScene::SceneInterface::rootPath; - - if ( m_splitter && m_splitter->hasPaths() ) - { - return m_splitter->hasPath( path ); - } - else - { -#if UT_MAJOR_VERSION_INT >= 18 - GU_DetailHandle handle = objNode->getRenderGeometryHandle( context, false ); -#else - GU_DetailHandle handle = ( sopNode ) ? sopNode->getCookedGeoHandle( context, false ) : objNode->getRenderGeometryHandle( context, false ); -#endif - GU_DetailHandle newHandle = contentHandle(); - - FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( ( newHandle.isNull() ) ? handle : newHandle ); - bool hasConvertableGeometry = converter != nullptr; - - if ( !hasConvertableGeometry ) - { - // display some diagnostics about why this SOP cannot be converted. - - std::set uniquePrimTypes; - getUniquePrimitives( geo, uniquePrimTypes ); - - throw IECore::Exception( - boost::str( - boost::format( "Error converting SOP: '%1%' to scc. Potentially unsupported prim types found: [ %2% ]" ) % - objNode->getFullPath().c_str() % - boost::algorithm::join( uniquePrimTypes, ", " ) - ) - ); - } - - return hasConvertableGeometry; - } - } - - /// \todo: need to account for OBJ_CAMERA and OBJ_LIGHT - - return false; -} - -ConstObjectPtr LiveScene::readObject( double time, const IECore::Canceller *canceller ) const -{ - OBJ_Node *objNode = retrieveNode( true )->castToOBJNode(); - if ( !objNode ) - { - return nullptr; - } - - if ( objNode->getObjectType() == OBJ_GEOMETRY ) - { - double adjustedTime = adjustTime( time ); - OP_Context context( adjustedTime ); -#if UT_MAJOR_VERSION_INT >= 18 - GU_DetailHandle handle = objNode->getRenderGeometryHandle( context, false ); -#else - SOP_Node* sopNode = renderNode( objNode ); - GU_DetailHandle handle = ( sopNode ) ? sopNode->getCookedGeoHandle( context, false ) : objNode->getRenderGeometryHandle( context, false ); -#endif - if ( !handle ) - { - return nullptr; - } - - if ( !m_splitter ) - { - m_splitter = new DetailSplitter( objNode, adjustedTime, /* key */ "name", /* useHoudiniSegment */ false); - } - else - { - m_splitter->update( objNode, adjustedTime ); - } - - std::string name; - SceneInterface::Path path; - relativeContentPath( path ); - pathToString( path, name ); - - if (auto obj = m_splitter->splitObject( name )) - { - return removeTagsBlindData( obj ); - } - - GU_DetailHandle newHandle = contentHandle(); - FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( ( newHandle.isNull() ) ? handle : newHandle ); - if ( !converter ) - { - Path path; - this->path( path ); - pathToString( path, name ); - - GU_DetailHandleAutoReadLock readHandle( newHandle ); - std::set uniquePrimTypes; - getUniquePrimitives( readHandle.getGdp(), uniquePrimTypes ); - - throw IECore::Exception - ( - boost::str( boost::format( "Unable to split geometry. [%1%] prim types have the same name" ) % boost::algorithm::join( uniquePrimTypes, ", " ) ) - ); - } - - return converter->convert(); - } - - /// \todo: need to account for cameras and lights - - return nullptr; -} - -PrimitiveVariableMap LiveScene::readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const -{ - // \todo Optimize this function, adding special cases such as for Meshes. - ConstPrimitivePtr prim = runTimeCast< const Primitive >( readObject( time ) ); - if ( !prim ) - { - throw Exception( "Object does not have primitive variables!" ); - } - return prim->variables; -} - -void LiveScene::writeObject( const Object *object, double time ) -{ - throw Exception( "IECoreHoudini::LiveScene is read-only" ); -} - -void LiveScene::childNames( NameList &childNames ) const -{ - OP_Node *node = retrieveNode(); - OBJ_Node *objNode = node->castToOBJNode(); - OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode(); - - // add subnet children - if ( node->isManager() || ( objNode && objNode->getObjectType() == OBJ_SUBNET ) ) - { - for ( int i=0; i < node->getNchildren(); ++i ) - { - OBJ_Node *child = node->getChild( i )->castToOBJNode(); - - // ignore children that have incoming connections, as those are actually grandchildren - // also ignore the contentNode, which is actually an extension of ourself - if ( child && child != contentNode && !hasInput( child ) ) - { - childNames.push_back( Name( child->getName() ) ); - } - } - } - - if ( !contentNode ) - { - return; - } - -#if UT_MAJOR_VERSION_INT >= 16 - - // add connected outputs - OP_NodeList childList; - contentNode->getOutputNodes(childList); - for ( OP_Node * child : childList) - { - childNames.push_back( Name( child->getName() ) ); - } - -#else - - // add connected outputs - for ( unsigned i=0; i < contentNode->nOutputs(); ++i ) - { - childNames.push_back( Name( contentNode->getOutput( i )->getName() ) ); - } - -#endif - - - // add child shapes within the geometry - if ( contentNode->getObjectType() != OBJ_GEOMETRY ) - { - return; - } - - IECoreScene::SceneInterface::Path parentPath ( m_path.begin() + m_contentIndex, m_path.end()); - - if ( m_splitter ) - { - DetailSplitter::Names names = m_splitter->getNames( m_contentIndex ? parentPath : IECoreScene::SceneInterface::rootPath ); - - for( const auto &c : names ) - { - childNames.push_back( c ); - } - } - -} - -bool LiveScene::hasChild( const Name &name ) const -{ - Path contentPath; - return (bool)retrieveChild( name, contentPath, NullIfMissing ); -} - -SceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) -{ - Path contentPath; - OP_Node *child = retrieveChild( name, contentPath, missingBehaviour ); - if ( !child ) - { - return 0; - } - - UT_String nodePath; - child->getFullPath( nodePath ); - - Path rootPath; - rootPath.resize( m_rootIndex ); - std::copy( m_path.begin(), m_path.begin() + m_rootIndex, rootPath.begin() ); - - /// \todo: is this really what we want? can we just pass rootIndex and contentIndex instead? - return duplicate( nodePath, contentPath, rootPath); -} - -ConstSceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) const -{ - return const_cast( this )->child( name, missingBehaviour ); -} - -SceneInterfacePtr LiveScene::createChild( const Name &name ) -{ - throw Exception( "IECoreHoudini::LiveScene is read-only" ); -} - -ConstSceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) const -{ - return retrieveScene( path, missingBehaviour ); -} - -SceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) -{ - return retrieveScene( path, missingBehaviour ); -} - -void LiveScene::hash( HashType hashType, double time, MurmurHash &h ) const -{ - throw Exception( "Hashes currently not supported in IECoreHoudini::LiveScene objects." ); -} - -OP_Node *LiveScene::retrieveNode( bool content, MissingBehaviour missingBehaviour ) const -{ - OP_Node *node = OPgetDirector()->findNode( m_nodePath ); - if ( node && content ) - { - if ( OP_Node *contentNode = locateContent( node ) ) - { - node = contentNode; - } - } - - if ( missingBehaviour == ThrowIfMissing ) - { - if ( !node ) - { - throw Exception( "IECoreHoudini::LiveScene: Node \"" + m_nodePath.toStdString() + "\" no longer exists." ); - } - - if ( !node->isManager() && !node->castToOBJNode() ) - { - throw Exception( "IECoreHoudini::LiveScene: Node \"" + m_nodePath.toStdString() + "\" is not a valid OBJ." ); - } - } - - return node; -} - -OP_Node *LiveScene::locateContent( OP_Node *node ) const -{ - OBJ_Node *objNode = node->castToOBJNode(); - if ( node->isManager() || ( objNode && objNode->getObjectType() == OBJ_SUBNET ) ) - { - for ( int i=0; i < node->getNchildren(); ++i ) - { - OP_Node *child = node->getChild( i ); - if ( child->getName().equal( contentName.c_str() ) ) - { - return child; - } - } - } - else if ( objNode && objNode->getObjectType() == OBJ_GEOMETRY ) - { - return objNode; - } - - return 0; -} - -OP_Node *LiveScene::retrieveChild( const Name &name, Path &contentPath, MissingBehaviour missingBehaviour ) const -{ - OP_Node *node = retrieveNode( false, missingBehaviour ); - OP_Node *contentBaseNode = retrieveNode( true, missingBehaviour ); - if ( !node || !contentBaseNode ) - { - return 0; - } - - OBJ_Node *objNode = node->castToOBJNode(); - OBJ_Node *contentNode = contentBaseNode->castToOBJNode(); - - // check subnet children - if ( node->isManager() || ( objNode && objNode->getObjectType() == OBJ_SUBNET ) ) - { - for ( int i=0; i < node->getNchildren(); ++i ) - { - OBJ_Node *child = node->getChild( i )->castToOBJNode(); - // the contentNode is actually an extension of ourself - if ( child == contentNode ) - { - continue; - } - - if ( child && child->getName().equal( name.c_str() ) && !hasInput( child ) ) - { - return child; - } - } - } - - if ( contentNode ) - { - // check connected outputs -#if UT_MAJOR_VERSION_INT >= 16 - OP_NodeList childList; - contentNode->getOutputNodes(childList); - for ( OP_Node * child : childList) - { - if ( child->getName().equal( name.c_str() ) ) - { - return child; - } - } -#else - for ( unsigned i=0; i < contentNode->nOutputs(); ++i ) - { - OP_Node *child = contentNode->getOutput( i ); - if ( child->getName().equal( name.c_str() ) ) - { - return child; - } - } -#endif - // check child shapes within the geo - if ( contentNode->getObjectType() == OBJ_GEOMETRY ) - { - OP_Context context( adjustedDefaultTime() ); - - IECoreScene::SceneInterface::Path parentPath ( m_path.begin() + m_contentIndex, m_path.end()); - - parentPath = m_contentIndex ? parentPath : IECoreScene::SceneInterface::rootPath; - parentPath.push_back(name); - - if ( m_splitter->hasPath( parentPath, false ) ) - { - size_t contentSize = ( m_contentIndex ) ? m_path.size() - m_contentIndex : 0; - if ( contentSize ) - { - contentPath.resize( contentSize ); - std::copy( m_path.begin() + m_contentIndex, m_path.end(), contentPath.begin() ); - } - - contentPath.push_back( name ); - - return contentNode; - } - } - } - - if ( missingBehaviour == SceneInterface::ThrowIfMissing ) - { - Path p; - path( p ); - std::string pStr; - pathToString( p, pStr ); - throw Exception( "IECoreHoudini::LiveScene::retrieveChild: Path \"" + pStr + "\" has no child named " + name.string() + "." ); - } - - return 0; -} - -SceneInterfacePtr LiveScene::retrieveScene( const Path &path, MissingBehaviour missingBehaviour ) const -{ - Path rootPath, emptyPath; - rootPath.resize( m_rootIndex ); - std::copy( m_path.begin(), m_path.begin() + m_rootIndex, rootPath.begin() ); - - LiveScenePtr rootScene = create(); - rootScene->setDefaultTime( m_defaultTime ); - for ( Path::const_iterator it = rootPath.begin(); it != rootPath.end(); ++it ) - { - rootScene = IECore::runTimeCast( rootScene->child( *it ) ); - if ( !rootScene ) - { - return 0; - } - } - - UT_String rootNodePath; - OP_Node *node = rootScene->retrieveNode(); - if ( !node ) - { - return 0; - } - node->getFullPath( rootNodePath ); - - /// \todo: is this really what we want? can we just pass rootIndex and contentIndex instead? - SceneInterfacePtr scene = duplicate( rootNodePath, emptyPath, rootPath); - for ( Path::const_iterator it = path.begin(); it != path.end(); ++it ) - { - scene = scene->child( *it, missingBehaviour ); - if ( !scene ) - { - return 0; - } - } - - return scene; -} - -bool LiveScene::hasInput( const OP_Node *node ) const -{ - int numInputs = node->nInputs(); - for ( int j=0; j < numInputs; ++j ) - { - OP_Input *input = node->getInputReferenceConst( j ); - if ( input && !input->isIndirect() ) - { - return true; - } - } - - return false; -} - -double LiveScene::adjustTime( double time ) const -{ - return time - CHgetManager()->getSecsPerSample(); -} - -bool LiveScene::matchPattern( const char *value, const char *pattern ) const -{ - size_t size = strlen( pattern ); - - // can't be a match unless its exactly the right length - if ( ( strlen( value ) < size ) || ( strlen( value ) > size && value[size] != '\0' && value[size] != '/' ) ) - { - return false; - } - - // all characters must match - for ( size_t i = 0; i < size; ++i ) - { - if ( value[i] != pattern[i] ) - { - return false; - } - } - - return true; -} - -const char *LiveScene::matchPath( const char *value ) const -{ - // looking for empty path - if ( !m_contentIndex ) - { - // houdini returns 0 for empty strings in some cases - if ( value == 0 || !value[0] || !strcmp( value, "/" ) ) - { - return emptyString; - } - - return &value[0]; - } - - // looking for some value, so empty is a failed match - if ( value == 0 ) - { - return NULL; - } - - size_t i = 0; - for ( Path::const_iterator it = m_path.begin() + m_contentIndex; it != m_path.end(); ++it ) - { - const char *current = it->c_str(); - - if ( value[i] == '/' ) - { - i++; - } - - if ( !matchPattern( &value[i], current ) ) - { - return NULL; - } - - i += strlen( current ); - } - - return &value[i]; -} - -std::pair LiveScene::nextWord( const char *value ) const -{ - std::pair result( value, 0 ); - - if ( value[0] == '/' ) - { - result.first = &value[1]; - result.second = 1; - } - - size_t size = strlen( value ); - for ( ; result.second < size; ++result.second ) - { - if ( value[result.second] == '/' || value[result.second] == '\0' ) - { - result.second--; - break; - } - } - - return result; -} - -void LiveScene::relativeContentPath( SceneInterface::Path &path ) const -{ - path.clear(); - - if ( !m_contentIndex ) - { - return; - } - - path.reserve( m_path.size() - m_contentIndex ); - path.insert( path.begin(), m_path.begin() + m_contentIndex, m_path.end() ); -} - -GU_DetailHandle LiveScene::contentHandle() const -{ - std::string name; - SceneInterface::Path path; - relativeContentPath( path ); - pathToString( path, name ); - - GU_DetailHandle handle = m_splitter->split( name.c_str() ); - - // we need to try again, in case the user didn't use a / prefix on the shape name - if ( handle.isNull() && m_contentIndex == 1 && !path.empty() && path[0] != "" ) - { - handle = m_splitter->split( &name.c_str()[1] ); - } - - return handle; -} - -void LiveScene::registerCustomAttributes( ReadNamesFn namesFn, ReadAttrFn readFn, bool callEmbedded ) -{ - CustomAttributeReader r; - r.m_names = namesFn; - r.m_read = readFn; - r.m_callEmbedded = callEmbedded; - customAttributeReaders().push_back( r ); -} - -void LiveScene::clearCustomAttributeReaders() -{ - customAttributeReaders().clear(); -} - -std::vector &LiveScene::customAttributeReaders() -{ - static std::vector readers; - return readers; -} - -void LiveScene::registerCustomTags( HasTagFn hasFn, ReadTagsFn readFn, bool callEmbedded ) -{ - CustomTagReader r; - r.m_has = hasFn; - r.m_read = readFn; - r.m_callEmbedded = callEmbedded; - customTagReaders().push_back( r ); -} - -void LiveScene::clearCustomTagReaders() -{ - customTagReaders().clear(); -} - -std::vector &LiveScene::customTagReaders() -{ - static std::vector readers; - return readers; -} - -LiveScenePtr LiveScene::create() const -{ - return new LiveScene(); -} - -LiveScenePtr LiveScene::duplicate( const UT_String &nodePath, const Path &contentPath, const Path &rootPath) const -{ - return new LiveScene( nodePath, contentPath, rootPath, *this); -} - diff --git a/src/IECoreHoudini/MessageHandler.cpp b/src/IECoreHoudini/MessageHandler.cpp deleted file mode 100644 index a14c3c7e30..0000000000 --- a/src/IECoreHoudini/MessageHandler.cpp +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/MessageHandler.h" - -using namespace IECoreHoudini; - -MessageHandler::MessageHandler( HandlerFn errorFn, HandlerFn warningFn, HandlerFn infoFn, HandlerFn debugFn ) - : m_errorFn( errorFn ), m_warningFn( warningFn ), m_infoFn( infoFn ), m_debugFn( debugFn ) -{ -} - -MessageHandler::~MessageHandler() -{ - m_errorFn = 0; - m_warningFn = 0; - m_infoFn = 0; - m_debugFn = 0; -} - -void MessageHandler::handle( Level level, const std::string &context, const std::string &message ) -{ - std::string msg( context + " : " + message ); - const char *m = msg.c_str(); - switch( level ) - { - case MessageHandler::Error : - if ( m_errorFn ) - { - m_errorFn( m ); - } - break; - case MessageHandler::Warning : - if ( m_warningFn ) - { - m_warningFn( m ); - } - break; - case MessageHandler::Info : - if ( m_infoFn ) - { - m_infoFn( m ); - } - break; - case MessageHandler::Debug : - if ( m_debugFn ) - { - m_debugFn( m ); - } - break; - default : - // do nothing for invalid levels - break; - } -} diff --git a/src/IECoreHoudini/NodeHandle.cpp b/src/IECoreHoudini/NodeHandle.cpp deleted file mode 100644 index eb3e8cd724..0000000000 --- a/src/IECoreHoudini/NodeHandle.cpp +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/NodeHandle.h" - -#include "OP/OP_Director.h" - -#include "boost/shared_ptr.hpp" - -using namespace IECoreHoudini; - -NodeHandle::NodeHandle() -{ -} - -NodeHandle::NodeHandle( const OP_Node *node ) -{ - UT_String path = ""; - node->getFullPath( path ); - m_homNode = boost::shared_ptr( dynamic_cast( HOM().node( path ) ) ); -} - -NodeHandle::~NodeHandle() -{ -} - -bool NodeHandle::alive() const -{ - return (bool)node(); -} - -OP_Node *NodeHandle::node() const -{ - if ( !m_homNode ) - { - return 0; - } - - // get the hom path and use opdirector to get a regular OP_Node* to our node - try - { - OP_Node *node = OPgetDirector()->findNode( m_homNode->path().c_str() ); - if ( node ) - { - return node; - } - } - catch( HOM_ObjectWasDeleted &e ) - { - } - - return 0; -} diff --git a/src/IECoreHoudini/OBJ_SceneCacheGeometry.cpp b/src/IECoreHoudini/OBJ_SceneCacheGeometry.cpp deleted file mode 100644 index d82334cc35..0000000000 --- a/src/IECoreHoudini/OBJ_SceneCacheGeometry.cpp +++ /dev/null @@ -1,179 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/OBJ_SceneCacheGeometry.h" - -#include "IECoreHoudini/SOP_SceneCacheSource.h" - -#include "UT/UT_ValArray.h" -#include "UT/UT_Version.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -const char *OBJ_SceneCacheGeometry::typeName = "ieSceneCacheGeometry"; - -int *OBJ_SceneCacheGeometry::g_indirection = 0; - -OBJ_SceneCacheGeometry::OBJ_SceneCacheGeometry( OP_Network *net, const char *name, OP_Operator *op ) : OBJ_SceneCacheNode( net, name, op ) -{ - if ( !g_indirection ) - { - g_indirection = OP_Parameters::allocIndirect( this->getParmList()->getEntries() ); - } -} - -OBJ_SceneCacheGeometry::~OBJ_SceneCacheGeometry() -{ -} - -OP_Node *OBJ_SceneCacheGeometry::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new OBJ_SceneCacheGeometry( net, name, op ); -} - -OP_TemplatePair *OBJ_SceneCacheGeometry::buildParameters() -{ - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( OBJ_SceneCacheNode::buildParameters() ); - } - - return templatePair; -} - -bool OBJ_SceneCacheGeometry::runCreateScript() -{ - UT_String path; - getFullPath( path ); - - // add the standard mantra geometry parms - UT_String script( "opproperty -f -F Render " + path.toStdString() + " mantra default_geometry" ); - -#if UT_MAJOR_VERSION_INT < 17 - - executeHscriptScript( script, 0 ); - -#else - - OP_Context context; - executeHscriptScript( script, context ); - -#endif - - - return OBJ_Geometry::runCreateScript(); -} - -void OBJ_SceneCacheGeometry::expandHierarchy( const SceneInterface *scene ) -{ - if ( !scene ) - { - return; - } - - doExpandGeometry( scene ); - setInt( pExpanded.getToken(), 0, 0, 1 ); -} - -void OBJ_SceneCacheGeometry::pushToHierarchy() -{ - UT_String attribFilter, attribCopy, tagFilter, shapeFilter, fullPathName; - bool tagGroups = getTagGroups(); - getAttributeFilter( attribFilter ); - getAttributeCopy( attribCopy ); - getTagFilter( tagFilter ); - getShapeFilter( shapeFilter ); - getFullPathName( fullPathName ); - GeometryType geomType = getGeometryType(); - - UT_ValArray children; - int numSceneSops = getOpsByName( SOP_SceneCacheSource::typeName, children ); - for ( int i=0; i < numSceneSops; ++i ) - { - SOP_SceneCacheSource *sop = reinterpret_cast( children( i ) ); - sop->setAttributeFilter( attribFilter ); - sop->setAttributeCopy( attribCopy ); - sop->setTagFilter( tagFilter ); - sop->setTagGroups( tagGroups ); - sop->setVisibilityFilter( getVisibilityFilter() ); - sop->setShapeFilter( shapeFilter ); - sop->setFullPathName( fullPathName ); - sop->setGeometryType( (SOP_SceneCacheSource::GeometryType)geomType ); - } -} - -void OBJ_SceneCacheGeometry::doExpandGeometry( const SceneInterface *scene ) -{ - const char *name = ( scene->name() == SceneInterface::rootName ) ? "root" : scene->name().c_str(); - OP_Node *opNode = createNode( SOP_SceneCacheSource::typeName, name ); - SOP_SceneCacheSource *sop = reinterpret_cast( opNode ); - - sop->referenceParent( pFile.getToken() ); - sop->referenceParent( pRoot.getToken() ); - - bool objectOnly = true; - Space space = getSpace(); - SOP_SceneCacheSource::Space sopSpace = SOP_SceneCacheSource::Object; - if ( space == World || space == Path ) - { - objectOnly = false; - sopSpace = SOP_SceneCacheSource::Path; - } - - UT_String attribFilter, attribCopy, tagFilter, shapeFilter, fullPathName; - getAttributeFilter( attribFilter ); - sop->setAttributeFilter( attribFilter ); - getAttributeCopy( attribCopy ); - sop->setAttributeCopy( attribCopy ); - getTagFilter( tagFilter ); - sop->setTagFilter( tagFilter ); - sop->setTagGroups( getTagGroups() ); - sop->setVisibilityFilter( getVisibilityFilter() ); - getShapeFilter( shapeFilter ); - sop->setShapeFilter( shapeFilter ); - getFullPathName( fullPathName ); - sop->setFullPathName( fullPathName ); - - sop->setSpace( sopSpace ); - sop->setObjectOnly( objectOnly ); - sop->setGeometryType( (SOP_SceneCacheSource::GeometryType)getGeometryType() ); -} - -int *OBJ_SceneCacheGeometry::getIndirect() const -{ - return g_indirection; -} diff --git a/src/IECoreHoudini/OBJ_SceneCacheNode.cpp b/src/IECoreHoudini/OBJ_SceneCacheNode.cpp deleted file mode 100644 index 3350f77147..0000000000 --- a/src/IECoreHoudini/OBJ_SceneCacheNode.cpp +++ /dev/null @@ -1,555 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/OBJ_SceneCacheNode.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/LiveScene.h" - -#include "OBJ/OBJ_Geometry.h" -#include "OBJ/OBJ_Node.h" -#include "OBJ/OBJ_SubNet.h" -#include "PRM/PRM_Include.h" -#include "PRM/PRM_Parm.h" -#include "PRM/PRM_SpareData.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -template -OBJ_SceneCacheNode::OBJ_SceneCacheNode( OP_Network *net, const char *name, OP_Operator *op ) - : SceneCacheNode( net, name, op ) -{ -} - -template -OBJ_SceneCacheNode::~OBJ_SceneCacheNode() -{ -} - -template -PRM_Name OBJ_SceneCacheNode::pMainSwitcher( "mainSwitcher", "Main Switcher" ); - -template -PRM_Name OBJ_SceneCacheNode::pExpand( "expand", "Expand" ); - -template -PRM_Name OBJ_SceneCacheNode::pPush( "push", "Push Options" ); - -template -PRM_Name OBJ_SceneCacheNode::pCollapse( "collapse", "Collapse" ); - -template -PRM_Name OBJ_SceneCacheNode::pExpanded( "expanded", "Expanded" ); - -template -PRM_Name OBJ_SceneCacheNode::pOverrideTransform( "overrideTransform", "Override Transform" ); - -template -PRM_Name OBJ_SceneCacheNode::pOutTranslate( "outT", "Out Translate" ); - -template -PRM_Name OBJ_SceneCacheNode::pOutRotate( "outR", "Out Rotate" ); - -template -PRM_Name OBJ_SceneCacheNode::pOutScale( "outS", "Out Scale" ); - -static PRM_Default outTranslateDefault[] = { - PRM_Default( 0, "hou.pwd().parmTransform().extractTranslates()[0]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractTranslates()[1]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractTranslates()[2]", CH_PYTHON_EXPRESSION ) -}; - -static PRM_Default outRotateDefault[] = { - PRM_Default( 0, "hou.pwd().parmTransform().extractRotates()[0]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractRotates()[1]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractRotates()[2]", CH_PYTHON_EXPRESSION ) -}; - -static PRM_Default outScaleDefault[] = { - PRM_Default( 0, "hou.pwd().parmTransform().extractScales()[0]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractScales()[1]", CH_PYTHON_EXPRESSION ), - PRM_Default( 0, "hou.pwd().parmTransform().extractScales()[2]", CH_PYTHON_EXPRESSION ) -}; - -static void copyParm( PRM_Template &src, PRM_Template &dest, bool visible = true ) -{ - PRM_Name *name = new PRM_Name( src.getToken(), src.getLabel(), src.getExpressionFlag() ); - name->harden(); - - PRM_Type type = ( visible ) ? src.getType() : (PRM_Type) (src.getType() | PRM_TYPE_INVISIBLE); - - dest.initialize( - type, - src.getTypeExtended(), - src.exportLevel(), - src.getVectorSize(), - name, - src.getFactoryDefaults(), - src.getChoiceListPtr(), - src.getRangePtr(), - src.getCallback(), - src.getSparePtr(), - src.getParmGroup(), - (const char *)src.getHelpText(), - src.getConditionalBasePtr() - ); -} - -template -PRM_Template *OBJ_SceneCacheNode::buildParameters( OP_TemplatePair *extraParameters ) -{ - static PRM_Template *thisTemplate = 0; - if ( thisTemplate ) - { - return thisTemplate; - } - - PRM_Template *objTemplate = BaseType::getTemplateList( OBJ_PARMS_PLAIN ); - PRM_Template *mainTemplate = OBJ_SceneCacheNode::buildMainParameters()->myTemplate; - PRM_Template *optionTemplate = OBJ_SceneCacheNode::buildOptionParameters()->myTemplate; - PRM_Template *extraTemplate = ( extraParameters ) ? extraParameters->myTemplate : 0; - PRM_Template *expansionTemplate = buildExpansionParameters()->myTemplate; - PRM_Template *outputTemplate = buildOutputParameters()->myTemplate; - - unsigned numObjParms = PRM_Template::countTemplates( objTemplate ); - unsigned numMainParms = PRM_Template::countTemplates( mainTemplate ); - unsigned numOptionParms = PRM_Template::countTemplates( optionTemplate ); - unsigned numExtraParms = ( extraTemplate ) ? PRM_Template::countTemplates( extraTemplate ) : 0; - unsigned numExpansionParms = PRM_Template::countTemplates( expansionTemplate ); - unsigned numOutputParms = PRM_Template::countTemplates( outputTemplate ); - - thisTemplate = new PRM_Template[ numObjParms + numMainParms + numOptionParms + numExtraParms + numExpansionParms + numOutputParms + 3 ]; - - // add the SceneCacheNode folders to the stdswitcher - unsigned switcherIndex = PRM_Template::getTemplateIndexByToken( objTemplate, "stdswitcher" ); - PRM_Template &stdswitcher = objTemplate[switcherIndex]; - unsigned numFolders = stdswitcher.getVectorSize(); - static PRM_Default *folders = new PRM_Default[ numFolders + 3 ]; - folders[0] = PRM_Default( numMainParms + numExtraParms + numExpansionParms, "Main" ); - folders[1] = PRM_Default( numOptionParms + 1, "Options" ); - folders[2] = PRM_Default( numOutputParms, "Output" ); - - // add the normal folders - PRM_Default *defaults = stdswitcher.getFactoryDefaults(); - for ( unsigned j = 0; j < numFolders; ++j ) - { - // add an extra parm to the transform folder - if ( !strcmp( defaults[j].getString(), "Transform" ) ) - { - folders[j+3] = PRM_Default( defaults[j].getFloat() + 1, defaults[j].getString() ); - } - else - { - folders[j+3] = defaults[j]; - } - } - - // re-init the stdswitcher so we get our new folders - thisTemplate[0] = stdswitcher; - thisTemplate[0].initialize( - stdswitcher.getType(), - stdswitcher.getTypeExtended(), - stdswitcher.exportLevel(), - numFolders + 3, - stdswitcher.getNamePtr(), - folders, - stdswitcher.getChoiceListPtr(), - stdswitcher.getRangePtr(), - stdswitcher.getCallback(), - stdswitcher.getSparePtr(), - stdswitcher.getParmGroup(), - (const char *)stdswitcher.getHelpText(), - stdswitcher.getConditionalBasePtr() - ); - - // add the generic SceneCacheNode parms - unsigned totalParms = 1; - for ( unsigned i = 0; i < numMainParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = mainTemplate[i]; - } - - // add the extra parms for this node - for ( unsigned i = 0; i < numExtraParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = extraTemplate[i]; - } - - // add the generic OBJ_SceneCacheNode expansion parms - for ( unsigned i = 0; i < numExpansionParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = expansionTemplate[i]; - } - - // add the push options button - thisTemplate[totalParms] = PRM_Template( - PRM_CALLBACK, 1, &pPush, 0, 0, 0, &OBJ_SceneCacheNode::pushButtonCallback, 0, 0, - "Push the relevant parameter values to the hierarchy below.\n" - ); - totalParms++; - - // add the generic SceneCacheNode option parms - for ( unsigned i = 0; i < numOptionParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = optionTemplate[i]; - } - - // add the OBJ_SceneCacheNode output parms - for ( unsigned i = 0; i < numOutputParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = outputTemplate[i]; - } - - // add the override parm - thisTemplate[totalParms] = PRM_Template( - PRM_TOGGLE, 1, &pOverrideTransform, 0, 0, 0, &OBJ_SceneCacheNode::sceneParmChangedCallback, 0, 0, - "Determines whether this OBJ reads from file or from the user parms." - ); - totalParms++; - - // add the generic OBJ_Node parms - int transformIndex = thisTemplate[0].findSwitcherFolderWithLabel( "Transform" ); - for ( unsigned i = 0; i < numObjParms; ++i, ++totalParms ) - { - // this was added above - if ( i == switcherIndex ) - { - totalParms--; - continue; - } - - thisTemplate[totalParms] = objTemplate[i]; - - int switcher, folder; - bool visible = true; - bool inFolder = PRM_Template::getEnclosingSwitcherFolder( thisTemplate, totalParms, switcher, folder ); - if ( inFolder && ( folder == transformIndex ) ) - { - visible = ( - !strcmp( thisTemplate[totalParms].getToken(), "t" ) || - !strcmp( thisTemplate[totalParms].getToken(), "r" ) || - !strcmp( thisTemplate[totalParms].getToken(), "s" ) - ); - } - - copyParm( objTemplate[i], thisTemplate[totalParms], visible ); - } - - return thisTemplate; -} - -template -OP_TemplatePair *OBJ_SceneCacheNode::buildExpansionParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - thisTemplate = new PRM_Template[4]; - - thisTemplate[0] = PRM_Template( - PRM_CALLBACK, 1, &pExpand, 0, 0, 0, &OBJ_SceneCacheNode::expandButtonCallback, 0, 0, - "Expand the hierarchy below the specified root path.\n" - "Some nodes may define additional options that are used during the expansion process." - ); - - thisTemplate[1] = PRM_Template( - PRM_CALLBACK, 1, &pCollapse, 0, 0, 0, &OBJ_SceneCacheNode::collapseButtonCallback, 0, 0, - "Clean the hierarchy below the specified root path. Note that this is a destructive operation. " - "All nodes contained within will be deleted." - ); - - thisTemplate[2] = PRM_Template( - PRM_TOGGLE, 1, &pExpanded, 0, 0, 0, 0, 0, 0, - "A toggle to indicate whether this level is expanded or not. This does not affect cooking, " - "and the value may be changed by automated scripts. Expansion will be blocked when this is on." - ); - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -template -OP_TemplatePair *OBJ_SceneCacheNode::buildOutputParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - thisTemplate = new PRM_Template[5]; - - thisTemplate[0] = PRM_Template( - PRM_XYZ | PRM_TYPE_NOCOOK, 3, &pOutTranslate, outTranslateDefault, 0, 0, 0, 0, 0, - "Output translation calculated by this node. This is for user clarity only and is not editable." - ); - - thisTemplate[1] = PRM_Template( - PRM_XYZ | PRM_TYPE_NOCOOK, 3, &pOutRotate, outRotateDefault, 0, 0, 0, 0, 0, - "Output rotation calculated by this node. This is for user clarity only and is not editable." - ); - - thisTemplate[2] = PRM_Template( - PRM_XYZ | PRM_TYPE_NOCOOK, 3, &pOutScale, outScaleDefault, 0, 0, 0, 0, 0, - "Output scale calculated by this node. This is for user clarity only and is not editable." - ); - - thisTemplate[3] = PRM_Template( - PRM_STRING | PRM_TYPE_NOCOOK, 1, &LiveScene::pTags, 0, 0, 0, 0, 0, 0, - "A space separated list of tags to add when caching with the SceneCache ROP." - ); - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -template -int OBJ_SceneCacheNode::expandButtonCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - std::string file; - OBJ_SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node || !node->ensureFile( file ) || node->evalInt( pExpanded.getToken(), 0, 0 ) ) - { - return 0; - } - - node->setDisplay( false ); - node->expandHierarchy( node->scene( file, node->getPath() ).get() ); - node->setDisplay( true ); - - return 1; -} - -template -int OBJ_SceneCacheNode::pushButtonCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - std::string file; - OBJ_SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node || !node->ensureFile( file ) || !node->evalInt( pExpanded.getToken(), 0, 0 ) ) - { - return 0; - } - - node->pushToHierarchy(); - - return 1; -} - -template -int OBJ_SceneCacheNode::collapseButtonCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - OBJ_SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node ) - { - return 0; - } - - node->collapseHierarchy(); - - return 1; -} - -template -void OBJ_SceneCacheNode::collapseHierarchy() -{ - OP_NodeList childNodes; - for ( int i=0; i < this->getNchildren(); ++i ) - { - childNodes.append( this->getChild( i ) ); - } - - this->destroyNodes( childNodes ); - this->setInt( pExpanded.getToken(), 0, 0, 0 ); -} - -template -void OBJ_SceneCacheNode::sceneChanged() -{ - SceneCacheNode::sceneChanged(); - this->m_static = boost::indeterminate; -} - -template -void OBJ_SceneCacheNode::updateState() -{ - // do not read from file if overriding - if ( this->evalInt( pOverrideTransform.getToken(), 0, 0 ) ) - { - this->m_static = boost::indeterminate; - return; - } - - std::string file; - if ( !OBJ_SceneCacheNode::ensureFile( file ) ) - { - this->m_static = boost::indeterminate; - return; - } - - std::string path = this->getPath(); - - ConstSceneInterfacePtr scene = this->scene( file, path ); - const SampledSceneInterface *sampledScene = IECore::runTimeCast( scene.get() ); - - this->m_static = ( sampledScene ) ? ( sampledScene->numTransformSamples() < 2 ) : false; - - // only update time dependency if Houdini thinks its static - if ( !BaseType::flags().getTimeDep() && !BaseType::getParmList()->getCookTimeDependent() ) - { - BaseType::flags().setTimeDep( bool( !this->m_static ) ); - BaseType::getParmList()->setCookTimeDependent( bool( !this->m_static ) ); - } -} - -template -bool OBJ_SceneCacheNode::getParmTransform( OP_Context &context, UT_DMatrix4 &xform ) -{ - std::string file = this->getFile(); - std::string path = this->getPath(); - OBJ_SceneCacheNode::Space space = (OBJ_SceneCacheNode::Space)this->getSpace(); - - MurmurHash hash; - hash.append( file ); - hash.append( path ); - hash.append( space ); - - // make sure the state is valid - if ( boost::indeterminate( this->m_static ) ) - { - updateState(); - } - - // only update time dependency if Houdini thinks its static - if ( !BaseType::flags().getTimeDep() && !BaseType::getParmList()->getCookTimeDependent() ) - { - BaseType::flags().setTimeDep( bool( !this->m_static ) ); - BaseType::getParmList()->setCookTimeDependent( bool( !this->m_static ) ); - } - - // do not read from file if overriding - if ( this->evalInt( pOverrideTransform.getToken(), 0, 0 ) ) - { - BaseType::getParmTransform( context, xform ); - return true; - } - - if ( this->m_static == true && this->m_loaded && this->m_hash == hash ) - { - xform = m_xform; - return true; - } - - if ( !SceneCacheNode::ensureFile( file ) ) - { - SceneCacheNode::addError( OBJ_ERR_CANT_FIND_OBJ, ( file + " is not a valid .scc" ).c_str() ); - return false; - } - - ConstSceneInterfacePtr scene = this->scene( file, path ); - if ( !scene ) - { - SceneCacheNode::addError( OBJ_ERR_CANT_FIND_OBJ, ( path + " is not a valid location in " + file ).c_str() ); - return false; - } - - Imath::M44d transform; - if ( space == SceneCacheNode::World ) - { - transform = SceneCacheNode::worldTransform( file, path, this->time( context ) ); - } - else if ( space == SceneCacheNode::Local ) - { - transform = scene->readTransformAsMatrix( this->time( context ) ); - } - - xform = IECore::convert( transform ); - m_xform = xform; - this->m_hash = hash; - this->m_loaded = true; - - return true; -} - -template -OP_ERROR OBJ_SceneCacheNode::cookMyObj( OP_Context &context ) -{ - OP_ERROR status = BaseType::cookMyObj( context ); - - // only update time dependency if Houdini thinks its static - if ( !BaseType::flags().getTimeDep() && !BaseType::getParmList()->getCookTimeDependent() ) - { - BaseType::flags().setTimeDep( bool( !this->m_static ) ); - BaseType::getParmList()->setCookTimeDependent( bool( !this->m_static ) ); - } - - return status; -} - -template -bool OBJ_SceneCacheNode::updateParmsFlags() -{ - bool expanded = this->evalInt( pExpanded.getToken(), 0, 0 ); - this->enableParm( pExpand.getToken(), !expanded ); - this->enableParm( pExpanded.getToken(), !expanded ); - this->enableParm( pCollapse.getToken(), expanded ); - bool override = this->evalInt( pOverrideTransform.getToken(), 0, 0 ); - this->enableParm( "t", override ); - this->enableParm( "r", override ); - this->enableParm( "s", override ); - this->enableParm( pOutTranslate.getToken(), false ); - this->enableParm( pOutRotate.getToken(), false ); - this->enableParm( pOutScale.getToken(), false ); - return true; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Known Specializations -////////////////////////////////////////////////////////////////////////////////////////// - -namespace IECoreHoudini -{ - template class OBJ_SceneCacheNode; - template class OBJ_SceneCacheNode; -} diff --git a/src/IECoreHoudini/OBJ_SceneCacheTransform.cpp b/src/IECoreHoudini/OBJ_SceneCacheTransform.cpp deleted file mode 100644 index 043a321f25..0000000000 --- a/src/IECoreHoudini/OBJ_SceneCacheTransform.cpp +++ /dev/null @@ -1,597 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/OBJ_SceneCacheTransform.h" - -#include "IECoreHoudini/OBJ_SceneCacheGeometry.h" - -#include "OP/OP_Layout.h" - -#include "UT/UT_Version.h" -#if UT_MAJOR_VERSION_INT >= 16 -#include "OP/OP_SubnetIndirectInput.h" -#endif - -#include "PRM/PRM_ChoiceList.h" -#include "UT/UT_Interrupt.h" -#include "UT/UT_ValArray.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -const char *OBJ_SceneCacheTransform::typeName = "ieSceneCacheTransform"; - -int *OBJ_SceneCacheTransform::g_indirection = 0; - -OBJ_SceneCacheTransform::OBJ_SceneCacheTransform( OP_Network *net, const char *name, OP_Operator *op ) : OBJ_SceneCacheNode( net, name, op ) -{ - if ( !g_indirection ) - { - g_indirection = OP_Parameters::allocIndirect( this->getParmList()->getEntries() ); - } -} - -OBJ_SceneCacheTransform::~OBJ_SceneCacheTransform() -{ -} - -OP_Node *OBJ_SceneCacheTransform::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new OBJ_SceneCacheTransform( net, name, op ); -} - -PRM_Name OBJ_SceneCacheTransform::pHierarchy( "hierarchy", "Hierarchy" ); -PRM_Name OBJ_SceneCacheTransform::pDepth( "depth", "Depth" ); - -PRM_Default OBJ_SceneCacheTransform::hierarchyDefault( SubNetworks ); -PRM_Default OBJ_SceneCacheTransform::depthDefault( AllDescendants ); - -static PRM_Name hierarchyNames[] = { - PRM_Name( "0", "SubNetworks" ), - PRM_Name( "1", "Parenting" ), - PRM_Name( "2", "Flat Geometry" ), - PRM_Name( 0 ) // sentinal -}; - -static PRM_Name depthNames[] = { - PRM_Name( "0", "All Descendants" ), - PRM_Name( "1", "Children" ), - PRM_Name( 0 ) // sentinal -}; - -PRM_ChoiceList OBJ_SceneCacheTransform::hierarchyList( PRM_CHOICELIST_SINGLE, &hierarchyNames[0] ); -PRM_ChoiceList OBJ_SceneCacheTransform::depthList( PRM_CHOICELIST_SINGLE, &depthNames[0] ); - -OP_TemplatePair *OBJ_SceneCacheTransform::buildParameters() -{ - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( OBJ_SceneCacheNode::buildParameters( buildExtraParameters() ) ); - } - - return templatePair; -} - -OP_TemplatePair *OBJ_SceneCacheTransform::buildExtraParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - thisTemplate = new PRM_Template[3]; - - thisTemplate[0] = PRM_Template( - PRM_INT, 1, &pHierarchy, &hierarchyDefault, &hierarchyList, 0, 0, 0, 0, - "Choose the node network style used when expanding. Parenting will create a graph using " - "node connections, SubNetworks will create a deep hierarchy, and Flat Geometry will " - "create a single OBJ and SOP." - ); - thisTemplate[1] = PRM_Template( - PRM_INT, 1, &pDepth, &depthDefault, &depthList, 0, 0, 0, 0, - "Choose how deep to expand. All Descendants will expand everything below the specified root " - "path and Children will only expand the immediate children of the root path, which may " - "or may not contain geometry." - ); - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -void OBJ_SceneCacheTransform::expandHierarchy( const SceneInterface *scene ) -{ - if ( !scene ) - { - return; - } - - Parameters params; - params.geometryType = getGeometryType(); - params.depth = (Depth)evalInt( pDepth.getToken(), 0, 0 ); - params.hierarchy = (Hierarchy)evalInt( pHierarchy.getToken(), 0, 0 ); - params.tagGroups = getTagGroups(); - params.visibilityFilter = getVisibilityFilter(); - getAttributeFilter( params.attributeFilter ); - getAttributeCopy( params.attributeCopy ); - getShapeFilter( params.shapeFilter ); - getTagFilter( params.tagFilterStr ); - getTagFilter( params.tagFilter ); - getFullPathName( params.fullPathName ); - - if ( params.hierarchy == FlatGeometry ) - { - // Collapse first, in case the immediate object was already created on during parent expansion - collapseHierarchy(); - doExpandObject( scene, this, params ); - setInt( pExpanded.getToken(), 0, 0, 1 ); - return; - } - - OBJ_Node *rootNode = this; - if ( scene->hasObject() ) - { - Parameters rootParams( params ); - rootParams.hierarchy = SubNetworks; - rootParams.depth = Children; - OBJ_Node *objNode = doExpandObject( scene, this, rootParams ); - if ( params.hierarchy == Parenting ) - { - rootNode = objNode; - } - } - else if ( params.hierarchy == Parenting ) - { - /// \todo: this is terrible. can we use the subnet input instead? - rootNode = reinterpret_cast( createNode( "geo", "TMP" ) ); - } - - if ( params.hierarchy == Parenting ) - { - rootNode->setIndirectInput( 0, this->getParentInput( 0 ) ); - } - - UT_Interrupt *progress = UTgetInterrupt(); - if ( !progress->opStart( ( "Expand Hierarchy for " + getPath() ).c_str() ) ) - { - return; - } - - doExpandChildren( scene, rootNode, params ); - setInt( pExpanded.getToken(), 0, 0, 1 ); - - if ( params.hierarchy == Parenting && !scene->hasObject() ) - { - destroyNode( rootNode ); - } - - progress->opEnd(); -} - -OBJ_Node *OBJ_SceneCacheTransform::doExpandObject( const SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ) -{ - const char *name = ( params.hierarchy == Parenting ) ? scene->name().c_str() : "geo"; - OP_Node *opNode = parent->createNode( OBJ_SceneCacheGeometry::typeName, name ); - OBJ_SceneCacheGeometry *geo = reinterpret_cast( opNode ); - - geo->referenceParent( pFile.getToken() ); - if ( params.hierarchy == Parenting ) - { - geo->setPath( scene ); - } - else - { - geo->referenceParent( pRoot.getToken() ); - geo->setIndirectInput( 0, parent->getParentInput( 0 ) ); - } - - Space space = ( params.depth == AllDescendants ) ? Path : ( params.hierarchy == Parenting ) ? Local : Object; - geo->setSpace( (OBJ_SceneCacheGeometry::Space)space ); - geo->setGeometryType( (OBJ_SceneCacheGeometry::GeometryType)params.geometryType ); - geo->setAttributeFilter( params.attributeFilter ); - geo->setAttributeCopy( params.attributeCopy ); - geo->setShapeFilter( params.shapeFilter ); - geo->setFullPathName( params.fullPathName ); - - bool visible = tagged( scene, params.tagFilter ); - if ( visible ) - { - geo->setTagFilter( params.tagFilterStr ); - geo->setTagGroups( params.tagGroups ); - } - - geo->setDisplay( visible ); - geo->expandHierarchy( scene ); - - return geo; -} - -OBJ_Node *OBJ_SceneCacheTransform::doExpandChild( const SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ) -{ - OP_Node *opNode = parent->createNode( OBJ_SceneCacheTransform::typeName, scene->name().c_str() ); - OBJ_SceneCacheTransform *xform = reinterpret_cast( opNode ); - - xform->referenceParent( pFile.getToken() ); - xform->setPath( scene ); - xform->setSpace( Local ); - xform->setGeometryType( (OBJ_SceneCacheTransform::GeometryType)params.geometryType ); - xform->setAttributeFilter( params.attributeFilter ); - xform->setAttributeCopy( params.attributeCopy ); - xform->setShapeFilter( params.shapeFilter ); - xform->setFullPathName( params.fullPathName ); - xform->setInt( pHierarchy.getToken(), 0, 0, params.hierarchy ); - xform->setInt( pDepth.getToken(), 0, 0, params.depth ); - - SceneInterface::NameList children; - scene->childNames( children ); - if ( children.empty() && !scene->hasObject() ) - { - xform->setInt( pExpanded.getToken(), 0, 0, 1 ); - } - - if ( tagged( scene, params.tagFilter ) ) - { - xform->setTagFilter( params.tagFilterStr ); - } - else - { - xform->setDisplay( false ); - } - - if ( params.hierarchy == SubNetworks ) - { - xform->setIndirectInput( 0, parent->getParentInput( 0 ) ); - } - - return xform; -} - -void OBJ_SceneCacheTransform::doExpandChildren( const SceneInterface *scene, OP_Network *parent, const Parameters ¶ms ) -{ - UT_Interrupt *progress = UTgetInterrupt(); - progress->setLongOpText( ( "Expanding " + scene->name().string() ).c_str() ); - if ( progress->opInterrupt() ) - { - return; - } - - OP_Network *inputNode = parent; - if ( params.hierarchy == Parenting ) - { - parent = parent->getParent(); - } - - SceneInterface::NameList children; - scene->childNames( children ); - for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it ) - { - ConstSceneInterfacePtr child = scene->child( *it ); - - OBJ_Node *childNode = 0; - if ( params.hierarchy == SubNetworks ) - { - childNode = doExpandChild( child.get(), parent, params ); - if ( params.depth == AllDescendants && child->hasObject() && tagged( child.get(), params.tagFilter ) ) - { - Parameters childParams( params ); - childParams.depth = Children; - doExpandObject( child.get(), childNode, childParams ); - } - } - else if ( params.hierarchy == Parenting ) - { - if ( child->hasObject() ) - { - Parameters childParams( params ); - childParams.depth = Children; - childNode = doExpandObject( child.get(), parent, childParams ); - } - else - { - childNode = doExpandChild( child.get(), parent, params ); - } - - childNode->setInput( 0, inputNode ); - } - - if ( params.depth == AllDescendants ) - { - if ( params.hierarchy == SubNetworks && !tagged( child.get(), params.tagFilter ) ) - { - // we don't expand non-tagged children for SubNetwork mode, but we - // do for Parenting mode, because otherwise the hierarchy would be - // stuck in an un-expandable state. - continue; - } - - doExpandChildren( child.get(), childNode, params ); - childNode->setInt( pExpanded.getToken(), 0, 0, 1 ); - } - } - - OP_Layout layout( parent ); - -#if UT_MAJOR_VERSION_INT >= 16 - - OP_SubnetIndirectInput *parentInput = parent->getParentInput( 0 ); - layout.addLayoutItem( parentInput->getInputItem() ); - for ( int i=0; i < parent->getNchildren(); ++i ) - { - layout.addLayoutItem( parent->getChild( i ) ); - } - -#else - - layout.addLayoutOp( parent->getParentInput( 0 ) ); - for ( int i=0; i < parent->getNchildren(); ++i ) - { - layout.addLayoutOp( parent->getChild( i ) ); - } - -#endif - - layout.layoutOps( OP_LAYOUT_TOP_TO_BOT, parent, parent->getParentInput( 0 ) ); -} - -void OBJ_SceneCacheTransform::pushToHierarchy() -{ - UT_String attribFilter, attribCopy, shapeFilter, fullPathName; - bool tagGroups = getTagGroups(); - bool visibilityFilter = getVisibilityFilter(); - getAttributeFilter( attribFilter ); - getAttributeCopy( attribCopy ); - getShapeFilter( shapeFilter ); - getFullPathName( fullPathName ); - GeometryType geometryType = getGeometryType(); - - UT_String tagFilterStr; - UT_StringMMPattern tagFilter; - getTagFilter( tagFilterStr ); - tagFilter.compile( tagFilterStr ); - - UT_ValArray children; - int numSceneNodes = getOpsByName( OBJ_SceneCacheTransform::typeName, children ); - for ( int i=0; i < numSceneNodes; ++i ) - { - OBJ_SceneCacheTransform *xform = reinterpret_cast( children( i ) ); - xform->setAttributeFilter( attribFilter ); - xform->setAttributeCopy( attribCopy ); - xform->setShapeFilter( shapeFilter ); - xform->setFullPathName( fullPathName ); - xform->setGeometryType( geometryType ); - - std::string file; - bool visible = false; - if ( IECoreScene::ConstSceneInterfacePtr scene = xform->scene() ) - { - if ( tagged( scene.get(), tagFilter ) ) - { - visible = true; - xform->setTagFilter( tagFilterStr ); - xform->setTagGroups( tagGroups ); - xform->setVisibilityFilter( visibilityFilter ); - if ( visibilityFilter ) - { - xform->setVisibilityExpression(); - } - else - { - xform->clearVisibilityExpression(); - } - } - } - - xform->setRender( visible ); - xform->setDisplay( visible ); - xform->pushToHierarchy(); - } - - children.clear(); - numSceneNodes = getOpsByName( OBJ_SceneCacheGeometry::typeName, children ); - for ( int i=0; i < numSceneNodes; ++i ) - { - OBJ_SceneCacheGeometry *geo = reinterpret_cast( children( i ) ); - geo->setAttributeFilter( attribFilter ); - geo->setAttributeCopy( attribCopy ); - geo->setShapeFilter( shapeFilter ); - geo->setFullPathName( fullPathName ); - geo->setGeometryType( (OBJ_SceneCacheGeometry::GeometryType)geometryType ); - - std::string file; - bool visible = false; - if ( IECoreScene::ConstSceneInterfacePtr scene = geo->scene() ) - { - visible = tagged( scene.get(), tagFilter ); - if ( visible ) - { - geo->setTagFilter( tagFilterStr ); - geo->setTagGroups( tagGroups ); - geo->setVisibilityFilter( visibilityFilter ); - if ( visibilityFilter ) - { - geo->setVisibilityExpression(); - } - else - { - geo->clearVisibilityExpression(); - } - } - } - - geo->setRender( visible ); - geo->setDisplay( visible ); - geo->pushToHierarchy(); - } -} - -OBJ_SceneCacheTransform::Parameters::Parameters() -{ -} - -OBJ_SceneCacheTransform::Parameters::Parameters( const Parameters &other ) -{ - geometryType = other.geometryType; - hierarchy = other.hierarchy; - depth = other.depth; - attributeFilter = other.attributeFilter; - attributeCopy = other.attributeCopy; - shapeFilter = other.shapeFilter; - tagFilterStr = other.tagFilterStr; - tagFilter.compile( tagFilterStr ); - tagGroups = other.tagGroups; - visibilityFilter = other.visibilityFilter; - fullPathName = other.fullPathName; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Registration for LiveScene extra attributes -////////////////////////////////////////////////////////////////////////////////////////// - -OBJ_SceneCacheTransform::LiveSceneAddOn OBJ_SceneCacheTransform::g_liveSceneAddOn; - -OBJ_SceneCacheTransform::LiveSceneAddOn::LiveSceneAddOn() -{ - LiveScene::registerCustomAttributes( OBJ_SceneCacheTransform::attributeNames, OBJ_SceneCacheTransform::readAttribute, true ); - LiveScene::registerCustomTags( OBJ_SceneCacheTransform::hasTag, OBJ_SceneCacheTransform::readTags, true ); -} - -void OBJ_SceneCacheTransform::attributeNames( const OP_Node *node, SceneInterface::NameList &attrs ) -{ - // make sure its a SceneCacheNode - if ( !node->hasParm( pFile.getToken() ) || !node->hasParm( pRoot.getToken() ) ) - { - return; - } - - const SceneCacheNode *sceneNode = reinterpret_cast< const SceneCacheNode* >( node ); - /// \todo: do we need to ensure the file exists first? - ConstSceneInterfacePtr scene = OBJ_SceneCacheTransform::scene( sceneNode->getFile(), sceneNode->getPath() ); - if ( !scene ) - { - return; - } - - scene->attributeNames( attrs ); - - const char *expanded = pExpanded.getToken(); - if ( node->hasParm( expanded ) && !node->evalInt( expanded, 0, 0 ) ) - { - attrs.push_back( LinkedScene::linkAttribute ); - } -} - -IECore::ConstObjectPtr OBJ_SceneCacheTransform::readAttribute( const OP_Node *node, const SceneInterface::Name &name, double time ) -{ - // make sure its a SceneCacheNode - if ( !node->hasParm( pFile.getToken() ) || !node->hasParm( pRoot.getToken() ) ) - { - return 0; - } - - const SceneCacheNode *sceneNode = reinterpret_cast< const SceneCacheNode* >( node ); - /// \todo: do we need to ensure the file exists first? - ConstSceneInterfacePtr scene = OBJ_SceneCacheTransform::scene( sceneNode->getFile(), sceneNode->getPath() ); - if ( !scene ) - { - return 0; - } - - if ( name == LinkedScene::linkAttribute ) - { - const char *expanded = pExpanded.getToken(); - if ( node->hasParm( expanded ) && !node->evalInt( expanded, 0, 0 ) ) - { - return LinkedScene::linkAttributeData( scene.get(), time ); - } - - return 0; - } - - try - { - return scene->readAttribute( name, time ); - } - catch( ... ) - { - return 0; - } -} - -bool OBJ_SceneCacheTransform::hasTag( const OP_Node *node, const SceneInterface::Name &tag, int filter ) -{ - // make sure its a SceneCacheNode - if ( !node->hasParm( pFile.getToken() ) || !node->hasParm( pRoot.getToken() ) ) - { - return false; - } - - const SceneCacheNode *sceneNode = reinterpret_cast< const SceneCacheNode* >( node ); - /// \todo: do we need to ensure the file exists first? - ConstSceneInterfacePtr scene = OBJ_SceneCacheTransform::scene( sceneNode->getFile(), sceneNode->getPath() ); - if ( !scene ) - { - return false; - } - - return scene->hasTag( tag, filter ); -} - -void OBJ_SceneCacheTransform::readTags( const OP_Node *node, SceneInterface::NameList &tags, int filter ) -{ - // make sure its a SceneCacheNode - if ( !node->hasParm( pFile.getToken() ) || !node->hasParm( pRoot.getToken() ) ) - { - return; - } - - const SceneCacheNode *sceneNode = reinterpret_cast< const SceneCacheNode* >( node ); - /// \todo: do we need to ensure the file exists first? - ConstSceneInterfacePtr scene = OBJ_SceneCacheTransform::scene( sceneNode->getFile(), sceneNode->getPath() ); - if ( !scene ) - { - return; - } - - scene->readTags( tags, filter ); -} - -int *OBJ_SceneCacheTransform::getIndirect() const -{ - return g_indirection; -} diff --git a/src/IECoreHoudini/ParameterisedHolder.cpp b/src/IECoreHoudini/ParameterisedHolder.cpp deleted file mode 100644 index 8b8bc7d8a3..0000000000 --- a/src/IECoreHoudini/ParameterisedHolder.cpp +++ /dev/null @@ -1,951 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// \todo: libIECoreHoudini should not use python. Move any use case to the IECoreHoudini bindings -#include "boost/python.hpp" - -#include "IECoreHoudini/ParameterisedHolder.h" - -#include "IECoreHoudini/CoreHoudini.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/LevelFilteredMessageHandler.h" -#include "IECore/OStreamMessageHandler.h" -#include "IECore/ParameterisedInterface.h" -#include "IECore/SimpleTypedData.h" - -#include "CH/CH_LocalVariable.h" -#include "OBJ/OBJ_Node.h" -#include "PRM/PRM_Include.h" -#include "PRM/PRM_Parm.h" -#include "ROP/ROP_Node.h" -#include "SOP/SOP_Node.h" - -#include "boost/bind/bind.hpp" -#include "boost/format.hpp" - -using namespace boost; -using namespace boost::placeholders; -using namespace boost::python; - -using namespace IECore; -using namespace IECoreHoudini; - -template -PRM_Name ParameterisedHolder::pParameterisedClassCategory( "__classCategory", "Category:" ); -template -PRM_Name ParameterisedHolder::pParameterisedClassName( "__className", "Class:" ); -template -PRM_Name ParameterisedHolder::pParameterisedVersion( "__classVersion", " Version:" ); -template -PRM_Name ParameterisedHolder::pParameterisedSearchPathEnvVar( "__classSearchPathEnvVar", "SearchPathEnvVar:" ); -template -PRM_Name ParameterisedHolder::pMatchString( "__classMatchString", "MatchString" ); -template -PRM_Name ParameterisedHolder::pReloadButton( "__classReloadButton", "Reload" ); -template -PRM_Name ParameterisedHolder::pEvaluateParameters( "__evaluateParameters", "ParameterEval" ); -template -PRM_Name ParameterisedHolder::pSwitcher( "__parameterSwitcher", "Switcher" ); - -template -PRM_Default ParameterisedHolder::matchStringDefault( 0, "*" ); -template -PRM_Default ParameterisedHolder::switcherDefaults[] = { PRM_Default( 0, "Parameters" ) }; - -template -PRM_ChoiceList ParameterisedHolder::classCategoryMenu( PRM_CHOICELIST_SINGLE, &ParameterisedHolder::buildClassCategoryMenu ); -template -PRM_ChoiceList ParameterisedHolder::classNameMenu( PRM_CHOICELIST_SINGLE, &ParameterisedHolder::buildClassNameMenu ); -template -PRM_ChoiceList ParameterisedHolder::classVersionMenu( PRM_CHOICELIST_SINGLE, &ParameterisedHolder::buildVersionMenu ); - -template -PRM_Template ParameterisedHolder::parameters[] = { - PRM_Template( PRM_STRING|PRM_TYPE_JOIN_NEXT, 1, &pParameterisedClassCategory, 0, &classCategoryMenu, 0, &ParameterisedHolder::reloadClassCallback ), - PRM_Template( PRM_STRING|PRM_TYPE_JOIN_NEXT, 1, &pParameterisedClassName, 0, &classNameMenu, 0, &ParameterisedHolder::reloadClassCallback ), - PRM_Template( PRM_STRING|PRM_TYPE_JOIN_NEXT, 1, &pParameterisedVersion, 0, &classVersionMenu, 0, &ParameterisedHolder::reloadClassCallback ), - PRM_Template( PRM_STRING|PRM_TYPE_JOIN_NEXT|PRM_TYPE_INVISIBLE, 1, &pParameterisedSearchPathEnvVar, 0, 0, 0, &ParameterisedHolder::reloadClassCallback ), - PRM_Template( PRM_STRING|PRM_TYPE_INVISIBLE, 1, &pMatchString, &matchStringDefault ), - PRM_Template( PRM_CALLBACK, 1, &pReloadButton, 0, 0, 0, &ParameterisedHolder::reloadButtonCallback ), - PRM_Template( PRM_INT|PRM_TYPE_INVISIBLE, 1, &pEvaluateParameters ), - PRM_Template( PRM_SWITCHER, 1, &pSwitcher, switcherDefaults ), - PRM_Template() -}; - -template -CH_LocalVariable ParameterisedHolder::variables[] = { - { 0, 0, 0 }, -}; - -template -ParameterisedHolder::ParameterisedHolder( OP_Network *net, const char *name, OP_Operator *op ) : BaseType( net, name, op ) -{ - CoreHoudini::initPython(); - - this->getParm( "__evaluateParameters" ).setExpression( 0, "val = 0\nreturn val", CH_PYTHON, 0 ); - this->getParm( "__evaluateParameters" ).setLockedFlag( 0, 1 ); -} - -template -ParameterisedHolder::~ParameterisedHolder() -{ -} - -template -void ParameterisedHolder::buildClassCategoryMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - ParameterisedHolder *holder = reinterpret_cast*>( data ); - if ( !holder ) - { - return; - } - - menu[0].setToken( "" ); - menu[0].setLabel( "< No Category Selected >" ); - unsigned int pos = 1; - - UT_String value; - holder->evalString( value, pMatchString.getToken(), 0, 0 ); - std::string matchString( value.toStdString() ); - size_t padding = matchString.length(); - - holder->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - std::vector names; - classNames( searchPathEnvVar, matchString, names ); - - std::set categories; - for ( std::vector::const_iterator it=names.begin(); it != names.end(); it++ ) - { - size_t divider = (*it).rfind( "/" ); - if ( divider != std::string::npos ) - { - categories.insert( (*it).substr( 0, divider ) ); - } - } - - for ( std::set::const_iterator it=categories.begin(); it != categories.end(); it++, pos++ ) - { - menu[pos].setToken( (*it).c_str() ); - menu[pos].setLabel( (*it).substr( (*it).find( matchString ) + padding ).c_str() ); - } - - // mark the end of our menu - menu[pos].setToken( 0 ); -} - -template -void ParameterisedHolder::buildClassNameMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - ParameterisedHolder *holder = reinterpret_cast*>( data ); - if ( !holder ) - { - return; - } - - menu[0].setToken( "" ); - menu[0].setLabel( "< No Class Loaded >" ); - unsigned int pos = 1; - - UT_String value; - holder->evalString( value, pMatchString.getToken(), 0, 0 ); - std::string matchString( value.toStdString() ); - - holder->evalString( value, pParameterisedClassCategory.getToken(), 0, 0 ); - std::string category( value.toStdString() ); - if ( category != "" ) - { - matchString = category + "/*"; - } - - size_t padding = matchString.length(); - - holder->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - std::vector names; - classNames( searchPathEnvVar, matchString, names ); - - for ( std::vector::const_iterator it=names.begin(); it != names.end(); it++, pos++ ) - { - menu[pos].setToken( (*it).c_str() ); - menu[pos].setLabel( (*it).substr( (*it).find( matchString ) + padding ).c_str() ); - } - - // mark the end of our menu - menu[pos].setToken( 0 ); -} - -template -void ParameterisedHolder::buildVersionMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - ParameterisedHolder *holder = reinterpret_cast*>( data ); - if ( !holder ) - { - return; - } - - unsigned int pos = 0; - - UT_String value; - holder->evalString( value, pParameterisedClassName.getToken(), 0, 0 ); - std::string className( value.toStdString() ); - - if ( className != "" ) - { - holder->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - std::vector versions; - classVersions( className, searchPathEnvVar, versions ); - for ( std::vector::iterator it=versions.begin(); it != versions.end(); it++, pos++ ) - { - std::stringstream ss; - ss << (*it); - menu[pos].setToken( ss.str().c_str() ); - menu[pos].setLabel( ss.str().c_str() ); - } - } - - if ( !pos ) - { - menu[0].setToken( "" ); - menu[0].setLabel( "< No Version >" ); - pos++; - } - - // mark the end of our menu - menu[pos].setToken( 0 ); -} - -template -int ParameterisedHolder::reloadClassCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - ParameterisedHolder *holder = reinterpret_cast*>( data ); - if ( !holder ) - { - return 0; - } - - UT_String value; - holder->evalString( value, pParameterisedClassCategory.getToken(), 0, 0 ); - std::string category( value.toStdString() ); - - holder->evalString( value, pParameterisedClassName.getToken(), 0, 0 ); - std::string className( value.toStdString() ); - - holder->evalString( value, pParameterisedVersion.getToken(), 0, 0 ); - int version = -1; - if ( value != "" ) - { - version = boost::lexical_cast( value.buffer() ); - } - - holder->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - size_t divider = holder->m_loadedClassName.rfind( "/" ); - if ( holder->m_loadedClassName != "" && divider != std::string::npos && category != holder->m_loadedClassName.substr( 0, divider ) ) - { - className = ""; - } - - if ( className != holder->m_loadedClassName ) - { - version = -1; - } - - if ( className == "" ) - { - version = -1; - holder->setParameterised( 0 ); - } - else if ( version == -1 ) - { - version = defaultClassVersion( className, searchPathEnvVar ); - holder->setString( boost::lexical_cast( version ).c_str(), CH_STRING_LITERAL, pParameterisedVersion.getToken(), 0, 0 ); - } - - holder->load( className, version, searchPathEnvVar ); - - return 1; -} - -template -int ParameterisedHolder::reloadButtonCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - ParameterisedHolder *holder = reinterpret_cast*>( data ); - if ( !holder ) - { - return 0; - } - - UT_String value; - holder->evalString( value, pParameterisedClassName.getToken(), 0, 0 ); - std::string className( value.toStdString() ); - - holder->evalString( value, pParameterisedVersion.getToken(), 0, 0 ); - int version = -1; - if ( value != "" ) - { - version = boost::lexical_cast( value.buffer() ); - } - - holder->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - CoreHoudini::evalPython( "IECore.ClassLoader.defaultLoader( \"" + searchPathEnvVar + "\" ).refresh()" ); - holder->load( className, version, searchPathEnvVar ); - - return 1; -} - -template -const char *ParameterisedHolder::inputLabel( unsigned pos ) const -{ - if ( (int)pos > (int)m_inputParameters.size() - 1 ) - { - return ""; - } - - const Parameter *parm = m_inputParameters[pos].get(); - return ( parm->name() + ": " + parm->description() ).c_str(); -} - -template -unsigned ParameterisedHolder::minInputs() const -{ - /// \todo: need to check for 'required' inputs and increase this number accordingly - return 0; -} - -template -unsigned ParameterisedHolder::maxInputs() const -{ - // this makes sure when we first load we have 4 inputs - // the wires get connected before the Op is loaded onto the node - if ( !m_parameterised || m_inputParameters.size() > 4 ) - { - return 4; - } - - return m_inputParameters.size(); -} - -template -bool ParameterisedHolder::setNodeValues() -{ - RunTimeTypedPtr parameterised = getParameterised(); - if ( !parameterised ) - { - return false; - } - - IECore::MessageHandler::Scope handlerScope( getMessageHandler() ); - - UT_String path; - this->getFullPath( path ); - std::string cmd = "IECoreHoudini.FnParameterisedHolder( hou.node( \""; - cmd += path.buffer(); - cmd += "\") )"; - { - IECorePython::ScopedGILLock lock; - try - { - handle<> resultHandle( PyRun_String( cmd.c_str(), Py_eval_input, CoreHoudini::globalContext().ptr(), CoreHoudini::globalContext().ptr() ) ); - object fn( resultHandle ); - fn.attr( "updateParameters" )( parameterised ); - } - catch( ... ) - { - PyErr_Print(); - } - } - - return true; -} - -template -void ParameterisedHolder::setParameterisedValues( double time ) -{ - IECore::ParameterisedInterface *parameterised = getParameterisedInterface(); - if ( !parameterised ) - { - return; - } - - // push the input values into the associated parameters - setInputParameterValues( time ); - - // update the remaining parameters to match the node values - updateParameter( parameterised->parameters(), time, "", true ); -} - -template -bool ParameterisedHolder::hasParameterised() -{ - return (bool)(m_parameterised.get() != 0); -} - -template -void ParameterisedHolder::setParameterised( IECore::RunTimeTypedPtr p ) -{ - this->setString( "", CH_STRING_LITERAL, pParameterisedClassName.getToken(), 0, 0 ); - this->setString( boost::lexical_cast( -1 ).c_str(), CH_STRING_LITERAL, pParameterisedVersion.getToken(), 0, 0 ); - - m_parameterised = p; - m_loadedClassName = ""; - - refreshInputConnections(); -} - -template -void ParameterisedHolder::setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ) -{ - size_t divider = className.rfind( "/" ); - std::string category = ( divider == std::string::npos ) ? "" : className.substr( 0, divider ); - this->setString( category.c_str(), CH_STRING_LITERAL, pParameterisedClassCategory.getToken(), 0, 0 ); - this->setString( className.c_str(), CH_STRING_LITERAL, pParameterisedClassName.getToken(), 0, 0 ); - this->setString( boost::lexical_cast( classVersion ).c_str(), CH_STRING_LITERAL, pParameterisedVersion.getToken(), 0, 0 ); - this->setString( searchPathEnvVar.c_str(), CH_STRING_LITERAL, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - - m_parameterised = loadParameterised( className, classVersion, searchPathEnvVar ); - m_loadedClassName = m_parameterised ? className : ""; - - refreshInputConnections(); -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::getParameterised() -{ - return m_parameterised; -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::loadParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ) -{ - IECorePython::ScopedGILLock gilLock; - - std::string pythonCmd = boost::str( boost::format( "IECore.ClassLoader.defaultLoader( \"%s\" ).load( \"%s\", %d )()\n" ) % searchPathEnvVar % className % classVersion ); - - try - { - boost::python::handle<> resultHandle( PyRun_String( pythonCmd.c_str(), Py_eval_input, CoreHoudini::globalContext().ptr(), CoreHoudini::globalContext().ptr() ) ); - boost::python::object result( resultHandle ); - return boost::python::extract( result )(); - } - catch( ... ) - { - PyErr_Print(); - } - - return 0; -} - -template -void ParameterisedHolder::load( const std::string &className, int classVersion, const std::string &searchPathEnvVar, bool updateGui ) -{ - RunTimeTypedPtr parameterised = 0; - if ( className != "" && classVersion != -1 && searchPathEnvVar != "" ) - { - setParameterised( className, classVersion, searchPathEnvVar ); - parameterised = getParameterised(); - m_loadedClassName = className; - } - - if ( !parameterised ) - { - m_loadedClassName = ""; - m_inputParameters.clear(); - this->addError( SOP_MESSAGE, "ParameterisedHolder has no parameterised class to operate on!" ); - } - - m_dirty = true; - - if ( !updateGui ) - { - return; - } - - setNodeValues(); -} - -template -bool ParameterisedHolder::load( UT_IStream &is, const char *ext, const char *path ) -{ - bool loaded = OP_Node::load( is, ext, path ); - - UT_String value; - this->evalString( value, pParameterisedClassName.getToken(), 0, 0 ); - std::string className( value.toStdString() ); - - this->evalString( value, pParameterisedVersion.getToken(), 0, 0 ); - int version = -1; - if ( value != "" ) - { - version = boost::lexical_cast( value.buffer() ); - } - - this->evalString( value, pParameterisedSearchPathEnvVar.getToken(), 0, 0 ); - std::string searchPathEnvVar( value.toStdString() ); - - if ( className != "" && version != -1 && searchPathEnvVar != "" ) - { - load( className, version, searchPathEnvVar, false ); - } - - /// \todo: not entirely certain this is returning the correct thing - return loaded; -} - -template -void ParameterisedHolder::updateParameter( ParameterPtr parm, float now, std::string prefix, bool top_level ) -{ - try - { - // find out our parameter name - std::string parm_name = prefix + std::string( parm->name() ); - - // compoundParameters - recursively calling updateParameter on children - if ( parm->isInstanceOf( IECore::CompoundParameterTypeId ) ) - { - if ( top_level==true ) - { - // only our top-level compound parameter should apply the generic prefix - parm_name = "parm_"; - } - else - { - parm_name += "_"; - } - - IECore::CompoundParameterPtr compound = IECore::runTimeCast(parm); - if ( parm ) - { - const CompoundParameter::ParameterMap &childParms = compound->parameters(); - for( CompoundParameter::ParameterMap::const_iterator it=childParms.begin(); it != childParms.end(); it++ ) - { - updateParameter( it->second, now, parm_name ); - } - } - return; - } - - // check we can find the parameter on our Houdini node - if ( !this->getParmList()->getParmPtr( parm_name.c_str() ) ) - { - return; - } - - // does this parameter cause a gui refresh? - bool do_update = true; - if( CompoundObjectPtr uiData = parm->userData()->member( "UI" ) ) - { - if( BoolDataPtr update_data = uiData->member( "update" ) ) - { - do_update = update_data->readable(); - } - } - - // handle the different parameter types - switch( parm->typeId() ) - { - // int parameter - case IECore::IntParameterTypeId: - { - int val = static_cast( parm->defaultValue() )->readable(); - - // horrible hack to accomodate Houdini's MenuParmTemplate for IntParameters - // We really need ParameterHandlers in c++ and Houdini really needs to - // support proper menus on any ParmTemplate. - if ( parm->presetsOnly() ) - { - UT_String hStr; - this->evalString( hStr, parm_name.c_str(), 0, now ); - if ( !hStr.isInteger() ) - { - throw IECore::InvalidArgumentException( "Attempt to set IntParameter " + parm->name() + " to a non-int value " + hStr.toStdString() ); - } - - val = hStr.toInt(); - } - else - { - val = this->evalInt( parm_name.c_str(), 0, now ); - } - - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::IntData(val) ); - break; - } - - // V2f parameter - case IECore::V2iParameterTypeId: - { - int vals[2]; - for ( unsigned int i=0; i<2; i++ ) - vals[i] = this->evalInt( parm_name.c_str(), i, now ); - Imath::V2i val(vals[0], vals[1]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V2iData(val) ); - break; - } - - // V3i parameter - case IECore::V3iParameterTypeId: - { - int vals[3]; - for ( unsigned int i=0; i<3; i++ ) - vals[i] = this->evalInt( parm_name.c_str(), i, now ); - Imath::V3i val(vals[0], vals[1], vals[2]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V3iData(val) ); - break; - } - - // float parameter - case IECore::FloatParameterTypeId: - { - float val = this->evalFloat( parm_name.c_str(), 0, now ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::FloatData(val) ); - break; - } - - // V2f parameter - case IECore::V2fParameterTypeId: - { - float vals[2]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::V2f val(vals[0], vals[1]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V2fData(val) ); - break; - } - - // V3f parameter - case IECore::V3fParameterTypeId: - { - float vals[3]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::V3f val(vals[0], vals[1], vals[2]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V3fData(val) ); - break; - } - - // double parameter - case IECore::DoubleParameterTypeId: - { - float val = this->evalFloat( parm_name.c_str(), 0, now ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::DoubleData(val) ); - break; - } - - // V2d parameter - case IECore::V2dParameterTypeId: - { - float vals[2]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::V2d val(vals[0], vals[1]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V2dData(val) ); - break; - } - - // V3d parameter - case IECore::V3dParameterTypeId: - { - float vals[3]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::V3d val(vals[0], vals[1], vals[2]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::V3dData(val) ); - break; - } - - // bool parameter - case IECore::BoolParameterTypeId: - { - bool val = (bool)this->evalInt( parm_name.c_str(), 0, now ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::BoolData(val) ); - break; - } - - // string parameter - case IECore::StringParameterTypeId: - case IECore::ValidatedStringParameterTypeId: - case IECore::PathParameterTypeId: - case IECore::DirNameParameterTypeId: - case IECore::FileNameParameterTypeId: - case IECore::FileSequenceParameterTypeId: - { - UT_String h_str; - this->evalString( h_str, parm_name.c_str(), 0, now ); - std::string val( h_str.buffer() ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::StringData(val) ); - break; - } - - // colour 3f parameter - case IECore::Color3fParameterTypeId: - { - float vals[3]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Color3f val( vals[0], vals[1], vals[2] ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Color3fData( val ) ); - break; - } - - // colour 4f parameter - case IECore::Color4fParameterTypeId: - { - float vals[4]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Color4f val( vals[0], vals[1], vals[2], vals[3] ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Color4fData( val ) ); - break; - } - - // M44f - case IECore::M44fParameterTypeId: - { - float vals[16]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::M44f val(vals[0], vals[1], vals[2], vals[3], - vals[4], vals[5], vals[6], vals[7], - vals[8], vals[9], vals[10], vals[11], - vals[12], vals[13], vals[14], vals[15]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::M44fData(val) ); - break; - } - - // M44d - case IECore::M44dParameterTypeId: - { - float vals[16]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::M44d val(vals[0], vals[1], vals[2], vals[3], - vals[4], vals[5], vals[6], vals[7], - vals[8], vals[9], vals[10], vals[11], - vals[12], vals[13], vals[14], vals[15]); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::M44dData(val) ); - break; - } - - // Box2i - case IECore::Box2iParameterTypeId: - { - int vals[4]; - for ( unsigned int i=0; i<4; i++ ) - vals[i] = this->evalInt( parm_name.c_str(), i, now ); - Imath::Box2i val( Imath::V2i( vals[0], vals[1] ), - Imath::V2i( vals[2], vals[3] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box2iData(val) ); - break; - } - - // Box2f - case IECore::Box2fParameterTypeId: - { - float vals[4]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Box2f val( Imath::V2f( vals[0], vals[1] ), - Imath::V2f( vals[2], vals[3] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box2fData(val) ); - break; - } - - // Box2d - case IECore::Box2dParameterTypeId: - { - float vals[4]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Box2d val( Imath::V2d( vals[0], vals[1] ), - Imath::V2d( vals[2], vals[3] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box2dData(val) ); - break; - } - - // Box3i - case IECore::Box3iParameterTypeId: - { - int vals[6]; - for ( unsigned int i=0; i<6; i++ ) - vals[i] = this->evalInt( parm_name.c_str(), i, now ); - Imath::Box3i val( Imath::V3i( vals[0], vals[1], vals[2] ), - Imath::V3i( vals[3], vals[4], vals[5] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box3iData(val) ); - break; - } - - // Box3f - case IECore::Box3fParameterTypeId: - { - float vals[6]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Box3f val( Imath::V3f( vals[0], vals[1], vals[2] ), - Imath::V3f( vals[3], vals[4], vals[5] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box3fData(val) ); - break; - } - - // Box3d - case IECore::Box3dParameterTypeId: - { - float vals[6]; - this->evalFloats( parm_name.c_str(), vals, now ); - Imath::Box3d val( Imath::V3d( vals[0], vals[1], vals[2] ), - Imath::V3d( vals[3], vals[4], vals[5] ) ); - checkForUpdate( do_update, val, parm ); - parm->setValue( new IECore::Box3dData(val) ); - break; - } - - // Compound - case IECore::CompoundParameterTypeId: - { - IECore::msg( IECore::Msg::Warning, "ParameterisedHolder::updateParameter", "todo: need to add code to evaluate compoundParameters and it's children." ); - break; - } - - default: - IECore::msg( IECore::Msg::Warning, "ParameterisedHolder::updateParameter", "Could not get parameter values from '" + parm_name + "' of type " + parm->typeName() ); - break; - } - } - catch( const std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "ParameterisedHolder::updateParameter", e.what() ); - } - catch( ... ) - { - IECore::msg( IECore::Msg::Error, "ParameterisedHolder::updateParameter", "Caught unknown exception" ); - } -} - -template -IECore::MessageHandler *ParameterisedHolder::getMessageHandler() -{ - return m_messageHandler.get(); -} - -template -void ParameterisedHolder::setMessageHandler( IECore::MessageHandler *handler ) -{ - m_messageHandler = handler; -} - -template -void ParameterisedHolder::classNames( const std::string searchPathEnvVar, const std::string &matchString, std::vector &names ) -{ - IECorePython::ScopedGILLock lock; - std::vector classNames; - try - { - std::string pythonCmd = boost::str( boost::format( "IECore.ClassLoader.defaultLoader( \"%s\" ).classNames(\"%s\")" ) % searchPathEnvVar % matchString ); - object result = CoreHoudini::evalPython( pythonCmd ); - boost::python::list extractedNames = extract( result )(); - - names.clear(); - for ( unsigned i=0; i < extractedNames.attr( "__len__" )(); i++ ) - { - names.push_back( extract( extractedNames[i] ) ); - } - } - catch( ... ) - { - PyErr_Print(); - } -} - -template -void ParameterisedHolder::classVersions( const std::string className, const std::string searchPathEnvVar, std::vector &versions ) -{ - IECorePython::ScopedGILLock lock; - try - { - std::string pythonCmd = boost::str( boost::format( "IECore.ClassLoader.defaultLoader( \"%s\" ).versions( \"%s\" )" ) % searchPathEnvVar % className ); - object result = CoreHoudini::evalPython( pythonCmd ); - boost::python::list extractedVersions = extract( result )(); - - versions.clear(); - for ( unsigned i=0; i < extractedVersions.attr( "__len__" )(); i++ ) - { - versions.push_back( extract( extractedVersions[i] ) ); - } - } - catch( ... ) - { - PyErr_Print(); - } -} - -template -int ParameterisedHolder::defaultClassVersion( const std::string className, const std::string searchPathEnvVar ) -{ - std::vector versions; - classVersions( className, searchPathEnvVar, versions ); - - return versions.empty() ? -1 : versions[versions.size()-1]; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Known Specializations -////////////////////////////////////////////////////////////////////////////////////////// - -namespace IECoreHoudini -{ - template class ParameterisedHolder; - template class ParameterisedHolder; - template class ParameterisedHolder; -} diff --git a/src/IECoreHoudini/ParameterisedHolderInterface.cpp b/src/IECoreHoudini/ParameterisedHolderInterface.cpp deleted file mode 100644 index 631aadc069..0000000000 --- a/src/IECoreHoudini/ParameterisedHolderInterface.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ParameterisedHolderInterface.h" - -#include "IECore/Object.h" -#include "IECore/ParameterisedInterface.h" - -using namespace IECoreHoudini; - -ParameterisedHolderInterface::ParameterisedHolderInterface() -{ -} - -ParameterisedHolderInterface::~ParameterisedHolderInterface() -{ -} - -IECore::ParameterisedInterface *ParameterisedHolderInterface::getParameterisedInterface() -{ - return dynamic_cast( getParameterised().get() ); -} diff --git a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp b/src/IECoreHoudini/ROP_SceneCacheWriter.cpp deleted file mode 100644 index c4e058cd9a..0000000000 --- a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp +++ /dev/null @@ -1,583 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ROP_SceneCacheWriter.h" - -#include "IECoreHoudini/Convert.h" - -#include "IECoreScene/LinkedScene.h" - -#include "GA/GA_Names.h" -#include "GU/GU_Detail.h" -#include "OBJ/OBJ_Node.h" -#include "OP/OP_Bundle.h" -#include "OP/OP_Director.h" -#include "PRM/PRM_Include.h" -#include "PRM/PRM_Parm.h" -#include "PRM/PRM_SpareData.h" -#include "ROP/ROP_Error.h" -#include "SOP/SOP_Node.h" -#include "UT/UT_Interrupt.h" -#include "UT/UT_StringMMPattern.h" -#include "UT/UT_ValArray.h" - -#include "boost/filesystem/path.hpp" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -const char *ROP_SceneCacheWriter::typeName = "ieSceneCacheWriter"; - -ROP_SceneCacheWriter::ROP_SceneCacheWriter( OP_Network *net, const char *name, OP_Operator *op ) - : ROP_Node( net, name, op ), m_liveHoudiniScene( 0 ), m_liveScene( 0 ), m_outScene( 0 ), m_forceFilter( 0 ), m_startTime( 0 ), m_endTime( 0 ) -{ -} - -ROP_SceneCacheWriter::~ROP_SceneCacheWriter() -{ - delete m_forceFilter; -} - -OP_Node *ROP_SceneCacheWriter::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new ROP_SceneCacheWriter( net, name, op ); -} - -PRM_Name ROP_SceneCacheWriter::pFile( "file", "File" ); -PRM_Name ROP_SceneCacheWriter::pRootObject( "rootObject", "Root Object" ); -PRM_Name ROP_SceneCacheWriter::pForceObjects( "forceObjects", "Force Objects" ); - -PRM_Default ROP_SceneCacheWriter::fileDefault( 0, "$HIP/output.scc" ); -PRM_Default ROP_SceneCacheWriter::rootObjectDefault( 0, "/obj" ); -PRM_SpareData ROP_SceneCacheWriter::forceObjectsSpareData; - -const SceneInterface::Name &ROP_SceneCacheWriter::changingHierarchyAttribute( "sceneInterface:changingHierarchy" ); - -OP_TemplatePair *ROP_SceneCacheWriter::buildParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - PRM_Template *baseTemplate = ROP_Node::getROPbaseTemplate(); - PRM_Template *scriptTemplate = ROP_Node::getROPscriptTemplate(); - - unsigned numBaseParms = PRM_Template::countTemplates( baseTemplate ); - unsigned numScriptParms = PRM_Template::countTemplates( scriptTemplate ); - - thisTemplate = new PRM_Template[ numBaseParms + numScriptParms + 4 ]; - - // add the ROP base parms - unsigned totalParms = 0; - for ( unsigned i = 0; i < numBaseParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = baseTemplate[i]; - } - - // add the SceneCache parms - thisTemplate[totalParms] = PRM_Template( - PRM_FILE, 1, &pFile, &fileDefault, 0, 0, 0, 0, 0, - "An SCC file to write, based on the Houdini hierarchy defined by the Root Object provided." - ); - totalParms++; - - thisTemplate[totalParms] = PRM_Template( - PRM_STRING, PRM_TYPE_DYNAMIC_PATH, 1, &pRootObject, &rootObjectDefault, 0, 0, 0, - &PRM_SpareData::objPath, 0, "The node to use as the root of the SceneCache" - ); - totalParms++; - - forceObjectsSpareData.copyFrom( PRM_SpareData::objPath ); - forceObjectsSpareData.setOpRelative( "/obj" ); - thisTemplate[totalParms] = PRM_Template( - PRM_STRING, PRM_TYPE_DYNAMIC_PATH_LIST, 1, &pForceObjects, 0, 0, 0, 0, - &forceObjectsSpareData, 0, "Optional list of nodes to force as expanded objects. " - "If this list is used, then links will be stored for any node not listed." - ); - totalParms++; - - // add the ROP script parms - for ( unsigned i = 0; i < numScriptParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = scriptTemplate[i]; - } - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -int ROP_SceneCacheWriter::startRender( int nframes, fpreal s, fpreal e ) -{ - UT_String nodePath; - evalString( nodePath, pRootObject.getToken(), 0, 0 ); - OP_Node* node = this->findNode( nodePath ); - UT_String actualNodePath( node->getFullPath() ); - - UT_String value; - evalString( value, pFile.getToken(), 0, 0 ); - std::string file = value.toStdString(); - - try - { - SceneInterface::Path emptyPath; - m_liveHoudiniScene = new IECoreHoudini::LiveScene( actualNodePath, emptyPath, emptyPath, s + CHgetManager()->getSecsPerSample() ); - // wrapping with a LinkedScene to ensure full expansion when writing the non-linked file - if ( linked( file ) ) - { - m_liveScene = m_liveHoudiniScene; - } - else - { - m_liveScene = new LinkedScene( m_liveHoudiniScene ); - } - } - catch ( IECore::Exception &e ) - { - addError( ROP_MESSAGE, e.what() ); - return false; - } - - try - { - m_outScene = SceneInterface::create( file, IndexedIO::Write ); - } - catch ( IECore::Exception &e ) - { - addError( ROP_MESSAGE, ( "Could not create a writable IECoreScene::SceneInterface at \"" + file + "\"" ).c_str() ); - return false; - } - - UT_String forceObjects; - evalString( forceObjects, pForceObjects.getToken(), 0, 0 ); - - m_forceFilter = 0; - if ( linked( file ) && !forceObjects.equal( "" ) ) - { - // get the list of nodes matching the filter - const PRM_SpareData *data = getParm( pForceObjects.getToken() ).getSparePtr(); - OBJ_Node *baseNode = OPgetDirector()->findNode( data->getOpRelative() )->castToOBJNode(); - OP_Bundle *bundle = getParmBundle( pForceObjects.getToken(), 0, forceObjects, baseNode, data->getOpFilter() ); - - // add all of the parent nodes - UT_ValArray nodes; - bundle->getMembers( nodes ); - size_t numNodes = nodes.entries(); - for ( size_t i = 0; i < numNodes; ++i ) - { - OP_Node *current = nodes( i )->getParent(); - while ( current ) - { - bundle->addOp( current ); - current = current->getParent(); - } - } - - // build a matchable filter from all these nodes - UT_WorkBuffer buffer; - bundle->buildString( buffer ); - buffer.copyIntoString( forceObjects ); - m_forceFilter = new UT_StringMMPattern(); - m_forceFilter->compile( forceObjects ); - } - - // We need to adjust the time for writing, because Houdini treats time starting - // at Frame 1, while SceneInterfaces treat time starting at Frame 0. - m_startTime = s + CHgetManager()->getSecsPerSample(); - m_endTime = e + CHgetManager()->getSecsPerSample(); - - return true; -} - -ROP_RENDER_CODE ROP_SceneCacheWriter::renderFrame( fpreal time, UT_Interrupt *boss ) -{ - // We need to adjust the time for writing, because Houdini treats time starting - // at Frame 1, while SceneInterfaces treat time starting at Frame 0. - double writeTime = time + CHgetManager()->getSecsPerSample(); - - // the interruptor passed in is null for some reason, so just get the global one - UT_Interrupt *progress = UTgetInterrupt(); - if ( !progress->opStart( ( boost::format( "Writing Houdini time %f as SceneCache time %f" ) % time % writeTime ).str().c_str() ) ) - { - addError( 0, "Cache aborted" ); - return ROP_ABORT_RENDER; - } - - executePreFrameScript( time ); - - // update the default evaluation time to avoid double cooking - m_liveHoudiniScene->setDefaultTime( writeTime ); - - SceneInterfacePtr outScene = m_outScene; - - // we need to re-root the scene if its trying to cache a top level object - UT_String nodePath; - evalString( nodePath, pRootObject.getToken(), 0, 0 ); - OBJ_Node *node = this->findNode( nodePath )->castToOBJNode(); - if ( node && node->getObjectType() == OBJ_GEOMETRY ) - { - bool reRoot = true; - OP_Context context( time ); - if ( const GU_Detail *geo = node->getRenderGeometry( context, false ) ) - { - GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if ( nameAttrib.isValid() ) - { - reRoot = false; - GA_StringTableStatistics stats; - const GA_Attribute *nameAttr = nameAttrib.getAttribute(); - const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); - tuple->getStatistics( nameAttr, stats ); - GA_Size numShapes = stats.getEntries(); - if ( numShapes == 0 ) - { - reRoot = true; - } - else if ( numShapes == 1 ) - { - GA_Size numStrings = stats.getCapacity(); - for ( GA_Size i=0; i < numStrings; ++i ) - { - GA_StringIndexType validatedIndex = tuple->validateTableHandle( nameAttr, i ); - if ( validatedIndex < 0 ) - { - continue; - } - - const char *name = tuple->getTableString( nameAttr, validatedIndex ); - if( ( name == 0 ) || ( !strcmp( name, "" ) || !strcmp( name, "/" ) ) ) - { - reRoot = true; - } - } - } - } - } - else - { - UT_String msg; - std::string messages = "Re-rooting flat geo failed."; - node->getErrorMessages( msg ); - if ( msg != UT_String::getEmptyString() ) - { - messages += "\n\nErrors from " + nodePath.toStdString() + ":\n" + msg.toStdString(); - } - - if ( SOP_Node *sop = node->getRenderSopPtr() ) - { - sop->getErrorMessages( msg ); - if ( msg != UT_String::getEmptyString() ) - { - sop->getFullPath( nodePath ); - messages += "\n\nErrors from " + nodePath.toStdString() + ":\n" + msg.toStdString(); - } - } - - addError( 0, messages.c_str() ); - progress->opEnd(); - return ROP_ABORT_RENDER; - } - - if ( reRoot ) - { - outScene = m_outScene->child( node->getName().toStdString(), SceneInterface::CreateIfMissing ); - } - } - - ROP_RENDER_CODE status = doWrite( m_liveScene.get(), outScene.get(), writeTime, progress ); - if ( status != ROP_ABORT_RENDER ) - { - executePostFrameScript( time ); - } - - progress->opEnd(); - return status; -} - -ROP_RENDER_CODE ROP_SceneCacheWriter::endRender() -{ - m_liveHoudiniScene = 0; - m_liveScene = 0; - m_outScene = 0; - - return ROP_CONTINUE_RENDER; -} - -ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, SceneInterface *outScene, double time, UT_Interrupt *progress ) -{ - SceneInterface::Path p; - std::string strPath; - liveScene->path( p ); - SceneInterface::pathToString( p, strPath ); - - progress->setLongOpText( ( "Writing " + liveScene->name().string() ).c_str() ); - if ( progress->opInterrupt() ) - { - addError( 0, ( "Cache aborted during " + liveScene->name().string() ).c_str() ); - return ROP_ABORT_RENDER; - } - - if ( liveScene != m_liveScene ) - { - outScene->writeTransform( liveScene->readTransform( time ).get(), time ); - } - - Mode mode = NaturalExpand; - const LiveScene *hScene = IECore::runTimeCast( liveScene ); - if ( hScene && m_forceFilter ) - { - UT_String nodePath; - hScene->node()->getFullPath( nodePath ); - mode = ( nodePath.multiMatch( *m_forceFilter ) ) ? ForcedExpand : ForcedLink; - } - - SceneInterface::NameList attrs; - liveScene->attributeNames( attrs ); - for ( SceneInterface::NameList::iterator it = attrs.begin(); it != attrs.end(); ++it ) - { - if ( *it == LinkedScene::linkAttribute ) - { - if ( mode == ForcedExpand ) - { - continue; - } - - mode = NaturalLink; - } - - if ( ConstObjectPtr data = liveScene->readAttribute( *it, time ) ) - { - outScene->writeAttribute( *it, data.get(), time ); - } - } - - if ( mode == ForcedLink ) - { - if ( const SceneCacheNode *sceneNode = static_cast< const SceneCacheNode* >( hScene->node() ) ) - { - if ( ConstSceneInterfacePtr scene = sceneNode->scene() ) - { - outScene->writeAttribute( LinkedScene::linkAttribute, LinkedScene::linkAttributeData( scene.get(), time ).get(), time ); - return ROP_CONTINUE_RENDER; - } - } - } - - if ( mode == NaturalLink ) - { - return ROP_CONTINUE_RENDER; - } - - SceneInterface::NameList tags; - try - { - liveScene->readTags( tags ); - } - catch ( std::runtime_error &e ) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Error reading tags for location %1% See below for more details.\n%2%") % strPath % e.what() - ).c_str() - ); - return ROP_ABORT_RENDER; - } - outScene->writeTags( tags ); - - bool hasObject = false; - - try - { - hasObject = liveScene->hasObject(); - } - catch( const IECore::Exception &e ) - { - addError( ROP_MESSAGE, e.what() ); - } - - if( hasObject ) - { - try - { - auto srcObject = liveScene->readObject( time ); - if ( !srcObject ) - { - addError( ROP_MESSAGE, boost::str( boost::format("unable to convert '%1%'") % strPath).c_str() ); - } - outScene->writeObject( srcObject.get(), time ); - } - catch ( IECore::Exception &e ) - { - addError( ROP_MESSAGE, e.what() ); - return ROP_ABORT_RENDER; - } - catch ( std::runtime_error &e ) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Error reading object for location %1% See below for more details.\n%2%") % strPath % e.what() - ).c_str() - - ); - return ROP_ABORT_RENDER; - } - } - - SceneInterface::NameList children; - liveScene->childNames( children ); - for ( SceneInterface::NameList::iterator it = children.begin(); it != children.end(); ++it ) - { - ConstSceneInterfacePtr liveChild = liveScene->child( *it ); - - SceneInterfacePtr outChild = 0; - if ( outScene->hasChild( *it ) ) - { - outChild = outScene->child( *it ); - } - else - { - outChild = outScene->createChild( *it ); - - if ( time != m_startTime ) - { - try - { - outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); - outChild->writeAttribute( IECoreScene::SceneInterface::visibilityName, new BoolData( false ), time - 1e-6 ); - } - catch( const std::exception &e) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Name prim attribute (locations) are changing over time. Are the names consistent between time samples? See below for more details.\n%1%") % e.what() - ).c_str() - ); - return ROP_ABORT_RENDER; - } - } - } - - if ( outChild->hasAttribute( changingHierarchyAttribute ) ) - { - try - { - outChild->writeAttribute( IECoreScene::SceneInterface::visibilityName, new BoolData( true ), time ); - } - catch( const std::exception &e) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Name prim attribute (locations) are changing over time. Are the names consistent between time samples? See below for more details\n%1%") % e.what() - ).c_str() - ); - return ROP_ABORT_RENDER; - } - } - - ROP_RENDER_CODE status = doWrite( liveChild.get(), outChild.get(), time, progress ); - if ( status != ROP_CONTINUE_RENDER ) - { - return status; - } - } - - // turn visibility off if the child disappears - SceneInterface::NameList outChildren; - outScene->childNames( outChildren ); - for ( SceneInterface::NameList::iterator it = outChildren.begin(); it != outChildren.end(); ++it ) - { - if ( !liveScene->hasChild( *it ) ) - { - SceneInterfacePtr outChild = outScene->child( *it ); - if ( !outChild->hasAttribute( IECoreScene::SceneInterface::visibilityName ) ) - { - try - { - outChild->writeAttribute( IECoreScene::SceneInterface::visibilityName, new BoolData( true ), time - 1e-6 ); - } - catch( const std::exception &e) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Name prim attribute (locations) are changing over time. Are the names consistent between time samples? See below for more details\n%1%") % e.what() - ).c_str() - ); - return ROP_ABORT_RENDER; - } - } - - try - { - outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); - outChild->writeAttribute( IECoreScene::SceneInterface::visibilityName, new BoolData( false ), time ); - } - catch( const std::exception &e) - { - addError( ROP_MESSAGE, - boost::str( - boost::format( - "ROP Scene Cache Writer: Name prim attribute (locations) are changing over time. Are the names consistent between time samples? See below for more details\n%1%" ) % e.what() - ).c_str() - ); - return ROP_ABORT_RENDER; - } - } - } - - return ROP_CONTINUE_RENDER; -} - -bool ROP_SceneCacheWriter::updateParmsFlags() -{ - UT_String value; - evalString( value, pFile.getToken(), 0, 0 ); - std::string file = value.toStdString(); - enableParm( pForceObjects.getToken(), linked( file ) ); - return true; -} - -bool ROP_SceneCacheWriter::linked( const std::string &file ) const -{ - return ( boost::filesystem::path( file ).extension().string() == ".lscc" ); -} diff --git a/src/IECoreHoudini/SOP_CortexConverter.cpp b/src/IECoreHoudini/SOP_CortexConverter.cpp deleted file mode 100644 index 0974e8ce65..0000000000 --- a/src/IECoreHoudini/SOP_CortexConverter.cpp +++ /dev/null @@ -1,266 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SOP_CortexConverter.h" - -#include "IECoreHoudini/DetailSplitter.h" -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" - -#include "IECoreScene/Group.h" -#include "IECoreScene/WorldBlock.h" - -#include "OP/OP_NodeInfoParms.h" -#include "PRM/PRM_ChoiceList.h" -#include "PRM/PRM_Default.h" -#include "UT/UT_Interrupt.h" -#include "UT/UT_StringMMPattern.h" - -using namespace IECoreHoudini; - -const char *SOP_CortexConverter::typeName = "ieCortexConverter"; - -PRM_Name SOP_CortexConverter::pNameFilter( "nameFilter", "Name Filter" ); -PRM_Name SOP_CortexConverter::pAttributeFilter( "attributeFilter", "Attribute Filter" ); -PRM_Name SOP_CortexConverter::pResultType( "resultType", "Result Type" ); -PRM_Name SOP_CortexConverter::pConvertStandardAttributes( "convertStandardAttributes", "Convert Standard Attributes" ); - -PRM_Default SOP_CortexConverter::convertStandardAttributesDefault( true ); -PRM_Default SOP_CortexConverter::filterDefault( 0, "*" ); -PRM_Default SOP_CortexConverter::resultTypeDefault( Houdini ); - -static PRM_Name resultTypes[] = { - PRM_Name( "0", "Cortex" ), - PRM_Name( "1", "Houdini" ), - PRM_Name( 0 ) // sentinal -}; - -PRM_ChoiceList SOP_CortexConverter::resultTypeList( PRM_CHOICELIST_SINGLE, resultTypes ); - -PRM_Template SOP_CortexConverter::parameters[] = { - PRM_Template( - PRM_STRING, 1, &pNameFilter, &filterDefault, 0, 0, 0, 0, 0, - "A list of named shapes to convert. Uses Houdini matching syntax." - ), - PRM_Template( - PRM_STRING, 1, &pAttributeFilter, &filterDefault, 0, 0, 0, 0, 0, - "A list of attribute names to load, if they exist on each shape. Uses Houdini matching syntax. " - "P will always be loaded." - ), - PRM_Template( - PRM_INT, 1, &pResultType, &resultTypeDefault, &resultTypeList, 0, 0, 0, 0, - "The type of geometry to output. Shapes matching the name filter will be converted to this type. " - "Shapes that do not match will be passed through." - ), - PRM_Template( - PRM_TOGGLE, 1, &pConvertStandardAttributes, &convertStandardAttributesDefault, 0, 0, 0, 0, 0, - "Performs automated conversion of standard PrimitiveVariables to Houdini Attributes and vice versa (i.e. Pref->rest ; Cs->Cd ; s,t->uv)" - ), - PRM_Template() -}; - -CH_LocalVariable SOP_CortexConverter::variables[] = { - { 0, 0, 0 }, -}; - -OP_Node *SOP_CortexConverter::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new SOP_CortexConverter( net, name, op ); -} - -SOP_CortexConverter::SOP_CortexConverter( OP_Network *net, const char *name, OP_Operator *op ) - : SOP_Node(net, name, op) -{ -} - -SOP_CortexConverter::~SOP_CortexConverter() -{ -} - -OP_ERROR SOP_CortexConverter::cookMySop( OP_Context &context ) -{ - if( lockInputs( context ) >= UT_ERROR_ABORT ) - { - return error(); - } - - UT_Interrupt *boss = UTgetInterrupt(); - boss->opStart("Building CortexConverter Geometry..."); - gdp->clearAndDestroy(); - - UT_String nameFilterStr; - evalString( nameFilterStr, pNameFilter.getToken(), 0, 0 ); - UT_StringMMPattern nameFilter; - nameFilter.compile( nameFilterStr ); - - UT_String p( "P" ); - UT_String attributeFilter; - evalString( attributeFilter, pAttributeFilter.getToken(), 0, 0 ); - if ( !p.match( attributeFilter ) ) - { - attributeFilter += " P"; - } - const std::string attributeFilterStr = attributeFilter.toStdString(); - - ResultType type = (ResultType)this->evalInt( pResultType.getToken(), 0, 0 ); - bool convertStandardAttributes = evalInt( pConvertStandardAttributes.getToken(), 0, 0 ); - - DetailSplitterPtr splitter = new DetailSplitter( inputGeoHandle( 0 ) ); - std::vector names; - splitter->values( names ); - for ( std::vector::const_iterator it = names.begin(); it != names.end(); ++it ) - { - const std::string &name = *it; - - // we want match all to also match no-name - if ( UT_String( name ).multiMatch( nameFilter ) || ( name == "" && UT_String( "*" ).multiMatch( nameFilter ) ) ) - { - doConvert( splitter->split( name ), name, type, attributeFilterStr, convertStandardAttributes ); - } - else - { - doPassThrough( splitter->split( name ), name ); - } - } - - boss->opEnd(); - unlockInputs(); - return error(); -} - -void SOP_CortexConverter::doConvert( const GU_DetailHandle &handle, const std::string &name, ResultType type, const std::string &attributeFilter, bool convertStandardAttributes ) -{ - if ( handle.isNull() ) - { - addError( SOP_MESSAGE, ( "Could not extract the geometry named " + name ).c_str() ); - return; - } - - FromHoudiniGeometryConverterPtr fromConverter = FromHoudiniGeometryConverter::create( handle ); - if ( !fromConverter ) - { - addError( SOP_MESSAGE, ( "Could not convert the geometry named " + name ).c_str() ); - return; - } - - IECore::ObjectPtr result = fromConverter->convert(); - if ( !result ) - { - addError( SOP_MESSAGE, ( "Could not find Cortex Object named " + name + " on input geometry" ).c_str() ); - return; - } - - ToHoudiniGeometryConverterPtr converter = ( type == Cortex ) ? new ToHoudiniCortexObjectConverter( result.get() ) : ToHoudiniGeometryConverter::create( result.get() ); - converter->nameParameter()->setTypedValue( name ); - converter->attributeFilterParameter()->setTypedValue( attributeFilter ); - converter->convertStandardAttributesParameter()->setTypedValue( convertStandardAttributes ); - - if ( !converter->convert( myGdpHandle ) ) - { - addError( SOP_MESSAGE, ( "Could not convert the Cortex Object named " + name + " to Houdini geometry" ).c_str() ); - } -} - -void SOP_CortexConverter::doPassThrough( const GU_DetailHandle &handle, const std::string &name ) -{ - if ( handle.isNull() ) - { - addError( SOP_MESSAGE, ( "Could not pass through the geometry named " + name ).c_str() ); - return; - } - - GU_DetailHandleAutoReadLock readHandle( handle ); - const GU_Detail *inputGeo = readHandle.getGdp(); - if ( !inputGeo ) - { - addError( SOP_MESSAGE, ( "Could not pass through the geometry named " + name ).c_str() ); - return; - } - - gdp->merge( *inputGeo ); -} - -void SOP_CortexConverter::getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ) -{ - SOP_Node::getNodeSpecificInfoText( context, parms ); - - GEO_CortexPrimitive::infoText( getCookedGeo( context ), context, parms ); - - if ( !evalInt( pConvertStandardAttributes.getToken(), 0, 0 ) ) - { - return; - } - - UT_String p( "P" ); - UT_String filter; - evalString( filter, pAttributeFilter.getToken(), 0, 0 ); - if ( !p.match( filter ) ) - { - filter += " P"; - } - UT_StringMMPattern attributeFilter; - attributeFilter.compile( filter ); - - /// \todo: this text could come from a static method on a class that manages these name relations (once that exists) - parms.append( "Converting standard Cortex PrimitiveVariables:\n" ); - if ( UT_String( "s" ).multiMatch( attributeFilter ) && UT_String( "t" ).multiMatch( attributeFilter ) ) - { - parms.append( " s,t <--> uv\n" ); - } - - if ( UT_String( "Cs" ).multiMatch( attributeFilter ) ) - { - parms.append( " Cs <--> Cd\n" ); - } - - if ( UT_String( "Pref" ).multiMatch( attributeFilter ) ) - { - parms.append( " Pref <--> rest\n" ); - } - - if ( UT_String( "width" ).multiMatch( attributeFilter ) ) - { - parms.append( " width <--> pscale\n" ); - } - - if ( UT_String( "Os" ).multiMatch( attributeFilter ) ) - { - parms.append( " Os <--> Alpha\n" ); - } -} diff --git a/src/IECoreHoudini/SOP_OpHolder.cpp b/src/IECoreHoudini/SOP_OpHolder.cpp deleted file mode 100644 index 8718728ce2..0000000000 --- a/src/IECoreHoudini/SOP_OpHolder.cpp +++ /dev/null @@ -1,204 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SOP_OpHolder.h" - -#include "IECoreHoudini/DetailSplitter.h" -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "PRM/PRM_Parm.h" -#include "UT/UT_Interrupt.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -OP_Node *SOP_OpHolder::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new SOP_OpHolder( net, name, op ); -} - -SOP_OpHolder::SOP_OpHolder( OP_Network *net, const char *name, OP_Operator *op ) : SOP_ParameterisedHolder( net, name, op ) -{ - getParm( pParameterisedSearchPathEnvVar.getToken() ).setValue( 0, "IECORE_OP_PATHS", CH_STRING_LITERAL ); -} - -SOP_OpHolder::~SOP_OpHolder() -{ -} - -/// Cook the SOP! This method does all the work -OP_ERROR SOP_OpHolder::cookMySop( OP_Context &context ) -{ - IECore::MessageHandler::Scope handlerScope( getMessageHandler() ); - - // some defaults and useful variables - Imath::Box3f bbox( Imath::V3f(-1,-1,-1), Imath::V3f(1,1,1) ); - float now = context.getTime(); - - // force eval of our nodes parameters with our hidden parameter expression - evalInt( "__evaluateParameters", 0, now ); - - // get our op - IECore::OpPtr op = IECore::runTimeCast( getParameterised() ); - - // check for a valid parameterised on this SOP - if ( !op ) - { - UT_String msg( "Op Holder has no parameterised class to operate on!" ); - addError( SOP_MESSAGE, msg ); - return error(); - } - - if( lockInputs(context)>=UT_ERROR_ABORT ) - { - return error(); - } - - // start our work - UT_Interrupt *boss = UTgetInterrupt(); - boss->opStart("Building OpHolder Geometry..."); - gdp->clearAndDestroy(); - - // update the op parameters - setParameterisedValues( now ); - - // main input is reserved for splitting by name when the filter is enabled - UT_StringMMPattern nameFilter; - if ( !m_inputParameters.empty() && getNameFilter( m_inputParameters[0].get(), nameFilter ) ) - { - DetailSplitterPtr splitter = new DetailSplitter( inputGeoHandle( 0 ) ); - std::vector names; - splitter->values( names ); - for ( std::vector::const_iterator it = names.begin(); it != names.end(); ++it ) - { - const std::string &name = *it; - // we want match all to also match no-name - if ( UT_String( name ).multiMatch( nameFilter ) || ( name == "" && UT_String( "*" ).multiMatch( nameFilter ) ) ) - { - doOperation( op.get(), splitter->split( name ), name ); - } - else - { - doPassThrough( splitter->split( name ), name ); - } - } - } - else - { - doOperation( op.get(), GU_DetailHandle(), "" ); - } - - boss->opEnd(); - unlockInputs(); - return error(); -} - -void SOP_OpHolder::doOperation( IECore::Op *op, const GU_DetailHandle &handle, const std::string &name ) -{ - if ( !m_inputParameters.empty() ) - { - SOP_ParameterisedHolder::setInputParameterValue( m_inputParameters[0].get(), handle, 0 ); - } - - IECore::ConstObjectPtr result = 0; - - try - { - result = op->operate(); - } - catch( boost::python::error_already_set &e ) - { - // \todo: libIECoreHoudini should not use python. Determine if - // this is still required or if the other catch cases are enough. - addError( SOP_MESSAGE, "Error raised during Python evaluation!" ); - IECorePython::ScopedGILLock lock; - PyErr_Print(); - } - catch( const IECore::Exception &e ) - { - addError( SOP_MESSAGE, e.what() ); - } - catch( const std::exception &e ) - { - addError( SOP_MESSAGE, e.what() ); - } - catch( ... ) - { - addError( SOP_MESSAGE, "Caught unknown exception!" ); - } - - if ( result ) - { - ToHoudiniCortexObjectConverterPtr converter = new ToHoudiniCortexObjectConverter( result.get() ); - converter->nameParameter()->setTypedValue( name ); - if ( !converter->convert( myGdpHandle ) ) - { - addError( SOP_MESSAGE, "Unable to store op result on gdp" ); - } - } -} - -void SOP_OpHolder::doPassThrough( const GU_DetailHandle &handle, const std::string &name ) -{ - if ( handle.isNull() ) - { - addError( SOP_MESSAGE, ( "Could not pass through the geometry named " + name ).c_str() ); - return; - } - - GU_DetailHandleAutoReadLock readHandle( handle ); - const GU_Detail *inputGeo = readHandle.getGdp(); - if ( !inputGeo ) - { - addError( SOP_MESSAGE, ( "Could not pass through the geometry named " + name ).c_str() ); - return; - } - - gdp->merge( *inputGeo ); -} - -void SOP_OpHolder::setInputParameterValue( IECore::Parameter *parameter, const GU_DetailHandle &handle, unsigned inputIndex ) -{ - if ( inputIndex == 0 ) - { - return; - } - - SOP_ParameterisedHolder::setInputParameterValue( parameter, handle, inputIndex ); -} diff --git a/src/IECoreHoudini/SOP_ParameterisedHolder.cpp b/src/IECoreHoudini/SOP_ParameterisedHolder.cpp deleted file mode 100644 index 1a687a0705..0000000000 --- a/src/IECoreHoudini/SOP_ParameterisedHolder.cpp +++ /dev/null @@ -1,239 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SOP_ParameterisedHolder.h" - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#include "IECoreScene/Group.h" -#include "IECoreScene/WorldBlock.h" - -#include "IECore/Op.h" - -#include "GA/GA_AIFBlindData.h" - -#include "boost/bind/bind.hpp" - -using namespace boost; -using namespace boost::placeholders; - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -SOP_ParameterisedHolder::SOP_ParameterisedHolder( OP_Network *net, const char *name, OP_Operator *op ) : ParameterisedHolder( net, name, op ) -{ - IECoreHoudini::MessageHandler::HandlerFn errorFn = boost::bind( &SOP_ParameterisedHolder::addError, this, SOP_MESSAGE, _1 ); - IECoreHoudini::MessageHandler::HandlerFn warningFn = boost::bind( &SOP_ParameterisedHolder::addWarning, this, SOP_MESSAGE, _1 ); - IECoreHoudini::MessageHandler::HandlerFn infoFn = boost::bind( &SOP_ParameterisedHolder::addMessage, this, SOP_MESSAGE, _1 ); - IECore::MessageHandlerPtr h = new IECoreHoudini::MessageHandler( errorFn, warningFn, infoFn, infoFn ); - setMessageHandler( h.get() ); -} - -SOP_ParameterisedHolder::~SOP_ParameterisedHolder() -{ -} - -void SOP_ParameterisedHolder::refreshInputConnections() -{ - // store the existing input nodes - unsigned numInputs = nInputs(); - std::vector inputNodes; - for ( unsigned i=0; i < numInputs; i++ ) - { - OP_Node *input = getInput( i ); - if ( !input ) - { - continue; - } - - inputNodes.push_back( input ); - } - - // clear the input parameters and break the node connections - disconnectAllInputs(); - m_inputParameters.clear(); - - ParameterisedInterface *parameterised = getParameterisedInterface(); - if ( !parameterised ) - { - return; - } - - // add inputs for the appropriate parameters - const CompoundParameter::ParameterVector ¶meters = parameterised->parameters()->orderedParameters(); - for ( CompoundParameter::ParameterVector::const_iterator it=parameters.begin(); it!=parameters.end(); it++ ) - { - // adding ObjectParameters explicitly so generic data can be passed through - // ParameterisedHolders even if they don't make particular sense in SOPs. - if ( (*it)->typeId() == ObjectParameterTypeId ) - { - m_inputParameters.push_back( *it ); - } - else - { - const ObjectParameter *objectParam = IECore::runTimeCast( it->get() ); - if ( !objectParam ) - { - continue; - } - - FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( GU_DetailHandle(), objectParam->validTypes() ); - if ( converter ) - { - m_inputParameters.push_back( *it ); - /// \todo: add converter parameters here once ParameterHandlers are defined in c++ - } - } - - /// \todo: try using the messageHandler(). it might not work outside of a cook though... - if ( m_inputParameters.size() > 4 ) - { - std::cerr << "ieParameterisedHolder does not support more than 4 input parameter connections." << std::endl; - } - } - - // remake the connections to inputs that still exist - numInputs = std::min( inputNodes.size(), m_inputParameters.size() ); - for ( unsigned i=0; i < numInputs; i++ ) - { - setInput( i, inputNodes[i] ); - } - - /// \todo: Is this really the only we can get the gui to update the input connections? - setXY( getX()+.0001, getY()+.0001 ); - setXY( getX()-.0001, getY()-.0001 ); -} - -void SOP_ParameterisedHolder::setInputParameterValues( float now ) -{ - for ( unsigned int i=0; i < m_inputParameters.size(); i++ ) - { - useInputSource( i, m_dirty, false ); - - setInputParameterValue( m_inputParameters[i].get(), GU_DetailHandle(), i ); - } -} - -void SOP_ParameterisedHolder::setInputParameterValue( IECore::Parameter *parameter, const GU_DetailHandle &handle, unsigned inputIndex ) -{ - IECore::ObjectParameter *objectParameter = IECore::runTimeCast( parameter ); - if ( !objectParameter ) - { - return; - } - - GU_DetailHandle inputHandle = ( handle.isNull() ) ? filteredInputValue( parameter, inputIndex ) : handle; - FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( inputHandle, objectParameter->validTypes() ); - if ( !converter ) - { - addWarning( SOP_MESSAGE, ( boost::format( "Could not find an appropriate converter for parameter \"%s\" (input %d)" ) % parameter->name() % inputIndex ).str().c_str() ); - return; - } - - // set converter parameters from the node values - const CompoundParameter::ParameterVector &converterParameters = converter->parameters()->orderedParameters(); - for ( CompoundParameter::ParameterVector::const_iterator it=converterParameters.begin(); it != converterParameters.end(); ++it ) - { - updateParameter( *it, 0, "parm_" + parameter->name() + "_" ); - } - - try - { - IECore::ObjectPtr result = converter->convert(); - if ( !result ) - { - return; - } - parameter->setValidatedValue( result ); - } - catch ( const IECore::Exception &e ) - { - addError( SOP_MESSAGE, e.what() ); - } - catch ( std::runtime_error &e ) - { - addError( SOP_MESSAGE, e.what() ); - } -} - -GU_DetailHandle SOP_ParameterisedHolder::filteredInputValue( const IECore::Parameter *parameter, unsigned inputIndex ) -{ - GU_DetailHandle inputHandle = inputGeoHandle( inputIndex ); - GU_DetailHandleAutoReadLock readHandle( inputHandle ); - const GU_Detail *inputGdp = readHandle.getGdp(); - if ( !inputGdp ) - { - return inputHandle; - } - - UT_StringMMPattern nameFilter; - if ( getNameFilter( parameter, nameFilter ) ) - { - GU_DetailHandle filteredGeo = FromHoudiniGeometryConverter::extract( inputGdp, nameFilter ); - if ( !filteredGeo.isNull() ) - { - return filteredGeo; - } - } - - return inputHandle; -} - -bool SOP_ParameterisedHolder::getNameFilter( const IECore::Parameter *parameter, UT_StringMMPattern &filter ) -{ - const std::string useNameFilterParm = "parm_" + parameter->name() + "_useNameFilter"; - const std::string nameFitlerParm = "parm_" + parameter->name() + "_nameFilter"; - if ( hasParm( useNameFilterParm.c_str() ) && hasParm( nameFitlerParm.c_str() ) && evalInt( useNameFilterParm.c_str(), 0, 0 ) ) - { - UT_String filterStr; - evalString( filterStr, nameFitlerParm.c_str(), 0, 0 ); - filter.compile( filterStr ); - return true; - } - - return false; -} - -void SOP_ParameterisedHolder::getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ) -{ - SOP_Node::getNodeSpecificInfoText( context, parms ); - - // add type descriptions for the Cortex Objects - GEO_CortexPrimitive::infoText( getCookedGeo( context ), context, parms ); -} diff --git a/src/IECoreHoudini/SOP_SceneCacheSource.cpp b/src/IECoreHoudini/SOP_SceneCacheSource.cpp deleted file mode 100644 index 37cffa7d21..0000000000 --- a/src/IECoreHoudini/SOP_SceneCacheSource.cpp +++ /dev/null @@ -1,883 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SOP_SceneCacheSource.h" - -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/ToHoudiniStringAttribConverter.h" - -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/Group.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/PointsPrimitive.h" -#include "IECoreScene/TransformOp.h" -#include "IECoreScene/VisibleRenderable.h" - -#include "IECore/DespatchTypedData.h" -#include "IECore/TypeTraits.h" - -#include "Imath/ImathMatrixAlgo.h" - -#include "GA/GA_Names.h" -#include "OP/OP_NodeInfoParms.h" -#include "PRM/PRM_ChoiceList.h" -#include "PRM/PRM_Default.h" -#include "UT/UT_Interrupt.h" -#include "UT/UT_StringMMPattern.h" -#include "UT/UT_WorkArgs.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -static InternedString pName( "P" ); -static InternedString mRefName( "user:Mref" ); - -const char *SOP_SceneCacheSource::typeName = "ieSceneCacheSource"; - -PRM_Name SOP_SceneCacheSource::pObjectOnly( "objectOnly", "Object Only" ); - -OP_TemplatePair *SOP_SceneCacheSource::buildParameters() -{ - static OP_TemplatePair *templatePair = 0; - if ( templatePair ) - { - return templatePair; - } - - PRM_Template *mainTemplate = SOP_SceneCacheSource::buildMainParameters()->myTemplate; - PRM_Template *optionTemplate = SOP_SceneCacheSource::buildOptionParameters()->myTemplate; - - unsigned numMainParms = PRM_Template::countTemplates( mainTemplate ); - unsigned numOptionParms = PRM_Template::countTemplates( optionTemplate ); - - static PRM_Template *thisTemplate = new PRM_Template[ numMainParms + numOptionParms + 2 ]; - - // add the generic SceneCacheNode parms - unsigned totalParms = 0; - for ( unsigned i = 0; i < numMainParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = mainTemplate[i]; - } - - // add the generic SceneCacheNode option parms - for ( unsigned i = 0; i < numOptionParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = optionTemplate[i]; - } - - // add the parms for this node - thisTemplate[totalParms] = PRM_Template( - PRM_TOGGLE, 1, &pObjectOnly, 0, 0, 0, &sceneParmChangedCallback, 0, 0, - "Determines whether this SOP cooks the current object only, or traverses down through the hierarchy." - ); - totalParms++; - - templatePair = new OP_TemplatePair( thisTemplate ); - return templatePair; -} - -SOP_SceneCacheSource::SOP_SceneCacheSource( OP_Network *net, const char *name, OP_Operator *op ) : SceneCacheNode( net, name, op ) -{ -} - -SOP_SceneCacheSource::~SOP_SceneCacheSource() -{ -} - -OP_Node *SOP_SceneCacheSource::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new SOP_SceneCacheSource( net, name, op ); -} - -bool SOP_SceneCacheSource::getObjectOnly() const -{ - return evalInt( pObjectOnly.getToken(), 0, 0 ); -} - -void SOP_SceneCacheSource::setObjectOnly( bool objectOnly ) -{ - setInt( pObjectOnly.getToken(), 0, 0, objectOnly ); - sceneChanged(); -} - -void SOP_SceneCacheSource::sceneChanged() -{ - SceneCacheNode::sceneChanged(); - - std::string file; - if ( !ensureFile( file ) ) - { - m_static = boost::indeterminate; - return; - } - - m_static = false; - - ConstSceneInterfacePtr scene = this->scene( file, getPath() ); - const SampledSceneInterface *sampledScene = IECore::runTimeCast( scene.get() ); - if ( sampledScene ) - { - bool objectOnly = this->evalInt( pObjectOnly.getToken(), 0, 0 ); - m_static = ( objectOnly && sampledScene->hasObject() ) ? ( sampledScene->numObjectSamples() < 2 ) : ( sampledScene->numBoundSamples() < 2 ); - } - - flags().setTimeDep( bool( !m_static ) ); -} - -OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context ) -{ - // make sure the state is valid - if ( boost::indeterminate( m_static ) ) - { - sceneChanged(); - } - - flags().setTimeDep( bool( !m_static ) ); - - std::string file; - if ( !ensureFile( file ) ) - { - addError( SOP_ATTRIBUTE_INVALID, ( file + " is not a valid .scc" ).c_str() ); - gdp->clearAndDestroy(); - return error(); - } - - std::string path = getPath(); - Space space = getSpace(); - SOP_SceneCacheSource::GeometryType geometryType = (SOP_SceneCacheSource::GeometryType)this->evalInt( pGeometryType.getToken(), 0, 0 ); - - UT_String tagFilterStr; - getTagFilter( tagFilterStr ); - UT_StringMMPattern tagFilter; - tagFilter.compile( tagFilterStr ); - - UT_String shapeFilterStr; - getShapeFilter( shapeFilterStr ); - UT_StringMMPattern shapeFilter; - shapeFilter.compile( shapeFilterStr ); - - UT_String p( "P" ); - UT_String attributeFilter; - getAttributeFilter( attributeFilter ); - if ( !p.match( attributeFilter ) ) - { - attributeFilter += " P"; - } - - UT_String attributeCopy; - getAttributeCopy( attributeCopy ); - - UT_String fullPathName; - getFullPathName( fullPathName ); - - ConstSceneInterfacePtr scene = this->scene( file, path ); - if ( !scene ) - { - addError( SOP_ATTRIBUTE_INVALID, ( path + " is not a valid location in " + file ).c_str() ); - gdp->clearAndDestroy(); - return error(); - } - - MurmurHash hash; - hash.append( file ); - hash.append( path ); - hash.append( space ); - hash.append( tagFilterStr ); - hash.append( getTagGroups() ); - hash.append( shapeFilterStr ); - hash.append( attributeFilter ); - hash.append( attributeCopy ); - hash.append( fullPathName ); - hash.append( geometryType ); - hash.append( getObjectOnly() ); - hash.append( getVisibilityFilter() ); - - if ( !m_loaded || m_hash != hash ) - { - gdp->clearAndDestroy(); - } - - double readTime = time( context ); - Imath::M44d transform = ( space == World ) ? worldTransform( file, path, readTime ) : Imath::M44d(); - - SceneInterface::Path rootPath; - scene->path( rootPath ); - - UT_Interrupt *progress = UTgetInterrupt(); - if ( !progress->opStart( ( "Cooking objects for " + getPath() ).c_str() ) ) - { - addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted before it started" ); - gdp->clearAndDestroy(); - return error(); - } - - Parameters params; - UT_String attribFilter; - getAttributeFilter( attribFilter ); - params.attributeFilter = attribFilter.toStdString(); - params.attributeCopy = attributeCopy.toStdString(); - params.fullPathName = fullPathName.toStdString(); - params.geometryType = getGeometryType(); - params.tagGroups = getTagGroups(); - params.visibilityFilter = getVisibilityFilter(); - params.inheritedVisibility = true; - getShapeFilter( params.shapeFilter ); - getTagFilter( params.tagFilter ); - - // Building a map from shape name to primitive range, which will be used during - // convertObject() to do a lazy update of animated primvars where possible, and - // to destroy changing topology shapes when necessary. - GA_ROHandleS nameAttrib( gdp, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if( nameAttrib.isValid() ) - { - std::map offsets; - - GA_Offset start, end; - for( GA_Iterator it( gdp->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - std::string current = ""; - if( const char *value = nameAttrib.get( offset ) ) - { - current = value; - } - auto oIt = offsets.insert( { current, GA_OffsetList() } ).first; - oIt->second.append( offset ); - } - } - - for( const auto &kv : offsets ) - { - params.namedRanges[kv.first] = GA_Range( gdp->getPrimitiveMap(), kv.second ); - } - } - - loadObjects( scene.get(), transform, readTime, space, params, rootPath.size(), SceneInterface::rootName.string() ); - - if ( progress->opInterrupt( 100 ) ) - { - addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted" ); - gdp->clearAndDestroy(); - m_loaded = false; - m_hash = MurmurHash(); - } - else - { - m_loaded = true; - m_hash = hash; - } - - progress->opEnd(); - - return error(); -} - -ConstObjectPtr SOP_SceneCacheSource::buildTransformPointCloud( const IECoreScene::SceneInterface *scene,const Imath::M44d &transform,const double time, Parameters ¶ms,const bool hasObject ) -{ - params.hasAnimatedTopology = false; - params.hasAnimatedPrimVars = true; - params.animatedPrimVars.clear(); - Imath::V3f p(0); - std::vector point( 1, p ); - PointsPrimitivePtr points = new PointsPrimitive( new V3fVectorData( point ) ); - - // has object - std::vector hasObjects( 1, hasObject ); - points->variables["hasobject"] = PrimitiveVariable( PrimitiveVariable::Vertex, new IntVectorData( hasObjects ) ); - - // transform matrix - std::vector transformMatrix( 1, transform ); - points->variables["transform"] = PrimitiveVariable( PrimitiveVariable::Vertex, new M44dVectorData( transformMatrix ) ); - - Imath::V3d scale; - extractScaling( transform, scale, false ); - float uniformScale = ( fabs( scale.x ) + fabs( scale.y ) + fabs( scale.z ) ) / 3.0f; - std::vector pscale( 1, uniformScale ); - points->variables["pscale"] = PrimitiveVariable( PrimitiveVariable::Vertex, new FloatVectorData( pscale ) ); - - std::vector scales( 1, scale / uniformScale ); - points->variables["scale"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( scales ) ); - - Imath::M44d rotationMatrix = transform; - removeScalingAndShear( rotationMatrix, false ); - std::vector orientation( 1, extractQuat( rotationMatrix ) ); - points->variables["orient"] = PrimitiveVariable( PrimitiveVariable::Vertex, new QuatfVectorData( orientation ) ); - - if ( scene->hasAttribute( mRefName ) ) - { - if ( IECore::ConstObjectPtr mRefAttr = scene->readAttribute( mRefName, time ) ) - { - const IECore::M44dData* mRef = IECore::runTimeCast( mRefAttr.get() ); - if ( mRef ) - { - // mref transform - const Imath::M44d &refTransform = mRef->readable(); - std::vector mRefMatrix( 1, refTransform ); - points->variables["resttransform"] = PrimitiveVariable( PrimitiveVariable::Vertex, new M44dVectorData( mRefMatrix ) ); - - // rest position - std::vector rest( 1, refTransform.translation() ); - points->variables["restposition"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( rest ) ); - params.animatedPrimVars.push_back( "resttransform" ); - params.animatedPrimVars.push_back( "restposition" ); - } - } - } - params.animatedPrimVars.push_back( "P" ); - params.animatedPrimVars.push_back( "transform" ); - params.animatedPrimVars.push_back( "pscale" ); - params.animatedPrimVars.push_back( "scale" ); - params.animatedPrimVars.push_back( "orient" ); - - return points; - -} -void SOP_SceneCacheSource::loadObjects( const IECoreScene::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters ¶ms, size_t rootSize, std::string currentPath ) -{ - UT_Interrupt *progress = UTgetInterrupt(); - progress->setLongOpText( ( "Loading " + scene->name().string() ).c_str() ); - if ( progress->opInterrupt() ) - { - return; - } - - if ( currentPath != scene->name().string() ) - { - if ( currentPath.back() != '/' ) - { - currentPath += "/"; - } - currentPath += scene->name().string(); - } - - std::string name = relativePath( scene, rootSize ); - - // filter out visibility or inherited visibility - if ( params.visibilityFilter ) - { - if ( scene->hasAttribute( IECoreScene::SceneInterface::visibilityName ) ) - { - params.inheritedVisibility = IECore::runTimeCast< const IECore::BoolData >( scene->readAttribute( IECoreScene::SceneInterface::visibilityName, time ) )->readable(); - } - - if ( !params.inheritedVisibility ) - { - // check the primitve range map to see if this shape exists already - - std::map::iterator rIt = params.namedRanges.find( name ); - if ( rIt != params.namedRanges.end() && !rIt->second.isEmpty() ) - { - GA_Range primRange = rIt->second; - gdp->destroyPrimitives( primRange, true ); - } - } - - } - - if ( UT_String( currentPath ).multiMatch( params.shapeFilter ) && tagged( scene, params.tagFilter ) ) - { - - if ( params.inheritedVisibility ) - { - Imath::M44d currentTransform; - if ( space == Local ) - { - currentTransform = scene->readTransformAsMatrix( time ); - } - else if ( space != Object ) - { - currentTransform = transform; - } - ConstObjectPtr object = 0; - if ( scene->hasObject() ) - { - if ( params.geometryType == BoundingBox ) - { - Imath::Box3d bound = scene->readBound( time ); - object = MeshPrimitive::createBox( Imath::Box3f( bound.min, bound.max ) ); - - params.hasAnimatedTopology = false; - params.hasAnimatedPrimVars = true; - params.animatedPrimVars.clear(); - params.animatedPrimVars.push_back( "P" ); - } - else if ( params.geometryType == PointCloud ) - { - std::vector point( 1, scene->readBound( time ).center() ); - PointsPrimitivePtr points = new PointsPrimitive( new V3fVectorData( point ) ); - std::vector basis1( 1, Imath::V3f( currentTransform[0][0], currentTransform[0][1], currentTransform[0][2] ) ); - std::vector basis2( 1, Imath::V3f( currentTransform[1][0], currentTransform[1][1], currentTransform[1][2] ) ); - std::vector basis3( 1, Imath::V3f( currentTransform[2][0], currentTransform[2][1], currentTransform[2][2] ) ); - points->variables["basis1"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis1 ) ); - points->variables["basis2"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis2 ) ); - points->variables["basis3"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis3 ) ); - - params.hasAnimatedTopology = false; - params.hasAnimatedPrimVars = true; - params.animatedPrimVars.clear(); - params.animatedPrimVars.push_back( "P" ); - params.animatedPrimVars.push_back( "basis1" ); - params.animatedPrimVars.push_back( "basis2" ); - params.animatedPrimVars.push_back( "basis3" ); - - object = points; - } - else if( params.geometryType == TransformPointCloud ) - { - object = buildTransformPointCloud( scene, currentTransform, time, params, true ); - } - else - { - object = scene->readObject( time ); - - params.hasAnimatedTopology = scene->hasAttribute( SceneCache::animatedObjectTopologyAttribute ); - params.hasAnimatedPrimVars = scene->hasAttribute( SceneCache::animatedObjectPrimVarsAttribute ); - if ( params.hasAnimatedPrimVars ) - { - const ConstObjectPtr animatedPrimVarObj = scene->readAttribute( SceneCache::animatedObjectPrimVarsAttribute, 0 ); - const InternedStringVectorData *animatedPrimVarData = IECore::runTimeCast( animatedPrimVarObj.get() ); - if ( animatedPrimVarData ) - { - const std::vector &values = animatedPrimVarData->readable(); - params.animatedPrimVars.clear(); - params.animatedPrimVars.resize( values.size() ); - std::copy( values.begin(), values.end(), params.animatedPrimVars.begin() ); - } - } - - } - } - else if( params.geometryType == TransformPointCloud ) - { - object = buildTransformPointCloud( scene, currentTransform, time, params, false ); - } - - if ( object ) - { - // modify the object if necessary - object = modifyObject( object.get(), params ); - - // transform the object unless its an identity - if ( currentTransform != Imath::M44d() ) - { - object = transformObject( object.get(), currentTransform, params ); - } - - // convert the object to Houdini - if ( !convertObject( object.get(), name, scene, params ) ) - { - addWarning( SOP_MESSAGE, ( "Could not convert " + currentPath + " to Houdini" ).c_str() ); - } - } - } - } - - if ( evalInt( pObjectOnly.getToken(), 0, 0 ) ) - { - return; - } - - SceneInterface::NameList children; - scene->childNames( children ); - std::sort( children.begin(), children.end(), InternedStringSort() ); - bool parentInheritedVisibility = params.inheritedVisibility; - for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it ) - { - ConstSceneInterfacePtr child = scene->child( *it ); - if ( tagged( child.get(), params.tagFilter ) ) - { - loadObjects( child.get(), child->readTransformAsMatrix( time ) * transform, time, space, params, rootSize, currentPath ); - // reset inherited visibility from the parent - params.inheritedVisibility = parentInheritedVisibility; - } - } -} - -ConstObjectPtr SOP_SceneCacheSource::modifyObject( const IECore::Object *object, Parameters ¶ms ) -{ - ConstObjectPtr result = object; - - if ( params.attributeCopy != "" ) - { - if ( const Primitive *primitive = IECore::runTimeCast( object ) ) - { - PrimitivePtr modified = 0; - const PrimitiveVariableMap &variables = primitive->variables; - - UT_WorkArgs pairs; - UT_String args( params.attributeCopy ); - args.tokenize( pairs, " " ); - for ( int i = 0; i < pairs.entries(); ++i ) - { - UT_WorkArgs values; - UT_String pair( pairs[i] ); - pair.tokenize( values, ":" ); - if ( values.entries() != 2 ) - { - continue; - } - - PrimitiveVariableMap::const_iterator it = variables.find( values[0] ); - if ( it != variables.end() ) - { - if ( !modified ) - { - modified = primitive->copy(); - } - - // we need to copy the data in case either copy will be modified later on - const PrimitiveVariable &orig = modified->variables[values[0]]; - modified->variables[values[1]] = PrimitiveVariable( orig.interpolation, orig.data->copy() ); - } - } - - if ( modified ) - { - result = modified; - } - } - } - - return result; -} - -template -SOP_SceneCacheSource::TransformGeometricData::ReturnType SOP_SceneCacheSource::TransformGeometricData::operator()( const T *data ) const -{ - GeometricData::Interpretation interp = data->getInterpretation(); - return ( interp == GeometricData::Point || interp == GeometricData::Normal || interp == GeometricData::Vector ); -} - -ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters ¶ms ) -{ - if ( const Primitive *primitive = IECore::runTimeCast( object ) ) - { - TransformOpPtr transformer = new TransformOp(); - transformer->inputParameter()->setValue( const_cast( primitive ) ); // safe because we set the copy parameter - transformer->copyParameter()->setTypedValue( true ); - transformer->matrixParameter()->setValue( new M44dData( transform ) ); - - // add all Point and Normal prim vars to the transformation list, except for rest/Pref - const PrimitiveVariableMap &variables = primitive->variables; - std::vector &primVars = transformer->primVarsParameter()->getTypedValue(); - primVars.clear(); - for ( PrimitiveVariableMap::const_iterator it = variables.begin(); it != variables.end(); ++it ) - { - if ( despatchTypedData( it->second.data.get() ) ) - { - // we don't want to alter rest/Pref because Houdini excepts these to be non-transforming prim vars - if ( it->first == "rest" || it->first == "Pref" ) - { - continue; - } - - primVars.push_back( it->first ); - - // add the transforming prim vars to the animated list - if ( std::find( params.animatedPrimVars.begin(), params.animatedPrimVars.end(), it->first ) == params.animatedPrimVars.end() ) - { - params.animatedPrimVars.push_back( it->first ); - params.hasAnimatedPrimVars = true; - } - } - } - - return transformer->operate(); - } - else if ( const Group *group = IECore::runTimeCast( object ) ) - { - GroupPtr result = group->copy(); - MatrixTransformPtr matTransform = matrixTransform( transform ); - if ( const Transform *transform = group->getTransform() ) - { - matTransform->matrix *= transform->transform(); - } - result->setTransform( matTransform ); - return result; - } - else if ( const CoordinateSystem *coord = IECore::runTimeCast( object ) ) - { - CoordinateSystemPtr result = coord->copy(); - MatrixTransformPtr matTransform = matrixTransform( transform ); - if ( const Transform *transform = coord->getTransform() ) - { - matTransform->matrix *= transform->transform(); - } - result->setTransform( matTransform ); - return result; - } - - return object; -} - -bool SOP_SceneCacheSource::convertObject( const IECore::Object *object, const std::string &name, const SceneInterface *scene, Parameters ¶ms ) -{ - ToHoudiniGeometryConverterPtr converter = nullptr; - if ( params.geometryType == Cortex ) - { - converter = new ToHoudiniCortexObjectConverter( object ); - } - else - { - const VisibleRenderable *renderable = IECore::runTimeCast( object ); - if ( !renderable ) - { - return false; - } - - converter = ToHoudiniGeometryConverter::create( renderable ); - } - - if ( !converter ) - { - return false; - } - - // we need to set the name regardless of whether - // we're reusing prims or doing the full conversion - // because this parameter can have an affect in - // transferAttribs() as well as convert() - converter->nameParameter()->setTypedValue( name ); - - // check the primitve range map to see if this shape exists already - std::map::iterator rIt = params.namedRanges.find( name ); - if ( rIt != params.namedRanges.end() && !rIt->second.isEmpty() ) - { - GA_Range primRange = rIt->second; - const Primitive *primitive = IECore::runTimeCast( object ); - if ( primitive && !params.hasAnimatedTopology && params.hasAnimatedPrimVars ) - { - // this means constant topology and primitive variables, even though multiple samples were written - if ( params.animatedPrimVars.empty() ) - { - return true; - } - - GA_Range pointRange( *gdp, primRange, GA_ATTRIB_POINT, GA_Range::primitiveref(), false ); - - // update the animated primitive variables only - std::string animatedPrimVarStr = ""; - for ( std::vector::const_iterator it = params.animatedPrimVars.begin(); it != params.animatedPrimVars.end(); ++it ) - { - animatedPrimVarStr += it->string() + " "; - } - - converter->attributeFilterParameter()->setTypedValue( animatedPrimVarStr ); - - try - { - converter->transferAttribs( gdp, pointRange, primRange ); - return true; - } - catch ( std::exception &e ) - { - addWarning( SOP_MESSAGE, e.what() ); - return false; - } - catch ( ... ) - { - addWarning( SOP_MESSAGE, "Attribute transfer failed for unknown reasons" ); - return false; - } - } - else - { - // topology is changing, so destroy the exisiting primitives - gdp->destroyPrimitives( primRange, true ); - } - } - - // fallback to full conversion - converter->attributeFilterParameter()->setTypedValue( params.attributeFilter ); - - try - { - GA_Offset firstNewPrim = gdp->getPrimitiveMap().lastOffset() + 1; - - bool status = converter->convert( myGdpHandle ); - - // adds the full path in addition to the relative name - const GA_IndexMap &primMap = gdp->getPrimitiveMap(); - GA_Range newPrims( primMap, firstNewPrim, primMap.lastOffset() + 1 ); - - if ( params.fullPathName != "" ) - { - if ( newPrims.isValid() ) - { - std::string fullName; - SceneInterface::Path path; - scene->path( path ); - SceneInterface::pathToString( path, fullName ); - - GA_RWAttributeRef pathAttribRef = ToHoudiniStringVectorAttribConverter::convertString( params.fullPathName, fullName, gdp, newPrims ); - status = status && pathAttribRef.isValid(); - } - } - - if ( params.tagGroups ) - { - static UT_StringMMPattern convertTagFilter; - if( convertTagFilter.isEmpty() ) - { - convertTagFilter.compile( "ObjectType:*" ); - } - SceneInterface::NameList tags; - scene->readTags( tags, IECoreScene::SceneInterface::LocalTag ); - for ( SceneInterface::NameList::const_iterator it=tags.begin(); it != tags.end(); ++it ) - { - UT_String tag( *it ); - // skip this tag because it's used behind the scenes - if ( tag.multiMatch( convertTagFilter ) ) - { - continue; - } - - // replace this special character found in SCC tags that will prevent the group from being created - tag.substitute(":", "_"); - - tag.prepend("ieTag_"); - - GA_PrimitiveGroup *group = gdp->findPrimitiveGroup(tag); - if ( !group ) - { - group = gdp->newPrimitiveGroup(tag); - } - group->addRange(newPrims); - } - } - - return status; - } - catch ( std::exception &e ) - { - addWarning( SOP_MESSAGE, e.what() ); - return false; - } - catch ( ... ) - { - addWarning( SOP_MESSAGE, "Conversion failed for unknown reasons" ); - return false; - } -} - -void SOP_SceneCacheSource::getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ) -{ - SceneCacheNode::getNodeSpecificInfoText( context, parms ); - - // add type descriptions for the Cortex Objects - GeometryType geometryType = (GeometryType)this->evalInt( pGeometryType.getToken(), 0, 0 ); - if ( geometryType == Cortex ) - { - GEO_CortexPrimitive::infoText( getCookedGeo( context ), context, parms ); - return; - } - - // add conversion details for Houdini geo - UT_String p( "P" ); - UT_String filter; - evalString( filter, pAttributeFilter.getToken(), 0, 0 ); - if ( !p.match( filter ) ) - { - filter += " P"; - } - UT_StringMMPattern attributeFilter; - attributeFilter.compile( filter ); - - /// \todo: this text could come from a static method on a class that manages these name relations (once that exists) - parms.append( "Converting standard Cortex PrimitiveVariables:\n" ); - if ( UT_String( "s" ).multiMatch( attributeFilter ) && UT_String( "t" ).multiMatch( attributeFilter ) ) - { - parms.append( " s,t -> uv\n" ); - } - - if ( UT_String( "Cs" ).multiMatch( attributeFilter ) ) - { - parms.append( " Cs -> Cd\n" ); - } - - if ( UT_String( "Pref" ).multiMatch( attributeFilter ) ) - { - parms.append( " Pref -> rest\n" ); - } - - if ( UT_String( "width" ).multiMatch( attributeFilter ) ) - { - parms.append( " width -> pscale\n" ); - } - - if ( UT_String( "Os" ).multiMatch( attributeFilter ) ) - { - parms.append( " Os -> Alpha\n" ); - } -} - -MatrixTransformPtr SOP_SceneCacheSource::matrixTransform( Imath::M44d t ) -{ - return new MatrixTransform( - Imath::M44f( - t[0][0], t[0][1], t[0][2], t[0][3], - t[1][0], t[1][1], t[1][2], t[1][3], - t[2][0], t[2][1], t[2][2], t[2][3], - t[3][0], t[3][1], t[3][2], t[3][3] - ) - ); -} - -std::string SOP_SceneCacheSource::relativePath( const IECoreScene::SceneInterface *scene, size_t rootSize ) -{ - SceneInterface::Path path, relative; - scene->path( path ); - - SceneInterface::Path::iterator start = path.begin() + rootSize; - if ( start != path.end() ) - { - relative.resize( path.end() - start ); - std::copy( start, path.end(), relative.begin() ); - } - - std::string result; - SceneInterface::pathToString( relative, result ); - - return result; -} - -bool SOP_SceneCacheSource::InternedStringSort::operator() ( const SceneInterface::Name &i, const SceneInterface::Name &j ) -{ - return ( i.string() < j.string() ); -} diff --git a/src/IECoreHoudini/SOP_SceneCacheTransform.cpp b/src/IECoreHoudini/SOP_SceneCacheTransform.cpp deleted file mode 100644 index 4ff395a708..0000000000 --- a/src/IECoreHoudini/SOP_SceneCacheTransform.cpp +++ /dev/null @@ -1,355 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SOP_SceneCacheTransform.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" - -#include "GA/GA_Names.h" -#include "OP/OP_NodeInfoParms.h" -#include "PRM/PRM_ChoiceList.h" -#include "PRM/PRM_Default.h" -#include "UT/UT_Interrupt.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -static InternedString pName( "P" ); - -const char *SOP_SceneCacheTransform::typeName = "ieSceneCacheTransform"; - -PRM_Name SOP_SceneCacheTransform::pMode( "mode", "Mode" ); -PRM_Name SOP_SceneCacheTransform::pInvert( "invert", "Invert" ); - -PRM_Default SOP_SceneCacheTransform::modeDefault( Name ); - -static PRM_Name modes[] = { - PRM_Name( "0", "Name" ), - PRM_Name( "1", "Root" ), - PRM_Name( 0 ) // sentinal -}; - -PRM_ChoiceList SOP_SceneCacheTransform::modeList( PRM_CHOICELIST_SINGLE, &modes[0] ); - -OP_TemplatePair *SOP_SceneCacheTransform::buildParameters() -{ - static OP_TemplatePair *templatePair = 0; - if ( templatePair ) - { - return templatePair; - } - - PRM_Template *mainTemplate = SOP_SceneCacheTransform::buildMainParameters()->myTemplate; - unsigned numMainParms = PRM_Template::countTemplates( mainTemplate ); - static PRM_Template *thisTemplate = new PRM_Template[ numMainParms + 3 ]; - - // add the generic SceneCacheNode parms - unsigned totalParms = 0; - for ( unsigned i = 0; i < numMainParms; ++i, ++totalParms ) - { - thisTemplate[totalParms] = mainTemplate[i]; - } - - thisTemplate[totalParms] = PRM_Template( - PRM_INT, 1, &pMode, &modeDefault, &modeList, 0, 0, 0, 0, - "The transformation mode. \"Name\" mode transforms each named primitive range by the " - "matching path in the given SceneCache file, relative to the \"root\" parameter. \"Root\" " - "mode transforms all primitives by a single transform from the SceneCache file, as " - "specified by the \"root\" parameter." - ); - totalParms++; - - thisTemplate[totalParms] = PRM_Template( - PRM_TOGGLE, 1, &pInvert, 0, 0, 0, 0, 0, 0, - "Invert the transformation matrix before applying it to the geometry." - ); - totalParms++; - - templatePair = new OP_TemplatePair( thisTemplate ); - return templatePair; -} - -SOP_SceneCacheTransform::SOP_SceneCacheTransform( OP_Network *net, const char *name, OP_Operator *op ) : SceneCacheNode( net, name, op ) -{ -} - -SOP_SceneCacheTransform::~SOP_SceneCacheTransform() -{ -} - -OP_Node *SOP_SceneCacheTransform::create( OP_Network *net, const char *name, OP_Operator *op ) -{ - return new SOP_SceneCacheTransform( net, name, op ); -} - -void SOP_SceneCacheTransform::sceneChanged() -{ - SceneCacheNode::sceneChanged(); - m_static = boost::indeterminate; -} - -OP_ERROR SOP_SceneCacheTransform::cookMySop( OP_Context &context ) -{ - std::string file; - if ( !ensureFile( file ) ) - { - addError( SOP_ATTRIBUTE_INVALID, ( file + " is not a valid .scc" ).c_str() ); - gdp->clearAndDestroy(); - sceneChanged(); - return error(); - } - - std::string path = getPath(); - Space space = getSpace(); - Mode mode = (Mode)this->evalInt( pMode.getToken(), 0, 0 ); - bool invert = this->evalInt( pInvert.getToken(), 0, 0 ); - - ConstSceneInterfacePtr scene = this->scene( file, path ); - if ( !scene ) - { - addError( SOP_ATTRIBUTE_INVALID, ( path + " is not a valid location in " + file ).c_str() ); - gdp->clearAndDestroy(); - sceneChanged(); - return error(); - } - - MurmurHash hash; - hash.append( file ); - hash.append( path ); - hash.append( space ); - - if ( !m_loaded || m_hash != hash ) - { - sceneChanged(); - } - - if ( lockInputs( context ) >= UT_ERROR_ABORT ) - { - return error(); - } - - gdp->stashAll(); - duplicatePointSource( 0, context ); - - UT_Interrupt *progress = UTgetInterrupt(); - if ( !progress->opStart( "Transforming objects" ) ) - { - addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted before it started" ); - gdp->clearAndDestroy(); - unlockInputs(); - return error(); - } - - m_static = boost::indeterminate; - - double readTime = time( context ); - - if ( mode == Root ) - { - UT_Matrix4 transform = getTransform( scene.get(), scene.get(), readTime, space, invert ); - gdp->transform( transform ); - } - else if ( mode == Name ) - { - transformByName( scene.get(), readTime, space, invert ); - } - else - { - addError( SOP_ATTRIBUTE_INVALID, "Invalid Mode" ); - } - - flags().setTimeDep( bool( !m_static ) ); - - if ( progress->opInterrupt( 100 ) ) - { - addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted" ); - gdp->clearAndDestroy(); - m_loaded = false; - m_hash = MurmurHash(); - } - else - { - m_loaded = true; - m_hash = hash; - } - - progress->opEnd(); - - unlockInputs(); - return error(); -} - -void SOP_SceneCacheTransform::transformByName( const SceneInterface *scene, double time, Space space, bool invert ) -{ - // Building a map from shape name to primitive range - /// \todo: this is duplicated from SOP_SceneCacheSource.cpp. Can it be unified somewhere? - /// Is this an argument for a different kind of DetailSplitter? DetailRanger? - std::map namedRanges; - GA_ROHandleS nameAttrib( gdp, GA_ATTRIB_PRIMITIVE, GA_Names::name ); - if ( nameAttrib.isValid() ) - { - std::map offsets; - - GA_Offset start, end; - for( GA_Iterator it( gdp->getPrimitiveRange() ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - std::string current = ""; - if( const char *value = nameAttrib.get( offset ) ) - { - current = value; - } - - auto oIt = offsets.insert( { current, GA_OffsetList() } ).first; - oIt->second.append( offset ); - } - } - - for( const auto &kv : offsets ) - { - namedRanges[kv.first] = GA_Range( gdp->getPrimitiveMap(), kv.second ); - } - } - - std::string rootPathStr; - SceneInterface::Path rootPath; - scene->path( rootPath ); - SceneInterface::pathToString( rootPath, rootPathStr ); - - for ( std::map::iterator it = namedRanges.begin(); it != namedRanges.end(); ++it ) - { - std::string fullPathStr = rootPathStr + it->first; - SceneInterface::Path fullPath; - SceneInterface::stringToPath( fullPathStr, fullPath ); - - if ( ConstSceneInterfacePtr leaf = scene->scene( fullPath, SceneInterface::NullIfMissing ) ) - { - UT_Matrix4 transform = getTransform( scene, leaf.get(), time, space, invert ); - gdp->transform( transform, it->second, false ); - } - } -} - -UT_Matrix4 SOP_SceneCacheTransform::getTransform( const SceneInterface *rootScene, const SceneInterface *scene, double time, Space space, bool invert ) -{ - Imath::M44d transform; - if ( space == World ) - { - transform = relativeTransform( scene->scene( SceneInterface::rootPath ).get(), scene, time ); - } - else if ( space == Local ) - { - transform = scene->readTransformAsMatrix( time ); - } - else if ( space == Path ) - { - transform = relativeTransform( rootScene, scene, time ); - } - - // we don't need to update if we've already confirmed it is animated - if ( m_static || boost::indeterminate( m_static ) ) - { - if ( space == Local ) - { - if ( const SampledSceneInterface *sampledScene = IECore::runTimeCast( scene ) ) - { - m_static = ( sampledScene->numTransformSamples() < 2 ); - } - else - { - m_static = false; - } - } - else - { - // if we never set m_static false by this point, then the whole thing is static - m_static = true; - } - } - - UT_Matrix4 matrix = UT_Matrix4( IECore::convert( transform ) ); - if ( invert ) - { - matrix.invert(); - } - - return matrix; -} - -Imath::M44d SOP_SceneCacheTransform::relativeTransform( const IECoreScene::SceneInterface *rootScene, const IECoreScene::SceneInterface *scene, double time ) -{ - Imath::M44d result; - - SceneInterface::Path p, rootPath; - scene->path( p ); - rootScene->path( rootPath ); - - ConstSceneInterfacePtr current = rootScene; - for ( SceneInterface::Path::const_iterator it = p.begin() + rootPath.size(); current && it != p.end(); ++it ) - { - current = current->child( *it, SceneInterface::NullIfMissing ); - if ( !current ) - { - m_static = false; - break; - } - - if ( const SampledSceneInterface *sampledCurrent = IECore::runTimeCast( current.get() ) ) - { - if ( sampledCurrent->numTransformSamples() > 1 ) - { - m_static = false; - } - } - else - { - m_static = false; - } - - result = current->readTransformAsMatrix( time ) * result; - } - - return result; -} - -void SOP_SceneCacheTransform::getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms ) -{ - SceneCacheNode::getNodeSpecificInfoText( context, parms ); - - // add type descriptions for the Cortex Objects - GEO_CortexPrimitive::infoText( getCookedGeo( context ), context, parms ); -} diff --git a/src/IECoreHoudini/SceneCacheNode.cpp b/src/IECoreHoudini/SceneCacheNode.cpp deleted file mode 100644 index 51ed24d752..0000000000 --- a/src/IECoreHoudini/SceneCacheNode.cpp +++ /dev/null @@ -1,839 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECore/TypeTraits.h" - -#include "IECoreScene/SharedSceneInterfaces.h" - -#include "CH/CH_Manager.h" -#include "OBJ/OBJ_Geometry.h" -#include "OBJ/OBJ_SubNet.h" -#include "PRM/PRM_ChoiceList.h" -#include "PRM/PRM_Parm.h" -#include "SOP/SOP_Node.h" -#include "UT/UT_StringMMPattern.h" - -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -static UT_StringRef visibilityExpression( "import IECoreHoudini\nsc = IECoreHoudini.SceneCacheNode( hou.pwd() )\nreturn sc.visibility(hou.frame())" ); - -////////////////////////////////////////////////////////////////////////////////////////// -// SceneCacheNode implementation -////////////////////////////////////////////////////////////////////////////////////////// - -template -SceneCacheNode::SceneCacheNode( OP_Network *net, const char *name, OP_Operator *op ) : - BaseType( net, name, op ), m_loaded( false ), m_static( boost::indeterminate ) -{ - BaseType::flags().setTimeDep( true ); -} - -template -SceneCacheNode::~SceneCacheNode() -{ -} - -template -PRM_Name SceneCacheNode::pFile( "file", "File" ); - -template -PRM_Name SceneCacheNode::pReload( "reload", "Reload" ); - -template -PRM_Name SceneCacheNode::pRoot( "root", "Root" ); - -template -PRM_Name SceneCacheNode::pSpace( "space", "Space" ); - -template -PRM_Name SceneCacheNode::pAttributeFilter( "attributeFilter", "Attribute Filter" ); - -template -PRM_Name SceneCacheNode::pAttributeCopy( "attributeCopy", "Attribute Copy" ); - -template -PRM_Name SceneCacheNode::pTagFilter( "tagFilter", "Tag Filter" ); - -template -PRM_Name SceneCacheNode::pTagGroups( "tagGroups", "Convert Tags to Groups" ); - -template -PRM_Name SceneCacheNode::pShapeFilter( "shapeFilter", "Shape Filter" ); - -template -PRM_Name SceneCacheNode::pFullPathName( "fullPathName", "Full Path Name" ); - -template -PRM_Name SceneCacheNode::pGeometryType( "geometryType", "Geometry Type" ); - -template -PRM_Name SceneCacheNode::pVisibilityFilter( "visibilityFilter", "Visibility Filter" ); - -template -PRM_Default SceneCacheNode::rootDefault( 0, "/" ); - -template -PRM_Default SceneCacheNode::spaceDefault( World ); - -template -PRM_Default SceneCacheNode::filterDefault( 0, "*" ); - -template -PRM_Default SceneCacheNode::geometryTypeDefault( Cortex ); - -static PRM_Name spaceNames[] = { - PRM_Name( "0", "World" ), - PRM_Name( "1", "Path" ), - PRM_Name( "2", "Local" ), - PRM_Name( "3", "Object" ), - PRM_Name( 0 ) // sentinal -}; - -static PRM_Name geometryTypes[] = { - PRM_Name( "0", "Cortex Primitives" ), - PRM_Name( "1", "Houdini Geometry" ), - PRM_Name( "2", "Bounding Boxes" ), - PRM_Name( "3", "Point Cloud" ), - PRM_Name( "4", "Transform Point Cloud" ), - PRM_Name( 0 ) // sentinal -}; - -static PRM_Name attributeCopyOptions[] = { - PRM_Name( "P:Pref", "P:Pref" ), - PRM_Name( 0 ) // sentinal -}; - -template -PRM_ChoiceList SceneCacheNode::rootMenu( PRM_CHOICELIST_REPLACE, &SceneCacheNode::buildRootMenu ); - -template -PRM_ChoiceList SceneCacheNode::spaceList( PRM_CHOICELIST_SINGLE, &spaceNames[0] ); - -template -PRM_ChoiceList SceneCacheNode::geometryTypeList( PRM_CHOICELIST_SINGLE, &geometryTypes[0] ); - -template -PRM_ChoiceList SceneCacheNode::attributeCopyMenu( PRM_CHOICELIST_TOGGLE, &attributeCopyOptions[0] ); - -template -PRM_ChoiceList SceneCacheNode::tagFilterMenu( PRM_CHOICELIST_TOGGLE, &SceneCacheNode::buildTagFilterMenu ); - -template -PRM_ChoiceList SceneCacheNode::shapeFilterMenu( PRM_CHOICELIST_TOGGLE, &SceneCacheNode::buildShapeFilterMenu ); - -template -OP_TemplatePair *SceneCacheNode::buildMainParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - thisTemplate = new PRM_Template[5]; - - thisTemplate[0] = PRM_Template( - PRM_FILE | PRM_TYPE_JOIN_NEXT, 1, &pFile, 0, 0, 0, &SceneCacheNode::sceneParmChangedCallback, 0, 0, - "A static or animated SCC or LSCC file to load, starting at the Root path provided." - ); - - thisTemplate[1] = PRM_Template( - PRM_CALLBACK, 1, &pReload, 0, 0, 0, &SceneCacheNode::reloadButtonCallback, 0, 0, - "Removes the current SCC or LSCC file from the cache. This will force a recook on this node, and " - "cause all other nodes using this file to require a recook as well." - ); - - thisTemplate[2] = PRM_Template( - PRM_STRING, 1, &pRoot, &rootDefault, &rootMenu, 0, &SceneCacheNode::sceneParmChangedCallback, 0, 0, - "Root path inside the SCC or LSCC of the hierarchy to load" - ); - - thisTemplate[3] = PRM_Template( - PRM_INT, 1, &pSpace, &spaceDefault, &spaceList, 0, 0, 0, 0, - "Re-orient the objects by choosing a space. World transforms from \"/\" on down the hierarchy, " - "Path re-roots the transformation starting at the specified root path, Local uses the current level " - "transformations only, and Object is an identity transform" - ); - - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -template -OP_TemplatePair *SceneCacheNode::buildOptionParameters() -{ - static PRM_Template *thisTemplate = 0; - if ( !thisTemplate ) - { - thisTemplate = new PRM_Template[9]; - - thisTemplate[0] = PRM_Template( - PRM_INT, 1, &pGeometryType, &geometryTypeDefault, &geometryTypeList, 0, 0, 0, 0, - "The type of geometry to load. Cortex Primitives are faster, but only allow manipulation through " - "OpHolders or specificly designed nodes. Houdini Geometry will use the converters to create standard " - "geo that can be manipulated anywhere." - ); - - thisTemplate[1] = PRM_Template( - PRM_STRING, 1, &pAttributeFilter, &filterDefault, 0, 0, 0, 0, 0, - "A list of attribute names to load, if they exist on each shape. Uses Houdini matching syntax. " - "The filter expects Cortex names as exist in the cache, and performs automated conversion to " - "standard Houdini Attributes (i.e. Pref->rest ; Cs->Cd ; s,t->uv). P will always be loaded." - ); - - thisTemplate[2] = PRM_Template( - PRM_STRING, 1, &pAttributeCopy, 0, &attributeCopyMenu, 0, 0, 0, 0, - "Attributes to copy before loading into Houdini. This uses a:b syntax to copy duplicate attributes. " - "Note that using this field will cause a duplication in memory before entering Houdini, which may " - "impact performance." - ); - - thisTemplate[3] = PRM_Template( - PRM_STRING, 1, &pShapeFilter, &filterDefault, &shapeFilterMenu, 0, 0, 0, 0, - "A list of filters to decide which shapes to load. Uses Houdini matching syntax." - ); - - thisTemplate[4] = PRM_Template( - PRM_STRING, 1, &pTagFilter, &filterDefault, &tagFilterMenu, 0, 0, 0, 0, - "A list of filters to decide which tags to expand. In SubNetwork mode, branches that do not " - "match the filter will remain collapsed. In Parenting mode, the tag filters just control initial " - "visibility. In FlatGeometry mode they essentially delete the non-tagged geometry. Uses Houdini " - "matching syntax, but matches *any* of the tags." - ); - - thisTemplate[5] = PRM_Template( - PRM_TOGGLE, 1, &pVisibilityFilter, 0, 0, 0, &sceneParmChangedCallback, 0, 0, - "Determines whether this SOP cull out hidden location or not." - ); - - thisTemplate[6] = PRM_Template( - PRM_TOGGLE, 1, &pTagGroups, 0, 0, 0, 0, 0, 0, - "Convert SCC tags into Houdini primitive groups." - ); - - thisTemplate[7] = PRM_Template( - PRM_STRING, 1, &pFullPathName, 0, 0, 0, 0, 0, 0, - "Load the full path of the object as a primitive attribute with this name. This is for user " - "convenience and has no meaning in terms of processing or exporting SceneCaches. If left empty, " - "the full path will not be loaded. It is the user's responsibility to remove this attribute prior " - "to exporting new SceneCaches if necessary." - ); - } - - static OP_TemplatePair *templatePair = 0; - if ( !templatePair ) - { - templatePair = new OP_TemplatePair( thisTemplate ); - } - - return templatePair; -} - -template -void SceneCacheNode::buildRootMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node ) - { - return; - } - - menu[0].setToken( SceneInterface::rootName.c_str() ); - menu[0].setLabel( SceneInterface::rootName.c_str() ); - - std::string file; - if ( !node->ensureFile( file ) ) - { - // mark the end of our menu - menu[1].setToken( 0 ); - return; - } - - std::vector descendants; - node->descendantNames( node->scene( file, SceneInterface::rootName ).get(), descendants ); - node->createMenu( menu, descendants ); -} - -template -void SceneCacheNode::buildTagFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node ) - { - return; - } - - menu[0].setToken( "*" ); - menu[0].setLabel( "*" ); - - std::string file; - if ( !node->ensureFile( file ) ) - { - // mark the end of our menu - menu[1].setToken( 0 ); - return; - } - - ConstSceneInterfacePtr scene = node->scene( file, node->getPath() ); - if ( !scene ) - { - // mark the end of our menu - menu[1].setToken( 0 ); - return; - } - - SceneInterface::NameList tags; - scene->readTags( tags, IECoreScene::SceneInterface::EveryTag ); - std::vector tagStrings; - for ( SceneInterface::NameList::const_iterator it=tags.begin(); it != tags.end(); ++it ) - { - tagStrings.push_back( *it ); - } - - node->createMenu( menu, tagStrings ); -} - -template -void SceneCacheNode::buildShapeFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * ) -{ - SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node ) - { - return; - } - - menu[0].setToken( "*" ); - menu[0].setLabel( "*" ); - - std::string file; - if ( !node->ensureFile( file ) ) - { - // mark the end of our menu - menu[1].setToken( 0 ); - return; - } - - ConstSceneInterfacePtr scene = node->scene( file, node->getPath() ); - if ( !scene ) - { - // mark the end of our menu - menu[1].setToken( 0 ); - return; - } - - std::vector objects; - node->objectNames( scene.get(), objects ); - std::sort( objects.begin(), objects.end() ); - node->createMenu( menu, objects ); -} - -template -int SceneCacheNode::sceneParmChangedCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node ) - { - return 0; - } - - node->sceneChanged(); - - return 1; -} - -template -int SceneCacheNode::reloadButtonCallback( void *data, int index, float time, const PRM_Template *tplate ) -{ - std::string file; - SceneCacheNode *node = reinterpret_cast*>( data ); - if ( !node || !node->ensureFile( file ) ) - { - return 0; - } - - SharedSceneInterfaces::erase( file ); - node->sceneChanged(); - node->forceRecook(); - - return 1; -} - -template -void SceneCacheNode::sceneChanged() -{ - m_loaded = false; -} - -template -bool SceneCacheNode::ensureFile( std::string &file ) -{ - file = getFile(); - - boost::filesystem::path filePath = boost::filesystem::path( file ); - std::vector extensions = SceneInterface::supportedExtensions( IndexedIO::Read ); - if ( filePath.has_extension() && std::find( extensions.begin(), extensions.end(), filePath.extension().string().substr( 1 ) ) != extensions.end() && boost::filesystem::exists( filePath ) ) - { - return true; - } - - return false; -} - -template -std::string SceneCacheNode::getFile() const -{ - UT_String value; - this->evalString( value, pFile.getToken(), 0, 0 ); - return value.toStdString(); -} - -template -void SceneCacheNode::setFile( std::string file ) -{ - this->setString( UT_String( file ), CH_STRING_LITERAL, pFile.getToken(), 0, 0 ); - sceneChanged(); -} - -template -std::string SceneCacheNode::getPath() const -{ - UT_String value; - this->evalString( value, pRoot.getToken(), 0, 0 ); - return ( value == "" ) ? "/" : value.toStdString(); -} - -template -void SceneCacheNode::setPath( const IECoreScene::SceneInterface *scene ) -{ - std::string str; - SceneInterface::Path p; - scene->path( p ); - SceneInterface::pathToString( p, str ); - - this->setString( UT_String( str ), CH_STRING_LITERAL, pRoot.getToken(), 0, 0 ); - sceneChanged(); -} - -template -typename SceneCacheNode::Space SceneCacheNode::getSpace() const -{ - return (Space)this->evalInt( pSpace.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setSpace( SceneCacheNode::Space space ) -{ - this->setInt( pSpace.getToken(), 0, 0, space ); -} - -template -typename SceneCacheNode::GeometryType SceneCacheNode::getGeometryType() const -{ - return (GeometryType)this->evalInt( pGeometryType.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setGeometryType( SceneCacheNode::GeometryType type ) -{ - this->setInt( pGeometryType.getToken(), 0, 0, type ); -} - -template -void SceneCacheNode::getAttributeFilter( UT_String &filter ) const -{ - this->evalString( filter, pAttributeFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::getAttributeFilter( UT_StringMMPattern &filter ) const -{ - UT_String value; - getAttributeFilter( value ); - filter.compile( value ); -} - -template -void SceneCacheNode::setAttributeFilter( const UT_String &filter ) -{ - this->setString( filter, CH_STRING_LITERAL, pAttributeFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::getAttributeCopy( UT_String &value ) const -{ - this->evalString( value, pAttributeCopy.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setAttributeCopy( const UT_String &value ) -{ - this->setString( value, CH_STRING_LITERAL, pAttributeCopy.getToken(), 0, 0 ); -} - -template -bool SceneCacheNode::getVisibilityFilter() const -{ - return this->evalInt( pVisibilityFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setVisibilityFilter( bool visibilityFilter ) -{ - this->setInt( pVisibilityFilter.getToken(), 0, 0, visibilityFilter ); -} - -template -void SceneCacheNode::setVisibilityExpression() -{ - this->setInt( "tdisplay", 0, 0, 1 ); - this->setString( visibilityExpression, CH_PYTHON_EXPRESSION, "display", 0, 0 ); -} - -template -void SceneCacheNode::clearVisibilityExpression() -{ - this->destroyChannel( "tdisplay" ); - this->destroyChannel( "display" ); - this->setInt( "tdisplay", 0, 0, 0 ); - this->setInt( "display", 0, 0, 1 ); -} - -template -void SceneCacheNode::getTagFilter( UT_String &filter ) const -{ - this->evalString( filter, pTagFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::getTagFilter( UT_StringMMPattern &filter ) const -{ - UT_String value; - getTagFilter( value ); - filter.compile( value ); -} - -template -void SceneCacheNode::setTagFilter( const UT_String &filter ) -{ - this->setString( filter, CH_STRING_LITERAL, pTagFilter.getToken(), 0, 0 ); -} - -template -bool SceneCacheNode::getTagGroups() const -{ - return this->evalInt( pTagGroups.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setTagGroups( bool tagGroups ) -{ - return this->setInt( pTagGroups.getToken(), 0, 0, tagGroups ); -} - -template -void SceneCacheNode::getShapeFilter( UT_String &filter ) const -{ - this->evalString( filter, pShapeFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::getShapeFilter( UT_StringMMPattern &filter ) const -{ - UT_String value; - getShapeFilter( value ); - filter.compile( value ); -} - -template -void SceneCacheNode::setShapeFilter( const UT_String &filter ) -{ - this->setString( filter, CH_STRING_LITERAL, pShapeFilter.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::getFullPathName( UT_String &name ) const -{ - this->evalString( name, pFullPathName.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::setFullPathName( const UT_String &name ) -{ - this->setString( name, CH_STRING_LITERAL, pFullPathName.getToken(), 0, 0 ); -} - -template -void SceneCacheNode::referenceParent( const char *parmName ) -{ - this->getParm( parmName ).setChannelReference( 0, 0, ( std::string( "../" ) + parmName ).c_str() ); - sceneChanged(); -} - -template -void SceneCacheNode::descendantNames( const IECoreScene::SceneInterface *scene, std::vector &descendants ) -{ - if ( !scene ) - { - return; - } - - SceneInterface::NameList children; - scene->childNames( children ); - - std::string current = ""; - if ( scene->name() != SceneInterface::rootName ) - { - SceneInterface::Path p; - scene->path( p ); - SceneInterface::pathToString( p, current ); - } - - for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it ) - { - descendants.push_back( current + "/" + it->value() ); - } - - for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it ) - { - descendantNames( scene->child( *it ).get(), descendants ); - } -}; - -template -void SceneCacheNode::objectNames( const IECoreScene::SceneInterface *scene, std::vector &objects ) -{ - if ( !scene ) - { - return; - } - - if ( scene->hasObject() ) - { - objects.push_back( getFullScenePath( scene ) ); - } - - SceneInterface::NameList children; - scene->childNames( children ); - for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it ) - { - objectNames( scene->child( *it ).get(), objects ); - } -} - -template -std::string SceneCacheNode::getFullScenePath( const SceneInterface *scene ) -{ - std::string sPath; - SceneInterface::Path scenePath; - scene->path( scenePath ); - SceneInterface::pathToString( scenePath, sPath ); - return sPath; -}; - -template -void SceneCacheNode::createMenu( PRM_Name *menu, const std::vector &values ) -{ - unsigned pos = 1; - // currently menus display funny if we exceed 1500 despite the limit being 8191... - for ( std::vector::const_iterator it=values.begin(); ( it != values.end() ) && ( pos < 1500 ); ++it, ++pos ) - { - menu[pos].setToken( (*it).c_str() ); - menu[pos].setLabel( (*it).c_str() ); - } - - // mark the end of our menu - menu[pos].setToken( 0 ); -} - -template -bool SceneCacheNode::tagged( const IECoreScene::SceneInterface *scene, const UT_StringMMPattern &filter ) -{ - SceneInterface::NameList tags; - scene->readTags( tags, IECoreScene::SceneInterface::EveryTag ); - for ( SceneInterface::NameList::const_iterator it=tags.begin(); it != tags.end(); ++it ) - { - if ( UT_String( *it ).multiMatch( filter ) ) - { - return true; - } - } - - // an empty list should be equivalent to matching an empty string - if ( tags.empty() && UT_String( "" ).multiMatch( filter ) ) - { - return true; - } - - return false; -} - -template -ConstSceneInterfacePtr SceneCacheNode::scene() const -{ - if ( !this->hasParm( pFile.getToken() ) || !this->hasParm( pRoot.getToken() ) ) - { - return 0; - } - - try - { - return this->scene( getFile(), getPath() ); - } - catch( ... ) - { - return 0; - } - - return 0; -} - -template -ConstSceneInterfacePtr SceneCacheNode::scene( const std::string &fileName, const std::string &path ) -{ - ConstSceneInterfacePtr result = 0; - - try - { - result = SharedSceneInterfaces::get( fileName ); - if ( path != SceneInterface::rootName.string() ) - { - SceneInterface::Path p; - SceneInterface::stringToPath( path, p ); - result = result->scene( p, SceneInterface::NullIfMissing ); - } - } - catch ( std::exception &e ) - { - std::cerr << "Error loading \"" << fileName << "\" at location \"" << path << "\": " << e.what() << std::endl; - } - catch ( ... ) - { - std::cerr << "Unknown error loading \"" << fileName << "\" at location \"" << path << "\": " << std::endl; - } - - return result; -} - -template -double SceneCacheNode::time( OP_Context context ) const -{ - return context.getTime() + CHgetManager()->getSecsPerSample(); -} - -template -Imath::M44d SceneCacheNode::worldTransform( const std::string &fileName, const std::string &path, double time ) -{ - ConstSceneInterfacePtr scene = this->scene( fileName, SceneInterface::rootName ); - - SceneInterface::Path p; - SceneInterface::stringToPath( path, p ); - Imath::M44d result = scene->readTransformAsMatrix( time ); - for ( SceneInterface::Path::const_iterator it = p.begin(); scene && it != p.end(); ++it ) - { - scene = scene->child( *it, SceneInterface::NullIfMissing ); - if ( !scene ) - { - break; - } - - result = scene->readTransformAsMatrix( time ) * result; - } - - return result; -} - -template -bool SceneCacheNode::visibility( double frame ) const -{ - OP_Context context; - context.setFrame( frame ); - double t = time( context ); - - ConstSceneInterfacePtr scene = this->scene( getFile(), SceneInterface::rootName ); - - std::string path = getPath(); - SceneInterface::Path p; - SceneInterface::stringToPath( path, p ); - if ( scene->hasAttribute( IECoreScene::SceneInterface::visibilityName ) ) - { - if( !IECore::runTimeCast< const IECore::BoolData >( scene->readAttribute( IECoreScene::SceneInterface::visibilityName, t ) )->readable() ) - { - return false; - } - } - - for ( SceneInterface::Path::const_iterator it = p.begin(); scene && it != p.end(); ++it ) - { - scene = scene->child( *it, SceneInterface::NullIfMissing ); - if ( !scene ) - { - break; - } - - if ( scene->hasAttribute( IECoreScene::SceneInterface::visibilityName ) ) - { - if( !IECore::runTimeCast< const IECore::BoolData >( scene->readAttribute( IECoreScene::SceneInterface::visibilityName, t ) )->readable() ) - { - return false; - } - } - - } - - return true; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Known Specializations -////////////////////////////////////////////////////////////////////////////////////////// - -namespace IECoreHoudini -{ - template class SceneCacheNode; - template class SceneCacheNode; - template class SceneCacheNode; - template class SceneCacheNode; - template class SceneCacheNode; -} diff --git a/src/IECoreHoudini/ToHoudiniAttribConverter.cpp b/src/IECoreHoudini/ToHoudiniAttribConverter.cpp deleted file mode 100644 index 469598b2e9..0000000000 --- a/src/IECoreHoudini/ToHoudiniAttribConverter.cpp +++ /dev/null @@ -1,102 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniAttribConverter.h" - -using namespace IECore; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniAttribConverter ); - -ToHoudiniAttribConverter::ToHoudiniAttribConverter( const Data *data, const std::string &description ) - : ToHoudiniConverter( description, DataTypeId ) -{ - srcParameter()->setValue( (Data *)data ); -} - -ToHoudiniAttribConverter::~ToHoudiniAttribConverter() -{ -} - -GA_RWAttributeRef ToHoudiniAttribConverter::convert( std::string name, GU_Detail *geo ) const -{ - return doConversion( (const IECore::Data *)srcParameter()->getValidatedValue(), name, geo ); -} - -GA_RWAttributeRef ToHoudiniAttribConverter::convert( std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - return doConversion( (const IECore::Data *)srcParameter()->getValidatedValue(), name, geo, range ); -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -ToHoudiniAttribConverterPtr ToHoudiniAttribConverter::create( const Data *data ) -{ - const TypesToFnsMap *m = typesToFns(); - - TypesToFnsMap::const_iterator it = m->find( Types( data->typeId() ) ); - if( it!=m->end() ) - { - return it->second( data ); - } - - return 0; -} - -void ToHoudiniAttribConverter::registerConverter( IECore::TypeId fromType, CreatorFn creator ) -{ - TypesToFnsMap *m = typesToFns(); - m->insert( TypesToFnsMap::value_type( Types( fromType ), creator ) ); -} - -ToHoudiniAttribConverter::TypesToFnsMap *ToHoudiniAttribConverter::typesToFns() -{ - static TypesToFnsMap *m = new TypesToFnsMap; - return m; -} - -///////////////////////////////////////////////////////////////////////////////// -// Implementation of nested Types class -///////////////////////////////////////////////////////////////////////////////// - -ToHoudiniAttribConverter::Types::Types( IECore::TypeId from ) : fromType( from ) -{ -} - -bool ToHoudiniAttribConverter::Types::operator < ( const Types &other ) const -{ - return fromType < other.fromType; -} diff --git a/src/IECoreHoudini/ToHoudiniCompoundObjectConverter.cpp b/src/IECoreHoudini/ToHoudiniCompoundObjectConverter.cpp deleted file mode 100644 index 3cfe03ab7f..0000000000 --- a/src/IECoreHoudini/ToHoudiniCompoundObjectConverter.cpp +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniCompoundObjectConverter.h" - -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" - -#include "IECore/CompoundObject.h" - -using namespace IECore; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniCompoundObjectConverter ); - -ToHoudiniGeometryConverter::Description ToHoudiniCompoundObjectConverter::m_description( CompoundObjectTypeId ); - -ToHoudiniCompoundObjectConverter::ToHoudiniCompoundObjectConverter( const Object *object ) : - ToHoudiniGeometryConverter( object, "Converts the members of an IECore::CompoundObject to a Houdini GU_Detail." ) -{ -} - -ToHoudiniCompoundObjectConverter::~ToHoudiniCompoundObjectConverter() -{ -} - -bool ToHoudiniCompoundObjectConverter::doConversion( const Object *object, GU_Detail *geo ) const -{ - const CompoundObject *compound = IECore::runTimeCast( object ); - if ( !compound ) - { - return false; - } - - GU_DetailHandle handle; - handle.allocateAndSet( geo, false ); - size_t numPrims = geo->getNumPrimitives(); - - std::string name = nameParameter()->getTypedValue(); - if ( name != "" ) - { - name += "/"; - } - - ToHoudiniCortexObjectConverterPtr converter = new ToHoudiniCortexObjectConverter( object ); - - const CompoundObject::ObjectMap &members = compound->members(); - for ( CompoundObject::ObjectMap::const_iterator it = members.begin(); it != members.end(); ++it ) - { - converter->nameParameter()->setTypedValue( name + it->first.string() ); - converter->srcParameter()->setValue( it->second ); - converter->convert( handle ); - } - - return ( (size_t)geo->getNumPrimitives() > numPrims ); -} - -void ToHoudiniCompoundObjectConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const -{ -} diff --git a/src/IECoreHoudini/ToHoudiniConverter.cpp b/src/IECoreHoudini/ToHoudiniConverter.cpp deleted file mode 100644 index 73965512c0..0000000000 --- a/src/IECoreHoudini/ToHoudiniConverter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniConverter.h" - -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniConverter ); - -ToHoudiniConverter::ToHoudiniConverter( const std::string &description, IECore::TypeId supportedType ) - : IECore::FromCoreConverter( description, supportedType ) -{ -} - -ToHoudiniConverter::~ToHoudiniConverter() -{ -} diff --git a/src/IECoreHoudini/ToHoudiniCortexObjectConverter.cpp b/src/IECoreHoudini/ToHoudiniCortexObjectConverter.cpp deleted file mode 100644 index 5137a614ec..0000000000 --- a/src/IECoreHoudini/ToHoudiniCortexObjectConverter.cpp +++ /dev/null @@ -1,172 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/ToHoudiniStringAttribConverter.h" - -#include "SYS/SYS_Types.h" -#include "UT/UT_StringMMPattern.h" - - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniCortexObjectConverter ); - -ToHoudiniGeometryConverter::Description ToHoudiniCortexObjectConverter::m_description( ObjectTypeId ); - -ToHoudiniCortexObjectConverter::ToHoudiniCortexObjectConverter( const Object *object ) : - ToHoudiniGeometryConverter( object, "Converts an IECore::Object to a Houdini GU_Detail." ) -{ -} - -ToHoudiniCortexObjectConverter::~ToHoudiniCortexObjectConverter() -{ -} - -bool ToHoudiniCortexObjectConverter::doConversion( const Object *object, GU_Detail *geo ) const -{ - ConstObjectPtr result = filterAttribs( object ); - - GA_Size numPrims = geo->getNumPrimitives(); - - CortexPrimitive::build( geo, result.get() ); - - GA_OffsetList offsets; - offsets.append( geo->primitiveOffset( numPrims ) ); - GA_Range newPrims( geo->getPrimitiveMap(), offsets ); - - if ( nameParameter()->getTypedValue() != "" ) - { - setName( geo, newPrims ); - } - // backwards compatibility with older data - else if ( const BlindDataHolder *holder = IECore::runTimeCast( object ) ) - { - if ( const StringData *nameData = holder->blindData()->member( "name" ) ) - { - ToHoudiniStringVectorAttribConverter::convertString( "name", nameData->readable(), geo, newPrims ); - } - } - - return ( (GA_Size)geo->getNumPrimitives() > numPrims ); -} - -void ToHoudiniCortexObjectConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const -{ - GA_Primitive *hPrim = geo->getPrimitiveList().get( prims.begin().getOffset() ); - - if ( hPrim->getTypeId() != CortexPrimitive::typeId() ) - { - return; - } - - const Primitive *input = IECore::runTimeCast( srcParameter()->getValue() ); - - Primitive *output = IECore::runTimeCast( ((CortexPrimitive *)hPrim)->getObject() ); - - if ( !input || !output ) - { - return; - } - - const char *filter = attributeFilterParameter()->getTypedValue().c_str(); - for ( PrimitiveVariableMap::const_iterator it = input->variables.begin() ; it != input->variables.end(); ++it ) - { - if ( !UT_String( it->first ).multiMatch( filter ) ) - { - continue; - } - - if ( output->isPrimitiveVariableValid( it->second ) ) - { - output->variables[it->first] = it->second; - } - } - - if ( UT_String( "P" ).multiMatch( filter ) ) - { - geo->setPos3( points.begin().getOffset(), IECore::convert( input->bound().center() ) ); - } -} - -ConstObjectPtr ToHoudiniCortexObjectConverter::filterAttribs( const Object *object ) const -{ - const Primitive *primitive = IECore::runTimeCast( object ); - if ( !primitive ) - { - return object; - } - - const char *filter = attributeFilterParameter()->getTypedValue().c_str(); - - std::vector variablesToErase; - const PrimitiveVariableMap &variables = primitive->variables; - for ( PrimitiveVariableMap::const_iterator it = variables.begin(); it != variables.end(); ++it ) - { - if ( !UT_String( it->first ).multiMatch( filter ) ) - { - variablesToErase.push_back( it->first ); - } - } - - if ( variablesToErase.empty() ) - { - return object; - } - - PrimitivePtr result = primitive->copy(); - PrimitiveVariableMap &resultVariables = result->variables; - for ( size_t i = 0; i < variablesToErase.size(); ++i ) - { - resultVariables.erase( variablesToErase[i] ); - } - - return result; -} diff --git a/src/IECoreHoudini/ToHoudiniCurvesConverter.cpp b/src/IECoreHoudini/ToHoudiniCurvesConverter.cpp deleted file mode 100644 index 88facccc1b..0000000000 --- a/src/IECoreHoudini/ToHoudiniCurvesConverter.cpp +++ /dev/null @@ -1,251 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniCurvesConverter.h" - -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/ToHoudiniPolygonsConverter.h" -#include "IECoreHoudini/TypeTraits.h" - -#include "IECore/DespatchTypedData.h" - -#include "GU/GU_PrimNURBCurve.h" -#include "GU/GU_PrimPoly.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniCurvesConverter ); - -ToHoudiniGeometryConverter::Description ToHoudiniCurvesConverter::m_description( CurvesPrimitive::staticTypeId() ); - -ToHoudiniCurvesConverter::ToHoudiniCurvesConverter( const IECore::Object *object ) : - ToHoudiniGeometryConverter( object, "Converts an IECoreScene::CurvesPrimitive to a Houdini GU_Detail." ) -{ -} - -ToHoudiniCurvesConverter::~ToHoudiniCurvesConverter() -{ -} - -bool ToHoudiniCurvesConverter::doConversion( const Object *object, GU_Detail *geo ) const -{ - const CurvesPrimitive *curves = static_cast( object ); - if ( !curves ) - { - return false; - } - - bool periodic = curves->periodic(); - bool duplicatedEnds = !periodic && ( curves->basis() == CubicBasisf::bSpline() ); - - bool isLinear = curves->basis() == CubicBasisf::linear(); - - if ( isLinear && !periodic ) - { - GA_Range newPoints = appendPoints( geo, curves->variableSize( PrimitiveVariable::Vertex ) ); - if ( !newPoints.isValid() || newPoints.empty() ) - { - return false; - } - - GA_OffsetList pointOffsets; - pointOffsets.harden( newPoints.getEntries() ); - pointOffsets.setEntries( newPoints.getEntries() ); - - size_t i = 0; - GA_Offset start, end; - for( GA_Iterator it( newPoints ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset, ++i ) - { - pointOffsets.set( i, offset ); - } - } - - const std::vector &verticesPerCurve = curves->verticesPerCurve()->readable(); - - GA_OffsetList offsets; - offsets.harden( verticesPerCurve.size() ); - offsets.setEntries( verticesPerCurve.size() ); - - size_t vertCount = 0; - size_t numPrims = geo->getNumPrimitives(); - - for( size_t f=0, numFaces = verticesPerCurve.size(); f < numFaces; ++f ) - { - GU_PrimPoly *poly = GU_PrimPoly::build( geo, 0, GU_POLY_OPEN, 0 ); - offsets.set( f, geo->primitiveOffset( numPrims + f ) ); - - for( size_t v=0; v < (size_t)verticesPerCurve[f]; ++v ) - { - poly->appendVertex( pointOffsets.get( vertCount ) ); - vertCount++; - } - } - - GA_Range newPrims( geo->getPrimitiveMap(), offsets ); - transferAttribs( geo, newPoints, newPrims ); - - return true; - } - else - { - size_t numPoints = curves->variableSize( PrimitiveVariable::Vertex ); - if ( duplicatedEnds ) - { - numPoints -= 4 * curves->numCurves(); - } - - GA_Range newPoints = appendPoints( geo, numPoints ); - if ( !newPoints.isValid() || newPoints.empty() ) - { - return false; - } - - GA_OffsetList pointOffsets; - pointOffsets.harden( newPoints.getEntries() ); - pointOffsets.setEntries( newPoints.getEntries() ); - - size_t i = 0; - GA_Offset start, end; - for( GA_Iterator it( newPoints ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset, ++i ) - { - pointOffsets.set( i, offset ); - } - } - - const std::vector &verticesPerCurve = curves->verticesPerCurve()->readable(); - int order = ( curves->basis() == CubicBasisf::bSpline() ) ? 4 : 2; - bool interpEnds = !(periodic && ( curves->basis() == CubicBasisf::bSpline() )); - - GA_OffsetList offsets; - offsets.harden( verticesPerCurve.size() ); - offsets.setEntries( verticesPerCurve.size() ); - - size_t vertCount = 0; - size_t numPrims = geo->getNumPrimitives(); - for( size_t c=0; c < verticesPerCurve.size(); ++c ) - { - size_t numVerts = duplicatedEnds ? verticesPerCurve[c] - 4 : verticesPerCurve[c]; - GU_PrimNURBCurve *curve = GU_PrimNURBCurve::build( geo, numVerts, order, periodic, interpEnds, false ); - if ( !curve ) - { - return false; - } - - offsets.set( c, geo->primitiveOffset( numPrims + c ) ); - - for ( size_t v=0; v < numVerts; ++v ) - { - curve->setVertexPoint( v, pointOffsets.get( vertCount + v ) ); - } - - vertCount += numVerts; - } - - GA_Range newPrims( geo->getPrimitiveMap(), offsets ); - transferAttribs( geo, newPoints, newPrims ); - - return true; - } - - -} - -PrimitiveVariable ToHoudiniCurvesConverter::processPrimitiveVariable( const IECoreScene::Primitive *primitive, const PrimitiveVariable &primVar ) const -{ - const CurvesPrimitive *curves = static_cast( primitive ); - if ( !curves ) - { - return primVar; - } - - // adjust for duplicated end points - bool duplicatedEnds = !curves->periodic() && ( curves->basis() == CubicBasisf::bSpline() ); - if ( duplicatedEnds && primVar.interpolation == IECoreScene::PrimitiveVariable::Vertex ) - { - RemoveDuplicateEnds func( curves->verticesPerCurve()->readable() ); - DataPtr data = despatchTypedData( primVar.data.get(), func ); - return PrimitiveVariable( IECoreScene::PrimitiveVariable::Vertex, data ); - } - - return primVar; -} - -void ToHoudiniCurvesConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const -{ - const Primitive *primitive = IECore::runTimeCast( srcParameter()->getValidatedValue() ); - if ( primitive ) - { - transferAttribValues( primitive, geo, points, prims, PrimitiveVariable::Vertex ); - } - - setName( geo, prims ); -} - -ToHoudiniCurvesConverter::RemoveDuplicateEnds::RemoveDuplicateEnds( const std::vector &vertsPerCurve ) : m_vertsPerCurve( vertsPerCurve ) -{ -} - -template -ToHoudiniCurvesConverter::RemoveDuplicateEnds::ReturnType ToHoudiniCurvesConverter::RemoveDuplicateEnds::operator()( const T *data ) const -{ - assert( data ); - - typedef typename T::ValueType::value_type ValueType; - - const std::vector &origValues = data->readable(); - - typename T::Ptr result = new T(); - std::vector &newValues = result->writable(); - newValues.reserve( origValues.size() ); - - size_t index = 0; - for ( size_t i=0; i < m_vertsPerCurve.size(); i++ ) - { - for ( size_t j=0; j < (size_t)m_vertsPerCurve[i]; j++, index++ ) - { - if ( j > 1 && j < (size_t)m_vertsPerCurve[i]-2 ) - { - newValues.push_back( origValues[index] ); - } - } - } - - return result; -} diff --git a/src/IECoreHoudini/ToHoudiniGeometryConverter.cpp b/src/IECoreHoudini/ToHoudiniGeometryConverter.cpp deleted file mode 100644 index af194642f2..0000000000 --- a/src/IECoreHoudini/ToHoudiniGeometryConverter.cpp +++ /dev/null @@ -1,514 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" - -#include "IECoreHoudini/Convert.h" -#include "IECoreHoudini/ToHoudiniAttribConverter.h" -#include "IECoreHoudini/ToHoudiniStringAttribConverter.h" - -#include "IECore/CompoundData.h" -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" - -#include "SYS/SYS_Types.h" -#include "UT/UT_StringMMPattern.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniGeometryConverter ); - -ToHoudiniGeometryConverter::ToHoudiniGeometryConverter( const IECore::Object *object, const std::string &description ) - : ToHoudiniConverter( description, ObjectTypeId ) -{ - srcParameter()->setValue( const_cast( object ) ); // safe because the object is const in doConversion - - m_nameParameter = new StringParameter( - "name", - "The name given to the converted primitive(s). If empty, primitives will be unnamed", - "" - ); - - m_attributeFilterParameter = new StringParameter( - "attributeFilter", - "A list of attribute names to convert, if they exist. Uses Houdini matching syntax.", - "*" - ); - - m_convertStandardAttributesParameter = new BoolParameter( - "convertStandardAttributes", - "Performs automated conversion of standard PrimitiveVariables to Houdini Attributes (i.e. Pref->rest ; Cs->Cd)", - true - ); - - parameters()->addParameter( m_nameParameter ); - parameters()->addParameter( m_attributeFilterParameter ); - parameters()->addParameter( m_convertStandardAttributesParameter ); -} - -ToHoudiniGeometryConverter::~ToHoudiniGeometryConverter() -{ -} - -BoolParameter *ToHoudiniGeometryConverter::convertStandardAttributesParameter() -{ - return m_convertStandardAttributesParameter.get(); -} - -const BoolParameter *ToHoudiniGeometryConverter::convertStandardAttributesParameter() const -{ - return m_convertStandardAttributesParameter.get(); -} - -StringParameter *ToHoudiniGeometryConverter::nameParameter() -{ - return m_nameParameter.get(); -} - -const StringParameter *ToHoudiniGeometryConverter::nameParameter() const -{ - return m_nameParameter.get(); -} - -StringParameter *ToHoudiniGeometryConverter::attributeFilterParameter() -{ - return m_attributeFilterParameter.get(); -} - -const StringParameter *ToHoudiniGeometryConverter::attributeFilterParameter() const -{ - return m_attributeFilterParameter.get(); -} - -bool ToHoudiniGeometryConverter::convert( GU_DetailHandle handle ) const -{ - ConstCompoundObjectPtr operands = parameters()->getTypedValidatedValue(); - GU_DetailHandleAutoWriteLock writeHandle( handle ); - - GU_Detail *geo = writeHandle.getGdp(); - if ( !geo ) - { - return false; - } - - bool result = doConversion( srcParameter()->getValidatedValue(), geo ); - if ( result ) - { - geo->bumpAllDataIds(); - geo->incrementMetaCacheCount(); - } - - return result; -} - -GA_Range ToHoudiniGeometryConverter::appendPoints( GA_Detail *geo, size_t numPoints ) const -{ - if ( !numPoints ) - { - return GA_Range(); - } - - GA_Offset firstPoint = geo->appendPointBlock( numPoints ); - - return GA_Range( geo->getPointMap(), firstPoint, firstPoint + numPoints ); -} - -PrimitiveVariable ToHoudiniGeometryConverter::processPrimitiveVariable( const IECoreScene::Primitive *primitive, const PrimitiveVariable &primVar ) const -{ - return primVar; -} - -void ToHoudiniGeometryConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const -{ - const Primitive *primitive = IECore::runTimeCast( srcParameter()->getValidatedValue() ); - if ( primitive ) - { - transferAttribValues( primitive, geo, points, prims ); - } - - setName( geo, prims ); -} - -void ToHoudiniGeometryConverter::setName( GU_Detail *geo, const GA_Range &prims ) const -{ - // add the name attribute based on the parameter - const std::string &name = nameParameter()->getTypedValue(); - if ( name != "" && prims.isValid() ) - { - ToHoudiniStringVectorAttribConverter::convertString( "name", name, geo, prims ); - } -} - -void ToHoudiniGeometryConverter::transferAttribValues( - const Primitive *primitive, GU_Detail *geo, - const GA_Range &points, const GA_Range &prims, - PrimitiveVariable::Interpolation vertexInterpolation, - PrimitiveVariable::Interpolation primitiveInterpolation, - PrimitiveVariable::Interpolation pointInterpolation, - PrimitiveVariable::Interpolation detailInterpolation -) const -{ - GA_OffsetList offsets; - if( prims.isValid() ) - { - const GA_PrimitiveList &primitives = geo->getPrimitiveList(); - - GA_Offset start, end; - for( GA_Iterator it( prims ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset ) - { - const GA_Primitive *prim = primitives.get( offset ); - /// \todo: we shouldn't reverse winding for open polys (eg linear curves) - bool reverseWinding = ( prim->getTypeId() == GEO_PRIMPOLY ); - size_t numPrimVerts = prim->getVertexCount(); - for( size_t v = 0; v < numPrimVerts; v++ ) - { - if( reverseWinding ) - { - offsets.append( prim->getVertexOffset( numPrimVerts - 1 - v ) ); - } - else - { - offsets.append( prim->getVertexOffset( v ) ); - } - } - } - } - } - - GA_Range vertRange( geo->getVertexMap(), offsets ); - - UT_String filter( attributeFilterParameter()->getTypedValue() ); - - bool convertStandardAttributes = m_convertStandardAttributesParameter->getTypedValue(); - - // process all primvars with UV interpretation - for ( const auto &it : primitive->variables) - { - - if ( !UT_String( it.first ).multiMatch( filter ) ) - { - continue; - } - - if (const V2fVectorData *uvData = runTimeCast ( it.second.data.get() ) ) - { - if ( uvData->getInterpretation() != GeometricData::UV ) - { - continue; - } - - PrimitiveVariable::IndexedView uvIndexedView ( it.second ); - - // Houdini prefers a V3f uvw rather than V2f uv, - // though they advise setting the 3rd component to 0. - std::vector uvw; - uvw.reserve( uvIndexedView.size() ); - for ( size_t i=0; i < uvIndexedView.size(); ++i ) - { - uvw.emplace_back( uvIndexedView[i][0], uvIndexedView[i][1], 0 ); - } - - GA_Range range; - if( it.second.interpolation == pointInterpolation ) - { - range = points; - } - else if( it.second.interpolation == primitiveInterpolation ) - { - range = prims; - } - else if( it.second.interpolation == vertexInterpolation ) - { - range = vertRange; - } - else - { - IECore::msg( - IECore::MessageHandler::Warning, - "ToHoudiniGeometryConverter", - "UV PrimitiveVariable '" + it.first + "' has invalid interpolation. Ignoring." - ); - continue; - } - - - V3fVectorData::Ptr uvwData = new V3fVectorData( uvw ); - uvwData->setInterpretation( GeometricData::UV ); - - ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( uvwData.get() ); - converter->convert( it.first, geo, range ); - filter += " ^" + it.first; - } - } - - - UT_StringMMPattern attribFilter; - attribFilter.compile( filter ); - - // add the primitive variables to the various GEO_AttribDicts based on interpolation type - for ( PrimitiveVariableMap::const_iterator it=primitive->variables.begin() ; it != primitive->variables.end(); it++ ) - { - if( !primitive->isPrimitiveVariableValid( it->second ) ) - { - IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniGeometryConverter", "PrimitiveVariable " + it->first + " is invalid. Ignoring." ); - continue; - } - - UT_String varName( it->first ); - if ( !varName.multiMatch( attribFilter ) ) - { - continue; - } - - PrimitiveVariable primVar = processPrimitiveVariable( primitive, it->second ); - - DataPtr data = nullptr; - ToHoudiniAttribConverterPtr converter = nullptr; - - if( primVar.indices && primVar.data->typeId() == StringVectorDataTypeId ) - { - // we want to process the indexed strings rather than the expanded strings - converter = ToHoudiniAttribConverter::create( primVar.data.get() ); - if( ToHoudiniStringVectorAttribConverter *stringVectorConverter = IECore::runTimeCast( converter.get() ) ) - { - stringVectorConverter->indicesParameter()->setValidatedValue( primVar.indices.get() ); - } - } - else - { - // all other primitive variables must be expanded - data = primVar.expandedData(); - converter = ToHoudiniAttribConverter::create( data.get() ); - } - - if ( !converter ) - { - continue; - } - - const std::string name = ( convertStandardAttributes ) ? processPrimitiveVariableName( it->first ) : it->first; - - if ( primVar.interpolation == detailInterpolation ) - { - // add detail attribs - try - { - converter->convert( name, geo ); - } - catch ( std::exception &e ) - { - throw IECore::Exception( "PrimitiveVariable \"" + it->first + "\" could not be converted as a Detail Attrib: " + e.what() ); - } - } - else if ( primVar.interpolation == pointInterpolation ) - { - -#if UT_MAJOR_VERSION_INT < 15 - - // add point attribs - if ( name == "P" ) - { - // special case for P - transferP( runTimeCast( primVar.data.get() ), geo, points ); - } - else - -#endif - - { - try - { - GA_RWAttributeRef attrRef = converter->convert( name, geo, points ); - - // mark rest as non-transforming so it doesn't get manipulated once inside Houdini - if ( name == "rest" || name == "Pref" ) - { - -#if UT_MAJOR_VERSION_INT >= 15 - - attrRef.setTypeInfo( GA_TYPE_VOID ); - -#else - - attrRef.getAttribute()->setNonTransforming( true ); - -#endif - - } - } - catch ( std::exception &e ) - { - throw IECore::Exception( "PrimitiveVariable \"" + it->first + "\" could not be converted as a Point Attrib: " + e.what() ); - } - } - } - else if ( primVar.interpolation == primitiveInterpolation ) - { - // add primitive attribs - try - { - converter->convert( name, geo, prims ); - } - catch ( std::exception &e ) - { - throw IECore::Exception( "PrimitiveVariable \"" + it->first + "\" could not be converted as a Primitive Attrib: " + e.what() ); - } - } - else if ( primVar.interpolation == vertexInterpolation ) - { - // add vertex attribs - try - { - converter->convert( name, geo, vertRange ); - } - catch ( std::exception &e ) - { - throw IECore::Exception( "PrimitiveVariable \"" + it->first + "\" could not be converted as a Vertex Attrib: " + e.what() ); - } - } - } - - // backwards compatibility with older data - const StringData *nameData = primitive->blindData()->member( "name" ); - if ( nameData && prims.isValid() ) - { - ToHoudiniStringVectorAttribConverter::convertString( "name", nameData->readable(), geo, prims ); - } -} - -void ToHoudiniGeometryConverter::transferP( const IECore::V3fVectorData *positions, GU_Detail *geo, const GA_Range &points ) const -{ - if ( !positions ) - { - return; - } - - const std::vector &pos = positions->readable(); - - size_t i = 0; - for ( GA_Iterator it=points.begin(); !it.atEnd(); ++it, ++i ) - { - geo->setPos3( it.getOffset(), IECore::convert( pos[i] ) ); - } -} - -const std::string ToHoudiniGeometryConverter::processPrimitiveVariableName( const std::string &name ) const -{ - /// \todo: This should probably be some formal static map. Make sure to update FromHoudiniGeometryConverter as well. - if ( name == "Cs" ) - { - return "Cd"; - } - else if ( name == "Os" ) - { - return "Alpha"; - } - else if ( name == "Pref" ) - { - return "rest"; - } - else if ( name == "width" ) - { - return "pscale"; - } - - return name; -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -ToHoudiniGeometryConverterPtr ToHoudiniGeometryConverter::create( const Object *object ) -{ - const TypesToFnsMap *m = typesToFns(); - TypesToFnsMap::const_iterator it = m->find( Types( object->typeId() ) ); - if( it!=m->end() ) - { - return it->second( object ); - } - - // no exact match, so check for base class matches - const std::vector &bases = RunTimeTyped::baseTypeIds( object->typeId() ); - for ( std::vector::const_iterator it = bases.begin(); it != bases.end(); ++it ) - { - TypesToFnsMap::const_iterator cIt = m->find( Types( *it ) ); - if ( cIt != m->end() ) - { - return cIt->second( object ); - } - } - - return 0; -} - -void ToHoudiniGeometryConverter::registerConverter( IECore::TypeId fromType, CreatorFn creator ) -{ - TypesToFnsMap *m = typesToFns(); - m->insert( TypesToFnsMap::value_type( Types( fromType ), creator ) ); -} - -ToHoudiniGeometryConverter::TypesToFnsMap *ToHoudiniGeometryConverter::typesToFns() -{ - static TypesToFnsMap *m = new TypesToFnsMap; - return m; -} - -void ToHoudiniGeometryConverter::supportedTypes( std::set &types ) -{ - types.clear(); - - const TypesToFnsMap *m = typesToFns(); - for ( TypesToFnsMap::const_iterator it=m->begin(); it != m->end(); it ++ ) - { - types.insert( it->first.fromType ); - } -} - -///////////////////////////////////////////////////////////////////////////////// -// Implementation of nested Types class -///////////////////////////////////////////////////////////////////////////////// - -ToHoudiniGeometryConverter::Types::Types( IECore::TypeId from ) : fromType( from ) -{ -} - -bool ToHoudiniGeometryConverter::Types::operator < ( const Types &other ) const -{ - return fromType < other.fromType; -} diff --git a/src/IECoreHoudini/ToHoudiniNumericAttribConverter.cpp b/src/IECoreHoudini/ToHoudiniNumericAttribConverter.cpp deleted file mode 100644 index a22b7b2836..0000000000 --- a/src/IECoreHoudini/ToHoudiniNumericAttribConverter.cpp +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniNumericAttribConverter.h" - -using namespace IECore; - -namespace IECoreHoudini -{ - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniFloatVectorAttribConverter, ToHoudiniFloatVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV2fVectorAttribConverter, ToHoudiniV2fVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV3fVectorAttribConverter, ToHoudiniV3fVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniColor3fVectorAttribConverter, ToHoudiniColor3fVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniIntVectorAttribConverter, ToHoudiniIntVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV2iVectorAttribConverter, ToHoudiniV2iVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV3iVectorAttribConverter, ToHoudiniV3iVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM33fVectorAttribConverter, ToHoudiniM33fVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM44fVectorAttribConverter, ToHoudiniM44fVectorAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM44dVectorAttribConverter, ToHoudiniM44dVectorAttribConverterTypeId ) - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniFloatDetailAttribConverter, ToHoudiniFloatDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV2fDetailAttribConverter, ToHoudiniV2fDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV3fDetailAttribConverter, ToHoudiniV3fDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniColor3fDetailAttribConverter, ToHoudiniColor3fDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniIntDetailAttribConverter, ToHoudiniIntDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV2iDetailAttribConverter, ToHoudiniV2iDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniV3iDetailAttribConverter, ToHoudiniV3iDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM33fDetailAttribConverter, ToHoudiniM33fDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM44fDetailAttribConverter, ToHoudiniM44fDetailAttribConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( ToHoudiniM44dDetailAttribConverter, ToHoudiniM44dDetailAttribConverterTypeId ) - -// Explicit instantiations for numeric vector classes -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; -template class ToHoudiniNumericVectorAttribConverter; - -// Explicit instantiations for numeric detail classes -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; -template class ToHoudiniNumericDetailAttribConverter; - -} // namespace IECoreHoudini diff --git a/src/IECoreHoudini/ToHoudiniPointsConverter.cpp b/src/IECoreHoudini/ToHoudiniPointsConverter.cpp deleted file mode 100644 index decb07d2fa..0000000000 --- a/src/IECoreHoudini/ToHoudiniPointsConverter.cpp +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniPointsConverter.h" - -#include "GU/GU_PrimPart.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniPointsConverter ); - -ToHoudiniGeometryConverter::Description ToHoudiniPointsConverter::m_description( IECoreScene::PointsPrimitive::staticTypeId() ); - -ToHoudiniPointsConverter::ToHoudiniPointsConverter( const Object *object ) : - ToHoudiniGeometryConverter( object, "Converts an IECoreScene::PointsPrimitive to a Houdini GU_Detail." ) -{ -} - -ToHoudiniPointsConverter::~ToHoudiniPointsConverter() -{ -} - -bool ToHoudiniPointsConverter::doConversion( const Object *object, GU_Detail *geo ) const -{ - const PointsPrimitive *points = static_cast( object ); - if ( !points ) - { - return false; - } - - size_t numPrims = geo->getNumPrimitives(); - GU_PrimParticle *system = GU_PrimParticle::build( geo, points->getNumPoints(), true ); - GA_Range newPoints = system->getPointRange(); - if ( !newPoints.isValid() || newPoints.empty() ) - { - return false; - } - - GA_OffsetList offsets; - offsets.append( geo->primitiveOffset( numPrims ) ); - GA_Range newPrims( geo->getPrimitiveMap(), offsets ); - - transferAttribs( geo, newPoints, newPrims ); - - return true; -} - -void ToHoudiniPointsConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const -{ - const Primitive *primitive = IECore::runTimeCast( srcParameter()->getValidatedValue() ); - if ( primitive ) - { - transferAttribValues( primitive, geo, points, prims, PrimitiveVariable::Vertex ); - } - - setName( geo, prims ); -} diff --git a/src/IECoreHoudini/ToHoudiniPolygonsConverter.cpp b/src/IECoreHoudini/ToHoudiniPolygonsConverter.cpp deleted file mode 100644 index d331993666..0000000000 --- a/src/IECoreHoudini/ToHoudiniPolygonsConverter.cpp +++ /dev/null @@ -1,186 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniPolygonsConverter.h" - -#include "IECoreHoudini/ToHoudiniStringAttribConverter.h" - -#include "GU/GU_EdgeCreaseParms.h" -#include "GU/GU_PrimPoly.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreHoudini; - -namespace -{ - -const InternedString g_interpolationAttrib( "ieMeshInterpolation" ); -const InternedString g_catmullClark( "catmullClark" ); -const InternedString g_poly( "poly" ); -const InternedString g_subdiv( "subdiv" ); -const InternedString g_cornerWeightAttrib( "cornerweight" ); - -} // namespace - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniPolygonsConverter ); - -ToHoudiniGeometryConverter::Description ToHoudiniPolygonsConverter::m_description( IECoreScene::MeshPrimitive::staticTypeId() ); - -ToHoudiniPolygonsConverter::ToHoudiniPolygonsConverter( const Object *object ) : - ToHoudiniGeometryConverter( object, "Converts an IECoreScene::MeshPrimitive to a Houdini GU_Detail." ) -{ -} - -ToHoudiniPolygonsConverter::~ToHoudiniPolygonsConverter() -{ -} - -bool ToHoudiniPolygonsConverter::doConversion( const Object *object, GU_Detail *geo ) const -{ - const MeshPrimitive *mesh = static_cast( object ); - if ( !mesh ) - { - return false; - } - - GA_Range newPoints = appendPoints( geo, mesh->variableSize( PrimitiveVariable::Vertex ) ); - if ( !newPoints.isValid() || newPoints.empty() ) - { - return false; - } - - GA_OffsetList pointOffsets; - pointOffsets.harden( newPoints.getEntries() ); - pointOffsets.setEntries( newPoints.getEntries() ); - - size_t i = 0; - GA_Offset start, end; - for( GA_Iterator it( newPoints ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end; ++offset, ++i ) - { - pointOffsets.set( i, offset ); - } - } - - const std::vector &vertexIds = mesh->vertexIds()->readable(); - const std::vector &verticesPerFace = mesh->verticesPerFace()->readable(); - - GA_OffsetList offsets; - offsets.harden( verticesPerFace.size() ); - offsets.setEntries( verticesPerFace.size() ); - - size_t vertCount = 0; - size_t numPrims = geo->getNumPrimitives(); - for ( size_t f = 0, numFaces = verticesPerFace.size(); f < numFaces; ++f ) - { - GU_PrimPoly *poly = GU_PrimPoly::build( geo, 0, GU_POLY_CLOSED, 0 ); - offsets.set( f, geo->primitiveOffset( numPrims + f ) ); - - for( size_t v=0; v < (size_t)verticesPerFace[f]; ++v ) - { - poly->appendVertex( pointOffsets.get( vertexIds[ vertCount + verticesPerFace[f] - 1 - v ] ) ); - } - - vertCount += verticesPerFace[f]; - } - - GA_Range newPrims( geo->getPrimitiveMap(), offsets ); - transferAttribs( geo, newPoints, newPrims ); - - // add the interpolation type - if ( newPrims.isValid() ) - { - const std::string &interpolation = ( g_catmullClark == mesh->interpolation() ) ? g_subdiv : g_poly; - ToHoudiniStringVectorAttribConverter::convertString( g_interpolationAttrib, interpolation, geo, newPrims ); - } - - const auto &cornerIds = mesh->cornerIds()->readable(); - if( !cornerIds.empty() ) - { - // Houdini stores corners via a Point Attrib, but does not have any API for corners, - // so we construct a non-sparse float vector and convert using an AttribConverter. - - const auto &cornerSharpnesses = mesh->cornerSharpnesses()->readable(); - - FloatVectorDataPtr cornerWeightData = new FloatVectorData; - auto &cornerWeights = cornerWeightData->writable(); - cornerWeights.resize( newPoints.getMaxEntries(), 0.0f ); - for( size_t i = 0; i < cornerIds.size(); ++i ) - { - cornerWeights[cornerIds[i]] = cornerSharpnesses[i]; - } - - ToHoudiniAttribConverter::create( cornerWeightData.get() )->convert( g_cornerWeightAttrib, geo, newPoints ); - } - - const auto &creaseLengths = mesh->creaseLengths()->readable(); - if( !creaseLengths.empty() ) - { - // Houdini stores creases via a Vertex Attrib, with the first face-vert of each creased face-edge - // containing the sharpness, and all other face-verts set to 0. Its easier to use the GU Crease API - // directly than it would be using an AttribConverter. - - const auto &creaseIds = mesh->creaseIds()->readable(); - const auto &creaseSharpnesses = mesh->creaseSharpnesses()->readable(); - - GA_EdgeGroup creaseEdges( *geo ); - GU_EdgeCreaseParms creaseParms; - creaseParms.myAction = GU_EDGECREASE_SET; - - int creaseIdOffset = 0; - for( size_t i = 0; i < creaseLengths.size(); ++i ) - { - int length = creaseLengths[i]; - - creaseEdges.clear(); - - for( int j = 1; j < length; ++j ) - { - GA_Offset p0 = pointOffsets.get( creaseIds[creaseIdOffset + j - 1] ); - GA_Offset p1 = pointOffsets.get( creaseIds[creaseIdOffset + j] ); - creaseEdges.add( p0, p1 ); - } - - creaseParms.myGroup = &creaseEdges; - creaseParms.myCreaseValue = creaseSharpnesses[i]; - geo->edgeCrease( creaseParms ); - - creaseIdOffset += length; - } - } - - return true; -} diff --git a/src/IECoreHoudini/ToHoudiniQuatAttribConverter.cpp b/src/IECoreHoudini/ToHoudiniQuatAttribConverter.cpp deleted file mode 100644 index c06ed194d9..0000000000 --- a/src/IECoreHoudini/ToHoudiniQuatAttribConverter.cpp +++ /dev/null @@ -1,93 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniQuatAttribConverter.h" - -#include "IECore/MessageHandler.h" - -using namespace IECore; - -namespace IECoreHoudini -{ - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniQuatVectorAttribConverter ); - -ToHoudiniAttribConverter::Description ToHoudiniQuatVectorAttribConverter::m_description( QuatfVectorData::staticTypeId() ); - -ToHoudiniQuatVectorAttribConverter::ToHoudiniQuatVectorAttribConverter( const IECore::Data *data ) : - ToHoudiniAttribConverter( data, "Converts IECore::QuatfVectorData to a GB_Attribute on the provided GU_Detail." ) -{ -} - -ToHoudiniQuatVectorAttribConverter::~ToHoudiniQuatVectorAttribConverter() -{ -} - -GA_RWAttributeRef ToHoudiniQuatVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const -{ - IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniQuatVectorAttribConverter", "Does not support Detail attributes. Ignoring \"" + name + "\"" ); - return GA_RWAttributeRef(); -} - -GA_RWAttributeRef ToHoudiniQuatVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - assert( data ); - - GA_RWAttributeRef attrRef = geo->addFloatTuple( range.getOwner(), name.c_str(), 4 ); - if ( attrRef.isInvalid() ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniQuatVectorAttribConverter::doConversion: Invalid GA_RWAttributeRef returned for PrimitiveVariable \"%s\"." ) % name ).str() ); - } - attrRef.setTypeInfo( GA_TYPE_QUATERNION ); - - const QuatfVectorData* dataPtr = IECore::runTimeCast( data ); - - // reorder quaternion components for houdini: - std::vector floatData; - floatData.reserve( 4 * dataPtr->readable().size() ); - for( std::vector::const_iterator it = dataPtr->readable().begin(); it != dataPtr->readable().end(); ++it ) - { - floatData.push_back( (*it)[1] ); - floatData.push_back( (*it)[2] ); - floatData.push_back( (*it)[3] ); - floatData.push_back( (*it)[0] ); - } - - GA_Attribute *attr = attrRef.getAttribute(); - attr->getAIFTuple()->setRange( attr, range, floatData.data() ); - - return attrRef; -} - -} // namespace IECoreHoudini diff --git a/src/IECoreHoudini/ToHoudiniStringAttribConverter.cpp b/src/IECoreHoudini/ToHoudiniStringAttribConverter.cpp deleted file mode 100644 index 5acfbfc59b..0000000000 --- a/src/IECoreHoudini/ToHoudiniStringAttribConverter.cpp +++ /dev/null @@ -1,188 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/ToHoudiniStringAttribConverter.h" - -#include "IECore/MessageHandler.h" - -#include "UT/UT_Version.h" -#if UT_MAJOR_VERSION_INT >= 17 -#include "UT/UT_StdUtil.h" -#endif - -using namespace IECore; - -namespace IECoreHoudini -{ - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniStringVectorAttribConverter ); - -ToHoudiniAttribConverter::Description ToHoudiniStringVectorAttribConverter::m_description( StringVectorData::staticTypeId() ); - -ToHoudiniStringVectorAttribConverter::ToHoudiniStringVectorAttribConverter( const IECore::Data *data ) : - ToHoudiniAttribConverter( data, "Converts IECore::StringVectorData to a GB_Attribute on the provided GU_Detail." ) -{ - m_indicesParameter = new IntVectorParameter( "indices", "the indices into the source StringVectorData", new IntVectorData() ); - parameters()->addParameter( m_indicesParameter ); -} - -ToHoudiniStringVectorAttribConverter::~ToHoudiniStringVectorAttribConverter() -{ -} - -IntVectorParameterPtr ToHoudiniStringVectorAttribConverter::indicesParameter() -{ - return m_indicesParameter; -} - -ConstIntVectorParameterPtr ToHoudiniStringVectorAttribConverter::indicesParameter() const -{ - return m_indicesParameter; -} - -GA_RWAttributeRef ToHoudiniStringVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const -{ - IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniStringVectorAttribConverter", "Does not support Detail attributes. Ignoring \"" + name + "\"" ); - return GA_RWAttributeRef(); -} - -GA_RWAttributeRef ToHoudiniStringVectorAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - assert( data ); - - const IECore::StringVectorData *stringVectorData = IECore::runTimeCast( data ); - if ( !stringVectorData ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniStringVectorAttribConverter::doConversion: PrimitiveVariable \"%s\" does not contain IECore::StringVectorData." ) % name ).str() ); - } - - GA_RWAttributeRef attrRef = geo->addStringTuple( range.getOwner(), name.c_str(), 1 ); - if ( attrRef.isInvalid() ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniStringVectorAttribConverter::doConversion: Invalid GA_RWAttributeRef returned for PrimitiveVariable \"%s\"." ) % name ).str() ); - } - - if ( !range.isValid() || range.empty() ) - { - return attrRef; - } - - UT_StringArray strings; - -#if UT_MAJOR_VERSION_INT < 17 - - strings.fromStdVectorOfStrings( stringVectorData->readable() ); - -#else - - UTarrayFromStdVectorOfStrings( strings, stringVectorData->readable() ); - -#endif - - const std::vector &indices = ((const IECore::IntVectorData *)m_indicesParameter->getValidatedValue())->readable(); - if ( indices.empty() || !strings.entries() ) - { - return attrRef; - } - - GA_Attribute *attr = attrRef.getAttribute(); - const GA_AIFSharedStringTuple *tuple = attr->getAIFSharedStringTuple(); - GA_AIFSharedStringTuple::StringBuffer handles = tuple->addStrings( attr, strings ); - - size_t i = 0; - size_t numIndices = indices.size(); - GA_Offset start, end; - for( GA_Iterator it( range ); it.blockAdvance( start, end ); ) - { - for( GA_Offset offset = start; offset < end && i < numIndices; ++offset, ++i ) - { - tuple->setHandle( attr, offset, handles.getStringIndex( indices[i] ), 0 ); - } - } - - return attrRef; -} - -GA_RWAttributeRef ToHoudiniStringVectorAttribConverter::convertString( std::string name, std::string value, GU_Detail *geo, GA_Range range ) -{ - StringVectorDataPtr valueData = new StringVectorData(); - valueData->writable().push_back( value ); - std::vector indexValues( range.getEntries(), 0 ); - IntVectorDataPtr indexData = new IntVectorData( indexValues ); - ToHoudiniStringVectorAttribConverterPtr converter = new ToHoudiniStringVectorAttribConverter( valueData.get() ); - converter->indicesParameter()->setValidatedValue( indexData ); - return converter->convert( name, geo, range ); -} - -IE_CORE_DEFINERUNTIMETYPED( ToHoudiniStringDetailAttribConverter ); - -ToHoudiniAttribConverter::Description ToHoudiniStringDetailAttribConverter::m_description( StringData::staticTypeId() ); - -ToHoudiniStringDetailAttribConverter::ToHoudiniStringDetailAttribConverter( const IECore::Data *data ) : - ToHoudiniAttribConverter( data, "Converts IECore::StringData to a GB_Attribute on the provided GU_Detail." ) -{ -} - -ToHoudiniStringDetailAttribConverter::~ToHoudiniStringDetailAttribConverter() -{ -} - -GA_RWAttributeRef ToHoudiniStringDetailAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo ) const -{ - assert( data ); - - const StringData *stringData = IECore::runTimeCast( data ); - if ( !stringData ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniStringDetailAttribConverter::doConversion: PrimitiveVariable \"%s\" does not contain IECore::StringData." ) % name ).str() ); - } - - GA_RWAttributeRef attrRef = geo->addStringTuple( GA_ATTRIB_DETAIL, name.c_str(), 1 ); - if ( attrRef.isInvalid() ) - { - throw IECore::Exception( ( boost::format( "ToHoudiniStringDetailAttribConverter::doConversion: Invalid GA_RWAttributeRef returned for PrimitiveVariable \"%s\"." ) % name ).str() ); - } - - GA_Attribute *attr = attrRef.getAttribute(); - attr->getAIFSharedStringTuple()->setString( attr, 0, stringData->readable().c_str(), 0 ); - - return attrRef; -} - -GA_RWAttributeRef ToHoudiniStringDetailAttribConverter::doConversion( const IECore::Data *data, std::string name, GU_Detail *geo, const GA_Range &range ) const -{ - throw IECore::Exception( "ToHoudiniStringDetailAttribConverter does not support Element attributes." ); -} - -} // namespace IECoreHoudini diff --git a/src/IECoreHoudini/UT_ObjectPoolCache.cpp b/src/IECoreHoudini/UT_ObjectPoolCache.cpp deleted file mode 100644 index 6beec3f4c9..0000000000 --- a/src/IECoreHoudini/UT_ObjectPoolCache.cpp +++ /dev/null @@ -1,98 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/UT_ObjectPoolCache.h" - -using namespace IECoreHoudini; - -UT_ObjectPoolCache::UT_ObjectPoolCache( const std::string &name, IECore::ObjectPoolPtr objectPool ) - : m_name( name ), m_pool( objectPool ) -{ -} - -UT_ObjectPoolCache::~UT_ObjectPoolCache() -{ -} - -const char *UT_ObjectPoolCache::utGetCacheName() const -{ - return m_name.c_str(); -} - -int64 UT_ObjectPoolCache::utGetCurrentSize() const -{ - return m_pool->memoryUsage(); -} - -int64 UT_ObjectPoolCache::utReduceCacheSizeBy( int64 amount ) -{ - size_t begin = m_pool->memoryUsage(); - size_t max = m_pool->getMaxMemoryUsage(); - m_pool->setMaxMemoryUsage( begin - amount ); - m_pool->setMaxMemoryUsage( max ); - - return begin - m_pool->memoryUsage(); -} - -bool UT_ObjectPoolCache::utHasMaxSize() const -{ - return true; -} - -int64 UT_ObjectPoolCache::utGetMaxSize() const -{ - return m_pool->getMaxMemoryUsage(); -} - -void UT_ObjectPoolCache::utSetMaxSize( int64 amount ) -{ - m_pool->setMaxMemoryUsage( amount ); -} - -bool UT_ObjectPoolCache::utHasMinSize() const -{ - return false; -} - -UT_ObjectPoolCache *UT_ObjectPoolCache::defaultObjectPoolCache() -{ - static UT_ObjectPoolCache *defaultCache = 0; - - if ( !defaultCache ) - { - defaultCache = new UT_ObjectPoolCache( "Cortex Object Pool", IECore::ObjectPool::defaultObjectPool() ); - } - - return defaultCache; -} diff --git a/src/IECoreHoudini/bindings/FnParameterisedHolderBinding.cpp b/src/IECoreHoudini/bindings/FnParameterisedHolderBinding.cpp deleted file mode 100644 index 28164b8420..0000000000 --- a/src/IECoreHoudini/bindings/FnParameterisedHolderBinding.cpp +++ /dev/null @@ -1,197 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FnParameterisedHolderBinding.h" - -#include "IECoreHoudini/NodeHandle.h" -#include "IECoreHoudini/ParameterisedHolderInterface.h" - -#include "OP/OP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -namespace -{ - -class FnParameterisedHolder -{ - public : - - FnParameterisedHolder( OP_Node *node=0 ) - : m_handle() - { - if ( !node ) - { - return; - } - - if ( getHolder( node ) ) - { - setHolder( node ); - } - else - { - UT_String path; - node->getFullPath( path ); - std::cerr << path << " was not a valid ieParameterisedHolder!" << std::endl; - } - } - - virtual ~FnParameterisedHolder() - { - } - - bool hasParameterised() - { - if ( hasHolder() ) - { - ParameterisedHolderInterface *holder = getHolder( static_cast( m_handle.node() ) ); - if ( holder ) - { - return holder->hasParameterised(); - } - } - - return false; - } - - void setParameterised( IECore::RunTimeTypedPtr p ) - { - if ( !p || !hasHolder() ) - { - return; - } - - ParameterisedHolderInterface *holder = getHolder( static_cast( m_handle.node() ) ); - if ( !holder ) - { - return; - } - - holder->setParameterised( p ); - } - - void setParameterised( const std::string &className, int classVerison, const std::string &seachPathEnvVar ) - { - if ( !hasHolder() ) - { - return; - } - - ParameterisedHolderInterface *holder = getHolder( static_cast( m_handle.node() ) ); - if ( !holder ) - { - return; - } - - holder->setParameterised( className, classVerison, seachPathEnvVar ); - } - - /// Sets the values of the parameters of the held Parameterised object - /// to reflect the values of the attributes of the node. - /// \todo: add setNodeValues as well - void setParameterisedValues( double time ) - { - if ( !hasHolder() ) - { - return; - } - - ParameterisedHolderInterface *holder = getHolder( static_cast( m_handle.node() ) ); - if ( !holder ) - { - return; - } - - holder->setParameterisedValues( time ); - } - - - IECore::RunTimeTypedPtr getParameterised() - { - if ( hasHolder() ) - { - ParameterisedHolderInterface *holder = getHolder( static_cast( m_handle.node() ) ); - if ( holder ) - { - return holder->getParameterised(); - } - } - - return nullptr; - } - - - private : - - bool hasHolder() - { - return m_handle.alive(); - } - - void setHolder( OP_Node *node ) - { - m_handle = node; - } - - ParameterisedHolderInterface *getHolder( OP_Node *node ) - { - if ( node ) - { - return dynamic_cast( node ); - } - - return nullptr; - } - - NodeHandle m_handle; - -}; - -} // namespace - -void IECoreHoudini::bindFnParameterisedHolder() -{ - class_( "_FnParameterisedHolder" ) - .def( init() ) - .def( "hasParameterised", &FnParameterisedHolder::hasParameterised ) - .def( "setParameterised", (void (FnParameterisedHolder::*)( IECore::RunTimeTypedPtr ))&FnParameterisedHolder::setParameterised ) - .def( "setParameterised", (void (FnParameterisedHolder::*)( const std::string &, int, const std::string & ))&FnParameterisedHolder::setParameterised ) - .def( "getParameterised", &FnParameterisedHolder::getParameterised ) - .def( "setParameterisedValues", &FnParameterisedHolder::setParameterisedValues ) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.cpp deleted file mode 100644 index 21402f7dc7..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniCompoundObjectConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "SOP/SOP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindFromHoudiniCompoundObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniConverterBinding.cpp deleted file mode 100644 index 98606a61cc..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniConverterBinding.cpp +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreHoudini; -using namespace boost::python; - -void IECoreHoudini::bindFromHoudiniConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.cpp deleted file mode 100644 index b1b33b3387..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniCortexObjectConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "SOP/SOP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindFromHoudiniCortexObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.cpp deleted file mode 100644 index f5166fb375..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniCurvesConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "SOP/SOP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindFromHoudiniCurvesConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.cpp deleted file mode 100644 index 43c37cfc2e..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.cpp +++ /dev/null @@ -1,119 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniGeometryConverter.h" - -#include "IECorePython/IECoreBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" -#include "IECorePython/ScopedGILRelease.h" - -#include "IECore/Exception.h" - -#include "HOM/HOM_GUDetailHandle.h" -#include "HOM/HOM_Geometry.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -static list supportedTypes() -{ - list result; - std::set e; - FromHoudiniGeometryConverter::supportedTypes( e ); - for ( std::set::const_iterator it = e.begin(); it != e.end(); ++it ) - { - result.append( *it ); - } - - return result; -} - -static FromHoudiniGeometryConverterPtr createFromGeo( HOM_Geometry *homGeo, IECore::TypeId resultType ) -{ - IECorePython::ScopedGILRelease scopedGILRelease; - - // this HOM manipulation was provided by SideFx, with a warning - // that it is safe but not really meant for HDK developers - HOM_GUDetailHandle *gu_handle = homGeo->_guDetailHandle(); - GU_Detail *geo = (GU_Detail *)gu_handle->_asVoidPointer(); - - GU_DetailHandle handle; - handle.allocateAndSet( geo, false ); - - return FromHoudiniGeometryConverter::create( handle, resultType ); -} - -static FromHoudiniGeometryConverterPtr createDummy( object ids ) -{ - extract ex( ids ); - if( ex.check() ) - { - return FromHoudiniGeometryConverter::create( GU_DetailHandle(), ex() ); - } - - std::set resultTypes; - for ( long i = 0; i < IECorePython::len( ids ); i++ ) - { - extract ex( ids[i] ); - if ( !ex.check() ) - { - throw IECore::InvalidArgumentException( "FromHoudiniGeometryConverter.supportedTypes: List element is not an IECore.TypeId" ); - } - - resultTypes.insert( ex() ); - } - - return FromHoudiniGeometryConverter::create( GU_DetailHandle(), resultTypes ); -} - -static FromHoudiniGeometryConverterPtr create( const SOP_Node *sop, const std::string &nameFilter, IECore::TypeId resultType ) -{ - IECorePython::ScopedGILRelease scopedGILRelease; - return FromHoudiniGeometryConverter::create( sop, nameFilter, resultType ); -} - -void IECoreHoudini::bindFromHoudiniGeometryConverter() -{ - IECorePython::RunTimeTypedClass< FromHoudiniGeometryConverter >() - .def( "create", (FromHoudiniGeometryConverterPtr (*)( const SOP_Node *, const std::string &, IECore::TypeId ) )&::create, ( arg_( "sop" ), arg_( "nameFilter" ) = "", arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - .def( "createFromGeo", &createFromGeo, ( arg_( "geo" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "createFromGeo" ) - .def( "createDummy", &createDummy, ( arg_( "resultTypes" ) ) ).staticmethod( "createDummy" ) - .def( "supportedTypes", &supportedTypes ) - .staticmethod( "supportedTypes" ) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.cpp deleted file mode 100644 index a76784b199..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniPointsConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "SOP/SOP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindFromHoudiniPointsConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.cpp b/src/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.cpp deleted file mode 100644 index 7435025584..0000000000 --- a/src/IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.h" - -#include "IECoreHoudini/FromHoudiniPolygonsConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "SOP/SOP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindFromHoudiniPolygonsConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/IECoreHoudiniModule.cpp b/src/IECoreHoudini/bindings/IECoreHoudiniModule.cpp deleted file mode 100644 index 20c7862311..0000000000 --- a/src/IECoreHoudini/bindings/IECoreHoudiniModule.cpp +++ /dev/null @@ -1,196 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/FnParameterisedHolderBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniCompoundObjectConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniCortexObjectConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniCurvesConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniGeometryConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniPointsConverterBinding.h" -#include "IECoreHoudini/bindings/FromHoudiniPolygonsConverterBinding.h" -#include "IECoreHoudini/bindings/LiveSceneBinding.h" -#include "IECoreHoudini/bindings/SceneCacheNodeBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniGeometryConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.h" -#include "IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.h" -#include "IECoreHoudini/bindings/TypeIdBinding.h" - -#include "IECoreHoudini/CoreHoudini.h" -#include "IECoreHoudini/CoreHoudiniVersion.h" -#include "IECoreHoudini/LiveScene.h" - -#include "IECorePython/PointerFromSWIG.h" - -#include "IECore/Object.h" -#include "IECore/Parameterised.h" - -#include "HOM/HOM_Geometry.h" -#include "HOM/HOM_Node.h" -#include "OP/OP_Director.h" -#include "OP/OP_Node.h" - -// must be included before RE_Visual to avoid a compilation -// error todo with QT_NO_EMIT in QtCore/qobjectdefs.h -#include "RE/RE_Render.h" -#include "UT/UT_Version.h" -#if UT_MAJOR_VERSION_INT >= 16 -#include "RE/RE_Visual.h" -#elif UT_MAJOR_VERSION_INT >= 14 -#include "RE/RE_QtVisual.h" -#endif - -#include "RE/RE_Render.h" -#include "RE/RE_Server.h" -#include "RE/RE_Visual.h" -#include "RE/RE_Window.h" -#include "SOP/SOP_Node.h" - -#include "boost/python/suite/indexing/vector_indexing_suite.hpp" - - -using namespace IECoreHoudini; -using namespace boost::python; - -// returns a OP_Node from a hou node instance -static void *extractNodeFromHOM( PyObject *o ) -{ - if( !PyObject_HasAttrString( o, "this" ) ) - { - return 0; - } - - PyObject *thisAttr = PyObject_GetAttrString( o, "this" ); - if( !thisAttr ) - { - return 0; - } - - /// \todo: here we 'assume' we have a HOM_Node object, when it really could be anything... - HOM_Node *homNode = static_cast(((IECorePython::Detail::PySwigObject*)thisAttr)->ptr); - - return OPgetDirector()->findNode( homNode->path().c_str() ); -} - -// This little function makes the OpenGL context for Houdini's main window -// current. This can be necessary when wanting to create your own OpenGL context -// which shares resources (textures, vertex buffers etc) with Houdini's contexts. -// See GafferUI/GLWidget.py for an example of the hideous abuse this allows. -static void makeMainGLContextCurrent() -{ - RE_Window *window = RE_OGLRender::getMainContext(); - RE_Render *render = window->getRender(); - -#if defined( IECOREHOUDINI_WITH_QT5 ) - - render->makeCurrent(); - -#else - - render->makeCurrentQt(); - -#endif - -} - -#if UT_MAJOR_VERSION_INT >= 14 && UT_MAJOR_VERSION_INT < 16 -// This little function returns the address of Houdini's shared QGLWidget -// This can be necessary when wanting to create your own OpenGL context -// which shares resources (textures, vertex buffers etc) with Houdini's contexts. -// See GafferUI/GLWidget.py for an example of the hideous abuse this allows. -static uint64_t sharedGLWidget() -{ - return (uint64_t)RE_QtVisual::getSharedGLWidget(); -} - -#endif - -static void cleanup() -{ - CoreHoudini::cleanupPython(); - LiveScene::clearCustomAttributeReaders(); - LiveScene::clearCustomTagReaders(); -} - -BOOST_PYTHON_MODULE(_IECoreHoudini) -{ - // setup our global python context - CoreHoudini::initPython(); - - // bind our IECoreHoudini classes & types - bindTypeId(); - bindFnParameterisedHolder(); - bindFromHoudiniConverter(); - bindFromHoudiniGeometryConverter(); - bindFromHoudiniPointsConverter(); - bindFromHoudiniPolygonsConverter(); - bindToHoudiniConverter(); - bindToHoudiniGeometryConverter(); - bindToHoudiniPointsConverter(); - bindToHoudiniPolygonsConverter(); - bindFromHoudiniCurvesConverter(); - bindToHoudiniCurvesConverter(); - bindSceneCacheNode(); - bindLiveScene(); - bindFromHoudiniCortexObjectConverter(); - bindToHoudiniCortexObjectConverter(); - bindFromHoudiniCompoundObjectConverter(); - bindToHoudiniCompoundObjectConverter(); - - // register our node converter functions - boost::python::converter::registry::insert( &extractNodeFromHOM, boost::python::type_id() ); - boost::python::converter::registry::insert( &extractNodeFromHOM, boost::python::type_id() ); - - IECorePython::PointerFromSWIG(); - - def( "makeMainGLContextCurrent", &makeMainGLContextCurrent ); - -#if UT_MAJOR_VERSION_INT >= 14 && UT_MAJOR_VERSION_INT < 16 - - def( "sharedGLWidget", &sharedGLWidget ); - -#endif - - def( "cleanup", &cleanup ); - -} diff --git a/src/IECoreHoudini/bindings/LiveSceneBinding.cpp b/src/IECoreHoudini/bindings/LiveSceneBinding.cpp deleted file mode 100644 index ba887012b6..0000000000 --- a/src/IECoreHoudini/bindings/LiveSceneBinding.cpp +++ /dev/null @@ -1,214 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/LiveSceneBinding.h" - -#include "IECoreHoudini/CoreHoudini.h" -#include "IECoreHoudini/LiveScene.h" - -#include "IECorePython/IECoreBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - -#include "boost/python/suite/indexing/container_utils.hpp" - -using namespace IECoreHoudini; -using namespace boost::python; - -namespace -{ - -void listToPath( const list &l, IECoreScene::SceneInterface::Path &p ) -{ - int listLen = IECorePython::len( l ); - for (int i = 0; i < listLen; i++ ) - { - extract< std::string > ex( l[i] ); - if ( !ex.check() ) - { - throw IECore::InvalidArgumentException( std::string( "Invalid path! Should be a list of strings!" ) ); - } - p.push_back( ex() ); - } -} - - -LiveScenePtr constructor( const std::string n, const list &c, const list &r, double defaultTime ) -{ - UT_String nodePath( n ); - IECoreScene::SceneInterface::Path contentPath, rootPath; - listToPath( c, contentPath ); - listToPath( r, rootPath ); - - // constructing a LiveScene can cause SOPs to cook (via the DetailSplitter), - // which can cause further python evaluations (eg parm expressions), so we - // must release the GIL to avoid deadlocks. - IECorePython::ScopedGILRelease gilRelease; - return new LiveScene( nodePath, contentPath, rootPath, defaultTime ); -} - -/// \todo: return a PyObject* directly if SideFx provides a swig-free method for creating one from a HOM_Node* -std::string getNodePath( LiveScene *scene ) -{ - const OP_Node *node = scene->node(); - if ( !node ) - { - return 0; - } - - UT_String path; - node->getFullPath( path ); - - return path.toStdString(); -} - -//! utility function to acquire a houdini node by it's path in the node graph -boost::python::object getNodeAsPython( const UT_String &path ) -{ - static boost::python::object houModule = boost::python::import( "hou" ); - static boost::python::object nodeFn = houModule.attr( "node" ); - - return nodeFn( path.c_str() ); -} - -} // namespace - - -IECore::DataPtr readWorldTransform( LiveScene &scene, double time ) -{ - if ( IECore::ConstDataPtr t = scene.readWorldTransform( time ) ) - { - return t->copy(); - } - - return 0; -} - -class CustomTagReader -{ - public : - CustomTagReader( object hasFn, object readFn ) : m_has( hasFn ), m_read( readFn ) - { - } - - bool operator() ( const OP_Node *node, const IECoreScene::SceneInterface::Name &tag, int filter ) - { - UT_String path; - node->getFullPath( path ); - IECorePython::ScopedGILLock gilLock; - - return m_has( getNodeAsPython( path ), tag, filter ); - } - - void operator() ( const OP_Node *node, IECoreScene::SceneInterface::NameList &tags, int filter ) - { - UT_String path; - node->getFullPath( path ); - IECorePython::ScopedGILLock gilLock; - object o = m_read( getNodeAsPython ( path ), filter ); - extract l( o ); - if ( !l.check() ) - { - throw IECore::InvalidArgumentException( std::string( "Invalid value! Expecting a list of strings." ) ); - } - - container_utils::extend_container( tags, l() ); - } - - object m_has; - object m_read; -}; - -void registerCustomTags( object hasFn, object readFn ) -{ - CustomTagReader reader( hasFn, readFn ); - LiveScene::registerCustomTags( reader, reader, false ); -} - -class CustomAttributeReader -{ - public : - CustomAttributeReader( object namesFn, object readFn ) : m_names( namesFn ), m_read( readFn ) - { - } - - IECore::ConstObjectPtr operator() ( const OP_Node *node, const IECoreScene::SceneInterface::Name &attr, double time ) - { - UT_String path; - node->getFullPath( path ); - IECorePython::ScopedGILLock gilLock; - return extract( m_read( getNodeAsPython( path ), attr, time ) ); - } - - void operator() ( const OP_Node *node, IECoreScene::SceneInterface::NameList &attributes ) - { - UT_String path; - node->getFullPath( path ); - IECorePython::ScopedGILLock gilLock; - object o = m_names( getNodeAsPython( path ) ); - extract l( o ); - if ( !l.check() ) - { - throw IECore::InvalidArgumentException( std::string( "Invalid value! Expecting a list of strings." ) ); - } - - container_utils::extend_container( attributes, l() ); - } - - object m_names; - object m_read; -}; - -void registerCustomAttributes( object namesFn, object readFn ) -{ - CustomAttributeReader reader( namesFn, readFn ); - LiveScene::registerCustomAttributes( reader, reader, false ); -} - -void IECoreHoudini::bindLiveScene() -{ - IECorePython::RunTimeTypedClass() - .def( init<>() ) - .def( "__init__", make_constructor( &constructor, default_call_policies(), ( arg( "nodePath" ), arg( "contentPath" ) = list(), arg( "rootPath" ) = list(), arg( "defaultTime" ) = std::numeric_limits::infinity() ) ) ) - .def( "getDefaultTime", &LiveScene::getDefaultTime ) - .def( "setDefaultTime", &LiveScene::setDefaultTime ) - .def( "embedded", &LiveScene::embedded ) - .def( "_getNodePath", &getNodePath ) - .def( "readWorldTransform", &readWorldTransform ) - .def( "readWorldTransformAsMatrix", &LiveScene::readWorldTransformAsMatrix ) - .def( "registerCustomTags", registerCustomTags ).staticmethod( "registerCustomTags" ) - .def( "registerCustomAttributes", registerCustomAttributes ).staticmethod( "registerCustomAttributes" ) - ; -} diff --git a/src/IECoreHoudini/bindings/SceneCacheNodeBinding.cpp b/src/IECoreHoudini/bindings/SceneCacheNodeBinding.cpp deleted file mode 100644 index 7c6451eee5..0000000000 --- a/src/IECoreHoudini/bindings/SceneCacheNodeBinding.cpp +++ /dev/null @@ -1,169 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/SceneCacheNodeBinding.h" - -#include "IECoreHoudini/NodeHandle.h" -#include "IECoreHoudini/OBJ_SceneCacheTransform.h" -#include "IECoreHoudini/OBJ_SceneCacheNode.h" -#include "IECoreHoudini/SceneCacheNode.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/MessageHandler.h" - -#include "OP/OP_Node.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -class SceneCacheNodeHelper -{ - public : - - SceneCacheNodeHelper( OP_Node *node = 0 ) - { - if ( !node ) - { - return; - } - - if ( sceneNode( node ) ) - { - m_handle = node; - } - else - { - UT_String path; - node->getFullPath( path ); - IECore::msg( IECore::MessageHandler::Error, "SceneCacheNode", path.toStdString() + " was not a valid SceneCacheNode" ); - } - } - - ~SceneCacheNodeHelper() - { - } - - bool hasNode() const - { - return m_handle.alive(); - } - - SceneCacheNode *sceneNode( OP_Node *node ) const - { - // make sure its a SceneCacheNode - if ( !node || !node->hasParm( SceneCacheNode::pFile.getToken() ) || !node->hasParm( SceneCacheNode::pRoot.getToken() ) ) - { - return 0; - } - - return reinterpret_cast* >( node ); - } - - IECoreScene::SceneInterfacePtr scene() const - { - if ( !hasNode() ) - { - return 0; - } - - if ( SceneCacheNode *node = sceneNode( m_handle.node() ) ) - { - if ( IECoreScene::ConstSceneInterfacePtr s = node->scene() ) - { - return const_cast( s.get() ); - } - } - - return 0; - } - - bool visibility( double frame ) const - { - if ( !hasNode() ) - { - return false; - } - - if ( SceneCacheNode *node = sceneNode( m_handle.node() ) ) - { - return node->visibility( frame ); - } - - return false; - } - - private : - - NodeHandle m_handle; - -}; - -void IECoreHoudini::bindSceneCacheNode() -{ - scope modeCacheNodeScope = class_( "SceneCacheNode" ) - .def( init() ) - .def( "scene", &SceneCacheNodeHelper::scene ) - .def( "visibility", &SceneCacheNodeHelper::visibility ) - ; - - enum_::Space>( "Space" ) - .value( "World", SceneCacheNode::World ) - .value( "Path", SceneCacheNode::Path ) - .value( "Local", SceneCacheNode::Local ) - .value( "Object", SceneCacheNode::Object ) - ; - - enum_::GeometryType>( "GeometryType" ) - .value( "Cortex", SceneCacheNode::Cortex ) - .value( "Houdini", SceneCacheNode::Houdini ) - .value( "BoundingBox", SceneCacheNode::BoundingBox ) - .value( "PointCloud", SceneCacheNode::PointCloud ) - .value( "TransformPointCloud", SceneCacheNode::TransformPointCloud ) - ; - - enum_( "Hierarchy" ) - .value( "SubNetworks", OBJ_SceneCacheTransform::SubNetworks ) - .value( "Parenting", OBJ_SceneCacheTransform::Parenting ) - .value( "FlatGeometry", OBJ_SceneCacheTransform::FlatGeometry ) - ; - - enum_( "Depth" ) - .value( "AllDescendants", OBJ_SceneCacheTransform::AllDescendants ) - .value( "Children", OBJ_SceneCacheTransform::Children ) - ; - -} diff --git a/src/IECoreHoudini/bindings/ToHoudinGeometryConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudinGeometryConverterBinding.cpp deleted file mode 100644 index dbb3e9aa5b..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudinGeometryConverterBinding.cpp +++ /dev/null @@ -1,143 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/ToHoudiniGeometryConverter.h" -#include "IECoreHoudini/bindings/ToHoudiniGeometryConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "CH/CH_Manager.h" -#include "HOM/HOM_GUDetailHandle.h" -#include "HOM/HOM_Geometry.h" -#include "SOP/SOP_Node.h" -#include "OP/OP_NodeFlags.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -static bool convert( ToHoudiniGeometryConverter &c, GU_DetailHandle &handle, bool append ) -{ - if ( handle.isNull() ) - { - return false; - } - - if ( !append ) - { - GU_DetailHandleAutoWriteLock writeHandle( handle ); - GU_Detail *geo = writeHandle.getGdp(); - if ( !geo ) - { - return false; - } - - geo->clearAndDestroy(); - } - - return c.convert( handle ); -} - -/// Extracts the GU_DetailHandle from a SOP_Node and converts it. If append is true, -/// the conversion will append to the existing GU_Detail. If append is false, the GU_Detail -/// will be cleared before conversion. -static bool convertToSop( ToHoudiniGeometryConverter &c, SOP_Node *sop, bool append ) -{ - // create the work context - OP_Context context; - context.setTime( CHgetEvalTime() ); - - GU_DetailHandle handle = sop->getCookedGeoHandle( context ); - - if ( convert( c, handle, append ) ) - { - sop->setModelLock( OP_NodeFlags::OP_LockTypes::OP_HARD_LOCKED ); - return true; - } - - return false; -} - -/// Extracts the GU_DetailHandle from the HOM_Geometry and converts it. If append is true, -/// the conversion will append to the existing GU_Detail. If append is false, the GU_Detail -/// will be cleared before conversion. -static bool convertToGeo( ToHoudiniGeometryConverter &c, HOM_Geometry *homGeo, bool append ) -{ - if ( !homGeo ) - { - return false; - } - - // this HOM manipulation was provided by SideFx, with a warning - // that it is safe but not really meant for HDK developers - HOM_GUDetailHandle *gu_handle = homGeo->_guDetailHandle(); - if ( gu_handle->isReadOnly() ) - { - return false; - } - - GU_Detail *geo = (GU_Detail *)gu_handle->_asVoidPointer(); - - GU_DetailHandle handle; - handle.allocateAndSet( geo, false ); - - return convert( c, handle, append ); -} - -static list supportedTypes() -{ - list result; - std::set e; - ToHoudiniGeometryConverter::supportedTypes( e ); - for ( std::set::const_iterator it = e.begin(); it != e.end(); ++it ) - { - result.append( *it ); - } - - return result; -} - -void IECoreHoudini::bindToHoudiniGeometryConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "convert", &convertToSop, ( arg_( "self" ), arg_( "sop" ), arg_( "append" ) = false ), - "Extracts the GU_DetailHandle from a SOP_Node and converts it. The append flag defaults to False, which will clear the GU_Detail before conversion. If append is True, the conversion will append to the existing GU_Detail instead." ) - .def( "convertToGeo", &convertToGeo, ( arg_( "self" ), arg_( "geo" ), arg_( "append" ) = false ), - "Extracts the GU_Detail from a hou.Geometry object and converts it. The append flag defaults to False, which will clear the GU_Detail before conversion. If append is True, the conversion will append to the existing GU_Detail instead." ) - .def( "create", &ToHoudiniGeometryConverter::create ).staticmethod( "create" ) - .def( "supportedTypes", &supportedTypes ) - .staticmethod( "supportedTypes" ) - ; -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.cpp deleted file mode 100644 index 61da765562..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniCompoundObjectConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniCompoundObjectConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/CompoundObject.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindToHoudiniCompoundObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniConverterBinding.cpp deleted file mode 100644 index 9846b8c3d0..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniConverterBinding.cpp +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreHoudini; -using namespace boost::python; - -void IECoreHoudini::bindToHoudiniConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.cpp deleted file mode 100644 index ebf9939b41..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniCortexObjectConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniCortexObjectConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindToHoudiniCortexObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.cpp deleted file mode 100644 index 4544e8abc1..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniCurvesConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniCurvesConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindToHoudiniCurvesConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.cpp deleted file mode 100644 index 2e9757e895..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniPointsConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniPointsConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindToHoudiniPointsConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.cpp b/src/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.cpp deleted file mode 100644 index 93cfe2c941..0000000000 --- a/src/IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/ToHoudiniPolygonsConverterBinding.h" - -#include "IECoreHoudini/ToHoudiniPolygonsConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECoreHoudini; - -void IECoreHoudini::bindToHoudiniPolygonsConverter() -{ - IECorePython::RunTimeTypedClass() - .def(init()) - ; -} diff --git a/src/IECoreHoudini/bindings/TypeIdBinding.cpp b/src/IECoreHoudini/bindings/TypeIdBinding.cpp deleted file mode 100644 index 9fb3ec7e4c..0000000000 --- a/src/IECoreHoudini/bindings/TypeIdBinding.cpp +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreHoudini/bindings/TypeIdBinding.h" - -#include "IECoreHoudini/TypeIds.h" - -using namespace boost::python; - -namespace IECoreHoudini -{ - -void bindTypeId() -{ - enum_( "TypeId" ) - .value( "FromHoudiniConverter", FromHoudiniConverterTypeId ) - .value( "FromHoudiniGeometryConverter", FromHoudiniGeometryConverterTypeId ) - .value( "FromHoudiniPointsConverter", FromHoudiniPointsConverterTypeId ) - .value( "FromHoudiniPolygonsConverter", FromHoudiniPolygonsConverterTypeId ) - .value( "ToHoudiniConverter", ToHoudiniConverterTypeId ) - .value( "ToHoudiniGeometryConverter", ToHoudiniGeometryConverterTypeId ) - .value( "ToHoudiniPointsConverter", ToHoudiniPointsConverterTypeId ) - .value( "ToHoudiniPolygonsConverter", ToHoudiniPolygonsConverterTypeId ) - .value( "FromHoudiniCurvesConverter", FromHoudiniCurvesConverterTypeId ) - .value( "ToHoudiniCurvesConverter", ToHoudiniCurvesConverterTypeId ) - .value( "ToHoudiniAttribConverter", ToHoudiniAttribConverterTypeId ) - .value( "ToHoudiniFloatDetailAttribConverter", ToHoudiniFloatDetailAttribConverterTypeId ) - .value( "ToHoudiniV2fDetailAttribConverter", ToHoudiniV2fDetailAttribConverterTypeId ) - .value( "ToHoudiniV3fDetailAttribConverter", ToHoudiniV3fDetailAttribConverterTypeId ) - .value( "ToHoudiniColor3fDetailAttribConverter", ToHoudiniColor3fDetailAttribConverterTypeId ) - .value( "ToHoudiniIntDetailAttribConverter", ToHoudiniIntDetailAttribConverterTypeId ) - .value( "ToHoudiniV2iDetailAttribConverter", ToHoudiniV2iDetailAttribConverterTypeId ) - .value( "ToHoudiniV3iDetailAttribConverter", ToHoudiniV3iDetailAttribConverterTypeId ) - .value( "ToHoudiniFloatVectorAttribConverter", ToHoudiniFloatVectorAttribConverterTypeId ) - .value( "ToHoudiniV2fVectorAttribConverter", ToHoudiniV2fVectorAttribConverterTypeId ) - .value( "ToHoudiniV3fVectorAttribConverter", ToHoudiniV3fVectorAttribConverterTypeId ) - .value( "ToHoudiniColor3fVectorAttribConverter", ToHoudiniColor3fVectorAttribConverterTypeId ) - .value( "ToHoudiniIntVectorAttribConverter", ToHoudiniIntVectorAttribConverterTypeId ) - .value( "ToHoudiniV2iVectorAttribConverter", ToHoudiniV2iVectorAttribConverterTypeId ) - .value( "ToHoudiniV3iVectorAttribConverter", ToHoudiniV3iVectorAttribConverterTypeId ) - .value( "FromHoudiniGroupConverter", FromHoudiniGroupConverterTypeId ) - .value( "ToHoudiniGroupConverter", ToHoudiniGroupConverterTypeId ) - .value( "ToHoudiniStringDetailAttribConverter", ToHoudiniStringDetailAttribConverterTypeId ) - .value( "ToHoudiniStringVectorAttribConverter", ToHoudiniStringVectorAttribConverterTypeId ) - .value( "LiveScene", LiveSceneTypeId ) - .value( "FromHoudiniCortexObjectConverter", FromHoudiniCortexObjectConverterTypeId ) - .value( "ToHoudiniCortexObjectConverter", ToHoudiniCortexObjectConverterTypeId ) - .value( "FromHoudiniCompoundObjectConverter", FromHoudiniCompoundObjectConverterTypeId ) - .value( "ToHoudiniCompoundObjectConverter", ToHoudiniCompoundObjectConverterTypeId ) - ; -} - -} diff --git a/src/IECoreHoudini/plugin/Plugin.cpp b/src/IECoreHoudini/plugin/Plugin.cpp deleted file mode 100644 index 3bf45b3b1a..0000000000 --- a/src/IECoreHoudini/plugin/Plugin.cpp +++ /dev/null @@ -1,209 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreHoudini/GEO_CobIOTranslator.h" -#include "IECoreHoudini/GEO_CortexPrimitive.h" -#include "IECoreHoudini/GU_CortexPrimitive.h" -#include "IECoreHoudini/OBJ_SceneCacheGeometry.h" -#include "IECoreHoudini/OBJ_SceneCacheTransform.h" -#include "IECoreHoudini/ROP_SceneCacheWriter.h" -#include "IECoreHoudini/SOP_CortexConverter.h" -#include "IECoreHoudini/SOP_OpHolder.h" -#include "IECoreHoudini/SOP_ParameterisedHolder.h" -#include "IECoreHoudini/SOP_SceneCacheSource.h" -#include "IECoreHoudini/SOP_SceneCacheTransform.h" - -#include "DM/DM_RenderTable.h" -#include "OP/OP_OperatorTable.h" -#include "UT/UT_DSOVersion.h" -#include "UT/UT_IOTable.h" -#include "UT/UT_Version.h" - -#if UT_MAJOR_VERSION_INT >= 14 - -typedef IECoreHoudini::GEO_CortexPrimitive CortexPrimitive; - -#else - -#include "IECoreHoudini/GU_CortexPrimitive.h" - -typedef IECoreHoudini::GU_CortexPrimitive CortexPrimitive; - -#endif - -using namespace IECoreHoudini; - -/// Tell Houdini that this plugin should be loaded with RTLD_GLOBAL -extern "C" -{ - SYS_VISIBILITY_EXPORT void HoudiniDSOInit( UT_DSOInfo &dsoinfo ) - { - const char *forceGlobals = std::getenv( "IECORE_RTLD_GLOBAL" ); - if( !forceGlobals || !strcmp( forceGlobals, "1" ) ) - { - dsoinfo.loadGlobal = true; - } - } -} - -/// Declare our new SOPs -void newSopOperator(OP_OperatorTable *table) -{ - OP_Operator *opHolder = new OP_Operator( - "ieOpHolder", "Cortex Op", - SOP_OpHolder::create, SOP_ParameterisedHolder::parameters, 0, 4, - SOP_ParameterisedHolder::variables, OP_FLAG_GENERATOR - ); - opHolder->setIconName( "CortexLogoMini" ); - - OP_Operator *converter = new OP_Operator( - SOP_CortexConverter::typeName, "Cortex Convert", - SOP_CortexConverter::create, SOP_CortexConverter::parameters, 1, 1, - SOP_CortexConverter::variables, OP_FLAG_GENERATOR - ); - converter->setIconName( "CortexLogoMini" ); - - OP_Operator *sceneCacheSource = new OP_Operator( - SOP_SceneCacheSource::typeName, "SceneCache Source", - SOP_SceneCacheSource::create, SOP_SceneCacheSource::buildParameters(), 0, 0, - NULL, OP_FLAG_GENERATOR - ); - /// \todo: get a new icon - sceneCacheSource->setIconName( "SOP_ieCortexConverter" ); - - OP_Operator *sceneCacheTransform = new OP_Operator( - SOP_SceneCacheTransform::typeName, "SceneCache Xform", - SOP_SceneCacheTransform::create, SOP_SceneCacheTransform::buildParameters(), 1, 1, NULL - ); - /// \todo: get a new icon - sceneCacheTransform->setIconName( "SOP_xform" ); - - table->addOperator( opHolder ); - table->addOperator( converter ); - table->addOperator( sceneCacheSource ); - table->addOperator( sceneCacheTransform ); - - table->addOpHidden( opHolder->getName() ); - table->addOpHidden( converter->getName() ); - table->addOpHidden( sceneCacheSource->getName() ); - table->addOpHidden( sceneCacheTransform->getName() ); -} - -void newObjectOperator( OP_OperatorTable *table ) -{ - OP_Operator *sceneCacheTransform = new OP_Operator( - OBJ_SceneCacheTransform::typeName, "SceneCache Xform", - OBJ_SceneCacheTransform::create, - OBJ_SceneCacheTransform::buildParameters(), -#if UT_MAJOR_VERSION_INT >= 16 - OBJ_SceneCacheTransform::theChildTableName, -#endif - 0, 1 - ); - /// \todo: get a new icon - sceneCacheTransform->setIconName( "SOP_ieCortexConverter" ); - - OP_Operator *sceneCacheGeometry = new OP_Operator( - OBJ_SceneCacheGeometry::typeName, "SceneCache GEO", - OBJ_SceneCacheGeometry::create, - OBJ_SceneCacheGeometry::buildParameters(), -#if UT_MAJOR_VERSION_INT >= 16 - OBJ_SceneCacheGeometry::theChildTableName, -#endif - 0, 1, NULL - ); - /// \todo: get a new icon - sceneCacheGeometry->setIconName( "SOP_ieProceduralHolder" ); - - table->addOperator( sceneCacheTransform ); - table->addOperator( sceneCacheGeometry ); - - table->addOpHidden( sceneCacheTransform->getName() ); - table->addOpHidden( sceneCacheGeometry->getName() ); -} - -void newDriverOperator( OP_OperatorTable *table ) -{ - OP_Operator *sceneCacheWriter = new OP_Operator( - ROP_SceneCacheWriter::typeName, "SceneCache Writer", - ROP_SceneCacheWriter::create, - ROP_SceneCacheWriter::buildParameters(), -#if UT_MAJOR_VERSION_INT >= 16 - ROP_SceneCacheWriter::theChildTableName, -#endif - 0, 999, NULL, - OP_FLAG_GENERATOR - ); - sceneCacheWriter->setIconName( "CortexLogoMini" ); - - table->addOperator( sceneCacheWriter ); - - table->addOpHidden( sceneCacheWriter->getName() ); -} - -/// Declare our new Render Hooks for Houdini 12.0 and 12.1 only -#if UT_MAJOR_VERSION_INT == 12 && UT_MINOR_VERSION_INT <= 1 -void newRenderHook( GR_RenderTable *table ) -{ - GR_Cortex *hook = new GR_Cortex; - table->addHook( hook, GR_RENDER_HOOK_VERSION ); -} -#endif -extern "C"{ - void newGeometryPrim( GA_PrimitiveFactory *factory ) - { - - CortexPrimitive::registerDefinition(factory); - - } -} - -/// Declare our new IO Translators -void newGeometryIO( void * ) -{ - GU_Detail::registerIOTranslator( new GEO_CobIOTranslator() ); - - UT_ExtensionList *geoextension = UTgetGeoExtensions(); - if ( !geoextension->findExtension( "cob" ) ) - { - geoextension->addExtension( "cob" ); - } - if ( !geoextension->findExtension( "pdc" ) ) - { - geoextension->addExtension( "pdc" ); - } -} diff --git a/src/IECoreMaya/BoolParameterHandler.cpp b/src/IECoreMaya/BoolParameterHandler.cpp deleted file mode 100644 index 8efdd098fc..0000000000 --- a/src/IECoreMaya/BoolParameterHandler.cpp +++ /dev/null @@ -1,146 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/BoolParameterHandler.h" - -#include "IECore/TypedParameter.h" -#include "IECore/CompoundObject.h" - -#include "maya/MFnNumericAttribute.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< BoolParameterHandler > registrar( IECore::BoolParameter::staticTypeId() ); - -MStatus BoolParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstBoolParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnNumericAttribute fnNAttr( attribute ); - if( !fnNAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - fnNAttr.setDefault( p->typedDefaultValue() ); - - bool keyable = true; - bool channelBox = true; - - const IECore::ConstCompoundObjectPtr userData = parameter->userData(); - assert( userData ); - - /// \todo This stuff could be consolidated into one place as it appears to be duplicated in several - /// ParameterHandlers - const IECore::ConstCompoundObjectPtr maya = userData->member("maya"); - if (maya) - { - const IECore::ConstBoolDataPtr keyableData = maya->member("keyable"); - if (keyableData) - { - keyable = keyableData->readable(); - } - - const IECore::ConstBoolDataPtr channelBoxData = maya->member("channelBox"); - if (channelBoxData) - { - channelBox = channelBoxData->readable(); - } - } - - fnNAttr.setKeyable( keyable ); - - // Calling setChannelBox(true) disables keying - if (!keyable) - { - fnNAttr.setChannelBox( channelBox ); - } - - return finishUpdating( parameter, plug ); -} - -MPlug BoolParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstBoolParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnNumericAttribute fnNAttr; - MObject attribute = fnNAttr.create( plugName, plugName, MFnNumericData::kBoolean, p->typedDefaultValue() ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - return result; -} - -MStatus BoolParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstBoolParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - return plug.setValue( p->getTypedValue() ); -} - -MStatus BoolParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - IECore::BoolParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - bool v; - MStatus result; - result = plug.getValue( v ); - if( result ) - { - p->setTypedValue( v ); - } - return result; -} diff --git a/src/IECoreMaya/BoxParameterHandler.cpp b/src/IECoreMaya/BoxParameterHandler.cpp deleted file mode 100644 index 9a0b152649..0000000000 --- a/src/IECoreMaya/BoxParameterHandler.cpp +++ /dev/null @@ -1,259 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/BoxParameterHandler.h" - -#include "IECore/NumericParameter.h" -#include "IECore/TypedParameter.h" - -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnCompoundAttribute.h" - - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< BoxParameterHandler > box2fRegistrar( IECore::Box2fParameter::staticTypeId() ); -static ParameterHandler::Description< BoxParameterHandler > box3fRegistrar( IECore::Box3fParameter::staticTypeId() ); -static ParameterHandler::Description< BoxParameterHandler > box2dRegistrar( IECore::Box2dParameter::staticTypeId() ); -static ParameterHandler::Description< BoxParameterHandler > box3dRegistrar( IECore::Box3dParameter::staticTypeId() ); - -template -MStatus BoxParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( fnCAttr.numChildren()!=2 ) - { - return MS::kFailure; - } - - MFnNumericAttribute fnMinAttr( fnCAttr.child( 0 ) ); - if( fnMinAttr.unitType()!=NumericTraits::dataType() ) - { - return MS::kFailure; - } - - MFnNumericAttribute fnMaxAttr( fnCAttr.child( 1 ) ); - if( fnMaxAttr.unitType()!=NumericTraits::dataType() ) - { - return MS::kFailure; - } - - // Set the default value for the leaf attributes individually. Calling - // the variants of setDefault that set several components at a time - // seems to exercise a maya bug. See similar comment in CompoundNumericParameterHandler. - Box defValue = p->typedDefaultValue(); - MStatus s; - for( unsigned i=0; i -MPlug BoxParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnNumericAttribute fnNAttr; - MFnCompoundAttribute fnCAttr; - MObject oMin, oMax; - switch( T::dimensions() ) - { - case 2 : - { - MObject oMinX = fnNAttr.create( plugName + "MinX", plugName + "MinX", NumericTraits::baseDataType() ); - MObject oMinY = fnNAttr.create( plugName + "MinY", plugName + "MinY", NumericTraits::baseDataType() ); - oMin = fnNAttr.create( plugName + "Min", plugName + "Min", oMinX, oMinY ); - - MObject oMaxX = fnNAttr.create( plugName + "MaxX", plugName + "MaxX", NumericTraits::baseDataType() ); - MObject oMaxY = fnNAttr.create( plugName + "MaxY", plugName + "MaxY", NumericTraits::baseDataType() ); - oMax = fnNAttr.create( plugName + "Max", plugName + "Max", oMaxX, oMaxY ); - } - break; - case 3 : - oMin = fnNAttr.createPoint( plugName + "Min", plugName + "Min" ); - oMax = fnNAttr.createPoint( plugName + "Max", plugName + "Max" ); - break; - default : - return MPlug(); - } - - MObject attribute = fnCAttr.create( plugName, plugName ); - fnCAttr.addChild( oMin ); - fnCAttr.addChild( oMax ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus BoxParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != 2 ) - { - return MS::kFailure; - } - - MPlug minPlug = plug.child( 0 ); - MPlug maxPlug = plug.child( 1 ); - - if( minPlug.numChildren()!=T::dimensions() || maxPlug.numChildren()!=T::dimensions() ) - { - return MS::kFailure; - } - - Box v = p->getTypedValue(); - for( unsigned i=0; i -MStatus BoxParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - typename IECore::TypedParameter >::Ptr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != 2 ) - { - return MS::kFailure; - } - - MPlug minPlug = plug.child( 0 ); - MPlug maxPlug = plug.child( 1 ); - - if( minPlug.numChildren()!=T::dimensions() || maxPlug.numChildren()!=T::dimensions() ) - { - return MS::kFailure; - } - - Box v; - for( unsigned i=0; isetTypedValue( v ); - return MS::kSuccess; -} diff --git a/src/IECoreMaya/CacheSet.cpp b/src/IECoreMaya/CacheSet.cpp deleted file mode 100644 index 6f917b0f1c..0000000000 --- a/src/IECoreMaya/CacheSet.cpp +++ /dev/null @@ -1,141 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MTime.h" -#include "maya/MGlobal.h" - -#include "IECore/Exception.h" -#include "IECoreMaya/CacheSet.h" -#include "IECoreMaya/MayaTime.h" -#include "IECoreMaya/MayaTypeIds.h" - -using namespace IECore; -using namespace IECoreMaya; - -MObject CacheSet::aActive; -MObject CacheSet::aFrameRate; -MObject CacheSet::aOversamples; -MObject CacheSet::aOutFrameMel; - -MTypeId CacheSet::id( CacheSetId ); - -CacheSet::CacheSet() -{ -} - -CacheSet::~CacheSet() -{ -} - -void *CacheSet::creator() -{ - return new CacheSet; -} - -bool CacheSet::isAbstractClass() const -{ - // ideally we would return true, but then pymel gets upset, because - // it tries to make a node of every single type during startup, and prints - // warnings if it fails. i'm not sure why it does this. - return false; -} - -MStatus CacheSet::initialize() -{ - MStatus s; - MFnNumericAttribute nAttr; - MFnTypedAttribute tAttr; - - aActive = nAttr.create("active", "a", MFnNumericData::kBoolean, true, &s); - nAttr.setReadable(true); - nAttr.setWritable(true); - nAttr.setStorable(true); - nAttr.setKeyable(true); - - aFrameRate = nAttr.create("frameRate", "fr", MFnNumericData::kDouble, 24.0, &s); - nAttr.setReadable(true); - nAttr.setWritable(true); - nAttr.setStorable(true); - nAttr.setMin(1.0); - - aOversamples = nAttr.create("oversamples", "os", MFnNumericData::kInt, 1, &s); - nAttr.setReadable(true); - nAttr.setWritable(true); - nAttr.setStorable(true); - nAttr.setMin(1); - - aOutFrameMel = tAttr.create("outFrameMel", "ofc", MFnData::kString); - tAttr.setWritable(false); - tAttr.setReadable(true); - - - s = addAttribute(aActive); - assert(s); - - s = addAttribute(aFrameRate); - assert(s); - - s = addAttribute(aOversamples); - assert(s); - - s = addAttribute(aOutFrameMel); - assert(s); - - s = attributeAffects(aActive, aOutFrameMel); - assert(s); - - return MS::kSuccess; -} - -MString CacheSet::melFromStringArray(const MStringArray &a) const -{ - MString mel = "{"; - for (unsigned i = 0; i < a.length(); i++) - { - if (i != 0) - { - mel += ", "; - } - mel += "\""; - mel += a[i]; - mel += "\""; - } - mel += "}"; - - return mel; -} diff --git a/src/IECoreMaya/CallbackId.cpp b/src/IECoreMaya/CallbackId.cpp deleted file mode 100644 index d9498bc4d2..0000000000 --- a/src/IECoreMaya/CallbackId.cpp +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/CallbackId.h" -#include "IECoreMaya/StatusException.h" - -using namespace IECoreMaya; - -CallbackId::CallbackId() - : m_id( 0 ) -{ -} - -CallbackId::CallbackId( MCallbackId id ) - : m_id( id ) -{ -} - -CallbackId::~CallbackId() -{ - if( m_id ) - { - StatusException::throwIfError( MMessage::removeCallback( m_id ) ); - } -} - -const CallbackId &CallbackId::operator = ( MCallbackId id ) -{ - if( m_id ) - { - StatusException::throwIfError( MMessage::removeCallback( m_id ) ); - } - m_id = id; - return *this; -} - - -CallbackId::CallbackId( const CallbackId &other ) -{ -} diff --git a/src/IECoreMaya/ClassParameterHandler.cpp b/src/IECoreMaya/ClassParameterHandler.cpp deleted file mode 100644 index 0699d78e0e..0000000000 --- a/src/IECoreMaya/ClassParameterHandler.cpp +++ /dev/null @@ -1,342 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "maya/MFnCompoundAttribute.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MGlobal.h" - -#include "IECore/CompoundObject.h" -#include "IECore/Exception.h" -#include "IECore/SimpleTypedData.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECoreMaya/ClassParameterHandler.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static ParameterHandler::Description registrar( IECore::ClassParameterTypeId ); - -MStatus ClassParameterHandler::setClass( IECore::ParameterPtr parameter, const MString &className, int classVersion, const MString &searchPathEnvVar ) -{ - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( parameter ); - pythonParameter.attr( "setClass" )( className.asChar(), classVersion, searchPathEnvVar.asChar() ); - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - return MS::kFailure; - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassParameterHandler::setClass : " ) + e.what() ); - return MS::kFailure; - } - return MS::kSuccess; -} - -MStatus ClassParameterHandler::getClass( IECore::ConstParameterPtr parameter, MString &className, int &classVersion, MString &searchPathEnvVar ) -{ - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( boost::const_pointer_cast( parameter ) ); - boost::python::tuple classInfo = extract( pythonParameter.attr( "getClass" )( true ) ); - - className = extract( classInfo[1] ); - classVersion = extract( classInfo[2] ); - searchPathEnvVar = extract( classInfo[3] ); - - return MS::kSuccess; - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassParameterHandler::getClass : " ) + e.what() ); - } - return MS::kFailure; -} - -void ClassParameterHandler::currentClass( const MPlug &plug, MString &className, int &classVersion, MString &searchPathEnvVar ) -{ - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if ( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kStringArray ) - { - // compatibility for the deprecated compound plug behaviour - className = plug.child( 0 ).asString(); - classVersion = plug.child( 1 ).asInt(); - searchPathEnvVar = plug.child( 2 ).asString(); - return; - } - - MFnStringArrayData fnSAD( plug.asMObject() ); - if ( fnSAD.length() == 0 ) - { - className = ""; - classVersion = 0; - searchPathEnvVar = ""; - return; - } - - if ( fnSAD.length() != 3 ) - { - throw( IECore::InvalidArgumentException( ( plug.name() + " has more than 3 values. Expected name, version, searchPath only." ).asChar() ) ); - } - - MStringArray storedClassInfo = fnSAD.array(); - if ( !storedClassInfo[1].isInt() ) - { - throw( IECore::InvalidArgumentException( ( "Second value of " + plug.name() + " must represent an integer" ).asChar() ) ); - } - - className = storedClassInfo[0]; - classVersion = storedClassInfo[1].asInt(); - searchPathEnvVar = storedClassInfo[2]; -} - -MStatus ClassParameterHandler::doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - MString className; - int classVersion; - MString searchPathEnvVar; - - try - { - currentClass( plug, className, classVersion, searchPathEnvVar ); - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassParameterHandler::doRestore : " ) + e.what() ); - return MS::kFailure; - } - - return setClass( parameter, className, classVersion, searchPathEnvVar ); -} - -MStatus ClassParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassParameterTypeId ) ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - // compatibility for the deprecated compound plug behaviour: should return MS::kFailure - MFnTypedAttribute fnTAttr( attribute ); - if ( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kStringArray ) - { - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( fnCAttr.numChildren()!=3 ) - { - return MS::kFailure; - } - - MObject classNameAttr = fnCAttr.child( 0 ); - MFnTypedAttribute fnTAttr( classNameAttr ); - if( !fnTAttr.hasObj( classNameAttr ) ) - { - return MS::kFailure; - } - if( fnTAttr.name() != fnCAttr.name() + "__className" ) - { - return MS::kFailure; - } - if( fnTAttr.attrType()!=MFnData::kString ) - { - return MS::kFailure; - } - - MObject classVersionAttr = fnCAttr.child( 1 ); - MFnNumericAttribute fnNAttr( classVersionAttr ); - if( !fnNAttr.hasObj( classVersionAttr ) ) - { - return MS::kFailure; - } - if( fnNAttr.name() != fnCAttr.name() + "__classVersion" ) - { - return MS::kFailure; - } - if( fnNAttr.unitType() != MFnNumericData::kInt ) - { - return MS::kFailure; - } - - MObject searchPathEnvVarAttr = fnCAttr.child( 2 ); - fnTAttr.setObject( searchPathEnvVarAttr ); - if( !fnTAttr.hasObj( searchPathEnvVarAttr ) ) - { - return MS::kFailure; - } - if( fnTAttr.name() != fnCAttr.name() + "__searchPathEnvVar" ) - { - return MS::kFailure; - } - if( fnTAttr.attrType()!=MFnData::kString ) - { - return MS::kFailure; - } - - if( !storeClass( parameter, plug ) ) - { - return MS::kFailure; - } - } - - if( !storeClass( parameter, plug ) ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -MPlug ClassParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassParameterTypeId ) ) - { - return MPlug(); - } - - MFnTypedAttribute fnTAttr; - MObject attribute = fnTAttr.create( plugName, plugName, MFnData::kStringArray ); - MPlug result = finishCreating( parameter, attribute, node ); - - if( !storeClass( parameter, result ) ) - { - return MPlug(); // failure - } - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); // failure - } - - return result; -} - -MStatus ClassParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassParameterTypeId ) ) - { - return MS::kFailure; - } - return MS::kSuccess; -} - -MStatus ClassParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassParameterTypeId ) ) - { - return MS::kFailure; - } - - return MS::kSuccess; -} - -MStatus ClassParameterHandler::storeClass( IECore::ConstParameterPtr parameter, MPlug &plug ) -{ - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( boost::const_pointer_cast( parameter ) ); - boost::python::object classInfo = pythonParameter.attr( "getClass" )( true ); - - std::string className = boost::python::extract( classInfo[1] ); - int classVersion = boost::python::extract( classInfo[2] ); - std::string searchPathEnvVar = boost::python::extract( classInfo[3] ); - - MString storedClassName; - int storedClassVersion; - MString storedSearchPathEnvVar; - currentClass( plug, storedClassName, storedClassVersion, storedSearchPathEnvVar ); - - // only set the plug values if the new value is genuinely different, as otherwise - // we end up generating unwanted reference edits. - if ( storedClassName != className.c_str() || storedClassVersion != classVersion || storedSearchPathEnvVar != searchPathEnvVar.c_str() ) - { - MStringArray updatedClassInfo; - updatedClassInfo.append( className.c_str() ); - MString classVersionStr; - classVersionStr.set( classVersion, 0 ); - updatedClassInfo.append( classVersionStr ); - updatedClassInfo.append( searchPathEnvVar.c_str() ); - - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if ( fnTAttr.attrType() == MFnData::kStringArray ) - { - MObject data = MFnStringArrayData().create( updatedClassInfo ); - plug.setValue( data ); - } - else - { - // compatibility for the deprecated compound plug behaviour. keeping this code - // so we can still read old scenes. creation of these plugs has been removed. - /// \todo: find all such notes and remove the unnecessary code for Cortex 9. - plug.child( 0 ).setString( className.c_str() ); - plug.child( 1 ).setInt( classVersion ); - plug.child( 2 ).setString( searchPathEnvVar.c_str() ); - } - } - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - return MS::kFailure; - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassParameterHandler::setClass : " ) + e.what() ); - return MS::kFailure; - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ClassVectorParameterHandler.cpp b/src/IECoreMaya/ClassVectorParameterHandler.cpp deleted file mode 100644 index e64a9b402c..0000000000 --- a/src/IECoreMaya/ClassVectorParameterHandler.cpp +++ /dev/null @@ -1,400 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "maya/MFnCompoundAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MFnIntArrayData.h" -#include "maya/MGlobal.h" - -#include "IECore/CompoundObject.h" -#include "IECore/SimpleTypedData.h" - -#include "IECorePython/ScopedGILLock.h" -#include "IECorePython/IECoreBinding.h" - -#include "IECoreMaya/ClassVectorParameterHandler.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static ParameterHandler::Description registrar( IECore::ClassVectorParameterTypeId ); - - -MStatus ClassVectorParameterHandler::setClasses( IECore::ParameterPtr parameter, const MStringArray ¶meterNames, const MStringArray &classNames, const MIntArray &classVersions ) -{ - assert( parameterNames.length() == classNames.length() ); - assert( parameterNames.length() == classVersions.length() ); - - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( parameter ); - - boost::python::list classes; - for( unsigned i=0; i( parameter ) ); - boost::python::list classesInfo = extract( pythonParameter.attr( "getClasses" )( true ) ); - - int l = boost::python::len( classesInfo ); - for( int i=0; i( classesInfo[i] ); - parameterNames.append( MString( extract( c[1] ) ) ); - classNames.append( MString( extract( c[2] ) ) ); - classVersions.append( extract( c[3] ) ); - } - - return MS::kSuccess; - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassVectorParameterHandler::getClasses : " ) + e.what() ); - } - return MS::kFailure; -} - -void ClassVectorParameterHandler::currentClasses( const MPlug &plug, MStringArray ¶meterNames, MStringArray &classNames, MIntArray &classVersions ) -{ - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if ( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kStringArray ) - { - // compatibility for the deprecated compound plug behaviour - MObject parameterNamesObject = plug.child( 0 ).asMObject(); - MFnStringArrayData fnSAD( parameterNamesObject ); - fnSAD.copyTo( parameterNames ); - - MObject classNamesObject = plug.child( 1 ).asMObject(); - fnSAD.setObject( classNamesObject ); - fnSAD.copyTo( classNames ); - - MObject classVersionsObject = plug.child( 2 ).asMObject(); - MFnIntArrayData fnIAD( classVersionsObject ); - fnIAD.copyTo( classVersions ); - return; - } - - parameterNames.clear(); - classNames.clear(); - classVersions.clear(); - - MFnStringArrayData fnSAD( plug.asMObject() ); - if ( fnSAD.length() == 0 ) - { - return; - } - - if ( fnSAD.length() % 3 != 0 ) - { - throw( IECore::InvalidArgumentException( ( plug.name() + " needs 3 values per class. Expected a series of name, className, version." ).asChar() ) ); - } - - MStringArray storedClassInfo = fnSAD.array(); - for ( unsigned i=0; i < storedClassInfo.length(); i+=3 ) - { - if ( !storedClassInfo[i+2].isInt() ) - { - throw( IECore::InvalidArgumentException( ( "Version values of " + plug.name() + " must represent an integer" ).asChar() ) ); - } - - parameterNames.append( storedClassInfo[i] ); - classNames.append( storedClassInfo[i+1] ); - classVersions.append( storedClassInfo[i+2].asInt() ); - } -} - -MStatus ClassVectorParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassVectorParameterTypeId ) ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - // compatibility for the deprecated compound plug behaviour: should return MS::kFailure - if ( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kStringArray ) - { - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( fnCAttr.numChildren()!=3 ) - { - return MS::kFailure; - } - - MObject parameterNamesAttr = fnCAttr.child( 0 ); - MFnTypedAttribute fnTAttr( parameterNamesAttr ); - if( !fnTAttr.hasObj( parameterNamesAttr ) ) - { - return MS::kFailure; - } - if( fnTAttr.name() != fnCAttr.name() + "__parameterNames" ) - { - return MS::kFailure; - } - if( fnTAttr.attrType()!=MFnData::kStringArray ) - { - return MS::kFailure; - } - - MObject classNamesAttr = fnCAttr.child( 1 ); - fnTAttr.setObject( classNamesAttr ); - if( !fnTAttr.hasObj( classNamesAttr ) ) - { - return MS::kFailure; - } - if( fnTAttr.name() != fnCAttr.name() + "__classNames" ) - { - return MS::kFailure; - } - if( fnTAttr.attrType()!=MFnData::kStringArray ) - { - return MS::kFailure; - } - - MObject classVersionsAttr = fnCAttr.child( 2 ); - fnTAttr.setObject( classVersionsAttr ); - if( !fnTAttr.hasObj( classVersionsAttr ) ) - { - return MS::kFailure; - } - if( fnTAttr.name() != fnCAttr.name() + "__classVersions" ) - { - return MS::kFailure; - } - if( fnTAttr.attrType()!=MFnData::kIntArray ) - { - return MS::kFailure; - } - } - - if( !storeClasses( parameter, plug ) ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -MStatus ClassVectorParameterHandler::doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - MStringArray parameterNames; - MStringArray classNames; - MIntArray classVersions; - - try - { - currentClasses( plug, parameterNames, classNames, classVersions ); - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassVectorParameterHandler::doRestore : " ) + e.what() ); - return MS::kFailure; - } - - return setClasses( parameter, parameterNames, classNames, classVersions ); -} - -MPlug ClassVectorParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassVectorParameterTypeId ) ) - { - return MPlug(); - } - - MFnTypedAttribute fnTAttr; - MObject attribute = fnTAttr.create( plugName, plugName, MFnData::kStringArray ); - MPlug result = finishCreating( parameter, attribute, node ); - - if( !storeClasses( parameter, result ) ) - { - return MPlug(); // failure - } - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); // failure - } - - return result; -} - -MStatus ClassVectorParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassVectorParameterTypeId ) ) - { - return MS::kFailure; - } - return MS::kSuccess; -} - -MStatus ClassVectorParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - if( !parameter || !parameter->isInstanceOf( IECore::ClassVectorParameterTypeId ) ) - { - return MS::kFailure; - } - - return MS::kSuccess; -} - -MStatus ClassVectorParameterHandler::storeClasses( IECore::ConstParameterPtr parameter, MPlug &plug ) -{ - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( boost::const_pointer_cast( parameter ) ); - boost::python::object classes = pythonParameter.attr( "getClasses" )( true ); - - MStringArray storedParameterNames; - MStringArray storedClassNames; - MIntArray storedClassVersions; - currentClasses( plug, storedParameterNames, storedClassNames, storedClassVersions ); - unsigned storedParameterNamesLength = storedParameterNames.length(); - unsigned storedClassNamesLength = storedClassNames.length(); - unsigned storedClassVersionsLength = storedClassVersions.length(); - - MStringArray updatedClassInfo; - // compatibility for the deprecated compound plug behaviour - MStringArray parameterNames; - MStringArray classNames; - MIntArray classVersions; - - size_t l = IECorePython::len( classes ); - bool changed = l != storedParameterNamesLength || l != storedClassNamesLength || l != storedClassVersionsLength; - - for( size_t i=0; i( cl[1] )(); - updatedClassInfo.append( parameterName ); - parameterNames.append( parameterName ); - if( i < storedParameterNamesLength && parameterName != storedParameterNames[i] ) - { - changed = true; - } - - MString className = boost::python::extract( cl[2] )(); - updatedClassInfo.append( className ); - classNames.append( className ); - if( i < storedClassNamesLength && className != storedClassNames[i] ) - { - changed = true; - } - - int classVersion = boost::python::extract( cl[3] ); - MString classVersionStr; - classVersionStr.set( classVersion, 0 ); - updatedClassInfo.append( classVersionStr ); - classVersions.append( classVersion ); - if( i < storedClassVersionsLength && classVersion != storedClassVersions[i] ) - { - changed = true; - } - } - - // only set the plug values if the new value is genuinely different, as otherwise - // we end up generating unwanted reference edits. - if ( changed ) - { - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if ( fnTAttr.attrType() == MFnData::kStringArray ) - { - MObject data = MFnStringArrayData().create( updatedClassInfo ); - plug.setValue( data ); - } - else - { - // compatibility for the deprecated compound plug behaviour. keeping this code - // so we can still read old scenes. creation of these plugs has been removed. - /// \todo: find all such notes and remove the unnecessary code for Cortex 9. - MObject parameterNamesObject = MFnStringArrayData().create( parameterNames ); - plug.child( 0 ).setValue( parameterNamesObject ); - MObject classNamesObject = MFnStringArrayData().create( classNames ); - plug.child( 1 ).setValue( classNamesObject ); - MObject classVersionsObject = MFnIntArrayData().create( classVersions ); - plug.child( 2 ).setValue( classVersionsObject ); - } - } - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - return MS::kFailure; - } - catch( const std::exception &e ) - { - MGlobal::displayError( MString( "ClassVectorParameterHandler::setClass : " ) + e.what() ); - return MS::kFailure; - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ColorSplineParameterHandler.cpp b/src/IECoreMaya/ColorSplineParameterHandler.cpp deleted file mode 100644 index 7b1c161287..0000000000 --- a/src/IECoreMaya/ColorSplineParameterHandler.cpp +++ /dev/null @@ -1,307 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/ColorSplineParameterHandler.h" -#include "IECoreMaya/MArrayIter.h" - -#include "IECore/SplineParameter.h" - -#include "IECoreMaya/Convert.h" - -#include "maya/MFnCompoundAttribute.h" -#include "maya/MRampAttribute.h" -#include "maya/MFloatArray.h" -#include "maya/MIntArray.h" -#include "maya/MColor.h" -#include "maya/MColorArray.h" -#include "maya/MGlobal.h" -#include "maya/MFnDagNode.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -template<> ParameterHandler::Description< ColorSplineParameterHandler< IECore::SplinefColor3f > > - ColorSplineParameterHandler< IECore::SplinefColor3f >::g_registrar - ( IECore::SplinefColor3fParameter::staticTypeId() ); - -template<> ParameterHandler::Description< ColorSplineParameterHandler< IECore::SplinefColor4f > > - ColorSplineParameterHandler< IECore::SplinefColor4f >::g_registrar - ( IECore::SplinefColor4fParameter::staticTypeId() ); - -template -MStatus ColorSplineParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - MRampAttribute fnRAttr( plug ); - if( !fnRAttr.isColorRamp() ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -template -MPlug ColorSplineParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MPlug(); - } - - MRampAttribute fnRAttr; - MObject attribute = fnRAttr.createColorRamp( plugName, plugName ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus ColorSplineParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - assert( parameter ); - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MRampAttribute fnRAttr( plug ); - if ( !fnRAttr.isColorRamp() ) - { - return MS::kFailure; - } - - const S &spline = p->getTypedValue(); - - MStatus s; - MIntArray indicesToReuse; - plug.getExistingArrayAttributeIndices( indicesToReuse, &s ); - assert( s ); - - int nextNewLogicalIndex = 0; - if( indicesToReuse.length() ) - { - nextNewLogicalIndex = 1 + *std::max_element( MArrayIter::begin( indicesToReuse ), MArrayIter::end( indicesToReuse ) ); - } - - assert( indicesToReuse.length() == fnRAttr.getNumEntries() ); - - size_t pointsSizeMinus2 = spline.points.size() - 2; - unsigned pointIndex = 0; - unsigned numExpectedPoints = 0; - for ( typename S::PointContainer::const_iterator it = spline.points.begin(); it != spline.points.end(); ++it, ++pointIndex ) - { - // we commonly double up the endpoints on cortex splines to force interpolation to the end. - // maya does this implicitly, so we skip duplicated endpoints when passing the splines into maya. - // this avoids users having to be responsible for managing the duplicates, and gives them some consistency - // with the splines they edit elsewhere in maya. - if( ( pointIndex==1 && *it == *spline.points.begin() ) || ( pointIndex==pointsSizeMinus2 && *it == *spline.points.rbegin() ) ) - { - continue; - } - - MPlug pointPlug; - if( indicesToReuse.length() ) - { - pointPlug = plug.elementByLogicalIndex( indicesToReuse[0] ); - indicesToReuse.remove( 0 ); - } - else - { - pointPlug = plug.elementByLogicalIndex( nextNewLogicalIndex++ ); - } - - s = pointPlug.child( 0 ).setValue( it->first ); assert( s ); - MPlug colorPlug = pointPlug.child( 1 ); - colorPlug.child( 0 ).setValue( it->second[0] ); - colorPlug.child( 1 ).setValue( it->second[1] ); - colorPlug.child( 2 ).setValue( it->second[2] ); - // hardcoding interpolation of 3 (spline) because the MRampAttribute::MInterpolation enum values don't actually - // correspond to the necessary plug values at all. - s = pointPlug.child( 2 ).setValue( 3 ); assert( s ); - - numExpectedPoints++; - } - - // delete any of the original indices which we didn't reuse. we can't use MRampAttribute::deleteEntries - // here as it's utterly unreliable. - if( indicesToReuse.length() ) - { - MString plugName = plug.name(); - MObject node = plug.node(); - MFnDagNode fnDAGN( node ); - if( fnDAGN.hasObj( node ) ) - { - plugName = fnDAGN.fullPathName() + "." + plug.partialName(); - } - for( unsigned i=0; isecond[0], it->second[1], it->second[2] ); - if ( fabs( it->first - position ) < 1.e-3f && ( color2 - color ).length() < 1.e-3f ) - { - found = true; - } - } - assert( found ); - } - } -#endif - - return MS::kSuccess; -} - -template -MStatus ColorSplineParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::Ptr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - S spline; - - MStatus s; - MRampAttribute fnRAttr( plug, &s ); - assert( s ); - - if ( !fnRAttr.isColorRamp() ) - { - return MS::kFailure; - } - - MIntArray indices; - (const_cast( plug )).getExistingArrayAttributeIndices( indices, &s ); - - for( unsigned i = 0; i < indices.length(); i++ ) - { - MPlug pointPlug = plug.elementByLogicalIndex( indices[i] ); - MPlug colorPlug = pointPlug.child( 1 ); - - typename S::YType y( 1 ); - y[0] = colorPlug.child( 0 ).asDouble(); - y[1] = colorPlug.child( 1 ).asDouble(); - y[2] = colorPlug.child( 2 ).asDouble(); - - spline.points.insert( - typename S::PointContainer::value_type( pointPlug.child( 0 ).asDouble(), y ) - ); - } - - // maya seems to do an implicit doubling up of the end points to cause interpolation to the ends. - // our spline has no such implicit behaviour so we explicitly double up. - if( spline.points.size() ) - { -#ifndef NDEBUG - size_t oldSplineSize = spline.points.size(); -#endif - - assert( spline.points.begin()->first <= spline.points.rbegin()->first ); - spline.points.insert( *spline.points.begin() ); - spline.points.insert( *spline.points.rbegin() ); - assert( spline.points.size() == oldSplineSize + 2 ); - } - - p->setTypedValue( spline ); - - if( spline.points.size() ) - { - assert( spline.points.size() >= 2 ); - assert( spline.points.size() == fnRAttr.getNumEntries() + 2 ); - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/CompoundNumericParameterHandler.cpp b/src/IECoreMaya/CompoundNumericParameterHandler.cpp deleted file mode 100644 index 52b2f135f6..0000000000 --- a/src/IECoreMaya/CompoundNumericParameterHandler.cpp +++ /dev/null @@ -1,269 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/CompoundNumericParameterHandler.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/NumericParameter.h" -#include "IECore/CompoundParameter.h" -#include "IECore/TypedParameter.h" - -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnCompoundAttribute.h" - - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< CompoundNumericParameterHandler > v2iRegistrar( IECore::V2iParameter::staticTypeId() ); -static ParameterHandler::Description< CompoundNumericParameterHandler > v3iRegistrar( IECore::V3iParameter::staticTypeId() ); - -static ParameterHandler::Description< CompoundNumericParameterHandler > v2fRegistrar( IECore::V2fParameter::staticTypeId() ); -static ParameterHandler::Description< CompoundNumericParameterHandler > v3fRegistrar( IECore::V3fParameter::staticTypeId() ); - -static ParameterHandler::Description< CompoundNumericParameterHandler > v2dRegistrar( IECore::V2dParameter::staticTypeId() ); -static ParameterHandler::Description< CompoundNumericParameterHandler > v3dRegistrar( IECore::V3dParameter::staticTypeId() ); - -static ParameterHandler::Description< CompoundNumericParameterHandler > color3fRegistrar( IECore::Color3fParameter::staticTypeId() ); - -template -MStatus CompoundNumericParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnNumericAttribute fnNAttr( attribute ); - if( !fnNAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( fnNAttr.unitType()!=NumericTraits::dataType() ) - { - return MS::kFailure; - } - - /// Set the default value one child attribute at a time. It would appear that using the variants of setDefault - /// which take 2 or 3 arguments can exercise a Maya bug. - T defValue = p->typedDefaultValue(); - for( unsigned i=0; i::isColor() ); - - bool keyable = true; - bool channelBox = true; - - const IECore::ConstCompoundObjectPtr userData = parameter->userData(); - assert( userData ); - - const IECore::ConstCompoundObjectPtr maya = userData->member("maya"); - if (maya) - { - const IECore::ConstBoolDataPtr keyableData = maya->member("keyable"); - if (keyableData) - { - keyable = keyableData->readable(); - } - - const IECore::ConstBoolDataPtr channelBoxData = maya->member("channelBox"); - if (channelBoxData) - { - channelBox = channelBoxData->readable(); - } - } - - fnNAttr.setKeyable( keyable ); - - // Calling setChannelBox(true) disables keying - if (!keyable) - { - fnNAttr.setChannelBox( channelBox ); - } - - return finishUpdating( parameter, plug ); -} - -template -MPlug CompoundNumericParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - typename IECore::TypedParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnNumericAttribute fnNAttr; - MObject attribute; - switch( T::dimensions() ) - { - case 2 : - { - assert( !NumericTraits::isColor() ); - MObject e0 = fnNAttr.create( plugName + "X", plugName + "X", NumericTraits::baseDataType() ); - MObject e1 = fnNAttr.create( plugName + "Y", plugName + "Y", NumericTraits::baseDataType() ); - attribute = fnNAttr.create( plugName, plugName, e0, e1 ); - } - break; - case 3 : - if( NumericTraits::isColor() ) - { - attribute = fnNAttr.createColor( plugName, plugName ); - } - else - { - MObject e0 = fnNAttr.create( plugName + "X", plugName + "X", NumericTraits::baseDataType() ); - MObject e1 = fnNAttr.create( plugName + "Y", plugName + "Y", NumericTraits::baseDataType() ); - MObject e2 = fnNAttr.create( plugName + "Z", plugName + "Z", NumericTraits::baseDataType() ); - attribute = fnNAttr.create( plugName, plugName, e0, e1, e2 ); - } - break; - default : - assert( false ); - return MPlug(); - } - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus CompoundNumericParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != T::dimensions() ) - { - return MS::kFailure; - } - - T v = p->getTypedValue(); - for( unsigned i=0; i -MStatus CompoundNumericParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - typename IECore::TypedParameter::Ptr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != T::dimensions() ) - { - return MS::kFailure; - } - - T v; - for( unsigned i=0; isetTypedValue( v ); - return MS::kSuccess; -} diff --git a/src/IECoreMaya/CompoundParameterHandler.cpp b/src/IECoreMaya/CompoundParameterHandler.cpp deleted file mode 100644 index 603db76682..0000000000 --- a/src/IECoreMaya/CompoundParameterHandler.cpp +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/CompoundParameterHandler.h" - -#include "IECore/CompoundParameter.h" - -#include "maya/MFnMessageAttribute.h" - -using namespace IECoreMaya; - -static ParameterHandler::Description registrar( IECore::CompoundParameter::staticTypeId() ); - -MStatus CompoundParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstCompoundParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnMessageAttribute fnMAttr( attribute ); - if( !fnMAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -MPlug CompoundParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstCompoundParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnMessageAttribute fnMAttr; - MObject attribute = fnMAttr.create( plugName, plugName ); - - MPlug result = finishCreating( parameter, attribute, node ); - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); - } - - return result; -} - -MStatus CompoundParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - return MS::kSuccess; -} - -MStatus CompoundParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - return MS::kSuccess; -} diff --git a/src/IECoreMaya/Convert.cpp b/src/IECoreMaya/Convert.cpp deleted file mode 100644 index cfbf7e807d..0000000000 --- a/src/IECoreMaya/Convert.cpp +++ /dev/null @@ -1,647 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MStatus.h" -#include "maya/MIntArray.h" -#include "maya/MDoubleArray.h" -#include "maya/MStringArray.h" -#include "maya/MVectorArray.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/SimpleTypedData.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/StatusException.h" - -using namespace Imath; - -namespace IECore -{ - -template<> -std::string convert( const MString &from ) -{ - return from.asChar(); -} - -template<> -MString convert( const std::string &from ) -{ - return from.c_str(); -} - -template<> -Imath::V3f convert( const MVector &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -Imath::V3f convert( const MFloatVector &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -Imath::V3d convert( const MVector &from ) -{ - return Imath::V3d( from[0], from[1], from[2] ); -} - -template<> -Imath::V3d convert( const MFloatVector &from ) -{ - return Imath::V3d( from[0], from[1], from[2] ); -} - -template<> -Imath::V3f convert( const MPoint &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -Imath::V3f convert( const MFloatPoint &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -Imath::V3d convert( const MPoint &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -Imath::V3d convert( const MFloatPoint &from ) -{ - return Imath::V3f( from[0], from[1], from[2] ); -} - -template<> -MVector convert( const Imath::V3f &from ) -{ - return MVector( from[0], from[1], from[2] ); -} - -template<> -MVector convert( const Imath::V3d &from ) -{ - return MVector( from[0], from[1], from[2] ); -} - -template<> -MVector convert( const Imath::Color3f &from ) -{ - return MVector( from[0], from[1], from[2] ); -} - -template<> -MFloatVector convert( const Imath::V3f &from ) -{ - return MFloatVector( from[0], from[1], from[2] ); -} - -template<> -MFloatVector convert( const Imath::V3d &from ) -{ - return MFloatVector( from[0], from[1], from[2] ); -} - -template<> -MFloatVector convert( const Imath::Color3f &from ) -{ - return MFloatVector( from[0], from[1], from[2] ); -} - -template<> -MPoint convert( const Imath::V3f &from ) -{ - return MPoint( from[0], from[1], from[2] ); -} - -template<> -MPoint convert( const Imath::V3d &from ) -{ - return MPoint( from[0], from[1], from[2] ); -} - -template<> -MFloatPoint convert( const Imath::V3f &from ) -{ - return MFloatPoint( from[0], from[1], from[2] ); -} - -template<> -MFloatPoint convert( const Imath::V3d &from ) -{ - return MFloatPoint( from[0], from[1], from[2] ); -} - -template<> -Imath::Color3f convert( const MVector &from ) -{ - return Imath::Color3f( from[0], from[1], from[2] ); -} - -template<> -Imath::Color3f convert( const MColor &from ) -{ - return Imath::Color3f( from[0], from[1], from[2] ); -} - -template<> -Imath::Color4f convert( const MColor &from ) -{ - return Imath::Color4f( from[0], from[1], from[2], 1.0f ); -} - -template<> -MColor convert( const Imath::Color3f &from ) -{ - return MColor( from[0], from[1], from[2], 1.0 ); -} - -template<> -MColor convert( const Imath::Color4f &from ) -{ - return MColor( from[0], from[1], from[2], from[3] ); -} - -template<> -MBoundingBox convert( const Imath::Box3f &from ) -{ - if( from.isEmpty() ) - { - return MBoundingBox(); - } - return MBoundingBox( convert( from.min ), convert( from.max ) ); -} - -template<> -Imath::Box3f convert( const MBoundingBox &from ) -{ - return Imath::Box3f( convert( from.min() ), convert( from.max() ) ); -} - -template<> -MBoundingBox convert( const Imath::Box3d &from ) -{ - if( from.isEmpty() ) - { - return MBoundingBox(); - } - return MBoundingBox( convert( from.min ), convert( from.max ) ); -} - -template<> -Imath::Box3d convert( const MBoundingBox &from ) -{ - return Imath::Box3d( convert( from.min() ), convert( from.max() ) ); -} - -template<> -Imath::Quatf convert( const MQuaternion &from ) -{ - return Imath::Quatf( static_cast(from[3]), static_cast(from[0]), static_cast(from[1]), static_cast(from[2]) ); -} - -template<> -MQuaternion convert( const Imath::Quatf &from ) -{ - return MQuaternion( static_cast(from[1]), static_cast(from[2]), static_cast(from[3]), static_cast(from[0]) ); -} - -template<> -Imath::Quatd convert( const MQuaternion &from ) -{ - return Imath::Quatd( from[3], from[0], from[1], from[2] ); -} - -template<> -MQuaternion convert( const Imath::Quatd &from ) -{ - return MQuaternion( from[1], from[2], from[3], from[0] ); -} - -template<> -Imath::M44f convert( const MMatrix &from ) -{ - return Imath::M44f( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], - from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -Imath::M44d convert( const MMatrix &from ) -{ - return Imath::M44d( from[0][0], from[0][1], from[0][2], from[0][3], from[1][0], from[1][1], from[1][2], from[1][3], - from[2][0], from[2][1], from[2][2], from[2][3], from[3][0], from[3][1], from[3][2], from[3][3] ); -} - -template<> -MMatrix convert( const Imath::M44f &from ) -{ - return MMatrix( from.x ); -} - -template<> -MMatrix convert( const Imath::M44d &from ) -{ - return MMatrix( from.x ); -} - -template< typename T > -typename Imath::Euler::Order mayaToImathRotationOrder( MEulerRotation::RotationOrder order ) -{ - switch( order ) - { - case MEulerRotation::kXYZ: - return Imath::Euler::XYZ; - case MEulerRotation::kYZX: - return Imath::Euler::YZX; - case MEulerRotation::kZXY: - return Imath::Euler::ZXY; - case MEulerRotation::kXZY: - return Imath::Euler::XZY; - case MEulerRotation::kYXZ: - return Imath::Euler::YXZ; - case MEulerRotation::kZYX: - return Imath::Euler::ZYX; - default: - // default rotation. - return Imath::Euler::XYZ; - } -} - -template< typename T > -MEulerRotation::RotationOrder iMathToMayaRotationOrder( typename Imath::Euler::Order order ) -{ - switch( order ) - { - case Imath::Euler::XYZ: - return MEulerRotation::kXYZ; - case Imath::Euler::YZX: - return MEulerRotation::kYZX; - case Imath::Euler::ZXY: - return MEulerRotation::kZXY; - case Imath::Euler::XZY: - return MEulerRotation::kXZY; - case Imath::Euler::YXZ: - return MEulerRotation::kYXZ; - case Imath::Euler::ZYX: - return MEulerRotation::kZYX; - default: - // default rotation. - return MEulerRotation::kXYZ; - } -} - -template<> -Imath::Eulerf convert( const MEulerRotation &from ) -{ - return Imath::Eulerf( from.x, from.y, from.z, mayaToImathRotationOrder( from.order ), Imath::Eulerf::XYZLayout ); -} - -template<> -MEulerRotation convert( const Imath::Eulerf &from ) -{ - Imath::V3f xyz = from.toXYZVector(); - return MEulerRotation( xyz.x, xyz.y, xyz.z, iMathToMayaRotationOrder( from.order() ) ); -} - -template<> -Imath::Eulerd convert( const MEulerRotation &from ) -{ - return Imath::Eulerd( from.x, from.y, from.z, mayaToImathRotationOrder( from.order ), Imath::Eulerd::XYZLayout ); -} - -template<> -MEulerRotation convert( const Imath::Eulerd &from ) -{ - Imath::V3d xyz = from.toXYZVector(); - return MEulerRotation( xyz.x, xyz.y, xyz.z, iMathToMayaRotationOrder( from.order() ) ); -} - -template< typename T > -IECore::TransformationMatrix convertTransf( const MTransformationMatrix &from ) -{ - IECore::TransformationMatrix to; - double vector[3]; - to.scalePivot = convert< Imath::Vec3, MPoint >( from.scalePivot( MSpace::kTransform ) ); - from.getScale( vector, MSpace::kTransform ); - to.scale = Imath::Vec3( static_cast(vector[0]), static_cast(vector[1]), static_cast(vector[2]) ); - from.getShear( vector, MSpace::kTransform ); - to.shear = Imath::Vec3( static_cast(vector[0]), static_cast(vector[1]), static_cast(vector[2]) ); - to.scalePivotTranslation = convert< Imath::Vec3, MVector>( from.scalePivotTranslation( MSpace::kTransform ) ); - to.rotatePivot = convert< Imath::Vec3, MPoint>( from.rotatePivot( MSpace::kTransform ) ); - to.rotationOrientation = convert< Imath::Quat, MQuaternion>( from.rotationOrientation() ); - to.rotate = convert< Imath::Euler, MEulerRotation>( from.eulerRotation() ); - to.rotatePivotTranslation = convert< Imath::Vec3, MVector >( from.rotatePivotTranslation( MSpace::kTransform ) ); - to.translate = convert< Imath::Vec3, MVector >( from.getTranslation( MSpace::kTransform ) ); - return to; -} - -template< typename T > -MTransformationMatrix convertTransf( const IECore::TransformationMatrix &from ) -{ - MTransformationMatrix to; - double vector[3]; - to.setScalePivot( convert< MPoint, Imath::Vec3 >( from.scalePivot ), MSpace::kTransform, false ); - vector[0] = static_cast( from.scale[0] ); - vector[1] = static_cast( from.scale[1] ); - vector[2] = static_cast( from.scale[2] ); - to.setScale( vector, MSpace::kTransform ); - vector[0] = static_cast( from.shear[0] ); - vector[1] = static_cast( from.shear[1] ); - vector[2] = static_cast( from.shear[2] ); - to.setShear( vector, MSpace::kTransform ); - to.setScalePivotTranslation( convert< MVector, Imath::Vec3 >( from.scalePivotTranslation ), MSpace::kTransform ); - to.setRotatePivot( convert< MPoint, Imath::Vec3 >( from.rotatePivot ), MSpace::kTransform, false ); - to.setRotationOrientation( convert< MQuaternion, Imath::Quat >( from.rotationOrientation ) ); - to.rotateTo( convert< MEulerRotation, Imath::Euler >( from.rotate ) ); - to.setRotatePivotTranslation( convert< MVector, Imath::Vec3 >( from.rotatePivotTranslation ), MSpace::kTransform ); - to.setTranslation( convert< MVector, Imath::Vec3 >( from.translate ), MSpace::kTransform ); - return to; -} - -template<> -IECore::TransformationMatrixf convert( const MTransformationMatrix &from ) -{ - return convertTransf< float >( from ); -} - -template<> -MTransformationMatrix convert( const IECore::TransformationMatrixf &from ) -{ - return convertTransf< float >( from ); -} - -template<> -IECore::TransformationMatrixd convert( const MTransformationMatrix &from ) -{ - return convertTransf< double >( from ); -} - -template<> -MTransformationMatrix convert( const IECore::TransformationMatrixd &from ) -{ - return convertTransf< double >( from ); -} - -template<> -IECore::DataPtr convert( const MCommandResult &result ) -{ - MStatus s; - switch (result.resultType()) - { - case MCommandResult::kInvalid: - { - // No result - return 0; - } - case MCommandResult::kInt: - { - int i; - s = result.getResult(i); - assert(s); - - IECore::IntDataPtr data = new IECore::IntData(); - data->writable() = i; - - return data; - } - case MCommandResult::kIntArray: - { - MIntArray v; - s = result.getResult(v); - assert(s); - unsigned sz = v.length(); - IECore::IntVectorDataPtr data = new IECore::IntVectorData(); - data->writable().resize(sz); - for (unsigned i = 0; i < sz; i++) - { - (data->writable())[i] = v[i]; - } - - return data; - } - case MCommandResult::kDouble: - { - double d; - s = result.getResult(d); - assert(s); - - IECore::FloatDataPtr data = new IECore::FloatData(); - data->writable() = static_cast(d); - - return data; - } - case MCommandResult::kDoubleArray: - { - MDoubleArray v; - s = result.getResult(v); - assert(s); - unsigned sz = v.length(); - IECore::DoubleVectorDataPtr data = new IECore::DoubleVectorData(); - data->writable().resize(sz); - for (unsigned i = 0; i < sz; i++) - { - data->writable()[i] = v[i]; - } - - return data; - } - case MCommandResult::kString: - { - MString str; - s = result.getResult(str); - assert(s); - - IECore::StringDataPtr data = new IECore::StringData(); - data->writable() = std::string(str.asChar()); - - return data; - } - case MCommandResult::kStringArray: - { - MStringArray v; - s = result.getResult(v); - assert(s); - unsigned sz = v.length(); - IECore::StringVectorDataPtr data = new IECore::StringVectorData(); - data->writable().resize(sz); - for (unsigned i = 0; i < sz; i++) - { - data->writable()[i] = std::string(v[i].asChar()); - } - - return data; - } - case MCommandResult::kVector: - { - MVector v; - s = result.getResult(v); - assert(s); - - IECore::V3fDataPtr data = new IECore::V3fData(); - data->writable() = Imath::V3f(v.x, v.y, v.z); - - return data; - } - case MCommandResult::kVectorArray: - { - MVectorArray v; - s = result.getResult(v); - assert(s); - unsigned sz = v.length(); - IECore::V3fVectorDataPtr data = new IECore::V3fVectorData(); - data->writable().resize(sz); - for (unsigned i = 0; i < sz; i++) - { - data->writable()[i] = Imath::V3f(v[i].x, v[i].y, v[i].z); - } - - return data; - } - case MCommandResult::kMatrix: - { - MDoubleArray v; - int numRows, numColumns; - - s = result.getResult(v, numRows, numColumns); - assert(s); - - if (numRows > 4 || numColumns > 4) - { - throw IECoreMaya::StatusException( MS::kFailure ); - } - - IECore::M44fDataPtr data = new IECore::M44fData(); - - for (int i = 0; i < numColumns; i++) - { - for (int j = 0; j < numRows; j++) - { - (data->writable())[i][j] = v[i*numRows+j]; - } - } - - return data; - } - case MCommandResult::kMatrixArray: - { - return 0; - } - default: - - assert( false ); - return 0; - } -} - -template<> -MDistance convert( const double &from ) -{ - return MDistance( from, MDistance::kCentimeters ); -} - -template<> -double convert( const MDistance &from ) -{ - return from.asCentimeters(); -} - -template<> -MAngle convert( const double &from ) -{ - return MAngle( from, MAngle::kRadians ); -} - -template<> -double convert( const MAngle &from ) -{ - return from.asRadians(); -} - -template<> -MTime convert( const double &from ) -{ - return MTime( from, MTime::kSeconds ); -} - -template<> -double convert( const MTime &from ) -{ - return from.as( MTime::kSeconds ); -} - -template<> -MDistance convert( const float &from ) -{ - return MDistance( from, MDistance::kCentimeters ); -} - -template<> -float convert( const MDistance &from ) -{ - return from.asCentimeters(); -} - -template<> -MAngle convert( const float &from ) -{ - return MAngle( from, MAngle::kRadians ); -} - -template<> -float convert( const MAngle &from ) -{ - return from.asRadians(); -} - -template<> -MTime convert( const float &from ) -{ - return MTime( from, MTime::kSeconds ); -} - -template<> -float convert( const MTime &from ) -{ - return from.as( MTime::kSeconds ); -} - -} // namespace IECore diff --git a/src/IECoreMaya/ConverterHolder.cpp b/src/IECoreMaya/ConverterHolder.cpp deleted file mode 100644 index 038ec66925..0000000000 --- a/src/IECoreMaya/ConverterHolder.cpp +++ /dev/null @@ -1,106 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ConverterHolder.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/MayaTypeIds.h" - -#include "IECore/Object.h" - -#include "maya/MFnMessageAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnStringData.h" - -using namespace IECoreMaya; - -MTypeId ConverterHolder::id = ConverterHolderId; -MObject ConverterHolder::aIn; -MObject ConverterHolder::aFileName; - -ConverterHolder::ConverterHolder() -{ -} - -ConverterHolder::~ConverterHolder() -{ -} - -void *ConverterHolder::creator() -{ - return new ConverterHolder; -} - -MStatus ConverterHolder::initialize() -{ - MStatus s = inheritAttributesFrom( ParameterisedHolderNode::typeName ); - if( !s ) - { - return s; - } - - MFnMessageAttribute fnMAttr; - aIn = fnMAttr.create( "input", "in", &s ); - assert( s ); - s = addAttribute( aIn ); - assert( s ); - - MFnTypedAttribute fnTAttr; - MFnStringData fnSData; - aFileName = fnTAttr.create( "fileName", "fn", MFnData::kString, fnSData.create( "" ) , &s ); - assert( s ); - s = addAttribute( aFileName ); - assert( s ); - - return MS::kSuccess; -} - -MStatus ConverterHolder::connectionMade( const MPlug &plug, const MPlug &otherPlug, bool asSrc ) -{ - if( plug==aIn ) - { - MObject otherNode = otherPlug.node(); - FromMayaConverterPtr converter = FromMayaObjectConverter::create( otherNode ); - setParameterised( converter ); - } - return MS::kSuccess; -} - -MStatus ConverterHolder::connectionBroken( const MPlug &plug, const MPlug &otherPlug, bool asSrc ) -{ - if( plug==aIn ) - { - setParameterised( 0 ); - } - return MS::kSuccess; -} diff --git a/src/IECoreMaya/CurveCombiner.cpp b/src/IECoreMaya/CurveCombiner.cpp deleted file mode 100644 index 23e978c6c5..0000000000 --- a/src/IECoreMaya/CurveCombiner.cpp +++ /dev/null @@ -1,147 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnPluginData.h" - -#include "IECoreScene/CurvesMergeOp.h" - -#include "IECoreMaya/CurveCombiner.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/ObjectData.h" -#include "IECoreMaya/FromMayaCurveConverter.h" - -using namespace IECoreMaya; - -const MTypeId CurveCombiner::id = CurveCombinerId; -const MString CurveCombiner::typeName = "ieCurveCombiner"; -MObject CurveCombiner::aInputCurves; -MObject CurveCombiner::aOutputCurves; - -CurveCombiner::CurveCombiner() -{ -} - -CurveCombiner::~CurveCombiner() -{ -} - -void *CurveCombiner::creator() -{ - return new CurveCombiner; -} - -MStatus CurveCombiner::initialize() -{ - - MFnTypedAttribute fnTAttr; - - aInputCurves = fnTAttr.create( "inputCurves", "ic", MFnData::kNurbsCurve ); - fnTAttr.setReadable( false ); - fnTAttr.setWritable( true ); - fnTAttr.setStorable( true ); - fnTAttr.setConnectable( true ); - fnTAttr.setHidden( false ); - fnTAttr.setArray( true ); - fnTAttr.setIndexMatters( false ); - - addAttribute( aInputCurves ); - - aOutputCurves = fnTAttr.create( "outputCurves", "oc", IECoreMaya::ObjectData::id ); - fnTAttr.setReadable( true ); - fnTAttr.setWritable( false ); - fnTAttr.setStorable( true ); - fnTAttr.setConnectable( true ); - fnTAttr.setHidden( false ); - - addAttribute( aOutputCurves ); - - attributeAffects( aInputCurves, aOutputCurves ); - - return MS::kSuccess; -} - -MStatus CurveCombiner::compute( const MPlug &plug, MDataBlock &dataBlock ) -{ - - if( plug==aOutputCurves ) - { - - MArrayDataHandle arrayHandle = dataBlock.inputArrayValue( aInputCurves ); - IECoreScene::CurvesPrimitivePtr combinedCurves = 0; - - IECoreScene::CurvesMergeOpPtr curvesMergeOp = new IECoreScene::CurvesMergeOp(); - curvesMergeOp->copyParameter()->setTypedValue( false ); - - unsigned numCurves = arrayHandle.elementCount(); - for( unsigned curveIndex = 0; curveIndex < numCurves; curveIndex++, arrayHandle.next() ) - { - MObject curve = arrayHandle.inputValue().asNurbsCurve(); - FromMayaCurveConverterPtr converter = new FromMayaCurveConverter( curve ); - // we want worldspace points if a worldShape is connected, and local otherwise - converter->spaceParameter()->setNumericValue( FromMayaShapeConverter::World ); - IECoreScene::CurvesPrimitivePtr cortexCurve = boost::static_pointer_cast( converter->convert() ); - - if( !combinedCurves ) - { - combinedCurves = cortexCurve; - curvesMergeOp->inputParameter()->setValue( combinedCurves ); - } - else - { - curvesMergeOp->curvesParameter()->setValue( cortexCurve ); - curvesMergeOp->operate(); - } - } - - if( !combinedCurves ) - { - combinedCurves = new IECoreScene::CurvesPrimitive(); - } - - MFnPluginData fnD; - MObject data = fnD.create( IECoreMaya::ObjectData::id ); - IECoreMaya::ObjectData *objectData = dynamic_cast( fnD.data() ); - objectData->setObject( combinedCurves ); - - dataBlock.outputValue( aOutputCurves ).set( objectData ); - dataBlock.setClean( aOutputCurves ); - - return MS::kSuccess; - - } - - return MS::kUnknownParameter; -} - diff --git a/src/IECoreMaya/DateTimeParameterHandler.cpp b/src/IECoreMaya/DateTimeParameterHandler.cpp deleted file mode 100644 index 52e0f6b8e9..0000000000 --- a/src/IECoreMaya/DateTimeParameterHandler.cpp +++ /dev/null @@ -1,136 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/DateTimeParameterHandler.h" -#include "IECoreMaya/MayaTypeIds.h" - -#include "IECore/DateTimeParameter.h" - -#include "maya/MFnTypedAttribute.h" -#include "maya/MPlug.h" - -#include "boost/date_time/posix_time/posix_time.hpp" - -using namespace IECoreMaya; - -static ParameterHandler::Description< DateTimeParameterHandler > registrar( IECore::DateTimeParameter::staticTypeId() ); - -MStatus DateTimeParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstDateTimeParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - - // we'd like to be setting the default value here, but as maya doesn't save the default value - // for dynamic string attributes in scene files, it'll be lost when the scene is reloaded. it's - // best therefore that we don't set the default at all, so that the default is "", which is what - // it'll be when we reload the scene - this ensures that any values set in the attribute later - // will be saved correctly (if we set the default to "X" and the value was "X", maya won't save the - // default or the value at all, and we end up with a value of "" on scene reload). - - MFnTypedAttribute fnTAttr( attribute ); - if( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kString ) - { - return MS::kFailure; - } - - // Should this fail if getPlugValue fails? - MString v = ""; - if( plug.getValue( v ) ) - { - try - { - boost::posix_time::from_iso_string( v.asChar() ); - } - catch ( boost::bad_lexical_cast &e ) - { - return MS::kFailure; - } - } - - return finishUpdating( parameter, plug ); -} - -MPlug DateTimeParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstDateTimeParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MObject attribute; - MFnTypedAttribute fnTAttr; - attribute = fnTAttr.create( plugName, plugName, MFnData::kString /* see comments in stringUpdate for why we don't specify a default here */ ); - - MPlug result = finishCreating( parameter, attribute, node ); - if( finishUpdating( parameter, result ) ) - { - return result; - } - - return MPlug(); -} - -MStatus DateTimeParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstDateTimeParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - return plug.setValue( boost::posix_time::to_iso_string( p->getTypedValue() ).c_str() ); -} - -MStatus DateTimeParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - IECore::DateTimeParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MString v = ""; - MStatus result = plug.getValue( v ); - if( result ) - { - p->setTypedValue( boost::posix_time::from_iso_string( v.asChar() ) ); - } - return result; -} diff --git a/src/IECoreMaya/DisplayStyle.cpp b/src/IECoreMaya/DisplayStyle.cpp deleted file mode 100644 index 54d5506d6c..0000000000 --- a/src/IECoreMaya/DisplayStyle.cpp +++ /dev/null @@ -1,134 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreGL/TypedStateComponent.h" -#include "IECoreGL/Primitive.h" -#include "IECoreGL/ShaderLoader.h" -#include "IECoreGL/ShaderStateComponent.h" -#include "IECoreGL/TextureLoader.h" - -#include "IECoreMaya/DisplayStyle.h" - -using namespace IECoreMaya; - -struct DisplayStyle::Data -{ - IECoreGL::StatePtr wireframeState; - IECoreGL::StatePtr shadedState; - IECoreGL::StatePtr pointsState; - IECoreGL::StatePtr boundsState; - IECoreGL::StatePtr litState; -}; - -DisplayStyle::DisplayStyle() -{ - m_data = new Data; - m_data->wireframeState = new IECoreGL::State( true ); - m_data->shadedState = new IECoreGL::State( true ); - m_data->pointsState = new IECoreGL::State( true ); - m_data->boundsState = new IECoreGL::State( true ); - m_data->litState = new IECoreGL::State( true ); - - m_data->wireframeState->add( new IECoreGL::Primitive::DrawSolid( false ) ); - m_data->wireframeState->add( new IECoreGL::Primitive::DrawWireframe( true ) ); - - m_data->pointsState->add( new IECoreGL::Primitive::DrawSolid( false ) ); - m_data->pointsState->add( new IECoreGL::Primitive::DrawPoints( true ) ); - m_data->pointsState->add( new IECoreGL::Primitive::PointWidth( 2.0f ) ); - - m_data->boundsState->add( new IECoreGL::Primitive::DrawSolid( false ) ); - m_data->boundsState->add( new IECoreGL::Primitive::DrawBound( true ) ); - - m_data->litState->add( - new IECoreGL::ShaderStateComponent( - IECoreGL::ShaderLoader::defaultShaderLoader(), - IECoreGL::TextureLoader::defaultTextureLoader(), - IECoreGL::Shader::defaultVertexSource(), - IECoreGL::Shader::defaultGeometrySource(), - IECoreGL::Shader::lambertFragmentSource(), - new IECore::CompoundObject() - ), - /// \todo: by setting true here, we are forcing an override of all other - /// ShaderStateComponents in the hierarchy. Is this desirable in all cases? - true - ); -} - -DisplayStyle::~DisplayStyle() -{ - delete m_data; -} - -IECoreGL::State *DisplayStyle::baseState( M3dView::DisplayStyle style, M3dView::LightingMode lightingMode, bool transferCurrentColor ) -{ - switch( style ) - { - - case M3dView::kBoundingBox : - if( transferCurrentColor ) - { - Imath::Color4f wc; glGetFloatv( GL_CURRENT_COLOR, wc.getValue() ); - m_data->boundsState->add( new IECoreGL::BoundColorStateComponent( wc ) ); - } - return m_data->boundsState.get(); - - case M3dView::kFlatShaded : - case M3dView::kGouraudShaded : - if ( lightingMode != M3dView::kLightDefault ) - { - return m_data->litState.get(); - } - return m_data->shadedState.get(); - - case M3dView::kWireFrame : - if( transferCurrentColor ) - { - Imath::Color4f wc; glGetFloatv( GL_CURRENT_COLOR, wc.getValue() ); - m_data->wireframeState->add( new IECoreGL::WireframeColorStateComponent( wc ) ); - } - return m_data->wireframeState.get(); - - case M3dView::kPoints : - if( transferCurrentColor ) - { - Imath::Color4f wc; glGetFloatv( GL_CURRENT_COLOR, wc.getValue() ); - m_data->pointsState->add( new IECoreGL::PointColorStateComponent( wc ) ); - } - return m_data->pointsState.get(); - - default : - return m_data->shadedState.get(); - - } -} diff --git a/src/IECoreMaya/DrawableHolder.cpp b/src/IECoreMaya/DrawableHolder.cpp deleted file mode 100644 index 25213833d7..0000000000 --- a/src/IECoreMaya/DrawableHolder.cpp +++ /dev/null @@ -1,177 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECore/SimpleTypedData.h" -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECoreGL/Scene.h" -#include "IECoreGL/Renderer.h" -#include "IECoreGL/Camera.h" - -#include "IECoreMaya/DrawableHolder.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/Convert.h" - -#include "maya/MGlobal.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnNumericData.h" - -using namespace IECoreMaya; - -const MTypeId DrawableHolder::id = DrawableHolderId; -const MString DrawableHolder::typeName = "ieDrawable"; - -MObject DrawableHolder::aDraw; - -DrawableHolder::DrawableHolder() - : m_scene( 0 ) -{ -} - -DrawableHolder::~DrawableHolder() -{ -} - -void *DrawableHolder::creator() -{ - return new DrawableHolder; -} - -MStatus DrawableHolder::initialize() -{ - MStatus s = inheritAttributesFrom( ParameterisedHolderSurfaceShape::typeName ); - if( !s ) - { - MGlobal::displayError( "DrawableHolder::initialize(): " + s.errorString() ); - } - - MFnNumericAttribute nAttr; - - aDraw = nAttr.create( "draw", "draw", MFnNumericData::kBoolean, 1, &s ); - assert( s ); - nAttr.setReadable( true ); - nAttr.setWritable( true ); - nAttr.setStorable( true ); - nAttr.setConnectable( true ); - nAttr.setHidden( false ); - - s = addAttribute( aDraw ); - assert( s ); - - return s; -} - -bool DrawableHolder::isBounded() const -{ - return true; -} - -MBoundingBox DrawableHolder::boundingBox() const -{ - IECoreGL::ConstScenePtr s = ((DrawableHolder *)this)->scene(); - if( s ) - { - Imath::Box3f b = s->bound(); - return IECore::convert( b ); - } - return MBoundingBox(); -} - -MStatus DrawableHolder::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - if( std::string( plug.partialName().substring( 0, 4 ).asChar() ) == ParameterisedHolderSurfaceShape::g_attributeNamePrefix ) - { - m_scene = 0; - } - return ParameterisedHolderSurfaceShape::setDependentsDirty( plug, plugArray ); -} - -IECoreGL::ConstScenePtr DrawableHolder::scene() -{ - if( m_scene ) - { - return m_scene; - } - - m_scene = 0; - IECore::RunTimeTypedPtr drawable = getParameterised(); - IECore::ParameterisedInterface *drawableInterface = dynamic_cast( drawable.get() ); - if( drawableInterface ) - { - setParameterisedValues(); - try - { - IECoreGL::RendererPtr renderer = new IECoreGL::Renderer; - renderer->setOption( "gl:mode", new IECore::StringData( "deferred" ) ); - renderer->worldBegin(); - - { - IECorePython::ScopedGILLock gilLock; - boost::python::object pythonDrawable( drawable ); - pythonDrawable.attr( "draw" )( renderer ); - } - - renderer->worldEnd(); - - m_scene = renderer->scene(); - m_scene->setCamera( 0 ); - - } - catch( boost::python::error_already_set &e ) - { - IECorePython::ScopedGILLock gilLock; - PyErr_Print(); - } - catch( IECore::Exception &e ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::scene", e.what() ); - } - catch( std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::scene", e.what() ); - } - catch( ... ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::scene", "Exception thrown in MapGenerator::draw" ); - } - } - - return m_scene; - -} diff --git a/src/IECoreMaya/DrawableHolderUI.cpp b/src/IECoreMaya/DrawableHolderUI.cpp deleted file mode 100644 index 7fa6caf3bc..0000000000 --- a/src/IECoreMaya/DrawableHolderUI.cpp +++ /dev/null @@ -1,305 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "IECoreGL/GL.h" // must come first so glew.h is included before gl.h - -#include "maya/MDrawData.h" -#include "maya/MDagPath.h" -#include "maya/MSelectionList.h" -#include "maya/MSelectionMask.h" -#include "maya/MIntArray.h" -#include "maya/MPointArray.h" -#include "maya/MFnCamera.h" -#include "maya/MMatrix.h" - -#include "IECore/MessageHandler.h" - -#include "IECoreGL/Scene.h" -#include "IECoreGL/State.h" - -#include "IECoreMaya/DrawableHolderUI.h" -#include "IECoreMaya/DrawableHolder.h" - -using namespace IECoreMaya; -using namespace std; - -DrawableHolderUI::DrawableHolderUI() -{ - IECoreGL::init( true ); -} - -DrawableHolderUI::~DrawableHolderUI() -{ -} - -void *DrawableHolderUI::creator() -{ - return new DrawableHolderUI; -} - -void DrawableHolderUI::getDrawRequests( const MDrawInfo &info, bool objectAndActiveOnly, MDrawRequestQueue &requests ) -{ - // it's easy if noone want to look at us - if( !info.objectDisplayStatus( M3dView::kDisplayLocators ) ) - { - return; - } - - // the node we're meant to be drawing - DrawableHolder *drawableHolder = dynamic_cast( surfaceShape() ); - if( !drawableHolder ) - { - return; - } - - // do we actually want to draw it? - MPlug pDraw( drawableHolder->thisMObject(), DrawableHolder::aDraw ); - bool draw = true; - pDraw.getValue( draw ); - - if( !draw ) - { - return; - } - - // draw data encapsulating that node - MDrawData drawData; - getDrawData( drawableHolder, drawData ); - - MDrawRequest request = info.getPrototype( *this ); - request.setDrawData( drawData ); - - // set correct drawing colour: - switch( info.displayStatus() ) - { - case M3dView::kLead : - request.setColor( 18, M3dView::kActiveColors ); - break; - case M3dView::kActive : - request.setColor( 15, M3dView::kActiveColors ); - break; - case M3dView::kActiveAffected : - request.setColor( 8, M3dView::kActiveColors ); - break; - case M3dView::kHilite : - request.setColor( 17, M3dView::kActiveColors ); - break; - case M3dView::kTemplate : - request.setColor( 2, M3dView::kDormantColors ); - break; - case M3dView::kActiveTemplate : - request.setColor( 19, M3dView::kActiveColors ); - break; - default : - // dormant - request.setColor( 4, M3dView::kDormantColors ); - break; - } - - requests.add( request ); -} - -void DrawableHolderUI::draw( const MDrawRequest &request, M3dView &view ) const -{ - MDrawData drawData = request.drawData(); - DrawableHolder *drawableHolder = (DrawableHolder *)drawData.geometry(); - assert( drawableHolder ); - - IECoreGL::ConstScenePtr s = drawableHolder->scene(); - if( !s ) - { - return; - } - - view.beginGL(); - - // maya can sometimes leave an error from it's own code, - // and we don't want that to confuse us in our drawing code. - while( glGetError()!=GL_NO_ERROR ) - { - } - - // if we're being drawn as part of a selection operation we need - // to make sure there's a name on the name stack, as the IECoreGL::NameStateComponent - // expects to be able to load a name into it (it fails with an invalid operation if - // there's no name slot to load into). - if( view.selectMode() ) - { - view.pushName( 0 ); - } - - try - { - // do the main render - s->render( m_displayStyle.baseState( request.displayStyle() ) ); - - // do a wireframe render over the top if we're selected and we just did a solid - // draw. - bool selected = request.displayStatus()==M3dView::kActive || request.displayStatus()==M3dView::kLead; - bool solid = request.displayStyle()==M3dView::kFlatShaded || request.displayStyle()==M3dView::kGouraudShaded; - if( selected && solid ) - { - s->render( m_displayStyle.baseState( M3dView::kWireFrame ) ); - } - } - catch( std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolderUI::draw", e.what() ); - } - - view.endGL(); -} - -bool DrawableHolderUI::select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const -{ - MStatus s; - - // early out if we're not selectable. we always allow components to be selected if we're highlighted, - // but we don't allow ourselves to be selected as a whole unless meshes are in the selection mask. - // it's not ideal that we act like a mesh, but it's at least consistent with the drawing mask we use. - if( selectInfo.displayStatus() != M3dView::kHilite ) - { - MSelectionMask meshMask( MSelectionMask::kSelectMeshes ); - if( !selectInfo.selectable( meshMask ) ) - { - return false; - } - } - - // early out if we have no scene to draw - DrawableHolder *drawableHolder = static_cast( surfaceShape() ); - IECoreGL::ConstScenePtr scene = drawableHolder->scene(); - if( !scene ) - { - return false; - } - - // we want to perform the selection using an IECoreGL::Selector, so we - // can avoid the performance penalty associated with using GL_SELECT mode. - // that means we don't really want to call view.beginSelect(), but we have to - // call it just to get the projection matrix for our own selection, because as far - // as i can tell, there is no other way of getting it reliably. - - M3dView view = selectInfo.view(); - view.beginSelect(); - Imath::M44d projectionMatrix; - glGetDoublev( GL_PROJECTION_MATRIX, projectionMatrix.getValue() ); - view.endSelect(); - - view.beginGL(); - - glMatrixMode( GL_PROJECTION ); - glLoadMatrixd( projectionMatrix.getValue() ); - - IECoreGL::Selector::Mode selectionMode = IECoreGL::Selector::IDRender; - if( selectInfo.displayStatus() == M3dView::kHilite && !selectInfo.singleSelection() ) - { - selectionMode = IECoreGL::Selector::OcclusionQuery; - } - - std::vector hits; - { - IECoreGL::Selector selector( Imath::Box2f( Imath::V2f( 0 ), Imath::V2f( 1 ) ), selectionMode, hits ); - - IECoreGL::State::bindBaseState(); - selector.baseState()->bind(); - scene->render( selector.baseState() ); - } - - view.endGL(); - - if( !hits.size() ) - { - return false; - } - - // find the depth of the closest hit: - MIntArray componentIndices; - float depthMin = std::numeric_limits::max(); - for( int i=0, e = hits.size(); i < e; i++ ) - { - if( hits[i].depthMin < depthMin ) - { - depthMin = hits[i].depthMin; - } - } - - - // figure out the world space location of the closest hit - - MDagPath camera; - view.getCamera( camera ); - MFnCamera fnCamera( camera.node() ); - float near = fnCamera.nearClippingPlane(); - float far = fnCamera.farClippingPlane(); - - float z = -1; - if( fnCamera.isOrtho() ) - { - z = Imath::lerp( near, far, depthMin ); - } - else - { - // perspective camera - depth isn't linear so linearise to get z - float a = far / ( far - near ); - float b = far * near / ( near - far ); - z = b / ( depthMin - a ); - } - - MPoint localRayOrigin; - MVector localRayDirection; - selectInfo.getLocalRay( localRayOrigin, localRayDirection ); - MMatrix localToCamera = selectInfo.selectPath().inclusiveMatrix() * camera.inclusiveMatrix().inverse(); - MPoint cameraRayOrigin = localRayOrigin * localToCamera; - MVector cameraRayDirection = localRayDirection * localToCamera; - - MPoint cameraIntersectionPoint = cameraRayOrigin + cameraRayDirection * ( -( z - near ) / cameraRayDirection.z ); - MPoint worldIntersectionPoint = cameraIntersectionPoint * camera.inclusiveMatrix(); - - MSelectionList item; - item.add( selectInfo.selectPath() ); - - selectInfo.addSelection( - item, worldIntersectionPoint, - selectionList, worldSpaceSelectPts, - MSelectionMask::kSelectMeshes, - false - ); - - return true; -} - diff --git a/src/IECoreMaya/FloatSplineParameterHandler.cpp b/src/IECoreMaya/FloatSplineParameterHandler.cpp deleted file mode 100644 index b8f582dfb3..0000000000 --- a/src/IECoreMaya/FloatSplineParameterHandler.cpp +++ /dev/null @@ -1,312 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/FloatSplineParameterHandler.h" -#include "IECoreMaya/MArrayIter.h" - -#include "IECore/SplineParameter.h" - -#include "maya/MFnCompoundAttribute.h" -#include "maya/MRampAttribute.h" -#include "maya/MFloatArray.h" -#include "maya/MIntArray.h" -#include "maya/MGlobal.h" -#include "maya/MFnDagNode.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -template<> ParameterHandler::Description< FloatSplineParameterHandler< IECore::Splineff > > - FloatSplineParameterHandler< IECore::Splineff >::g_registrar( IECore::SplineffParameter::staticTypeId() ); - -template<> ParameterHandler::Description< FloatSplineParameterHandler< IECore::Splinedd > > - FloatSplineParameterHandler< IECore::Splinedd >::g_registrar( IECore::SplineddParameter::staticTypeId() ); - -template -MStatus FloatSplineParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - MRampAttribute fnRAttr( plug ); - if( !fnRAttr.isCurveRamp() ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -template -MPlug FloatSplineParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MPlug(); - } - - MRampAttribute fnRAttr; - MObject attribute = fnRAttr.createCurveRamp( plugName, plugName ); - - MPlug result = finishCreating( parameter, attribute, node ); - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); - } - - return result; -} - -template -MStatus FloatSplineParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - assert( parameter ); - typename IECore::TypedParameter< S >::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MRampAttribute fnRAttr( plug ); - if ( !fnRAttr.isCurveRamp() ) - { - return MS::kFailure; - } - - const S &spline = p->getTypedValue(); - - MStatus s; - MIntArray indicesToReuse; - plug.getExistingArrayAttributeIndices( indicesToReuse, &s ); - assert( s ); - - int nextNewLogicalIndex = 0; - if( indicesToReuse.length() ) - { - nextNewLogicalIndex = 1 + *std::max_element( MArrayIter::begin( indicesToReuse ), MArrayIter::end( indicesToReuse ) ); - } - - assert( indicesToReuse.length() == fnRAttr.getNumEntries() ); - - size_t pointsSizeMinus2 = spline.points.size() - 2; - unsigned pointIndex = 0; - unsigned numExpectedPoints = 0; - for ( typename S::PointContainer::const_iterator it = spline.points.begin(); it != spline.points.end(); ++it, ++pointIndex ) - { - // we commonly double up the endpoints on cortex splines to force interpolation to the end. - // maya does this implicitly, so we skip duplicated endpoints when passing the splines into maya. - // this avoids users having to be responsible for managing the duplicates, and gives them some consistency - // with the splines they edit elsewhere in maya. - if( ( pointIndex==1 && *it == *spline.points.begin() ) || ( pointIndex==pointsSizeMinus2 && *it == *spline.points.rbegin() ) ) - { - continue; - } - - MPlug pointPlug; - if( indicesToReuse.length() ) - { - pointPlug = plug.elementByLogicalIndex( indicesToReuse[0] ); - indicesToReuse.remove( 0 ); - } - else - { - // this creates us a new spline point for us, and avoids the bug in MRampAttribute::addEntries which - // somehow manages to create duplicate logical indexes. - pointPlug = plug.elementByLogicalIndex( nextNewLogicalIndex++ ); - } - - s = pointPlug.child( 0 ).setValue( it->first ); assert( s ); - s = pointPlug.child( 1 ).setValue( it->second ); assert( s ); - // hardcoding interpolation of 3 (spline) because the MRampAttribute::MInterpolation enum values don't actually - // correspond to the necessary plug values at all. - s = pointPlug.child( 2 ).setValue( 3 ); assert( s ); - - numExpectedPoints++; - } - - // delete any of the original indices which we didn't reuse. we can't use MRampAttrubute::deleteEntries - // here as it's utterly unreliable. - if( indicesToReuse.length() ) - { - MString plugName = plug.name(); - MObject node = plug.node(); - MFnDagNode fnDAGN( node ); - if( fnDAGN.hasObj( node ) ) - { - plugName = fnDAGN.fullPathName() + "." + plug.partialName(); - } - for( unsigned i=0; i uniqueIndices; - std::copy( - MArrayIter::begin( allLogicalIndices ), - MArrayIter::end( allLogicalIndices ), - std::insert_iterator >( uniqueIndices, uniqueIndices.begin() ) - ); - assert( uniqueIndices.size()==allLogicalIndices.length() ); - - // then check that every element of the ramp has a suitable equivalent in - // the original spline - MIntArray indices; - MFloatArray positions; - MFloatArray values; - MIntArray interps; - fnRAttr.getEntries( indices, positions, values, interps, &s ); - assert( s ); - assert( numExpectedPoints == positions.length() ); - assert( numExpectedPoints == values.length() ); - assert( numExpectedPoints == interps.length() ); - assert( numExpectedPoints == indices.length() ); - - for ( unsigned i = 0; i < positions.length(); i++ ) - { - float position = positions[ i ]; - float value = values[ i ]; - - bool found = false; - - for ( typename S::PointContainer::const_iterator it = spline.points.begin(); it != spline.points.end() && !found; ++it ) - { - if ( fabs( it->first - position ) < 1.e-3f && fabs( it->second - value ) < 1.e-3f ) - { - found = true; - } - } - assert( found ); - } - } -#endif - - return MS::kSuccess; -} - -template -MStatus FloatSplineParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - assert( parameter ); - - typename IECore::TypedParameter< S >::Ptr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - S spline; - - MStatus s; - MRampAttribute fnRAttr( plug, &s ); - assert( s ); - - if ( !fnRAttr.isCurveRamp() ) - { - return MS::kFailure; - } - - MIntArray indices; - (const_cast( plug )).getExistingArrayAttributeIndices( indices, &s ); - - for( unsigned i = 0; i < indices.length(); i++ ) - { - MPlug pointPlug = plug.elementByLogicalIndex( indices[i] ); - spline.points.insert( - typename S::PointContainer::value_type( pointPlug.child( 0 ).asDouble(), pointPlug.child( 1 ).asDouble() ) - ); - } - - // maya seems to do an implicit doubling up of the end points to cause interpolation to the ends. - // our spline has no such implicit behaviour so we explicitly double up. - if( spline.points.size() ) - { -#ifndef NDEBUG - size_t oldSplineSize = spline.points.size(); -#endif - - assert( spline.points.begin()->first <= spline.points.rbegin()->first ); - spline.points.insert( *spline.points.begin() ); - spline.points.insert( *spline.points.rbegin() ); - assert( spline.points.size() == oldSplineSize + 2 ); - } - - p->setTypedValue( spline ); - - if( spline.points.size() ) - { - assert( spline.points.size() >= 2 ); - assert( spline.points.size() == fnRAttr.getNumEntries() + 2 ); - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/FromMayaArrayDataConverter.cpp b/src/IECoreMaya/FromMayaArrayDataConverter.cpp deleted file mode 100644 index 12154e76d0..0000000000 --- a/src/IECoreMaya/FromMayaArrayDataConverter.cpp +++ /dev/null @@ -1,136 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaArrayDataConverter.h" -#include "IECoreMaya/MArrayTraits.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/VectorTypedData.h" - -#include "IECore/GeometricTypedData.h" - -using namespace IECore; - -namespace IECoreMaya -{ - -namespace -{ - -template -struct SetInterpolation -{ - static void set( T* resultData ){} -}; - -template -struct SetInterpolation > -{ - static void set( IECore::GeometricTypedData *resultData ) - { - resultData->setInterpretation( IECore::GeometricData::Point ); - } -}; - -template -struct SetInterpolation > -{ - static void set( IECore::GeometricTypedData *resultData ) - { - resultData->setInterpretation( IECore::GeometricData::Vector ); - } -}; - -} - -template -FromMayaArrayDataConverter::FromMayaArrayDataConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts maya array data types to IECore::TypedVectorData types.", object ) -{ -} - -template -IECore::ObjectPtr FromMayaArrayDataConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - typename MArrayTraits::DataFn fnArrayData( object ); - if( !fnArrayData.hasObj( object ) ) - { - return 0; - } - - F array = fnArrayData.array(); - typename T::Ptr resultData = new T; - typename T::ValueType &resultArray = resultData->writable(); - - resultArray.resize( array.length() ); - for( unsigned int i=0; i::ValueType>( array[i] ); - } - - SetInterpolation::set( resultData.get() ); - - return resultData; -} - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterii, FromMayaArrayDataConverteriiTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterib, FromMayaArrayDataConverteribTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterdd, FromMayaArrayDataConverterddTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterdf, FromMayaArrayDataConverterdfTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterss, FromMayaArrayDataConverterssTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterVV3f, FromMayaArrayDataConverterVV3fTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterVV3d, FromMayaArrayDataConverterVV3dTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterPV3f, FromMayaArrayDataConverterPV3fTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterPV3d, FromMayaArrayDataConverterPV3dTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaArrayDataConverterVC3f, FromMayaArrayDataConverterVC3fTypeId ) - -// Registrations and instantiations - -#define REGISTER_AND_INSTANTIATE( F, T, DEFAULT ) \ - template<> \ - FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaArrayDataConverter::m_description( MArrayTraits::dataType(), T::staticTypeId(), DEFAULT ); \ - template class FromMayaArrayDataConverter; - -REGISTER_AND_INSTANTIATE( MIntArray, IntVectorData, true ) -REGISTER_AND_INSTANTIATE( MIntArray, BoolVectorData, false ) -REGISTER_AND_INSTANTIATE( MDoubleArray, DoubleVectorData, true ) -REGISTER_AND_INSTANTIATE( MDoubleArray, FloatVectorData, false ) -REGISTER_AND_INSTANTIATE( MStringArray, StringVectorData, true ) -REGISTER_AND_INSTANTIATE( MVectorArray, V3fVectorData, false ) -REGISTER_AND_INSTANTIATE( MVectorArray, V3dVectorData, true ) -REGISTER_AND_INSTANTIATE( MVectorArray, Color3fVectorData, false ); -REGISTER_AND_INSTANTIATE( MPointArray, V3fVectorData, false ) -REGISTER_AND_INSTANTIATE( MPointArray, V3dVectorData, true ) - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/FromMayaCameraConverter.cpp b/src/IECoreMaya/FromMayaCameraConverter.cpp deleted file mode 100644 index a8655774e2..0000000000 --- a/src/IECoreMaya/FromMayaCameraConverter.cpp +++ /dev/null @@ -1,179 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaCameraConverter.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/AngleConversion.h" -#include "IECoreScene/Camera.h" -#include "IECoreScene/MatrixTransform.h" - -#include "maya/MFnCamera.h" -#include "maya/MFnEnumAttribute.h" -#include "maya/MString.h" -#include "maya/MRenderUtil.h" -#include "maya/MCommonRenderSettingsData.h" -#include "maya/MDagPath.h" -#include "maya/MPlug.h" - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace Imath; - -namespace { - -// It's awesome that not only does Maya bake this random mm-to-inch conversion into their -// camera, but they use the pre 1959 definition of the inch -const float INCH_TO_MM = 25.400051; - -} - -IE_CORE_DEFINERUNTIMETYPED( FromMayaCameraConverter ); - -FromMayaDagNodeConverter::Description FromMayaCameraConverter::m_description( MFn::kCamera, Camera::staticTypeId(), true ); - -FromMayaCameraConverter::FromMayaCameraConverter( const MDagPath &dagPath ) - : FromMayaDagNodeConverter( "Converts maya camera shape nodes into IECoreScene::Camera objects.", dagPath ) -{ -} - -IECore::ObjectPtr FromMayaCameraConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnCamera fnCamera( dagPath ); - - // convert things that are required by the IECore::Renderer specification - - CameraPtr result = new Camera; - - if( fnCamera.hasAttribute( "ieCamera_overrideResolution" ) ) - { - MStatus success1, success2; - MPlug resPlug( fnCamera.object(), fnCamera.attribute( "ieCamera_overrideResolution" )); - if( resPlug.numChildren() == 2 ) - { -#if MAYA_API_VERSION >= 20180000 - int x = resPlug.child(0).asInt( &success1 ); - int y = resPlug.child(1).asInt( &success2 ); -#else - int x = resPlug.child(0).asInt( MDGContext::fsNormal, &success1 ); - int y = resPlug.child(1).asInt( MDGContext::fsNormal, &success2 ); -#endif - if( success1 == MS::kSuccess && success2 == MS::kSuccess ) - { - result->setResolution( Imath::V2i( x, y ) ); - } - } - } - - if( fnCamera.hasAttribute( "ieCamera_overridePixelAspectRatio" ) ) - { - MStatus success; - MPlug overridePixelAspectRatioPlug( fnCamera.object(), fnCamera.attribute( "ieCamera_overridePixelAspectRatio" ) ); -#if MAYA_API_VERSION >= 20180000 - float overridePixelAspectRatio = overridePixelAspectRatioPlug.asFloat( &success ); -#else - float overridePixelAspectRatio = overridePixelAspectRatioPlug.asFloat( MDGContext::fsNormal, &success ); -#endif - - if( success == MS::kSuccess ) - { - result->setPixelAspectRatio( overridePixelAspectRatio ); - } - } - - if( fnCamera.hasAttribute( "ieCamera_overrideFilmFit" ) ) - { - MStatus success; - MPlug overrideFilmFitPlug( fnCamera.object(), fnCamera.attribute( "ieCamera_overrideFilmFit" ) ); - MFnEnumAttribute enumAttr( overrideFilmFitPlug.attribute(), &success ); - if( success == MS::kSuccess ) - { -#if MAYA_API_VERSION >= 20180000 - MString overrideFilmFit = enumAttr.fieldName( overrideFilmFitPlug.asInt( &success) ); -#else - MString overrideFilmFit = enumAttr.fieldName( overrideFilmFitPlug.asInt( MDGContext::fsNormal, &success) ); -#endif - if( success == MS::kSuccess ) - { - if( overrideFilmFit == "Horizontal" ) - { - result->setFilmFit( Camera::FilmFit::Horizontal ); - } - else if( overrideFilmFit == "Vertical" ) - { - result->setFilmFit( Camera::FilmFit::Vertical ); - } - else if( overrideFilmFit == "Fit" ) - { - result->setFilmFit( Camera::FilmFit::Fit ); - } - else if( overrideFilmFit == "Fill" ) - { - result->setFilmFit( Camera::FilmFit::Fill ); - } - else if( overrideFilmFit == "Distort" ) - { - result->setFilmFit( Camera::FilmFit::Distort ); - } - } - } - } - - result->setClippingPlanes( Imath::V2f( fnCamera.nearClippingPlane(), fnCamera.farClippingPlane() ) ); - - if( fnCamera.isOrtho() ) - { - // orthographic - result->setProjection( "orthographic" ); - result->setAperture( V2f( fnCamera.orthoWidth() ) ); - } - else - { - // perspective - result->setProjection( "perspective" ); - - result->setAperture( INCH_TO_MM * V2f( fnCamera.horizontalFilmAperture(), fnCamera.verticalFilmAperture() ) ); - result->setApertureOffset( INCH_TO_MM * V2f( fnCamera.horizontalFilmOffset(), fnCamera.verticalFilmOffset() ) ); - result->setFocalLength( fnCamera.focalLength() ); - } - if( fnCamera.isDepthOfField() ) - { - result->setFStop( fnCamera.fStop() ); - } - result->setFocusDistance( fnCamera.focusDistance() ); - - return result; -} diff --git a/src/IECoreMaya/FromMayaCompoundNumericPlugConverter.cpp b/src/IECoreMaya/FromMayaCompoundNumericPlugConverter.cpp deleted file mode 100644 index 32c1d34972..0000000000 --- a/src/IECoreMaya/FromMayaCompoundNumericPlugConverter.cpp +++ /dev/null @@ -1,109 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaCompoundNumericPlugConverter.h" -#include "IECoreMaya/NumericTraits.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/MessageHandler.h" - -#include "boost/type_traits/is_same.hpp" - -using namespace IECore; -using namespace Imath; -using namespace boost; - -namespace IECoreMaya -{ - -template -FromMayaPlugConverter::Description > FromMayaCompoundNumericPlugConverter::m_description( NumericTraits::dataType(), T::staticTypeId(), is_same::value ); - -template -FromMayaCompoundNumericPlugConverter::FromMayaCompoundNumericPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ -} - -template -IECore::ObjectPtr FromMayaCompoundNumericPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - typename F::BaseType v; - typename T::ValueType vv; - for( unsigned int i=0; i; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; - -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; - -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; - -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; -template class FromMayaCompoundNumericPlugConverter; - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/FromMayaConverter.cpp b/src/IECoreMaya/FromMayaConverter.cpp deleted file mode 100644 index 34e83a2d2f..0000000000 --- a/src/IECoreMaya/FromMayaConverter.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaConverter.h" - -#include "IECore/CompoundParameter.h" - -using namespace IECoreMaya; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaConverter ); - -FromMayaConverter::FromMayaConverter( const std::string &description ) - : ToCoreConverter( description ) -{ -} - -FromMayaConverter::~FromMayaConverter() -{ -} diff --git a/src/IECoreMaya/FromMayaCurveConverter.cpp b/src/IECoreMaya/FromMayaCurveConverter.cpp deleted file mode 100644 index da858f3c41..0000000000 --- a/src/IECoreMaya/FromMayaCurveConverter.cpp +++ /dev/null @@ -1,162 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaCurveConverter.h" -#include "IECoreMaya/MArrayIter.h" -#include "IECoreMaya/VectorTraits.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/VectorOps.h" -#include "IECore/Exception.h" -#include "IECore/CompoundParameter.h" -#include "IECoreScene/CurvesPrimitive.h" - -#include "maya/MFnNurbsCurve.h" - -#include - -using namespace IECoreMaya; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaCurveConverter ); - -IECoreMaya::FromMayaShapeConverter::Description FromMayaCurveConverter::m_description( MFn::kNurbsCurve, IECoreScene::CurvesPrimitive::staticTypeId(), true ); -IECoreMaya::FromMayaShapeConverter::Description FromMayaCurveConverter::m_dataDescription( MFn::kNurbsCurveData, IECoreScene::CurvesPrimitive::staticTypeId(), true ); - -FromMayaCurveConverter::FromMayaCurveConverter( const MObject &object ) - : FromMayaShapeConverter( "Converts maya curve shapes into IECoreScene::CurvesPrimitive objects.", object ) -{ - constructCommon(); -} - -FromMayaCurveConverter::FromMayaCurveConverter( const MDagPath &dagPath ) - : FromMayaShapeConverter( "Converts maya curve shapes into IECoreScene::CurvesPrimitive objects.", dagPath ) -{ - constructCommon(); -} - -void FromMayaCurveConverter::constructCommon() -{ - m_linearParameter = new IECore::BoolParameter( - "linearBasis", - "When this parameter is set to true, all curves are converted with a linear basis." - "When it is false (the default) then cubic curves will be converted with a bSpline" - "basis. In both cases, curves which are not cubic are converted with a linear basis.", - false - ); - parameters()->addParameter( m_linearParameter ); -} - -IECoreScene::PrimitivePtr FromMayaCurveConverter::doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnNurbsCurve fnCurve( object ); - if( !fnCurve.hasObj( object ) ) - { - throw IECore::InvalidArgumentException( "FromMayaCurveConverter::doPrimitiveConversion : not a nurbs curve." ); - } - return doPrimitiveConversion( fnCurve ); -} - -IECoreScene::PrimitivePtr FromMayaCurveConverter::doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnNurbsCurve fnCurve( dagPath ); - if( !fnCurve.hasObj( dagPath.node() ) ) - { - throw IECore::InvalidArgumentException( "FromMayaCurveConverter::doPrimitiveConversion : not a nurbs curve." ); - } - return doPrimitiveConversion( fnCurve ); -} - -IECoreScene::PrimitivePtr FromMayaCurveConverter::doPrimitiveConversion( MFnNurbsCurve &fnCurve ) const -{ - // decide on the basis and periodicity - int mDegree = fnCurve.degree(); - IECore::CubicBasisf basis = IECore::CubicBasisf::linear(); - if( m_linearParameter->getTypedValue()==false && mDegree==3 ) - { - basis = IECore::CubicBasisf::bSpline(); - } - bool periodic = false; - if( fnCurve.form()==MFnNurbsCurve::kPeriodic ) - { - periodic = true; - } - - // get the points and convert them - MPointArray mPoints; - fnCurve.getCVs( mPoints, space() ); - if( periodic ) - { - // maya duplicates the first points at the end, whereas we just wrap around. - // remove the duplicates. - mPoints.setLength( mPoints.length() - mDegree ); - } - - bool duplicateEnds = false; - if( !periodic && mDegree==3 ) - { - // there's an implicit duplication of the end points that we need to make explicit - duplicateEnds = true; - } - - IECore::V3fVectorDataPtr pointsData = new IECore::V3fVectorData; - std::vector &points = pointsData->writable(); - std::vector::iterator transformDst; - if( duplicateEnds ) - { - points.resize( mPoints.length() + 4 ); - transformDst = points.begin(); - *transformDst++ = IECore::convert( mPoints[0] ); - *transformDst++ = IECore::convert( mPoints[0] ); - } - else - { - points.resize( mPoints.length() ); - transformDst = points.begin(); - } - - std::transform( MArrayIter::begin( mPoints ), MArrayIter::end( mPoints ), transformDst, IECore::VecConvert() ); - - if( duplicateEnds ) - { - points[points.size()-1] = IECore::convert( mPoints[mPoints.length()-1] ); - points[points.size()-2] = IECore::convert( mPoints[mPoints.length()-1] ); - } - - // make and return the curve - IECore::IntVectorDataPtr vertsPerCurve = new IECore::IntVectorData; - vertsPerCurve->writable().push_back( points.size() ); - - return new IECoreScene::CurvesPrimitive( vertsPerCurve, basis, periodic, pointsData ); -} diff --git a/src/IECoreMaya/FromMayaDagNodeConverter.cpp b/src/IECoreMaya/FromMayaDagNodeConverter.cpp deleted file mode 100644 index 5703e81d82..0000000000 --- a/src/IECoreMaya/FromMayaDagNodeConverter.cpp +++ /dev/null @@ -1,118 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaDagNodeConverter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/MessageHandler.h" - -#include "maya/MPxNode.h" -#include "maya/MFnDagNode.h" - -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaDagNodeConverter ); - -FromMayaDagNodeConverter::FromMayaDagNodeConverter( const std::string &description, const MDagPath &dagPath ) - : FromMayaObjectConverter( description, dagPath.node() ), m_dagPath( dagPath ) -{ -} - -IECore::ObjectPtr FromMayaDagNodeConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - if( !m_dagPath.isValid() ) - { - return 0; - } - return doConversion( m_dagPath, operands ); -} - -FromMayaDagNodeConverterPtr FromMayaDagNodeConverter::create( const MDagPath &dagPath, IECore::TypeId resultType ) -{ - - MayaType typeId( dagPath.apiType(), 0 ); - - MPxNode* userNode = MFnDagNode( dagPath ).userNode(); - if( userNode ) - { - typeId.first = MFn::kInvalid; - typeId.second = userNode->typeId().id(); - } - - const TypesToFnsMap &m = typesToFns(); - TypesToFnsMap::const_iterator it = m.find( Types( typeId, resultType ) ); - if( it!=m.end() ) - { - return it->second( dagPath ); - } - - // if not then see if the default converter is suitable - DefaultConvertersMap &dc = defaultConverters(); - DefaultConvertersMap::const_iterator dcIt = dc.find( typeId ); - if( dcIt != dc.end() ) - { - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( dagPath ); - } - } - - return 0; -} - -FromMayaDagNodeConverter::TypesToFnsMap &FromMayaDagNodeConverter::typesToFns() -{ - static TypesToFnsMap m; - return m; -} - -FromMayaDagNodeConverter::DefaultConvertersMap &FromMayaDagNodeConverter::defaultConverters() -{ - static DefaultConvertersMap m; - return m; -} - -void FromMayaDagNodeConverter::registerConverter( const MayaType fromType, IECore::TypeId resultType, bool defaultConversion, CreatorFn creator ) -{ - TypesToFnsMap &m = typesToFns(); - TypesToFnsMap::const_iterator it = m.insert( TypesToFnsMap::value_type( Types( fromType, resultType), creator ) ).first; - if( defaultConversion ) - { - DefaultConvertersMap &dc = defaultConverters(); - if( ! dc.insert( DefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaDagNodeConverter::registerConverter", boost::format( "Default conversion for MFn::Type %d already registered - ignoring second registration." ) % fromType.first ); - } - } -} diff --git a/src/IECoreMaya/FromMayaEnumPlugConverter.cpp b/src/IECoreMaya/FromMayaEnumPlugConverter.cpp deleted file mode 100644 index 242e6d3a0c..0000000000 --- a/src/IECoreMaya/FromMayaEnumPlugConverter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2019, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaEnumPlugConverter.h" - -#include "IECore/MessageHandler.h" - -#include "maya/MString.h" -#include "maya/MFnEnumAttribute.h" - - - -using namespace IECore; - -namespace IECoreMaya -{ - -template -FromMayaPlugConverter::Description< FromMayaEnumPlugConverter > FromMayaEnumPlugConverter::m_description{}; - -template -const MString FromMayaEnumPlugConverter::convertToStringCategory = "ieConvertToStringData"; - -template -FromMayaEnumPlugConverter::FromMayaEnumPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ -} - -template<> -IECore::ObjectPtr FromMayaEnumPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - return new IECore::ShortData( plug().asShort() ); -} - -template<> -IECore::ObjectPtr FromMayaEnumPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - MFnEnumAttribute fne( plug().attribute() ); - return new IECore::StringData( fne.fieldName( plug().asShort() ).asChar() ); -} - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaEnumPlugConverterst, FromMayaEnumPlugConverterstTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaEnumPlugConvertersh, FromMayaEnumPlugConvertershTypeId ) - -template class FromMayaEnumPlugConverter; -template class FromMayaEnumPlugConverter; -} diff --git a/src/IECoreMaya/FromMayaFluidConverter.cpp b/src/IECoreMaya/FromMayaFluidConverter.cpp deleted file mode 100644 index 9b1075d3e8..0000000000 --- a/src/IECoreMaya/FromMayaFluidConverter.cpp +++ /dev/null @@ -1,346 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/FromMayaFluidConverter.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MatrixMultiplyOp.h" -#include "IECore/SimpleTypedData.h" -#include "IECoreScene/PointsPrimitive.h" - -#include "maya/MFn.h" -#include "maya/MFnFluid.h" - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace std; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaFluidConverter ); - -// Not registering as the default converter as at some point I presume we'll have a converter to some sort of voxel object, and that would make -// a better default. -FromMayaShapeConverter::Description FromMayaFluidConverter::m_description( MFn::kFluid, PointsPrimitive::staticTypeId(), false ); - -FromMayaFluidConverter::FromMayaFluidConverter( const MObject &object ) - : FromMayaShapeConverter( "Converts maya fluid data to IECoreScene::PointsPrimitive Object", object ) -{ - constructCommon(); -} - -FromMayaFluidConverter::FromMayaFluidConverter( const MDagPath &dagPath ) - : FromMayaShapeConverter( "Converts maya fluid data to IECoreScene::PointsPrimitive Object", dagPath ) -{ - constructCommon(); -} - -FromMayaFluidConverter::~FromMayaFluidConverter() -{ -} - -void FromMayaFluidConverter::constructCommon() -{ - m_velocityParameter = new BoolParameter( - "velocity", - "When this is on the fluid's velocities are added to the result as a primitive variable named \"velocity\".", - true - ); - parameters()->addParameter( m_velocityParameter ); - - m_densityParameter = new BoolParameter( - "density", - "When this is on the fluid's densities are added to the result as a primitive variable named \"density\".", - true - ); - parameters()->addParameter( m_densityParameter ); - - m_pressureParameter = new BoolParameter( - "pressure", - "When this is on the fluid's pressures are added to the result as a primitive variable named \"pressure\".", - true - ); - parameters()->addParameter( m_pressureParameter ); - - m_temperatureParameter = new BoolParameter( - "temperature", - "When this is on the fluid's temperatures are added to the result as a primitive variable named \"temperature\".", - true - ); - parameters()->addParameter( m_temperatureParameter ); - - m_fuelParameter = new BoolParameter( - "fuel", - "When this is on the fluid's fuel is added to the result as a primitive variable named \"fuel\".", - true - ); - parameters()->addParameter( m_fuelParameter ); - - m_falloffParameter = new BoolParameter( - "falloff", - "When this is on the fluid's falloff is added to the result as a primitive variable named \"falloff\".", - true - ); - parameters()->addParameter( m_falloffParameter ); - - m_colorParameter = new BoolParameter( - "color", - "When this is on the fluid's colors are added to the result as a primitive variable named \"color\".", - true - ); - parameters()->addParameter( m_colorParameter ); - - m_textureCoordinatesParameter = new BoolParameter( - "textureCoordinates", - "When this is on the fluid's texture coordinates are added to the result as a primitive variable named \"uvw\" or \"uv\".", - true - ); - parameters()->addParameter( m_textureCoordinatesParameter ); -} - -void FromMayaFluidConverter::addPrimVar( IECoreScene::PrimitivePtr primitive, const std::string &name, size_t numPoints, MFnFluid &fnFluid, float *(MFnFluid::*fn)( MStatus * ) ) const -{ - MStatus s; - float *mayaPtr = ((fnFluid).*(fn))( &s ); - if ( s ) - { - assert( mayaPtr ); - FloatVectorDataPtr floatData = new FloatVectorData(); - floatData->writable().resize( numPoints ); - std::copy( mayaPtr, mayaPtr + numPoints, &(floatData->writable()[0]) ); - PrimitiveVariable newVar( PrimitiveVariable::Vertex, floatData ); - primitive->variables[ name ] = newVar; - } -} - -IECoreScene::PrimitivePtr FromMayaFluidConverter::doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnFluid fnFluid( object ); - if( !fnFluid.hasObj( object ) ) - { - return 0; - } - return doPrimitiveConversion( fnFluid ); -} - -IECoreScene::PrimitivePtr FromMayaFluidConverter::doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnFluid fnFluid( dagPath ); - if( !fnFluid.hasObj( dagPath.node() ) ) - { - return 0; - } - return doPrimitiveConversion( fnFluid ); -} - -IECoreScene::PrimitivePtr FromMayaFluidConverter::doPrimitiveConversion( MFnFluid &fnFluid ) const -{ - MStatus s; - unsigned int nPoints = fnFluid.gridSize( &s ); - if ( !s ) - { - return 0; - } - unsigned int xRes, yRes, zRes; - int xVel, yVel, zVel; - if ( !fnFluid.getResolution( xRes, yRes, zRes ) ) - { - return 0; - } - - V3fVectorDataPtr positionsData = new V3fVectorData; - positionsData->setInterpretation( GeometricData::Point ); - V3fVectorDataPtr velocitiesData = new V3fVectorData; - velocitiesData->setInterpretation( GeometricData::Vector ); - V3fVectorData::ValueType positions = positionsData->writable(); - V3fVectorData::ValueType velocities = velocitiesData->writable(); - positions.resize( nPoints ); - velocities.resize( nPoints ); - - float *velX, *velY, *velZ; - if ( !fnFluid.getVelocity( velX, velY, velZ ) ) - { - return 0; - } - - MPoint centerPos; - for ( unsigned int x = 0; x < xRes; x++ ) - { - for ( unsigned int y = 0; y < yRes; y++ ) - { - for ( unsigned int z = 0; z < zRes; z++ ) - { - int p = fnFluid.index( x, y, z ); - if ( !fnFluid.voxelCenterPosition( x, y, z, centerPos ) ) - { - return 0; - } - positions[p] = IECore::convert< V3f >( centerPos ); - fnFluid.index( p, xRes, yRes, zRes, xVel, yVel, zVel ); - - /// \todo Does this work for 2D fluids? And wouldn't we like the option to convert those to ImagePrimitives instead? - assert( velX ); - assert( velY ); - assert( velZ ); - velocities[p] = (V3f( velX[xVel], velY[yVel], velZ[zVel] ) + V3f( velX[xVel+1], velY[yVel+1], velZ[zVel+1] )) / 2; - } - } - } - - // make a matrix multiply op if we need it - // and if we have the right information available - MatrixMultiplyOpPtr matrixMultiplier = 0; - if( space()==MSpace::kWorld ) - { - const MDagPath *d = dagPath( true ); - if( d ) - { - matrixMultiplier = new MatrixMultiplyOp; - matrixMultiplier->copyParameter()->setTypedValue( false ); // modify input in place - matrixMultiplier->matrixParameter()->setValue( new M44fData( IECore::convert( d->inclusiveMatrix() ) ) ); - } - } - - PointsPrimitivePtr pp = new PointsPrimitive( nPoints ); - - if( matrixMultiplier ) - { - matrixMultiplier->inputParameter()->setValue( positionsData ); - matrixMultiplier->operate(); - } - pp->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, positionsData ); - - if( m_velocityParameter->getTypedValue() ) - { - if( matrixMultiplier ) - { - matrixMultiplier->inputParameter()->setValue( velocitiesData ); - matrixMultiplier->operate(); - } - pp->variables["velocity"] = PrimitiveVariable( PrimitiveVariable::Vertex, velocitiesData ); - } - - if( m_densityParameter->getTypedValue() ) - { - addPrimVar( pp, "density", nPoints, fnFluid, &MFnFluid::density ); - } - - if( m_pressureParameter->getTypedValue() ) - { - addPrimVar( pp, "pressure", nPoints, fnFluid, &MFnFluid::pressure ); - } - - if( m_temperatureParameter->getTypedValue() ) - { - addPrimVar( pp, "temperature", nPoints, fnFluid, &MFnFluid::temperature ); - } - - if( m_fuelParameter->getTypedValue() ) - { - addPrimVar( pp, "fuel", nPoints, fnFluid, &MFnFluid::fuel ); - } - - if( m_falloffParameter->getTypedValue() ) - { - addPrimVar( pp, "falloff", nPoints, fnFluid, &MFnFluid::falloff ); - } - - if( m_colorParameter->getTypedValue() ) - { - float *redPtr; - float *greenPtr; - float *bluePtr; - if ( fnFluid.getColors( redPtr, greenPtr, bluePtr ) ) - { - assert( redPtr ); - assert( greenPtr ); - assert( bluePtr ); - V3fVectorDataPtr colorData = new V3fVectorData(); - colorData->setInterpretation( GeometricData::Color ); - V3fVectorData::ValueType &colorVector = colorData->writable(); - colorVector.resize( nPoints ); - for ( unsigned i = 0; i < nPoints; i++ ) - { - colorVector[i] = V3f( redPtr[i], greenPtr[i], bluePtr[i] ); - } - PrimitiveVariable varColor( PrimitiveVariable::Vertex, colorData ); - - /// \todo Why not "Cs"? - pp->variables["color"] = varColor; - } - } - - if(m_textureCoordinatesParameter->getTypedValue() ) - { - float *uPtr; - float *vPtr; - float *wPtr; - if ( fnFluid.getCoordinates( uPtr, vPtr, wPtr ) ) - { - if ( wPtr == NULL ) - { - assert( uPtr ); - assert( vPtr ); - V2fVectorDataPtr uvData = new V2fVectorData(); - V2fVectorData::ValueType &uvVector = uvData->writable(); - uvVector.resize( nPoints ); - for ( unsigned i = 0; i < nPoints; i++ ) - { - uvVector[i] = V2f( uPtr[i], vPtr[i] ); - } - PrimitiveVariable varUV( PrimitiveVariable::Vertex, uvData ); - pp->variables["uv"] = varUV; /// \todo Why not s,t? - } - else - { - assert( uPtr ); - assert( vPtr ); - V3fVectorDataPtr uvwData = new V3fVectorData(); - V3fVectorData::ValueType &uvwVector = uvwData->writable(); - uvwVector.resize( nPoints ); - for ( unsigned i = 0; i < nPoints; i++ ) - { - uvwVector[i] = V3f( uPtr[i], vPtr[i], wPtr[i] ); - } - PrimitiveVariable varUVW( PrimitiveVariable::Vertex, uvwData ); - pp->variables["uvw"] = varUVW; /// \todo Why not s,t,u or perhaps __Pref? - } - } - } - - return pp; -} diff --git a/src/IECoreMaya/FromMayaGroupConverter.cpp b/src/IECoreMaya/FromMayaGroupConverter.cpp deleted file mode 100644 index 2fccfd287a..0000000000 --- a/src/IECoreMaya/FromMayaGroupConverter.cpp +++ /dev/null @@ -1,135 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaGroupConverter.h" -#include "IECoreMaya/FromMayaMeshConverter.h" -#include "IECoreMaya/MatrixTraits.h" - -#include "IECore/MatrixOps.h" -#include "IECore/CompoundObject.h" -#include "IECoreScene/Group.h" -#include "IECoreScene/MatrixTransform.h" - -#include "maya/MFn.h" -#include "maya/MFnDagNode.h" - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace std; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaGroupConverter ); - -FromMayaDagNodeConverter::Description FromMayaGroupConverter::m_description( MFn::kTransform, Group::staticTypeId(), true ); - -FromMayaGroupConverter::FromMayaGroupConverter( const MDagPath &dagPath ) - : FromMayaDagNodeConverter( "Converts transforms to Group objects.", dagPath ) -{ - - /// \todo I see no need for this to be a parameter. Surely it should be a given that we ignore intermediates? - BoolParameterPtr ignoreIntermediateObjects = new BoolParameter( - "ignoreIntermediateObjects", - "If true, all the intermediate objects will be excluded from the conversion.", - true - ); - parameters()->addParameter( ignoreIntermediateObjects ); - - FromMayaObjectConverterPtr m = new FromMayaMeshConverter( MObject() ); - m_meshParameters = new CompoundParameter( "meshes", "Parameters to control the conversion of meshes.", m->parameters()->orderedParameters().begin(), m->parameters()->orderedParameters().end() ); - parameters()->addParameter( m_meshParameters ); - -} - -IECore::ObjectPtr FromMayaGroupConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - bool ignoreIntermediate = false; - CompoundObject::ObjectMap::const_iterator it = operands->members().find( "ignoreIntermediateObjects" ); - if ( it != operands->members().end() ) - { - ignoreIntermediate = boost::static_pointer_cast< BoolData >( it->second )->readable(); - } - - if( dagPath.apiType()==MFn::kTransform ) - { - MFnDagNode fnDagNode( dagPath ); - - GroupPtr result = new Group(); - result->setTransform( new MatrixTransform( matConvert( fnDagNode.transformationMatrix() ) ) ); - - unsigned int n = dagPath.childCount(); - for( unsigned int i=0; i( doConversion( child, operands ) ); - if( v ) - { - result->addChild( v ); - } - } - return result; - } - else - { - FromMayaShapeConverterPtr c = 0; - if( dagPath.apiType()==MFn::kMesh ) - { - c = new FromMayaMeshConverter( dagPath ); - c->parameters()->setValue( m_meshParameters->getValue() ); - } - else - { - c = FromMayaShapeConverter::create( dagPath, VisibleRenderable::staticTypeId() ); - } - - if( c ) - { - return c->convert(); - } - } - - return 0; -} diff --git a/src/IECoreMaya/FromMayaImageConverter.cpp b/src/IECoreMaya/FromMayaImageConverter.cpp deleted file mode 100644 index edd124e551..0000000000 --- a/src/IECoreMaya/FromMayaImageConverter.cpp +++ /dev/null @@ -1,236 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "boost/static_assert.hpp" -#include "boost/format.hpp" -#include "boost/multi_array.hpp" - -#include "IECore/CompoundParameter.h" -#include "IECore/Exception.h" -#include "IECore/ScaledDataConversion.h" - -#include "IECoreMaya/FromMayaImageConverter.h" -#include "IECoreMaya/MImageAccessor.h" - -#include "Imath/ImathBox.h" - -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaImageConverter ); - -FromMayaImageConverter::FromMayaImageConverter( MImage &image ) : FromMayaConverter( "" ), m_image( image ) -{ - m_depthParameter = new BoolParameter( - "depth", - "When this is on the depth channel (if present), is added as primitive variable 'Z'", - true - ); - - parameters()->addParameter( m_depthParameter ); -} - -const MImage &FromMayaImageConverter::image() const -{ - return m_image; -} - -BoolParameterPtr FromMayaImageConverter::depthParameter() -{ - return m_depthParameter; -} - -BoolParameterPtr FromMayaImageConverter::depthParameter() const -{ - return m_depthParameter; -} - -template -void FromMayaImageConverter::writeChannels( ImagePrimitivePtr target, const std::vector< std::string > &channelNames ) const -{ - assert( target ); - unsigned numChannels = m_image.depth() / ( m_image.pixelType() == MImage::kFloat ? sizeof(float) : sizeof(unsigned char) ); - unsigned width, height; - m_image.getSize( width, height ); - assert( width ); - assert( height ); - - std::vector< boost::multi_array_ref< float, 2 > > channelArrays; - - for ( std::vector< std::string >::const_iterator it = channelNames.begin(); it != channelNames.end(); ++it ) - { - float *dataArray = &runTimeCast( target->channels[*it] )->writable()[0]; - assert( dataArray ); - channelArrays.push_back( boost::multi_array_ref< float, 2 >( dataArray, boost::extents[height][width] ) ); - } - - boost::multi_array_ref< T, 3 > pixels( MImageAccessor::getPixels( m_image ), boost::extents[height][width][numChannels] ); - - ScaledDataConversion< T, float > converter; - for ( unsigned x = 0; x < width; x++ ) - { - for ( unsigned y = 0; y < height; y++ ) - { - for ( unsigned c = 0; c < channelNames.size(); c++ ) - { - /// Vertical flip, to match Maya - channelArrays[c][height - 1 - y][x] = converter( pixels[y][x][c] ); - } - } - } -} - -void FromMayaImageConverter::writeDepth( ImagePrimitivePtr target, const float *depth ) const -{ - assert( target ); - unsigned width, height; - m_image.getSize( width, height ); - assert( width ); - assert( height ); - - boost::multi_array_ref< const float, 2 > depthArray( depth, boost::extents[height][width] ); - - FloatVectorDataPtr targetDepth = new FloatVectorData(); - targetDepth->writable().resize( width * height ); - - boost::multi_array_ref< float, 2 > targetDepthArray( &(targetDepth->writable()[0]), boost::extents[height][width] ); - - for ( unsigned x = 0; x < width; x++ ) - { - for ( unsigned y = 0; y < height; y++ ) - { - /// Vertical flip, to match Maya - targetDepthArray[height - 1 - y][x] = depthArray[y][x]; - } - } - - target->channels["Z"] = targetDepth; -} - -ObjectPtr FromMayaImageConverter::doConversion( ConstCompoundObjectPtr operands ) const -{ - assert( operands ); - - unsigned width, height; - MStatus s = m_image.getSize( width, height ); - - if ( !s || width * height == 0 ) - { - return new ImagePrimitive(); - } - - Imath::Box2i dataWindow( Imath::V2i( 0, 0 ),Imath::V2i( width - 1 , height - 1 ) ); - assert( !dataWindow.isEmpty() ); - - ImagePrimitivePtr img = new ImagePrimitive( dataWindow, dataWindow ); - - std::vector< std::string > channels; - if ( m_image.isRGBA() ) - { - channels.push_back( "R" ); - channels.push_back( "G" ); - channels.push_back( "B" ); - channels.push_back( "A" ); - } - else - { - channels.push_back( "B" ); - channels.push_back( "G" ); - channels.push_back( "R" ); - channels.push_back( "A" ); - } - - unsigned numChannels = m_image.depth() / ( m_image.pixelType() == MImage::kFloat ? sizeof(float) : sizeof(unsigned char) ); - while ( channels.size() > numChannels ) - { - channels.pop_back(); - } - - if ( channels.size() < 3 ) - { - throw InvalidArgumentException( "FromMayaImageConverter: MImage has unsupported channel count" ); - } - assert( channels.size() == 3 || channels.size() == 4 ); - assert( channels.size() <= numChannels ); - - for ( std::vector< std::string >::const_iterator it = channels.begin(); it != channels.end(); ++it ) - { - FloatVectorDataPtr data = new FloatVectorData(); - assert( data ); - - data->writable().resize( width * height ); - - img->channels[ *it ] = data; - } - - switch ( m_image.pixelType() ) - { - case MImage::kFloat : - writeChannels( img, channels ); - break; - case MImage::kByte : - writeChannels( img, channels ); - break; - default : - throw InvalidArgumentException( "FromMayaImageConverter: MImage has unknown pixel type" ); - } - - if ( m_depthParameter->getTypedValue() ) - { - if ( m_image.haveDepth() ) - { - float *depth = m_image.depthMap(); - assert( depth ); - unsigned depthWidth = 0, depthHeight = 0; - - s = m_image.getDepthMapSize( depthWidth, depthHeight ); - assert( s ); - - if ( depthWidth != width || depthHeight != height ) - { - throw InvalidArgumentException( "FromMayaImageConverter: Different color/depth resolutions" ); - } - - writeDepth( img, depth ); - } - } - - assert( img->channelsValid() ); - - return img; -} diff --git a/src/IECoreMaya/FromMayaInstancerConverter.cpp b/src/IECoreMaya/FromMayaInstancerConverter.cpp deleted file mode 100644 index 3b10778102..0000000000 --- a/src/IECoreMaya/FromMayaInstancerConverter.cpp +++ /dev/null @@ -1,316 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -#include "IECoreMaya/FromMayaInstancerConverter.h" - -#include "IECoreMaya/FromMayaArrayDataConverter.h" - -#include "IECoreScene/PointsPrimitive.h" - -#include "IECore/NullObject.h" -#include "IECore/AngleConversion.h" - -#include "maya/MDataHandle.h" -#include "maya/MDoubleArray.h" -#include "maya/MIntArray.h" -#include "maya/MFnArrayAttrsData.h" -#include "maya/MFnDoubleArrayData.h" -#include "maya/MFnInstancer.h" -#include "maya/MFnIntArrayData.h" -#include "maya/MFnVectorArrayData.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MPlug.h" -#include "maya/MPlugArray.h" -#include "maya/MStringArray.h" -#include "maya/MVectorArray.h" - -#include "ImathEuler.h" - -#include "boost/algorithm/string/replace.hpp" - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace std; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaInstancerConverter ); - -namespace -{ - -DataPtr convert( const MString &attrName, MFnArrayAttrsData &attrsData ) -{ - MFnArrayAttrsData::Type t = MFnArrayAttrsData::kInvalid; - attrsData.checkArrayExist( attrName, t ); - - switch( t ) - { - case MFnArrayAttrsData::kVectorArray: - { - MFnVectorArrayData vectorArrayData; - - FromMayaArrayDataConverterVV3f::Ptr converter = new FromMayaArrayDataConverterVV3f( - vectorArrayData.create( - attrsData.vectorArray( - attrName - ) - ) - ); - return runTimeCast( converter->convert() ); - } - case MFnArrayAttrsData::kDoubleArray: - { - MFnDoubleArrayData doubleArrayData; - FromMayaArrayDataConverterdd::Ptr converter = new FromMayaArrayDataConverterdd( - doubleArrayData.create( - attrsData.doubleArray( - attrName - ) - ) - ); - return runTimeCast( converter->convert() ); - - } - case MFnArrayAttrsData::kIntArray: - { - MFnIntArrayData intArrayData; - FromMayaArrayDataConverterii::Ptr converter = new FromMayaArrayDataConverterii( intArrayData.create( attrsData.intArray( attrName ) ) ); - return runTimeCast( converter->convert() ); - - } - case MFnArrayAttrsData::kStringArray: - { - MFnStringArrayData stringArrayData; - FromMayaArrayDataConverterss::Ptr converter = new FromMayaArrayDataConverterss( - stringArrayData.create( - attrsData.stringArray( - attrName - ) - ) - ); - return runTimeCast( converter->convert() ); - - } - case MFnArrayAttrsData::kInvalid: - case MFnArrayAttrsData::kLast: - break; - } - - return nullptr; -} - -IECore::QuatfVectorDataPtr eulerToQuat( IECore::V3fVectorData *eulerData, Imath::Eulerf::Order order, bool isDegrees ) -{ - auto &readableEulerData = eulerData->readable(); - - IECore::QuatfVectorDataPtr quatData = new IECore::QuatfVectorData(); - auto &writableQuatData = quatData->writable(); - - writableQuatData.reserve( readableEulerData.size() ); - - for( const auto& rotation : readableEulerData ) - { - float x = isDegrees ? IECore::degreesToRadians( rotation.x ) : rotation.x; - float y = isDegrees ? IECore::degreesToRadians( rotation.y ) : rotation.y; - float z = isDegrees ? IECore::degreesToRadians( rotation.z ) : rotation.z; - - Imath::Eulerf euler( x, y, z, order ); - writableQuatData.push_back( euler.toQuat() ); - } - - return quatData; -} - -IECore::IntVectorDataPtr doubleToInt( IECore::DoubleVectorData *doubleData ) -{ - auto &readableDoubleData = doubleData->readable(); - - IECore::IntVectorDataPtr intData = new IECore::IntVectorData(); - auto &writableIntData = intData->writable(); - - writableIntData.reserve( readableDoubleData.size() ); - - for( const auto value : readableDoubleData ) - { - writableIntData.push_back( (int) value ); - } - - return intData; -} - -Imath::Eulerf::Order getRotationOrder( int instancerRotationOrder ) -{ - using namespace Imath; - static const std::vector orders = {Eulerf::XYZ, Eulerf::XZY, Eulerf::YZX, Eulerf::YXZ, Eulerf::ZXY, Eulerf::ZYX}; - if( instancerRotationOrder >= (int) orders.size() ) - { - return Eulerf::Default; - } - return orders[instancerRotationOrder]; -} -} // namespace - -FromMayaDagNodeConverter::Description FromMayaInstancerConverter::m_description( - MFn::kInstancer, PointsPrimitive::staticTypeId(), true -); - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// constructors -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -FromMayaInstancerConverter::FromMayaInstancerConverter( const MDagPath &dagPath ) : FromMayaDagNodeConverter( - "Converts Instancer to IECoreScene::PointsPrimitive objects.", dagPath -) -{ -} - -FromMayaInstancerConverter::~FromMayaInstancerConverter() -{ -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// conversion -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -IECore::ObjectPtr FromMayaInstancerConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnInstancer instancer; - - if( !instancer.setObject( dagPath ) ) - { - return nullptr; - } - - MStatus status; - Imath::Eulerf::Order order; - MPlug rotationOrderPlug = instancer.findPlug( "rotationOrder", false, &status ); - order = status ? getRotationOrder( rotationOrderPlug.asInt() ) : Imath::Eulerf::Default; - - MPlug rotationUnits = instancer.findPlug( "rotationAngleUnits", false, &status ); - bool isDegrees = status ? rotationUnits.asInt() == 0 : false; // if isDegrees == false then we have radians - - auto emptyPositions = new V3fVectorData(); - emptyPositions->setInterpretation( GeometricData::Interpretation::Point ); - PointsPrimitivePtr pointsPrimitive = new PointsPrimitive( emptyPositions, nullptr ); - - MPlug inputPointsPlug = instancer.findPlug( "inputPoints", false, &status ); - if( !status ) - { - return pointsPrimitive; - } - - MFnArrayAttrsData attrsData( inputPointsPlug.asMDataHandle().data(), &status ); - if( !status ) - { - return pointsPrimitive; - } - - MStringArray attributeNames = attrsData.list(); - - for( size_t a = 0; a < attributeNames.length(); ++a ) - { - const MString &attrName = attributeNames[a]; - - DataPtr d = ::convert( attrName, attrsData ); - if( d ) - { - std::string cortexAttributeName( attrName.asChar() ); - - if( attrName == "position" ) - { - cortexAttributeName = "P"; - auto pointData = runTimeCast( d ).get(); - pointsPrimitive->setNumPoints( pointData->readable().size() ); - pointData->setInterpretation( IECore::GeometricData::Interpretation::Point ); - } - else if( attrName == "rotation" ) - { - cortexAttributeName = "orient"; - d = eulerToQuat( runTimeCast( d.get() ), order, isDegrees ); - } - else if (attrName == "objectIndex") - { - cortexAttributeName = "instanceType"; - d = doubleToInt( runTimeCast( d.get() ) ); - } - else if( attrName == "visibility" ) - { - d = doubleToInt( runTimeCast( d.get() ) ); - } - else if ( attrName == "id") - { - d = doubleToInt( runTimeCast( d.get() ) ); - } - - pointsPrimitive->variables[cortexAttributeName] = PrimitiveVariable( PrimitiveVariable::Vertex, d ); - } - } - - MPlug inputHierarchy = instancer.findPlug( "inputHierarchy", false, &status ); - - if( status ) - { - StringVectorDataPtr instancePathsData = new StringVectorData(); - auto &writableInstancePaths = instancePathsData->writable(); - - for( unsigned int i = 0; i < inputHierarchy.numElements(); ++i ) - { - MPlug e = inputHierarchy.elementByLogicalIndex( i ); - MPlugArray inputs; - e.connectedTo( inputs, true, false ); - if( inputs.length() ) - { - MStatus s; - MFnDagNode dag( inputs[0].node(), &s ); - if( s ) - { - std::string instancePath = boost::algorithm::replace_all_copy( - std::string( dag.fullPathName().asChar() ), std::string( "|" ), std::string( "/" ) - ); - writableInstancePaths.push_back( instancePath ); - } - } - } - - pointsPrimitive->variables["instances"] = PrimitiveVariable( PrimitiveVariable::Constant, instancePathsData ); - } - - return pointsPrimitive; - -} - diff --git a/src/IECoreMaya/FromMayaLocatorConverter.cpp b/src/IECoreMaya/FromMayaLocatorConverter.cpp deleted file mode 100644 index b93ee041ee..0000000000 --- a/src/IECoreMaya/FromMayaLocatorConverter.cpp +++ /dev/null @@ -1,123 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaLocatorConverter.h" -#include "IECoreMaya/Convert.h" - -#include "Imath/ImathVec.h" -#include "Imath/ImathMatrix.h" - -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/MatrixTransform.h" - -#include "maya/MPlug.h" -#include "maya/MString.h" -#include "maya/MDagPath.h" -#include "maya/MFnDagNode.h" - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaLocatorConverter ); - -FromMayaDagNodeConverter::Description FromMayaLocatorConverter::m_description( MFn::kLocator, CoordinateSystem::staticTypeId(), true ); - -FromMayaLocatorConverter::FromMayaLocatorConverter( const MDagPath &dagPath ) - : FromMayaDagNodeConverter( "Converts maya locator shape nodes into IECoreScene::CoordinateSystem objects.", dagPath ) -{ -} - -IECore::ObjectPtr FromMayaLocatorConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus st; - - bool hasLocator = dagPath.hasFn( MFn::kLocator, &st ); - if (!st || !hasLocator) - { - throw Exception( "Could not find locator!" ); - } - - MObject locatorObj = dagPath.node(); - if ( !locatorObj.hasFn( MFn::kLocator ) ) - { - throw Exception( "Not a locator!" ); - } - - MFnDagNode fnLocator( locatorObj ); - - CoordinateSystemPtr result = new CoordinateSystem; - result->setName( IECore::convert( fnLocator.name() ) ); - - /// obtain local position and scale from locator - Imath::V3f position(0), scale(0); - - MPlug positionPlug = fnLocator.findPlug( "localPositionX", false, &st ); - if ( !st ) - throw Exception("Could not find 'localPositionX' plug!"); - positionPlug.getValue(position[0]); - - positionPlug = fnLocator.findPlug( "localPositionY", false, &st ); - if ( !st ) - throw Exception("Could not find 'localPositionY' plug!"); - positionPlug.getValue(position[1]); - - positionPlug = fnLocator.findPlug( "localPositionZ", false, &st ); - if ( !st ) - throw Exception("Could not find 'localPositionZ' plug!"); - positionPlug.getValue(position[2]); - - MPlug scalePlug = fnLocator.findPlug( "localScaleX", false, &st ); - if ( !st ) - throw Exception("Could not find 'localScaleX' plug!"); - scalePlug.getValue(scale[0]); - - scalePlug = fnLocator.findPlug( "localScaleY", false, &st ); - if ( !st ) - throw Exception("Could not find 'localScaleY' plug!"); - scalePlug.getValue(scale[1]); - - scalePlug = fnLocator.findPlug( "localScaleZ", false, &st ); - if ( !st ) - throw Exception("Could not find 'localScaleZ' plug!"); - scalePlug.getValue(scale[2]); - - Imath::M44f scaleM,translateM; - scaleM.scale(scale); - translateM.translate(position); - result->setTransform( new MatrixTransform( scaleM * translateM ) ); - - return result; -} diff --git a/src/IECoreMaya/FromMayaMatrixDataConverter.cpp b/src/IECoreMaya/FromMayaMatrixDataConverter.cpp deleted file mode 100644 index eff13d821f..0000000000 --- a/src/IECoreMaya/FromMayaMatrixDataConverter.cpp +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaMatrixDataConverter.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/SimpleTypedData.h" - -#include "maya/MFnMatrixData.h" - -using namespace IECoreMaya; -using namespace IECore; - -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaMatrixDataConverter::m_description( MFn::kMatrixData, M44dData::staticTypeId(), true ); -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaMatrixDataConverter::m_description( MFn::kMatrixData, M44fData::staticTypeId(), false ); - -template -FromMayaMatrixDataConverter::FromMayaMatrixDataConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts maya matrix data to IECore::M44*Data types.", object ) -{ -} - -template -IECore::ObjectPtr FromMayaMatrixDataConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnMatrixData fnMD( object ); - if( !fnMD.hasObj( object ) ) - { - return 0; - } - - MMatrix mayaMatrix = fnMD.matrix(); - typename T::ValueType coreMatrix = IECore::convert( mayaMatrix ); - - return new T( coreMatrix ); -} - -/// Explicit instantiations. -template class FromMayaMatrixDataConverter; -template class FromMayaMatrixDataConverter; - diff --git a/src/IECoreMaya/FromMayaMatrixVectorDataConverter.cpp b/src/IECoreMaya/FromMayaMatrixVectorDataConverter.cpp deleted file mode 100644 index abba4adaf7..0000000000 --- a/src/IECoreMaya/FromMayaMatrixVectorDataConverter.cpp +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaMatrixVectorDataConverter.h" - -#include "IECore/VectorTypedData.h" - -#include "maya/MDoubleArray.h" -#include "maya/MFnDoubleArrayData.h" - -using namespace IECoreMaya; -using namespace IECore; - -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaMatrixVectorDataConverter::m_description( MFn::kDoubleArrayData, M44dVectorData::staticTypeId(), false ); -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaMatrixVectorDataConverter::m_description( MFn::kDoubleArrayData, M44fVectorData::staticTypeId(), false ); - -template -FromMayaMatrixVectorDataConverter::FromMayaMatrixVectorDataConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts maya double array data to IECore::M44*VectorData types.", object ) -{ -} - -template -IECore::ObjectPtr FromMayaMatrixVectorDataConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnDoubleArrayData fnArrayData( object ); - if( !fnArrayData.hasObj( object ) ) - { - return 0; - } - if( ( fnArrayData.length() % 16 ) != 0 ) - { - return 0; - } - - MDoubleArray array = fnArrayData.array(); - typename T::Ptr resultData = new T; - typename T::ValueType &resultArray = resultData->writable(); - - resultArray.resize( array.length() / 16 ); - for ( unsigned int i=0; i; -template class FromMayaMatrixVectorDataConverter; - diff --git a/src/IECoreMaya/FromMayaMeshConverter.cpp b/src/IECoreMaya/FromMayaMeshConverter.cpp deleted file mode 100644 index cc490ea626..0000000000 --- a/src/IECoreMaya/FromMayaMeshConverter.cpp +++ /dev/null @@ -1,670 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaMeshConverter.h" -#include "IECoreMaya/FromMayaPlugConverter.h" -#include "IECoreMaya/MArrayIter.h" -#include "IECoreMaya/VectorTraits.h" - -#include "IECore/VectorOps.h" -#include "IECore/CompoundParameter.h" -#include "IECore/NumericParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/DespatchTypedData.h" -#include "IECoreScene/MeshPrimitive.h" - -#include "maya/MFn.h" -#include "maya/MFnMesh.h" -#include "maya/MFnAttribute.h" -#include "maya/MString.h" - -#if MAYA_API_VERSION >= 201800 -#include "maya/MDGContextGuard.h" -#endif - -#include - -using namespace IECoreMaya; -using namespace IECore; -using namespace IECoreScene; -using namespace std; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaMeshConverter ); - -FromMayaShapeConverter::Description FromMayaMeshConverter::m_description( MFn::kMesh, MeshPrimitive::staticTypeId(), true ); -FromMayaShapeConverter::Description FromMayaMeshConverter::m_dataDescription( MFn::kMeshData, MeshPrimitive::staticTypeId(), true ); - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// structors -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -FromMayaMeshConverter::FromMayaMeshConverter( const MObject &object ) - : FromMayaShapeConverter( "Converts poly meshes to IECoreScene::MeshPrimitive objects.", object ) -{ - constructCommon(); -} - -FromMayaMeshConverter::FromMayaMeshConverter( const MDagPath &dagPath ) - : FromMayaShapeConverter( "Converts poly meshes to IECoreScene::MeshPrimitive objects.", dagPath ) -{ - constructCommon(); -} - -void FromMayaMeshConverter::constructCommon() -{ - - // interpolation - StringParameter::PresetsContainer interpolationPresets; - interpolationPresets.push_back( StringParameter::Preset( "poly", "linear" ) ); - interpolationPresets.push_back( StringParameter::Preset( "subdiv", "catmullClark" ) ); - // the last interpolation type is 'default' - interpolationPresets.push_back( StringParameter::Preset( "default", "default" ) ); - - StringParameterPtr interpolation = new StringParameter( - "interpolation", - "Sets the interpolation type of the new mesh. When 'default' is used it will query the attribute 'ieMeshInterpolation' from the Mesh instead (and use linear if nonexistent).", - "default", - interpolationPresets - ); - - parameters()->addParameter( interpolation ); - // normals - BoolParameterPtr normals = new BoolParameter( - "normals", - "When this is on the mesh normals are added to the result as a primitive variable named \"N\". " - "Note that normals will only ever be added to meshes created with linear interpolation as " - "vertex normals are unsuitable for meshes which will be rendered with some form of " - "subdivision.", - true - ); - parameters()->addParameter( normals ); - - // uv - BoolParameterPtr uv = new BoolParameter( - "uv", - "When this is on the uv sets are added to the result as primitive variables", - true - ); - parameters()->addParameter( uv ); - - // colors - BoolParameterPtr colors = new BoolParameter( - "colors", - "When this is on the default color set is added to the result as primitive variable named \"Cs\".", - false - ); - - parameters()->addParameter( colors ); - - // extra colors - BoolParameterPtr extraColors = new BoolParameter( - "extraColors", - "When this is on, all color sets are added to the result as primitive variables named \"setName_Cs\".", - false - ); - - parameters()->addParameter( extraColors ); - - BoolParameterPtr creases = new BoolParameter( - "creases", - "When this is on, all corners and edge creases are added to the result.", - true - ); - - parameters()->addParameter( creases ); - -} - -FromMayaMeshConverter::~FromMayaMeshConverter() -{ -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// parameter access -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -IECore::StringParameter *FromMayaMeshConverter::interpolationParameter() -{ - return parameters()->parameter< StringParameter >( "interpolation" ); -} - -const IECore::StringParameter *FromMayaMeshConverter::interpolationParameter() const -{ - return parameters()->parameter< StringParameter >( "interpolation" ); -} - -IECore::BoolParameter *FromMayaMeshConverter::normalsParameter() -{ - return parameters()->parameter< BoolParameter >( "normals" ); -} -const IECore::BoolParameter *FromMayaMeshConverter::normalsParameter() const -{ - return parameters()->parameter< BoolParameter >( "normals" ); -} - -IECore::BoolParameter *FromMayaMeshConverter::uvParameter() -{ - return parameters()->parameter< BoolParameter >( "uv" ); -} - -const IECore::BoolParameter *FromMayaMeshConverter::uvParameter() const -{ - return parameters()->parameter< BoolParameter >( "uv" ); -} - -IECore::BoolParameter *FromMayaMeshConverter::colorsParameter() -{ - return parameters()->parameter< BoolParameter >( "colors" ); -} - -const IECore::BoolParameter *FromMayaMeshConverter::colorsParameter() const -{ - return parameters()->parameter< BoolParameter >( "colors" ); -} - -IECore::BoolParameter *FromMayaMeshConverter::extraColorsParameter() -{ - return parameters()->parameter< BoolParameter >( "extraColors" ); -} - -const IECore::BoolParameter *FromMayaMeshConverter::extraColorsParameter() const -{ - return parameters()->parameter< BoolParameter >( "extraColors" ); -} - -IECore::BoolParameter *FromMayaMeshConverter::creasesParameter() -{ - return parameters()->parameter< BoolParameter >( "creases" ); -} - -const IECore::BoolParameter *FromMayaMeshConverter::creasesParameter() const -{ - return parameters()->parameter< BoolParameter >( "creases" ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// conversion -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -IECoreScene::PrimitiveVariable FromMayaMeshConverter::points() const -{ - MFnMesh fnMesh; - const MDagPath *d = dagPath( true ); - if( d ) - { - fnMesh.setObject( *d ); - } - else - { - fnMesh.setObject( object() ); - } - - V3fVectorDataPtr points = new V3fVectorData; - points->setInterpretation( GeometricData::Point ); - int numVerts = fnMesh.numVertices(); - points->writable().resize( numVerts ); - - if( space() == MSpace::kObject ) - { - const V3f* rawPoints = ( const V3f* )fnMesh.getRawPoints(0); - copy( rawPoints, rawPoints + numVerts, points->writable().begin() ); - } - else - { - MFloatPointArray mPoints; - fnMesh.getPoints( mPoints, space() ); - std::transform( MArrayIter::begin( mPoints ), MArrayIter::end( mPoints ), points->writable().begin(), VecConvert() ); - } - - return PrimitiveVariable( PrimitiveVariable::Vertex, points ); -} - -IECoreScene::PrimitiveVariable FromMayaMeshConverter::normals() const -{ - MFnMesh fnMesh; - const MDagPath *d = dagPath( true ); - if( d ) - { - fnMesh.setObject( *d ); - } - else - { - fnMesh.setObject( object() ); - } - - V3fVectorDataPtr normalsData = new V3fVectorData; - normalsData->setInterpretation( GeometricData::Normal ); - vector &normals = normalsData->writable(); - normals.reserve( fnMesh.numFaceVertices() ); - - int numPolygons = fnMesh.numPolygons(); - V3f blankVector; - - if( space() == MSpace::kObject ) - { - const float* rawNormals = fnMesh.getRawNormals(0); - MIntArray normalIds; - for( int i=0; i &vertsPerFace ) const -{ - MFnMesh fnMesh( object() ); - - IntVectorDataPtr indexData = new IntVectorData; - vector &indices = indexData->writable(); - indices.reserve( fnMesh.numFaceVertices() ); - - // get uv data. A list of uv counts per polygon, and a bunch of uv ids: - MIntArray uvCounts, uvIds; - fnMesh.getAssignedUVs( uvCounts, uvIds, &uvSet ); - - int uvIdIndex = 0; - for( size_t i=0; i < vertsPerFace.size(); ++i ) - { - int numPolyUvs = uvCounts[i]; - int numPolyVerts = vertsPerFace[i]; - - if( numPolyUvs == 0 ) - { - for( int j=0; j < numPolyVerts; ++j ) - { - indices.push_back( 0 ); - } - } - else - { - for( int j=0; j < numPolyVerts; ++j ) - { - indices.push_back( uvIds[ uvIdIndex++ ] ); - } - } - } - - V2fVectorDataPtr uvData = new V2fVectorData; - uvData->setInterpretation( GeometricData::UV ); - std::vector &uvs = uvData->writable(); - - MFloatArray uArray, vArray; - fnMesh.getUVs( uArray, vArray, &uvSet ); - - size_t numIndices = indices.size(); - if( uArray.length() == 0 ) - { - uvs.resize( numIndices, Imath::V2f( .0f ) ); - } - else - { - uvs.reserve( uArray.length() ); - for( size_t i=0; i < uArray.length(); ++i ) - { - uvs.emplace_back( uArray[i], vArray[i] ); - } - } - - return PrimitiveVariable( PrimitiveVariable::FaceVarying, uvData, indexData ); -} - -IECoreScene::PrimitiveVariable FromMayaMeshConverter::colors( const MString &colorSet, bool forceRgb ) const -{ - MFnMesh fnMesh( object() ); - MFnMesh::MColorRepresentation rep = fnMesh.getColorRepresentation( colorSet ); - - int numColors = fnMesh.numFaceVertices(); - MColorArray colors; - MColor defaultColor(0,0,0,1); - if ( !fnMesh.getFaceVertexColors( colors, &colorSet, &defaultColor ) ) - { - throw Exception( ( boost::format( "Failed to obtain colors from color set '%s'" ) % colorSet ).str() ); - } - - int availableColors = colors.length(); - if ( availableColors > numColors ) - { - availableColors = numColors; - } - - DataPtr data; - - if ( rep == MFnMesh::kAlpha ) - { - if ( forceRgb ) - { - Color3fVectorDataPtr colorVec = new Color3fVectorData(); - colorVec->writable().resize( numColors, Imath::Color3f(1) ); - std::vector< Imath::Color3f >::iterator it = colorVec->writable().begin(); - for ( int i = 0; i < availableColors; i++, it++ ) - { - *it = Imath::Color3f( colors[i][3] ); - } - data = colorVec; - } - else - { - FloatVectorDataPtr colorVec = new FloatVectorData(); - colorVec->writable().resize( numColors, 1 ); - std::vector< float >::iterator it = colorVec->writable().begin(); - for ( int i = 0; i < availableColors; i++, it++ ) - { - *it = colors[i][3]; - } - data = colorVec; - } - } - else - { - if ( rep == MFnMesh::kRGB || forceRgb ) - { - Color3fVectorDataPtr colorVec = new Color3fVectorData(); - colorVec->writable().resize( numColors, Imath::Color3f(0,0,0) ); - std::vector< Imath::Color3f >::iterator it = colorVec->writable().begin(); - for ( int i = 0; i < availableColors; i++, it++ ) - { - const MColor &c = colors[i]; - *it = Imath::Color3f( c[0], c[1], c[2] ); - } - data = colorVec; - } - else - { - Color4fVectorDataPtr colorVec = new Color4fVectorData(); - colorVec->writable().resize( numColors, Imath::Color4f(0,0,0,1) ); - std::vector< Imath::Color4f >::iterator it = colorVec->writable().begin(); - for ( int i = 0; i < availableColors; i++, it++ ) - { - const MColor &c = colors[i]; - *it = Imath::Color4f( c[0], c[1], c[2], c[3] ); - } - data = colorVec; - } - } - return PrimitiveVariable( PrimitiveVariable::FaceVarying, data ); -} - -void FromMayaMeshConverter::corners( MeshPrimitive *mesh ) const -{ - MFnMesh fnMesh( object() ); - - MUintArray vertexIds; - MDoubleArray creaseData; - - MStatus s = fnMesh.getCreaseVertices( vertexIds, creaseData ); - - if( !s ) - { - // Instead of returning empty data in the case where no creases are - // present, Maya considers this a failure. We ignore the error status and - // return without modifying the given vectors. - return; - } - - assert( vertexIds.length() == creaseData.length() ); - - IntVectorDataPtr cornerIdsData = new IntVectorData(); - std::vector &cornerIds = cornerIdsData->writable(); - cornerIds.reserve( vertexIds.length() ); - - FloatVectorDataPtr cornerSharpnessesData = new FloatVectorData(); - std::vector &cornerSharpnesses = cornerSharpnessesData->writable(); - cornerSharpnesses.reserve( creaseData.length() ); - - for( size_t i = 0; i < vertexIds.length(); ++i ) - { - cornerIds.push_back( vertexIds[i] ); - cornerSharpnesses.push_back( creaseData[i] ); - } - - mesh->setCorners( cornerIdsData.get(), cornerSharpnessesData.get() ); -} - -void FromMayaMeshConverter::creases( MeshPrimitive *mesh ) const -{ - MFnMesh fnMesh( object() ); - - MUintArray edgeIds; - MDoubleArray creaseData; - - MStatus s = fnMesh.getCreaseEdges( edgeIds, creaseData ); - if( !s ) - { - // Instead of returning empty data in the case where no creases are - // present, Maya considers this a failure. We ignore the error status and - // return without modifying the given vectors. - return; - } - - assert( edgeIds.length() == creaseData.length() ); - - IntVectorDataPtr creaseLengthsData = new IntVectorData(); - std::vector &creaseLengths = creaseLengthsData->writable(); - creaseLengths.resize( edgeIds.length(), 2 ); - - IntVectorDataPtr creaseIdsData = new IntVectorData(); - std::vector &creaseIds = creaseIdsData->writable(); - creaseIds.reserve( creaseLengths.size() * 2 ); - - FloatVectorDataPtr creaseSharpnessesData = new FloatVectorData(); - std::vector &creaseSharpnesses = creaseSharpnessesData->writable(); - creaseSharpnesses.reserve( creaseLengths.size() ); - - // Maya stores creases via edge id. Cortex uses vertex ids instead. The - // following handles the conversion. - // \todo: Cortex supports a more compact crease representation that saves - // some memory. An additional compacting step here would allow us to reap - // the benefits. - - int2 vertexList; - for( size_t i = 0; i < edgeIds.length(); ++i ) - { - fnMesh.getEdgeVertices( edgeIds[i], vertexList ); - - creaseIds.push_back( vertexList[0] ); - creaseIds.push_back( vertexList[1] ); - - creaseSharpnesses.push_back( creaseData[ i ] ); - } - - mesh->setCreases( creaseLengthsData.get(), creaseIdsData.get(), creaseSharpnessesData.get() ); -} - -IECoreScene::PrimitivePtr FromMayaMeshConverter::doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnMesh fnMesh( object ); - return doPrimitiveConversion( fnMesh ); -} - -IECoreScene::PrimitivePtr FromMayaMeshConverter::doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnMesh fnMesh( dagPath ); - return doPrimitiveConversion( fnMesh ); -} - -IECoreScene::PrimitivePtr FromMayaMeshConverter::doPrimitiveConversion( MFnMesh &fnMesh ) const -{ - // get basic topology and create a mesh - int numPolygons = fnMesh.numPolygons(); - IntVectorDataPtr verticesPerFaceData = new IntVectorData; - verticesPerFaceData->writable().resize( numPolygons ); - vector::iterator verticesPerFaceIt = verticesPerFaceData->writable().begin(); - - IntVectorDataPtr vertexIds = new IntVectorData; - // We are calling fnMesh.numFaceVertices() twice to work around a known bug in Maya. When accessing - // certain MFnMesh API calls, given a mesh with 6 or more UV sets, which has never been evaluated - // before, the first call returns 0 and kFailure, and the second call works as expected. - // See ToMayaMeshConverterTest.testManyUVConversionsFromPlug for an example of how this might occur. - fnMesh.numFaceVertices(); - vertexIds->writable().resize( fnMesh.numFaceVertices() ); - vector::iterator vertexIdsIt = vertexIds->writable().begin(); - - MIntArray vertexCounts, polygonVertices; - fnMesh.getVertices( vertexCounts, polygonVertices ); - - copy( MArrayIter::begin( vertexCounts ), MArrayIter::end( vertexCounts ), verticesPerFaceIt ); - copy( MArrayIter::begin( polygonVertices ), MArrayIter::end( polygonVertices ), vertexIdsIt ); - - std::string interpolation = interpolationParameter()->getTypedValue(); - if ( interpolation == "default" ) - { - MStatus st; - MPlug interpolationPlug = fnMesh.findPlug( "ieMeshInterpolation", false, &st ); - if ( st ) - { -#if MAYA_API_VERSION >= 201800 - unsigned int interpolationIndex; - { - MDGContextGuard ctxGuard( MDGContext::fsNormal ); - interpolationIndex = interpolationPlug.asInt(&st); - } -#else - unsigned int interpolationIndex = interpolationPlug.asInt(MDGContext::fsNormal, &st); -#endif - if ( st ) - { - if ( interpolationIndex < interpolationParameter()->getPresets().size() - 1 ) - { - // convert interpolation index to the preset value - interpolation = boost::static_pointer_cast< StringData >( interpolationParameter()->getPresets()[interpolationIndex].second )->readable(); - } - else - { - interpolation = "linear"; - } - } - else - { - interpolation = "linear"; - } - } - else - { - interpolation = "linear"; - } - } - - MeshPrimitivePtr result = new MeshPrimitive( verticesPerFaceData, vertexIds, interpolation ); - - result->variables["P"] = points(); - - if( normalsParameter()->getTypedValue() && interpolation=="linear" ) - { - result->variables["N"] = normals(); - } - - MString currentUVSet; - fnMesh.getCurrentUVSetName( currentUVSet ); - - if( uvParameter()->getTypedValue() && currentUVSet.length() ) - { - MStringArray uvSets; - fnMesh.getUVSetNames( uvSets ); - for( unsigned int i = 0; i < uvSets.length(); i++ ) - { - if( uvSets[i] == currentUVSet ) - { - result->variables["uv"] = uvs( currentUVSet, verticesPerFaceData->readable() ); - } - else - { - result->variables[uvSets[i].asChar()] = uvs( uvSets[i], verticesPerFaceData->readable() ); - } - } - } - - bool convertColors = colorsParameter()->getTypedValue(); - bool convertExtraColors = extraColorsParameter()->getTypedValue(); - if ( convertColors || convertExtraColors ) - { - MString currentColorSet; - fnMesh.getCurrentColorSetName( currentColorSet ); - MStringArray colorSets; - fnMesh.getColorSetNames( colorSets ); - for( unsigned int i=0; ivariables["Cs"] = colors( currentColorSet, true ); - } - - if( convertExtraColors ) - { - MString sName = colorSets[i] + "_Cs"; - // Extra color sets are not converted - result->variables[sName.asChar()] = colors( colorSets[i] ); - } - } - } - - bool convertCreases = creasesParameter()->getTypedValue(); - if( convertCreases ) - { - corners( result.get() ); - creases( result.get() ); - } - - return result; -} diff --git a/src/IECoreMaya/FromMayaNumericDataConverter.cpp b/src/IECoreMaya/FromMayaNumericDataConverter.cpp deleted file mode 100644 index 71312651e7..0000000000 --- a/src/IECoreMaya/FromMayaNumericDataConverter.cpp +++ /dev/null @@ -1,183 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaNumericDataConverter.h" - -#include "IECore/SimpleTypedData.h" - -#include "maya/MFn.h" -#include "maya/MFnNumericData.h" - -#include - -using namespace IECoreMaya; -using namespace IECore; -using namespace std; -using namespace Imath; - -// 3d vector conversion -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_3Double( MFn::kData3Double, V3dDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_3Float( MFn::kData3Float, V3fDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_3Int( MFn::kData3Int, V3iDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_3Short( MFn::kData3Short, V3iDataTypeId, true ); -// 2d vector conversion -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_2Double( MFn::kData2Double, V2dDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_2Float( MFn::kData2Float, V2fDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_2Int( MFn::kData2Int, V2iDataTypeId, true ); -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaNumericDataConverter::g_2Short( MFn::kData2Short, V3iDataTypeId , true); - - -FromMayaNumericDataConverter::FromMayaNumericDataConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts types compatible with MFnNumericData.", object ) -{ -} - -IECore::ObjectPtr FromMayaNumericDataConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - MFnNumericData fnData( object, &s ); - - switch (fnData.numericType()) - { - case MFnNumericData::k2Short: - { - short s1, s2; - s = fnData.getData( s1, s2 ); - assert(s); - - V2iDataPtr data = new V2iData(); - data->writable().x = s1; - data->writable().y = s2; - - return data; - } - case MFnNumericData::k3Short: - { - short s1, s2, s3; - s = fnData.getData( s1, s2, s3 ); - assert(s); - - V3iDataPtr data = new V3iData(); - data->writable().x = s1; - data->writable().y = s2; - data->writable().z = s3; - - return data; - } - case MFnNumericData::k2Int: - { - int i1, i2; - s = fnData.getData( i1, i2 ); - assert(s); - - V2iDataPtr data = new V2iData(); - data->writable().x = i1; - data->writable().y = i2; - - return data; - } - case MFnNumericData::k3Int: - { - int i1, i2, i3; - s = fnData.getData( i1, i2, i3); - assert(s); - - V3iDataPtr data = new V3iData(); - data->writable().x = i1; - data->writable().y = i2; - data->writable().z = i3; - - return data; - } - case MFnNumericData::k2Float: - { - float f1, f2; - s = fnData.getData( f1, f2 ); - assert(s); - - V2fDataPtr data = new V2fData(); - data->writable().x = f1; - data->writable().y = f2; - - return data; - } - case MFnNumericData::k3Float: - { - float f1, f2, f3; - s = fnData.getData( f1, f2, f3 ); - assert(s); - - V3fDataPtr data = new V3fData(); - data->writable().x = f1; - data->writable().y = f2; - data->writable().z = f3; - - return data; - } - case MFnNumericData::k2Double: - { - double d1, d2; - s = fnData.getData( d1, d2 ); - assert(s); - - V2dDataPtr data = new V2dData(); - data->writable().x = d1; - data->writable().y = d2; - - return data; - } - case MFnNumericData::k3Double: - { - double d1, d2, d3; - s = fnData.getData( d1, d2, d3 ); - assert(s); - - V3dDataPtr data = new V3dData(); - data->writable().x = d1; - data->writable().y = d2; - data->writable().z = d3; - - return data; - } - case MFnNumericData::kDouble: - case MFnNumericData::kFloat: - case MFnNumericData::kInt: - case MFnNumericData::kBoolean: - case MFnNumericData::kByte: - case MFnNumericData::kChar: - case MFnNumericData::kShort: - default: - return 0; - } -} diff --git a/src/IECoreMaya/FromMayaNumericPlugConverter.cpp b/src/IECoreMaya/FromMayaNumericPlugConverter.cpp deleted file mode 100644 index 230a197ef5..0000000000 --- a/src/IECoreMaya/FromMayaNumericPlugConverter.cpp +++ /dev/null @@ -1,129 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaNumericPlugConverter.h" -#include "IECoreMaya/NumericTraits.h" - -#include "IECore/CompoundData.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/VectorTypedData.h" - -#include "maya/MFnNumericAttribute.h" - -#include "boost/type_traits/is_same.hpp" - - -using namespace IECore; -using namespace Imath; -using namespace boost; - -namespace IECoreMaya -{ - -template -FromMayaPlugConverter::Description > FromMayaNumericPlugConverter::m_description( NumericTraits::dataType(), T::staticTypeId(), is_same::value ); - -template -FromMayaNumericPlugConverter::FromMayaNumericPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ -} - -template -IECore::ObjectPtr FromMayaNumericPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - if (plug().isArray()) - { - int numElements = plug().numElements(); - MIntArray indiceList; - typedef TypedData > VecDataType; - typename VecDataType::Ptr data = new VecDataType(); - IntVectorData::Ptr indices = new IntVectorData(); - - auto &dataWritable = data->writable(); - auto &indicesWritable = indices->writable(); - dataWritable.reserve( numElements ); - indicesWritable.reserve( numElements ); - - for (int i =0; i < numElements; ++i) - { - MPlug childPlug = plug()[i]; - typename T::ValueType v; - childPlug.getValue(v); - dataWritable.push_back(v); - indicesWritable.push_back(childPlug.logicalIndex()); - } - - CompoundDataPtr outData = new CompoundData(); - outData->writable()["indices"] = indices; - outData->writable()["data"] = data; - return outData; - } - else - { - typename T::ValueType v; - plug().getValue( v ); - return new T( v ); - } -} - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterbb, FromMayaNumericPlugConverterbbTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterbi, FromMayaNumericPlugConverterbiTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterii, FromMayaNumericPlugConverteriiTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterif, FromMayaNumericPlugConverterifTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterid, FromMayaNumericPlugConverteridTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterfi, FromMayaNumericPlugConverterfiTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterff, FromMayaNumericPlugConverterffTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterfd, FromMayaNumericPlugConverterfdTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterdi, FromMayaNumericPlugConverterdiTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterdf, FromMayaNumericPlugConverterdfTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterdd, FromMayaNumericPlugConverterddTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaNumericPlugConverterss, FromMayaNumericPlugConverterssTypeId ) - -/// Explicit instantiations. -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; -template class FromMayaNumericPlugConverter; - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/FromMayaObjectConverter.cpp b/src/IECoreMaya/FromMayaObjectConverter.cpp deleted file mode 100644 index ea42addf44..0000000000 --- a/src/IECoreMaya/FromMayaObjectConverter.cpp +++ /dev/null @@ -1,267 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/FromMayaPlugConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/BlindDataHolder.h" -#include "IECore/MessageHandler.h" - -#include "maya/MFnDependencyNode.h" -#include "maya/MStringArray.h" -#include "maya/MFnAttribute.h" - -using namespace IECoreMaya; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaObjectConverter ); - -FromMayaObjectConverter::FromMayaObjectConverter( const std::string &description, const MObject &object ) - : FromMayaConverter( description ), m_objectHandle( object ) -{ - - StringParameter::PresetsContainer blindDataAttrPrefixPresets; - blindDataAttrPrefixPresets.push_back( StringParameter::Preset( "ie", "ie" ) ); - blindDataAttrPrefixPresets.push_back( StringParameter::Preset( "None", "" ) ); - m_blindDataAttrPrefixParameter = new StringParameter( - "blindDataAttrPrefix", - "Any attribute names beginning with this prefix will be added to the blindData dictionary on the converted object. " - "Note that this parameter is only valid if the object being converted is a node, and the converted object is capable " - "of holding the blind data. Empty string matches no attribute.", - "", // by default, no attributes are converted to blindData. - // \todo Consider creating a registration mechanism to override the default. - blindDataAttrPrefixPresets - ); - - m_blindDataRemoveNamespaceParameter = new BoolParameter( - "blindDataRemoveNamespace", - "In addition to converting attributes to blind data on the converted object, the node name is " - "saved as an additional piece of blind data. If this parameter is set, then the maya namespace " - "will be removed from the name before saving.", - true - ); - - parameters()->addParameter( m_blindDataAttrPrefixParameter ); - parameters()->addParameter( m_blindDataRemoveNamespaceParameter ); - -} - -///////////////////////////////////////////////////////////////////////////////// -// Object to convert -///////////////////////////////////////////////////////////////////////////////// - - -const MObject &FromMayaObjectConverter::object() const -{ - if( objectIsAlive() ) - { - return m_objectHandle.objectRef(); - } - return MObject::kNullObj; -} - -bool FromMayaObjectConverter::objectIsAlive() const -{ - return m_objectHandle.isAlive(); -} - -///////////////////////////////////////////////////////////////////////////////// -// Conversion -///////////////////////////////////////////////////////////////////////////////// - -IECore::ObjectPtr FromMayaObjectConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - if( !objectIsAlive() ) - { - return 0; - } - IECore::ObjectPtr converted = doConversion( object(), operands ); - addBlindData( object(), converted ); - return converted; -} - -void FromMayaObjectConverter::addBlindData( const MObject &object, IECore::ObjectPtr convertedObject ) const -{ - IECore::BlindDataHolderPtr blindDataHolder = IECore::runTimeCast( convertedObject ); - if( !blindDataHolder ) - { - return; - } - - MFnDependencyNode fnNode( object ); - if( !fnNode.hasObj( object ) ) - { - return; - } - - CompoundDataMap &blindData = blindDataHolder->blindData()->writable(); - - MString blindPrefix = m_blindDataAttrPrefixParameter->getTypedValue().c_str(); - bool ignoreNamespace = m_blindDataRemoveNamespaceParameter->getTypedValue(); - - unsigned int n = fnNode.attributeCount(); - std::string objectName; - objectName = fnNode.name().asChar(); - - // eliminate namespace from name... - if ( ignoreNamespace ) - { - MStringArray parts; - if ( fnNode.name().split( ':', parts ) ) - { - objectName = parts[ parts.length() - 1 ].asChar(); - } - } - blindData[ "name" ] = new StringData( objectName ); - - if (blindPrefix == "") - { - // empty string matches no attributes. - return; - } - - for( unsigned int i=0; i blindPrefix.length() && attrName.substring( 0, blindPrefix.length()-1 )==blindPrefix ) - { - MPlug plug = fnNode.findPlug( attr, false ); - if( !plug.parent().isNull() ) - { - continue; // we don't want to pick up the children of compound numeric attributes - } - MString plugName = plug.name(); - - // find a converter for the plug - FromMayaConverterPtr converter = FromMayaPlugConverter::create( plug ); - - // run the conversion and check we've got data as a result - DataPtr data = 0; - if( converter ) - { - data = runTimeCast( converter->convert() ); - } - if( !data ) - { - msg( Msg::Warning, "FromMayaRenderableConverterUtil::addBlindDataAttributes", boost::format( "Attribute \"%s\" could not be converted to Data." ) % plugName.asChar() ); - continue; - } - blindData[ attrName.asChar() ] = data; - } - } - - -} - -///////////////////////////////////////////////////////////////////////////////// -// Parameters -///////////////////////////////////////////////////////////////////////////////// - -IECore::StringParameterPtr FromMayaObjectConverter::blindDataAttrPrefixParameter() -{ - return m_blindDataAttrPrefixParameter; -} - -IECore::ConstStringParameterPtr FromMayaObjectConverter::blindDataAttrPrefixParameter() const -{ - return m_blindDataAttrPrefixParameter; -} - -IECore::BoolParameterPtr FromMayaObjectConverter::blindDataRemoveNamespaceParameter() -{ - return m_blindDataRemoveNamespaceParameter; -} -IECore::ConstBoolParameterPtr FromMayaObjectConverter::blindDataRemoveNamespaceParameter() const -{ - return m_blindDataRemoveNamespaceParameter; -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -FromMayaObjectConverterPtr FromMayaObjectConverter::create( const MObject &object, IECore::TypeId resultType ) -{ - const TypesToFnsMap &m = typesToFns(); - - TypesToFnsMap::const_iterator it = m.find( Types( object.apiType(), resultType ) ); - if( it!=m.end() ) - { - return it->second( object ); - } - - // if not then see if the default converter is suitable - DefaultConvertersMap &dc = defaultConverters(); - DefaultConvertersMap::const_iterator dcIt = dc.find( object.apiType() ); - if( dcIt != dc.end() ) - { - // we only use the default converter if no result type has been specified, or if the requested type is a base class - // of the type the default converter will create. - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( object ); - } - } - - return 0; -} - -void FromMayaObjectConverter::registerConverter( const MFn::Type fromType, IECore::TypeId resultType, bool defaultConversion, CreatorFn creator ) -{ - TypesToFnsMap &m = typesToFns(); - TypesToFnsMap::const_iterator it = m.insert( TypesToFnsMap::value_type( Types( fromType, resultType), creator ) ).first; - if( defaultConversion ) - { - DefaultConvertersMap &dc = defaultConverters(); - if( ! dc.insert( DefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaObjectConverter::registerConverter", boost::format( "Default conversion for MFn::Type %d already registered - ignoring second registration." ) % fromType ); - } - } -} - -FromMayaObjectConverter::TypesToFnsMap &FromMayaObjectConverter::typesToFns() -{ - static TypesToFnsMap m; - return m; -} - -FromMayaObjectConverter::DefaultConvertersMap &FromMayaObjectConverter::defaultConverters() -{ - static DefaultConvertersMap m; - return m; -} diff --git a/src/IECoreMaya/FromMayaObjectDataConverter.cpp b/src/IECoreMaya/FromMayaObjectDataConverter.cpp deleted file mode 100644 index bf66b5b3eb..0000000000 --- a/src/IECoreMaya/FromMayaObjectDataConverter.cpp +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaObjectDataConverter.h" -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ObjectData.h" - -#include "maya/MFnPluginData.h" - -using namespace IECoreMaya; -using namespace IECore; - -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaObjectDataConverter::g_description( MFn::kPluginData, Object::staticTypeId(), true ); - -FromMayaObjectDataConverter::FromMayaObjectDataConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts IECoreMaya::ObjectData to an IECore::Object.", object ) -{ -} - -ObjectPtr FromMayaObjectDataConverter::doConversion( const MObject &obj, ConstCompoundObjectPtr operands ) const -{ - MStatus s; - MFnPluginData fnPluginData( obj, &s ); - if ( !s ) - { - return 0; - } - - /// If we ever support more than one type of data, we can handle them here. - const ObjectData *objectData = dynamic_cast< const ObjectData * >( fnPluginData.data( &s ) ); - if ( !objectData || !s ) - { - return 0; - } - - ConstObjectPtr object = objectData->getObject(); - if ( !object ) - { - return 0; - } - - assert( object ); - return object->copy(); -} diff --git a/src/IECoreMaya/FromMayaParticleConverter.cpp b/src/IECoreMaya/FromMayaParticleConverter.cpp deleted file mode 100644 index 4545d26da2..0000000000 --- a/src/IECoreMaya/FromMayaParticleConverter.cpp +++ /dev/null @@ -1,352 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/format.hpp" - -#include "IECoreMaya/FromMayaParticleConverter.h" -#include "IECoreMaya/MArrayIter.h" -#include "IECoreMaya/VectorTraits.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/VectorOps.h" -#include "IECore/Exception.h" -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECoreScene/PointsPrimitive.h" - -#include "IECore/AngleConversion.h" - -#include "maya/MFnParticleSystem.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MPlug.h" -#if MAYA_API_VERSION >= 201800 -#include "maya/MDGContextGuard.h" -#endif - -#include "boost/algorithm/string/split.hpp" -#include "boost/algorithm/string/classification.hpp" - -#include - -using namespace IECoreMaya; -using namespace Imath; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaParticleConverter ); - -IECoreMaya::FromMayaShapeConverter::Description FromMayaParticleConverter::m_kNParticleDescription( MFn::kNParticle, IECoreScene::PointsPrimitive::staticTypeId(), true ); -IECoreMaya::FromMayaShapeConverter::Description FromMayaParticleConverter::m_kParticleDescription( MFn::kParticle, IECoreScene::PointsPrimitive::staticTypeId(), true ); - -FromMayaParticleConverter::FromMayaParticleConverter( const MObject &object ) - : FromMayaShapeConverter( "Converts Maya particle shapes into IECoreScene::PointsPrimitive objects.", object ) -{ - constructCommon(); -} - -FromMayaParticleConverter::FromMayaParticleConverter( const MDagPath &dagPath ) - : FromMayaShapeConverter( "Converts Maya particle shapes into IECoreScene::PointsPrimitive objects.", dagPath ) -{ - constructCommon(); -} - -void FromMayaParticleConverter::constructCommon() -{ - - IECore::StringVectorDataPtr attributeNamesDefaultData = new IECore::StringVectorData(); - IECore::StringVectorData::ValueType &attributeNames = attributeNamesDefaultData->writable(); - - // add all Maya default per-particle attributes - attributeNames.push_back( "position=P" ); - attributeNames.push_back( "velocity" ); - attributeNames.push_back( "age" ); - attributeNames.push_back( "mass" ); - attributeNames.push_back( "acceleration" ); - - m_attributeNamesParameter = new IECore::StringVectorParameter( - "attributeNames", - "The per-particle attribute names to be added as primitive variables to the PointsPrimitive. " - "The \"position\" attribute is always added as \"P\" so there is no need to specify it again here", - attributeNamesDefaultData - /// \todo Add presets - ); - - parameters()->addParameter( m_attributeNamesParameter ); -} - -IECore::StringVectorParameterPtr FromMayaParticleConverter::attributeNamesParameter() -{ - return m_attributeNamesParameter; -} - -IECore::ConstStringVectorParameterPtr FromMayaParticleConverter::attributeNamesParameter() const -{ - return m_attributeNamesParameter; -} - -IECoreScene::PrimitivePtr FromMayaParticleConverter::doPrimitiveConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnParticleSystem fnParticle( object ); - if( !fnParticle.hasObj( object ) ) - { - throw IECore::InvalidArgumentException( boost::str( boost::format( "FromMayaParticleConverter::doPrimitiveConversion : '%s' is not a particle shape.") % MFnDependencyNode( object ).name().asChar() ) ); - } - return doPrimitiveConversion( fnParticle ); -} - -IECoreScene::PrimitivePtr FromMayaParticleConverter::doPrimitiveConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MFnParticleSystem fnParticle( dagPath ); - if( !fnParticle.hasObj( dagPath.node() ) ) - { - throw IECore::InvalidArgumentException( boost::str( boost::format( "FromMayaParticleConverter::doPrimitiveConversion : '%s' is not a particle shape.") % dagPath.partialPathName().asChar() ) ); - } - return doPrimitiveConversion( fnParticle ); -} - -IECoreScene::PrimitivePtr FromMayaParticleConverter::doPrimitiveConversion( MFnParticleSystem &fnParticle ) const -{ - MStatus s; - IECoreScene::PointsPrimitivePtr points = new IECoreScene::PointsPrimitive( fnParticle.count( ) ); - - MPlug particleRenderTypePlug = fnParticle.findPlug( "particleRenderType", false, &s ); - if ( s ) - { - std::string renderTypeValue; - int particleRenderType = particleRenderTypePlug.asInt( &s ); - switch ( particleRenderType ) - { - case 3 : // points - { - renderTypeValue = "disk"; - break; - } - case 4 : // spheres - { - renderTypeValue = "sphere"; - break; - } - case 5 : // sprites - { - renderTypeValue = "patch"; - break; - } - default : - { - renderTypeValue = "disk"; - break; - } - } - - points->variables[ "type" ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Constant, new IECore::StringData( renderTypeValue ) ); - } - - const IECore::StringVectorParameter::ValueType &attributeNames = attributeNamesParameter()->getTypedValue(); - - IECore::StringVectorParameter::ValueType allAttributeNames = attributeNames; - - MPlug particleAttributePlugs = fnParticle.findPlug( "ieParticleAttributes", false, &s ); - - if ( s ) - { - MString particleAttributes; - -#if MAYA_API_VERSION >= 201800 - { - MDGContextGuard ctxGuard( MDGContext::fsNormal ); - particleAttributes = particleAttributePlugs.asString( &s ); - } -#else - particleAttributes = particleAttributePlugs.asString(MDGContext::fsNormal, &s); -#endif - - if ( s ) - { - std::string strParticleAttributes( particleAttributes.asChar() ); - std::vector additionalAttributeNames; - boost::split( additionalAttributeNames, strParticleAttributes, boost::is_any_of( ",: " ) ); - - allAttributeNames.insert( allAttributeNames.end(), - additionalAttributeNames.begin(), - additionalAttributeNames.end() - ); - } - else - { - IECore::msg( - IECore::Msg::Warning, - "FromMayaParticleConverter::doPrimitiveConversion", - boost::format( "Attribute 'ieParticleAttributes' must be string" ) - ); - } - } - - bool usesConstantColor = false; - if ( fnParticle.hasAttribute( "colorInput" ) ) - { - usesConstantColor = true ? fnParticle.findPlug( "colorInput" ).asInt() == 0: false; - } - - for ( IECore::StringVectorParameter::ValueType::const_iterator it = allAttributeNames.begin(); it != allAttributeNames.end(); ++it ) - { - MString attrName = it->c_str(); - std::string primVarName = it->c_str(); - - // check if primvar name should be remapped - std::vector primVarMapping; - boost::split( primVarMapping, primVarName, boost::is_any_of( "=" ) ); - if ( primVarMapping.size() == 2 ) - { - attrName = primVarMapping[ 0 ].c_str(); - primVarName = primVarMapping[ 1 ].c_str(); - } - - if ( fnParticle.isPerParticleIntAttribute( attrName, &s ) ) - { - assert( s ); - MIntArray arr; - unsigned int len = fnParticle.getPerParticleAttribute( attrName, arr, &s ); - assert( len == fnParticle.count() ); - - IECore::IntVectorDataPtr data = new IECore::IntVectorData(); - data->writable().resize( len ); - data->writable().assign( MArrayIter::begin( arr ), MArrayIter::end( arr ) ); - points->variables[ primVarName ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Vertex, data ); - } - else if ( fnParticle.isPerParticleDoubleAttribute( attrName, &s ) ) - { - assert( s ); - MDoubleArray arr; - unsigned int len = fnParticle.getPerParticleAttribute( attrName, arr, &s ); - assert( len == fnParticle.count() ); - - IECore::FloatVectorDataPtr data = new IECore::FloatVectorData(); - data->writable().resize( len ); - if ( attrName == MString("radiusPP") && primVarName == "width" ) - { - // convert radius to width (as used in Cortex / Gaffer) - std::vector &dataVector = data->writable(); - for ( unsigned int i = 0; i < len; i++ ) - { - dataVector[i] = arr[i] * 2.0f; - } - } - else - { - data->writable().assign( MArrayIter::begin( arr ), MArrayIter::end( arr ) ); - } - - points->variables[ primVarName ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Vertex, data ); - } - else if ( attrName == MString( "rgbPP" ) && ( !fnParticle.isPerParticleVectorAttribute( attrName, &s ) || usesConstantColor ) ) - { - // if there is no RGB per-particle attribute or constant color is used, write a constant primvar instead - if ( fnParticle.hasAttribute( "colorRed" ) && fnParticle.hasAttribute( "colorGreen" ) && fnParticle.hasAttribute( "colorBlue" ) ) - { - float r = (float) fnParticle.findPlug( "colorRed" ).asDouble(); - float g = (float) fnParticle.findPlug( "colorGreen" ).asDouble(); - float b = (float) fnParticle.findPlug( "colorBlue" ).asDouble(); - - IECore::Color3fDataPtr data = new IECore::Color3fData( { r, g, b } ); - points->variables[ primVarName ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Constant, data ); - } - else - { - IECore::msg( IECore::Msg::Warning, "FromMayaParticleConverter", boost::format( "Node \"%s\", does not have per-particle or per-object color attributes." ) % fnParticle.name().asChar() ); - } - } - else if ( fnParticle.isPerParticleVectorAttribute( attrName, &s ) ) - { - assert( s ); - MVectorArray arr; - unsigned int len = fnParticle.getPerParticleAttribute( attrName, arr, &s ); - assert( len == fnParticle.count() ); - - if ( attrName == MString( "rotationPP" ) && primVarName == "orientation" ) - { - // get euler data and convert to quaternion - IECore::V3fVectorDataPtr eulerData = new IECore::V3fVectorData(); - eulerData->writable().resize( len ); - std::transform( MArrayIter::begin( arr ), MArrayIter::end( arr ), eulerData->writable().begin(), IECore::VecConvert() ); - - auto &readableEulerData = eulerData->readable(); - - IECore::QuatfVectorDataPtr quatData = new IECore::QuatfVectorData(); - auto &writableQuatData = quatData->writable(); - - writableQuatData.reserve( readableEulerData.size() ); - - for( const auto& rotation : readableEulerData ) - { - float x = IECore::degreesToRadians( rotation.x ); - float y = IECore::degreesToRadians( rotation.y ); - float z = IECore::degreesToRadians( rotation.z ); - - Imath::Eulerf euler( x, y, z, Imath::Eulerf::Default ); - writableQuatData.push_back( euler.toQuat() ); - } - - points->variables[ primVarName ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Vertex, quatData ); - } - else - { - IECore::V3fVectorDataPtr data = new IECore::V3fVectorData(); - if ( primVarName == "P" ) - { - data->setInterpretation( IECore::GeometricData::Point ); - } - else if ( attrName == MString( "rgbPP" ) ) - { - data->setInterpretation( IECore::GeometricData::Color ); - } - else - { - data->setInterpretation( IECore::GeometricData::Vector ); - } - - data->writable().resize( len ); - std::transform( MArrayIter::begin( arr ), MArrayIter::end( arr ), data->writable().begin(), IECore::VecConvert() ); - points->variables[ primVarName ] = IECoreScene::PrimitiveVariable( IECoreScene::PrimitiveVariable::Vertex, data ); - } - - - } - else if ( attrName.length() > 1 ) - { - IECore::msg( IECore::Msg::Warning, "FromMayaParticleConverter", boost::format( "Ignoring attribute \"%s\", which is not a valid per-particle attribute" ) % attrName.asChar() ); - } - - } - - assert( points->arePrimitiveVariablesValid() ); - return points; -} diff --git a/src/IECoreMaya/FromMayaPlugConverter.cpp b/src/IECoreMaya/FromMayaPlugConverter.cpp deleted file mode 100644 index f5b36b759f..0000000000 --- a/src/IECoreMaya/FromMayaPlugConverter.cpp +++ /dev/null @@ -1,242 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MFnAttribute.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnUnitAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnEnumAttribute.h" - -#include "IECore/MessageHandler.h" - -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/FromMayaEnumPlugConverter.h" -#include "IECoreMaya/FromMayaPlugConverter.h" - -using namespace IECoreMaya; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaPlugConverter ); - -FromMayaPlugConverter::FromMayaPlugConverter( const MPlug &plug ) - : FromMayaConverter( "Converts the value held in a maya plug." ), m_plug( plug ) -{ -} - -const MPlug &FromMayaPlugConverter::plug() const -{ - return m_plug; -} - -FromMayaPlugConverter::NumericTypesToFnsMap &FromMayaPlugConverter::numericTypesToFns() -{ - static NumericTypesToFnsMap m; - return m; -} - -FromMayaPlugConverter::NumericDefaultConvertersMap &FromMayaPlugConverter::numericDefaultConverters() -{ - static NumericDefaultConvertersMap m; - return m; -} - -void FromMayaPlugConverter::registerConverter( const MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ) -{ - NumericTypesToFnsMap &m = numericTypesToFns(); - NumericTypesToFnsMap::const_iterator it = m.insert( NumericTypesToFnsMap::value_type( NumericTypePair( fromType, resultType ), creator ) ).first; - if( isDefaultConverter ) - { - NumericDefaultConvertersMap &dc = numericDefaultConverters(); - if( ! dc.insert( NumericDefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaPlugConverter::registerConverter", boost::format( "Default conversion for MFnNumericData::Type %d already registered - ignoring second registration." ) % fromType ); - } - } -} - -FromMayaPlugConverter::TypedTypesToFnsMap &FromMayaPlugConverter::typedTypesToFns() -{ - static TypedTypesToFnsMap m; - return m; -} - -FromMayaPlugConverter::TypedDefaultConvertersMap &FromMayaPlugConverter::typedDefaultConverters() -{ - static TypedDefaultConvertersMap m; - return m; -} - -void FromMayaPlugConverter::registerConverter( const MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ) -{ - TypedTypesToFnsMap &m = typedTypesToFns(); - TypedTypesToFnsMap::const_iterator it = m.insert( TypedTypesToFnsMap::value_type( TypedTypePair( fromType, resultType ), creator ) ).first; - if( isDefaultConverter ) - { - TypedDefaultConvertersMap &dc = typedDefaultConverters(); - if( ! dc.insert( TypedDefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaPlugConverter::registerConverter", boost::format( "Default conversion for MFnData::Type %d already registered - ignoring second registration." ) % fromType ); - } - } -} - -FromMayaPlugConverter::UnitTypesToFnsMap &FromMayaPlugConverter::unitTypesToFns() -{ - static UnitTypesToFnsMap m; - return m; -} - -FromMayaPlugConverter::UnitDefaultConvertersMap &FromMayaPlugConverter::unitDefaultConverters() -{ - static UnitDefaultConvertersMap m; - return m; -} - -void FromMayaPlugConverter::registerConverter( const MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator ) -{ - UnitTypesToFnsMap &m = unitTypesToFns(); - UnitTypesToFnsMap::const_iterator it = m.insert(UnitTypesToFnsMap::value_type( UnitTypePair( fromType, resultType ), creator ) ).first; - if( isDefaultConverter ) - { - UnitDefaultConvertersMap &dc = unitDefaultConverters(); - if( ! dc.insert( UnitDefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaPlugConverter::registerConverter", boost::format( "Default conversion for MFnUnitAttribute::Type %d already registered - ignoring second registration." ) % fromType ); - } - } -} - -FromMayaConverterPtr FromMayaPlugConverter::create( const MPlug &plug, IECore::TypeId resultType ) -{ - MObject attribute = plug.attribute(); - - if( attribute.hasFn( MFn::kUnitAttribute ) ) - { - MFnUnitAttribute fnUAttr( attribute ); - const UnitTypesToFnsMap &m = unitTypesToFns(); - UnitTypesToFnsMap::const_iterator it = m.find( UnitTypePair( fnUAttr.unitType(), resultType ) ); - if( it!=m.end() ) - { - return it->second( plug ); - } - - UnitDefaultConvertersMap &dc = unitDefaultConverters(); - UnitDefaultConvertersMap::const_iterator dcIt = dc.find( fnUAttr.unitType() ); - if( dcIt != dc.end() ) - { - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( plug ); - } - } - } - - if( attribute.hasFn( MFn::kNumericAttribute ) ) - { - MFnNumericAttribute fnNAttr( attribute ); - const NumericTypesToFnsMap &m = numericTypesToFns(); - - if( fnNAttr.isUsedAsColor() ) - { - NumericTypesToFnsMap::const_iterator it = m.find( NumericTypePair( fnNAttr.unitType(), IECore::Color3fDataTypeId ) ); - if( it!=m.end() ) - { - return it->second( plug ); - } - } - - NumericTypesToFnsMap::const_iterator it = m.find( NumericTypePair( fnNAttr.unitType(), resultType ) ); - if( it!=m.end() ) - { - return it->second( plug ); - } - - NumericDefaultConvertersMap &dc = numericDefaultConverters(); - NumericDefaultConvertersMap::const_iterator dcIt = dc.find( fnNAttr.unitType() ); - if( dcIt != dc.end() ) - { - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( plug ); - } - } - } - - if( attribute.hasFn( MFn::kTypedAttribute ) ) - { - MFnTypedAttribute fnTAttr( attribute ); - const TypedTypesToFnsMap &m = typedTypesToFns(); - TypedTypesToFnsMap::const_iterator it = m.find( TypedTypePair( fnTAttr.attrType(), resultType ) ); - if( it!=m.end() ) - { - return it->second( plug ); - } - - TypedDefaultConvertersMap &dc = typedDefaultConverters(); - TypedDefaultConvertersMap::const_iterator dcIt = dc.find( fnTAttr.attrType() ); - if( dcIt != dc.end() ) - { - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( plug ); - } - } - } - if( attribute.hasFn( MFn::kEnumAttribute ) ) - { - MFnEnumAttribute fnEAttr( attribute ); - if ( resultType == IECore::TypeId::StringDataTypeId || ( resultType == IECore::InvalidTypeId && fnEAttr.hasCategory( FromMayaEnumPlugConverter::convertToStringCategory ) ) ) - { - return new FromMayaEnumPlugConverter( plug ); - } - else - { - return new FromMayaEnumPlugConverter( plug ); - } - } - - MObject o; - plug.getValue( o ); - if( resultType==IECore::InvalidTypeId ) - { - return FromMayaObjectConverter::create( o ); - } - else - { - return FromMayaObjectConverter::create( o, resultType ); - } -} - diff --git a/src/IECoreMaya/FromMayaPluginDataPlugConverter.cpp b/src/IECoreMaya/FromMayaPluginDataPlugConverter.cpp deleted file mode 100644 index b30eb2f46f..0000000000 --- a/src/IECoreMaya/FromMayaPluginDataPlugConverter.cpp +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MFnPluginData.h" - -#include "IECoreMaya/FromMayaPluginDataPlugConverter.h" -#include "IECoreMaya/FromMayaObjectDataConverter.h" - -using namespace IECoreMaya; -using namespace IECore; - -FromMayaPlugConverter::Description FromMayaPluginDataPlugConverter::m_description( MFnData::kPlugin, Object::staticTypeId(), true ); - -FromMayaPluginDataPlugConverter::FromMayaPluginDataPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ -} - -IECore::ObjectPtr FromMayaPluginDataPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - assert( operands ); - - MStatus s; - MObject data; - s = plug().getValue( data ); - if ( !s ) - { - return 0; - } - - FromMayaObjectConverterPtr c = FromMayaObjectConverter::create( data ); - if ( !c ) - { - return 0; - } - - return c->convert(); -} diff --git a/src/IECoreMaya/FromMayaShapeConverter.cpp b/src/IECoreMaya/FromMayaShapeConverter.cpp deleted file mode 100644 index 08657ead70..0000000000 --- a/src/IECoreMaya/FromMayaShapeConverter.cpp +++ /dev/null @@ -1,311 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaShapeConverter.h" -#include "IECoreMaya/FromMayaPlugConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/DespatchTypedData.h" -#include "IECoreScene/Primitive.h" - -#include "maya/MFnDependencyNode.h" -#include "maya/MFnAttribute.h" - -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaShapeConverter ); - -FromMayaShapeConverter::FromMayaShapeConverter( const std::string &description, const MObject &object ) - : FromMayaObjectConverter( description, object ) -{ - constructCommon(); -} - -FromMayaShapeConverter::FromMayaShapeConverter( const std::string &description, const MDagPath &dagPath ) - : FromMayaObjectConverter( description, dagPath.node() ), m_dagPath( dagPath ) -{ - constructCommon(); -} - -void FromMayaShapeConverter::constructCommon() -{ - IECore::IntParameter::PresetsContainer spacePresets; - spacePresets.push_back( IECore::IntParameter::Preset( "Object", Object ) ); - spacePresets.push_back( IECore::IntParameter::Preset( "World", World ) ); - m_spaceParameter = new IECore::IntParameter( - "space", - "The space in which the object is exported.", - Object, - Object, - World, - spacePresets, - true - ); - - parameters()->addParameter( m_spaceParameter ); -} - -IECore::IntParameterPtr FromMayaShapeConverter::spaceParameter() -{ - return m_spaceParameter; -} - -IECore::ConstIntParameterPtr FromMayaShapeConverter::spaceParameter() const -{ - return m_spaceParameter; -} - -IECore::ObjectPtr FromMayaShapeConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - IECoreScene::PrimitivePtr p = 0; - - const MDagPath *d = dagPath( true ); - if( d ) - { - p = doPrimitiveConversion( *d, operands ); - } - else - { - p = doPrimitiveConversion( object, operands ); - } - if( p ) - { - addPrimVars( object, p ); - } - return p; -} - -void FromMayaShapeConverter::addPrimVars( const MObject &object, IECoreScene::PrimitivePtr primitive ) const -{ - MFnDependencyNode fnNode( object ); - if( !fnNode.hasObj( object ) ) - { - return; - } - - MString prefix = "iePrimVar"; - unsigned int n = fnNode.attributeCount(); - for( unsigned int i=0; i prefix.length() ) - { - MPlug plug = fnNode.findPlug( attr, false ); - if( !plug.parent().isNull() ) - { - continue; // we don't want to pick up the children of compound numeric attributes - } - MString plugName = plug.name(); - - // find a converter for the plug, asking for conversion to float types by preference - FromMayaConverterPtr converter = FromMayaPlugConverter::create( plug, IECore::FloatDataTypeId ); - if( !converter ) - { - converter = FromMayaPlugConverter::create( plug, IECore::V3fDataTypeId ); - } - if( !converter ) - { - converter = FromMayaPlugConverter::create( plug, IECore::V3fVectorDataTypeId ); - } - if( !converter ) - { - converter = FromMayaPlugConverter::create( plug, IECore::FloatVectorDataTypeId ); - } - if( !converter ) - { - converter = FromMayaPlugConverter::create( plug ); - } - - // run the conversion and check we've got data as a result - IECore::DataPtr data = 0; - if( converter ) - { - data = IECore::runTimeCast( converter->convert() ); - } - if( !data ) - { - IECore::msg( IECore::Msg::Warning, "FromMayaShapeConverter::addPrimVars", boost::format( "Attribute \"%s\" could not be converted to Data." ) % plugName.asChar() ); - continue; - } - - // convert V3fData to Color3fData if attribute has usedAsColor() set. - if( IECore::V3fDataPtr vData = IECore::runTimeCast( data ) ) - { - if( fnAttr.isUsedAsColor() ) - { - Imath::V3f v = vData->readable(); - data = new IECore::Color3fData( Imath::Color3f( v.x, v.y, v.z ) ); - } - } - - // see if interpolation has been specified, and find primitive variable name - std::string primVarName = attrName.asChar() + prefix.length(); - IECoreScene::PrimitiveVariable::Interpolation interpolation = IECoreScene::PrimitiveVariable::Invalid; - if( attrName.length()>prefix.length()+3 ) - { - const char *c = attrName.asChar(); - if( c[prefix.length()]=='_' && c[prefix.length()+2]=='_' ) - { - char t = c[prefix.length()+1]; - primVarName = attrName.asChar() + prefix.length() + 3; - switch( t ) - { - case 'C' : - interpolation = IECoreScene::PrimitiveVariable::Constant; - break; - case 'U' : - interpolation = IECoreScene::PrimitiveVariable::Uniform; - break; - case 'V' : - interpolation = IECoreScene::PrimitiveVariable::Vertex; - break; - case 'Y' : - interpolation = IECoreScene::PrimitiveVariable::Varying; - break; - case 'F' : - interpolation = IECoreScene::PrimitiveVariable::FaceVarying; - break; - default : - IECore::msg( IECore::Msg::Warning, "FromMayaShapeConverter::addPrimVars", boost::format( "Attribute \"%s\" has unknown interpolation - guessing interpolation." ) % plugName.asChar() ); - break; - } - } - } - - // guess interpolation if not specified - if( interpolation==IECoreScene::PrimitiveVariable::Invalid ) - { - interpolation = primitive->inferInterpolation( data.get() ); - } - - if( interpolation==IECoreScene::PrimitiveVariable::Invalid ) - { - IECore::msg( IECore::Msg::Warning, "FromMayaShapeConverter::addPrimVars", boost::format( "Attribute \"%s\" has unsuitable size." ) % plugName.asChar() ); - continue; - } - - // finally add the primvar - primitive->variables[primVarName] = IECoreScene::PrimitiveVariable( interpolation, data ); - - } - } - - -} - -MSpace::Space FromMayaShapeConverter::space() const -{ - Space s = (Space)m_spaceParameter->getNumericValue(); - switch( s ) - { - case Object : - return MSpace::kObject; - case World : - return MSpace::kWorld; - } - assert( 0 ); // should never get here - return MSpace::kObject; -} - -const MDagPath *FromMayaShapeConverter::dagPath( bool emitSpaceWarnings ) const -{ - if( m_dagPath.isValid() ) - { - return &m_dagPath; - } - - if( emitSpaceWarnings && !object().hasFn( MFn::kData ) && space()==MSpace::kWorld ) - { - IECore::msg( IECore::Msg::Warning, "FromMayaShapeConverter", "World space requested but no dag path provided." ); - } - - return 0; -} - -FromMayaShapeConverterPtr FromMayaShapeConverter::create( const MDagPath &dagPath, IECore::TypeId resultType ) -{ - const ShapeTypesToFnsMap &m = shapeTypesToFns(); - - // see if there's a specific converter for us - ShapeTypesToFnsMap::const_iterator it = m.find( ShapeTypes( dagPath.apiType(), resultType ) ); - if( it != m.end() ) - { - return it->second( dagPath ); - } - - // if not then see if the default converter is suitable - DefaultConvertersMap &dc = defaultConverters(); - DefaultConvertersMap::const_iterator dcIt = dc.find( dagPath.apiType() ); - if( dcIt != dc.end() ) - { - // we only use the default converter if no result type has been specified, or if the requested type is a base class - // of the type the default converter will create. - if( resultType==IECore::InvalidTypeId || RunTimeTyped::inheritsFrom( dcIt->second->first.second, resultType ) ) - { - return dcIt->second->second( dagPath ); - } - } - - return 0; -} - -void FromMayaShapeConverter::registerShapeConverter( const MFn::Type fromType, IECore::TypeId resultType, bool defaultConverter, ShapeCreatorFn creator ) -{ - ShapeTypesToFnsMap &m = shapeTypesToFns(); - ShapeTypesToFnsMap::const_iterator it = m.insert( ShapeTypesToFnsMap::value_type( ShapeTypes( fromType, resultType ), creator ) ).first; - if( defaultConverter ) - { - DefaultConvertersMap &dc = defaultConverters(); - if( ! dc.insert( DefaultConvertersMap::value_type( fromType, it ) ).second ) - { - IECore::msg( IECore::Msg::Error, "FromMayaShapeConverter::registerShapeConverter", boost::format( "Default conversion for MFn::Type %d already registered - ignoring second registration." ) % fromType ); - } - } -} - -FromMayaShapeConverter::ShapeTypesToFnsMap &FromMayaShapeConverter::shapeTypesToFns() -{ - static ShapeTypesToFnsMap m; - return m; -} - -FromMayaShapeConverter::DefaultConvertersMap &FromMayaShapeConverter::defaultConverters() -{ - static DefaultConvertersMap m; - return m; -} - diff --git a/src/IECoreMaya/FromMayaSkinClusterConverter.cpp b/src/IECoreMaya/FromMayaSkinClusterConverter.cpp deleted file mode 100644 index c4922502f6..0000000000 --- a/src/IECoreMaya/FromMayaSkinClusterConverter.cpp +++ /dev/null @@ -1,179 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2012, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaSkinClusterConverter.h" -#include "IECoreMaya/FromMayaSkinClusterWeightsConverter.h" -#include "IECoreMaya/Convert.h" -#include "IECore/Exception.h" -#include "IECore/DataConvert.h" -#include "IECore/ScaledDataConversion.h" -#include "IECore/MessageHandler.h" -#include "IECore/CompoundData.h" -#include "IECore/CompoundParameter.h" -#include "IECoreScene/SmoothSkinningData.h" - -#include "maya/MFnSkinCluster.h" -#include "maya/MFnDagNode.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnMatrixData.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPath.h" -#include "maya/MDagPathArray.h" -#include "maya/MObjectArray.h" -#include "maya/MItGeometry.h" -#include "maya/MPlug.h" - -using namespace IECoreMaya; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaSkinClusterConverter ); - -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaSkinClusterConverter::m_description( MFn::kSkinClusterFilter, IECoreScene::SmoothSkinningData::staticTypeId(), true ); - -FromMayaSkinClusterConverter::FromMayaSkinClusterConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts data on skinCluster nodes.into SmoothSkinningData", object ) -{ - IECore::IntParameter::PresetsContainer influenceNamePresets; - influenceNamePresets.push_back( IECore::IntParameter::Preset( "Partial", Partial ) ); - influenceNamePresets.push_back( IECore::IntParameter::Preset( "Full", Full ) ); - - m_influenceNameParameter = new IECore::IntParameter( - "influenceName", - "Will the influence names contain the partial or full dag path.", - Partial, - Partial, - Full, - influenceNamePresets, - true - ); - - parameters()->addParameter( m_influenceNameParameter ); -} - -IECore::IntParameterPtr FromMayaSkinClusterConverter::influenceNameParameter() -{ - return m_influenceNameParameter; -} - -IECore::ConstIntParameterPtr FromMayaSkinClusterConverter::influenceNameParameter() const -{ - return m_influenceNameParameter; -} - -IECore::ObjectPtr FromMayaSkinClusterConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus stat; - - // our data storage objects - IECore::StringVectorDataPtr influenceNamesData = new IECore::StringVectorData(); - IECore::M44fVectorDataPtr influencePoseData = new IECore::M44fVectorData(); - IECore::IntVectorDataPtr pointIndexOffsetsData = new IECore::IntVectorData(); - IECore::IntVectorDataPtr pointInfluenceCountsData = new IECore::IntVectorData(); - IECore::IntVectorDataPtr pointInfluenceIndicesData = new IECore::IntVectorData(); - IECore::FloatVectorDataPtr pointInfluenceWeightsData = new IECore::FloatVectorData(); - auto &influenceNamesDataW = influenceNamesData->writable(); - auto &influencePoseDataW = influencePoseData->writable(); - - // get a skin cluster fn - MFnSkinCluster skinClusterFn(object); - - MDagPathArray influencePaths; - skinClusterFn.influenceObjects(influencePaths); - - // get the influence names - int influencesCount = influencePaths.length(); - influenceNamesDataW.reserve( influencesCount ); - - InfluenceName in = (InfluenceName)m_influenceNameParameter->getNumericValue(); - switch( in ) - { - case Partial : - { - for (int i=0; i < influencesCount; i++) - { - influenceNamesDataW.push_back( influencePaths[i].partialPathName(&stat).asChar() ); - } - break; - } - case Full : - { - for (int i=0; i < influencesCount; i++) - { - influenceNamesDataW.push_back( influencePaths[i].fullPathName(&stat).asChar() ); - } - break; - } - } - - // extract bind pose - MFnDependencyNode skinClusterNodeFn( object ); - - MPlug bindPreMatrixArrayPlug = skinClusterNodeFn.findPlug( "bindPreMatrix", false, &stat ); - - for (int i=0; i < influencesCount; i++) - { - MPlug bindPreMatrixElementPlug = bindPreMatrixArrayPlug.elementByLogicalIndex( - skinClusterFn.indexForInfluenceObject( influencePaths[i], NULL ), &stat); - MObject matObj; - bindPreMatrixElementPlug.getValue( matObj ); - MFnMatrixData matFn( matObj, &stat ); - MMatrix mat = matFn.matrix(); - Imath::M44f cmat = IECore::convert( mat ); - - influencePoseDataW.push_back( cmat ); - } - - // extract the weights - FromMayaObjectConverterPtr converter = new IECoreMaya::FromMayaSkinClusterWeightsConverter( object ); - if ( !converter ) - { - throw IECore::Exception("FromMayaSkinClusterConverter::doConversion - Could not create FromMayaSkinClusterWeightsConverter" ); - } - - // TODO: Update SmoothSkinningData to also handle UShortVectorData weights - converter->parameters()->parameter("useCompression")->setTypedValue( false ); - IECore::CompoundObjectPtr weightDataPtr = IECore::runTimeCast( converter->convert() ); - - pointInfluenceWeightsData = weightDataPtr->member("pointInfluenceWeights", true ); - pointInfluenceIndicesData = weightDataPtr->member("pointInfluenceIndices", true ); - pointIndexOffsetsData = weightDataPtr->member("pointIndexOffsets", true ); - pointInfluenceCountsData = weightDataPtr->member("pointInfluenceCounts", true ); - - return new IECoreScene::SmoothSkinningData( influenceNamesData, influencePoseData, pointIndexOffsetsData, - pointInfluenceCountsData, pointInfluenceIndicesData, pointInfluenceWeightsData ); - -} diff --git a/src/IECoreMaya/FromMayaSkinClusterWeightsConverter.cpp b/src/IECoreMaya/FromMayaSkinClusterWeightsConverter.cpp deleted file mode 100644 index bc81e0582e..0000000000 --- a/src/IECoreMaya/FromMayaSkinClusterWeightsConverter.cpp +++ /dev/null @@ -1,163 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2012, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaSkinClusterWeightsConverter.h" -#include "IECoreMaya/Convert.h" -#include "IECore/DataConvert.h" -#include "IECore/ScaledDataConversion.h" -#include "IECore/Exception.h" -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/VectorTypedData.h" - -#include "maya/MFnSkinCluster.h" -#include "maya/MFnDagNode.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPath.h" -#include "maya/MObjectArray.h" -#include "maya/MItGeometry.h" - -using namespace IECoreMaya; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaSkinClusterWeightsConverter ); - -FromMayaObjectConverter::FromMayaObjectConverterDescription FromMayaSkinClusterWeightsConverter::m_description( MFn::kSkinClusterFilter, IECore::CompoundObject::staticTypeId(), false ); - -FromMayaSkinClusterWeightsConverter::FromMayaSkinClusterWeightsConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts weights from skinCluster nodes to a CompoundObject", object ) -{ - m_useCompression = new IECore::BoolParameter( - "useCompression", - "Compress weights as Shorts", - true - ); - m_compressionThreshold = new IECore::FloatParameter( - "compressionThreshold", - "Weights below that threshold are being ignored.", - 0.0 - ); - - parameters()->addParameter( m_useCompression ); - parameters()->addParameter( m_compressionThreshold ); -} - -IECore::ObjectPtr FromMayaSkinClusterWeightsConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus status; - - // our data storage objects - IECore::FloatVectorDataPtr pointInfluenceWeightsData = new IECore::FloatVectorData(); - IECore::IntVectorDataPtr pointInfluenceIndicesData = new IECore::IntVectorData(); - IECore::IntVectorDataPtr pointIndexOffsetsData = new IECore::IntVectorData(); - IECore::IntVectorDataPtr pointInfluenceCountsData = new IECore::IntVectorData(); - - auto &pointInfluenceWeightsW = pointInfluenceWeightsData->writable(); - auto &pointInfluenceIndicesW = pointInfluenceIndicesData->writable(); - auto &pointIndexOffsetsW = pointIndexOffsetsData->writable(); - auto &pointInfluenceCountsW = pointInfluenceCountsData->writable(); - - float compressionThreshold = m_compressionThreshold->getNumericValue(); - - // // get a skin cluster fn - MFnSkinCluster skinClusterFn(object); - - // get the first input geometry to the skin cluster - // TODO: if needed, extend this to retrieve more than one output geometry - MObjectArray outputGeoObjs; - status = skinClusterFn.getOutputGeometry( outputGeoObjs ); - if ( !status ) - { - throw IECore::Exception( "FromMayaSkinClusterWeightsConverter: skinCluster node does not have any output geometry!" ); - } - - // get the dag path to the first object - MFnDagNode dagFn( outputGeoObjs[0] ); - MDagPath geoPath; - dagFn.getPath( geoPath ); - - // generate a geo iterator for the components - MItGeometry geoIt( outputGeoObjs[0] ); - int currentOffset = 0; - - // loop through all the points of the geometry to extract their bind information - for ( ; !geoIt.isDone(); geoIt.next() ) - { - MObject pointObj = geoIt.currentItem( &status ); - MDoubleArray weights; - unsigned int weightsCount; - - skinClusterFn.getWeights( geoPath, pointObj, weights, weightsCount ); - int pointInfluencesCount = 0; - - for ( int influenceId = 0; influenceId < int( weightsCount ); influenceId++ ) - { - // ignore zero weights, we are generating a compressed (non-sparse) representation of the weights - if ( weights[influenceId] > compressionThreshold ) - { - pointInfluencesCount++; - pointInfluenceWeightsW.push_back( float( weights[influenceId] ) ); - pointInfluenceIndicesW.push_back( influenceId ); - } - } - - pointIndexOffsetsW.push_back( currentOffset ); - pointInfluenceCountsW.push_back( pointInfluencesCount ); - currentOffset += pointInfluencesCount; - } - - - IECore::CompoundObjectPtr outDataPtr = new IECore::CompoundObject(); - - outDataPtr->members()["pointInfluenceIndices"] = pointInfluenceIndicesData; - outDataPtr->members()["pointIndexOffsets"] = pointIndexOffsetsData; - outDataPtr->members()["pointInfluenceCounts"] = pointInfluenceCountsData; - - bool useCompression = m_useCompression->getTypedValue(); - if ( useCompression ) - { - IECore::DataConvert< IECore::FloatVectorData, IECore::UShortVectorData, IECore::ScaledDataConversion< float, unsigned short > >converter; - IECore::UShortVectorDataPtr pointInfluenceShortWeightsData = converter( pointInfluenceWeightsData ); - outDataPtr->members()["pointInfluenceWeights"] = pointInfluenceShortWeightsData; - } - else - { - outDataPtr->members()["pointInfluenceWeights"] = pointInfluenceWeightsData; - } - - return outDataPtr; -} diff --git a/src/IECoreMaya/FromMayaStringPlugConverter.cpp b/src/IECoreMaya/FromMayaStringPlugConverter.cpp deleted file mode 100644 index 0d5add6e34..0000000000 --- a/src/IECoreMaya/FromMayaStringPlugConverter.cpp +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaStringPlugConverter.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/MessageHandler.h" - -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaStringPlugConverter ); - -FromMayaPlugConverter::Description FromMayaStringPlugConverter::m_description( MFnData::kString, StringData::staticTypeId(), true ); - -FromMayaStringPlugConverter::FromMayaStringPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ -} - -IECore::ObjectPtr FromMayaStringPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - MString s; - plug().getValue( s ); - return new StringData( s.asChar() ); -} diff --git a/src/IECoreMaya/FromMayaTransformConverter.cpp b/src/IECoreMaya/FromMayaTransformConverter.cpp deleted file mode 100644 index 8244020f31..0000000000 --- a/src/IECoreMaya/FromMayaTransformConverter.cpp +++ /dev/null @@ -1,183 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaTransformConverter.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/TransformationMatrixData.h" - -#include "maya/MTransformationMatrix.h" -#include "maya/MFnMatrixData.h" -#include "maya/MFnTransform.h" -#include "maya/MPlug.h" - -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( FromMayaTransformConverter ); - -FromMayaDagNodeConverter::Description FromMayaTransformConverter::g_description( MFn::kTransform, IECore::TransformationMatrixdData::staticTypeId(), false ); - -FromMayaTransformConverter::FromMayaTransformConverter( const MDagPath &dagPath ) - : FromMayaDagNodeConverter( "Converts transform nodes.", dagPath ) -{ - - IECore::IntParameter::PresetsContainer spacePresets; - spacePresets.push_back( IECore::IntParameter::Preset( "Local", Local ) ); - spacePresets.push_back( IECore::IntParameter::Preset( "World", World ) ); - spacePresets.push_back( IECore::IntParameter::Preset( "Custom", Custom ) ); - m_spaceParameter = new IECore::IntParameter( - "space", - "The space in which the transform is converted.", - World, - Local, - Custom, - spacePresets, - true - ); - - parameters()->addParameter( m_spaceParameter ); - - IECore::M44fParameterPtr customSpace = new IECore::M44fParameter( - "customSpace", - "If 'space' is 'Custom' then this parameter defines the space which the transform should be relative to. The operation is transform * inverse(customSpace).", - new IECore::M44fData() - ); - parameters()->addParameter( customSpace ); - - m_lastRotationValid = false; - m_eulerFilterParameter = new IECore::BoolParameter( - "eulerFilter", - "If this parameter is on, then rotations are filtered so as to be as " - "close as possible to the previously converted rotation. This allows " - "the reuse of the same converter over a series of frames to produce a series " - "of transformations which will interpolate smoothly.", - false - ); - - parameters()->addParameter( m_eulerFilterParameter ); - - /// \todo We need this parameter because we're finding that our conversion of the maya - /// MTransformationMatrix class to our TransformationMatrix classes isn't yielding the same - /// results when the pivot is non-zero. We should figure out the real reason for that rather - /// than use this parameter as a crutch. - m_zeroPivotsParameter = new IECore::BoolParameter( - "zeroPivots", - "If this parameter is on, then the scale and rotate pivots are reset to zero, " - "adjusting the transform to maintain the same positioning.", - false - ); - - parameters()->addParameter( m_zeroPivotsParameter ); -} - -IECore::IntParameterPtr FromMayaTransformConverter::spaceParameter() -{ - return m_spaceParameter; -} - -IECore::ConstIntParameterPtr FromMayaTransformConverter::spaceParameter() const -{ - return m_spaceParameter; -} - -IECore::BoolParameterPtr FromMayaTransformConverter::eulerFilterParameter() -{ - return m_eulerFilterParameter; -} - -IECore::ConstBoolParameterPtr FromMayaTransformConverter::eulerFilterParameter() const -{ - return m_eulerFilterParameter; -} - -IECore::BoolParameterPtr FromMayaTransformConverter::zeroPivotsParameter() -{ - return m_zeroPivotsParameter; -} - -IECore::ConstBoolParameterPtr FromMayaTransformConverter::zeroPivotsParameter() const -{ - return m_zeroPivotsParameter; -} - -IECore::ObjectPtr FromMayaTransformConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const -{ - MTransformationMatrix transform; - - if( m_spaceParameter->getNumericValue()==Local ) - { - MFnTransform fnT( dagPath ); - transform = fnT.transformation(); - } - else - { - unsigned instIndex = dagPath.instanceNumber(); - - MObject dagNode = dagPath.node(); - MFnDependencyNode fnN( dagNode ); - - MPlug plug = fnN.findPlug( "worldMatrix", false ); - MPlug instPlug = plug.elementByLogicalIndex( instIndex ); - - MObject matrix; - instPlug.getValue( matrix ); - - MFnMatrixData fnM( matrix ); - transform = fnM.transformation(); - - if ( m_spaceParameter->getNumericValue() == Custom ) - { - // multiply world transform by the inverse of the custom space matrix. - transform = transform.asMatrix() * IECore::convert< MMatrix, Imath::M44f >( operands->member< IECore::M44fData >("customSpace", true)->readable().inverse() ); - } - } - - if( m_zeroPivotsParameter->getTypedValue() ) - { - transform.setScalePivot( MPoint( 0, 0, 0 ), MSpace::kTransform, true ); - transform.setRotatePivot( MPoint( 0, 0, 0 ), MSpace::kTransform, true ); - } - - if( m_eulerFilterParameter->getTypedValue() && m_lastRotationValid ) - { - transform.rotateTo( transform.eulerRotation().closestSolution( m_lastRotation ) ); - } - - m_lastRotation = transform.eulerRotation(); - m_lastRotationValid = true; - - return new IECore::TransformationMatrixdData( IECore::convert( transform ) ); -} - diff --git a/src/IECoreMaya/FromMayaTransformationMatrixConverter.cpp b/src/IECoreMaya/FromMayaTransformationMatrixConverter.cpp deleted file mode 100644 index cb63206422..0000000000 --- a/src/IECoreMaya/FromMayaTransformationMatrixConverter.cpp +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaTransformationMatrixConverter.h" -#include "IECoreMaya/Convert.h" - -#include "IECore/TransformationMatrixData.h" - -#include "maya/MFn.h" -#include "maya/MFnMatrixData.h" -#include "maya/MFnTransform.h" - -using namespace IECore; -using namespace std; -using namespace Imath; - -namespace IECoreMaya -{ - -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaTransformationMatrixConverter::g_description( MFn::kTransform, TransformationMatrixdData::staticTypeId(), false ); -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaTransformationMatrixConverter::g_dataDescription( MFn::kMatrixData, TransformationMatrixdData::staticTypeId(), false ); - -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaTransformationMatrixConverter::g_description( MFn::kTransform, TransformationMatrixfData::staticTypeId(), false ); -template<> -FromMayaObjectConverter::FromMayaObjectConverterDescription > FromMayaTransformationMatrixConverter::g_dataDescription( MFn::kMatrixData, TransformationMatrixfData::staticTypeId(), false ); - -template -FromMayaTransformationMatrixConverter::FromMayaTransformationMatrixConverter( const MObject &object ) - : FromMayaObjectConverter( "Converts maya matrix data to IECore::TransformationMatrixData.", object ) -{ -} - -template -IECore::ObjectPtr FromMayaTransformationMatrixConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - MFnMatrixData fnMatrixData( object ); - if( fnMatrixData.hasObj( object ) ) - { - MTransformationMatrix t = fnMatrixData.transformation(); - typename T::ValueType tt = IECore::convert( t ); - return new T( tt ); - } - MFnTransform fnTranf( object, &s ); - if (s) - { - MTransformationMatrix t = fnTranf.transformation(); - typename T::ValueType tt = IECore::convert( t ); - return new T( tt ); - } - return 0; -} - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaTransformationMatrixfConverter, FromMayaTransformationMatrixfConverterTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaTransformationMatrixdConverter, FromMayaTransformationMatrixdConverterTypeId ) - -template class FromMayaTransformationMatrixConverter; -template class FromMayaTransformationMatrixConverter; - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/FromMayaUnitPlugConverter.cpp b/src/IECoreMaya/FromMayaUnitPlugConverter.cpp deleted file mode 100644 index 1930a9b65f..0000000000 --- a/src/IECoreMaya/FromMayaUnitPlugConverter.cpp +++ /dev/null @@ -1,188 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/FromMayaUnitPlugConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include "maya/MAngle.h" -#include "maya/MDistance.h" -#include "maya/MTime.h" - -#include "boost/type_traits/is_same.hpp" - -namespace IECoreMaya -{ - -template -FromMayaPlugConverter::Description > FromMayaUnitPlugConverter::m_angleDescription( MFnUnitAttribute::kAngle, IECore::TypedData::staticTypeId(), boost::is_same::value ); -template -FromMayaPlugConverter::Description > FromMayaUnitPlugConverter::m_distanceDescription( MFnUnitAttribute::kDistance, IECore::TypedData::staticTypeId(), boost::is_same::value ); -template -FromMayaPlugConverter::Description > FromMayaUnitPlugConverter::m_timeDescription( MFnUnitAttribute::kTime, IECore::TypedData::staticTypeId(), boost::is_same::value ); - -template -FromMayaUnitPlugConverter::FromMayaUnitPlugConverter( const MPlug &plug ) - : FromMayaPlugConverter( plug ) -{ - IECore::IntParameter::PresetsContainer anglePresets; - anglePresets.push_back( IECore::IntParameter::Preset( "Radians", MAngle::kRadians ) ); - anglePresets.push_back( IECore::IntParameter::Preset( "Degrees", MAngle::kDegrees ) ); - m_angleUnitParameter = new IECore::IntParameter( - "angleUnit", - "The unit in which angular values are returned.", - MAngle::kRadians, - MAngle::kRadians, - MAngle::kDegrees, - anglePresets, - true - ); - - IECore::IntParameter::PresetsContainer distancePresets; - distancePresets.push_back( IECore::IntParameter::Preset( "Inches", MDistance::kInches ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Feet", MDistance::kFeet ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Yards", MDistance::kYards ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Miles", MDistance::kMiles ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Millimeters", MDistance::kMillimeters ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Centimeters", MDistance::kCentimeters ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Meters", MDistance::kMeters ) ); - distancePresets.push_back( IECore::IntParameter::Preset( "Kilometers", MDistance::kKilometers ) ); - m_distanceUnitParameter = new IECore::IntParameter( - "distanceUnit", - "The unit in which distance values are returned.", - MDistance::kCentimeters, - MDistance::kInches, - MDistance::kMeters, - distancePresets, - true - ); - - IECore::IntParameter::PresetsContainer timePresets; - timePresets.push_back( IECore::IntParameter::Preset( "Hours", MTime::kHours ) ); - timePresets.push_back( IECore::IntParameter::Preset( "Minutes", MTime::kMinutes ) ); - timePresets.push_back( IECore::IntParameter::Preset( "Seconds", MTime::kSeconds ) ); - timePresets.push_back( IECore::IntParameter::Preset( "Milliseconds", MTime::kMilliseconds ) ); - m_timeUnitParameter = new IECore::IntParameter( - "timeUnit", - "The unit in which time values are returned.", - MTime::kSeconds, - MTime::kHours, - MTime::kMilliseconds, - timePresets, - true - ); - - parameters()->addParameter( m_angleUnitParameter ); - parameters()->addParameter( m_distanceUnitParameter ); - parameters()->addParameter( m_timeUnitParameter ); - -} - -template -IECore::IntParameterPtr FromMayaUnitPlugConverter::angleUnitParameter() -{ - return m_angleUnitParameter; -} - -template -IECore::ConstIntParameterPtr FromMayaUnitPlugConverter::angleUnitParameter() const -{ - return m_angleUnitParameter; -} - -template -IECore::IntParameterPtr FromMayaUnitPlugConverter::distanceUnitParameter() -{ - return m_distanceUnitParameter; -} - -template -IECore::ConstIntParameterPtr FromMayaUnitPlugConverter::distanceUnitParameter() const -{ - return m_distanceUnitParameter; -} - -template -IECore::IntParameterPtr FromMayaUnitPlugConverter::timeUnitParameter() -{ - return m_timeUnitParameter; -} - -template -IECore::ConstIntParameterPtr FromMayaUnitPlugConverter::timeUnitParameter() const -{ - return m_timeUnitParameter; -} - -template -IECore::ObjectPtr FromMayaUnitPlugConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - typedef IECore::TypedData ResultType; - - MObject attr = plug().attribute(); - MFnUnitAttribute fnUAttr( attr ); - switch( fnUAttr.unitType() ) - { - case MFnUnitAttribute::kTime : - { - MTime t; - plug().getValue( t ); - return new ResultType( t.as( (MTime::Unit)m_timeUnitParameter->getNumericValue() ) ); - } - case MFnUnitAttribute::kDistance : - { - MDistance d; - plug().getValue( d ); - return new ResultType( d.as( (MDistance::Unit)m_distanceUnitParameter->getNumericValue() ) ); - } - case MFnUnitAttribute::kAngle : - { - MAngle a; - plug().getValue( a ); - return new ResultType( a.as( (MAngle::Unit)m_angleUnitParameter->getNumericValue() ) ); - } - default : - return 0; - } -} - -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaUnitPlugConverterf, FromMayaUnitPlugConverterfTypeId ) -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( FromMayaUnitPlugConverterd, FromMayaUnitPlugConverterdTypeId ) - -// explicit instantiation -template class FromMayaUnitPlugConverter; -template class FromMayaUnitPlugConverter; - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/IECoreMaya.cpp b/src/IECoreMaya/IECoreMaya.cpp deleted file mode 100644 index 2ba03f40ad..0000000000 --- a/src/IECoreMaya/IECoreMaya.cpp +++ /dev/null @@ -1,287 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "boost/format.hpp" - -#include "maya/MPxNode.h" -#include "maya/MPxLocatorNode.h" -#include "maya/MPxDeformerNode.h" -#include "maya/MPxObjectSet.h" -#include "maya/MPxFieldNode.h" -#include "maya/MPxImagePlane.h" -#include "maya/MPxSurfaceShapeUI.h" -#include "maya/MGlobal.h" -#include "maya/MDrawRegistry.h" -#undef None // must come after certain Maya includes which include X11/X.h - -#include "IECore/Parameterised.h" -#include "IECore/LevelFilteredMessageHandler.h" - -#include "IECoreMaya/IECoreMaya.h" -#include "IECoreMaya/CacheSet.h" -#include "IECoreMaya/ParameterisedHolder.h" -#include "IECoreMaya/TransientParameterisedHolderNode.h" -#include "IECoreMaya/OpHolder.h" -#include "IECoreMaya/PythonCmd.h" -#include "IECoreMaya/MessageHandler.h" -#include "IECoreMaya/ObjectData.h" -#include "IECoreMaya/ConverterHolder.h" -#include "IECoreMaya/ImageFile.h" -#include "IECoreMaya/ImagePlaneHolder.h" -#include "IECoreMaya/ParameterisedHolderSetValueCmd.h" -#include "IECoreMaya/ParameterisedHolderModificationCmd.h" -#include "IECoreMaya/CurveCombiner.h" -#include "IECoreMaya/V3Manipulator.h" -#include "IECoreMaya/ParameterisedHolderManipContextCommand.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/DrawableHolder.h" -#include "IECoreMaya/DrawableHolderUI.h" -#include "IECoreMaya/SceneShape.h" -#include "IECoreMaya/SceneShapeProxy.h" -#include "IECoreMaya/SceneShapeUI.h" -#include "IECoreMaya/SceneShapeProxyUI.h" -#include "IECoreMaya/SceneShapeInterface.h" -#include "IECoreMaya/SceneShapeSubSceneOverride.h" - -// see ObjectParameterHandler::doUpdate() for an explanation of the necessity for dummy data -static void *dummyDataCreator() -{ - // we never want to create dummy data, we just need the type to be registered. - // we therefore treat any creation attempt as a failure. - std::cerr << "IECoreMaya::dummyDataCreator : unexpected attempt to make dummy data." << std::endl; - exit( EXIT_FAILURE ); - return 0; -} - -namespace IECoreMaya -{ - -static unsigned long g_refCount = 0; - -MStatus initialize(MFnPlugin &plugin) -{ - MStatus s = MS::kSuccess; - - if (g_refCount == 0) - { - - // register plugin - - s = plugin.registerData( ObjectData::typeName, ObjectData::id, ObjectData::creator); - s = plugin.registerData( "ieDummyData", DummyDataId, dummyDataCreator ); - - s = plugin.registerNode( "ieCacheSet", CacheSet::id, CacheSet::creator, CacheSet::initialize, - MPxNode::kObjectSet ); - - s = plugin.registerNode( ParameterisedHolderNode::typeName, ParameterisedHolderNode::id, - ParameterisedHolderNode::creator, ParameterisedHolderNode::initialize ); - assert( s ); - - s = plugin.registerNode( ParameterisedHolderLocator::typeName, ParameterisedHolderLocator::id, - ParameterisedHolderLocator::creator, ParameterisedHolderLocator::initialize, MPxNode::kLocatorNode ); - assert( s ); - - s = plugin.registerNode( ParameterisedHolderDeformer::typeName, ParameterisedHolderDeformer::id, - ParameterisedHolderDeformer::creator, ParameterisedHolderDeformer::initialize, MPxNode::kDeformerNode ); - assert( s ); - - s = plugin.registerNode( ParameterisedHolderField::typeName, ParameterisedHolderField::id, - ParameterisedHolderField::creator, ParameterisedHolderField::initialize, MPxNode::kFieldNode ); - assert( s ); - - s = plugin.registerNode( ParameterisedHolderSet::typeName, ParameterisedHolderSet::id, - ParameterisedHolderSet::creator, ParameterisedHolderSet::initialize, MPxNode::kObjectSet ); - assert( s ); - - s = plugin.registerShape( ParameterisedHolderSurfaceShape::typeName, ParameterisedHolderSurfaceShape::id, - ParameterisedHolderSurfaceShape::creator, ParameterisedHolderSurfaceShape::initialize, []() -> void* { return new MPxSurfaceShapeUI; } ); - assert( s ); - - s = plugin.registerShape( ParameterisedHolderComponentShape::typeName, ParameterisedHolderComponentShape::id, - ParameterisedHolderComponentShape::creator, ParameterisedHolderComponentShape::initialize, []() -> void* { return new MPxSurfaceShapeUI; } ); - assert( s ); - - s = plugin.registerShape( DrawableHolder::typeName, DrawableHolder::id, - DrawableHolder::creator, DrawableHolder::initialize, DrawableHolderUI::creator ); - assert( s ); - - s = plugin.registerShape( "ieSceneShapeInterface", SceneShapeInterface::id, - SceneShapeInterface::creator, SceneShapeInterface::initialize, SceneShapeUI::creator ); - assert( s ); - - s = plugin.registerShape( "ieSceneShape", SceneShape::id, - SceneShape::creator, SceneShape::initialize, SceneShapeUI::creator, &SceneShapeSubSceneOverride::drawDbClassification() ); - assert( s ); - - s = MHWRender::MDrawRegistry::registerSubSceneOverrideCreator( SceneShapeSubSceneOverride::drawDbClassification(), SceneShapeSubSceneOverride::drawDbId(), SceneShapeSubSceneOverride::Creator ); - assert( s ); - - /// Note the missing classification for the draw DB and the "missing" call to "MHWRender::MDrawRegistry::registerSubSceneOverrideCreator" - /// after registering the Shape itself. See the documentation of the SceneShapeProxy class in SceneShapeProxy.h for the reason behind this. - s = plugin.registerShape( "ieSceneShapeProxy", SceneShapeProxy::id, - SceneShapeProxy::creator, SceneShapeProxy::initialize, SceneShapeProxyUI::creator ); - assert( s ); - - s = plugin.registerNode( "ieOpHolderNode", OpHolderNode::id, - OpHolderNode::creator, OpHolderNode::initialize ); - assert( s ); - - s = plugin.registerNode( "ieConverterHolder", ConverterHolder::id, - ConverterHolder::creator, ConverterHolder::initialize ); - assert( s ); - - s = plugin.registerNode( TransientParameterisedHolderNode::typeName, TransientParameterisedHolderNode::id, - TransientParameterisedHolderNode::creator, TransientParameterisedHolderNode::initialize ); - assert( s ); - - s = plugin.registerNode( ParameterisedHolderImagePlane::typeName, ParameterisedHolderImagePlane::id, - ParameterisedHolderImagePlane::creator, ParameterisedHolderImagePlane::initialize, MPxNode::kImagePlaneNode ); - assert( s ); - - s = plugin.registerNode( "ieImagePlaneHolder", ImagePlaneHolder::id, - ImagePlaneHolder::creator, ImagePlaneHolder::initialize, MPxNode::kImagePlaneNode ); - assert( s ); - - s = plugin.registerNode( CurveCombiner::typeName, CurveCombiner::id, - CurveCombiner::creator, CurveCombiner::initialize, MPxNode::kDependNode ); - assert( s ); - - // This should be used to set the classification of any manipulators that are - // compatible with the ieParameterisedHolderManipContext to permit the UI code - // to identify if a Parameter is manipulatable. - const MString manipClassification( "ieParameterManipulator" ); - // Convention for parameter manipulator names: - // ieManipulator - - s = plugin.registerNode( "ieV3fParameterManipulator", V3Manipulator::id, - V3Manipulator::creator, V3Manipulator::initialize, MPxNode::kManipContainer, &manipClassification ); - assert( s ); - - s = plugin.registerCommand( "iePython", PythonCmd::creator, PythonCmd::newSyntax ); - PythonCmd::initialize(); - - s = plugin.registerCommand( "ieParameterisedHolderSetValue", ParameterisedHolderSetValueCmd::creator, ParameterisedHolderSetValueCmd::newSyntax ); - - s = plugin.registerCommand( "ieParameterisedHolderModification", ParameterisedHolderModificationCmd::creator ); - - s = plugin.registerContextCommand("ieParameterisedHolderManipContext", &ParameterisedHolderManipContextCommand::creator ); - - MStringArray imageFileExtensions; - imageFileExtensions.append( "exr" ); - - s = plugin.registerImageFile( "ieImageFile", ImageFile::creator, imageFileExtensions); - assert( s ); - - /// \todo This may well need to change, depending on how we allow people to install - /// the mel files. - MString cmd = "source \"IECoreMaya/IECoreMaya.mel\";"; - s = MGlobal::executeCommand(cmd); - - if( !getenv( "IECOREMAYA_DISABLEOUTPUTREDIRECTION" ) ) - { - IECore::MessageHandlerPtr h = new IECoreMaya::MessageHandler; - h = new IECore::LevelFilteredMessageHandler( h, IECore::LevelFilteredMessageHandler::defaultLevel() ); - IECore::MessageHandler::setDefaultHandler( h ); - } - - if( MGlobal::mayaState() == MGlobal::kInteractive ) - { - MGlobal::executePythonCommand( "import IECoreMaya; IECoreMaya.Menus.createCortexMenu()" ); - } - - } - - g_refCount ++; - - return MS::kSuccess; -} - -MStatus uninitialize(MFnPlugin &plugin) -{ - MStatus s = MS::kSuccess; - - assert( g_refCount > 0 ); - - g_refCount --; - - if (g_refCount == 0) - { - // unregister plugin - - s = plugin.deregisterNode( CacheSet::id ); - s = plugin.deregisterNode( ParameterisedHolderNode::id ); - s = plugin.deregisterNode( DrawableHolder::id ); - s = plugin.deregisterNode( ParameterisedHolderLocator::id ); - s = plugin.deregisterNode( ParameterisedHolderDeformer::id ); - s = plugin.deregisterNode( ParameterisedHolderField::id ); - s = plugin.deregisterNode( ParameterisedHolderSet::id ); - s = plugin.deregisterNode( ParameterisedHolderSurfaceShape::id ); - s = plugin.deregisterNode( ParameterisedHolderComponentShape::id ); - s = plugin.deregisterNode( SceneShapeInterface::id ); - s = plugin.deregisterNode( SceneShape::id ); - s = plugin.deregisterNode( SceneShapeProxy::id ); - s = plugin.deregisterNode( OpHolderNode::id ); - s = plugin.deregisterNode( ConverterHolder::id ); - s = plugin.deregisterNode( TransientParameterisedHolderNode::id ); - s = plugin.deregisterNode( ParameterisedHolderImagePlane::id ); - s = plugin.deregisterNode( ImagePlaneHolder::id ); - s = plugin.deregisterNode( CurveCombiner::id ); - s = plugin.deregisterNode( V3Manipulator::id ); - - s = plugin.deregisterCommand( "iePython" ); - PythonCmd::uninitialize(); - - s = plugin.deregisterCommand( "ieParameterisedHolderModification" ); - s = plugin.deregisterCommand( "ieParameterisedHolderSetValue" ); - s = plugin.deregisterContextCommand("ieParameterisedHolderManipContext"); - - s = plugin.deregisterData( DummyDataId ); - s = plugin.deregisterData( ObjectData::id ); - - s = plugin.deregisterImageFile( "ieImageFile" ); - - if( MGlobal::mayaState() == MGlobal::kInteractive ) - { - MGlobal::executePythonCommand( "import IECoreMaya; IECoreMaya.Menus.removeCortexMenu()" ); - } - - } - - return s; -} - -} diff --git a/src/IECoreMaya/ImageFile.cpp b/src/IECoreMaya/ImageFile.cpp deleted file mode 100644 index d5c03d6d47..0000000000 --- a/src/IECoreMaya/ImageFile.cpp +++ /dev/null @@ -1,301 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "IECoreGL/GL.h" - -#include "maya/MGlobal.h" -#include "maya/MImage.h" -#include "maya/MImageFileInfo.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/DespatchTypedData.h" -#include "IECore/ScaledDataConversion.h" -#include "IECore/DataConvert.h" - -#include "IECoreImage/ImageReader.h" -#include "IECoreImage/ImagePrimitive.h" - -#include "IECoreMaya/ImageFile.h" - -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreMaya; - -ImageFile::ImageFile() : m_rData( 0 ), m_gData( 0 ), m_bData( 0 ), m_aData( 0 ) -{ -} - -ImageFile::~ImageFile() -{ -} - -void *ImageFile::creator() -{ - return new ImageFile; -} - -struct ImageFile::ChannelConverter -{ - typedef FloatVectorDataPtr ReturnType; - - std::string m_pathName; - std::string m_channelName; - - template - ReturnType operator()( typename T::ConstPtr data ) - { - assert( data ); - - return DataConvert < T, FloatVectorData, ScaledDataConversion< typename T::ValueType::value_type, float> >()( data ); - }; - - struct ErrorHandler - { - template - void operator()( typename T::ConstPtr data, const F& functor ) - { - assert( data ); - - throw InvalidArgumentException( ( boost::format( "ImageFile: Invalid data type \"%s\" for channel %s while reading %s" ) % Object::typeNameFromTypeId( data->typeId() ) % functor.m_channelName % functor.m_pathName ).str() ); - } - }; -}; - -MStatus ImageFile::open( MString pathName, MImageFileInfo* info ) -{ - ImagePrimitivePtr image; - ImageReaderPtr reader; - - try - { - reader = runTimeCast( Reader::create( pathName.asChar() ) ); - if (!reader) - { - return MS::kFailure; - } - - image = runTimeCast< ImagePrimitive >( reader->read() ); - if (!image) - { - return MS::kFailure; - } - - if (!reader->isComplete()) - { - return MS::kFailure; - } - } - catch ( std::exception &e ) - { - return MS::kFailure; - } - - m_width = image->getDataWindow().size().x + 1; - m_height = image->getDataWindow().size().y + 1; - - std::vector channelNames; - image->channelNames( channelNames ); - - if ( std::find( channelNames.begin(), channelNames.end(), "R" ) == channelNames.end() - || std::find( channelNames.begin(), channelNames.end(), "G" ) == channelNames.end() - || std::find( channelNames.begin(), channelNames.end(), "B" ) == channelNames.end() ) - { - return MS::kFailure; - } - - m_numChannels = 3; - if ( std::find( channelNames.begin(), channelNames.end(), "A" ) != channelNames.end() ) - { - m_numChannels = 4; - } - - assert( m_numChannels == 3 || m_numChannels == 4 ); - - try - { - - ChannelConverter converter; - converter.m_pathName = pathName.asChar(); - - DataPtr rData = image->channels["R"]; - if (! rData ) - { - return MS::kFailure; - } - - converter.m_channelName = "R"; - m_rData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( rData.get(), converter ); - - DataPtr gData = image->channels["G"]; - if (! gData ) - { - return MS::kFailure; - } - - converter.m_channelName = "G"; - m_gData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( gData.get(), converter ); - - DataPtr bData = image->channels["B"]; - if (! bData ) - { - return MS::kFailure; - } - - converter.m_channelName = "B"; - m_bData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( bData.get(), converter ); - - if ( m_numChannels == 4 ) - { - DataPtr aData = image->channels["A"]; - if (! aData ) - { - return MS::kFailure; - } - - converter.m_channelName = "A"; - m_aData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( aData.get(), converter ); - } - - } - catch ( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - - if (info) - { - info->width( m_width ); - info->height( m_height ); - - info->channels( m_numChannels ); - info->numberOfImages( 1 ); - - info->imageType( MImageFileInfo::kImageTypeColor ); - info->pixelType( MImage::kFloat ); - info->hardwareType( MImageFileInfo::kHwTexture2D ); - } - - return MS::kSuccess; -} - -void ImageFile::populateImage( float* pixels ) const -{ - assert( pixels ); - - for (unsigned y = 0; y < m_height; y++) - { - for (unsigned x = 0; x < m_width; x++) - { - unsigned pixelIndex = ((m_height - y - 1) * m_width) + x; - - assert( pixelIndex < m_width * m_height ); - - *pixels++ = m_rData->readable()[ pixelIndex ]; - *pixels++ = m_gData->readable()[ pixelIndex ]; - *pixels++ = m_bData->readable()[ pixelIndex ]; - - if ( m_aData ) - { - *pixels++ = m_aData->readable()[ pixelIndex ]; - } - } - } -} - -MStatus ImageFile::load( MImage& image, unsigned int idx ) -{ - MStatus s; - - assert( idx == 0 ); - assert( m_rData ); - assert( m_gData ); - assert( m_bData ); - - s = image.create( m_width, m_height, m_numChannels, MImage::kFloat ); - assert(s); - - image.setRGBA( true ); - - populateImage( image.floatPixels() ); - - return MS::kSuccess; -} - -MStatus ImageFile::glLoad( const MImageFileInfo& info, unsigned int idx ) -{ - assert( idx == 0 ); - assert( m_rData ); - assert( m_gData ); - assert( m_bData ); - - std::vector pixels; - pixels.resize( m_width * m_height * m_numChannels ); - - populateImage( &pixels[0] ); - - switch (m_numChannels) - { - case 3: - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, m_width, m_height, 0, GL_RGB, GL_FLOAT, &pixels[0] ); - break; - case 4: - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_FLOAT, &pixels[0] ); - break; - default: - assert(false); - } - - return MS::kSuccess; -} - diff --git a/src/IECoreMaya/ImagePlaneHolder.cpp b/src/IECoreMaya/ImagePlaneHolder.cpp deleted file mode 100644 index e9a54c3597..0000000000 --- a/src/IECoreMaya/ImagePlaneHolder.cpp +++ /dev/null @@ -1,166 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" -#include -#include - -#include "boost/format.hpp" - -#include "maya/MImage.h" -#include "maya/MGlobal.h" - -#include "IECoreMaya/ImagePlaneHolder.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/ToMayaImageConverter.h" - -#include "IECore/MessageHandler.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Object.h" -#include "IECore/TypedParameter.h" - -#include "IECoreImage/ImagePrimitive.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/Parameterised.h" - -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreMaya; - -MTypeId ImagePlaneHolder::id( ImagePlaneHolderId ); - -ImagePlaneHolder::ImagePlaneHolder() -{ -} - -ImagePlaneHolder::~ImagePlaneHolder() -{ -} - -void ImagePlaneHolder::postConstructor() -{ - setExistWithoutInConnections(true); - setExistWithoutOutConnections(true); -} - -void *ImagePlaneHolder::creator() -{ - return new ImagePlaneHolder(); -} - -MStatus ImagePlaneHolder::initialize() -{ - return inheritAttributesFrom( ParameterisedHolderImagePlane::typeName ); -} - -MStatus ImagePlaneHolder::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - /// This isn't the best way of doing it, but at this point we can't even be sure that the Op has been loaded, - /// so calling plugParameter() may not work. We can't call getOp() or getParameterised() here, as it seems - /// we can't do things such as adding/removing attributes within this function - if( std::string( plug.partialName().substring( 0, 4 ).asChar() ) == g_attributeNamePrefix ) - { - setImageDirty(); - } - - return ParameterisedHolderImagePlane::setDependentsDirty( plug, plugArray ); -} - -MStatus ImagePlaneHolder::loadImageMap ( const MString &fileName, int frame, MImage &image ) -{ - IECore::OpPtr op = getOp(); - - if (op) - { - IECore::ObjectPtr result; - - try - { - ParameterisedHolderImagePlane::setParameterisedValues(); - result = op->operate(); - if (!result) - { - return MS::kFailure; - } - - ImagePrimitivePtr imageResult = runTimeCast< ImagePrimitive >( result ); - - if (!imageResult ) - { - MGlobal::displayError( "ImagePlaneHolder: Op did not return an ImagePrimtiive" ); // \todo - return MS::kFailure; - } - - ToMayaImageConverterPtr toMaya = new ToMayaImageConverter( imageResult ); - - MStatus s = toMaya->convert( image ); - if ( !s ) - { - return MS::kFailure; - } - - return MS::kSuccess; - } - catch( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - catch( boost::python::error_already_set &e ) - { - IECorePython::ScopedGILLock gilLock; - PyErr_Print(); - return MS::kFailure; - } - catch (...) - { - MGlobal::displayError( "ImagePlaneHolder: Caught unknown error" ); - return MS::kFailure; - } - } - - return MS::kFailure; -} - -MStatus ImagePlaneHolder::setOp( const std::string &className, int classVersion ) -{ - return setParameterised( className, classVersion, "IECORE_OP_PATHS"); -} - -IECore::OpPtr ImagePlaneHolder::getOp( std::string *className, int *classVersion ) -{ - return IECore::runTimeCast( getParameterised( className, classVersion ) ); -} diff --git a/src/IECoreMaya/ImageViewportPostProcess.cpp b/src/IECoreMaya/ImageViewportPostProcess.cpp deleted file mode 100644 index d67e3c1e23..0000000000 --- a/src/IECoreMaya/ImageViewportPostProcess.cpp +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MGlobal.h" - -#include "IECoreMaya/ImageViewportPostProcess.h" -#include "IECoreMaya/FromMayaImageConverter.h" -#include "IECoreMaya/ToMayaImageConverter.h" - -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreMaya; - -ImageViewportPostProcess::ImageViewportPostProcess() -{ -} - -ImageViewportPostProcess::~ImageViewportPostProcess() -{ -} - -void ImageViewportPostProcess::postRender( const std::string &panelName, MImage &viewportImage ) -{ - FromMayaImageConverterPtr fromMaya = new FromMayaImageConverter( viewportImage ); - fromMaya->depthParameter()->setTypedValue( needsDepth() ); - ImagePrimitivePtr image = runTimeCast< ImagePrimitive >( fromMaya->convert() ); - - assert( image->channelsValid() ); - - postRender( panelName, image ); - - if ( !image->channelsValid() ) - { - MGlobal::displayError( "ImageViewportPostProcess: Image primvars invalid after postprocess" ); - } - else - { - ToMayaImageConverterPtr toMaya = new ToMayaImageConverter( image ); - toMaya->convert( viewportImage ); - } -} diff --git a/src/IECoreMaya/LineSegmentParameterHandler.cpp b/src/IECoreMaya/LineSegmentParameterHandler.cpp deleted file mode 100644 index 22bf78e21d..0000000000 --- a/src/IECoreMaya/LineSegmentParameterHandler.cpp +++ /dev/null @@ -1,256 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnCompoundAttribute.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "IECoreMaya/LineSegmentParameterHandler.h" -#include "IECoreMaya/NumericTraits.h" - -using namespace IECore; -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< LineSegmentParameterHandler > g_ineSegment2dRegistrar( IECore::LineSegment3fParameter::staticTypeId() ); -static ParameterHandler::Description< LineSegmentParameterHandler > g_ineSegment3dRegistrar( IECore::LineSegment3dParameter::staticTypeId() ); - -template -MPlug LineSegmentParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - typename T::ConstPtr p = runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnNumericAttribute fnNAttr; - MFnCompoundAttribute fnCAttr; - MObject oStart, oEnd; - switch( Point::dimensions() ) - { - case 2 : - { - MObject oStartX = fnNAttr.create( plugName + "StartX", plugName + "StartX", NumericTraits::baseDataType() ); - MObject oStartY = fnNAttr.create( plugName + "StartY", plugName + "StartY", NumericTraits::baseDataType() ); - oStart = fnNAttr.create( plugName + "Start", plugName + "Start", oStartX, oStartY ); - - MObject oEndX = fnNAttr.create( plugName + "EndX", plugName + "EndX", NumericTraits::baseDataType() ); - MObject oEndY = fnNAttr.create( plugName + "EndY", plugName + "EndY", NumericTraits::baseDataType() ); - oEnd = fnNAttr.create( plugName + "End", plugName + "End", oEndX, oEndY ); - } - break; - case 3 : - oStart = fnNAttr.createPoint( plugName + "Start", plugName + "Start" ); - oEnd = fnNAttr.createPoint( plugName + "End", plugName + "End" ); - break; - default : - return MPlug(); - } - - MObject attribute = fnCAttr.create( plugName, plugName ); - fnCAttr.addChild( oStart ); - fnCAttr.addChild( oEnd ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus LineSegmentParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename T::ConstPtr p = runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( fnCAttr.numChildren()!=2 ) - { - return MS::kFailure; - } - - MFnNumericAttribute fnStartAttr( fnCAttr.child( 0 ) ); - if( fnStartAttr.unitType()!=NumericTraits::dataType() ) - { - return MS::kFailure; - } - - MFnNumericAttribute fnEndAttr( fnCAttr.child( 1 ) ); - if( fnEndAttr.unitType()!=NumericTraits::dataType() ) - { - return MS::kFailure; - } - - // Set the default value for the leaf attributes individually. Calling - // the variants of setDefault that set several components at a time - // seems to exercise a maya bug. See similar comment in CompoundNumericParameterHandler. - LineSegment defValue = p->typedDefaultValue(); - MStatus s; - for( unsigned i=0; i -MStatus LineSegmentParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename T::ConstPtr p = runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != 2 ) - { - return MS::kFailure; - } - - MPlug startPlug = plug.child( 0 ); - MPlug endPlug = plug.child( 1 ); - - if( startPlug.numChildren()!=Point::dimensions() || endPlug.numChildren()!=Point::dimensions() ) - { - return MS::kFailure; - } - - LineSegment v = p->getTypedValue(); - for( unsigned i=0; i -MStatus LineSegmentParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - typename T::Ptr p = runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - if( plug.numChildren() != 2 ) - { - return MS::kFailure; - } - - MPlug startPlug = plug.child( 0 ); - MPlug endPlug = plug.child( 1 ); - - if( startPlug.numChildren()!=Point::dimensions() || endPlug.numChildren()!=Point::dimensions() ) - { - return MS::kFailure; - } - - LineSegment v; - for( unsigned i=0; isetTypedValue( v ); - return MS::kSuccess; -} - diff --git a/src/IECoreMaya/LiveScene.cpp b/src/IECoreMaya/LiveScene.cpp deleted file mode 100644 index e7d5b8fd51..0000000000 --- a/src/IECoreMaya/LiveScene.cpp +++ /dev/null @@ -1,1263 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/Exception.h" -#include "IECore/TransformationMatrixData.h" -#include "IECore/NullObject.h" -#include "IECore/MessageHandler.h" -#include "IECoreScene/MatrixTransform.h" -#include "IECoreScene/Camera.h" -#include "IECoreScene/Primitive.h" -#include "IECoreScene/CurvesMergeOp.h" -#include "IECoreScene/MeshMergeOp.h" - -#include "IECoreMaya/LiveScene.h" -#include "IECoreMaya/FromMayaPlugConverter.h" -#include "IECoreMaya/FromMayaTransformConverter.h" -#include "IECoreMaya/FromMayaShapeConverter.h" -#include "IECoreMaya/FromMayaDagNodeConverter.h" -#include "IECoreMaya/FromMayaCameraConverter.h" -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/SceneShape.h" -#include "IECoreMaya/FromMayaCurveConverter.h" -#include "IECoreMaya/FromMayaMeshConverter.h" -#include "IECoreMaya/FromMayaInstancerConverter.h" - -#include "maya/MFnDagNode.h" -#include "maya/MFnTransform.h" -#include "maya/MPxTransform.h" -#include "maya/MPxSurfaceShape.h" -#include "maya/MFnCamera.h" -#include "maya/MFnMatrixData.h" -#include "maya/MFnNumericData.h" -#include "maya/MFnAttribute.h" -#include "maya/MSelectionList.h" -#include "maya/MAnimControl.h" -#include "maya/MString.h" -#include "maya/MTime.h" -#include "maya/MItDag.h" -#include "maya/MPlug.h" -#include "maya/MTransformationMatrix.h" -#include "maya/MDagPathArray.h" -#include "maya/MFnNurbsCurve.h" -#include "maya/MGlobal.h" -#include "maya/MFnSet.h" -#include "maya/MFnInstancer.h" - -#include "Imath/ImathBoxAlgo.h" - -#include "boost/algorithm/string.hpp" -#include "boost/tokenizer.hpp" -#include "boost/format.hpp" - -#include "tbb/recursive_mutex.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( LiveScene ); - -namespace -{ - -SceneInterface::Name g_userAttrPrefix{ "user:" }; -SceneInterface::Name g_mayaUserAttrPrefix{ "ieAttr_" }; - -void readExportableSets( std::set &exportableSets, const MDagPath &dagPath ) -{ - // convert maya sets to tags - MSelectionList selectionList; - selectionList.add( dagPath ); - - MObjectArray sets; - if( !MGlobal::getAssociatedSets( selectionList, sets ) ) - { - return; - } - - for( unsigned int i = 0, numSets = sets.length(); i < numSets; ++i ) - { - MStatus s; - MFnSet set( sets[i], &s ); - - if( !s ) - { - continue; - } - - MPlug exportPlug = set.findPlug( "ieExport", false, &s ); - - if( !s ) - { - continue; - } - - if( exportPlug.asBool() ) - { - exportableSets.insert( SceneInterface::Name( set.name().asChar() ) ); - } - - } -} - -} - -IECoreScene::SceneInterface::Name LiveScene::visibilityOverrideName{ "ieVisibility" }; - -// this stuff requires a mutex, as all them maya DG functions aint thread safe! -LiveScene::Mutex LiveScene::s_mutex; -tbb::recursive_mutex g_mutex; - -LiveScene::LiveScene() : m_isRoot( true ) -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - // initialize to the root path: - MItDag it; - it.getPath( m_dagPath ); -} - -LiveScene::LiveScene( const MDagPath& p, bool isRoot ) : m_isRoot( isRoot ) -{ - // this constructor is expected to be called when g_mutex is locked! - m_dagPath = p; -} - -std::string LiveScene::fileName() const -{ - throw Exception( "IECoreMaya::LiveScene does not support fileName()." ); -} - -MDagPath LiveScene::dagPath() const -{ - return m_dagPath; -} - -LiveScenePtr LiveScene::duplicate( const MDagPath& p, bool isRoot ) const -{ - return new LiveScene( p, isRoot ); -} - -SceneInterface::Name LiveScene::name() const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::name: Dag path no longer exists!" ); - } - - std::string nameStr = m_dagPath.fullPathName().asChar(); - - if( nameStr.size() <= 1 ) - { - return SceneInterface::rootName; - } - - size_t pipePos = nameStr.rfind("|"); - if( pipePos != std::string::npos ) - { - return std::string( nameStr.begin() + pipePos + 1, nameStr.end() ); - } - else - { - return nameStr; - } -} - -void LiveScene::path( Path &p ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::path: Dag path no longer exists!" ); - } - - dagPathToPath( m_dagPath, p ); -} - -Imath::Box3d LiveScene::readBound( double time ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( fabs( MAnimControl::currentTime().as( MTime::kSeconds ) - time ) > 1.e-4 ) - { - throw Exception( "IECoreMaya::LiveScene::readBound: time must be the same as on the maya timeline!" ); - } - - if( m_isRoot ) - { - MDagPathArray paths; - getChildDags( m_dagPath, paths ); - - Imath::Box3d bound; - - for( unsigned i=0; i < paths.length(); ++i ) - { - MFnDagNode dagFn( paths[i] ); - Imath::Box3d b = IECore::convert( dagFn.boundingBox() ); - - if( b.hasVolume() ) - { - bound.extendBy( b ); - } - } - - return bound; - } - else if( m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::readBound: Dag path no longer exists!" ); - } - else - { - MFnDagNode dagFn( m_dagPath ); - Imath::Box3d ret = IECore::convert( dagFn.boundingBox() ); - Imath::M44d invTransform = IECore::convert( dagFn.transformationMatrix() ).inverse(); - return Imath::transform( ret, invTransform ); - } -} - -void LiveScene::writeBound( const Imath::Box3d &bound, double time ) -{ - throw Exception( "IECoreMaya::LiveScene::writeBound: write operations not supported!" ); -} - -ConstDataPtr LiveScene::readTransform( double time ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::readTransform: Dag path no longer exists!" ); - } - - if( fabs( MAnimControl::currentTime().as( MTime::kSeconds ) - time ) > 1.e-4 ) - { - throw Exception( "IECoreMaya::LiveScene::readTransform: time must be the same as on the maya timeline!" ); - } - - if( m_dagPath.hasFn( MFn::kTransform ) ) - { - MFnTransform dagFn( m_dagPath ); - return new IECore::TransformationMatrixdData( IECore::convert( dagFn.transformation() ) ); - } - else - { - return new TransformationMatrixdData( IECore::TransformationMatrixd() ); - } -} - -Imath::M44d LiveScene::readTransformAsMatrix( double time ) const -{ - return runTimeCast< const TransformationMatrixdData >( readTransform( time ) )->readable().transform(); -} - -void LiveScene::writeTransform( const Data *transform, double time ) -{ - throw Exception( "IECoreMaya::LiveScene::writeTransform: write operations not supported!" ); -} - -bool LiveScene::hasAttribute( const Name &name ) const -{ - if ( !m_isRoot && m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::hasAttribute: Dag path no longer exists!" ); - } - - // Visibility is always defined - if( name == SceneInterface::visibilityName ) - { - return true; - } - - // Check the maya transform for the attribute - Name mayaAttributeName = toMayaAttributeName( name ); - if( !mayaAttributeName.string().empty() ) - { - MFnDependencyNode fnNode( m_dagPath.node() ); - MFnAttribute fnAttr; - unsigned int n = fnNode.attributeCount(); - for( unsigned int i = 0; i < n; ++i ) - { - MObject attr = fnNode.attribute( i ); - fnAttr.setObject( attr ); - Name attrName = fnAttr.name().asChar(); - if( attrName == mayaAttributeName ) - { - return true; - } - } - } - - // Check custom registered readers for the attribute name - std::vector< CustomAttributeReader > &attributeReaders = customAttributeReaders(); - for ( std::vector< CustomAttributeReader >::const_iterator it = attributeReaders.begin(); it != attributeReaders.end(); ++it ) - { - if ( it->m_mightHave ) - { - if ( ! it->m_mightHave( m_dagPath, name ) ) - { - continue; - } - } - - NameList names; - { - // call it->m_names under a mutex, as it could be reading plug values, - // which isn't thread safe: - tbb::recursive_mutex::scoped_lock l( g_mutex ); - it->m_names( m_dagPath, names ); - } - - if ( std::find(names.begin(), names.end(), name) != names.end() ) - { - return true; - } - } - - return false; -} - -void LiveScene::attributeNames( NameList &attrs ) const -{ - if( !m_isRoot && m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::attributeNames: Dag path no longer exists!" ); - } - - tbb::recursive_mutex::scoped_lock l( g_mutex ); - attrs.clear(); - attrs.push_back( SceneInterface::visibilityName ); - - // Get the attributes exposed on the maya transform - MFnDependencyNode fnNode( m_dagPath.node() ); - unsigned int n = fnNode.attributeCount(); - for( unsigned int i=0; i::const_iterator it = customAttributeReaders().begin(); it != customAttributeReaders().end(); it++ ) - { - it->m_names( m_dagPath, attrs ); - } - - // remove duplicates: - std::sort( attrs.begin(), attrs.end() ); - attrs.erase( std::unique( attrs.begin(), attrs.end() ), attrs.end() ); -} - -ConstObjectPtr LiveScene::readAttribute( const Name &name, double time ) const -{ - if ( !m_isRoot && m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::readAttribute: Dag path no longer exists!" ); - } - - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - // Check the maya transform for the attribute - // It's important to read the transform attributes before the custom attributes so that they will - // be found before custom attributes (giving them the opportunity to override) - Name mayaAttributeName = toMayaAttributeName( name ); - if( !mayaAttributeName.string().empty() ) - { - MStatus st; - MFnDependencyNode fnNode( m_dagPath.node() ); - MPlug attrPlug = fnNode.findPlug( mayaAttributeName.c_str(), false, &st ); - if( st ) - { - FromMayaConverterPtr plugConverter = FromMayaPlugConverter::create( attrPlug ); - if( !plugConverter ) - { - return IECore::NullObject::defaultNullObject(); - } - return plugConverter->convert(); - } - } - - // Read custom attributes - std::vector< CustomAttributeReader > &attributeReaders = customAttributeReaders(); - for ( std::vector< CustomAttributeReader >::const_reverse_iterator it = attributeReaders.rbegin(); it != attributeReaders.rend(); ++it ) - { - ConstObjectPtr attr = it->m_read( m_dagPath, name ); - if( !attr ) - { - continue; - } - return attr; - } - - // Special Case - Visibility - // Let the maya transform's "visibility" attribute set scene:visible when: - // 1) A maya override attribute doesn't exist on the transform (via ieVisibility) and - // 2) The visibility is not set by a custom attribute reader (like a SceneShape) - if( name == SceneInterface::visibilityName ) - { - // The root is always visible - if( m_isRoot ) - { - return new BoolData( true ); - } - - // Return the transform's visibility - MFnTransform transformFn( m_dagPath ); - bool visible = transformFn.findPlug( MPxTransform::visibility, false).asBool(); - return new BoolData( visible ); - } - - return IECore::NullObject::defaultNullObject(); -} - -void LiveScene::writeAttribute( const Name &name, const Object *attribute, double time ) -{ - throw Exception( "IECoreMaya::LiveScene::writeAttribute: write operations not supported!" ); -} - -bool LiveScene::hasTag( const Name &name, int filter ) const -{ - if ( m_isRoot ) - { - return false; - } - - if( m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::hasTag: Dag path no longer exists!" ); - } - - std::set sets; - readExportableSets(sets, m_dagPath); - - if( sets.find( name ) != sets.end() ) - { - return true; - } - - std::vector &tagReaders = customTagReaders(); - for ( std::vector::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it ) - { - if ( it->m_has( m_dagPath, name, filter ) ) - { - return true; - } - } - - return false; -} - -void LiveScene::readTags( NameList &tags, int filter ) const -{ - tags.clear(); - - if ( m_isRoot ) - { - return; - } - - if( m_dagPath.length() == 0 ) - { - throw Exception( "IECoreMaya::LiveScene::attributeNames: Dag path no longer exists!" ); - } - - std::set uniqueTags; - readExportableSets(uniqueTags, m_dagPath); - - // read tags from ieTags attribute: - MStatus st; - MFnDependencyNode fnNode( m_dagPath.node() ); - MPlug tagsPlug = fnNode.findPlug( "ieTags", false, &st ); - if( st ) - { - std::string tagsStr( tagsPlug.asString().asChar() ); - boost::tokenizer > t( tagsStr, boost::char_separator( " " ) ); - for ( - boost::tokenizer >::iterator it = t.begin(); - it != t.end(); - ++it - ) - { - uniqueTags.insert( Name( *it ) ); - } - } - - // read tags from custom readers: - std::vector &tagReaders = customTagReaders(); - for ( std::vector::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it ) - { - NameList values; - it->m_read( m_dagPath, values, filter ); - uniqueTags.insert( values.begin(), values.end() ); - } - - tags.insert( tags.end(), uniqueTags.begin(), uniqueTags.end() ); -} - -void LiveScene::writeTags( const NameList &tags ) -{ - throw Exception( "IECoreMaya::LiveScene::writeTags not supported" ); -} - -SceneInterface::NameList LiveScene::setNames( bool includeDescendantSets ) const -{ - return SceneInterface::NameList(); -} - -IECore::PathMatcher LiveScene::readSet( const Name &name, bool includeDescendantSets, const IECore::Canceller *canceller ) const -{ - throw Exception( "IECoreMaya::LiveScene::readSet not supported" ); -} - -void LiveScene::writeSet( const Name &name, const IECore::PathMatcher &set ) -{ - throw Exception( "IECoreMaya::LiveScene::writeSet not supported" ); -} - -void LiveScene::hashSet( const Name& setName, IECore::MurmurHash &h ) const -{ - SceneInterface::hashSet( setName, h ); -} - -namespace -{ - -template -struct PrimMergerTraits; - -template<> -struct PrimMergerTraits -{ - typedef FromMayaCurveConverter ConverterType; - typedef CurvesMergeOp MergeOpType; - static CurvesPrimitiveParameter * primParameter( MergeOpType* mop ) - { - return mop->curvesParameter(); - } -}; - -template<> -struct PrimMergerTraits -{ - typedef FromMayaMeshConverter ConverterType; - typedef MeshMergeOp MergeOpType; - static MeshPrimitiveParameter * primParameter( MergeOpType* mop ) - { - return mop->meshParameter(); - } -}; - -template -class PrimMerger -{ - typedef typename PrimMergerTraits::ConverterType ConverterType; - typedef typename PrimMergerTraits::MergeOpType MergeOpType; - typedef typename MergeOpType::PrimitiveType PrimitiveType; - - public: - - static void createMergeOp( MDagPath &childDag, IECore::ModifyOpPtr &op ) - { - typename ConverterType::Ptr converter = runTimeCast( ConverterType::create( childDag ) ); - if( ! converter ) - { - throw Exception( ( boost::format( "Creating merge op failed! " ) % childDag.fullPathName().asChar() ).str() ); - } - typename PrimitiveType::Ptr cprim = runTimeCast( converter->convert() ); - op = new MergeOpType; - op->copyParameter()->setTypedValue( false ); - op->inputParameter()->setValue( cprim ); - } - - static void mergePrim( MDagPath &childDag, IECore::ModifyOpPtr &op ) - { - typename ConverterType::Ptr converter = runTimeCast( ConverterType::create( childDag ) ); - if( ! converter ) - { - throw Exception( ( boost::format( "Merging primitive failed! " ) % childDag.fullPathName().asChar() ).str() ); - } - typename PrimitiveType::Ptr prim = runTimeCast( converter->convert() ); - MergeOpType *mop = runTimeCast( op.get() ); - PrimMergerTraits::primParameter( mop )->setValue( const_cast( prim.get() ) ); - op->operate(); - } - -}; - -bool hasMergeableObjects( const MDagPath &p ) -{ - // When there are multiple child shapes that can be merged, readMergedObject() returns an object that has all the shapes merged in it. - // This is because multiple Maya shapes can be converted to one IECore primitive eg. nurbs curves -> IECore::CurvesPrimitive. - // We want to have multiple shape nodes in Maya, and want it to be one primitive if viewed through IECoreMaya::LiveScene. - unsigned int childCount = p.childCount(); - - // At least two shapes need to exist to merge. - if( childCount < 2 ) - { - return false; - } - - bool isMergeable = false; - MFnNurbsCurve::Form acceptableCurveForm = MFnNurbsCurve::kInvalid; - int acceptableCurveDegree = -1; - MFn::Type foundType = MFn::kInvalid; - for ( unsigned int c = 0; c < childCount; c++ ) - { - MObject childObject = p.child( c ); - MFn::Type type = childObject.apiType(); - - if( type == MFn::kNurbsCurve ) - { - MFnNurbsCurve fnNCurve( childObject ); - - if( acceptableCurveForm == MFnNurbsCurve::kInvalid ) - { - acceptableCurveForm = fnNCurve.form(); - } - else if ( fnNCurve.form() != acceptableCurveForm ) - { - msg( Msg::Warning, p.fullPathName().asChar(), "Found curves with different kind of forms under the same transform!" ); - return false; - } - - int degree = fnNCurve.degree(); - if( degree == 0 ) - { - msg( Msg::Warning, p.fullPathName().asChar(), "Could not get a curve degree!" ); - return false; - } - if( acceptableCurveDegree == -1 ) - { - acceptableCurveDegree = degree; - } - else if ( degree != acceptableCurveDegree ) - { - msg( Msg::Warning, p.fullPathName().asChar(), "Found curves with different degrees under the same transform!" ); - return false; - } - } - - if( type == MFn::kMesh || type == MFn::kNurbsCurve ) - { - if( MFnDagNode( childObject ).isIntermediateObject() ) - { - continue; - } - - if( foundType == MFn::kInvalid ) - { - foundType = type; - } - else if( foundType == type ) - { - isMergeable = true; - } - else - { - msg( Msg::Warning, p.fullPathName().asChar(), "Found multiple shape types under the same transform!" ); - return false; - } - } - } - - return isMergeable; - -} - -ConstObjectPtr readMergedObject( const MDagPath &p ) -{ - unsigned int childCount = p.childCount(); - - IECore::ModifyOpPtr op = NULL; - - for ( unsigned int c = 0; c < childCount; c++ ) - { - MObject childObject = p.child( c ); - MFn::Type type = childObject.apiType(); - - if( type != MFn::kNurbsCurve && type != MFn::kMesh ) - { - continue; - } - - MFnDagNode fnChildDag( childObject ); - if( fnChildDag.isIntermediateObject() ) - { - continue; - } - - MDagPath childDag; - fnChildDag.getPath( childDag ); - - if( ! op ) - { - if( type == MFn::kNurbsCurve ) - { - PrimMerger::createMergeOp( childDag, op ); - } - else - { - PrimMerger::createMergeOp( childDag, op ); - } - } - else - { - if( type == MFn::kNurbsCurve ) - { - PrimMerger::mergePrim( childDag, op ); - } - else - { - PrimMerger::mergePrim( childDag, op ); - } - } - - } - - assert( op ); - return op->inputParameter()->getValue(); -} - -} // anonymous namespace. - -bool LiveScene::hasObject() const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_isRoot ) - { - return false; - } - else if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::hasObject: Dag path no longer exists!" ); - } - - if( hasMergeableObjects( m_dagPath ) ) - { - return true; - } - - for ( std::vector< CustomReader >::const_reverse_iterator it = customObjectReaders().rbegin(); it != customObjectReaders().rend(); it++ ) - { - if ( it->m_has( m_dagPath ) ) - { - return true; - } - } - - // if no custom object was detected, we try the general cortex converter - unsigned int childCount = 0; - m_dagPath.numberOfShapesDirectlyBelow(childCount); - - for ( unsigned int c = 0; c < childCount; c++ ) - { - MDagPath childDag = m_dagPath; - if( childDag.extendToShapeDirectlyBelow( c ) ) - { - MFnDagNode fnChildDag(childDag); - if ( fnChildDag.isIntermediateObject() ) - { - continue; - } - - FromMayaShapeConverterPtr shapeConverter = FromMayaShapeConverter::create( childDag ); - if( shapeConverter ) - { - return true; - } - - FromMayaDagNodeConverterPtr dagConverter = FromMayaDagNodeConverter::create( childDag ); - if( dagConverter ) - { - return true; - } - } - } - - if( runTimeCast (FromMayaDagNodeConverter::create( m_dagPath ) ) ) - { - return true; - } - - return false; -} - -ConstObjectPtr LiveScene::readObject( double time, const IECore::Canceller *canceller ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::readObject: Dag path no longer exists!" ); - } - - double currentMayaTime = MAnimControl::currentTime().as( MTime::kSeconds ); - if( fabs( currentMayaTime - time ) > 1.e-4 ) - { - - throw Exception( - boost::str( - boost::format( "IECoreMaya::LiveScene::readObject: time : %1% must be the same as on the maya timeline : %2% " ) % - time % - currentMayaTime - ) - ); - } - - if ( hasMergeableObjects( m_dagPath ) ) - { - return readMergedObject( m_dagPath ); - } - - for ( std::vector< CustomReader >::const_reverse_iterator it = customObjectReaders().rbegin(); it != customObjectReaders().rend(); it++ ) - { - if ( it->m_has( m_dagPath ) ) - { - return it->m_read( m_dagPath ); - } - } - - // if no custom object was detected, we try the general cortex converter - unsigned int childCount = 0; - m_dagPath.numberOfShapesDirectlyBelow(childCount); - - for ( unsigned int c = 0; c < childCount; c++ ) - { - MDagPath childDag = m_dagPath; - if( childDag.extendToShapeDirectlyBelow( c ) ) - { - MFnDagNode fnChildDag(childDag); - if ( fnChildDag.isIntermediateObject() ) - { - continue; - } - - FromMayaShapeConverterPtr shapeConverter = FromMayaShapeConverter::create( childDag ); - if( shapeConverter ) - { - return shapeConverter->convert(); - } - - FromMayaDagNodeConverterPtr dagConverter = FromMayaDagNodeConverter::create( childDag ); - if( dagConverter ) - { - return dagConverter->convert(); - } - } - } - - if( FromMayaInstancerConverterPtr converter = runTimeCast (FromMayaDagNodeConverter::create( m_dagPath ) ) ) - { - return converter->convert(); - } - - return IECore::NullObject::defaultNullObject(); -} - -PrimitiveVariableMap LiveScene::readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const -{ - // \todo Optimize this function, adding special cases such as for Meshes. - ConstPrimitivePtr prim = runTimeCast< const Primitive >( readObject( time ) ); - if ( !prim ) - { - throw Exception( "Object does not have primitive variables!" ); - } - return prim->variables; -} - -void LiveScene::writeObject( const Object *object, double time ) -{ - throw Exception( "IECoreMaya::LiveScene::writeObject: write operations not supported!" ); -} - -void LiveScene::getChildDags( const MDagPath& dagPath, MDagPathArray& paths ) const -{ - for( unsigned i=0; i < dagPath.childCount(); ++i ) - { - MDagPath childPath = dagPath; - childPath.push( dagPath.child( i ) ); - - // Remove top level nodes which are not serializable - // examples include ground plane, manipulators, hypershade cameras & geometry. - // Perhaps there are cases where non serializable objects need to be exported but - // it might be easier to special case add them then special case remove all unwanted objects - if( dagPath.length() == 0 ) - { - MStatus r; - MFnDependencyNode depNode( childPath.node(), &r ); - if( !r ) - { - continue; - } - - if( !depNode.canBeWritten() ) - { - continue; - } - } - - paths.append( childPath ); - } -} - -void LiveScene::childNames( NameList &childNames ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::childNames: Dag path no longer exists!" ); - } - - unsigned currentPathLength = m_dagPath.fullPathName().length(); - MDagPathArray paths; - getChildDags( m_dagPath, paths ); - - for( unsigned i=0; i < paths.length(); ++i ) - { - if( paths[i].hasFn( MFn::kTransform ) ) - { - std::string childName( paths[i].fullPathName().asChar() + currentPathLength + 1 ); - childNames.push_back( Name( childName ) ); - } - } -} - -bool LiveScene::hasChild( const Name &name ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::childNames: Dag path no longer exists!" ); - } - - unsigned currentPathLength = m_dagPath.fullPathName().length(); - MDagPathArray paths; - getChildDags( m_dagPath, paths ); - - for( unsigned i=0; i < paths.length(); ++i ) - { - if( paths[i].hasFn( MFn::kTransform ) ) - { - std::string childName( paths[i].fullPathName().asChar() + currentPathLength + 1 ); - if( Name( childName ) == name ) - { - return true; - } - } - } - return false; -} - -IECoreScene::SceneInterfacePtr LiveScene::retrieveChild( const Name &name, MissingBehaviour missingBehaviour ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( m_dagPath.length() == 0 && !m_isRoot ) - { - throw Exception( "IECoreMaya::LiveScene::retrieveChild: Dag path no longer exists!" ); - } - - MSelectionList sel; - sel.add( m_dagPath.fullPathName() + "|" + std::string( name ).c_str() ); - - MDagPath path; - sel.getDagPath( 0, path ); - - if( !path.hasFn( MFn::kTransform ) ) - { - if( missingBehaviour == SceneInterface::ThrowIfMissing ) - { - throw Exception( "IECoreMaya::LiveScene::retrieveChild: Couldn't find transform at specified path " + std::string( path.fullPathName().asChar() ) ); - } - return nullptr; - } - - return duplicate( path ); -} - -SceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) -{ - return retrieveChild( name, missingBehaviour ); -} - -ConstSceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) const -{ - return retrieveChild( name, missingBehaviour ); -} - -SceneInterfacePtr LiveScene::createChild( const Name &name ) -{ - return nullptr; -} - -SceneInterfacePtr LiveScene::retrieveScene( const Path &path, MissingBehaviour missingBehaviour ) const -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( path.size() == 0 ) - { - MItDag it; - MDagPath rootPath; - it.getPath( rootPath ); - return duplicate( rootPath, true ); - } - - MString pathName; - - for( Path::const_iterator it=path.begin(); it != path.end(); ++it ) - { - pathName += "|"; - pathName += std::string( *it ).c_str(); - } - - MSelectionList sel; - MStatus st = sel.add( pathName ); - if( !st ) - { - if( missingBehaviour == SceneInterface::ThrowIfMissing ) - { - std::string pathName; - for( size_t i = 0; i < path.size(); ++i ) - { - pathName += std::string( path[i] ) + "/"; - } - - throw Exception( "IECoreMaya::LiveScene::retrieveScene: Couldn't find transform at specified path " + pathName ); - } - return nullptr; - } - - MDagPath dagPath; - sel.getDagPath( 0, dagPath ); - - if( dagPath.hasFn( MFn::kTransform ) ) - { - return duplicate( dagPath ); - } - else - { - if( missingBehaviour == SceneInterface::ThrowIfMissing ) - { - std::string pathName; - for( size_t i = 0; i < path.size(); ++i ) - { - pathName += std::string( path[i] ) + "/"; - } - - throw Exception( "IECoreMaya::LiveScene::retrieveScene: Couldn't find transform at specified path " + pathName ); - } - return nullptr; - } - -} - -ConstSceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) const -{ - return retrieveScene( path, missingBehaviour ); -} - -SceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) -{ - return retrieveScene( path, missingBehaviour ); -} - -void LiveScene::hash( HashType hashType, double time, MurmurHash &h ) const -{ - throw Exception( "Hashes currently not supported in IECoreMaya::LiveScene objects." ); -} - -void LiveScene::dagPathToPath( MDagPath dagPath, IECoreScene::SceneInterface::Path &path ) -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - path.clear(); - - if( dagPath.isValid() ) - { - // Only transforms can be part of the path - if( !dagPath.hasFn( MFn::kTransform ) ) - { - dagPath.pop(); - } - - const std::string pathStr( dagPath.fullPathName().asChar() ); - const boost::tokenizer< boost::char_separator > tokens( pathStr, boost::char_separator( "|" ) ); - for ( const auto &token : tokens ) - { - path.push_back( token ); - } - - return; - } - - throw Exception( "IECoreMaya::LiveScene::dagPathToPath invalid dag path." ); -} - -void LiveScene::pathToDagPath( const IECoreScene::SceneInterface::Path &path, MDagPath &dagPath ) -{ - tbb::recursive_mutex::scoped_lock l( g_mutex ); - - if( path.empty() ) - { - MItDag itDag; - itDag.getPath( dagPath ); - return; - } - - std::string dagPathStr; - for( const auto &name : path ) - { - dagPathStr += "|"; - dagPathStr += name; - } - - MSelectionList sel; - if( sel.add( dagPathStr.c_str() ) && sel.getDagPath( 0, dagPath ) ) - { - return; - } - - // Invalid dag path - std::string pathStr; - IECoreScene::SceneInterface::pathToString( path, pathStr ); - throw Exception( - boost::str( - boost::format( "IECoreMaya::LiveScene::pathToDagPath invalid conversion to dag path from \"%1%\"." ) % pathStr - ) - ); -} - -void LiveScene::registerCustomObject( HasFn hasFn, ReadFn readFn ) -{ - CustomReader r; - r.m_has = hasFn; - r.m_read = readFn; - customObjectReaders().push_back(r); -} - -void LiveScene::registerCustomAttributes( NamesFn namesFn, ReadAttrFn readFn ) -{ - registerCustomAttributes( namesFn, readFn, 0 ); -} - -void LiveScene::registerCustomAttributes( NamesFn namesFn, ReadAttrFn readFn, MightHaveFn mightHaveFn ) -{ - CustomAttributeReader r; - r.m_names = namesFn; - r.m_read = readFn; - r.m_mightHave = mightHaveFn; - customAttributeReaders().push_back(r); -} - -void LiveScene::registerCustomTags( HasTagFn hasFn, ReadTagsFn readFn ) -{ - CustomTagReader r; - r.m_has = hasFn; - r.m_read = readFn; - customTagReaders().push_back( r ); -} - -std::vector &LiveScene::customObjectReaders() -{ - static std::vector readers; - return readers; -} - -std::vector &LiveScene::customAttributeReaders() -{ - static std::vector readers; - return readers; -} - -std::vector &LiveScene::customTagReaders() -{ - static std::vector readers; - return readers; -} - -// If useful, this could be extended to register arbitrary mappings from cortex attr names to maya attr names -// If the mapping exists, and the attribute value is convertible to a maya plug, then the user has the ability -// to override the attribute value (from the perspective of Live Scene) -LiveScene::Name LiveScene::toMayaAttributeName( const LiveScene::Name &name ) -{ - // Scene Visibility - if( name == SceneInterface::visibilityName ) - { - return visibilityOverrideName; - } - - // User Attributes - if( name.string().length() > 5 && boost::starts_with( name.string(), g_userAttrPrefix.string() ) ) - { - std::string attrName = name; - attrName = attrName.substr( 5, attrName.length() - 1 ); - boost::replace_all( attrName, ":", "__" ); - return g_mayaUserAttrPrefix.string() + attrName; - } - - // No corresponding attribute name - return Name(); -} - -LiveScene::Name LiveScene::fromMayaAttributeName( const LiveScene::Name &name ) -{ - // Scene Visibility - if( name == visibilityOverrideName ) - { - return SceneInterface::visibilityName; - } - - // User Attributes - if( name.string().length() > 7 && boost::starts_with( name.string(), g_mayaUserAttrPrefix.string() ) ) - { - std::string attrName = name; - attrName = attrName.substr( 7, attrName.length() - 1 ); - boost::replace_all( attrName, "__", ":" ); - return g_userAttrPrefix.string() + attrName; - } - - // No corresponding attribute name, so return empty string - return Name(); -} diff --git a/src/IECoreMaya/MDataHandleAccessor.cpp b/src/IECoreMaya/MDataHandleAccessor.cpp deleted file mode 100644 index 0de029f850..0000000000 --- a/src/IECoreMaya/MDataHandleAccessor.cpp +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/MDataHandleAccessor.h" - -using namespace IECoreMaya; - -/// Ensure that all specialisations instantiate correctly -template class MDataHandleAccessor< MObject >; -template class MDataHandleAccessor< bool >; -template class MDataHandleAccessor< char >; -template class MDataHandleAccessor< unsigned char >; -template class MDataHandleAccessor< short >; -template class MDataHandleAccessor< int >; -template class MDataHandleAccessor< void* >; -template class MDataHandleAccessor< float >; -template class MDataHandleAccessor< double >; -template class MDataHandleAccessor< MDistance >; -template class MDataHandleAccessor< MAngle >; -template class MDataHandleAccessor< MTime >; -template class MDataHandleAccessor< short2 >; -template class MDataHandleAccessor< int2 >; -template class MDataHandleAccessor< float2 >; -template class MDataHandleAccessor< double2 >; -template class MDataHandleAccessor< short3 >; -template class MDataHandleAccessor< int3 >; -template class MDataHandleAccessor< float3 >; -template class MDataHandleAccessor< double3 >; -template class MDataHandleAccessor< MVector >; -template class MDataHandleAccessor< MFloatVector >; -template class MDataHandleAccessor< MMatrix >; -template class MDataHandleAccessor< MFloatMatrix >; -template class MDataHandleAccessor< MString >; -template class MDataHandleAccessor< MPxData * >; diff --git a/src/IECoreMaya/MayaHeaderGenerator.cpp b/src/IECoreMaya/MayaHeaderGenerator.cpp deleted file mode 100644 index 1f24c581bb..0000000000 --- a/src/IECoreMaya/MayaHeaderGenerator.cpp +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -#define MNoVersionString - -#include "IECore/HeaderGenerator.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/CompoundData.h" - -#include "maya/MGlobal.h" -#include "maya/MFileIO.h" -#include "maya/MAnimControl.h" -#include "maya/MTime.h" - -using namespace IECore; - -namespace IECoreMaya -{ - -static void mayaHeaderGenerator( CompoundObjectPtr header ) -{ - CompoundDataPtr compound = new CompoundData(); - compound->writable()["mayaVersion"] = new StringData( MGlobal::mayaVersion().asChar() ); - compound->writable()["sceneFile"] = new StringData( MFileIO::currentFile().asChar() ); - compound->writable()["currentTime"] = new FloatData( MAnimControl::currentTime().value() ); - compound->writable()["minTime"] = new FloatData( MAnimControl::minTime().value() ); - compound->writable()["maxTime"] = new FloatData( MAnimControl::maxTime().value() ); - compound->writable()["frameRate"] = new FloatData( 1. / MTime( 1., MTime::uiUnit() ).as( MTime::kSeconds ) ); - - header->members()["maya"] = compound; -} - -static bool resIeCoreMaya = HeaderGenerator::registerDataHeaderGenerator( &mayaHeaderGenerator ); - -} diff --git a/src/IECoreMaya/MayaTime.cpp b/src/IECoreMaya/MayaTime.cpp deleted file mode 100644 index 2f91e652af..0000000000 --- a/src/IECoreMaya/MayaTime.cpp +++ /dev/null @@ -1,121 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MTime.h" - -#include "IECore/Exception.h" -#include "IECoreMaya/MayaTime.h" - -using namespace IECore; -using namespace IECoreMaya; - -double MayaTime::fps( MTime::Unit unit ) -{ - unsigned i = 0; - while( m_table[ i ].unit != MTime::kInvalid ) - { - if ( m_table[ i ].unit == unit ) - { - return m_table[ i ].fps; - } - i++; - } - throw Exception( "Invalid time unit!" ); - return 0; -} - -MTime::Unit MayaTime::unit( double fps ) -{ - unsigned i = 0; - while( m_table[ i ].unit != MTime::kInvalid ) - { - if ( m_table[ i ].fps == fps ) - { - return m_table[ i ].unit; - } - i++; - } - throw Exception( "Invalid fps!" ); - return MTime::kInvalid; -} - -MayaTime::TimeTable MayaTime::m_table[] = -{ - // MTime, , Unit -> FPS - { MTime::kHours, 1. / (60 * 60) }, - { MTime::kMinutes, 1. / 60 }, - { MTime::kSeconds, 1.}, - { MTime::kMilliseconds, 1000.}, - { MTime::kGames, 15}, - { MTime::kFilm, 24}, - { MTime::kPALFrame, 25}, - { MTime::kNTSCFrame, 30}, - { MTime::kShowScan, 48}, - { MTime::kPALField, 50}, - { MTime::kNTSCField, 60}, - { MTime::k2FPS, 2}, - { MTime::k3FPS, 3}, - { MTime::k4FPS, 4}, - { MTime::k5FPS, 5}, - { MTime::k6FPS, 6}, - { MTime::k8FPS, 8}, - { MTime::k10FPS, 10}, - { MTime::k12FPS, 12}, - { MTime::k16FPS, 16}, - { MTime::k20FPS, 20}, - { MTime::k40FPS, 40}, - { MTime::k75FPS, 75}, - { MTime::k80FPS, 80}, - { MTime::k100FPS, 100}, - { MTime::k120FPS, 120}, - { MTime::k125FPS, 125}, - { MTime::k150FPS, 150}, - { MTime::k200FPS, 200}, - { MTime::k240FPS, 240}, - { MTime::k250FPS, 250}, - { MTime::k300FPS, 300}, - { MTime::k375FPS, 375}, - { MTime::k400FPS, 400}, - { MTime::k500FPS, 500}, - { MTime::k600FPS, 600}, - { MTime::k750FPS, 750}, - { MTime::k1200FPS, 1200}, - { MTime::k1500FPS, 1500}, - { MTime::k2000FPS, 2000}, - { MTime::k3000FPS, 3000}, - { MTime::k6000FPS, 6000}, - { MTime::kInvalid, 0 } -}; diff --git a/src/IECoreMaya/MeshParameterHandler.cpp b/src/IECoreMaya/MeshParameterHandler.cpp deleted file mode 100644 index 376036da1b..0000000000 --- a/src/IECoreMaya/MeshParameterHandler.cpp +++ /dev/null @@ -1,158 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011 Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/FromMayaMeshConverter.h" -#include "IECoreMaya/MeshParameterHandler.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/ObjectData.h" - -#include "IECoreScene/TypedPrimitiveParameter.h" -#include "IECoreScene/MeshPrimitive.h" - -#include "maya/MFnGenericAttribute.h" -#include "maya/MFnMeshData.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< MeshParameterHandler > registrar( IECoreScene::MeshPrimitiveParameter::staticTypeId(), IECoreScene::MeshPrimitive::staticTypeId() ); - -MStatus MeshParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnGenericAttribute fnGAttr( attribute ); - if( !fnGAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - fnGAttr.addDataAccept( MFnData::kMesh ); - // maya has an odd behaviour whereby a generic attribute with only one accepted datatype will - // transform itself into a typed attribute after file save and load. here we add an accept - // for a second dummy datatype to ensure that the attribute will still be a generic attribute - // when saved and loaded. - fnGAttr.addAccept( DummyDataId ); - - return finishUpdating( parameter, plug ); -} - -MPlug MeshParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - /// Use a generic attribute, so we could eventually accept other ObjectParamter types, too. - MFnGenericAttribute fnGAttr; - MObject attribute = fnGAttr.create( plugName, plugName ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -MStatus MeshParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MFnMeshData fnData; - MObject data = fnData.create(); - - /// \todo Pull in userData from parameter to set up conversion parameters - ToMayaObjectConverterPtr converter = ToMayaObjectConverter::create( p->getValue(), MFn::kMeshData ); - assert(converter); - bool conversionSuccess = converter->convert( data ); - - if ( !conversionSuccess ) - { - return MS::kFailure; - } - - /// \todo It seems like this can occassionally fail, usually with an empty mesh, but sometimes not. Try to establish exactly why. - plug.setValue( data ); - - return MS::kSuccess; -} - -MStatus MeshParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - IECore::ObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject v; - MStatus result = plug.getValue( v ); - if( result ) - { - /// \todo Pull in userData from parameter to set up conversion parameters - FromMayaMeshConverterPtr converter = boost::dynamic_pointer_cast< FromMayaMeshConverter > ( FromMayaObjectConverter::create( v, IECoreScene::MeshPrimitive::staticTypeId() ) ); - assert(converter); - - converter->spaceParameter()->setNumericValue( (int)FromMayaMeshConverter::World ); - p->setValue( converter->convert() ); - return MS::kSuccess; - } - else - { - // technically we should be returning the error status here, but we don't - // as this case appears to be pretty common, and the resulting errors tend to be - // annoying rather than helpful. - // - // the failure to get the plug value appears to be because we don't save - // empty mesh values to file (see ParameterisedHolder::shouldSave). - // this means that when the file is loaded again the plug.getValue() - // method will fail and we end up here. the best thing we can do in this - // case seems to be to assume that the value should be an empty mesh. - p->setValue( new IECoreScene::MeshPrimitive() ); - return MS::kSuccess; - } -} diff --git a/src/IECoreMaya/MessageHandler.cpp b/src/IECoreMaya/MessageHandler.cpp deleted file mode 100644 index 326106949c..0000000000 --- a/src/IECoreMaya/MessageHandler.cpp +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/MessageHandler.h" - -#include "maya/MGlobal.h" - -using namespace IECoreMaya; - -void MessageHandler::handle( Level level, const std::string &context, const std::string &message ) -{ - - // MGlobal.display* seemingly is not thread safe. - std::lock_guard lock( m_mutex ); - - MString m = MString( context.c_str() ) + " : " + message.c_str(); - switch( level ) - { - case MessageHandler::Error : - MGlobal::displayError( m ); - break; - case MessageHandler::Warning : - MGlobal::displayWarning( m ); - break; - case MessageHandler::Info : - case MessageHandler::Debug : - MGlobal::displayInfo( m ); - break; - default : - // do nothing for invalid levels - break; - } -} diff --git a/src/IECoreMaya/NumericParameterHandler.cpp b/src/IECoreMaya/NumericParameterHandler.cpp deleted file mode 100644 index 643bdb7874..0000000000 --- a/src/IECoreMaya/NumericParameterHandler.cpp +++ /dev/null @@ -1,198 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/NumericParameterHandler.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/NumericParameter.h" -#include "IECore/CompoundObject.h" - -#include "maya/MFnNumericAttribute.h" - - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< NumericParameterHandler > intRegistrar( IECore::IntParameter::staticTypeId() ); -static ParameterHandler::Description< NumericParameterHandler > floatRegistrar( IECore::FloatParameter::staticTypeId() ); -static ParameterHandler::Description< NumericParameterHandler > doubleRegistrar( IECore::DoubleParameter::staticTypeId() ); - -template -MStatus NumericParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::NumericParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnNumericAttribute fnNAttr( attribute ); - if( !fnNAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - if( fnNAttr.unitType() != NumericTraits::dataType() ) - { - return MS::kFailure; - } - - fnNAttr.setDefault( p->numericDefaultValue() ); - - if( p->minValue()!=std::numeric_limits::lowest() ) - { - fnNAttr.setMin( p->minValue() ); - } - else - { - // parameter has no min value - if( fnNAttr.hasMin() ) - { - // there is no way of unsetting a minimum value - // in maya. - return MS::kFailure; - } - } - - if( p->maxValue()!=std::numeric_limits::max() ) - { - fnNAttr.setMax( p->maxValue() ); - } - else - { - // parameter has no max value - if( fnNAttr.hasMax() ) - { - // there is no way of unsetting a maximum value - // in maya. - return MS::kFailure; - } - } - - T v; - MStatus result = plug.getValue( v ); - if( result ) - { - IECore::ObjectPtr d = new IECore::TypedData( v ); - if( !parameter->valueValid( d.get() ) ) - { - return MS::kFailure; - } - } - - bool keyable = true; - bool channelBox = true; - - const IECore::ConstCompoundObjectPtr userData = parameter->userData(); - assert( userData ); - - const IECore::ConstCompoundObjectPtr maya = userData->member("maya"); - if (maya) - { - const IECore::ConstBoolDataPtr keyableData = maya->member("keyable"); - if (keyableData) - { - keyable = keyableData->readable(); - } - - const IECore::ConstBoolDataPtr channelBoxData = maya->member("channelBox"); - if (channelBoxData) - { - channelBox = channelBoxData->readable(); - } - } - - fnNAttr.setKeyable( keyable ); - - // Calling setChannelBox(true) disables keying - if (!keyable) - { - fnNAttr.setChannelBox( channelBox ); - } - - return finishUpdating( parameter, plug ); -} - -template -MPlug NumericParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - typename IECore::NumericParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnNumericAttribute fnNAttr; - MObject attribute = fnNAttr.create( plugName, plugName, NumericTraits::dataType(), p->numericDefaultValue() ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus NumericParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::NumericParameter::ConstPtr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - return plug.setValue( p->getNumericValue() ); -} - -template -MStatus NumericParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - typename IECore::NumericParameter::Ptr p = IECore::runTimeCast >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - T v; - MStatus result; - result = plug.getValue( v ); - if( result ) - { - p->setNumericValue( v ); - } - return result; -} diff --git a/src/IECoreMaya/NumericTraits.cpp b/src/IECoreMaya/NumericTraits.cpp deleted file mode 100644 index 6215baad3d..0000000000 --- a/src/IECoreMaya/NumericTraits.cpp +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" - -using namespace IECoreMaya; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::kShort; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::kBoolean; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::kInt; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::kFloat; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::kDouble; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k2Int; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kInt; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k3Int; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kInt; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k2Float; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kFloat; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k3Float; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kFloat; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k2Double; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kDouble; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k3Double; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kDouble; }; - -template<> -MFnNumericData::Type NumericTraits::dataType() { return MFnNumericData::k3Float; }; -template<> -MFnNumericData::Type NumericTraits::baseDataType() { return MFnNumericData::kFloat; }; -template<> -bool NumericTraits::isColor() { return true; }; diff --git a/src/IECoreMaya/ObjectData.cpp b/src/IECoreMaya/ObjectData.cpp deleted file mode 100644 index 7ed8b44755..0000000000 --- a/src/IECoreMaya/ObjectData.cpp +++ /dev/null @@ -1,244 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "boost/type_traits/is_integral.hpp" - -#include "maya/MGlobal.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/MemoryIndexedIO.h" -#include "IECore/HexConversion.h" - -#include "IECoreMaya/ObjectData.h" -#include "IECoreMaya/MayaTypeIds.h" - -using namespace IECore; -using namespace IECoreMaya; - -const MString ObjectData::typeName( "ieObjectData" ); -const MTypeId ObjectData::id( ObjectDataId ); - -ObjectData::ObjectData() : m_copyMode( Deep ), m_object( 0 ) -{ -} - -ObjectData::~ObjectData() -{ -} - -void *ObjectData::creator() -{ - return new ObjectData; -} - -MStatus ObjectData::readASCII( const MArgList &argList, unsigned int &endOfTheLastParsedElement ) -{ - m_object = 0; - - if ( argList.length() == 1 ) - { - MStatus s; - MString str = argList.asString( endOfTheLastParsedElement++, &s ); - - if ( !s ) - { - return s; - } - CharVectorDataPtr buf = new CharVectorData(); - buf->writable().resize( str.length() / 2 ); - IECore::hexToDec( str.asChar(), str.asChar() + str.length(), buf->writable().begin() ); - - try - { - MemoryIndexedIOPtr io = new MemoryIndexedIO( buf, IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Read ); - setObject( Object::load( io, "object" ) ); - return MS::kSuccess; - } - catch ( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - } - else if ( argList.length() == 0 ) - { - - return MS::kSuccess; - } - else - { - return MS::kFailure; - } -} - -MStatus ObjectData::readBinary( istream& in, unsigned length ) -{ - CharVectorDataPtr buf = new CharVectorData( ); - buf->writable().resize( length ); - CharVectorData::ValueType &data = buf->writable(); - - in.read( &data[0], length ); - - try - { - MemoryIndexedIOPtr io = new MemoryIndexedIO( buf, IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Read ); - setObject( Object::load( io, "object" ) ); - return MS::kSuccess; - } - catch ( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } -} - -MStatus ObjectData::writeASCII( ostream& out ) -{ - if ( m_object ) - { - try - { - MemoryIndexedIOPtr io = new MemoryIndexedIO( ConstCharVectorDataPtr(), IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Write ); - - getObject()->save( io, "object" ); - - ConstCharVectorDataPtr buf = io->buffer(); - const CharVectorData::ValueType &data = buf->readable(); - - // for some reason maya's parser is quicker to parse and concatenate a series of shorter strings - // than it is to parse a single long string. so we output lots of little string concatenations in order to - // speed up the reading. - out << "( \n"; - - const size_t chunkSize = 5000; - for( size_t i = 0; i < data.size(); i += chunkSize ) - { - if( i!=0 ) - { - out << " + "; - } - out << "\""; - out << decToHex( data.begin() + i, data.begin() + std::min( data.size(), i + chunkSize ) ); - out << "\"\n"; - } - - out << ")\n"; - - } - catch ( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - } - - return MS::kSuccess; -} - -MStatus ObjectData::writeBinary( ostream& out ) -{ - if ( m_object ) - { - try - { - MemoryIndexedIOPtr io = new MemoryIndexedIO( ConstCharVectorDataPtr(), IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Write ); - - getObject()->save( io, "object" ); - - ConstCharVectorDataPtr buf = io->buffer(); - const CharVectorData::ValueType &data = buf->readable(); - - int sz = data.size(); - out.write( &data[0], sz ); - } - catch ( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - } - - return MS::kSuccess; -} - -void ObjectData::setCopyMode( CopyMode mode ) -{ - m_copyMode = mode; -} - -ObjectData::CopyMode ObjectData::getCopyMode() const -{ - return m_copyMode; -} - -void ObjectData::copy( const MPxData &other ) -{ - const ObjectData *otherData = dynamic_cast( &other ); - if( otherData->m_copyMode==Deep ) - { - m_object = otherData->m_object ? otherData->m_object->copy() : 0; - } - else - { - m_object = otherData->m_object; - } - m_copyMode = otherData->m_copyMode; -} - -MTypeId ObjectData::typeId() const -{ - return id; -} - -MString ObjectData::name() const -{ - return typeName; -} - -ObjectPtr ObjectData::getObject() -{ - return m_object; -} - -ConstObjectPtr ObjectData::getObject() const -{ - return m_object; -} - -void ObjectData::setObject( ObjectPtr otherObject ) -{ - m_object = otherObject; -} diff --git a/src/IECoreMaya/ObjectMFnDataParameterHandler.cpp b/src/IECoreMaya/ObjectMFnDataParameterHandler.cpp deleted file mode 100644 index 914df20a7b..0000000000 --- a/src/IECoreMaya/ObjectMFnDataParameterHandler.cpp +++ /dev/null @@ -1,178 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/ObjectMFnDataParameterHandler.h" -#include "IECoreMaya/MFnDataTypeTraits.h" - -#include "IECore/VectorTypedData.h" -#include "IECore/SimpleTypedParameter.h" -#include "IECore/VectorTypedParameter.h" -#include "IECore/CompoundParameter.h" -#include "IECore/CompoundObject.h" -#include "IECore/ObjectParameter.h" - -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/ObjectData.h" - -#include "maya/MFnData.h" -#include "maya/MFnGenericAttribute.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::V3fVectorParameter, MFnData::kVectorArray > > v3fVectorRegistrar( IECore::V3fVectorParameter::staticTypeId(), IECore::V3fVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::V3dVectorParameter, MFnData::kVectorArray > > v3dVectorRegistrar( IECore::V3dVectorParameter::staticTypeId(), IECore::V3dVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::M44fParameter, MFnData::kMatrix > > m44fRegistrar( IECore::M44fParameter::staticTypeId(), IECore::M44fData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::M44dParameter, MFnData::kMatrix > > m44dRegistrar( IECore::M44dParameter::staticTypeId(), IECore::M44dData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::FloatVectorParameter, MFnData::kDoubleArray > > floatVectorRegistrar( IECore::FloatVectorParameter::staticTypeId(), IECore::FloatVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::DoubleVectorParameter, MFnData::kDoubleArray > > doubleVectorRegistrar( IECore::DoubleVectorParameter::staticTypeId(), IECore::DoubleVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::IntVectorParameter, MFnData::kIntArray > > intVectorRegistrar( IECore::IntVectorParameter::staticTypeId(), IECore::IntVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::BoolVectorParameter, MFnData::kIntArray > > boolVectorRegistrar( IECore::BoolVectorParameter::staticTypeId(), IECore::BoolVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::M44fVectorParameter, MFnData::kDoubleArray > > m44fVectorRegistrar( IECore::M44fVectorParameter::staticTypeId(), IECore::M44fVectorData::staticTypeId() ); -ParameterHandler::Description< ObjectMFnDataParameterHandler< IECore::M44dVectorParameter, MFnData::kDoubleArray > > m44dVectorRegistrar( IECore::M44dVectorParameter::staticTypeId(), IECore::M44dVectorData::staticTypeId() ); - -template -MStatus ObjectMFnDataParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if (!IECore::runTimeCast( parameter ) && !IECore::runTimeCast( parameter )) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnGenericAttribute fnGAttr( attribute ); - if( !fnGAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - fnGAttr.addDataAccept( D ); - // maya has an odd behaviour whereby a generic attribute with only one accepted datatype will - // transform itself into a typed attribute after file save and load. here we add an accept - // for a second dummy datatype to ensure that the attribute will still be a generic attribute - // when saved and loaded. - fnGAttr.addAccept( DummyDataId ); - - return finishUpdating( parameter, plug ); -} - -template -MPlug ObjectMFnDataParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - if (!IECore::runTimeCast( parameter ) && !IECore::runTimeCast( parameter )) - { - return MPlug(); - } - - /// Use a generic attribute, so we could eventually accept other ObjectParamter types, too. - MStatus s; - MFnGenericAttribute fnGAttr; - MObject attribute = fnGAttr.create( plugName, plugName, &s ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -template -MStatus ObjectMFnDataParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - if (!IECore::runTimeCast( parameter ) && !IECore::runTimeCast( parameter )) - { - return MS::kFailure; - } - - typedef IECore::TypedData Data; - - assert( parameter->getValue() ); - typename Data::ConstPtr v = IECore::runTimeCast( parameter->getValue() ); - - /// It's OK for this cast to fail, for example if a parameter type has changed from V3fVectorData to V3dVectorData. This can - /// happen when scenes are reopened. The ObjectParameterHandler will just try other ways of setting the value instead. - if (!v) - { - return MS::kFailure; - } - - ToMayaObjectConverterPtr converter = ToMayaObjectConverter::create( v, MFnDataTypeTraits::dataType() ); - if( !converter ) - { - return MS::kFailure; - } - - MObject obj; - bool success = converter->convert( obj ); - if (!success) - { - return MS::kFailure; - } - - assert( obj != MObject::kNullObj ); - - return plug.setValue( obj ); -} - -template -MStatus ObjectMFnDataParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - if (!IECore::runTimeCast( parameter ) && !IECore::runTimeCast( parameter )) - { - return MS::kFailure; - } - - MObject obj; - MStatus result = plug.getValue( obj ); - if (!result) - { - return MS::kFailure; - } - - FromMayaObjectConverterPtr converter = FromMayaObjectConverter::create( obj, T::ObjectType::staticTypeId() ); - /// It's OK if there's no converter - the ObjectParameterHandler will just try other ways of setting the value instead. - if (!converter) - { - return MS::kFailure; - } - - IECore::ObjectPtr v = converter->convert(); - assert( v ); - - parameter->setValue( v ); - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ObjectParameterHandler.cpp b/src/IECoreMaya/ObjectParameterHandler.cpp deleted file mode 100644 index ce1d0a6093..0000000000 --- a/src/IECoreMaya/ObjectParameterHandler.cpp +++ /dev/null @@ -1,205 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/ObjectParameterHandler.h" -#include "IECoreMaya/ObjectData.h" -#include "IECoreMaya/MayaTypeIds.h" - -#include "IECore/ObjectParameter.h" -#include "IECoreScene/MeshPrimitive.h" - -#include "maya/MFnGenericAttribute.h" -#include "maya/MPlug.h" -#include "maya/MFnPluginData.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< ObjectParameterHandler > registrar( IECore::ObjectParameter::staticTypeId() ); - -MStatus ObjectParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnGenericAttribute fnGAttr( attribute ); - if( !fnGAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - fnGAttr.addAccept( ObjectData::id ); - // maya has an odd behaviour whereby a generic attribute with only one accepted datatype will - // transform itself into a typed attribute after file save and load. here we add an accept - // for a second dummy datatype to ensure that the attribute will still be a generic attribute - // when saved and loaded. - fnGAttr.addAccept( DummyDataId ); - - for (IECore::ObjectParameter::TypeIdSet::const_iterator it = p->validTypes().begin(); it != p->validTypes().end(); ++it) - { - ConstParameterHandlerPtr h = ParameterHandler::create( *it ); - if (h) - { - if ( !h->doUpdate( parameter, plug ) ) - { - return MS::kFailure; - } - } - } - - return finishUpdating( parameter, plug ); -} - -MPlug ObjectParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnGenericAttribute fnGAttr; - MObject attribute = fnGAttr.create( plugName, plugName ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -MStatus ObjectParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - // Keep trying all the available handlers until we find one that works. - /// \todo Investigate whether we can do a parameter->getValue() here and just get the handler which represents it - for (IECore::ObjectParameter::TypeIdSet::const_iterator it = p->validTypes().begin(); it != p->validTypes().end(); ++it) - { - ConstParameterHandlerPtr h = ParameterHandler::create( *it ); - if (h) - { - if ( h->doSetValue( parameter, plug) ) - { - return MS::kSuccess; - } - } - } - - MStatus s; - - MFnPluginData fnData; - MObject plugData = fnData.create( ObjectData::id ); - assert( plugData != MObject::kNullObj ); - - s = fnData.setObject( plugData ); - assert(s); - - ObjectData* data = dynamic_cast( fnData.data(&s) ); - assert(s); - assert(data); - - data->setObject( p->getValue()->copy() ); - return plug.setValue( plugData ); -} - -MStatus ObjectParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - IECore::ObjectParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - /// Keep trying all the available handlers until we find one that works - for (IECore::ObjectParameter::TypeIdSet::const_iterator it = p->validTypes().begin(); it != p->validTypes().end(); ++it) - { - ConstParameterHandlerPtr h = ParameterHandler::create( *it ); - if (h) - { - if ( h->doSetValue( plug, parameter ) ) - { - return MS::kSuccess; - } - } - } - - MStatus s; - MObject plugData; - s = plug.getValue( plugData ); - if (!s) - { - // We might be here as the attribute isn't storable, - // in that case we set the parameter to its default value. - // If it is storable, then something has gone awry. - MFnAttribute fnA( plug.attribute() ); - bool isStorable = fnA.isStorable( &s ); - if( s && !isStorable ) - { - parameter->setValue( parameter->defaultValue()->copy() ); - return MS::kSuccess; - } - else - { - return MS::kFailure; - } - } - - MFnPluginData fnData( plugData, &s ); - if (!s) - { - return MS::kFailure; - } - - ObjectData *data = dynamic_cast( fnData.data( &s ) ); - if (!data || !s) - { - return MS::kFailure; - } - - parameter->setValue( data->getObject() ); - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ObjectVectorParameterHandler.cpp b/src/IECoreMaya/ObjectVectorParameterHandler.cpp deleted file mode 100644 index 8b7d253a67..0000000000 --- a/src/IECoreMaya/ObjectVectorParameterHandler.cpp +++ /dev/null @@ -1,138 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ObjectVectorParameterHandler.h" -#include "IECoreMaya/FromMayaPlugConverter.h" -#include "IECoreMaya/ObjectData.h" - -#include "IECore/MessageHandler.h" -#include "IECore/ObjectVector.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "maya/MFnTypedAttribute.h" - -using namespace std; -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -static ParameterHandler::Description< ObjectVectorParameterHandler > registrar( ObjectVectorParameter::staticTypeId() ); - -MPlug ObjectVectorParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - ConstObjectVectorParameterPtr p = IECore::runTimeCast< const ObjectVectorParameter >( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnTypedAttribute fnTAttr; - MObject attribute = fnTAttr.create( plugName, plugName, ObjectData::id ); - fnTAttr.setArray( true ); - fnTAttr.setDisconnectBehavior( MFnAttribute::kDelete ); - - MPlug result = finishCreating( parameter, attribute, node ); - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); - } - - return result; -} - -MStatus ObjectVectorParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - ConstObjectVectorParameterPtr p = IECore::runTimeCast< const ObjectVectorParameter >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if( !fnTAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - return finishUpdating( parameter, plug ); -} - -MStatus ObjectVectorParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - ConstObjectVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - /// \todo Can we implement this? - - return MS::kSuccess; -} - -MStatus ObjectVectorParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - ObjectVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MStatus s; - - ObjectVectorPtr v = new ObjectVector; - - unsigned numElements = const_cast( plug ).evaluateNumElements(); - for( unsigned i=0; iconvert(); - } - - v->members().resize( std::max( elementPlug.logicalIndex() + 1, v->members().size() ), 0 ); - v->members()[elementPlug.logicalIndex()] = obj; - } - - p->setValue( v ); - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/OpHolder.cpp b/src/IECoreMaya/OpHolder.cpp deleted file mode 100644 index c8c1ad9ba9..0000000000 --- a/src/IECoreMaya/OpHolder.cpp +++ /dev/null @@ -1,295 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" -#include -#include - -#include "boost/format.hpp" - -#include "maya/MPxNode.h" -#include "maya/MPlugArray.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnAttribute.h" -#include "maya/MDGModifier.h" -#include "maya/MGlobal.h" -#include "maya/MFnNumericAttribute.h" - -#include "IECoreMaya/OpHolder.h" -#include "IECoreMaya/ParameterHandler.h" -#include "IECoreMaya/MayaTypeIds.h" - -#include "IECore/MessageHandler.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Object.h" -#include "IECore/TypedParameter.h" -#include "IECore/Parameterised.h" - -#include "IECorePython/ScopedGILLock.h" - -using namespace IECore; -using namespace IECoreMaya; - -template -MObject OpHolder::aResultDependency; - -// this post load callback is used to dirty the result plug -// following loading - see further comments in initialize. -template -class OpHolder::PostLoadCallback : public IECoreMaya::PostLoadCallback -{ - - public : - - PostLoadCallback( OpHolder *node ) - : m_node( node ) - { - } - - protected : - - OpHolder *m_node; - - virtual void postLoad() - { - MFnDependencyNode fnDN( m_node->thisMObject() ); - - MPlug plug = fnDN.findPlug( aResultDependency, false ); - plug.setValue( 1 ); - - m_node->m_postLoadCallback = 0; // remove this callback - } - -}; - -template -OpHolder::OpHolder() -{ - m_postLoadCallback = new PostLoadCallback( this ); -} - -template -OpHolder::~OpHolder() -{ -} - -template -void *OpHolder::creator() -{ - return new OpHolder(); -} - -template -MStatus OpHolder::initialize() -{ - MStatus s = OpHolder::inheritAttributesFrom( ParameterisedHolder::typeName ); - if( !s ) - { - return s; - } - - // when we create the result attribute in createResultAttribute(), we make it - // non-storable. it's common for the result to be a large object such as a mesh so - // storing it would be prohibitively expensive, and in any case it doesn't make sense to - // store something which can be recomputed. - // - // however, that causes problems because maya seems incapable of realising that because - // it didn't save the attribute in the file, it can't possibly have a valid value. - // maya also doesn't call setDependentsDirty() during scene open, so we don't get a - // chance to dirty the result at that point either. to work around this, we create this dummy dependency - // attribute, which we change the value of in a post load callback. this value change - // triggers setDependentsDirty and we're able to dirty the result before anyone tries to use - // it. see FnParameterisedHolderTest.testResultAttrSaveLoad() for a test case exercising this - // workaround. - MFnNumericAttribute fnNAttr; - aResultDependency = fnNAttr.create( "resultDependency", "rdep", MFnNumericData::kInt, 0 ); - fnNAttr.setStorable( false ); - fnNAttr.setHidden( true ); - - return B::addAttribute( aResultDependency ); -} - -template -MStatus OpHolder::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - - /// This isn't the best way of doing it, but at this point we can't even be sure that the Op has been loaded, - /// so calling plugParameter() may not work. We can't call getOp() or getParameterised() here, as it seems - /// we can't do things such as adding/removing attributes within this function - if( std::string( plug.partialName().substring( 0, 4 ).asChar() ) == ParameterisedHolder::g_attributeNamePrefix || plug==aResultDependency ) - { - MFnDependencyNode fnDN( B::thisMObject() ); - MStatus s; - MPlug resultPlug = fnDN.findPlug( "result" , false, &s); - if ( s && !resultPlug.isNull() ) - { - plugArray.append( resultPlug ); - } - } - - return ParameterisedHolder::setDependentsDirty( plug, plugArray ); -} - -template -MStatus OpHolder::compute( const MPlug &plug, MDataBlock &block ) -{ - IECore::OpPtr op = getOp(); - - if (op) - { - MFnDependencyNode fnDN( B::thisMObject() ); - MPlug resultPlug( B::thisMObject(), fnDN.attribute( "result" ) ); - - if (plug != resultPlug) - { - return MS::kUnknownParameter; - } - - IECore::ObjectPtr result; - - try - { - ParameterisedHolder::setParameterisedValues( true /* lazy */ ); - result = op->operate(); - if (!result) - { - return MS::kFailure; - } - } - catch( std::exception &e ) - { - MGlobal::displayError( e.what() ); - return MS::kFailure; - } - catch( boost::python::error_already_set &e ) - { - IECorePython::ScopedGILLock lock; - PyErr_Print(); - return MS::kFailure; - } - catch (...) - { - return MS::kFailure; - } - - assert( result ); - MStatus s = ParameterHandler::setValue( op->resultParameter(), resultPlug ); - - block.setClean( resultPlug ); - - return s; - } - - return MS::kFailure; -} - -template -MStatus OpHolder::setParameterised( IECore::RunTimeTypedPtr p ) -{ - MStatus s = ParameterisedHolder::setParameterised( p ); - if( !s ) - { - return s; - } - - return createResultAttribute(); -} - -template -IECore::RunTimeTypedPtr OpHolder::getParameterised( std::string *classNameOut, int *classVersionOut, std::string *searchPathEnvVarOut ) -{ - bool mustCreateResultAttribute = !ParameterisedHolder::m_parameterised; - - IECore::RunTimeTypedPtr result = ParameterisedHolder::getParameterised( classNameOut, classVersionOut, searchPathEnvVarOut ); - if( result && mustCreateResultAttribute ) - { - MStatus s = createResultAttribute(); - if( !s ) - { - ParameterisedHolder::m_parameterised = 0; - ParameterisedHolder::m_failedToLoad = true; - } - } - - return result; -} - -template -MStatus OpHolder::createResultAttribute() -{ - IECore::OpPtr op = IECore::runTimeCast( ParameterisedHolder::m_parameterised ); - - if( !op ) - { - MString nodeName = ParameterisedHolder::name(); - msg( Msg::Error, "OpHolder::createResultAttribute", boost::format( "No Op found on node \"%s\"." ) % nodeName.asChar() ); - return MStatus::kFailure; - } - - MStatus s = ParameterisedHolder::createOrUpdateAttribute( const_cast( op->resultParameter() ), "result" ); - if( !s ) - { - MString nodeName = ParameterisedHolder::name(); - msg( Msg::Error, "OpHolder::createResultAttribute", boost::format( "Unable to update result attribute to represent class \"%s\" on node \"%s\"." ) % op->typeName() % nodeName.asChar() ); - return s; - } - - MFnDependencyNode fnDN( B::thisMObject() ); - MObject attribute = fnDN.attribute( "result" ); - - MFnAttribute fnAttr( attribute ); - fnAttr.setWritable( false ); - fnAttr.setStorable( false ); - - return MStatus::kSuccess; -} - -template -MStatus OpHolder::setOp( const std::string &className, int classVersion ) -{ - return ParameterisedHolder::setParameterised( className, classVersion, "IECORE_OP_PATHS"); -} - -template -IECore::OpPtr OpHolder::getOp( std::string *className, int *classVersion, std::string *searchPathEnvVar ) -{ - return IECore::runTimeCast( getParameterised( className, classVersion, searchPathEnvVar ) ); -} - - -template<> -MTypeId OpHolderNode::id( OpHolderNodeId ); - -template class OpHolder; - diff --git a/src/IECoreMaya/ParameterHandler.cpp b/src/IECoreMaya/ParameterHandler.cpp deleted file mode 100644 index 1ed39663ec..0000000000 --- a/src/IECoreMaya/ParameterHandler.cpp +++ /dev/null @@ -1,241 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MFnExpression.h" -#include "maya/MFnDagNode.h" -#include "maya/MDGModifier.h" -#include "maya/MFnAttribute.h" - -#include "IECore/CompoundObject.h" -#include "IECore/SimpleTypedData.h" - -#include "IECoreMaya/ParameterHandler.h" - -using namespace IECoreMaya; - -ParameterHandler::~ParameterHandler() -{ -} - -MPlug ParameterHandler::create( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) -{ - assert( parameter ); - assert( plugName.length() ); - - ConstParameterHandlerPtr h = create( parameter ); - if( !h ) - { - return MPlug(); - } - return h->doCreate( parameter, plugName, node ); -} - -MStatus ParameterHandler::update( IECore::ConstParameterPtr parameter, MPlug &plug ) -{ - assert( parameter ); - - ConstParameterHandlerPtr h = ParameterHandler::create( parameter ); - if( !h ) - { - return MS::kFailure; - } - return h->doUpdate( parameter, plug ); -} - -MStatus ParameterHandler::setValue( IECore::ConstParameterPtr parameter, MPlug &plug ) -{ - assert( parameter ); - assert( ! plug.isNull() ); - - if ( plug.isFreeToChange( false, true ) == MPlug::kFreeToChange ) - { - ConstParameterHandlerPtr h = ParameterHandler::create( parameter ); - if( !h ) - { - return MS::kFailure; - } - return h->doSetValue( parameter, plug ); - } - else - { - return MS::kSuccess; - } -} - -MStatus ParameterHandler::setValue( const MPlug &plug, IECore::ParameterPtr parameter ) -{ - assert( parameter ); - assert( ! plug.isNull() ); - - ConstParameterHandlerPtr h = ParameterHandler::create( boost::static_pointer_cast< const IECore::Parameter > (parameter) ); - if( !h ) - { - return MS::kFailure; - } - return h->doSetValue( plug, parameter ); -} - -MStatus ParameterHandler::restore( const MPlug &plug, IECore::ParameterPtr parameter ) -{ - assert( parameter ); - assert( ! plug.isNull() ); - - ConstParameterHandlerPtr h = ParameterHandler::create( boost::static_pointer_cast (parameter) ); - if( !h ) - { - return MS::kFailure; - } - return h->doRestore( plug, parameter ); -} - -ConstParameterHandlerPtr ParameterHandler::create( IECore::ConstParameterPtr parameter ) -{ - return create( parameter->typeId() ); -} - -ConstParameterHandlerPtr ParameterHandler::create( IECore::ConstObjectPtr object ) -{ - return create( object->typeId() ); -} - -ConstParameterHandlerPtr ParameterHandler::create( IECore::TypeId id ) -{ - const HandlerMap &h = handlers(); - - do { - HandlerMap::const_iterator it = h.find( id ); - if( it!=h.end() ) - { - return it->second; - } - id = IECore::RunTimeTyped::baseTypeId( id ); - } while( id!=IECore::InvalidTypeId ); - - return 0; -} - -ParameterHandler::HandlerMap &ParameterHandler::handlers() -{ - static HandlerMap *g_handlers = new HandlerMap(); - - return *g_handlers; -} - -void ParameterHandler::registerHandler( IECore::TypeId parameterType, IECore::TypeId dataType, ConstParameterHandlerPtr handler ) -{ - assert( parameterType != IECore::InvalidTypeId ); - handlers()[parameterType] = handler; - - if ( dataType != IECore::InvalidTypeId ) - { - handlers()[dataType] = handler; - } -} - -MPlug ParameterHandler::finishCreating( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - // create default connections and expressions - - IECore::ConstCompoundObjectPtr mayaUserData = parameter->userData()->member( "maya" ); - if( mayaUserData ) - { - MObject node = plug.node(); - - MFnDependencyNode fnDN( node ); - MString nodeName = fnDN.name(); - MFnDagNode fnDAGN( node ); - if( fnDAGN.hasObj( node ) ) - { - nodeName = fnDAGN.fullPathName(); - } - - IECore::ConstStringDataPtr defaultConnection = mayaUserData->member( "defaultConnection" ); - if( defaultConnection ) - { - std::string cmd = std::string( "connectAttr " ) + defaultConnection->readable() + " " + nodeName.asChar() + "." + plug.partialName().asChar(); - MDGModifier dgMod; - dgMod.commandToExecute( cmd.c_str() ); - dgMod.doIt(); - } - IECore::ConstStringDataPtr defaultExpression = mayaUserData->member( "defaultExpression" ); - if( defaultExpression ) - { - MString cmd = nodeName + "." + plug.partialName() + defaultExpression->readable().c_str(); - MFnExpression expFn; - expFn.create( cmd ); - } - } - - - return plug; -} - -MPlug ParameterHandler::finishCreating( IECore::ConstParameterPtr parameter, MObject &attribute, MObject &node ) const -{ - MFnDependencyNode fnNode( node ); - fnNode.addAttribute( attribute ); - MPlug plug( node, attribute ); - return finishCreating( parameter, plug ); -} - -MStatus ParameterHandler::finishUpdating( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - MStatus status = MS::kSuccess; - - IECore::ConstCompoundObjectPtr mayaUserData = parameter->userData()->member( "maya" ); - if( mayaUserData ) - { - IECore::ConstBoolDataPtr storable = mayaUserData->member( "storable" ); - if( storable ) - { - MFnAttribute fnA( plug.attribute() ); - status = fnA.setStorable( storable->readable() ); - } - } - - return status; -} - -MStatus ParameterHandler::finishUpdating( IECore::ConstParameterPtr parameter, MObject &attribute, MObject &node ) const -{ - MFnDependencyNode fnNode( node ); - fnNode.addAttribute( attribute ); - MPlug plug( node, attribute ); - return finishUpdating( parameter, plug ); -} - -MStatus ParameterHandler::doRestore( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ParameterManipContainer.cpp b/src/IECoreMaya/ParameterManipContainer.cpp deleted file mode 100644 index 236461dcbf..0000000000 --- a/src/IECoreMaya/ParameterManipContainer.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -#include "IECoreMaya/ParameterManipContainer.h" - -using namespace IECoreMaya; - -ParameterManipContainer::ParameterManipContainer() - : m_label( "" ) -{ -} - -void ParameterManipContainer::setPlug( MPlug &plug ) -{ - m_plug = plug; -} - -MPlug ParameterManipContainer::getPlug() -{ - return m_plug; -} - -void ParameterManipContainer::setLabel( MString &label ) -{ - m_label = label; -} - -MString ParameterManipContainer::getLabel() -{ - return m_label; -} - diff --git a/src/IECoreMaya/ParameterisedHolder.cpp b/src/IECoreMaya/ParameterisedHolder.cpp deleted file mode 100644 index c93e933e52..0000000000 --- a/src/IECoreMaya/ParameterisedHolder.cpp +++ /dev/null @@ -1,917 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" -#include "boost/format.hpp" -#include "boost/tokenizer.hpp" - -#include "IECoreMaya/Export.h" -IECORE_PUSH_DEFAULT_VISIBILITY -#include "maya/MPxNode.h" -#include "maya/MPxLocatorNode.h" -#include "maya/MPxDeformerNode.h" -#include "maya/MPxObjectSet.h" -#include "maya/MPxFieldNode.h" -#include "maya/MPxSurfaceShape.h" -#include "maya/MPxComponentShape.h" -#include "maya/MPxImagePlane.h" -IECORE_POP_DEFAULT_VISIBILITY - -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnCompoundAttribute.h" -#include "maya/MObjectArray.h" -#include "maya/MPlugArray.h" -#include "maya/MDGModifier.h" -#include "maya/MNodeMessage.h" -#include "maya/MFnPluginData.h" -#include "maya/MFnMesh.h" -#include "maya/MFnGenericAttribute.h" -#include "maya/MPxManipContainer.h" -#undef None // must come after certain Maya includes which include X11/X.h - -#include "IECoreMaya/ParameterisedHolder.h" -#include "IECoreMaya/ParameterHandler.h" -#include "IECoreMaya/PythonCmd.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/ObjectData.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/MessageHandler.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Object.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/ObjectVector.h" -#include "IECore/ObjectParameter.h" - -#include - -using namespace IECore; -using namespace IECoreMaya; -using namespace boost::python; -using namespace boost; -using namespace std; - -template -MObject ParameterisedHolder::aParameterisedClassName; -template -MObject ParameterisedHolder::aParameterisedVersion; -template -MObject ParameterisedHolder::aParameterisedSearchPathEnvVar; - -template -const std::string ParameterisedHolder::g_attributeNamePrefix = "parm_"; - -template -ParameterisedHolder::PLCB::PLCB( ParameterisedHolder *node) : m_node(node) -{ -} - -template -void ParameterisedHolder::PLCB::postLoad() -{ - assert(m_node); - m_node->getParameterised(); - // remove the callback so we don't do this again later when other files are imported etc. - m_node->m_plcb = 0; -} - -template -ParameterisedHolder::ParameterisedHolder() - : m_parameterised( 0 ), m_failedToLoad( false ) -{ - m_plcb = new PLCB( this ); -} - -template -ParameterisedHolder::~ParameterisedHolder() -{ -} - -template -void ParameterisedHolder::postConstructor() -{ - B::setExistWithoutInConnections(true); - B::setExistWithoutOutConnections(true); -} - -template -MStatus ParameterisedHolder::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - if( plug==aParameterisedClassName || plug==aParameterisedVersion || plug==aParameterisedSearchPathEnvVar ) - { - // if the held class changes in any way then we ditch it so we're forced to reload - // in getParameterised(). - m_parameterised = 0; - m_failedToLoad = false; - } - else - { - // if the plug represents a parameter then we add that parameter to a list - // of dirty parameters. this lets us optimise setParameterisedValues so we only - // set the values of parameters whose plugs have changed since last time. - // we only bother doing this if we've loaded the class already, as calling plugParameter() - // would otherwise cause a premature loading of the class. when we load the class all parameters - // are marked as dirty anyway so there's no point worrying about it here. - if( m_parameterised ) - { - MPlug p = plug; - ParameterPtr parameter = 0; - do - { - parameter = plugParameter( p ); - if( p.isChild() ) - { - p = p.parent(); - } - else if( p.isElement() ) - { - p = p.array(); - } - else - { - p = MPlug(); - } - } while( !parameter && !p.isNull() ); - if( parameter ) - { - m_dirtyParameters.insert( parameter ); - } - } - } - - return B::setDependentsDirty( plug, plugArray ); -} - -template -MStatus ParameterisedHolder::shouldSave( const MPlug &plug, bool &isSaving ) -{ - ParameterPtr parameter = plugParameter( plug ); - if( parameter ) - { - // For parameters we found in the parameter map, we always handle - // them ourselves, setting isSaving to either true or false, - // and returning kSuccess, which means "Ignore the default behaviour" - // There is no particular reason not use the standard behaviour - // of calling the parent shouldSave, but instead we set isSaving - // to always true and store our parm_ attributes even when they - // are at default values. This is because it used to work that way - // for all parms, and Lucio is concerned that changing this - // could break something - isSaving = true; - - - /// Maya 8.5 and 2009 crash when saving a GenericAttribute (such as that - /// created by the MeshParameterHandler) containing an "empty" mesh. - /// This only applies to ASCII files, saving to binary works. Here - /// we prevent Maya saving the value. - MFnGenericAttribute fnGA; - if( fnGA.hasObj( plug.attribute() ) ) - { - MObject value = plug.asMObject(); - MFnMesh fnMesh( value ); - if( fnMesh.hasObj( value ) && fnMesh.numPolygons()==0 ) - { - isSaving = false; - } - } - - return MS::kSuccess; - } - else - { - // For parameters that aren't special, use the default behaviour of - // the base class. - // NOTE: This is not very clear in the documentation, but for most - // parameters, the default behaviour is to not touch isSaving, - // and return kUnknownParameter, which Maya interprets as meaning - // that we're not doing anything special, so use the default - // behaviour. Maya then checks whether the plug has changed from - // default, and exports it if it has - return B::shouldSave( plug, isSaving ); - } -} - -template -void *ParameterisedHolder::creator() -{ - return new ParameterisedHolder(); -} - -template -MStatus ParameterisedHolder::initialize() -{ - MStatus s; - MFnTypedAttribute tAttr; - MFnNumericAttribute nAttr; - - aParameterisedClassName = tAttr.create( "className", "clas", MFnData::kString ); - tAttr.setReadable(true); - tAttr.setWritable(true); - tAttr.setStorable(true); - tAttr.setConnectable(false); - tAttr.setHidden(true); - - s = B::addAttribute( aParameterisedClassName ); - assert(s); - - aParameterisedVersion = nAttr.create("version", "ver", MFnNumericData::kInt, 1, &s ); - assert(s); - nAttr.setReadable(true); - nAttr.setWritable(true); - nAttr.setStorable(true); - nAttr.setConnectable(false); - nAttr.setHidden(true); - - - s = B::addAttribute( aParameterisedVersion ); - assert(s); - - aParameterisedSearchPathEnvVar = tAttr.create("searchPathEnvVar", "spev", MFnData::kString ); - tAttr.setReadable(true); - tAttr.setWritable(true); - tAttr.setStorable(true); - tAttr.setConnectable(false); - tAttr.setHidden(true); - - s = B::addAttribute( aParameterisedSearchPathEnvVar ); - assert(s); - - MPxManipContainer::addToManipConnectTable( id ); - - return MS::kSuccess; -} - -template -MStatus ParameterisedHolder::setParameterised( IECore::RunTimeTypedPtr p ) -{ - MPlug pClassName( B::thisMObject(), aParameterisedClassName ); - MPlug pVersion( B::thisMObject(), aParameterisedVersion ); - MPlug pSearchPathEnvVar( B::thisMObject(), aParameterisedSearchPathEnvVar ); - pClassName.setValue( "" ); - pVersion.setValue( 0 ); - pSearchPathEnvVar.setValue( "" ); - - m_parameterised = p; - m_failedToLoad = false; - - MStatus s = createAndRemoveAttributes(); - if( !s ) - { - m_parameterised = 0; - return s; - } - - return MStatus::kSuccess; -} - -template -MStatus ParameterisedHolder::setParameterised( const std::string &className, int classVersion, const std::string &searchPathEnvVar ) -{ - MPlug pClassName( B::thisMObject(), aParameterisedClassName ); - MPlug pVersion( B::thisMObject(), aParameterisedVersion ); - MPlug pSearchPathEnvVar( B::thisMObject(), aParameterisedSearchPathEnvVar ); - pClassName.setValue( className.c_str() ); - pVersion.setValue( classVersion ); - pSearchPathEnvVar.setValue( searchPathEnvVar.c_str() ); - - m_parameterised = 0; - m_failedToLoad = false; - - if( getParameterised() ) - { - return MStatus::kSuccess; - } - - return MStatus::kFailure; -} - -template -MStatus ParameterisedHolder::updateParameterised() -{ - return createAndRemoveAttributes(); -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::getParameterised( std::string *classNameOut, int *classVersionOut, std::string *searchPathEnvVarOut ) -{ - MPlug pClassName( B::thisMObject(), aParameterisedClassName ); - MPlug pVersion( B::thisMObject(), aParameterisedVersion ); - MPlug pSearchPathEnvVar( B::thisMObject(), aParameterisedSearchPathEnvVar ); - - MString className; - int version; - MString searchPathEnvVar; - - pClassName.getValue( className ); - - pVersion.getValue( version ); - pSearchPathEnvVar.getValue( searchPathEnvVar ); - - if( !m_parameterised && !m_failedToLoad ) - { - m_failedToLoad = true; - if( className!="" ) - { - m_parameterised = loadClass( className, version, searchPathEnvVar ); - if( m_parameterised ) - { - // we'll only create and remove attributes if we loaded successfully. - // this avoids the situation where the loading fails due to some - // correctable error, but we've just deleted all the attributes with - // all the settings and connections important to the user. - if( createAndRemoveAttributes( true ) ) - { - m_failedToLoad = false; - } - } - } - } - - // fill output parameters - if( m_parameterised ) - { - if( classNameOut ) - { - *classNameOut = className.asChar(); - } - if( classVersionOut ) - { - *classVersionOut = version; - } - if( searchPathEnvVarOut ) - { - *searchPathEnvVarOut = searchPathEnvVar.asChar(); - } - } - - return m_parameterised; -} - -template -MStatus ParameterisedHolder::setNodeValues() -{ - // to update the parameter->name map if necessary - getParameterised(); - - MFnDependencyNode fnDN( B::thisMObject() ); - - ParameterToAttributeNameMap::const_iterator it; - for( it=m_parametersToAttributeNames.begin(); it!=m_parametersToAttributeNames.end(); it++ ) - { - MPlug p = fnDN.findPlug( it->second, false ); - if( p.isNull() ) - { - return MStatus::kFailure; - } - try - { - MStatus s = ParameterHandler::setValue( it->first, p ); - if( !s ) - { - return s; - } - } - catch( std::exception &e ) - { - msg( Msg::Error, "ParameterisedHolder::setNodeValues", boost::format( "Caught exception while setting parameter value to attribute %s : %s" ) % p.name().asChar() % e.what()); - return MStatus::kFailure; - } - catch( ... ) - { - msg( Msg::Error, "ParameterisedHolder::setNodeValues", boost::format( "Caught exception while setting parameter value to attribute %s." ) % p.name().asChar() ); - return MStatus::kFailure; - } - } - return MStatus::kSuccess; -} - -template -MStatus ParameterisedHolder::setNodeValue( ParameterPtr pa ) -{ - MPlug p = parameterPlug( pa ); - if( p.isNull() ) - { - return MStatus::kFailure; - } - - MStatus s = MS::kSuccess; - - try - { - s = IECoreMaya::ParameterHandler::setValue( pa, p ); - } - catch ( std::exception &e ) - { - msg( Msg::Error, "ParameterisedHolder::setNodeValues", boost::format( "Caught exception while setting parameter value to attribute %s : %s" ) % p.name().asChar() % e.what()); - s = MS::kFailure; - } - catch (...) - { - msg( Msg::Error, "ParameterisedHolder::setNodeValues", boost::format( "Caught exception while setting parameter value to attribute %s" ) % p.name().asChar()); - s = MS::kFailure; - } - - return s; -} - -template -MStatus ParameterisedHolder::setParameterisedValues() -{ - return setParameterisedValues( false /* not lazy */ ); -} - -template -MStatus ParameterisedHolder::setParameterisedValues( bool lazy ) -{ - ParameterisedInterface *parameterisedInterface = getParameterisedInterface(); - if( !parameterisedInterface ) - { - return MS::kFailure; - } - - MStatus s; - setParameterisedValuesWalk( lazy, parameterisedInterface->parameters(), s ); - return s; -} - -template -bool ParameterisedHolder::setParameterisedValuesWalk( bool lazy, IECore::ParameterPtr parameter, MStatus &status ) -{ - MFnDependencyNode fnDN( B::thisMObject() ); - - // traverse child parameters if we have them - - bool childParametersWereSet = false; - if( parameter->isInstanceOf( CompoundParameter::staticTypeId() ) ) - { - CompoundParameterPtr compoundParameter = boost::static_pointer_cast( parameter ); - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - bool b = setParameterisedValuesWalk( lazy, *cIt, status ); - childParametersWereSet = childParametersWereSet || b; - } - } - - // then set this parameter if necessary - - bool thisParameterWasSet = false; - if( parameter->name()!="" && (!lazy || m_dirtyParameters.find( parameter )!=m_dirtyParameters.end()) ) - { - ParameterToAttributeNameMap::const_iterator nIt = m_parametersToAttributeNames.find( parameter ); - if( nIt==m_parametersToAttributeNames.end() ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Unable to find plug name for parameter %s" ) % parameter->name() ); - status = MS::kFailure; - } - else - { - - MPlug p = fnDN.findPlug( nIt->second, false ); - if( p.isNull() ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Unable to find plug for parameter %s" ) % parameter->name() ); - status = MS::kFailure; - } - else - { - try - { - MStatus s = ParameterHandler::setValue( p, parameter ); - if( !s ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Failed to set parameter value from %s" ) % p.name().asChar() ); - status = s; - } - else - { - m_dirtyParameters.erase( parameter ); - thisParameterWasSet = true; - } - } - catch( std::exception &e ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Caught exception while setting parameter value from %s : %s" ) % p.name().asChar() % e.what()); - status = MS::kFailure; - } - catch( ... ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Caught unknown exception while setting parameter value from %s" ) % p.name().asChar() ); - status = MS::kFailure; - } - } - } - } - - // increment the updateCount if necessary - - if( thisParameterWasSet || childParametersWereSet ) - { - CompoundObjectPtr userData = parameter->userData(); - IntDataPtr updateCount = userData->member( "updateCount" ); - if( !updateCount ) - { - updateCount = new IntData( 0 ); - userData->members()["updateCount"] = updateCount; - } - else - { - updateCount->writable()++; - } - } - - return childParametersWereSet || thisParameterWasSet; -} - -template -MStatus ParameterisedHolder::setParameterisedValue( ParameterPtr pa ) -{ - MPlug p = parameterPlug( pa ); - if( p.isNull() ) - { - return MStatus::kFailure; - } - - MStatus s = MS::kSuccess; - - try - { - s = IECoreMaya::ParameterHandler::setValue( p, pa ); - if( s ) - { - m_dirtyParameters.erase( pa ); - } - } - catch ( std::exception &e ) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Caught exception while setting parameter value from %s : %s" ) % p.name().asChar() % e.what()); - s = MS::kFailure; - } - catch (...) - { - msg( Msg::Error, "ParameterisedHolder::setParameterisedValues", boost::format( "Caught exception while setting parameter value from %s" ) % p.name().asChar()); - s = MS::kFailure; - } - - return s; -} - -template -MPlug ParameterisedHolder::parameterPlug( IECore::ConstParameterPtr parameter ) -{ - // to update the parameter->name map if necessary - getParameterised(); - - ParameterToAttributeNameMap::const_iterator it = m_parametersToAttributeNames.find( boost::const_pointer_cast( parameter ) ); - if( it==m_parametersToAttributeNames.end() ) - { - return MPlug(); - } - - MFnDependencyNode fnDN( B::thisMObject() ); - return MPlug( B::thisMObject(), fnDN.attribute( it->second ) ); -} - -template -IECore::ParameterPtr ParameterisedHolder::plugParameter( const MPlug &plug ) -{ - assert( ! plug.isNull() ); - - // to update the parameter->name map if necessary - getParameterised(); - AttributeNameToParameterMap::const_iterator it = m_attributeNamesToParameters.find( plug.partialName() ); - if( it==m_attributeNamesToParameters.end() ) - { - return 0; - } - return it->second; -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::loadClass( const MString &className, int classVersion, const MString &searchPathEnvVar ) -{ - string toExecute = boost::str( format( - "IECore.ClassLoader.defaultLoader( \"%s\" ).load( \"%s\", %d )()\n" - ) % searchPathEnvVar.asChar() % className.asChar() % classVersion - ); - - IECorePython::ScopedGILLock gilLock; - - try - { - handle<> resultHandle( PyRun_String( - toExecute.c_str(), - Py_eval_input, PythonCmd::globalContext().ptr(), - PythonCmd::globalContext().ptr() ) - ); - object result( resultHandle ); - return extract( result )(); - } - catch( error_already_set &e ) - { - MFnDependencyNode fnDN( B::thisMObject() ); - - msg( Msg::Error, "ParameterisedHolder::loadClass", - boost::format( "Unable to load class \"%s\" version %d into node %s." ) % className.asChar() % classVersion % fnDN.name().asChar()); - - PyErr_Print(); - } - catch( ... ) - { - MFnDependencyNode fnDN( B::thisMObject() ); - - msg( Msg::Error, "ParameterisedHolder::loadClass", - boost::format( "Unable to load class \"%s\" version %d into node %s." ) % className.asChar() % classVersion % fnDN.name().asChar()); - } - return 0; -} - -template -MStatus ParameterisedHolder::createAndRemoveAttributes( bool callRestore ) -{ - m_attributeNamesToParameters.clear(); - m_parametersToAttributeNames.clear(); - - MStatus s; - if( m_parameterised ) - { - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - s = createAttributesWalk( parameterisedInterface->parameters(), "parm", callRestore ); - if( !s ) - { - msg( Msg::Error, "ParameterisedHolder::createAndRemoveAttributes", boost::format( "Unable to create attributes to represent class." ) ); - return s; - } - } - - s = removeUnecessaryAttributes(); - if( !s ) - { - msg( Msg::Error, "ParameterisedHolder::createAndRemoveAttributes", "Failed to remove unecessary attributes." ); - return s; - } - - return MS::kSuccess; -} - -template -MStatus ParameterisedHolder::createAttributesWalk( IECore::ConstCompoundParameterPtr parameter, const std::string &rootName, bool callRestore ) -{ - - const CompoundParameter::ParameterVector &children = parameter->orderedParameters(); - for( size_t i=0; iname(); - MString mAttributeName = attributeName.c_str(); - - m_attributeNamesToParameters[mAttributeName] = children[i]; - m_parametersToAttributeNames[children[i]] = mAttributeName; - m_dirtyParameters.insert( children[i] ); - - MStatus s = createOrUpdateAttribute( children[i], mAttributeName, callRestore ); - if( !s ) - { - return s; - } - - // recurse to the children if this is a compound child - CompoundParameterPtr compoundChild = runTimeCast( children[i] ); - if( compoundChild ) - { - MStatus s = createAttributesWalk( compoundChild, rootName + "_" + compoundChild->name(), callRestore ); - if( !s ) - { - return s; - } - } - } - - return MS::kSuccess; -} - -template -MStatus ParameterisedHolder::createOrUpdateAttribute( IECore::ParameterPtr parameter, const MString &attributeName, bool callRestore ) -{ - MObject node = B::thisMObject(); - MFnDependencyNode fnDN( node ); - - MPlugArray connectionsFromMe, connectionsToMe; - - // try to reuse an old plug if we can - MPlug plug = fnDN.findPlug( attributeName, false /* no networked plugs please */ ); - if( !plug.isNull() ) - { - MStatus s = MS::kSuccess; - if( callRestore ) - { - ParameterHandler::restore( plug, parameter ); - } - - if( s ) - { - s = IECoreMaya::ParameterHandler::update( parameter, plug ); - if( s ) - { - return MS::kSuccess; - } - } - - // failed to restore and/or update (parameter type probably changed). - // remove the current attribute and fall through to the create - // code - - // remember connections so we can remake them for the new - // attribute. we have to be careful to only store non-networked plugs as - // networked plugs are invalidated by the removal of the attribute. - nonNetworkedConnections( plug, connectionsFromMe, connectionsToMe ); - - fnDN.removeAttribute( plug.attribute() ); - } - - // reuse failed - create a new attribute - /// \todo: update ParameterisedHolder to accept null plugs when the todo in ParameterHandler::create is addressed - plug = IECoreMaya::ParameterHandler::create( parameter, attributeName, node ); - if( plug.isNull() ) - { - msg( Msg::Error, "ParameterisedHolder::createOrUpdateAttribute", boost::format( "Failed to create attribute to represent parameter \"%s\" of type \"%s\"" ) % parameter->name() % parameter->typeName() ); - return MS::kFailure; - } - - // restore any existing connections - if( connectionsFromMe.length() || connectionsToMe.length() ) - { - MDGModifier dgMod; - for (unsigned i = 0; i < connectionsFromMe.length(); i++) - { - dgMod.connect( plug, connectionsFromMe[i] ); - } - for (unsigned i = 0; i < connectionsToMe.length(); i++) - { - dgMod.connect( connectionsToMe[i], plug ); - } - - dgMod.doIt(); - } - - /// and set the value of the attribute, in case it differs from the default - return IECoreMaya::ParameterHandler::setValue( parameter, plug ); -} - -template -MStatus ParameterisedHolder::removeUnecessaryAttributes() -{ - MObjectArray toRemove; - MFnDependencyNode fnDN( B::thisMObject() ); - for( unsigned i=0; i -void ParameterisedHolder::nonNetworkedConnections( const MPlug &plug, MPlugArray &connectionsFromPlug, MPlugArray &connectionsToPlug ) const -{ - MPlugArray from; - MPlugArray to; - - // the MPlug.connectedTo() method is documented as always returning networked plugs. - plug.connectedTo( from, false, true ); - plug.connectedTo( to, true, false ); - - connectionsFromPlug.clear(); connectionsFromPlug.setLength( from.length() ); - connectionsToPlug.clear(); connectionsToPlug.setLength( to.length() ); - - for( unsigned i=0; i -MTypeId ParameterisedHolderNode::id( ParameterisedHolderNodeId ); - -template<> -MString ParameterisedHolderNode::typeName( "ieParameterisedHolderNode" ); - -template<> -MTypeId ParameterisedHolderLocator::id( ParameterisedHolderLocatorId ); - -template<> -MString ParameterisedHolderLocator::typeName( "ieParameterisedHolderLocator" ); - -template<> -MTypeId ParameterisedHolderDeformer::id( ParameterisedHolderDeformerId ); - -template<> -MString ParameterisedHolderDeformer::typeName( "ieParameterisedHolderDeformer" ); - -template<> -MTypeId ParameterisedHolderField::id( ParameterisedHolderFieldId ); - -template<> -MString ParameterisedHolderField::typeName( "ieParameterisedHolderField" ); - -template<> -MTypeId ParameterisedHolderSet::id( ParameterisedHolderSetId ); - -template<> -MString ParameterisedHolderSet::typeName( "ieParameterisedHolderSet" ); - -template<> -MTypeId ParameterisedHolderSurfaceShape::id( ParameterisedHolderSurfaceShapeId ); - -template<> -MString ParameterisedHolderSurfaceShape::typeName( "ieParameterisedHolderSurfaceShape" ); - -template<> -MTypeId ParameterisedHolderComponentShape::id( ParameterisedHolderComponentShapeId ); - -template<> -MString ParameterisedHolderComponentShape::typeName( "ieParameterisedHolderComponentShape" ); - -template<> -MTypeId ParameterisedHolderImagePlane::id( ParameterisedHolderImagePlaneId ); - -template<> -MString ParameterisedHolderImagePlane::typeName( "ieParameterisedHolderImagePlane" ); - -// explicit instantiation -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; -template class ParameterisedHolder; diff --git a/src/IECoreMaya/ParameterisedHolderInterface.cpp b/src/IECoreMaya/ParameterisedHolderInterface.cpp deleted file mode 100644 index 9762911cbf..0000000000 --- a/src/IECoreMaya/ParameterisedHolderInterface.cpp +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ParameterisedHolderInterface.h" - -#include "IECore/Object.h" -#include "IECore/ParameterisedInterface.h" - -using namespace IECoreMaya; - -ParameterisedHolderInterface::ParameterisedHolderInterface() -{ -} - -ParameterisedHolderInterface::~ParameterisedHolderInterface() -{ -} - -IECore::ParameterisedInterface *ParameterisedHolderInterface::getParameterisedInterface() -{ - return dynamic_cast( getParameterised().get() ); -} - -IECore::ParameterisedInterface *ParameterisedHolderInterface::getParameterisedInterface( std::string *className, int *classVersion, std::string *searchPathEnvVar ) -{ - return dynamic_cast( getParameterised( className, classVersion, searchPathEnvVar ).get() ); - -} diff --git a/src/IECoreMaya/ParameterisedHolderManipContext.cpp b/src/IECoreMaya/ParameterisedHolderManipContext.cpp deleted file mode 100644 index 0271175bb5..0000000000 --- a/src/IECoreMaya/ParameterisedHolderManipContext.cpp +++ /dev/null @@ -1,332 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ParameterisedHolderManipContext.h" -#include "IECoreMaya/ParameterManipContainer.h" -#include "IECoreMaya/ParameterisedHolderInterface.h" - -#include -#include -#undef None // must come after certain Maya includes which include X11/X.h - -#include "IECore/SimpleTypedData.h" -#include "IECore/CompoundParameter.h" - -using namespace IECore; -using namespace IECoreMaya; - -ParameterisedHolderManipContext::ParameterisedHolderManipContext() : - m_toolOn( false ), m_mode( First ), m_targetPlugPath( "" ) -{ - setTitleString( "ParameterisedHolder Manipulator" ); -} - - -void ParameterisedHolderManipContext::toolOnSetup( MEvent & ) -{ - m_toolOn = true; - - updateHelpString(); - - MStatus status; - selectionChangeCallback = MModelMessage::addCallback( MModelMessage::kActiveListModified, - updateManipulators, - this, - &status ); - if( !status ) - { - MGlobal::displayError( "ParameterisedHolderManipContext::toolOnSetup() Unable to add " - "selectionChanged callback for manipulators." ); - } - - updateManipulators( this ); -} - -void ParameterisedHolderManipContext::toolOffCleanup() -{ - MStatus status = MModelMessage::removeCallback( selectionChangeCallback ); - if( !status ) - { - MGlobal::displayError( "ParameterisedHolderManipContext::toolOffCleanup() Unable to remove " - "selectionChanged callback." ); - } - - m_toolOn = false; - - MPxContext::toolOffCleanup(); -} - -void ParameterisedHolderManipContext::updateManipulators( void *blindData ) -{ - ParameterisedHolderManipContext *ctx = (ParameterisedHolderManipContext *)blindData; - ctx->updateManipulators(); -} - -void ParameterisedHolderManipContext::updateManipulators() -{ - deleteManipulators(); - - MStatus stat; - - if( m_mode == Targeted && m_targetPlugPath == "" ) - { - MGlobal::displayError( "ParameterisedHolderManipContext: No target parameter specified to manipulate." ); - return; - } - - MSelectionList list; - stat = MGlobal::getActiveSelectionList( list ); - - if( !stat ) - { - MGlobal::displayError( "ParameterisedHolderManipContext::updateManipulators() Unable to get " - "the active selection list." ); - return; - } - - for( MItSelectionList it( list, MFn::kInvalid, &stat ); !it.isDone(); it.next() ) - { - MObject node; - it.getDependNode( node ); - dagWalk( node ); - } - -} - -void ParameterisedHolderManipContext::dagWalk( MObject &node ) -{ - MStatus stat; - MFnDagNode dagFn( node, &stat ); - if( !stat ) - { - processNode( node ); - } - else - { - unsigned int numChildren = dagFn.childCount(); - if( numChildren == 0 ) - { - processNode( node ); - } - else - { - for( unsigned int i = 0; i < numChildren; i++ ) - { - MObject child = dagFn.child( i ); - dagWalk( child ); - } - } - } -} - -void ParameterisedHolderManipContext::processNode( MObject &node ) -{ - MStatus stat; - MFnDependencyNode nodeFn( node, &stat ); - if( !stat ) - { - return; - } - - ParameterisedHolderInterface *pHolder = dynamic_cast( nodeFn.userNode() ); - if( !pHolder ) - { - return; - } - - if( m_mode == Targeted ) - { - MStatus stat; - MPlug targetPlug = nodeFn.findPlug( m_targetPlugPath, false, &stat ); - if( stat ) - { - createAndConnectManip( pHolder->plugParameter( targetPlug ), nodeFn ); - } - } - else - { - ParameterisedInterface *parameterisedInterface = pHolder->getParameterisedInterface(); - if( parameterisedInterface ) - { - createManipulatorWalk( parameterisedInterface->parameters(), nodeFn ); - } - } -} - - -MPxManipContainer *ParameterisedHolderManipContext::createManipulatorWalk( ParameterPtr parameter, MFnDependencyNode &nodeFn ) -{ - if( CompoundParameterPtr c = runTimeCast( parameter ) ) - { - MPxManipContainer *manip = 0; - for( CompoundParameter::ParameterVector::const_iterator it = c->orderedParameters().begin(); it != c->orderedParameters().end(); it++ ) - { - manip = createManipulatorWalk( *it, nodeFn ); - if( m_mode == First && manip ) - { - return manip; - } - } - return manip; - } - else - { - return createAndConnectManip( parameter, nodeFn ); - } -} - -MPxManipContainer *ParameterisedHolderManipContext::createAndConnectManip( ParameterPtr parameter, MFnDependencyNode &nodeFn ) -{ - if( !parameter ) - { - return 0; - } - - // The 'name' of the manipulator to create is: ieManipulator - MString manipLabel( "" ); - MString manipName( "ie" ); - - CompoundObjectPtr userData = parameter->userData(); - if( CompoundObjectPtr manipData = userData->member( "UI" ) ) - { - // Allow the parameter to opt-out of having a manipulator - if( BoolDataPtr enableData = manipData->member( "disableManip" ) ) - { - if( enableData->readable() == true ) - { - return 0; - } - } - - if( StringDataPtr labelData = manipData->member( "manipLabel" ) ) - { - manipLabel += MString( labelData->readable().c_str() ); - } - - if( StringDataPtr hintData = manipData->member( "manipTypeHint" ) ) - { - manipName += MString( hintData->readable().c_str() ); - } - } - - manipName += parameter->typeName(); - manipName += "Manipulator"; - - MObject manipObj; - MPxManipContainer *manip = MPxManipContainer::newManipulator( manipName, manipObj ); - - if( !manip ) - { - return 0; - } - - // If we are derived from our custom manipulator base, then we can set the - // desired plug name into the manipulator, incase it wishes to use it. - ParameterManipContainer *paramManip = dynamic_cast( manip ); - if( paramManip ) - { - ParameterisedHolderInterface *pHolder = dynamic_cast( nodeFn.userNode() ); - MPlug targetPlug = pHolder->parameterPlug( parameter ); - paramManip->setPlug( targetPlug ); - if( manipLabel != "" ) - { - paramManip->setLabel( manipLabel ); - } - } - - addManipulator( manipObj ); - MStatus stat = manip->connectToDependNode( nodeFn.object() ); - - if( !stat ) - { - MGlobal::displayError( "ParameterisedHolderManipContext::createAndConnectManip() Unable to connect manipulator." ); - return 0; - } - - return manip; -} - - -void ParameterisedHolderManipContext::setTarget( MString &plugName ) -{ - m_targetPlugPath = plugName; - if( m_toolOn ) - { - updateHelpString(); - updateManipulators(); - } -} - -MString ParameterisedHolderManipContext::getTarget() -{ - return m_targetPlugPath; -} - -void ParameterisedHolderManipContext::setMode( ParameterisedHolderManipContext::Mode m ) -{ - m_mode = m; - if( m_toolOn ) - { - updateHelpString(); - updateManipulators(); - } -} - -ParameterisedHolderManipContext::Mode ParameterisedHolderManipContext::getMode() -{ - return m_mode; -} - -void ParameterisedHolderManipContext::updateHelpString() -{ - switch( m_mode ) - { - case First: - setHelpString( "Adjusting the first manipulatable parameter on the selection." ); - break; - - case All: - setHelpString( "Adjusting all manipulatable parameter on the selection." ); - break; - - case Targeted: - setHelpString( "Adjusting the parameter named '" + m_targetPlugPath + "' on the selection, if available." ); - break; - } -} - - - - - diff --git a/src/IECoreMaya/ParameterisedHolderManipContextCommand.cpp b/src/IECoreMaya/ParameterisedHolderManipContextCommand.cpp deleted file mode 100644 index fd7203a412..0000000000 --- a/src/IECoreMaya/ParameterisedHolderManipContextCommand.cpp +++ /dev/null @@ -1,166 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ParameterisedHolderManipContextCommand.h" - -#include "IECoreMaya/ParameterisedHolderManipContext.h" - -#include - -using namespace IECoreMaya; - -ParameterisedHolderManipContextCommand::ParameterisedHolderManipContextCommand() -{ -} - -void *ParameterisedHolderManipContextCommand::creator() -{ - return new ParameterisedHolderManipContextCommand; -} - -MPxContext *ParameterisedHolderManipContextCommand::makeObj() -{ - m_context = new ParameterisedHolderManipContext; - return m_context; -} - - -MStatus ParameterisedHolderManipContextCommand::doEditFlags() -{ - MStatus stat; - - MArgParser args = parser(); - - if( args.isFlagSet( kModeFlag ) ) - { - MString mode; - stat = args.getFlagArgument( kModeFlag, 0, mode ); - if( !stat ) - { - stat.perror( "Invalid argument passed to " kModeFlagLong " flag. Valid options are: 'all', 'first' or 'targeted'." ); - return stat; - } - if( mode == "all" ) - { - m_context->setMode( ParameterisedHolderManipContext::All ); - } - else if( mode == "first" ) - { - m_context->setMode( ParameterisedHolderManipContext::First ); - } - else if( mode == "targeted" ) - { - m_context->setMode( ParameterisedHolderManipContext::Targeted ); - } - else - { - stat.perror( "Unknkown mode passed to " kModeFlagLong " flag. Valid options are: 'all', 'first' or 'targeted'." ); - return stat; - } - } - - if( args.isFlagSet( kTargetFlag ) ) - { - MString param; - stat = args.getFlagArgument( kTargetFlag, 0, param ); - if( !stat ) - { - stat.perror( "Invalid argument passed to " kTargetFlagLong " flag." ); - return stat; - } - m_context->setTarget( param ); - } - - return MS::kSuccess; -} - -MStatus ParameterisedHolderManipContextCommand::doQueryFlags() -{ - MArgParser args = parser(); - - if( args.isFlagSet( kModeFlag ) ) - { - ParameterisedHolderManipContext::Mode m = m_context->getMode(); - switch( m ) - { - case ParameterisedHolderManipContext::All: - setResult( MString( "all" ) ); - break; - - case ParameterisedHolderManipContext::First: - setResult( MString( "first" ) ); - break; - - case ParameterisedHolderManipContext::Targeted: - setResult( MString( "targeted" ) ); - break; - - default: - setResult( MString( "unknown" ) ); - } - } - - if( args.isFlagSet( kTargetFlag ) ) - { - setResult( m_context->getTarget() ); - } - - return MS::kSuccess; -} - -MStatus ParameterisedHolderManipContextCommand::appendSyntax() -{ - MStatus stat; - - MSyntax mySyntax = syntax(); - - stat = mySyntax.addFlag( kModeFlag, kModeFlagLong, MSyntax::kString ); - if ( !stat ) - { - return MS::kFailure; - } - - stat = mySyntax.addFlag( kTargetFlag, kTargetFlagLong, MSyntax::kString ); - if ( !stat ) - { - return MS::kFailure; - } - - return MS::kSuccess; -} - - - - - diff --git a/src/IECoreMaya/ParameterisedHolderModificationCmd.cpp b/src/IECoreMaya/ParameterisedHolderModificationCmd.cpp deleted file mode 100644 index df839e1cdb..0000000000 --- a/src/IECoreMaya/ParameterisedHolderModificationCmd.cpp +++ /dev/null @@ -1,470 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/algorithm/string/split.hpp" -#include "boost/algorithm/string/classification.hpp" - -#include "maya/MArgList.h" -#include "maya/MSelectionList.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnDagNode.h" -#include "maya/MGlobal.h" - -#include "IECore/Object.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/ParameterisedHolderModificationCmd.h" -#include "IECoreMaya/ClassParameterHandler.h" -#include "IECoreMaya/ClassVectorParameterHandler.h" - -using namespace IECoreMaya; -using namespace IECore; - -IECore::ConstObjectPtr ParameterisedHolderModificationCmd::g_originalValue = 0; -IECore::ConstCompoundDataPtr ParameterisedHolderModificationCmd::g_originalClasses = 0; -IECore::ConstObjectPtr ParameterisedHolderModificationCmd::g_newValue = 0; -IECore::ConstCompoundDataPtr ParameterisedHolderModificationCmd::g_newClasses = 0; - -ParameterisedHolderModificationCmd::ParameterisedHolderModificationCmd() - : m_parameterisedHolder( 0 ), m_originalValues( 0 ), m_newValues( 0 ), m_changingClass( false ) -{ -} - -ParameterisedHolderModificationCmd::~ParameterisedHolderModificationCmd() -{ -} - -void *ParameterisedHolderModificationCmd::creator() -{ - return new ParameterisedHolderModificationCmd; -} - -bool ParameterisedHolderModificationCmd::isUndoable() const -{ - return true; -} - -bool ParameterisedHolderModificationCmd::hasSyntax() const -{ - return false; -} - -MStatus ParameterisedHolderModificationCmd::doIt( const MArgList &argList ) -{ - // get the node we're operating on - - MSelectionList selection; - selection.add( argList.asString( 0 ) ); - - selection.getDependNode( 0, m_node ); - if( m_node.isNull() ) - { - return MS::kFailure; - } - - MFnDependencyNode fnNode( m_node ); - MPxNode *userNode = fnNode.userNode(); - m_parameterisedHolder = dynamic_cast( userNode ); - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - // if we're being asked to change class then store the details of the class we want to set - // and the one we're replacing - - if( argList.length() == 4 ) - { - std::string originalClassName; - std::string originalSearchPathEnvVar; - m_parameterisedHolder->getParameterised( &originalClassName, &m_originalClassVersion, &originalSearchPathEnvVar ); - m_originalClassName = originalClassName.c_str(); - m_originalSearchPathEnvVar = originalSearchPathEnvVar.c_str(); - - m_newClassName = argList.asString( 1 ); - m_newClassVersion = argList.asInt( 2 ); - m_newSearchPathEnvVar = argList.asString( 3 ); - - m_changingClass = true; - } - else if( argList.length() != 1 ) - { - displayError( "ieParameterisedHolderSetParameterised : wrong number of arguments." ); - return MS::kFailure; - } - - // store the original and new values of everything. these are just passed in from - // the FnParameterisedHolder. in the case of changing the held class we won't have - // any new values. - - m_originalValues = g_originalValue; - m_originalClasses = g_originalClasses; - m_newValues = g_newValue; - m_newClasses = g_newClasses; - - g_originalValue = 0; - g_originalClasses = 0; - g_newValue = 0; - g_newClasses = 0; - - // change the maya side class or monkey with the maya side class parameters as requested. then remember the new values - // of everything and which parameters are changing so we can push them in and out during undo and redo. - - if( m_changingClass ) - { - MStatus s = m_parameterisedHolder->setParameterised( m_newClassName.asChar(), m_newClassVersion, m_newSearchPathEnvVar.asChar() ); - if ( !s ) - { - return s; - } - m_newValues = m_parameterisedHolder->getParameterisedInterface()->parameters()->getValue()->copy(); - storeParametersWithNewValues( m_originalValues.get(), m_newValues.get(), "" ); - despatchSetParameterisedCallbacks(); - } - else - { - storeParametersWithNewValues( m_originalValues.get(), m_newValues.get(), "" ); - m_parameterisedHolder->updateParameterised(); - setNodeValuesForParametersWithNewValues(); - despatchClassSetCallbacks(); - } - - return MS::kSuccess; -} - -MStatus ParameterisedHolderModificationCmd::undoIt() -{ - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - MStatus s; - if( m_changingClass ) - { - s = m_parameterisedHolder->setParameterised( m_originalClassName.asChar(), m_originalClassVersion, m_originalSearchPathEnvVar.asChar() ); - if( !s ) - { - return s; - } - } - - if( m_originalClasses->readable().size() ) - { - restoreClassParameterStates( m_originalClasses.get(), m_parameterisedHolder->getParameterisedInterface()->parameters(), "" ); - m_parameterisedHolder->updateParameterised(); - } - - if( m_originalValues ) - { - m_parameterisedHolder->getParameterisedInterface()->parameters()->setValue( m_originalValues->copy() ); - setNodeValuesForParametersWithNewValues(); - } - - // despatch callbacks only when the dust has settled - if( m_changingClass ) - { - despatchSetParameterisedCallbacks(); - } - else - { - despatchClassSetCallbacks(); - } - - return s; -} - -MStatus ParameterisedHolderModificationCmd::redoIt() -{ - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - if( m_changingClass ) - { - MStatus s = m_parameterisedHolder->setParameterised( m_newClassName.asChar(), m_newClassVersion, m_newSearchPathEnvVar.asChar() ); - if ( !s ) - { - return s; - } - despatchSetParameterisedCallbacks(); - } - else - { - restoreClassParameterStates( m_newClasses.get(), m_parameterisedHolder->getParameterisedInterface()->parameters(), "" ); - m_parameterisedHolder->getParameterisedInterface()->parameters()->setValue( m_newValues->copy() ); - m_parameterisedHolder->updateParameterised(); - setNodeValuesForParametersWithNewValues(); - despatchClassSetCallbacks(); - } - - return MS::kSuccess; -} - -void ParameterisedHolderModificationCmd::restoreClassParameterStates( const IECore::CompoundData *classes, IECore::Parameter *parameter, const std::string &parentParameterPath ) -{ - std::string parameterPath = parentParameterPath; - if( parentParameterPath.size() ) - { - parameterPath += "."; - } - parameterPath += parameter->name(); - - if( parameter->isInstanceOf( "ClassParameter" ) ) - { - const CompoundData *c = classes->member( parameterPath ); - if( c ) - { - ClassParameterHandler::setClass( - parameter, - c->member( "className" )->readable().c_str(), - c->member( "classVersion" )->readable(), - c->member( "searchPathEnvVar" )->readable().c_str() - ); - } - } - else if( parameter->isInstanceOf( "ClassVectorParameter" ) ) - { - const CompoundData *c = classes->member( parameterPath ); - if( c ) - { - IECore::ConstStringVectorDataPtr parameterNames = c->member( "parameterNames" ); - IECore::ConstStringVectorDataPtr classNames = c->member( "classNames" ); - IECore::ConstIntVectorDataPtr classVersions = c->member( "classVersions" ); - MStringArray mParameterNames; - MStringArray mClassNames; - MIntArray mClassVersions; - int numClasses = parameterNames->readable().size(); - for( int i=0; ireadable()[i].c_str() ); - mClassNames.append( classNames->readable()[i].c_str() ); - mClassVersions.append( classVersions->readable()[i] ); - } - ClassVectorParameterHandler::setClasses( parameter, mParameterNames, mClassNames, mClassVersions ); - } - } - - if( parameter->isInstanceOf( IECore::CompoundParameter::staticTypeId() ) ) - { - CompoundParameter *compoundParameter = static_cast( parameter ); - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ ) - { - restoreClassParameterStates( classes, it->get(), parameterPath ); - } - } -} - -void ParameterisedHolderModificationCmd::storeParametersWithNewValues( const IECore::Object *originalValue, const IECore::Object *newValue, const std::string ¶meterPath ) -{ - if( !(originalValue && newValue) ) - { - // if either of the values isn't present then a parameter is appearing and disappearing due to - // Class*Parameter edits. we treat it as a parameter with a new value so that it'll get it's value - // transferred into maya appropriately. - m_parametersWithNewValues.insert( parameterPath ); - } - else if( originalValue->typeId() != newValue->typeId() ) - { - // types are different so there's clearly a new value involved - m_parametersWithNewValues.insert( parameterPath ); - } - else if( originalValue->isInstanceOf( CompoundObject::staticTypeId() ) ) - { - // compound value, representing several child parameters - attempt to recurse. - // we need to consider children of both the original and new parameters in case a parameter - // exists only on one side. - const CompoundObject *originalCompound = static_cast( originalValue ); - const CompoundObject *newCompound = static_cast( newValue ); - const CompoundObject::ObjectMap &originalChildren = originalCompound->members(); - for( CompoundObject::ObjectMap::const_iterator it = originalChildren.begin(); it!=originalChildren.end(); it++ ) - { - std::string childParameterPath; - if( parameterPath.size() ) - { - childParameterPath = parameterPath + "." + it->first.value(); - } - else - { - childParameterPath = it->first; - } - storeParametersWithNewValues( it->second.get(), newCompound->member( it->first ), childParameterPath ); - } - - const CompoundObject::ObjectMap &newChildren = static_cast( newValue )->members(); - for( CompoundObject::ObjectMap::const_iterator it = newChildren.begin(); it!=newChildren.end(); it++ ) - { - if( originalChildren.find( it->first )==originalChildren.end() ) - { - // this is a child we didn't encounter in the first iteration. - std::string childParameterPath; - if( parameterPath.size() ) - { - childParameterPath = parameterPath + "." + it->first.value(); - } - else - { - childParameterPath = it->first; - } - storeParametersWithNewValues( 0, it->second.get(), childParameterPath ); - } - } - } - else - { - if( !originalValue->isEqualTo( newValue ) ) - { - m_parametersWithNewValues.insert( parameterPath ); - } - } -} - -void ParameterisedHolderModificationCmd::setNodeValuesForParametersWithNewValues() const -{ - ParameterisedInterface *parameterised = m_parameterisedHolder->getParameterisedInterface(); - for( std::set::const_iterator it=m_parametersWithNewValues.begin(); it!=m_parametersWithNewValues.end(); it++ ) - { - Parameter *p = parameterFromPath( parameterised, *it ); - if( p ) - { - setNodeValue( p ); - } - } -} - -void ParameterisedHolderModificationCmd::setNodeValue( IECore::Parameter *parameter ) const -{ - m_parameterisedHolder->setNodeValue( parameter ); - - if( parameter->isInstanceOf( CompoundParameter::staticTypeId() ) ) - { - // recurse to the children - this is the only reason this function - // is necessary as ParameterisedHolder::setNodeValue() doesn't recurse. - CompoundParameter *compoundParameter = static_cast( parameter ); - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ ) - { - setNodeValue( it->get() ); - } - } -} - -void ParameterisedHolderModificationCmd::despatchSetParameterisedCallbacks() const -{ - MFnDependencyNode fnNode( m_node ); - MString nodeName = fnNode.name(); - MFnDagNode fnDN( m_node ); - if( fnDN.hasObj( m_node ) ) - { - nodeName = fnDN.fullPathName(); - } - - MGlobal::executePythonCommand( "import IECoreMaya; IECoreMaya.FnParameterisedHolder._despatchSetParameterisedCallbacks( \"" + nodeName + "\" )" ); -} - -void ParameterisedHolderModificationCmd::despatchClassSetCallbacks() const -{ - MFnDependencyNode fnNode( m_node ); - MString nodeName = fnNode.name(); - MFnDagNode fnDN( m_node ); - if( fnDN.hasObj( m_node ) ) - { - nodeName = fnDN.fullPathName(); - } - - ParameterisedInterface *parameterised = m_parameterisedHolder->getParameterisedInterface(); - - std::set names; - for( IECore::CompoundDataMap::const_iterator it=m_originalClasses->readable().begin(); it!=m_originalClasses->readable().end(); it++ ) - { - names.insert( it->first ); - } - for( IECore::CompoundDataMap::const_iterator it=m_newClasses->readable().begin(); it!=m_newClasses->readable().end(); it++ ) - { - names.insert( it->first ); - } - - for( std::set::const_iterator it=names.begin(); it!=names.end(); it++ ) - { - Parameter *parameter = parameterFromPath( parameterised, *it ); - if( parameter ) - { - IECore::CompoundDataMap::const_iterator it1 = m_originalClasses->readable().find( *it ); - IECore::CompoundDataMap::const_iterator it2 = m_newClasses->readable().find( *it ); - - if( it1==m_originalClasses->readable().end() || it2==m_newClasses->readable().end() || !(it1->second->isEqualTo( it2->second.get() ) ) ) - { - MPlug parameterPlug = m_parameterisedHolder->parameterPlug( parameter ); - MString plugName = nodeName + "." + parameterPlug.partialName(); - if( parameter->isInstanceOf( "ClassParameter" ) ) - { - MGlobal::executePythonCommand( "import IECoreMaya; IECoreMaya.FnParameterisedHolder._despatchSetClassParameterClassCallbacks( \"" + plugName + "\" )" ); - } - else - { - MGlobal::executePythonCommand( "import IECoreMaya; IECoreMaya.FnParameterisedHolder._despatchSetClassVectorParameterClassesCallbacks( \"" + plugName + "\" )" ); - } - } - } - } -} - -IECore::Parameter *ParameterisedHolderModificationCmd::parameterFromPath( ParameterisedInterface *parameterised, const std::string &path ) const -{ - std::vector names; - boost::split( names, path, boost::is_any_of( "." ) ); - - CompoundParameter *parent = parameterised->parameters(); - for( int i=0; i<(int)names.size(); i++ ) - { - if( i==((int)names.size()-1) ) - { - return parent->parameter( names[i] ); - } - else - { - parent = parent->parameter( names[i] ); - if( !parent ) - { - return 0; - } - } - } - - return 0; -} diff --git a/src/IECoreMaya/ParameterisedHolderSetValueCmd.cpp b/src/IECoreMaya/ParameterisedHolderSetValueCmd.cpp deleted file mode 100644 index ddcfd97da7..0000000000 --- a/src/IECoreMaya/ParameterisedHolderSetValueCmd.cpp +++ /dev/null @@ -1,203 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MArgList.h" -#include "maya/MSyntax.h" -#include "maya/MArgDatabase.h" -#include "maya/MSelectionList.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MStringArray.h" - -#include "IECore/Object.h" -#include "IECore/Parameter.h" -#include "IECore/CompoundParameter.h" - -#include "IECoreMaya/ParameterisedHolderSetValueCmd.h" - -using namespace IECoreMaya; - -ParameterisedHolderSetValueCmd::ParameterisedHolderSetValueCmd() - : m_parameterisedHolder( 0 ), m_parameter( 0 ) -{ -} - -ParameterisedHolderSetValueCmd::~ParameterisedHolderSetValueCmd() -{ -} - -void *ParameterisedHolderSetValueCmd::creator() -{ - return new ParameterisedHolderSetValueCmd; -} - -MSyntax ParameterisedHolderSetValueCmd::newSyntax() -{ - MSyntax s; - - s.addFlag( "p", "plug", MSyntax::kString ); - - s.setObjectType( MSyntax::kSelectionList, 1, 1 ); - - return s; -} - -bool ParameterisedHolderSetValueCmd::isUndoable() const -{ - return true; -} - -MStatus ParameterisedHolderSetValueCmd::doIt( const MArgList &argList ) -{ - MArgDatabase args( syntax(), argList ); - - // get the node we're operating on - MSelectionList objects; - //args.getObjects( objects ); // leaving for further investigation - // \todo: MArgDatabase.getObjects() seems to be broken in Maya 2009. - // It returns and empty MSelectionList when the argList is a ParameterisedHolderSet - // Note that the MArgDatabase still seems to be valid, since we extract the plug name later on - // Creating the MSelectionList directly from argList instead. - MString objectStr; - argList.get( 0, objectStr ); - objects.add( objectStr ); - - MStringArray selStr; objects.getSelectionStrings( selStr ); - assert( objects.length()==1 ); - MObject node; - objects.getDependNode( 0, node ); - MFnDependencyNode fnNode( node ); - MPxNode *userNode = fnNode.userNode(); - m_parameterisedHolder = dynamic_cast( userNode ); - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - // see if we're being asked to operate on a specific parameter or - // just the whole thing. - MString plugName = args.flagArgumentString( "plug", 0 ); - if( plugName!="" ) - { - MPlug plug = fnNode.findPlug( plugName, false ); - if( plug.isNull() ) - { - m_parameterisedHolder = 0; // so we won't attempt anything in undoIt or redoIt - return MS::kFailure; - } - m_parameter = m_parameterisedHolder->plugParameter( plug ); - if( !m_parameter ) - { - m_parameterisedHolder = 0; // so we won't attempt anything in undoIt or redoIt - return MS::kFailure; - } - } - - // store the values we'll be setting in doIt and undoIt - - IECore::ParameterisedInterface *interface = m_parameterisedHolder->getParameterisedInterface(); - IECore::ParameterPtr parameter = m_parameter ? m_parameter : IECore::ParameterPtr(interface->parameters()); - - // we must copy the value here, as the m_originalValue = parm->getValue() below updates the value in place, - // which would modify tmp if it weren't a copy. - IECore::CompoundObjectPtr tmp = static_cast( parameter->getValue() )->copy(); - - m_newValue = parameter->getValue()->copy(); - if( m_parameter ) - { - m_parameterisedHolder->setParameterisedValue( parameter ); - } - else - { - m_parameterisedHolder->setParameterisedValues(); - } - m_originalValue = parameter->getValue(); - - parameter->setValue( tmp ); - - return redoIt(); -} - -MStatus ParameterisedHolderSetValueCmd::redoIt() -{ - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - IECore::ParameterisedInterface *interface = m_parameterisedHolder->getParameterisedInterface(); - IECore::ParameterPtr parameter = m_parameter ? m_parameter : IECore::ParameterPtr(interface->parameters()); - - IECore::ObjectPtr tmp = parameter->getValue(); - - parameter->setValue( m_newValue ); - if( m_parameter ) - { - m_parameterisedHolder->setNodeValue( parameter ); - } - else - { - m_parameterisedHolder->setNodeValues(); - } - - parameter->setValue( tmp ); - - return MStatus::kSuccess; -} - -MStatus ParameterisedHolderSetValueCmd::undoIt() -{ - if( !m_parameterisedHolder ) - { - return MStatus::kFailure; - } - - IECore::ParameterisedInterface *interface = m_parameterisedHolder->getParameterisedInterface(); - IECore::ParameterPtr parameter = m_parameter ? m_parameter : IECore::ParameterPtr(interface->parameters()); - - IECore::ObjectPtr tmp = parameter->getValue(); - - parameter->setValue( m_originalValue ); - if( m_parameter ) - { - m_parameterisedHolder->setNodeValue( parameter ); - } - else - { - m_parameterisedHolder->setNodeValues(); - } - - parameter->setValue( tmp ); - - return MStatus::kSuccess; -} diff --git a/src/IECoreMaya/PlaybackFrameList.cpp b/src/IECoreMaya/PlaybackFrameList.cpp deleted file mode 100644 index 6d7314a5d6..0000000000 --- a/src/IECoreMaya/PlaybackFrameList.cpp +++ /dev/null @@ -1,138 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MAnimControl.h" -#include "maya/MTime.h" - -#include "IECoreMaya/PlaybackFrameList.h" - -using namespace IECore; -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( PlaybackFrameList ); - -FrameList::Parser< PlaybackFrameList > PlaybackFrameList::g_parserRegistrar; - -PlaybackFrameList::PlaybackFrameList( PlaybackFrameList::Range r ) : m_range( r ) -{ -} - -PlaybackFrameList::~PlaybackFrameList() -{ -} - -PlaybackFrameList::Range PlaybackFrameList::getRange() const -{ - return m_range; -} - -void PlaybackFrameList::setRange( Range r ) -{ - m_range = r; -} - -void PlaybackFrameList::asList( std::vector &frames ) const -{ - frames.clear(); - - MTime start, end; - - if ( m_range == Animation ) - { - start = MAnimControl::animationStartTime(); - end = MAnimControl::animationEndTime(); - } - else if ( m_range == Playback ) - { - start = MAnimControl::minTime(); - end = MAnimControl::maxTime(); - } - else - { - assert( false ); - } - - Frame startFrame = static_cast( start.as( MTime::uiUnit() ) ); - Frame endFrame = static_cast( end.as( MTime::uiUnit() ) ); - - for ( Frame i = startFrame; i <= endFrame; i++ ) - { - frames.push_back( i ); - } -} - -std::string PlaybackFrameList::asString() const -{ - if ( m_range == Animation ) - { - return "animation"; - } - else - { - assert( m_range == Playback ); - return "playback"; - } -} - -FrameListPtr PlaybackFrameList::copy() const -{ - return new PlaybackFrameList( m_range ); -} - -bool PlaybackFrameList::isEqualTo( ConstFrameListPtr other ) const -{ - if ( !FrameList::isEqualTo( other ) ) - { - return false; - } - - ConstPlaybackFrameListPtr otherF = assertedStaticCast< const PlaybackFrameList >( other ); - - return m_range == otherF->m_range; -} - -FrameListPtr PlaybackFrameList::parse( const std::string &frameList ) -{ - if ( frameList == "animation" ) - { - return new PlaybackFrameList( Animation ); - } - else if ( frameList == "playback" ) - { - return new PlaybackFrameList( Playback ); - } - return 0; -} diff --git a/src/IECoreMaya/PostLoadCallback.cpp b/src/IECoreMaya/PostLoadCallback.cpp deleted file mode 100644 index c3a56af021..0000000000 --- a/src/IECoreMaya/PostLoadCallback.cpp +++ /dev/null @@ -1,101 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MFileIO.h" -#include "maya/MString.h" -#include "maya/MMessage.h" -#include "maya/MSceneMessage.h" -#include "maya/MEventMessage.h" - -#include "IECoreMaya/PostLoadCallback.h" - -using namespace IECoreMaya; - -class PostLoadCallback::PostLoadCallbackData -{ - friend class PostLoadCallback; - - public: - - PostLoadCallbackData(PostLoadCallback* plcb) : m_plcb( plcb ) - { - MStatus s; - - m_callbacks.append( MSceneMessage::addCallback( MSceneMessage::kAfterOpen, &afterLoad, this, &s ) ); - assert(s); - m_callbacks.append( MSceneMessage::addCallback( MSceneMessage::kAfterImport, &afterLoad, this, &s ) ); - assert(s); - m_callbacks.append( MSceneMessage::addCallback( MSceneMessage::kAfterReference, &afterLoad, this, &s ) ); - assert(s); - } - - ~PostLoadCallbackData() - { - MMessage::removeCallbacks( m_callbacks ); - } - - static void afterLoad(void *clientData) - { - assert( clientData ); - - // we only emit the callback when isReadingFile() is false, as this indicates that all - // loading is complete. otherwise we would emit a whole series of callbacks when loading a scene - // with lots of references in. - if( !MFileIO::isReadingFile() ) - { - PostLoadCallbackData* data = static_cast( clientData ); - - assert( data->m_plcb ); - data->m_plcb->postLoad(); - } - } - - private: - - MCallbackIdArray m_callbacks; - - PostLoadCallback* m_plcb; -}; - -PostLoadCallback::PostLoadCallback() -{ - m_data = new PostLoadCallbackData(this); -} - -PostLoadCallback::~PostLoadCallback() -{ - delete m_data; -} diff --git a/src/IECoreMaya/PythonCmd.cpp b/src/IECoreMaya/PythonCmd.cpp deleted file mode 100644 index 1926b8a547..0000000000 --- a/src/IECoreMaya/PythonCmd.cpp +++ /dev/null @@ -1,424 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" -#include "boost/format.hpp" -#include - -#include "maya/MArgList.h" -#include "maya/MGlobal.h" -#include "maya/MSyntax.h" -#include "maya/MArgDatabase.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECoreMaya/PythonCmd.h" - -static const char *kCommandFlag = "-cmd"; -static const char *kCommandFlagLong = "-command"; - -static const char *kFileFlag = "-f"; -static const char *kFileFlagLong = "-file"; - -static const char *kEvalFlag = "-e"; -static const char *kEvalFlagLong = "-eval"; - -static const char *kContextFlag = "-ctx"; -static const char *kContextFlagLong = "-context"; - -static const char *kCreateContextFlag = "-cc"; -static const char *kCreateContextFlagLong = "-createContext"; - -static const char *kDeleteContextFlag = "-dc"; -static const char *kDeleteContextFlagLong = "-deleteContext"; - -using namespace IECoreMaya; -using namespace boost::python; -using namespace boost; -using namespace std; - -object PythonCmd::g_globalContext; -bool PythonCmd::g_initialized; -PythonCmd::ContextMap PythonCmd::g_contextMap; - -void PythonCmd::import( const std::string &moduleName ) -{ - IECorePython::ScopedGILLock lock; - - try - { - string toExecute = boost::str( format( - "import %1%\n" - ) % moduleName - ); - - handle<> ignored( PyRun_String( - toExecute.c_str(), - Py_file_input, g_globalContext.ptr(), - g_globalContext.ptr() ) - ); - } - catch ( error_already_set & ) - { - PyErr_Print(); - } - -} - -void PythonCmd::initialize() -{ - if (!g_initialized) - { - /// Maya (8.5 onwards) may have already initialized Maya for us - if (!Py_IsInitialized()) - { - Py_Initialize(); - } - - assert( Py_IsInitialized() ); - - IECorePython::ScopedGILLock lock; - - /// Initialize the __main__ module if not already present - PyObject* sysModules = PyImport_GetModuleDict(); - assert(sysModules); - - object mainModule(borrowed(PyDict_GetItemString(sysModules, "__main__"))); - assert( mainModule ); - - /// Retrieve the global context from the __main__ module - g_globalContext = mainModule.attr("__dict__"); - assert( g_globalContext ); - - import( "IECore" ); - import( "IECoreMaya" ); - import( "IECoreGL" ); - - g_initialized = true; - - } -} - -void PythonCmd::uninitialize() -{ - if (g_initialized) - { -#if MAYA_API_VERSION < 850 - Py_Finalize(); -#endif - g_contextMap.clear(); - } - g_initialized = false; -} - -boost::python::object &PythonCmd::globalContext() -{ - return g_globalContext; -} - -PythonCmd::PythonCmd() -{ - assert( g_initialized ); -} - -PythonCmd::~PythonCmd() -{ -} - -void *PythonCmd::creator() -{ - return new PythonCmd; -} - -MSyntax PythonCmd::newSyntax() -{ - MSyntax syn; - MStatus s; - - s = syn.addFlag( kCommandFlag, kCommandFlagLong, MSyntax::kString ); - assert(s); - - s = syn.addFlag( kFileFlag, kFileFlagLong, MSyntax::kString ); - assert(s); - - s = syn.addFlag( kEvalFlag, kEvalFlagLong, MSyntax::kString ); - assert(s); - - s = syn.addFlag( kContextFlag, kContextFlagLong, MSyntax::kString ); - assert(s); - - s = syn.addFlag( kCreateContextFlag, kCreateContextFlagLong, MSyntax::kString ); - assert(s); - - s = syn.addFlag( kDeleteContextFlag, kDeleteContextFlagLong, MSyntax::kString ); - assert(s); - - return syn; -} - - -MStatus PythonCmd::doIt( const MArgList &argList ) -{ - MStatus s; - MArgDatabase args( syntax(), argList ); - - if (args.isFlagSet( kCommandFlag ) && args.isFlagSet( kFileFlag ) ) - { - displayError("Must specify only one of " + MString(kCommandFlagLong) + "/" + MString(kFileFlagLong)); - return MS::kFailure; - } - - IECorePython::ScopedGILLock gilLock; - - list argv; - - PySys_SetObject( (char *)"argv", argv.ptr() ); - - object *context = &g_globalContext; - assert(context); - - if (args.isFlagSet( kContextFlagLong ) ) - { - if (args.isFlagSet( kCreateContextFlagLong ) || args.isFlagSet( kDeleteContextFlagLong ) ) - { - displayError("Syntax error"); - return MS::kFailure; - } - - if (!args.isFlagSet( kCommandFlagLong ) && !args.isFlagSet( kFileFlagLong ) ) - { - displayError("Must specify one of " + MString(kCommandFlagLong) + "/" + MString(kFileFlagLong) ); - return MS::kFailure; - } - - MString contextName; - s = args.getFlagArgument( kContextFlagLong, 0, contextName ); - assert(s); - - ContextMap::iterator it = g_contextMap.find( contextName.asChar() ); - if (it == g_contextMap.end()) - { - displayError("Context does not exist"); - return MS::kFailure; - } - - context = &(it->second); - assert( context != &g_globalContext ); - } - - if (args.isFlagSet( kCreateContextFlag ) || args.isFlagSet( kCreateContextFlagLong )) - { - if (args.isFlagSet( kContextFlagLong ) || args.isFlagSet( kDeleteContextFlagLong ) ) - { - displayError("Syntax error"); - return MS::kFailure; - } - - MString contextName; - s = args.getFlagArgument( kCreateContextFlagLong, 0, contextName ); - assert(s); - - ContextMap::iterator it = g_contextMap.find( contextName.asChar() ); - if (it != g_contextMap.end()) - { - displayWarning("Context already exists"); - context = &(it->second); - } - else - { - g_contextMap[ contextName.asChar() ] = dict(); - context = &(g_contextMap[ contextName.asChar() ]); - } - assert( context != &g_globalContext ); - return MS::kSuccess; - } - - if (args.isFlagSet( kDeleteContextFlagLong ) ) - { - if (args.isFlagSet( kContextFlagLong ) || args.isFlagSet( kCreateContextFlagLong ) ) - { - displayError("Syntax error"); - return MS::kFailure; - } - - if (args.isFlagSet( kCommandFlagLong ) || args.isFlagSet( kFileFlagLong ) ) - { - displayError("Syntax error"); - return MS::kFailure; - } - - MString contextName; - s = args.getFlagArgument( kDeleteContextFlagLong, 0, contextName ); - assert(s); - - ContextMap::iterator it = g_contextMap.find( contextName.asChar() ); - if (it == g_contextMap.end()) - { - displayWarning("Context does not exist"); - } - else - { - g_contextMap.erase( it ); - } - return MS::kSuccess; - } - - assert(context); - - if (args.isFlagSet( kCommandFlagLong ) ) - { - if (args.isFlagSet( kFileFlagLong ) || args.isFlagSet( kEvalFlagLong ) ) - { - displayError("Must specify only one of " + MString(kCommandFlagLong) + "/" + MString(kFileFlagLong) + "/" + MString(kEvalFlagLong)); - return MS::kFailure; - } - MString cmd; - s = args.getFlagArgument( kCommandFlagLong, 0, cmd ); - - argv.append( "" ); - - try - { - handle<> ignored(( - PyRun_String( - cmd.asChar(), - Py_file_input, - context->ptr(), - context->ptr() - ) - )); - return MS::kSuccess; - } - catch(error_already_set &e) - { - PyErr_Print(); - return MS::kFailure; - } - catch(...) - { - displayError("Caught unexpected exception"); - return MS::kFailure; - } - - } - else if (args.isFlagSet( kFileFlagLong ) ) - { - if (args.isFlagSet( kCommandFlagLong ) || args.isFlagSet( kEvalFlagLong ) ) - { - displayError("Must specify only one of " + MString(kCommandFlagLong) + "/" + MString(kFileFlagLong) + "/" + MString(kEvalFlagLong) ); - return MS::kFailure; - } - - MString filename; - s = args.getFlagArgument( kFileFlagLong, 0, filename ); - assert(s); - - argv.append( filename.asChar() ); // causes python to print out the filename appropriately in a stack trace - - FILE *fp = fopen( filename.asChar(), "r" ); - if (!fp) - { - displayError( MString("Cannot open file ") + filename ); - return MS::kFailure; - } - - try - { - handle<> ignored(( - PyRun_FileEx( - fp, - filename.asChar(), - Py_file_input, - context->ptr(), - context->ptr(), - 1 - ) - )); - return MS::kSuccess; - } - catch(error_already_set &e) - { - PyErr_Print(); - return MS::kFailure; - } - catch(...) - { - displayError("Caught unexpected exception"); - return MS::kFailure; - } - } - else if (args.isFlagSet( kEvalFlagLong ) ) - { - if (args.isFlagSet( kCommandFlagLong ) || args.isFlagSet( kFileFlagLong ) ) - { - displayError("Must specify only one of " + MString(kCommandFlagLong) + "/" + MString(kFileFlagLong) + "/" + MString(kEvalFlagLong) ); - return MS::kFailure; - } - - MString cmd; - s = args.getFlagArgument( kEvalFlagLong, 0, cmd ); - assert(s); - - argv.append( cmd.asChar() ); - - try - { - handle<> resultHandle( ( - PyRun_String( - cmd.asChar(), - Py_eval_input, - context->ptr(), - context->ptr() - ) - ) ); - - object result( resultHandle ); - string strResult = extract( boost::python::str( result ) )(); - setResult( strResult.c_str() ); - return MS::kSuccess; - } - catch(error_already_set &e) - { - PyErr_Print(); - return MS::kFailure; - } - catch(...) - { - displayError( "Caught unexpected exception" ); - return MS::kFailure; - } - } - - return MS::kFailure; -} diff --git a/src/IECoreMaya/SceneShape.cpp b/src/IECoreMaya/SceneShape.cpp deleted file mode 100644 index 8b02b91fcc..0000000000 --- a/src/IECoreMaya/SceneShape.cpp +++ /dev/null @@ -1,475 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/SharedSceneInterfaces.h" -#include "IECoreScene/LinkedScene.h" - -#include "IECoreMaya/SceneShape.h" -#include "IECoreMaya/LiveScene.h" -#include "IECoreMaya/MayaTypeIds.h" - -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnStringData.h" -#include "maya/MPlugArray.h" -#include "maya/MFnDagNode.h" -#include "maya/MTime.h" -#include "maya/MEvaluationNode.h" -#include "maya/MItDependencyGraph.h" - - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -namespace -{ -const MString g_mayaGlobalTimeNodeName( "time1" ); -} - -MTypeId SceneShape::id = SceneShapeId; -MObject SceneShape::aSceneFilePlug; -MObject SceneShape::aSceneRootPlug; - -// registers this class in LiveScene -SceneShape::LiveSceneAddOn SceneShape::g_liveSceneAddon; - -SceneShape::LiveSceneAddOn::LiveSceneAddOn() -{ - LiveScene::registerCustomObject( SceneShape::hasSceneShapeObject, SceneShape::readSceneShapeObject ); - LiveScene::registerCustomAttributes( SceneShape::sceneShapeAttributeNames, SceneShape::readSceneShapeAttribute ); - LiveScene::registerCustomTags( SceneShape::hasTag, SceneShape::readTags ); -} - -SceneShape::SceneShape() - : m_sceneDirty( true ) -{ -} - -SceneShape::~SceneShape() -{ -} - -void *SceneShape::creator() -{ - return new SceneShape; -} - -void SceneShape::postConstructor() -{ - SceneShapeInterface::postConstructor(); - setRenderable( true ); -} - -MStatus SceneShape::initialize() -{ - MStatus s = inheritAttributesFrom( "ieSceneShapeInterface" ); - MFnTypedAttribute tAttr; - - // will need to check for sceneFile extensions - aSceneFilePlug = tAttr.create( "file", "scf", MFnData::kString ); - s = addAttribute( aSceneFilePlug ); - assert( s ); - - aSceneRootPlug = tAttr.create( "root", "scr", MFnData::kString, MFnStringData().create( "/" ), &s ); - assert( s ); - s = addAttribute( aSceneRootPlug ); - assert( s ); - - attributeAffects( aSceneFilePlug, aTransform ); - attributeAffects( aSceneFilePlug, aBound ); - attributeAffects( aSceneFilePlug, aOutputObjects ); - attributeAffects( aSceneFilePlug, aAttributes ); - - attributeAffects( aSceneRootPlug, aTransform ); - attributeAffects( aSceneRootPlug, aBound ); - attributeAffects( aSceneRootPlug, aOutputObjects ); - attributeAffects( aSceneRootPlug, aAttributes ); - - return s; -} - -IECoreScene::ConstSceneInterfacePtr SceneShape::getSceneInterface() -{ - if( !m_sceneDirty ) - { - return m_scene; - } - - MPlug pSceneFile( thisMObject(), aSceneFilePlug ); - MString sceneFile; - pSceneFile.getValue( sceneFile ); - - MPlug pSceneRoot( thisMObject(), aSceneRootPlug ); - MString sceneRoot; - pSceneRoot.getValue( sceneRoot ); - - try - { - m_scene = IECoreScene::SharedSceneInterfaces::get( sceneFile.asChar() ); - IECoreScene::SceneInterface::Path rootPath; - IECoreScene::SceneInterface::stringToPath( sceneRoot.asChar(), rootPath ); - m_scene = m_scene->scene( rootPath ); - - m_sceneDirty = false; - } - catch( std::exception &e ) - { - m_scene = nullptr; - } - - return m_scene; -} - -MStatus SceneShape::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - if( plug == aSceneFilePlug || plug == aSceneRootPlug || plug == aObjectDependency ) - { - m_sceneDirty = true; - setDirty(); - childChanged( kBoundingBoxChanged ); - } - - return SceneShapeInterface::setDependentsDirty( plug, plugArray ); -} - -MStatus SceneShape::preEvaluation( const MDGContext& context, const MEvaluationNode& evaluationNode ) -{ - // Dirty implementation for Evaluation Graph (Parallel / Serial Mode) - MStatus status; - - // Do nothing if context is not normal - if( !context.isNormal() ) - { - return MStatus::kFailure; - } - - if( ( evaluationNode.dirtyPlugExists( aSceneFilePlug, &status ) && status ) || ( evaluationNode.dirtyPlugExists( aSceneRootPlug, &status ) && status ) || ( evaluationNode.dirtyPlugExists( aObjectDependency, &status ) && status ) ) - { - m_sceneDirty = true; - setDirty(); - childChanged( kBoundingBoxChanged ); - } - - return SceneShapeInterface::preEvaluation( context, evaluationNode ); -} - -SceneShape *SceneShape::findScene( const MDagPath &p, bool noIntermediate, MDagPath *dagPath ) -{ - // Parse all children because numberOfShapesDirectlyBelow does not include intermediate shapes - unsigned int childCount = p.childCount(); - for ( unsigned int c = 0; c < childCount; c++ ) - { - MStatus st; - MObject childObject = p.child( c, &st ); - if( st ) - { - MFnDagNode fnChildDag(childObject); - MPxNode* userNode = fnChildDag.userNode(); - - if( userNode && ( userNode->typeId() == SceneShapeId || userNode->typeId() == SceneShapeProxyId ) ) - { - if ( noIntermediate && fnChildDag.isIntermediateObject() ) - { - continue; - } - - SceneShape *sceneShape = dynamic_cast< SceneShape * >( userNode ); - if ( !sceneShape ) - { - throw Exception( "Could not get a pointer to SceneShape!"); - } - if ( dagPath ) - { - MDagPath childDag; - fnChildDag.getPath( childDag ); - *dagPath = childDag; - } - return sceneShape; - } - } - } - return nullptr; -} - -bool SceneShape::hasSceneShapeLink( const MDagPath &p ) -{ - // We exclude intermediate objects because this indicates that a native maya dag node is - // replacing the object (and hierarchy) at this location, and we can no longer link back - // to the original cache. - MDagPath dagPath; - SceneShape *sceneShape = findScene( p, true, &dagPath ); - if ( !sceneShape ) - { - return false; - } - - MFnDagNode fnChildDag( dagPath ); - MStatus st; - MPlug objectOnlyPlug = fnChildDag.findPlug( aObjectOnly, false, &st ); - if( !st ) - { - throw Exception( "Could not find 'objectOnly' plug in SceneShape!"); - } - - // if we're doing objects only, we just output the object directly, so we don't need link attributes... - if( objectOnlyPlug.asBool() ) - { - return false; - } - - if ( !sceneShape->getSceneInterface() ) - { - return false; - } - - // so if it's not object only, then we know the scene loads everything and we can create a link to it. - return true; -} - -ConstObjectPtr SceneShape::readSceneShapeLink( const MDagPath &p ) -{ - MDagPath dagPath; - SceneShape *sceneShape = findScene( p, true, &dagPath ); - if ( !sceneShape ) - { - throw Exception( "readSceneShapeLink: Could not find SceneShape!" ); - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if ( !scene ) - { - throw Exception( "Empty scene!"); - } - - MFnDagNode fnChildDag( dagPath ); - MStatus st; - MPlug timePlug = fnChildDag.findPlug( aTime, false, &st ); - if( !st ) - { - throw Exception( "Could not find 'time' plug in SceneShape!" ); - } - - MItDependencyGraph it = MItDependencyGraph( timePlug, MFn::kInvalid, MItDependencyGraph::kUpstream, MItDependencyGraph::kDepthFirst, MItDependencyGraph::kPlugLevel ); - for ( ; !it.isDone() ; it.next() ) - { - MPlug currPlug = it.thisPlug( &st ); - CHECK_MSTATUS(st); - MFnDependencyNode nodeFn( currPlug.node(), &st ); - CHECK_MSTATUS(st); - - if ( nodeFn.name() == g_mayaGlobalTimeNodeName ) - { - /// The plug is connected to maya global time, so no time remapping is happening - return LinkedScene::linkAttributeData( scene ); - } - - unsigned int nodeId = nodeFn.typeId().id(); - bool isSceneShape = nodeId == SceneShapeId || nodeId == SceneShapeProxyId; - if ( !isSceneShape ) - { - /// The time plug is not connected to global maya time or a scene shape (expanded hierarchy), - /// so we assume some kind of time manipulation (a maya add node to offset the value or similiar) - MTime time; - timePlug.getValue( time ); - return LinkedScene::linkAttributeData( scene, time.as( MTime::kSeconds ) ); - } - } - - /// The time plug doesn't have any connection at all (time hold) - MTime time; - timePlug.getValue( time ); - return LinkedScene::linkAttributeData( scene, time.as( MTime::kSeconds ) ); -} - -void SceneShape::sceneShapeAttributeNames( const MDagPath &p, SceneInterface::NameList &attributeNames ) -{ - // Note that we include intermediate SceneShapes objects since we may have substituted native - // maya dag nodes for our SceneShape nodes, but we don't want to lose visibility of our attributes - MDagPath dagPath; - SceneShape *sceneShape = findScene( p, false, &dagPath ); - if ( !sceneShape ) - { - return; - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if ( !scene ) - { - return; - } - - SceneInterface::NameList sceneAttrNames; - scene->attributeNames( sceneAttrNames ); - attributeNames.insert( attributeNames.end(), sceneAttrNames.begin(), sceneAttrNames.end() ); - - MFnDagNode fnChildDag( dagPath ); - if( !fnChildDag.isIntermediateObject() && hasSceneShapeLink( p ) ) - { - attributeNames.push_back( LinkedScene::linkAttribute ); - } - -} - -ConstObjectPtr SceneShape::readSceneShapeAttribute( const MDagPath &p, SceneInterface::Name attributeName ) -{ - MDagPath dagPath; - SceneShape *sceneShape = findScene( p, false, &dagPath ); - if ( !sceneShape ) - { - return nullptr; - } - - MFnDagNode fnChildDag( dagPath ); - if( attributeName == LinkedScene::linkAttribute ) - { - if( !fnChildDag.isIntermediateObject() ) - { - return readSceneShapeLink(p); - } - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if ( !scene ) - { - return nullptr; - } - - MPlug timePlug = fnChildDag.findPlug( aTime, false ); - MTime time; - timePlug.getValue( time ); - try - { - return scene->readAttribute( attributeName, time.as( MTime::kSeconds ) ); - } - catch( ... ) - { - return nullptr; - } -} - -bool SceneShape::hasSceneShapeObject( const MDagPath &p ) -{ - MDagPath dagPath; - SceneShape *sceneShape = findScene( p, true, &dagPath ); - if ( !sceneShape ) - { - return false; - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if( !scene ) - { - return false; - } - - MStatus st; - MFnDagNode fnChildDag( dagPath ); - MPlug objectOnlyPlug = fnChildDag.findPlug( aObjectOnly, false, &st ); - if( !st ) - { - throw Exception( "Could not find 'objectOnly' plug in SceneShape!"); - } - - // When objectOnly == true, we assume that this SceneShape will contain the object (if one exists) - // When objectOnly == false, we expose this SceneShapes path to LiveScene as a link. - // Paths with links do not hold their own objects, they are contained in the associated LinkedScene. - // Therefore, if objectOnly == false, we assume we are a link and that we do not have an object. - // If we want to be able to read the links transparently with LiveScene, then we need to decorate LiveScene with LinkedScene. - // ie) LinkedScenePtr linkedScene = new LinkedScene{ new LiveScene }; - if( !objectOnlyPlug.asBool() ) - { - return false; - } - - return scene->hasObject(); -} - -ConstObjectPtr SceneShape::readSceneShapeObject( const MDagPath &p ) -{ - SceneShape *sceneShape = findScene( p, true ); - if ( !sceneShape ) - { - return nullptr; - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if( !scene ) - { - return nullptr; - } - - // Live scene will call `hasSceneShapeObject` before `readSceneShapeObject` - // Therefore it's unnecessary to recheck for the objectOnly plug (objectOnly = True) - - MPlug pTime( sceneShape->thisMObject(), aTime ); - MTime time; - pTime.getValue( time ); - double t = time.as( MTime::kSeconds ); - - return scene->readObject( t ); -} - -bool SceneShape::hasTag( const MDagPath &p, const SceneInterface::Name &tag, int filter ) -{ - SceneShape *sceneShape = findScene( p, false ); - if ( !sceneShape ) - { - return false; - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if ( !scene ) - { - return false; - } - - return scene->hasTag( tag, filter ); -} - -void SceneShape::readTags( const MDagPath &p, SceneInterface::NameList &tags, int filter ) -{ - SceneShape *sceneShape = findScene( p, false ); - if ( !sceneShape ) - { - return; - } - - const SceneInterface *scene = sceneShape->getSceneInterface().get(); - if ( !scene ) - { - return; - } - - scene->readTags( tags, filter ); -} diff --git a/src/IECoreMaya/SceneShapeInterface.cpp b/src/IECoreMaya/SceneShapeInterface.cpp deleted file mode 100644 index de619446ab..0000000000 --- a/src/IECoreMaya/SceneShapeInterface.cpp +++ /dev/null @@ -1,1689 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/SceneShapeInterface.h" -#include "IECoreMaya/SceneShapeInterfaceComponentBoundIterator.h" - -#include "boost/python.hpp" -#include "boost/tokenizer.hpp" - -#include "Imath/ImathMatrixAlgo.h" -#include "Imath/ImathBoxAlgo.h" - -#include "IECoreGL/Renderer.h" -#include "IECoreGL/Scene.h" -#include "IECoreGL/TypedStateComponent.h" -#include "IECoreGL/NameStateComponent.h" -#include "IECoreGL/State.h" -#include "IECoreGL/Camera.h" -#include "IECoreGL/Renderable.h" -#include "IECoreGL/Group.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaMeshConverter.h" -#include "IECoreMaya/ToMayaCurveConverter.h" -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/PostLoadCallback.h" -#include "IECoreMaya/LiveScene.h" - -#include "IECorePython/ScopedGILLock.h" -#include "IECorePython/ScopedGILRelease.h" - -#include "IECore/VectorOps.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/CompoundParameter.h" -#include "IECore/AngleConversion.h" -#include "IECore/MatrixAlgo.h" -#include "IECoreScene/VisibleRenderable.h" -#include "IECoreScene/TransformBlock.h" -#include "IECoreScene/AttributeBlock.h" -#include "IECoreScene/SampledSceneInterface.h" -#include "IECoreScene/CurvesPrimitive.h" -#include "IECoreScene/TransformOp.h" -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/Transform.h" -#include "IECoreScene/LinkedScene.h" - -#include "maya/MArrayDataBuilder.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnEnumAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnGenericAttribute.h" -#include "maya/MFnUnitAttribute.h" -#include "maya/MFnCompoundAttribute.h" -#include "maya/MFnSingleIndexedComponent.h" -#include "maya/MSelectionList.h" -#include "maya/MAttributeSpec.h" -#include "maya/MAttributeIndex.h" -#include "maya/MAttributeSpecArray.h" -#include "maya/MDagPath.h" -#include "maya/MFnStringData.h" -#include "maya/MFnMatrixData.h" -#include "maya/MFnMeshData.h" -#include "maya/MFnNurbsCurveData.h" -#include "maya/MFnGeometryData.h" -#include "maya/MPlugArray.h" -#include "maya/MFileIO.h" -#include "maya/MAnimControl.h" - -#if MAYA_API_VERSION >= 201600 - -#include "maya/MEvaluationNode.h" - -#endif - -using namespace Imath; -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -MTypeId SceneShapeInterface::id = SceneShapeInterfaceId; -MObject SceneShapeInterface::aObjectOnly; -MObject SceneShapeInterface::aDrawGeometry; -MObject SceneShapeInterface::aDrawRootBound; -MObject SceneShapeInterface::aDrawChildBounds; -MObject SceneShapeInterface::aDrawTagsFilter; -MObject SceneShapeInterface::aQuerySpace; -MObject SceneShapeInterface::aTime; -MObject SceneShapeInterface::aOutTime; -MObject SceneShapeInterface::aSceneQueries; -MObject SceneShapeInterface::aAttributeQueries; -MObject SceneShapeInterface::aConvertParamQueries; -MObject SceneShapeInterface::aOutputObjects; -MObject SceneShapeInterface::aObjectDependency; -MObject SceneShapeInterface::aAttributes; -MObject SceneShapeInterface::aAttributeValues; -MObject SceneShapeInterface::aTransform; -MObject SceneShapeInterface::aTranslate; -MObject SceneShapeInterface::aTranslateX; -MObject SceneShapeInterface::aTranslateY; -MObject SceneShapeInterface::aTranslateZ; -MObject SceneShapeInterface::aRotate; -MObject SceneShapeInterface::aRotateX; -MObject SceneShapeInterface::aRotateY; -MObject SceneShapeInterface::aRotateZ; -MObject SceneShapeInterface::aScale; -MObject SceneShapeInterface::aScaleX; -MObject SceneShapeInterface::aScaleY; -MObject SceneShapeInterface::aScaleZ; -MObject SceneShapeInterface::aBound; -MObject SceneShapeInterface::aBoundMin; -MObject SceneShapeInterface::aBoundMinX; -MObject SceneShapeInterface::aBoundMinY; -MObject SceneShapeInterface::aBoundMinZ; -MObject SceneShapeInterface::aBoundMax; -MObject SceneShapeInterface::aBoundMaxX; -MObject SceneShapeInterface::aBoundMaxY; -MObject SceneShapeInterface::aBoundMaxZ; -MObject SceneShapeInterface::aBoundCenter; -MObject SceneShapeInterface::aBoundCenterX; -MObject SceneShapeInterface::aBoundCenterY; -MObject SceneShapeInterface::aBoundCenterZ; - -// This post load callback is used to dirty the aOutputObjects elements -// following loading - see further comments in initialize. -class SceneShapeInterface::PostLoadCallback : public IECoreMaya::PostLoadCallback -{ - - public : - - PostLoadCallback( SceneShapeInterface *node ) : m_node( node ) - { - } - - protected : - - SceneShapeInterface *m_node; - - virtual void postLoad() - { - MFnDependencyNode fnDN( m_node->thisMObject() ); - MPlug plug = fnDN.findPlug( aObjectDependency, false ); - plug.setValue( 1 ); - - m_node->m_postLoadCallback = 0; // remove this callback - } - -}; - -SceneShapeInterface::SceneShapeInterface() - : m_previewSceneDirty( true ) -{ - // We only create the post load callback when Maya is reading a scene, - // so that it does not effect nodes as they are created by users. - m_postLoadCallback = ( MFileIO::isReadingFile() ) ? new PostLoadCallback( this ) : NULL; -} - -SceneShapeInterface::~SceneShapeInterface() -{ - -} - -void *SceneShapeInterface::creator() -{ - return new SceneShapeInterface; -} - -void SceneShapeInterface::postConstructor() -{ - setExistWithoutInConnections(true); - setExistWithoutOutConnections(true); -} - -MStatus SceneShapeInterface::initialize() -{ - MFnNumericAttribute nAttr; - MFnTypedAttribute tAttr; - MFnCompoundAttribute cAttr; - MFnGenericAttribute gAttr; - MFnUnitAttribute uAttr; - MFnEnumAttribute eAttr; - - MStatus s; - - aObjectOnly = nAttr.create( "objectOnly", "obj", MFnNumericData::kBoolean, 0 ); - nAttr.setReadable( true ); - nAttr.setWritable( true ); - nAttr.setStorable( true ); - nAttr.setConnectable( true ); - nAttr.setHidden( false ); - - addAttribute( aObjectOnly ); - - aDrawGeometry = nAttr.create( "drawGeometry", "drg", MFnNumericData::kBoolean, 0, &s ); - nAttr.setReadable( true ); - nAttr.setWritable( true ); - nAttr.setStorable( true ); - nAttr.setConnectable( true ); - nAttr.setHidden( false ); - nAttr.setChannelBox( true ); - - s = addAttribute( aDrawGeometry ); - - aDrawRootBound = nAttr.create( "drawRootBound", "drbd", MFnNumericData::kBoolean, 1, &s ); - nAttr.setReadable( true ); - nAttr.setWritable( true ); - nAttr.setStorable( true ); - nAttr.setConnectable( true ); - nAttr.setHidden( false ); - nAttr.setChannelBox( true ); - - s = addAttribute( aDrawRootBound ); - - aDrawChildBounds = nAttr.create( "drawChildBounds", "dchd", MFnNumericData::kBoolean, 0, &s ); - nAttr.setReadable( true ); - nAttr.setWritable( true ); - nAttr.setStorable( true ); - nAttr.setConnectable( true ); - nAttr.setHidden( false ); - nAttr.setChannelBox( true ); - - s = addAttribute( aDrawChildBounds ); - - aDrawTagsFilter = tAttr.create( "drawTagsFilter", "dtf", MFnData::kString, MFnStringData().create( "" ), &s ); - assert( s ); - s = addAttribute( aDrawTagsFilter ); - assert( s ); - - aQuerySpace = eAttr.create( "querySpace", "qsp", 0); - eAttr.addField( "World", World ); - eAttr.addField( "Local", Local ); - - s = addAttribute( aQuerySpace ); - - aTime = uAttr.create( "time", "tim", MFnUnitAttribute::kTime, 0.0, &s ); - uAttr.setConnectable( true ); - uAttr.setHidden( false ); - uAttr.setReadable( true ); - uAttr.setWritable( true ); - uAttr.setStorable( true ); - - s = addAttribute( aTime ); - - aOutTime = uAttr.create( "outTime", "otm", MFnUnitAttribute::kTime, 0.0, &s ); - uAttr.setReadable( true ); - uAttr.setWritable( false ); - uAttr.setStorable( false ); - - s = addAttribute( aOutTime ); - - // Queries - - aSceneQueries = tAttr.create( "queryPaths", "qpa", MFnData::kString ); - tAttr.setReadable( true ); - tAttr.setWritable( true ); - tAttr.setStorable( true ); - tAttr.setConnectable( true ); - tAttr.setHidden( false ); - tAttr.setArray( true ); - tAttr.setIndexMatters( true ); - - s = addAttribute( aSceneQueries ); - - aAttributeQueries = tAttr.create( "queryAttributes", "qat", MFnData::kString ); - tAttr.setReadable( true ); - tAttr.setWritable( true ); - tAttr.setStorable( true ); - tAttr.setConnectable( true ); - tAttr.setHidden( false ); - tAttr.setArray( true ); - tAttr.setIndexMatters( true ); - - s = addAttribute( aAttributeQueries ); - - aConvertParamQueries = tAttr.create( "queryConvertParameters", "qcp", MFnData::kString ); - tAttr.setReadable( true ); - tAttr.setWritable( true ); - tAttr.setStorable( true ); - tAttr.setConnectable( true ); - tAttr.setHidden( false ); - tAttr.setArray( true ); - tAttr.setIndexMatters( true ); - - s = addAttribute( aConvertParamQueries ); - - // Output objects - aOutputObjects = gAttr.create( "outObjects", "oob", &s ); - gAttr.addDataAccept( MFnMeshData::kMesh ); - gAttr.addDataAccept( MFnNurbsCurveData::kNurbsCurve ); - gAttr.addNumericDataAccept( MFnNumericData::k3Double ); - gAttr.setReadable( true ); - gAttr.setWritable( false ); - gAttr.setArray( true ); - gAttr.setIndexMatters( true ); - gAttr.setUsesArrayDataBuilder( true ); - gAttr.setStorable( false ); - s = addAttribute( aOutputObjects ); - - // A Maya bug causes mesh attributes to compute on scene open, even when nothing should be - // pulling on them. While dynamic attributes can work around this issue for single meshes, - // arrays of meshes suffer from the erroneous compute as either static or dynamic attributes. - // - // We work around the problem by adding a PostLoadCallback if the node was created while the - // scene is being read from disk. This callback is used to short circuit the compute which - // was triggered on scene open. Since the compute may have actually been necessary, we use - // this dummy dependency attribute to dirty the output object attributes immediately following - // load. At this point the callback deletes itself, and the newly dirtied output objects will - // re-compute if something was actually pulling on them. - aObjectDependency = nAttr.create( "objectDependency", "objDep", MFnNumericData::kInt, 0 ); - nAttr.setStorable( false ); - nAttr.setHidden( true ); - s = addAttribute( aObjectDependency ); - - // Transform - - aTranslateX = nAttr.create( "outTranslateX", "otx", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aTranslateY = nAttr.create( "outTranslateY", "oty", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aTranslateZ = nAttr.create( "outTranslateZ", "otz", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aTranslate = nAttr.create( "outTranslate", "obt", aTranslateX, aTranslateY, aTranslateZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aRotateX = uAttr.create( "outRotateX", "orx", MFnUnitAttribute::kAngle, 0.0, &s ); - uAttr.setWritable( false ); - uAttr.setStorable( false ); - - aRotateY = uAttr.create( "outRotateY", "ory", MFnUnitAttribute::kAngle, 0.0, &s ); - uAttr.setWritable( false ); - uAttr.setStorable( false ); - - aRotateZ = uAttr.create( "outRotateZ", "orz", MFnUnitAttribute::kAngle, 0.0, &s ); - uAttr.setWritable( false ); - uAttr.setStorable( false ); - - aRotate = nAttr.create( "outRotate", "obr", aRotateX, aRotateY, aRotateZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aScaleX = nAttr.create( "outScaleX", "osx", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aScaleY = nAttr.create( "outScaleY", "osy", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aScaleZ = nAttr.create( "outScaleZ", "osz", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aScale = nAttr.create( "outScale", "obs", aScaleX, aScaleY, aScaleZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aTransform = cAttr.create( "outTransform", "otr" ); - cAttr.addChild( aTranslate ); - cAttr.addChild( aRotate ); - cAttr.addChild( aScale ); - cAttr.setReadable( true ); - cAttr.setWritable( false ); - cAttr.setArray( true ); - cAttr.setIndexMatters( true ); - cAttr.setUsesArrayDataBuilder( true ); - cAttr.setStorable( false ); - - s = addAttribute( aTransform ); - - // Bounding box - - aBoundMinX = nAttr.create( "outBoundMinX", "obminx", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMinY = nAttr.create( "outBoundMinY", "cobminy", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMinZ = nAttr.create( "outBoundMinZ", "obminz", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMin = nAttr.create( "outBoundMin", "obmin", aBoundMinX, aBoundMinY, aBoundMinZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMaxX = nAttr.create( "outBoundMaxX", "obmaxx", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMaxY = nAttr.create( "outBoundMaxY", "cobmaxy", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMaxZ = nAttr.create( "outBoundMaxZ", "obmaxz", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundMax = nAttr.create( "outBoundMax", "obmax", aBoundMaxX, aBoundMaxY, aBoundMaxZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundCenterX = nAttr.create( "outBoundCenterX", "obcx", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundCenterY = nAttr.create( "outBoundCenterY", "obcy", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundCenterZ = nAttr.create( "outBoundCenterZ", "obcz", MFnNumericData::kFloat, 0, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBoundCenter = nAttr.create( "outBoundCenter", "obc", aBoundCenterX, aBoundCenterY, aBoundCenterZ, &s ); - nAttr.setWritable( false ); - nAttr.setStorable( false ); - - aBound = cAttr.create( "outBound", "obd" ); - cAttr.addChild( aBoundMin ); - cAttr.addChild( aBoundMax ); - cAttr.addChild( aBoundCenter ); - cAttr.setReadable( true ); - cAttr.setWritable( false ); - cAttr.setArray( true ); - cAttr.setIndexMatters( true ); - cAttr.setUsesArrayDataBuilder( true ); - cAttr.setStorable( false ); - - s = addAttribute( aBound ); - assert( s ); - - // Attributes - - MFnGenericAttribute genAttr; - aAttributeValues = genAttr.create( "attributeValues", "atv", &s ); - genAttr.addNumericDataAccept( MFnNumericData::kBoolean ); - genAttr.addNumericDataAccept( MFnNumericData::kShort ); - genAttr.addNumericDataAccept( MFnNumericData::kInt ); - genAttr.addNumericDataAccept( MFnNumericData::kInt64 ); - genAttr.addNumericDataAccept( MFnNumericData::kFloat ); - genAttr.addNumericDataAccept( MFnNumericData::kDouble ); - genAttr.addDataAccept( MFnData::kString ); - genAttr.addDataAccept( MFnData::kMatrix ); - genAttr.setReadable( true ); - genAttr.setWritable( false ); - genAttr.setStorable( false ); - genAttr.setConnectable( true ); - genAttr.setArray( true ); - genAttr.setIndexMatters( true ); - genAttr.setUsesArrayDataBuilder( true ); - - addAttribute( aAttributeValues ); - - aAttributes = cAttr.create( "attributes", "ott" ); - cAttr.addChild( aAttributeValues ); - cAttr.setReadable( true ); - cAttr.setWritable( false ); - cAttr.setArray( true ); - cAttr.setIndexMatters( true ); - cAttr.setUsesArrayDataBuilder( true ); - cAttr.setReadable( true ); - cAttr.setStorable( false ); - - s = addAttribute( aAttributes ); - - attributeAffects( aSceneQueries, aTransform ); - attributeAffects( aSceneQueries, aBound ); - attributeAffects( aSceneQueries, aOutputObjects ); - attributeAffects( aSceneQueries, aAttributes ); - - attributeAffects( aAttributeQueries, aAttributes ); - - attributeAffects( aConvertParamQueries, aOutputObjects ); - - attributeAffects( aQuerySpace, aTransform ); - attributeAffects( aQuerySpace, aBound ); - attributeAffects( aQuerySpace, aOutputObjects ); - - attributeAffects( aTime, aOutTime ); - - return s; -} - -ConstSceneInterfacePtr SceneShapeInterface::getSceneInterface( ) -{ - throw Exception( "SceneShapeInterface: getSceneInterface not implemented!" ); -} - -bool SceneShapeInterface::isBounded() const -{ - return true; -} - -double SceneShapeInterface::time() const -{ - MPlug pTime( thisMObject(), aTime ); - MTime time; - pTime.getValue( time ); - return time.as( MTime::kSeconds ); -} - -bool SceneShapeInterface::isVisible( const MDagPath &dagPath ) -{ - // Let maya check for basic dag visibility - // Maya handles hidden shapes, display layers, render layers, and intermediate objects - if( !dagPath.isVisible() ) - { - return false; - } - - // Check for ancestral visibility via LiveScene which accounts for visibility overrides which are not exposed to maya - IECoreMaya::ConstLiveScenePtr liveScene = new IECoreMaya::LiveScene(); - const double currentTime = MAnimControl::currentTime().as( MTime::kSeconds ); - - SceneInterface::Path scenePath; - IECoreMaya::LiveScene::dagPathToPath( dagPath, scenePath ); - const size_t pathLength = scenePath.size(); - for( size_t i = 0; i < pathLength; ++i ) - { - ConstSceneInterfacePtr scene = liveScene->scene( scenePath ); - ConstBoolDataPtr liveSceneVisibility = runTimeCast( scene->readAttribute( SceneInterface::visibilityName, currentTime ) ); - if( liveSceneVisibility && !liveSceneVisibility->readable() ) - { - // Not visible due to a visibility override - return false; - } - - scenePath.pop_back(); - } - - return true; -} - -MBoundingBox SceneShapeInterface::boundingBox() const -{ - MBoundingBox bound( MPoint( -1, -1, -1 ), MPoint( 1, 1, 1 ) ); - - ConstSceneInterfacePtr scn = const_cast(this)->getSceneInterface(); - - if( scn ) - { - try - { - MPlug pTime( thisMObject(), aTime ); - MTime time; - pTime.getValue( time ); - - // Check what bounding box we need. If objectOnly we want the objectBound, else the scene bound. - // If objectOnly and no object, return the scene bound to have something sensible. It won't be drawn. - - MPlug pObjectOnly( thisMObject(), aObjectOnly ); - bool objectOnly; - pObjectOnly.getValue( objectOnly ); - - bool objectBound = objectOnly; - if( objectOnly ) - { - // Check for an object - if( scn->hasObject() ) - { - ConstObjectPtr object = scn->readObject( time.as( MTime::kSeconds ) ); - const VisibleRenderable *obj = runTimeCast< const VisibleRenderable >( object.get() ); - if( obj ) - { - Box3f objBox = obj->bound(); - if( !objBox.isEmpty() ) - { - bound = convert( objBox ); - } - } - } - else - { - objectBound = false; - } - - } - - if( !objectBound ) - { - Box3d b = scn->readBound( time.as( MTime::kSeconds ) ); - if( !b.isEmpty() ) - { - bound = convert( b ); - } - } - } - catch( std::exception &e ) - { - msg( Msg::Error, "SceneShapeInterface::boundingBox", e.what() ); - } - catch( ... ) - { - msg( Msg::Error, "SceneShapeInterface::boundingBox", "Exception thrown in SceneShapeInterface::bound" ); - } - } - - return bound; -} - -MStatus SceneShapeInterface::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) -{ - if( plug == aTime ) - { - // Check if sceneInterface is animated. If not, plugs are not dependent on time - if( animatedScene() ) - { - m_previewSceneDirty = true; - childChanged( kBoundingBoxChanged ); // needed to tell maya the bounding box has changed - - // Need to go through all output plugs, since Maya doesn't propagate dirtiness from parent plug to the children in setDependentsDirty - MPlug pObjects( thisMObject(), aOutputObjects ); - for( unsigned i=0; i= 201600 - -MStatus SceneShapeInterface::preEvaluation( const MDGContext &context, const MEvaluationNode &evaluationNode ) -{ - // this is in the Maya devkit simpleEvaluationNode example so - // I'm including it here, though I'm not sure when/why we'd - // be called with a non-normal context. - if( !context.isNormal() ) - { - return MStatus::kFailure; - } - - if( - ( evaluationNode.dirtyPlugExists( aTime ) && animatedScene() ) || - evaluationNode.dirtyPlugExists( aDrawGeometry ) || - evaluationNode.dirtyPlugExists( aDrawChildBounds ) || - evaluationNode.dirtyPlugExists( aObjectOnly ) || - evaluationNode.dirtyPlugExists( aDrawTagsFilter ) - ) - { - m_previewSceneDirty = true; - } - - return MS::kSuccess; -} - -#endif - -MStatus SceneShapeInterface::compute( const MPlug &plug, MDataBlock &dataBlock ) -{ - MStatus s; - MPlug topLevelPlug = plug; - int index = -1; - // Look for parent plug index - while( topLevelPlug.isChild() || topLevelPlug.isElement() ) - { - if( topLevelPlug.isChild() ) - { - topLevelPlug = topLevelPlug.parent(); - } - if( topLevelPlug.isElement() ) - { - index = topLevelPlug.logicalIndex(); - topLevelPlug = topLevelPlug.array(); - } - } - - if ( topLevelPlug == aOutputObjects && m_postLoadCallback ) - { - return MS::kFailure; - } - - if( topLevelPlug == aOutputObjects || topLevelPlug == aTransform || topLevelPlug == aBound || topLevelPlug == aAttributes ) - { - MIntArray indices; - - if( index == -1 ) - { - // in parallel evaluation mode, we may receive the top level plug - // directly, which means we need to compute all child plugs. - topLevelPlug.getExistingArrayAttributeIndices( indices ); - } - else - { - // we still get the direct element if we're in DG mode. - indices.append( index ); - } - - MDataHandle timeHandle = dataBlock.inputValue( aTime ); - MTime time = timeHandle.asTime(); - - MPlug pQuerySpace( thisMObject(), aQuerySpace ); - int querySpace; - pQuerySpace.getValue( querySpace ); - - MString name; - SceneInterface::Path path; - MPlug pSceneQueries( thisMObject(), aSceneQueries ); - - ConstSceneInterfacePtr sc = getSceneInterface(); - if( !sc ) - { - // Scene Interface isn't valid - MFnDagNode dag(thisMObject()); - msg( Msg::Error, dag.fullPathName().asChar(), "Input values are invalid." ); - return MS::kFailure; - } - - unsigned numIndices = indices.length(); - for( unsigned i = 0; i < numIndices; ++i ) - { - MPlug pQuery = pSceneQueries.elementByLogicalIndex( indices[i] ); - pQuery.getValue( name ); - path = fullPathName( name.asChar() ); - ConstSceneInterfacePtr scene = sc->scene( path, SceneInterface::NullIfMissing ); - if( !scene ) - { - // Queried element doesn't exist - MFnDagNode dag(thisMObject()); - msg( Msg::Warning, dag.fullPathName().asChar(), boost::format( "Queried element '%s' at index '%s' does not exist " ) % name.asChar() % indices[i] ); - return MS::kFailure; - } - - s = computeOutputPlug( plug, topLevelPlug, dataBlock, scene.get(), indices[i], querySpace, time ); - if( !s ) - { - return s; - } - } - } - else if( topLevelPlug == aOutTime ) - { - MDataHandle timeHandle = dataBlock.inputValue( aTime ); - MTime time = timeHandle.asTime(); - - MDataHandle outTimeHandle = dataBlock.outputValue( aOutTime ); - outTimeHandle.setMTime( time ); - } - - return MS::kSuccess; -} - -MStatus SceneShapeInterface::computeOutputPlug( const MPlug &plug, const MPlug &topLevelPlug, MDataBlock &dataBlock, const IECoreScene::SceneInterface *scene, int topLevelIndex, int querySpace, MTime &time ) -{ - MStatus s; - - if( topLevelPlug == aTransform ) - { - MArrayDataHandle transformHandle = dataBlock.outputArrayValue( aTransform ); - MArrayDataBuilder transformBuilder = transformHandle.builder(); - - M44d transformd; - if( querySpace == World ) - { - // World Space (starting from scene root) - transformd = worldTransform( scene, time.as( MTime::kSeconds ) ); - } - else if( querySpace == Local ) - { - // Local space - transformd = scene->readTransformAsMatrix( time.as( MTime::kSeconds ) ); - } - - V3f translate( 0 ), shear( 0 ), rotate( 0 ), scale( 1 ); - extractSHRT( convert( transformd ), scale, shear, rotate, translate ); - - MDataHandle transformElementHandle = transformBuilder.addElement( topLevelIndex ); - transformElementHandle.child( aTranslate ).set3Float( translate[0], translate[1], translate[2] ); - transformElementHandle.child( aRotate ).child( aRotateX ).setMAngle( MAngle( rotate[0] ) ); - transformElementHandle.child( aRotate ).child( aRotateY ).setMAngle( MAngle( rotate[1] ) ); - transformElementHandle.child( aRotate ).child( aRotateZ ).setMAngle( MAngle( rotate[2] ) ); - transformElementHandle.child( aScale ).set3Float( scale[0], scale[1], scale[2] ); - } - else if( topLevelPlug == aOutputObjects && scene->hasObject() ) - { - MArrayDataHandle outputDataHandle = dataBlock.outputArrayValue( aOutputObjects, &s ); - MArrayDataBuilder outputBuilder = outputDataHandle.builder(); - - ConstObjectPtr object = scene->readObject( time.as( MTime::kSeconds ) ); - - if( querySpace == World ) - { - // If world space, need to transform the object using the concatenated matrix from the sceneInterface path to the query path - M44d transformd; - transformd = worldTransform( scene, time.as( MTime::kSeconds ) ); - - TransformOpPtr transformer = new TransformOp(); - transformer->inputParameter()->setValue( const_cast< Object *>(object.get()) ); /// safe const_cast because the op will duplicate the Object. - transformer->copyParameter()->setTypedValue( true ); - transformer->matrixParameter()->setValue( new M44dData( transformd ) ); - object = transformer->operate(); - } - - IECore::TypeId type = object->typeId(); - if( type == CoordinateSystem::staticTypeId() ) - { - IECoreScene::ConstCoordinateSystemPtr coordSys = IECore::runTimeCast( object ); - Imath::M44f m; - if( coordSys->getTransform() ) - { - m = coordSys->getTransform()->transform(); - } - Imath::V3f s(0), h(0), r(0), t(0); - Imath::extractSHRT(m, s, h, r, t); - - MFnNumericData fnData; - MObject data = fnData.create( MFnNumericData::k3Double ); - fnData.setData( (double)t[0], (double)t[1], (double)t[2] ); - - MDataHandle handle = outputBuilder.addElement( topLevelIndex ); - handle.set( data ); - } - else - { - ToMayaObjectConverterPtr converter = ToMayaObjectConverter::create( object ); - - if( converter ) - { - bool isParamRead = readConvertParam( converter->parameters(), topLevelIndex ); - if( ! isParamRead ) - { - return MS::kFailure; - } - - MObject data; - // Check the type for now, because a dag node is created if you pass an empty MObject to the converter - // Won't be needed anymore when the related todo is addressed in the converter - - if( type == MeshPrimitive::staticTypeId() ) - { - MFnMeshData fnData; - data = fnData.create(); - } - else if( type == CurvesPrimitive::staticTypeId() ) - { - MFnNurbsCurveData fnData; - data = fnData.create(); - - } - - if( !data.isNull() ) - { - bool conversionSuccess = converter->convert( data ); - if ( conversionSuccess ) - { - MDataHandle h = outputBuilder.addElement( topLevelIndex, &s ); - s = h.set( data ); - } - else - { - MFnDagNode dag(thisMObject()); - msg( Msg::Warning, dag.fullPathName().asChar(), boost::format( "Convert object failed! index=" ) % topLevelIndex ); - } - } - } - } - } - else if( topLevelPlug == aBound ) - { - MArrayDataHandle boundHandle = dataBlock.outputArrayValue( aBound ); - MArrayDataBuilder boundBuilder = boundHandle.builder(); - - Box3d bboxd = scene->readBound( time.as( MTime::kSeconds ) ); - - if( querySpace == World ) - { - // World Space (from root path) - M44d transformd = worldTransform( scene, time.as( MTime::kSeconds ) ); - bboxd = transform( bboxd, transformd ); - } - Box3f bound( bboxd.min, bboxd.max ); - - MDataHandle boundElementHandle = boundBuilder.addElement( topLevelIndex ); - boundElementHandle.child( aBoundMin ).set3Float( bound.min[0], bound.min[1], bound.min[2] ); - boundElementHandle.child( aBoundMax ).set3Float( bound.max[0], bound.max[1], bound.max[2] ); - V3f boundCenter = bound.center(); - boundElementHandle.child( aBoundCenter ).set3Float( boundCenter[0], boundCenter[1], boundCenter[2] ); - } - else if( topLevelPlug == aAttributes ) - { - MIntArray attrIndices; - if( plug.isElement() && !plug.isCompound() ) - { - attrIndices.append( plug.logicalIndex() ); - } - else - { - // in parallel evaluation mode, we may receive the top level plug - // directly, which means we need to compute all child plugs. - topLevelPlug.elementByLogicalIndex( topLevelIndex ).getExistingArrayAttributeIndices( attrIndices ); - } - - MPlug pAttributeQueries( thisMObject(), aAttributeQueries ); - - unsigned numAttrs = attrIndices.length(); - for( unsigned i = 0; i < numAttrs; ++i ) - { - MPlug pAttributeQuery = pAttributeQueries.elementByLogicalIndex( attrIndices[i] ); - MString attrName; - pAttributeQuery.getValue( attrName ); - - if( !scene->hasAttribute( attrName.asChar() ) ) - { - // Queried attribute doesn't exist - MFnDagNode dag(thisMObject()); - msg( Msg::Warning, dag.fullPathName().asChar(), boost::format( "Queried attribute '%s' at index '%s' does not exist " ) % attrName.asChar() % attrIndices[i] ); - return MS::kFailure; - } - - // Attribute query results are returned as attributes[ sceneQuery index ].attributeValues[ attributeQuery index ] - - MArrayDataHandle attributesHandle = dataBlock.outputArrayValue( aAttributes ); - MArrayDataBuilder builder = attributesHandle.builder(); - - MDataHandle elementHandle = builder.addElement( topLevelIndex ); - - MDataHandle attributeValuesHandle = elementHandle.child( aAttributeValues ); - - MArrayDataHandle arrayHandle( attributeValuesHandle ); - arrayHandle.jumpToElement( attrIndices[i] ); - MDataHandle currentElement = arrayHandle.outputValue(); - - ConstObjectPtr attrValue = scene->readAttribute( attrName.asChar(), time.as( MTime::kSeconds ) ); - /// \todo Use a generic data converter that would be compatible with a generic attribute. - IECore::TypeId type = attrValue->typeId(); - switch ( type ) - { - case BoolDataTypeId: - { - bool value = static_cast< const BoolData * >( attrValue.get() )->readable(); - currentElement.setGenericBool( value, true ); - break; - } - case ShortDataTypeId: - { - short value = static_cast< const ShortData * >( attrValue.get() )->readable(); - currentElement.setGenericShort( value, true ); - break; - } - case IntDataTypeId: - { - int value = static_cast< const IntData * >( attrValue.get() )->readable(); - currentElement.setGenericInt( value, true ); - break; - } - case Int64DataTypeId: - { - int64_t value = static_cast< const Int64Data * >( attrValue.get() )->readable(); - currentElement.setGenericInt64( value, true ); - break; - } - case FloatDataTypeId: - { - float value = static_cast< const FloatData * >( attrValue.get() )->readable(); - currentElement.setGenericFloat( value, true ); - break; - } - case DoubleDataTypeId: - { - float value = static_cast< const DoubleData * >( attrValue.get() )->readable(); - currentElement.setGenericDouble( value, true ); - break; - } - case StringDataTypeId: - { - MString value( static_cast< const StringData * >( attrValue.get() )->readable().c_str() ); - currentElement.setString( value ); - break; - } - case M44fDataTypeId: - { - M44f matrix = static_cast< const M44fData * >( attrValue.get() )->readable(); - MMatrix mayaMatrix = convert< MMatrix >( matrix ); - MFnMatrixData matrixFn; - MObject value = matrixFn.create( mayaMatrix ); - currentElement.setMObject( value ); - break; - } - case M44dDataTypeId: - { - M44d matrix = static_cast< const M44dData * >( attrValue.get() )->readable(); - MMatrix mayaMatrix = convert< MMatrix >( matrix ); - MFnMatrixData matrixFn; - MObject value = matrixFn.create( mayaMatrix ); - currentElement.setMObject( value ); - break; - } - default: - { - msg( Msg::Warning, "SceneShapeInterface::computeOutputPlug", boost::format( "Cannot convert queried attribute %s of type %s to a maya plug value." ) % attrName.asChar() % attrValue->typeName() ); - break; - } - } - } - } - - return s; -} - -M44d SceneShapeInterface::worldTransform( ConstSceneInterfacePtr scene, double time ) -{ - SceneInterface::Path p; - scene->path( p ); - - ConstSceneInterfacePtr tmpScene = getSceneInterface(); - SceneInterface::Path pRoot; - tmpScene->path( pRoot ); - M44d result; - - for ( SceneInterface::Path::const_iterator it = p.begin()+pRoot.size(); tmpScene && it != p.end(); ++it ) - { - tmpScene = tmpScene->child( *it, SceneInterface::NullIfMissing ); - if ( !tmpScene ) - { - break; - } - - result = tmpScene->readTransformAsMatrix( time ) * result; - } - - return result; -} - -MPxSurfaceShape::MatchResult SceneShapeInterface::matchComponent( const MSelectionList &item, const MAttributeSpecArray &spec, MSelectionList &list ) -{ - if( spec.length() == 1 ) - { - MAttributeSpec attrSpec = spec[0]; - MStatus s; - - int dim = attrSpec.dimensions(); - - if ( (dim > 0) && attrSpec.name() == "f" ) - { - int numElements = m_nameToGroupMap.size(); - - MAttributeIndex attrIndex = attrSpec[0]; - - if ( attrIndex.type() != MAttributeIndex::kInteger ) - { - return MPxSurfaceShape::kMatchInvalidAttributeRange; - } - - int upper = numElements - 1; - int lower = 0; - if ( attrIndex.hasLowerBound() ) - { - attrIndex.getLower( lower ); - } - if ( attrIndex.hasUpperBound() ) - { - attrIndex.getUpper( upper ); - } - - // Check the attribute index range is valid - if ( (attrIndex.hasRange() && !attrIndex.hasValidRange() ) || (upper >= numElements) || (lower < 0 ) ) - { - return MPxSurfaceShape::kMatchInvalidAttributeRange; - } - - MDagPath path; - item.getDagPath( 0, path ); - - MFnSingleIndexedComponent fnComp; - MObject comp = fnComp.create( MFn::kMeshPolygonComponent, &s ); - - for ( int i=lower; i<=upper; i++ ) - { - fnComp.addElement( i ); - } - - list.add( path, comp ); - - return MPxSurfaceShape::kMatchOk; - } - } - - return MPxSurfaceShape::matchComponent( item, spec, list ); -} - -MSelectionMask SceneShapeInterface::getShapeSelectionMask() const -{ - MSelectionMask retVal( MSelectionMask::kSelectMeshes ); - return retVal; -} - -MSelectionMask SceneShapeInterface::getComponentSelectionMask() const -{ - MSelectionMask retVal( MSelectionMask::kSelectMeshFaces ); - return retVal; -} - -/// Blank implementation of this method. This is to avoid a crash when you try and use the rotation manipulator maya gives -/// you when you've selected procedural components in rotation mode (maya 2013) -void SceneShapeInterface::transformUsing( const MMatrix &mat, const MObjectArray &componentList, MPxSurfaceShape::MVertexCachingMode cachingMode, MPointArray *pointCache ) -{ -} - -/// This method is overridden to supply a geometry iterator, which maya uses to work out -/// the bounding boxes of the components you've selected in the viewport -MPxGeometryIterator* SceneShapeInterface::geometryIteratorSetup( MObjectArray& componentList, MObject& components, bool forReadOnly ) -{ - if ( components.isNull() ) - { - return new SceneShapeInterfaceComponentBoundIterator( this, componentList ); - } - else - { - return new SceneShapeInterfaceComponentBoundIterator( this, components ); - } -} - -Imath::Box3d SceneShapeInterface::componentBound( int idx ) -{ - // get relative path name from index - IECore::InternedString name = selectionName( idx ); - - SceneInterface::Path path; - path = fullPathName( name.value() ); - ConstSceneInterfacePtr scene = getSceneInterface()->scene( path, SceneInterface::NullIfMissing ); - if( !scene ) - { - msg( Msg::Warning, "SceneShapeInterface::componentBound", boost::format( "no scene for component %s" ) % name.value() ); - return Imath::Box3d( Imath::V3d(-1), Imath::V3d(1) ); - } - - MPlug pTime( thisMObject(), aTime ); - MTime time; - pTime.getValue( time ); - - // read bound from scene interface and return it in world space - Imath::Box3d componentBound = scene->readBound( time.as( MTime::kSeconds ) ); - M44d transformd = worldTransform( scene, time.as( MTime::kSeconds ) ); - - componentBound = transform( componentBound, transformd ); - - return componentBound; -} - -void SceneShapeInterface::buildScene( IECoreGL::RendererPtr renderer, ConstSceneInterfacePtr subSceneInterface ) -{ - // Grab plug values to know what we need to render - MPlug pTime( thisMObject(), aTime ); - MTime time; - pTime.getValue( time ); - - MPlug pDrawBounds( thisMObject(), aDrawChildBounds ); - bool drawBounds; - pDrawBounds.getValue( drawBounds ); - - MPlug pDrawGeometry( thisMObject(), aDrawGeometry ); - bool drawGeometry; - pDrawGeometry.getValue( drawGeometry ); - - MPlug pObjectOnly( thisMObject(), aObjectOnly ); - bool objectOnly; - pObjectOnly.getValue( objectOnly ); - - if( !drawGeometry && !drawBounds ) - { - return; - } - - MPlug pDrawTagsFilter( thisMObject(), aDrawTagsFilter ); - MString drawTagsFilter; - pDrawTagsFilter.getValue( drawTagsFilter ); - - typedef boost::tokenizer > Tokenizer; - std::string txt(drawTagsFilter.asChar()); - Tokenizer tokens( txt, boost::char_separator(" ")); - Tokenizer::iterator t = tokens.begin(); - SceneInterface::NameList drawTags; - for ( ; t != tokens.end(); t++ ) - { - if ( t->size() ) - { - /// test if the scene location has the tag to start with.. - if ( subSceneInterface->hasTag( *t, SceneInterface::EveryTag ) ) - { - drawTags.push_back( *t ); - } - else - { - msg( Msg::Warning, name().asChar(), std::string("Tag '") + *t + "'does not exist in scene. Ignoring it for filtering."); - } - } - } - - renderer->concatTransform( convert( worldTransform( subSceneInterface, time.as( MTime::kSeconds ) ) ) ); - - recurseBuildScene( renderer.get(), subSceneInterface.get(), time.as( MTime::kSeconds ), drawBounds, drawGeometry, objectOnly, drawTags ); -} - -void SceneShapeInterface::recurseBuildScene( IECoreGL::Renderer * renderer, const SceneInterface *subSceneInterface, double time, bool drawBounds, bool drawGeometry, bool objectOnly, const SceneInterface::NameList &drawTags ) -{ - if ( drawTags.size() ) - { - SceneInterface::NameList::const_iterator it; - for ( it = drawTags.begin(); it != drawTags.end(); it++ ) - { - if ( subSceneInterface->hasTag( *it, SceneInterface::EveryTag ) ) - { - break; - } - } - /// stop drawing if the current scene location does not have the required tags. - if ( it == drawTags.end() ) - { - return; - } - } - - if ( subSceneInterface->hasAttribute( SceneInterface::visibilityName ) ) - { - if( ConstBoolDataPtr vis = runTimeCast( subSceneInterface->readAttribute( SceneInterface::visibilityName, time ) ) ) - { - if( !vis->readable() ) - { - return; - } - } - } - - AttributeBlock a(renderer); - SceneInterface::Path pathName; - subSceneInterface->path( pathName ); - std::string pathStr = relativePathName( pathName ); - renderer->setAttribute( "name", new StringData( pathStr ) ); - renderer->setAttribute( "gl:curvesPrimitive:useGLLines", new BoolData( true ) ); - - if(pathStr != "/") - { - // Path space - renderer->concatTransform( convert( subSceneInterface->readTransformAsMatrix( time ) ) ); - } - - // Need to add this attribute block to get a parent group with that name that includes the object and/or bound - AttributeBlock aNew(renderer); - - if ( subSceneInterface->hasAttribute( LinkedScene::fileNameLinkAttribute ) ) - { - // we are at a link location... create a hash to uniquely identify it. - MurmurHash hash; - subSceneInterface->readAttribute( LinkedScene::fileNameLinkAttribute, time )->hash( hash ); - subSceneInterface->readAttribute( LinkedScene::rootLinkAttribute, time )->hash( hash ); - subSceneInterface->readAttribute( LinkedScene::timeLinkAttribute, time )->hash( hash ); - /// register the hash mapped to the name of the group - InternedString pathInternedStr(pathStr); - std::pair< HashToName::iterator, bool > ret = m_hashToName.insert( HashToName::value_type( hash, pathInternedStr ) ); - if ( !ret.second ) - { - /// the same location was already rendered, so we store the current location for instanting later... - m_instances.push_back( InstanceInfo(pathInternedStr, ret.first->second) ); - return; - } - } - - - if( drawGeometry && subSceneInterface->hasObject() ) - { - ConstObjectPtr object = subSceneInterface->readObject( time ); - - if( runTimeCast< const CoordinateSystem >(object.get()) ) - { - // manually draw coordinate systems so they don't override the gl name state: - AttributeBlock a(renderer); - renderer->setAttribute( "gl:curvesPrimitive:useGLLines", new IECore::BoolData( true ) ); - renderer->setAttribute( "gl:curvesPrimitive:glLineWidth", new IECore::FloatData( 2 ) ); - - IECore::V3fVectorDataPtr p = new IECore::V3fVectorData; - - p->writable().push_back( Imath::V3f( 0, 0, 0 ) ); - p->writable().push_back( Imath::V3f( 1, 0, 0 ) ); - - p->writable().push_back( Imath::V3f( 0, 0, 0 ) ); - p->writable().push_back( Imath::V3f( 0, 1, 0 ) ); - - p->writable().push_back( Imath::V3f( 0, 0, 0 ) ); - p->writable().push_back( Imath::V3f( 0, 0, 1 ) ); - - IECore::IntVectorDataPtr inds = new IECore::IntVectorData; - inds->writable().resize( 3, 2 ); - - CurvesPrimitivePtr curves = new IECoreScene::CurvesPrimitive( inds, IECore::CubicBasisf::linear(), false, p ); - - curves->render( renderer ); - } - else if( const Renderable *o = runTimeCast< const Renderable >(object.get()) ) - { - o->render(renderer); - } - } - - if( drawBounds && pathStr != "/" ) - { - Box3d b = subSceneInterface->readBound( time ); - Box3f bbox( b.min, b.max ); - if( !bbox.isEmpty() ) - { - CurvesPrimitive::createBox( bbox )->render( renderer ); - } - } - - if( !objectOnly ) - { - // We need the entire hierarchy, iterate through all the sceneInterface children - SceneInterface::NameList childNames; - subSceneInterface->childNames( childNames ); - for ( SceneInterface::NameList::const_iterator it = childNames.begin(); it != childNames.end(); ++it ) - { - ConstSceneInterfacePtr childScene = subSceneInterface->child( *it ); - recurseBuildScene( renderer, childScene.get(), time, drawBounds, drawGeometry, objectOnly, drawTags ); - } - } -} - -void SceneShapeInterface::createInstances() -{ - for ( InstanceArray::iterator it = m_instances.begin(); it != m_instances.end(); it++ ) - { - const InternedString &instanceName = it->first; - const InternedString &instanceSourceName = it->second; - - NameToGroupMap::const_iterator srcIt = m_nameToGroupMap.find( instanceSourceName ); - - assert ( srcIt != m_nameToGroupMap.end() ); - - const IECoreGL::Group *srcGroup = srcIt->second.second.get(); - - NameToGroupMap::iterator trgIt = m_nameToGroupMap.find( instanceName ); - IECoreGL::Group *trgGroup = trgIt->second.second.get(); - - // copy the src group to the trg group (empty instance group) - recurseCopyGroup( srcGroup, trgGroup, instanceName.value() ); - } - - /// clear the maps we don't need them. - m_hashToName.clear(); - m_instances.clear(); -} - -void SceneShapeInterface::recurseCopyGroup( const IECoreGL::Group *srcGroup, IECoreGL::Group *trgGroup, const std::string &namePrefix ) -{ - const IECoreGL::Group::ChildContainer &children = srcGroup->children(); - - for ( IECoreGL::Group::ChildContainer::const_iterator it = children.begin(); it != children.end(); ++it ) - { - IECoreGL::Group *group = runTimeCast< IECoreGL::Group >( it->get() ); - - if ( group ) - { - IECoreGL::GroupPtr newGroup = new IECoreGL::Group(); - // copy state, including the name state component - IECoreGL::StatePtr newState = new IECoreGL::State( *group->getState() ); - newGroup->setState( newState ); - std::string newName; - const IECoreGL::NameStateComponent *nameState = newState->get< IECoreGL::NameStateComponent >(); - /// now override the name state component - if ( nameState ) - { - const std::string &srcName = nameState->name(); - size_t found = srcName.rfind('/'); - if (found!=std::string::npos) - { - // we take the current "directory" and prepend it with the namePrefix - newName = namePrefix; - newName.append( srcName, found, std::string::npos ); - newState->add( new IECoreGL::NameStateComponent( newName ) ); - // we also need to register the group in the selection maps... - registerGroup( newName, newGroup ); - } - } - newGroup->setTransform( group->getTransform() ); - recurseCopyGroup( group, newGroup.get(), newName.size() ? newName.c_str() : namePrefix ); - trgGroup->addChild( newGroup ); - } - else - { - trgGroup->addChild( *it ); - } - } - -} - -IECoreGL::ConstScenePtr SceneShapeInterface::glScene() -{ - if(!m_previewSceneDirty) - { - return m_scene; - } - - ConstSceneInterfacePtr sceneInterface = getSceneInterface(); - - if( sceneInterface ) - { - SceneInterface::NameList childNames; - sceneInterface->childNames( childNames ); - - IECoreGL::RendererPtr renderer = new IECoreGL::Renderer(); - renderer->setOption( "gl:mode", new StringData( "deferred" ) ); - - renderer->worldBegin(); - { - buildScene( renderer, sceneInterface ); - } - renderer->worldEnd(); - - m_scene = renderer->scene(); - m_scene->setCamera( 0 ); - } - - // Update component name to group map - m_nameToGroupMap.clear(); - m_indexToNameMap.clear(); - IECoreGL::ConstStatePtr defaultState = IECoreGL::State::defaultState(); - buildGroups( defaultState->get(), m_scene->root() ); - createInstances(); - - m_previewSceneDirty = false; - - return m_scene; -} - -void SceneShapeInterface::registerGroup( const std::string &name, IECoreGL::GroupPtr &group ) -{ - int index = m_nameToGroupMap.size(); - std::pair< NameToGroupMap::iterator, bool> ret; - ret = m_nameToGroupMap.insert( std::pair< InternedString, NameToGroupMap::mapped_type > (name, NameToGroupMap::mapped_type( index, group )) ); - if( ret.second ) - { - m_indexToNameMap.push_back( name ); - } -} - -void SceneShapeInterface::buildGroups( IECoreGL::ConstNameStateComponentPtr nameState, IECoreGL::GroupPtr group ) -{ - assert( nameState ); - assert( group ); - assert( group->getState() ); - - if ( group->getState()->get< IECoreGL::NameStateComponent >() ) - { - nameState = group->getState()->get< IECoreGL::NameStateComponent >(); - } - - const std::string &name = nameState->name(); - if( name != "unnamed" ) - { - registerGroup( name, group ); - } - - const IECoreGL::Group::ChildContainer &children = group->children(); - for ( IECoreGL::Group::ChildContainer::const_iterator it = children.begin(); it != children.end(); ++it ) - { - assert( *it ); - group = runTimeCast< IECoreGL::Group >( *it ); - if ( group ) - { - buildGroups( nameState, group ); - } - } -} - -void SceneShapeInterface::setDirty() -{ - m_previewSceneDirty = true; -} - -IECoreGL::GroupPtr SceneShapeInterface::glGroup( const IECore::InternedString &name ) -{ - // make sure the gl scene's been built, as this keeps m_nameToGroupMap up to date - const_cast( this )->glScene(); - - NameToGroupMap::const_iterator elementIt = m_nameToGroupMap.find( name ); - if( elementIt != m_nameToGroupMap.end() ) - { - return elementIt->second.second; - } - else - { - return 0; - } -} - -int SceneShapeInterface::selectionIndex( const IECore::InternedString &name ) -{ - // make sure the gl scene's been built, as this keeps m_indexToNameMap up to date - const_cast( this )->glScene(); - - NameToGroupMap::const_iterator elementIt = m_nameToGroupMap.find( name ); - if( elementIt != m_nameToGroupMap.end() ) - { - return elementIt->second.first; - } - else - { - return -1; - } -} - -IECore::InternedString SceneShapeInterface::selectionName( int index ) -{ - // make sure the gl scene's been built, as this keeps m_indexToNameMap up to date - const_cast( this )->glScene(); - return m_indexToNameMap[index]; -} - -const std::vector< InternedString > & SceneShapeInterface::componentNames() const -{ - // make sure the gl scene's been built, as this keeps m_indexToNameMap up to date - const_cast( this )->glScene(); - return m_indexToNameMap; -} - -std::string SceneShapeInterface::relativePathName( SceneInterface::Path path ) -{ - SceneInterface::Path root; - getSceneInterface()->path( root ); - assert( root.size() <= path.size() ); - - if( root == path ) - { - return "/"; - } - - std::string pathName; - - SceneInterface::Path::const_iterator it = path.begin(); - it += root.size(); - - for ( ; it != path.end(); it++ ) - { - pathName += '/'; - pathName += it->value(); - } - - return pathName; -} - -SceneInterface::Path SceneShapeInterface::fullPathName( std::string relativeName ) -{ - SceneInterface::Path root; - getSceneInterface()->path( root ); - - SceneInterface::Path relativePath; - SceneInterface::stringToPath( relativeName, relativePath ); - - SceneInterface::Path fullPath( root ); - fullPath.insert( fullPath.end(), relativePath.begin(), relativePath.end() ); - - return fullPath; -} - -bool SceneShapeInterface::readConvertParam( CompoundParameterPtr parameters, int attrIndex ) const -{ - IECorePython::ScopedGILLock gilLock; - - boost::python::list parserArgList; - { - MPlug pConvertParamQueries( thisMObject(), aConvertParamQueries ); - MPlug pConvertParamQuery = pConvertParamQueries.elementByLogicalIndex( attrIndex ); - MString paramsStr; - pConvertParamQuery.getValue( paramsStr ); - - const std::string pstr = paramsStr.asChar(); - boost::tokenizer > t( pstr, boost::char_separator( " " ) ); - boost::tokenizer >::const_iterator it, endIt; - for ( it = t.begin(), endIt = t.end(); it != endIt; ++it ) - { - parserArgList.append( *it ); - } - } - - try - { - boost::python::import( "IECore" ).attr( "ParameterParser" )().attr( "parse" )( parserArgList, parameters ); - } - catch( const std::exception& e ) - { - MFnDagNode dag( thisMObject() ); - msg( Msg::Error, dag.fullPathName().asChar(), boost::format( "Convert parameter parse error %s. %d" ) % e.what() % attrIndex ); - return false; - } - - return true; -} - -bool SceneShapeInterface::animatedScene() -{ - ConstSampledSceneInterfacePtr scene = runTimeCast< const SampledSceneInterface >( getSceneInterface() ); - return ( !scene || scene->numBoundSamples() > 1 ); -} diff --git a/src/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.cpp b/src/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.cpp deleted file mode 100644 index b7cccbdff8..0000000000 --- a/src/IECoreMaya/SceneShapeInterfaceComponentBoundIterator.cpp +++ /dev/null @@ -1,178 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/SceneShapeInterfaceComponentBoundIterator.h" - -#include "maya/MFnSingleIndexedComponent.h" - -using namespace IECoreMaya; - -SceneShapeInterfaceComponentBoundIterator::SceneShapeInterfaceComponentBoundIterator( void *userGeometry, MObjectArray &components ) - : MPxGeometryIterator( userGeometry, components ), - m_sceneShapeInterface( (SceneShapeInterface*) userGeometry ), - m_idx( 0 ), - m_components( components ) -{ - computeNumComponents(); -} - -SceneShapeInterfaceComponentBoundIterator::SceneShapeInterfaceComponentBoundIterator( void *userGeometry, MObject &components ) - : MPxGeometryIterator( userGeometry, components ), - m_sceneShapeInterface( (SceneShapeInterface*) userGeometry ), - m_idx( 0 ) -{ - m_components.append( components ); - computeNumComponents(); -} - -void SceneShapeInterfaceComponentBoundIterator::computeNumComponents() -{ - MStatus s; - m_numComponents = 0; - for( unsigned j=0; j < m_components.length(); ++j ) - { - MFnSingleIndexedComponent fnCmp( m_components[j], &s ); - if( s ) - { - m_numComponents += fnCmp.elementCount(); - } - } -} - -void SceneShapeInterfaceComponentBoundIterator::reset() -{ - m_idx = 0; -} - -MPoint SceneShapeInterfaceComponentBoundIterator::point() const -{ - MPoint ret; - - Imath::Box3d bbox = m_sceneShapeInterface->componentBound( index() ); - - switch( m_idx % 8 ) - { - case 0: ret = MPoint( bbox.min[0], bbox.min[1], bbox.min[2] ); break; - case 1: ret = MPoint( bbox.max[0], bbox.min[1], bbox.min[2] ); break; - case 2: ret = MPoint( bbox.min[0], bbox.max[1], bbox.min[2] ); break; - case 3: ret = MPoint( bbox.max[0], bbox.max[1], bbox.min[2] ); break; - case 4: ret = MPoint( bbox.min[0], bbox.min[1], bbox.max[2] ); break; - case 5: ret = MPoint( bbox.max[0], bbox.min[1], bbox.max[2] ); break; - case 6: ret = MPoint( bbox.min[0], bbox.max[1], bbox.max[2] ); break; - case 7: ret = MPoint( bbox.max[0], bbox.max[1], bbox.max[2] ); break; - default: break; - } - - return ret; -} - -void SceneShapeInterfaceComponentBoundIterator::setPoint( const MPoint & ) const -{ -} - -int SceneShapeInterfaceComponentBoundIterator::iteratorCount() const -{ - // one for each bounding box corner - return m_numComponents * 8; -} - -bool SceneShapeInterfaceComponentBoundIterator::hasPoints() const -{ - return true; -} - - -bool SceneShapeInterfaceComponentBoundIterator::isDone() const -{ - return m_idx >= m_numComponents * 8; -} - -#if MAYA_API_VERSION < 202200 -void SceneShapeInterfaceComponentBoundIterator::next() -{ - ++m_idx; -} -#else -MStatus SceneShapeInterfaceComponentBoundIterator::next() -{ - if( isDone() ) - { - return MS::kFailure; - } - - ++m_idx; - - return MS::kSuccess; -} -#endif - -void SceneShapeInterfaceComponentBoundIterator::component( MObject &component ) -{ - component = MObject::kNullObj; -} - -int SceneShapeInterfaceComponentBoundIterator::setPointGetNext(MPoint &p) -{ - return m_idx + 1; -} - -int SceneShapeInterfaceComponentBoundIterator::index() const -{ - MStatus s; - unsigned componentNum = 0; - unsigned targetComponentNum = m_idx / 8; - for( unsigned j=0; j < m_components.length(); ++j ) - { - MFnSingleIndexedComponent fnCmp( m_components[j], &s ); - if( s ) - { - if( componentNum + fnCmp.elementCount() > targetComponentNum ) - { - return fnCmp.element( targetComponentNum - componentNum ); - } - componentNum += fnCmp.elementCount(); - } - } - return 0; -} - -bool SceneShapeInterfaceComponentBoundIterator::hasNormals() const -{ - return false; -} - -int SceneShapeInterfaceComponentBoundIterator::indexUnsimplified() const -{ - return m_idx; -} diff --git a/src/IECoreMaya/SceneShapeProxy.cpp b/src/IECoreMaya/SceneShapeProxy.cpp deleted file mode 100644 index 965d0f95ba..0000000000 --- a/src/IECoreMaya/SceneShapeProxy.cpp +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/SceneShapeProxy.h" -#include "IECoreMaya/MayaTypeIds.h" - -using namespace IECoreMaya; - -MTypeId SceneShapeProxy::id = SceneShapeProxyId; - -SceneShapeProxy::SceneShapeProxy() {} - -SceneShapeProxy::~SceneShapeProxy() {} - -void *SceneShapeProxy::creator() -{ - return new SceneShapeProxy; -} - -MStatus SceneShapeProxy::initialize() -{ - MStatus s = inheritAttributesFrom( "ieSceneShape" ); - return s; -} diff --git a/src/IECoreMaya/SceneShapeProxyUI.cpp b/src/IECoreMaya/SceneShapeProxyUI.cpp deleted file mode 100644 index 935348cf81..0000000000 --- a/src/IECoreMaya/SceneShapeProxyUI.cpp +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/SceneShapeProxyUI.h" - -using namespace IECoreMaya; - -SceneShapeProxyUI::SceneShapeProxyUI() -{ -} - -void *SceneShapeProxyUI::creator() -{ - return new SceneShapeProxyUI; -} diff --git a/src/IECoreMaya/SceneShapeSubSceneOverride.cpp b/src/IECoreMaya/SceneShapeSubSceneOverride.cpp deleted file mode 100644 index 419086c5e9..0000000000 --- a/src/IECoreMaya/SceneShapeSubSceneOverride.cpp +++ /dev/null @@ -1,1946 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/SceneShapeSubSceneOverride.h" - -#include "IECoreMaya/Convert.h" - -#include "IECoreScene/CurvesPrimitive.h" -#include "IECoreScene/MeshAlgo.h" -#include "IECoreScene/PointsPrimitive.h" -#include "IECoreScene/SampledSceneInterface.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/LRUCache.h" -#include "IECore/MessageHandler.h" -#include "IECore/NullObject.h" -#include "IECore/Object.h" -#include "IECore/SimpleTypedData.h" - -#include "maya/MDrawRegistry.h" -#include "maya/MFnDagNode.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnSingleIndexedComponent.h" -#include "maya/MHWGeometry.h" -#include "maya/MGlobal.h" -#include "maya/MHWGeometryUtilities.h" -#include "maya/MItDependencyGraph.h" -#include "maya/MItDependencyNodes.h" -#include "maya/MItSelectionList.h" -#include "maya/MObjectArray.h" -#include "maya/MPlugArray.h" -#include "maya/MPxComponentConverter.h" -#include "maya/MSelectionContext.h" -#include "maya/MSelectionList.h" -#include "maya/MShaderManager.h" -#include "maya/MUserData.h" -#include "maya/M3dView.h" - -#include "boost/lexical_cast.hpp" - -#include "tbb/parallel_reduce.h" -#include "tbb/parallel_for.h" -#include "tbb/blocked_range.h" -#include "tbb/task_group.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; -using namespace MHWRender; - -namespace -{ - -// Limit is given in bytes. -size_t memoryLimit() -{ - // Environment variable sets limit in megabytes - defaulting to 500mb - const char *m = getenv( "IECORE_MAYA_VP2_MEMORY" ); - size_t mi = m ? boost::lexical_cast( m ) : 500; - - return mi * 1024 * 1024; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// Expandulator -// We define expandulation as the process of taking a primitive variable and -// converting it to a facevarying representation on a triangulated mesh. This -// abstraction is here so that, for a given topology, we compute the triangulated -// version only once. Doing so improves performance if the topology of a mesh -// doesn't change across frames and even more so if multiple meshes in the scene -// have the same topology. -//////////////////////////////////////////////////////////////////////////////////////////// - -class Expandulator -{ - -public: - - explicit Expandulator( const Primitive *primitive ) - { - if( !primitive ) - { - // null primitives represent a bounding box, which have constant topology - fillBoundData(); - } - else if( const auto *mesh = runTimeCast( primitive ) ) - { - fillMeshData( mesh ); - } - else if( const auto *curves = runTimeCast( primitive ) ) - { - fillCurvesData( curves ); - } - else if( const auto *points = runTimeCast( primitive ) ) - { - fillPointsData( points ); - } - } - - ~Expandulator() = default; - - /// \todo: should this return a MVertexBuffer directly? - ConstV3fVectorDataPtr expandulateVertex( const PrimitiveVariable::IndexedView &in ) const - { - const std::vector &triangulatedIndices = m_triangulatedIndices->readable(); - - V3fVectorDataPtr result( new V3fVectorData() ); - std::vector &resultWritable = result->writable(); - resultWritable.resize( triangulatedIndices.size() ); - - tbb::parallel_for( - tbb::blocked_range( 0, triangulatedIndices.size() ), - [&in, &resultWritable, &triangulatedIndices]( const tbb::blocked_range &range ) - { - for( int i = range.begin(); i != range.end(); ++i ) - { - resultWritable[i] = in[triangulatedIndices[i]]; - } - } - ); - - return result; - } - - /// \todo: should this return a MVertexBuffer directly? - ConstV2fVectorDataPtr expandulateFacevarying( const PrimitiveVariable::IndexedView &in ) const - { - const std::vector &triangulatedIndices = m_triangulatedIndices->readable(); - - V2fVectorDataPtr result( new V2fVectorData() ); - std::vector &resultWritable = result->writable(); - resultWritable.resize( triangulatedIndices.size() ); - - const std::vector &mapToOldFacevaryingReadable = m_mapToOldFacevarying->readable(); - - tbb::parallel_for( - tbb::blocked_range( 0, triangulatedIndices.size() ), - [&in, &resultWritable, &mapToOldFacevaryingReadable]( const tbb::blocked_range &range ) - { - for( int i = range.begin(); i != range.end(); ++i ) - { - resultWritable[i] = in[mapToOldFacevaryingReadable[i]]; - } - } - ); - - return result; - } - - IndexBufferPtr &indices() - { - return m_indexBuffer; - } - - IndexBufferPtr &wireframeIndices( bool force = true ) - { - if( !m_wireframeIndexBuffer && force ) - { - computeWireframeIndices(); - } - - return m_wireframeIndexBuffer; - } - - size_t memoryUsage() const - { - size_t total = m_indexBuffer->size() * sizeof( unsigned int ); - - // For meshes the indices and wireframe indices are distinct and we compute wireframe indices - // lazily. We store several additional members to do so and their combined memory is more than - // the wireframe indices would be. In practice `memoryUsage()` is only called when inserting an - // Expandulator into the global Cache, at which point we haven't computed wireframe indices, - // so we accumulate these members instead. If we do eventually compute wireframe indices, - // these members will be cleared and m_wireframeIndexBuffer will be filled. Its unlikely - // that `memoryUsage()` will be re-called, but we'll have a safe over-estimate in any case. - if( m_numVerticesPerFace ) - { - total += m_numVerticesPerFace->Object::memoryUsage(); - total += m_originalIndices->Object::memoryUsage(); - total += m_oldToTriangulatedIndexMapping->Object::memoryUsage(); - } - else - { - // For curves, points, and bounding boxes the wireframe indices and normal indices - // are shared, so we don't need to re-count the memory usage, since we've already - // accumulated m_indexBuffer above. - } - - // For meshes, we store 2 extra members in order to perform expandulation of PrimitiveVariables - // later on (eg. when an MVertexBuffer is requested from the global Cache). These members will - // not be cleared, but they are null for curves, points, and bounding boxes. - if( m_triangulatedIndices ) - { - total += m_triangulatedIndices->Object::memoryUsage(); - } - if( m_mapToOldFacevarying ) - { - total += m_mapToOldFacevarying->Object::memoryUsage(); - } - - return total; - } - -private : - - void fillPointsData( const PointsPrimitive *points ) - { - size_t numPoints = points->getNumPoints(); - - std::vector indices; - indices.reserve( numPoints ); - for( size_t i = 0; i < numPoints; ++i ) - { - indices.emplace_back( i ); - } - - m_indexBuffer = createIndexBuffer( indices ); - m_wireframeIndexBuffer = m_indexBuffer; - } - - void fillCurvesData( const CurvesPrimitive *curves ) - { - const auto &verticesPerCurve = curves->verticesPerCurve()->readable(); - - size_t numElements = 0; - for( size_t i = 0; i < curves->numCurves(); ++i ) - { - numElements += curves->numSegments( i ) * 2; - } - - std::vector indices; - indices.reserve( numElements ); - - int positionBufferOffset = 0; - int indexBufferOffset = 0; - for( size_t i = 0; i < curves->numCurves(); ++i ) - { - size_t numSegments = curves->numSegments( i ); - int endPointDuplication = ( verticesPerCurve[i] - ( (int)numSegments + 1 ) ) / 2; - int segmentCurrent = positionBufferOffset + endPointDuplication; - for( size_t j = 0; j < numSegments; ++j ) - { - indices.emplace_back( segmentCurrent ); - indices.emplace_back( segmentCurrent + 1 ); - - indexBufferOffset++; - segmentCurrent++; - } - positionBufferOffset += verticesPerCurve[i]; - } - - m_indexBuffer = createIndexBuffer( indices ); - m_wireframeIndexBuffer = m_indexBuffer; - } - - void fillMeshData( const MeshPrimitive *mesh ) - { - m_numVerticesPerFace = mesh->verticesPerFace(); - - // Store original indices - m_originalIndices = mesh->vertexIds(); - - // Store triangulated indices - IECoreScene::MeshPrimitivePtr triangulated = IECore::runTimeCast( mesh->copy() ); - IntVectorDataPtr sequentialIndices( new IntVectorData() ); - std::vector &sequentialIndicesWritable = sequentialIndices->writable(); - - sequentialIndicesWritable.resize( triangulated->variableSize(PrimitiveVariable::Interpolation::FaceVarying) ); - tbb::parallel_for( - tbb::blocked_range( 0, sequentialIndicesWritable.size() ), [&sequentialIndicesWritable]( const tbb::blocked_range &r ) - { - for( size_t i = r.begin(); i != r.end(); ++i ) - { - sequentialIndicesWritable[i] = i; - } - } - ); - - // We store these indices on the mesh that we'll triangulate in order to get - // a mapping from new to old indices for facevarying data. - triangulated->variables["_indexMap"] = PrimitiveVariable( PrimitiveVariable::FaceVarying, sequentialIndices ); - - triangulated = MeshAlgo::triangulate( triangulated.get() ); - - m_triangulatedIndices = triangulated->vertexIds(); - const std::vector &triangulatedIndicesReadable = m_triangulatedIndices->readable(); - - m_oldToTriangulatedIndexMapping = new IntVectorData; - std::vector &oldToTriangulatedIndexMappingWritable = m_oldToTriangulatedIndexMapping->writable(); - oldToTriangulatedIndexMappingWritable.resize( mesh->variableSize( PrimitiveVariable::Vertex ) ); - - std::vector indices; - indices.resize( triangulatedIndicesReadable.size() ); - - tbb::parallel_for( - tbb::blocked_range( 0, indices.size() ), [&indices, &triangulatedIndicesReadable, &oldToTriangulatedIndexMappingWritable]( const tbb::blocked_range &r ) - { - for( size_t i = r.begin(); i != r.end(); ++i ) - { - indices[i] = i; - oldToTriangulatedIndexMappingWritable[ triangulatedIndicesReadable[i] ] = i; - } - } - ); - - m_mapToOldFacevarying = triangulated->expandedVariableData( "_indexMap" ); - - // Note m_wireframeBuffer remains null until `wireframeIndices()` is called explicitly - m_indexBuffer = createIndexBuffer( indices ); - } - - void fillBoundData() - { - // Indices: - // - // 7------6 - // /| /| - // 3------2 | - // | 4----|-5 - // |/ |/ - // 0------1 - - m_indexBuffer = createIndexBuffer( { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 7, 3, 6, 2, 4, 0, 5, 1 } ); - m_wireframeIndexBuffer = indices(); - } - - void computeWireframeIndices() - { - // this is only called for meshes, so we can use the mesh specific data members. - - const std::vector &numVerticesPerFaceReadable = m_numVerticesPerFace->readable(); - - // Compute partial sum to make algorithm parallelisable. - // [4, 4, 4, 4] -> [4, 8, 12, 16] - std::vector partialSum( numVerticesPerFaceReadable.size() ); - std::partial_sum(numVerticesPerFaceReadable.begin(), numVerticesPerFaceReadable.end(), partialSum.begin(), std::plus()); - - int totalNumEdgeIndices = partialSum[partialSum.size()-1] * 2; - - std::vector indices; - indices.resize( totalNumEdgeIndices ); - - const std::vector &originalIndicesReadable = m_originalIndices->readable(); - const std::vector &oldToTriangulatedIndexMapping = m_oldToTriangulatedIndexMapping->readable(); - - // Construct list of indices that can be used to render wireframes - tbb::parallel_for( - tbb::blocked_range( 0, numVerticesPerFaceReadable.size() ), [&partialSum, &numVerticesPerFaceReadable, &originalIndicesReadable, &indices, oldToTriangulatedIndexMapping]( const tbb::blocked_range &r ) - { - for( size_t i = r.begin(); i != r.end(); ++i ) - { - int offset = i == 0 ? 0 : partialSum[i-1]; - int numVerts = numVerticesPerFaceReadable[i]; - - for( int k = 0; k < numVerts; ++k ) - { - int oldIndexA = originalIndicesReadable[offset + k]; - int oldIndexB = originalIndicesReadable[offset + (k+1)%numVerts]; - - int insertion = (offset + k) * 2; - - indices[insertion] = oldToTriangulatedIndexMapping[ oldIndexA ]; - indices[insertion + 1] = oldToTriangulatedIndexMapping[ oldIndexB ]; - } - } - } - ); - - // we don't need to store these anymore so we can free up some memory - // this won't help us stay in the cache longer, but it should help the - // user to stay within an overall memory budget. - m_numVerticesPerFace = nullptr; - m_originalIndices = nullptr; - m_oldToTriangulatedIndexMapping = nullptr; - - m_wireframeIndexBuffer = createIndexBuffer( indices ); - } - - static IndexBufferPtr createIndexBuffer( const std::vector &data ) - { - IndexBufferPtr buffer( new MIndexBuffer( MGeometry::kUnsignedInt32 ) ); - size_t numEntries = data.size(); - void *bufferData = buffer->acquire( numEntries, true ); - if( bufferData && buffer ) - { - memcpy( bufferData, data.data(), sizeof( unsigned int ) * numEntries ); - buffer->commit( bufferData ); - } - else - { - msg( Msg::Error, "SceneShapeSubSceneOverride::bufferGetter", "Memory acquisition for index buffer failed." ); - } - - return buffer; - } - - // for all primitives - IndexBufferPtr m_indexBuffer; - IndexBufferPtr m_wireframeIndexBuffer; - - // for meshes only - IECore::ConstIntVectorDataPtr m_numVerticesPerFace; - IECore::ConstIntVectorDataPtr m_originalIndices; - IECore::ConstIntVectorDataPtr m_triangulatedIndices; - IECore::IntVectorDataPtr m_oldToTriangulatedIndexMapping; - IECore::IntVectorDataPtr m_mapToOldFacevarying; -}; - -using ExpandulatorPtr = std::shared_ptr; - -//////////////////////////////////////////////////////////////////////////////////////////// -// Maya Buffer Cache -//////////////////////////////////////////////////////////////////////////////////////////// - -VertexBufferPtr createVertexBuffer( const MVertexBufferDescriptor &descriptor, const V3fVectorData *data ) -{ - VertexBufferPtr buffer( new MVertexBuffer( descriptor ) ); - - size_t numEntries = data->readable().size(); - void *bufferData = buffer->acquire( numEntries, true ); - if( bufferData && buffer ) - { - memcpy( bufferData, data->baseReadable(), sizeof( float ) * 3 * numEntries ); - buffer->commit( bufferData ); - } - else - { - msg( Msg::Error, "SceneShapeSubSceneOverride::bufferGetter", ( boost::format( "Memory acquisition for %s buffer failed." ) % descriptor.semanticName() ).str() ); - } - - return buffer; -} - -VertexBufferPtr createVertexBuffer( const MVertexBufferDescriptor &descriptor, const V2fVectorData *data ) -{ - VertexBufferPtr buffer( new MVertexBuffer( descriptor ) ); - - size_t numEntries = data->readable().size(); - void *bufferData = buffer->acquire( numEntries, true ); - if( bufferData && buffer ) - { - memcpy( bufferData, data->baseReadable(), sizeof( float ) * 2 * numEntries ); - buffer->commit( bufferData ); - } - else - { - msg( Msg::Error, "SceneShapeSubSceneOverride::bufferGetter", "Memory acquisition for uv buffer failed." ); - } - - return buffer; -} - -using CacheEntry = boost::variant; -using CacheEntryPtr = std::shared_ptr; - -boost::signals2::signal &bufferEvictedSignal() -{ - static boost::signals2::signal g_bufferEvictedSignal; - return g_bufferEvictedSignal; -} - -struct CacheCleanup -{ - void operator() ( const IECore::MurmurHash &key, const CacheEntryPtr &entry ) - { - if( auto buffer = boost::get( entry.get() ) ) - { - bufferEvictedSignal()( std::make_shared( *buffer ) ); - } - else if( auto expandulator = boost::get( entry.get() ) ) - { - bufferEvictedSignal()( std::make_shared( expandulator->get()->indices() ) ); - - auto wireframeIndices = expandulator->get()->wireframeIndices( /* force */ false ); - if( wireframeIndices && wireframeIndices != expandulator->get()->indices() ) - { - bufferEvictedSignal()( std::make_shared( wireframeIndices ) ); - } - } - } -}; - -struct CacheKey -{ - CacheKey( const MVertexBufferDescriptor &descriptor, const IECoreScene::Primitive *primitive, const Expandulator *expandulator, const MBoundingBox &bound ) - : descriptor( descriptor ), primitive( primitive ), expandulator( expandulator ), bound( bound ) - { - hash.append( descriptor.semantic() ); - - if( !primitive ) - { - // null primitives represent a bounding box wireframe - hash.append( bound.min().x ); - hash.append( bound.min().y ); - hash.append( bound.min().z ); - hash.append( bound.max().x ); - hash.append( bound.max().y ); - hash.append( bound.max().z ); - return; - } - else if( !expandulator ) - { - // an expandulator is being requested, so we hash the primitive topology and ignore the PrimitiveVariables. - primitive->topologyHash( hash ); - } - else - { - // a VertexBuffer is being requested, so we hash the associated PrimitiveVariable. - - // mesh variables will be expandulated, so we include the topology hash as well. - if( const auto *mesh = runTimeCast( primitive ) ) - { - mesh->topologyHash( hash ); - } - - /// \todo: consider more efficent ways to hash PrimitiveVariable data. Can we assume taking - /// the address of the data is enough given we know its coming straight off disk? - switch( descriptor.semantic() ) - { - case MGeometry::kPosition : - { - primitive->variableData( "P" )->hash( hash ); - break; - } - case MGeometry::kNormal : - { - // for meshes implicit normals will be generated from the topology, which we've already hashed. - // for other primitives, we don't yet support normals. - break; - } - case MGeometry::kTexture : - { - const auto it = primitive->variables.find( "uv" ); - if( it != primitive->variables.end() ) - { - it->second.data->hash( hash ); - if( it->second.indices ) - { - it->second.indices->hash( hash ); - } - } - break; - } - default : - { - break; - } - } - } - } - - operator const IECore::MurmurHash & () const - { - return hash; - } - - // the semantic of the descriptor also encodes whether this represents indices - // or vertices. An invalid semantic implies indices. - const MVertexBufferDescriptor descriptor; - const Primitive *primitive; - const Expandulator *expandulator; - const MBoundingBox bound; - IECore::MurmurHash hash; -}; - -CacheEntryPtr cacheGetter( const CacheKey &key, size_t &cost ) -{ - if( key.descriptor.semantic() ) - { - // a key with a valid semantic means we're creating an MVertexBuffer representing a specific primvar - VertexBufferPtr buffer = nullptr; - - switch( key.descriptor.semantic() ) - { - case MGeometry::kPosition : - { - ConstV3fVectorDataPtr data = nullptr; - if( !key.primitive ) - { - // bounding box - std::vector p; - p.reserve( 8 ); - p.emplace_back( key.bound.min().x, key.bound.min().y, key.bound.min().z ); // Indices: - p.emplace_back( key.bound.max().x, key.bound.min().y, key.bound.min().z ); - p.emplace_back( key.bound.max().x, key.bound.max().y, key.bound.min().z ); // 7------6 - p.emplace_back( key.bound.min().x, key.bound.max().y, key.bound.min().z ); // /| /| - p.emplace_back( key.bound.min().x, key.bound.min().y, key.bound.max().z ); // 3------2 | - p.emplace_back( key.bound.max().x, key.bound.min().y, key.bound.max().z ); // | 4----|-5 - p.emplace_back( key.bound.max().x, key.bound.max().y, key.bound.max().z ); // |/ |/ - p.emplace_back( key.bound.min().x, key.bound.max().y, key.bound.max().z ); // 0------1 - data = new V3fVectorData( p ); - } - else if( runTimeCast( key.primitive ) ) - { - const auto positionsView = key.primitive->variableIndexedView( "P" ); - data = IECore::runTimeCast( key.expandulator->expandulateVertex( *positionsView ) ); - } - else - { - data = key.primitive->variableData( "P" ); - } - - cost = data->Object::memoryUsage(); - buffer = createVertexBuffer( key.descriptor, data.get() ); - break; - } - case MGeometry::kNormal : - { - ConstV3fVectorDataPtr data = nullptr; - if( const auto *mesh = runTimeCast( key.primitive ) ) - { - auto normals = MeshAlgo::calculateNormals( mesh ); - PrimitiveVariable::IndexedView normalsView( normals ); - data = IECore::runTimeCast( key.expandulator->expandulateVertex( normalsView ) ); - } - else - { - return nullptr; - } - - cost = data->Object::memoryUsage(); - buffer = createVertexBuffer( key.descriptor, data.get() ); - break; - } - case MGeometry::kTexture : - { - auto uvView = key.primitive->variableIndexedView( "uv" ); - if( !uvView ) - { - return nullptr; - } - - ConstV2fVectorDataPtr data = nullptr; - if( runTimeCast( key.primitive ) ) - { - data = key.expandulator->expandulateFacevarying( *uvView ); - } - else - { - data = key.primitive->expandedVariableData( "uv" ); - } - - cost = data->Object::memoryUsage(); - buffer = createVertexBuffer( key.descriptor, data.get() ); - break; - } - default : - { - break; - } - } - - return std::make_shared( buffer ); - } - else - { - // a key without a valid semantic means we're creating an Expandulator representing the topology of a primitive - auto expandulator = std::make_shared( key.primitive ); - cost = expandulator->memoryUsage(); - return std::make_shared( expandulator ); - } -} - -using Cache = IECore::LRUCache; - -Cache &cache() -{ - static Cache g_cache( cacheGetter, CacheCleanup(), memoryLimit() ); - return g_cache; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// Misc Utilities -//////////////////////////////////////////////////////////////////////////////////////////// - -// For the given node return the out plug on the surface shader that is assigned -MPlug getShaderOutPlug( const MObject &sceneShapeNode ) -{ - MPlug result = MPlug(); - - MObjectArray sets, components; - MFnDagNode node( sceneShapeNode ); - if( !node.getConnectedSetsAndMembers( 0, sets, components, true ) ) - { - return result; - } - - for( size_t i = 0; i < sets.length(); ++i ) - { - MStatus status; - MFnDependencyNode fnSet( sets[i], &status ); - - if( !status ) - { - return result; - } - - MPlug shaderPlug = fnSet.findPlug( "surfaceShader", false ); - if( shaderPlug.isNull() ) - { - return result; - } - - MPlugArray connectedPlugs; - shaderPlug.connectedTo( connectedPlugs, true, false ); - - if( connectedPlugs.length() >= 1 ) - { - return connectedPlugs[0]; - } - } - - return result; -} - -bool isPathSelected( const MSelectionList &selectionList, const MDagPath &path ) -{ - MStatus status = MStatus::kSuccess; - MDagPath pathCopy = path; - - while( status ) - { - if( selectionList.hasItem( pathCopy ) ) - { - return true; - } - - status = pathCopy.pop(); - } - - return false; -} - -struct SelectionStateShaders -{ - SelectionStateShaders( MHWRender::MShaderInstance *unselected, MHWRender::MShaderInstance *selected ) - : unselected( unselected ), selected( selected ) - { - } - - MHWRender::MShaderInstance *unselected; - MHWRender::MShaderInstance *selected; -}; - -struct TextureStateShaders -{ - TextureStateShaders( MHWRender::MShaderInstance *untextured, MHWRender::MShaderInstance *textured ) - : untextured( untextured ), textured( textured ) - { - } - - MHWRender::MShaderInstance *untextured; - MHWRender::MShaderInstance *textured; -}; - -SelectionStateShaders getWireShaders() -{ - static SelectionStateShaders shaders( nullptr, nullptr ); - - if( !shaders.unselected || !shaders.selected ) - { - MRenderer* renderer = MRenderer::theRenderer(); - if( !renderer ) - { - return shaders; - } - - const MShaderManager* shaderManager = renderer->getShaderManager(); - if( !shaderManager ) - { - return shaders; - } - - shaders.unselected = shaderManager->getStockShader( MShaderManager::k3dSolidShader ); - shaders.selected = shaders.unselected->clone(); - - MDoubleArray a, b; - MGlobal::executeCommand( "colorIndex -q 19", a ); - MGlobal::executeCommand( "colorIndex -q 5", b ); - - const float highlightedWireColor[] = {(float)a[0], (float)a[1], (float)a[2], 1.0f}; - const float unhighlightedWireColor[] = {(float)b[0], (float)b[1], (float)b[2], 1.0f}; - - shaders.unselected->setParameter("solidColor", unhighlightedWireColor ); - shaders.selected->setParameter("solidColor", highlightedWireColor ); - } - - return shaders; -} - -SelectionStateShaders getComponentWireShaders() -{ - static SelectionStateShaders shaders( nullptr, nullptr ); - - if( !shaders.unselected || !shaders.selected ) - { - MRenderer* renderer = MRenderer::theRenderer(); - if( !renderer ) - { - return shaders; - } - - const MShaderManager* shaderManager = renderer->getShaderManager(); - if( !shaderManager ) - { - return shaders; - } - - MDoubleArray a, b; - MGlobal::executeCommand( "colorIndex -q 21", a ); - MGlobal::executeCommand( "colorIndex -q 18", b ); - - const float highlightedWireColor[] = {(float)a[0], (float)a[1], (float)a[2], 1.0f}; - const float unhighlightedWireColor[] = {(float)b[0], (float)b[1], (float)b[2], 1.0f}; - - shaders.unselected = shaderManager->getStockShader( MShaderManager::k3dSolidShader ); - shaders.selected = shaders.unselected->clone(); - - shaders.unselected->setParameter("solidColor", unhighlightedWireColor ); - shaders.selected->setParameter("solidColor", highlightedWireColor ); - } - - return shaders; -} - -TextureStateShaders getAssignedSurfaceShaders( const MObject &object ) -{ - TextureStateShaders shaders( nullptr, nullptr ); - - if( shaders.untextured && shaders.textured ) - { - return shaders; - } - - MRenderer* renderer = MRenderer::theRenderer(); - if( !renderer ) - { - return shaders; - } - - const MShaderManager* shaderManager = renderer->getShaderManager(); - if( !shaderManager ) - { - return shaders; - } - - MStatus s; - MFnDagNode node( object, &s ); - if( !s ) - { - return shaders; - } - - MDagPathArray instances; - node.getAllPaths( instances ); - - MPlug shaderOutPlug = getShaderOutPlug( object ); - - if( !shaderOutPlug.isNull() ) - { - #if MAYA_API_VERSION >= 201650 - shaders.untextured = shaderManager->getShaderFromNode( shaderOutPlug.node(), instances[0], nullptr, nullptr, nullptr, nullptr, /* nonTextured = */ true ); - shaders.textured = shaderManager->getShaderFromNode( shaderOutPlug.node(), instances[0], nullptr, nullptr, nullptr, nullptr, /* nonTextured = */ false ); - #else - shaders.untextured = shaderManager->getShaderFromNode( shaderOutPlug.node(), instances[0], 0, 0, 0, 0 ); - shaders.textured = shaderManager->getShaderFromNode( shaderOutPlug.node(), instances[0], 0, 0, 0, 0 ); - #endif - } - else - { - shaders.untextured = shaderManager->getStockShader( MShaderManager::MStockShader::k3dDefaultMaterialShader ); - shaders.textured = shaders.untextured; - } - - return shaders; -} - -bool componentsSelectable( const MDagPath &path ) -{ - MHWRender::DisplayStatus displayStatus = MHWRender::MGeometryUtilities::displayStatus( path ); - bool selectable = displayStatus == MHWRender::kHilite; - return selectable; -} - -bool objectCanBeRendered( const IECore::ConstObjectPtr &object ) -{ - switch( static_cast( object->typeId() ) ) - { - case IECoreScene::TypeId::MeshPrimitiveTypeId : - case IECoreScene::TypeId::PointsPrimitiveTypeId : - case IECoreScene::TypeId::CurvesPrimitiveTypeId : - { - return true; - } - default : - return false; - } -} - -bool sceneIsAnimated( const SceneInterface *sceneInterface ) -{ - const auto *scene = IECore::runTimeCast< const SampledSceneInterface >( sceneInterface ); - return ( !scene || scene->numBoundSamples() > 1 ); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////////////////// -// Private subclasses -//////////////////////////////////////////////////////////////////////////////////////////// - -struct IECoreMaya::SceneShapeSubSceneOverride::AllShaders -{ - explicit AllShaders( const MObject &object ) - : componentWireShaders(nullptr, nullptr ), - wireShaders(nullptr, nullptr ), - textureStateShaders(nullptr, nullptr) - { - componentWireShaders = getComponentWireShaders(); - wireShaders = getWireShaders(); - textureStateShaders = getAssignedSurfaceShaders( object ); - } - - MShaderInstance* getShader(RenderStyle style, bool componentMode, bool isSelected ) const - { - switch( style ) - { - case RenderStyle::BoundingBox : - case RenderStyle::Wireframe : - { - if( componentMode ) - { - return isSelected ? componentWireShaders.selected : componentWireShaders.unselected; - } - else - { - return isSelected ? wireShaders.selected : wireShaders.unselected; - } - } - case RenderStyle::Solid : - case RenderStyle::Textured : - { - return style == RenderStyle::Solid ? textureStateShaders.untextured : textureStateShaders.textured; - } - default : - return nullptr; - } - } - SelectionStateShaders componentWireShaders; - SelectionStateShaders wireShaders; - TextureStateShaders textureStateShaders; -}; - -class IECoreMaya::SceneShapeSubSceneOverride::RenderItemUserData : public MUserData -{ -public : - - explicit RenderItemUserData( int componentIndex ) - : MUserData( false ), // do not delete when render item is deleted, we manage life time - componentIndex( componentIndex ) - { - } - - ~RenderItemUserData() override = default; - - int componentIndex; - -}; - -// As we render a render item per component, all we need to know here is the -// component index per render item. -class SceneShapeSubSceneOverride::ComponentConverter : public MPxComponentConverter -{ - public : - - static MPxComponentConverter *creator() - { - return new ComponentConverter(); - } - - ComponentConverter() - : MPxComponentConverter(), m_idx( -1 ) - { - } - - ~ComponentConverter() override = default; - - void initialize( const MRenderItem &renderItem ) override - { - m_idx = dynamic_cast(renderItem.customData())->componentIndex; - m_object = m_component.create( MFn::kMeshPolygonComponent ); - } - - void addIntersection( MIntersection &intersection ) override - { - m_component.addElement( m_idx ); - } - - MObject component() override - { - return m_object; - } - - MSelectionMask selectionMask () const override - { - return MSelectionMask::kSelectMeshFaces; - } - - private : - - MFnSingleIndexedComponent m_component; - MObject m_object; - int m_idx; -}; - -//////////////////////////////////////////////////////////////////////////////////////////// -// Construction and book keeping -//////////////////////////////////////////////////////////////////////////////////////////// - -MString& SceneShapeSubSceneOverride::drawDbClassification() -{ - static MString classification{ "drawdb/subscene/ieSceneShape" }; - return classification; -} - -MString& SceneShapeSubSceneOverride::drawDbId() -{ - static MString id{ "SceneShapeSubSceneOverride" }; - return id; -} - -DrawAPI SceneShapeSubSceneOverride::supportedDrawAPIs() const -{ - return kAllDevices; -} - -MPxSubSceneOverride* SceneShapeSubSceneOverride::Creator( const MObject& obj ) -{ - return new SceneShapeSubSceneOverride( obj ); -} - -SceneShapeSubSceneOverride::SceneShapeSubSceneOverride( const MObject& obj ) - : MPxSubSceneOverride( obj ), m_drawTagsFilter( "" ), m_time( -1 ), m_drawRootBounds( false ), m_drawChildBounds( false ), m_shaderOutPlug(), m_instancedRendering( false /* instancedRendering switch */ ), m_geometryVisible( false ), m_objectOnly( false ) -{ - MStatus status; - MFnDependencyNode node( obj, &status ); - - if( status ) - { - m_sceneShape = dynamic_cast( node.userNode() ); - } - - m_allShaders = std::make_shared( m_sceneShape->thisMObject() ); - - m_evictionConnection = bufferEvictedSignal().connect( boost::bind( &SceneShapeSubSceneOverride::bufferEvictedCallback, this, boost::placeholders::_1 ) ); -} - -SceneShapeSubSceneOverride::~SceneShapeSubSceneOverride() = default; - -//////////////////////////////////////////////////////////////////////////////////////////// -// Drawing -//////////////////////////////////////////////////////////////////////////////////////////// - -bool SceneShapeSubSceneOverride::requiresUpdate(const MSubSceneContainer& container, const MFrameContext& frameContext) const -{ - bool allInvisible = true; - MFnDagNode dagNode( m_sceneShape->thisMObject() ); - MDagPathArray dagPaths; - dagNode.getAllPaths( dagPaths ); - for( size_t i = 0; i < dagPaths.length(); ++i ) - { - if( dagPaths[i].isVisible() ) - { - allInvisible = false; - break; - } - } - - // check if there are viewport filters that hide the shape - M3dView view; - MString panelName; - frameContext.renderingDestination( panelName ); - M3dView::getM3dViewFromModelPanel( panelName, view ); - - bool allInvisibleByFilter = false; - if( view.viewIsFiltered() ) - { - allInvisibleByFilter = true; - - // Create a selection list of the dagPaths which are visible after the view is filtered - MSelectionList visibleList; - view.filteredObjectList( visibleList ); - - // Create a selection list with all of our dag paths - MSelectionList dagPathList; - for( const auto &dagPath : dagPaths ) - { - dagPathList.add( dagPath ); - } - - // Intersect the two lists to determine if any of our dag paths remain unfiltered - visibleList.intersect( dagPathList, true ); - if( !visibleList.isEmpty() ) - { - allInvisibleByFilter = false; - } - } - - bool anyRenderItemEnabled = false; - MSubSceneContainer::ConstIterator *it = container.getConstIterator(); - const MRenderItem *renderItem = nullptr; - while( (renderItem = it->next()) != nullptr ) - { - if( renderItem->isEnabled() ) - { - anyRenderItemEnabled = true; - break; - } - } - it->destroy(); - - if( anyRenderItemEnabled ) - { - if( allInvisible || allInvisibleByFilter ) - { - // if some RenderItems are enabled and all instances are invisible - // then we do require an update. - return true; - } - } - else - { - // if all RenderItems are disabled and all instances are invisible - // then we can opt out of updating for a significant performance gain. - // if all RenderItems are disabled but some instances are visible - // then we do require an update. - return !( allInvisible || allInvisibleByFilter ); - } - - // TIME UPDATED? - if( m_sceneShape->time() != m_time && sceneIsAnimated( m_sceneInterface.get() ) ) - { - return true; - } - - // SCENE UPDATED? - if( m_sceneInterface != m_sceneShape->getSceneInterface() ) - { - return true; - } - - // DRAW GEOMETRY SETTINGS UPDATED? - StyleMask tmpMask; - checkDisplayOverrides( (MFrameContext::DisplayStyle)frameContext.getDisplayStyle(), tmpMask ); - - if( tmpMask != m_styleMask ) - { - return true; - } - - // ROOT BOUNDING BOX SETTING UPDATED? - bool tmpDrawRootBound; - MPlug drawRootBoundsPlug( m_sceneShape->thisMObject(), SceneShape::aDrawRootBound ); - drawRootBoundsPlug.getValue( tmpDrawRootBound ); - if( tmpDrawRootBound != m_drawRootBounds ) - { - return true; - } - - // The objectOnly toggle determines if we need to recurse our internal scene locations - bool tmpObjectOnly; - MPlug( m_sceneShape->thisMObject(), SceneShape::aObjectOnly ).getValue( tmpObjectOnly ); - if( tmpObjectOnly != m_objectOnly ) - { - return true; - } - - // TAGS FILTER UPDATED? - MString tmpTagsFilter; - MPlug drawTagsFilterPlug( m_sceneShape->thisMObject(), SceneShape::aDrawTagsFilter ); - drawTagsFilterPlug.getValue( tmpTagsFilter ); - if( tmpTagsFilter.asChar() != m_drawTagsFilter ) - { - return true; - } - - // \todo: This should scale better. It's depending on both the selection and the instances at the moment. - // COMPONENT SELECTION UPDATED? - IndexMap selectedComponents; - selectedComponentIndices( selectedComponents ); - if( selectedComponents != m_selectedComponents ) - { - return true; - } - - // SHADER UPDATED? - if( getShaderOutPlug( m_sceneShape->thisMObject() ) != m_shaderOutPlug ) - { - return true; - } - - Instances currentInstances; - collectInstances( currentInstances ); - - if( currentInstances.size() != m_instances.size() ) - { - return true; // instance was added or removed - } - - for( const auto &instance : currentInstances ) - { - // \todo: doesn't properly account for duplicates in the containers, but is probably good enough for now. - if( std::find( m_instances.begin(), m_instances.end(), instance ) == m_instances.end() ) - { - return true; - } - } - - return false; -} - -void SceneShapeSubSceneOverride::update( MSubSceneContainer& container, const MFrameContext& frameContext ) -{ - // To make sure we keep within our memory bounds, we need to clean up buffers - // that have been marked for deletion. - for( BufferPtr &buffer : m_markedForDeletion ) - { - Buffer *b = buffer.get(); - auto it = m_bufferToRenderItems.find( b ); - if( it == m_bufferToRenderItems.end() ) - { - continue; - } - - const RenderItemNames &names = it->second; - for( const auto &name : names ) - { - container.remove( name ); - } - m_bufferToRenderItems.erase( b ); - } - - m_markedForDeletion.clear(); // releases memory - - // We'll set internal state based on settings in maya and then perform updates - // by disabling all MRenderItems and reenabling those needed by walking the - // tree. MRenderItems can be found in the container via their name. We make unique - // MRenderItems per location, style, time, & maya instance. - - m_time = m_sceneShape->time(); - - IECoreScene::ConstSceneInterfacePtr tmpSceneInterface = m_sceneShape->getSceneInterface(); - if( m_sceneInterface != tmpSceneInterface ) - { - // All data in the container is invalid now and we can safely clear it - container.clear(); - m_sceneInterface = tmpSceneInterface; - m_sceneInterface->path( m_rootPath ); - SceneInterface::pathToString( m_rootPath, m_rootLocation ); - } - - // STYLE - // Used to skip rendering independently of style mask - MPlug drawGeometryPlug( m_sceneShape->thisMObject(), SceneShape::aDrawGeometry ); - drawGeometryPlug.getValue( m_geometryVisible ); - - checkDisplayOverrides( (MFrameContext::DisplayStyle)frameContext.getDisplayStyle(), m_styleMask ); - - // DRAWING ROOTS - MPlug drawRootBoundsPlug( m_sceneShape->thisMObject(), SceneShape::aDrawRootBound ); - drawRootBoundsPlug.getValue( m_drawRootBounds ); - - // DRAWING CHILD BOUNDS - MPlug drawAllBoundsPlug( m_sceneShape->thisMObject(), SceneShape::aDrawChildBounds ); - drawAllBoundsPlug.getValue( m_drawChildBounds ); - - // The objectOnly toggle determines if we need to recurse our internal scene locations - bool tmpObjectOnly = MPlug( m_sceneShape->thisMObject(), SceneShape::aObjectOnly ).asBool(); - if( tmpObjectOnly != m_objectOnly ) - { - m_objectOnly = tmpObjectOnly; - } - - // TAGS - MString tmpTagsFilter; - MPlug drawTagsFilterPlug( m_sceneShape->thisMObject(), SceneShape::aDrawTagsFilter ); - drawTagsFilterPlug.getValue( tmpTagsFilter ); - if( tmpTagsFilter.asChar() != m_drawTagsFilter ) - { - m_drawTagsFilter = tmpTagsFilter.asChar(); - } - - // COMPONENT SELECTION - m_selectedComponents.clear(); - selectedComponentIndices( m_selectedComponents ); - - // INSTANCES - sort out transformation and selection - m_instances.clear(); - collectInstances( m_instances ); - - // SHADING - MPlug currentShaderOutPlug = getShaderOutPlug( m_sceneShape->thisMObject() ); - if( currentShaderOutPlug.name() != m_shaderOutPlug.name() ) - { - m_shaderOutPlug = currentShaderOutPlug; - m_allShaders = std::make_shared( m_sceneShape->thisMObject() ); - } - - // Disable all MRenderItems before traversing the scene \todo: performance - // improvement -> we don't have to do some of this if all that changed is a - // shader for example. - MSubSceneContainer::Iterator *it = container.getIterator(); - MRenderItem *renderItem = nullptr; - while( (renderItem = it->next()) != nullptr ) - { - renderItem->enable( false ); - } - it->destroy(); - - bool allInvisible = true; - for( auto &instance : m_instances ) - { - if( instance.visible ) - { - allInvisible = false; - break; - } - } - - // check if there are viewport filters that hide the shape - M3dView view; - MString panelName; - MSelectionList viewSelectedSet; - frameContext.renderingDestination( panelName ); - M3dView::getM3dViewFromModelPanel( panelName, view ); - view.filteredObjectList( viewSelectedSet ); - - bool allInvisibleByFilter = false; - if( view.viewIsFiltered() ) - { - allInvisibleByFilter = true; - - // Create a selection list of the dagPaths which are visible after the view is filtered - MSelectionList visibleList; - view.filteredObjectList( visibleList ); - - // Create a selection list with all of our dag paths - MSelectionList dagPathList; - for( const auto &instance : m_instances ) - { - dagPathList.add( instance.path ); - } - - // Intersect the two lists to determine if any of our dag paths remain unfiltered - visibleList.intersect( dagPathList, true ); - if( !visibleList.isEmpty() ) - { - allInvisibleByFilter = false; - } - } - - if( allInvisible || allInvisibleByFilter ) - { - return; // no need to do any scene traversing - } - - // Create and enable MRenderItems while traversing the scene hierarchy - RenderItemMap renderItems; - /// \todo: SceneInterface structure is consistent over time. Consider separating the - /// traversal from the RenderItem accumulation to avoid unneeded IndexedIO per-draw - visitSceneLocations( m_sceneInterface.get(), renderItems, container, MMatrix(), "", true ); - - for( auto *item : m_renderItemsToEnable ) - { - item->enable( true ); - } - m_renderItemsToEnable.clear(); -} - -void SceneShapeSubSceneOverride::visitSceneLocations( const SceneInterface *sceneInterface, RenderItemMap &renderItems, MSubSceneContainer &container, const MMatrix &matrix, std::string relativeLocation, bool isRoot ) -{ - if( !sceneInterface ) - { - return; - } - - MMatrix accumulatedMatrix; - if( !isRoot ) - { - relativeLocation += "/"; - relativeLocation += sceneInterface->name(); - accumulatedMatrix = IECore::convert( sceneInterface->readTransformAsMatrix( m_time ) ) * matrix; - } - - // Dispatch to children only if we need to draw them - if( - ( m_geometryVisible || m_drawChildBounds ) && - !m_objectOnly && - ( m_drawTagsFilter.empty() || sceneInterface->hasTag( m_drawTagsFilter, SceneInterface::DescendantTag | SceneInterface::LocalTag ) ) - ) - { - SceneInterface::NameList childNames; - sceneInterface->childNames( childNames ); - - for( const auto &childName : childNames ) - { - ConstSceneInterfacePtr child = sceneInterface->child( childName ); - visitSceneLocations( child.get(), renderItems, container, accumulatedMatrix, relativeLocation, false ); - } - } - - // Now handle current location. - if( isRoot ) - { - // override relative location for root as it would otherwise be empty - relativeLocation = "/"; - } - - if( isRoot && m_drawRootBounds ) - { - std::string rootItemName = m_rootLocation + "_root_style_" + std::to_string( (int)RenderStyle::BoundingBox ); - if( sceneIsAnimated( sceneInterface ) ) - { - rootItemName += "_" + std::to_string( m_time ); - } - - const MBoundingBox bound = IECore::convert( sceneInterface->readBound( m_time ) ); - - int count = 0; - for( const auto &instance : m_instances ) - { - if ( !instance.visible ) - { - continue; - } - std::string instanceName = rootItemName + "_" + std::to_string( count++ ); - MString itemName( instanceName.c_str() ); - MRenderItem *renderItem = acquireRenderItem( container, IECore::NullObject::defaultNullObject(), instance, relativeLocation, bound, itemName, RenderStyle::BoundingBox ); - - addInstanceTransform( *renderItem, instance.transformation ); - } - } - - if( !sceneInterface->hasObject() ) - { - return; - } - - // respect tags - if( !m_drawTagsFilter.empty() && !sceneInterface->hasTag( m_drawTagsFilter ) ) - { - return; - } - - IECore::ConstObjectPtr object = sceneInterface->readObject( m_time ); - if( !objectCanBeRendered( object ) ) - { - return; - } - - ConstPrimitivePtr primitive = IECore::runTimeCast( object ); - if( !primitive ) - { - return; - } - - // We're going to render this object - compute its bounds only once and reuse them. - const MBoundingBox bound = IECore::convert( sceneInterface->readBound( m_time ) ); - - // Adding RenderItems as needed - // ---------------------------- - for( RenderStyle style : supportedRenderStyles() ) - { - // Global switch to hide all geometry - continuing early to avoid drawing selected wireframes. - // \todo: This is a little messy as it's kind of included in the mask, but we can't rely on the mask for selected instances. - if( !m_geometryVisible && style != RenderStyle::BoundingBox ) - { - continue; - } - - // Skipping unneeded MRenderItems based on display modes etc. - // NOTE: wireframe visibility is determined mostly by per-instance data. - if( style !=RenderStyle::Wireframe ) - { - int maskIndex = (int)style; - - if( style == RenderStyle::Textured ) - { - maskIndex = (int)RenderStyle::Solid; - } - - if( !m_styleMask.test( maskIndex ) ) - { - continue; - } - } - - std::string baseItemName = m_rootLocation + relativeLocation + "_style_" + std::to_string( (int)style ); - if( sceneIsAnimated( sceneInterface ) ) - { - baseItemName += "_time_" + std::to_string( m_time ); - } - - int count = 0; - for( const auto &instance : m_instances ) - { - if( !instance.visible ) - { - continue; - } - - if( style == RenderStyle::Wireframe ) // wireframe visibility is mostly driven by instance data and needs to be handled here. - { - if( !m_styleMask.test( (int)RenderStyle::Wireframe ) && !instance.selected && !instance.componentMode ) - { - continue; - } - } - - std::string instanceName = baseItemName + "_instance_" + std::to_string( count++ ); - MString itemName( instanceName.c_str() ); - MRenderItem *renderItem = acquireRenderItem( container, object.get(), instance, relativeLocation, bound, itemName, style ); - - // Update the selection mask to enable marquee selection of components we explicitly disable - // wireframe selection in Solid mode, because otherwise we'd get double selections (the marquee - // overlaps both the mesh and the wireframe). Note we're still allowing bounding box selection - // so double selection is still possible, and this breaks toggle selection mode. - if( style == RenderStyle::Wireframe && m_styleMask.test( (int)RenderStyle::Solid ) ) - { - renderItem->setSelectionMask( MSelectionMask::kSelectMeshes ); - } - else - { - renderItem->setSelectionMask( instance.componentMode ? MSelectionMask::kSelectMeshFaces : MSelectionMask::kSelectMeshes ); - } - - addInstanceTransform( *renderItem, accumulatedMatrix * instance.transformation ); - } - } -} - -MRenderItem *SceneShapeSubSceneOverride::acquireRenderItem( - MSubSceneContainer &container, const IECore::Object *object, - const Instance &instance, const std::string &relativeLocation, - const MBoundingBox &bound, const MString &name, RenderStyle style -) -{ - MRenderItem *renderItem = container.find( name ); - if( renderItem ) - { - updateShaders( renderItem, instance, relativeLocation, style ); - - auto result = m_renderItemsToEnable.insert( renderItem ); - if( result.second ) // we hadn't removed the instance transforms on this renderItem yet - { - removeAllInstances( *renderItem ); - } - - return renderItem; - } - - switch( style ) - { - case RenderStyle::BoundingBox : - { - renderItem = MRenderItem::Create( name, MRenderItem::DecorationItem, MGeometry::kLines); - renderItem->setDrawMode( MGeometry::kAll ); - renderItem->castsShadows( false ); - renderItem->receivesShadows( false ); - renderItem->setExcludedFromPostEffects( true ); - renderItem->depthPriority( MRenderItem::sActiveWireDepthPriority ); - break; - } - case RenderStyle::Wireframe : - { - switch( static_cast( object->typeId() ) ) - { - case IECoreScene::TypeId::PointsPrimitiveTypeId : - renderItem = MRenderItem::Create( name, MRenderItem::DecorationItem, MGeometry::kPoints ); - break; - case IECoreScene::TypeId::CurvesPrimitiveTypeId : - case IECoreScene::TypeId::MeshPrimitiveTypeId : - renderItem = MRenderItem::Create( name, MRenderItem::DecorationItem, MGeometry::kLines ); - break; - default : - return nullptr; - } - renderItem->setDrawMode( MGeometry::kAll ); - renderItem->castsShadows( false ); - renderItem->receivesShadows( false ); - renderItem->setExcludedFromPostEffects( true ); - renderItem->depthPriority( MRenderItem::sActiveWireDepthPriority ); - break; - } - case RenderStyle::Solid : - case RenderStyle::Textured : - { - switch( static_cast( object->typeId() ) ) - { - case IECoreScene::TypeId::PointsPrimitiveTypeId : - { - renderItem = MRenderItem::Create( name, MRenderItem::MaterialSceneItem, MGeometry::kPoints ); - break; - } - case IECoreScene::TypeId::MeshPrimitiveTypeId : - { - renderItem = MRenderItem::Create( name, MRenderItem::MaterialSceneItem, MGeometry::kTriangles ); - break; - } - case IECoreScene::TypeId::CurvesPrimitiveTypeId : - { - renderItem = MRenderItem::Create( name, MRenderItem::MaterialSceneItem, MGeometry::kLines ); - break; - } - default : - break; - - } - - renderItem->setDrawMode( ( style == RenderStyle::Solid ) ? MGeometry::kShaded : MGeometry::kTextured ); - renderItem->castsShadows( true ); - renderItem->receivesShadows( true ); - renderItem->setExcludedFromPostEffects( false ); - } - default : - break; - } - - container.add( renderItem ); - - /// \todo: stop using the SceneShapeInterface selectionIndex. It relies on a secondary IECoreGL render. - RenderItemUserDataPtr userData = acquireUserData( m_sceneShape->selectionIndex( relativeLocation ) ); - renderItem->setCustomData( userData.get() ); - MDrawRegistry::registerComponentConverter( name, ComponentConverter::creator ); - - // Before setting geometry, a shader has to be assigned so that the data requirements are clear. - updateShaders( renderItem, instance, relativeLocation, style ); - - setBuffersForRenderItem( - ( style == RenderStyle::BoundingBox ) ? nullptr : runTimeCast( object ), - renderItem, - style == RenderStyle::Wireframe || style == RenderStyle::BoundingBox, - bound - ); - - /// \todo: this implies a one-to-one RenderItem to instance relationship, but - /// we're supposed to be sharing RenderItems across instances. Investigate... - m_renderItemNameToDagPath[name.asChar()] = instance.path; - - return renderItem; -} - -void SceneShapeSubSceneOverride::updateShaders( MRenderItem *renderItem, const Instance &instance, const std::string &relativeLocation, RenderStyle style ) -{ - MShaderInstance *shader = nullptr; - if( instance.componentMode ) - { - bool componentSelected = false; - auto selectionIt = m_selectedComponents.find( instance.path.fullPathName().asChar() ); - if( selectionIt != m_selectedComponents.end() ) - { - componentSelected = selectionIt->second.count( dynamic_cast(renderItem->customData())->componentIndex ) > 0; - } - - shader = m_allShaders->getShader( style, instance.componentMode, componentSelected ); - } - else - { - shader = m_allShaders->getShader( style, instance.componentMode, instance.selected ); - } - - if( renderItem->getShader() != shader ) - { - renderItem->setShader( shader ); - } -} - -void SceneShapeSubSceneOverride::setBuffersForRenderItem( const Primitive *primitive, MRenderItem *renderItem, bool wireframe, const MBoundingBox &bound ) -{ - CacheEntryPtr entry = cache().get( { MVertexBufferDescriptor(), primitive, nullptr, bound } ); - - // get the MIndexBuffer for the topology - ExpandulatorPtr expandulator = boost::get( *entry ); - IndexBufferPtr &indexBuffer = wireframe ? expandulator->wireframeIndices() : expandulator->indices(); - BufferPtr buffer = std::make_shared( indexBuffer ); - auto it = m_bufferToRenderItems.find( buffer.get() ); - if( it == m_bufferToRenderItems.end() ) - { - m_bufferToRenderItems.emplace( buffer.get(), RenderItemNames{ renderItem->name() } ); - } - else - { - it->second.emplace_back( renderItem->name() ); - } - - MVertexBufferArray vertexBufferArray; - const MVertexBufferDescriptorList &descriptorList = renderItem->requiredVertexBuffers(); - for( int i = 0; i < descriptorList.length(); ++i ) - { - MVertexBufferDescriptor descriptor; - descriptorList.getDescriptor( i, descriptor ); - - // Autodesk suggests this workaround to fix an issue with instanced - // rendering of MRenderItems and selection issues. Will need to be removed - // once we run this in a Maya version that has their internal patch applied. - if( descriptor.offset() < 0 ) - { - descriptor.setOffset( 0 ); - } - // Workaround ends - - switch( descriptor.semantic() ) - { - case MGeometry::kPosition : - case MGeometry::kNormal : - case MGeometry::kTexture : - { - entry = cache().get( { descriptor, primitive, expandulator.get(), bound } ); - break; - } - default : - { - continue; - } - } - - if( !entry ) - { - continue; - } - - VertexBufferPtr vertexBuffer = boost::get( *entry ); - vertexBufferArray.addBuffer( descriptor.semanticName(), vertexBuffer.get() ); - buffer = std::make_shared( vertexBuffer ); - it = m_bufferToRenderItems.find( buffer.get() ); - if( it == m_bufferToRenderItems.end() ) - { - m_bufferToRenderItems.emplace( buffer.get(), RenderItemNames{ renderItem->name() } ); - } - else - { - it->second.emplace_back( renderItem->name() ); - } - } - - setGeometryForRenderItem( *renderItem, vertexBufferArray, *indexBuffer, &bound ); -} - -void SceneShapeSubSceneOverride::checkDisplayOverrides( MFrameContext::DisplayStyle displayStyle, StyleMask &mask ) const -{ - bool boundsOverride = false; - MPlug drawAllBoundsPlug( m_sceneShape->thisMObject(), SceneShape::aDrawChildBounds ); - drawAllBoundsPlug.getValue( boundsOverride ); - - bool geometryOverride = false; - MPlug drawGeometryPlug( m_sceneShape->thisMObject(), SceneShape::aDrawGeometry ); - drawGeometryPlug.getValue( geometryOverride ); - - // Determine if we need to render bounding boxes - mask.reset( (int)RenderStyle::BoundingBox ); - if( boundsOverride || ( displayStyle & MHWRender::MFrameContext::kBoundingBox ) > 0 ) - { - mask.set( (int)RenderStyle::BoundingBox ); - } - - // Determine if we need to render wireframes - mask.reset( (int)RenderStyle::Wireframe ); - if( geometryOverride && ( displayStyle & MHWRender::MFrameContext::kWireFrame ) > 0 ) - { - mask.set( (int)RenderStyle::Wireframe ); - } - - // Determine if we need to render shaded geometry - mask.reset( (int)RenderStyle::Solid ); - if( geometryOverride && ( displayStyle & ( MHWRender::MFrameContext::kGouraudShaded | MHWRender::MFrameContext::kTextured | MHWRender::MFrameContext::kFlatShaded ) ) ) - { - mask.set( (int)RenderStyle::Solid ); - } -} - -SceneShapeSubSceneOverride::RenderItemUserDataPtr SceneShapeSubSceneOverride::acquireUserData( int componentIndex ) -{ - const auto &entry = m_userDataMap.find( componentIndex ); - if( entry != m_userDataMap.end() ) - { - return entry->second; - } - - RenderItemUserDataPtr data( new RenderItemUserData( componentIndex ) ); - m_userDataMap.emplace( componentIndex, data ); - return data; -} - -void SceneShapeSubSceneOverride::bufferEvictedCallback( const BufferPtr &buffer ) -{ - m_markedForDeletion.emplace_back( buffer ); // hold on to the resource just a little longer -} - -const std::vector &SceneShapeSubSceneOverride::supportedRenderStyles() -{ - static std::vector g_supportedStyles = { RenderStyle::BoundingBox, RenderStyle::Wireframe, RenderStyle::Solid, RenderStyle::Textured }; - return g_supportedStyles; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// Selection and Instancing Utilities -//////////////////////////////////////////////////////////////////////////////////////////// - -#if MAYA_API_VERSION > 201650 -bool SceneShapeSubSceneOverride::getInstancedSelectionPath( const MRenderItem &renderItem, const MIntersection &intersection, MDagPath &dagPath ) const -{ - auto it = m_renderItemNameToDagPath.find( renderItem.name().asChar() ); - if( it != m_renderItemNameToDagPath.end() ) - { - dagPath.set( it->second ); - return true; - } - - return false; -} -#endif - -void SceneShapeSubSceneOverride::updateSelectionGranularity( const MDagPath &path, MSelectionContext &selectionContext ) -{ - MDagPath parent( path ); - parent.pop(); - - if( componentsSelectable( parent ) ) - { - selectionContext.setSelectionLevel( MHWRender::MSelectionContext::kComponent ); - } - else - { - selectionContext.setSelectionLevel( MHWRender::MSelectionContext::kObject ); - } -} - -void SceneShapeSubSceneOverride::selectedComponentIndices( SceneShapeSubSceneOverride::IndexMap &indexMap ) const -{ - MStatus s; - - MSelectionList selectionList; - MGlobal::getActiveSelectionList( selectionList ); - MItSelectionList selectionIter( selectionList ); - - MFnDagNode dagNode( m_sceneShape->thisMObject() ); - MDagPathArray dagPaths; - dagNode.getAllPaths(dagPaths); - - // Initialize map with empty sets - for( size_t i = 0; i < dagPaths.length(); ++i ) - { - std::string keyPath = dagPaths[i].fullPathName().asChar(); - indexMap[keyPath] = std::set(); - } - - for( ; !selectionIter.isDone(); selectionIter.next() ) - { - MDagPath selectedPath; // path to shape - MObject comp; - selectionIter.getDagPath( selectedPath, comp ); - - if( comp.isNull() ) - { - continue; - } - - MFnSingleIndexedComponent compFn( comp, &s ); - if( !s ) - { - continue; - } - - std::string key = selectedPath.fullPathName().asChar(); - auto it = indexMap.find( key ); - if( it == indexMap.end() ) - { - continue; - } - - MIntArray componentIndices; - compFn.getElements( componentIndices ); - - for( size_t i = 0; i < componentIndices.length(); ++i ) - { - it->second.insert( componentIndices[i] ); - } - } -} - -void SceneShapeSubSceneOverride::collectInstances( Instances &instances ) const -{ - MSelectionList selectionList; - MGlobal::getActiveSelectionList( selectionList ); - - MFnDagNode dagNode( m_sceneShape->thisMObject() ); - MDagPathArray dagPaths; - dagNode.getAllPaths(dagPaths); - size_t numInstances = dagPaths.length(); - instances.reserve( numInstances ); - - for( size_t pathIndex = 0; pathIndex < numInstances; ++pathIndex ) - { - MDagPath& path = dagPaths[pathIndex]; - MMatrix matrix = path.inclusiveMatrix(); - bool pathSelected = isPathSelected( selectionList, path ); - bool componentMode = componentsSelectable( path ); - bool visible = IECoreMaya::SceneShapeInterface::isVisible( path ); - - instances.emplace_back( matrix, pathSelected, componentMode, path, visible ); - } -} diff --git a/src/IECoreMaya/SceneShapeUI.cpp b/src/IECoreMaya/SceneShapeUI.cpp deleted file mode 100644 index 35b840a9ad..0000000000 --- a/src/IECoreMaya/SceneShapeUI.cpp +++ /dev/null @@ -1,919 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "IECoreGL/GL.h" // must come first so glew.h is included before gl.h - -#include "maya/MTypes.h" -#include "maya/MGlobal.h" -#include "maya/MDagPath.h" -#include "maya/MDrawData.h" -#include "maya/MDrawInfo.h" -#include "maya/MDrawRequestQueue.h" -#include "maya/MSelectInfo.h" -#include "maya/MSelectionList.h" -#include "maya/MSelectionMask.h" -#include "maya/MMaterial.h" -#include "maya/MFnSingleIndexedComponent.h" -#include "maya/MObjectArray.h" -#include "maya/MIntArray.h" -#include "maya/MPointArray.h" -#include "maya/MDoubleArray.h" -#include "maya/MFnCamera.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MStringArray.h" -#undef None // must come after certain Maya includes which include X11/X.h - -#include "IECore/MessageHandler.h" -#include "IECore/RunTimeTyped.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/MeshPrimitiveEvaluator.h" - -#include "IECoreGL/Scene.h" -#include "IECoreGL/State.h" -#include "IECoreGL/StateComponent.h" -#include "IECoreGL/TypedStateComponent.h" -#include "IECoreGL/NameStateComponent.h" -#include "IECoreGL/BoxPrimitive.h" -#include "IECoreGL/Exception.h" -#include "IECoreGL/Group.h" - -#include "IECoreMaya/SceneShapeUI.h" -#include "IECoreMaya/SceneShape.h" -#include "IECoreMaya/Convert.h" - -#include - -using namespace IECoreMaya; -using namespace std; - -SceneShapeUI::SceneShapeUI() -{ - IECoreGL::init( true ); -} - -SceneShapeUI::~SceneShapeUI() -{ -} - -void *SceneShapeUI::creator() -{ - return new SceneShapeUI; -} - - -void SceneShapeUI::getDrawRequests( const MDrawInfo &info, bool objectAndActiveOnly, MDrawRequestQueue &requests ) -{ - // it's easy if no one want to look at us - if( !info.objectDisplayStatus( M3dView::kDisplayMeshes ) ) - { - return; - } - - // make sure we don't have an ancestral visibility override which makes us invisible - if( !SceneShapeInterface::isVisible( info.multiPath() ) ) - { - return; - } - - // the node we're meant to be drawing - SceneShape *sceneShape = (SceneShape *)surfaceShape(); - - if( !sceneShape->getSceneInterface() ) - { - return; - } - - // draw data encapsulating that node - MDrawData drawData; - getDrawData( sceneShape, drawData ); - - // a request for the bound if necessary - MPlug pDrawBound( sceneShape->thisMObject(), SceneShape::aDrawRootBound ); - bool drawBound; - pDrawBound.getValue( drawBound ); - - if( drawBound ) - { - bool doDrawBound = true; - - // If objectOnly is true, check for an object. If none found, no need to add the bound request. - MPlug pObjectOnly( sceneShape->thisMObject(), SceneShape::aObjectOnly ); - bool objectOnly; - pObjectOnly.getValue( objectOnly ); - if( objectOnly && !sceneShape->getSceneInterface()->hasObject() ) - { - doDrawBound = false; - } - - if( doDrawBound ) - { - MDrawRequest request = info.getPrototype( *this ); - request.setDrawData( drawData ); - request.setToken( BoundDrawMode ); - request.setDisplayStyle( M3dView::kWireFrame ); - setWireFrameColors( request, info.displayStatus() ); - requests.add( request ); - } - - } - - MPlug pDrawAllBounds( sceneShape->thisMObject(), SceneShape::aDrawChildBounds ); - bool drawAllBounds = false; - pDrawAllBounds.getValue( drawAllBounds ); - - // requests for the scene if necessary - MPlug pGLPreview( sceneShape->thisMObject(), SceneShape::aDrawGeometry ); - bool glPreview; - pGLPreview.getValue( glPreview ); - - if( glPreview || drawAllBounds ) - { - if( info.displayStyle()==M3dView::kGouraudShaded || info.displayStyle()==M3dView::kFlatShaded ) - { - // make a request for solid drawing with a material - MDrawRequest solidRequest = info.getPrototype( *this ); - solidRequest.setDrawData( drawData ); - - MDagPath path = info.multiPath(); - M3dView view = info.view(); - MMaterial material = MPxSurfaceShapeUI::material( path ); - if( !material.evaluateMaterial( view, path ) ) - { - MString pathName = path.fullPathName(); - IECore::msg( IECore::Msg::Warning, "SceneShapeUI::getDrawRequests", boost::format( "Failed to evaluate material for \"%s\"." ) % pathName.asChar() ); - } - if( material.materialIsTextured() ) - { - material.evaluateTexture( drawData ); - } - solidRequest.setMaterial( material ); - // set the transparency request. we don't have a decent way of finding out - // if shaders applied by the procedural are transparent, so we've got a transparency - // attribute on the procedural holder for users to use. maya materials may also say - // they're transparent. if either asks for transparency then we'll ask for it here - bool transparent = false; - material.getHasTransparency( transparent ); - solidRequest.setIsTransparent( transparent ); - solidRequest.setToken( SceneDrawMode ); - requests.add( solidRequest ); - - if( info.displayStatus()==M3dView::kActive || info.displayStatus()==M3dView::kLead || info.displayStatus()==M3dView::kHilite ) - { - MDrawRequest wireRequest = info.getPrototype( *this ); - wireRequest.setDrawData( drawData ); - wireRequest.setDisplayStyle( M3dView::kWireFrame ); - wireRequest.setToken( SceneDrawMode ); - setWireFrameColors( wireRequest, info.displayStatus() ); - wireRequest.setComponent( MObject::kNullObj ); - - if ( !objectAndActiveOnly ) - { - if ( sceneShape->hasActiveComponents() ) - { - MObjectArray components = sceneShape->activeComponents(); - MObject component = components[0]; - wireRequest.setComponent( component ); - } - } - - requests.add( wireRequest ); - } - - } - else - { - MDrawRequest request = info.getPrototype( *this ); - request.setDrawData( drawData ); - setWireFrameColors( request, info.displayStatus() ); - request.setToken( SceneDrawMode ); - - request.setComponent( MObject::kNullObj ); - - if ( !objectAndActiveOnly ) - { - if ( sceneShape->hasActiveComponents() ) - { - MObjectArray components = sceneShape->activeComponents(); - MObject component = components[0]; - request.setComponent( component ); - } - } - requests.add( request ); - } - } - - -} - -void SceneShapeUI::setWireFrameColors( MDrawRequest &request, M3dView::DisplayStatus status ) -{ - // yes, this does use magic numbers for the color indices, and - // no, i don't know how to get them properly. the quadricShape api - // example is just doing this too. - switch( status ) - { - case M3dView::kLead : - request.setColor( 18, M3dView::kActiveColors ); - break; - case M3dView::kActive : - request.setColor( 15, M3dView::kActiveColors ); - break; - case M3dView::kActiveAffected : - request.setColor( 8, M3dView::kActiveColors ); - break; - case M3dView::kHilite : - request.setColor( 17, M3dView::kActiveColors ); - break; - case M3dView::kTemplate : - request.setColor( 2, M3dView::kDormantColors ); - break; - case M3dView::kActiveTemplate : - request.setColor( 19, M3dView::kActiveColors ); - break; - default : - // dormant - request.setColor( 4, M3dView::kDormantColors ); - break; - } -} - -void SceneShapeUI::draw( const MDrawRequest &request, M3dView &view ) const -{ - // TODO: We'd like to remove all of this, but we leave it in during a transition phase - const char *envvar = std::getenv("CORTEX_SCENESHAPE_MAYA_VP1_SUPPORT"); - if( envvar && !( strcmp( envvar, "1" ) == 0 ) ) - { - return; - } - - MStatus s; - MDrawData drawData = request.drawData(); - SceneShape *sceneShape = (SceneShape *)drawData.geometry(); - assert( sceneShape ); - - view.beginGL(); - - M3dView::LightingMode lightingMode; - view.getLightingMode( lightingMode ); - - LightingState lightingState; - bool restoreLightState = cleanupLights( request, view, &lightingState ); - - // maya can sometimes leave an error from it's own code, - // and we don't want that to confuse us in our drawing code. - while( glGetError()!=GL_NO_ERROR ) - { - } - - try - { - // draw the bound if asked - if( request.token()==BoundDrawMode ) - { - IECoreGL::BoxPrimitive::renderWireframe( IECore::convert( sceneShape->boundingBox() ) ); - } - - // draw the scene if asked - if( request.token()==SceneDrawMode ) - { - resetHilites(); - - IECoreGL::ConstScenePtr scene = sceneShape->glScene(); - if( scene ) - { - IECoreGL::State *displayState = m_displayStyle.baseState( (M3dView::DisplayStyle)request.displayStyle(), lightingMode ); - - if ( request.component() != MObject::kNullObj ) - { - MDoubleArray col; - s = MGlobal::executeCommand( "colorIndex -q 21", col ); - assert( s ); - IECoreGL::WireframeColorStateComponentPtr hilite = new IECoreGL::WireframeColorStateComponent( Imath::Color4f( col[0], col[1], col[2], 1.0f ) ); - - MFnSingleIndexedComponent fnComp( request.component(), &s ); - assert( s ); - - int len = fnComp.elementCount( &s ); - assert( s ); - std::vector groupNames; - for ( int j = 0; j < len; j++ ) - { - int index = fnComp.element(j); - groupNames.push_back( sceneShape->selectionName( index ) ); - } - // Sort by name to make sure we don't unhilite selected items that are further down the hierarchy - std::sort( groupNames.begin(), groupNames.end() ); - - for ( std::vector::iterator it = groupNames.begin(); it!= groupNames.end(); ++it) - { - IECoreGL::GroupPtr group = sceneShape->glGroup( *it ); - - hiliteGroups( - group, - hilite, - const_cast( displayState->get< IECoreGL::WireframeColorStateComponent >() ) - ); - } - } - - scene->render( displayState ); - } - } - } - catch( const IECoreGL::Exception &e ) - { - // much better to catch and report this than to let the application die - IECore::msg( IECore::Msg::Error, "SceneShapeUI::draw", boost::format( "IECoreGL Exception : %s" ) % e.what() ); - } - - if( restoreLightState ) - { - restoreLights( &lightingState ); - } - - view.endGL(); -} - -#if MAYA_API_VERSION >= 201300 - -bool SceneShapeUI::snap( MSelectInfo &snapInfo ) const -{ - // TODO: We'd like to remove all of this, but we leave it in during a transition phase - const char *envvar = std::getenv("CORTEX_SCENESHAPE_MAYA_VP1_SUPPORT"); - if( envvar && !( strcmp( envvar, "1" ) == 0 ) ) - { - return false; - } - - MStatus s; - - if( snapInfo.displayStatus() != M3dView::kHilite ) - { - MSelectionMask meshMask( MSelectionMask::kSelectMeshes ); - if( !snapInfo.selectable( meshMask ) ) - { - return false; - } - } - - // early out if we have no scene to draw - SceneShape *sceneShape = static_cast( surfaceShape() ); - const IECoreScene::SceneInterface *sceneInterface = sceneShape->getSceneInterface().get(); - if( !sceneInterface ) - { - return false; - } - - IECoreGL::ConstScenePtr scene = sceneShape->glScene(); - if( !scene ) - { - return false; - } - - // Get the viewport that the snapping operation is taking place in. - M3dView view = snapInfo.view(); - - // Use an IECoreGL::Selector to find the point in world space that we wish to snap to. - // We do this by first getting the origin of the selection ray and transforming it into - // NDC space using the OpenGL projection and transformation matrices. Once we have the - // point in NDC we can use it to define the viewport that the IECoreGL::Selector will use. - - MPoint localRayOrigin; - MVector localRayDirection; - snapInfo.getLocalRay( localRayOrigin, localRayDirection ); - - Imath::V3d org( localRayOrigin[0], localRayOrigin[1], localRayOrigin[2] ); - MDagPath camera; - view.getCamera( camera ); - MMatrix localToCamera = snapInfo.selectPath().inclusiveMatrix() * camera.inclusiveMatrix().inverse(); - - view.beginSelect(); - Imath::M44d projectionMatrix; - glGetDoublev( GL_PROJECTION_MATRIX, projectionMatrix.getValue() ); - view.endSelect(); - - double v[4][4]; - localToCamera.get( v ); - Imath::M44d cam( v ); - Imath::V3d ndcPt3d = ( (org * cam ) * projectionMatrix + Imath::V3d( 1. ) ) * Imath::V3d( .5 ); - Imath::V2d ndcPt( std::max( std::min( ndcPt3d[0], 1. ), 0. ), 1. - std::max( std::min( ndcPt3d[1], 1. ), 0. ) ); - - view.beginGL(); - - glMatrixMode( GL_PROJECTION ); - glLoadMatrixd( projectionMatrix.getValue() ); - - float radius = .001; // The radius of the selection area in NDC. - double aspect = double( view.portWidth() ) / view.portHeight(); - Imath::V2f selectionWH( radius, radius * aspect ); - - std::vector hits; - { - IECoreGL::Selector selector( Imath::Box2f( ndcPt - selectionWH, ndcPt + selectionWH ), IECoreGL::Selector::IDRender, hits ); - - IECoreGL::State::bindBaseState(); - selector.baseState()->bind(); - scene->render( selector.baseState() ); - } - - view.endGL(); - - if( hits.empty() ) - { - return false; - } - - // Get the closest mesh hit. - float depthMin = std::numeric_limits::max(); - int depthMinIndex = -1; - for( unsigned int i=0, e = hits.size(); i < e; i++ ) - { - if( hits[i].depthMin < depthMin ) - { - depthMin = hits[i].depthMin; - depthMinIndex = i; - } - } - - // Get the absolute path of the hit object. - IECoreScene::SceneInterface::Path objPath; - std::string objPathStr; - sceneInterface->path( objPath ); - IECoreScene::SceneInterface::pathToString( objPath, objPathStr ); - - objPathStr += IECoreGL::NameStateComponent::nameFromGLName( hits[depthMinIndex].name ); - IECoreScene::SceneInterface::stringToPath( objPathStr, objPath ); - - // Validate the hit selection. - IECoreScene::ConstSceneInterfacePtr childInterface; - try - { - childInterface = sceneInterface->scene( objPath ); - } - catch(...) - { - return false; - } - - if( !childInterface ) - { - return false; - } - - if( !childInterface->hasObject() ) - { - return false; - } - - // Get the mesh primitive so that we can query it's vertices. - double time = sceneShape->time(); - IECore::ConstObjectPtr object = childInterface->readObject( time ); - IECoreScene::ConstMeshPrimitivePtr meshPtr = IECore::runTimeCast( object.get() ); - - if ( !meshPtr ) - { - return false; - } - - // Calculate the snap point in object space. - MPoint worldIntersectionPoint; - selectionRayToWorldSpacePoint( camera, snapInfo, depthMin, worldIntersectionPoint ); - Imath::V3f pt( worldIntersectionPoint[0], worldIntersectionPoint[1], worldIntersectionPoint[2] ); - Imath::M44f objToWorld( worldTransform( childInterface.get(), time ) ); - pt = pt * objToWorld.inverse(); - - // Get the list of vertices in the mesh. - IECore::V3fVectorData::ConstPtr pointData( meshPtr->variableData( "P", IECoreScene::PrimitiveVariable::Vertex ) ); - const std::vector &vertices( pointData->readable() ); - - // Find the vertex that is closest to the snap point. - Imath::V3d closestVertex(0, 0, 0); - float closestDistance = std::numeric_limits::max(); - - for( std::vector::const_iterator it( vertices.begin() ); it != vertices.end(); ++it ) - { - Imath::V3d vert( *it ); - float d( ( pt - vert ).length() ); // Calculate the distance between the vertex and the snap point. - if( d < closestDistance ) - { - closestDistance = d; - closestVertex = vert; - } - } - - // Snap to the vertex. - closestVertex *= objToWorld; - snapInfo.setSnapPoint( MPoint( closestVertex[0], closestVertex[1], closestVertex[2] ) ); - return true; -} - -#endif - -void SceneShapeUI::selectionRayToWorldSpacePoint( const MDagPath &camera, const MSelectInfo &selectInfo, float depth, MPoint &worldIntersectionPoint ) const -{ - MPoint localRayOrigin; - MVector localRayDirection; - selectInfo.getLocalRay( localRayOrigin, localRayDirection ); - - MFnCamera fnCamera( camera.node() ); - float near = fnCamera.nearClippingPlane(); - float far = fnCamera.farClippingPlane(); - float z = -1; - - if( fnCamera.isOrtho() ) - { - z = Imath::lerp( near, far, depth ); - } - else - { - // perspective camera - depth isn't linear so linearise to get z - float a = far / ( far - near ); - float b = far * near / ( near - far ); - z = b / ( depth - a ); - } - - MMatrix localToCamera = selectInfo.selectPath().inclusiveMatrix() * camera.inclusiveMatrix().inverse(); - MPoint cameraRayOrigin = localRayOrigin * localToCamera; - MVector cameraRayDirection = localRayDirection * localToCamera; - - MPoint cameraIntersectionPoint = cameraRayOrigin + cameraRayDirection * ( -( z - near ) / cameraRayDirection.z ); - worldIntersectionPoint = cameraIntersectionPoint * camera.inclusiveMatrix(); -} - -bool SceneShapeUI::select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const -{ - // TODO: We'd like to remove all of this, but we leave it in during a transition phase - const char *envvar = std::getenv("CORTEX_SCENESHAPE_MAYA_VP1_SUPPORT"); - if( envvar && !( strcmp( envvar, "1" ) == 0 ) ) - { - return false; - } - - MStatus s; - - // early out if we're not selectable. we always allow components to be selected if we're highlighted, - // but we don't allow ourselves to be selected as a whole unless meshes are in the selection mask. - // it's not ideal that we act like a mesh, but it's at least consistent with the drawing mask we use. - if( selectInfo.displayStatus() != M3dView::kHilite ) - { - MSelectionMask meshMask( MSelectionMask::kSelectMeshes ); - // Apparently selectInfo.selectable() still returns true when meshes are not - // displayed by the M3dView, so we are also testing the objectDisplay status. - // This was last confirmed in Maya 2014, and is presumably a Maya bug. - if( !selectInfo.selectable( meshMask ) || !selectInfo.objectDisplayStatus( M3dView::kDisplayMeshes ) ) - { - return false; - } - } - - // early out if we have no scene to draw - SceneShape *sceneShape = static_cast( surfaceShape() ); - if( !sceneShape->getSceneInterface() ) - { - return false; - } - - IECoreGL::ConstScenePtr scene = sceneShape->glScene(); - if( !scene ) - { - return false; - } - - // we want to perform the selection using an IECoreGL::Selector, so we - // can avoid the performance penalty associated with using GL_SELECT mode. - // that means we don't really want to call view.beginSelect(), but we have to - // call it just to get the projection matrix for our own selection, because as far - // as I can tell, there is no other way of getting it reliably. - - M3dView view = selectInfo.view(); - view.beginSelect(); - Imath::M44d projectionMatrix; - glGetDoublev( GL_PROJECTION_MATRIX, projectionMatrix.getValue() ); - view.endSelect(); - - view.beginGL(); - - glMatrixMode( GL_PROJECTION ); - glLoadMatrixd( projectionMatrix.getValue() ); - - IECoreGL::Selector::Mode selectionMode = IECoreGL::Selector::IDRender; - if( selectInfo.displayStatus() == M3dView::kHilite && !selectInfo.singleSelection() ) - { - selectionMode = IECoreGL::Selector::OcclusionQuery; - } - - std::vector hits; - { - IECoreGL::Selector selector( Imath::Box2f( Imath::V2f( 0 ), Imath::V2f( 1 ) ), selectionMode, hits ); - - IECoreGL::State::bindBaseState(); - selector.baseState()->bind(); - scene->render( selector.baseState() ); - - if( selectInfo.displayStatus() != M3dView::kHilite ) - { - // We're not in component selection mode. We'd like to be able to select the scene shape - // using the bounding box so we draw it too but only if it is visible - MPlug pDrawBound( sceneShape->thisMObject(), SceneShape::aDrawRootBound ); - bool drawBound; - pDrawBound.getValue( drawBound ); - if( drawBound ) - { - IECoreGL::BoxPrimitive::renderWireframe( IECore::convert( sceneShape->boundingBox() ) ); - } - } - } - - view.endGL(); - - if( hits.empty() ) - { - return false; - } - - // iterate over the hits, converting them into components and also finding - // the closest one. - MIntArray componentIndices; - - float depthMin = std::numeric_limits::max(); - int depthMinIndex = -1; - for( unsigned int i=0, e = hits.size(); i < e; i++ ) - { - if( hits[i].depthMin < depthMin ) - { - depthMin = hits[i].depthMin; - depthMinIndex = componentIndices.length(); - } - int index = sceneShape->selectionIndex( IECoreGL::NameStateComponent::nameFromGLName( hits[i].name ) ); - componentIndices.append( index ); - } - - assert( depthMinIndex >= 0 ); - - // figure out the world space location of the closest hit - MDagPath camera; - view.getCamera( camera ); - - MPoint worldIntersectionPoint; - selectionRayToWorldSpacePoint( camera, selectInfo, depthMin, worldIntersectionPoint ); - - // turn the processed hits into appropriate changes to the current selection - if( selectInfo.displayStatus() == M3dView::kHilite ) - { - // selecting components - MFnSingleIndexedComponent fnComponent; - MObject component = fnComponent.create( MFn::kMeshPolygonComponent, &s ); assert( s ); - - if( selectInfo.singleSelection() ) - { - fnComponent.addElement( componentIndices[depthMinIndex] ); - } - else - { - fnComponent.addElements( componentIndices ); - } - - MSelectionList items; - items.add( selectInfo.multiPath(), component ); - - MDagPath path = selectInfo.multiPath(); - - selectInfo.addSelection( - items, worldIntersectionPoint, - selectionList, worldSpaceSelectPts, - MSelectionMask::kSelectMeshFaces, - true - ); - - } - else - { - // Check if we should be able to select that object - MPlug pObjectOnly( sceneShape->thisMObject(), SceneShape::aObjectOnly ); - bool objectOnly; - pObjectOnly.getValue( objectOnly ); - if( objectOnly && !sceneShape->getSceneInterface()->hasObject() ) - { - return true; - } - - // selecting objects - MSelectionList item; - item.add( selectInfo.selectPath() ); - - selectInfo.addSelection( - item, worldIntersectionPoint, - selectionList, worldSpaceSelectPts, - MSelectionMask::kSelectMeshes, - false - ); - } - - return true; -} - -Imath::M44d SceneShapeUI::worldTransform( const IECoreScene::SceneInterface *scene, double time ) const -{ - IECoreScene::SceneInterface::Path p; - scene->path( p ); - - IECoreScene::ConstSceneInterfacePtr tmpScene = scene->scene( IECoreScene::SceneInterface::rootPath ); - Imath::M44d result; - - for ( IECoreScene::SceneInterface::Path::const_iterator it = p.begin(); tmpScene && it != p.end(); ++it ) - { - tmpScene = tmpScene->child( *it, IECoreScene::SceneInterface::NullIfMissing ); - if ( !tmpScene ) - { - break; - } - - result = tmpScene->readTransformAsMatrix( time ) * result; - } - - return result; -} - -void SceneShapeUI::unhiliteGroupChildren( const std::string &name, IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr base ) const -{ - assert( base ); - assert( group ); - - /// Add state so that the group hilite state doesn't propogate down the hierarchy past the given name - IECoreGL::ConstNameStateComponentPtr n = group->getState()->get< IECoreGL::NameStateComponent >(); - if ( n && n->name() != name ) - { - if ( m_stateMap.find( group.get() ) == m_stateMap.end() ) - { - IECoreGL::StatePtr oldState = new IECoreGL::State( *(group->getState()) ); - assert( oldState ); - m_stateMap[ group.get() ] = oldState; - } - - group->getState()->add( base ); - return; - } - - const IECoreGL::Group::ChildContainer &children = group->children(); - for ( IECoreGL::Group::ChildContainer::const_iterator it = children.begin(); it != children.end(); ++it ) - { - assert( *it ); - - IECoreGL::GroupPtr childGroup = IECore::runTimeCast< IECoreGL::Group >( *it ); - if ( childGroup ) - { - unhiliteGroupChildren( name, childGroup, base ); - } - } -} - -void SceneShapeUI::hiliteGroups( IECoreGL::GroupPtr group, IECoreGL::StateComponentPtr hilite, IECoreGL::StateComponentPtr base ) const -{ - assert( base ); - - if( group ) - { - IECoreGL::ConstNameStateComponentPtr n = group->getState()->get< IECoreGL::NameStateComponent >(); - if( n ) - { - const std::string &name = n->name(); - unhiliteGroupChildren( name, group, base ); - } - - if ( m_stateMap.find( group.get() ) == m_stateMap.end() ) - { - IECoreGL::StatePtr oldState = new IECoreGL::State( *(group->getState()) ); - assert( oldState ); - m_stateMap[ group.get() ] = oldState; - } - - group->getState()->add( hilite ); - } -} - -void SceneShapeUI::resetHilites() const -{ - for ( StateMap::iterator it = m_stateMap.begin(); it != m_stateMap.end(); ++it ) - { - it->first->setState( it->second ); - } - - m_stateMap.clear(); -} - - -// Currently, Maya leaves lights in GL when you reduce the number of active lights in -// your scene. It fills the GL light space from 0 with the visible lights, so, we simply -// need to reset the potentially 'old' state of lights after the last one we know to be -// visible. We'll put it all back as we found it though. For the moment, this assumes -// Maya is filling GL consecutively, if they stop doing that, we'll need to get the -// actual light indexes from the view. Its just a bit quicker to assume this, whilst we can. -bool SceneShapeUI::cleanupLights( const MDrawRequest &request, M3dView &view, LightingState *s ) const -{ - - if( !(request.displayStyle()==M3dView::kFlatShaded || request.displayStyle()==M3dView::kGouraudShaded) ) - { - return false; - } - - M3dView::LightingMode mode; - view.getLightingMode(mode); - - if (mode == M3dView::kLightDefault) - { - s->numMayaLights = 1; - } - else - { - view.getLightCount( s->numMayaLights ); - } - - int sGlMaxLights = 0; - glGetIntegerv( GL_MAX_LIGHTS, &sGlMaxLights ); - s->numGlLights = sGlMaxLights; - - if( s->numMayaLights >= s->numGlLights || s->numGlLights == 0 ) - { - return false; - } - - unsigned int vectorSize = s->numGlLights - s->numMayaLights; - - s->diffuses.resize( vectorSize ); - s->specs.resize( vectorSize ); - s->ambients.resize( vectorSize ); - - static float s_defaultColor[] = { 0.0, 0.0, 0.0, 1.0 }; - - GLenum light; - unsigned int j = 0; - - for( unsigned int i = s->numMayaLights; i < s->numGlLights; i++ ) - { - light = GL_LIGHT0 + i; - - glGetLightfv( light, GL_DIFFUSE, s->diffuses[j].getValue() ); - glLightfv( light, GL_DIFFUSE, s_defaultColor ); - - glGetLightfv( light, GL_SPECULAR, s->specs[j].getValue() ); - glLightfv( light, GL_SPECULAR, s_defaultColor ); - - glGetLightfv( light, GL_AMBIENT, s->ambients[j].getValue() ); - glLightfv( light, GL_AMBIENT, s_defaultColor ); - - j++; - } - - return true; -} - -void SceneShapeUI::restoreLights( LightingState *s ) const -{ - GLenum light; - unsigned int j = 0; - - for( unsigned int i = s->numMayaLights; i < s->numGlLights; i++ ) - { - light = GL_LIGHT0 + i; - - glLightfv( light, GL_DIFFUSE, s->diffuses[j].getValue() ); - glLightfv( light, GL_SPECULAR, s->specs[j].getValue() ); - glLightfv( light, GL_AMBIENT, s->ambients[j].getValue() ); - - j++; - } -} diff --git a/src/IECoreMaya/StatusException.cpp b/src/IECoreMaya/StatusException.cpp deleted file mode 100644 index 61540fa8ab..0000000000 --- a/src/IECoreMaya/StatusException.cpp +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/StatusException.h" - -#include "maya/MString.h" - -using namespace IECoreMaya; - -StatusException::StatusException( const MStatus &status ) - : Exception( "" ) -{ - MString error = status.errorString(); - m_what = new RefCountedString( error.asChar() ); -} - -const char *StatusException::type() const throw() -{ - return "IECoreMaya::StatusException"; -} - -void StatusException::throwIfError( const MStatus &status ) -{ - if( !status ) - { - throw StatusException( status ); - } -} diff --git a/src/IECoreMaya/StringParameterHandler.cpp b/src/IECoreMaya/StringParameterHandler.cpp deleted file mode 100644 index 44655a3d31..0000000000 --- a/src/IECoreMaya/StringParameterHandler.cpp +++ /dev/null @@ -1,284 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/StringParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" -#include "IECore/CompoundParameter.h" -#include "IECore/CompoundObject.h" -#include "IECore/FileNameParameter.h" -#include "IECore/DirNameParameter.h" -#include "IECore/ValidatedStringParameter.h" -#include "IECore/FileSequenceParameter.h" -#include "IECore/FrameListParameter.h" - -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnMessageAttribute.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MStringArray.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MDagPath.h" -#include "maya/MPlugArray.h" -#include "maya/MFnSet.h" -#include "maya/MSelectionList.h" - -#include "maya/MStringArray.h" - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< StringParameterHandler > stringRegistrar( IECore::StringParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > pathRegistrar( IECore::PathParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > fileNameRegistrar( IECore::FileNameParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > dirNameRegistrar( IECore::DirNameParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > validatedStringRegistrar( IECore::ValidatedStringParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > fileSequenceRegistrar( IECore::FileSequenceParameter::staticTypeId() ); -static ParameterHandler::Description< StringParameterHandler > frameListRegistrar( IECore::FrameListParameter::staticTypeId() ); - -MStatus StringParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstStringParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - - switch( getValueProvider(parameter) ) - { - case ConnectedNodeNameValueProvider : - { - MFnMessageAttribute fnMAttr( attribute ); - if( !fnMAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - break; - } - - default : - { - // we'd like to be setting the default value here, but as maya doesn't save the default value - // for dynamic string attributes in scene files, it'll be lost when the scene is reloaded. it's - // best therefore that we don't set the default at all, so that the default is "", which is what - // it'll be when we reload the scene - this ensures that any values set in the attribute later - // will be saved correctly (if we set the default to "X" and the value was "X", maya won't save the - // default or the value at all, and we end up with a value of "" on scene reload). - - MFnTypedAttribute fnTAttr( attribute ); - if( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kString ) - { - return MS::kFailure; - } - - // Should this fail if getPlugValue fails? - MString v = ""; - if( getPlugValue( plug, p, v ) ) - { - IECore::ObjectPtr d = new IECore::StringData( v.asChar() ); - if( !parameter->valueValid( d.get() ) ) - { - return MS::kFailure; - } - } - } - } - - return finishUpdating( parameter, plug ); -} - -MPlug StringParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstStringParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - MObject attribute; - - switch( getValueProvider(parameter) ) - { - case ConnectedNodeNameValueProvider : - { - MFnMessageAttribute fnMAttr; - attribute = fnMAttr.create( plugName, plugName ); - break; - } - - default : - { - MFnTypedAttribute fnTAttr; - attribute = fnTAttr.create( plugName, plugName, MFnData::kString /* see comments in stringUpdate for why we don't specify a default here */ ); - } - } - - MPlug thePlug = finishCreating( parameter, attribute, node ); - if( finishUpdating( parameter, thePlug ) ) - { - return thePlug; - } - - return MPlug(); -} - -MStatus StringParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstStringParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - switch( getValueProvider(parameter) ) - { - case ConnectedNodeNameValueProvider : - { - return MS::kSuccess; - } - - default : - return plug.setValue( p->getTypedValue().c_str() ); - } -} - -MStatus StringParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - - IECore::StringParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MString v = ""; - MStatus result = getPlugValue( plug, p, v ); - if( result ) - { - p->setTypedValue( v.asChar() ); - } - - return result; -} - -MStatus StringParameterHandler::getPlugValue( const MPlug &plug, IECore::ConstStringParameterPtr parameter, MString &value ) const -{ - MStatus result; - - switch( getValueProvider(parameter) ) - { - case NodeNameValueProvider : - { - MObject node = plug.node(); - return getPathOrNameFromNode( node, value ); - } - - case ConnectedNodeNameValueProvider : - { - MPlugArray connections; - bool connected = plug.connectedTo( connections, true, false, &result); - if( !connected ) - { - value = ""; - return MS::kSuccess; - } - - MObject node = connections[0].node(); - return getPathOrNameFromNode( node, value ); - } - - default : - return plug.getValue( value ); - } - - return MS::kFailure; -} - -MStatus StringParameterHandler::getPathOrNameFromNode( const MObject &node, MString &name ) -{ - MStatus result; - - if( node.hasFn(MFn::kDagNode) ) - { - MDagPath path; - result = MDagPath::getAPathTo( node, path ); - if( !result ) - { - return MS::kFailure; - } - name = path.fullPathName(); - } - else - { - MFnDependencyNode fnDN( node, &result ); - if( !result ) - { - return MS::kFailure; - } - name = fnDN.name(); - } - return MS::kSuccess; -} - -StringParameterHandler::ValueProvider StringParameterHandler::getValueProvider( const IECore::ConstParameterPtr parameter ) -{ - const IECore::ConstCompoundObjectPtr userData = parameter->userData(); - const IECore::ConstCompoundObjectPtr maya = userData->member("maya"); - if (!maya) - { - return InvalidValueProvider; - } - - const IECore::ConstStringDataPtr valueProvider = maya->member("valueProvider"); - if (!valueProvider) - { - return InvalidValueProvider; - } - - if( valueProvider->readable() == "nodeName" ) - { - return NodeNameValueProvider; - } - else if( valueProvider->readable() == "connectedNodeName" ) - { - return ConnectedNodeNameValueProvider; - } - - return InvalidValueProvider; -} - diff --git a/src/IECoreMaya/StringVectorParameterHandler.cpp b/src/IECoreMaya/StringVectorParameterHandler.cpp deleted file mode 100644 index fa6ef9262a..0000000000 --- a/src/IECoreMaya/StringVectorParameterHandler.cpp +++ /dev/null @@ -1,232 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/StringVectorParameterHandler.h" - -#include "IECore/VectorTypedParameter.h" -#include "IECore/CompoundObject.h" - -#include "maya/MFnTypedAttribute.h" -#include "maya/MFnMessageAttribute.h" -#include "maya/MFnStringArrayData.h" -#include "maya/MStringArray.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MDagPath.h" -#include "maya/MPlugArray.h" -#include "maya/MFnSet.h" -#include "maya/MSelectionList.h" - - -using namespace IECoreMaya; -using namespace Imath; -using namespace boost; - -static ParameterHandler::Description< StringVectorParameterHandler > registrar( IECore::StringVectorParameter::staticTypeId() ); - -MStatus StringVectorParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstStringVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnTypedAttribute fnTAttr( attribute ); - if( !fnTAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - const IECore::StringVectorParameter::ValueType &value = p->typedDefaultValue(); - MStringArray defaultValue; - - for (IECore::StringVectorParameter::ValueType::const_iterator it = value.begin(); it != value.end(); ++it) - { - defaultValue.append( it->c_str() ); - } - - fnTAttr.setDefault( MFnStringArrayData().create( defaultValue ) ); - - return finishUpdating( parameter, plug ); -} - -MPlug StringVectorParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - IECore::ConstStringVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MPlug(); - } - - const IECore::StringVectorParameter::ValueType &value = p->typedDefaultValue(); - MStringArray defaultValue; - - for (IECore::StringVectorParameter::ValueType::const_iterator it = value.begin(); it != value.end(); ++it) - { - defaultValue.append( it->c_str() ); - } - - MFnTypedAttribute fnTAttr; - MObject attribute = fnTAttr.create( plugName, plugName, MFnData::kStringArray, MFnStringArrayData().create( defaultValue ) ); - - MPlug result = finishCreating( parameter, attribute, node ); - doUpdate( parameter, result ); - - return result; -} - -MStatus StringVectorParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - IECore::ConstStringVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - const IECore::StringVectorParameter::ValueType &value = p->getTypedValue(); - MStringArray arr; - - for (IECore::StringVectorParameter::ValueType::const_iterator it = value.begin(); it != value.end(); ++it) - { - arr.append( it->c_str() ); - } - - - MObject data = MFnStringArrayData().create( arr ); - - return plug.setValue( data ); -} - -MStatus StringVectorParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - IECore::StringVectorParameterPtr p = IECore::runTimeCast( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MStringArray arr; - MStatus result; - const IECore::ConstCompoundObjectPtr userData = parameter->userData(); - const IECore::ConstCompoundObjectPtr maya = userData->member("maya"); - - bool hasValueProvider = false; - - if (maya) - { - const IECore::ConstStringDataPtr valueProvider = maya->member("valueProvider"); - - if (valueProvider && valueProvider->readable() == "setMembers") - { - MStatus s; - MFnSet fnSet( plug.node(), &s ); - if (!s) - { - return s; - } - - MSelectionList members; - s = fnSet.getMembers( members, true ); - if (!s) - { - return s; - } - - for (unsigned i = 0; i < members.length(); ++i) - { - MObject node; - MPlug plug; - MDagPath path; - - if (members.getPlug(i, plug)) - { - arr.append( plug.name() ); - } - else if (members.getDagPath(i, path)) - { - arr.append( path.fullPathName() ); - } - else if (members.getDependNode(i, node)) - { - MFnDependencyNode fnDN(node); - arr.append( fnDN.name() ); - } - else - { - return MS::kFailure; - } - - } - - hasValueProvider = true; - } - } - - // it's essential that the fnData object is declared at the same scope as the arr object we copy - // the array into. this is because arr appears to become a reference into the same data as fnData - // holds, and when fnData goes out of scope the data appears to become unavailable and arr becomes of length 0 - MFnStringArrayData fnData; - if (!hasValueProvider) - { - MObject data; - result = plug.getValue( data ); - - if( result ) - { - MStatus s = fnData.setObject( data ); - if (!s) - { - return s; - } - - arr = fnData.array(); - } - } - - IECore::StringVectorParameter::ObjectType::Ptr valuePtr = new IECore::StringVectorParameter::ObjectType; - IECore::StringVectorParameter::ValueType &value = valuePtr->writable(); - value.reserve( arr.length() ); - - for (unsigned i = 0; i < arr.length(); i++) - { - value.push_back( arr[i].asChar() ); - } - - p->setValue( valuePtr ); - - return result; -} diff --git a/src/IECoreMaya/ToMayaArrayDataConverter.cpp b/src/IECoreMaya/ToMayaArrayDataConverter.cpp deleted file mode 100644 index 7ebb6d5b9d..0000000000 --- a/src/IECoreMaya/ToMayaArrayDataConverter.cpp +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MArrayDataBuilder.h" -#include "maya/MVectorArray.h" -#include "maya/MPointArray.h" -#include "maya/MStringArray.h" - -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/MArrayTraits.h" -#include "IECoreMaya/ToMayaArrayDataConverter.h" - -using namespace IECoreMaya; - -template -ToMayaObjectConverter::ToMayaObjectConverterDescription< ToMayaArrayDataConverter > ToMayaArrayDataConverter::g_description( F::staticTypeId(), MArrayTraits::dataType() ); - -template -ToMayaArrayDataConverter::ToMayaArrayDataConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECore::VectorData objects to a Maya object.", object) -{ -} - -template -bool ToMayaArrayDataConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - typename F::ConstPtr dataPtr = IECore::runTimeCast(from); - assert( dataPtr ); - - typename MArrayTraits::DataFn fnData; - - const typename F::ValueType &v = dataPtr->readable(); - - T array; - array.setLength( v.size() ); - - for (unsigned i = 0; i < v.size(); i++) - { - array[i] = IECore::convert< typename MArrayTraits::ValueType, typename F::ValueType::value_type >( v[i] ); - } - - to = fnData.create( array, &s ); - - return s; -} - -template class ToMayaArrayDataConverter< IECore::V3fVectorData, MVectorArray >; -template class ToMayaArrayDataConverter< IECore::V3dVectorData, MVectorArray >; -template class ToMayaArrayDataConverter< IECore::Color3fVectorData, MVectorArray >; -template class ToMayaArrayDataConverter< IECore::V3fVectorData, MPointArray >; -template class ToMayaArrayDataConverter< IECore::V3dVectorData, MPointArray >; -template class ToMayaArrayDataConverter< IECore::StringVectorData, MStringArray >; -template class ToMayaArrayDataConverter< IECore::DoubleVectorData, MDoubleArray >; -template class ToMayaArrayDataConverter< IECore::FloatVectorData, MDoubleArray >; -template class ToMayaArrayDataConverter< IECore::IntVectorData, MIntArray >; -template class ToMayaArrayDataConverter< IECore::BoolVectorData, MIntArray >; diff --git a/src/IECoreMaya/ToMayaCameraConverter.cpp b/src/IECoreMaya/ToMayaCameraConverter.cpp deleted file mode 100644 index 90a4e5cf0a..0000000000 --- a/src/IECoreMaya/ToMayaCameraConverter.cpp +++ /dev/null @@ -1,188 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MCommonRenderSettingsData.h" -#include "maya/MDagPath.h" -#include "maya/MDagModifier.h" -#include "maya/MFnCamera.h" -#include "maya/MFnTransform.h" -#include "maya/MRenderUtil.h" -#include "maya/MSelectionList.h" - -#include "IECore/AngleConversion.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECoreScene/Camera.h" -#include "IECoreScene/MatrixTransform.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaCameraConverter.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -namespace { - -// It's awesome that not only does Maya bake this random mm-to-inch conversion into their -// camera, but they use the pre 1959 definition of the inch -const float INCH_TO_MM = 25.400051; - -} - -ToMayaCameraConverter::Description ToMayaCameraConverter::g_description( IECoreScene::Camera::staticTypeId(), MFn::kCamera ); - -ToMayaCameraConverter::ToMayaCameraConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::Camera objects to Maya cameras.", object ) -{ -} - -bool ToMayaCameraConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - ConstCameraPtr camera = IECore::runTimeCast( from ); - if ( !camera ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaCameraConverter::doConversion", "The source object is not an IECoreScene::Camera." ); - return false; - } - - // check if incoming object is a cameraShape itself - MObject camObj; - MFnCamera fnCamera; - if ( fnCamera.hasObj( to ) ) - { - camObj = to; - } - - // check if incoming object is a parent of an existing cameraShape - if ( camObj.isNull() ) - { - MFnDagNode fnTo( to ); - for ( unsigned i=0; i < fnTo.childCount(); ++i ) - { - MObject child = fnTo.child( i ); - if ( fnCamera.hasObj( child ) ) - { - camObj = child; - break; - } - } - } - - // make a new cameraShape and parent it to the incoming object - if ( camObj.isNull() ) - { - if ( !MFnTransform().hasObj( to ) ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaCameraConverter::doConversion", "Unable to create a camera as a child of the input object." ); - return false; - } - - MDagModifier dagMod; - camObj = dagMod.createNode( "camera", to ); - if ( !dagMod.doIt() ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaCameraConverter::doConversion", "Unable to modify the DAG correctly." ); - dagMod.undoIt(); - return false; - } - } - - if ( camObj.isNull() ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaCameraConverter::doConversion", "Unable to find or create a camera from the input object." ); - return false; - } - - MDagPath camDag; - MFnDagNode( camObj ).getPath( camDag ); - fnCamera.setObject( camDag ); - - Imath::V2f clippingPlanes = camera->getClippingPlanes(); - fnCamera.setNearClippingPlane( clippingPlanes[0] ); - fnCamera.setFarClippingPlane( clippingPlanes[1] ); - - if ( camera->getProjection() == "perspective" ) - { - fnCamera.setIsOrtho( false ); - - - float focalLength = camera->getFocalLength(); - - // The factor of 0.1 here means we assume focal length units are in tenths of world units - // ( ie. focal length in millimeters, world units in centimeters ). World units may not - // really be centimeters, but using this as a default ( matching Alembic/USD ) preserves - // the focal length in the common case where we're not using DOF and don't care about - // focalLengthWorldScale - float focalLengthScale = camera->getFocalLengthWorldScale() / 0.1f; - - if( focalLengthScale * focalLength < 2.5f ) - { - // Maya arbitrarily disallows cameras with focal lengths less than 2.5 in whatever your - // focal length units are. If we encounter a camera smaller than this, I guess the best - // we can do is arbitrarily scale the units of focal length in order to preserve the ratios - // of focal length and aperture, so that we get the correct projection - focalLengthScale = 2.5f / focalLength; - } - - // setting field of view last as some of the other commands alter it - fnCamera.setFocalLength( std::max( 2.5f, focalLengthScale * focalLength ) ); - fnCamera.setHorizontalFilmAperture( focalLengthScale * camera->getAperture()[0] * ( 1.0f / INCH_TO_MM ) ); - fnCamera.setVerticalFilmAperture( focalLengthScale * camera->getAperture()[1] * ( 1.0f / INCH_TO_MM ) ); - fnCamera.setHorizontalFilmOffset( focalLengthScale * camera->getApertureOffset()[0] * ( 1.0f / INCH_TO_MM ) ); - fnCamera.setVerticalFilmOffset( focalLengthScale * camera->getApertureOffset()[1] * ( 1.0f / INCH_TO_MM ) ); - } - else - { - fnCamera.setIsOrtho( true ); - - // Maya appears to only support a square aperture for ortho cameras. - // This means that if the stored aperture is rectangular, and you perform a vertical fit, - // you will will get an incorrect result. Doesn't look like I can do anything about this. - fnCamera.setOrthoWidth( camera->getAperture()[0] ); - - // Maya doesn't support aperture offsets on ortho cameras. In theory, we could try to translate - // into a transform on the camera, but this would make things more complicated - } - - if( camera->getFStop() != 0.0f ) - { - fnCamera.setDepthOfField( true ); - fnCamera.setFStop( std::max( 1.0f, camera->getFStop() ) ); - } - - fnCamera.setFocusDistance( camera->getFocusDistance() ); - - return true; -} diff --git a/src/IECoreMaya/ToMayaConverter.cpp b/src/IECoreMaya/ToMayaConverter.cpp deleted file mode 100644 index 9920e9352e..0000000000 --- a/src/IECoreMaya/ToMayaConverter.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaConverter.h" - -#include "IECore/Object.h" - -using namespace IECoreMaya; - -IE_CORE_DEFINERUNTIMETYPED( ToMayaConverter ); - -ToMayaConverter::ToMayaConverter( const std::string &description, IECore::TypeId supportedType ) - : IECore::FromCoreConverter( description, supportedType ) -{ -} - -ToMayaConverter::~ToMayaConverter() -{ -} diff --git a/src/IECoreMaya/ToMayaCurveConverter.cpp b/src/IECoreMaya/ToMayaCurveConverter.cpp deleted file mode 100644 index a92298ee42..0000000000 --- a/src/IECoreMaya/ToMayaCurveConverter.cpp +++ /dev/null @@ -1,203 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "boost/format.hpp" - -#include "maya/MFnNurbsCurve.h" -#include "maya/MPointArray.h" -#include "maya/MDoubleArray.h" - -#include "IECore/MessageHandler.h" -#include "IECore/CompoundParameter.h" -#include "IECoreScene/CurvesPrimitive.h" -#include "IECoreScene/PrimitiveVariable.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaCurveConverter.h" - -using namespace IECoreMaya; - -ToMayaCurveConverter::Description ToMayaCurveConverter::g_curvesDataDescription( IECoreScene::CurvesPrimitive::staticTypeId(), MFn::kNurbsCurveData ); -ToMayaCurveConverter::Description ToMayaCurveConverter::g_curvesDescription( IECoreScene::CurvesPrimitive::staticTypeId(), MFn::kNurbsCurve ); - -ToMayaCurveConverter::ToMayaCurveConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::CurvesPrimitive objects to a Maya object.", object) -{ - m_indexParameter = new IECore::IntParameter( "index", "The index of the curve to be converted.", 0 ); - parameters()->addParameter( m_indexParameter ); -} - - -IECore::IntParameterPtr ToMayaCurveConverter::indexParameter() -{ - return m_indexParameter; -} - -IECore::ConstIntParameterPtr ToMayaCurveConverter::indexParameter() const -{ - return m_indexParameter; -} - -bool ToMayaCurveConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - IECoreScene::ConstCurvesPrimitivePtr curves = IECore::runTimeCast( from ); - - assert( curves ); - - if ( !curves->arePrimitiveVariablesValid() || !curves->numCurves() ) - { - return false; - } - - int curveIndex = indexParameter()->getNumericValue(); - if( curveIndex < 0 || curveIndex >= (int)curves->numCurves() ) - { - IECore::msg( IECore::Msg::Warning,"ToMayaCurveConverter::doConversion", boost::format( "Invalid curve index \"%d\"") % curveIndex ); - return false; - } - - IECore::ConstV3fVectorDataPtr p = curves->variableData< IECore::V3fVectorData >( "P", IECoreScene::PrimitiveVariable::Vertex ); - if( !p ) - { - IECore::msg( IECore::Msg::Warning,"ToMayaCurveConverter::doConversion", "Curve has no \"P\" data" ); - return false; - - } - - const std::vector& verticesPerCurve = curves->verticesPerCurve()->readable(); - int curveBase = 0; - for( int i=0; ibasis() != IECore::CubicBasisf::linear() && !curves->periodic() ) - { - // Maya implicitly duplicates end points, so they're explicitly duplicated in the CurvePrimitives. - // We need to remove those duplicates when converting back to Maya. Remove 2 cvs at start, 2 at end. - if( numVertices < 8 ) - { - IECore::msg( IECore::Msg::Warning,"ToMayaCurveConverter::doConversion", "The Curve Primitive does not have enough CVs to be converted into a Maya Curve. Needs at least 8." ); - return false; - } - - cvOffset = 2; - } - - const std::vector& pts = p->readable(); - - // triple up the start points for cubic periodic curves: - if( curves->periodic() && curves->basis() != IECore::CubicBasisf::linear() ) - { - vertexArray.append( IECore::convert( pts[curveBase] ) ); - vertexArray.append( vertexArray[0] ); - } - - for( int i = cvOffset; i < numVertices-cvOffset; ++i ) - { - vertexArray.append( IECore::convert( pts[i + curveBase] ) ); - } - - // if the curve is periodic, the first N cvs must be identical to the last N cvs, where N is the degree - // of the curve: - if( curves->periodic() ) - { - if( curves->basis() == IECore::CubicBasisf::linear() ) - { - // linear: N = 1 - vertexArray.append( vertexArray[0] ); - } - else - { - // cubic: N = 3 - vertexArray.append( vertexArray[0] ); - vertexArray.append( vertexArray[1] ); - vertexArray.append( vertexArray[2] ); - } - } - - unsigned vertexArrayLength = vertexArray.length(); - - MDoubleArray knotSequences; - if( curves->basis() == IECore::CubicBasisf::linear() ) - { - for( unsigned i=0; i < vertexArrayLength; ++i ) - { - knotSequences.append( i ); - } - } - else - { - if( curves->periodic() ) - { - // Periodic curve, knots must be spaced out. - knotSequences.append( -1 ); - for( unsigned i=0; i < vertexArrayLength+1; ++i ) - { - knotSequences.append( i ); - } - } - else - { - // For a cubic curve, the first three and last three knots must be duplicated for the curve start/end to start at the first/last CV. - knotSequences.append( 0 ); - knotSequences.append( 0 ); - for( unsigned i=0; i < vertexArrayLength-2; ++i ) - { - knotSequences.append( i ); - } - knotSequences.append( vertexArrayLength-3 ); - knotSequences.append( vertexArrayLength-3 ); - } - } - - MFnNurbsCurve fnCurve; - fnCurve.create( vertexArray, knotSequences, curves->basis() == IECore::CubicBasisf::linear() ? 1 : 3, curves->periodic() ? MFnNurbsCurve::kPeriodic : MFnNurbsCurve::kOpen, false, false, to, &s ); - if (!s) - { - IECore::msg( IECore::Msg::Warning,"ToMayaCurveConverter::doConversion", s.errorString().asChar() ); - return false; - } - - return true; -} diff --git a/src/IECoreMaya/ToMayaGroupConverter.cpp b/src/IECoreMaya/ToMayaGroupConverter.cpp deleted file mode 100644 index 16b15f1caa..0000000000 --- a/src/IECoreMaya/ToMayaGroupConverter.cpp +++ /dev/null @@ -1,120 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MFnDagNode.h" -#include "maya/MFnTransform.h" - -#include "IECore/SimpleTypedData.h" -#include "IECoreScene/Group.h" -#include "IECoreScene/AttributeState.h" - -#include "IECoreMaya/ToMayaGroupConverter.h" -#include "IECoreMaya/Convert.h" - -using namespace IECoreMaya; - -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaGroupConverter::g_registrar( IECoreScene::Group::staticTypeId(), MFn::kTransform ); - -ToMayaGroupConverter::ToMayaGroupConverter( IECore::ConstObjectPtr object ) - : ToMayaObjectConverter( "Converts IECoreScene::Group objects to maya hierarchies.", object ) -{ -} - -bool ToMayaGroupConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - IECoreScene::ConstGroupPtr group = IECore::runTimeCast( from ); - if( !group ) - { - return false; - } - - // find the name of this group, if it has one: - std::string name; - IECoreScene::Group::StateContainer::const_iterator it = group->state().begin(); - IECoreScene::Group::StateContainer::const_iterator end = group->state().end(); - - for(; it != end; ++it ) - { - IECoreScene::ConstAttributeStatePtr attrs = IECore::runTimeCast< const IECoreScene::AttributeState >( *it ); - if( !attrs ) - { - continue; - } - - IECore::CompoundDataMap::const_iterator nameIt = attrs->attributes().find( "name" ); - if( nameIt == attrs->attributes().end() ) - { - continue; - } - - IECore::ConstStringDataPtr nameData = IECore::runTimeCast< const IECore::StringData >( nameIt->second ); - name = nameData->readable(); - - // we only need the characters following the final slash: - size_t lastSlashPos = name.rfind("/"); - if( lastSlashPos != std::string::npos ) - { - name = std::string( name.begin() + lastSlashPos + 1, name.end() ); - } - - break; - } - - MFnTransform fnTransform; - MObject oTransform = fnTransform.create( to ); - if( name != "" ) - { - fnTransform.setName( name.c_str() ); - } - - IECoreScene::ConstTransformPtr coreTransform = group->getTransform(); - if( coreTransform ) - { - Imath::M44f matrix = coreTransform->transform(); - fnTransform.set( MTransformationMatrix( IECore::convert( matrix ) ) ); - } - - for( IECoreScene::Group::ChildContainer::const_iterator it=group->children().begin(); it!=group->children().end(); it++ ) - { - ToMayaObjectConverterPtr converter = ToMayaObjectConverter::create( *it ); - if( !converter ) - { - continue; - } - MObject parent = oTransform; - converter->convert( parent ); - } - - return true; -} diff --git a/src/IECoreMaya/ToMayaImageConverter.cpp b/src/IECoreMaya/ToMayaImageConverter.cpp deleted file mode 100644 index 4a71227c20..0000000000 --- a/src/IECoreMaya/ToMayaImageConverter.cpp +++ /dev/null @@ -1,372 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include -#include - -#include "boost/multi_array.hpp" - -#include "IECore/CompoundParameter.h" -#include "IECore/DespatchTypedData.h" -#include "IECore/DataConvert.h" -#include "IECore/ScaledDataConversion.h" -#include "IECore/TypedData.h" -#include "IECore/VectorTypedData.h" - -#include "IECoreImage/ImagePrimitive.h" - -#include "IECoreMaya/ToMayaImageConverter.h" -#include "IECoreMaya/MImageAccessor.h" - -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreMaya; - -using std::string; -using std::vector; - -IE_CORE_DEFINERUNTIMETYPED( ToMayaImageConverter ); - -ToMayaImageConverter::ToMayaImageConverter( ConstImagePrimitivePtr image ) - : ToMayaConverter( "Converts image types.", (IECore::TypeId)IECoreImage::ImagePrimitiveTypeId ) -{ - srcParameter()->setValue( boost::const_pointer_cast( image ) ); - - IntParameter::PresetsContainer typePresets; - typePresets.push_back( IntParameter::Preset( "Float", Float ) ); - typePresets.push_back( IntParameter::Preset( "Byte", Byte ) ); - m_typeParameter = new IntParameter( - "type", - "Type of image to convert to", - Byte, - typePresets ); - - parameters()->addParameter( m_typeParameter ); -} - -IntParameterPtr ToMayaImageConverter::typeParameter() -{ - return m_typeParameter; -} - -ConstIntParameterPtr ToMayaImageConverter::typeParameter() const -{ - return m_typeParameter; -} - -template -struct ToMayaImageConverter::ChannelConverter -{ - typedef typename TypedData< std::vector >::Ptr ReturnType; - - const std::string &m_channelName; - - ChannelConverter( const std::string &channelName ) : m_channelName( channelName ) - { - } - - template - ReturnType operator()( typename T::Ptr data ) - { - assert( data ); - - return DataConvert < T, TypedData< std::vector >, ScaledDataConversion< typename T::ValueType::value_type, C> >() - ( - boost::static_pointer_cast( data ) - ); - }; - - struct ErrorHandler - { - template - void operator()( typename T::ConstPtr data, const F& functor ) - { - assert( data ); - - throw InvalidArgumentException( ( boost::format( "ToMayaImageConverter: Invalid data type \"%s\" for channel \"%s\"." ) % Object::typeNameFromTypeId( data->typeId() ) % functor.m_channelName ).str() ); - } - }; -}; - -template -void ToMayaImageConverter::writeChannel( MImage &image, typename TypedData< std::vector >::Ptr channelData, unsigned channelOffset, unsigned numChannels ) const -{ - assert( channelOffset < numChannels ); - - ConstImagePrimitivePtr toConvert = runTimeCast( srcParameter()->getValidatedValue() ); - assert( toConvert ); - - unsigned width, height; - image.getSize( width, height ); - - const Imath::Box2i &dataWindow = toConvert->getDataWindow(); - const Imath::Box2i &displayWindow = toConvert->getDisplayWindow(); - - unsigned int dataWidth = dataWindow.size().x + 1; - unsigned int dataHeight = dataWindow.size().y + 1; - - Imath::V2i dataOffset = dataWindow.min - displayWindow.min ; - - boost::multi_array_ref< const T, 2 > src( &channelData->readable()[0], boost::extents[dataHeight][dataWidth] ); - boost::multi_array_ref< T, 3 > dst( MImageAccessor::getPixels( image ), boost::extents[ height ][ width ][ numChannels ] ); - - for ( unsigned x = 0; x < dataWidth; x++ ) - { - for ( unsigned y = 0; y < dataHeight; y++ ) - { - /// Vertical flip, to match Maya - dst[ ( height - 1 ) - ( y + dataOffset.y ) ][ x + dataOffset.x ][channelOffset] = src[y][x]; - } - } -} - -template -void ToMayaImageConverter::writeAlpha( MImage &image, const T &alpha ) const -{ - const int numChannels = 4; - const int channelOffset = 3; - - unsigned width, height; - image.getSize( width, height ); - - boost::multi_array_ref< T, 3 > dst( MImageAccessor::getPixels( image ), boost::extents[ height ][ width ][ numChannels ] ); - - for ( unsigned x = 0; x < width; x++ ) - { - for ( unsigned y = 0; y < height; y++ ) - { - dst[y][x][channelOffset] = alpha; - } - } -} - -void ToMayaImageConverter::writeDepth( MImage &image, FloatVectorDataPtr channelData ) const -{ - assert( channelData ); - ConstImagePrimitivePtr toConvert = runTimeCast( srcParameter()->getValidatedValue() ); - assert( toConvert ); - - unsigned width, height; - MStatus s = image.getSize( width, height ); - assert( s ); - - const Imath::Box2i &dataWindow = toConvert->getDataWindow(); - const Imath::Box2i &displayWindow = toConvert->getDisplayWindow(); - - unsigned int dataWidth = dataWindow.size().x + 1; - unsigned int dataHeight = dataWindow.size().y + 1; - - Imath::V2i dataOffset = dataWindow.min - displayWindow.min ; - - boost::multi_array_ref< const float, 2 > src( &channelData->readable()[0], boost::extents[dataHeight][dataWidth] ); - - std::vector depth; - depth.resize( height * width, 0 ); - boost::multi_array_ref< float, 2 > dst( &depth[0], boost::extents[ height ][ width ] ); - - for ( unsigned x = 0; x < dataWidth; x++ ) - { - for ( unsigned y = 0; y < dataHeight; y++ ) - { - /// Vertical flip, to match Maya - dst[ ( height - 1 ) - ( y + dataOffset.y ) ][ x + dataOffset.x ] = src[y][x]; - } - } - - s = image.setDepthMap( &depth[0], width, height ); - assert( s ); - assert( image.depth() ); -#ifndef NDEBUG - unsigned depthWidth = 0, depthHeight = 0; - s = image.getDepthMapSize( depthWidth, depthHeight ); - assert( s ); - assert( depthWidth == width ); - assert( depthHeight == height ); -#endif -} - -MStatus ToMayaImageConverter::convert( MImage &image ) const -{ - MStatus s; - ConstImagePrimitivePtr toConvert = runTimeCast( srcParameter()->getValidatedValue() ); - assert( toConvert ); - - unsigned int width = toConvert->getDisplayWindow().size().x + 1; - unsigned int height = toConvert->getDisplayWindow().size().y + 1; - - MImage::MPixelType pixelType = MImage::kUnknown; - switch( typeParameter()->getNumericValue() ) - { - case Float : - pixelType = MImage::kFloat; - break; - case Byte: - pixelType = MImage::kByte; - break; - default : - - assert( false ); - } - - /// Get the channels RGBA at the front, in that order, if they exist - vector desiredChannelOrder; - desiredChannelOrder.push_back( "R" ); - desiredChannelOrder.push_back( "G" ); - desiredChannelOrder.push_back( "B" ); - desiredChannelOrder.push_back( "A" ); - - vector channelNames; - for( const auto &channel : toConvert->channels ) - { - channelNames.push_back( channel.first ); - } - - vector filteredNames; - - int rgbChannelsFound = 0; - bool haveAlpha = false; - for ( vector::const_iterator it = desiredChannelOrder.begin(); it != desiredChannelOrder.end(); ++it ) - { - vector::iterator res = find( channelNames.begin(), channelNames.end(), *it ); - if ( res != channelNames.end() ) - { - if ( *it == "A" ) - { - haveAlpha = true; - } - else - { - rgbChannelsFound ++; - } - channelNames.erase( res ); - filteredNames.push_back( *it ); - } - } - channelNames = filteredNames; - - if ( rgbChannelsFound != 3 ) - { - return MS::kFailure; - } - - unsigned numChannels = 4; // We always add an alpha if one is not present. - - /// \todo We could optimise here by not recreating the image if the existing one matches our exact requirements - s = image.create( width, height, numChannels, pixelType ); - if ( !s ) - { - return s; - } - - image.setRGBA( true ); - - unsigned channelOffset = 0; - for ( vector::const_iterator it = channelNames.begin(); it != channelNames.end(); ++it, ++channelOffset ) - { - DataPtr dataContainer = toConvert->channels.find( *it )->second; - assert( dataContainer ); - - switch( pixelType ) - { - case MImage::kFloat : - { - ChannelConverter converter( *it ); - FloatVectorDataPtr channelData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( dataContainer.get(), converter ); - - writeChannel( image, channelData, channelOffset, numChannels ); - } - - break; - case MImage::kByte: - { - ChannelConverter converter( *it ); - UCharVectorDataPtr channelData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( dataContainer.get(), converter ); - - writeChannel( image, channelData, channelOffset, numChannels ); - } - - break; - default : - - assert( false ); - } - } - - if ( !haveAlpha ) - { - switch( pixelType ) - { - case MImage::kFloat : - { - writeAlpha( image, 1.0 ); - } - break; - case MImage::kByte : - { - writeAlpha( image, 255 ); - } - break; - default : - - assert( false ); - } - } - - const auto it = toConvert->channels.find( "Z" ); - if ( it != toConvert->channels.end() ) - { - DataPtr dataContainer = it->second; - assert( dataContainer ); - - ChannelConverter converter( "Z" ); - FloatVectorDataPtr channelData = despatchTypedData< - ChannelConverter, - TypeTraits::IsNumericVectorTypedData, - ChannelConverter::ErrorHandler - >( dataContainer.get(), converter ); - - writeDepth( image, channelData ); - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/ToMayaLocatorConverter.cpp b/src/IECoreMaya/ToMayaLocatorConverter.cpp deleted file mode 100644 index 9c648ba960..0000000000 --- a/src/IECoreMaya/ToMayaLocatorConverter.cpp +++ /dev/null @@ -1,155 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MDagPath.h" -#include "maya/MDagModifier.h" -#include "maya/MFnDagNode.h" -#include "maya/MSelectionList.h" -#include "maya/MFnTransform.h" -#include "maya/MPlug.h" - -#include "Imath/ImathMatrixAlgo.h" - -#include "IECore/AngleConversion.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECoreScene/CoordinateSystem.h" -#include "IECoreScene/MatrixTransform.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaLocatorConverter.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -ToMayaLocatorConverter::Description ToMayaLocatorConverter::g_description( IECoreScene::CoordinateSystem::staticTypeId(), MFn::kLocator ); - -ToMayaLocatorConverter::ToMayaLocatorConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::CoordinateSystem objects to Maya locators.", object ) -{ -} - -bool ToMayaLocatorConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - ConstCoordinateSystemPtr coordSys = IECore::runTimeCast( from ); - if ( !coordSys ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "The source object is not an IECoreScene::CoordinateSystem." ); - return false; - } - - // check if incoming object is a locator itself - MObject locatorObj; - if ( to.hasFn( MFn::kLocator ) ) - { - locatorObj = to; - } - - // check if incoming object is a parent of an existing locator - if ( locatorObj.isNull() ) - { - MFnDagNode fnTo( to ); - for ( unsigned i=0; i < fnTo.childCount(); ++i ) - { - MObject child = fnTo.child( i ); - if ( child.hasFn( MFn::kLocator ) ) - { - locatorObj = child; - break; - } - } - } - - // make a new locator and parent it to the incoming object - if ( locatorObj.isNull() ) - { - if ( !MFnTransform().hasObj( to ) ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to create a locator as a child of the input object." ); - return false; - } - - MDagModifier dagMod; - locatorObj = dagMod.createNode( "locator", to ); - dagMod.renameNode( locatorObj, coordSys->getName().c_str() ); - if ( !dagMod.doIt() ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to modify the DAG correctly." ); - dagMod.undoIt(); - return false; - } - } - - if ( locatorObj.isNull() ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to find or create a locator from the input object." ); - return false; - } - - MFnDagNode fnLocator( locatorObj ); - - Imath::M44f m; - const IECoreScene::Transform* transform = coordSys->getTransform(); - if( transform ) - { - m = transform->transform(); - } - Imath::V3f s(0), h(0), r(0), t(0); - Imath::extractSHRT(m, s, h, r, t); - - /// obtain local position and scale from locator - MStatus st; - MPlug positionPlug = fnLocator.findPlug( "localPositionX", false, &st ); - if ( !st ) return false; - positionPlug.setValue(t[0]); - positionPlug = fnLocator.findPlug( "localPositionY", false, &st ); - if ( !st ) return false; - positionPlug.setValue(t[1]); - positionPlug = fnLocator.findPlug( "localPositionZ", false, &st ); - if ( !st ) return false; - positionPlug.setValue(t[2]); - - MPlug scalePlug = fnLocator.findPlug( "localScaleX", false, &st ); - if ( !st ) return false; - scalePlug.setValue(s[0]); - scalePlug = fnLocator.findPlug( "localScaleY", false, &st ); - if ( !st ) return false; - scalePlug.setValue(s[1]); - scalePlug = fnLocator.findPlug( "localScaleZ", false, &st ); - if ( !st ) return false; - scalePlug.setValue(s[2]); - - return true; -} diff --git a/src/IECoreMaya/ToMayaMatrixDataConverter.cpp b/src/IECoreMaya/ToMayaMatrixDataConverter.cpp deleted file mode 100644 index bdd9b06ac4..0000000000 --- a/src/IECoreMaya/ToMayaMatrixDataConverter.cpp +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/SimpleTypedData.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/MArrayTraits.h" -#include "IECoreMaya/ToMayaMatrixDataConverter.h" - -#include "maya/MFnMatrixData.h" - -using namespace IECoreMaya; - -template -ToMayaObjectConverter::ToMayaObjectConverterDescription > ToMayaMatrixDataConverter::g_description( F::staticTypeId(), MFn::kMatrixData ); - -template -ToMayaMatrixDataConverter::ToMayaMatrixDataConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECore::M44*Data objects to a Maya object.", object ) -{ -} - -template -bool ToMayaMatrixDataConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - typename F::ConstPtr data = IECore::runTimeCast( from ); - if( !data ) - { - return false; - } - - const typename F::ValueType &coreMatrix = data->readable(); - MMatrix mayaMatrix = IECore::convert( coreMatrix ); - - MFnMatrixData fnMD; - to = fnMD.create( mayaMatrix, &s ); - - return s; -} - -template class ToMayaMatrixDataConverter; -template class ToMayaMatrixDataConverter; diff --git a/src/IECoreMaya/ToMayaMatrixVectorDataConverter.cpp b/src/IECoreMaya/ToMayaMatrixVectorDataConverter.cpp deleted file mode 100644 index 189f9af7aa..0000000000 --- a/src/IECoreMaya/ToMayaMatrixVectorDataConverter.cpp +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/ToMayaMatrixVectorDataConverter.h" - -#include "maya/MDoubleArray.h" -#include "maya/MFnDoubleArrayData.h" - -using namespace IECoreMaya; - -template -ToMayaObjectConverter::ToMayaObjectConverterDescription > ToMayaMatrixVectorDataConverter::g_description( F::staticTypeId(), MFn::kDoubleArrayData ); - -template -ToMayaMatrixVectorDataConverter::ToMayaMatrixVectorDataConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECore::M44*VectorData objects to a Maya object.", object ) -{ -} - -template -bool ToMayaMatrixVectorDataConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - typename F::ConstPtr data = IECore::runTimeCast( from ); - if( !data ) - { - return false; - } - - MFnDoubleArrayData fnData; - - const typename F::ValueType &v = data->readable(); - - MDoubleArray array; - array.setLength( v.size() * 16 ); - - for ( unsigned i=0; i < v.size(); i++ ) - { - for ( unsigned j=0; j < 4; j++ ) - { - for ( unsigned k=0; k < 4; k++ ) - { - array[ i*16 + j*4 + k ] = (double)v[i][j][k]; - } - } - } - - to = fnData.create( array, &s ); - - return s; -} - -template class ToMayaMatrixVectorDataConverter; -template class ToMayaMatrixVectorDataConverter; diff --git a/src/IECoreMaya/ToMayaMeshConverter.cpp b/src/IECoreMaya/ToMayaMeshConverter.cpp deleted file mode 100644 index 39fb938e4c..0000000000 --- a/src/IECoreMaya/ToMayaMeshConverter.cpp +++ /dev/null @@ -1,536 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "boost/format.hpp" - -#include "maya/MDagPath.h" -#include "maya/MFnMeshData.h" -#include "maya/MFnMesh.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MPointArray.h" -#include "maya/MFloatPointArray.h" -#include "maya/MFloatVectorArray.h" -#include "maya/MFloatArray.h" -#include "maya/MIntArray.h" -#include "maya/MItMeshPolygon.h" -#include "maya/MGlobal.h" -#include "maya/MPlug.h" -#include "maya/MFnEnumAttribute.h" -#include "maya/MUintArray.h" -#include "maya/MItMeshVertex.h" - -#include "IECore/MessageHandler.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/PrimitiveVariable.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaMeshConverter.h" -#include "IECoreMaya/FromMayaMeshConverter.h" - -using namespace IECoreMaya; - -ToMayaMeshConverter::Description ToMayaMeshConverter::g_meshDataDescription( IECoreScene::MeshPrimitive::staticTypeId(), MFn::kMeshData ); -ToMayaMeshConverter::Description ToMayaMeshConverter::g_meshDescription( IECoreScene::MeshPrimitive::staticTypeId(), MFn::kMesh ); - -ToMayaMeshConverter::ToMayaMeshConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::MeshPrimitive objects to a Maya object.", object) -{ -} - -void ToMayaMeshConverter::assignDefaultShadingGroup( MObject &shape ) const -{ - MFnDagNode fnDN( shape ); - // it would perhaps be preferable to use MFnSet::addMember() instead but at the time of - // writing (maya 2010) that seems to print out "Result : initialShadingGroup" totally unnecessarily. - MGlobal::executeCommand( "sets -addElement initialShadingGroup " + fnDN.fullPathName() ); -} - -void ToMayaMeshConverter::addUVSet( MFnMesh &fnMesh, const MIntArray &polygonCounts, const IECoreScene::MeshPrimitive *mesh, IECoreScene::PrimitiveVariableMap::const_iterator &uvIt ) const -{ - // Maya's default UV set is named "map1" instead of "uv" - MString uvSetName = uvIt->first == "uv" ? "map1" : uvIt->first.c_str(); - - if( uvIt->second.interpolation != IECoreScene::PrimitiveVariable::FaceVarying ) - { - IECore::msg( IECore::Msg::Warning,"ToMayaMeshConverter::doConversion", boost::format( "PrimitiveVariable \"%s\" has unsupported interpolation (expected FaceVarying).") % uvSetName.asChar() ); - return; - } - - const IECore::V2fVectorData *uvData = IECore::runTimeCast( uvIt->second.data.get() ); - if ( !uvData ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", boost::format( "PrimitiveVariable \"%s\" has unsupported type \"%s\"." ) % uvSetName.asChar() % uvIt->second.data->typeName() ); - return; - } - - bool setExists = false; - MStringArray existingSets; - fnMesh.getUVSetNames( existingSets ); - for ( unsigned i=0; i < existingSets.length(); ++i ) - { - if( uvSetName == existingSets[i] ) - { - fnMesh.clearUVs( &uvSetName ); - setExists = true; - break; - } - } - - if ( !setExists ) - { - MDagPath dag; - MStatus s = fnMesh.getPath( dag ); - if ( s ) - { - fnMesh.createUVSetWithName( uvSetName ); - } - else - { - fnMesh.createUVSetDataMeshWithName( uvSetName ); - } - } - - const std::vector &uvs = uvData->readable(); - - MIntArray uvIds; - MFloatArray uArray; - MFloatArray vArray; - - if( uvIt->second.indices ) - { - const std::vector &indices = uvIt->second.indices->readable(); - size_t numIndices = indices.size(); - uvIds.setLength( numIndices ); - for( size_t i = 0; i < numIndices; ++i ) - { - uvIds[i] = indices[i]; - } - - size_t numUVs = uvs.size(); - uArray.setLength( numUVs ); - vArray.setLength( numUVs ); - for( size_t i = 0; i < numUVs; ++i ) - { - uArray[i] = uvs[i][0]; - vArray[i] = uvs[i][1]; - } - } - else - { - // If for some reason we cannot find the uv indices, set the UVs using the old way - // the performances in maya won't be good (for weigth painting in particular) - // We've already guaranteed that the data is FaceVarying above. - - size_t numUVs = uvs.size(); - uvIds.setLength( numUVs ); - uArray.setLength( numUVs ); - vArray.setLength( numUVs ); - - for( size_t i = 0; i < numUVs; ++i ) - { - uvIds[i] = i; - uArray[i] = uvs[i][0]; - vArray[i] = uvs[i][1]; - } - } - - MStatus s = fnMesh.setUVs( uArray, vArray, &uvSetName ); - if ( !s ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Failed to set UVs." ); - return; - } - s = fnMesh.assignUVs( polygonCounts, uvIds, &uvSetName ); - if ( !s ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Failed to assign UVs." ); - return; - } -} - -bool ToMayaMeshConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - IECoreScene::ConstMeshPrimitivePtr mesh = IECore::runTimeCast( from ); - assert( mesh ); - - if ( !mesh->arePrimitiveVariablesValid() ) - { - return false; - } - - MFloatPointArray vertexArray; - MIntArray polygonCounts; - MIntArray polygonConnects; - - MFnMesh fnMesh; - - int numVertices = 0; - IECoreScene::PrimitiveVariableMap::const_iterator it = mesh->variables.find("P"); - if ( it != mesh->variables.end() ) - { - /// \todo Employ some M*Array converters to simplify this - IECore::ConstV3fVectorDataPtr p = IECore::runTimeCast(it->second.data); - if (p) - { - numVertices = p->readable().size(); - - vertexArray.setLength( numVertices ); - for (int i = 0; i < numVertices; i++) - { - vertexArray[i] = IECore::convert( p->readable()[i] ); - } - } - else - { - IECore::ConstV3dVectorDataPtr p = IECore::runTimeCast(it->second.data); - if (p) - { - numVertices = p->readable().size(); - - vertexArray.setLength( numVertices ); - for (int i = 0; i < numVertices; i++) - { - vertexArray[i] = IECore::convert( p->readable()[i] ); - } - } - else - { - // "P" is not convertible to an array of "points" - return false; - } - } - } - - - IECore::ConstIntVectorDataPtr verticesPerFace = mesh->verticesPerFace(); - assert( verticesPerFace ); - int numPolygons = verticesPerFace->readable().size(); - - polygonCounts.setLength( numPolygons ); - for (int i = 0; i < numPolygons; i++) - { - polygonCounts[i] = verticesPerFace->readable()[i]; - } - - IECore::ConstIntVectorDataPtr vertexIds = mesh->vertexIds(); - assert( vertexIds ); - int numPolygonConnects = vertexIds->readable().size(); - polygonConnects.setLength( numPolygonConnects ); - for (int i = 0; i < numPolygonConnects; i++) - { - polygonConnects[i] = vertexIds->readable()[i]; - } - - MObject mObj = fnMesh.create( numVertices, numPolygons, vertexArray, polygonCounts, polygonConnects, to, &s ); - - if (!s) - { - return false; - } - - it = mesh->variables.find("N"); - if ( it != mesh->variables.end() ) - { - if (it->second.interpolation == IECoreScene::PrimitiveVariable::FaceVarying ) - { - /// \todo Employ some M*Array converters to simplify this - MVectorArray vertexNormalsArray; - IECore::ConstV3fVectorDataPtr n = IECore::runTimeCast(it->second.data); - if (n) - { - IECoreScene::PrimitiveVariable::IndexedView normalView = IECoreScene::PrimitiveVariable::IndexedView( it->second ); - vertexNormalsArray.setLength( normalView.size() ); - - size_t i = 0; - for(const auto& normal : normalView) - { - vertexNormalsArray[i++] = IECore::convert( normal ); - } - } - else - { - IECore::ConstV3dVectorDataPtr n = IECore::runTimeCast(it->second.data); - if (n) - { - IECoreScene::PrimitiveVariable::IndexedView normalView = IECoreScene::PrimitiveVariable::IndexedView( it->second ); - vertexNormalsArray.setLength( normalView.size() ); - - size_t i = 0; - for(const auto& normal : normalView) - { - vertexNormalsArray[i++] = IECore::convert( normal ); - } - } - else - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", boost::format( "PrimitiveVariable \"N\" has unsupported type \"%s\"." ) % it->second.data->typeName() ); - } - } - - if ( vertexNormalsArray.length() ) - { - MStatus status; - MItMeshPolygon itPolygon( mObj, &status ); - if( status != MS::kSuccess ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Failed to create mesh iterator" ); - } - - unsigned v = 0; - MIntArray vertexIds; - MIntArray faceIds; - - for ( ; !itPolygon.isDone(); itPolygon.next() ) - { - for ( v=0; v < itPolygon.polygonVertexCount(); ++v ) - { - faceIds.append( itPolygon.index() ); - vertexIds.append( itPolygon.vertexIndex( v ) ); - } - } - - if( !fnMesh.setFaceVertexNormals( vertexNormalsArray, faceIds, vertexIds ) ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Setting normals failed" ); - } - } - } - else - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "PrimitiveVariable \"N\" has unsupported interpolation (expected FaceVarying)." ); - } - } - - /// Add UV sets - for ( it = mesh->variables.begin(); it != mesh->variables.end(); ++it ) - { - if( const IECore::V2fVectorData *data = IECore::runTimeCast( it->second.data.get() ) ) - { - if( data->getInterpretation() == IECore::GeometricData::UV ) - { - addUVSet( fnMesh, polygonCounts, mesh.get(), it ); - } - } - } - - /// Add corners and edge creases - - MUintArray cornerIdsMaya; - MDoubleArray cornerSharpnessMaya; - - const IECore::IntVectorData *cornerIdsData = mesh->cornerIds(); - const std::vector &cornerIds = cornerIdsData->readable(); - - if( !cornerIds.empty() ) - { - const IECore::FloatVectorData *cornerSharpnessesData = mesh->cornerSharpnesses(); - const std::vector &cornerSharpnesses = cornerSharpnessesData->readable(); - - for( size_t i = 0; i < cornerIds.size(); ++i ) - { - cornerIdsMaya.append( cornerIds[i] ); - cornerSharpnessMaya.append( cornerSharpnesses[i] ); - } - - s = fnMesh.setCreaseVertices( cornerIdsMaya, cornerSharpnessMaya ); - if( !s ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", boost::format( "Failed to set crease vertices with message: %s" ) % s.errorString().asChar() ); - } - } - - MUintArray edgeIdsMaya; - MDoubleArray creaseSharpnessMaya; - - const IECore::IntVectorData *creaseIdsData = mesh->creaseIds(); - const std::vector &creaseIds = creaseIdsData->readable(); - - if( !creaseIds.empty() ) - { - const IECore::FloatVectorData *creaseSharpnessesData = mesh->creaseSharpnesses(); - const std::vector &creaseSharpnesses = creaseSharpnessesData->readable(); - - const IECore::IntVectorData *creaseLengthsData = mesh->creaseLengths(); - const std::vector &creaseLengths = creaseLengthsData->readable(); - - // Cortex stores vertex ids to specify creases. Maya uses edge ids - // instead. The following handles the conversion. - - MItMeshVertex vertexIt( mObj ); - - int offset = 0; - for( size_t i = 0; i < creaseLengths.size(); ++i ) - { - if( creaseSharpnesses[i] == 0 ) - { - continue; - } - - int length = creaseLengths[i]; - - for( int j = 1; j < length; ++j ) - { - int vertexId1 = creaseIds[offset + j - 1]; - int vertexId2 = creaseIds[offset + j]; - - int previousIdx; // we don't need this - - MIntArray connectedEdges; - vertexIt.setIndex( vertexId1, previousIdx ); - vertexIt.getConnectedEdges( connectedEdges ); - - bool found = false; - for( size_t edgeIdIdx = 0; edgeIdIdx < connectedEdges.length(); ++edgeIdIdx ) - { - int oppositeVertexId; - vertexIt.getOppositeVertex( oppositeVertexId, connectedEdges[edgeIdIdx] ); - - if( vertexId2 == oppositeVertexId ) - { - found = true; - edgeIdsMaya.append( connectedEdges[edgeIdIdx] ); - creaseSharpnessMaya.append( creaseSharpnesses[i] ); - break; - } - } - - if( !found ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", boost::format( "Failed to find edge for vertex pair (%i, %i)" ) % vertexId1 % vertexId2 ); - } - } - - offset += length; - } - - if( !fnMesh.setCreaseEdges( edgeIdsMaya, creaseSharpnessMaya ) ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Failed to set crease edges" ); - } - } - - /// If we're making a mesh node (rather than a mesh data) then make sure it belongs - /// to the default shading group and add the ieMeshInterpolation attribute. - MObject oMesh = fnMesh.object(); - if( oMesh.apiType()==MFn::kMesh ) - { - assignDefaultShadingGroup( oMesh ); - setMeshInterpolationAttribute( oMesh, mesh->interpolation() ); - } - - /// \todo Other primvars, e.g. vertex color ("Cs") - - return true; -} - -bool ToMayaMeshConverter::setMeshInterpolationAttribute( MObject &object, std::string interpolation ) -{ - MStatus st; - MFnDependencyNode fnDep(object, &st); - if ( !st ) - { - return false; - } - - int interpolationValue = 0; - - FromMayaMeshConverter fromMaya(object); - const IECore::Parameter::PresetsContainer &presets = fromMaya.interpolationParameter()->getPresets(); - IECore::Parameter::PresetsContainer::const_iterator it; - - if ( interpolation != "default" ) - { - int index = 0; - - for ( it = presets.begin(); it != presets.end(); it++, index++ ) - { - if ( interpolation == it->first || interpolation == boost::static_pointer_cast< IECore::StringData >(it->second)->readable() ) - { - interpolationValue = index; - break; - } - } - if ( it == presets.end() ) - { - return false; - } - } - - MPlug interpPlug = fnDep.findPlug( "ieMeshInterpolation", false, &st ); - - if ( !st ) - { - MFnEnumAttribute fnAttrib; - MObject newAttr = fnAttrib.create( "ieMeshInterpolation", "interp", 0, &st ); - if ( !st ) - { - return false; - } - - int index = 0; - for ( it = presets.begin(); it != presets.end(); it++ ) - { - if ( it->first == "default" ) - { - continue; - } - fnAttrib.addField( it->first.c_str(), index ); - index++; - } - - // looks like the attribute does not exist yet.. - st = fnDep.addAttribute( newAttr ); - if ( !st ) - { - return false; - } - interpPlug = fnDep.findPlug( "ieMeshInterpolation", false, &st ); - if ( !st ) - { - return false; - } - } - - st = interpPlug.setValue( interpolationValue ); - if ( !st ) - { - return false; - } - - return true; -} diff --git a/src/IECoreMaya/ToMayaNumericDataConverter.cpp b/src/IECoreMaya/ToMayaNumericDataConverter.cpp deleted file mode 100644 index 856e0f2f9c..0000000000 --- a/src/IECoreMaya/ToMayaNumericDataConverter.cpp +++ /dev/null @@ -1,173 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaNumericDataConverter.h" - -#include "IECore/SimpleTypedData.h" - -#include "maya/MFn.h" -#include "maya/MFnNumericData.h" - -#include - -using namespace IECoreMaya; -using namespace IECore; -using namespace std; -using namespace Imath; -using namespace boost; - -// 3d vector conversion -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_3Double( V3dDataTypeId, MFn::kData3Double ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_3Float( V3fDataTypeId, MFn::kData3Float ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_3Int( V3iDataTypeId, MFn::kData3Int ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_3Short( V3iDataTypeId, MFn::kData3Short ); - -// 2d vector conversion -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_2Double( V2dDataTypeId, MFn::kData2Double ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_2Float( V2fDataTypeId, MFn::kData2Float ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_2Int( V2iDataTypeId, MFn::kData2Int ); -ToMayaObjectConverter::ToMayaObjectConverterDescription ToMayaNumericDataConverter::g_2Short( V2iDataTypeId, MFn::kData2Short ); - - -ToMayaNumericDataConverter::ToMayaNumericDataConverter( ConstObjectPtr object ) - : ToMayaObjectConverter( "Converts IECore::Data types to maya numeric data objects.", object ) -{ -} - -bool ToMayaNumericDataConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - MFnNumericData fnData( to, &s ); - - switch ( fnData.numericType() ) - { - case MFnNumericData::k2Short: - { - ConstV2iDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( (short)data->readable().x, (short)data->readable().y ); - return (s); - } - case MFnNumericData::k3Short: - { - ConstV3iDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( (short)data->readable().x, (short)data->readable().y, (short)data->readable().z ); - return (s); - } - case MFnNumericData::k2Int: - { - ConstV2iDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( (int)data->readable().x, (int)data->readable().y ); - return (s); - } - case MFnNumericData::k3Int: - { - ConstV3iDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( (int)data->readable().x, (int)data->readable().y, (int)data->readable().z ); - return (s); - } - case MFnNumericData::k2Float: - { - ConstV2fDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( data->readable().x, data->readable().y ); - return (s); - } - case MFnNumericData::k3Float: - { - ConstV3fDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( data->readable().x, data->readable().y, data->readable().z ); - return (s); - } - case MFnNumericData::k2Double: - { - ConstV2dDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( data->readable().x, data->readable().y ); - return (s); - } - case MFnNumericData::k3Double: - { - ConstV3dDataPtr data = runTimeCast( from ); - if (data == 0) - { - return false; - } - - s = fnData.setData( data->readable().x, data->readable().y, data->readable().z ); - return (s); - } - case MFnNumericData::kDouble: - case MFnNumericData::kFloat: - case MFnNumericData::kInt: - case MFnNumericData::kBoolean: - case MFnNumericData::kByte: - case MFnNumericData::kChar: - case MFnNumericData::kShort: - default: - return false; - } -} diff --git a/src/IECoreMaya/ToMayaObjectConverter.cpp b/src/IECoreMaya/ToMayaObjectConverter.cpp deleted file mode 100644 index 64dba47221..0000000000 --- a/src/IECoreMaya/ToMayaObjectConverter.cpp +++ /dev/null @@ -1,117 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ToMayaObjectConverter.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/CompoundData.h" - -#include - -using namespace IECoreMaya; -using namespace IECore; - -IE_CORE_DEFINERUNTIMETYPED( ToMayaObjectConverter ); - -ToMayaObjectConverter::ToMayaObjectConverter( const std::string &description, ConstObjectPtr object ) - : ToMayaConverter( description, IECore::ObjectTypeId ) -{ - srcParameter()->setValue( boost::const_pointer_cast( object ) ); -} - -bool ToMayaObjectConverter::convert( MObject &object ) const -{ - ConstCompoundObjectPtr operands = parameters()->getTypedValidatedValue(); - return doConversion( srcParameter()->getValidatedValue(), object, operands ); -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -ToMayaObjectConverterPtr ToMayaObjectConverter::create( ConstObjectPtr object ) -{ - const TypesToFnsMap *m = typesToFns(); - TypesToFnsMap::const_iterator it = m->find( Types( object->typeId(), MFn::kInvalid ) ); - if( it!=m->end() ) - { - return it->second( object ); - } - return 0; -} - -ToMayaObjectConverterPtr ToMayaObjectConverter::create( ConstObjectPtr object, MFn::Type resultType ) -{ - const TypesToFnsMap *m = typesToFns(); - TypesToFnsMap::const_iterator it = m->find( Types( object->typeId(), resultType ) ); - if( it!=m->end() ) - { - return it->second( object ); - } - return 0; -} - -void ToMayaObjectConverter::registerConverter( IECore::TypeId fromType, const MFn::Type resultType, CreatorFn creator ) -{ - TypesToFnsMap *m = typesToFns(); - m->insert( TypesToFnsMap::value_type( Types( fromType, resultType ), creator ) ); - m->insert( TypesToFnsMap::value_type( Types( fromType, MFn::kInvalid ), creator ) ); // for the create function which doesn't care about resultType -} - -ToMayaObjectConverter::TypesToFnsMap *ToMayaObjectConverter::typesToFns() -{ - static TypesToFnsMap *m = new TypesToFnsMap; - return m; -} - -///////////////////////////////////////////////////////////////////////////////// -// Implementation of nested Types class -///////////////////////////////////////////////////////////////////////////////// - -ToMayaObjectConverter::Types::Types( IECore::TypeId from, MFn::Type result ) - : fromType( from ), resultType( result ) -{ -} - -bool ToMayaObjectConverter::Types::operator < ( const Types &other ) const -{ - if( fromType != other.fromType ) - { - return fromType < other.fromType; - } - else - { - return resultType < other.resultType; - } -} diff --git a/src/IECoreMaya/ToMayaParticleConverter.cpp b/src/IECoreMaya/ToMayaParticleConverter.cpp deleted file mode 100644 index 32504567ce..0000000000 --- a/src/IECoreMaya/ToMayaParticleConverter.cpp +++ /dev/null @@ -1,200 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MSelectionList.h" -#include "maya/MDGModifier.h" -#include "maya/MGlobal.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MPlug.h" -#include "maya/MPointArray.h" - -#include "IECoreScene/PointsPrimitive.h" - -#include "IECoreMaya/ToMayaParticleConverter.h" -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/MArrayIter.h" - -using namespace std; -using namespace Imath; -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreMaya; - -ToMayaParticleConverter::Description ToMayaParticleConverter::g_description( IECoreScene::PointsPrimitive::staticTypeId(), MFn::kParticle ); - -ToMayaParticleConverter::ToMayaParticleConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::Primitive objects to Maya particle shapes.", object ) -{ -} - -bool ToMayaParticleConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - IECoreScene::ConstPrimitivePtr primitive = IECore::runTimeCast( from ); - if( !primitive ) - { - return false; - } - - if( !primitive->arePrimitiveVariablesValid() ) - { - return false; - } - - // get the position primitive variable and abort if it's not there - ConstDataPtr p = primitive->variableData( "P", PrimitiveVariable::Vertex ); - if( !p ) - { - // accept "position" so we can convert the results of the PDCParticleReader without having - // to rename things - p = primitive->variableData( "position", PrimitiveVariable::Vertex ); - if( !p ) - { - return false; - } - } - if( !p->isInstanceOf( V3fVectorDataTypeId ) && !p->isInstanceOf( V3dVectorDataTypeId ) ) - { - return false; - } - - // get/make a particle shape. - // if we've been passed a particle system then we'll update it. - // if we're passed a parent then we'll create one under it. - // if we're passed nothing then we'll create our own parent. - MFnParticleSystem fnPS; - if( !fnPS.hasObj( to ) ) - { - to = fnPS.create( to ); - } - - // emit a particle for each position. it is much faster to emit - // them all at once from an array than to call the emit( MPoint ) method - // many times. - - MPointArray mp( primitive->variableSize( PrimitiveVariable::Vertex ) ); - if( p->isInstanceOf( V3fVectorDataTypeId ) ) - { - const vector &pReadable = boost::static_pointer_cast( p )->readable(); - std::transform( pReadable.begin(), pReadable.end(), MArrayIter::begin( mp ), IECore::convert ); - } - else - { - const vector &pReadable = boost::static_pointer_cast( p )->readable(); - std::transform( pReadable.begin(), pReadable.end(), MArrayIter::begin( mp ), IECore::convert ); - } - - fnPS.emit( mp ); - - // add all other vertex primvars as per-particle attributes - - for( PrimitiveVariableMap::const_iterator it=primitive->variables.begin(); it!=primitive->variables.end(); it++ ) - { - if( it->second.interpolation!=PrimitiveVariable::Vertex ) - { - continue; - } - if( it->first=="P" ) - { - continue; - } - - if( it->first=="Cs" ) - { - addAttribute( it->second.data.get(), fnPS, "rgbPP" ); - } - else - { - addAttribute( it->second.data.get(), fnPS, it->first.c_str() ); - } - } - - // make sure it can be rendered. - // it would perhaps be preferable to use MFnSet::addMember() instead but at the time of - // writing (maya 2010) that seems to print out "Result : initialParticleSE" totally unnecessarily. - MGlobal::executeCommand( "sets -addElement initialParticleSE " + fnPS.fullPathName() ); - - // freeze everything - fnPS.saveInitialState(); - - // connect it to time so it can be used for simulation - MSelectionList selection; - selection.add( "time1" ); - MObject time1; - selection.getDependNode( 0, time1 ); - MFnDependencyNode fnTime1( time1 ); - - MDGModifier dgMod; - dgMod.connect( fnTime1.findPlug( "outTime", false ), fnPS.findPlug( "currentTime", true ) ); - dgMod.doIt(); - - return true; -} - -void ToMayaParticleConverter::addAttribute( const IECore::Data *data, MFnParticleSystem &fnPS, const MString &attrName ) const -{ - MFnData::Type attrType = MFnData::kInvalid; - MFn::Type dataType = MFn::kInvalid; - switch( data->typeId() ) - { - case V3fVectorDataTypeId : - case V3dVectorDataTypeId : - case Color3fVectorDataTypeId : - attrType = MFnData::kVectorArray; - dataType = MFn::kVectorArrayData; - break; - case FloatVectorDataTypeId : - attrType = MFnData::kDoubleArray; - dataType = MFn::kDoubleArrayData; - break; - default : - return; - } - - MPlug plug = fnPS.findPlug( attrName, false ); - if( plug.isNull() ) - { - MFnTypedAttribute fnTA; - fnPS.addAttribute( fnTA.create( attrName, attrName, attrType ) ); - fnPS.addAttribute( fnTA.create( attrName + "0", attrName + "0", attrType ) ); - plug = fnPS.findPlug( attrName, false ); - } - - MObject value; - ToMayaObjectConverterPtr dataConverter = ToMayaObjectConverter::create( data, dataType ); - dataConverter->convert( value ); - plug.setValue( value ); -} diff --git a/src/IECoreMaya/ToMayaPlugConverter.cpp b/src/IECoreMaya/ToMayaPlugConverter.cpp deleted file mode 100644 index 843a20176e..0000000000 --- a/src/IECoreMaya/ToMayaPlugConverter.cpp +++ /dev/null @@ -1,267 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MFnAttribute.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnUnitAttribute.h" -#include "maya/MFnTypedAttribute.h" -#include "maya/MString.h" -#include "maya/MTime.h" -#include "maya/MAngle.h" -#include "maya/MDistance.h" -#include "maya/MFnPluginData.h" - -#include "IECore/CompoundData.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/VectorTypedData.h" - -#include "IECoreMaya/ObjectData.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/ToMayaPlugConverter.h" - -#include "boost/format.hpp" - -using namespace IECoreMaya; -using namespace IECore; -using namespace boost; - -IE_CORE_DEFINERUNTIMETYPED( ToMayaPlugConverter ); - -ToMayaPlugConverter::ToMayaPlugConverter( ConstObjectPtr object ) - : ToMayaConverter( "Places values in plugs.", IECore::ObjectTypeId ) -{ - srcParameter()->setValue( boost::const_pointer_cast( object ) ); -} - -ToMayaPlugConverterPtr ToMayaPlugConverter::create( const IECore::ObjectPtr src ) -{ - return new ToMayaPlugConverter( src ); -} - -template -MStatus ToMayaPlugConverter::setPlugValue(MPlug &plug, const DataType &data) -{ - return plug.setValue(data); -} - - -// specializations for Unit Attributes -namespace IECoreMaya -{ - -template <> -MStatus ToMayaPlugConverter::setPlugValue(MPlug &plug, const float &data) -{ - MTime t; - t.setUnit(MTime::kSeconds); - t.setValue(data); - return plug.setValue(t); -} - -template <> -MStatus ToMayaPlugConverter::setPlugValue(MPlug &plug, const float &data) -{ - MDistance t; - t.setUnit(MDistance::kCentimeters); - t.setValue(data); - return plug.setValue(t); -} - -template <> -MStatus ToMayaPlugConverter::setPlugValue(MPlug &plug, const float &data) -{ - MAngle t; - t.setUnit(MAngle::kRadians); - t.setValue(data); - return plug.setValue(t); -} - -} // namespace IECoreMaya - - -template -MStatus ToMayaPlugConverter::convertAttr(MPlug &plug) const -{ - MStatus s; - if (plug.isArray()) - { - IECore::CompoundData::ConstPtr data = IECore::runTimeCast( srcParameter()->getValidatedValue() ); - if (!data) - { - return s; - } - - typedef TypedData< std::vector > VecDataType; - const VecDataType *indexedData = data->member( "data", true ); - const IntVectorData *indices = data->member( "indices", true ); - - // set all indexed values - - const auto &dataReadable = indexedData->readable(); - const auto &indicesReadable = indices->readable(); - size_t dataSize = dataReadable.size(); - size_t indicesSize = indicesReadable.size(); - if ( dataSize != indicesSize ) - { - throw Exception(boost::str(boost::format( "Error setting array data for\"%s\" . Length of indices and data array do not match." ) % plug.info() )); - } - - for( size_t i=0; i < dataSize; ++i ) - { - MPlug currentPlug = plug.elementByLogicalIndex(indicesReadable[i]); - s = setPlugValue(currentPlug, dataReadable[i]); - if (s != MStatus::kSuccess) return s; - } - } - else if( typename IECore::TypedData::ConstPtr data = runTimeCast >( srcParameter()->getValidatedValue() ) ) - { - return setPlugValue( plug, data->readable() ); - } - return s; -} - -bool ToMayaPlugConverter::convert( MPlug &plug ) const -{ - ConstObjectPtr toConvert = srcParameter()->getValidatedValue(); - MStatus s; - MObject attr = plug.attribute(); - - // uses the same types used in FromMayaPlugConverter. - if (attr.hasFn(MFn::kUnitAttribute)) - { - MFnUnitAttribute fnAttr( attr, &s ); - - switch (fnAttr.unitType()) - { - case MFnUnitAttribute::kTime: - { - return convertAttr(plug); - } - case MFnUnitAttribute::kAngle: - { - return convertAttr(plug); - } - case MFnUnitAttribute::kDistance: - { - return convertAttr(plug); - } - default: - return 0; - } - } - else if (attr.hasFn( MFn::kNumericAttribute ) ) - { - MFnNumericAttribute fnAttr( attr, &s ); - assert(s); - - switch (fnAttr.unitType()) - { - case MFnNumericData::kDouble: - { - return (convertAttr(plug)); - } - case MFnNumericData::kFloat: - { - return (convertAttr(plug)); - } - case MFnNumericData::kInt: - { - return (convertAttr(plug)); - } - case MFnNumericData::kBoolean: - { - return (convertAttr(plug)); - } - case MFnNumericData::kChar: - { - return (convertAttr(plug)); - } - case MFnNumericData::kShort: - case MFnNumericData::kByte: - { - return (convertAttr(plug)); - } - default: - // Fall-through to MObject conversion. - break; - } - - } - else if (attr.hasFn(MFn::kEnumAttribute)) - { - return (convertAttr(plug)); - } - - // simple types failed - see if it'll accept ObjectData - MFnAttribute fnAttr( attr ); - if( fnAttr.accepts( ObjectData::id ) ) - { - MFnPluginData fnData; - MObject data = fnData.create( ObjectData::id ); - - ObjectData *oData = dynamic_cast( fnData.data() ); - oData->setObject( toConvert->copy() ); - - return plug.setValue( data ); - } - - // doesn't accept ObjectData, have a bash at storing - // an arbitrary MObject. - - try - { - MObject value; - s = plug.getValue( value ); - assert(s); - - ToMayaObjectConverterPtr objectConverter = ToMayaObjectConverter::create( toConvert ); - - if (objectConverter) - { - if ( !objectConverter->convert( value ) ) - { - return false; - } - s = plug.setValue( value ); - return (s); - } - } - catch (...) - { - } - - return false; -} diff --git a/src/IECoreMaya/ToMayaSkinClusterConverter.cpp b/src/IECoreMaya/ToMayaSkinClusterConverter.cpp deleted file mode 100644 index fff2547a7c..0000000000 --- a/src/IECoreMaya/ToMayaSkinClusterConverter.cpp +++ /dev/null @@ -1,399 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "boost/format.hpp" - -#include "maya/MFnSkinCluster.h" -#include "maya/MFnIkJoint.h" -#include "maya/MFnDagNode.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnMatrixData.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPath.h" -#include "maya/MDagPathArray.h" -#include "maya/MDGModifier.h" -#include "maya/MGlobal.h" -#include "maya/MItGeometry.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MMatrixArray.h" -#include "maya/MObjectArray.h" -#include "maya/MPlug.h" -#include "maya/MPlugArray.h" -#include "maya/MSelectionList.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/PrimitiveVariable.h" - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaSkinClusterConverter.h" - -using namespace IECoreMaya; - -ToMayaSkinClusterConverter::Description ToMayaSkinClusterConverter::g_skinClusterDescription( IECoreScene::SmoothSkinningData::staticTypeId(), MFn::kSkinClusterFilter ); - -ToMayaSkinClusterConverter::ToMayaSkinClusterConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts IECoreScene::SmoothSkinningData objects to a Maya skinCluster.", object) -{ - m_ignoreMissingInfluencesParameter = new IECore::BoolParameter( - "ignoreMissingInfluences", - "If True, ignores SmoothSkinningData influences that aren't in the Maya scene and prunes the weights of Maya skinCluster influences that aren't in the SmoothSkinningData", - false - ); - - m_ignoreBindPoseParameter = new IECore::BoolParameter( - "ignoreBindPose", - "If True, does not make connections to the bindPose node", - false - ); - - parameters()->addParameter( m_ignoreMissingInfluencesParameter ); - parameters()->addParameter( m_ignoreBindPoseParameter ); -} - -bool ToMayaSkinClusterConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - IECoreScene::ConstSmoothSkinningDataPtr skinningData = IECore::runTimeCast( from ); - assert( skinningData ); - - const std::vector &influenceNames = skinningData->influenceNames()->readable(); - const std::vector &influencePoseData = skinningData->influencePose()->readable(); - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - const std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->readable(); - - MFnDependencyNode fnSkinClusterNode( to, &s ); - MFnSkinCluster fnSkinCluster( to, &s ); - if ( s != MS::kSuccess ) - { - /// \todo: optional parameter to allow custom node types and checks for the necessary attributes - /// \todo: create a new skinCluster if we want a kSkinClusterFilter and this isn't one - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid skinCluster" ) % fnSkinClusterNode.name() ).str() ); - } - - const unsigned origNumInfluences = influenceNames.size(); - unsigned numInfluences = origNumInfluences; - std::vector ignoreInfluence( origNumInfluences, false ); - std::vector indexMap( origNumInfluences, -1 ); - const bool ignoreMissingInfluences = m_ignoreMissingInfluencesParameter->getTypedValue(); - const bool ignoreBindPose = m_ignoreBindPoseParameter->getTypedValue(); - - // gather the influence objects - MObject mObj; - MDagPath path; - MSelectionList influenceList; - MDagPathArray influencePaths; - for ( unsigned i=0, index=0; i < origNumInfluences; i++ ) - { - MString influenceName( influenceNames[i].c_str() ); - s = influenceList.add( influenceName ); - if ( !s ) - { - if ( ignoreMissingInfluences ) - { - ignoreInfluence[i] = true; - MGlobal::displayWarning( MString( "ToMayaSkinClusterConverter: \"" + influenceName + "\" is not a valid influence" ) ); - continue; - } - - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid influence" ) % influenceName ).str() ); - } - - influenceList.getDependNode( index, mObj ); - MFnIkJoint fnInfluence( mObj, &s ); - if ( !s ) - { - if ( ignoreMissingInfluences ) - { - ignoreInfluence[i] = true; - influenceList.remove( index ); - MGlobal::displayWarning( MString( "ToMayaSkinClusterConverter: \"" + influenceName + "\" is not a valid influence" ) ); - continue; - } - - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid influence" ) % influenceName ).str() ); - } - - fnInfluence.getPath( path ); - influencePaths.append( path ); - indexMap[i] = index; - index++; - } - - MPlugArray connectedPlugs; - - bool existingBindPose = true; - MPlug bindPlug = fnSkinClusterNode.findPlug( "bindPose", false, &s ); - if ( !bindPlug.connectedTo( connectedPlugs, true, false ) ) - { - existingBindPose = false; - if ( !ignoreBindPose ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" does not have a valid bindPose" ) % fnSkinClusterNode.name() ).str() ); - } - } - - MPlug bindPoseMatrixArrayPlug; - MPlug bindPoseMemberArrayPlug; - if ( existingBindPose ) - { - MFnDependencyNode fnBindPose( connectedPlugs[0].node() ); - if ( fnBindPose.typeName() != "dagPose" ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid bindPose" ) % fnBindPose.name() ).str() ); - } - - bindPoseMatrixArrayPlug = fnBindPose.findPlug( "worldMatrix", false, &s ); - bindPoseMemberArrayPlug = fnBindPose.findPlug( "members", false, &s ); - } - - /// \todo: optional parameter to reset the skinCluster's geomMatrix plug - - // break existing influence connections to the skinCluster - MDGModifier dgModifier; - MMatrixArray ignoredPreMatrices; - MPlug matrixArrayPlug = fnSkinClusterNode.findPlug( "matrix", false, &s ); - MPlug bindPreMatrixArrayPlug = fnSkinClusterNode.findPlug( "bindPreMatrix", false, &s ); - for ( unsigned i=0; i < matrixArrayPlug.numConnectedElements(); i++ ) - { - MPlug matrixPlug = matrixArrayPlug.connectionByPhysicalIndex( i, &s ); - matrixPlug.connectedTo( connectedPlugs, true, false ); - if ( !connectedPlugs.length() ) - { - continue; - } - - MFnIkJoint fnInfluence( connectedPlugs[0].node() ); - fnInfluence.getPath( path ); - if ( ignoreMissingInfluences && !influenceList.hasItem( path ) ) - { - MPlug preMatrixPlug = bindPreMatrixArrayPlug.elementByLogicalIndex( i ); - preMatrixPlug.getValue( mObj ); - MFnMatrixData matFn( mObj ); - ignoredPreMatrices.append( matFn.matrix() ); - ignoreInfluence.push_back( false ); - indexMap.push_back( influenceList.length() ); - influenceList.add( connectedPlugs[0].node() ); - numInfluences++; - } - dgModifier.disconnect( connectedPlugs[0], matrixPlug ); - } - MPlug lockArrayPlug = fnSkinClusterNode.findPlug( "lockWeights", false, &s ); - for ( unsigned i=0; i < lockArrayPlug.numConnectedElements(); i++ ) - { - MPlug lockPlug = lockArrayPlug.connectionByPhysicalIndex( i, &s ); - lockPlug.connectedTo( connectedPlugs, true, false ); - if ( connectedPlugs.length() ) - { - dgModifier.disconnect( connectedPlugs[0], lockPlug ); - } - } - MPlug paintPlug = fnSkinClusterNode.findPlug( "paintTrans", false, &s ); - paintPlug.connectedTo( connectedPlugs, true, false ); - if ( connectedPlugs.length() ) - { - dgModifier.disconnect( connectedPlugs[0], paintPlug ); - } - - // break existing influence connections to the bind pose - if ( existingBindPose ) - { - for ( unsigned i=0; i < bindPoseMatrixArrayPlug.numConnectedElements(); i++ ) - { - MPlug matrixPlug = bindPoseMatrixArrayPlug.connectionByPhysicalIndex( i, &s ); - matrixPlug.connectedTo( connectedPlugs, true, false ); - if ( connectedPlugs.length() ) - { - dgModifier.disconnect( connectedPlugs[0], matrixPlug ); - } - } - for ( unsigned i=0; i < bindPoseMemberArrayPlug.numConnectedElements(); i++ ) - { - MPlug memberPlug = bindPoseMemberArrayPlug.connectionByPhysicalIndex( i, &s ); - memberPlug.connectedTo( connectedPlugs, true, false ); - if ( connectedPlugs.length() ) - { - dgModifier.disconnect( connectedPlugs[0], memberPlug ); - } - } - } - - if ( !dgModifier.doIt() ) - { - dgModifier.undoIt(); - throw IECore::Exception( "ToMayaSkinClusterConverter: Unable to break the influence connections" ); - } - - // make connections from influences to skinCluster and bindPose - for ( unsigned i=0; i < numInfluences; i++ ) - { - if ( ignoreInfluence[i] ) - { - continue; - } - - int index = indexMap[i]; - s = influenceList.getDependNode( index, mObj ); - MFnIkJoint fnInfluence( mObj, &s ); - MPlug influenceMatrixPlug = fnInfluence.findPlug( "worldMatrix", false, &s ).elementByLogicalIndex( 0, &s ); - MPlug influenceMessagePlug = fnInfluence.findPlug( "message", false, &s ); - MPlug influenceBindPosePlug = fnInfluence.findPlug( "bindPose", false, &s ); - MPlug influenceLockPlug = fnInfluence.findPlug( "lockInfluenceWeights", false, &s ); - if ( !s ) - { - // add the lockInfluenceWeights attribute if it doesn't exist - MFnNumericAttribute nAttr; - MObject attribute = nAttr.create( "lockInfluenceWeights", "liw", MFnNumericData::kBoolean, false ); - fnInfluence.addAttribute( attribute ); - influenceLockPlug = fnInfluence.findPlug( "lockInfluenceWeights", false, &s ); - } - - // connect influence to the skinCluster - MPlug matrixPlug = matrixArrayPlug.elementByLogicalIndex( index ); - MPlug lockPlug = lockArrayPlug.elementByLogicalIndex( index ); - dgModifier.connect( influenceMatrixPlug, matrixPlug ); - dgModifier.connect( influenceLockPlug, lockPlug ); - - // connect influence to the bindPose - if ( !ignoreBindPose ) - { - MPlug bindPoseMatrixPlug = bindPoseMatrixArrayPlug.elementByLogicalIndex( index ); - MPlug memberPlug = bindPoseMemberArrayPlug.elementByLogicalIndex( index ); - dgModifier.connect( influenceMessagePlug, bindPoseMatrixPlug ); - dgModifier.connect( influenceBindPosePlug, memberPlug ); - } - } - unsigned firstIndex = find( ignoreInfluence.begin(), ignoreInfluence.end(), false ) - ignoreInfluence.begin(); - influenceList.getDependNode( firstIndex, mObj ); - MFnDependencyNode fnInfluence( mObj ); - MPlug influenceMessagePlug = fnInfluence.findPlug( "message", false, &s ); - dgModifier.connect( influenceMessagePlug, paintPlug ); - if ( !dgModifier.doIt() ) - { - dgModifier.undoIt(); - throw IECore::Exception( "ToMayaSkinClusterConverter: Unable to create the influence connections" ); - } - - // use influencePoseData as bindPreMatrix - for ( unsigned i=0; i < numInfluences; i++ ) - { - if ( ignoreInfluence[i] ) - { - continue; - } - - MMatrix preMatrix = ( i < origNumInfluences ) ? IECore::convert( influencePoseData[i] ) : ignoredPreMatrices[i-origNumInfluences]; - MPlug preMatrixPlug = bindPreMatrixArrayPlug.elementByLogicalIndex( indexMap[i], &s ); - s = preMatrixPlug.getValue( mObj ); - if ( s ) - { - MFnMatrixData matFn( mObj ); - matFn.set( preMatrix ); - mObj = matFn.object(); - } - else - { - MFnMatrixData matFn; - mObj = matFn.create( preMatrix ); - } - - preMatrixPlug.setValue( mObj ); - } - - // remove unneeded bindPreMatrix children - unsigned existingElements = bindPreMatrixArrayPlug.numElements(); - for ( unsigned i=influenceList.length(); i < existingElements; i++ ) - { - MPlug preMatrixPlug = bindPreMatrixArrayPlug.elementByLogicalIndex( i, &s ); - /// \todo: surely there is a way to accomplish this in c++... - MGlobal::executeCommand( ( boost::format( "removeMultiInstance %s" ) % preMatrixPlug.name() ).str().c_str() ); - } - - // get the geometry - MObjectArray outputGeoObjs; - if ( !fnSkinCluster.getOutputGeometry( outputGeoObjs ) ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: skinCluster \"%s\" does not have any output geometry!" ) % fnSkinCluster.name() ).str() ); - } - MFnDagNode dagFn( outputGeoObjs[0] ); - MDagPath geoPath; - dagFn.getPath( geoPath ); - - // loop through all the points of the geometry and set the weights - MItGeometry geoIt( outputGeoObjs[0] ); - - size_t pointCount = geoIt.exactCount(); - if( pointCount != pointIndexOffsets.size() ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: topology of skinCluster \"%s\"'s output geometry has changed!" ) % fnSkinCluster.name() ).str() ); - } - - MPlug weightListArrayPlug = fnSkinClusterNode.findPlug( "weightList", false, &s ); - for ( unsigned pIndex=0; !geoIt.isDone(); geoIt.next(), pIndex++ ) - { - MPlug pointWeightsPlug = weightListArrayPlug.elementByLogicalIndex( pIndex, &s ).child( 0 ); - - // remove existing influence weight plugs - MIntArray existingInfluenceIndices; - pointWeightsPlug.getExistingArrayAttributeIndices( existingInfluenceIndices ); - for( unsigned i=0; i < existingInfluenceIndices.length(); i++ ) - { - MPlug influenceWeightPlug = pointWeightsPlug.elementByLogicalIndex( existingInfluenceIndices[i], &s ); - MGlobal::executeCommand( ( boost::format( "removeMultiInstance -break 1 %s" ) % influenceWeightPlug.name() ).str().c_str() ); - } - - // add new influence weight plugs - int firstIndex = pointIndexOffsets[pIndex]; - for( int i=0; i < pointInfluenceCounts[pIndex]; i++ ) - { - int influenceIndex = pointInfluenceIndices[ firstIndex + i ]; - if ( ignoreInfluence[ influenceIndex ] ) - { - continue; - } - - int skinClusterInfluenceIndex = fnSkinCluster.indexForInfluenceObject( influencePaths[ indexMap[ influenceIndex ] ] ); - MPlug influenceWeightPlug = pointWeightsPlug.elementByLogicalIndex( skinClusterInfluenceIndex, &s ); - influenceWeightPlug.setValue( pointInfluenceWeights[ firstIndex + i ] ); - } - } - - return true; -} diff --git a/src/IECoreMaya/ToMayaSkinClusterWeightsConverter.cpp b/src/IECoreMaya/ToMayaSkinClusterWeightsConverter.cpp deleted file mode 100644 index 7c7c4bc828..0000000000 --- a/src/IECoreMaya/ToMayaSkinClusterWeightsConverter.cpp +++ /dev/null @@ -1,158 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/Convert.h" -#include "IECoreMaya/ToMayaSkinClusterWeightsConverter.h" - -#include "IECore/DataConvert.h" -#include "IECore/ScaledDataConversion.h" -#include "IECore/CompoundData.h" -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/PrimitiveVariable.h" - -#include "maya/MFnSkinCluster.h" -#include "maya/MFnIkJoint.h" -#include "maya/MFnDagNode.h" -#include "maya/MFnDependencyNode.h" -#include "maya/MFnMatrixData.h" -#include "maya/MDoubleArray.h" -#include "maya/MDagPath.h" -#include "maya/MDagPathArray.h" -#include "maya/MDGModifier.h" -#include "maya/MGlobal.h" -#include "maya/MItGeometry.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MMatrixArray.h" -#include "maya/MObjectArray.h" -#include "maya/MPlug.h" -#include "maya/MPlugArray.h" -#include "maya/MSelectionList.h" - -#include "boost/format.hpp" - -#include - -using namespace IECoreMaya; - -ToMayaSkinClusterWeightsConverter::Description ToMayaSkinClusterWeightsConverter::g_skinClusterDescription( IECore::CompoundObject::staticTypeId(), MFn::kSkinClusterFilter ); - -ToMayaSkinClusterWeightsConverter::ToMayaSkinClusterWeightsConverter( IECore::ConstObjectPtr object ) -: ToMayaObjectConverter( "Converts a skinCluster weights CompoundObject to Maya skinCluster weights.", object) -{ -} - -bool ToMayaSkinClusterWeightsConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const -{ - MStatus s; - - IECore::ConstCompoundObjectPtr weightDataPtr = IECore::runTimeCast( from ); - assert( weightDataPtr ); - - IECore::ConstIntVectorDataPtr pointInfluenceIndicesData = weightDataPtr->member("pointInfluenceIndices", true ); - IECore::ConstIntVectorDataPtr pointIndexOffsetsData = weightDataPtr->member("pointIndexOffsets", true ); - IECore::ConstIntVectorDataPtr pointInfluenceCountsData = weightDataPtr->member("pointInfluenceCounts", true ); - IECore::ConstFloatVectorDataPtr pointInfluenceWeightsData = new IECore::FloatVectorData(); - - if ( weightDataPtr->member("pointInfluenceWeights") ) - { - pointInfluenceWeightsData = weightDataPtr->member("pointInfluenceWeights"); - } - else if ( weightDataPtr->member("pointInfluenceWeights") ) - { - IECore::ConstUShortVectorDataPtr weightsShortData = weightDataPtr->member("pointInfluenceWeights" ); - IECore::DataConvert< IECore::UShortVectorData, IECore::FloatVectorData, IECore::ScaledDataConversion< unsigned short, float > >converter; - pointInfluenceWeightsData = converter( weightsShortData ); - } - - const auto &pointInfluenceWeights = pointInfluenceWeightsData->readable(); - const auto &pointInfluenceIndices = pointInfluenceIndicesData->readable(); - const auto &pointIndexOffsets = pointIndexOffsetsData->readable(); - const auto &pointInfluenceCounts = pointInfluenceCountsData->readable(); - - MFnDependencyNode fnSkinClusterNode( to, &s ); - MFnSkinCluster fnSkinCluster( to, &s ); - if ( s != MS::kSuccess ) - { - /// \todo: optional parameter to allow custom node types and checks for the necessary attributes - /// \todo: create a new skinCluster if we want a kSkinClusterFilter and this isn't one - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterWeightsConverter: \"%s\" is not a valid skinCluster" ) % fnSkinClusterNode.name() ).str() ); - } - - - // get the geometry - MObjectArray outputGeoObjs; - if ( !fnSkinCluster.getOutputGeometry( outputGeoObjs ) ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterWeightsConverter: skinCluster \"%s\" does not have any output geometry!" ) % fnSkinCluster.name() ).str() ); - } - - // loop through all the points of the geometry and set the weights - MItGeometry geoIt( outputGeoObjs[0] ); - - size_t pointCount = geoIt.exactCount(); - if( pointCount != pointIndexOffsets.size() ) - { - throw IECore::Exception( ( boost::format( "ToMayaSkinClusterWeightsConverter: topology of skinCluster \"%s\"'s output geometry has changed!" ) % fnSkinCluster.name() ).str() ); - } - - MPlug weightListArrayPlug = fnSkinClusterNode.findPlug( "weightList", false, &s ); - for ( unsigned pIndex=0; !geoIt.isDone(); geoIt.next(), pIndex++ ) - { - MPlug pointWeightsPlug = weightListArrayPlug.elementByLogicalIndex( pIndex, &s ).child( 0 ); - - // remove existing influence weight plugs - MIntArray existingInfluenceIndices; - pointWeightsPlug.getExistingArrayAttributeIndices( existingInfluenceIndices ); - for( unsigned i=0; i < existingInfluenceIndices.length(); i++ ) - { - MPlug influenceWeightPlug = pointWeightsPlug.elementByLogicalIndex( existingInfluenceIndices[i], &s ); - MGlobal::executeCommand( ( boost::format( "removeMultiInstance -break 1 %s" ) % influenceWeightPlug.name() ).str().c_str() ); - } - - // add new influence weight plugs - int firstIndex = pointIndexOffsets[pIndex]; - for( int i=0; i < pointInfluenceCounts[pIndex]; i++ ) - { - int influenceIndex = pointInfluenceIndices[ firstIndex + i ]; - - // int skinClusterInfluenceIndex = fnSkinCluster.indexForInfluenceObject( influencePaths[ indexMap[ influenceIndex ] ] ); - MPlug influenceWeightPlug = pointWeightsPlug.elementByLogicalIndex( influenceIndex, &s ); - influenceWeightPlug.setValue( pointInfluenceWeights[ firstIndex + i ] ); - } - } - - return true; -} diff --git a/src/IECoreMaya/TransformationMatrixParameterHandler.cpp b/src/IECoreMaya/TransformationMatrixParameterHandler.cpp deleted file mode 100644 index 7fec065723..0000000000 --- a/src/IECoreMaya/TransformationMatrixParameterHandler.cpp +++ /dev/null @@ -1,377 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/NumericTraits.h" -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/TransformationMatrixParameterHandler.h" - -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/TransformationMatrix.h" - -#include "maya/MFnCompoundAttribute.h" -#include "maya/MFnNumericAttribute.h" -#include "maya/MFnUnitAttribute.h" - -using namespace IECoreMaya; -using namespace Imath; - -// T & R should be kept first, to make iteration easier later on -// as they are the only two with special attribute types. -#define TRANSLATE_INDEX 0 -#define ROTATE_INDEX 1 -#define SCALE_INDEX 2 -#define SHEAR_INDEX 3 -#define SCALEPIVOT_INDEX 4 -#define SCALEPIVOTTRANS_INDEX 5 -#define ROTATEPIVOT_INDEX 6 -#define ROTATEPIVOTTRANS_INDEX 7 - -// We keep this in an array to allow a bunch of tasks to be done in a loop later. -// The order here should correlate with the defines above. -template -MString TransformationMatrixParameterHandler::g_attributeNames[] = { - "translate", - "rotate", - "scale", - "shear", - "scalePivot", - "scalePivotTranslation", - "rotatePivot", - "rotatePivotTranslation" -}; - -static ParameterHandler::Description< TransformationMatrixParameterHandler > floatRegistrar( IECore::TransformationMatrixfParameter::staticTypeId() ); -static ParameterHandler::Description< TransformationMatrixParameterHandler > doubleRegistrar( IECore::TransformationMatrixdParameter::staticTypeId() ); - -template -MStatus TransformationMatrixParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - MObject attribute = plug.attribute(); - MFnCompoundAttribute fnCAttr( attribute ); - if( !fnCAttr.hasObj( attribute ) ) - { - return MS::kFailure; - } - - if( plug.numChildren() != 8 ) - { - return MS::kFailure; - } - - MStatus stat; - MPlug tmpPlug; - - for( unsigned int i=0; i<8; i++ ) - { - tmpPlug = plug.child( i, &stat ); - - // Verify the naming of the child plugs. - - const MString name = tmpPlug.partialName(); - const unsigned int len = name.length() - 1; - const unsigned int nlen = g_attributeNames[i].length() - 1; - const MString nameEnd = name.substringW( len - nlen, len ); - - if( !stat || nameEnd != g_attributeNames[i] ) - { - return MS::kFailure; - } - - MObject attr = tmpPlug.attribute(); - fnCAttr.setObject( attr ); - if( !fnCAttr.hasObj( attr ) ) - { - return MS::kFailure; - } - } - - IECore::TransformationMatrix tMatrix = p->typedDefaultValue(); - - if( !setUnitVecDefaultValues( plug.child( TRANSLATE_INDEX ), tMatrix.translate ) ) - return MS::kFailure; - - if( !setUnitVecDefaultValues( plug.child( ROTATE_INDEX ), tMatrix.rotate ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( SCALE_INDEX ), tMatrix.scale ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( SHEAR_INDEX ), tMatrix.shear ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( SCALEPIVOT_INDEX ), tMatrix.scalePivot ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( SCALEPIVOTTRANS_INDEX ), tMatrix.scalePivotTranslation ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( ROTATEPIVOT_INDEX ), tMatrix.rotatePivot ) ) - return MS::kFailure; - - if( !setVecDefaultValues( plug.child( ROTATEPIVOTTRANS_INDEX ), tMatrix.rotatePivotTranslation ) ) - return MS::kFailure; - - return finishUpdating( parameter, plug ); -} - -template -MPlug TransformationMatrixParameterHandler::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MPlug(); - } - - MFnCompoundAttribute fnCAttr; - MObject attribute = fnCAttr.create( plugName, plugName ); - - MFnNumericAttribute fnNAttr; - MFnUnitAttribute fnUAttr; - - // As TransformationMatrix embodies a fairly comprehensive rotation model, were going to be a little - // more basic here, and just supply a V3f rotation and pretend that the Quartonean isn't there. - ///\todo Expose rotation order and rotationOrientation. - - // These use the '0', '1' and '2' child suffixes instead of 'X' 'Y' and 'Z' to match those created by fnNAttr.create() @ L188. - MObject p1 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", MFnUnitAttribute::kDistance ); - MObject p2 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", MFnUnitAttribute::kDistance ); - MObject p3 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", MFnUnitAttribute::kDistance ); - fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ], plugName + g_attributeNames[ TRANSLATE_INDEX ], p1, p2, p3 ) ); - - p1 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "0", plugName + g_attributeNames[ ROTATE_INDEX ] + "0", MFnUnitAttribute::kAngle ); - p2 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "1", plugName + g_attributeNames[ ROTATE_INDEX ] + "1", MFnUnitAttribute::kAngle ); - p3 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "2", plugName + g_attributeNames[ ROTATE_INDEX ] + "2", MFnUnitAttribute::kAngle ); - fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ], plugName + g_attributeNames[ ROTATE_INDEX ], p1, p2, p3 ) ); - - for( unsigned int i=2; i<8; i++ ) - { - fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[i], plugName + g_attributeNames[i], NumericTraits >::dataType() ) ); - } - - MPlug result = finishCreating( parameter, attribute, node ); - - if( !doUpdate( parameter, result ) ) - { - return MPlug(); // failure - } - - if( !finishUpdating( parameter, result ) ) - { - return MPlug(); // failure - } - - return result; -} - -template -MStatus TransformationMatrixParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const -{ - typename IECore::TypedParameter >::ConstPtr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - IECore::TransformationMatrix tMatrix = p->getTypedValue(); - - if( tMatrix.rotate.order() != Imath::Euler::XYZ ) - { - IECore::msg( - IECore::Msg::Error, - "TransformationMatrixParameterHandler::doSetValue", - "The rotation order of the parameter '"+parameter->name()+"' is not XYZ, unable to set value." - ); - return MS::kFailure; - } - - if( !setVecValues( plug.child( TRANSLATE_INDEX ), tMatrix.translate ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( ROTATE_INDEX ), tMatrix.rotate ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( SCALE_INDEX ), tMatrix.scale ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( SHEAR_INDEX ), tMatrix.shear ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( SCALEPIVOT_INDEX ), tMatrix.scalePivot ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( SCALEPIVOTTRANS_INDEX ), tMatrix.scalePivotTranslation ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( ROTATEPIVOT_INDEX ), tMatrix.rotatePivot ) ) - return MS::kFailure; - - if( !setVecValues( plug.child( ROTATEPIVOTTRANS_INDEX ), tMatrix.rotatePivotTranslation ) ) - return MS::kFailure; - - return MS::kSuccess; -} - -template -MStatus TransformationMatrixParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const -{ - typename IECore::TypedParameter >::Ptr p = IECore::runTimeCast > >( parameter ); - if( !p ) - { - return MS::kFailure; - } - - IECore::TransformationMatrix tMatrix = p->getTypedValue(); - - if( tMatrix.rotate.order() != Imath::Euler::XYZ ) - { - IECore::msg( - IECore::Msg::Error, - "TransformationMatrixParameterHandler::doSetValue", - "The rotation order of the parameter '"+parameter->name()+"' is not XYZ, unable to set value." - ); - return MS::kFailure; - } - - std::vector > v; - v.resize(8); - - for( unsigned int i=0; i<8; i++ ) - { - if( !getVecValues( plug.child(i), v[i] ) ) - return MS::kFailure; - } - - tMatrix.translate = v[ TRANSLATE_INDEX ]; - tMatrix.rotate = Imath::Euler(v[ ROTATE_INDEX ]); - tMatrix.scale = v[ SCALE_INDEX ]; - tMatrix.shear = v[ SHEAR_INDEX ]; - tMatrix.scalePivot = v[ SCALEPIVOT_INDEX ]; - tMatrix.scalePivotTranslation = v[ SCALEPIVOTTRANS_INDEX ]; - tMatrix.rotatePivot = v[ ROTATEPIVOT_INDEX ]; - tMatrix.rotatePivotTranslation = v[ ROTATEPIVOTTRANS_INDEX ]; - - p->setTypedValue( tMatrix ); - - return MS::kSuccess; -} - -template -MStatus TransformationMatrixParameterHandler::setVecValues( MPlug vecPlug, Imath::Vec3 &values ) const -{ - if( vecPlug.numChildren() != 3 ) - { - return MS::kFailure; - } - - for( unsigned int i=0; i<3; i++ ) - { - if( !vecPlug.child(i).setValue( values[i] ) ) - { - return MS::kFailure; - } - } - - return MS::kSuccess; -} - -template -MStatus TransformationMatrixParameterHandler::getVecValues( MPlug vecPlug, Imath::Vec3 &values ) const -{ - if( vecPlug.numChildren() != 3 ) - { - return MS::kFailure; - } - - for( unsigned int i=0; i<3; i++ ) - { - if( !vecPlug.child(i).getValue( values[i] ) ) - { - return MS::kFailure; - } - } - - return MS::kSuccess; -} - - -template -MStatus TransformationMatrixParameterHandler::setVecDefaultValues( MPlug vecPlug, Imath::Vec3 &defaultValue ) const -{ - if( vecPlug.numChildren() != 3 ) - { - return MS::kFailure; - } - - MFnNumericAttribute fnN; - for( unsigned int i=0; i<3; i++ ) - { - fnN.setObject( vecPlug.child(i).attribute() ); - if( !fnN.setDefault( defaultValue[i] ) ) - { - return MS::kFailure; - } - } - - return MS::kSuccess; -} - -template -MStatus TransformationMatrixParameterHandler::setUnitVecDefaultValues( MPlug vecPlug, Imath::Vec3 &defaultValue ) const -{ - if( vecPlug.numChildren() != 3 ) - { - return MS::kFailure; - } - - MFnUnitAttribute fnU; - for( unsigned int i=0; i<3; i++ ) - { - fnU.setObject( vecPlug.child(i).attribute() ); - if( !fnU.setDefault( defaultValue[i] ) ) - { - return MS::kFailure; - } - } - - return MS::kSuccess; -} diff --git a/src/IECoreMaya/TransientParameterisedHolderNode.cpp b/src/IECoreMaya/TransientParameterisedHolderNode.cpp deleted file mode 100644 index e15e22b037..0000000000 --- a/src/IECoreMaya/TransientParameterisedHolderNode.cpp +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - - -#include "IECoreMaya/MayaTypeIds.h" -#include "IECoreMaya/TransientParameterisedHolderNode.h" - -using namespace IECore; -using namespace IECoreMaya; - -MTypeId TransientParameterisedHolderNode::id ( TransientParameterisedHolderNodeId ); -MString TransientParameterisedHolderNode::typeName ( "ieTransientParameterisedHolderNode" ); - -TransientParameterisedHolderNode::TransientParameterisedHolderNode() -{ -} - -TransientParameterisedHolderNode::~TransientParameterisedHolderNode() -{ -} - -void *TransientParameterisedHolderNode::creator() -{ - return new TransientParameterisedHolderNode(); -} - -MStatus TransientParameterisedHolderNode::initialize() -{ - MStatus s = inheritAttributesFrom( ParameterisedHolderNode::typeName ); - if( !s ) - { - return s; - } - - return s; -} diff --git a/src/IECoreMaya/V3Manipulator.cpp b/src/IECoreMaya/V3Manipulator.cpp deleted file mode 100644 index 9dd696c611..0000000000 --- a/src/IECoreMaya/V3Manipulator.cpp +++ /dev/null @@ -1,243 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/CompoundObject.h" -#include "IECore/SimpleTypedData.h" -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/V3Manipulator.h" -#include "IECoreMaya/ParameterisedHolderInterface.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace IECore; -using namespace IECoreMaya; - -MTypeId V3Manipulator::id = V3ManipulatorTypeId; - -V3Manipulator::V3Manipulator() - : m_worldSpace( false ) -{ -} - -V3Manipulator::~V3Manipulator() -{ -} - -void *V3Manipulator::creator() -{ - return new V3Manipulator(); -} - -MStatus V3Manipulator::initialize() -{ - return MPxManipContainer::initialize(); -} - -MStatus V3Manipulator::createChildren() -{ - m_translateManip = addFreePointTriadManip( "Manipulates the vector in space.", "translate" ); - return MStatus::kSuccess; -} - -MStatus V3Manipulator::connectToDependNode( const MObject & node ) -{ - MFnDagNode dagFn( node ); - MDagPath nodePath; - dagFn.getPath( nodePath ); - - MStatus status; - m_translatePlug = dagFn.findPlug( m_plug.partialName(), false, &status ); - if( !status ) - { - return MStatus::kFailure; - } - - MFnFreePointTriadManip translateFn( m_translateManip ); - translateFn.connectToPointPlug( m_translatePlug ); - - addManipToPlugConversionCallback( m_translatePlug, (manipToPlugConversionCallback)&V3Manipulator::vectorManipToPlugConversion ); - addPlugToManipConversionCallback( translateFn.pointIndex(), (plugToManipConversionCallback)&V3Manipulator::vectorPlugToManipConversion ); - - MStatus stat = finishAddingManips(); - if( stat == MStatus::kFailure ) - { - return MStatus::kFailure; - } - - MPxManipContainer::connectToDependNode( node ); - - readParameterOptions( dagFn ); - - if( m_worldSpace) - { - m_localMatrix.setToIdentity(); - m_localMatrixInv.setToIdentity(); - } - else - { - // Inherit any transform to the parent - MDagPath transformPath = nodePath; - transformPath.pop(); - MFnTransform transformFn( transformPath ); - m_localMatrix = transformPath.inclusiveMatrix(); - m_localMatrixInv = transformPath.inclusiveMatrixInverse(); - } - return stat; -} - -void V3Manipulator::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) -{ - MPxManipContainer::draw( view, path, style, status); -} - -MManipData V3Manipulator::vectorPlugToManipConversion( unsigned int manipIndex ) -{ - MFnFreePointTriadManip translateFn( m_translateManip ); - - MFnNumericData numericData; - MObject returnData = numericData.create( MFnNumericData::k3Double ); - numericData.setData( 0.0, 0.0, 0.0 ); - MPoint p = getPlugValues( m_translatePlug ) * m_localMatrix; - numericData.setData( p.x, p.y, p.z ); - return MManipData( returnData ); -} - -MManipData V3Manipulator::vectorManipToPlugConversion( unsigned int plugIndex ) -{ - MFnFreePointTriadManip translateFn( m_translateManip ); - MPoint t; - getConverterManipValue( translateFn.pointIndex(), t ); - t = t * m_localMatrixInv; - - MFnNumericData numericData; - MObject returnData; - - // We have to check what type of data to generate so Maya - // will be able to set it back into the attribute correctly. - MFnNumericAttribute attr( m_translatePlug.attribute() ); - if( attr.unitType() == MFnNumericData::k3Float ) - { - returnData = numericData.create( MFnNumericData::k3Float ); - numericData.setData( float(t.x), float(t.y), float(t.z) ); - } - else - { - returnData = numericData.create( MFnNumericData::k3Double ); - numericData.setData( t.x, t.y, t.z ); - } - return MManipData( returnData ); -} - -void V3Manipulator::getPlugValues( MPlug &plug, double *values ) -{ - if( plug.numChildren() == 3 ) - { - for( unsigned i = 0; i<3; i++ ) - { - MPlug child = plug.child( i ); - *values = child.asDouble(); - values++; - } - } - else - { - for( unsigned i = 0; i<3; i++ ) - { - MPlug element = plug.elementByLogicalIndex( i ); - *values = element.asDouble(); - values++; - } - } -} - -void V3Manipulator::getPlugValues( MPlug &plug, MFnNumericData &data ) -{ - double values[3]; - getPlugValues( plug, values ); - data.setData( values[0], values[1], values[2] ); -} - -MPoint V3Manipulator::getPlugValues( MPlug &plug ) -{ - double values[3]; - getPlugValues( plug, values ); - return MPoint( values[0], values[1], values[2] ); -} - -void V3Manipulator::readParameterOptions( MFnDagNode &nodeFn ) -{ - ParameterisedHolderInterface *pHolder = dynamic_cast( nodeFn.userNode() ); - if( !pHolder ) - { - return; - } - - ParameterPtr parameter = pHolder->plugParameter( m_plug ); - CompoundObjectPtr userData = parameter->userData(); - - if( CompoundObjectPtr uiData = userData->member( "UI" ) ) - { - // World space parameter values - if( StringDataPtr wsData = uiData->member( "manipSpace" ) ) - { - if( wsData->readable() == "world" ) - { - m_worldSpace = true; - } - else if( wsData->readable() == "object" ) - { - m_worldSpace = false; - } - else - { - MGlobal::displayWarning( "V3Manipulator: Ignoring invalid v3ManipSpace '" - + MString( wsData->readable().c_str() ) - + "' for parameter '" - + MString( parameter->name().c_str() ) - + "', using 'object'." ); - } - } - } -} - diff --git a/src/IECoreMaya/ViewportPostProcess.cpp b/src/IECoreMaya/ViewportPostProcess.cpp deleted file mode 100644 index 5e2364dcf8..0000000000 --- a/src/IECoreMaya/ViewportPostProcess.cpp +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreMaya/ViewportPostProcess.h" - -using namespace IECore; -using namespace IECoreMaya; - -ViewportPostProcess::ViewportPostProcess() : RefCounted() -{ -} - -ViewportPostProcess::~ViewportPostProcess() -{ -} - -bool ViewportPostProcess::needsDepth() const -{ - return false; -} - -void ViewportPostProcess::preRender( const std::string &panelName ) -{ -} diff --git a/src/IECoreMaya/bindings/CallbackIdBinding.cpp b/src/IECoreMaya/bindings/CallbackIdBinding.cpp deleted file mode 100644 index 4367d4aa2d..0000000000 --- a/src/IECoreMaya/bindings/CallbackIdBinding.cpp +++ /dev/null @@ -1,98 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/bindings/CallbackIdBinding.h" -#include "IECoreMaya/CallbackId.h" - -#include "IECorePython/PointerFromSWIG.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -static MCallbackId callbackIdFromPython( PyObject *id ) -{ - if( PyCapsule_CheckExact( id ) ) - { - // maya 2011 stores the id as a PyCObject, probably to avoid the problems - // documented in the next block. - return (MCallbackId)PyCapsule_GetPointer( id, nullptr ); - } - else - { - // maya prior to 2011 stores the id as a PySwigObject. - - // if we allow a bound MCallbackId to die in python then we get this error printing out : - // - // "swig/python detected a memory leak of type 'MCallbackId *', no destructor found". - // - // this appears to be due to a bug in maya's bindings for MCallbackId. we increment a reference here so the - // object will never die and the message will never appear. this is far from ideal, but the - // test in CallbackIdTest.py verifies that this doesn't cause the callback to leak (this could - // be a big deal as it could be a member function on a large object). according to the message - // the MCallbackId is going to leak anyway, so we're not making matters any worse. - Py_INCREF( id ); - - // extract the MCallbackId from the SWIG object we're being passed. This isn't - // typesafe in any way - calling with anything other than the correct type - // is likely to explode. i haven't yet found a good way of checking the type. - return *(MCallbackId *)(((IECorePython::Detail::PySwigObject *)id)->ptr); - } -} - -class CallbackIdWrapper : public CallbackId -{ - - public : - - CallbackIdWrapper( PyObject *id ) - : CallbackId( callbackIdFromPython( id ) ) - { - - } - -}; - -void bindCallbackId() -{ - - class_( "CallbackId", init() ) - ; - -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/FnParameterisedHolderBinding.cpp b/src/IECoreMaya/bindings/FnParameterisedHolderBinding.cpp deleted file mode 100644 index e0d667b118..0000000000 --- a/src/IECoreMaya/bindings/FnParameterisedHolderBinding.cpp +++ /dev/null @@ -1,171 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include - -#include "maya/MFnDependencyNode.h" - -#include "IECore/Object.h" -#include "IECore/Parameterised.h" -#include "IECorePython/PointerFromSWIG.h" - -#include "IECoreMaya/bindings/FnParameterisedHolderBinding.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/ParameterisedHolder.h" -#include "IECoreMaya/ParameterisedHolderModificationCmd.h" - -using namespace IECore; -using namespace IECoreMaya; -using namespace IECorePython; -using namespace boost::python; - -static ParameterisedHolderInterface *interface( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - - MPxNode *userNode = fnDN->userNode(); - if( userNode ) - { - ParameterisedHolderInterface *interface = dynamic_cast( userNode ); - if( interface ) - { - return interface; - } - } - // failed - throw Exception( ( MString("Node \"") + fnDN->name() + "\" is not a ParameterisedHolder" ).asChar() ); -} - -static void setParameterised( MFnDependencyNode *fnDN, RunTimeTypedPtr p ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface(fnDN)->setParameterised( p ) ); -} - -static void setParameterised2( MFnDependencyNode *fnDN, const std::string &className, int classVersion, const std::string &envVarName ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface(fnDN)->setParameterised( className, classVersion, envVarName ) ); -} - -static boost::python::tuple getParameterised( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - - std::string className; int classVersion = 0; std::string searchPath; - RunTimeTypedPtr p = interface( fnDN )->getParameterised( &className, &classVersion, &searchPath ); - return boost::python::make_tuple( p, className, classVersion, searchPath ); -} - -static void setNodeValues( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface( fnDN )->setNodeValues() ); -} - -static void setNodeValue( MFnDependencyNode *fnDN, ParameterPtr pa ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface( fnDN )->setNodeValue( pa ) ); -} - -static void setParameterisedValues( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface( fnDN )->setParameterisedValues() ); -} - -static void setParameterisedValue( MFnDependencyNode *fnDN, ParameterPtr pa ) -{ - assert( fnDN ); - - StatusException::throwIfError( interface( fnDN )->setParameterisedValue( pa ) ); -} - -static std::string parameterPlug( MFnDependencyNode *fnDN, ParameterPtr pa ) -{ - assert( fnDN ); - - // we don't know how to push a swig wrapped MPlug into python, - // so we have to push the name and then let the python half of - // MFnParameterisedHolder construct an MPlug from it. - MString name = interface( fnDN )->parameterPlug( pa ).partialName(); - return name.asChar(); -} - -static ParameterPtr plugParameter( MFnDependencyNode *fnDN, MPlug *plug ) -{ - assert( fnDN ); - - return interface( fnDN )->plugParameter( *plug ); -} - -namespace IECoreMaya -{ - -void parameterisedHolderAssignModificationState( IECore::ObjectPtr originalValue, IECore::CompoundDataPtr originalClasses, IECore::ObjectPtr newValue, IECore::CompoundDataPtr newClasses ) -{ - ParameterisedHolderModificationCmd::g_originalValue = originalValue; - ParameterisedHolderModificationCmd::g_originalClasses = originalClasses; - ParameterisedHolderModificationCmd::g_newValue = newValue; - ParameterisedHolderModificationCmd::g_newClasses = newClasses; -} - -void bindFnParameterisedHolder() -{ - - def( "_parameterisedHolderSetParameterised", &setParameterised ); - def( "_parameterisedHolderSetParameterised", &setParameterised2 ); - def( "_parameterisedHolderGetParameterised", &getParameterised ); - def( "_parameterisedHolderSetNodeValues", &setNodeValues ); - def( "_parameterisedHolderSetNodeValue", &setNodeValue ); - def( "_parameterisedHolderSetParameterisedValues", &setParameterisedValues ); - def( "_parameterisedHolderSetParameterisedValue", &setParameterisedValue ); - def( "_parameterisedHolderParameterPlug", ¶meterPlug ); - def( "_parameterisedHolderPlugParameter", &plugParameter ); - def( "_parameterisedHolderAssignModificationState", ¶meterisedHolderAssignModificationState ); - - PointerFromSWIG(); - PointerFromSWIG(); - -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/FnSceneShapeBinding.cpp b/src/IECoreMaya/bindings/FnSceneShapeBinding.cpp deleted file mode 100644 index bdd6fb5489..0000000000 --- a/src/IECoreMaya/bindings/FnSceneShapeBinding.cpp +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include - -#include "maya/MFnDependencyNode.h" - -#include "IECoreScene/SceneInterface.h" - -#include "IECoreMaya/bindings/FnSceneShapeBinding.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/SceneShapeInterface.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static IECoreScene::SceneInterfacePtr sceneInterface( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - MPxNode *userNode = fnDN->userNode(); - SceneShapeInterface *sc = dynamic_cast( userNode ); - if( sc ) - { - IECoreScene::ConstSceneInterfacePtr scnInterface = sc->getSceneInterface(); - return const_cast( scnInterface.get() ); - } - - // failed - throw IECore::Exception( ( MString("Node \"") + fnDN->name() + "\" is not a SceneShape" ).asChar() ); -} - -static list componentNames( MFnDependencyNode *fnDN ) -{ - assert( fnDN ); - MPxNode *userNode = fnDN->userNode(); - SceneShapeInterface *sc = dynamic_cast( userNode ); - if( sc ) - { - std::vector names = sc->componentNames(); - - list result; - for( std::vector::const_iterator it = names.begin(); it!=names.end(); it++ ) - { - result.append( (*it).value() ); - } - - return result; - } - // failed - throw IECore::Exception( ( MString("Node \"") + fnDN->name() + "\" is not a SceneShape" ).asChar() ); -} - -void IECoreMaya::bindFnSceneShape() -{ - - def( "_sceneShapeSceneInterface", &sceneInterface ); - def( "_sceneShapeComponentNames", &componentNames ); - -} diff --git a/src/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.cpp deleted file mode 100644 index c36399567c..0000000000 --- a/src/IECoreMaya/bindings/FromMayaArrayDataConverterBinding.cpp +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaArrayDataConverter.h" -#include "IECoreMaya/bindings/FromMayaArrayDataConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -template -static void bind() -{ - IECorePython::RunTimeTypedClass() - ; -} - -void IECoreMaya::bindFromMayaArrayDataConverter() -{ - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); -} diff --git a/src/IECoreMaya/bindings/FromMayaCameraConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaCameraConverterBinding.cpp deleted file mode 100644 index 35a10b633f..0000000000 --- a/src/IECoreMaya/bindings/FromMayaCameraConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaCameraConverter.h" -#include "IECoreMaya/bindings/FromMayaCameraConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaCameraConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.cpp deleted file mode 100644 index 43b185e458..0000000000 --- a/src/IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.cpp +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaCompoundNumericPlugConverter.h" -#include "IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -template -static void bind() -{ - IECorePython::RunTimeTypedClass() - ; -} - -void IECoreMaya::bindFromMayaCompoundNumericPlugConverter() -{ - bind(); - bind(); - bind(); - - bind(); - bind(); - bind(); - - bind(); - bind(); - bind(); - bind(); - - bind(); - bind(); - bind(); - bind(); - -} diff --git a/src/IECoreMaya/bindings/FromMayaConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaConverterBinding.cpp deleted file mode 100644 index dcf13d9264..0000000000 --- a/src/IECoreMaya/bindings/FromMayaConverterBinding.cpp +++ /dev/null @@ -1,111 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaConverter.h" -#include "IECoreMaya/FromMayaShapeConverter.h" -#include "IECoreMaya/FromMayaDagNodeConverter.h" -#include "IECoreMaya/FromMayaPlugConverter.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/Object.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static IECoreMaya::FromMayaConverterPtr create( const char *n, IECore::TypeId resultType ) -{ - MSelectionList l; - StatusException::throwIfError( l.add( MString( n ) ) ); - - MDagPath p; - MStatus s; - - MPlug pl; - s = l.getPlug( 0, pl ); - if( s ) - { - FromMayaConverterPtr c = FromMayaPlugConverter::create( pl, resultType ); - if( c ) - { - return c; - } - - } - else - { - s = l.getDagPath( 0, p ); - if( s ) - { - FromMayaConverterPtr c = FromMayaShapeConverter::create( p, resultType ); - if( c ) - { - return c; - } - c = FromMayaDagNodeConverter::create( p, resultType ); - if( c ) - { - return c; - } - } - - MObject o; - s = l.getDependNode( 0, o ); - if( s ) - { - FromMayaConverterPtr c = FromMayaObjectConverter::create( o, resultType ); - if( c ) - { - return c; - } - } - } - - return 0; -} - -void IECoreMaya::bindFromMayaConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "create", &create, ( arg_( "object" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaCurveConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaCurveConverterBinding.cpp deleted file mode 100644 index fd5552d269..0000000000 --- a/src/IECoreMaya/bindings/FromMayaCurveConverterBinding.cpp +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaCurveConverter.h" -#include "IECoreMaya/bindings/FromMayaCurveConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaCurveConverter() -{ - IECorePython::RunTimeTypedClass() - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.cpp deleted file mode 100644 index c778764c8d..0000000000 --- a/src/IECoreMaya/bindings/FromMayaDagNodeConverterBinding.cpp +++ /dev/null @@ -1,66 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaDagNodeConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaDagNodeConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static IECoreMaya::FromMayaDagNodeConverterPtr create( const char *n, IECore::TypeId resultType ) -{ - MSelectionList l; - l.add( MString( n ) ); - MDagPath p; - MStatus s = l.getDagPath( 0, p ); - StatusException::throwIfError( s ); - return FromMayaDagNodeConverter::create( p, resultType ); -} - -void IECoreMaya::bindFromMayaDagNodeConverter() -{ - - scope s = IECorePython::RunTimeTypedClass() - .def( "create", &create, ( arg_( "object" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - ; - -} diff --git a/src/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.cpp deleted file mode 100644 index 64f099babe..0000000000 --- a/src/IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.cpp +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2019, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.h" - -#include "IECoreMaya/FromMayaEnumPlugConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "maya/MString.h" - - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaEnumPlugConverter() -{ - { - scope sh = IECorePython::RunTimeTypedClass(); - sh.attr( "convertToStringCategory" ) = FromMayaEnumPlugConvertersh::convertToStringCategory.asChar(); - } - - { - scope st = IECorePython::RunTimeTypedClass(); - st.attr( "convertToStringCategory" ) = FromMayaEnumPlugConverterst::convertToStringCategory.asChar(); - } -} diff --git a/src/IECoreMaya/bindings/FromMayaGroupConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaGroupConverterBinding.cpp deleted file mode 100644 index 9a7685ba78..0000000000 --- a/src/IECoreMaya/bindings/FromMayaGroupConverterBinding.cpp +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaGroupConverter.h" -#include "IECoreMaya/bindings/FromMayaGroupConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaGroupConverter() -{ - IECorePython::RunTimeTypedClass() - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaImageConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaImageConverterBinding.cpp deleted file mode 100644 index e5c71bbbb7..0000000000 --- a/src/IECoreMaya/bindings/FromMayaImageConverterBinding.cpp +++ /dev/null @@ -1,52 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECoreMaya/FromMayaImageConverter.h" -#include "IECoreMaya/bindings/FromMayaImageConverterBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaImageConverter() -{ - - IECorePython::RunTimeTypedClass() - .def( init() ) - ; - -} diff --git a/src/IECoreMaya/bindings/FromMayaInstancerConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaInstancerConverterBinding.cpp deleted file mode 100644 index 1b3da108ec..0000000000 --- a/src/IECoreMaya/bindings/FromMayaInstancerConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - - -#include "IECoreMaya/bindings/FromMayaInstancerConverterBinding.h" -#include "IECoreMaya/FromMayaInstancerConverter.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "boost/python.hpp" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaInstancerConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaLocatorConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaLocatorConverterBinding.cpp deleted file mode 100644 index 741db4cd1b..0000000000 --- a/src/IECoreMaya/bindings/FromMayaLocatorConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaLocatorConverter.h" -#include "IECoreMaya/bindings/FromMayaLocatorConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaLocatorConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaMeshConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaMeshConverterBinding.cpp deleted file mode 100644 index face0aa3ca..0000000000 --- a/src/IECoreMaya/bindings/FromMayaMeshConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaMeshConverter.h" -#include "IECoreMaya/bindings/FromMayaMeshConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaMeshConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaNumericPlugConvertBinding.cpp b/src/IECoreMaya/bindings/FromMayaNumericPlugConvertBinding.cpp deleted file mode 100644 index 074dca382c..0000000000 --- a/src/IECoreMaya/bindings/FromMayaNumericPlugConvertBinding.cpp +++ /dev/null @@ -1,66 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaNumericPlugConverter.h" -#include "IECoreMaya/bindings/FromMayaNumericPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -template -static void bind() -{ - IECorePython::RunTimeTypedClass() - ; -} - -void IECoreMaya::bindFromMayaNumericPlugConverter() -{ - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); - bind(); -} diff --git a/src/IECoreMaya/bindings/FromMayaObjectConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaObjectConverterBinding.cpp deleted file mode 100644 index 41cb2b7daf..0000000000 --- a/src/IECoreMaya/bindings/FromMayaObjectConverterBinding.cpp +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/bindings/FromMayaObjectConverterBinding.h" -#include "IECoreMaya/FromMayaObjectConverter.h" -#include "IECoreMaya/StatusException.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "create", &FromMayaObjectConverter::create, ( arg_( "object" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaParticleConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaParticleConverterBinding.cpp deleted file mode 100644 index 682002ed16..0000000000 --- a/src/IECoreMaya/bindings/FromMayaParticleConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaParticleConverter.h" -#include "IECoreMaya/bindings/FromMayaParticleConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaParticleConverter() -{ - - IECorePython::RunTimeTypedClass() - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaPlugConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaPlugConverterBinding.cpp deleted file mode 100644 index 20510190e1..0000000000 --- a/src/IECoreMaya/bindings/FromMayaPlugConverterBinding.cpp +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaPlugConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaPlugConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "convert", &FromMayaPlugConverter::convert ) - .def( "create", &FromMayaPlugConverter::create, ( arg_( "plug" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaShapeConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaShapeConverterBinding.cpp deleted file mode 100644 index 2997c83a2d..0000000000 --- a/src/IECoreMaya/bindings/FromMayaShapeConverterBinding.cpp +++ /dev/null @@ -1,59 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaShapeConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaShapeConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaShapeConverter() -{ - scope s = IECorePython::RunTimeTypedClass() - .def( "create", &FromMayaShapeConverter::create, ( arg_( "object" ), arg_( "resultType" ) = IECore::InvalidTypeId ) ).staticmethod( "create" ) - ; - - enum_( "Space" ) - .value( "Object", FromMayaShapeConverter::Object ) - .value( "World", FromMayaShapeConverter::World ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.cpp deleted file mode 100644 index c36ba0c1cf..0000000000 --- a/src/IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.cpp +++ /dev/null @@ -1,58 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaSkinClusterConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - - - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaSkinClusterConverter() -{ - scope s = IECorePython::RunTimeTypedClass(); - - enum_( "InfluenceName" ) - .value( "Partial", FromMayaSkinClusterConverter::Partial ) - .value( "Full", FromMayaSkinClusterConverter::Full ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.cpp deleted file mode 100644 index fa5d21d423..0000000000 --- a/src/IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaSkinClusterWeightsConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - - - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaSkinClusterWeightsConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.cpp deleted file mode 100644 index 05012c091a..0000000000 --- a/src/IECoreMaya/bindings/FromMayaStringPlugConverterBinding.cpp +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaStringPlugConverter.h" -#include "IECoreMaya/bindings/FromMayaStringPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaStringPlugConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreMaya/bindings/FromMayaTransformConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaTransformConverterBinding.cpp deleted file mode 100644 index ea4c451409..0000000000 --- a/src/IECoreMaya/bindings/FromMayaTransformConverterBinding.cpp +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaTransformConverter.h" -#include "IECoreMaya/bindings/FromMayaTransformConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindFromMayaTransformConverter() -{ - scope s = IECorePython::RunTimeTypedClass() - .def( init() ) - ; - - enum_( "Space" ) - .value( "Local", FromMayaTransformConverter::Local ) - .value( "World", FromMayaTransformConverter::World ) - ; -} diff --git a/src/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.cpp deleted file mode 100644 index 7fc496987d..0000000000 --- a/src/IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.cpp +++ /dev/null @@ -1,56 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaTransformationMatrixConverter.h" -#include "IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -template -static void bind() -{ - IECorePython::RunTimeTypedClass() - ; -} - -void IECoreMaya::bindFromMayaTransformationMatrixConverter() -{ - bind(); - bind(); -} diff --git a/src/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.cpp b/src/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.cpp deleted file mode 100644 index 0a5fe0d16e..0000000000 --- a/src/IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.cpp +++ /dev/null @@ -1,56 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/FromMayaUnitPlugConverter.h" -#include "IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -template -static void bind() -{ - IECorePython::RunTimeTypedClass() - ; -} - -void IECoreMaya::bindFromMayaUnitPlugConverter() -{ - bind(); - bind(); -} diff --git a/src/IECoreMaya/bindings/IECoreMaya.cpp b/src/IECoreMaya/bindings/IECoreMaya.cpp deleted file mode 100644 index 139cbd4139..0000000000 --- a/src/IECoreMaya/bindings/IECoreMaya.cpp +++ /dev/null @@ -1,168 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2014, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "maya/MPxNode.h" -#include "maya/MSelectionList.h" -#include "maya/MFnDependencyNode.h" - -#include "IECore/Parameterised.h" - -#include "IECoreMaya/IECoreMaya.h" -#include "IECoreMaya/bindings/FnParameterisedHolderBinding.h" -#include "IECoreMaya/bindings/FromMayaConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaPlugConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaObjectConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaCameraConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaCameraConverterBinding.h" -#include "IECoreMaya/bindings/MayaMeshBuilderBinding.h" -#include "IECoreMaya/bindings/FromMayaShapeConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaCurveConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaParticleConverterBinding.h" -#include "IECoreMaya/bindings/StandaloneBinding.h" -#include "IECoreMaya/bindings/FromMayaDagNodeConverterBinding.h" -#include "IECoreMaya/bindings/TypeIdBinding.h" -#include "IECoreMaya/bindings/MPlugFromPython.h" -#include "IECoreMaya/bindings/MObjectFromPython.h" -#include "IECoreMaya/bindings/MDagPathFromPython.h" -#include "IECoreMaya/bindings/ToMayaConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaPlugConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaObjectConverterBinding.h" -#include "IECoreMaya/bindings/MayaTypeIdBinding.h" -#include "IECoreMaya/bindings/FromMayaMeshConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaTransformConverterBinding.h" -#include "IECoreMaya/bindings/CallbackIdBinding.h" -#include "IECoreMaya/bindings/PlaybackFrameListBinding.h" -#include "IECoreMaya/bindings/MStringFromPython.h" -#include "IECoreMaya/bindings/ViewportPostProcessBinding.h" -#include "IECoreMaya/bindings/ImageViewportPostProcessBinding.h" -#include "IECoreMaya/bindings/FromMayaGroupConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaUnitPlugConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaNumericPlugConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaArrayDataConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaCompoundNumericPlugConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaTransformationMatrixConverterBinding.h" -#include "IECoreMaya/bindings/MessageHandlerBinding.h" -#include "IECoreMaya/bindings/FromMayaSkinClusterConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaSkinClusterWeightsConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaMeshConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaCurveConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaGroupConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaParticleConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaImageConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaImageConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaStringPlugConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaCameraConverterBinding.h" -#include "IECoreMaya/bindings/LiveSceneBinding.h" -#include "IECoreMaya/bindings/FnSceneShapeBinding.h" -#include "IECoreMaya/bindings/FromMayaLocatorConverterBinding.h" -#include "IECoreMaya/bindings/ToMayaLocatorConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaInstancerConverterBinding.h" -#include "IECoreMaya/bindings/FromMayaEnumPlugConverterBinding.h" - -using namespace IECore; -using namespace IECoreMaya; - -using namespace boost::python; - -/// \todo create proper assertions for unicode length for each version of Maya by OS. -/// Note: the line sizeof(Py_UNICODE) does not work on OSX -#ifdef LINUX -/// On Linux Maya is built with 4-byte Unicode characters, so we need to ensure that we're doing -/// the same so that all external symbols resolve correctly at runtime. -#if ( MAYA_API_VERSION >= 2008 ) -BOOST_STATIC_ASSERT(sizeof(Py_UNICODE) == 4); -#endif -#endif - -BOOST_PYTHON_MODULE(_IECoreMaya) -{ - bindFnParameterisedHolder(); - bindFromMayaConverter(); - bindFromMayaPlugConverter(); - bindFromMayaObjectConverter(); - bindFromMayaDagNodeConverter(); - bindFromMayaCameraConverter(); - bindMayaMeshBuilder(); - bindTypeId(); - bindFromMayaShapeConverter(); - bindFromMayaCurveConverter(); - bindFromMayaParticleConverter(); - bindStandalone(); - bindMPlugFromPython(); - bindMObjectFromPython(); - bindMDagPathFromPython(); - bindToMayaConverter(); - bindToMayaPlugConverter(); - bindToMayaObjectConverter(); - bindMayaTypeId(); - bindFromMayaMeshConverter(); - bindFromMayaTransformConverter(); - bindCallbackId(); - bindPlaybackFrameList(); - bindMStringFromPython(); - bindViewportPostProcess(); - bindImageViewportPostProcess(); - bindFromMayaGroupConverter(); - bindFromMayaUnitPlugConverter(); - bindFromMayaNumericPlugConverter(); - bindFromMayaArrayDataConverter(); - bindFromMayaCompoundNumericPlugConverter(); - bindFromMayaTransformationMatrixConverter(); - bindMessageHandler(); - bindFromMayaSkinClusterConverter(); - bindFromMayaSkinClusterWeightsConverter(); - bindToMayaSkinClusterConverter(); - bindToMayaSkinClusterWeightsConverter(); - bindToMayaMeshConverter(); - bindToMayaCurveConverter(); - bindToMayaGroupConverter(); - bindToMayaParticleConverter(); - bindToMayaImageConverter(); - bindFromMayaImageConverter(); - bindFromMayaStringPlugConverter(); - bindToMayaCameraConverter(); - bindLiveScene(); - bindFnSceneShape(); - bindFromMayaLocatorConverter(); - bindToMayaLocatorConverter(); - bindFromMayaInstancerConverter(); - bindFromMayaEnumPlugConverter(); -} diff --git a/src/IECoreMaya/bindings/ImageViewportPostProcessBinding.cpp b/src/IECoreMaya/bindings/ImageViewportPostProcessBinding.cpp deleted file mode 100644 index b319730d65..0000000000 --- a/src/IECoreMaya/bindings/ImageViewportPostProcessBinding.cpp +++ /dev/null @@ -1,145 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "maya/MGlobal.h" - -#include "IECorePython/RefCountedBinding.h" -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/Exception.h" - -#include "IECoreMaya/StatusException.h" - -#include "IECoreMaya/bindings/ImageViewportPostProcessBinding.h" -#include "IECoreMaya/ImageViewportPostProcess.h" - -using namespace IECore; -using namespace IECorePython; -using namespace boost::python; - -namespace IECoreMaya -{ - -struct ImageViewportPostProcessWrapper : RefCountedWrapper< ImageViewportPostProcess > -{ - - ImageViewportPostProcessWrapper(PyObject *wrapperSelf ) - : RefCountedWrapper( wrapperSelf ) - { - } - - virtual ~ImageViewportPostProcessWrapper() - { - } - - virtual bool needsDepth () const - { - if( isSubclassed() ) - { - ScopedGILLock gilLock; - object o = this->methodOverride( "needsDepth" ); - if( o ) - { - try - { - return o(); - } - catch( error_already_set &e ) - { - PyErr_Print(); - return false; - } - } - } - - return ImageViewportPostProcess::needsDepth(); - } - - virtual void preRender( const std::string &panelName ) - { - ScopedGILLock gilLock; - object o = this->methodOverride( "preRender" ); - if( o ) - { - try - { - o( panelName ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - } - } - else - { - ImageViewportPostProcess::preRender( panelName ); - } - } - - virtual void postRender( const std::string &panelName, IECoreImage::ImagePrimitivePtr image ) - { - ScopedGILLock gilLock; - object o = this->methodOverride( "postRender" ); - if( o ) - { - try - { - o( panelName, image ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - } - } - else - { - /// Maya would crash if we were to throw an exception here - MGlobal::displayError( "ImageViewportPostProcess: postRender() python method not defined" ); - } - } -}; - -void bindImageViewportPostProcess() -{ - RefCountedClass( "ImageViewportPostProcess" ) - .def( init<>() ) - .def( "needsDepth", &ImageViewportPostProcessWrapper::needsDepth ) - .def( "preRender", &ImageViewportPostProcessWrapper::preRender ) - .def( "postRender", pure_virtual( &ImageViewportPostProcessWrapper::postRender ) ) - ; -} - -} diff --git a/src/IECoreMaya/bindings/LiveSceneBinding.cpp b/src/IECoreMaya/bindings/LiveSceneBinding.cpp deleted file mode 100644 index a5138e0e74..0000000000 --- a/src/IECoreMaya/bindings/LiveSceneBinding.cpp +++ /dev/null @@ -1,255 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MString.h" - -#include "boost/python.hpp" -#include "boost/python/suite/indexing/container_utils.hpp" - -#include "IECoreMaya/LiveScene.h" -#include "IECoreMaya/bindings/LiveSceneBinding.h" - -#include "IECorePython/IECoreBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" -#include "IECorePython/ScopedGILLock.h" - -using namespace IECoreMaya; -using namespace boost::python; - -namespace -{ - -class CustomTagReader -{ - public : - CustomTagReader( object hasFn, object readFn ) : m_has( hasFn ), m_read( readFn ) - { - } - - bool operator() ( const MDagPath &dagPath, const IECoreScene::SceneInterface::Name &tag, int filter ) - { - MString p = dagPath.fullPathName(); - IECorePython::ScopedGILLock gilLock; - try - { - return m_has( p.asChar(), tag, filter ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - throw IECore::Exception( std::string( "Python exception while checking IECoreMaya::LiveScene tag " + tag.string() ) ); - } - } - - void operator() ( const MDagPath &dagPath, IECoreScene::SceneInterface::NameList &tags, int filter ) - { - MString p = dagPath.fullPathName(); - IECorePython::ScopedGILLock gilLock; - object o; - try - { - o = m_read( p.asChar(), filter ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - throw IECore::Exception( std::string( "Python exception while evaluating IECoreMaya::LiveScene tags" ) ); - } - extract l( o ); - if ( !l.check() ) - { - throw IECore::InvalidArgumentException( std::string( "Invalid value! Expecting a list of strings." ) ); - } - - container_utils::extend_container( tags, l() ); - } - - object m_has; - object m_read; -}; - -void registerCustomTags( object hasFn, object readFn ) -{ - CustomTagReader reader( hasFn, readFn ); - LiveScene::registerCustomTags( reader, reader ); -} - -class CustomAttributeReader -{ - public : - CustomAttributeReader( object namesFn, object readFn ) : m_names( namesFn ), m_read( readFn ) - { - } - - IECore::ConstObjectPtr operator() ( const MDagPath &dagPath, const IECoreScene::SceneInterface::Name &attr ) - { - MString p = dagPath.fullPathName(); - IECorePython::ScopedGILLock gilLock; - try - { - return extract(m_read( p.asChar(), attr )); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - throw IECore::Exception( std::string( "Python exception while evaluating IECoreMaya::LiveScene attribute " + attr.string() ) ); - } - } - - void operator() ( const MDagPath &dagPath, IECoreScene::SceneInterface::NameList &attributes ) - { - MString p = dagPath.fullPathName(); - IECorePython::ScopedGILLock gilLock; - object o; - try - { - o = m_names( p.asChar() ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - throw IECore::Exception( std::string( "Python exception while evaluating attribute names for IECoreMaya::LiveScene." ) ); - } - - extract l( o ); - if ( !l.check() ) - { - throw IECore::InvalidArgumentException( std::string( "Invalid value! Expecting a list of strings." ) ); - } - - container_utils::extend_container( attributes, l() ); - } - - object m_names; - object m_read; -}; - -class CustomAttributeReaderMightHave -{ - public : - CustomAttributeReaderMightHave( object mightHaveFn ) : m_mightHave( mightHaveFn ) - { - } - - bool operator() ( const MDagPath &dagPath, const IECoreScene::SceneInterface::Name &attr ) - { - // Use with care when registering a Python function. - // MDagPath::fullPathName() is a slow API. We allow registering the "might have" callback from Python - // for compatibility with IECoreMaya C++ API but registering a Python "might have" function may spoil the efficiency. - MString p = dagPath.fullPathName(); - IECorePython::ScopedGILLock gilLock; - try - { - return m_mightHave( p.asChar(), attr ); - } - catch ( error_already_set &e ) - { - PyErr_Print(); - throw IECore::Exception( std::string( "Python exception while evaluating IECoreMaya::LiveScene attribute " + attr.string() ) ); - } - } - - object m_mightHave; -}; - -void registerCustomAttributes( object namesFn, object readFn, object mightHaveFn ) -{ - CustomAttributeReader reader( namesFn, readFn ); - - if ( mightHaveFn == object() ) - { - LiveScene::registerCustomAttributes( reader, reader ); - } - else - { - CustomAttributeReaderMightHave readerm( mightHaveFn ); - LiveScene::registerCustomAttributes( reader, reader, readerm ); - } -} - -inline std::string dagPath( object liveSceneObject ) -{ - const LiveScene &liveScene = extract( liveSceneObject ); - return liveScene.dagPath().fullPathName().asChar(); -} - -inline list dagPathToPath( object dagObj ) -{ - list pathList; - extract dagPath( dagObj ); - - // Return the root path (an empty list) if we are given an empty string - // Maya doesn't really have a "root" dag path, so this is as close as we can get while simultaneously - // ensuring dagPathToPath( pathToDagPath( [] ) ) == [] - if( dagPath.check() && len( dagObj ) == 0 ) - { - return pathList; - } - - // Get the path, or throw if the dag path object is invalid - IECoreScene::SceneInterface::Path path; - LiveScene::dagPathToPath( dagPath(), path ); - for(const auto &name : path ) - { - pathList.append( name.string() ); - } - return pathList; -} - -inline std::string pathToDagPath( list pathList ) -{ - IECoreScene::SceneInterface::Path path; - container_utils::extend_container( path, pathList ); - - MDagPath dagPath; - LiveScene::pathToDagPath( path, dagPath ); - return dagPath.fullPathName().asChar(); -} - -} // namespace - -void IECoreMaya::bindLiveScene() -{ - IECorePython::RunTimeTypedClass() - .def( init<>() ) - .def( "registerCustomTags", registerCustomTags, ( arg_( "hasFn" ), arg_( "readFn" ) ) ).staticmethod( "registerCustomTags" ) - .def( "registerCustomAttributes", registerCustomAttributes, ( arg_( "namesFn" ), arg_( "readFn" ), arg_( "mightHaveFn" ) = object() ) ).staticmethod( "registerCustomAttributes" ) - .def( "dagPath", ::dagPath ) - .def( "dagPathToPath", ::dagPathToPath ).staticmethod( "dagPathToPath" ) - .def( "pathToDagPath", ::pathToDagPath ).staticmethod( "pathToDagPath" ) - .def( "toMayaAttributeName", LiveScene::toMayaAttributeName ).staticmethod( "toMayaAttributeName" ) - .def( "fromMayaAttributeName", LiveScene::fromMayaAttributeName ).staticmethod( "fromMayaAttributeName" ) - .def_readonly("visibilityOverrideName", LiveScene::visibilityOverrideName ) - ; -} diff --git a/src/IECoreMaya/bindings/MDagPathFromPython.cpp b/src/IECoreMaya/bindings/MDagPathFromPython.cpp deleted file mode 100644 index 58decdc4b4..0000000000 --- a/src/IECoreMaya/bindings/MDagPathFromPython.cpp +++ /dev/null @@ -1,99 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/StatusException.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" -#include "maya/MDagPath.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -struct MDagPathFromPython -{ - static void *convertible( PyObject *obj ) - { - if( PyUnicode_Check( obj ) || PyBytes_Check( obj ) ) - { - return obj; - } - else - { - return 0; - } - } - - static void construct( PyObject *obj, converter::rvalue_from_python_stage1_data *data ) - { - void *storage = ((converter::rvalue_from_python_storage*)data)->storage.bytes; - - MString name; - - if( PyUnicode_Check( obj ) ) - { - PyObject *ascii = PyUnicode_AsASCIIString( obj ); - name = PyBytes_AsString( ascii ); - Py_DECREF( ascii ); - } - else - { - name = PyBytes_AsString( obj ); - } - - MSelectionList s; - StatusException::throwIfError( s.add( name ) ); - - MDagPath path; - StatusException::throwIfError( s.getDagPath( 0, path ) ); - - new (storage) MDagPath( path ); - data->convertible = storage; - } -}; - -void bindMDagPathFromPython() -{ - converter::registry::push_back( - &MDagPathFromPython::convertible, - &MDagPathFromPython::construct, - type_id() - ); -} - -} // namespace IECore diff --git a/src/IECoreMaya/bindings/MObjectFromPython.cpp b/src/IECoreMaya/bindings/MObjectFromPython.cpp deleted file mode 100644 index 8182642348..0000000000 --- a/src/IECoreMaya/bindings/MObjectFromPython.cpp +++ /dev/null @@ -1,100 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/StatusException.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" -#include "maya/MObject.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -struct MObjectFromPython -{ - static void *convertible( PyObject *obj ) - { - if( PyUnicode_Check( obj ) || PyBytes_Check( obj ) ) - { - return obj; - } - else - { - return 0; - } - } - - static void construct( PyObject *obj, converter::rvalue_from_python_stage1_data *data ) - { - void *storage = ((converter::rvalue_from_python_storage*)data)->storage.bytes; - - MString objectName; - - if( PyUnicode_Check( obj ) ) - { - PyObject *ascii = PyUnicode_AsASCIIString( obj ); - objectName = PyBytes_AsString( ascii ); - Py_DECREF( ascii ); - } - else - { - objectName = PyBytes_AsString( obj ); - } - - MSelectionList s; - StatusException::throwIfError( s.add( objectName ) ); - - MObject object; - StatusException::throwIfError( s.getDependNode( 0, object ) ); - - new (storage) MObject( object ); - data->convertible = storage; - } -}; - -void bindMObjectFromPython() -{ - converter::registry::push_back( - &MObjectFromPython::convertible, - &MObjectFromPython::construct, - type_id() - ); - -} - -} // namespace IECore diff --git a/src/IECoreMaya/bindings/MPlugFromPython.cpp b/src/IECoreMaya/bindings/MPlugFromPython.cpp deleted file mode 100644 index b1b59884b9..0000000000 --- a/src/IECoreMaya/bindings/MPlugFromPython.cpp +++ /dev/null @@ -1,100 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/StatusException.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" -#include "maya/MPlug.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -struct MPlugFromPython -{ - static void *convertible( PyObject *obj ) - { - if( PyUnicode_Check( obj ) || PyBytes_Check( obj ) ) - { - return obj; - } - else - { - return 0; - } - } - - static void construct( PyObject *obj, converter::rvalue_from_python_stage1_data *data ) - { - void *storage = ((converter::rvalue_from_python_storage*)data)->storage.bytes; - - MString plugName; - - if( PyUnicode_Check( obj ) ) - { - PyObject *ascii = PyUnicode_AsASCIIString( obj ); - plugName = PyBytes_AsString( ascii ); - Py_DECREF( ascii ); - } - else - { - plugName = PyBytes_AsString( obj ); - } - - MSelectionList s; - StatusException::throwIfError( s.add( plugName ) ); - - MPlug plug; - StatusException::throwIfError( s.getPlug( 0, plug ) ); - - new (storage) MPlug( plug ); - data->convertible = storage; - } -}; - -void bindMPlugFromPython() -{ - converter::registry::push_back( - &MPlugFromPython::convertible, - &MPlugFromPython::construct, - type_id() - ); - -} - -} // namespace IECore diff --git a/src/IECoreMaya/bindings/MStringFromPython.cpp b/src/IECoreMaya/bindings/MStringFromPython.cpp deleted file mode 100644 index 95ef362d03..0000000000 --- a/src/IECoreMaya/bindings/MStringFromPython.cpp +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/StatusException.h" - -#include "maya/MSelectionList.h" -#include "maya/MString.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -struct MStringFromPython -{ - static void *convertible( PyObject *obj ) - { - if( PyUnicode_Check( obj ) || PyBytes_Check( obj ) ) - { - return obj; - } - else - { - return 0; - } - } - - static void construct( PyObject *obj, converter::rvalue_from_python_stage1_data *data ) - { - void *storage = ((converter::rvalue_from_python_storage*)data)->storage.bytes; - - MString name; - - if( PyUnicode_Check( obj ) ) - { - PyObject *ascii = PyUnicode_AsASCIIString( obj ); - new (storage) MString( PyBytes_AsString( ascii ) ); - Py_DECREF( ascii ); - } - else - { - new (storage) MString( PyBytes_AsString( obj ) ); - } - - data->convertible = storage; - } -}; - -void bindMStringFromPython() -{ - converter::registry::push_back( - &MStringFromPython::convertible, - &MStringFromPython::construct, - type_id() - ); -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/MayaMeshBuilderBinding.cpp b/src/IECoreMaya/bindings/MayaMeshBuilderBinding.cpp deleted file mode 100644 index 39f93b58e5..0000000000 --- a/src/IECoreMaya/bindings/MayaMeshBuilderBinding.cpp +++ /dev/null @@ -1,70 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/bindings/MayaMeshBuilderBinding.h" -#include "IECoreMaya/MayaMeshBuilder.h" - -#include "IECorePython/RefCountedBinding.h" - -using namespace boost; -using namespace boost::python; - -using namespace IECore; -using namespace IECorePython; - -namespace IECoreMaya -{ - -template -void bindMayaMeshBuilder( const char *name ) -{ - RefCountedClass( name ) - .def( init< MObject > () ) - .def( "addVertex", &T::addVertex ) - .def( "addTriangle", &T::addTriangle ) - .def( "mesh", &T::mesh ) - ; - - implicitly_convertible< typename T::Ptr, RefCountedPtr>(); -} - -void bindMayaMeshBuilder() -{ - bindMayaMeshBuilder< MayaMeshBuilder >( "MayaMeshBuilderf" ); - bindMayaMeshBuilder< MayaMeshBuilder >( "MayaMeshBuilderd" ); -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/MayaTypeIdBinding.cpp b/src/IECoreMaya/bindings/MayaTypeIdBinding.cpp deleted file mode 100644 index cbe1e9f8c4..0000000000 --- a/src/IECoreMaya/bindings/MayaTypeIdBinding.cpp +++ /dev/null @@ -1,76 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2009, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "IECoreMaya/MayaTypeIds.h" - -#include "maya/MTypeId.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -void bindMayaTypeId() -{ - /// We use a helper class written in Python to allow conversion of these to proper SWIG MTypeId objects - enum_< long int > ( "_MayaTypeId" ) - .value( "CacheSet", CacheSetId ) - .value( "ObjectData", ObjectDataId ) - .value( "ParameterisedHolderLocator", ParameterisedHolderLocatorId ) - .value( "ParameterisedHolderDeformer", ParameterisedHolderDeformerId ) - .value( "ParameterisedHolderField", ParameterisedHolderFieldId ) - .value( "ParameterisedHolderSet", ParameterisedHolderSetId ) - .value( "OpHolderNode", OpHolderNodeId ) - .value( "ConverterHolder", ConverterHolderId ) - .value( "ParameterisedHolderSurfaceShape", ParameterisedHolderSurfaceShapeId ) - .value( "ParameterisedHolderComponentShape", ParameterisedHolderComponentShapeId ) - .value( "ParameterisedHolderNode", ParameterisedHolderNodeId ) - .value( "ProceduralHolder", ProceduralHolderId ) - .value( "TransientParameterisedHolderNode", TransientParameterisedHolderNodeId ) - .value( "ParameterisedHolderImagePlane", ParameterisedHolderImagePlaneId ) - .value( "ImagePlaneHolder", ImagePlaneHolderId ) - .value( "CurveCombiner", CurveCombinerId ) - .value( "DummyData", DummyDataId ) - .value( "DrawableHolder", DrawableHolderId ) - .value( "GeometryCombiner", GeometryCombinerId ) - .value( "SceneShapeInterface", SceneShapeInterfaceId ) - .value( "SceneShape", SceneShapeId ) - .value( "SceneShapeProxy", SceneShapeProxyId ) - ; -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/MessageHandlerBinding.cpp b/src/IECoreMaya/bindings/MessageHandlerBinding.cpp deleted file mode 100644 index 2b3d53b7a9..0000000000 --- a/src/IECoreMaya/bindings/MessageHandlerBinding.cpp +++ /dev/null @@ -1,55 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/RefCountedBinding.h" - -#include "IECoreMaya/MessageHandler.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -void bindMessageHandler() -{ - - IECorePython::RefCountedClass( "MessageHandler" ) - .def( init<>() ) - ; - -} - -} diff --git a/src/IECoreMaya/bindings/PlaybackFrameListBinding.cpp b/src/IECoreMaya/bindings/PlaybackFrameListBinding.cpp deleted file mode 100644 index 5e674168f5..0000000000 --- a/src/IECoreMaya/bindings/PlaybackFrameListBinding.cpp +++ /dev/null @@ -1,83 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECore/Exception.h" - -#include "IECorePython/IECoreBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECoreMaya/bindings/PlaybackFrameListBinding.h" -#include "IECoreMaya/PlaybackFrameList.h" - -using namespace IECore; -using namespace boost::python; - -namespace IECorePython -{ - template<> - std::string repr( IECoreMaya::PlaybackFrameList &x ) - { - std::stringstream s; - - s << "IECoreMaya.PlaybackFrameList( "; - - object item( x.getRange() ); - s << call_method< std::string >( item.ptr(), "__repr__" ); - s << " ) "; - - return s.str(); - } -} - -namespace IECoreMaya -{ - -void bindPlaybackFrameList() -{ - object o = IECorePython::RunTimeTypedClass() - .def( init< PlaybackFrameList::Range >() ) - .add_property( "range", &PlaybackFrameList::getRange, &PlaybackFrameList::setRange ) - ; - - scope oS( o ); - - enum_< PlaybackFrameList::Range >( "Range" ) - .value( "Animation", PlaybackFrameList::Animation ) - .value( "Playback", PlaybackFrameList::Playback ) - ; -} - -} diff --git a/src/IECoreMaya/bindings/StandaloneBinding.cpp b/src/IECoreMaya/bindings/StandaloneBinding.cpp deleted file mode 100644 index fcf97520c2..0000000000 --- a/src/IECoreMaya/bindings/StandaloneBinding.cpp +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "maya/MLibrary.h" - -using namespace boost; -using namespace boost::python; - -namespace IECoreMaya -{ - -/// A workaround for the fact that Maya doesn't expose MLibrary::cleanup to Python -struct Standalone -{ - static void cleanup( int exitCode ) - { - MLibrary::cleanup( exitCode ); - } -}; - -void bindStandalone() -{ - class_< Standalone, boost::noncopyable >( "Standalone", no_init ) - .def( "cleanup", &Standalone::cleanup).staticmethod( "cleanup" ) - ; -} - -} // namespace IECoreMaya diff --git a/src/IECoreMaya/bindings/ToMayaCameraConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaCameraConverterBinding.cpp deleted file mode 100644 index 4f5a172131..0000000000 --- a/src/IECoreMaya/bindings/ToMayaCameraConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaCameraConverter.h" -#include "IECoreMaya/bindings/ToMayaCameraConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaCameraConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaConverterBinding.cpp deleted file mode 100644 index 6daa7b95cc..0000000000 --- a/src/IECoreMaya/bindings/ToMayaConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaConverter.h" -#include "IECoreMaya/bindings/ToMayaConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/Object.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaConverter() -{ - IECorePython::RunTimeTypedClass() - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaCurveConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaCurveConverterBinding.cpp deleted file mode 100644 index 445eec4976..0000000000 --- a/src/IECoreMaya/bindings/ToMayaCurveConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaCurveConverter.h" -#include "IECoreMaya/bindings/ToMayaCurveConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECore; -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaCurveConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaGroupConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaGroupConverterBinding.cpp deleted file mode 100644 index e26b6d4f52..0000000000 --- a/src/IECoreMaya/bindings/ToMayaGroupConverterBinding.cpp +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaGroupConverter.h" -#include "IECoreMaya/bindings/ToMayaGroupConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - - -void IECoreMaya::bindToMayaGroupConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaImageConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaImageConverterBinding.cpp deleted file mode 100644 index 15759d9734..0000000000 --- a/src/IECoreMaya/bindings/ToMayaImageConverterBinding.cpp +++ /dev/null @@ -1,63 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/RunTimeTypedBinding.h" -#include "IECorePython/PointerFromSWIG.h" - -#include "IECoreMaya/ToMayaImageConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/ToMayaImageConverterBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -static void convert( ToMayaImageConverter &c, MImage &i ) -{ - MStatus s = c.convert( i ); - StatusException::throwIfError( s ); -} - -void IECoreMaya::bindToMayaImageConverter() -{ - - IECorePython::RunTimeTypedClass() - .def( init() ) - .def( "convert", &convert ) - ; - - IECorePython::PointerFromSWIG(); - -} diff --git a/src/IECoreMaya/bindings/ToMayaLocatorConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaLocatorConverterBinding.cpp deleted file mode 100644 index 44bcfd217b..0000000000 --- a/src/IECoreMaya/bindings/ToMayaLocatorConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaLocatorConverter.h" -#include "IECoreMaya/bindings/ToMayaLocatorConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaLocatorConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaMeshConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaMeshConverterBinding.cpp deleted file mode 100644 index f1cac2c555..0000000000 --- a/src/IECoreMaya/bindings/ToMayaMeshConverterBinding.cpp +++ /dev/null @@ -1,83 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "maya/MObject.h" -#include "maya/MSelectionList.h" - -#include "boost/python.hpp" - -#include "IECore/MessageHandler.h" - -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/ToMayaMeshConverter.h" -#include "IECoreMaya/bindings/ToMayaMeshConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECore; -using namespace IECoreMaya; -using namespace boost::python; - -// we use the shape name instead of MObject -static bool setMeshInterpolationAttribute( std::string n, std::string interpolation ) -{ - MSelectionList l; - StatusException::throwIfError( l.add( MString( n.c_str() ) ) ); - - MStatus s; - MObject o; - - s = l.getDependNode( 0, o ); - if( !s ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::setMeshInterpolationAttribute", "Could not get depedency node: " + n ); - return false; - } - - if ( !ToMayaMeshConverter::setMeshInterpolationAttribute( o, interpolation ) ) - { - IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::setMeshInterpolationAttribute", "Failed to set interpolation attribute in " + n ); - return false; - } - - return true; -} - -void IECoreMaya::bindToMayaMeshConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - .def( "setMeshInterpolationAttribute", setMeshInterpolationAttribute, ( arg_( "nodeName" ), arg_( "interpolation" ) = "linear" ) ).staticmethod( "setMeshInterpolationAttribute" ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaObjectConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaObjectConverterBinding.cpp deleted file mode 100644 index 9af9bb27e1..0000000000 --- a/src/IECoreMaya/bindings/ToMayaObjectConverterBinding.cpp +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaObjectConverter.h" -#include "IECoreMaya/bindings/ToMayaObjectConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/Object.h" - -using namespace IECoreMaya; -using namespace boost::python; - -// weird but harmless hack - we can only get an rvalue (const reference) out -// of python but we need an lvalue (reference). the object in python is non -// const anyway though so this is harmless -static bool convert( ToMayaObjectConverter &c, const MObject &o ) -{ - return c.convert( (MObject &)o ); -} - -void IECoreMaya::bindToMayaObjectConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "convert", &convert ) - .def( "create", (ToMayaObjectConverterPtr (*)( IECore::ConstObjectPtr))&ToMayaObjectConverter::create ).staticmethod( "create" ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaParticleConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaParticleConverterBinding.cpp deleted file mode 100644 index 81effdf74f..0000000000 --- a/src/IECoreMaya/bindings/ToMayaParticleConverterBinding.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaParticleConverter.h" -#include "IECoreMaya/bindings/ToMayaParticleConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaParticleConverter() -{ - IECorePython::RunTimeTypedClass() - .def( init() ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaPlugConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaPlugConverterBinding.cpp deleted file mode 100644 index e8d0bb9f67..0000000000 --- a/src/IECoreMaya/bindings/ToMayaPlugConverterBinding.cpp +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaPlugConverter.h" -#include "IECoreMaya/bindings/ToMayaPlugConverterBinding.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/Object.h" - -using namespace IECoreMaya; -using namespace boost::python; - -// our plug converters can't get an lvalue out of python, and that's what -// it wants to get an MPlug & for the convert call. so we have to wrap it -// with this iffy const MPlug & version and a cast (the const MPlug & can -// be treated as an rvalue so our converters work with it). -static bool convert( ToMayaPlugConverter &c, const MPlug &p ) -{ - return c.convert( (MPlug &)p ); -} - -void IECoreMaya::bindToMayaPlugConverter() -{ - IECorePython::RunTimeTypedClass() - .def( "convert", &convert ) - .def( "create", &ToMayaPlugConverter::create ).staticmethod( "create" ) - ; -} diff --git a/src/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.cpp deleted file mode 100644 index ecde7e8d70..0000000000 --- a/src/IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.cpp +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaSkinClusterConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/ToMayaSkinClusterConverterBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaSkinClusterConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.cpp b/src/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.cpp deleted file mode 100644 index 7858ab40e8..0000000000 --- a/src/IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.cpp +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreMaya/ToMayaSkinClusterWeightsConverter.h" -#include "IECoreMaya/StatusException.h" -#include "IECoreMaya/bindings/ToMayaSkinClusterWeightsConverterBinding.h" -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace IECoreMaya; -using namespace boost::python; - -void IECoreMaya::bindToMayaSkinClusterWeightsConverter() -{ - IECorePython::RunTimeTypedClass(); -} diff --git a/src/IECoreMaya/bindings/TypeIdBinding.cpp b/src/IECoreMaya/bindings/TypeIdBinding.cpp deleted file mode 100644 index ec1c627ca5..0000000000 --- a/src/IECoreMaya/bindings/TypeIdBinding.cpp +++ /dev/null @@ -1,136 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2014, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include - -#include "IECoreMaya/TypeIds.h" -#include "IECoreMaya/bindings/TypeIdBinding.h" - -using namespace boost::python; - -namespace IECoreMaya -{ - -void bindTypeId() -{ - enum_( "TypeId" ) - .value( "FromMayaConverter", FromMayaConverterTypeId ) - .value( "FromMayaObjectConverter", FromMayaObjectConverterTypeId ) - .value( "FromMayaPlugConverter", FromMayaPlugConverterTypeId ) - .value( "FromMayaMeshConverter", FromMayaMeshConverterTypeId ) - .value( "FromMayaCameraConverter", FromMayaCameraConverterTypeId ) - .value( "FromMayaGroupConverter", FromMayaGroupConverterTypeId ) - .value( "FromMayaNumericDataConverter", FromMayaNumericDataConverterTypeId ) - .value( "FromMayaNumericPlugConverter", FromMayaNumericPlugConverterTypeId ) - .value( "FromMayaFluidConverter", FromMayaFluidConverterTypeId ) - .value( "FromMayaStringPlugConverter", FromMayaStringPlugConverterTypeId ) - .value( "FromMayaShapeConverter", FromMayaShapeConverterTypeId ) - .value( "FromMayaCurveConverter", FromMayaCurveConverterTypeId ) - .value( "FromMayaParticleConverter", FromMayaParticleConverterTypeId ) - .value( "FromMayaDagNodeConverter", FromMayaDagNodeConverterTypeId ) - .value( "ToMayaConverter", ToMayaConverterTypeId ) - .value( "ToMayaObjectConverter", ToMayaObjectConverterTypeId ) - .value( "ToMayaNumericDataConverter", ToMayaNumericDataConverterTypeId ) - .value( "ToMayaCurveConverter", ToMayaCurveConverterTypeId ) - .value( "ToMayaMeshConverter", ToMayaMeshConverterTypeId ) - .value( "ToMayaArrayDataConverter", ToMayaArrayDataConverterTypeId ) - .value( "ToMayaPlugConverter", ToMayaPlugConverterTypeId ) - .value( "FromMayaPluginDataPlugConverter", FromMayaPluginDataPlugConverterTypeId ) - .value( "FromMayaTransformConverter", FromMayaTransformConverterTypeId ) - .value( "FromMayaImageConverter", FromMayaImageConverterTypeId ) - .value( "ToMayaImageConverter", ToMayaImageConverterTypeId ) - .value( "PlaybackFrameList", PlaybackFrameListTypeId ) - .value( "FromMayaUnitPlugConverterf", FromMayaUnitPlugConverterfTypeId ) - .value( "FromMayaUnitPlugConverterd", FromMayaUnitPlugConverterdTypeId ) - .value( "FromMayaNumericPlugConverterbb", FromMayaNumericPlugConverterbbTypeId ) - .value( "FromMayaNumericPlugConverterbi", FromMayaNumericPlugConverterbiTypeId ) - .value( "FromMayaNumericPlugConverterii", FromMayaNumericPlugConverteriiTypeId ) - .value( "FromMayaNumericPlugConverterif", FromMayaNumericPlugConverterifTypeId ) - .value( "FromMayaNumericPlugConverterid", FromMayaNumericPlugConverteridTypeId ) - .value( "FromMayaNumericPlugConverterfi", FromMayaNumericPlugConverterfiTypeId ) - .value( "FromMayaNumericPlugConverterff", FromMayaNumericPlugConverterffTypeId ) - .value( "FromMayaNumericPlugConverterfd", FromMayaNumericPlugConverterfdTypeId ) - .value( "FromMayaNumericPlugConverterdi", FromMayaNumericPlugConverterdiTypeId ) - .value( "FromMayaNumericPlugConverterdf", FromMayaNumericPlugConverterdfTypeId ) - .value( "FromMayaNumericPlugConverterdd", FromMayaNumericPlugConverterddTypeId ) - .value( "FromMayaNumericPlugConverterss", FromMayaNumericPlugConverterssTypeId ) - .value( "FromMayaArrayDataConverterii", FromMayaArrayDataConverteriiTypeId ) - .value( "FromMayaArrayDataConverterib", FromMayaArrayDataConverteribTypeId ) - .value( "FromMayaArrayDataConverterdd", FromMayaArrayDataConverterddTypeId ) - .value( "FromMayaArrayDataConverterdf", FromMayaArrayDataConverterdfTypeId ) - .value( "FromMayaArrayDataConverterss", FromMayaArrayDataConverterssTypeId ) - .value( "FromMayaArrayDataConverterVV3f", FromMayaArrayDataConverterVV3fTypeId ) - .value( "FromMayaArrayDataConverterVV3d", FromMayaArrayDataConverterVV3dTypeId ) - .value( "FromMayaArrayDataConverterVC3f", FromMayaArrayDataConverterVC3fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2fV2i", FromMayaCompoundNumericPlugConverterV2fV2iTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2fV2f", FromMayaCompoundNumericPlugConverterV2fV2fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2fV2d", FromMayaCompoundNumericPlugConverterV2fV2dTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2dV2i", FromMayaCompoundNumericPlugConverterV2dV2iTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2dV2f", FromMayaCompoundNumericPlugConverterV2dV2fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV2dV2d", FromMayaCompoundNumericPlugConverterV2dV2dTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3fV3i", FromMayaCompoundNumericPlugConverterV3fV3iTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3fV3f", FromMayaCompoundNumericPlugConverterV3fV3fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3fV3d", FromMayaCompoundNumericPlugConverterV3fV3dTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3fC3f", FromMayaCompoundNumericPlugConverterV3fC3fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3dV3i", FromMayaCompoundNumericPlugConverterV3dV3iTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3dV3f", FromMayaCompoundNumericPlugConverterV3dV3fTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3dV3d", FromMayaCompoundNumericPlugConverterV3dV3dTypeId ) - .value( "FromMayaCompoundNumericPlugConverterV3dC3f", FromMayaCompoundNumericPlugConverterV3dC3fTypeId ) - .value( "FromMayaTransformationMatrixfConverter", FromMayaTransformationMatrixfConverterTypeId ) - .value( "FromMayaTransformationMatrixdConverter", FromMayaTransformationMatrixdConverterTypeId ) - .value( "FromMayaSkinClusterConverter", FromMayaSkinClusterConverterTypeId ) - .value( "FromMayaSkinClusterWeightsConverter", FromMayaSkinClusterWeightsConverterTypeId ) - .value( "ToMayaSkinClusterConverter", ToMayaSkinClusterConverterTypeId ) - .value( "ToMayaSkinClusterWeightsConverter", ToMayaSkinClusterWeightsConverterTypeId ) - .value( "FromMayaMatrixVectorDataConverter", FromMayaMatrixVectorDataConverterTypeId ) - .value( "ToMayaMatrixVectorDataConverter", ToMayaMatrixVectorDataConverterTypeId ) - .value( "ToMayaGroupConverter", ToMayaGroupConverterTypeId ) - .value( "ToMayaParticleConverter", ToMayaParticleConverterTypeId ) - .value( "ToMayaCameraConverter", ToMayaCameraConverterTypeId ) - .value( "LiveScene", LiveSceneTypeId ) - .value( "FromMayaProceduralHolderConverter", FromMayaProceduralHolderConverterTypeId ) - .value( "FromMayaLocatorConverter", FromMayaLocatorConverterTypeId ) - .value( "ToMayaLocatorConverter", ToMayaLocatorConverterTypeId ) - .value( "FromMayaArrayDataConverterPV3f", FromMayaArrayDataConverterPV3fTypeId ) - .value( "FromMayaArrayDataConverterPV3d", FromMayaArrayDataConverterPV3dTypeId ) - .value( "FromMayaInstancerConverter", FromMayaInstancerConverterTypeId) - .value( "FromMayaEnumPlugConverterst", FromMayaEnumPlugConverterstTypeId) - .value( "FromMayaEnumPlugConvertersh", FromMayaEnumPlugConvertershTypeId) - ; -} - -} diff --git a/src/IECoreMaya/bindings/ViewportPostProcessBinding.cpp b/src/IECoreMaya/bindings/ViewportPostProcessBinding.cpp deleted file mode 100644 index c480743685..0000000000 --- a/src/IECoreMaya/bindings/ViewportPostProcessBinding.cpp +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "maya/MGlobal.h" - -#include "IECore/Exception.h" - -#include "IECoreMaya/StatusException.h" - -#include "IECoreMaya/bindings/ViewportPostProcessBinding.h" -#include "IECoreMaya/ViewportPostProcess.h" - -#include "IECorePython/RefCountedBinding.h" - -using namespace IECore; -using namespace IECorePython; -using namespace boost::python; - -namespace IECoreMaya -{ - -void bindViewportPostProcess() -{ - RefCountedClass ViewportPostProcessPyClass( "ViewportPostProcess" ) - ; -} - -} diff --git a/src/IECoreMaya/plugin/Loader.cpp b/src/IECoreMaya/plugin/Loader.cpp deleted file mode 100644 index e3b885a219..0000000000 --- a/src/IECoreMaya/plugin/Loader.cpp +++ /dev/null @@ -1,122 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "maya/MFnPlugin.h" - -#include "IECore/Export.h" - -static void *g_libraryHandle = 0; - -/// \todo: Consider dropping this loader mechanism entirely: -/// https://mayastation.typepad.com/maya-station/2012/02/global-symbol-evaluation.html -#define STR2(a) #a -#define STR(a) STR2(a) -#if MAYA_API_VERSION >= 20190000 - #define IECOREMAYA_INITIALIZE_PLUGIN_SYMBOL "_Z16initializePluginN8Autodesk4Maya16OpenMaya" STR(MAYA_APP_VERSION) "00007MObjectE" - #define IECOREMAYA_UNINITIALIZE_PLUGIN_SYMBOL "_Z18uninitializePluginN8Autodesk4Maya16OpenMaya" STR(MAYA_APP_VERSION) "00007MObjectE" -#elif MAYA_API_VERSION >= 20180000 - #define IECOREMAYA_INITIALIZE_PLUGIN_SYMBOL "_Z16initializePluginN8Autodesk4Maya16OpenMaya201800007MObjectE" - #define IECOREMAYA_UNINITIALIZE_PLUGIN_SYMBOL "_Z18uninitializePluginN8Autodesk4Maya16OpenMaya201800007MObjectE" -#else - #define IECOREMAYA_INITIALIZE_PLUGIN_SYMBOL "_Z16initializePlugin7MObject" - #define IECOREMAYA_UNINITIALIZE_PLUGIN_SYMBOL "_Z18uninitializePlugin7MObject" -#endif - -IECORE_EXPORT MStatus initializePlugin( MObject obj ) -{ - assert( !g_libraryHandle ); - MFnPlugin plugin(obj, "Image Engine", "1.0"); - - std::string pluginName = plugin.name().asChar(); - std::string pluginPath = plugin.loadPath().asChar(); - - std::string implName = pluginPath + "/impl/" + pluginName + ".so"; - - const char *forceGlobals = std::getenv( "IECORE_RTLD_GLOBAL" ); - if( !forceGlobals || !strcmp( forceGlobals, "1" ) ) - { - g_libraryHandle = dlopen( implName.c_str(), RTLD_NOW | RTLD_GLOBAL ); - } - else - { - g_libraryHandle = dlopen( implName.c_str(), RTLD_NOW ); - } - - if (! g_libraryHandle ) - { - printf("Failed to load '%s':\n%s\n", implName.c_str(), dlerror()); - return MS::kFailure; - } - - void *initializeSymbol = dlsym( g_libraryHandle, IECOREMAYA_INITIALIZE_PLUGIN_SYMBOL ); - if ( ! initializeSymbol ) - { - printf( "Unable to find symbol: %s\n%s\n", IECOREMAYA_INITIALIZE_PLUGIN_SYMBOL, dlerror() ); - dlclose( g_libraryHandle ); - g_libraryHandle = 0; - return MS::kFailure; - } - - typedef MStatus (*InitializePluginFn)( MObject ); - - InitializePluginFn initializePluginImpl = (InitializePluginFn)( initializeSymbol ); - - return initializePluginImpl( obj ); -} - -IECORE_EXPORT MStatus uninitializePlugin( MObject obj ) -{ - MFnPlugin plugin(obj); - assert( g_libraryHandle ); - - void *uninitializeSymbol = dlsym( g_libraryHandle, IECOREMAYA_UNINITIALIZE_PLUGIN_SYMBOL ); - if ( !uninitializeSymbol ) - { - printf( "Unable to find symbol: %s\n%s\n", IECOREMAYA_UNINITIALIZE_PLUGIN_SYMBOL, dlerror() ); - dlclose( g_libraryHandle ); - g_libraryHandle = 0; - return MS::kFailure; - } - - typedef MStatus (*UninitializePluginFn)( MObject ); - UninitializePluginFn uninitializePluginImpl = (UninitializePluginFn)( uninitializeSymbol ); - - MStatus s = uninitializePluginImpl( obj ); - dlclose( g_libraryHandle ); - g_libraryHandle = 0; - return s; -} diff --git a/src/IECoreMaya/plugin/Plugin.cpp b/src/IECoreMaya/plugin/Plugin.cpp deleted file mode 100644 index 454b407d6d..0000000000 --- a/src/IECoreMaya/plugin/Plugin.cpp +++ /dev/null @@ -1,52 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/Export.h" - -#include "IECoreMaya/IECoreMaya.h" - -IECORE_EXPORT MStatus initializePlugin( MObject obj ) -{ - MStatus s; - MFnPlugin plugin(obj, "Image Engine", "1.0"); - return IECoreMaya::initialize( plugin ); -} - -IECORE_EXPORT MStatus uninitializePlugin( MObject obj ) -{ - MStatus s; - MFnPlugin plugin(obj); - IECoreMaya::uninitialize( plugin ); - return MS::kSuccess; -} diff --git a/src/IECoreNuke/BoolParameterHandler.cpp b/src/IECoreNuke/BoolParameterHandler.cpp deleted file mode 100644 index d688c3f83b..0000000000 --- a/src/IECoreNuke/BoolParameterHandler.cpp +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/BoolParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description BoolParameterHandler::g_description( BoolParameter::staticTypeId() ); - -BoolParameterHandler::BoolParameterHandler() - : m_knob( 0 ) -{ -} - -void BoolParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( f.makeKnobs() ) - { - m_storage = static_cast( parameter )->typedDefaultValue(); - } - - std::string label = knobLabel( parameter ); - m_knob = Bool_knob( f, &m_storage, knobName, label.c_str() ); - DD::Image::SetFlags( f, DD::Image::Knob::STARTLINE ); - setKnobProperties( parameter, f, m_knob ); -} - -void BoolParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - BoolParameter *boolParameter = static_cast( parameter ); - if( valueSource==Storage ) - { - boolParameter->setTypedValue( m_storage ); - } - else - { - boolParameter->setTypedValue( m_knob->get_value() > 0.0 ); - } -} - -void BoolParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const BoolParameter *boolParameter = static_cast( parameter ); - m_knob->set_value( boolParameter->getTypedValue() ? 1.0 : 0.0 ); -} diff --git a/src/IECoreNuke/Box3ParameterHandler.cpp b/src/IECoreNuke/Box3ParameterHandler.cpp deleted file mode 100644 index 1376f4a4c4..0000000000 --- a/src/IECoreNuke/Box3ParameterHandler.cpp +++ /dev/null @@ -1,108 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/Box3ParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -template -ParameterHandler::Description > Box3ParameterHandler::g_description( T::staticTypeId() ); - -template -Box3ParameterHandler::Box3ParameterHandler() - : m_knob( 0 ) -{ -} - -template -void Box3ParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( f.makeKnobs() ) - { - typename T::ValueType defaultValue = static_cast( parameter )->typedDefaultValue(); - m_storage.min = defaultValue.min; - m_storage.max = defaultValue.max; - } - - std::string label = knobLabel( parameter ); - m_knob = Box3_knob( f, (float *)&m_storage, knobName, label.c_str() ); - setKnobProperties( parameter, f, m_knob ); -} - -template -void Box3ParameterHandler::setParameterValue(IECore::Parameter *parameter, ValueSource valueSource ) -{ - T *boxParameter = static_cast( parameter ); - - typename T::ValueType value; - if( valueSource==Storage ) - { - value.min = m_storage.min; - value.max = m_storage.max; - } - else - { - value.min.x = m_knob->get_value( 0 ); - value.min.y = m_knob->get_value( 1 ); - value.min.z = m_knob->get_value( 2 ); - value.max.x = m_knob->get_value( 3 ); - value.max.y = m_knob->get_value( 4 ); - value.max.z = m_knob->get_value( 5 ); - } - - boxParameter->setTypedValue( value ); -} - -template -void Box3ParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const T *boxParameter = static_cast( parameter ); - typename T::ValueType value = boxParameter->getTypedValue(); - m_knob->set_value( value.min.x, 0 ); - m_knob->set_value( value.min.y, 1 ); - m_knob->set_value( value.min.z, 2 ); - m_knob->set_value( value.max.x, 3 ); - m_knob->set_value( value.max.y, 4 ); - m_knob->set_value( value.max.z, 5 ); -} - -// explicit instantiation - -template class Box3ParameterHandler; -template class Box3ParameterHandler; diff --git a/src/IECoreNuke/ClassParameterHandler.cpp b/src/IECoreNuke/ClassParameterHandler.cpp deleted file mode 100644 index 537956b0f4..0000000000 --- a/src/IECoreNuke/ClassParameterHandler.cpp +++ /dev/null @@ -1,248 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/ClassParameterHandler.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/CompoundObject.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" - -#include "DDImage/Enumeration_KnobI.h" -#include "DDImage/Knobs.h" - -#include "boost/algorithm/string/replace.hpp" - -using namespace boost; -using namespace std; -using namespace boost::python; -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description ClassParameterHandler::g_description( ClassParameterTypeId ); - -ClassParameterHandler::ClassParameterHandler() -{ -} - -void ClassParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - beginGroup( parameter, knobName, f ); - - classChooserKnob( parameter, knobName, f ); - - childKnobs( parameter, knobName, f ); - - endGroup( parameter, knobName, f ); -} - -void ClassParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - CompoundParameterHandler::setParameterValue( parameter, valueSource ); -} - -void ClassParameterHandler::setState( IECore::Parameter *parameter, const IECore::Object *state ) -{ - const CompoundObject *d = static_cast( state ); - - const std::string &className = d->member( "__className" )->readable(); - int classVersion = d->member( "__classVersion" )->readable(); - const std::string &classSearchPathEnvVar = d->member( "__searchPathEnvVar" )->readable(); - - /// \todo C++ code shouldn't have to call python explicity to do this stuff. - /// We could define an abstract C++ class with the right interface and then derive - /// from it to implement it in python. - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - pythonParameter.attr( "setClass" )( className, classVersion, classSearchPathEnvVar ); - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassParameterHandler::setState", e.what() ); - } - - CompoundParameterHandler::setState( parameter, state ); -} - -IECore::ObjectPtr ClassParameterHandler::getState( const IECore::Parameter *parameter ) -{ - CompoundObjectPtr result = boost::static_pointer_cast( CompoundParameterHandler::getState( parameter ) ); - if( !result ) - { - result = new CompoundObject; - } - - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - boost::python::tuple classInfo = extract( pythonParameter.attr( "getClass" )( true ) ); - - std::string className = extract( classInfo[1] )(); - int classVersion = extract( classInfo[2] )(); - std::string searchPathEnvVar = extract( classInfo[3] )(); - - result->members()["__className"] = new IECore::StringData( className ); - result->members()["__classVersion"] = new IECore::IntData( classVersion ); - result->members()["__searchPathEnvVar"] = new IECore::StringData( searchPathEnvVar ); - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassParameterHandler::getState", e.what() ); - } - return result; -} - -void ClassParameterHandler::classChooserKnob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - - std::string classChooserName = string( knobName ) + "__classChooser"; - - static const char *emptyMenu[] = { " ", "", 0 }; - DD::Image::Knob *classChooser = PyPulldown_knob( f, emptyMenu, classChooserName.c_str(), "No class loaded" ); - - if( !f.makeKnobs() ) - { - // making the menu is slow, and only needs doing when we're making knobs (not storing for instance), - // so early out now to avoid massive slowdown. - return; - } - - vector menuItems; - menuItems.push_back( " " ); - menuItems.push_back( "" ); - - std::string label = "No class loaded"; - - IECorePython::ScopedGILLock gilLock; - try - { - // get current class name, and set label from it - - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - boost::python::tuple classInfo = extract( pythonParameter.attr( "getClass" )( true ) ); - - std::string className = extract( classInfo[1] )(); - if( className != "" ) - { - int classVersion = extract( classInfo[2] )(); - label = className + " v" + lexical_cast( classVersion ); - } - - // if there is a current class, then add a menu item - // to allow it to be removed. - - std::string parameterPath = knobName + 5; // naughty! we're not meant to know the knob name format - replace_all( parameterPath, "_", "']['" ); - boost::format setClassFormat( - "with IECoreNuke.FnParameterisedHolder( nuke.thisNode() ).parameterModificationContext() as parameters :" - " parameters['%s'].setClass( '%s', %d )" - ); - - if( className!="" ) - { - menuItems.push_back( "Remove" ); - menuItems.push_back( ( setClassFormat % parameterPath % "" % 0 ).str() ); - } - - // find alternative classes which could be loaded - - std::string classNameFilter = "*"; - const CompoundObject *userData = parameter->userData(); - if( const CompoundObject *ui = userData->member( "UI" ) ) - { - if( const StringData *classNameFilterData = ui->member( "classNameFilter" ) ) - { - classNameFilter = classNameFilterData->readable(); - } - } - - std::string searchPathEnvVar = extract( classInfo[3] )(); - object ieCore = import( "IECore" ); - object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultLoader" )( searchPathEnvVar ); - object classNames = classLoader.attr( "classNames" )( classNameFilter ); - - // and build menu items to allow each of the alternative classes to be loaded - - int numClasses = len( classNames ); - for( int i=0; i( classNames[i] )(); - object classVersions = classLoader.attr( "versions" )( object( classNames[i] ) ); - int numVersions = len( classVersions ); - - for( int j=0; j( classVersions[j].attr( "__str__" )() )(); - if( numVersions > 1 ) - { - /// \todo We need to make this menu nice and hierarchical. - /// We need the nuke boys to sort that out though. - menuItems.push_back( className + " v" + versionString ); - } - else - { - menuItems.push_back( className ); - } - - menuItems.push_back( ( setClassFormat % parameterPath % className % versionString ).str() ); - } - } - - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassParameterHandler::classChooserKnob", e.what() ); - } - - classChooser->label( label.c_str() ); - classChooser->enumerationKnob()->menu( menuItems ); -} diff --git a/src/IECoreNuke/ClassVectorParameterHandler.cpp b/src/IECoreNuke/ClassVectorParameterHandler.cpp deleted file mode 100644 index ac04bb76b9..0000000000 --- a/src/IECoreNuke/ClassVectorParameterHandler.cpp +++ /dev/null @@ -1,292 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/ClassVectorParameterHandler.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" -#include "IECore/VectorTypedData.h" - -#include "DDImage/Enumeration_KnobI.h" -#include "DDImage/Knobs.h" - -#include "boost/algorithm/string/replace.hpp" -#include "boost/python/suite/indexing/container_utils.hpp" - -using namespace boost; -using namespace std; -using namespace boost::python; -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description ClassVectorParameterHandler::g_description( ClassVectorParameterTypeId ); - -ClassVectorParameterHandler::ClassVectorParameterHandler() -{ -} - -void ClassVectorParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - beginGroup( parameter, knobName, f ); - - childKnobs( parameter, knobName, f ); - - addEditKnobs( parameter, knobName, f ); - - endGroup( parameter, knobName, f ); -} - -void ClassVectorParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - CompoundParameterHandler::setParameterValue( parameter, valueSource ); -} - -void ClassVectorParameterHandler::setState( IECore::Parameter *parameter, const IECore::Object *state ) -{ - const CompoundObject *d = static_cast( state ); - - const vector ¶meterNames = d->member( "__parameterNames" )->readable(); - const vector &classNames = d->member( "__classNames" )->readable(); - const vector &classVersions = d->member( "__classVersions" )->readable(); - - /// \todo C++ code shouldn't have to call python explicity to do this stuff. - /// We could define an abstract C++ class with the right interface and then derive - /// from it to implement it in python. - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::list classes; - for( size_t i=0; i( parameter ) ) ); - pythonParameter.attr( "setClasses" )( classes ); - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassVectorParameterHandler::setState", e.what() ); - } - - CompoundParameterHandler::setState( parameter, state ); -} - -IECore::ObjectPtr ClassVectorParameterHandler::getState( const IECore::Parameter *parameter ) -{ - CompoundObjectPtr result = boost::static_pointer_cast( CompoundParameterHandler::getState( parameter ) ); - if( !result ) - { - result = new CompoundObject; - } - - IECorePython::ScopedGILLock gilLock; - try - { - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - boost::python::list classes = extract( pythonParameter.attr( "getClasses" )( true ) ); - - IECore::StringVectorDataPtr parameterNames = new StringVectorData; - IECore::StringVectorDataPtr classNames = new StringVectorData; - IECore::IntVectorDataPtr classVersions = new IntVectorData; - int numClasses = len( classes ); - for( int i=0; iwritable().push_back( extract( classes[i][1] ) ); - classNames->writable().push_back( extract( classes[i][2] ) ); - classVersions->writable().push_back( extract( classes[i][3] ) ); - } - - result->members()["__parameterNames"] = parameterNames; - result->members()["__classNames"] = classNames; - result->members()["__classVersions"] = classVersions; - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassVectorParameterHandler::getState", e.what() ); - } - return result; -} - -void ClassVectorParameterHandler::addEditKnobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - std::string addName = string( knobName ) + "__addClass"; - std::string removeName = string( knobName ) + "__removeClass"; - - static const char *emptyMenu[] = { " ", "", 0 }; - DD::Image::Knob *addKnob = PyPulldown_knob( f, emptyMenu, addName.c_str(), "Add" ); - DD::Image::Knob *removeKnob = PyPulldown_knob( f, emptyMenu, removeName.c_str(), " Remove" ); - ClearFlags( f, DD::Image::Knob::STARTLINE ); - - if( !f.makeKnobs() ) - { - // making the menu is slow, and only needs doing when we're making knobs (not storing for instance), - // so early out now to avoid massive slowdown. - return; - } - - std::string parameterPath = knobName + 5; // naughty! we're not meant to know the knob name format - replace_all( parameterPath, "_", "']['" ); - - IECorePython::ScopedGILLock gilLock; - try - { - buildAddMenu( addKnob, parameter, parameterPath ); - buildRemoveMenu( removeKnob, parameter, parameterPath ); - } - catch( boost::python::error_already_set &e ) - { - PyErr_Print(); - } - catch( const std::exception &e ) - { - msg( Msg::Error, "ClassVectorParameterHandler::addEditKnobs", e.what() ); - } -} - -void ClassVectorParameterHandler::buildAddMenu( DD::Image::Knob *knob, const IECore::Parameter *parameter, const std::string ¶meterPath ) -{ - vector menuItems; - menuItems.push_back( " " ); - menuItems.push_back( "" ); - - // get the parameter as a python object - - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - - // figure out what classes it accepts - - std::string classNameFilter = "*"; - const CompoundObject *userData = parameter->userData(); - if( const CompoundObject *ui = userData->member( "UI" ) ) - { - if( const StringData *classNameFilterData = ui->member( "classNameFilter" ) ) - { - classNameFilter = classNameFilterData->readable(); - } - } - - std::string searchPathEnvVar = extract( pythonParameter.attr( "searchPathEnvVar" )() )(); - - object ieCore = import( "IECore" ); - object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultLoader" )( searchPathEnvVar ); - object classNames = classLoader.attr( "classNames" )( classNameFilter ); - - // and for each class make a menu item in the add class menu - - int numClasses = len( classNames ); - for( int i=0; i( classNames[i] )(); - object classVersions = classLoader.attr( "versions" )( object( classNames[i] ) ); - int numVersions = len( classVersions ); - - for( int j=0; j( classVersions[j].attr( "__str__" )() )(); - if( numVersions > 1 ) - { - /// \todo We need to make this menu nice and hierarchical. - /// We need the nuke boys to sort that out though. - menuItems.push_back( className + " v" + versionString ); - } - else - { - menuItems.push_back( className ); - } - - - std::string cmd = ( boost::format( - - "with IECoreNuke.FnParameterisedHolder( nuke.thisNode() ).parameterModificationContext() as parameters :" - " parameter = parameters['%s']; parameter.setClass( parameter.newParameterName(), '%s', %d );" - - ) % parameterPath % className % versionString ).str(); - - menuItems.push_back( cmd ); - } - } - - knob->enumerationKnob()->menu( menuItems ); -} - -void ClassVectorParameterHandler::buildRemoveMenu( DD::Image::Knob *knob, const IECore::Parameter *parameter, const std::string ¶meterPath ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - - vector menuItems; - menuItems.push_back( " " ); - menuItems.push_back( "" ); - - // get the parameter as a python object - - boost::python::object pythonParameter( ParameterPtr( const_cast( parameter ) ) ); - - // then make a menu entry in the remove class menu for each currently held class - - boost::python::list classes = extract( pythonParameter.attr( "getClasses" )( true ) ); - - int numClasses = len( classes ); - for( int i=0; i( classes[i][1] ); - const IECore::Parameter *childParameter = compoundParameter->parameter( parameterName ); - - menuItems.push_back( knobLabel( childParameter ) ); - - std::string cmd = ( boost::format( - - "with IECoreNuke.FnParameterisedHolder( nuke.thisNode() ).parameterModificationContext() as parameters :" - " parameter = parameters['%s']; parameter.removeClass( '%s' );" - - ) % parameterPath % parameterName ).str(); - - menuItems.push_back( cmd ); - } - - knob->enumerationKnob()->menu( menuItems ); -} diff --git a/src/IECoreNuke/Color3fParameterHandler.cpp b/src/IECoreNuke/Color3fParameterHandler.cpp deleted file mode 100644 index fc6eae7359..0000000000 --- a/src/IECoreNuke/Color3fParameterHandler.cpp +++ /dev/null @@ -1,88 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/Color3fParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description Color3fParameterHandler::g_description( Color3fParameter::staticTypeId() ); - -Color3fParameterHandler::Color3fParameterHandler() -{ -} - -void Color3fParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - const Color3fParameter *color3fParameter = static_cast( parameter ); - - if( f.makeKnobs() ) - { - m_storage = color3fParameter->typedDefaultValue(); - } - - std::string label = knobLabel( parameter ); - m_knob = Color_knob( f, &m_storage.x, knobName, label.c_str() ); - setKnobProperties( parameter, f, m_knob ); -} - -void Color3fParameterHandler::setParameterValue( Parameter *parameter, ValueSource valueSource ) -{ - Imath::Color3f value; - if( valueSource==Storage ) - { - value = m_storage; - } - else - { - value[0] = m_knob->get_value( 0 ); - value[1] = m_knob->get_value( 1 ); - value[2] = m_knob->get_value( 2 ); - } - - static_cast( parameter )->setTypedValue( value ); -} - -void Color3fParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - Imath::Color3f value = static_cast( parameter )->getTypedValue(); - m_knob->set_value( value[0], 0 ); - m_knob->set_value( value[1], 1 ); - m_knob->set_value( value[2], 2 ); -} - diff --git a/src/IECoreNuke/CompoundParameterHandler.cpp b/src/IECoreNuke/CompoundParameterHandler.cpp deleted file mode 100644 index 4ac51aa685..0000000000 --- a/src/IECoreNuke/CompoundParameterHandler.cpp +++ /dev/null @@ -1,388 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/CompoundParameterHandler.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description CompoundParameterHandler::g_description( CompoundParameter::staticTypeId() ); - -CompoundParameterHandler::CompoundParameterHandler() -{ -} - -int CompoundParameterHandler::minimumInputs( const IECore::Parameter *parameter ) -{ - int min = 0; - int max = 0; - bool error = false; - inputs( parameter, min, max, error ); - return error ? 0 : min; -} - -int CompoundParameterHandler::maximumInputs( const IECore::Parameter *parameter ) -{ - int min = 0; - int max = 0; - bool error = false; - inputs( parameter, min, max, error ); - return error ? 0 : max; -} - -void CompoundParameterHandler::inputs( const IECore::Parameter *parameter, int &minimum, int &maximum, bool &error ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - - bool foundOptionalInputs = false; - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), true ); - if( h ) - { - int min = h->minimumInputs( cIt->get() ); - int max = h->maximumInputs( cIt->get() ); - - if( min && foundOptionalInputs ) - { - msg( Msg::Error, "CompoundParameterHandler::inputs", "Parameter needing inputs found after parameter needing optional inputs." ); - error = true; - } - - if( max != min ) - { - foundOptionalInputs = true; - } - - minimum += min; - maximum += max; - } - } -} - -bool CompoundParameterHandler::testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), true ); - if( h ) - { - int inputs = h->maximumInputs( cIt->get() ); - if( inputs > input ) - { - return h->testInput( cIt->get(), input, op ); - } - input -= inputs; // make indexing relative to the next handler. - } - } - return false; -} - -void CompoundParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), true ); - if( h ) - { - int maxInputs = h->maximumInputs( cIt->get() ); - if( maxInputs ) - { - int minInputs = h->minimumInputs( cIt->get() ); - int numInputs = minInputs==maxInputs ? minInputs : last - first; - h->setParameterValue( cIt->get(), first, first + numInputs ); - first += numInputs; - } - } - } -} - -void CompoundParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - beginGroup( parameter, knobName, f ); - - childKnobs( parameter, knobName, f ); - - endGroup( parameter, knobName, f ); -} - -void CompoundParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - CompoundParameter *compoundParameter = static_cast( parameter ); - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), false ); - if( h ) - { - h->setParameterValue( cIt->get(), valueSource ); - } - } -} - -void CompoundParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), false ); - if( h ) - { - h->setKnobValue( cIt->get() ); - } - } -} - -void CompoundParameterHandler::setState( IECore::Parameter *parameter, const IECore::Object *state ) -{ - const CompoundObject *o = static_cast( state ); - CompoundParameter *compoundParameter = static_cast( parameter ); - - const CompoundObject::ObjectMap &members = o->members(); - for( CompoundObject::ObjectMap::const_iterator it = members.begin(); it!=members.end(); it++ ) - { - Parameter *child = compoundParameter->parameter( it->first ); - if( child ) - { - ParameterHandlerPtr h = handler( child, true ); - if( h ) - { - h->setState( child, it->second.get() ); - } - } - } -} - -IECore::ObjectPtr CompoundParameterHandler::getState( const IECore::Parameter *parameter ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - CompoundObjectPtr result = new CompoundObject; - - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), true ); - if( h ) - { - ObjectPtr childState = h->getState( cIt->get() ); - if( childState ) - { - result->members()[(*cIt)->name()] = childState; - } - } - } - - if( result->members().size() ) - { - return result; - } - - return 0; -} - -void CompoundParameterHandler::beginGroup( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( 0==strcmp( knobName, "parm" ) ) - { - // we don't need any grouping for the top level compound parameter - return; - } - - std::string label = knobLabel( parameter ); - - switch( containerType( parameter ) ) - { - case Tab : - DD::Image::Tab_knob( f, label.c_str() ); - break; - case Toolbar : - DD::Image::BeginToolbar( f, knobName, label.c_str() ); - break; - case Collapsible : - default : - DD::Image::BeginClosedGroup( f, knobName, label.c_str() ); - break; - } -} - -void CompoundParameterHandler::endGroup( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( 0==strcmp( knobName, "parm" ) ) - { - // we don't need any grouping for the top level compound parameter - return; - } - - switch( containerType( parameter ) ) - { - case Tab : - // don't need to do anything to close a tab - break; - case Toolbar : - DD::Image::EndToolbar( f ); - break; - case Collapsible : - default : - DD::Image::EndGroup( f ); - break; - } -} - -void CompoundParameterHandler::childKnobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - const CompoundParameter *compoundParameter = static_cast( parameter ); - - bool inTabGroup = false; - const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); - for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ ) - { - ParameterHandlerPtr h = handler( cIt->get(), true ); - if( h ) - { - bool wantTabGroup = false; - const CompoundParameter *childCompound = runTimeCast( cIt->get() ); - if( childCompound ) - { - wantTabGroup = containerType( childCompound ) == Tab; - } - if( wantTabGroup && !inTabGroup ) - { - DD::Image::BeginTabGroup( f, "" ); - inTabGroup = true; - } - else if( !wantTabGroup && inTabGroup ) - { - DD::Image::EndTabGroup( f ); - inTabGroup = false; - } - - std::string childKnobName = std::string( knobName ) + "_" + (*cIt)->name(); - h->knobs( cIt->get(), childKnobName.c_str(), f ); - } - } -} - -CompoundParameterHandler::ContainerType CompoundParameterHandler::containerType( const IECore::Parameter *parameter ) -{ - const CompoundObject *userData = parameter->userData(); - const CompoundObject *ui = userData->member( "UI" ); - if( !ui ) - { - return Collapsible; - } - - const StringData *typeHint = ui->member( "typeHint" ); - if( !typeHint ) - { - return Collapsible; - } - - if( typeHint->readable()=="collapsible" || typeHint->readable()=="collapsable" ) - { - return Collapsible; - } - else if( typeHint->readable()=="tab" ) - { - return Tab; - } - else if( typeHint->readable()=="toolbar" ) - { - return Toolbar; - } - - return Collapsible; -} - -std::string CompoundParameterHandler::knobLabel( const IECore::Parameter *parameter ) const -{ - // Code to display the same label as would be displayed in maya. - // this relies on the convention of having an invisible StringParameter named - // label immediately under the CompoundParameter. not very pretty. - /// \todo Perhaps we could come up with a better means of specifying labels and header - /// parameters for ClassParameter and ClassVectorParameter. - const CompoundParameter *compoundParameter = static_cast( parameter ); - const StringParameter *labelParameter = compoundParameter->parameter( "label" ); - if( labelParameter ) - { - const CompoundObject *userData = labelParameter->userData(); - const CompoundObject *ui = userData->member( "UI" ); - if( ui ) - { - const BoolData *visible = ui->member( "visible" ); - if( visible && !visible->readable() ) - { - return labelParameter->getTypedValue(); - } - } - } - - return ParameterHandler::knobLabel( parameter ); -} - -ParameterHandlerPtr CompoundParameterHandler::handler( const Parameter *child, bool createIfMissing ) -{ - HandlerMap::const_iterator it = m_handlers.find( child->internedName() ); - if( it!=m_handlers.end() ) - { - return it->second; - } - - if( !createIfMissing ) - { - return 0; - } - - ParameterHandlerPtr h = ParameterHandler::create( child ); - if( !h ) - { - IECore::msg( IECore::Msg::Warning, "IECoreNuke::CompoundParameterHandler", boost::format( "Unable to create handler for parameter \"%s\" of type \"%s\"" ) % child->name() % child->typeName() ); - } - - m_handlers[child->internedName()] = h; - return h; -} diff --git a/src/IECoreNuke/Convert.cpp b/src/IECoreNuke/Convert.cpp deleted file mode 100644 index 7dbc4696e4..0000000000 --- a/src/IECoreNuke/Convert.cpp +++ /dev/null @@ -1,196 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/Convert.h" - -namespace IECore -{ - -template<> -Imath::V2f convert( const DD::Image::Vector2 &from ) -{ - return Imath::V2f( from.x, from.y ); -} - -template<> -Imath::V2d convert( const DD::Image::Vector2 &from ) -{ - return Imath::V2d( from.x, from.y ); -} - -template<> -Imath::V2f convert( const DD::Image::Vector3 &from ) -{ - return Imath::V2f( from.x, from.y ); -} - -template<> -Imath::V2d convert( const DD::Image::Vector3 &from ) -{ - return Imath::V2d( from.x, from.y ); -} - -template<> -Imath::V3f convert( const DD::Image::Vector3 &from ) -{ - return Imath::V3f( from.x, from.y, from.z ); -} - -template<> -Imath::V3d convert( const DD::Image::Vector3 &from ) -{ - return Imath::V3d( from.x, from.y, from.z ); -} - -template<> -Imath::Color3f convert( const DD::Image::Vector3 &from ) -{ - return Imath::Color3f( from.x, from.y, from.z ); -} - -template<> -DD::Image::Vector3 convert( const Imath::V3f &from ) -{ - return DD::Image::Vector3( from.x, from.y, from.z ); -} - -template<> -DD::Image::Vector3 convert( const Imath::V3d &from ) -{ - return DD::Image::Vector3( from.x, from.y, from.z ); -} - -template<> -Imath::V2f convert( const DD::Image::Vector4 &from ) -{ - return Imath::V2f( from.x, from.y ); -} - -template<> -Imath::V2d convert( const DD::Image::Vector4 &from ) -{ - return Imath::V2d( from.x, from.y ); -} - -template<> -Imath::V3f convert( const DD::Image::Vector4 &from ) -{ - return Imath::V3f( from.x, from.y, from.z ); -} - -template<> -Imath::V3d convert( const DD::Image::Vector4 &from ) -{ - return Imath::V3d( from.x, from.y, from.z ); -} - -template<> -Imath::Color3f convert( const DD::Image::Vector4 &from ) -{ - return Imath::Color3f( from.x, from.y, from.z ); -} - -template<> -Imath::Color4f convert( const DD::Image::Vector4 &from ) -{ - return Imath::Color4f( from.x, from.y, from.z, from.w ); -} - -template<> -Imath::M44f convert( const DD::Image::Matrix4 &from ) -{ - Imath::M44f result; - for( unsigned int i=0; i<4; i++ ) - { - for( unsigned int j=0; j<4; j++ ) - { - result[j][i] = from[j][i]; - } - } - return result; -} - -template<> -Imath::M44d convert( const DD::Image::Matrix4 &from ) -{ - Imath::M44d result; - for( unsigned int i=0; i<4; i++ ) - { - for( unsigned int j=0; j<4; j++ ) - { - result[j][i] = from[j][i]; - } - } - return result; -} - -template<> -DD::Image::Matrix4 convert( const Imath::M44d& transform ) -{ - DD::Image::Matrix4 nukeMatrix; - for ( unsigned x=0; x < 4; x++ ) - { - for ( unsigned y=0; y < 4; y++ ) - { - nukeMatrix[x][y] = transform[x][y]; - } - } - return nukeMatrix; -} - -template<> -Imath::Box2i convert( const DD::Image::Box &from ) -{ - return Imath::Box2i( Imath::V2i( from.x(), from.y() ), Imath::V2i( from.r(), from.t() ) ); -} - -template<> -DD::Image::Box3 convert( const Imath::Box3f &from ) -{ - return DD::Image::Box3( convert( from.min ), convert( from.max ) ); -} - -template<> -Imath::Box3f convert( const DD::Image::Box3 &from ) -{ - return Imath::Box3f( convert( from.min() ), convert( from.max() ) ); -} - -template<> -Imath::Box3d convert( const DD::Image::Box3 &from ) -{ - return Imath::Box3d( convert( from.min() ), convert( from.max() ) ); -} - -} // namespace IECore diff --git a/src/IECoreNuke/DisplayIop.cpp b/src/IECoreNuke/DisplayIop.cpp deleted file mode 100644 index 4f3ba5f958..0000000000 --- a/src/IECoreNuke/DisplayIop.cpp +++ /dev/null @@ -1,312 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2012, J3P LLC. All rights reserved. -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/DisplayIop.h" - -#include "IECoreNuke/TypeIds.h" - -#include "IECoreImage/ImageDisplayDriver.h" - -#include "IECore/LRUCache.h" - -#include "DDImage/Knobs.h" -#include "DDImage/Row.h" - -#include "boost/bind/bind.hpp" -#include "boost/lexical_cast.hpp" -#include "boost/signals2.hpp" - -using namespace boost::placeholders; -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreNuke; -using namespace DD::Image; -using namespace Imath; - -////////////////////////////////////////////////////////////////////////// -// DisplayDriverServer cache. Many nodes may all want to use a server on -// the same port. We therefore use an LRUCache to manage the lifetime of -// the servers and provide them to the nodes. -////////////////////////////////////////////////////////////////////////// - -typedef LRUCache ServerCache; - -// key is the port number for the server. -static DisplayDriverServerPtr serverCacheGetter( int key, size_t &cost ) -{ - cost = 1; - return new DisplayDriverServer( key ); -} - -// max cost of 4 means we will never have more than 4 unused servers at any one time. -static ServerCache g_servers( serverCacheGetter, 4 ); - -////////////////////////////////////////////////////////////////////////// -// NukeDisplayDriver implementation -////////////////////////////////////////////////////////////////////////// - -namespace IECoreNuke -{ - -class NukeDisplayDriver : public IECoreImage::ImageDisplayDriver -{ - - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( NukeDisplayDriver, NukeDisplayDriverTypeId, IECoreImage::ImageDisplayDriver ); - - NukeDisplayDriver( const Imath::Box2i &displayWindow, const Imath::Box2i &dataWindow, const std::vector &channelNames, ConstCompoundDataPtr parameters ) - : ImageDisplayDriver( displayWindow, dataWindow, channelNames, parameters ) - { - if( parameters ) - { - m_parameters = parameters->copy(); - } - else - { - m_parameters = new CompoundData; - } - - instanceCreatedSignal( this ); - } - - virtual ~NukeDisplayDriver() - { - } - - /// Returns a copy of the parameters used in creating this instance. This - /// is useful in recognising relevant instances in the instanceCreatedSignal. - ConstCompoundDataPtr parameters() const - { - return m_parameters; - } - - /// Updates the current image, and then emits the dataReceivedSignal. - virtual void imageData( const Imath::Box2i &box, const float *data, size_t dataSize ) - { - ImageDisplayDriver::imageData( box, data, dataSize ); - dataReceivedSignal( this, box ); - } - - /// This signal is emitted when a new NukeDisplayDriver has been created. - /// This allows nuke nodes to pick up the new DisplayDrivers even when they're - /// created in some other code, such as a DisplayDriverServer. - typedef boost::signals2::signal InstanceCreatedSignal; - static InstanceCreatedSignal instanceCreatedSignal; - - /// This signal is emitted when this NukeDisplayDriver instance receives new data. - typedef boost::signals2::signal DataReceivedSignal; - DataReceivedSignal dataReceivedSignal; - - private : - - static const DisplayDriverDescription g_description; - - ConstCompoundDataPtr m_parameters; - -}; - -NukeDisplayDriver::InstanceCreatedSignal NukeDisplayDriver::instanceCreatedSignal; -const DisplayDriver::DisplayDriverDescription NukeDisplayDriver::g_description; - -} // namespace IECoreNuke - -////////////////////////////////////////////////////////////////////////// -// DisplayIop implementation -////////////////////////////////////////////////////////////////////////// - -const DD::Image::Iop::Description DisplayIop::g_description( "ieDisplay", DisplayIop::build ); - -DisplayIop::DisplayIop( Node *node ) - : Iop( node ), m_portNumber( 1559 ), m_server( g_servers.get( m_portNumber ) ), m_updateCount( 0 ), m_driver( 0 ) -{ - inputs( 0 ); - slowness( 0 ); // disable caching as we're buffering everything internally ourselves - NukeDisplayDriver::instanceCreatedSignal.connect( boost::bind( &DisplayIop::driverCreated, this, _1 ) ); -} - -DisplayIop::~DisplayIop() -{ - NukeDisplayDriver::instanceCreatedSignal.disconnect( boost::bind( &DisplayIop::driverCreated, this, _1 ) ); - connectToDriver( 0 ); -} - -const char *DisplayIop::Class() const -{ - return "ieDisplay"; -} - -const char *DisplayIop::node_help() const -{ - return "Acts as a framebuffer for external renderers."; -} - -void DisplayIop::knobs( DD::Image::Knob_Callback f ) -{ - Iop::knobs( f ); - - Int_knob( f, &m_portNumber, "portNumber", "Port Number" ); - // we must have KNOB_CHANGED_RECURSIVE set otherwise nuke doesn't give us knob_changed() - // calls when the knob value is changed from a knobChanged method of a PythonPanel. - SetFlags( f, Knob::KNOB_CHANGED_ALWAYS | Knob::KNOB_CHANGED_RECURSIVE | Knob::NO_ANIMATION ); - Tooltip( - f, - "The port on which to receive images. This must match " - "the port being used by the renderer to send images." - ); - -} - -int DisplayIop::knob_changed( DD::Image::Knob *knob ) -{ - if( knob->is( "portNumber" ) ) - { - int portNumber = (int)this->knob( "portNumber" )->get_value(); - m_server = g_servers.get( portNumber ); - return 1; - } - - return Iop::knob_changed( knob ); -} - -void DisplayIop::append( DD::Image::Hash &hash ) -{ - Iop::append( hash ); - - hash.append( __DATE__ ); - hash.append( __TIME__ ); - hash.append( firstDisplayIop()->m_updateCount ); -} - -void DisplayIop::_validate( bool forReal ) -{ - Box2i displayWindow( V2i( 0, 0 ), V2i( 255, 255 ) ); - - if( firstDisplayIop()->m_driver ) - { - displayWindow = firstDisplayIop()->m_driver->image()->getDisplayWindow(); - } - - m_format = m_fullSizeFormat = Format( displayWindow.size().x + 1, displayWindow.size().y + 1 ); - // these set function don't copy the format, but instead reference its address. - // we therefore have to store the format as member data. - info_.format( m_format ); - info_.full_size_format( m_fullSizeFormat ); - info_.set( m_format ); - - info_.channels( Mask_RGBA ); -} - -void DisplayIop::engine( int y, int x, int r, const DD::Image::ChannelSet &channels, DD::Image::Row &row ) -{ - Channel outputChannels[4] = { Chan_Red, Chan_Green, Chan_Blue, Chan_Alpha }; - const char *inputChannels[] = { "R", "G", "B", "A", nullptr }; - - const ImagePrimitive *image = nullptr; - Box2i inputDataWindow; - Box2i inputDisplayWindow; - if( firstDisplayIop()->m_driver ) - { - image = firstDisplayIop()->m_driver->image().get(); - inputDataWindow = image->getDataWindow(); - inputDisplayWindow = image->getDisplayWindow(); - } - - int i = 0; - while( inputChannels[i] ) - { - const FloatVectorData *inputData = image ? image->getChannel( inputChannels[i] ) : nullptr; - if( inputData ) - { - float *output = row.writable( outputChannels[i] ) + x; - // remap coordinate relative to our data window. nuke images have pixel origin at bottom, - // cortex images have pixel origin at top. - V2i pDataWindow = V2i( x, inputDisplayWindow.max.y - y ) - inputDataWindow.min; - const float *input = &((inputData->readable())[pDataWindow.y*(inputDataWindow.size().x+1) + pDataWindow.x]); - memcpy( output, input, (r-x) * sizeof( float ) ); - } - else - { - row.erase( outputChannels[i] ); - } - i++; - } -} - -DD::Image::Op *DisplayIop::build( Node *node ) -{ - return new DisplayIop( node ); -} - -DisplayIop *DisplayIop::firstDisplayIop() -{ - return static_cast( firstOp() ); -} - -void DisplayIop::driverCreated( NukeDisplayDriver *driver ) -{ - ConstStringDataPtr portNumber = driver->parameters()->member( "displayPort" ); - if( portNumber && boost::lexical_cast( portNumber->readable() ) == m_portNumber ) - { - firstDisplayIop()->connectToDriver( driver ); - } -} - -void DisplayIop::connectToDriver( NukeDisplayDriver *driver ) -{ - assert( this == firstDisplayIop() ); - - if( m_driver ) - { - m_driver->dataReceivedSignal.disconnect( boost::bind( &DisplayIop::driverDataReceived, this, _1, _2 ) ); - } - - m_driver = driver; - if( m_driver ) - { - m_driver->dataReceivedSignal.connect( boost::bind( &DisplayIop::driverDataReceived, this, _1, _2 ) ); - } - - m_updateCount++; - asapUpdate(); -} - -void DisplayIop::driverDataReceived( NukeDisplayDriver *driver, const Imath::Box2i &box ) -{ - assert( this == firstDisplayIop() ); - m_updateCount++; - asapUpdate(); -} diff --git a/src/IECoreNuke/DrawableHolder.cpp b/src/IECoreNuke/DrawableHolder.cpp deleted file mode 100644 index 9d2f16c8b6..0000000000 --- a/src/IECoreNuke/DrawableHolder.cpp +++ /dev/null @@ -1,217 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/DrawableHolder.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreGL/Camera.h" -#include "IECoreGL/Group.h" -#include "IECoreGL/Renderer.h" -#include "IECoreGL/Scene.h" - -#include "IECoreScene/WorldBlock.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" - -#include "DDImage/Knob.h" -#include "DDImage/Knobs.h" -#include "DDImage/ViewerContext.h" - -using namespace IECoreNuke; - -const DD::Image::Op::Description DrawableHolder::g_description( "ieDrawable", build ); - -DrawableHolder::DrawableHolder( Node *node ) - : ParameterisedHolderOp( node ), - m_scene( 0 ), - m_transform( DD::Image::Matrix4::identity() ), - m_transformKnob( 0 ) -{ - inputs( 0 ); -} - -DrawableHolder::~DrawableHolder() -{ -} - -void DrawableHolder::knobs( DD::Image::Knob_Callback f ) -{ - ParameterisedHolderOp::knobs( f ); - - DD::Image::Tab_knob( f, "Transform" ); - - m_transformKnob = DD::Image::Axis_knob( f, &m_transform, "transform", "Transform" ); - -} - -void DrawableHolder::build_handles( DD::Image::ViewerContext *ctx ) -{ - if( ctx->transform_mode() == DD::Image::VIEWER_2D ) - { - return; - } - - if( m_transformKnob->build_handle( ctx ) ) - { - m_transformKnob->add_draw_handle( ctx ); - } - - DD::Image::Matrix4 parentMatrix = ctx->modelmatrix; - ctx->modelmatrix *= m_transform; - - buildParameterKnobHandles( ctx ); - - IECoreGL::ConstScenePtr s = scene(); - if( s ) - { - Imath::Box3f b = s->root()->bound(); - if( b.hasVolume() ) - { - ctx->expand_bbox( node_selected(), IECore::convert( b ) ); - } - } - - add_draw_handle( ctx ); - - ctx->modelmatrix = parentMatrix; -} - -void DrawableHolder::draw_handle( DD::Image::ViewerContext *ctx ) -{ - if( ctx->draw_solid() ) - { - IECoreGL::ConstScenePtr s = scene(); - if( s ) - { - - // nuke apparently uses the name stack to determine which handle is under - // the mouse. the IECoreGL::NameStateComponent will ruin this by overwriting - // the current name. we work around this by pushing another name onto the stack. - // the NameStateComponent will overwrite this name, but nuke will still detect - // hits on the drawable using the original name one level lower in the stack. - glPushName( 0 ); - - try - { - s->render(); - } - catch( const std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::draw_handle", e.what() ); - } - - glPopName(); - - } - } -} - -IECoreGL::ConstScenePtr DrawableHolder::scene() -{ - if( m_scene && hash()==m_sceneHash ) - { - return m_scene; - } - - m_scene = 0; - - IECore::ConstRunTimeTypedPtr drawable = parameterised(); - if( drawable ) - { - setParameterValues(); - - try - { - - IECoreGL::RendererPtr renderer = new IECoreGL::Renderer(); - renderer->setOption( "gl:mode", new IECore::StringData( "deferred" ) ); - - { - IECoreScene::WorldBlock worldBlock( renderer ); - { - IECorePython::ScopedGILLock gilLock; - boost::python::object pythonDrawable( boost::const_pointer_cast( drawable ) ); - pythonDrawable.attr( "draw" )( IECoreScene::RendererPtr( renderer ) ); - } - } - - m_scene = renderer->scene(); - m_scene->setCamera( 0 ); - - } - catch( boost::python::error_already_set &e ) - { - IECorePython::ScopedGILLock gilLock; - PyErr_Print(); - } - catch( const std::exception &e ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::scene", e.what() ); - } - catch( ... ) - { - IECore::msg( IECore::Msg::Error, "DrawableHolder::scene", "Caught unknown exception" ); - } - - } - - m_sceneHash = hash(); - return m_scene; -} - -Imath::M44f DrawableHolder::transform() -{ - return IECore::convert( m_transform ); -} - -DD::Image::Op *DrawableHolder::build( Node *node ) -{ - return new DrawableHolder( node ); -} - -const char *DrawableHolder::Class() const -{ - return g_description.name; -} - -const char *DrawableHolder::node_help() const -{ - return "Displays drawable things."; -} diff --git a/src/IECoreNuke/FloatParameterHandler.cpp b/src/IECoreNuke/FloatParameterHandler.cpp deleted file mode 100644 index 45996aa6f0..0000000000 --- a/src/IECoreNuke/FloatParameterHandler.cpp +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/FloatParameterHandler.h" - -#include "IECore/NumericParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description FloatParameterHandler::g_description( FloatParameter::staticTypeId() ); - -FloatParameterHandler::FloatParameterHandler() - : m_storage( 0 ), - m_knob( 0 ) -{ -} - -void FloatParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - const FloatParameter *floatParameter = static_cast( parameter ); - - if( f.makeKnobs() ) - { - m_storage = floatParameter->numericDefaultValue(); - } - - std::string label = knobLabel( parameter ); - DD::Image::IRange range( floatParameter->minValue(), floatParameter->maxValue() ); - m_knob = Float_knob( f, &m_storage, range, knobName, label.c_str() ); - DD::Image::SetFlags( f, DD::Image::Knob::FORCE_RANGE ); - if( !(floatParameter->hasMinValue() && floatParameter->hasMaxValue()) ) - { - DD::Image::ClearFlags( f, DD::Image::Knob::SLIDER ); - } - setKnobProperties( parameter, f, m_knob ); -} - -void FloatParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - FloatParameter *floatParameter = static_cast( parameter ); - if( valueSource==Storage ) - { - floatParameter->setNumericValue( m_storage ); - } - else - { - floatParameter->setNumericValue( m_knob->get_value() ); - } -} - -void FloatParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const FloatParameter *floatParameter = static_cast( parameter ); - m_knob->set_value( floatParameter->getNumericValue() ); -} diff --git a/src/IECoreNuke/FromNukeCameraConverter.cpp b/src/IECoreNuke/FromNukeCameraConverter.cpp deleted file mode 100644 index 089fb98f3c..0000000000 --- a/src/IECoreNuke/FromNukeCameraConverter.cpp +++ /dev/null @@ -1,104 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/FromNukeCameraConverter.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreScene/Camera.h" -#include "IECoreScene/MatrixTransform.h" - -#include "IECore/AngleConversion.h" -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" - -using namespace IECoreNuke; -using namespace IECore; -using namespace IECoreScene; -using namespace Imath; - -FromNukeCameraConverter::FromNukeCameraConverter( const DD::Image::CameraOp *camera ) - : FromNukeConverter( "Converts nuke cameras to IECore cameras." ), m_camera( camera ) -{ -} - -FromNukeCameraConverter::~FromNukeCameraConverter() -{ -} - -IECore::ObjectPtr FromNukeCameraConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - CameraPtr result = new IECoreScene::Camera(); - - // clipping planes - result->setClippingPlanes( V2f( m_camera->Near(), m_camera->Far() ) ); - - // projection - switch( m_camera->projection_mode() ) - { - case DD::Image::CameraOp::LENS_PERSPECTIVE : - { - result->setProjection( "perspective" ); - result->setFocalLength( m_camera->focal_length() ); - break; - } - case DD::Image::CameraOp::LENS_UV : - case DD::Image::CameraOp::LENS_SPHERICAL : - case DD::Image::CameraOp::LENS_RENDER_CAMERA : - msg( Msg::Warning, "FromNukeCameraConverter::doConversion", "Unsupported projection type - reverting to orthographic" ); - // fall through to orthographic code - [[fallthrough]]; - case DD::Image::CameraOp::LENS_ORTHOGRAPHIC : - { - result->setProjection( "orthographic" ); - break; - } - } - - // TODO - I haven't tested any of this - I'm not sure how to use it, because it doesn't appear to - // be used anywhere. Why does it even exist? - V2f screenWindowScale = IECore::convert( m_camera->win_scale() ); - V2f screenWindowTranslate = IECore::convert( m_camera->win_translate() ); - result->setAperture( V2f( m_camera->film_width(), m_camera->film_height() ) * screenWindowScale ); - result->setApertureOffset( screenWindowTranslate ); - - // we don't currently support window roll - if( m_camera->win_roll() != 0.0 ) - { - msg( Msg::Warning, "FromNukeCameraConverter::doConversion", "Window roll is not supported" ); - } - - return result; -} diff --git a/src/IECoreNuke/FromNukeConverter.cpp b/src/IECoreNuke/FromNukeConverter.cpp deleted file mode 100644 index 850d29cbe3..0000000000 --- a/src/IECoreNuke/FromNukeConverter.cpp +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/FromNukeConverter.h" - -using namespace IECore; -using namespace IECoreNuke; - -FromNukeConverter::FromNukeConverter( const std::string &description ) - : ToCoreConverter( description ) -{ -} - -FromNukeConverter::~FromNukeConverter() -{ -} diff --git a/src/IECoreNuke/FromNukePointsConverter.cpp b/src/IECoreNuke/FromNukePointsConverter.cpp deleted file mode 100644 index 38b1b792b2..0000000000 --- a/src/IECoreNuke/FromNukePointsConverter.cpp +++ /dev/null @@ -1,155 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/FromNukePointsConverter.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreScene/PointsPrimitive.h" - -#include "DDImage/ParticleOp.h" - -using namespace IECoreNuke; -using namespace IECore; -using namespace IECoreScene; -using namespace DD::Image; - -FromNukePointsConverter::FromNukePointsConverter( const DD::Image::GeoInfo *geo, DD::Image::Op* op ) - : FromNukeConverter( "Converts nuke ParticleSprites to IECore PointsPrimitive." ), m_geo( geo ), m_op( op ) -{ -} - -FromNukePointsConverter::~FromNukePointsConverter() -{ -} - -IECore::ObjectPtr FromNukePointsConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - - // get points - V3fVectorDataPtr p = new V3fVectorData(); - if( const DD::Image::PointList *pl = m_geo->point_list() ) - { - p->writable().resize( pl->size() ); - std::transform( pl->begin(), pl->end(), p->writable().begin(), IECore::convert ); - } - - PointsPrimitivePtr result = new PointsPrimitive( p ); - - // get colour - const DD::Image::Attribute *colorAttr = m_geo->get_typed_attribute( "Cf", DD::Image::VECTOR4_ATTRIB ); - if( colorAttr && colorAttr->size() == result->getNumPoints() ) - { - Color3fVectorDataPtr colorData = new Color3fVectorData(); - colorData->writable().resize( result->getNumPoints() ); - std::transform( colorAttr->vector4_list->begin(), colorAttr->vector4_list->end(), colorData->writable().begin(), IECore::convert ); - result->variables["Cs"] = PrimitiveVariable( PrimitiveVariable::Vertex, colorData ); - - // Adding a separate alpha primvar as according to my test - // Cs is a Color3f in Gaffer. While we could also use 3f here, I think it is reasonable - // to combine alpha inside Cs and hope it gets supported by Gaffer and then we can remove - // the alpha primvar. - FloatVectorDataPtr alphaData = new FloatVectorData(); - auto& alpha = alphaData->writable(); - alpha.resize( result->getNumPoints() ); - - for( size_t i=0; i < result->getNumPoints(); i++ ) - { - alpha[i] = colorAttr->vector4( i ).w; - } - result->variables["alpha"] = PrimitiveVariable( PrimitiveVariable::Vertex, alphaData ); - } - - // get pid - const DD::Image::Attribute *idAttr = m_geo->get_typed_attribute( "id", DD::Image::INT_ATTRIB ); - if( idAttr && idAttr->size() == result->getNumPoints() ) - { - IntVectorDataPtr idData = new IntVectorData(); - auto& id = idData->writable(); - id.resize( result->getNumPoints() ); - for( size_t i=0; i < result->getNumPoints(); i++ ) - { - id[i] = idAttr->integer( i ); - } - result->variables["pid"] = PrimitiveVariable( PrimitiveVariable::Vertex, idData ); - } - - // get size/width - const DD::Image::Attribute *sizeAttr = m_geo->get_typed_attribute( "size", DD::Image::FLOAT_ATTRIB ); - if( sizeAttr && sizeAttr->size() == result->getNumPoints() ) - { - FloatVectorDataPtr widthData = new FloatVectorData(); - auto& width = widthData->writable(); - width.resize( result->getNumPoints() ); - - for( size_t i=0; i < result->getNumPoints(); i++ ) - { - width[i] = sizeAttr->flt( i ); - } - result->variables["width"] = PrimitiveVariable( PrimitiveVariable::Vertex, widthData ); - } - - // get vel - // Nuke's particle system seems to be a bit ad-hock rather than integrated in the 3D sub-system. - // To get the particle velocity, we mix the API ( ParticleOp and GeoOp ). Arguably, we could switch - // to use the ParticleOp API for everything but for now I decided to keep accessing what can be using the - // GeoOp/GeoInfo API, hoping that Foundry will ultimately get the particle to geo fully supported. - // - // Another important detail here is that we are using the m_op->input0, this is based on the expectation - // that the LiveScene will always be the client of this kind of converter. - // In which case, the LiveScene is always internal to a GeoOp derived node (LiveSceneHolder or WriteGeo) - auto particleOp = m_op->particleOp(); - if ( particleOp ) - { - OutputContext oc; - oc.setFrame( m_op->outputContext().frame() ); - particleOp->setOutputContext( oc ); - float prevTime, outTime; - const auto particleSystem = particleOp->getParticleSystem(prevTime, outTime, true, nullptr); - - V3fVectorDataPtr velData = new V3fVectorData(); - auto& vel = velData->writable(); - vel.resize( result->getNumPoints() ); - for( size_t i=0; i < result->getNumPoints(); i++ ) - { - // velocity seems to be calculated per time step so we need to multiply by the frames per second to get velocity compatible with motion blur rendering. - vel[i] = IECore::convert( particleSystem->particleVelocity( i ) ) * DD::Image::root_real_fps(); - } - - result->variables["velocity"] = PrimitiveVariable( PrimitiveVariable::Vertex, velData ); - } - // \todo Other primitive variables - - return result; -} diff --git a/src/IECoreNuke/FromNukeTileConverter.cpp b/src/IECoreNuke/FromNukeTileConverter.cpp deleted file mode 100644 index bf1531b00d..0000000000 --- a/src/IECoreNuke/FromNukeTileConverter.cpp +++ /dev/null @@ -1,93 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/FromNukeTileConverter.h" - -#include "IECoreImage/ImagePrimitive.h" - -using namespace Imath; -using namespace IECore; -using namespace IECoreImage; -using namespace IECoreNuke; - -FromNukeTileConverter::FromNukeTileConverter( const DD::Image::Tile *tile ) - : FromNukeConverter( "Converts nuke Tiles to IECoreImage ImagePrimitives." ), m_tile( tile ) -{ -} - -FromNukeTileConverter::~FromNukeTileConverter() -{ -} - -IECore::ObjectPtr FromNukeTileConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - Box2i dataWindow( V2i( m_tile->x(), m_tile->y() ), V2i( m_tile->r() - 1, m_tile->t() - 1 ) ); - ImagePrimitivePtr result = new ImagePrimitive( dataWindow, dataWindow ); - - foreach( z, m_tile->channels() ) - { - std::string name; - switch( z ) - { - case DD::Image::Chan_Red : - name = "R"; - break; - case DD::Image::Chan_Green : - name = "G"; - break; - case DD::Image::Chan_Blue : - name = "B"; - break; - case DD::Image::Chan_Alpha : - name = "A"; - break; - case DD::Image::Chan_Z : - name = "Z"; - break; - default : - name = getName( z ); - } - - FloatVectorDataPtr channelData = result->createChannel( name ); - float *out = &*(channelData->writable().begin()); - - for( int y=m_tile->t()-1; y>=m_tile->y(); y-- ) - { - memcpy( out, (*m_tile)[z][y] + m_tile->x(), m_tile->w() * sizeof( float ) ); - out += m_tile->w(); - } - } - - return result; -} diff --git a/src/IECoreNuke/ImagePrimitiveParameterHandler.cpp b/src/IECoreNuke/ImagePrimitiveParameterHandler.cpp deleted file mode 100644 index e6c2454bd3..0000000000 --- a/src/IECoreNuke/ImagePrimitiveParameterHandler.cpp +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ImagePrimitiveParameterHandler.h" - -#include "IECoreNuke/FromNukeTileConverter.h" - -#include "IECoreImage/ImagePrimitive.h" -#include "IECoreImage/ImagePrimitiveParameter.h" - -using namespace IECoreNuke; - -ParameterHandler::Description ImagePrimitiveParameterHandler::g_description( (IECore::TypeId)IECoreImage::ImagePrimitiveParameter::staticTypeId() ); - -ImagePrimitiveParameterHandler::ImagePrimitiveParameterHandler() -{ -} - -int ImagePrimitiveParameterHandler::minimumInputs( const IECore::Parameter *parameter ) -{ - return 1; -} - -int ImagePrimitiveParameterHandler::maximumInputs( const IECore::Parameter *parameter ) -{ - return 1; -} - -bool ImagePrimitiveParameterHandler::testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ) -{ - if( dynamic_cast( op ) ) - { - return 1; - } - return 0; -} - -void ImagePrimitiveParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) -{ - DD::Image::Iop *iOp = static_cast( *first ); - if( iOp ) - { - DD::Image::Tile tile( *iOp, iOp->requested_channels(), true ); - - FromNukeTileConverterPtr converter = new FromNukeTileConverter( &tile ); - IECoreImage::ImagePrimitivePtr image = boost::static_pointer_cast( converter->convert() ); - - /// \todo Sort out data window vs display window and suchlike. - - parameter->setValue( image ); - return; - } - - // no input - set parameter to default value. - parameter->setValue( parameter->defaultValue()->copy() ); -} diff --git a/src/IECoreNuke/IntParameterHandler.cpp b/src/IECoreNuke/IntParameterHandler.cpp deleted file mode 100644 index 7653b944f4..0000000000 --- a/src/IECoreNuke/IntParameterHandler.cpp +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/IntParameterHandler.h" - -#include "IECore/NumericParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description IntParameterHandler::g_description( IntParameter::staticTypeId() ); - -IntParameterHandler::IntParameterHandler() - : m_storage( 0 ), - m_knob( 0 ) -{ -} - -void IntParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - const IntParameter *intParameter = static_cast( parameter ); - - if( f.makeKnobs() ) - { - m_storage = intParameter->numericDefaultValue(); - } - - std::string label = knobLabel( parameter ); - DD::Image::IRange range( intParameter->minValue(), intParameter->maxValue() ); - m_knob = Int_knob( f, &m_storage, range, knobName, label.c_str() ); - DD::Image::SetFlags( f, DD::Image::Knob::FORCE_RANGE ); - setKnobProperties( parameter, f, m_knob ); -} - -void IntParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - IntParameter *intParameter = static_cast( parameter ); - if( valueSource==Storage ) - { - intParameter->setNumericValue( m_storage ); - } - else - { - intParameter->setNumericValue( (int)m_knob->get_value() ); - } -} - -void IntParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const IntParameter *intParameter = static_cast( parameter ); - m_knob->set_value( intParameter->getNumericValue(), 0 ); -} - diff --git a/src/IECoreNuke/LensDistort.cpp b/src/IECoreNuke/LensDistort.cpp deleted file mode 100644 index 17ebfddd7a..0000000000 --- a/src/IECoreNuke/LensDistort.cpp +++ /dev/null @@ -1,622 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Weta Digital Limited. All rights reserved. -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/LensDistort.h" - -#include "IECore/CachedReader.h" -#include "IECore/FastFloat.h" -#include "IECore/NumericParameter.h" -#include "IECore/Reader.h" - -#include "DDImage/Pixel.h" -#include "DDImage/Tile.h" - -#include "boost/algorithm/string.hpp" -#include "boost/regex.hpp" - -#include -#include -#include - -#include -#include -#include - -using namespace DD::Image; - -namespace IECoreNuke -{ - -static const char* const CLASS = "ieLensDistort"; - -static const char* const HELP = "Applies or removes lens distortion from an input using a parameterised lens model."; - -DD::Image::Op *LensDistort::build( Node *node ){ return new LensDistort( node ); } - -const Iop::Description LensDistort::m_description( CLASS, LensDistort::build ); - -const char *LensDistort::Class() const { return m_description.name; } - -const char *LensDistort::node_help() const { return HELP; } - -const char ** LensDistort::modelNames() -{ - static bool init = false; - static std::vector lensModels = IECore::LensModel::lensModels(); - static const char ** cStrings = new const char*[lensModels.size()+1]; - - if ( !init ) - { - const unsigned int nLensModels( lensModels.size() ); - for ( unsigned int i = 0; i < nLensModels; i++ ) - { - cStrings[i] = lensModels[i].c_str(); - } - cStrings[lensModels.size()] = 0; - init = true; - } - - return cStrings; -} - -int LensDistort::indexFromModelName( const char *name ) -{ - const char** names = modelNames(); - for ( int idx = 0; names[idx] != 0; ++idx ) - { - if (strcmp(names[idx], name) == 0) return idx; - } - return 0; -} - -LensDistort::LensDistort( Node* node ) : - Iop(node), - m_nThreads( std::max( 16u, Thread::numCPUs + Thread::numThreads + 1 ) ), - m_lensModel( 0 ), - m_numNewKnobs( 0 ), - m_kModel( NULL ), - m_mode( Distort ), - m_assetPath( "" ), - m_hasValidFileSequence( false ), - m_useFileSequence( false ) -{ - // Work out the most threads we can have and create an instance of the lens model for each one. - // This is useful for any lens model implementation that uses the ldpk library is as it is not thread safe. - m_locks = new Lock[m_nThreads]; - m_model.resize( m_nThreads, NULL ); - for( int i = 0; i < m_nThreads; ++i ) m_model[i] = IECore::LensModel::create(modelNames()[0]); -} - -void LensDistort::updateLensModel( bool updateKnobsFromParameters ) -{ - if ( updateKnobsFromParameters ) m_pluginAttributes.clear(); // Give us a fresh start by clearing our internal parameter list. - - // Get the parameters from our lens model. - std::vector params( m_model[0]->parameters()->orderedParameters() ); - - // For each parameter in the new lens model, check to see if we already have a similar knob on our UI. If we do then we copy the value - // of the old parameter to the new. - int attrIdx = 0; - for( std::vector::iterator j = params.begin(); j != params.end(); ++j ) - { - // Get the default value. - IECore::ConstObjectPtr o( (*j)->getValue() ); - - // We only handle double parameters so ignore all other types... - IECore::ConstDoubleDataPtr d = IECore::runTimeCast( o.get() ); - if (!d) continue; - - bool parameterExists = false; - for (unsigned int i = attrIdx; i < m_pluginAttributes.size(); i++) - { - if ( (*j)->name() == m_pluginAttributes[i].m_name ) - { - // Move the existing parameter to the correct location in our list of parameters. - parameterExists = true; - m_pluginAttributes.insert( m_pluginAttributes.begin()+attrIdx, m_pluginAttributes[i] ); - m_pluginAttributes.erase( m_pluginAttributes.begin()+i+1 ); - break; - } - } - ++attrIdx; - - if ( parameterExists ) continue; - - // Add the new attribute. - double value( d->readable() ); - m_pluginAttributes.insert( m_pluginAttributes.begin()+attrIdx-1, PluginAttribute( (*j)->name().c_str(), value ) ); - } - - // Erase all remaining parameters that are not in our current lens model. - m_pluginAttributes.erase( m_pluginAttributes.begin()+attrIdx, m_pluginAttributes.end() ); - -} - -void LensDistort::setLensModel( IECore::ConstCompoundObjectPtr parameters ) -{ - const unsigned int nPlugins( m_nThreads ); - if ( parameters ) - { - for( unsigned int i = 0; i < nPlugins; ++i ) - { - m_model[i] = IECore::LensModel::create( parameters ); - } - } - - updateLensModel( true ); -} - -void LensDistort::setLensModel( std::string modelName ) -{ - const unsigned int nPlugins( m_nThreads ); - for( unsigned int i = 0; i < nPlugins; ++i ) - { - m_model[i] = IECore::LensModel::create( modelName ); - } - - updateLensModel(); -} - -void LensDistort::_validate(bool for_real) -{ - copy_info(); - - m_filter.initialize(); - - // Update the lens model if the frame or frame offset changed. - std::string filePath; - if ( m_useFileSequence ) - { - m_hasValidFileSequence = setLensFromFile( filePath ); - } - - // Handle the knobs' status. - if ( knob("model" ) != NULL) knob("model")->enable( !m_useFileSequence ); - for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ ) - { - if ( it->m_knob != NULL) it->m_knob->enable( !m_useFileSequence ); - } - - // Check that the path isn't null. - if ( (!m_hasValidFileSequence) && m_useFileSequence ) - { - error( boost::str( boost::format( "Can not find lens file \"%s\"" ) % filePath ).c_str() ); - set_out_channels( Mask_None ); - return; - } - - // Iterate over our list of parameters and update the lens models. - for( int i = 0; i < m_nThreads; i++ ) - { - for( PluginAttributeList::const_iterator j = m_pluginAttributes.begin(); j != m_pluginAttributes.end(); j++) - { - m_model[i]->parameters()->parameter( j->m_name )->setNumericValue( j->m_value ); - } - m_model[i]->validate(); - } - - // Set the output bounding box according to the lens model. - bool black = input0().black_outside(); - Imath::Box2i input( Imath::V2i( input0().info().x(), input0().info().y() ), Imath::V2i( input0().info().r()-1, input0().info().t()-1 ) ); - Imath::Box2i box( m_model[0]->bounds( m_mode, input, format().width(), format().height() ) ); - info_.set( box.min.x-black, box.min.y-black, box.max.x+black, box.max.y+black ); - - set_out_channels( Mask_All ); -} - -// Given an output bounding box, compute the input bounding box and request the image data that we need. -// We do this be using the output size and getting the bounds of the inverse distortion. -void LensDistort::_request( int x, int y, int r, int t, ChannelMask channels, int count ) -{ - Imath::Box2i requestArea( Imath::V2i( x, y ), Imath::V2i( r-1, t-1 ) ); - Imath::Box2i box( m_model[0]->bounds( !m_mode, requestArea, format().width(), format().height() ) ); - DD::Image::Box distortedRequestedBox( box.min.x, box.min.y, box.max.x+1, box.max.y+1 ); - distortedRequestedBox.intersect( input0().info() ); - input0().request( distortedRequestedBox, channels, count ); -} - -void LensDistort::engine( int y, int x, int r, ChannelMask channels, Row & outrow ) -{ - // Provide an early-out for any black rows. - bool blackOutside = info().black_outside(); - if( blackOutside && ( y == info().t()-1 || y == info().y() ) ) - { - outrow.erase( channels ); - return; - } - - const Info &info = input0().info(); - const double h( format().height() ); - const double w( format().width() ); - const double v( double(y)/h ); - double x_min = std::numeric_limits::max(); - double x_max = std::numeric_limits::min(); - double y_min = std::numeric_limits::max(); - double y_max = std::numeric_limits::min(); - - // Work out which of the array of lens models we should use depending on the current thread. - int lensIdx = 0; - const Thread::ThreadInfo * f = Thread::thisThread(); - if( f ) lensIdx=f->index; - - // Clamp the index to the array range. - lensIdx = lensIdx > m_nThreads ? 0 : lensIdx; - - // Create an array of distorted values that we will populate. - Imath::V2d distort[r-x]; - - // Thread safe read of distortion data. - { - Guard l( m_locks[lensIdx] ); - - // Distort each pixel on the row, store the result in an array and track the bounding box. - for( int i = x; i < r; i++ ) - { - double u = (i+0.0)/w; - - Imath::V2d &dp( distort[i-x] ); - Imath::V2d p(u, v); - if( m_mode ) - { - dp = m_model[lensIdx]->distort( p ); - } - else - { - dp = m_model[lensIdx]->undistort( p ); - } - - dp.x *= w; - dp.y *= h; - - // Clamp our distorted values to the bounding box. - dp.x = std::max( double(info.x()), dp.x ); - dp.y = std::max( double(info.y()), dp.y ); - dp.x = std::min( double(info.r()-1), dp.x ); - dp.y = std::min( double(info.t()-1), dp.y ); - x_min = std::min( x_min, dp.x ); - y_min = std::min( y_min, dp.y ); - x_max = std::max( x_max, dp.x ); - y_max = std::max( y_max, dp.y ); - } - } - - // Now we know which pixels we'll need, request them! - y_max++; - x_max++; - - DD::Image::Pixel out(channels); - - // Lock the tile into the cache - DD::Image::Tile t( input0(), IECore::fastFloatFloor( x_min ), IECore::fastFloatFloor( y_min ), IECore::fastFloatCeil( x_max ), IECore::fastFloatCeil( y_max ), channels ); - - // Write the black outside pixels. - if( blackOutside ) - { - foreach ( z, channels ) - { - outrow.writable(z)[x] = 0.f; - outrow.writable(z)[r-1] = 0.f; - } - } - - // Loop over our array of precomputed points, and ask nuke to perform a filtered lookup for us. - for( int i = x+blackOutside; i < r-blackOutside; i++ ) - { - if(aborted()) break; - input0().sample( distort[i-x].x+0.5, distort[i-x].y+0.5, 1.0, 1.0, &m_filter, out ); - foreach ( z, channels ) - { - outrow.writable(z)[i] = out[z]; - } - } -} - -void LensDistort::append( DD::Image::Hash &hash ) -{ - std::string path; - if ( getFileSequencePath( path ) ) - { - hash.append( path ); - } - else - { - hash.append( m_assetPath ); - } - - for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ ) - { - hash.append( it->m_name ); - hash.append( it->m_value ); - } - - hash.append( m_lensModel ); - hash.append( m_mode ); - hash.append( m_hasValidFileSequence ); - hash.append( m_useFileSequence ); - hash.append( outputContext().frame() ); -} - -bool LensDistort::getFileSequencePath( std::string& path ) -{ - path = ""; - - // Check that the path isn't null. - try - { - if ( knob("lensFileSequence") != NULL ) - { - std::stringstream pathStream; - knob("lensFileSequence")->to_script( pathStream, &(outputContext()), false ); - path = pathStream.str(); - - // If the text field has no data ... - if ( path == "" ) return false; - } - return true; - } - catch( ... ) - { - } - return false; -} - -bool LensDistort::setLensFromFile( std::string &returnPath ) -{ - returnPath.clear(); - - // Check that the returnPath isn't null. - if ( !getFileSequencePath( returnPath ) ) return false; - - // Get the returnPath required for the current context. - const float frame = outputContext().frame(); - if ( !strchr( returnPath.c_str(), '#' ) ) - { - boost::algorithm::replace_first( returnPath, "%07d", "%07i" ); - boost::algorithm::replace_first( returnPath, "%06d", "%06i" ); - boost::algorithm::replace_first( returnPath, "%05d", "%05i" ); - boost::algorithm::replace_first( returnPath, "%04d", "%04i" ); - boost::algorithm::replace_first( returnPath, "%03d", "%03i" ); - boost::algorithm::replace_first( returnPath, "%02d", "%02i" ); - boost::algorithm::replace_first( returnPath, "%d", "%1i" ); - } - else - { - boost::algorithm::replace_first( returnPath, "#######", "%07i" ); - boost::algorithm::replace_first( returnPath, "######", "%06i" ); - boost::algorithm::replace_first( returnPath, "#####", "%05i" ); - boost::algorithm::replace_first( returnPath, "####", "%04i" ); - boost::algorithm::replace_first( returnPath, "###", "%03i" ); - boost::algorithm::replace_first( returnPath, "##", "%02i" ); - boost::algorithm::replace_first( returnPath, "#", "%1i" ); - } - - try - { - returnPath = boost::str( boost::format( returnPath ) % int(frame) ); - } - catch( ... ) - { - // it's ok if the above throws - it just means there wasn't a number specified in the - // filename, so we just use the filename as is - } - - // Check to see if the file returnPath is valid. - std::ifstream ifile; - ifile.open( returnPath.c_str(), std::ifstream::in ); - if ( !ifile.is_open() ) return false;; - - // Try to open the lens file. - try - { - IECore::CachedReaderPtr reader( IECore::CachedReader::defaultCachedReader() ); - IECore::ConstObjectPtr o = reader->read( returnPath ); - IECore::ConstCompoundObjectPtr p = IECore::runTimeCast< const IECore::CompoundObject >( o ); - if ( p ) - { - // Update the lensModel knob. - m_lensModel = indexFromModelName( p->member( "lensModel", true )->readable().c_str() ); - m_kModel->set_value( m_lensModel ); - setLensModel( p ); - return true; - } - } - catch( const IECore::Exception &e ) - { - return false; - } - - return false; -} - -void LensDistort::knobs( Knob_Callback f ) -{ - File_knob( f, &m_assetPath, "lensFileSequence", "Lens File Sequence" ); - SetFlags( f, Knob::KNOB_CHANGED_ALWAYS ); - SetFlags( f, Knob::ALWAYS_SAVE ); - SetFlags( f, Knob::NO_UNDO ); - Tooltip( f, "Directory name containing the lens files. Usually COB files..." ); - - Divider( f ); - - m_filter.knobs(f); - - static const char * const modes[] = { "Distort", "Undistort", 0 }; - Enumeration_knob( f, &m_mode, modes, "mode", "Mode" ); - Tooltip( f, "Whether to Distort or Undistort the input by the current lens model." ); - SetFlags( f, Knob::KNOB_CHANGED_ALWAYS ); - SetFlags( f, Knob::ALWAYS_SAVE ); - - m_lastStaticKnob = m_kModel = Enumeration_knob( f, &m_lensModel, modelNames(), "model", "Model" ); - Tooltip( f, "Choose the lens model to distort the input with. This list is populated with all lens models that have been registered to Cortex." ); - SetFlags( f, Knob::KNOB_CHANGED_ALWAYS ); - SetFlags( f, Knob::ALWAYS_SAVE ); - SetFlags( f, Knob::NO_UNDO ); - - updatePluginAttributesFromKnobs(); - - // Create the Dynamic knobs. - if( f.makeKnobs() ) - { - setLensModel( modelNames()[0] ); - m_numNewKnobs = add_knobs( buildDynamicKnobs, this->firstOp(), f ); - } - else - { - LensDistort::addDynamicKnobs( this->firstOp(), f ); - } -} - -void LensDistort::updatePluginAttributesFromKnobs() -{ - for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ ) - { - Knob *k = it->m_knob; - if ( k ) - { - std::stringstream s; - k->to_script( s, 0, false ); - it->m_script = s.str(); - it->m_value = k->get_value(); - } - } -} - -int LensDistort::knob_changed(Knob* k) -{ - // If the lensFileSequence knob just changed then we need to check if it is valid and load it. - if ( k->is( "lensFileSequence" ) ) - { - bool updateRequired = false; - - std::string path; - bool oldValue = m_useFileSequence; - m_useFileSequence = getFileSequencePath( path ); - updateRequired |= oldValue != m_useFileSequence; - - if ( m_useFileSequence ) - { - bool oldValue = m_hasValidFileSequence; - std::string path; - m_hasValidFileSequence = setLensFromFile( path ); - updateRequired |= m_hasValidFileSequence != oldValue; - } - - if( updateRequired ) - { - updateUI(); - } - - return true; - } - - // If the lens model was just changed then we need to set it internally and then update the UI. - if ( k->is( "model" ) ) - { - setLensModel( modelNames()[getLensModel()] ); - updateUI(); - return true; - } - - // Update our internal reference of the knob value that just changed... - if ( !m_hasValidFileSequence ) - { - std::stringstream s; - std::string name( k->name() ); - for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ ) - { - if( name == it->m_name ) - { - k->to_script( s, 0, false ); - it->m_script = s.str(); - it->m_value = k->get_value(); - return true; - } - } - } - - // Do we need to update the UI? - if ( k == &Knob::showPanel ) - { - updateUI(); - return true; - } - - return Iop::knob_changed(k); -} - -void LensDistort::updateUI() -{ - m_numNewKnobs = replace_knobs( m_lastStaticKnob, m_numNewKnobs, addDynamicKnobs, this->firstOp() ); - - // Handle the knobs state. - if ( knob("model" ) != NULL) knob("model")->enable( !m_useFileSequence ); - for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ ) - { - if ( it->m_knob != NULL) it->m_knob->enable( !m_useFileSequence ); - } -} - -void LensDistort::buildDynamicKnobs(void* p, DD::Image::Knob_Callback f) -{ - PluginAttributeList& attributeList( ((LensDistort*)p)->attributeList() ); - const unsigned int nAttributes( attributeList.size() ); - for ( unsigned int i = 0; i < nAttributes; ++i ) - { - attributeList[i].m_knob = Double_knob( f, &attributeList[i].m_value, attributeList[i].m_name.c_str(), attributeList[i].m_name.c_str() ); - if( attributeList[i].m_script != "" ) - { - attributeList[i].m_knob->from_script( attributeList[i].m_script.c_str() ); - } - SetFlags( f, Knob::ALWAYS_SAVE ); - } -} - -void LensDistort::addDynamicKnobs(void* p, DD::Image::Knob_Callback f) -{ - PluginAttributeList& attributeList( ((LensDistort*)p)->attributeList() ); - const unsigned int nAttributes( attributeList.size() ); - for ( unsigned int i = 0; i < nAttributes; ++i ) - { - attributeList[i].m_knob = Double_knob( f, &attributeList[i].m_value, attributeList[i].m_name.c_str(), attributeList[i].m_name.c_str() ); - if( attributeList[i].m_script != "" ) - { - attributeList[i].m_knob->from_script( attributeList[i].m_script.c_str() ); - } - SetFlags( f, Knob::ALWAYS_SAVE ); - SetFlags( f, Knob::KNOB_CHANGED_ALWAYS ); - } -} - -} // namespace IECoreNuke diff --git a/src/IECoreNuke/LineSegment3ParameterHandler.cpp b/src/IECoreNuke/LineSegment3ParameterHandler.cpp deleted file mode 100644 index 228122a7aa..0000000000 --- a/src/IECoreNuke/LineSegment3ParameterHandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/LineSegment3ParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -template -ParameterHandler::Description > LineSegment3ParameterHandler::g_description( T::staticTypeId() ); - -template -LineSegment3ParameterHandler::LineSegment3ParameterHandler() - : m_startKnob( 0 ), m_endKnob( 0 ) -{ -} - -template -void LineSegment3ParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( f.makeKnobs() ) - { - typename T::ValueType defaultValue = static_cast( parameter )->typedDefaultValue(); - m_storage.p0 = defaultValue.p0; - m_storage.p1 = defaultValue.p1 - defaultValue.p0; // second value in nuke is relative to first - } - - std::string label = knobLabel( parameter ); - - std::string startKnobName = std::string( knobName ) + "Start"; - std::string startKnobLabel = label + " Start"; - m_startKnob = XYZ_knob( f, (float *)&(m_storage.p0), startKnobName.c_str(), startKnobLabel.c_str() ); - setKnobProperties( parameter, f, m_startKnob ); - - std::string endKnobName = std::string( knobName ) + "End"; - std::string endKnobLabel = label + " End"; - m_endKnob = XYZ_knob( f, (float *)&(m_storage.p1), endKnobName.c_str(), endKnobLabel.c_str(), m_startKnob ); - setKnobProperties( parameter, f, m_endKnob ); -} - -template -void LineSegment3ParameterHandler::setParameterValue(IECore::Parameter *parameter, ValueSource valueSource ) -{ - T *lineParameter = static_cast( parameter ); - - typename T::ValueType value; - if( valueSource==Storage ) - { - value.p0 = m_storage.p0; - value.p1 = m_storage.p0 + m_storage.p1; - } - else - { - value.p0.x = m_startKnob->get_value( 0 ); - value.p0.y = m_startKnob->get_value( 1 ); - value.p0.z = m_startKnob->get_value( 2 ); - value.p1.x = m_endKnob->get_value( 0 ); - value.p1.y = m_endKnob->get_value( 1 ); - value.p1.z = m_endKnob->get_value( 2 ); - value.p1 += value.p0; // second value in nuke is relative to first - } - - lineParameter->setTypedValue( value ); -} - -template -void LineSegment3ParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const T *lineParameter = static_cast( parameter ); - typename T::ValueType value = lineParameter->getTypedValue(); - m_startKnob->set_value( value.p0.x, 0 ); - m_startKnob->set_value( value.p0.y, 1 ); - m_startKnob->set_value( value.p0.z, 2 ); - m_endKnob->set_value( value.p1.x - value.p0.x, 0 ); - m_endKnob->set_value( value.p1.y - value.p0.y, 1 ); - m_endKnob->set_value( value.p1.z - value.p0.z, 2 ); -} - -// explicit instantiation - -template class LineSegment3ParameterHandler; -template class LineSegment3ParameterHandler; diff --git a/src/IECoreNuke/LiveScene.cpp b/src/IECoreNuke/LiveScene.cpp deleted file mode 100644 index c2457e7fd1..0000000000 --- a/src/IECoreNuke/LiveScene.cpp +++ /dev/null @@ -1,685 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/LiveScene.h" - -#include "DDImage/Scene.h" -#include "DDImage/Execute.h" -#include "DDImage/ParticleOp.h" - -#include "IECoreNuke/Convert.h" -#include "IECoreNuke/MeshFromNuke.h" -#include "IECoreNuke/FromNukePointsConverter.h" - -#include "IECore/Exception.h" -#include "IECore/NullObject.h" -#include "IECore/TransformationMatrixData.h" - -#include "Imath/ImathBoxAlgo.h" - -#include "boost/algorithm/string.hpp" -#include "boost/format.hpp" -#include "boost/tokenizer.hpp" - -#include "tbb/recursive_mutex.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreNuke; -using namespace DD::Image; - -namespace -{ - -IECore::TransformationMatrixd convertTransformMatrix( DD::Image::Matrix4& from ) -{ - auto to = IECore::TransformationMatrixd(); - DD::Image::Vector3 rotation, translation, scale, shear; - from.decompose( rotation, translation, scale, shear, DD::Image::Matrix4::RotationOrder::eXYZ ); - to.scale = IECore::convert( scale ); - to.shear = IECore::convert( shear ); - to.rotate = IECore::convert( rotation ); - to.translate = IECore::convert( translation ); - return to; -} - -tbb::recursive_mutex g_mutex; - -LiveScene::LiveSceneGeometryCache &cachedGeometryListMap() -{ - static LiveScene::LiveSceneGeometryCache *cache = new LiveScene::LiveSceneGeometryCache(); - return *cache; -} - -} - -const std::string& LiveScene::nameAttribute( "ieName" ); - -IE_CORE_DEFINERUNTIMETYPED( LiveScene ); - -LiveScene::LiveScene() : m_op( nullptr ) -{ -} - -LiveScene::LiveScene( GeoOp *op, const IECoreScene::SceneInterface::Path& rootPath ) : m_op( op ), m_rootPath( rootPath ) -{ - m_pathMatcher = IECore::PathMatcher(); - m_pathMatcher.addPath( m_rootPath ); -} - -LiveScene::~LiveScene() -{ -} - -void LiveScene::setOp( DD::Image::GeoOp* op ) -{ - m_op = op; - m_objectPathMap.clear(); -} - -const GeoOp *LiveScene::getOp() const -{ - return m_op; -} - -double LiveScene::timeToFrame( const double& time ) -{ - return time * DD::Image::root_real_fps(); -} - -double LiveScene::frameToTime( const int& frame ) -{ - return frame / double( DD::Image::root_real_fps() ); -} - -std::string LiveScene::geoInfoPath( const int& index ) const -{ - auto it = m_objectPathMap.find( index ); - if ( it != m_objectPathMap.end() ) - { - return it->second; - } - else - { - auto info = object( index ); - if ( !info ) - { - return "/undefined" + std::to_string( index ); - } - std::string nameValue; - if( auto nameAttrib = info->get_group_attribute( GroupType::Group_Object, nameAttribute.data() ) ) - { - nameValue = nameAttrib->stdstring(); - } - else - { - nameValue = "/object" + std::to_string( index ); - } - - m_objectPathMap[index] = nameValue; - - return nameValue; - } -} - -void LiveScene::cacheGeometryList( const double& frame ) const -{ - DD::Image::Hash h; - if( auto parent = m_op->parent() ) - { - h = static_cast( parent )->hash(); - } - else - { - h = static_cast( m_op )->hash(); - } - auto it = cachedGeometryListMap().find( this ); - if ( it == cachedGeometryListMap().end() ) - { - auto geomList = geometryList( frame ); - cachedGeometryListMap()[this][h][frame] = geomList; - } - else - { - auto jit = cachedGeometryListMap()[this].find( h ); - if ( jit == cachedGeometryListMap()[this].end() ) - { - auto geomList = geometryList( frame ); - cachedGeometryListMap()[this][h][frame] = geomList; - } - else - { - auto kit = cachedGeometryListMap()[this][h].find( frame ); - if ( kit == cachedGeometryListMap()[this][h].end() ) - { - auto geomList = geometryList( frame ); - cachedGeometryListMap()[this][h][frame] = geomList; - } - } - } -} - -unsigned LiveScene::objectNum( const double* time) const -{ - double frame; - if ( time ) - { - frame = timeToFrame( *time ); - } - else - { - frame = m_op->outputContext().frame(); - } - cacheGeometryList( frame ); - - DD::Image::Hash h; - if( auto parent = m_op->parent() ) - { - h = static_cast( parent )->hash(); - } - else - { - h = static_cast( m_op )->hash(); - } - - auto cit = cachedGeometryListMap().find( this ); - if ( cit != cachedGeometryListMap().end() ) - { - auto jit = cachedGeometryListMap()[this].find( h ); - if ( jit != cachedGeometryListMap()[this].end() ) - { - - auto kit = cachedGeometryListMap()[this][h].find( frame ); - if ( kit != cachedGeometryListMap()[this][h].end() ) - { - return cachedGeometryListMap()[this][h][frame].objects(); - } - } - } - - return 0; -} - -DD::Image::GeoInfo* LiveScene::object( const unsigned& index, const double* time ) const -{ - double frame; - if ( time ) - { - frame = timeToFrame( *time ); - } - else - { - frame = m_op->outputContext().frame(); - } - cacheGeometryList( frame ); - - DD::Image::Hash h; - if( auto parent = m_op->parent() ) - { - h = static_cast( parent )->hash(); - } - else - { - h = static_cast( m_op )->hash(); - } - - auto cit = cachedGeometryListMap().find( this ); - if ( cit != cachedGeometryListMap().end() ) - { - auto jit = cachedGeometryListMap()[this].find( h ); - if ( jit != cachedGeometryListMap()[this].end() ) - { - - auto kit = cachedGeometryListMap()[this][h].find( frame ); - if ( kit != cachedGeometryListMap()[this][h].end() ) - { - return &kit->second.object( index ); - } - } - } - return nullptr; -} - -DD::Image::GeometryList LiveScene::geometryList( DD::Image::Op* op, const double& frame ) const -{ - boost::shared_ptr scene( new DD::Image::Scene() ); - boost::shared_ptr geo( new DD::Image::GeometryList() ); - - auto executioner = Execute(); - auto executableOp = executioner.generateOp( op, 0, frame ); - if ( !executableOp ) - { - return *geo; - } - - DD::Image::GeoOp* geoOp = executableOp->geoOp(); - if ( !geoOp ) - { - return *geo; - } - - geoOp->validate(true); - - geoOp->get_geometry( *scene, *geo ); - - return *geo; -} - -DD::Image::GeometryList LiveScene::geometryList( const double& frame ) const -{ - // Nuke Geometry API is not thread safe so we need to use a mutex here to avoid crashes. - tbb::recursive_mutex::scoped_lock l( g_mutex ); - DD::Image::GeometryList result; - - if( m_op->input0() && m_op->input0()->particleOp() ) - { - auto particleToGeo = Op::create( "ParticleToGeo", m_op ); - particleToGeo->set_input( 0, m_op->input0() ); - result = geometryList( particleToGeo, frame ); - } - else - { - result = geometryList( m_op, frame ); - } - - return result; -} - -std::string LiveScene::fileName() const -{ - throw Exception( "IECoreNuke::LiveScene does not support fileName()." ); -} - -SceneInterface::Name LiveScene::name() const -{ - if ( m_rootPath.empty() ) - { - return IECoreScene::SceneInterface::rootName; - } - - return *m_rootPath.rbegin(); -} - -void LiveScene::path( Path &p ) const -{ - p.clear(); - p = m_rootPath; -} - -Imath::Box3d LiveScene::readBound( double time ) const -{ - Imath::Box3d bound; - bound.makeEmpty(); - std::string rootPathStr; - IECoreScene::SceneInterface::Path currentPath; - for( unsigned i=0; i < objectNum( &time ); ++i ) - { - auto nameValue = geoInfoPath( i ); - auto result = m_pathMatcher.match( nameValue ); - if ( ( result != IECore::PathMatcher::AncestorMatch ) && ( result != IECore::PathMatcher::ExactMatch ) ) - { - continue; - } - IECoreScene::SceneInterface::pathToString( m_rootPath, rootPathStr ); - IECoreScene::SceneInterface::stringToPath( nameValue, currentPath ); - - auto info = object( i, &time ); - if ( !info ) - { - return bound; - } - - Box3 objectBound; - if ( ( currentPath.size() > 1 ) && ( ( currentPath.size() == m_rootPath.size() + 1 ) || ( nameValue == rootPathStr ) ) ) - { - // object space bound - objectBound = info->bbox(); - } - else - { - objectBound = info->getTransformedBBox(); - } - Imath::Box3d b = IECore::convert( objectBound ); - - if( b.hasVolume() ) - { - bound.extendBy( b ); - } - } - - return bound; -} - -void LiveScene::writeBound( const Imath::Box3d &bound, double time ) -{ - throw Exception( "IECoreNuke::LiveScene::writeBound: write operations not supported!" ); -} - -ConstDataPtr LiveScene::readTransform( double time ) const -{ - for( unsigned i=0; i < objectNum( &time ); ++i ) - { - auto nameValue = geoInfoPath( i ); - auto result = m_pathMatcher.match( nameValue ); - if ( result == IECore::PathMatcher::ExactMatch ) - { - auto geoInfo = object( i, &time ); - if( !geoInfo ) - { - return new TransformationMatrixdData( IECore::TransformationMatrixd() ); - } - auto from = geoInfo->matrix; - return new TransformationMatrixdData( convertTransformMatrix( from ) ); - } - } - - return new TransformationMatrixdData( IECore::TransformationMatrixd() ); -} - -Imath::M44d LiveScene::readTransformAsMatrix( double time ) const -{ - return runTimeCast< const TransformationMatrixdData >( readTransform( time ) )->readable().transform(); -} - -void LiveScene::writeTransform( const Data *transform, double time ) -{ - throw Exception( "IECoreNuke::LiveScene::writeTransform: write operations not supported!" ); -} - -bool LiveScene::hasAttribute( const Name &name ) const -{ - return false; -} - -void LiveScene::attributeNames( NameList &attrs ) const -{ -} - -ConstObjectPtr LiveScene::readAttribute( const Name &name, double time ) const -{ - return IECore::NullObject::defaultNullObject(); -} - -void LiveScene::writeAttribute( const Name &name, const Object *attribute, double time ) -{ - throw Exception( "IECoreNuke::LiveScene::writeAttribute: write operations not supported!" ); -} - -bool LiveScene::hasTag( const Name &name, int filter ) const -{ - return false; -} - -void LiveScene::readTags( NameList &tags, int filter ) const -{ -} - -void LiveScene::writeTags( const NameList &tags ) -{ - throw Exception( "IECoreNuke::LiveScene::writeTags not supported" ); -} - -SceneInterface::NameList LiveScene::setNames( bool includeDescendantSets ) const -{ - return SceneInterface::NameList(); -} - -IECore::PathMatcher LiveScene::readSet( const Name &name, bool includeDescendantSets, const IECore::Canceller *canceller ) const -{ - return IECore::PathMatcher(); -} - -void LiveScene::writeSet( const Name &name, const IECore::PathMatcher &set ) -{ - throw Exception( "IECoreNuke::LiveScene::writeSet not supported" ); -} - -void LiveScene::hashSet( const Name& setName, IECore::MurmurHash &h ) const -{ -} - -bool LiveScene::hasObject() const -{ - for( unsigned i=0; i < objectNum(); ++i ) - { - auto nameValue = geoInfoPath( i ); - auto result = m_pathMatcher.match( nameValue ); - if ( result == IECore::PathMatcher::ExactMatch ) - { - return true; - } - } - - return false; -} - -ConstObjectPtr LiveScene::readObject( double time, const IECore::Canceller *canceller) const -{ - for( unsigned i=0; i < objectNum(); ++i ) - { - auto nameValue = geoInfoPath( i ); - auto result = m_pathMatcher.match( nameValue ); - if ( result == IECore::PathMatcher::ExactMatch ) - { - auto geoInfo = object( i, &time ); - if ( !geoInfo ) - { - return IECore::NullObject::defaultNullObject(); - } - if ( geoInfo->primitives() == 1 && ( geoInfo->primitive( 0 )->getPrimitiveType() == DD::Image::PrimitiveType::eParticlesSprite ) ) - { - auto converter = new IECoreNuke::FromNukePointsConverter( geoInfo, m_op->input0() ); - return converter->convert(); - } - else - { - MeshFromNukePtr converter = new IECoreNuke::MeshFromNuke( geoInfo ); - return converter->convert(); - } - } - } - - return IECore::NullObject::defaultNullObject(); -} - -PrimitiveVariableMap LiveScene::readObjectPrimitiveVariables( const std::vector &primVarNames, double time ) const -{ - throw Exception( "IECoreNuke::readObjectPrimitiveVariables() not implemented!" ); -} - -void LiveScene::writeObject( const Object *object, double time ) -{ - throw Exception( "IECoreNuke::LiveScene::writeObject: write operations not supported!" ); -} - -void LiveScene::childNames( NameList &childNames ) const -{ - childNames.clear(); - std::vector allPaths; - - for( unsigned i=0; i < objectNum(); ++i ) - { - auto nameValue = geoInfoPath( i ); - auto result = m_pathMatcher.match( nameValue ); - if ( ( result == IECore::PathMatcher::AncestorMatch ) || ( result == IECore::PathMatcher::ExactMatch ) ) - { - allPaths.push_back( nameValue ); - } - } - - // filter only children - IECoreScene::SceneInterface::Path allPath; - std::string rootPathStr; - IECoreScene::SceneInterface::pathToString( m_rootPath, rootPathStr ); - for ( auto& path : allPaths ) - { - // ignore children with a different root path - if ( !( path.rfind( rootPathStr, 0 ) == 0 ) ) - { - continue; - } - - allPath.clear(); - IECoreScene::SceneInterface::stringToPath( path, allPath ); - if ( m_rootPath.size() < allPath.size() ) - { - // ignore duplicates. - if ( find( childNames.begin(), childNames.end(), allPath[m_rootPath.size()] ) != childNames.end() ) - { - continue; - } - childNames.push_back( allPath[m_rootPath.size()] ); - } - } -} - -bool LiveScene::hasChild( const Name &name ) const -{ - IECoreScene::SceneInterface::NameList names; - childNames( names ); - - return find( names.cbegin(), names.cend(), name ) != names.cend(); -} - -SceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) -{ - IECoreScene::SceneInterface::NameList names; - childNames( names ); - - if( find( names.cbegin(), names.cend(), name ) == names.cend() ) - { - switch ( missingBehaviour ) - { - case MissingBehaviour::ThrowIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name \"" + name.string() + "\" is not a valid childName." ); - case MissingBehaviour::NullIfMissing: - return nullptr; - case MissingBehaviour::CreateIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name\"" + name.string() + "\" is missing and LiveScene is read-only" ); - } - } - - IECoreScene::SceneInterface::Path newPath = m_rootPath; - newPath.push_back( name.string() ); - - return new LiveScene( m_op, newPath ); -} - -ConstSceneInterfacePtr LiveScene::child( const Name &name, MissingBehaviour missingBehaviour ) const -{ - IECoreScene::SceneInterface::NameList names; - childNames( names ); - - if( find( names.cbegin(), names.cend(), name ) == names.cend() ) - { - switch ( missingBehaviour ) - { - case MissingBehaviour::ThrowIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name \"" + name.string() + "\" is not a valid childName." ); - case MissingBehaviour::NullIfMissing: - return nullptr; - case MissingBehaviour::CreateIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name\"" + name.string() + "\" is missing and LiveScene is read-only" ); - } - } - - IECoreScene::SceneInterface::Path newPath = m_rootPath; - newPath.push_back( name.string() ); - - return new LiveScene( m_op, newPath ); -} - -SceneInterfacePtr LiveScene::createChild( const Name &name ) -{ - throw Exception( "IECoreNuke::LiveScene is read-only" ); -} - -ConstSceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) const -{ - IECoreNuke::ConstLiveScenePtr currentScene( this ); - for ( const auto& child : path ) - { - if ( auto childScene = currentScene->child( child, missingBehaviour ) ) - { - currentScene = dynamic_cast( childScene.get() ); - } - else - { - switch ( missingBehaviour ) - { - case MissingBehaviour::ThrowIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name \"" + child.string() + "\" is not a valid childName." ); - case MissingBehaviour::NullIfMissing: - return nullptr; - case MissingBehaviour::CreateIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name\"" + child.string() + "\" is missing and LiveScene is read-only" ); - } - } - } - - return new LiveScene( m_op, path ); -} - -SceneInterfacePtr LiveScene::scene( const Path &path, MissingBehaviour missingBehaviour ) -{ - IECoreNuke::LiveScenePtr currentScene( this ); - for ( const auto& child : path ) - { - if ( auto childScene = currentScene->child( child, missingBehaviour ) ) - { - currentScene = dynamic_cast( childScene.get() ); - } - else - { - switch ( missingBehaviour ) - { - case MissingBehaviour::ThrowIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name \"" + child.string() + "\" is not a valid childName." ); - case MissingBehaviour::NullIfMissing: - return nullptr; - case MissingBehaviour::CreateIfMissing: - throw Exception( "IECoreNuke::LiveScene: Name\"" + child.string() + "\" is missing and LiveScene is read-only" ); - } - } - } - - return new LiveScene( m_op, path ); -} - -void LiveScene::hash( HashType hashType, double time, MurmurHash &h ) const -{ - Path p; - path( p ); - h.append( &( p[0] ), p.size() ); -} diff --git a/src/IECoreNuke/LiveSceneHolder.cpp b/src/IECoreNuke/LiveSceneHolder.cpp deleted file mode 100644 index 2a8795f72c..0000000000 --- a/src/IECoreNuke/LiveSceneHolder.cpp +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/LiveSceneHolder.h" - -#include "IECoreNuke/LiveSceneKnob.h" - -using namespace IECoreNuke; - -const DD::Image::Op::Description LiveSceneHolder::g_description( "ieLiveScene", build ); - -LiveSceneHolder::LiveSceneHolder( Node *node ) - : DD::Image::GeoOp( node ) -{ -} - -LiveSceneHolder::~LiveSceneHolder() -{ -} - -void LiveSceneHolder::knobs( DD::Image::Knob_Callback f ) -{ - Op::knobs( f ); - - LiveSceneKnob::sceneKnob( f, this, "scene", "Scene" ); -} - -DD::Image::Op *LiveSceneHolder::build( Node *node ) -{ - return new LiveSceneHolder( node ); -} - -const char *LiveSceneHolder::Class() const -{ - return g_description.name; -} - -const char *LiveSceneHolder::node_help() const -{ - return "Holds cortex live scene on the \"scene\" knob."; -} - -IECoreNuke::LiveScenePtr LiveSceneHolder::liveScene() -{ - return new IECoreNuke::LiveScene( this ); -} diff --git a/src/IECoreNuke/LiveSceneKnob.cpp b/src/IECoreNuke/LiveSceneKnob.cpp deleted file mode 100644 index 69c207431a..0000000000 --- a/src/IECoreNuke/LiveSceneKnob.cpp +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/LiveSceneKnob.h" - -#include "IECorePython/ScopedGILLock.h" - -using namespace IECoreNuke; -using namespace DD::Image; -using namespace boost::python; - -LiveSceneKnob::LiveSceneKnob( DD::Image::Knob_Closure* f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label ) - : DD::Image::Knob( f, name, label ), m_value( nullptr ), m_op(op) -{ - - set_flag( NO_ANIMATION ); - - // set up the object that will provide the python binding - IECorePython::ScopedGILLock gilLock; - Detail::PythonLiveSceneKnobPtr pythonKnob = new Detail::PythonLiveSceneKnob; - pythonKnob->sceneKnob = this; - object pythonKnobLiveScene( pythonKnob ); - Py_INCREF( pythonKnobLiveScene.ptr() ); - setPyObject( pythonKnobLiveScene.ptr() ); -} - -LiveSceneKnob::~LiveSceneKnob() -{ - // tidy up the object for the python binding - IECorePython::ScopedGILLock gilLock; - object pythonKnobLiveScene( handle<>( borrowed( (PyObject *)pyObject() ) ) ); - Detail::PythonLiveSceneKnobPtr pythonKnob = extract( pythonKnobLiveScene ); - pythonKnob->sceneKnob = nullptr; - Py_DECREF( pythonKnobLiveScene.ptr() ); -} - -IECoreNuke::LiveScenePtr LiveSceneKnob::getValue() -{ - if( auto geoOp = dynamic_cast( m_op ) ) - { - geoOp->validate(true); - m_value.reset(); - m_value = new IECoreNuke::LiveScene( m_op ); - } - return m_value; -} - -LiveSceneKnob *LiveSceneKnob::sceneKnob( DD::Image::Knob_Callback f, IECoreNuke::LiveSceneHolder* op, const char *name, const char *label ) -{ - return CustomKnob2( LiveSceneKnob, f, op, name, label ); -} - -const char *LiveSceneKnob::Class() const -{ - return "LiveSceneKnob"; -} diff --git a/src/IECoreNuke/MeshFromNuke.cpp b/src/IECoreNuke/MeshFromNuke.cpp deleted file mode 100644 index 74bf814b21..0000000000 --- a/src/IECoreNuke/MeshFromNuke.cpp +++ /dev/null @@ -1,141 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/MeshFromNuke.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreScene/MeshPrimitive.h" - -#include - -using namespace IECoreNuke; -using namespace IECore; -using namespace IECoreScene; - -MeshFromNuke::MeshFromNuke( const DD::Image::GeoInfo *geo ) - : FromNukeConverter( "Converts nuke meshes to IECore meshes." ), m_geo( geo ) -{ -} - -MeshFromNuke::~MeshFromNuke() -{ -} - -IECore::ObjectPtr MeshFromNuke::doConversion( IECore::ConstCompoundObjectPtr operands ) const -{ - // topology - IntVectorDataPtr verticesPerFaceData = new IntVectorData; - IntVectorDataPtr vertexIdsData = new IntVectorData; - std::vector &verticesPerFace = verticesPerFaceData->writable(); - std::vector &vertexIds = vertexIdsData->writable(); - - unsigned numPrimitives = m_geo->primitives(); - const DD::Image::Primitive **primitives = m_geo->primitive_array(); - std::vector tmpFaceVertices; - for( unsigned primIndex=0; primIndexfaces(); - for( unsigned faceIndex=0; faceIndexface_vertices( faceIndex ); - verticesPerFace.push_back( numFaceVertices ); - tmpFaceVertices.resize( numFaceVertices ); - prim->get_face_vertices( faceIndex, &(tmpFaceVertices[0]) ); - for( unsigned i=0; ivertex( tmpFaceVertices[i] ) ); - } - } - } - - MeshPrimitivePtr result = new MeshPrimitive( verticesPerFaceData, vertexIdsData, "linear" ); - - // points - if( const DD::Image::PointList *pl = m_geo->point_list() ) - { - V3fVectorDataPtr p = new V3fVectorData(); - p->writable().resize( pl->size() ); - std::transform( pl->begin(), pl->end(), p->writable().begin(), IECore::convert ); - result->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, p ); - } - - // uvs - PrimitiveVariable::Interpolation uvInterpolation = PrimitiveVariable::Vertex; - const DD::Image::Attribute *uvAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Points, "uv", DD::Image::VECTOR4_ATTRIB ); - if( !uvAttr ) - { - uvAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Vertices, "uv", DD::Image::VECTOR4_ATTRIB ); - uvInterpolation = PrimitiveVariable::FaceVarying; - } - - if( uvAttr ) - { - V2fVectorDataPtr uvData = new V2fVectorData(); - uvData->setInterpretation( GeometricData::UV ); - std::vector &uvs = uvData->writable(); - uvs.reserve( uvAttr->size() ); - unsigned numUVs = uvAttr->size(); - for( unsigned i=0; ivector4( i ).x, uvAttr->vector4( i ).y ); - } - result->variables["uv"] = PrimitiveVariable( uvInterpolation, uvData ); - } - - // normals - PrimitiveVariable::Interpolation nInterpolation = PrimitiveVariable::Vertex; - const DD::Image::Attribute *nAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Points, "N", DD::Image::NORMAL_ATTRIB ); - if( !nAttr ) - { - nAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Vertices, "N", DD::Image::NORMAL_ATTRIB ); - nInterpolation = PrimitiveVariable::FaceVarying; - } - - if( nAttr ) - { - V3fVectorDataPtr nd = new V3fVectorData(); - std::vector &n = nd->writable(); - n.resize( nAttr->size() ); - for( unsigned i=0; i( nAttr->normal( i ) ); - } - result->variables["N"] = PrimitiveVariable( nInterpolation, nd ); - } - - return result; -} diff --git a/src/IECoreNuke/MeshPrimitiveParameterHandler.cpp b/src/IECoreNuke/MeshPrimitiveParameterHandler.cpp deleted file mode 100644 index fc44c1f4bf..0000000000 --- a/src/IECoreNuke/MeshPrimitiveParameterHandler.cpp +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/MeshPrimitiveParameterHandler.h" - -#include "IECoreNuke/MeshFromNuke.h" - -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/TypedPrimitiveParameter.h" - -#include "DDImage/GeoOp.h" -#include "DDImage/Scene.h" - -using namespace IECoreNuke; - -ParameterHandler::Description MeshPrimitiveParameterHandler::g_description( IECoreScene::MeshPrimitiveParameter::staticTypeId() ); - -MeshPrimitiveParameterHandler::MeshPrimitiveParameterHandler() -{ -} - -int MeshPrimitiveParameterHandler::minimumInputs( const IECore::Parameter *parameter ) -{ - return 1; -} - -int MeshPrimitiveParameterHandler::maximumInputs( const IECore::Parameter *parameter ) -{ - return 1; -} - -bool MeshPrimitiveParameterHandler::testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ) -{ - if( dynamic_cast( op ) ) - { - return 1; - } - return 0; -} - -void MeshPrimitiveParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) -{ - DD::Image::GeoOp *geoOp = static_cast( *first ); - if( geoOp ) - { - boost::shared_ptr scene( new DD::Image::Scene() ); - geoOp->build_scene( *scene ); - - if( scene->objects() ) - { - /// \todo Need to deal with more than just the first object. - MeshFromNukePtr converter = new IECoreNuke::MeshFromNuke( &scene->object( 0 ) ); - parameter->setValue( converter->convert() ); - return; - } - } - - // no input, or conversion failed. set parameter to default value. - parameter->setValue( parameter->defaultValue()->copy() ); -} diff --git a/src/IECoreNuke/MeshToNukeGeometryConverter.cpp b/src/IECoreNuke/MeshToNukeGeometryConverter.cpp deleted file mode 100644 index 1aea74224e..0000000000 --- a/src/IECoreNuke/MeshToNukeGeometryConverter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/MeshToNukeGeometryConverter.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreScene/MeshPrimitive.h" - -#include "IECore/TypeIds.h" - -#include "DDImage/Polygon.h" - -using namespace boost; -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreNuke; -using namespace DD::Image; - -MeshToNukeGeometryConverter::ToNukeGeometryConverterDescription MeshToNukeGeometryConverter::g_description( MeshPrimitive::staticTypeId() ); - -MeshToNukeGeometryConverter::MeshToNukeGeometryConverter( IECore::ConstObjectPtr object ) -: ToNukeGeometryConverter( "Converts IECore.MeshPrimitive objects to geometry in a Nuke GeometryList object.", MeshPrimitive::staticTypeId(), object ) -{ -} - -void MeshToNukeGeometryConverter::doConversion( const IECore::Object *from, GeometryList &to, int objIndex, const IECore::CompoundObject *operands ) const -{ - assert( from ); - const MeshPrimitive *mesh = static_cast( from ); - - const std::vector &vertPerFace = mesh->verticesPerFace()->readable(); - const std::vector &vertIds = mesh->vertexIds()->readable(); - std::vector::const_iterator ids = vertIds.begin(); - - // create polygons - for ( std::vector::const_iterator vpf = vertPerFace.begin(); vpf != vertPerFace.end(); vpf++ ) - { - Polygon *p = new Polygon( *vpf, true ); - for ( int v = 0; v < *vpf; v++, ids++ ) - { - p->vertex(v) = *ids; - } - to.add_primitive( objIndex, p ); - } - - // get points - // \todo: add parameters for standard prim vars - const V3fVectorData *meshPoints = mesh->variableData< V3fVectorData >( "P", PrimitiveVariable::Vertex ); - if ( meshPoints ) - { - unsigned numPoints = meshPoints->readable().size(); - PointList* points = to.writable_points( objIndex ); - points->resize( numPoints ); - std::transform( meshPoints->readable().begin(), meshPoints->readable().end(), points->begin(), IECore::convert< DD::Image::Vector3, Imath::V3f > ); - } - - // get normals - const V3fVectorData *meshNormals = mesh->variableData< V3fVectorData >( "N", PrimitiveVariable::Vertex ); - if ( meshNormals ) - { - Attribute* N = to.writable_attribute( objIndex, Group_Points, "N", NORMAL_ATTRIB); - unsigned p = 0; - for ( std::vector< Imath::V3f >::const_iterator nIt = meshNormals->readable().begin(); nIt < meshNormals->readable().end(); nIt++, p++) - { - N->normal(p) = IECore::convert< Vector3, Imath::V3f >( *nIt ); - } - } - - // get uvs - PrimitiveVariableMap::const_iterator uvIt = mesh->variables.find( "uv" ); - if( uvIt != mesh->variables.end() && uvIt->second.interpolation == PrimitiveVariable::FaceVarying && uvIt->second.data->typeId() == V2fVectorDataTypeId ) - { - Attribute* uv = to.writable_attribute( objIndex, Group_Vertices, "uv", VECTOR4_ATTRIB ); - if( uvIt->second.indices ) - { - const std::vector &uvs = runTimeCast( uvIt->second.data )->readable(); - const std::vector &indices = uvIt->second.indices->readable(); - - for( size_t i = 0; i < indices.size() ; ++i ) - { - uv->vector4( i ).set( uvs[indices[i]][0], uvs[indices[i]][1], 0.0f, 1.0f ); - } - } - else - { - const std::vector &uvs = runTimeCast( uvIt->second.data )->readable(); - - for( size_t i = 0; i < uvs.size() ; ++i ) - { - uv->vector4( i ).set( uvs[i][0], uvs[i][1], 0.0f, 1.0f ); - } - } - } - - // get colours - const Color3fVectorData *meshColours = mesh->variableData< Color3fVectorData >( "Cs", PrimitiveVariable::FaceVarying ); - if ( meshColours ) - { - Attribute *Cf = to.writable_attribute( objIndex, Group_Vertices, "Cf", VECTOR4_ATTRIB ); - unsigned v = 0; - for ( std::vector< Imath::Color3f >::const_iterator cIt = meshColours->readable().begin(); cIt < meshColours->readable().end(); cIt++, v++) - { - Cf->vector4( v ).set( (*cIt)[0], (*cIt)[1], (*cIt)[2], 1 ); - } - } - - // \todo Implement custom prim vars... -} diff --git a/src/IECoreNuke/ObjectHolder.cpp b/src/IECoreNuke/ObjectHolder.cpp deleted file mode 100644 index e135633a40..0000000000 --- a/src/IECoreNuke/ObjectHolder.cpp +++ /dev/null @@ -1,73 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ObjectHolder.h" - -#include "IECoreNuke/ObjectKnob.h" - -using namespace IECoreNuke; - -const DD::Image::Op::Description ObjectHolder::g_description( "ieObject", build ); - -ObjectHolder::ObjectHolder( Node *node ) - : DD::Image::Op( node ), - m_object( 0 ) -{ -} - -ObjectHolder::~ObjectHolder() -{ -} - -void ObjectHolder::knobs( DD::Image::Knob_Callback f ) -{ - Op::knobs( f ); - - ObjectKnob::objectKnob( f, &m_object, "object", "Object" ); -} - -DD::Image::Op *ObjectHolder::build( Node *node ) -{ - return new ObjectHolder( node ); -} - -const char *ObjectHolder::Class() const -{ - return g_description.name; -} - -const char *ObjectHolder::node_help() const -{ - return "Holds cortex objects on the \"object\" knob."; -} diff --git a/src/IECoreNuke/ObjectKnob.cpp b/src/IECoreNuke/ObjectKnob.cpp deleted file mode 100644 index 8403f4c167..0000000000 --- a/src/IECoreNuke/ObjectKnob.cpp +++ /dev/null @@ -1,181 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/ObjectKnob.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/HexConversion.h" -#include "IECore/MemoryIndexedIO.h" - -using namespace IECoreNuke; -using namespace DD::Image; -using namespace boost::python; - -ObjectKnob::ObjectKnob( DD::Image::Knob_Closure *f, IECore::ObjectPtr *storage, const char *name, const char *label ) - : DD::Image::Knob( f, name, label ), m_defaultValue( 0 ), m_value( 0 ) -{ - - set_flag( NO_ANIMATION ); - - if( storage && *storage ) - { - m_defaultValue = (*storage)->copy(); - m_value = m_defaultValue; - } - - // set up the object that will provide the python binding - IECorePython::ScopedGILLock gilLock; - Detail::PythonObjectKnobPtr pythonKnob = new Detail::PythonObjectKnob; - pythonKnob->objectKnob = this; - object pythonKnobObject( pythonKnob ); - Py_INCREF( pythonKnobObject.ptr() ); - setPyObject( pythonKnobObject.ptr() ); -} - -ObjectKnob::~ObjectKnob() -{ - // tidy up the object for the python binding - IECorePython::ScopedGILLock gilLock; - object pythonKnobObject( handle<>( borrowed( (PyObject *)pyObject() ) ) ); - Detail::PythonObjectKnobPtr pythonKnob = extract( pythonKnobObject ); - pythonKnob->objectKnob = 0; - Py_DECREF( pythonKnobObject.ptr() ); -} - -bool ObjectKnob::setValue( IECore::ConstObjectPtr value ) -{ - if( !valuesEqual( m_value.get(), value.get() ) ) - { - new_undo(); - m_value = value ? value->copy() : 0; - changed(); - return true; - } - - return false; -} - -IECore::ConstObjectPtr ObjectKnob::getValue() const -{ - return m_value; -} - -ObjectKnob *ObjectKnob::objectKnob( DD::Image::Knob_Callback f, IECore::ObjectPtr *storage, const char *name, const char *label ) -{ - return CustomKnob2( ObjectKnob, f, storage, name, label ); -} - -const char *ObjectKnob::Class() const -{ - return "ObjectKnob"; -} - -void ObjectKnob::to_script( std::ostream &os, const DD::Image::OutputContext *context, bool quote ) const -{ - if( quote ) - { - os << "{"; - } - - if( m_value ) - { - IECore::MemoryIndexedIOPtr io = new IECore::MemoryIndexedIO( IECore::ConstCharVectorDataPtr(), IECore::IndexedIO::rootPath, IECore::IndexedIO::Exclusive | IECore::IndexedIO::Write ); - m_value->save( io, "object" ); - IECore::ConstCharVectorDataPtr buffer = io->buffer(); - os << IECore::decToHex( buffer->readable().begin(), buffer->readable().end() ); - } - - if( quote ) - { - os << "}"; - } -} - -bool ObjectKnob::from_script( const char *value ) -{ - IECore::ObjectPtr object = m_defaultValue; - if( value && strlen( value ) ) - { - - size_t n = strlen( value ); - IECore::CharVectorDataPtr buffer = new IECore::CharVectorData; - buffer->writable().resize( n / 2 ); - IECore::hexToDec( value, value + n, buffer->writable().begin() ); - - try - { - IECore::MemoryIndexedIOPtr io = new IECore::MemoryIndexedIO( buffer, IECore::IndexedIO::rootPath, IECore::IndexedIO::Exclusive | IECore::IndexedIO::Read ); - object = IECore::Object::load( io, "object" ); - } - catch( std::exception &e ) - { - error( e.what() ); - } - - } - - return setValue( object ); -} - -bool ObjectKnob::not_default() const -{ - return !valuesEqual( m_value.get(), m_defaultValue.get() ); -} - -void ObjectKnob::store( DD::Image::StoreType storeType, void *storage, DD::Image::Hash &hash, const DD::Image::OutputContext &context ) -{ - assert( storeType == DD::Image::Custom ); - if( storage ) - { - *((IECore::ObjectPtr *)storage) = m_value; - } -} - -bool ObjectKnob::valuesEqual( const IECore::Object *value1, const IECore::Object *value2 ) const -{ - bool equal = true; - if( value2 ) - { - equal = value1 && value1->isEqualTo( value2 ); - } - else - { - equal = !value1; - } - - return equal; -} diff --git a/src/IECoreNuke/ObjectVectorParameterHandler.cpp b/src/IECoreNuke/ObjectVectorParameterHandler.cpp deleted file mode 100644 index 8137f1599f..0000000000 --- a/src/IECoreNuke/ObjectVectorParameterHandler.cpp +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ObjectVectorParameterHandler.h" - -#include "IECoreNuke/OpHolder.h" - -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/ObjectVector.h" - -using namespace IECoreNuke; - -ParameterHandler::Description ObjectVectorParameterHandler::g_description( IECore::ObjectVectorParameter::staticTypeId() ); - -ObjectVectorParameterHandler::ObjectVectorParameterHandler() -{ -} - -int ObjectVectorParameterHandler::minimumInputs( const IECore::Parameter *parameter ) -{ - return 0; -} - -int ObjectVectorParameterHandler::maximumInputs( const IECore::Parameter *parameter ) -{ - return 100; -} - -bool ObjectVectorParameterHandler::testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ) -{ - if( dynamic_cast( op ) ) - { - return 1; - } - return 0; -} - -void ObjectVectorParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) -{ - assert( last == first + 1 ); - - IECore::ObjectVectorPtr value = new IECore::ObjectVector; - for( InputIterator it=first; it!=last; it++ ) - { - OpHolder *opHolder = static_cast( *it ); - if( opHolder ) - { - IECore::ObjectPtr o = opHolder->engine(); - value->members().push_back( o ); - } - } - - parameter->setValue( value ); -} diff --git a/src/IECoreNuke/OpHolder.cpp b/src/IECoreNuke/OpHolder.cpp deleted file mode 100644 index ccd9111b1c..0000000000 --- a/src/IECoreNuke/OpHolder.cpp +++ /dev/null @@ -1,120 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/OpHolder.h" - -using namespace IECoreNuke; - -static IECore::ObjectPtr g_lastExecuteResult = 0; - -const DD::Image::Op::Description OpHolder::g_description( "ieOp", build ); - -OpHolder::OpHolder( Node *node ) - : ParameterisedHolderOp( node ), - DD::Image::Executable( this ), - m_result( 0 ) -{ -} - -OpHolder::~OpHolder() -{ -} - -IECore::ObjectPtr OpHolder::engine() -{ - if( m_result && hash()==m_resultHash ) - { - return m_result; - } - - IECore::ConstOpPtr constOp = IECore::runTimeCast( parameterised() ); - if( !constOp ) - { - return 0; - } - - /// \todo operate() should be const, then we wouldn't need this cast. - IECore::OpPtr op = boost::const_pointer_cast( constOp ); - - setParameterValues(); /// \todo is this really needed?? didn't we do that in validate()? - setParameterValuesFromInputs(); /// \todo Should this be done by an engine() call on the base class? - - m_result = op->operate(); - m_resultHash = hash(); - - return m_result; -} - -DD::Image::Op *OpHolder::build( Node *node ) -{ - return new OpHolder( node ); -} - -const char *OpHolder::Class() const -{ - return g_description.name; -} - -const char *OpHolder::node_help() const -{ - return "Executes Cortex Ops."; -} - -DD::Image::Executable *OpHolder::executable() -{ - return this; -} - -bool OpHolder::isExecuteThreadSafe() const -{ - return false; -} - -void OpHolder::execute() -{ - IECore::ObjectPtr result = engine(); - g_lastExecuteResult = result; -} - -bool OpHolder::isWrite() -{ - return false; -} - -IECore::ObjectPtr OpHolder::executeResult() -{ - IECore::ObjectPtr result = g_lastExecuteResult; - g_lastExecuteResult = 0; - return result; -} diff --git a/src/IECoreNuke/ParameterHandler.cpp b/src/IECoreNuke/ParameterHandler.cpp deleted file mode 100644 index 8a222d22b3..0000000000 --- a/src/IECoreNuke/ParameterHandler.cpp +++ /dev/null @@ -1,159 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ParameterHandler.h" - -#include "IECoreNuke/PresetsOnlyParameterHandler.h" - -#include "IECore/CamelCase.h" -#include "IECore/CompoundObject.h" -#include "IECore/SimpleTypedData.h" - -#include "DDImage/Knobs.h" - -using namespace DD::Image; -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::ParameterHandler() -{ -} - -int ParameterHandler::minimumInputs( const IECore::Parameter *parameter ) -{ - return 0; -} - -int ParameterHandler::maximumInputs( const IECore::Parameter *parameter ) -{ - return 0; -} - -bool ParameterHandler::testInput( const IECore::Parameter *parameter, int input, const DD::Image::Op *op ) -{ - return false; -} - -void ParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) -{ -} - -void ParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ -} - -void ParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ -} - -void ParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ -} - -void ParameterHandler::setState( IECore::Parameter *parameter, const IECore::Object *state ) -{ - assert( 0 ); // shouldn't get called because we don't return a state in getState() -} - -IECore::ObjectPtr ParameterHandler::getState( const IECore::Parameter *parameter ) -{ - return 0; -} - -ParameterHandlerPtr ParameterHandler::create( const IECore::Parameter *parameter ) -{ - if( parameter->presetsOnly() ) - { - return new PresetsOnlyParameterHandler(); - } - - const CreatorFnMap &creators = creatorFns(); - TypeId typeId = parameter->typeId(); - while( typeId!=InvalidTypeId ) - { - CreatorFnMap::const_iterator it = creators.find( typeId ); - if( it!=creators.end() ) - { - return it->second(); - } - typeId = RunTimeTyped::baseTypeId( typeId ); - } - return 0; -} - -ParameterHandler::CreatorFnMap &ParameterHandler::creatorFns() -{ - static CreatorFnMap creators; - return creators; -} - -std::string ParameterHandler::knobLabel( const IECore::Parameter *parameter ) const -{ - return IECore::CamelCase::toSpaced( parameter->name().c_str() ); -} - -void ParameterHandler::setKnobProperties( const IECore::Parameter *parameter, DD::Image::Knob_Callback f, DD::Image::Knob *knob ) const -{ - const CompoundObject *userData = parameter->userData(); - const CompoundObject *ui = userData->member( "UI" ); - - int flags = 0; - if( ui ) - { - const BoolData *visible = ui->member( "visible" ); - if( visible && !visible->readable() ) - { - flags |= Knob::INVISIBLE; - } - } - - SetFlags( f, flags ); - Tooltip( f, parameter->description() ); - - if( f.makeKnobs() ) - { - const CompoundObject *nuke = userData->member( "nuke" ); - if( nuke ) - { - const StringData *defaultExpression = nuke->member( "defaultExpression" ); - if( defaultExpression ) - { - if( knob->from_script( defaultExpression->readable().c_str() ) ) - { - knob->changed(); - } - } - } - } -} diff --git a/src/IECoreNuke/ParameterisedHolder.cpp b/src/IECoreNuke/ParameterisedHolder.cpp deleted file mode 100644 index 1321b9798d..0000000000 --- a/src/IECoreNuke/ParameterisedHolder.cpp +++ /dev/null @@ -1,555 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/ParameterisedHolder.h" - -#include "IECoreNuke/ParameterHandler.h" - -#include "IECorePython/ScopedGILLock.h" - -#include "IECore/CompoundParameter.h" -#include "IECore/MessageHandler.h" -#include "IECore/SimpleTypedData.h" - -#include "DDImage/Enumeration_KnobI.h" -#include "DDImage/Iop.h" -#include "DDImage/Knob.h" -#include "DDImage/Knobs.h" -#include "DDImage/Op.h" - -#include "boost/format.hpp" -#include "boost/python/suite/indexing/container_utils.hpp" - -using namespace std; -using namespace boost; -using namespace boost::python; -using namespace IECore; -using namespace IECoreNuke; - -static IECore::RunTimeTypedPtr g_getParameterisedResult = 0; -static IECore::RunTimeTypedPtr g_modifiedParametersInput = 0; - -template -ParameterisedHolder::ParameterisedHolder( Node *node ) - : BaseType( node ), - m_classSpecifierKnob( 0 ), - m_classReloadKnob( 0 ), - m_classDividerKnob( 0 ), - m_parameterised( 0 ), - m_currentClassSpecification( 0 ), - m_parameterHandler( 0 ), - m_numParameterKnobs( 0 ), - m_getParameterisedKnob( 0 ), - m_modifiedParametersKnob( 0 ) -{ - this->inputs( 0 ); -} - -template -ParameterisedHolder::~ParameterisedHolder() -{ -} - -template -int ParameterisedHolder::minimum_inputs() const -{ - const ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - if( parameterisedInterface ) - { - return m_parameterHandler->minimumInputs( parameterisedInterface->parameters() ); - } - return 0; -} - -template -int ParameterisedHolder::maximum_inputs() const -{ - const ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - if( parameterisedInterface ) - { - return m_parameterHandler->maximumInputs( parameterisedInterface->parameters() ); - } - return 0; -} - -template -bool ParameterisedHolder::test_input( int input, DD::Image::Op *op ) const -{ - const ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - if( parameterisedInterface ) - { - return m_parameterHandler->testInput( parameterisedInterface->parameters(), input, op ); - } - return false; -} - -template -void ParameterisedHolder::knobs( DD::Image::Knob_Callback f ) -{ - BaseType::knobs( f ); - - m_classSpecifierKnob = ObjectKnob::objectKnob( f, 0, "classSpecifier", "classSpecifier" ); - SetFlags( f, DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - - m_getParameterisedKnob = Button( f, "__getParameterised" ); - SetFlags( f, DD::Image::Knob::KNOB_CHANGED_ALWAYS | DD::Image::Knob::INVISIBLE ); - - m_modifiedParametersKnob = Button( f, "__modifiedParameters" ); - SetFlags( f, DD::Image::Knob::KNOB_CHANGED_ALWAYS | DD::Image::Knob::INVISIBLE ); - - static const char *noVersions[] = { "No class loaded", "", 0 }; - m_versionChooserKnob = PyPulldown_knob( f, noVersions, "versionChooser", "No class loaded" ); - - m_classReloadKnob = Button( f, "classReload", "Reload" ); - SetFlags( f, DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - - DD::Image::Knob *classDividerKnob = Divider( f, "" ); - if( classDividerKnob ) - { - // the Divider() call only returns a value during knob creation, and - // returns 0 the rest of the time. - m_classDividerKnob = classDividerKnob; - } - - // add on the knobs for the parameters. first we must make sure that our held class - // is up to date. although we update it in knob_changed when a new class or state has - // been requested, this will only be applied to the one lucky ParameterisedHolder instance - // that nuke chooses to send knob_changed to. nuke will frequently have other ParameterisedHolder - // instances for the same node, and those don't get a chance to update. so we call updateParameterised - // here so they can get synced up too. - - updateParameterised( false ); - - BaseType::add_knobs( parameterKnobs, this, f ); -} - -template -int ParameterisedHolder::knob_changed( DD::Image::Knob *knob ) -{ - if( knob==m_classSpecifierKnob || knob==m_classReloadKnob ) - { - // reload the class, or load a new class - - updateParameterised( knob==m_classReloadKnob ); - - // regenerate the knobs used to represent the parameters - - replaceKnobs(); - - // update the version menu - - updateVersionChooser(); - - return 1; - } - else if( knob==m_getParameterisedKnob ) - { - // this is triggered by the FnParameterisedHolder.getParameterised implementation. - // currently there's no way to get an Op * and call a method on it from - // python, so we use the knob_changed() mechanism to simulate a function call by - // shoving the result into g_getParameterisedResult for subsequent retrieval. - - g_getParameterisedResult = loadClass( false ); - if( g_getParameterisedResult ) - { - ParameterisedInterface *parameterisedInterface = dynamic_cast( g_getParameterisedResult.get() ); - // apply current state - ConstCompoundObjectPtr classSpecifier = runTimeCast( m_classSpecifierKnob->getValue() ); - ConstObjectPtr handlerState = classSpecifier->member( "handlerState" ); - if( handlerState ) - { - m_parameterHandler->setState( parameterisedInterface->parameters(), handlerState.get() ); - } - // get values directly from knobs as they haven't been stored at this point - m_parameterHandler->setParameterValue( parameterisedInterface->parameters(), ParameterHandler::Knob ); - } - - return 1; - } - else if( knob==m_modifiedParametersKnob ) - { - // this is triggered by the FnParameterisedHolder.classModificationContext() implementation. - // as above, we use this method in lieu of being able to call a method on this class. - - // get the new handler state and store it so we have it for save/load copy/paste etc - //////////////////////////////////////////////////////////////////////////////////// - - ParameterisedInterface *inputParameterisedInterface = dynamic_cast( g_modifiedParametersInput.get() ); - ObjectPtr handlerState = m_parameterHandler->getState( inputParameterisedInterface->parameters() ); - CompoundObjectPtr classSpecifier = runTimeCast( m_classSpecifierKnob->getValue()->copy() ); - if( handlerState ) - { - classSpecifier->members()["handlerState"] = handlerState; - } - else - { - classSpecifier->members().erase( "handlerState" ); - } - // it seems that setting the value from inside knob_changed() doesn't emit a new knob_changed(), which - // is fortunately what we want. - m_classSpecifierKnob->setValue( classSpecifier ); - - // apply the new state to the current parameterised object - //////////////////////////////////////////////////////////////////////////////////// - - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - if( handlerState ) - { - m_parameterHandler->setState( parameterisedInterface->parameters(), handlerState.get() ); - } - parameterisedInterface->parameters()->setValue( inputParameterisedInterface->parameters()->getValue() ); - - // update the knobs using our newly updated parameterised object - //////////////////////////////////////////////////////////////////////////////////// - - replaceKnobs(); - setKnobValues(); - - // forget the input - - g_modifiedParametersInput = 0; - - return 1; - } - - return BaseType::knob_changed( knob ); -} - -template -void ParameterisedHolder::_validate( bool forReal ) -{ - BaseType::_validate( forReal ); - - const std::vector &inputs = BaseType::getInputs(); - for( std::vector::const_iterator it=inputs.begin(); it!=inputs.end(); it++ ) - { - if( DD::Image::Iop *iOp = dynamic_cast( *it ) ) - { - iOp->request( DD::Image::Mask_All, 1 ); - } - } - - setParameterValues(); -} - -template -IECore::ConstRunTimeTypedPtr ParameterisedHolder::parameterised() -{ - return m_parameterised; -} - -template -const IECore::ParameterisedInterface *ParameterisedHolder::parameterisedInterface() -{ - return dynamic_cast( m_parameterised.get() ); -} - -template -void ParameterisedHolder::setParameterValuesFromInputs() -{ - if( m_parameterHandler ) - { - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - m_parameterHandler->setParameterValue( parameterisedInterface->parameters(), BaseType::getInputs().begin(), BaseType::getInputs().end() ); - } -} - -template -void ParameterisedHolder::setParameterValues() -{ - if( m_parameterHandler ) - { - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - m_parameterHandler->setParameterValue( parameterisedInterface->parameters() ); - } -} - -template -void ParameterisedHolder::setKnobValues() -{ - if( m_parameterHandler ) - { - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - m_parameterHandler->setKnobValue( parameterisedInterface->parameters() ); - } -} - - -template -void ParameterisedHolder::buildParameterKnobHandles( DD::Image::ViewerContext *ctx ) const -{ - if( !BaseType::panel_visible() ) - { - return; - } - - int knobIndex = 0; - while( DD::Image::Knob *k = BaseType::knob( knobIndex++ ) ) - { - if( k->name().compare( 0, 5, "parm_" ) == 0 ) - { - if( k->build_handle( ctx ) ) - { - k->add_draw_handle( ctx ); - } - } - } -} - -template -void ParameterisedHolder::replaceKnobs() -{ - - // in an ideal world, nuke would notice when the new knobs are the same name/type as the old ones, - // and keep the values and animation and wotnot - they even have a comment in the docs saying how - // nice that would be. but that doesn't exist right now, so we do it ourselves. we're doing - // it here rather than complicating the ParameterHandler mechanism in the hope that in the future - // Nuke will do it for us and we can then just remove this little bit of code rather than rejig - // the actual API. - - std::map knobScripts; - DD::Image::Knob *pKnob = 0; - for( int i=0; (pKnob = BaseType::knob( i )); i++ ) - { - if( pKnob->name().compare( 0, 5, "parm_" ) == 0 ) - { - ostringstream ss; - pKnob->to_script( ss, 0, false ); - knobScripts[pKnob->name()] = ss.str(); - } - } - - m_numParameterKnobs = this->replace_knobs( m_classDividerKnob, m_numParameterKnobs, parameterKnobs, this ); - - for( int i=0; (pKnob = BaseType::knob( i )); i++ ) - { - std::map::const_iterator it = knobScripts.find( pKnob->name() ); - if( it!=knobScripts.end() ) - { - if( pKnob->from_script( it->second.c_str() ) ) - { - pKnob->changed(); - } - } - } - -} - -template -void ParameterisedHolder::parameterKnobs( void *that, DD::Image::Knob_Callback f ) -{ - const ParameterisedHolder *parameterisedHolder = static_cast( that ); - - if( parameterisedHolder->m_parameterHandler ) - { - const ParameterisedInterface *parameterisedInterface = dynamic_cast( parameterisedHolder->m_parameterised.get() ); - parameterisedHolder->m_parameterHandler->knobs( parameterisedInterface->parameters(), "parm", f ); - } -} - -template -void ParameterisedHolder::updateVersionChooser() -{ - IECore::ConstCompoundObjectPtr d = IECore::runTimeCast( m_classSpecifierKnob->getValue() ); - if( !d ) - { - return; - } - - // get the versions if there are any - - std::string className = d->member( "className" )->readable(); - int classVersion = d->member( "classVersion" )->readable(); - std::vector classVersions; - if( m_parameterised ) - { - - std::string classSearchPathEnvVar = d->member( "classSearchPathEnvVar" )->readable(); - - { - IECorePython::ScopedGILLock gilLock; - - object ieCore = import( "IECore" ); - object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultLoader" )( classSearchPathEnvVar ); - object classVersionsObject = classLoader.attr( "versions" )( className ); - - container_utils::extend_container( classVersions, classVersionsObject ); - } - - } - - // and update the knob with menu items for each version - - string label; - vector menuItems; - if( m_parameterised ) - { - label = className + " v" + lexical_cast( classVersion ); - - for( unsigned i=0; i( classVersions[i] ) ); - - std::string s = - - "fnPH = IECoreNuke.FnParameterisedHolder( nuke.thisNode() )\n" - "current = fnPH.getParameterised()\n" - "fnPH.setParameterised( current[1], " + lexical_cast( classVersions[i] ) + ", current[3] )"; - - menuItems.push_back( s ); - } - } - else - { - label = "No class loaded"; - menuItems.push_back( label ); - menuItems.push_back( "" ); - } - - m_versionChooserKnob->label( label.c_str() ); - m_versionChooserKnob->enumerationKnob()->menu( menuItems ); -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::loadClass( bool refreshLoader ) -{ - - std::string className; - int classVersion; - std::string classSearchPathEnvVar; - - IECore::ConstCompoundObjectPtr d = IECore::runTimeCast( ((ObjectKnob *)BaseType::knob( "classSpecifier" ))->getValue() ); - - if( d ) - { - className = d->member( "className" )->readable(); - classVersion = d->member( "classVersion" )->readable(); - classSearchPathEnvVar = d->member( "classSearchPathEnvVar" )->readable(); - } - - if( className=="" ) - { - return 0; - } - - IECorePython::ScopedGILLock gilLock; - - try - { - - // get the loader - - object ieCore = import( "IECore" ); - object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultLoader" )( classSearchPathEnvVar ); - - // make sure it's refreshed if required - - if( refreshLoader ) - { - classLoader.attr( "refresh" )(); - } - - // then load an instance of the class - - object result = classLoader.attr( "load" )( className, classVersion )(); - - // and return it - - return extract( result )(); - } - catch( error_already_set & ) - { - msg( Msg::Error, "ParameterisedHolder::loadClass", - boost::format( "Unable to load class \"%s\" version %d into node %s." ) % className % classVersion % BaseType::node_name() ); - - PyErr_Print(); - } - catch( ... ) - { - msg( Msg::Error, "ParameterisedHolder::loadClass", - boost::format( "Unable to load class \"%s\" version %d into node %s." ) % className % classVersion % BaseType::node_name() ); - } - return 0; - -} - -template -void ParameterisedHolder::updateParameterised( bool reload ) -{ - if( !reload && m_currentClassSpecification==m_classSpecifierKnob->getValue() ) - { - return; - } - - m_parameterised = loadClass( reload ); - - m_parameterHandler = 0; - ParameterisedInterface *parameterisedInterface = dynamic_cast( m_parameterised.get() ); - if( parameterisedInterface ) - { - m_parameterHandler = ParameterHandler::create( parameterisedInterface->parameters() ); - - // apply the previously stored handler state - - ConstCompoundObjectPtr classSpecifier = runTimeCast( m_classSpecifierKnob->getValue() ); - ConstObjectPtr handlerState = classSpecifier->member( "handlerState" ); - if( handlerState ) - { - m_parameterHandler->setState( parameterisedInterface->parameters(), handlerState.get() ); - } - } - - m_currentClassSpecification = m_classSpecifierKnob->getValue(); -} - -template -IECore::RunTimeTypedPtr ParameterisedHolder::getParameterisedResult() -{ - IECore::RunTimeTypedPtr result = g_getParameterisedResult; - g_getParameterisedResult = 0; - return result; -} - -template -void ParameterisedHolder::setModifiedParametersInput( IECore::RunTimeTypedPtr parameterised ) -{ - g_modifiedParametersInput = parameterised; -} - -// explicit instantiation - -template class ParameterisedHolder; - diff --git a/src/IECoreNuke/PathParameterHandler.cpp b/src/IECoreNuke/PathParameterHandler.cpp deleted file mode 100644 index aa2a943589..0000000000 --- a/src/IECoreNuke/PathParameterHandler.cpp +++ /dev/null @@ -1,58 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/PathParameterHandler.h" - -#include "IECore/PathParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description PathParameterHandler::g_description( PathParameter::staticTypeId() ); - -PathParameterHandler::PathParameterHandler() -{ -} - -DD::Image::Knob *PathParameterHandler::knob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f, const char **storage ) -{ - std::string label = knobLabel( parameter ); - /// \todo This should be a call to File_knob, but when we have a File_knob the value - /// restoration code in ParameterisedHolder::replaceKnobs() fails silently. We'd rather - /// keep our values than have a file selector button. I think this is a bug in Nuke, so - /// if it ever gets fixed we could introduce File_knob again (tested in 6.2v4). - return String_knob( f, storage, knobName, label.c_str() ); -} diff --git a/src/IECoreNuke/PointToNukeGeometryConverter.cpp b/src/IECoreNuke/PointToNukeGeometryConverter.cpp deleted file mode 100644 index 5170ad999b..0000000000 --- a/src/IECoreNuke/PointToNukeGeometryConverter.cpp +++ /dev/null @@ -1,166 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/PointToNukeGeometryConverter.h" - -#include "IECoreNuke/Convert.h" - -#include "IECoreScene/PointsPrimitive.h" - -#include "IECore/SimpleTypedData.h" -#include "IECore/TypeIds.h" - -#include "DDImage/Particles.h" -#include "DDImage/Vector3.h" - -using namespace boost; -using namespace IECore; -using namespace IECoreScene; -using namespace IECoreNuke; -using namespace DD::Image; - -PointToNukeGeometryConverter::ToNukeGeometryConverterDescription PointToNukeGeometryConverter::g_description( PointsPrimitive::staticTypeId() ); - -PointToNukeGeometryConverter::PointToNukeGeometryConverter( IECore::ConstObjectPtr object ) -: ToNukeGeometryConverter( "Converts IECore.PointPrimitive objects to geometry in a Nuke GeometryList object.", PointsPrimitive::staticTypeId(), object ) -{ -} - -void PointToNukeGeometryConverter::doConversion( const IECore::Object *from, GeometryList &to, int objIndex, const IECore::CompoundObject *operands ) const -{ - assert( from ); - - const PointsPrimitive *points = static_cast( from ); - to.add_primitive(objIndex, new Particles(Point::POINT, unsigned(points->getNumPoints()), 0)); - - // get points - // \todo: add parameters for standard prim vars - const V3fVectorData *pointPoints = points->variableData< V3fVectorData >( "P", PrimitiveVariable::Vertex ); - if ( pointPoints ) - { - unsigned numPoints = pointPoints->readable().size(); - PointList* outPoints = to.writable_points( objIndex ); - outPoints->resize( numPoints ); - std::transform( pointPoints->readable().begin(), pointPoints->readable().end(), outPoints->begin(), IECore::convert< DD::Image::Vector3, Imath::V3f > ); - } - - // get normals - const V3fVectorData *pointNormals = points->variableData< V3fVectorData >( "N", PrimitiveVariable::Vertex ); - if ( pointNormals ) - { - Attribute* N = to.writable_attribute( objIndex, Group_Points, "N", NORMAL_ATTRIB); - unsigned p = 0; - for ( std::vector< Imath::V3f >::const_iterator nIt = pointNormals->readable().begin(); nIt < pointNormals->readable().end(); nIt++, p++) - { - N->normal(p) = IECore::convert< Vector3, Imath::V3f >( *nIt ); - } - } - // get width - const FloatData *constWidth = points->variableData< FloatData >( "constantwidth", PrimitiveVariable::Constant ); - const FloatVectorData *width = points->variableData< FloatVectorData >( "width", PrimitiveVariable::Vertex ); - Attribute* size = to.writable_attribute( objIndex, Group_Points, "size", FLOAT_ATTRIB ); - unsigned v = 0; - if ( constWidth || width ) - { - if (width) - { - std::vector< float >::const_iterator widthIt = width->readable().begin(); - for ( ; widthIt < width->readable().end(); widthIt++, v++) - { - size->flt(v) = *widthIt; - } - } - else - { - for( ; v< points->getNumPoints(); v++ ) - { - size->flt(v) = constWidth->readable(); - } - } - } - else - { - for( ; v < points->getNumPoints(); v++ ) - { - size->flt(v) = 0.1; - } - - } - - // get uvs - PrimitiveVariableMap::const_iterator uvIt = points->variables.find( "uv" ); - if( uvIt != points->variables.end() && uvIt->second.interpolation == PrimitiveVariable::Vertex && uvIt->second.data->typeId() == V2fVectorDataTypeId ) - { - Attribute* uv = to.writable_attribute( objIndex, Group_Vertices, "uv", VECTOR4_ATTRIB ); - if( uvIt->second.indices ) - { - const std::vector &uvs = runTimeCast( uvIt->second.data )->readable(); - const std::vector &indices = uvIt->second.indices->readable(); - - for( size_t i = 0; i < indices.size() ; ++i ) - { - uv->vector4( i ).set( uvs[indices[i]][0], uvs[indices[i]][1], 0.0f, 1.0f ); - } - } - else - { - const std::vector &uvs = runTimeCast( uvIt->second.data )->readable(); - - for( size_t i = 0; i < uvs.size() ; ++i ) - { - uv->vector4( i ).set( uvs[i][0], uvs[i][1], 0.0f, 1.0f ); - } - } - } - - Attribute *Cf = to.writable_attribute( objIndex, Group_Vertices, "Cf", VECTOR4_ATTRIB ); - v = 0; - // get colours - const Color3fVectorData *pointColours = points->variableData< Color3fVectorData >( "Cs", PrimitiveVariable::Vertex ); - if ( pointColours ) - { - for ( std::vector< Imath::Color3f >::const_iterator cIt = pointColours->readable().begin(); cIt < pointColours->readable().end(); cIt++, v++) - { - Cf->vector4( v ).set( (*cIt)[0], (*cIt)[1], (*cIt)[2], 1 ); - } - } - else - { - for ( v=0; v < points->getNumPoints(); v++) - { - Cf->vector4( v ).set(1, 1, 1, 1); - } - - } -} diff --git a/src/IECoreNuke/PresetsOnlyParameterHandler.cpp b/src/IECoreNuke/PresetsOnlyParameterHandler.cpp deleted file mode 100644 index c9374ba1cb..0000000000 --- a/src/IECoreNuke/PresetsOnlyParameterHandler.cpp +++ /dev/null @@ -1,99 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/PresetsOnlyParameterHandler.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -PresetsOnlyParameterHandler::PresetsOnlyParameterHandler() - : m_knob( 0 ) -{ -} - -void PresetsOnlyParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( f.makeKnobs() ) - { - m_names.clear(); - const Parameter::PresetsContainer &presets = parameter->getPresets(); - for( Parameter::PresetsContainer::const_iterator it = presets.begin(); it!=presets.end(); it++ ) - { - if( it->second->isEqualTo( parameter->defaultValue() ) ) - { - m_storage = m_names.size(); - } - - InternedString presetName( it->first ); - m_names.push_back( presetName.value().c_str() ); - } - m_names.push_back( 0 ); - } - - std::string label = knobLabel( parameter ); - m_knob = Enumeration_knob( f, &m_storage, &(m_names[0]), knobName, label.c_str() ); - - setKnobProperties( parameter, f, m_knob ); -} - -void PresetsOnlyParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - int presetIndex = 0; - if( valueSource==Storage ) - { - presetIndex = m_storage; - } - else - { - presetIndex = (int)m_knob->get_value(); - } - - parameter->setValue( parameter->getPresets()[presetIndex].second ); -} - -void PresetsOnlyParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const Parameter::PresetsContainer &presets = parameter->getPresets(); - std::string currentPresetName = parameter->getCurrentPresetName(); - size_t presetIndex = 0; - for( Parameter::PresetsContainer::const_iterator it = presets.begin(); it!=presets.end(); it++, presetIndex++ ) - { - if( it->first==currentPresetName ) - { - m_knob->set_value( presetIndex ); - } - } -} diff --git a/src/IECoreNuke/Python.cpp b/src/IECoreNuke/Python.cpp deleted file mode 100644 index 40c8d0e718..0000000000 --- a/src/IECoreNuke/Python.cpp +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/ScopedGILLock.h" - -using namespace boost::python; - -namespace IECoreNuke -{ - -// we use this to make sure the IECore and IECoreNuke modules are imported when -// the cortex plugins load. this makes life easier in a few places where it is assumed -// that bindings exist. -struct Python -{ - - Python() - { - IECorePython::ScopedGILLock gilLock; - - object mainModule = object( handle<>( borrowed( PyImport_AddModule( "__main__" ) ) ) ); - object mainModuleNamespace = mainModule.attr( "__dict__" ); - - std::string toExecute = "import IECore\nimport IECoreNuke"; - - try - { - handle<> resultHandle( PyRun_String( - toExecute.c_str(), - Py_file_input, - mainModuleNamespace.ptr(), - mainModuleNamespace.ptr() - ) ); - } - catch( error_already_set & ) - { - PyErr_Print(); - } - } - -}; - -// this static instance is what causes the initialisation -static Python g_init; - -} // namespace IECoreNuke diff --git a/src/IECoreNuke/SceneCacheReader.cpp b/src/IECoreNuke/SceneCacheReader.cpp deleted file mode 100644 index f368b52190..0000000000 --- a/src/IECoreNuke/SceneCacheReader.cpp +++ /dev/null @@ -1,1162 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/SceneCacheReader.h" - -#include "IECoreNuke/Convert.h" -#include "IECoreNuke/Hash.h" -#include "IECoreNuke/ToNukeGeometryConverter.h" - -#include "IECoreGL/BoxPrimitive.h" -#include "IECoreGL/Camera.h" -#include "IECoreGL/Exception.h" -#include "IECoreGL/GL.h" -#include "IECoreGL/Group.h" -#include "IECoreGL/IECoreGL.h" -#include "IECoreGL/NameStateComponent.h" -#include "IECoreGL/State.h" -#include "IECoreGL/StateComponent.h" -#include "IECoreGL/TypedStateComponent.h" - -#include "IECorePython/CheckedGILRelease.h" - -#include "IECoreScene/AttributeBlock.h" -#include "IECoreScene/CurvesPrimitive.h" -#include "IECoreScene/SceneCache.h" -#include "IECoreScene/SceneInterface.h" -#include "IECoreScene/SharedSceneInterfaces.h" -#include "IECoreScene/TransformOp.h" - -#include "DDImage/Enumeration_KnobI.h" -#include "DDImage/GeoSelectKnobI.h" -#include "DDImage/SceneView_KnobI.h" - -#include "boost/regex.hpp" - -#include -#include - -using namespace DD::Image; -using namespace IECoreNuke; -using namespace std; -using namespace Imath; - -static const char* const CLASS = "ieSceneCacheReader"; - -static const char* const HELP = "Loads and displays geometry from a scene cache file."; - -DD::Image::Op *SceneCacheReader::build( Node *node ){ return new SceneCacheReader( node ); } - -const Op::Description SceneCacheReader::m_description( CLASS, SceneCacheReader::build ); - -const char *SceneCacheReader::Class() const { return m_description.name; } - -const char *SceneCacheReader::node_help() const { return HELP; } - -typedef std::map< std::string, std::vector< unsigned int > > TagMap; - -class SceneCacheReader::SharedData -{ - public : - SharedData() : - m_evaluatedFilePath( "" ), - m_rootText( "/" ), - m_filterText( "" ), - m_filterTagText( "" ), - m_pathPrefix( "" ), - m_pathPrefixLength( 0 ), - m_scriptFinishedLoading( false ), - m_isFirstRun( true ) - { - } - - std::string m_evaluatedFilePath; // Holds the SceneCache file path after any TCL scripts have been evaluated.. - std::string m_rootText; // Holds the processed root item in the SceneCache. - std::string m_filterText; // Processed text to filter the scene with. - std::string m_filterTagText; // Processed text to filter the tags with. - - // Hashes that are used to both provide an early-out to some methods - // and also contribute towards a hash for the geometry. - DD::Image::Hash m_selectionHash; - DD::Image::Hash m_filterHash; - DD::Image::Hash m_sceneHash; - - // When buildSceneView is called to parse the scene cache and generate a list of entries for the SceneView_knob, - // this map is also populated. It holds a mapping of tag names to the indices of items which have that tag. - // It is used within the filterScene method to quickly filter items with a particular tag. - TagMap m_tagMap; - - // When specifying a root we store the path to it's parent item along with the length of it. We do this so that when - // we are building the list of items in the SceneView_knob we can strip this path quickly from the front of the - // name and easily restore it later to load it from the SceneCache. This ensures that the names of the items in the - // SceneView_knob are kept short. - std::string m_pathPrefix; - unsigned int m_pathPrefixLength; - - /// The SceneView_knob holds a list of all leaf items in the scene. When filtering the SceneView we specify indices into - /// this list. When setting or querying the selected items in the SceneView_knob we need to use indices into the list of - /// filtered (visible) items. This means that we have to keep a look-up table of mappings between indices in the filtered - /// list of items and the index within the complete list of items in the scene. - std::map m_itemToFiltered; // Mapping of the index within the full scene list and the filtered scene list. - std::vector m_filteredToItem; // Mapping from an index in the filtered scene list to the complete scene list. - std::vector m_selectedItems; // An array of selected items - - // A flag which is set when all of the knobs have been loaded from the script. - bool m_scriptFinishedLoading; - - // A flag which is used to initialize the internal data structures the first time the node is run. - bool m_isFirstRun; -}; - -// A simple function for comparing two strings. Used when sorting a vector of strings. -bool compareNoCase( const string& s1, const string& s2 ) -{ - return strcasecmp( s1.c_str(), s2.c_str() ) <= 0; -} - -// Used when removing redundant slashes from a path. -bool bothSlashes( char a, char b ) -{ - return a == '/' && b == '/'; -} - -static void buildSceneView( std::vector< std::string > &list, TagMap &tagMap, const IECoreScene::ConstSceneInterfacePtr sceneInterface, int rootPrefixLen ); - -SceneCacheReader::SceneCacheReader( Node *node ) - : SourceGeo( node ), - m_filePath( "" ), - m_root( "/" ), - m_filter( "" ), - m_worldSpace( false ), - m_visibilityFilter( false ), - m_filePathKnob( NULL ), - m_baseParentMatrixKnob( NULL ), - m_sceneKnob( NULL ), - m_tagFilterKnob( NULL ), - m_sceneFilterKnob( NULL ), - m_rootKnob( NULL ), - m_visibilityFilterKnob( NULL ), - m_data(NULL) -{ - m_baseParentMatrix.makeIdentity(); - - if ( firstOp() == this ) - { - m_data = new SharedData(); - } -} - -SceneCacheReader::~SceneCacheReader() -{ - delete m_data; -} - -SceneCacheReader *SceneCacheReader::firstReader() -{ - return dynamic_cast(firstOp()); -} - -const SceneCacheReader *SceneCacheReader::firstReader() const -{ - return dynamic_cast(firstOp()); -} - -SceneCacheReader::SharedData *SceneCacheReader::sharedData() -{ - return firstReader()->m_data; -} - -const SceneCacheReader::SharedData *SceneCacheReader::sharedData() const -{ - return firstReader()->m_data; -} - -void SceneCacheReader::_validate( bool forReal ) -{ - - IECorePython::CheckedGILRelease gilRelease; - - if ( firstReader() != this ) - { - SourceGeo::_validate( forReal ); - return; - } - - m_data->m_scriptFinishedLoading = true; - - if( m_data->m_isFirstRun ) - { - Knob *k = knob("loadAll"); - if( k != NULL ) - { - k->set_value( true ); - } - - m_data->m_isFirstRun = false; - loadAllFromKnobs(); - } - else - { - filterScene( m_data->m_filterText, m_data->m_filterTagText ); - } - - SourceGeo::_validate( forReal ); -} - -void SceneCacheReader::knobs( DD::Image::Knob_Callback f ) -{ - SourceGeo::knobs( f ); - - m_filePathKnob = File_knob( f, &m_filePath, "file", "File" ); - SetFlags( f, DD::Image::Knob::MODIFIES_GEOMETRY | DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - Tooltip( f, - "File name for the scene cache." - ); - - m_rootKnob = String_knob( f, &m_root, "sceneRoot", "Root" ); - SetFlags( f, DD::Image::Knob::MODIFIES_GEOMETRY | DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS | DD::Image::Knob::NO_ANIMATION ); - Tooltip( f, - "Root path for the scene cache." - ); - - int p = 0; - const char* tagNames[2] = { "None", 0 }; - m_tagFilterKnob = Enumeration_knob( f, &p, tagNames, "filterByTag", "Filter Tag" ); - SetFlags( f, DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - Tooltip( f, - "Filter items in the scene by their tagged attributes." - ); - - m_visibilityFilterKnob = Bool_knob( f, &m_visibilityFilter, "visibilityFilter" ); - SetFlags( f, DD::Image::Knob::STARTLINE | DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - Tooltip( f, - "Filter items in the scene based on their visibility attribute" - ); - - m_sceneFilterKnob = String_knob( f, &m_filter, "filterByName", "Filter Name" ); - SetFlags( f, DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - Tooltip( f, - "Filter items in the scene using full or partial matches of their names against this text." - ); - - const char* e = { 0 }; - m_sceneKnob = SceneView_knob( f, &p, &e, "sceneView", "Scene Hierarchy" ); - SetFlags( f, DD::Image::Knob::RESIZABLE | DD::Image::Knob::MODIFIES_GEOMETRY | DD::Image::Knob::SAVE_MENU | DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS - | DD::Image::Knob::KNOB_CHANGED_RIGHTCONTEXT | DD::Image::Knob::NO_ANIMATION - ); - - Bool_knob( f, &m_worldSpace, "worldSpace", "World Space" ); - SetFlags( f, DD::Image::Knob::STARTLINE | DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS ); - Tooltip( f, - "Use world space as opposed to root to calculate transform for each location." - ); - - // transform knobs - m_baseParentMatrixKnob = Axis_knob(f, &m_baseParentMatrix, "transform"); - if ( m_baseParentMatrixKnob != NULL) - { - if (GeoOp::selectable() == true) - { - m_baseParentMatrixKnob->enable(); - } - else - { - m_baseParentMatrixKnob->disable(); - } - } - - // This knob should never be changed by the user. It provides a mechanism for us to know when the - // item's knobs have been fully loaded through either a script load or a copy/paste. We need this - // because in order to rebuild our internal data structures correctly we require all of the knob's - // values to be loaded. Look at the knob_changed() method for more information. - bool b = false; - Bool_knob( f, &b, "loadAll" ); - SetFlags( f, DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS | DD::Image::Knob::INVISIBLE ); - -} - -int SceneCacheReader::knob_changed(Knob* k) -{ - if ( firstReader() != this ) - { - return SourceGeo::knob_changed(k); - } - - if ( k != NULL ) - { - if ( knob("selectable") == k ) - { - if ( GeoOp::selectable() == true ) - { - m_baseParentMatrixKnob->enable(); - } - else - { - m_baseParentMatrixKnob->disable(); - } - return 1; - } - else if( m_filePathKnob == k ) - { - // during knob_changed we cannot query m_filePath because it returns the previous value. - if ( script_expand( m_filePathKnob->get_text() ) ) - { - m_data->m_evaluatedFilePath = script_result(); - script_unlock(); - } - - if ( m_data->m_scriptFinishedLoading ) - { - // we want to keep current selection... - loadAllFromKnobs(); - } - return 1; - } - else if( m_rootKnob == k ) - { - std::string root = m_rootKnob->get_text(); - - // Validate the root string by removing duplicate '/' and ensuring that it starts with a '/' but doesn't end with one. - root.erase( std::unique( root.begin(), root.end(), bothSlashes ), root.end()); - - if( root.size() > 1 && root[ root.size()-1 ] == '/' ) - { - root = root.substr(0, root.size()-1); - } - - if( root.empty() ) - { - root = std::string("/"); - } - else if( root[0] != '/' ) - { - root = std::string("/") + root; - } - - // We would like the items in the SceneView_knob to be listed under the name of the root rather than it's full - // path. This means that we need to modify all of the item strings that we pass to it by removing the unwanted - // part of the path. - // To make recovery of the full path easier we store the unwanted of the path as a member. - IECoreScene::SceneInterface::Path rootPath; - IECoreScene::SceneInterface::stringToPath( root, rootPath ); - m_data->m_pathPrefix.clear(); - if( rootPath.size() > 0 ) - { - rootPath.pop_back(); - IECoreScene::SceneInterface::pathToString( rootPath, m_data->m_pathPrefix ); - } - - // We keep the length of the unwanted path string so that we can use it to easily truncate the names of the items - // that we use to populate the SceneView_knob. - m_data->m_pathPrefixLength = m_data->m_pathPrefix.size(); - m_data->m_rootText = root; - m_rootKnob->set_text( root.c_str() ); - - // Finally, update the UI with the validated string and rebuild the SceneView_knob. - if ( m_data->m_scriptFinishedLoading ) - { - // we want to keep current selection... - loadAllFromKnobs(); - } - return 1; - } - else if ( m_sceneFilterKnob == k ) - { - // As the filter expression or tag has changed, filter the scene again. - if( m_sceneFilterKnob ) - { - const char* c = m_sceneFilterKnob->get_text(); - if( c ) - { - m_data->m_filterText = std::string( c ); - } - else - { - m_data->m_filterText = ""; - } - } - - if ( m_data->m_scriptFinishedLoading ) - { - filterScene( m_data->m_filterText, m_data->m_filterTagText ); - } - return 1; - } - else if ( m_tagFilterKnob == k ) - { - // Get the tag's name. - m_data->m_filterTagText = std::string(""); - if( m_tagFilterKnob ) - { - tagSelection( m_data->m_filterTagText ); - } - - if ( m_data->m_scriptFinishedLoading ) - { - filterScene( m_data->m_filterText, m_data->m_filterTagText ); - } - return 1; - } - else if( m_sceneKnob == k ) - { - m_data->m_selectionHash = Hash(); - return 1; - } - // This knob is only loaded when a script is pasted or loaded from a file. - // As it is loaded last we know that the other knobs have already been set. - // This means that we have enough information to build our internal data - // structures. - else if( knob("loadAll") == k ) - { - if( !m_data->m_scriptFinishedLoading ) - { - m_data->m_scriptFinishedLoading = true; - validate( false ); - } - - return 1; - } - else if( std::string( k->name() ) == "hidePanel" || std::string( k->name() ) == "showPanel" ) - { - if( !m_data->m_scriptFinishedLoading ) - { - m_data->m_scriptFinishedLoading = true; - if( knob( "loadAll" ) != NULL ) - { - validate( false ); - } - } - - return SourceGeo::knob_changed(k); - } - } - - return SourceGeo::knob_changed(k); -} - -void SceneCacheReader::loadAllFromKnobs() -{ - assert ( firstReader() == this ); - - if( !m_data->m_scriptFinishedLoading ) - { - return; - } - - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - - std::vector selectionIndices; - sceneView->getSelectedItems( selectionIndices ); - - std::vector filterIndices; - sceneView->getImportedItems( filterIndices ); - - std::vector oldItems = sceneView->menu(); - - rebuildSceneView(); - - // filter of the scene without worrying about selection - m_data->m_filterHash = Hash(); - filterScene( m_data->m_filterText, m_data->m_filterTagText, false ); - - const std::vector< std::string > &items = sceneView->menu(); - - // Try to remap the previous selection to the current items available. - std::vector newSelectionIndices; - for( std::vector::const_iterator it( selectionIndices.begin() ); it != selectionIndices.end(); ++it ) - { - int itemIndex( filterIndices[*it] ); - const std::string &itemName( oldItems[itemIndex] ); - - std::vector::const_iterator selectedIt( std::find( items.begin(), items.end(), itemName ) ); - if ( selectedIt == items.end() ) - { - warning( ( std::string( "WARNING: Could not load selected geometry \"" ) + itemName + std::string( "\" as it no longer exists in the scene cache." ) ).c_str() ); - continue; - } - - unsigned int index = (selectedIt - items.begin()); - - if ( index < m_data->m_itemToFiltered.size() ) - { - index = m_data->m_itemToFiltered[index]; - } - newSelectionIndices.push_back( index ); - } - - sceneView->setSelectedItems( newSelectionIndices ); - m_data->m_selectionHash = Hash(); -} - -void SceneCacheReader::clearSceneViewSelection() -{ - assert ( firstReader() == this ); - - if( m_sceneKnob != NULL ) - { - std::vector emptySelection; - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - sceneView->setSelectedItems( emptySelection ); - m_data->m_selectionHash = Hash(); - } -} - -Hash SceneCacheReader::sceneHash() const -{ - if ( firstReader() != this ) - { - return firstReader()->sceneHash(); - } - - Hash newHash; - newHash.append( m_data->m_evaluatedFilePath ); - newHash.append( m_data->m_rootText ); - newHash.append( outputContext().frame() ); - return newHash; -} - -Hash SceneCacheReader::selectionHash( bool force ) const -{ - if ( firstReader() != this ) - { - return firstReader()->selectionHash(force); - } - - if ( force || m_data->m_selectionHash == Hash() ) - { - Hash newHash; - - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - - std::vector indices; - sceneView->getImportedItems( indices ); - - newHash.append( (unsigned int)indices.size() ); - for( std::vector::const_iterator cit( indices.begin() ); cit != indices.end(); ++cit ) - { - newHash.append( *cit ); - } - - m_data->m_selectedItems.clear(); - sceneView->getSelectedItems( m_data->m_selectedItems ); - newHash.append( (unsigned int)m_data->m_selectedItems.size() ); - for( std::vector::const_iterator cit( m_data->m_selectedItems.begin() ); cit != m_data->m_selectedItems.end(); ++cit ) - { - newHash.append( *cit ); - } - - m_data->m_selectionHash = newHash; - } - return m_data->m_selectionHash; -} - -void SceneCacheReader::rebuildSceneView() -{ - assert ( firstReader() == this ); - - if( !m_data->m_scriptFinishedLoading ) - { - return; - } - - if( m_data->m_isFirstRun ) - { - validate( false ); - } - - Hash newSceneHash( sceneHash() ); - - // Check to see if the scene has changed. If it has then we need to - // rebuild our internal representation of it. - if( m_data->m_sceneHash != newSceneHash ) - { - // Set the new hash. - m_data->m_sceneHash = newSceneHash; - - IECoreScene::ConstSceneInterfacePtr sceneInterface = getSceneInterface(); - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - - // If we have a selection, clear it! - if( m_data->m_selectedItems.size() != 0 ) - { - clearSceneViewSelection(); - } - - // Reset our internal data structures. - m_data->m_tagMap.clear(); - - // Clear the SceneView_knob. - std::vector sceneItems; - sceneView->menu( sceneItems ); - - if( sceneInterface && sceneView ) - { - // Rebuild our list of items which we will use to populate the SceneView_knob. - buildSceneView( sceneItems, m_data->m_tagMap, sceneInterface, m_data->m_pathPrefixLength ); - } - - updateTagFilterKnob(); - - m_data->m_selectionHash = Hash(); - - if( !sceneItems.empty() ) - { - // Reset the list of selected entries and populate the SceneView_knob. - sceneView->addItems( sceneItems ); - } - } -} - -void SceneCacheReader::build_handles(ViewerContext* ctx) -{ - // Call build_matrix_handle to multiply the context model matrix with the parent base matrix so the - // items above it will display correctly. - build_matrix_handles(ctx, m_baseParentMatrix); -} - -const std::string &SceneCacheReader::itemName( int index ) const -{ - assert ( firstReader() == this ); - - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - const std::vector &items( sceneView->menu() ); - return items[index]; -} - -// The purpose of the filterScene method is to both filter out unwanted items from the SceneView_knob -// and create a mapping between the indices of the resulting items and their position in the full -// list of items in the scene. We do this because when we query the SceneView_knob for the selected -// items, we are returned a list of indices within the filtered items. Therefore, to get the -// names of these items we need to use a LUT of filtered indices to indices within the list of names. -// These LUTs are the m_itemToFiltered and m_filteredToItem maps. -void SceneCacheReader::filterScene( const std::string &filterText, const std::string &filterTag, bool keepSelection ) -{ - assert ( firstReader() == this ); - - if( !m_data->m_scriptFinishedLoading ) - { - return; - } - - if( m_data->m_isFirstRun ) - { - validate( false ); - } - - Hash newFilterHash( sceneHash() ); - newFilterHash.append( m_data->m_evaluatedFilePath ); - newFilterHash.append( m_data->m_rootText ); - newFilterHash.append( filterText ); - newFilterHash.append( filterTag ); - - if( m_data->m_filterHash == newFilterHash ) - { - return; - } - m_data->m_filterHash = newFilterHash; - - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - - // Get the item indices of the currently selected items so that - // we can add them to the newly filtered scene. - std::vector newSelection; - - if ( keepSelection ) - { - sceneView->getSelectedItems( newSelection ); // Set the vector to the indices of the filtered items. - for( std::vector::iterator it( newSelection.begin() ); it != newSelection.end(); ++it ) - { - if ( *it < m_data->m_filteredToItem.size() ) - { - *it = m_data->m_filteredToItem[*it]; // Convert the filter index to a item index. - } - } - } - - // Reset our LUTs as we are going to rebuild them. - m_data->m_itemToFiltered.clear(); - m_data->m_filteredToItem.clear(); - - // Are we also filtering by tag? - bool filterByTag = false; - if( filterTag != "" && filterTag != "None" ) - { - filterByTag = true; - } - - // Remove duplicate slashes in the expression. - std::string expr = filterText; - expr.erase( std::unique( expr.begin(), expr.end(), bothSlashes ), expr.end()); - - std::vector filteredIndices; - - const std::vector &sceneItems = sceneView->menu(); - - if( expr != "/" && expr != "*" && expr != "" ) - { - // Get the filter text that we will use to filter the scene. - try - { - // Loop over all of the items in the scene and create a unique list of all entries whose name matches our regular expression. - boost::regex expression( expr ); - - if( filterByTag ) // Filter by tag and expression - { - for( std::vector::const_iterator it = m_data->m_tagMap[filterTag].begin(); it != m_data->m_tagMap[filterTag].end(); ++it ) - { - const std::string &itemName( sceneItems[*it] ); - boost::sregex_token_iterator iter( itemName.begin(), itemName.end(), expression, 0 ); - boost::sregex_token_iterator end; - if( iter != end ) - { - // Append the index to our vector of filtered items. - filteredIndices.push_back( *it ); - } - } - } - else // Only filter by expression. - { - for( std::vector::const_iterator it = sceneItems.begin(); it != sceneItems.end(); ++it ) - { - boost::sregex_token_iterator iter( it->begin(), it->end(), expression, 0 ); - boost::sregex_token_iterator end; - if( iter != end ) - { - // Append the index to our vector of filtered items. - filteredIndices.push_back( it-sceneItems.begin() ); - } - } - } - } - catch(...) - { - } - } - else - { - filteredIndices.clear(); - if( !sceneItems.empty() ) - { - if( filterByTag ) - { - // Just filter the items with the chosen the tag. - const std::vector &tagIndices( m_data->m_tagMap[filterTag] ); - if( !tagIndices.empty() ) - { - filteredIndices.reserve( tagIndices.size() ); - for( std::vector::const_iterator it( tagIndices.begin() ); it != tagIndices.end(); ++it ) - { - filteredIndices.push_back( *it ); - } - } - } - else - { - // Don't filter any of the results. - filteredIndices.reserve( sceneItems.size() ); - for( std::vector::const_iterator it( sceneItems.begin() ); it != sceneItems.end(); ++it ) - { - int index = it - sceneItems.begin(); - filteredIndices.push_back( index ); - } - } - } - } - - // Add the old selection to the filtered results. - if( !newSelection.empty() ) - { - for( std::vector::const_iterator it( newSelection.begin() ); it != newSelection.end(); ++it ) - { - if ( *it <= sceneItems.size() ) - { - filteredIndices.push_back( *it ); - } - } - - // Make sure all indices in our selection are unique and sorted. - std::set selectionSet( filteredIndices.begin(), filteredIndices.end() ); - filteredIndices.clear(); - std::copy( selectionSet.begin(), selectionSet.end(), std::back_inserter(filteredIndices) ); - sort( filteredIndices.begin(), filteredIndices.end() ); - } - - m_data->m_filteredToItem = filteredIndices; - - // Restore the old selection. - m_data->m_itemToFiltered.clear(); - - // Set the filtered items. - std::vector currentIndices; - sceneView->getImportedItems( currentIndices ); - if( currentIndices != filteredIndices ) - { - sceneView->setImportedItems( filteredIndices ); - } - - // Create a mapping of item indices to filtered indices. - for( std::vector::const_iterator it( filteredIndices.begin() ); it != filteredIndices.end(); ++it ) - { - m_data->m_itemToFiltered[ *it ] = it - filteredIndices.begin(); - } - - // we invalidate the selection hash to force recomputation since importted items changed. - m_data->m_selectionHash = Hash(); -} - -void SceneCacheReader::tagSelection( std::string &selection ) const -{ - assert ( firstReader() == this ); - - Enumeration_KnobI *listView( m_tagFilterKnob->enumerationKnob() ); - const std::vector ¤tTagList( listView->menu() ); - unsigned int tagIndex = static_cast( m_tagFilterKnob->get_value() ); - if( tagIndex < currentTagList.size() ) - { - selection = currentTagList[tagIndex]; - return; - } - selection = ""; -} - -void SceneCacheReader::updateTagFilterKnob() -{ - assert ( firstReader() == this ); - - if( m_tagFilterKnob ) - { - std::vector tagNames; - tagNames.push_back( "None" ); - - for( TagMap::const_iterator it = m_data->m_tagMap.begin(); it != m_data->m_tagMap.end(); ++it ) - { - tagNames.push_back( it->first ); - } - - Enumeration_KnobI *listView( m_tagFilterKnob->enumerationKnob() ); - listView->menu( tagNames ); - - std::string currentTagSelection; - tagSelection( currentTagSelection ); - if ( std::find( tagNames.begin(), tagNames.end(), currentTagSelection ) == tagNames.end() ) - { - m_tagFilterKnob->set_value( 0 ); - } - } -} - -/// This recursive method traverses the sceneInterface to build a list of item names and a mapping of the tags to the indices in the items. -static void buildSceneView( std::vector< std::string > &list, TagMap &tagMap, const IECoreScene::ConstSceneInterfacePtr sceneInterface, int rootPrefixLen ) -{ - if( sceneInterface ) - { - if( sceneInterface->hasObject() ) - { - IECoreScene::SceneInterface::NameList tagNames; - sceneInterface->readTags( tagNames, IECoreScene::SceneInterface::LocalTag ); - for ( IECoreScene::SceneInterface::NameList::const_iterator it = tagNames.begin(); it != tagNames.end(); ++it ) - { - tagMap[*it].push_back( list.size() ); - } - - IECoreScene::SceneInterface::Path path; - sceneInterface->path( path ); - std::string pathStr; - IECoreScene::SceneInterface::pathToString( path, pathStr ); - - // The SceneView_knob requires that all entries belong to the same root item. - // This is an issue as the SceneCache can have multiple entries at root level. - // To resolve this issue we append "/root" to the item name when viewing the - // tree at root level. - if( rootPrefixLen == 0 ) // This means m_data->m_rootText == "/" - { - pathStr = std::string("/root") + pathStr; - } - else - { - pathStr = pathStr.substr( rootPrefixLen ); - } - list.push_back( pathStr ); - } - - IECoreScene::SceneInterface::NameList childNames; - sceneInterface->childNames( childNames ); - sort( childNames.begin(), childNames.end(), compareNoCase ); - - for ( IECoreScene::SceneInterface::NameList::const_iterator it = childNames.begin(); it != childNames.end(); ++it ) - { - IECoreScene::SceneInterface::Name name = *it; - const IECoreScene::ConstSceneInterfacePtr childScene = sceneInterface->child( name ); - buildSceneView( list, tagMap, childScene, rootPrefixLen ); - } - } -} - -void SceneCacheReader::append( DD::Image::Hash &hash ) -{ - SourceGeo::append( hash ); - - hash.append( sceneHash() ); - hash.append( selectionHash(true) ); - hash.append( m_worldSpace ); - hash.append( m_visibilityFilter ); - hash.append( outputContext().frame() ); -} - -void SceneCacheReader::get_geometry_hash() -{ - SourceGeo::get_geometry_hash(); - geo_hash[Group_Primitives].append( sceneHash() ); - geo_hash[Group_Primitives].append( selectionHash() ); - geo_hash[Group_Primitives].append( m_worldSpace ); - geo_hash[Group_Primitives].append( m_visibilityFilter ); - - IECoreScene::ConstSceneCachePtr sceneInterface = IECore::runTimeCast< const IECoreScene::SceneCache >(getSceneInterface()); - bool isAnimated = false; - if( sceneInterface && sceneInterface -> numBoundSamples() > 1 ) - { - isAnimated = true; - geo_hash[Group_Primitives].append( outputContext().frame() ); - } - - static const int groups[] = { Group_Points, Group_Attributes, Group_Matrix, Group_None }; - for( const int *g = groups; *g!=Group_None; g++ ) - { - geo_hash[*g].append( sceneHash() ); - geo_hash[*g].append( selectionHash() ); - geo_hash[*g].append( m_worldSpace ); - geo_hash[*g].append( m_visibilityFilter ); - if( isAnimated ) - { - geo_hash[*g].append( outputContext().frame() ); - } - } - - geo_hash[Group_Matrix].append(m_baseParentMatrix.a00); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a01); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a02); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a03); - - geo_hash[Group_Matrix].append(m_baseParentMatrix.a10); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a11); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a12); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a13); - - geo_hash[Group_Matrix].append(m_baseParentMatrix.a20); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a21); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a22); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a23); - - geo_hash[Group_Matrix].append(m_baseParentMatrix.a30); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a31); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a32); - geo_hash[Group_Matrix].append(m_baseParentMatrix.a33); - -} - -// Apply the concatenated matrix to all the GeoInfos. -void SceneCacheReader::geometry_engine( DD::Image::Scene& scene, GeometryList& out) -{ - SourceGeo::geometry_engine(scene, out); - - for( unsigned i = 0; i < out.size(); i++ ) - { - out[i].matrix = m_baseParentMatrix * m_indexToWorldTransform[i]; - } -} - -void SceneCacheReader::create_geometry( DD::Image::Scene &scene, DD::Image::GeometryList &out ) -{ - SharedData *data = sharedData(); - - // Don't do any work if our hash hasn't changed. - // this is important not only for speed, but also because - // something in nuke assumes we won't change anything if - // rebuilding isn't needed - we get crashes if we rebuild - // when not necessary. - if( !rebuild( Mask_Attributes )) - { - return; - } - - if( !m_filePath || data->m_evaluatedFilePath == "" ) - { - // Get rid of the old stuff, and return. - out.delete_objects(); - return; - } - - try - { - if( rebuild( Mask_Primitives ) || rebuild( Mask_Matrix ) ) - { - out.delete_objects(); - - // Loop over the selected items in the SceneView_knob and add them to the geometry list. - SceneView_KnobI *sceneView( m_sceneKnob->sceneViewKnob() ); - const std::vector &items = sceneView->menu(); - - for( std::vector::const_iterator it( data->m_selectedItems.begin() ); it != data->m_selectedItems.end(); ++it ) - { - unsigned int index = *it; - if ( index < data->m_filteredToItem.size() ) - { - loadPrimitive( out, items[ data->m_filteredToItem[index] ] ); - } - } - } - - } - catch( const std::exception &e ) - { - error( e.what() ); - return; - } -} - -void SceneCacheReader::loadPrimitive( DD::Image::GeometryList &out, const std::string &path ) -{ - SharedData *data = sharedData(); - - std::string itemPath; - if( data->m_rootText == "/" ) - { - // Remove the "/root" prefix that was added to the path name. - itemPath = path.substr( 5 ); // "/root" is 5 characters long... - } - else - { - // Add the prefix that we removed when creating the entry. - itemPath = data->m_pathPrefix + path; - } - - IECoreScene::ConstSceneInterfacePtr sceneInterface( getSceneInterface( itemPath ) ); - if( sceneInterface ) - { - double time = outputContext().frame() / DD::Image::root_real_fps(); - if ( m_visibilityFilter ) - { - if ( sceneInterface->hasAttribute( IECoreScene::SceneInterface::visibilityName ) ) - { - IECore::ConstBoolDataPtr visibility = IECore::runTimeCast< const IECore::BoolData >( sceneInterface->readAttribute( IECoreScene::SceneInterface::visibilityName, time ) ); - if ( !visibility->readable() ) - { - return; - } - } - } - IECore::ConstObjectPtr object = sceneInterface->readObject( time ); - IECoreScene::SceneInterface::Path rootPath; - if( m_worldSpace ) - { - IECoreScene::SceneInterface::stringToPath( "/", rootPath ); - } - else - { - IECoreScene::SceneInterface::stringToPath( data->m_rootText, rootPath ); - } - - Imath::M44d transformd; - transformd = worldTransform( sceneInterface, rootPath, time ); - - IECoreNuke::ToNukeGeometryConverterPtr converter = IECoreNuke::ToNukeGeometryConverter::create( object ); - if (converter) - { - converter->parameters()->parameter( "path" )->setValue( new IECore::StringData( itemPath ) ); - converter->convert( out ); - // store the world matrix to apply in geometry_engine because - // somewhere after the create_geometry nuke reset the matrix in the SourceGeo base class. - m_indexToWorldTransform[out.objects()-1] = IECore::convert( transformd ); - } - } -} - -Imath::M44d SceneCacheReader::worldTransform( IECoreScene::ConstSceneInterfacePtr scene, IECoreScene::SceneInterface::Path root, double time ) -{ - IECoreScene::SceneInterface::Path p; - scene->path( p ); - - IECoreScene::ConstSceneInterfacePtr tmpScene = scene->scene( root ); - IECoreScene::SceneInterface::Path pRoot; - tmpScene->path( pRoot ); - Imath::M44d result; - - for ( IECoreScene::SceneInterface::Path::const_iterator it = p.begin()+pRoot.size(); tmpScene && it != p.end(); ++it ) - { - tmpScene = tmpScene->child( *it, IECoreScene::SceneInterface::NullIfMissing ); - if ( !tmpScene ) - { - break; - } - - result = tmpScene->readTransformAsMatrix( time ) * result; - } - - return result; -} - -IECoreScene::ConstSceneInterfacePtr SceneCacheReader::getSceneInterface( const string &path ) -{ - const SharedData *data = sharedData(); - IECoreScene::ConstSceneInterfacePtr scene(0); - try - { - scene = IECoreScene::SharedSceneInterfaces::get( data->m_evaluatedFilePath ); - } - catch( const std::exception &e ) - { - error( (std::string("Could not open file ") + data->m_evaluatedFilePath ).c_str() ); - return 0; - } - - try - { - IECoreScene::SceneInterface::Path itemPath; - IECoreScene::SceneInterface::stringToPath( path, itemPath ); - scene = scene->scene( itemPath ); - } - catch( const std::exception &e ) - { - error( (std::string("Could not find root \"" + path + "\" in ") + data->m_evaluatedFilePath ).c_str() ); - return 0; - } - - return scene; -} - -IECoreScene::ConstSceneInterfacePtr SceneCacheReader::getSceneInterface() -{ - return getSceneInterface( sharedData()->m_rootText ); -} - diff --git a/src/IECoreNuke/SceneCacheWriter.cpp b/src/IECoreNuke/SceneCacheWriter.cpp deleted file mode 100644 index c78616cc1f..0000000000 --- a/src/IECoreNuke/SceneCacheWriter.cpp +++ /dev/null @@ -1,114 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/SceneCacheWriter.h" - -using namespace IECore; -using namespace IECoreNuke; -using namespace IECoreScene; - -DD::Image::GeoWriter::Description SceneCacheWriter::description( "scc\0", SceneCacheWriter::Build ); - -DD::Image::GeoWriter* SceneCacheWriter::Build( DD::Image::WriteGeo* readNode ) -{ - return new SceneCacheWriter( readNode ); -} - -SceneCacheWriter::SceneCacheWriter( DD::Image::WriteGeo* writeNode ) : - DD::Image::GeoWriter( writeNode ) -{ -} - -void SceneCacheWriter::execute( DD::Image::Scene& scene ) -{ - open(); - if ( auto geoOp = dynamic_cast( geo ) ) - { - m_liveScene = new IECoreNuke::LiveScene( geoOp ); - } - - IECoreScene::SceneInterface::NameList names; - m_liveScene->childNames( names ); - for ( const auto& name : names ) - { - writeLocation( m_liveScene, m_writer, name ); - } -} - -bool SceneCacheWriter::animation() const -{ - return true; -} - -bool SceneCacheWriter::open() -{ - if ( !m_writer ) - { - m_writer = IECoreScene::SceneInterface::create( std::string( filename() ), IECore::IndexedIO::Write ); - } - - return true; -} - -void SceneCacheWriter::writeLocation( ConstSceneInterfacePtr inScene, SceneInterfacePtr outScene, const IECore::InternedString& childName ) -{ - auto time = LiveScene::frameToTime( frame() ); - ConstSceneInterfacePtr inChild = inScene->child( childName, SceneInterface::MissingBehaviour::ThrowIfMissing ); - auto outChild = outScene->child( childName, IECoreScene::SceneInterface::MissingBehaviour::CreateIfMissing ); - try - { - outChild->writeTransform( inChild->readTransform( time ).get(), time ); - } - catch ( ... ) - { - } - if ( inChild->hasObject() ) - { - try - { - outChild->writeObject( inChild->readObject( time ).get(), time ); - } - catch ( ... ) - { - } - } - - // recursion - SceneInterface::NameList grandChildNames; - inChild->childNames( grandChildNames ); - for ( auto& grandChildName : grandChildNames ) - { - writeLocation( inChild, outChild, grandChildName ); - } -} diff --git a/src/IECoreNuke/StringParameterHandler.cpp b/src/IECoreNuke/StringParameterHandler.cpp deleted file mode 100644 index 572525c7a0..0000000000 --- a/src/IECoreNuke/StringParameterHandler.cpp +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/StringParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -ParameterHandler::Description StringParameterHandler::g_description( StringParameter::staticTypeId() ); - -StringParameterHandler::StringParameterHandler() - : m_storage( 0 ), m_knob( 0 ) -{ -} - -void StringParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - if( f.makeKnobs() ) - { - m_storage = static_cast( parameter )->typedDefaultValue().c_str(); - } - - m_knob = knob( parameter, knobName, f, &m_storage ); - /// we have a lot of procedurals which do their own variable expansion using a SubstitutedDict, - /// and the variables in the strings confuse nuke no end, so we're disabling expressions for now. - /// \todo Can we do better and allow the two to coexist? - SetFlags( f, DD::Image::Knob::NO_ANIMATION ); - setKnobProperties( parameter, f, m_knob ); -} - -void StringParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource ) -{ - StringParameter *stringParameter = static_cast( parameter ); - if( valueSource==Storage ) - { - stringParameter->setTypedValue( m_storage ); - } - else - { - std::ostringstream s; - m_knob->to_script( s, 0, false ); - stringParameter->setTypedValue( s.str() ); - } -} - -void StringParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - const StringParameter *stringParameter = static_cast( parameter ); - m_knob->set_text( stringParameter->getTypedValue().c_str() ); -} - -DD::Image::Knob *StringParameterHandler::knob( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f, const char **storage ) -{ - std::string label = knobLabel( parameter ); - return String_knob( f, storage, knobName, label.c_str() ); -} diff --git a/src/IECoreNuke/ToNukeConverter.cpp b/src/IECoreNuke/ToNukeConverter.cpp deleted file mode 100644 index a68f923d29..0000000000 --- a/src/IECoreNuke/ToNukeConverter.cpp +++ /dev/null @@ -1,50 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ToNukeConverter.h" - -#include "IECore/Object.h" - -using namespace IECoreNuke; - -IE_CORE_DEFINERUNTIMETYPED( ToNukeConverter ); - -ToNukeConverter::ToNukeConverter( const std::string &description, IECore::TypeId supportedType ) - : IECore::FromCoreConverter( description, supportedType ) -{ -} - -ToNukeConverter::~ToNukeConverter() -{ -} diff --git a/src/IECoreNuke/ToNukeGeometryConverter.cpp b/src/IECoreNuke/ToNukeGeometryConverter.cpp deleted file mode 100644 index fc5d3ac415..0000000000 --- a/src/IECoreNuke/ToNukeGeometryConverter.cpp +++ /dev/null @@ -1,118 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/ToNukeGeometryConverter.h" -#include "IECoreNuke/LiveScene.h" - -#include "IECore/CompoundData.h" -#include "IECore/CompoundParameter.h" - -#include - -using namespace IECoreNuke; -using namespace IECore; -using namespace DD::Image; - -IE_CORE_DEFINERUNTIMETYPED( ToNukeGeometryConverter ); - -ToNukeGeometryConverter::ToNukeGeometryConverter( const std::string &description, IECore::TypeId fromType, ConstObjectPtr object ) - : ToNukeConverter( description, fromType ) -{ - srcParameter()->setValue( boost::const_pointer_cast( object ) ); - - m_objIndexParameter = new IntParameter( "objIndex", "Index for the first object inserted on the GeometryList. Use -1 to simply add on the next index available", -1 ); - parameters()->addParameter( m_objIndexParameter ); - - m_pathParameter = new StringParameter( "path", "The object path in the hierarchy.", new StringData() ); - parameters()->addParameter( m_pathParameter ); - -} - -void ToNukeGeometryConverter::convert( GeometryList &geoList ) const -{ - int objIndex = m_objIndexParameter->getNumericValue(); - if ( objIndex == -1 ) - { - objIndex = (int)geoList.objects(); - } - geoList.add_object(objIndex); - - // add path attribute - auto nameAttribute = geoList.writable_attribute( objIndex, GroupType::Group_Object, IECoreNuke::LiveScene::nameAttribute.data(), AttribType::STD_STRING_ATTRIB); - nameAttribute->stdstring() = m_pathParameter->getTypedValue(); - - ConstCompoundObjectPtr operands = parameters()->getTypedValidatedValue(); - doConversion( srcParameter()->getValidatedValue(), geoList, objIndex, operands.get() ); -} - -///////////////////////////////////////////////////////////////////////////////// -// Factory -///////////////////////////////////////////////////////////////////////////////// - -ToNukeGeometryConverterPtr ToNukeGeometryConverter::create( ConstObjectPtr object ) -{ - const TypesToFnsMap *m = typesToFns(); - TypesToFnsMap::const_iterator it = m->find( Types( object->typeId() ) ); - if( it!=m->end() ) - { - return it->second( object ); - } - return 0; -} - -void ToNukeGeometryConverter::registerConverter( IECore::TypeId fromType, CreatorFn creator ) -{ - TypesToFnsMap *m = typesToFns(); - m->insert( TypesToFnsMap::value_type( Types( fromType ), creator ) ); -} - -ToNukeGeometryConverter::TypesToFnsMap *ToNukeGeometryConverter::typesToFns() -{ - static TypesToFnsMap *m = new TypesToFnsMap; - return m; -} - -///////////////////////////////////////////////////////////////////////////////// -// Implementation of nested Types class -///////////////////////////////////////////////////////////////////////////////// - -ToNukeGeometryConverter::Types::Types( IECore::TypeId from ) - : fromType( from ) -{ -} - -bool ToNukeGeometryConverter::Types::operator < ( const Types &other ) const -{ - return fromType < other.fromType; -} diff --git a/src/IECoreNuke/VecParameterHandler.cpp b/src/IECoreNuke/VecParameterHandler.cpp deleted file mode 100644 index 2d516a5adf..0000000000 --- a/src/IECoreNuke/VecParameterHandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/VecParameterHandler.h" - -#include "IECore/SimpleTypedParameter.h" - -#include "DDImage/Knobs.h" - -using namespace IECore; -using namespace IECoreNuke; - -template -ParameterHandler::Description > VecParameterHandler::g_description( T::staticTypeId() ); - -template -VecParameterHandler::VecParameterHandler() -{ -} - -template -void VecParameterHandler::knobs( const IECore::Parameter *parameter, const char *knobName, DD::Image::Knob_Callback f ) -{ - const T *vecParameter = static_cast( parameter ); - - if( f.makeKnobs() ) - { - typename T::ValueType defaultValue = vecParameter->typedDefaultValue(); - for( unsigned i=0; i -void VecParameterHandler::setParameterValue( Parameter *parameter, ValueSource valueSource ) -{ - typename T::ValueType value; - if( valueSource==Storage ) - { - for( unsigned i=0; iget_value( i ); - } - } - static_cast( parameter )->setTypedValue( value ); -} - -template -void VecParameterHandler::setKnobValue( const IECore::Parameter *parameter ) -{ - typename T::ValueType value = static_cast( parameter )->getTypedValue(); - for( unsigned i=0; iset_value( value[i], i ); - } -} - -// explicit instantiation - -template class VecParameterHandler; -template class VecParameterHandler; -template class VecParameterHandler; -template class VecParameterHandler; diff --git a/src/IECoreNuke/Warp.cpp b/src/IECoreNuke/Warp.cpp deleted file mode 100644 index 9fd2df0899..0000000000 --- a/src/IECoreNuke/Warp.cpp +++ /dev/null @@ -1,112 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreNuke/Warp.h" - -#include "DDImage/ARRAY.h" -#include "DDImage/Knobs.h" -#include "DDImage/Pixel.h" -#include "DDImage/Row.h" -#include "DDImage/Tile.h" - -using namespace IECoreNuke; -using namespace DD::Image; -using namespace Imath; - -Warp::Warp( Node *node ) - : Iop( node ), m_channels( Mask_RGBA ) -{ -} - -Warp::~Warp() -{ -} - -void Warp::knobs( DD::Image::Knob_Callback f ) -{ - Iop::knobs( f ); - ChannelSet_knob( f, &m_channels, "channels", "Channels" ); - Tooltip( f, "The channels to apply the warp to - other channels are passed through unchanged." ); -} - -void Warp::_validate( bool forReal ) -{ - set_out_channels( m_channels ); - Iop::_validate( forReal ); -} - -void Warp::_request( int x, int y, int r, int t, const DD::Image::ChannelSet &channels, int count ) -{ - // request the whole damn thing - we've no idea what the warp will do. - input( 0 )->request( channels, count ); -} - -void Warp::engine( int y, int x, int r, const DD::Image::ChannelSet &channels, DD::Image::Row &out ) -{ - // get the data for anything we don't plan on warping into the output row - ChannelSet unchangingChannels = channels; unchangingChannels -= out_channels(); - input( 0 )->get( y, x, r, unchangingChannels, out ); - if( Op::aborted() ) - { - return; - } - - // now write into the warp channels - /////////////////////////////////// - - // storing an array of pointers to the writable data seems marginally faster - // than calling Row::writable() in the inner loop. - ChannelSet changingChannels = out_channels(); changingChannels &= channels; - ARRAY( float *, writableChannels, (changingChannels.last() + 1) ); - for( Channel c=changingChannels.first(); c; c=changingChannels.next( c ) ) - { - writableChannels[c] = out.writable( c ); - } - - int xEnd = x + (r - x); - Pixel pixel( changingChannels ); - for( ; x() - .def( init<>() ) - ; -} diff --git a/src/IECoreNuke/bindings/LiveSceneKnobBinding.cpp b/src/IECoreNuke/bindings/LiveSceneKnobBinding.cpp deleted file mode 100644 index 80ed648a65..0000000000 --- a/src/IECoreNuke/bindings/LiveSceneKnobBinding.cpp +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/LiveSceneKnob.h" - -#include "IECorePython/RefCountedBinding.h" - -#include "IECore/Exception.h" - -using namespace boost::python; - -namespace IECoreNuke -{ - -// always check your knob before using it -static void check( Detail::PythonLiveSceneKnob &knob ) -{ - if( !knob.sceneKnob ) - { - throw( IECore::InvalidArgumentException( "Knob not alive." ) ); - } -} - -static const char *name( Detail::PythonLiveSceneKnob &knob ) -{ - check( knob ); - return knob.sceneKnob->name().c_str(); -} - -static const char *label( Detail::PythonLiveSceneKnob &knob ) -{ - check( knob ); - return knob.sceneKnob->label().c_str(); -} - -static IECoreNuke::LiveScenePtr getValue( Detail::PythonLiveSceneKnob &knob ) -{ - check( knob ); - IECoreNuke::LiveScenePtr v = knob.sceneKnob->getValue(); - return v; -} - -void bindLiveSceneKnob() -{ - - IECorePython::RefCountedClass( "LiveSceneKnob" ) - .def( "name", &name ) - .def( "label", &label ) - .def( "getValue", &getValue ) - ; - -} - -} // namespace IECoreNuke diff --git a/src/IECoreNuke/bindings/ObjectKnobBinding.cpp b/src/IECoreNuke/bindings/ObjectKnobBinding.cpp deleted file mode 100644 index b596a03a25..0000000000 --- a/src/IECoreNuke/bindings/ObjectKnobBinding.cpp +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECoreNuke/ObjectKnob.h" - -#include "IECorePython/RefCountedBinding.h" - -#include "IECore/Exception.h" - -using namespace boost::python; - -namespace IECoreNuke -{ - -// always check your knob before using it -static void check( Detail::PythonObjectKnob &knob ) -{ - if( !knob.objectKnob ) - { - throw( IECore::InvalidArgumentException( "Knob not alive." ) ); - } -} - -static const char *name( Detail::PythonObjectKnob &knob ) -{ - check( knob ); - return knob.objectKnob->name().c_str(); -} - -static const char *label( Detail::PythonObjectKnob &knob ) -{ - check( knob ); - return knob.objectKnob->label().c_str(); -} - -static bool setValue( Detail::PythonObjectKnob &knob, IECore::ObjectPtr value ) -{ - check( knob ); - return knob.objectKnob->setValue( value ); -} - -static IECore::ObjectPtr getValue( Detail::PythonObjectKnob &knob ) -{ - check( knob ); - IECore::ConstObjectPtr v = knob.objectKnob->getValue(); - return v ? v->copy() : 0; -} - -void bindObjectKnob() -{ - - IECorePython::RefCountedClass( "ObjectKnob" ) - .def( "name", &name ) - .def( "label", &label ) - .def( "setValue", &setValue ) - .def( "getValue", &getValue ) - ; - -} - -} // namespace IECoreNuke diff --git a/src/IECoreNuke/plugin/Plugin.cpp b/src/IECoreNuke/plugin/Plugin.cpp deleted file mode 100644 index 41a0e40746..0000000000 --- a/src/IECoreNuke/plugin/Plugin.cpp +++ /dev/null @@ -1,37 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// Strangely we actually don't need any code in the plugin, because all -// the registration of nodes is done by the IECoreNuke library. We simply -// need to link against it. diff --git a/src/IECoreNuke/plugin/ieProcedural.tcl b/src/IECoreNuke/plugin/ieProcedural.tcl deleted file mode 100644 index bcd31a09ac..0000000000 --- a/src/IECoreNuke/plugin/ieProcedural.tcl +++ /dev/null @@ -1,35 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -load ieCore diff --git a/src/IECoreNuke/plugin/menu.py b/src/IECoreNuke/plugin/menu.py deleted file mode 100644 index 2233b8cbb3..0000000000 --- a/src/IECoreNuke/plugin/menu.py +++ /dev/null @@ -1,57 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011-2013, Image Engine Design Inc. All rights reserved. -# Copyright (c) 2012, John Haddon. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -## \addtogroup environmentGroup -# -# IECORENUKE_DISABLE_MENU -# Set this to a value of 1 to disable the creation of the Cortex menu -# in Nuke. You can then use the helper functions in IECoreNuke.Menus -# to build your own site-specific menu structure. - -import os - -if os.environ.get( "IECORENUKE_DISABLE_MENU", "0" ) != "1" : - - import IECore - import IECoreNuke - import nuke - - nodesMenu = nuke.menu( "Nodes" ) - cortexMenu = nodesMenu.addMenu( "Cortex", icon="CortexMenu.png" ) - - cortexMenu.addCommand( "Display", "nuke.createNode( 'ieDisplay' )" ) - cortexMenu.addCommand( "LiveScene", "nuke.createNode( 'ieLiveScene' )" ) - cortexMenu.addCommand( "LensDistort", "nuke.createNode( 'ieLensDistort' )" ) - cortexMenu.addCommand( "SceneCacheReader", "nuke.createNode( 'ieSceneCacheReader' )" ) diff --git a/test/IECore/ClassLoader.py b/test/IECore/ClassLoader.py index 0f82fba35e..8287be416a 100644 --- a/test/IECore/ClassLoader.py +++ b/test/IECore/ClassLoader.py @@ -42,7 +42,7 @@ def test( self ) : l = IECore.ClassLoader( IECore.SearchPath( os.path.join( "test", "IECore", "ops" ) ) ) - self.assertEqual( l.classNames(), ["bad", "classParameterTest", "classVectorParameterTest", "colorSplineInput", "compoundObjectInOut", "floatParameter", os.path.join( "maths", "multiply" ), "matrixParameter", "mayaUserData", "meshMerge", "objectVectorInOut", "parameterTypes", os.path.join( "path.With.Dot", "multiply" ), "presetParsing", "splineInput", 'stringParsing', "unstorable" ] ) + self.assertEqual( l.classNames(), ["bad", "classParameterTest", "classVectorParameterTest", "colorSplineInput", "compoundObjectInOut", "floatParameter", os.path.join( "maths", "multiply" ), "matrixParameter", "meshMerge", "objectVectorInOut", "parameterTypes", os.path.join( "path.With.Dot", "multiply" ), "presetParsing", "splineInput", 'stringParsing', "unstorable" ] ) self.assertEqual( l.classNames( "p*" ), ["parameterTypes", os.path.join( "path.With.Dot", "multiply" ), "presetParsing"] ) self.assertEqual( l.getDefaultVersion( os.path.join( "maths", "multiply" ) ), 2 ) self.assertEqual( l.getDefaultVersion( "presetParsing" ), 1 ) @@ -57,7 +57,7 @@ def test( self ) : def testFinalSlash( self ) : l = IECore.ClassLoader( IECore.SearchPath( os.path.join( "test", "IECore", "ops" ) + os.path.sep ) ) - self.assertEqual( l.classNames(), ["bad", "classParameterTest", "classVectorParameterTest", "colorSplineInput", "compoundObjectInOut", "floatParameter", os.path.join( "maths", "multiply" ), "matrixParameter", "mayaUserData", "meshMerge", "objectVectorInOut", "parameterTypes", os.path.join( "path.With.Dot", "multiply" ), "presetParsing", "splineInput", 'stringParsing', "unstorable" ] ) + self.assertEqual( l.classNames(), ["bad", "classParameterTest", "classVectorParameterTest", "colorSplineInput", "compoundObjectInOut", "floatParameter", os.path.join( "maths", "multiply" ), "matrixParameter", "meshMerge", "objectVectorInOut", "parameterTypes", os.path.join( "path.With.Dot", "multiply" ), "presetParsing", "splineInput", 'stringParsing', "unstorable" ] ) def testStaticLoaders( self ) : diff --git a/test/IECore/ops/mayaUserData/mayaUserData-1.py b/test/IECore/ops/mayaUserData/mayaUserData-1.py deleted file mode 100644 index 534c1bff11..0000000000 --- a/test/IECore/ops/mayaUserData/mayaUserData-1.py +++ /dev/null @@ -1,92 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore - -class mayaUserData( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "An Op to test the IECoreMaya::ParameterHandler support for userData.", - IECore.IntParameter( - name = "result", - description = "d", - defaultValue = 2, - ) - ) - - self.parameters().addParameters( - - [ - IECore.IntParameter( - "t", - "", - 100, - userData = { - "maya" : { - "defaultConnection" : IECore.StringData( "time1.outTime" ), - } - } - ), - - IECore.IntParameter( - "e", - "", - 100, - userData = { - "maya" : { - "defaultExpression" : IECore.StringData( " = time1.outTime * 10" ), - } - } - ), - - IECore.StringParameter( - "s", - "", - "", - userData = { - "maya" : { - "valueProvider" : IECore.StringData( "connectedNodeName" ), - } - } - ), - ] - ) - - def doOperation( self, args ) : - - return IECore.IntData( 2 ) - -IECore.registerRunTimeTyped( mayaUserData ) diff --git a/test/IECoreHoudini/ActiveTake.py b/test/IECoreHoudini/ActiveTake.py deleted file mode 100644 index 5623ba56eb..0000000000 --- a/test/IECoreHoudini/ActiveTake.py +++ /dev/null @@ -1,107 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import hou -import IECoreHoudini -import unittest - -class TestActiveTake( IECoreHoudini.TestCase ) : - - # testing a take can be set with the context - def testSetTake( self ) : - - take = "take1" - hou.hscript( "takeadd %s" % take ) - - self.assertTrue( take in IECoreHoudini.ActiveTake.ls() ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - with IECoreHoudini.ActiveTake( take ) : - - self.assertEqual( take, IECoreHoudini.ActiveTake.name() ) - - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - # testing the current take can still be used - def testSetCurrentTake( self ) : - - take = IECoreHoudini.ActiveTake.name() - - self.assertTrue( take in IECoreHoudini.ActiveTake.ls() ) - self.assertEqual( take, IECoreHoudini.ActiveTake.name() ) - - with IECoreHoudini.ActiveTake( take ) : - - self.assertEqual( take, IECoreHoudini.ActiveTake.name() ) - - self.assertEqual( take, IECoreHoudini.ActiveTake.name() ) - - # testing a non-existant take won't break anything - def testFakeTake( self ) : - - take = "fake" - origTake = IECoreHoudini.ActiveTake.name() - - self.assertTrue( take not in IECoreHoudini.ActiveTake.ls() ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - with IECoreHoudini.ActiveTake( take ) : - - self.assertEqual( origTake, IECoreHoudini.ActiveTake.name() ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - self.assertEqual( origTake, IECoreHoudini.ActiveTake.name() ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - # testing deleting a take in the context - def testDeleteTake( self ) : - - take = "take1" - hou.hscript( "takeadd %s" % take ) - - self.assertTrue( take in IECoreHoudini.ActiveTake.ls() ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - with IECoreHoudini.ActiveTake( take ) : - - self.assertEqual( take, IECoreHoudini.ActiveTake.name() ) - hou.hscript( "takerm %s" % take ) - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - - self.assertNotEqual( take, IECoreHoudini.ActiveTake.name() ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/All.py b/test/IECoreHoudini/All.py deleted file mode 100644 index 8fda39bbcd..0000000000 --- a/test/IECoreHoudini/All.py +++ /dev/null @@ -1,72 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import sys -import unittest -import IECore -import IECoreHoudini -import hou - -from OpHolder import * -from ActiveTake import * -from NodeHandle import * -from FromHoudiniPointsConverter import * -from FromHoudiniPolygonsConverter import * -from ToHoudiniPointsConverter import * -from ToHoudiniPolygonsConverter import * -from CortexConverterSop import * -from FromHoudiniCurvesConverter import * -from ToHoudiniCurvesConverter import * -from CobIOTranslator import * -from TemporaryParameterValuesTest import * -from UpdateMode import * -from SceneCacheTest import * -from LiveSceneTest import * -from ToHoudiniCortexObjectConverter import * -from ToHoudiniCompoundObjectConverter import * - -IECoreHoudini.TestProgram( - testRunner = unittest.TextTestRunner( - stream = IECore.CompoundStream( - [ - sys.stderr, - open( "test/IECoreHoudini/resultsPython.txt", "w" ) - ] - ), - verbosity = 2 - ) -) diff --git a/test/IECoreHoudini/CobIOTranslator.py b/test/IECoreHoudini/CobIOTranslator.py deleted file mode 100644 index 8dcc5ce5a8..0000000000 --- a/test/IECoreHoudini/CobIOTranslator.py +++ /dev/null @@ -1,210 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os -import shutil - -class TestCobIOTranslator( IECoreHoudini.TestCase ) : - - __testDir = "test/cobIO" - __testFile = "%s/testCobIO.cob" % __testDir - __testPDCFile = "%s/testPdcIO.pdc" % __testDir - __testPTCFile = "%s/testPtcIO.ptc" % __testDir - - def torus( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - torus = geo.createNode( "torus" ) - facet = torus.createOutputNode( "facet" ) - facet.parm( "postnml" ).set( True ) - mountain = facet.createOutputNode( "mountain" ) - if hou.applicationVersion()[0] >= 16: - mountain.parm("offsetx").setExpression("$FF") - else: - mountain.parm("offset1").setExpression( "$FF" ) - - return mountain - - def points( self, inNode=None ) : - if not inNode : - inNode = self.torus() - - return inNode.createOutputNode( "scatter" ) - - def curves( self, inNode=None ) : - points = self.points( inNode ) - add = points.createOutputNode( "add" ) - add.parm( "stdswitcher1" ).set( 1 ) - add.parm( "switcher1" ).set( 1 ) - convert = add.createOutputNode( "convert" ) - convert.parm( "totype" ).set( 4 ) - - return convert - - def reader( self ) : - geo = hou.node( "/obj/geo1" ) - if not geo : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - - reader = geo.createNode( "file" ) - reader.parm( "file" ).set( TestCobIOTranslator.__testFile ) - reader.parm( "filemode" ).set( 1 ) - - return reader - - def writer( self, inNode ) : - writer = inNode.createOutputNode( "file" ) - writer.parm( "file" ).set( TestCobIOTranslator.__testFile ) - writer.parm( "filemode" ).set( 2 ) - - return writer - - def testReadWritePoints( self ) : - points = self.points() - writer = self.writer( points ) - reader = self.reader() - - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - writer.cook() - self.assertTrue( reader.geometry() ) - self.assertTrue( not reader.errors() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECore.TypeId( IECoreScene.TypeId.PointsPrimitive ) ) ) - - def testReadWriteMesh( self ) : - mesh = self.torus() - writer = self.writer( mesh ) - reader = self.reader() - - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - writer.cook() - self.assertTrue( reader.geometry() ) - self.assertTrue( not reader.errors() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECore.TypeId( IECoreScene.TypeId.MeshPrimitive ) ) ) - - def testReadWriteCurves( self ) : - curves = self.curves() - writer = self.writer( curves ) - reader = self.reader() - - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - writer.cook() - self.assertTrue( reader.geometry() ) - self.assertTrue( not reader.errors() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECore.TypeId( IECoreScene.TypeId.CurvesPrimitive ) ) ) - - def testCantReadBadCob( self ) : - writer = self.writer( self.torus() ) - reader = self.reader() - - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - writer.cook() - self.assertTrue( reader.geometry() ) - self.assertTrue( not reader.errors() ) - - with open( "testCobIO.cob", "w" ) as f : - f.write( "this is not a real cob" ) - - reader.parm( "file" ).set( "testCobIO.cob" ) - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - - os.remove( "testCobIO.cob" ) - - def testCobWithNonPrimitiveData( self ) : - IECore.ObjectWriter( imath.V3f( 1 ), TestCobIOTranslator.__testFile ).write() - reader = self.reader() - geo = reader.geometry() - prims = geo.prims() - self.assertFalse( reader.errors() ) - self.assertEqual( len(prims), 1 ) - self.assertEqual( prims[0].type(), hou.primType.Custom ) - self.assertEqual( prims[0].vertices()[0].point().number(), 0 ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) - self.assertTrue( isinstance( converter, IECoreHoudini.FromHoudiniCortexObjectConverter ) ) - result = converter.convert() - self.assertEqual( result, IECore.V3fData( imath.V3f( 1 ) ) ) - - def testReadWritePDC( self ) : - points = self.points() - writer = self.writer( points ) - writer.parm( "file" ).set( TestCobIOTranslator.__testPDCFile ) - reader = self.reader() - reader.parm( "file" ).set( TestCobIOTranslator.__testPDCFile ) - - self.assertTrue( not reader.geometry() ) - self.assertTrue( reader.errors() ) - writer.cook() - self.assertTrue( reader.geometry() ) - self.assertTrue( not reader.errors() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECore.TypeId( IECoreScene.TypeId.PointsPrimitive ) ) ) - - def setUp( self ) : - IECoreHoudini.TestCase.setUp( self ) - if not os.path.exists( TestCobIOTranslator.__testDir ) : - os.mkdir( TestCobIOTranslator.__testDir ) - - def tearDown( self ) : - if os.path.exists( TestCobIOTranslator.__testDir ) : - shutil.rmtree( TestCobIOTranslator.__testDir ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/CortexConverterSop.py b/test/IECoreHoudini/CortexConverterSop.py deleted file mode 100644 index 0f61659e39..0000000000 --- a/test/IECoreHoudini/CortexConverterSop.py +++ /dev/null @@ -1,561 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import hou -import IECore -import IECoreScene -import IECoreHoudini -import unittest - -class TestCortexConverterSop( IECoreHoudini.TestCase ): - - ToCortex = 0 - ToHoudini = 1 - - if hou.applicationVersion()[0] >= 16: - PointPositionAttribs = ['P'] - else: - PointPositionAttribs = ['P', 'Pw'] - - # make sure we can create the op - def testCreateCortexConverter(self) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - op = geo.createNode( "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load( "cobReader", 1)() - cl['filename'] = "test/IECoreHoudini/data/torus.cob" - fn = IECoreHoudini.FnOpHolder(op) - fn.setParameterised(cl) - IECoreHoudini.Utils.syncSopParametersWithOp(op) - op.cook() - self.assertEqual( cl.resultParameter().getValue().typeId(), IECoreScene.TypeId.MeshPrimitive ) - return (op, fn) - - # check it works for points - def testPointConversion(self): - (op,fn) = self.testCreateCortexConverter() - torus = op.createOutputNode( "ieCortexConverter" ) - scatter = torus.createOutputNode( "scatter" ) - scatter.parm( "npts" ).set( 5000 ) - attr = scatter.createOutputNode( "attribcreate", exact_type_name=True ) - attr.parm("name").set("testAttribute") - attr.parm("value1").setExpression("$PT") - to_cortex = attr.createOutputNode( "ieOpHolder" ) - cl = IECoreHoudini.Utils.op("objectDebug",1) - fn = IECoreHoudini.FnOpHolder(to_cortex) - fn.setParameterised(cl) - to_cortex.parm("parm_quiet").set(True) - to_houdini = to_cortex.createOutputNode("ieCortexConverter") - geo = to_houdini.geometry() - attrNames = [ p.name() for p in geo.pointAttribs() ] - attrNames.sort() - self.assertEqual( attrNames, TestCortexConverterSop.PointPositionAttribs + ["testAttribute"] ) - self.assertEqual( len(geo.points()), 5000 ) - self.assertEqual( len(geo.prims()), 1 ) - - # check it works for polygons - def testPolygonConversion(self): - (op,fn) = self.testCreateCortexConverter() - torus = op.createOutputNode( "ieCortexConverter" ) - geo = torus.geometry() - self.assertEqual( len(geo.points()), 100 ) - self.assertEqual( len(geo.prims()), 100 ) - attrNames = [ p.name() for p in geo.pointAttribs() ] - attrNames.sort() - self.assertEqual( attrNames, TestCortexConverterSop.PointPositionAttribs ) - for p in geo.prims(): - self.assertEqual( p.numVertices(), 4 ) - self.assertEqual( p.type(), hou.primType.Polygon ) - n = hou.node("/obj/geo1") - h_torus = n.createNode( "torus" ) - h_torus.parm( "rows" ).set( 10 ) - h_torus.parm( "cols" ).set( 10 ) - h_geo = h_torus.geometry() - self.assertEqual( len(geo.pointAttribs()), len(h_geo.pointAttribs()) ) - self.assertEqual( len(geo.prims()), len(h_geo.prims()) ) - - def scene( self ) : - - geo = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - boxA = geo.createNode( "box" ) - nameA = boxA.createOutputNode( "name" ) - nameA.parm( "name1" ).set( "boxA" ) - boxB = geo.createNode( "box" ) - nameB = boxB.createOutputNode( "name" ) - nameB.parm( "name1" ).set( "boxB" ) - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - nameC = torus.createOutputNode( "name" ) - nameC.parm( "name1" ).set( "torus" ) - merge = geo.createNode( "merge" ) - merge.setInput( 0, nameA ) - merge.setInput( 1, nameB ) - merge.setInput( 2, nameC ) - - return merge.createOutputNode( "ieCortexConverter" ) - - def testNameFilter( self ) : - - node = self.scene() - - # it all converts to Cortex prims - node.parm( "resultType" ).set( TestCortexConverterSop.ToCortex ) # - geo = node.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 3 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Custom ] * 3 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - # filter the middle shape only - node.parm( "nameFilter" ).set( "* ^boxB" ) - geo = node.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 8 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Custom ] + [ hou.primType.Polygon ] * 6 + [ hou.primType.Custom ] ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - # filters work on Cortex Prims as well - back = node.createOutputNode( "ieCortexConverter" ) - back.parm( "nameFilter" ).set( "* ^torus" ) - geo = back.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 13 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Polygon ] * 12 + [ hou.primType.Custom ] ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - # test unnamed shape, ie. multiple primitives with no name attribute - delname = back.createOutputNode( "attribute" ) - delname.parm( "primdel" ).set( "name" ) - unnamed = delname.createOutputNode( "ieCortexConverter" ) - geo = unnamed.geometry() - self.assertEqual( geo, None) - self.assertEqual( unnamed.errors(), ('Could not convert the geometry named ',) ) - - # unnamed with no filter is just a pass through - unnamed.parm( "nameFilter" ).set( "" ) - geo = unnamed.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 13 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Polygon ] * 12 + [ hou.primType.Custom ] ) - self.assertEqual( geo.findPrimAttrib( "name" ), None ) - - def testResultType( self ) : - - node = self.scene() - - # it all passes through - geo = node.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 112 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Polygon ] * 112 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 100 ) - - # it all converts to Cortex prims - node.parm( "resultType" ).set( TestCortexConverterSop.ToCortex ) - geo = node.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 3 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Custom ] * 3 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - # it all converts back to Houdini geo - back = node.createOutputNode( "ieCortexConverter" ) - geo = back.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 112 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Polygon ] * 112 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 6 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 100 ) - - def testAttributeFilter( self ) : - - torus = hou.node("/obj").createNode("geo", run_init_scripts=False).createNode( "torus" ) - color = torus.createOutputNode( "color" ) - color.parm( "class" ).set( 3 ) - color.parm( "colortype" ).set( 2 ) - rest = color.createOutputNode( "rest" ) - scale = rest.createOutputNode( "attribcreate" ) - scale.parm( "name1" ).set( "pscale" ) - scale.parm( "value1v1" ).setExpression( "$PT" ) - uvunwrap = scale.createOutputNode( "uvunwrap" ) - opHolder = uvunwrap.createOutputNode( "ieOpHolder" ) - fn = IECoreHoudini.FnOpHolder( opHolder ) - fn.setOp( "parameters/primitives/polyParam" ) - out = opHolder.createOutputNode( "ieCortexConverter" ) - - # verify input - inGeo = uvunwrap.geometry() - self.assertEqual( sorted([ x.name() for x in inGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in inGeo.primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in inGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in inGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in inGeo.globalAttribs() ]), ['varmap'] ) - - # verifty output - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # verify intermediate op result - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "varmap", "width" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # make sure P is forced - out.parm( "attributeFilter" ).set( "* ^P" ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # have to filter the source attrs - out.parm( "attributeFilter" ).set( "* ^uv ^pscale ^rest" ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - out.parm( "attributeFilter" ).set( "* ^uv ^width ^Pref" ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # make sure we can filter on both ends - opHolder.parm( "parm_input_attributeFilter" ).set( "* ^uv ^width ^Pref" ) - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "varmap", "uv", "width" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - opHolder.parm( "parm_input_attributeFilter" ).set( "* ^uv ^pscale ^rest" ) - opHolder.cook( True ) - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "varmap" ] ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # since the vars never made it to the op, the never make it out - out.parm( "attributeFilter" ).set( "*" ) - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - def testStandardAttributeConversion( self ) : - - torus = hou.node("/obj").createNode("geo", run_init_scripts=False).createNode( "torus" ) - color = torus.createOutputNode( "color" ) - color.parm( "class" ).set( 3 ) - color.parm( "colortype" ).set( 2 ) - rest = color.createOutputNode( "rest" ) - scale = rest.createOutputNode( "attribcreate" ) - scale.parm( "name1" ).set( "pscale" ) - scale.parm( "value1v1" ).setExpression( "$PT" ) - uvunwrap = scale.createOutputNode( "uvunwrap" ) - opHolder = uvunwrap.createOutputNode( "ieOpHolder" ) - fn = IECoreHoudini.FnOpHolder( opHolder ) - fn.setOp( "parameters/primitives/polyParam" ) - out = opHolder.createOutputNode( "ieCortexConverter" ) - - # verify input - inGeo = uvunwrap.geometry() - self.assertEqual( sorted([ x.name() for x in inGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in inGeo.primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in inGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in inGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in inGeo.globalAttribs() ]), ['varmap'] ) - - # verifty output - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # verify intermediate op result - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "varmap", "width" ] ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["Pref"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - inUvs = inGeo.findVertexAttrib( "uv" ) - outUvs = outGeo.findVertexAttrib( "uv" ) - - i = 0 - for prim in inGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( inUvs ) - self.assertAlmostEqual( uvValues[0], uvData[ uvIndices[i] ][0] ) - self.assertAlmostEqual( uvValues[1], uvData[ uvIndices[i] ][1] ) - i += 1 - - i = 0 - for prim in outGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( outUvs ) - self.assertAlmostEqual( uvValues[0], uvData[ uvIndices[i] ][0] ) - self.assertAlmostEqual( uvValues[1], uvData[ uvIndices[i] ][1] ) - i += 1 - - # turn off half the conversion - opHolder.parm( "parm_input_convertStandardAttributes" ).set( False ) - - # verifty output - outGeo = out.geometry() - self.assertEqual( sorted([ x.name() for x in outGeo.pointAttribs() ]), TestCortexConverterSop.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cd', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # verify intermediate op result - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cd", "P", "pscale", "rest", "uv" ] ) - else : - self.assertEqual( result.keys(), [ "Cd", "P", "pscale", "rest", "uv", "varmap" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["rest"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - inUvs = inGeo.findVertexAttrib( "uv" ) - outUvs = outGeo.findVertexAttrib( "uv" ) - - i = 0 - for prim in inGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( inUvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - i = 0 - for prim in outGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( outUvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - # turn off the other half of the conversion - opHolder.parm( "parm_input_convertStandardAttributes" ).set( True ) - out.parm( "convertStandardAttributes" ).set( False ) - - # verifty output - outGeo = out.geometry() - self.assertEqual( set([ x.name() for x in outGeo.pointAttribs() ]), set(TestCortexConverterSop.PointPositionAttribs + ['Pref', 'width']) ) - self.assertEqual( sorted([ x.name() for x in outGeo.primAttribs() ]), ["ieMeshInterpolation"] ) - self.assertEqual( sorted([ x.name() for x in outGeo.vertexAttribs() ]), ['Cs', 'uv'] ) - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), [] ) - else : - self.assertEqual( sorted([ x.name() for x in outGeo.globalAttribs() ]), ['varmap'] ) - - # verify intermediate op result - result = fn.getOp().resultParameter().getValue() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "varmap", "width" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["Pref"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - inUvs = inGeo.findVertexAttrib( "uv" ) - outUvs = outGeo.findVertexAttrib( "uv" ) - - i = 0 - for prim in inGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( inUvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - i = 0 - for prim in outGeo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( outUvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - def testSameName( self ) : - - node = self.scene() - - # it all converts to Cortex prims - node.parm( "resultType" ).set( TestCortexConverterSop.ToCortex ) - - geo = node.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 3 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Custom ] * 3 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'boxB', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxB' ]), 1 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - rename = node.createOutputNode( "name" ) - rename.parm( "group1" ).set( "@name=boxB" ) - rename.parm( "name1" ).set( "boxA" ) - - # still have 3 CortexObjects - geo = rename.geometry() - prims = geo.prims() - self.assertEqual( len(prims), 3 ) - self.assertEqual( [ x.type() for x in prims ], [ hou.primType.Custom ] * 3 ) - nameAttr = geo.findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ 'boxA', 'torus' ] ) ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'boxA' ]), 2 ) - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == 'torus' ]), 1 ) - - # turns into 2 named Houdini objects since 2 of the names were the same - toHoudini = rename.createOutputNode( "ieCortexConverter" ) - toHoudini.parm( "resultType" ).set( TestCortexConverterSop.ToHoudini ) - - geo = toHoudini.geometry() - self.assertEqual( geo, None ) - - self.assertEqual( toHoudini.errors(), ('Could not convert the geometry named boxA',) ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/FromHoudiniCurvesConverter.py b/test/IECoreHoudini/FromHoudiniCurvesConverter.py deleted file mode 100644 index 71e3654b9f..0000000000 --- a/test/IECoreHoudini/FromHoudiniCurvesConverter.py +++ /dev/null @@ -1,571 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import hou -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import imath - -class TestFromHoudiniCurvesConverter( IECoreHoudini.TestCase ) : - - __curveCoordinates = [ - "2.42892,0,-1.04096 1.69011,0,-9.88746 5.74288,0,-4.50183 2.69113,0,-2.78439 5.8923,0,1.53021 6.20965,-9.53674e-07,2.03933 2.72012,0,2.5738 1.76971,0,-0.632637", - "-0.560781,0,-1.04096 2.21995,0,-6.31734 4.77513,0,-6.61752 4.10862,0,-2.78439 4.29081,0,1.53021 6.20965,-9.53674e-07,3.7489 -2.61584,0,2.5738 -1.45801,0,0.780965", - "2.42892,0,-1.04096 2.21995,0,-4.51254 4.77513,0,-4.50183 6.32944,0,-2.78439 7.231,0,1.53021 6.20965,-9.53674e-07,3.7489 2.72012,0,2.5738 1.76971,0,0.780965", - "5.83427,0,-1.04096 2.21995,0,-4.51254 6.14141,0,-4.50183 7.48932,0,-2.78439 9.0197,0,1.53021 6.20965,-9.53674e-07,1.2141 2.72012,0,2.5738 3.23728,0,0.780965" - ] - - def createCurve( self, order=2, periodic=False, parent=None, coordIndex=0 ) : - - if not parent : - obj = hou.node("/obj") - parent = obj.createNode("geo", run_init_scripts=False) - - if hou.applicationVersion()[0] >= 19 : - curve = parent.createNode( "curve::" ) - else : - curve = parent.createNode( "curve" ) - - curve.parm( "type" ).set( 1 ) # NURBS - curve.parm( "order" ).set( order ) - curve.parm( "close" ).set( periodic ) - curve.parm( "coords" ).set( TestFromHoudiniCurvesConverter.__curveCoordinates[coordIndex] ) - - detailAttr = curve.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm("name").set( "detailAttribute" ) - detailAttr.parm("class").set( 0 ) # detail attribute - detailAttr.parm("type").set( 0 ) # float - detailAttr.parm("size").set( 1 ) # 1 element - detailAttr.parm("value1").set( 123.456 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm("name").set( "pointAttribute" ) - pointAttr.parm("class").set( 2 ) # point - pointAttr.parm("type").set( 0 ) # float - pointAttr.parm("size").set( 3 ) # 3 elements - pointAttr.parm("value1").set( 123.456 ) - pointAttr.parm("value2").set( 654.321 ) - pointAttr.parm("value2").set( 789.123 ) - - primAttr = pointAttr.createOutputNode( "attribcreate", exact_type_name=True ) - primAttr.parm("name").set( "primAttribute" ) - primAttr.parm("class").set( 1 ) # prim - primAttr.parm("type").set( 1 ) # int - primAttr.parm("size").set( 2 ) # 2 elements - primAttr.parm("value1").set( 10 ) - primAttr.parm("value2").set( 45 ) - - vertexAttr = primAttr.createOutputNode( "attribcreate", exact_type_name=True ) - vertexAttr.parm("name").set( "vertexAttribute" ) - vertexAttr.parm("class").set( 3 ) # vertex - vertexAttr.parm("type").set( 0 ) # float - vertexAttr.parm("size").set( 0 ) # 1 element - vertexAttr.parm("value1").setExpression( "$VTX" ) - - return vertexAttr - - def createCurves( self, numCurves, order=2, periodic=False ) : - - curves = [ self.createCurve( order, periodic ) ] - - geo = curves[0].parent() - - for i in range( 0, numCurves-1 ) : - curves.append( self.createCurve( order, periodic, geo, i%4 ) ) - - merge = geo.createNode( "merge" ) - - for i in range( 0, len(curves) ) : - merge.setInput( i, curves[i] ) - - return merge - - def testCreateConverter( self ) : - curve = self.createCurve() - converter = IECoreHoudini.FromHoudiniCurvesConverter( curve ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - return converter - - def testFactory( self ) : - curve = self.createCurve() - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( curve ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( curve, resultType = IECoreScene.TypeId.CurvesPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( curve, resultType = IECore.TypeId.Parameter ) - self.assertEqual( converter, None ) - - self.assertTrue( IECoreScene.TypeId.CurvesPrimitive in IECoreHoudini.FromHoudiniGeometryConverter.supportedTypes() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( IECoreScene.TypeId.CurvesPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( [ IECoreScene.TypeId.CurvesPrimitive ] ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - def testConvertFromHOMGeo( self ) : - geo = self.createCurve().geometry() - converter = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.CurvesPrimitive ) ) - - converter2 = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo, IECoreScene.TypeId.CurvesPrimitive ) - self.assertTrue( converter2.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - def verifyLinearCurves( self, sop ) : - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.CurvesPrimitive ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - geo = sop.geometry() - bBox = result.bound() - hBBox = geo.boundingBox() - for i in range( 0, 3 ) : - self.assertAlmostEqual( bBox.min()[i], hBBox.minvec()[i] ) - self.assertAlmostEqual( bBox.max()[i], hBBox.maxvec()[i] ) - - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), len(geo.points()) ) - self.assertEqual( result.verticesPerCurve().size(), len(geo.prims()) ) - index = 0 - for i in range( len( result.verticesPerCurve() ) ) : - self.assertEqual( result.verticesPerCurve()[i], geo.prims()[i].numVertices() ) - - hVertices = geo.prims()[i].vertices() - for j in range( len(hVertices) ) : - self.assertEqual( tuple(result["P"].data[index+j]), tuple(hVertices[j].point().position()) ) - - index += result.verticesPerCurve()[i] - - self.assertEqual( result.basis(), IECore.CubicBasisf.linear() ) - - for attr in geo.globalAttribs() : - if attr.name() == "varmap" : - continue - - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result[attr.name()].data.value, geo.attribValue( attr.name() ) ) - - sopPoints = geo.points() - for attr in geo.pointAttribs() : - if attr.name() == "Pw" : - continue - - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - - data = result[attr.name()].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPoints[i].attribValue( attr.name() ) ) - - sopPrims = geo.prims() - self.assertEqual( len(sopPrims), len(result.verticesPerCurve()) ) - - for attr in geo.primAttribs() : - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - - data = result[attr.name()].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[i].attribValue( attr.name() ) ) - - sopVerts = [] - for i in range( 0, len(sopPrims) ) : - verts = list(sopPrims[i].vertices()) - self.assertEqual( len(verts), result.verticesPerCurve()[i] ) - sopVerts.extend( verts ) - - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( len(sopVerts), result["P"].data.size() ) - for attr in geo.vertexAttribs() : - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - data = result[attr.name()].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopVerts[i].attribValue( attr.name() ) ) - - def testOneLinearCurve( self ) : - self.verifyLinearCurves( self.createCurve() ) - - def testOneLinearPeriodicCurve( self ) : - self.verifyLinearCurves( self.createCurve( periodic=True ) ) - - def testFourLinearCurves( self ) : - self.verifyLinearCurves( self.createCurves( 4 ) ) - - def testFourLinearPeriodicCurves( self ) : - self.verifyLinearCurves( self.createCurves( 4, periodic=True ) ) - - def testManyLinearCurves( self ) : - self.verifyLinearCurves( self.createCurves( 100 ) ) - - def testManyLinearPeriodicCurves( self ) : - self.verifyLinearCurves( self.createCurves( 100, periodic=True ) ) - - def verifyBSplineCurves( self, sop ) : - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertEqual( result.typeId(), IECoreScene.TypeId.CurvesPrimitive ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - geo = sop.geometry() - bBox = result.bound() - hBBox = geo.boundingBox() - for i in range( 0, 3 ) : - self.assertAlmostEqual( bBox.min()[i], hBBox.minvec()[i] ) - self.assertAlmostEqual( bBox.max()[i], hBBox.maxvec()[i] ) - - if result.periodic() : - extraPoints = 0 - else : - extraPoints = 4 - - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), len(geo.points()) + extraPoints*len(geo.prims()) ) - self.assertEqual( result.verticesPerCurve().size(), len(geo.prims()) ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - pIndex = 0 - for i in range( len( result.verticesPerCurve() ) ) : - self.assertEqual( result.verticesPerCurve()[i], geo.prims()[i].numVertices() + extraPoints ) - - hVertices = geo.prims()[i].vertices() - for j in range( len(hVertices) ) : - - if not result.periodic() and ( j == 0 or j == len(hVertices)-1 ) : - self.assertEqual( tuple(result["P"].data[pIndex]), tuple(hVertices[j].point().position()) ) - self.assertEqual( tuple(result["P"].data[pIndex+1]), tuple(hVertices[j].point().position()) ) - pIndex += 2 - - self.assertEqual( tuple(result["P"].data[pIndex]), tuple(hVertices[j].point().position()) ) - pIndex += 1 - - self.assertEqual( result.basis(), IECore.CubicBasisf.bSpline() ) - - for attr in geo.globalAttribs() : - if attr.name() == "varmap" : - continue - - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result[attr.name()].data.value, geo.attribValue( attr.name() ) ) - - sopPoints = geo.points() - for attr in geo.pointAttribs() : - if attr.name() == "Pw" : - continue - - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - - for attr in geo.vertexAttribs() : - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - - sopPrims = geo.prims() - self.assertEqual( len(sopPrims), len(result.verticesPerCurve()) ) - - for attr in geo.primAttribs() : - self.assertTrue( attr.name() in result ) - self.assertEqual( result[attr.name()].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - - data = result[attr.name()].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[i].attribValue( attr.name() ) ) - - pIndex = 0 - for i in range( len( result.verticesPerCurve() ) ) : - hVertices = sopPrims[i].vertices() - self.assertEqual( len(hVertices) + extraPoints, result.verticesPerCurve()[i] ) - for j in range( len(hVertices) ) : - - for attr in geo.pointAttribs() : - if attr.name() == "Pw" : - continue - - data = result[attr.name()].data - self.assertEqual( tuple(data[pIndex]), hVertices[j].point().attribValue( attr.name() ) ) - - if not result.periodic() and ( j == 0 or j == len(hVertices)-1 ) : - self.assertEqual( tuple(data[pIndex+1]), hVertices[j].point().attribValue( attr.name() ) ) - self.assertEqual( tuple(data[pIndex+2]), hVertices[j].point().attribValue( attr.name() ) ) - - for attr in geo.vertexAttribs() : - data = result[attr.name()].data - self.assertEqual( data[pIndex], hVertices[j].attribValue( attr.name() ) ) - - if not result.periodic() and ( j == 0 or j == len(hVertices)-1 ) : - self.assertEqual( data[pIndex+1], hVertices[j].attribValue( attr.name() ) ) - self.assertEqual( data[pIndex+2], hVertices[j].attribValue( attr.name() ) ) - - if not result.periodic() and ( j == 0 or j == len(hVertices)-1 ) : - pIndex += 3 - else : - pIndex += 1 - - def testOneBSplineCurve( self ) : - self.verifyBSplineCurves( self.createCurve( order=4 ) ) - - def testOneBSplinePeriodicCurve( self ) : - self.verifyBSplineCurves( self.createCurve( order=4, periodic=True ) ) - - def testFourBSplineCurves( self ) : - self.verifyBSplineCurves( self.createCurves( 4, order=4 ) ) - - def testFourBSplinePeriodicCurves( self ) : - self.verifyBSplineCurves( self.createCurves( 4, order=4, periodic=True ) ) - - def testManyBSplineCurves( self ) : - self.verifyBSplineCurves( self.createCurves( 100, order=4 ) ) - - def testManyBSplinePeriodicCurves( self ) : - self.verifyBSplineCurves( self.createCurves( 100, order=4, periodic=True ) ) - - def testAnimatingGeometry( self ) : - curves = self.createCurves( 4 ) - mountain = curves.createOutputNode( "mountain" ) - if hou.applicationVersion()[0] >= 16: - mountain.parm("offsetx").setExpression( "$FF" ) - else: - mountain.parm( "offset1" ).setExpression( "$FF" ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( mountain ) - hou.setFrame( 1 ) - result1 = converter.convert() - hou.setFrame( 2 ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( mountain ) - result2 = converter.convert() - self.assertNotEqual( result1["P"].data, result2["P"].data ) - self.assertNotEqual( result1, result2 ) - - def testName( self ) : - - curves = self.createCurves( 4 ) - name = curves.createOutputNode( "name" ) - name.parm( "name1" ).set( "curvesA" ) - curves2 = self.createCurve( parent = curves.parent() ) - name2 = curves2.createOutputNode( "name" ) - name2.parm( "name1" ).set( "curvesB" ) - merge = name.createOutputNode( "merge" ) - merge.setInput( 1, name2 ) - - converter = IECoreHoudini.FromHoudiniCurvesConverter( merge ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # all curves were converted as one CurvesPrimitive - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 5 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "curvesA" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # only the named curves were converted - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 4 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "curvesB" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # only the named curves were converted - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 1 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - def testAttributeFilter( self ) : - - curves = self.createCurves( 4 ) - uvunwrap = curves.createOutputNode( "uvunwrap" ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( uvunwrap ) - self.assertEqual( sorted(converter.convert().keys()), ['P', 'detailAttribute', 'pointAttribute', 'primAttribute', 'uv', 'varmap', 'vertexAttribute'] ) - converter.parameters()["attributeFilter"].setTypedValue( "P" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "* ^primAttribute ^varmap" ) - self.assertEqual( sorted(converter.convert().keys()), ['P', 'detailAttribute', 'pointAttribute', 'uv', 'vertexAttribute'] ) - # P must be converted - converter.parameters()["attributeFilter"].setTypedValue( "* ^P" ) - self.assertTrue( "P" in converter.convert().keys() ) - converter.parameters()["attributeFilter"].setTypedValue( "uv" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P", "uv" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P" ] ) - - def testErrorStates( self ) : - - # no prims - merge = self.createCurves( 4 ) - add = merge.createOutputNode( "add" ) - add.parm( "keep" ).set( True ) # deletes primitive and leaves points - converter = IECoreHoudini.FromHoudiniCurvesConverter( add ) - self.assertRaises( RuntimeError, converter.convert ) - - # non-curve prims - merge = self.createCurves( 4 ) - merge.createInputNode( 5, "box" ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( merge ) - self.assertRaises( RuntimeError, converter.convert ) - - # many curves, different orders - merge = self.createCurves( 4 ) - hou.parm( "/obj/geo3/curve3/order" ).set( 3 ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( merge ) - self.assertRaises( RuntimeError, converter.convert ) - - # many curves, different periodicity - merge = self.createCurves( 4 ) - hou.parm( "/obj/geo4/curve3/close" ).set( True ) - converter = IECoreHoudini.FromHoudiniCurvesConverter( merge ) - self.assertRaises( RuntimeError, converter.convert ) - - def testStandardAttributeConversion( self ) : - - curves = self.createCurves( 4 ) - color = curves.createOutputNode( "color" ) - color.parm( "colortype" ).set( 2 ) - rest = color.createOutputNode( "rest" ) - scale = rest.createOutputNode( "attribcreate" ) - scale.parm( "name1" ).set( "pscale" ) - scale.parm( "value1v1" ).setExpression( "$PT" ) - uvunwrap = scale.createOutputNode( "uvunwrap" ) - - converter = IECoreHoudini.FromHoudiniCurvesConverter( uvunwrap ) - result = converter.convert() - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "detailAttribute", "pointAttribute", "primAttribute", "uv", "varmap", "vertexAttribute", "width" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["Pref"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - for vert in prim.vertices() : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[i][0] ) - self.assertAlmostEqual( uvValues[1], uvData[i][1] ) - i += 1 - - converter["convertStandardAttributes"].setTypedValue( False ) - result = converter.convert() - self.assertEqual( result.keys(), [ "Cd", "P", "detailAttribute", "pointAttribute", "primAttribute", "pscale", "rest", "uv", "varmap", "vertexAttribute" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["rest"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - for vert in prim.vertices() : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[i][0], uvValues[0] ) - self.assertAlmostEqual( uvData[i][1], uvValues[1] ) - i += 1 - - def testAllOpenPolygonsConvertedAsLinearCurves( self ) : - - obj = hou.node( "/obj" ) - parent = obj.createNode( "geo", run_init_scripts = False ) - - if hou.applicationVersion()[0] >= 19 : - curves = [parent.createNode( "curve::" ), parent.createNode( "curve::" ), parent.createNode( "curve::" )] - else : - curves = [parent.createNode( "curve" ), parent.createNode( "curve" ), parent.createNode( "curve" )] - names = [parent.createNode( "name" ), parent.createNode( "name" ), parent.createNode( "name" )] - - curves[0].parm( "type" ).set( 0 ) # polygon - curves[0].parm( "close" ).set( False ) - curves[0].parm( "coords" ).set( "0, 0, 0 0, 1, 0 1, 1, 0" ) - names[0].parm( "name1" ).set( "/openCurve0" ) - - curves[1].parm( "type" ).set( 0 ) # polygon - curves[1].parm( "close" ).set( False ) - curves[1].parm( "coords" ).set( "0,0,0 0,0,1 1,0,1" ) - names[1].parm( "name1" ).set( "/openCurve1" ) - - curves[2].parm( "type" ).set( 0 ) # polygon - curves[2].parm( "close" ).set( False ) - curves[2].parm( "coords" ).set( "0,0,0 1,0,0" ) - names[2].parm( "name1" ).set( "/openCurve2" ) - - merge = parent.createNode( "merge" ) - - for i in range( 0, len( curves ) ) : - names[i].setInput( 0, curves[i] ) - merge.setInput( i, names[i] ) - - # Use the base FromHoudiniGeometryConverter.create to verify we create a CurvesConverter for this open polygon detail - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCurvesConverter ) ) ) - - actualCurvesPrimitive = converter.convert() - - self.assertTrue( actualCurvesPrimitive.isInstanceOf( IECoreScene.CurvesPrimitive ) ) - self.assertTrue( "P" in actualCurvesPrimitive ) - self.assertEqual( actualCurvesPrimitive.verticesPerCurve(), IECore.IntVectorData( [3, 3, 2] ) ) - self.assertEqual( actualCurvesPrimitive.basis().standardBasis(), IECore.StandardCubicBasis.Linear ) - self.assertEqual( actualCurvesPrimitive["P"].data, IECore.V3fVectorData( [ - imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), - imath.V3f( 0, 0, 0 ), imath.V3f( 0, 0, 1 ), imath.V3f( 1, 0, 1 ), - imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) - ], IECore.GeometricData.Interpretation.Point ) ) - - # Now we close one of the polygons - curves[2].parm( "close" ).set( True ) - names[2].parm( "name1" ).set( "/closedCurve0" ) - merge.setDisplayFlag( True ) - merge.setRenderFlag( True ) - - scene = IECoreHoudini.LiveScene( merge.parent().path() ) - self.assertTrue( scene.child( "closedCurve0" ).readObject( 0 ).isInstanceOf( IECoreScene.MeshPrimitive ) ) - self.assertTrue( scene.child( "openCurve0" ).readObject( 0 ).isInstanceOf( IECoreScene.CurvesPrimitive ) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/FromHoudiniPointsConverter.py b/test/IECoreHoudini/FromHoudiniPointsConverter.py deleted file mode 100644 index 75214dded8..0000000000 --- a/test/IECoreHoudini/FromHoudiniPointsConverter.py +++ /dev/null @@ -1,1058 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os -import math - -class TestFromHoudiniPointsConverter( IECoreHoudini.TestCase ) : - - def createBox( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - - return box - - def createTorus( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - - return torus - - def createPoints( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - facet = geo.createNode( "facet" ) - facet.parm("postnml").set(True) - points = geo.createNode( "scatter" ) - points.parm( "npts" ).set( 5000 ) - facet.setInput( 0, box ) - points.setInput( 0, facet ) - - return points - - def createPopNet( self ): - obj = hou.node( '/obj' ) - geo = obj.createNode("geo", run_init_scripts=False) - popNet = geo.createNode("dopnet", "popnet" ) - popObject = popNet.createNode( "popobject" ) - popSolver = popObject.createOutputNode( "popsolver" ) - output = popSolver.createOutputNode( "output" ) - output.setDisplayFlag( True ) - - return popNet - - # creates a converter - def testCreateConverter( self ) : - box = self.createBox() - converter = IECoreHoudini.FromHoudiniPointsConverter( box ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - return converter - - # creates a converter - def testFactory( self ) : - box = self.createBox() - points = self.createPoints() - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( box ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( points, resultType = IECoreScene.TypeId.PointsPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( box, resultType = IECore.TypeId.Parameter ) - self.assertEqual( converter, None ) - - self.assertTrue( IECoreScene.TypeId.PointsPrimitive in IECoreHoudini.FromHoudiniGeometryConverter.supportedTypes() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( IECoreScene.TypeId.PointsPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( [ IECoreScene.TypeId.PointsPrimitive ] ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - # performs geometry conversion - def testDoConversion( self ) : - converter = self.testCreateConverter() - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - - def testConvertFromHOMGeo( self ) : - geo = self.createPoints().geometry() - converter = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - - converter2 = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo, IECoreScene.TypeId.PointsPrimitive ) - self.assertTrue( converter2.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - # convert a mesh - def testConvertMesh( self ) : - torus = self.createTorus() - converter = IECoreHoudini.FromHoudiniPointsConverter( torus ) - result = converter.convert() - self.assertEqual( result.typeId(), IECoreScene.PointsPrimitive.staticTypeId() ) - - bbox = result.bound() - self.assertEqual( bbox.min().x, -2.0 ) - self.assertEqual( bbox.max().x, 2.0 ) - self.assertEqual( result.numPoints, 100 ) - for i in range( result.numPoints ) : - self.assertTrue( result["P"].data[i].x >= bbox.min().x ) - self.assertTrue( result["P"].data[i].x <= bbox.max().x ) - - # test prim/vertex attributes - def testConvertPrimVertAttributes( self ) : - torus = self.createTorus() - geo = torus.parent() - - # add vertex normals - facet = geo.createNode( "facet", node_name = "add_point_normals" ) - facet.parm("postnml").set(True) - facet.setInput( 0, torus ) - - # add a primitive colour attributes - primcol = geo.createNode( "primitive", node_name = "prim_colour" ) - primcol.parm("doclr").set(1) - primcol.parm("diffr").setExpression("rand($PR)") - primcol.parm("diffg").setExpression("rand($PR+1)") - primcol.parm("diffb").setExpression("rand($PR+2)") - primcol.setInput( 0, facet ) - - # add a load of different vertex attributes - vert_f1 = geo.createNode( "attribcreate", node_name = "vert_f1", exact_type_name=True ) - vert_f1.parm("name").set("vert_f1") - vert_f1.parm("class").set(3) - vert_f1.parm("value1").setExpression("$VTX*0.1") - vert_f1.setInput( 0, primcol ) - - vert_f2 = geo.createNode( "attribcreate", node_name = "vert_f2", exact_type_name=True ) - vert_f2.parm("name").set("vert_f2") - vert_f2.parm("class").set(3) - vert_f2.parm("size").set(2) - vert_f2.parm("value1").setExpression("$VTX*0.1") - vert_f2.parm("value2").setExpression("$VTX*0.1") - vert_f2.setInput( 0, vert_f1 ) - - vert_f3 = geo.createNode( "attribcreate", node_name = "vert_f3", exact_type_name=True ) - vert_f3.parm("name").set("vert_f3") - vert_f3.parm("class").set(3) - vert_f3.parm("size").set(3) - vert_f3.parm("value1").setExpression("$VTX*0.1") - vert_f3.parm("value2").setExpression("$VTX*0.1") - vert_f3.parm("value3").setExpression("$VTX*0.1") - vert_f3.setInput( 0, vert_f2 ) - - vert_i1 = geo.createNode( "attribcreate", node_name = "vert_i1", exact_type_name=True ) - vert_i1.parm("name").set("vert_i1") - vert_i1.parm("class").set(3) - vert_i1.parm("type").set(1) - vert_i1.parm("value1").setExpression("$VTX*0.1") - vert_i1.setInput( 0, vert_f3 ) - - vert_i2 = geo.createNode( "attribcreate", node_name = "vert_i2", exact_type_name=True ) - vert_i2.parm("name").set("vert_i2") - vert_i2.parm("class").set(3) - vert_i2.parm("type").set(1) - vert_i2.parm("size").set(2) - vert_i2.parm("value1").setExpression("$VTX*0.1") - vert_i2.parm("value2").setExpression("$VTX*0.1") - vert_i2.setInput( 0, vert_i1 ) - - vert_i3 = geo.createNode( "attribcreate", node_name = "vert_i3", exact_type_name=True ) - vert_i3.parm("name").set("vert_i3") - vert_i3.parm("class").set(3) - vert_i3.parm("type").set(1) - vert_i3.parm("size").set(3) - vert_i3.parm("value1").setExpression("$VTX*0.1") - vert_i3.parm("value2").setExpression("$VTX*0.1") - vert_i3.parm("value3").setExpression("$VTX*0.1") - vert_i3.setInput( 0, vert_i2 ) - - vert_v3f = geo.createNode( "attribcreate", node_name = "vert_v3f", exact_type_name=True ) - vert_v3f.parm("name").set("vert_v3f") - vert_v3f.parm("class").set(3) - vert_v3f.parm("type").set(2) - vert_v3f.parm("value1").setExpression("$VTX*0.1") - vert_v3f.parm("value2").setExpression("$VTX*0.1") - vert_v3f.parm("value3").setExpression("$VTX*0.1") - vert_v3f.setInput( 0, vert_i3 ) - - detail_i3 = geo.createNode( "attribcreate", node_name = "detail_i3", exact_type_name=True ) - detail_i3.parm("name").set("detail_i3") - detail_i3.parm("class").set(0) - detail_i3.parm("type").set(1) - detail_i3.parm("size").set(3) - detail_i3.parm("value1").set(123) - detail_i3.parm("value2").set(456.789) # can we catch it out with a float? - detail_i3.parm("value3").set(789) - detail_i3.setInput( 0, vert_v3f ) - - out = geo.createNode( "null", node_name="OUT" ) - out.setInput( 0, detail_i3 ) - - # convert it all - converter = IECoreHoudini.FromHoudiniPointsConverter( out ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - - bbox = result.bound() - self.assertEqual( bbox.min().x, -2.0 ) - self.assertEqual( bbox.max().x, 2.0 ) - self.assertEqual( result.numPoints, 100 ) - for i in range( result.numPoints ) : - self.assertTrue( result["P"].data[i].x >= bbox.min().x ) - self.assertTrue( result["P"].data[i].x <= bbox.max().x ) - - # test point attributes - self.assertTrue( "P" in result ) - self.assertEqual( result['P'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['P'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['P'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( "N" in result ) - self.assertEqual( result['N'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['N'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['N'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - # test detail attributes - self.assertTrue( "detail_i3" in result ) - self.assertEqual( result['detail_i3'].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result['detail_i3'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result['detail_i3'].data.value.x, 123 ) - self.assertEqual( result['detail_i3'].data.value.y, 456 ) - self.assertEqual( result['detail_i3'].data.value.z, 789 ) - - # test primitive attributes - self.assertTrue( "Cd" not in result ) - - # test vertex attributes - attrs = [ "vert_f1", "vert_f2", "vert_f3", "vert_i1", "vert_i2", "vert_i3", "vert_v3f" ] - for a in attrs : - self.assertTrue( a not in result ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # test prim/vertex attributes on a single primitive (mesh) - def testConvertMeshPrimVertAttributes( self ) : - torus = self.createTorus() - torus.parm( "type" ).set( 1 ) - geo = torus.parent() - - # add vertex normals - facet = geo.createNode( "facet", node_name = "add_point_normals" ) - facet.parm("postnml").set(True) - facet.setInput( 0, torus ) - - # add a primitive colour attributes - primcol = geo.createNode( "primitive", node_name = "prim_colour" ) - primcol.parm("doclr").set(1) - primcol.parm("diffr").setExpression("rand($PR)") - primcol.parm("diffg").setExpression("rand($PR+1)") - primcol.parm("diffb").setExpression("rand($PR+2)") - primcol.setInput( 0, facet ) - - # add a load of different vertex attributes - vert_f1 = geo.createNode( "attribcreate", node_name = "vert_f1", exact_type_name=True ) - vert_f1.parm("name").set("vert_f1") - vert_f1.parm("class").set(3) - vert_f1.parm("value1").setExpression("$VTX*0.1") - vert_f1.setInput( 0, primcol ) - - vert_f2 = geo.createNode( "attribcreate", node_name = "vert_f2", exact_type_name=True ) - vert_f2.parm("name").set("vert_f2") - vert_f2.parm("class").set(3) - vert_f2.parm("size").set(2) - vert_f2.parm("value1").setExpression("$VTX*0.1") - vert_f2.parm("value2").setExpression("$VTX*0.1") - vert_f2.setInput( 0, vert_f1 ) - - vert_f3 = geo.createNode( "attribcreate", node_name = "vert_f3", exact_type_name=True ) - vert_f3.parm("name").set("vert_f3") - vert_f3.parm("class").set(3) - vert_f3.parm("size").set(3) - vert_f3.parm("value1").setExpression("$VTX*0.1") - vert_f3.parm("value2").setExpression("$VTX*0.1") - vert_f3.parm("value3").setExpression("$VTX*0.1") - vert_f3.setInput( 0, vert_f2 ) - - vert_quat = geo.createNode( "attribcreate", node_name = "vert_quat", exact_type_name=True ) - vert_quat.parm("name").set("orient") - vert_quat.parm("class").set(3) - vert_quat.parm("size").set(4) - vert_quat.parm("value1").setExpression("$VTX*0.1") - vert_quat.parm("value2").setExpression("$VTX*0.2") - vert_quat.parm("value3").setExpression("$VTX*0.3") - vert_quat.parm("value4").setExpression("$VTX*0.4") - vert_quat.setInput( 0, vert_f3 ) - - vert_quat2 = geo.createNode( "attribcreate", node_name = "vert_quat2", exact_type_name=True ) - vert_quat2.parm("name").set("quat_2") - vert_quat2.parm("class").set(3) - vert_quat2.parm("size").set(4) - vert_quat2.parm("typeinfo").set(6) # set type info to quaternion - vert_quat2.parm("value1").setExpression("$VTX*0.2") - vert_quat2.parm("value2").setExpression("$VTX*0.4") - vert_quat2.parm("value3").setExpression("$VTX*0.6") - vert_quat2.parm("value4").setExpression("$VTX*0.8") - vert_quat2.setInput( 0, vert_quat ) - - vert_m44create = geo.createNode( "attribcreate", node_name = "vert_m44create", exact_type_name=True ) - vert_m44create.parm("name").set("m44") - vert_m44create.parm("class").set(3) - vert_m44create.parm("size").set(16) - vert_m44create.parm("typeinfo").set(7) # set type info to transformation matrix - vert_m44create.setInput( 0, vert_quat2 ) - - vert_m44 = geo.createNode( "attribwrangle", node_name = "vert_m44", exact_type_name=True ) - vert_m44.parm("snippet").set("4@m44 = maketransform(0,0,{ 10, 20, 30 },{ 30, 45, 60},{ 3, 4, 5 },{ 0, 0, 0 });") - vert_m44.parm("class").set(3) - vert_m44.setInput( 0, vert_m44create ) - - vert_m33create = geo.createNode( "attribcreate", node_name = "vert_m33create", exact_type_name=True ) - vert_m33create.parm("name").set("m33") - vert_m33create.parm("class").set(3) - vert_m33create.parm("size").set(9) - vert_m33create.setInput( 0, vert_m44 ) - - vert_m33 = geo.createNode( "attribwrangle", node_name = "vert_m33", exact_type_name=True ) - vert_m33.parm("snippet").set("3@m33 = matrix3(maketransform(0,0,{ 0, 0, 0 },{ 30, 45, 60},{ 3, 4, 5 },{ 0, 0, 0 }));") - vert_m33.parm("class").set(3) - vert_m33.setInput( 0, vert_m33create ) - - vert_i1 = geo.createNode( "attribcreate", node_name = "vert_i1", exact_type_name=True ) - vert_i1.parm("name").set("vert_i1") - vert_i1.parm("class").set(3) - vert_i1.parm("type").set(1) - vert_i1.parm("value1").setExpression("$VTX*0.1") - vert_i1.setInput( 0, vert_m33 ) - - vert_i2 = geo.createNode( "attribcreate", node_name = "vert_i2", exact_type_name=True ) - vert_i2.parm("name").set("vert_i2") - vert_i2.parm("class").set(3) - vert_i2.parm("type").set(1) - vert_i2.parm("size").set(2) - vert_i2.parm("value1").setExpression("$VTX*0.1") - vert_i2.parm("value2").setExpression("$VTX*0.1") - vert_i2.setInput( 0, vert_i1 ) - - vert_i3 = geo.createNode( "attribcreate", node_name = "vert_i3", exact_type_name=True ) - vert_i3.parm("name").set("vert_i3") - vert_i3.parm("class").set(3) - vert_i3.parm("type").set(1) - vert_i3.parm("size").set(3) - vert_i3.parm("value1").setExpression("$VTX*0.1") - vert_i3.parm("value2").setExpression("$VTX*0.1") - vert_i3.parm("value3").setExpression("$VTX*0.1") - vert_i3.setInput( 0, vert_i2 ) - - vert_v3f = geo.createNode( "attribcreate", node_name = "vert_v3f", exact_type_name=True ) - vert_v3f.parm("name").set("vert_v3f") - vert_v3f.parm("class").set(3) - vert_v3f.parm("type").set(2) - vert_v3f.parm("value1").setExpression("$VTX*0.1") - vert_v3f.parm("value2").setExpression("$VTX*0.1") - vert_v3f.parm("value3").setExpression("$VTX*0.1") - vert_v3f.setInput( 0, vert_i3 ) - - vertString = geo.createNode( "attribcreate", node_name = "vertString", exact_type_name=True ) - vertString.parm("name").set("vertString") - vertString.parm("class").set(3) - vertString.parm("type").set(3) - vertString.parm("string").setExpression("'string %06d!' % pwd().curPoint().number()", hou.exprLanguage.Python) - vertString.setInput( 0, vert_v3f ) - - - vertString2 = geo.createNode( "attribcreate", node_name = "vertString2", exact_type_name=True ) - vertString2.parm("name").set("vertString2") - vertString2.parm("class").set(3) - vertString2.parm("type").set(3) - vertString2.parm("string").setExpression("vals = [ 'd','c','e','a','g','f','b' ]\nreturn vals[ pwd().curPoint().number() % 7 ]", hou.exprLanguage.Python) - vertString2.setInput( 0, vertString ) - - vert_iList = geo.createNode( "attribwrangle", node_name = "vert_iList", exact_type_name=True ) - vert_iList.parm("snippet").set("int i[];\ni[]@vert_iList = i;") - vert_iList.parm("class").set(3) - vert_iList.setInput( 0, vertString2 ) - - vert_fList = geo.createNode( "attribwrangle", node_name = "vert_fList", exact_type_name=True ) - vert_fList.parm("snippet").set("float f[];\nf[]@vert_fList = f;") - vert_fList.parm("class").set(3) - vert_fList.setInput( 0, vert_iList ) - - - detail_i3 = geo.createNode( "attribcreate", node_name = "detail_i3", exact_type_name=True ) - detail_i3.parm("name").set("detail_i3") - detail_i3.parm("class").set(0) - detail_i3.parm("type").set(1) - detail_i3.parm("size").set(3) - detail_i3.parm("value1").set(123) - detail_i3.parm("value2").set(456.789) # can we catch it out with a float? - detail_i3.parm("value3").set(789) - detail_i3.setInput( 0, vert_fList ) - - detail_m33create = geo.createNode( "attribcreate", node_name = "detail_m33create", exact_type_name=True ) - detail_m33create.parm("name").set("detail_m33") - detail_m33create.parm("class").set(0) - detail_m33create.parm("size").set(9) - detail_m33create.setInput( 0, detail_i3 ) - - detail_m33 = geo.createNode( "attribwrangle", node_name = "detail_m33", exact_type_name=True ) - detail_m33.parm("snippet").set("3@detail_m33 = matrix3( maketransform(0,0,{ 10, 20, 30 },{ 30, 45, 60},{ 3, 4, 5 },{ 0, 0, 0 }) );") - detail_m33.parm("class").set(0) - detail_m33.setInput( 0, detail_m33create ) - - detail_m44create = geo.createNode( "attribcreate", node_name = "detail_m44create", exact_type_name=True ) - detail_m44create.parm("name").set("detail_m44") - detail_m44create.parm("class").set(0) - detail_m44create.parm("size").set(16) - detail_m44create.setInput( 0, detail_m33 ) - - detail_m44 = geo.createNode( "attribwrangle", node_name = "detail_m44", exact_type_name=True ) - detail_m44.parm("snippet").set("4@detail_m44 = maketransform(0,0,{ 10, 20, 30 },{ 30, 45, 60},{ 3, 4, 5 },{ 0, 0, 0 });") - detail_m44.parm("class").set(0) - detail_m44.setInput( 0, detail_m44create ) - - detail_iList = geo.createNode( "attribwrangle", node_name = "detail_iList", exact_type_name=True ) - detail_iList.parm("snippet").set("int i[];\ni[]@detail_iList = i;") - detail_iList.parm("class").set(0) - detail_iList.setInput( 0, detail_m44 ) - - detail_fList = geo.createNode( "attribwrangle", node_name = "detail_fList", exact_type_name=True ) - detail_fList.parm("snippet").set("float f[];\nf[]@detail_fList = f;") - detail_fList.parm("class").set(0) - detail_fList.setInput( 0, detail_iList ) - - out = geo.createNode( "null", node_name="OUT" ) - out.setInput( 0, detail_fList ) - - # convert it all - converter = IECoreHoudini.FromHoudiniPointsConverter( out ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - - bbox = result.bound() - self.assertEqual( bbox.min().x, -2.0 ) - self.assertEqual( bbox.max().x, 2.0 ) - self.assertEqual( result.numPoints, 100 ) - for i in range( result.numPoints ) : - self.assertTrue( result["P"].data[i].x >= bbox.min().x ) - self.assertTrue( result["P"].data[i].x <= bbox.max().x ) - - # integer and float list attributes are not currently supported, so should not appear in the primitive variable lists: - self.assertTrue( "vert_iList" not in result.keys() ) - self.assertTrue( "vert_fList" not in result.keys() ) - self.assertTrue( "detail_iList" not in result.keys() ) - self.assertTrue( "detail_fList" not in result.keys() ) - - # test point attributes - self.assertTrue( "P" in result ) - self.assertEqual( result['P'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['P'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['P'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( "N" in result ) - self.assertEqual( result['N'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['N'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['N'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - # test detail attributes - self.assertTrue( "detail_i3" in result ) - self.assertEqual( result['detail_i3'].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result['detail_i3'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result['detail_i3'].data.value.x, 123 ) - self.assertEqual( result['detail_i3'].data.value.y, 456 ) - self.assertEqual( result['detail_i3'].data.value.z, 789 ) - - # test primitive attributes - self.assertTrue( "Cs" in result ) - self.assertEqual( result["Cs"].data.typeId(), IECore.TypeId.Color3fVectorData ) - self.assertEqual( result["Cs"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - self.assertEqual( result["Cs"].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) : - for j in range( 0, 3 ) : - self.assertTrue( result["Cs"].data[i][j] >= 0.0 ) - self.assertTrue( result["Cs"].data[i][j] <= 1.0 ) - - # test vertex attributes - attrs = [ "vert_f1", "vert_f2", "vert_f3", "orient", "quat_2", "vert_i1", "vert_i2", "vert_i3", "vert_v3f" ] - for a in attrs : - self.assertTrue( a in result ) - self.assertEqual( result[a].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result[a].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - - # test indexed vertex attributes - for a in [ "vertString", "vertString2" ] : - self.assertTrue( a in result ) - self.assertEqual( result[a].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result[a].indices.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - - self.assertEqual( result["vert_f1"].data.typeId(), IECore.FloatVectorData.staticTypeId() ) - self.assertEqual( result["vert_f2"].data.typeId(), IECore.V2fVectorData.staticTypeId() ) - self.assertEqual( result["vert_f3"].data.typeId(), IECore.V3fVectorData.staticTypeId() ) - self.assertEqual( result["orient"].data.typeId(), IECore.QuatfVectorData.staticTypeId() ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) : - for j in range( 0, 3 ) : - self.assertTrue( result["vert_f3"].data[i][j] >= 0.0 ) - self.assertTrue( result["vert_f3"].data[i][j] < 400.1 ) - - self.assertAlmostEqual( result["orient"].data[i].r(), i * 0.4,5 ) - self.assertAlmostEqual( result["orient"].data[i].v()[0], i * 0.1,5 ) - self.assertAlmostEqual( result["orient"].data[i].v()[1], i * 0.2,5 ) - self.assertAlmostEqual( result["orient"].data[i].v()[2], i * 0.3,5 ) - - self.assertAlmostEqual( result["quat_2"].data[i].r(), i * 0.8,5 ) - self.assertAlmostEqual( result["quat_2"].data[i].v()[0], i * 0.2,5 ) - self.assertAlmostEqual( result["quat_2"].data[i].v()[1], i * 0.4,5 ) - self.assertAlmostEqual( result["quat_2"].data[i].v()[2], i * 0.6,5 ) - - self.assertEqual( result["vert_i1"].data.typeId(), IECore.IntVectorData.staticTypeId() ) - self.assertEqual( result["vert_i2"].data.typeId(), IECore.V2iVectorData.staticTypeId() ) - self.assertEqual( result["vert_i3"].data.typeId(), IECore.V3iVectorData.staticTypeId() ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) : - for j in range( 0, 3 ) : - self.assertTrue( result["vert_i3"].data[i][j] < 10 ) - - self.assertEqual( result["vert_v3f"].data.typeId(), IECore.V3fVectorData.staticTypeId() ) - - self.assertEqual( result["vertString"].data.typeId(), IECore.TypeId.StringVectorData ) - self.assertEqual( result["vertString"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result["vertString"].indices.typeId(), IECore.TypeId.IntVectorData ) - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) : - index = result["vertString"].indices[i] - self.assertEqual( index, i ) - self.assertEqual( result["vertString"].data[index], "string %06d!" % index ) - - # make sure the string tables are alphabetically sorted: - self.assertEqual( result["vertString2"].data, IECore.StringVectorData( ['a','b','c','d','e','f','g'] ) ) - stringVals = [ 'd','c','e','a','g','f','b' ] - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) : - index = result["vertString2"].indices[i] - self.assertEqual( result["vertString2"].data[ index ], stringVals[ i % 7 ] ) - - self.assertEqual( result["m44"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result["m44"].data.typeId(), IECore.M44fVectorData.staticTypeId() ) - - matrixScale, matrixShear, matrixRot, matrixTranslation = imath.V3f(), imath.V3f(), imath.V3f(), imath.V3f() - result["m44"].data[0].extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) - - self.assertEqual( matrixTranslation, imath.V3f( 10,20,30 ) ) - self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) - - self.assertEqual( result["detail_m44"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result["detail_m44"].data.typeId(), IECore.M44fData.staticTypeId() ) - - result["detail_m44"].data.value.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) - self.assertEqual( matrixTranslation, imath.V3f( 10,20,30 ) ) - self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) - - self.assertEqual( result["m33"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result["m33"].data.typeId(), IECore.M33fVectorData.staticTypeId() ) - - m3 = result["m33"].data[0] - m4 = imath.M44f( - m3[0][0], m3[0][1], m3[0][2], 0.0, - m3[1][0], m3[1][1], m3[1][2], 0.0, - m3[2][0], m3[2][1], m3[2][2], 0.0, - 0.0, 0.0, 0.0, 1.0 - ) - - m4.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) - self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) - - self.assertEqual( result["detail_m33"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result["detail_m33"].data.typeId(), IECore.M33fData.staticTypeId() ) - - m3 = result["detail_m33"].data.value - m4 = imath.M44f( - m3[0][0], m3[0][1], m3[0][2], 0.0, - m3[1][0], m3[1][1], m3[1][2], 0.0, - m3[2][0], m3[2][1], m3[2][2], 0.0, - 0.0, 0.0, 0.0, 1.0 - ) - - m4.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) - self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # convert some points - def testConvertPoints( self ) : - points = self.createPoints() - converter = IECoreHoudini.FromHoudiniPointsConverter( points ) - result = converter.convert() - self.assertEqual( result.typeId(), IECoreScene.PointsPrimitive.staticTypeId() ) - self.assertEqual( points.parm('npts').eval(), result.numPoints ) - self.assertTrue( "P" in result.keys() ) - self.assertTrue( "N" in result.keys() ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # simple attribute conversion - def testSetupAttributes( self ) : - points = self.createPoints() - geo = points.parent() - attr = geo.createNode( "attribcreate", exact_type_name=True ) - attr.setInput( 0, points ) - attr.parm("name").set( "test_attribute" ) - attr.parm("type").set(0) # float - attr.parm("size").set(1) # 1 element - attr.parm("value1").set(123.456) - attr.parm("value2").set(654.321) - converter = IECoreHoudini.FromHoudiniPointsConverter( attr ) - result = converter.convert() - self.assertTrue( "test_attribute" in result.keys() ) - self.assertEqual( result["test_attribute"].data.size(), points.parm('npts').eval() ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - return attr - - # testing point attributes and types - def testPointAttributes( self ) : - attr = self.testSetupAttributes() - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.FloatVectorData ) - self.assertTrue( result["test_attribute"].data[0] > 123.0 ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # integer - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.IntVectorData ) - self.assertEqual( result["test_attribute"].data[0], 123 ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(2) # 2 elementS - attr.parm("value2").set(456.789) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V2f( 123.456, 456.789 ) ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V2i( 123, 456 ) ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(3) # 3 elements - attr.parm("value3").set(999.999) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result["test_attribute"].data[0],imath.V3f( 123.456, 456.789, 999.999 ) ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V3i( 123, 456, 999 ) ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set( 3 ) # string - attr.parm( "string" ).setExpression("'string %06d!' % pwd().curPoint().number()", hou.exprLanguage.Python) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.StringVectorData ) - self.assertEqual( result["test_attribute"].data[10], "string 000010!" ) - self.assertEqual( result["test_attribute"].data.size(), 5000 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result["test_attribute"].indices[10], 10 ) - self.assertEqual( result["test_attribute"].indices.size(), 5000 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing detail attributes and types - def testDetailAttributes( self ) : - attr = self.testSetupAttributes() - attr.parm("class").set(0) # detail attribute - - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - attr.parm("value1").set(123.456) - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.FloatData ) - self.assertTrue( result["test_attribute"].data > IECore.FloatData( 123.0 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # integer - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.IntData ) - self.assertEqual( result["test_attribute"].data, IECore.IntData( 123 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(2) # 2 elementS - attr.parm("value2").set(456.789) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fData ) - self.assertEqual( result["test_attribute"].data.value, imath.V2f( 123.456, 456.789 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iData ) - self.assertEqual( result["test_attribute"].data.value, imath.V2i( 123, 456 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(3) # 3 elements - attr.parm("value3").set(999.999) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fData ) - self.assertEqual( result["test_attribute"].data.value, imath.V3f( 123.456, 456.789, 999.999 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result["test_attribute"].data.value, imath.V3i( 123, 456, 999 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set( 3 ) # string - attr.parm( "string" ).set( "string!" ) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.StringData ) - self.assertEqual( result["test_attribute"].data.value, "string!" ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing that float[4] doesn't work! - def testFloat4attr( self ) : # we can't deal with float 4's right now - attr = self.testSetupAttributes() - attr.parm("name").set( "test_attribute" ) - attr.parm("size").set(4) # 4 elements per point-attribute - converter = IECoreHoudini.FromHoudiniPointsConverter( attr ) - result = converter.convert() - self.assertTrue( "test_attribute" not in result.keys() ) # invalid due to being float[4] - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing conversion of animating geometry - def testAnimatingGeometry( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - facet = geo.createNode( "facet" ) - facet.parm("postnml").set(True) - mountain = geo.createNode( "mountain" ) - if hou.applicationVersion()[0] >= 16: - mountain.parm( "offsetx" ).setExpression( "$FF" ) - else: - mountain.parm("offset1").setExpression( "$FF" ) - points = geo.createNode( "scatter" ) - facet.setInput( 0, torus ) - mountain.setInput( 0, facet ) - points.setInput( 0, mountain ) - converter = IECoreHoudini.FromHoudiniPointsConverter( points ) - hou.setFrame(1) - points_1 = converter.convert() - hou.setFrame(2) - converter = IECoreHoudini.FromHoudiniPointsConverter( points ) - points_2 = converter.convert() - self.assertNotEqual( points_1["P"].data, points_2["P"].data ) - - # testing we can handle an object being deleted - def testObjectWasDeleted( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - converter = IECoreHoudini.FromHoudiniPointsConverter( torus ) - g1 = converter.convert() - torus.destroy() - g2 = converter.convert() - self.assertEqual( g2, g1 ) - self.assertRaises( RuntimeError, IECore.curry( IECoreHoudini.FromHoudiniPointsConverter, torus ) ) - - # testing we can handle an object being deleted - def testObjectWasDeletedFactory( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( torus ) - g1 = converter.convert() - torus.destroy() - g2 = converter.convert() - self.assertEqual( g2, g1 ) - self.assertRaises( RuntimeError, IECore.curry( IECoreHoudini.FromHoudiniGeometryConverter.create, torus ) ) - - # testing converting a Houdini particle primitive with detail and point attribs - def testParticlePrimitive( self ) : - obj = hou.node("/obj") - geo = obj.createNode( "geo", run_init_scripts=False ) - popnet = self.createPopNet() - location = popnet.createNode( "poplocation" ) - popSolver = popnet.node( "popsolver1" ) - popSolver.setInput( 2 , location ) - detailAttr = popnet.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm("name").set( "float3detail" ) - detailAttr.parm("class").set( 0 ) # detail - detailAttr.parm("type").set( 0 ) # float - detailAttr.parm("size").set( 3 ) # 3 elements - detailAttr.parm("value1").set( 1 ) - detailAttr.parm("value2").set( 2 ) - detailAttr.parm("value3").set( 3 ) - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm("name").set( "float3point" ) - pointAttr.parm("class").set( 2 ) # point - pointAttr.parm("type").set( 0 ) # float - pointAttr.parm("size").set( 3 ) # 3 elements - pointAttr.parm("value1").set( 1 ) - pointAttr.parm("value2").set( 2 ) - pointAttr.parm("value3").set( 3 ) - - hou.setFrame( 5 ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( pointAttr ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - points = converter.convert() - - self.assertEqual( type(points), IECoreScene.PointsPrimitive ) - self.assertEqual( points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 1043 ) - self.assertEqual( points["float3detail"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( type(points["float3detail"].data), IECore.V3fData ) - self.assertTrue( points["float3detail"].data.value.equalWithRelError( imath.V3f( 1, 2, 3 ), 1e-10 ) ) - self.assertEqual( type(points["float3point"].data), IECore.V3fVectorData ) - self.assertEqual( points["float3point"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - for p in points["float3point"].data : - self.assertTrue( p.equalWithRelError( imath.V3f( 1, 2, 3 ), 1e-10 ) ) - - self.assertTrue( points.arePrimitiveVariablesValid() ) - - add = pointAttr.createOutputNode( "add" ) - add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points - - converter = IECoreHoudini.FromHoudiniPointsConverter( add ) - points2 = converter.convert() - self.assertEqual( points2, points ) - - def testMultipleParticlePrimitives( self ) : - - obj = hou.node("/obj") - geo = obj.createNode( "geo", run_init_scripts=False ) - popnet = self.createPopNet() - fireworks = popnet.createNode( "popfireworks" ) - popSolver = popnet.node("popsolver1") - popSolver.setInput( 2, fireworks ) - - hou.setFrame( 28 ) - converter = IECoreHoudini.FromHoudiniPointsConverter( popnet ) - points = converter.convert() - - self.assertEqual( type(points), IECoreScene.PointsPrimitive ) - self.assertEqual( points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 24 ) - self.assertEqual( points["v"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( type(points["v"].data), IECore.V3fVectorData ) - self.assertEqual( points["v"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertEqual( points["nextid"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( points["nextid"].data, IECore.IntData( 24 ) ) - self.assertTrue( points.arePrimitiveVariablesValid() ) - - add = popnet.createOutputNode( "add" ) - add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points - - converter = IECoreHoudini.FromHoudiniPointsConverter( add ) - points2 = converter.convert() - # showing that prim attribs don't get converted because the interpolation size doesn't match - self.assertEqual( points2, points ) - - def testName( self ) : - - points = self.createPoints() - particles = points.createOutputNode( "add" ) - particles.parm( "addparticlesystem" ).set( True ) - name = particles.createOutputNode( "name" ) - name.parm( "name1" ).set( "points" ) - box = points.parent().createNode( "box" ) - name2 = box.createOutputNode( "name" ) - name2.parm( "name1" ).set( "box" ) - merge = name.createOutputNode( "merge" ) - merge.setInput( 1, name2 ) - - converter = IECoreHoudini.FromHoudiniPointsConverter( merge ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # both shapes were converted as one PointsPrimitive - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 5008 ) - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 1 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "points" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # only the named points were converted - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 5000 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "box", IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( converter, None ) - - def testAttributeFilter( self ) : - - points = self.createPoints() - particles = points.createOutputNode( "add" ) - particles.parm( "addparticlesystem" ).set( True ) - - # add vertex normals - facet = particles.createOutputNode( "facet", node_name = "add_point_normals" ) - facet.parm("postnml").set(True) - - # add a primitive colour attributes - primcol = facet.createOutputNode( "primitive", node_name = "prim_colour" ) - primcol.parm("doclr").set(1) - primcol.parm("diffr").setExpression("rand($PR)") - primcol.parm("diffg").setExpression("rand($PR+1)") - primcol.parm("diffb").setExpression("rand($PR+2)") - - detail = primcol.createOutputNode( "attribcreate", node_name = "detail", exact_type_name=True ) - detail.parm("name").set("detailAttr") - detail.parm("class").set(0) - detail.parm("type").set(1) - detail.parm("size").set(3) - detail.parm("value1").set(123) - detail.parm("value2").set(456.789) # can we catch it out with a float? - detail.parm("value3").set(789) - - converter = IECoreHoudini.FromHoudiniPointsConverter( detail ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "N", "P", "detailAttr", "varmap" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "P" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "* ^N ^varmap" ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "P", "detailAttr" ] ) - # P must be converted - converter.parameters()["attributeFilter"].setTypedValue( "* ^P" ) - self.assertTrue( "P" in converter.convert().keys() ) - - def testStandardAttributeConversion( self ) : - - points = self.createPoints() - color = points.createOutputNode( "color" ) - color.parm( "colortype" ).set( 2 ) - rest = color.createOutputNode( "rest" ) - scale = rest.createOutputNode( "attribcreate" ) - scale.parm( "name1" ).set( "pscale" ) - scale.parm( "value1v1" ).setExpression( "$PT" ) - - converter = IECoreHoudini.FromHoudiniPointsConverter( scale ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "N", "P", "Pref", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "N", "P", "Pref", "varmap", "width" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["Pref"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - converter["convertStandardAttributes"].setTypedValue( False ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cd", "N", "P", "pscale", "rest" ] ) - else : - self.assertEqual( result.keys(), [ "Cd", "N", "P", "pscale", "rest", "varmap" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["rest"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - def testZeroPointsWithStringAttribs( self ): - - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - null = geo.createNode( "null" ) - pointAttr = geo.createNode( "attribcreate", exact_type_name=True ) - pointAttr.setInput( 0, null ) - pointAttr.parm( "name" ).set( "test_attribute" ) - pointAttr.parm( "type" ).set( 3 ) - pointAttr.parm( "string" ).set( "test_string" ) - - converter = IECoreHoudini.FromHoudiniPointsConverter( pointAttr ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result.numPoints, 0 ) - self.assertEqual( result.keys(), [ "P", "test_attribute", "varmap" ] ) - self.assertEqual( result["P"].data, IECore.V3fVectorData( [], IECore.GeometricData.Interpretation.Point ) ) - self.assertEqual( result["test_attribute"].data, IECore.StringVectorData() ) - self.assertEqual( result["test_attribute"].indices, None ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/FromHoudiniPolygonsConverter.py b/test/IECoreHoudini/FromHoudiniPolygonsConverter.py deleted file mode 100644 index a6f17c6149..0000000000 --- a/test/IECoreHoudini/FromHoudiniPolygonsConverter.py +++ /dev/null @@ -1,1029 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestFromHoudiniPolygonsConverter( IECoreHoudini.TestCase ) : - - def createBox( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - - return box - - def createTorus( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - - return torus - - def createPoints( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - facet = geo.createNode( "facet" ) - facet.parm("postnml").set(True) - points = geo.createNode( "scatter" ) - points.parm( "npts" ).set( 5000 ) - facet.setInput( 0, box ) - points.setInput( 0, facet ) - - return points - - def createPopNet( self ): - obj = hou.node( '/obj' ) - geo = obj.createNode("geo", run_init_scripts=False) - popNet = geo.createNode("dopnet", "popnet" ) - popObject = popNet.createNode( "popobject" ) - popSolver = popObject.createOutputNode( "popsolver" ) - output = popSolver.createOutputNode( "output" ) - output.setDisplayFlag( True ) - - return popNet - - # creates a converter - def testCreateConverter( self ) : - box = self.createBox() - converter = IECoreHoudini.FromHoudiniPolygonsConverter( box ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - return converter - - # creates a converter - def testFactory( self ) : - box = self.createBox() - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( box ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( box, resultType = IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( box, resultType = IECore.TypeId.Parameter ) - self.assertEqual( converter, None ) - - self.assertTrue( IECoreScene.TypeId.MeshPrimitive in IECoreHoudini.FromHoudiniGeometryConverter.supportedTypes() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.createDummy( [ IECoreScene.TypeId.MeshPrimitive ] ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - # performs geometry conversion - def testDoConversion( self ) : - converter = self.testCreateConverter() - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - - def testConvertFromHOMGeo( self ) : - geo = self.createBox().geometry() - converter = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - - converter2 = IECoreHoudini.FromHoudiniGeometryConverter.createFromGeo( geo, IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter2.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - ## \todo: make sure we catch that bad_cast crash - - # convert a mesh - def testConvertMesh( self ) : - - torus = self.createTorus() - converter = IECoreHoudini.FromHoudiniPolygonsConverter( torus ) - result = converter.convert() - self.assertEqual( result.typeId(), IECoreScene.MeshPrimitive.staticTypeId() ) - - bbox = result.bound() - self.assertEqual( bbox.min().x, -1.5 ) - self.assertEqual( bbox.max().x, 1.5 ) - - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 100 ) - self.assertEqual( result.numFaces(), 100 ) - - self.assertEqual( len( result.verticesPerFace ), 100 ) - for i in range( len( result.verticesPerFace ) ) : - self.assertEqual( result.verticesPerFace[i], 4 ) - - self.assertEqual( len( result.vertexIds ), 400 ) - for i in range( len( result.vertexIds ) ) : - self.assertTrue( result.vertexIds[i] >= 0 ) - self.assertTrue( result.vertexIds[i] < 100 ) - - # test prim/vertex attributes - def testConvertPrimVertAttributes( self ) : - torus = self.createTorus() - geo = torus.parent() - - # add vertex normals - facet = geo.createNode( "facet", node_name = "add_point_normals" ) - facet.parm("postnml").set(True) - facet.setInput( 0, torus ) - - # add a primitive colour attributes - primcol = geo.createNode( "primitive", node_name = "prim_colour" ) - primcol.parm("doclr").set(1) - primcol.parm("diffr").setExpression("rand($PR)") - primcol.parm("diffg").setExpression("rand($PR+1)") - primcol.parm("diffb").setExpression("rand($PR+2)") - primcol.setInput( 0, facet ) - - # add a load of different vertex attributes - vert_f1 = geo.createNode( "attribcreate", node_name = "vert_f1", exact_type_name=True ) - vert_f1.parm("name").set("vert_f1") - vert_f1.parm("class").set(3) - vert_f1.parm("value1").setExpression("$VTX*0.1") - vert_f1.setInput( 0, primcol ) - - vert_f2 = geo.createNode( "attribcreate", node_name = "vert_f2", exact_type_name=True ) - vert_f2.parm("name").set("vert_f2") - vert_f2.parm("class").set(3) - vert_f2.parm("size").set(2) - vert_f2.parm("value1").setExpression("$VTX*0.1") - vert_f2.parm("value2").setExpression("$VTX*0.1") - vert_f2.setInput( 0, vert_f1 ) - - vert_f3 = geo.createNode( "attribcreate", node_name = "vert_f3", exact_type_name=True ) - vert_f3.parm("name").set("vert_f3") - vert_f3.parm("class").set(3) - vert_f3.parm("size").set(3) - vert_f3.parm("value1").setExpression("$VTX*0.1") - vert_f3.parm("value2").setExpression("$VTX*0.1") - vert_f3.parm("value3").setExpression("$VTX*0.1") - vert_f3.setInput( 0, vert_f2 ) - - vert_i1 = geo.createNode( "attribcreate", node_name = "vert_i1", exact_type_name=True ) - vert_i1.parm("name").set("vert_i1") - vert_i1.parm("class").set(3) - vert_i1.parm("type").set(1) - vert_i1.parm("value1").setExpression("$VTX*0.1") - vert_i1.setInput( 0, vert_f3 ) - - vert_i2 = geo.createNode( "attribcreate", node_name = "vert_i2", exact_type_name=True ) - vert_i2.parm("name").set("vert_i2") - vert_i2.parm("class").set(3) - vert_i2.parm("type").set(1) - vert_i2.parm("size").set(2) - vert_i2.parm("value1").setExpression("$VTX*0.1") - vert_i2.parm("value2").setExpression("$VTX*0.1") - vert_i2.setInput( 0, vert_i1 ) - - vert_i3 = geo.createNode( "attribcreate", node_name = "vert_i3", exact_type_name=True ) - vert_i3.parm("name").set("vert_i3") - vert_i3.parm("class").set(3) - vert_i3.parm("type").set(1) - vert_i3.parm("size").set(3) - vert_i3.parm("value1").setExpression("$VTX*0.1") - vert_i3.parm("value2").setExpression("$VTX*0.1") - vert_i3.parm("value3").setExpression("$VTX*0.1") - vert_i3.setInput( 0, vert_i2 ) - - vert_v3f = geo.createNode( "attribcreate", node_name = "vert_v3f", exact_type_name=True ) - vert_v3f.parm("name").set("vert_v3f") - vert_v3f.parm("class").set(3) - vert_v3f.parm("type").set(2) - vert_v3f.parm("value1").setExpression("$VTX*0.1") - vert_v3f.parm("value2").setExpression("$VTX*0.1") - vert_v3f.parm("value3").setExpression("$VTX*0.1") - vert_v3f.setInput( 0, vert_i3 ) - - vertString = geo.createNode( "attribcreate", node_name = "vertString", exact_type_name=True ) - vertString.parm("name").set("vertString") - vertString.parm("class").set(3) - vertString.parm("type").set(3) - vertString.parm("string").set("string $VTX!") - vertString.setInput( 0, vert_v3f ) - - detail_i3 = geo.createNode( "attribcreate", node_name = "detail_i3", exact_type_name=True ) - detail_i3.parm("name").set("detail_i3") - detail_i3.parm("class").set(0) - detail_i3.parm("type").set(1) - detail_i3.parm("size").set(3) - detail_i3.parm("value1").set(123) - detail_i3.parm("value2").set(456.789) # can we catch it out with a float? - detail_i3.parm("value3").set(789) - detail_i3.setInput( 0, vertString ) - - out = geo.createNode( "null", node_name="OUT" ) - out.setInput( 0, detail_i3 ) - - # convert it all - converter = IECoreHoudini.FromHoudiniPolygonsConverter( out ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - - result = converter.convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - - bbox = result.bound() - self.assertEqual( bbox.min().x, -1.5 ) - self.assertEqual( bbox.max().x, 1.5 ) - - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 100 ) - self.assertEqual( result.numFaces(), 100 ) - - self.assertEqual( len( result.verticesPerFace ), 100 ) - for i in range( len( result.verticesPerFace ) ) : - self.assertEqual( result.verticesPerFace[i], 4 ) - - self.assertEqual( len( result.vertexIds ), 400 ) - for i in range( len( result.vertexIds ) ) : - self.assertTrue( result.vertexIds[i] >= 0 ) - self.assertTrue( result.vertexIds[i] < 100 ) - - # test point attributes - self.assertTrue( "P" in result ) - self.assertEqual( result['P'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['P'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['P'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( "N" in result ) - self.assertEqual( result['N'].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result['N'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result['N'].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) - self.assertEqual( result["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - # test detail attributes - self.assertTrue( "detail_i3" in result ) - self.assertEqual( result['detail_i3'].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result['detail_i3'].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( result['detail_i3'].data.value.x, 123 ) - self.assertEqual( result['detail_i3'].data.value.y, 456 ) - self.assertEqual( result['detail_i3'].data.value.z, 789 ) - - # test primitive attributes - self.assertTrue( "Cs" in result ) - self.assertEqual( result["Cs"].data.typeId(), IECore.TypeId.Color3fVectorData ) - self.assertEqual( result["Cs"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - self.assertEqual( result["Cs"].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) : - for j in range( 0, 3 ) : - self.assertTrue( result["Cs"].data[i][j] >= 0.0 ) - self.assertTrue( result["Cs"].data[i][j] <= 1.0 ) - - # test vertex attributes - attrs = [ "vert_f1", "vert_f2", "vert_f3", "vert_i1", "vert_i2", "vert_i3", "vert_v3f" ] - for a in attrs : - self.assertTrue( a in result ) - self.assertEqual( result[a].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( result[a].data.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) - - # test indexed vertex attributes - for a in [ "vertString" ] : - self.assertTrue( a in result ) - self.assertEqual( result[a].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( result[a].indices.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) - - self.assertEqual( result["vert_f1"].data.typeId(), IECore.FloatVectorData.staticTypeId() ) - self.assertEqual( result["vert_f2"].data.typeId(), IECore.V2fVectorData.staticTypeId() ) - self.assertEqual( result["vert_f3"].data.typeId(), IECore.V3fVectorData.staticTypeId() ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) : - for j in range( 0, 3 ) : - self.assertTrue( result["vert_f3"].data[i][j] >= 0.0 ) - self.assertTrue( result["vert_f3"].data[i][j] < 0.4 ) - - self.assertEqual( result["vert_i1"].data.typeId(), IECore.IntVectorData.staticTypeId() ) - self.assertEqual( result["vert_i2"].data.typeId(), IECore.V2iVectorData.staticTypeId() ) - self.assertEqual( result["vert_i3"].data.typeId(), IECore.V3iVectorData.staticTypeId() ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) : - for j in range( 0, 3 ) : - self.assertEqual( result["vert_i3"].data[i][j], 0 ) - - self.assertEqual( result["vert_v3f"].data.typeId(), IECore.V3fVectorData.staticTypeId() ) - - self.assertEqual( result["vertString"].data.typeId(), IECore.TypeId.StringVectorData ) - self.assertEqual( result["vertString"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( result["vertString"].data.size(), 4 ) - self.assertEqual( result["vertString"].indices.typeId(), IECore.TypeId.IntVectorData ) - - for i in range( 0, result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) : - index = result["vertString"].indices[ result.vertexIds[i] ] - self.assertEqual( result["vertString"].data[ index ], "string %d!" % index ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - - def testConvertNull( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - null = geo.createNode( "null" ) - m = IECoreHoudini.FromHoudiniPolygonsConverter( null ).convert() - self.assertTrue( isinstance( m, IECoreScene.MeshPrimitive ) ) - self.assertEqual( m, IECoreScene.MeshPrimitive() ) - - # convert some points - def testConvertPoints( self ) : - points = self.createPoints() - m = IECoreHoudini.FromHoudiniPolygonsConverter( points ).convert() - self.assertTrue( isinstance( m, IECoreScene.MeshPrimitive ) ) - self.assertEqual( m, IECoreScene.MeshPrimitive() ) - - # simple attribute conversion - def testSetupAttributes( self ) : - torus = self.createTorus() - geo = torus.parent() - attr = geo.createNode( "attribcreate", exact_type_name=True ) - attr.setInput( 0, torus ) - attr.parm("name").set( "test_attribute" ) - attr.parm("type").set(0) # float - attr.parm("size").set(1) # 1 element - attr.parm("value1").set(123.456) - attr.parm("value2").set(654.321) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( attr ) - result = converter.convert() - self.assertTrue( "test_attribute" in result.keys() ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - return attr - - # testing point attributes and types - def testPointAttributes( self ) : - attr = self.testSetupAttributes() - - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - attr.parm("value1").set(123.456) - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.FloatVectorData ) - self.assertTrue( result["test_attribute"].data[0] > 123.0 ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # integer - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.IntVectorData ) - self.assertEqual( result["test_attribute"].data[0], 123 ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(2) # 2 elementS - attr.parm("value2").set(456.789) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V2f( 123.456, 456.789 ) ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V2i( 123, 456 ) ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(3) # 3 elements - attr.parm("value3").set(999.999) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result["test_attribute"].data[0],imath.V3f( 123.456, 456.789, 999.999 ) ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iVectorData ) - self.assertEqual( result["test_attribute"].data[0], imath.V3i( 123, 456, 999 ) ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set( 3 ) # string - attr.parm( "string" ).setExpression("'string %06d!' % pwd().curPoint().number()", hou.exprLanguage.Python) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.StringVectorData ) - self.assertEqual( result["test_attribute"].data[10], "string 000010!" ) - self.assertEqual( result["test_attribute"].data.size(), 100 ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( result["test_attribute"].indices[10], 10 ) - self.assertEqual( result["test_attribute"].indices.size(), 100 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing detail attributes and types - def testDetailAttributes( self ) : - attr = self.testSetupAttributes() - attr.parm("class").set(0) # detail attribute - - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - attr.parm("value1").set(123.456) - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.FloatData ) - self.assertTrue( result["test_attribute"].data > IECore.FloatData( 123.0 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # integer - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.IntData ) - self.assertEqual( result["test_attribute"].data, IECore.IntData( 123 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(2) # 2 elementS - attr.parm("value2").set(456.789) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fData ) - self.assertEqual( result["test_attribute"].data.value, imath.V2f( 123.456, 456.789 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iData ) - self.assertEqual( result["test_attribute"].data.value, imath.V2i( 123, 456 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(0) # float - attr.parm("size").set(3) # 3 elements - attr.parm("value3").set(999.999) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fData ) - self.assertEqual( result["test_attribute"].data.value, imath.V3f( 123.456, 456.789, 999.999 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set(1) # int - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result["test_attribute"].data.value, imath.V3i( 123, 456, 999 ) ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - attr.parm("type").set( 3 ) # string - attr.parm( "string" ).set( "string!" ) - result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() - self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.StringData ) - self.assertEqual( result["test_attribute"].data.value, "string!" ) - self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing that float[4] doesn't work! - def testFloat4attr( self ) : # we can't deal with float 4's right now - attr = self.testSetupAttributes() - attr.parm("name").set( "test_attribute" ) - attr.parm("size").set(4) # 4 elements per point-attribute - converter = IECoreHoudini.FromHoudiniPolygonsConverter( attr ) - result = converter.convert() - self.assertTrue( "test_attribute" not in result.keys() ) # invalid due to being float[4] - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # testing conversion of animating geometry - def testAnimatingGeometry( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - torus = geo.createNode( "torus" ) - facet = geo.createNode( "facet" ) - facet.parm("postnml").set(True) - mountain = geo.createNode( "mountain" ) - if hou.applicationVersion()[0] >= 16: - mountain.parm( "offsetx" ).setExpression( "$FF" ) - else: - mountain.parm("offset1").setExpression( "$FF" ) - facet.setInput( 0, torus ) - mountain.setInput( 0, facet ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( mountain ) - hou.setFrame( 1 ) - mesh1 = converter.convert() - hou.setFrame( 2 ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( mountain ) - mesh2 = converter.convert() - self.assertNotEqual( mesh1["P"].data, mesh2["P"].data ) - self.assertNotEqual( mesh1, mesh2 ) - - # testing we can handle an object being deleted - def testObjectWasDeleted( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( torus ) - g1 = converter.convert() - torus.destroy() - g2 = converter.convert() - self.assertEqual( g2, g1 ) - self.assertRaises( RuntimeError, IECore.curry( IECoreHoudini.FromHoudiniPolygonsConverter, torus ) ) - - # testing we can handle an object being deleted - def testObjectWasDeletedFactory( self ) : - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - torus = geo.createNode( "torus" ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( torus ) - g1 = converter.convert() - torus.destroy() - g2 = converter.convert() - self.assertEqual( g2, g1 ) - self.assertRaises( RuntimeError, IECore.curry( IECoreHoudini.FromHoudiniGeometryConverter.create, torus ) ) - - # testing converting a Houdini particle primitive with detail and point attribs - def testParticlePrimitive( self ) : - obj = hou.node("/obj") - geo = obj.createNode( "geo", run_init_scripts=False ) - popnet = self.createPopNet() - location = popnet.createNode( "poplocation" ) - popSolver = popnet.node( "popsolver1" ) - popSolver.setInput( 2, location ) - detailAttr = popnet.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm("name").set( "float3detail" ) - detailAttr.parm("class").set( 0 ) # detail - detailAttr.parm("type").set( 0 ) # float - detailAttr.parm("size").set( 3 ) # 3 elements - detailAttr.parm("value1").set( 1 ) - detailAttr.parm("value2").set( 2 ) - detailAttr.parm("value3").set( 3 ) - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm("name").set( "float3point" ) - pointAttr.parm("class").set( 2 ) # point - pointAttr.parm("type").set( 0 ) # float - pointAttr.parm("size").set( 3 ) # 3 elements - pointAttr.parm("value1").set( 1 ) - pointAttr.parm("value2").set( 2 ) - pointAttr.parm("value3").set( 3 ) - - particleSystem = pointAttr.createOutputNode( "add" ) - particleSystem.parm( "addparticlesystem" ).set( True ) - - hou.setFrame( 5 ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( particleSystem ) - self.assertRaises( RuntimeError, converter.convert ) - - add = particleSystem.createOutputNode( "add" ) - add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points - - m = IECoreHoudini.FromHoudiniPolygonsConverter( add ).convert() - self.assertTrue( isinstance( m, IECoreScene.MeshPrimitive ) ) - self.assertEqual( m, IECoreScene.MeshPrimitive() ) - - # testing winding order - def testWindingOrder( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - grid = geo.createNode( "grid" ) - grid.parm( "rows" ).set( 2 ) - grid.parm( "cols" ).set( 2 ) - - mesh = IECoreHoudini.FromHoudiniPolygonsConverter( grid ).convert() - p = mesh["P"].data - vertexIds = mesh.vertexIds - self.assertEqual( vertexIds.size(), 4 ) - - loop = IECore.V3fVectorData( [ p[vertexIds[0]], p[vertexIds[1]], p[vertexIds[2]], p[vertexIds[3]] ] ) - self.assertTrue( IECore.polygonNormal( loop ).equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.0001 ) ) - - # testing vertex data order - def testVertexDataOrder( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - grid = geo.createNode( "grid" ) - grid.parm( "rows" ).set( 2 ) - grid.parm( "cols" ).set( 2 ) - attr = grid.createOutputNode( "attribcreate", exact_type_name=True ) - attr.parm("name").set( "vertex" ) - attr.parm("class").set( 3 ) # vertex - attr.parm("type").set( 0 ) # float - attr.parm("value1").setExpression( "$VTX" ) - - mesh = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertEqual( mesh["vertex"].data, IECore.FloatVectorData( [ 3, 2, 1, 0 ] ) ) - - def testEmptyStringAttr( self ) : - torus = self.createTorus() - geo = torus.parent() - attr = geo.createNode( "attribcreate", exact_type_name=True ) - attr.setInput( 0, torus ) - attr.parm("name").set( "test_attribute" ) - attr.parm("type").set(3) # string - attr.parm("string").set("") - converter = IECoreHoudini.FromHoudiniPolygonsConverter( attr ) - result = converter.convert() - self.assertTrue( "test_attribute" in result.keys() ) - self.assertEqual( result["test_attribute"].data.size(), 1 ) - self.assertEqual( result["test_attribute"].indices.size(), 100 ) - self.assertEqual( result["test_attribute"].data[0], "" ) - for i in range( 0, 100 ) : - self.assertEqual( result["test_attribute"].indices[i], 0 ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - - def testName( self ) : - - torus = self.createTorus() - name = torus.createOutputNode( "name" ) - name.parm( "name1" ).set( "torus" ) - box = torus.parent().createNode( "box" ) - name2 = box.createOutputNode( "name" ) - name2.parm( "name1" ).set( "box" ) - merge = name.createOutputNode( "merge" ) - merge.setInput( 1, name2 ) - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( merge ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # both torii were converted as one mesh - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 106 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "torus" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # only the named polygons were converted - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "box" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - result = converter.convert() - # names are not stored on the object at all - self.assertEqual( result.blindData(), IECore.CompoundData() ) - self.assertFalse( "name" in result ) - # only the named polygons were converted - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - # the name filter will create a single MeshPrimitive - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( merge, "*" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - result = converter.convert() - - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 106 ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - - def testAttributeFilter( self ) : - - torus = self.createTorus() - - # add vertex normals - facet = torus.createOutputNode( "facet", node_name = "add_point_normals" ) - facet.parm("postnml").set(True) - - # add a primitive colour attributes - primcol = facet.createOutputNode( "primitive", node_name = "prim_colour" ) - primcol.parm("doclr").set(1) - primcol.parm("diffr").setExpression("rand($PR)") - primcol.parm("diffg").setExpression("rand($PR+1)") - primcol.parm("diffb").setExpression("rand($PR+2)") - - detail = primcol.createOutputNode( "attribcreate", node_name = "detail", exact_type_name=True ) - detail.parm("name").set("detailAttr") - detail.parm("class").set(0) - detail.parm("type").set(1) - detail.parm("size").set(3) - detail.parm("value1").set(123) - detail.parm("value2").set(456.789) # can we catch it out with a float? - detail.parm("value3").set(789) - - uvunwrap = detail.createOutputNode( "uvunwrap" ) - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( uvunwrap ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "N", "P", "detailAttr", "uv", "varmap" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "P" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "* ^N ^varmap" ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "P", "detailAttr", "uv" ] ) - # P must be converted - converter.parameters()["attributeFilter"].setTypedValue( "* ^P" ) - self.assertTrue( "P" in converter.convert().keys() ) - # have to filter the source attr - converter.parameters()["attributeFilter"].setTypedValue( "Cs" ) - self.assertEqual( sorted(converter.convert().keys()), [ "P" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "Cd" ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "P" ] ) - converter.parameters()["attributeFilter"].setTypedValue( "uv Cd" ) - self.assertEqual( sorted(converter.convert().keys()), [ "Cs", "P", "uv" ] ) - - def testStandardAttributeConversion( self ) : - - torus = self.createTorus() - color = torus.createOutputNode( "color" ) - color.parm( "colortype" ).set( 2 ) - rest = color.createOutputNode( "rest" ) - scale = rest.createOutputNode( "attribcreate" ) - scale.parm( "name1" ).set( "pscale" ) - scale.parm( "value1v1" ).setExpression( "$PT" ) - uvunwrap = scale.createOutputNode( "uvunwrap" ) - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( uvunwrap ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "width" ] ) - else : - self.assertEqual( result.keys(), [ "Cs", "P", "Pref", "uv", "varmap", "width" ] ) - - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["Pref"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - converter["convertStandardAttributes"].setTypedValue( False ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "Cd", "P", "pscale", "rest", "uv" ] ) - else : - self.assertEqual( result.keys(), [ "Cd", "P", "pscale", "rest", "uv", "varmap" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( result["rest"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - def testWeldUVs( self ) : - - torus = self.createTorus() - uvunwrap = torus.createOutputNode( "uvunwrap" ) - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( uvunwrap ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "P", "uv" ] ) - else : - self.assertEqual( result.keys(), [ "P", "uv", "varmap" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - self.assertEqual( result["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - converter["weldUVs"].setTypedValue( False ) - result = converter.convert() - if hou.applicationVersion()[0] >= 15 : - self.assertEqual( result.keys(), [ "P", "uv" ] ) - else : - self.assertEqual( result.keys(), [ "P", "uv", "varmap" ] ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - self.assertEqual( result["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - - uvData = result["uv"].data - self.assertEqual( result["uv"].indices, None ) - - geo = uvunwrap.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[i][0], uvValues[0] ) - self.assertAlmostEqual( uvData[i][1], uvValues[1] ) - i += 1 - - def testInterpolation( self ) : - - torus = self.createTorus() - normals = torus.createOutputNode( "facet" ) - normals.parm( "postnml" ).set( True ) - result = IECoreHoudini.FromHoudiniPolygonsConverter( normals ).convert() - self.assertTrue( "ieMeshInterpolation" not in result.keys() ) - self.assertEqual( result.interpolation, "linear" ) - self.assertTrue( "N" in result.keys() ) - - attr = normals.createOutputNode( "attribcreate", node_name = "interpolation", exact_type_name=True ) - attr.parm( "name" ).set( "ieMeshInterpolation" ) - attr.parm( "class" ).set( 1 ) # prim - attr.parm( "type" ).set( 3 ) # string - attr.parm( "string") .set( "subdiv" ) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertTrue( "ieMeshInterpolation" not in result.keys() ) - self.assertEqual( result.interpolation, "catmullClark" ) - self.assertTrue( "N" not in result.keys() ) - - attr.parm( "string") .set( "poly" ) - result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() - self.assertTrue( "ieMeshInterpolation" not in result.keys() ) - self.assertEqual( result.interpolation, "linear" ) - self.assertTrue( "N" in result.keys() ) - - def testRename( self ) : - - torus = self.createTorus() - name = torus.createOutputNode( "name" ) - name.parm( "name1" ).set( "foo" ) - rename = name.createOutputNode( "name" ) - rename.parm( "name1" ).set( "bar" ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( rename ) - self.assertTrue( isinstance( converter, IECoreHoudini.FromHoudiniPolygonsConverter ) ) - self.assertTrue( isinstance( converter.convert(), IECoreScene.MeshPrimitive ) ) - - - def testRenamedUVsExportedWithInterpretation( self ): - - box = self.createBox() # create cube geometry - quickShade = box.createOutputNode("uvquickshade") # quickly generate orthographically projected UVs - attribute = quickShade.createOutputNode("attribute") # rename the 'uv' attribute 'foo' - attribute.parm("frompt0").set("uv") - attribute.parm("topt0").set("foo") - - convertToCortex = attribute.createOutputNode("ieCortexConverter") - convertToCortex.parm("resultType").set(0) # convert to cortex - convertToHoudini = convertToCortex.createOutputNode("ieCortexConverter") - convertToHoudini.parm("resultType").set(1) # convert to back to houdini - - geo = convertToHoudini.geometry() - fooAttrib = geo.findPointAttrib( "foo" ) - - self.assertEqual( fooAttrib.qualifier(), "Texture Coord") - - roundTrippedUVs = [] - index = 0 - for pnt in geo.points() : - roundTrippedUVs.append( pnt.attribValue( fooAttrib ) ) - - self.assertEqual( roundTrippedUVs, [ - (0.0, 0.0, 0.0), - (1.0, 0.0, 0.0), - (1.0, 1.0, 0.0), - (0.0, 1.0, 0.0), - (0.0, 0.0, 0.0), - (1.0, 0.0, 0.0), - (1.0, 1.0, 0.0), - (0.0, 1.0, 0.0)] ) - - def testAttributeNamedUVIsAlwaysIndexed( self ): - - box = self.createBox() # create cube geometry - attributeCreate = box.createOutputNode("attribcreate", exact_type_name=True) - attributeCreate.parm("class").set(3) # vertex - attributeCreate.parm("type").set(0) #float - attributeCreate.parm("typeinfo").set(1) # None - attributeCreate.parm("name").set("uv") #attribute is named uv - attributeCreate.parm("size").set(3) #float3 - - result = IECoreHoudini.FromHoudiniPolygonsConverter( attributeCreate ).convert() - - self.assertEqual( result["uv"].data, IECore.V2fVectorData( [imath.V2f( 0, 0 )], IECore.GeometricData.Interpretation.UV ) ) - self.assertEqual( result["uv"].indices, IECore.IntVectorData( [0] * 24 ) ) - - def testCornersAndCreases( self ): - - box = self.createBox() # create cube geometry - crease = box.createOutputNode("crease", exact_type_name=True) - crease.parm("group").set("p5-6 p4-5-1") - crease.parm("crease").set(1.29) - dodgyCorner = crease.createOutputNode("crease", exact_type_name=True) - dodgyCorner.parm("group").set("p7") - dodgyCorner.parm("crease").set(10.0) - dodgyCorner.parm("creaseattrib").set("cornerweight") - corner = dodgyCorner.createOutputNode("attribpromote", exact_type_name=True) - corner.parm("inname").set("cornerweight") - corner.parm("inclass").set(3) # vertex - corner.parm("method").set(1) # minimum (to avoid interpolation) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( corner ).convert() - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result.keys(), [ "P" ] ) - - self.assertEqual( result.cornerIds(), IECore.IntVectorData( [ 7 ] ) ) - self.assertEqual( result.cornerSharpnesses(), IECore.FloatVectorData( [ 10.0 ] ) ) - - self.assertEqual( result.creaseLengths(), IECore.IntVectorData( [ 2, 2, 2 ] ) ) - self.assertEqual( result.creaseIds(), IECore.IntVectorData( [ 1, 5, 4, 5, 5, 6 ] ) ) - self.assertEqual( result.creaseSharpnesses(), IECore.FloatVectorData( [ 1.29, 1.29, 1.29 ] ) ) - - def testMeshInterpolationCrash( self ): - - subnet = hou.node("/obj").createNode("subnet") - geo = subnet.createNode( "geo", "geo" ) - - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 1000 ) - torus.parm( "cols" ).set( 1000 ) - - grouprange = torus.createOutputNode( "grouprange" ) - grouprange.parm( "groupname1" ).set( "mygroup" ) - grouprange.parm( "end1" ).set(50) - - name1 = grouprange.createOutputNode( "name" ) - name1.parm( "numnames" ).set( 2 ) - name1.parm( "name1" ).set( "/torus/all/of/it" ) - name1.parm( "name2" ).set( "/torus/part/of/it" ) - name1.parm( "group2" ).set( "mygroup" ) - - name2 = name1.createOutputNode( "name" ) - name2.parm( "attribname" ).set( "ieMeshInterpolation" ) - name2.parm( "numnames" ).set( 2 ) - name2.parm( "name1" ).set( "poly" ) - name2.parm( "name2" ).set( "subdiv" ) - name2.parm( "group2" ).set( "mygroup" ) - - groupdelete = name2.createOutputNode( "groupdelete" ) - groupdelete.parm( "group1" ).set( "mygroup" ) - - objectMerge = geo.createNode( "object_merge" ) - objectMerge.parm( "objpath1" ).set( groupdelete.path() ) - objectMerge.parm( "group1" ).set( "@name=/torus/part/of/it" ) - objectMerge.parm( "xformtype" ).set( 1 ) - - name3 = objectMerge.createOutputNode( "name" ) - name3.parm( "name1" ).set( "/" ) - name3.setDisplayFlag( True ) - name3.setRenderFlag( True ) - - result = IECoreHoudini.FromHoudiniGeometryConverter.create( hou.node( '/obj/subnet1/geo/name3' ) ).convert() - self.assertTrue( isinstance( result, IECoreScene.MeshPrimitive ) ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/LiveSceneTest.py b/test/IECoreHoudini/LiveSceneTest.py deleted file mode 100644 index 71032ab6f5..0000000000 --- a/test/IECoreHoudini/LiveSceneTest.py +++ /dev/null @@ -1,1384 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import hou -import imath - -import IECore -import IECoreScene -import IECoreHoudini - -class LiveSceneTest( IECoreHoudini.TestCase ) : - - def buildScene( self ) : - - obj = hou.node( "/obj" ) - sub1 = obj.createNode( "subnet", "sub1" ) - sub2 = obj.createNode( "subnet", "sub2" ) - box1 = sub1.createOutputNode( "geo", "box1", run_init_scripts=False ) - box1.createNode( "box", "actualBox" ) - actualBox = box1.children()[0] - bname = actualBox.createOutputNode( "name" ) - bname.parm( "name1" ).set( "/" ) - torus = box1.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - tname = torus.createOutputNode( "name" ) - tname.parm( "name1" ).set( "/gap/torus" ) - merge = bname.createOutputNode( "merge" ) - merge.setInput( 1, tname ) - merge.setRenderFlag( True ) - box2 = obj.createNode( "geo", "box2", run_init_scripts=False ) - box2.createNode( "box", "actualBox" ) - torus1 = sub1.createNode( "geo", "torus1", run_init_scripts=False ) - actualTorus1 = torus1.createNode( "torus", "actualTorus" ) - actualTorus1.parm( "rows" ).set( 10 ) - actualTorus1.parm( "cols" ).set( 10 ) - torus2 = torus1.createOutputNode( "geo", "torus2", run_init_scripts=False ) - actualTorus2 = torus2.createNode( "torus", "actualTorus" ) - actualTorus2.parm( "rows" ).set( 10 ) - actualTorus2.parm( "cols" ).set( 10 ) - - return IECoreHoudini.LiveScene() - - def testChildNames( self ) : - - scene = self.buildScene() - self.assertEqual( sorted( scene.childNames() ), [ "box2", "sub1", "sub2" ] ) - - child = scene.child( "sub1" ) - self.assertEqual( sorted( child.childNames() ), [ "box1", "torus1" ] ) - - child2 = child.child( "torus1" ) - self.assertEqual( sorted( child2.childNames() ), [ "torus2" ] ) - - child3 = child2.child( "torus2" ) - self.assertEqual( sorted( child3.childNames() ), [] ) - - box1 = child.child( "box1" ) - self.assertEqual( sorted( box1.childNames() ), [ "gap" ] ) - - gap = box1.child( "gap" ) - self.assertEqual( sorted( gap.childNames() ), [ "torus" ] ) - - self.assertEqual( gap.child( "torus" ).childNames(), [] ) - self.assertEqual( scene.child( "box2" ).childNames(), [] ) - self.assertEqual( scene.child( "sub2" ).childNames(), [] ) - - def testIndirectInputs( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1/torus1" ).setInput( 0, hou.node( "/obj/sub1" ).indirectInputs()[0] ) - - self.assertEqual( sorted( scene.childNames() ), [ "box2", "sub1", "sub2" ] ) - - child = scene.child( "sub1" ) - self.assertEqual( sorted( child.childNames() ), [ "box1", "torus1" ] ) - - child2 = child.child( "torus1" ) - self.assertEqual( sorted( child2.childNames() ), [ "torus2" ] ) - - child3 = child2.child( "torus2" ) - self.assertEqual( sorted( child3.childNames() ), [] ) - - box1 = child.child( "box1" ) - self.assertEqual( sorted( box1.childNames() ), [ "gap" ] ) - - gap = box1.child( "gap" ) - self.assertEqual( sorted( gap.childNames() ), [ "torus" ] ) - - self.assertEqual( gap.child( "torus" ).childNames(), [] ) - self.assertEqual( scene.child( "box2" ).childNames(), [] ) - self.assertEqual( scene.child( "sub2" ).childNames(), [] ) - - def testHasChild( self ) : - - scene = self.buildScene() - self.assertEqual( scene.hasChild( "box2" ), True ) - self.assertEqual( scene.hasChild( "sub1" ), True ) - self.assertEqual( scene.hasChild( "sub2" ), True ) - self.assertEqual( scene.hasChild( "fake" ), False ) - - child = scene.child( "sub1" ) - self.assertEqual( child.hasChild( "torus1" ), True ) - self.assertEqual( child.hasChild( "torus2" ), False ) - self.assertEqual( child.child( "torus1" ).hasChild( "torus2" ), True ) - self.assertEqual( child.hasChild( "fake" ), False ) - - self.assertEqual( child.hasChild( "box1" ), True ) - self.assertEqual( child.child( "box1" ).hasChild( "gap" ), True ) - self.assertEqual( child.child( "box1" ).hasChild( "torus" ), False ) - self.assertEqual( child.child( "box1" ).child( "gap" ).hasChild( "torus" ), True ) - - def testNames( self ) : - - scene = self.buildScene() - self.assertEqual( scene.name(), "/" ) - self.assertEqual( scene.child( "box2" ).name(), "box2" ) - self.assertEqual( scene.child( "sub2" ).name(), "sub2" ) - - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.name(), "sub1" ) - self.assertEqual( sub1.child( "box1" ).name(), "box1" ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).name(), "gap" ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).child( "torus" ).name(), "torus" ) - - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.name(), "torus1" ) - self.assertEqual( torus1.child( "torus2" ).name(), "torus2" ) - - def testPaths( self ) : - - scene = self.buildScene() - self.assertEqual( scene.path(), [] ) - self.assertEqual( scene.pathAsString(), "/" ) - self.assertEqual( scene.child( "box2" ).path(), [ "box2" ] ) - self.assertEqual( scene.child( "box2" ).pathAsString(), "/box2" ) - self.assertEqual( scene.child( "sub2" ).path(), [ "sub2" ] ) - self.assertEqual( scene.child( "sub2" ).pathAsString(), "/sub2" ) - - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.path(), [ "sub1" ] ) - self.assertEqual( sub1.pathAsString(), "/sub1" ) - self.assertEqual( sub1.child( "box1" ).path(), [ "sub1", "box1" ] ) - self.assertEqual( sub1.child( "box1" ).pathAsString(), "/sub1/box1" ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).path(), [ "sub1", "box1", "gap" ] ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).pathAsString(), "/sub1/box1/gap" ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).child( "torus" ).path(), [ "sub1", "box1", "gap", "torus" ] ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).child( "torus" ).pathAsString(), "/sub1/box1/gap/torus" ) - - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.path(), [ "sub1", "torus1" ] ) - self.assertEqual( torus1.pathAsString(), "/sub1/torus1" ) - self.assertEqual( torus1.child( "torus2" ).path(), [ "sub1", "torus1", "torus2" ] ) - self.assertEqual( torus1.child( "torus2" ).pathAsString(), "/sub1/torus1/torus2" ) - - ## \todo: add a harder test. 3 connections at the same level, and 3 one level deep - - self.assertRaises( RuntimeError, scene.child, "idontexist" ) - self.assertEqual( scene.child( "idontexist", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - # test the node that does exist according to houdini, but is actually a grandchild in our world - self.assertRaises( RuntimeError, scene.child, "box1" ) - self.assertEqual( scene.child( "box1", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - def testSceneMethod( self ) : - - scene = self.buildScene() - - self.assertEqual( scene.scene( [ "sub2" ] ).pathAsString(), "/sub2" ) - - torus1 = scene.scene( [ "sub1", "torus1" ] ) - self.assertEqual( torus1.name(), "torus1" ) - self.assertEqual( torus1.path(), [ "sub1", "torus1" ] ) - self.assertEqual( torus1.pathAsString(), "/sub1/torus1" ) - self.assertEqual( torus1.hasChild( "torus2" ), True ) - self.assertEqual( torus1.childNames(), [ "torus2" ] ) - - # does it still return absolute paths if we've gone to another location? - sub1 = scene.scene( [ "sub1" ] ) - self.assertEqual( sub1.scene( [] ).name(), "/" ) - self.assertEqual( sub1.scene( [ "sub1", "torus1", "torus2" ] ).pathAsString(), "/sub1/torus1/torus2" ) - self.assertEqual( sub1.scene( [ "box2" ] ).pathAsString(), "/box2" ) - - self.assertRaises( RuntimeError, scene.scene, [ "idontexist" ] ) - self.assertEqual( scene.scene( [ "idontexist" ], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - # test the node that does exist according to houdini, but is actually a grandchild in our world - self.assertRaises( RuntimeError, scene.scene, [ "box1" ] ) - self.assertEqual( scene.scene( [ "box1" ], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - def testHasObject( self ) : - - scene = self.buildScene() - self.assertEqual( scene.hasObject(), False ) - self.assertEqual( scene.child( "box2" ).hasObject(), True ) - self.assertEqual( scene.child( "sub2" ).hasObject(), False ) - - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.hasObject(), False ) - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.hasObject(), True ) - self.assertEqual( torus1.child( "torus2" ).hasObject(), True ) - self.assertEqual( sub1.child( "box1" ).hasObject(), True ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).hasObject(), False ) - self.assertEqual( sub1.child( "box1" ).child( "gap" ).child( "torus" ).hasObject(), True ) - - def testTags( self ) : - - # no tags by default - scene = self.buildScene() - self.assertEqual( scene.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( scene.hasTag( "any", IECoreScene.SceneInterface.EveryTag ) ) - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.readTags(IECoreScene.SceneInterface.EveryTag), [] ) - self.assertFalse( sub1.hasTag( "any",IECoreScene.SceneInterface.EveryTag ) ) - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.readTags(IECoreScene.SceneInterface.EveryTag), [] ) - self.assertFalse( torus1.hasTag( "any",IECoreScene.SceneInterface.EveryTag ) ) - - def addTags( node, tags ) : - - parm = node.addSpareParmTuple( hou.StringParmTemplate( "ieTags", "ieTags", 1, "" ) ) - parm.set( [ tags ] ) - - # we can add tags to OBJ nodes, but they do not trickle up automatically - addTags( hou.node( "/obj/sub1/torus1" ), "yellow" ) - addTags( hou.node( "/obj/box1" ), "sop top" ) - self.assertEqual( scene.readTags(IECoreScene.SceneInterface.EveryTag), [] ) - self.assertFalse( scene.hasTag( "yellow", IECoreScene.SceneInterface.EveryTag ) ) - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.readTags(IECoreScene.SceneInterface.EveryTag), [] ) - self.assertFalse( sub1.hasTag( "yellow", IECoreScene.SceneInterface.EveryTag ) ) - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.readTags(IECoreScene.SceneInterface.LocalTag), [ "yellow" ] ) - self.assertTrue( torus1.hasTag( "yellow",IECoreScene.SceneInterface.LocalTag ) ) - box1 = sub1.child( "box1" ) - self.assertEqual( sorted([ str(x) for x in box1.readTags(IECoreScene.SceneInterface.LocalTag) ]), [ "sop", "top" ] ) - self.assertTrue( box1.hasTag( "sop",IECoreScene.SceneInterface.LocalTag ) ) - self.assertTrue( box1.hasTag( "top",IECoreScene.SceneInterface.LocalTag ) ) - self.assertFalse( box1.hasTag( "yellow",IECoreScene.SceneInterface.EveryTag ) ) - - def addSopTags( node, tag, primRange ) : - - if hou.applicationVersion()[0] > 15: - group = node.createOutputNode( "grouprange" ) - group.parm("groupname1").set(tag) - group.parm("start1").set(primRange[0]) - group.parm("end1").set(primRange[1]) - group.parm("selecttotal1").set(1) - group.parm("method1").set(0) - group.setRenderFlag(True) - else: - group = node.createOutputNode("group") - group.parm( "crname" ).set( tag ) - group.parm( "groupop" ).set( 1 ) # by range - group.parm( "rangestart" ).set( primRange[0] ) - group.parm( "rangeend" ).deleteAllKeyframes() - group.parm( "rangeend" ).set( primRange[1] ) - group.parm( "select2" ).set( 1 ) - group.setRenderFlag( True ) - - # we can add tags to SOPs using groups, but they do not trickle up automatically - boxObj = hou.node( "/obj/box1" ) - addSopTags( boxObj.renderNode(), "ieTag_itsABox", ( 0, 5 ) ) # box only - addSopTags( boxObj.renderNode(), "notATag", ( 0, 5 ) ) # box only - addSopTags( boxObj.renderNode(), "ieTag_itsATorus", ( 6, 105 ) ) # torus only - addSopTags( boxObj.renderNode(), "ieTag_both:and", ( 3, 50 ) ) # parts of each - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.readTags(), [] ) - self.assertFalse( sub1.hasTag( "yellow" ) ) - box1 = sub1.child( "box1" ) - self.assertEqual( set(box1.readTags()), set( [IECore.InternedString(s) for s in [ "sop", "top", "itsABox", "both:and" ]]) ) - self.assertTrue( box1.hasTag( "sop" ) ) - self.assertTrue( box1.hasTag( "top" ) ) - self.assertTrue( box1.hasTag( "itsABox" ) ) - self.assertTrue( box1.hasTag( "both:and" ) ) - self.assertFalse( box1.hasTag( "itsATorus" ) ) - gap = box1.child( "gap" ) - self.assertEqual( gap.readTags(), [] ) - self.assertFalse( gap.hasTag( "sop" ) ) - self.assertFalse( gap.hasTag( "top" ) ) - self.assertFalse( gap.hasTag( "itsATorus" ) ) - torus = gap.child( "torus" ) - self.assertEqual( set(torus.readTags()), set( [IECore.InternedString(s) for s in [ "itsATorus", "both:and" ]]) ) - self.assertTrue( torus.hasTag( "itsATorus" ) ) - self.assertTrue( torus.hasTag( "both:and" ) ) - self.assertFalse( torus.hasTag( "sop" ) ) - self.assertFalse( torus.hasTag( "top" ) ) - self.assertFalse( torus.hasTag( "itsABox" ) ) - - def testLinks( self ) : - - # at this point, only SceneCacheNodes can define links - scene = self.buildScene() - self.assertFalse( scene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( scene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), None ) - sub1 = scene.child( "sub1" ) - self.assertFalse( sub1.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( sub1.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), None ) - torus1 = sub1.child( "torus1" ) - self.assertFalse( torus1.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( torus1.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), None ) - - def testDeletedPath( self ) : - - scene = self.buildScene() - sub1 = scene.child( "sub1" ) - torus1 = sub1.child( "torus1" ) - - hou.node( "/obj/sub1/torus1" ).destroy() - - self.assertRaises( RuntimeError, IECore.curry( torus1.scene, [ "sub1", "torus1" ] ) ) - self.assertEqual( torus1.scene( [ "sub1", "torus1" ], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - self.assertRaises( RuntimeError, IECore.curry( torus1.child, "torus2" ) ) - self.assertEqual( torus1.child( "torus2", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - self.assertRaises( RuntimeError, torus1.childNames ) - self.assertRaises( RuntimeError, torus1.hasObject ) - self.assertRaises( RuntimeError, IECore.curry( torus1.readBound, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( torus1.readObject, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( torus1.readTransform, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( torus1.readTransformAsMatrix, 0.0 ) ) - - def testReadMesh( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1" ).parmTuple( "t" ).set( [ 1, 2, 3 ] ) - hou.node( "/obj/sub1" ).parmTuple( "r" ).set( [ 10, 20, 30 ] ) - - box1 = scene.child( "sub1" ).child( "box1" ) - mesh = box1.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - - vertList = list( mesh["P"].data ) - self.assertEqual( len( vertList ), 8 ) - - # check the verts are in local space - self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, -0.5 ) ), 1 ) - - # check read primvars - self.assertEqual( mesh["P"], box1.readObjectPrimitiveVariables( [ "P" ], 0 )["P"] ) - - def testAnimatedMesh( self ) : - - scene = self.buildScene() - shape = hou.node( "/obj/box1/actualBox" ) - deformer = shape.createOutputNode( "twist" ) - deformer.parm( "paxis" ).set( 1 ) - deformer.parm( "strength" ).setExpression( "10*($T+(1.0/$FPS))" ) - - box1 = scene.child( "sub1" ).child( "box1" ) - mesh0 = box1.readObject( 0 ) - mesh0_5 = box1.readObject( 0.5 ) - mesh1 = box1.readObject( 1 ) - # the mesh hasn't moved because the deformer isn't the renderable SOP - self.assertEqual( mesh0, mesh0_5 ) - self.assertEqual( mesh0, mesh1 ) - self.assertEqual( len(mesh0["P"].data), 8 ) - self.assertEqual( mesh0["P"].data[0].x, -0.5 ) - self.assertEqual( mesh0_5["P"].data[0].x, -0.5 ) - self.assertEqual( mesh1["P"].data[0].x, -0.5 ) - - deformer.setRenderFlag( True ) - mesh0 = box1.readObject( 0 ) - mesh0_5 = box1.readObject( 0.5 ) - mesh1 = box1.readObject( 1 ) - self.assertEqual( len(mesh0["P"].data), 8 ) - self.assertEqual( len(mesh0_5["P"].data), 8 ) - self.assertEqual( len(mesh1["P"].data), 8 ) - self.assertEqual( mesh0["P"].data[0].x, -0.5 ) - self.assertAlmostEqual( mesh0_5["P"].data[0].x, -0.521334, 6 ) - self.assertAlmostEqual( mesh1["P"].data[0].x, -0.541675, 6 ) - - def testReadBound( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1" ).parmTuple( "t" ).set( [ 1, 1, 1 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "t" ).set( [ 2, 2, 2 ] ) - hou.node( "/obj/sub1/torus2" ).parmTuple( "t" ).set( [ -1, 0, 2 ] ) - hou.node( "/obj/box1" ).parmTuple( "t" ).set( [ -1, -1, -1 ] ) - # to make the bounds nice round numbers - hou.node( "/obj/sub1/torus1/actualTorus" ).parm( "rows" ).set( 100 ) - hou.node( "/obj/sub1/torus1/actualTorus" ).parm( "cols" ).set( 100 ) - hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "rows" ).set( 100 ) - hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "cols" ).set( 100 ) - - self.assertEqual( scene.child( "box2" ).readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - - sub1 = scene.child( "sub1" ) - box1 = sub1.child( "box1" ) - self.assertEqual( box1.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - - torus1 = sub1.child( "torus1" ) - torus2 = torus1.child( "torus2" ) - self.assertEqual( torus2.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 0 ), imath.Box3d( imath.V3d( -1.5 ), imath.V3d( 3.5, 2.5, 5.5 ) ) ) - self.assertEqual( scene.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 4.5, 3.5, 6.5 ) ) ) - - def testAnimatedBound( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1" ).parmTuple( "t" ).set( [ 1, 1, 1 ] ) - hou.node( "/obj/sub1/torus1" ).parm( "tx" ).setExpression( "$T+(1.0/$FPS)" ) - hou.node( "/obj/sub1/torus1" ).parm( "ty" ).setExpression( "$T+(1.0/$FPS)" ) - hou.node( "/obj/sub1/torus1" ).parm( "tz" ).setExpression( "$T+(1.0/$FPS)" ) - hou.node( "/obj/sub1/torus2" ).parmTuple( "t" ).set( [ -1, 0, 2 ] ) - hou.node( "/obj/box1" ).parm( "tx" ).setExpression( "-($T+(1.0/$FPS))" ) - hou.node( "/obj/box1" ).parm( "ty" ).setExpression( "-($T+(1.0/$FPS))" ) - hou.node( "/obj/box1" ).parm( "tz" ).setExpression( "-($T+(1.0/$FPS))" ) - # to make the bounds nice round numbers - hou.node( "/obj/sub1/torus1/actualTorus" ).parm( "rows" ).set( 100 ) - hou.node( "/obj/sub1/torus1/actualTorus" ).parm( "cols" ).set( 100 ) - hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "rows" ).set( 100 ) - hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "cols" ).set( 100 ) - - self.assertEqual( scene.child( "box2" ).readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - - sub1 = scene.child( "sub1" ) - box1 = sub1.child( "box1" ) - self.assertEqual( box1.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - - torus1 = sub1.child( "torus1" ) - torus2 = torus1.child( "torus2" ) - self.assertEqual( torus2.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( scene.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( 2.5, 1.5, 4.5 ) ) ) - - # time 1 - self.assertEqual( box1.readBound( 1 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - self.assertEqual( torus2.readBound( 1 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 1 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 1 ), imath.Box3d( imath.V3d( -1.5 ), imath.V3d( 2.5, 1.5, 4.5 ) ) ) - self.assertEqual( scene.readBound( 1 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 3.5, 2.5, 5.5 ) ) ) - - # time 1.5 - self.assertEqual( box1.readBound( 1.5 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) - self.assertEqual( torus2.readBound( 1.5 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 1.5 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 1.5 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 3, 2, 5 ) ) ) - self.assertEqual( scene.readBound( 1.5 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 4, 3, 6 ) ) ) - - def testReadTransformMethods( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1/torus1" ).parmTuple( "t" ).set( [ 1, 2, 3 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "r" ).set( [ 10, 20, 30 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "s" ).set( [ 4, 5, 6 ] ) - - torus1 = scene.child( "sub1" ).child( "torus1" ) - transform = torus1.readTransform( 0 ).value - - self.assertEqual( transform.translate.x, 1 ) - self.assertEqual( transform.translate.y, 2 ) - self.assertEqual( transform.translate.z, 3 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.x ), 10.0, 5 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.y ), 20.0, 5 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.z ), 30.0, 5 ) - self.assertAlmostEqual( transform.scale.x, 4, 6 ) - self.assertAlmostEqual( transform.scale.y, 5, 6 ) - self.assertAlmostEqual( transform.scale.z, 6, 6 ) - self.assertTrue( torus1.readTransformAsMatrix( 0 ).equalWithAbsError( transform.transform, 1e-6 ) ) - - def testReadWorldTransformMethods( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1" ).parmTuple( "t" ).set( [ 10, 20, 30 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "t" ).set( [ 1, 2, 3 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "r" ).set( [ 10, 20, 30 ] ) - hou.node( "/obj/sub1/torus1" ).parmTuple( "s" ).set( [ 4, 5, 6 ] ) - - torus1 = scene.child( "sub1" ).child( "torus1" ) - transform = torus1.readWorldTransform( 0 ).value - - self.assertEqual( transform.translate.x, 11 ) - self.assertEqual( transform.translate.y, 22 ) - self.assertEqual( transform.translate.z, 33 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.x ), 10.0, 5 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.y ), 20.0, 5 ) - self.assertAlmostEqual( IECore.radiansToDegrees( transform.rotate.z ), 30.0, 5 ) - self.assertAlmostEqual( transform.scale.x, 4, 6 ) - self.assertAlmostEqual( transform.scale.y, 5, 6 ) - self.assertAlmostEqual( transform.scale.z, 6, 6 ) - self.assertTrue( torus1.readWorldTransformAsMatrix( 0 ).equalWithAbsError( transform.transform, 1e-6 ) ) - - def testAnimatedTransform( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1/torus1" ).parm( "tx" ).setExpression( "$T+(1.0/$FPS)" ) - hou.node( "/obj/sub1/torus1" ).parm( "ty" ).setExpression( "$T+(1.0/$FPS)+1" ) - hou.node( "/obj/sub1/torus1" ).parm( "tz" ).setExpression( "$T+(1.0/$FPS)+2" ) - - torus1 = scene.child( "sub1" ).child( "torus1" ) - transform0 = torus1.readTransform( 0 ).value - transform0_5 = torus1.readTransform( 0.5 ).value - transform1 = torus1.readTransform( 1 ).value - - self.assertEqual( transform0.translate, imath.V3d( 0, 1, 2 ) ) - self.assertAlmostEqual( transform0_5.translate.x, 0.5, 5 ) - self.assertAlmostEqual( transform0_5.translate.y, 1.5, 5 ) - self.assertAlmostEqual( transform0_5.translate.z, 2.5, 5 ) - self.assertEqual( transform1.translate, imath.V3d( 1, 2, 3 ) ) - - def testFlatGeoWithGap( self ) : - - scene = self.buildScene() - hou.node( "/obj/box1/name1" ).parm( "name1" ).set( "/gap/box" ) - - box1 = scene.child( "sub1" ).child( "box1" ) - self.assertEqual( box1.path(), [ "sub1", "box1" ] ) - self.assertEqual( box1.pathAsString(), "/sub1/box1" ) - self.assertEqual( box1.name(), "box1" ) - self.assertEqual( sorted( box1.childNames() ), [ "gap" ] ) - self.assertEqual( box1.hasChild( "gap" ), True ) - self.assertEqual( box1.hasObject(), False ) - - gap = box1.child( "gap" ) - self.assertEqual( gap.path(), [ "sub1", "box1", "gap" ] ) - self.assertEqual( gap.pathAsString(), "/sub1/box1/gap" ) - self.assertEqual( gap.name(), "gap" ) - self.assertEqual( sorted( gap.childNames() ), [ "box", "torus" ] ) - self.assertEqual( gap.hasChild( "torus" ), True ) - self.assertEqual( gap.hasChild( "box" ), True ) - self.assertEqual( gap.hasObject(), False ) - - boxTorus = gap.child( "torus" ) - self.assertEqual( boxTorus.path(), [ "sub1", "box1", "gap", "torus" ] ) - self.assertEqual( boxTorus.pathAsString(), "/sub1/box1/gap/torus" ) - self.assertEqual( boxTorus.name(), "torus" ) - self.assertEqual( boxTorus.childNames(), [] ) - self.assertEqual( boxTorus.hasObject(), True ) - mesh = boxTorus.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 100 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - boxBox = gap.child( "box" ) - self.assertEqual( boxBox.path(), [ "sub1", "box1", "gap", "box" ] ) - self.assertEqual( boxBox.pathAsString(), "/sub1/box1/gap/box" ) - self.assertEqual( boxBox.name(), "box" ) - self.assertEqual( boxBox.childNames(), [] ) - self.assertEqual( boxBox.hasObject(), True ) - mesh = boxBox.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 8 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - def testRerooting( self ) : - - self.buildScene() - scene = IECoreHoudini.LiveScene( "/obj/sub1", rootPath = [ "sub1" ] ) - self.assertEqual( scene.path(), [] ) - self.assertEqual( scene.pathAsString(), "/" ) - self.assertEqual( scene.name(), "/" ) - self.assertEqual( sorted( scene.childNames() ), [ "box1", "torus1" ] ) - self.assertEqual( scene.hasChild( "box1" ), True ) - self.assertEqual( scene.hasChild( "torus1" ), True ) - self.assertEqual( scene.hasChild( "torus2" ), False ) - self.assertEqual( scene.hasObject(), False ) - - torus1 = scene.child( "torus1" ) - self.assertEqual( torus1.path(), [ "torus1" ] ) - self.assertEqual( torus1.pathAsString(), "/torus1" ) - self.assertEqual( torus1.name(), "torus1" ) - self.assertEqual( sorted( torus1.childNames() ), [ "torus2" ] ) - self.assertEqual( torus1.hasChild( "torus2" ), True ) - self.assertEqual( torus1.hasObject(), True ) - mesh = torus1.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 100 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - torus2 = torus1.child( "torus2" ) - self.assertEqual( torus2.path(), [ "torus1", "torus2" ] ) - self.assertEqual( torus2.pathAsString(), "/torus1/torus2" ) - self.assertEqual( torus2.name(), "torus2" ) - self.assertEqual( sorted( torus2.childNames() ), [] ) - self.assertEqual( torus2.hasObject(), True ) - mesh = torus2.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 100 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - box1 = scene.child( "box1" ) - self.assertEqual( box1.path(), [ "box1" ] ) - self.assertEqual( box1.pathAsString(), "/box1" ) - self.assertEqual( box1.name(), "box1" ) - self.assertEqual( sorted( box1.childNames() ), [ "gap" ] ) - self.assertEqual( box1.hasChild( "gap" ), True ) - self.assertEqual( box1.hasObject(), True ) - mesh = box1.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 8 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - gap = box1.child( "gap" ) - self.assertEqual( gap.path(), [ "box1", "gap" ] ) - self.assertEqual( gap.pathAsString(), "/box1/gap" ) - self.assertEqual( gap.name(), "gap" ) - self.assertEqual( sorted( gap.childNames() ), [ "torus" ] ) - self.assertEqual( gap.hasChild( "torus" ), True ) - self.assertEqual( gap.hasObject(), False ) - - boxTorus = gap.child( "torus" ) - self.assertEqual( boxTorus.path(), [ "box1", "gap", "torus" ] ) - self.assertEqual( boxTorus.pathAsString(), "/box1/gap/torus" ) - self.assertEqual( boxTorus.name(), "torus" ) - self.assertEqual( boxTorus.childNames(), [] ) - self.assertEqual( boxTorus.hasObject(), True ) - mesh = boxTorus.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 100 ) - self.assertEqual( mesh.blindData(), IECore.CompoundData() ) - - self.assertRaises( RuntimeError, scene.child, "box2" ) - self.assertEqual( scene.child( "box2", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - # test the node that does exist according to houdini, but is actually a grandchild in our world - self.assertRaises( RuntimeError, scene.child, "torus2" ) - self.assertEqual( scene.child( "torus2", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - torus1 = scene.scene( [ "torus1" ] ) - self.assertEqual( torus1.pathAsString(), "/torus1" ) - - # can't use scene() to go outside of the re-rooting - self.assertRaises( RuntimeError, scene.scene, [ "sub2" ] ) - self.assertEqual( scene.scene( [ "sub2" ], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - def testHiddenObjects( self ) : - - scene = self.buildScene() - hou.node( "/obj/sub1" ).setDisplayFlag( False ) - self.assertFalse( hou.node( "/obj/sub1" ).isObjectDisplayed() ) - self.assertFalse( hou.node( "/obj/sub1/torus1" ).isObjectDisplayed() ) - - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.childNames(), [ "torus1", "box1" ] ) - self.assertFalse( sub1.hasObject() ) - - torus = sub1.child( "torus1" ) - self.assertEqual( torus.childNames(), [ "torus2" ] ) - self.assertTrue( torus.hasObject() ) - self.assertTrue( isinstance( torus.readObject( 0 ), IECoreScene.MeshPrimitive ) ) - - def testDefaultTime( self ) : - - self.buildScene() - box = hou.node( "/obj/box1" ) - deformer = box.renderNode().createOutputNode( "twist" ) - deformer.parm( "paxis" ).set( 1 ) - deformer.parm( "strength" ).setExpression( "10*($T+1.0/$FPS)" ) - deformer.setRenderFlag( True ) - - self.assertNotEqual( hou.time(), 0.5 ) - self.assertEqual( deformer.cookCount(), 0 ) - scene = IECoreHoudini.LiveScene( box.path(), defaultTime = 0.5 ) - self.assertEqual( scene.getDefaultTime(), 0.5 ) - self.assertEqual( deformer.cookCount(), 1 ) - self.assertTrue( scene.hasObject() ) - self.assertEqual( deformer.cookCount(), 1 ) - self.assertEqual( scene.childNames(), [ "gap" ] ) - self.assertEqual( deformer.cookCount(), 1 ) - mesh0_5 = scene.readObject( 0.5 ) - self.assertEqual( deformer.cookCount(), 1 ) - self.assertEqual( len(mesh0_5["P"].data), 8 ) - self.assertAlmostEqual( mesh0_5["P"].data[0].x, -0.521334, 6 ) - - scene.setDefaultTime( 0 ) - self.assertEqual( scene.getDefaultTime(), 0 ) - self.assertEqual( deformer.cookCount(), 1 ) - self.assertTrue( scene.hasObject() ) - self.assertEqual( deformer.cookCount(), 2 ) - self.assertEqual( scene.childNames(), [ "gap" ] ) - self.assertEqual( deformer.cookCount(), 2 ) - mesh0 = scene.readObject( 0 ) - self.assertEqual( deformer.cookCount(), 2 ) - self.assertEqual( len(mesh0["P"].data), 8 ) - self.assertEqual( mesh0["P"].data[0].x, -0.5 ) - - scene.setDefaultTime( 0.5 ) - self.assertTrue( scene.hasObject() ) - self.assertEqual( deformer.cookCount(), 3 ) - gap = scene.scene( scene.path() + [ "gap" ] ) - self.assertEqual( deformer.cookCount(), 3 ) - - def testNode( self ) : - - scene = self.buildScene() - self.assertEqual( scene.node(), hou.node( "/obj" ) ) - - child = scene.child( "sub1" ) - self.assertEqual( child.node(), hou.node( "/obj/sub1" ) ) - - child2 = child.child( "torus1" ) - self.assertEqual( child2.node(), hou.node( "/obj/sub1/torus1" ) ) - - child3 = child2.child( "torus2" ) - self.assertEqual( child3.node(), hou.node( "/obj/sub1/torus2" ) ) - - box1 = child.child( "box1" ) - self.assertEqual( box1.node(), hou.node( "/obj/box1" ) ) - - # flattened geo still points to the parent OBJ - gap = box1.child( "gap" ) - self.assertEqual( gap.node(), hou.node( "/obj/box1" ) ) - self.assertEqual( gap.child( "torus" ).node(), hou.node( "/obj/box1" ) ) - - self.assertEqual( scene.child( "box2" ).node(), hou.node( "/obj/box2" ) ) - self.assertEqual( scene.child( "sub2" ).node(), hou.node( "/obj/sub2" ) ) - - def testEmbedded( self ) : - - scene = self.buildScene() - self.assertEqual( scene.embedded(), False ) - - child = scene.child( "sub1" ) - self.assertEqual( child.embedded(), False ) - - child2 = child.child( "torus1" ) - self.assertEqual( child2.embedded(), False ) - - child3 = child2.child( "torus2" ) - self.assertEqual( child3.embedded(), False ) - - box1 = child.child( "box1" ) - self.assertEqual( box1.embedded(), False ) - - gap = box1.child( "gap" ) - self.assertEqual( gap.embedded(), True ) - self.assertEqual( gap.child( "torus" ).embedded(), True ) - - self.assertEqual( scene.child( "box2" ).embedded(), False ) - self.assertEqual( scene.child( "sub2" ).embedded(), False ) - - def testSimilarNamesInFlatGeo( self ) : - - scene = self.buildScene() - name = hou.node( "/obj/box1" ).renderNode().createInputNode( 2, "name" ) - name.parm( "name1" ).set( "/gap/torus2" ) - torus = name.createInputNode( 0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - - box1 = scene.scene( [ "sub1", "box1" ] ) - self.assertEqual( box1.childNames(), [ "gap" ] ) - - gap = box1.child( "gap" ) - self.assertEqual( set(gap.childNames()), set([ "torus", "torus2" ]) ) - - torus = gap.child( "torus" ) - self.assertEqual( torus.childNames(), [] ) - self.assertTrue( torus.hasObject() ) - self.assertTrue( isinstance( torus.readObject( 0 ), IECoreScene.MeshPrimitive ) ) - self.assertEqual( torus.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - torus2 = gap.child( "torus2" ) - self.assertEqual( torus2.childNames(), [] ) - self.assertTrue( torus2.hasObject() ) - self.assertTrue( isinstance( torus2.readObject( 0 ), IECoreScene.MeshPrimitive ) ) - self.assertEqual( torus2.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - def testNonSlashNames( self ) : - - obj = hou.node( "/obj" ) - boxes = obj.createNode( "geo", "boxes", run_init_scripts=False ) - box1 = boxes.createNode( "box" ) - name1 = box1.createOutputNode( "name" ) - name1.parm( "name1" ).set( "/box1" ) - box2 = boxes.createNode( "box" ) - box2.parmTuple( "t" ).set( ( 3,3,3 ) ) - name2 = box2.createOutputNode( "name" ) - name2.parm( "name1" ).set( "/box2" ) - merge = name1.createOutputNode( "merge" ) - merge.setInput( 1, name2 ) - merge.setRenderFlag( True ) - - def test() : - - scene = IECoreHoudini.LiveScene() - self.assertEqual( scene.childNames(), [ "boxes" ] ) - boxesScene = scene.child( "boxes" ) - self.assertEqual( set(boxesScene.childNames()), set([ "box1", "box2" ]) ) - self.assertFalse( boxesScene.hasObject() ) - - box1Scene = boxesScene.child( "box1" ) - self.assertEqual( box1Scene.childNames(), [] ) - self.assertTrue( box1Scene.hasObject() ) - box1Obj = box1Scene.readObject( 0 ) - self.assertTrue( isinstance( box1Obj, IECoreScene.MeshPrimitive ) ) - self.assertEqual( box1Obj.numFaces(), 6 ) - self.assertTrue( box1Obj.arePrimitiveVariablesValid() ) - - box2Scene = boxesScene.child( "box2" ) - self.assertEqual( box2Scene.childNames(), [] ) - self.assertTrue( box2Scene.hasObject() ) - box2Obj = box2Scene.readObject( 0 ) - self.assertTrue( isinstance( box2Obj, IECoreScene.MeshPrimitive ) ) - self.assertEqual( box2Obj.numFaces(), 6 ) - self.assertTrue( box2Obj.arePrimitiveVariablesValid() ) - - self.assertNotEqual( box1Obj, box2Obj ) - box2Obj["P"] = box1Obj["P"] - self.assertEqual( box1Obj, box2Obj ) - - test() - name1.parm( "name1" ).set( "box1" ) - test() - name2.parm( "name1" ).set( "box2" ) - test() - name1.parm( "name1" ).set( "/box1" ) - test() - - def testCustomAttributes( self ) : - - scene = self.buildScene() - self.assertEqual( scene.attributeNames(), [] ) - self.assertFalse( scene.hasAttribute( "custom" ) ) - self.assertEqual( scene.readAttribute( "custom", 0 ), None ) - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.attributeNames(), [] ) - self.assertFalse( sub1.hasAttribute( "custom" ) ) - self.assertEqual( sub1.readAttribute( "custom", 0 ), None ) - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.attributeNames(), [] ) - self.assertFalse( torus1.hasAttribute( "custom" ) ) - self.assertEqual( torus1.readAttribute( "custom", 0 ), None ) - box1 = sub1.child( "box1" ) - self.assertEqual( box1.attributeNames(), [] ) - self.assertFalse( box1.hasAttribute( "custom" ) ) - self.assertEqual( box1.readAttribute( "custom", 0 ), None ) - gap = box1.child( "gap" ) - self.assertEqual( gap.attributeNames(), [] ) - self.assertFalse( gap.hasAttribute( "custom" ) ) - self.assertEqual( gap.readAttribute( "custom", 0 ), None ) - - doTest = True - - # declare functions for reading custom attribute names/values: - def names( node ) : - - if not doTest : - return [] - - if node.type().name() == "geo" : - return [ "custom" ] - - return [] - - # Register a function that returns nonsense - if the system's working properly, - # we should be able to override this custom attribute reader with one that actually - # returns real names: - def readDummyName( node, name, time ) : - - if not doTest : - return None - - if node.type().name() == "geo" and name == "custom" : - return IECore.StringData( "blahblahblah" ) - - return None - - IECoreHoudini.LiveScene.registerCustomAttributes( names, readDummyName ) - - def readName( node, name, time ) : - - if not doTest : - return None - - if node.type().name() == "geo" and name == "custom" : - return IECore.StringData( node.path() ) - - return None - - IECoreHoudini.LiveScene.registerCustomAttributes( names, readName ) - - # subnets do not have the new attribute - self.assertEqual( scene.attributeNames(), [] ) - self.assertFalse( scene.hasAttribute( "custom" ) ) - self.assertEqual( scene.readAttribute( "custom", 0 ), None ) - self.assertEqual( sub1.attributeNames(), [] ) - self.assertFalse( sub1.hasAttribute( "custom" ) ) - self.assertEqual( sub1.readAttribute( "custom", 0 ), None ) - - # geo nodes have the new attribute. We registered two custom readers: there should be no duplicate - # attribute names, and the last reader we registered should take precedence: - self.assertEqual( torus1.attributeNames(), [ "custom" ] ) - self.assertTrue( torus1.hasAttribute( "custom" ) ) - self.assertEqual( torus1.readAttribute( "custom", 0 ), IECore.StringData( torus1.node().path() ) ) - self.assertEqual( box1.attributeNames(), [ "custom" ] ) - self.assertTrue( box1.hasAttribute( "custom" ) ) - self.assertEqual( box1.readAttribute( "custom", 0 ), IECore.StringData( box1.node().path() ) ) - - # embedded shapes should not call the custom attribute python functions - self.assertEqual( gap.attributeNames(), [] ) - self.assertFalse( gap.hasAttribute( "custom" ) ) - - # two callbacks registering the same attribute should not double-register it - IECoreHoudini.LiveScene.registerCustomAttributes( names, readName ) - self.assertEqual( sub1.attributeNames(), [] ) - self.assertEqual( torus1.attributeNames(), [ "custom" ] ) - self.assertEqual( box1.attributeNames(), [ "custom" ] ) - self.assertEqual( gap.attributeNames(), [] ) - - # Disable custom attribute functions so they don't mess with other tests - doTest = False - - def testCustomTags( self ) : - - scene = self.buildScene() - self.assertEqual( scene.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( scene.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - sub1 = scene.child( "sub1" ) - self.assertEqual( sub1.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( sub1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - torus1 = sub1.child( "torus1" ) - self.assertEqual( torus1.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( torus1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - box1 = sub1.child( "box1" ) - self.assertEqual( box1.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( box1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - gap = box1.child( "gap" ) - self.assertEqual( gap.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - self.assertFalse( gap.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - - doTest = True - - def readTags( node, tagFilter ) : - - if not doTest : - return [] - - if node.type().name() == "geo" : - return [ "custom" ] - - if tagFilter & IECoreScene.SceneInterface.DescendantTag : - - def recurse( node ) : - if node.type().name() == "geo" : - return True - for child in node.children() : - if recurse( child ) : - return True - return False - - if recurse( node ) : - return [ "custom" ] - - return [] - - def hasTag( node, name, tagFilter ) : - - if not doTest : - return False - - if name != "custom" : - return False - - if node.type().name() == "geo" : - return True - - if tagFilter & IECoreScene.SceneInterface.DescendantTag : - - def recurse( node ) : - if node.type().name() == "geo" : - return True - for child in node.children() : - if recurse( child ) : - return True - return False - - return recurse( node ) - - return False - - IECoreHoudini.LiveScene.registerCustomTags( hasTag, readTags ) - - # subnets do not have the new tag directly - self.assertEqual( scene.readTags( IECoreScene.SceneInterface.LocalTag ), [] ) - self.assertFalse( scene.hasTag( "custom", IECoreScene.SceneInterface.LocalTag ) ) - self.assertEqual( sub1.readTags( IECoreScene.SceneInterface.LocalTag ), [] ) - self.assertFalse( sub1.hasTag( "custom", IECoreScene.SceneInterface.LocalTag ) ) - # but they do have them on children - self.assertEqual( scene.readTags(IECoreScene.SceneInterface.EveryTag), [ "custom" ] ) - self.assertTrue( scene.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - self.assertEqual( sub1.readTags(IECoreScene.SceneInterface.EveryTag), [ "custom" ] ) - self.assertTrue( sub1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - # geo nodes have the new tag directly and on children - self.assertEqual( torus1.readTags( IECoreScene.SceneInterface.LocalTag ), [ "custom" ] ) - self.assertEqual( torus1.readTags( IECoreScene.SceneInterface.EveryTag ), [ "custom" ] ) - self.assertTrue( torus1.hasTag( "custom", IECoreScene.SceneInterface.LocalTag ) ) - self.assertTrue( torus1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - self.assertEqual( box1.readTags( IECoreScene.SceneInterface.LocalTag ), [ "custom" ] ) - self.assertEqual( box1.readTags( IECoreScene.SceneInterface.EveryTag ), [ "custom" ] ) - self.assertTrue( box1.hasTag( "custom", IECoreScene.SceneInterface.LocalTag ) ) - self.assertTrue( box1.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - - # embedded shapes should not call the custom tags python functions - self.assertEqual( gap.readTags( IECoreScene.SceneInterface.LocalTag ), [ ] ) - self.assertEqual( gap.readTags( IECoreScene.SceneInterface.EveryTag ), [ ] ) - self.assertFalse( gap.hasTag( "custom", IECoreScene.SceneInterface.LocalTag ) ) - self.assertFalse( gap.hasTag( "custom", IECoreScene.SceneInterface.EveryTag ) ) - - # Disable custom tag functions so they don't mess with other tests - doTest = False - - def testBrokenSop( self ) : - - scene = self.buildScene() - boxNode = hou.node( "/obj/box1" ) - box1 = scene.scene( [ "sub1", "box1" ] ) - self.assertEqual( box1.hasObject(), True ) - mesh = box1.readObject( 0 ) - self.assertTrue( isinstance( mesh, IECoreScene.MeshPrimitive ) ) - self.assertEqual( mesh["P"].data.size(), 8 ) - self.assertEqual( box1.childNames(), [ "gap" ] ) - self.assertTrue( isinstance( box1.child( "gap" ), IECoreHoudini.LiveScene ) ) - - # forcing a cook error - hou.parm('/obj/box1/actualBox/sizex').setExpression( "fake" ) - - self.assertEqual( box1.hasObject(), False ) - self.assertEqual(box1.readObject( 0 ) , None ) - self.assertEqual( box1.childNames(), [] ) - self.assertRaises( RuntimeError, box1.child, "gap" ) - self.assertEqual( box1.child( "gap", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - self.assertRaises( hou.OperationFailed, box1.node().renderNode().cook ) - - def testMultipleTransforms( self ) : - - obj = hou.node( "/obj" ) - sub1 = obj.createNode( "subnet", "sub1" ) - sub2 = sub1.createNode( "subnet", "sub2" ) - sub2.setInput( 0, hou.node( "/obj/sub1" ).indirectInputs()[0] ) - sub3 = sub1.createOutputNode( "subnet", "sub3" ) - - sub1.parmTuple("t").set( (5.0,5.0,0.0) ) - - sc = IECoreHoudini.LiveScene() - sub1Sc = sc.scene(["sub1"]) - sub1Transform = sub1Sc.readTransform( 0 ).value - self.assertEqual( sub1Transform.translate, imath.V3d( 5.0, 5.0, 0.0 ) ) - sub2Sc = sub1Sc.child("sub2") - sub2Transform = sub2Sc.readTransform( 0 ).value - self.assertEqual( sub2Transform.translate, imath.V3d( 0.0, 0.0, 0.0 ) ) - sub3Sc = sub1Sc.child("sub3") - sub3Transform = sub3Sc.readTransform( 0 ).value - self.assertEqual( sub3Transform.translate, imath.V3d( 0.0, 0.0, 0.0 ) ) - - def testIgnoreNonOBJNodes( self ) : - - scene = self.buildScene() - rop = hou.node( "/obj" ).createNode( "ropnet" ) - self.assertTrue( isinstance( rop, hou.RopNode ) ) - # it is a child as far as Houdini is concerned - self.assertTrue( rop in scene.node().children() ) - # but since its not an OBJ, we silently ignore it's existence - self.assertTrue( rop.name() not in scene.childNames() ) - self.assertRaises( RuntimeError, scene.child, "ropnet" ) - self.assertEqual( scene.child( "ropnet", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - def testAttribWrangleName( self ) : - - geo = hou.node( "/obj" ).createNode( "geo" ) - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - name = torus.createOutputNode( "name" ) - name.parm( "name1" ).set( "/a" ) - wrangle = name.createOutputNode( "attribwrangle" ) - wrangle.parm( "class" ).set( 1 ) # primitive - wrangle.parm( "snippet" ).set( 's@name = "/b";' ) - - # since the geo is named it doesn't count as a - # local object, but rather as a child scene. - - name.setRenderFlag( True ) - scene = IECoreHoudini.LiveScene( geo.path() ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "a" ] ) - childScene = scene.child( "a" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - # this is still true after wrangling the name attrib, - # which we are testing because attribwrangle nodes - # do not clean up the mess they've made with the - # string table for attributes. - - wrangle.setRenderFlag( True ) - scene = IECoreHoudini.LiveScene( geo.path() ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "b" ] ) - childScene = scene.child( "b" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - # it works for nested names too - - wrangle.parm( "snippet" ).set( 's@name = "/c/d/e";' ) - scene = IECoreHoudini.LiveScene( geo.path() ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "c" ] ) - childScene = scene.child( "c" ) - self.assertFalse( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [ "d" ] ) - childScene = childScene.child( "d" ) - self.assertFalse( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [ "e" ] ) - childScene = childScene.child( "e" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - # it works if we have SOP level tags too - - group = wrangle.createOutputNode( "grouprange" ) - group.parm("groupname1").set( "ieTag_foo" ) - group.parm("start1").set( 0 ) - group.parm("end1").set( 5 ) - group.parm("selecttotal1").set( 1 ) - group.parm("method1").set( 0 ) - group.setRenderFlag( True ) - scene = IECoreHoudini.LiveScene( geo.path() ).child( "c" ).child( "d" ).child( "e" ) - self.assertEqual( scene.readTags(), [ "foo" ] ) - - def testStringArrayDetail( self ) : - - obj = hou.node( "/obj" ) - box1 = obj.createNode( "geo", "box1", run_init_scripts = False ) - box1.createNode( "box", "actualBox" ) - actualBox = box1.children()[0] - wrangle = actualBox.createOutputNode( "attribwrangle" ) - - wrangle.parm( "class" ).set( 0 ) - wrangle.parm( "snippet" ).set( """ - string tmp[] = {"stringA", "stringB", "stringC"}; - string tmp2 = "stringD"; - - s[]@foo = tmp; - s@bar = tmp2; - """ ) - - wrangle.setRenderFlag( True ) - - obj = IECoreHoudini.LiveScene().child( "box1" ).readObject( 0.0 ) - self.assertTrue( "foo" in obj.keys() ) - self.assertTrue( "bar" in obj.keys() ) - - self.assertEqual( obj["foo"].data, IECore.StringVectorData( ['stringA', 'stringB', 'stringC'] ) ) - self.assertEqual( obj["bar"].data, IECore.StringData( 'stringD' ) ) - - def testUVWelding( self ) : - - scene = self.buildScene() - box = hou.node('/obj/box1/actualBox') - # set to polygon mesh so we get divisions an hence internal UVs - box.parm( "type" ).set( 1 ) - box1UVs = box.createOutputNode( "uvunwrap" ) - hou.node('/obj/box1/name1').setInput( 0, box1UVs ) - torus1UVs = hou.node('/obj/box1/torus1').createOutputNode( "uvunwrap" ) - hou.node('/obj/box1/name2').setInput( 0, torus1UVs ) - name = hou.node( "/obj/box1" ).renderNode().createInputNode( 2, "name" ) - name.parm( "name1" ).set( "/gap/torus2" ) - torus2UVs = name.createInputNode( 0, "uvunwrap" ) - torus2 = torus2UVs.createInputNode( 0, "torus" ) - torus2.parm( "rows" ).set( 10 ) - torus2.parm( "cols" ).set( 10 ) - - def validateUVs( result, uvNode ) : - - self.assertTrue( isinstance( result, IECoreScene.MeshPrimitive ) ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertTrue( "uv" in result.keys() ) - self.assertEqual( result["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - self.assertTrue( isinstance( result["uv"].indices, IECore.IntVectorData ) ) - self.assertEqual( result["uv"].indices.size(), result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) - self.assertTrue( result["uv"].data.size() < result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) ) - - uvData = result["uv"].data - uvIndices = result["uv"].indices - - geo = uvNode.geometry() - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][0], uvValues[0] ) - self.assertAlmostEqual( uvData[ uvIndices[i] ][1], uvValues[1] ) - i += 1 - - box1 = scene.scene( [ "sub1", "box1" ] ) - torus = scene.scene( [ "sub1", "box1", "gap", "torus" ] ) - torus2 = scene.scene( [ "sub1", "box1", "gap", "torus2" ] ) - - validateUVs( box1.readObject( 0 ), box1UVs ) - validateUVs( torus.readObject( 0 ), torus1UVs ) - validateUVs( torus2.readObject( 0 ), torus2UVs ) - - def testMeshInterpolationForSplitLocations( self ) : - - def assertPoly( mesh ) : - - self.assertTrue( "ieMeshInterpolation" not in mesh.keys() ) - self.assertEqual( mesh.interpolation, "linear" ) - self.assertTrue( "N" in mesh.keys() ) - - def assertSubdiv( mesh ) : - - self.assertTrue( "ieMeshInterpolation" not in mesh.keys() ) - self.assertEqual( mesh.interpolation, "catmullClark" ) - self.assertTrue( "N" not in mesh.keys() ) - - scene = self.buildScene() - box = hou.node('/obj/box1/actualBox') - normals = box.createOutputNode( "facet" ) - normals.parm( "postnml" ).set( True ) - hou.node('/obj/box1/name1').setInput( 0, normals ) - boxScene = scene.scene( [ "sub1", "box1" ] ) - torusScene = scene.scene( [ "sub1", "box1", "gap", "torus" ] ) - - # neither has an interpolation so both should be linear - assertPoly( boxScene.readObject( 0 ) ) - assertPoly( torusScene.readObject( 0 ) ) - - # set the box to subdiv, leave the torus unspecified (default linear) - boxAttr = normals.createOutputNode( "attribcreate", node_name = "interpolation", exact_type_name=True ) - boxAttr.parm( "name" ).set( "ieMeshInterpolation" ) - boxAttr.parm( "class" ).set( 1 ) # prim - boxAttr.parm( "type" ).set( 3 ) # string - boxAttr.parm( "string" ) .set( "subdiv" ) - hou.node('/obj/box1/name1').setInput( 0, boxAttr ) - assertSubdiv( boxScene.readObject( 0 ) ) - assertPoly( torusScene.readObject( 0 ) ) - - # set the box to poly, leave the torus unspecified (default linear) - boxAttr.parm( "string" ) .set( "poly" ) - assertPoly( boxScene.readObject( 0 ) ) - assertPoly( torusScene.readObject( 0 ) ) - - # set the box to poly, set the torus to subdiv - torus1attr = hou.node('/obj/box1/torus1').createOutputNode( "attribcreate", node_name = "interpolation", exact_type_name=True ) - torus1attr.parm( "name" ).set( "ieMeshInterpolation" ) - torus1attr.parm( "class" ).set( 1 ) # prim - torus1attr.parm( "type" ).set( 3 ) # string - torus1attr.parm( "string" ) .set( "subdiv" ) - hou.node('/obj/box1/name2').setInput( 0, torus1attr ) - assertPoly( boxScene.readObject( 0 ) ) - assertSubdiv( torusScene.readObject( 0 ) ) - - # set the box to subdiv, set the torus to subdiv - boxAttr.parm( "string" ) .set( "subdiv" ) - assertSubdiv( boxScene.readObject( 0 ) ) - assertSubdiv( torusScene.readObject( 0 ) ) - - def testCornersAndCreasesForSplitLocations( self ) : - - scene = self.buildScene() - box = hou.node('/obj/box1/actualBox') - crease = box.createOutputNode("crease", exact_type_name=True) - crease.parm("group").set("p5-6 p4-5-1") - crease.parm("crease").set(1.29) - dodgyCorner = crease.createOutputNode("crease", exact_type_name=True) - dodgyCorner.parm("group").set("p7") - dodgyCorner.parm("crease").set(10.0) - dodgyCorner.parm("creaseattrib").set("cornerweight") - corner = dodgyCorner.createOutputNode("attribpromote", exact_type_name=True) - corner.parm("inname").set("cornerweight") - corner.parm("inclass").set(3) # vertex - corner.parm("method").set(1) # minimum (to avoid interpolation) - hou.node('/obj/box1/name1').setInput( 0, corner ) - - torus = hou.node('/obj/box1/torus1') - torus.parm("rows").set(6) - torus.parm("cols").set(6) - torusCrease = torus.createOutputNode( "crease", exact_type_name=True ) - # crease the top edge - torusCrease.parm("group").set("p35-30-31-32-33-34-35") - torusCrease.parm("crease").set(3) - torusDodgyCorner = torusCrease.createOutputNode("crease", exact_type_name=True) - # corner the bottom edge - torusDodgyCorner.parm("group").set("p6 p7 p8 p9 p10 p11") - torusDodgyCorner.parm("crease").set(5) - torusDodgyCorner.parm("creaseattrib").set("cornerweight") - torusCorner = torusDodgyCorner.createOutputNode("attribpromote", exact_type_name=True) - torusCorner.parm("inname").set("cornerweight") - torusCorner.parm("inclass").set(3) # vertex - torusCorner.parm("method").set(1) # minimum (to avoid interpolation) - hou.node('/obj/box1/name2').setInput( 0, torusCorner ) - - boxResult = scene.scene( [ "sub1", "box1" ] ).readObject( 0 ) - self.assertTrue( boxResult.arePrimitiveVariablesValid() ) - self.assertEqual( boxResult.keys(), [ "P" ] ) - self.assertEqual( boxResult.cornerIds(), IECore.IntVectorData( [ 7 ] ) ) - self.assertEqual( boxResult.cornerSharpnesses(), IECore.FloatVectorData( [ 10.0 ] ) ) - self.assertEqual( boxResult.creaseLengths(), IECore.IntVectorData( [ 2 ] * 3 ) ) - self.assertEqual( boxResult.creaseIds(), IECore.IntVectorData( [ 1, 5, 4, 5, 5, 6 ] ) ) - self.assertEqual( boxResult.creaseSharpnesses(), IECore.FloatVectorData( [ 1.29 ] * 3 ) ) - - torusResult = scene.scene( [ "sub1", "box1", "gap", "torus" ] ).readObject( 0 ) - self.assertTrue( torusResult.arePrimitiveVariablesValid() ) - self.assertEqual( torusResult.keys(), [ "P" ] ) - self.assertEqual( torusResult.cornerIds(), IECore.IntVectorData( [ 6, 7, 8, 9, 10, 11 ] ) ) - self.assertEqual( torusResult.cornerSharpnesses(), IECore.FloatVectorData( [ 5.0 ] * 6 ) ) - self.assertEqual( torusResult.creaseLengths(), IECore.IntVectorData( [ 2 ] * 6 ) ) - self.assertEqual( torusResult.creaseIds(), IECore.IntVectorData( [ 30, 35, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35 ] ) ) - self.assertEqual( torusResult.creaseSharpnesses(), IECore.FloatVectorData( [ 3 ] * 6 ) ) - - def testPythonDrivenCooks( self ) : - - obj = hou.node( "/obj" ) - box1 = obj.createNode( "geo", "box1", run_init_scripts = False ) - box1.createNode( "box", "actualBox" ) - actualBox = box1.children()[0] - # make it dense to slow down the compute - actualBox.parm( "type" ).set( 1 ) # PolygonMesh - actualBox.parmTuple( "divrate" ).set( ( 100, 100, 100 ) ) - # force a python cook during a per-point wrangle cook - wrangle = actualBox.createOutputNode( "attribwrangle" ) - wrangle.parm( "snippet" ).set( """ - s@foo = chs("test"); - """ ) - wrangle.setRenderFlag( True ) - wrangle.addSpareParmTuple( hou.StringParmTemplate( "test", "test", 1 ) ) - wrangle.parm( "test" ).setExpression( - "hou.node('.').inputs()[0].geometry()\nreturn 'im cooking!'", - language=hou.exprLanguage.Python - ) - - scene = IECoreHoudini.LiveScene( "/obj/box1" ) - self.assertTrue( scene.hasObject() ) - self.assertEqual( scene.childNames(), [] ) - obj = scene.readObject( 0.0 ) - self.assertTrue( "foo" in obj.keys() ) - self.assertEqual( obj["foo"].data, IECore.StringVectorData( [ 'im cooking!' ] ) ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/NodeHandle.py b/test/IECoreHoudini/NodeHandle.py deleted file mode 100644 index d66fdeabad..0000000000 --- a/test/IECoreHoudini/NodeHandle.py +++ /dev/null @@ -1,102 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import weakref -import gc - -import hou - -import IECore -import IECoreScene -import IECoreHoudini - -class TestNodeHandle( IECoreHoudini.TestCase ) : - - def createBox(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - return box - - # testing a class that uses NodeHandle internally can be created - def testCreation( self ) : - - box = self.createBox() - converter = IECoreHoudini.FromHoudiniPolygonsConverter( box ) - self.assertTrue( isinstance( converter, IECoreHoudini.FromHoudiniPolygonsConverter ) ) - - # testing deletion of HOM node is irrelevant - def testDeleteHOMNode( self ) : - - box = self.createBox() - w = weakref.ref( box ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( box ) - - del box - gc.collect() - - self.assertEqual( w(), None ) - self.assertTrue( converter.convert().isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - - # testing deletion of node causes converter to return None - def testDeleteNode( self ) : - - box = self.createBox() - w = weakref.ref( box ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( box ) - result = converter.convert() - - box.destroy() - gc.collect() - - self.assertRaises( Exception, w, [] ) - self.assertEqual( converter.convert(), result ) - - # testing new scene causes converter to return None - def testNewScene( self ) : - - box = self.createBox() - w = weakref.ref( box ) - converter = IECoreHoudini.FromHoudiniPolygonsConverter( box ) - result = converter.convert() - - hou.hipFile.clear( False ) - - self.assertRaises( Exception, w, [] ) - self.assertEqual( converter.convert(), result ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreHoudini/OpHolder.py b/test/IECoreHoudini/OpHolder.py deleted file mode 100644 index ec37868b28..0000000000 --- a/test/IECoreHoudini/OpHolder.py +++ /dev/null @@ -1,888 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os -import shutil - -class TestOpHolder( IECoreHoudini.TestCase ): - - def testOpHolder(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - op = geo.createNode( "ieOpHolder" ) - self.assertTrue( op ) - fn = IECoreHoudini.FnOpHolder( op ) - self.assertTrue( fn ) - return (op,fn) - - # tests a basic op, the function set and that it cooks as expected - def testSimpleOp(self): - (op, fn) = self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn.setParameterised( cl ) - self.assertNotEqual( fn.getParameterised(), None ) - self.assertEqual( fn.getParameterised(), cl ) - op.parm("parm_filename").set( self.__torusTestFile ) - op.cook() # cook using Houdini's cook mechanism, NOT operate() - self.assertEqual( fn.getParameterised()["filename"].getValue(), IECore.StringData( self.__torusTestFile ) ) - result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( result, IECore.Reader.create( self.__torusTestFile ).read() ) - - # tests the alternative 'all in one' opHolder creator - def testAlternateCreator(self): - n = IECoreHoudini.FnOpHolder.create( "noise_deformer", "noiseDeformer", 1 ) - self.assertTrue( n ) - fn = IECoreHoudini.FnOpHolder( n ) - self.assertTrue( fn ) - op = fn.getParameterised() - self.assertTrue( op ) - self.assertEqual( op.typeName(), "noiseDeformer" ) - - # tests creation within contexts (simulating from UIs) - def testContextCreator( self ) : - # test generic creation - n = IECoreHoudini.FnOpHolder.create( "vectorMaker", "vectors/V3fVectorCreator" ) - self.assertEqual( n.path(), "/obj/vectorMaker/vectorMaker" ) - - # test contextArgs outside UI mode fallback to generic behaviour - contextArgs = { "toolname" : "ieOpHolder" } - n2 = IECoreHoudini.FnOpHolder.create( "vectorMaker", "vectors/V3fVectorCreator", contextArgs=contextArgs ) - self.assertEqual( n2.path(), "/obj/vectorMaker1/vectorMaker" ) - - # test parent arg - geo = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - n3 = IECoreHoudini.FnOpHolder.create( "vectorMaker", "vectors/V3fVectorCreator", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n3.path(), "/obj/geo1/vectorMaker" ) - - # test automatic conversion - contextArgs["shiftclick"] = True - n4 = IECoreHoudini.FnOpHolder.create( "noise", "noiseDeformer", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n4.path(), "/obj/geo1/noise" ) - self.assertEqual( len(n4.outputConnectors()[0]), 1 ) - self.assertEqual( n4.outputConnectors()[0][0].outputNode().type().name(), "ieCortexConverter" ) - - # test automatic conversion and output connections - mountain = geo.createNode( "mountain" ) - contextArgs["outputnodename"] = mountain.path() - n5 = IECoreHoudini.FnOpHolder.create( "noise", "noiseDeformer", parent=geo, contextArgs=contextArgs ) - self.assertEqual( n5.path(), "/obj/geo1/noise1" ) - self.assertEqual( len(n5.outputConnectors()[0]), 1 ) - converter = n5.outputConnectors()[0][0].outputNode() - self.assertEqual( converter.type().name(), "ieCortexConverter" ) - self.assertEqual( len(converter.outputConnectors()[0]), 1 ) - outputNode = converter.outputConnectors()[0][0].outputNode() - self.assertEqual( outputNode.type().name(), "mountain::2.0" if hou.applicationVersion()[0] >= 16 else "mountain" ) - self.assertEqual( outputNode, mountain ) - - # test that a C++ op can be assigned using the function set - def testCppOp(self): - (op,fn) = self.testOpHolder() - mesh_normals = IECoreScene.MeshNormalsOp() - self.assertTrue( mesh_normals ) - fn.setParameterised(mesh_normals) - self.assertEqual( fn.getParameterised().typeName(), "MeshNormalsOp" ) - - # test that we can wire opholders together - def testWireTogether(self): - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - - v1_op = geo.createNode( "ieOpHolder", node_name="vector1" ) - fn = IECoreHoudini.FnOpHolder( v1_op ) - fn.setOp( "vectors/V3fVectorCreator", 1 ) - v1_op.parm("parm_size").set(3) - v1_op.parmTuple("parm_value").set( (1,2,3) ) - - v2_op = geo.createNode( "ieOpHolder", node_name="vector2" ) - fn = IECoreHoudini.FnOpHolder( v2_op ) - fn.setOp( "vectors/V3fVectorCreator", 1 ) - v2_op.parm("parm_size").set(3) - v2_op.parmTuple("parm_value").set( (4,5,6) ) - - add_op = geo.createNode( "ieOpHolder", node_name="add_vectors" ) - fn = IECoreHoudini.FnOpHolder( add_op ) - fn.setOp( "vectors/V3fVectorAdder", 1 ) - - print_op = geo.createNode( "ieOpHolder", node_name="print_values" ) - fn = IECoreHoudini.FnOpHolder( print_op ) - fn.setOp( "objectDebug", 1 ) - print_op.parm("parm_quiet").set(True) - - # connect our ops together - add_op.setInput( 0, v1_op ) - add_op.setInput( 1, v2_op ) - print_op.setInput( 0, add_op ) - - # cook and check our output - print_op.cook() - fn = IECoreHoudini.FnOpHolder(print_op) - result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( result, IECore.V3fVectorData( [imath.V3f(5,7,9),imath.V3f(5,7,9),imath.V3f(5,7,9)] ) ) - - # test that a hip with opHolders wired together can be saved and reloaded & still evaluate - def testSaveLoad(self): - hou.hipFile.clear(suppress_save_prompt=True) - save_file = "test/opHolder_testData/opSave_test.hip" - self.testWireTogether() - - # save scene - hou.hipFile.save(save_file) - - # new scene - hou.hipFile.clear(suppress_save_prompt=True) - - # open scene - hou.hipFile.load(save_file) - - # check some parameters are ok - self.assertEqual( hou.node("/obj/geo1/vector1").parm("parm_size").eval(), 3 ) - self.assertEqual( hou.node("/obj/geo1/vector1").parmTuple("parm_value").eval(), (1,2,3) ) - self.assertEqual( hou.node("/obj/geo1/vector2").parm("parm_size").eval(), 3 ) - self.assertEqual( hou.node("/obj/geo1/vector2").parmTuple("parm_value").eval(), (4,5,6) ) - - # check the result of our last opHolder - n = hou.node("/obj/geo1/print_values") - n.cook() - fn = IECoreHoudini.FnOpHolder(n) - result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( result, IECore.V3fVectorData( [imath.V3f(5,7,9),imath.V3f(5,7,9),imath.V3f(5,7,9)] ) ) - - # tests changing op and inputs - def testChangingOp( self ) : - n = IECoreHoudini.FnOpHolder.create( "test_node", "vectors/V3fVectorCreator", 1 ) - fn = IECoreHoudini.FnOpHolder( n ) - op = fn.getParameterised() - self.assertEqual( len(n.inputConnectors()), 0 ) - - fn.setOp( "objectDebug", 1 ) - self.assertEqual( len(n.inputConnectors()), 1 ) - torus = n.createInputNode( 0, "torus" ) - self.assertEqual( torus, n.inputConnections()[0].inputNode() ) - self.assertEqual( 0, n.inputConnections()[0].inputIndex() ) - - fn.setOp( "vectors/V3fVectorAdder", 1 ) - self.assertEqual( len(n.inputConnectors()), 2 ) - self.assertEqual( torus, n.inputConnections()[0].inputNode() ) - self.assertEqual( 0, n.inputConnections()[0].inputIndex() ) - box = n.createInputNode( 1, "box" ) - self.assertEqual( box, n.inputConnections()[1].inputNode() ) - self.assertEqual( 1, n.inputConnections()[1].inputIndex() ) - - n.setInput( 0, None ) - self.assertEqual( len(n.inputConnectors()), 2 ) - self.assertEqual( len(n.inputConnections()), 1 ) - self.assertEqual( box, n.inputConnections()[0].inputNode() ) - self.assertEqual( 1, n.inputConnections()[0].inputIndex() ) - fn.setOp( "objectDebug", 1 ) - self.assertEqual( len(n.inputConnectors()), 1 ) - self.assertEqual( box, n.inputConnections()[0].inputNode() ) - self.assertEqual( 0, n.inputConnections()[0].inputIndex() ) - - fn.setOp( "vectors/V3fVectorCreator", 1 ) - self.assertEqual( len(n.inputConnectors()), 0 ) - self.assertTrue( not n.inputConnectors() ) - - # tests creation of a lot of opHolders - def testLotsQuickly(self): - n = [] - for i in range(1000): - n.append( IECoreHoudini.FnOpHolder.create( "noise_deformer", "noiseDeformer", 1 ) ) - for _n in n: - _n.destroy() - - # test using the noiseDeformer op - def testModifyMesh(self): - (op, fn) = self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn.setParameterised( cl ) - op.parm("parm_filename").set( self.__torusNormalsTestFile ) - deformer = op.createOutputNode( "ieOpHolder" ) - self.assertTrue( deformer ) - cl = IECore.ClassLoader.defaultOpLoader().load("noiseDeformer", 1)() - self.assertEqual( cl.typeName(), "noiseDeformer" ) - fn = IECoreHoudini.FnOpHolder( deformer ) - fn.setParameterised( cl ) - deformer.parm("parm_magnitude").set( 2.5 ) - deformer.parmTuple("parm_frequency").set( (1,2,3) ) - deformer.cook() - torus = IECore.Reader.create( self.__torusNormalsTestFile ).read() - result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( len(result["P"].data), len(torus["P"].data) ) - self.assertEqual( len(result["N"].data), len(torus["N"].data) ) - self.assertNotEqual( result["P"], torus["P"] ) - self.assertNotEqual( result["N"], torus["N"] ) - return ( op, deformer ) - - # test the bbox on our Sop geometry is set correctly - def testOutputBBox(self): - (op,fn) = self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn.setParameterised( cl ) - op.parm("parm_filename").set( self.__torusNormalsTestFile ) - op.cook() - geo = op.geometry() - self.assertTrue( geo ) - bbox = geo.boundingBox() - self.assertTrue( bbox.isAlmostEqual(hou.BoundingBox(-1.5, -0.475528, -1.42658, 1.5, 0.475528, 1.42658)) ) - deformer = op.createOutputNode( "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load("noiseDeformer", 1)() - fn = IECoreHoudini.FnOpHolder( deformer ) - fn.setParameterised( cl ) - self.assertEqual( len(deformer.inputConnectors()), 1 ) - deformer.parm("parm_magnitude").set(2) - deformer.cook() - geo2 = deformer.geometry() - self.assertTrue( geo2 ) - bbox2 = geo2.boundingBox() - self.assertTrue( not bbox2.isAlmostEqual(hou.BoundingBox(-1.5, -0.475528, -1.42658, 1.5, 0.475528, 1.42658)) ) - self.assertTrue( bbox2.isAlmostEqual(hou.BoundingBox(-1.8938, -1.08025, -1.75561, 1.64279, 1.37116, 1.97013)) ) - return ( geo, deformer ) - - # test an opHolder with 2 primitive inputs - def testMultipleInputs(self): - (geo, deformer) = self.testModifyMesh() - swap = geo.createOutputNode( "ieOpHolder", node_name="swapP" ) - cl = IECore.ClassLoader.defaultOpLoader().load("swapAttribute", 1)() - fn = IECoreHoudini.FnOpHolder( swap ) - fn.setParameterised( cl ) - swap.setInput( 1, deformer ) - swap.cook() - src = IECoreHoudini.FnOpHolder( geo ).getParameterised().resultParameter().getValue() - deformer = IECoreHoudini.FnOpHolder( deformer ).getParameterised().resultParameter().getValue() - result = cl.resultParameter().getValue() - self.assertTrue( 'P' in result ) - self.assertNotEqual( result['P'].data, src['P'].data) - self.assertEqual( result['P'].data, deformer['P'].data) - self.assertEqual( result['N'].data, src['N'].data) - self.assertNotEqual( result['N'].data, deformer['N'].data) - - # tests compound parameter support - def testCompoundParameters(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/compoundParameters", 1)() - fn.setParameterised( cl ) - - # test we have the parameters & folders - num_folders = [ type(p.parmTemplate()).__name__ for p in op.spareParms()].count("FolderSetParmTemplate") - self.assertEqual( num_folders, 4 ) - p = op.parm( "parm_compound_1_jy" ) - self.assertTrue( p ) - self.assertEqual( p.containingFolders(), ('Parameters', 'My Compound 1') ) - p = op.parm( "parm_compound_2_kx" ) - self.assertTrue( p ) - self.assertEqual( p.containingFolders(), ('Parameters', 'My Compound 2') ) - p = op.parm( "parm_compound_3_compound_4_some_int" ) - self.assertTrue( p ) - self.assertEqual( p.containingFolders(), ('Parameters', 'My Compound 3', 'My Compound 4') ) - - # test that houdini values get set on cortex parameters correctly - p = op.parmTuple( "parm_compound_3_compound_4_some_int" ) - p.set( [345] ) - self.assertEqual( cl.parameters()["compound_3"]["compound_4"]["some_int"].getValue().value, 123 ) - op.cook() - self.assertEqual( cl.parameters()["compound_3"]["compound_4"]["some_int"].getValue().value, 345 ) - - p = op.parmTuple( "parm_compound_2_j" ) - p.set( [123.456, 456.789, 0.0] ) - self.assertTrue( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 8,16,32 ) ).length() < 0.001 ) - op.cook() - self.assertTrue( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) - - # test that caching parameters works - op.parm( "__classReloadButton" ).pressButton() - op.cook() - self.assertEqual( cl.parameters()["compound_3"]["compound_4"]["some_int"].getValue().value, 345 ) - self.assertTrue( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) - - def testObjectParameterConversion(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("objectDebug", 1)() - fn.setParameterised( cl ) - op.parm("parm_quiet").set( True ) - torus = op.createInputNode(0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - op.cook() - result = cl.resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - torus.parm("type").set(1) - - # torus -> add (keep=1) -> op - # the add (keep=1) removes the primitives but keeps the points - add = op.createInputNode( 0, "add" ) - add.parm( "keep" ).set( 1 ) - add.setInput( 0, torus ) - op.cook() - - result = cl.resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result.typeId(), IECoreScene.TypeId.PointsPrimitive ) - op2 = op.createInputNode(0, "ieOpHolder") - fn2 = IECoreHoudini.FnOpHolder( op2 ) - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn2.setParameterised(cl) - op2.parm("parm_filename").set( self.__torusTestFile ) - op.cook() - result2 = fn.getParameterised().resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result2.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result2["P"].data, result["P"].data ) - - def testObjectParameterWithMultipleTypesConversion( self ) : - ( op, fn ) = self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load( "multiTypeObject", 1 )() - fn.setParameterised( cl ) - torus = op.createInputNode( 0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - op.cook() - result = cl.resultParameter().getValue() - self.assertTrue( not op.errors() ) - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - - # torus -> add (keep=1) -> op - # the add (keep=1) removes the primitives but keeps the points - add = op.createInputNode( 0, "add" ) - add.parm( "keep" ).set( 1 ) - add.setInput( 0, torus ) - op.cook() - - result2 = cl.resultParameter().getValue() - self.assertTrue( not op.errors() ) - self.assertEqual( result2.typeId(), IECoreScene.TypeId.PointsPrimitive ) - op2 = op.createInputNode( 0, "ieOpHolder" ) - fn2 = IECoreHoudini.FnOpHolder( op2 ) - cl = IECore.ClassLoader.defaultOpLoader().load( "cobReader", 1 )() - fn2.setParameterised( cl ) - op2.parm( "parm_filename" ).set( self.__torusTestFile ) - op.cook() - result3 = fn.getParameterised().resultParameter().getValue() - self.assertTrue( not op.errors() ) - self.assertEqual( result3.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result3["P"].data, result["P"].data ) - cl = IECore.ClassLoader.defaultOpLoader().load( "vectors/V3fVectorAdder", 1 )() - fn2.setParameterised( cl ) - fn2.getParameterised().parameters()['vector1'].setValue( result["P"].data ) - fn2.getParameterised().parameters()['vector2'].setValue( result["P"].data ) - op.cook() - result4 = fn.getParameterised().resultParameter().getValue() - self.assertTrue( not op.errors() ) - self.assertEqual( result4.typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( result4["P"].data, result["P"].data + result["P"].data ) - - def testPrimitiveParameterConversion(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/primitives/primParam", 1)() - fn.setParameterised( cl ) - torus = op.createInputNode(0, "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - op.cook() - result = cl.resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result.typeId(), IECoreScene.TypeId.MeshPrimitive ) - torus.parm("type").set(1) - - # torus -> add (keep=1) -> op - # the add (keep=1) removes the primitives but keeps the points - add = op.createInputNode( 0, "add" ) - add.parm( "keep" ).set( 1 ) - add.setInput( 0, torus ) - op.cook() - - result = cl.resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result.typeId(), IECoreScene.TypeId.PointsPrimitive ) - op2 = op.createInputNode(0, "ieOpHolder") - fn = IECoreHoudini.FnOpHolder( op2 ) - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn.setParameterised(cl) - op2.parm("parm_filename").set( self.__torusTestFile ) - op.cook() - result2 = fn.getParameterised().resultParameter().getValue() - self.assertEqual( len( op.errors() ), 0 ) - self.assertEqual( result2.typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( result2["P"].data, result["P"].data ) - - def testPointsParameterConversion(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/primitives/pointParam", 1)() - fn.setParameterised( cl ) - cob = op.createInputNode(0, "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn2 = IECoreHoudini.FnOpHolder( cob ) - fn2.setParameterised( cl ) - cob.parm("parm_filename").set( self.__torusTestFile ) - self.assertRaises( hou.OperationFailed, op.cook ) - self.assertNotEqual( len( op.errors() ), 0 ) - cob = op.createInputNode(0, "torus" ) - op.cook() # should pass because torus will be converted to points - self.assertEqual( fn.getParameterised()['input'].getValue().typeId(), IECoreScene.TypeId.PointsPrimitive ) - self.assertEqual( fn.getParameterised().resultParameter().getValue().typeId(), IECoreScene.TypeId.PointsPrimitive ) - - def testPolygonsParameterConversion(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/primitives/polyParam", 1)() - fn.setParameterised( cl ) - cob = op.createInputNode(0, "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn2 = IECoreHoudini.FnOpHolder( cob ) - fn2.setParameterised( cl ) - cob.parm("parm_filename").set( self.__torusTestFile ) - op.cook() # should pass because we have a mesh primitive - torus = op.createInputNode(0, "torus" ) - op.cook() # should pass because torus will be converted to mesh - self.assertEqual( fn.getParameterised()['input'].getValue().typeId(), IECoreScene.TypeId.MeshPrimitive ) - self.assertEqual( fn.getParameterised().resultParameter().getValue().typeId(), IECoreScene.TypeId.MeshPrimitive ) - op2 = torus.createOutputNode( "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/primitives/pointParam", 1)() - fn = IECoreHoudini.FnOpHolder( op2 ) - fn.setParameterised( cl ) - op2.cook() - self.assertEqual( fn.getParameterised().resultParameter().getValue().typeId(), IECoreScene.TypeId.PointsPrimitive ) - op.setInput( 0, op2 ) - self.assertRaises( hou.OperationFailed, op.cook ) - self.assertNotEqual( len( op.errors() ), 0 ) - - def testInputConnectionsSaveLoad( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - ( holder, fn ) = self.testOpHolder() - fn.setOp( "meshMerge", 1 ) - - holderPath = holder.path() - torusPath = holder.createInputNode( 0, "torus" ).path() - boxPath = holder.createInputNode( 1, "box" ).path() - - self.assertEqual( len(holder.inputs()), 2 ) - self.assertEqual( holder.inputs()[0].path(), torusPath ) - self.assertEqual( holder.inputs()[1].path(), boxPath ) - - hip = "test/opHolder_testData/opSave_test.hip" - hou.hipFile.save( hip ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( hip ) - - holder = hou.node( holderPath ) - self.assertEqual( len(holder.inputs()), 2 ) - self.assertEqual( holder.inputs()[0].path(), torusPath ) - self.assertEqual( holder.inputs()[1].path(), boxPath ) - - def testInvalidValidation(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("cobReader", 1)() - fn.setParameterised( cl ) - op.parm("parm_filename").set( self.__torusTestFile ) - op2 = op.createOutputNode( "ieOpHolder" ) - cl = IECore.ClassLoader.defaultOpLoader().load("parameters/primitives/pointParam", 1)() - fn = IECoreHoudini.FnOpHolder(op2) - fn.setParameterised(cl) - self.assertRaises( hou.OperationFailed, op2.cook ) - self.assertNotEqual( len( op2.errors() ), 0 ) - - def testInvalidOp(self): - (op,fn)=self.testOpHolder() - cl = IECore.ClassLoader.defaultOpLoader().load("noiseDeformer", 1)() - fn.setParameterised( cl ) - self.assertRaises( hou.OperationFailed, op.cook ) - self.assertNotEqual( len( op.errors() ), 0 ) - - def testMatchString(self): - (op,fn)=self.testOpHolder() - op.parm( "__classMatchString" ).set( "*" ) - op.parm( "__className" ).set( "cobReader" ) - op.parm( "__className" ).pressButton() - cl = fn.getParameterised() - self.assertEqual( cl.typeName(), "cobReader" ) - op.parm( "__classMatchString" ).set( "object*" ) - results = fn.classNames() - self.assertEqual( len(fn.classNames()), 1 ) - op.parm( "__className" ).set( "cobReader" ) # this still works, should it be invalid? - op.parm( "__className" ).pressButton() - cl = fn.getParameterised() - self.assertEqual( cl.typeName(), "cobReader" ) - op.parm( "__classMatchString" ).set("*") - self.assertTrue( len(fn.classNames()) > 1 ) - - def testCategories( self ) : - ( op, fn ) = self.testOpHolder() - op.parm( "__classMatchString" ).set( "*" ) - self.assertEqual( op.parm( "__classCategory" ).eval(), "" ) - - op.parm( "__className" ).set( "cobReader" ) - self.assertEqual( op.parm( "__classCategory" ).eval(), "" ) - op.parm( "__className" ).pressButton() - self.assertEqual( fn.getParameterised().typeName(), "cobReader" ) - self.assertEqual( fn.getParameterised().path, "cobReader" ) - - op.parm( "__className" ).set( "vectors/V3fVectorCreator" ) - op.parm( "__className" ).pressButton() - self.assertEqual( op.parm( "__classCategory" ).eval(), "vectors" ) - self.assertEqual( fn.getParameterised().typeName(), "V3fVectorCreator" ) - self.assertEqual( fn.getParameterised().path, "vectors/V3fVectorCreator" ) - - op.parm( "__className" ).set( "" ) - op.parm( "__className" ).pressButton() - self.assertEqual( op.parm( "__classCategory" ).eval(), "vectors" ) - op.parm( "__classCategory" ).set( "" ) - op.parm( "__classCategory" ).pressButton() - self.assertRaises( hou.OperationFailed, op.cook ) - self.assertEqual( op.parm( "__className" ).eval(), "" ) - - op.parm( "__className" ).set( "parameters/compoundParameters" ) - op.parm( "__className" ).pressButton() - self.assertEqual( op.parm( "__classCategory" ).eval(), "parameters" ) - self.assertEqual( fn.getParameterised().typeName(), "compoundParameters" ) - self.assertEqual( fn.getParameterised().path, "parameters/compoundParameters" ) - op.parm( "__className" ).set( "parameters/primitives/pointParam" ) - op.parm( "__className" ).pressButton() - self.assertEqual( op.parm( "__classCategory" ).eval(), "parameters/primitives" ) - self.assertEqual( fn.getParameterised().typeName(), "pointParam" ) - self.assertEqual( fn.getParameterised().path, "parameters/primitives/pointParam" ) - - op.parm( "__classCategory" ).set( "" ) - op.parm( "__classCategory" ).pressButton() - self.assertTrue( len(fn.classNames()) > 4 ) - op.parm( "__classMatchString" ).set( "parameters/*" ) - self.assertEqual( len(fn.classNames()), 5 ) - - def testSetOpValues( self ) : - ( holder, fn ) = self.testOpHolder() - op = IECore.ClassLoader.defaultOpLoader().load( "noiseDeformer", 1 )() - fn.setOp( op ) - self.assertEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder.parmTuple( "parm_frequency" ).parmTemplate().defaultValue() ) - self.assertEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder.parmTuple( "parm_frequency" ).eval() ) - self.assertEqual( tuple(op.parameters()['frequency'].getTypedValue()), holder.parmTuple( "parm_frequency" ).eval() ) - - ( holder2, fn2 ) = self.testOpHolder() - op.parameters()['frequency'].setTypedValue( imath.V3f( 0.2, 0.4, 0.6 ) ) - fn2.setOp( op ) - self.assertEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder2.parmTuple( "parm_frequency" ).parmTemplate().defaultValue() ) - self.assertNotEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder2.parmTuple( "parm_frequency" ).eval() ) - self.assertEqual( tuple(op.parameters()['frequency'].getTypedValue()), holder2.parmTuple( "parm_frequency" ).eval() ) - - def testParameterDescriptions( self ) : - ( holder, fn ) = self.testOpHolder() - fn.setOp( "parameters/compoundParameters" ) - parameters = fn.getOp().parameters() - self.assertEqual( parameters['blah'].description, holder.parm( "parm_blah" ).parmTemplate().help() ) - self.assertEqual( parameters['compound_1']['j'].description, holder.parmTuple( "parm_compound_1_j" ).parmTemplate().help() ) - self.assertEqual( parameters['compound_1']['k'].description, holder.parmTuple( "parm_compound_1_k" ).parmTemplate().help() ) - self.assertEqual( parameters['compound_3']['compound_4']['some_int'].description, holder.parm( "parm_compound_3_compound_4_some_int" ).parmTemplate().help() ) - self.assertEqual( parameters['compound_5']['bool_1'].description, holder.parm( "parm_compound_5_bool_1" ).parmTemplate().help() ) - - def testNumericPresetMenus( self ) : - - # at present, Int/FloatParameters only support presetsOnly presets, due to the limitations of hou.MenuParmTemplate - ( holder, fn ) = self.testOpHolder() - holder.createInputNode( 0, "box" ) - fn.setOp( "parameters/primitives/preset", 1 ) - parm = holder.parm( "parm_switch" ) - self.assertTrue( isinstance( parm, hou.Parm ) ) - template = parm.parmTemplate() - self.assertTrue( isinstance( template, hou.MenuParmTemplate ) ) - # the int values are stored as strings in this crazy Houdini world - self.assertEqual( template.menuItems(), ( "20", "30" ) ) - self.assertEqual( template.menuLabels(), ( "A", "B" ) ) - self.assertEqual( template.defaultValue(), 0 ) - self.assertEqual( template.defaultValueAsString(), "20" ) - self.assertEqual( parm.eval(), 0 ) - self.assertEqual( parm.evalAsString(), "20" ) - - # but on the op values are really the ints we require - op = fn.getOp() - self.assertEqual( op["switch"].getTypedValue(), 20 ) - parm.set( 1 ) - holder.cook() - self.assertEqual( op["switch"].getTypedValue(), 30 ) - # Houdini 16 does not allow ordered menu parms to be set to non-menu items - # if the parm is set to an index, and the index doesn't exist, then the parm is set to the closest item menu - if hou.applicationVersion()[0] < 16: - parm.set( 2 ) - self.assertRaises( hou.OperationFailed, holder.cook ) - parm.set( -1 ) - self.assertRaises( hou.OperationFailed, holder.cook ) - parm.set( 0 ) - holder.cook() - self.assertTrue( not holder.errors() ) - - newHolder = holder.parent().createNode( "ieOpHolder" ) - newFn = IECoreHoudini.FnOpHolder( newHolder ) - op["switch"].setTypedValue( 30 ) - newFn.setOp( op ) - newParm = newHolder.parm( "parm_switch" ) - self.assertEqual( newParm.eval(), 1 ) - self.assertEqual( newParm.evalAsString(), "30" ) - - def testMessageHandling( self ) : - - ( holder, fn ) = self.testOpHolder() - fn.setOp( "noiseDeformer" ) - - self.assertRaises( hou.OperationFailed, holder.cook ) - self.assertTrue( "Must have primvar 'N' in primitive!" in "".join( holder.errors() ) ) - - torus = holder.createInputNode( 0, "torus" ) - self.assertRaises( hou.OperationFailed, holder.cook ) - self.assertTrue( "Must have primvar 'N' in primitive!" in "".join( holder.errors() ) ) - - holder2 = holder.createInputNode( 0, "ieOpHolder" ) - fn2 = IECoreHoudini.FnOpHolder( holder2 ) - fn2.setOp( "meshNormalsOp" ) - holder2.setInput( 0, torus ) - - holder.cook() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertEqual( len( holder2.errors() ), 0 ) - - fn2.setOp( "objectDebug", 2 ) - self.assertEqual( len( holder2.errors() ), 0 ) - self.assertEqual( len( holder2.warnings() ), 0 ) - - holder2.parm( "parm_messageLevel" ).set( int(IECore.MessageHandler.Level.Warning) ) - holder2.cook() - self.assertEqual( len( holder2.errors() ), 0 ) - self.assertNotEqual( len(holder2.warnings()), 0 ) - - holder2.parm( "parm_messageLevel" ).set( int(IECore.MessageHandler.Level.Error) ) - self.assertRaises( hou.OperationFailed, holder2.cook ) - self.assertNotEqual( len( holder2.errors() ), 0 ) - self.assertEqual( len( holder2.warnings() ), 0 ) - - def testAnimatedValues( self ) : - - noise = IECoreHoudini.FnOpHolder.create( "test", "noiseDeformer", 1 ) - fn = IECoreHoudini.FnOpHolder( noise ) - noise.parm( "parm_magnitude" ).setExpression( "$FF" ) - hou.setFrame( 1 ) - self.assertEqual( noise.evalParm( "parm_magnitude" ), 1 ) - self.assertEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 ) - hou.setFrame( 12.25 ) - self.assertEqual( noise.evalParm( "parm_magnitude" ), 12.25 ) - # values haven't been flushed yet - self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 ) - # so we flush them - fn.setParameterisedValues() - self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 12.25 ) - - def namedScene( self, opType ) : - - holder = IECoreHoudini.FnOpHolder.create( "holder", opType, 1 ) - - geo = holder.parent() - boxA = geo.createNode( "box" ) - nameA = boxA.createOutputNode( "name" ) - nameA.parm( "name1" ).set( "boxA" ) - - boxB = geo.createNode( "box" ) - transformB = boxB.createOutputNode( "xform" ) - transformB.parm( "tx" ).set( 5 ) - nameB = transformB.createOutputNode( "name" ) - nameB.parm( "name1" ).set( "boxB" ) - - boxC = geo.createNode( "box" ) - transformC = boxC.createOutputNode( "xform" ) - transformC.parm( "tx" ).set( 10 ) - nameC = transformC.createOutputNode( "name" ) - nameC.parm( "name1" ).set( "boxC" ) - - merge = geo.createNode( "merge" ) - merge.setInput( 0, nameA ) - merge.setInput( 1, nameB ) - merge.setInput( 2, nameC ) - - converter = merge.createOutputNode( "ieCortexConverter" ) - converter.parm( "resultType" ).set( 0 ) # Cortex - holder.setInput( 0, converter ) - - return holder - - def testMultipleOperations( self ) : - - holder = self.namedScene( "meshNormalsOp" ) - - def verify( passThrough = [] ) : - - geo = holder.geometry() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertEqual( len( holder.warnings() ), 0 ) - self.assertEqual( len(geo.prims()), 3 ) - names = [ "boxA", "boxB", "boxC" ] - for i in range( 0, len(geo.prims()) ) : - prim = geo.prims()[i] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.attribValue( "name" ), names[i] ) - - result = IECoreHoudini.FromHoudiniGeometryConverter.create( holder ).convert() - self.assertTrue( result.isInstanceOf( IECore.TypeId.CompoundObject ) ) - self.assertEqual( len(result), 3 ) - for name, child in result.items() : - self.assertTrue( child.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - self.assertTrue( child.arePrimitiveVariablesValid() ) - if name in passThrough : - self.assertEqual( child.keys(), [ "P" ] ) - else : - self.assertEqual( child.keys(), [ "N", "P" ] ) - - # normals were added to each mesh individually - verify() - - # non-matching shapes were passed through unmodified - holder.parm( "parm_input_nameFilter" ).set( "* ^boxA" ) - verify( passThrough = [ "boxA" ] ) - - # still operates multiple times for normal houdini geo - holder.inputConnections()[0].inputNode().bypass( True ) - geo = holder.geometry() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertEqual( len( holder.warnings() ), 0 ) - self.assertEqual( len(geo.prims()), 8 ) - names = [ "boxA", "boxB", "boxC" ] - for i in range( 0, 6 ) : - prim = geo.prims()[i] - self.assertEqual( prim.type(), hou.primType.Polygon ) - self.assertEqual( prim.attribValue( "name" ), "boxA" ) - prim = geo.prims()[6] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.attribValue( "name" ), "boxB" ) - prim = geo.prims()[7] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.attribValue( "name" ), "boxC" ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( holder ) - self.assertEqual( converter, None ) - - # no nameFilter with normal geo compresses to one mesh - holder.parm( "parm_input_useNameFilter" ).set( False ) - geo = holder.geometry() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertEqual( len( holder.warnings() ), 0 ) - self.assertEqual( len(geo.prims()), 1 ) - prim = geo.prims()[0] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( geo.findPrimAttrib( "name" ), None ) - result = IECoreHoudini.FromHoudiniGeometryConverter.create( holder ).convert() - self.assertTrue( result.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result.keys(), [ "N", "P" ] ) - - # no nameFilter with CortexObjects may have unexpected results (because the input parameter wants a single mesh) - holder.inputConnections()[0].inputNode().bypass( False ) - holder.cook() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertNotEqual( len(holder.warnings()), 0 ) - - def testNameFilterOnSecondaryInputs( self ) : - - holder = self.namedScene( "meshMerge" ) - torus = holder.parent().createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - holder.setInput( 1, torus ) - - def verify( numMergedFaces, passThrough = [] ) : - - geo = holder.geometry() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertEqual( len( holder.warnings() ), 0 ) - self.assertEqual( len(geo.prims()), 3 ) - names = [ "boxA", "boxB", "boxC" ] - for i in range( 0, len(geo.prims()) ) : - prim = geo.prims()[i] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.attribValue( "name" ), names[i] ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( holder ) - result = converter.convert() - - self.assertTrue( result.isInstanceOf( IECore.TypeId.CompoundObject ) ) - self.assertEqual( len(result), 3 ) - for name, child in result.items(): - self.assertTrue( child.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) - self.assertTrue( child.arePrimitiveVariablesValid() ) - if name in passThrough : - self.assertEqual( child.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 ) - else : - self.assertEqual( child.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 + numMergedFaces ) - - # torus is merged with each box - verify( numMergedFaces = 100 ) - - # torus is not merged with the passThrough boxes - holder.parm( "parm_input_nameFilter" ).set( "* ^boxA" ) - verify( numMergedFaces = 100, passThrough = [ "boxA" ] ) - - # multiple meshes in the second parameter may have unexpected results (because it wants a single mesh) - holder.setInput( 1, holder.inputConnections()[0].inputNode() ) - holder.cook() - self.assertEqual( len( holder.errors() ), 0 ) - self.assertNotEqual( len(holder.warnings()), 0 ) - - # a single mesh will merge - holder.parm( "parm_mesh_nameFilter" ).set( "boxB" ) - verify( numMergedFaces = 6, passThrough = [ "boxA" ] ) - - # a bulk of normal houdini geo will also merge (it compresses to one mesh) - converter = holder.inputConnections()[0].inputNode().createOutputNode( "ieCortexConverter" ) - holder.setInput( 1, converter ) - holder.parm( "parm_mesh_nameFilter" ).set( "*" ) - verify( numMergedFaces = 18, passThrough = [ "boxA" ] ) - holder.parm( "parm_mesh_nameFilter" ).set( "* ^boxA" ) - verify( numMergedFaces = 12, passThrough = [ "boxA" ] ) - holder.parm( "parm_mesh_useNameFilter" ).set( False ) - verify( numMergedFaces = 18, passThrough = [ "boxA" ] ) - - def setUp( self ) : - IECoreHoudini.TestCase.setUp( self ) - self.__torusTestFile = "test/IECoreHoudini/data/torus.cob" if hou.applicationVersion()[0] < 14 else "test/IECoreHoudini/data/torusH14.cob" - self.__torusNormalsTestFile = "test/IECoreHoudini/data/torus_with_normals.cob" - if not os.path.exists( "test/opHolder_testData" ): - os.mkdir( "test/opHolder_testData" ) - - def tearDown( self ) : - if os.path.exists( "test/opHolder_testData" ): - shutil.rmtree( "test/opHolder_testData" ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/SceneCacheTest.py b/test/IECoreHoudini/SceneCacheTest.py deleted file mode 100644 index 371f3bdac5..0000000000 --- a/test/IECoreHoudini/SceneCacheTest.py +++ /dev/null @@ -1,3669 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import uuid -import functools -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest - -class TestSceneCache( IECoreHoudini.TestCase ) : - - _keepFiles = False - - if hou.applicationVersion()[0] >= 16: - PointPositionAttribs = ['P'] - else: - PointPositionAttribs = ['P', 'Pw'] - - def setUp(self): - - IECoreHoudini.TestCase.setUp( self ) - - self._testFile = "test/test{testName}.scc".format(testName=self.id()) - self._testOutFile = "test/testOut{testName}.scc".format(testName=self.id()) - self._testLinkedOutFile = "test/testOut{testName}.lscc".format(testName=self.id()) - self._testHip = "test/test{testName}.hip".format(testName=self.id()) - self._testBgeo = "test/test{testName}.bgeo".format(testName=self.id()) - self._testBgeoGz = "test/test{testName}.bgeo.gz".format(testName=self.id()) - self._testGeo = "test/test{testName}.geo".format(testName=self.id()) - self._badFile = "test/test{testName}bad.file".format(testName=self.id()) - self._fake = "test/test{testName}fake.scc".format(testName=self.id()) - - def tearDown(self): - if TestSceneCache._keepFiles : - return - - for f in [self._testFile,self._testOutFile,self._testLinkedOutFile,self._testHip,self._testBgeo,self._testBgeoGz,self._testGeo]: - if os.path.exists(f): - os.remove(f) - - def sop( self, parent=None ) : - if not parent : - parent = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - sop = parent.createNode( "ieSceneCacheSource" ) - sop.parm( "file" ).set( self._testFile ) - return sop - - def xform( self, parent=None ) : - if not parent : - parent = hou.node( "/obj" ) - xform = parent.createNode( "ieSceneCacheTransform" ) - xform.parm( "file" ).set( self._testFile ) - return xform - - def geometry( self, parent=None ) : - if not parent : - parent = hou.node( "/obj" ) - geometry = parent.createNode( "ieSceneCacheGeometry" ) - geometry.parm( "file" ).set( self._testFile ) - return geometry - - def sopXform( self, parent=None ) : - merge = self.sopScene( parent ) - sop = merge.createOutputNode( "ieSceneCacheTransform" ) - sop.parm( "file" ).set( self._testFile ) - return sop - - def sopScene( self, parent=None ): - if not parent : - parent = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - box1 = parent.createNode( "box" ) - box2 = parent.createNode( "box" ) - box3 = parent.createNode( "box" ) - name1 = box1.createOutputNode( "name" ) - name1.parm( "name1" ).set( "/1" ) - name2 = box2.createOutputNode( "name" ) - name2.parm( "name1" ).set( "/1/2" ) - name3 = box3.createOutputNode( "name" ) - name3.parm( "name1" ).set( "/1/2/3" ) - merge = name1.createOutputNode( "merge" ) - merge.setInput( 1, name2 ) - merge.setInput( 2, name3 ) - - return merge - - def rop( self, rootObject, parent="/out" ) : - - rop = hou.node( parent ).createNode( "ieSceneCacheWriter" ) - rop.parm( "file" ).set( self._testOutFile ) - rop.parm( "rootObject" ).set( rootObject.path() ) - rop.parmTuple( "f" ).deleteAllKeyframes() - return rop - - def writeSCC( self, rotation=imath.V3d( 0, 0, 0 ), time=0, includeMesh=True ) : - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - - sc = scene.createChild( str( 1 ) ) - if includeMesh: - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - sc = sc.createChild( str( 2 ) ) - if includeMesh: - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ) ] * 6 ) ) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - sc = sc.createChild( str( 3 ) ) - if includeMesh: - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - return scene - - - def testBadFile( self ) : - - def testNode( node ) : - - node.parm( "file" ).set( "" ) - self.assertRaises( hou.OperationFailed, functools.partial( node.cook, True ) ) - self.assertTrue( node.errors() ) - node.parm( "file" ).set( "/tmp/fake" ) - self.assertRaises( hou.OperationFailed, functools.partial( node.cook, True ) ) - self.assertTrue( node.errors() ) - node.parm( "file" ).set( self._testFile ) - self.assertRaises( hou.OperationFailed, functools.partial( node.cook, True ) ) - self.assertTrue( node.errors() ) - self.writeSCC() - node.cook( force=True ) - self.assertTrue( not node.errors() ) - - testNode( self.sop() ) - os.remove( self._testFile ) - testNode( self.xform() ) - os.remove( self._testFile ) - testNode( self.geometry() ) - os.remove( self._testFile ) - testNode( self.sopXform() ) - - def testBadPath( self ) : - - def testNode( node ) : - - node.cook( force=True ) - self.assertTrue( not node.errors() ) - node.parm( "root" ).set( "/1/fake" ) - self.assertRaises( hou.OperationFailed, functools.partial( node.cook, True ) ) - self.assertTrue( node.errors() ) - node.parm( "root" ).set( "/1/2" ) - node.cook( force=True ) - self.assertTrue( not node.errors() ) - - if isinstance( node, hou.ObjNode ) : - node.parm( "expand" ).pressButton() - self.assertTrue( node.children() ) - node.parm( "root" ).set( "/1/fake" ) - node.parm( "collapse" ).pressButton() - node.parm( "expand" ).pressButton() - self.assertEqual( node.children(), tuple() ) - - self.writeSCC() - testNode( self.sop() ) - testNode( self.xform() ) - testNode( self.geometry() ) - testNode( self.sopXform() ) - - def testObjSubPaths( self ) : - - self.writeSCC() - - def testSimple( node ) : - - node.parm( "reload" ).pressButton() - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - node.parm( "root" ).set( "/1" ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 1, 0, 0 ) ) - node.parm( "root" ).set( "/1/2" ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 3, 0, 0 ) ) - node.parm( "root" ).set( "/1/2/3" ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 6, 0, 0 ) ) - - xform = self.xform() - geo = self.geometry() - testSimple( xform ) - testSimple( geo ) - - self.writeSCC( rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) - - def testRotated( node ) : - - node.parm( "reload" ).pressButton() - node.parm( "root" ).set( "/" ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( node.parmTransform().extractRotates(), hou.Vector3( 0, 0, 0 ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, 0 ) ) ) - node.parm( "root" ).set( "/1" ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 1, 0, 0 ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, -30 ) ) ) - node.parm( "root" ).set( "/1/2" ) - self.assertTrue( node.parmTransform().extractTranslates().isAlmostEqual( hou.Vector3( 2.73205, -1, 0 ) ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, -60 ) ) ) - node.parm( "root" ).set( "/1/2/3" ) - self.assertTrue( node.parmTransform().extractTranslates().isAlmostEqual( hou.Vector3( 4.23205, -3.59808, 0 ) ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, -90 ) ) ) - - testRotated( xform ) - testRotated( geo ) - - def testObjSpaceModes( self ) : - - self.writeSCC() - - def testSimple( node ) : - - node.parm( "reload" ).pressButton() - node.parm( "root" ).set( "/1/2" ) - self.assertEqual( node.parm( "space" ).eval(), IECoreHoudini.SceneCacheNode.Space.World ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 3, 0, 0 ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Path ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Local ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 2, 0, 0 ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Object ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - - xform = self.xform() - geo = self.geometry() - testSimple( xform ) - testSimple( geo ) - - self.writeSCC( rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) - - def testRotated( node ) : - - node.parm( "reload" ).pressButton() - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.World ) - self.assertTrue( node.parmTransform().extractTranslates().isAlmostEqual( hou.Vector3( 2.73205, -1, 0 ) ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, -60 ) ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Path ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, 0 ) ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Local ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 2, 0, 0 ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, -30 ) ) ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Object ) - self.assertEqual( node.parmTransform().extractTranslates(), hou.Vector3( 0, 0, 0 ) ) - self.assertTrue( node.parmTransform().extractRotates().isAlmostEqual( hou.Vector3( 0, 0, 0 ) ) ) - - testRotated( xform ) - testRotated( geo ) - - def testSopSubPaths( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1/2" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1/2/3" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - def testSopSpaceModes( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - self.assertEqual( node.parm( "space" ).eval(), IECoreHoudini.SceneCacheNode.Space.World ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Path ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Local ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 2, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 2.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Object ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - - node.parm( "root" ).set( "/1" ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.World ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Path ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 2, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 5, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 2.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 5.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Local ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 2, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 2.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Object ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - - def testSopTransformsPrimvars( self ) : - - def writeTestFile() : - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - - sc = scene.createChild( str( 1 ) ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 2 ) ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 3 ) ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Pref"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, mesh["P"].data ) - mesh["otherP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, mesh["P"].data ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 8 ) ) - sc.writeObject( mesh, 0 ) - - writeTestFile() - - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.World ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), sorted( TestSceneCache.PointPositionAttribs + ["Cd", "otherP", "rest"] ) ) - - # P is transformed - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - # other Point data is as well - self.assertEqual( prims[0].vertex( 0 ).point().attribValue( "otherP" ), ( 6, 0, 0 ) ) - # rest is not transformed - self.assertEqual( prims[0].vertex( 0 ).point().attribValue( "rest" ), ( 0, 0, 0 ) ) - # other data is not - self.assertEqual( prims[0].vertex( 0 ).point().attribValue( "Cd" ), ( 0, 0, 1 ) ) - - def testSopShapeFilter( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "shapeFilter" ).set( "* ^/1/2" ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1','/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 2 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "shapeFilter" ).set( "/1/2/3" ) - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 1 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - node.parm( "shapeFilter" ).set( "" ) - self.assertEqual( len(node.geometry().prims()), 0 ) - self.assertEqual( len(node.geometry().primGroups()), 0 ) - - def testSopAttributeFilter( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - node.parm( "attributeFilter" ).set( "P" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["ieMeshInterpolation", "name"] ) - self.assertEqual( node.geometry().vertexAttribs(), tuple() ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - node.parm( "attributeFilter" ).set( "* ^Cs" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - node.parm( "attributeFilter" ).set( "Cs" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - self.assertEqual( node.geometry().vertexAttribs(), tuple() ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - node.parm( "attributeFilter" ).set( "" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["ieMeshInterpolation", "name"] ) - self.assertEqual( node.geometry().vertexAttribs(), tuple() ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - def testSopAttributeCopy( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - # copying as expected, including automatic translation to rest - node.parm( "attributeCopy" ).set( "P:Pref" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), sorted( TestSceneCache.PointPositionAttribs + ["rest"] ) ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - # ensure the rest does not transform along with P by making sure it matches the static P - original = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - for point in node.geometry().points() : - rest = point.attribValue( "rest" ) - self.assertNotEqual( point.attribValue( "P" ), rest ) - self.assertEqual( original["P"].data[ point.number() % 8 ], imath.V3f( rest[0], rest[1], rest[2] ) ) - - # copying multiple prim vars - node.parm( "attributeCopy" ).set( "P:Pref Cs:Cspecial uv:myUvs" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), sorted( TestSceneCache.PointPositionAttribs + ["rest"] ) ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "Cspecial", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "myUvs", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - # ensure the rest does not transform along with P by making sure it matches the static P - for point in node.geometry().points() : - rest = point.attribValue( "rest" ) - self.assertNotEqual( point.attribValue( "P" ), rest ) - self.assertEqual( original["P"].data[ point.number() % 8 ], imath.V3f( rest[0], rest[1], rest[2] ) ) - for prim in node.geometry().prims() : - self.assertEqual( prim.attribValue( "Cd" ), prim.attribValue( "Cspecial" ) ) - - # copied prim var makes it through even though filtered one doesn't - node.parm( "attributeFilter" ).set( "* ^Cs" ) - node.parm( "attributeCopy" ).set( "Cs:Cspecial" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cspecial", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - # nonexistant prim vars are a no-op - node.parm( "attributeFilter" ).set( "*" ) - node.parm( "attributeCopy" ).set( "fake:notThere" ) - self.assertEqual( len(node.geometry().prims()), 18 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().vertexAttribs() ] ), ["N", "uv"] ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - - # still works for Cortex geo - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - node.parm( "attributeCopy" ).set( "P:Pref" ) - self.assertEqual( len(node.geometry().prims()), 3 ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().pointAttribs() ] ), TestSceneCache.PointPositionAttribs ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["name"] ) - self.assertEqual( node.geometry().vertexAttribs(), tuple() ) - self.assertEqual( node.geometry().globalAttribs(), tuple() ) - result = IECoreHoudini.FromHoudiniCompoundObjectConverter( node ).convert() - self.assertEqual( sorted( result.keys() ), [ "/1", "/1/2", "/1/2/3" ] ) - for key in result.keys() : - self.assertTrue( isinstance( result[key], IECoreScene.MeshPrimitive ) ) - self.assertEqual( sorted( result[key].keys() ), [ "Cs", "N", "P", "Pref", "uv" ] ) - self.assertNotEqual( result[key]["P"], result[key]["Pref"] ) - self.assertEqual( original["P"], result[key]["Pref"] ) - - def testExpandGeo( self ) : - - self.writeSCC() - geo = self.geometry() - self.assertEqual( geo.children(), tuple() ) - geo.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - geo.parm( "expand" ).pressButton() - self.assertEqual( len(geo.children()), 1 ) - node = geo.children()[0] - self.assertEqual( node.name(), "root" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 6, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - geo.parm( "root" ).set( "/1/2" ) - geo.parm( "collapse" ).pressButton() - geo.parm( "expand" ).pressButton() - self.assertEqual( len(geo.children()), 1 ) - node = geo.children()[0] - self.assertEqual( node.name(), "2" ) - node.parm( "root" ).set( "/1/2" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 6, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( geo.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - def cookAll( self, node ) : - node.cook( force=True ) - for child in node.children() : - self.cookAll( child ) - - def testExpandSubNetwork( self ) : - - self.writeSCC() - xform = self.xform() - self.assertEqual( xform.children(), tuple() ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 1 ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1/geo" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1/2" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1/2/geo" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1/2/3" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1/2/3/geo" ), hou.ObjNode ) ) - geo = hou.node( xform.path()+"/1/2/geo" ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outT" ).eval(), ( 1, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1/geo" ).parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/geo" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/geo" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2" ).parmTuple( "outT" ).eval(), ( 2, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/geo" ).parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/geo" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/geo" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3" ).parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3/geo" ).parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3/geo" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1/2/3/geo" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - xform.parm( "root" ).set( "/1/2" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 2 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3/geo" ), hou.ObjNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/3/geo" ).parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3/geo" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3/geo" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - xform.parm( "root" ).set( "/1" ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 2 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( hou.node( xform.path()+"/geo" ), hou.ObjNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 1, 0, 0 ) ) - - next = hou.node( xform.path()+"/2" ) - self.assertTrue( isinstance( next, hou.ObjNode ) ) - self.assertEqual( len(next.children()), 0 ) - next.parm( "expand" ).pressButton() - self.assertEqual( len(next.children()), 2 ) - self.assertTrue( isinstance( hou.node( xform.path()+"/2/3" ), hou.ObjNode ) ) - geo = hou.node( xform.path()+"/2/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - - next = hou.node( xform.path()+"/2/3" ) - self.assertTrue( isinstance( next, hou.ObjNode ) ) - self.assertEqual( len(next.children()), 0 ) - next.parm( "expand" ).pressButton() - self.assertEqual( len(next.children()), 1 ) - self.assertTrue( isinstance( hou.node( xform.path()+"/2/3/geo" ), hou.ObjNode ) ) - - def testExpandParenting( self ) : - - self.writeSCC() - xform = self.xform() - self.assertEqual( xform.children(), tuple() ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 3 ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/1" ).children()[0], hou.SopNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/2" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/2" ).children()[0], hou.SopNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3" ).children()[0], hou.SopNode ) ) - self.assertEqual( len(hou.node( xform.path()+"/1" ).inputs()), 0 ) - self.assertEqual( len(hou.node( xform.path()+"/2" ).inputs()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/3" ).inputs()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/1" ).outputs()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/2" ).outputs()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/3" ).outputs()), 0 ) - self.assertEqual( hou.node( xform.path()+"/1" ).outputs()[0], hou.node( xform.path()+"/2" ) ) - self.assertEqual( hou.node( xform.path()+"/2" ).outputs()[0], hou.node( xform.path()+"/3" ) ) - self.cookAll( xform ) - geo = hou.node( xform.path()+"/2" ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outT" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outT" ).eval(), ( 1, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/1" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/2" ).parmTuple( "outT" ).eval(), ( 2, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/2" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/2" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - xform.parm( "root" ).set( "/1/2" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 2 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( geo.children()[0], hou.SopNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3" ), hou.ObjNode ) ) - self.assertTrue( isinstance( hou.node( xform.path()+"/3" ).children()[0], hou.SopNode ) ) - self.assertEqual( len(geo.inputs()), 0 ) - self.assertEqual( len(hou.node( xform.path()+"/3" ).inputs()), 1 ) - self.assertEqual( len(geo.outputs()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/3" ).outputs()), 0 ) - self.assertEqual( geo.outputs()[0], hou.node( xform.path()+"/3" ) ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( xform.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( hou.node( xform.path()+"/3" ).parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - - xform.parm( "root" ).set( "/1" ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 2 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( geo.children()[0], hou.SopNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 1, 0, 0 ) ) - - next = hou.node( xform.path()+"/2" ) - self.assertTrue( isinstance( next, hou.ObjNode ) ) - self.assertEqual( len(geo.inputs()), 0 ) - self.assertEqual( len(next.inputs()), 1 ) - self.assertEqual( len(geo.outputs()), 1 ) - self.assertEqual( len(next.outputs()), 0 ) - self.assertEqual( geo.outputs()[0], next ) - self.assertEqual( len(next.children()), 1 ) - self.assertTrue( isinstance( next.children()[0], hou.SopNode ) ) - - def testExpandFlatGeometry( self ) : - - self.writeSCC() - xform = self.xform() - self.assertEqual( xform.children(), tuple() ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.FlatGeometry ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 1 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( geo.children()[0], hou.SopNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - self.assertEqual( node.name(), "root" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 6, 0, 0 ) ) - - xform.parm( "root" ).set( "/1/2" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 1 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( geo.children()[0], hou.SopNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - self.assertEqual( node.name(), "2" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 6, 0, 0 ) ) - - xform.parm( "root" ).set( "/1" ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 1 ) - geo = hou.node( xform.path()+"/geo" ) - self.assertTrue( isinstance( geo, hou.ObjNode ) ) - self.assertTrue( isinstance( geo.children()[0], hou.SopNode ) ) - self.cookAll( xform ) - node = geo.children()[0] - self.assertEqual( node.name(), "1" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position() * geo.worldTransform(), hou.Vector3( 1, 0, 0 ) ) - - def writeTaggedSCC( self ) : - - scene = self.writeSCC() - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - sc1.writeTags( [ "a" ] ) - sc2.writeTags( [ "b" ] ) - sc3.writeTags( [ "c" ] ) - - return scene - - def writeDualTaggedSCC( self ) : - - scene = self.writeTaggedSCC() - sc1 = scene.child( str(1 ) ) - sc4 = sc1.createChild( str(4) ) - sc4.writeTags( [ "d" ] ) - box = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - sc5 = sc4.createChild( str(5) ) - sc5.writeObject( box, 0 ) - - def testParmTrickleDown( self ) : - - def checkParms( node, geoType, tagFilter, attribFilter, shapeFilter, attribCopy, fullPathName ) : - - self.assertEqual( node.parm( "geometryType" ).eval(), geoType ) - self.assertEqual( node.parm( "attributeFilter" ).eval(), attribFilter ) - self.assertEqual( node.parm( "attributeCopy" ).eval(), attribCopy ) - self.assertEqual( node.parm( "shapeFilter" ).eval(), shapeFilter ) - self.assertEqual( node.parm( "fullPathName" ).eval(), fullPathName ) - if isinstance( node, hou.ObjNode ) : - self.assertEqual( node.parm( "expanded" ).eval(), True ) - - if node.isObjectDisplayed() : - self.assertEqual( node.parm( "tagFilter" ).eval(), tagFilter ) - else : - self.assertEqual( node.parm( "tagFilter" ).eval(), "*" ) - - for child in node.children() : - checkParms( child, geoType, tagFilter, attribFilter, shapeFilter, attribCopy, fullPathName ) - - self.writeDualTaggedSCC() - xform = self.xform() - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - xform.parm( "attributeFilter" ).set( "*" ) - xform.parm( "shapeFilter" ).set( "*" ) - xform.parm( "fullPathName" ).set( "fullPath" ) - xform.parm( "expand" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Cortex, "*", "*", "*", "", "fullPath" ) - - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "attributeFilter" ).set( "P ^N" ) - xform.parm( "attributeCopy" ).set( "P:Pref" ) - xform.parm( "shapeFilter" ).set( "/1/2 ^/1/2/3" ) - xform.parm( "fullPathName" ).set( "customName" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Houdini, "*", "P ^N", "/1/2 ^/1/2/3", "P:Pref", "customName" ) - - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - xform.parm( "attributeFilter" ).set( "*" ) - xform.parm( "attributeCopy" ).set( "" ) - xform.parm( "shapeFilter" ).set( "*" ) - xform.parm( "fullPathName" ).set( "fullPath" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Cortex, "*", "*", "*", "", "fullPath" ) - - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "attributeFilter" ).set( "P ^N" ) - xform.parm( "attributeCopy" ).set( "v:vIn" ) - xform.parm( "shapeFilter" ).set( "/1/2 ^/1/2/3" ) - xform.parm( "fullPathName" ).set( "customName" ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Houdini, "*", "P ^N", "/1/2 ^/1/2/3", "v:vIn", "customName" ) - - # now check just pushing the parms - - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - xform.parm( "attributeFilter" ).set( "P ^N" ) - xform.parm( "attributeCopy" ).set( "P:Pref" ) - xform.parm( "shapeFilter" ).set( "/1/2 ^/1/2/3" ) - xform.parm( "fullPathName" ).set( "fullPath" ) - xform.parm( "push" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Cortex, "*", "P ^N", "/1/2 ^/1/2/3", "P:Pref", "fullPath" ) - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5/geo" ).isObjectDisplayed() ) - - xform.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - xform.parm( "attributeFilter" ).set( "P N" ) - xform.parm( "attributeCopy" ).set( "P:Pref v:vIn" ) - xform.parm( "shapeFilter" ).set( "/1/2 /1/2/3" ) - xform.parm( "fullPathName" ).set( "customName" ) - xform.parm( "tagFilter" ).set( "d" ) - xform.parm( "push" ).pressButton() - checkParms( xform, IECoreHoudini.SceneCacheNode.GeometryType.Houdini, "d", "P N", "/1/2 /1/2/3", "P:Pref v:vIn", "customName" ) - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2/geo" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5/geo" ).isObjectDisplayed() ) - - def testTagFilter( self ) : - - self.writeDualTaggedSCC() - - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - self.assertEqual( sorted( xform.parm( "tagFilter" ).menuItems() ), [ "*", "ObjectType:MeshPrimitive", "a", "b", "c", "d" ] ) - xform.parm( "tagFilter" ).set( "b" ) - xform.parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/4" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/4/5" ), None ) - - xform.parm( "collapse" ).pressButton() - xform.parm( "tagFilter" ).set( "d" ) - xform.parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/2/geo" ), None ) - self.assertEqual( hou.node( xform.path()+"/1/2/3" ), None ) - self.assertTrue( hou.node( xform.path()+"/1/4" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5/geo" ).isObjectDisplayed() ) - - xform.parm( "collapse" ).pressButton() - xform.parm( "tagFilter" ).set( "b d" ) - xform.parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/4/5/geo" ).isObjectDisplayed() ) - - xform.parm( "collapse" ).pressButton() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "tagFilter" ).set( "b" ) - xform.parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/geo" ), None ) - hou.node( xform.path()+"/1" ).parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/2/geo" ), None ) - hou.node( xform.path()+"/1/2" ).parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/2//3geo" ), None ) - hou.node( xform.path()+"/1/2/3" ).parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/4/5" ), None ) - self.assertEqual( hou.node( xform.path()+"/1/4/5/geo" ), None ) - # is displayed because we forced it by expanding 4 explicitly - hou.node( xform.path()+"/1/4" ).parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1/4/5" ).isObjectDisplayed() ) - self.assertEqual( hou.node( xform.path()+"/1/4/5/geo" ), None ) - hou.node( xform.path()+"/1/4/5" ).parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1/4/5/geo" ).isObjectDisplayed() ) - - xform.parm( "collapse" ).pressButton() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "tagFilter" ).set( "b" ) - xform.parm( "expand" ).pressButton() - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/2" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/3" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/4" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/5" ).isObjectDisplayed() ) - - def testSopTagFilter( self ) : - - self.writeDualTaggedSCC() - - sop = self.sop() - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - sop.parm( "tagFilter" ).set( "b" ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - sop.parm( "tagFilter" ).set( "a" ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 24 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3', '/1/4/5' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - self.assertEqual( prims[18].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - - sop.parm( "tagFilter" ).set( "d" ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/4/5' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - - sop.parm( "tagFilter" ).set( "b d" ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 24 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3', '/1/4/5' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - self.assertEqual( prims[18].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - - def testEmptyTags( self ) : - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - - sc = scene.createChild( str( 1 ) ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 2 ) ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 3 ) ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - del scene, sc - - xform = self.xform() - xform.parm( "expand" ).pressButton() - self.assertEqual( len(xform.children()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/1" ).children()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/1/2" ).children()), 1 ) - self.assertEqual( len(hou.node( xform.path()+"/1/2/3" ).children()), 0 ) - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - self.assertEqual( scene.readTags( IECoreScene.SceneInterface.EveryTag ), [] ) - - self.assertTrue( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - - xform.parm( "tagFilter" ).set( "" ) - xform.parm( "push" ).pressButton() - self.assertFalse( hou.node( xform.path()+"/1" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2" ).isObjectDisplayed() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3" ).isObjectDisplayed() ) - - def testLiveTags( self ) : - - self.writeTaggedSCC() - - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "expand" ).pressButton() - scene = IECoreHoudini.LiveScene( xform.path() ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [] ) - for tag in scene.readTags(IECoreScene.SceneInterface.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - scene = IECoreHoudini.LiveScene( xform.path()+"/1/2" ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.AncestorTag ) ]), [ "ObjectType:MeshPrimitive", "a" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.DescendantTag ) ]), [ "ObjectType:MeshPrimitive", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [ "ObjectType:MeshPrimitive", "b" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - - # test tags exist even when children aren't expanded - xform.parm( "collapse" ).pressButton() - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "expand" ).pressButton() - scene = IECoreHoudini.LiveScene( xform.path() ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - hou.node( xform.path()+"/1" ).parm( "expand" ).pressButton() - scene = IECoreHoudini.LiveScene( xform.path()+"/1/2" ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.AncestorTag ) ]), [ "ObjectType:MeshPrimitive", "a" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.DescendantTag ) ]), [ "ObjectType:MeshPrimitive", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [ "ObjectType:MeshPrimitive", "b" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - - # test tags for parented expansion - xform.parm( "collapse" ).pressButton() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "expand" ).pressButton() - scene = IECoreHoudini.LiveScene( xform.path() ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - scene = IECoreHoudini.LiveScene( xform.path()+"/2" ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.AncestorTag ) ]), [ "ObjectType:MeshPrimitive", "a" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.DescendantTag ) ]), [ "ObjectType:MeshPrimitive", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [ "ObjectType:MeshPrimitive", "b" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.EveryTag ) ) - - # test user tags - b = hou.node( xform.path()+"/2" ) - b.parm( "ieTags" ).set( "testing user:tags" ) - group = b.renderNode().createOutputNode( "group" ) - group.parm( "crname" ).set( "ieTag_green" ) - group2 = group.createOutputNode( "group" ) - group2.parm( "crname" ).set( "notATag" ) - group2.setRenderFlag( True ) - scene = IECoreHoudini.LiveScene( xform.path() ) - # they don't currently affect parents, just the immediate node - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [] ) - for tag in scene.readTags( IECoreScene.SceneInterface.EveryTag ) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "testing", IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "user:tags", IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "green", IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "notATag", IECoreScene.SceneInterface.EveryTag ) ) - scene = IECoreHoudini.LiveScene( xform.path()+"/2" ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.AncestorTag ) ]), [ "ObjectType:MeshPrimitive", "a" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.DescendantTag ) ]), [ "ObjectType:MeshPrimitive", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.LocalTag ) ]), [ "ObjectType:MeshPrimitive", "b", "green", "testing", "user:tags" ] ) - for tag in scene.readTags(IECoreScene.SceneInterface.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.EveryTag ) ) - self.assertFalse( scene.hasTag( "notATag", IECoreScene.SceneInterface.EveryTag ) ) - - def testObjTagToGroups( self ) : - - self.writeDualTaggedSCC() - - xform = self.xform() - - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "tagFilter" ).set( "*" ) - xform.parm( "expand" ).pressButton() - - # no groups set by default - for src in ( c for c in xform.allSubChildren() if c.type().nameWithCategory() == "Sop/ieSceneCacheSource" ): - self.assertEqual( src.geometry().primGroups(), () ) - - # all groups enabled - xform.parm( "tagGroups" ).set(1) - xform.parm( "push" ).pressButton() - - for src in (c for c in xform.allSubChildren() if c.type().nameWithCategory() == "Sop/ieSceneCacheSource"): - if src.path() == ( xform.path() + "/1/geo/1" ): - for gr in src.geometry().primGroups(): - self.assertIn( gr.name(), [ "ieTag_a" ] ) - elif src.path() == ( xform.path() + "/1/2/geo/2" ): - for gr in src.geometry().primGroups(): - self.assertIn( gr.name(), [ "ieTag_b" ] ) - elif src.path() == ( xform.path() + "/1/2/3/geo/3" ): - for gr in src.geometry( ).primGroups( ): - self.assertIn( gr.name(), [ "ieTag_c" ] ) - elif src.path() == ( xform.path() + "/1/4/5/geo/5" ): - self.assertEqual( src.geometry( ).primGroups( ), tuple() ) - - # group b filtered - xform.parm( "tagFilter" ).set( "b" ) - xform.parm( "push" ).pressButton() - - srcs = [ c for c in xform.allSubChildren() if c.type().nameWithCategory() == "Sop/ieSceneCacheSource" ] - self.assertEqual( set( [ pg.name() for src in srcs for pg in src.geometry().primGroups() ] ), { "ieTag_a", "ieTag_b", "ieTag_c" } ) - - # check that all groups present when Hierarchy is set to parenting - xform.parm( "collapse" ).pressButton() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "tagFilter" ).set( "*" ) - xform.parm( "expand" ).pressButton() - - srcs = [ c for c in xform.allSubChildren( ) if c.type( ).nameWithCategory( ) == "Sop/ieSceneCacheSource" ] - for src in srcs : - for pg in src.geometry().primGroups(): - for prim in pg.prims(): - if prim.attribValue( "name" ) == "/1" : - self.assertIn( pg.name(), [ "ieTag_a" ] ) - elif prim.attribValue( "name" ) == "/1/2" : - self.assertIn( pg.name(), [ "ieTag_b" ] ) - elif prim.attribValue( "name" ) == "/1/2/3" : - self.assertIn( pg.name(), [ "ieTag_c" ] ) - elif prim.attribValue( "name" ) == "/1/4/5" : - self.assertEqual( src.geometry( ).primGroups( ), tuple( ) ) - - # check that d (which has no geometry) is filtered correctly when Hierarchy is set to flat hierarchy - xform.parm( "collapse" ).pressButton() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.FlatGeometry ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "tagFilter" ).set( "*" ) - xform.parm( "expand" ).pressButton() - - srcs = [ c for c in xform.allSubChildren( ) if c.type( ).nameWithCategory( ) == "Sop/ieSceneCacheSource" ] - for src in srcs: - for pg in src.geometry().primGroups(): - for prim in pg.prims() : - if prim.attribValue( "name" ) == "/1" : - self.assertIn( pg.name(), [ "ieTag_a" ] ) - elif prim.attribValue( "name" ) == "/1/2" : - self.assertIn( pg.name(), [ "ieTag_b" ] ) - elif prim.attribValue( "name" ) == "/1/2/3" : - self.assertIn( pg.name(), [ "ieTag_c" ] ) - elif prim.attribValue( "name" ) == "/1/4/5" : - self.assertEqual( src.geometry( ).primGroups( ), tuple( ) ) - - # group b filtered - xform.parm( "tagFilter" ).set( "b" ) - xform.parm( "push" ).pressButton() - - srcs = [ c for c in xform.allSubChildren() if c.type().nameWithCategory() == "Sop/ieSceneCacheSource" ] - self.assertEqual( set( [ pg.name() for src in srcs for pg in src.geometry().primGroups() ] ), { "ieTag_a", "ieTag_b", "ieTag_c" } ) - - - def writeAttributeSCC( self ) : - - scene = self.writeSCC() - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - sc1.writeAttribute( "label", IECore.StringData( "a" ), 0 ) - sc1.writeAttribute( "color", IECore.Color3fData( imath.Color3f( 0.5 ) ), 0 ) - sc2.writeAttribute( "label", IECore.StringData( "b" ), 0 ) - sc2.writeAttribute( "material", IECore.StringData( "rubber" ), 0 ) - sc3.writeAttribute( "label", IECore.StringData( "c" ), 0 ) - sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 0 ) ), 0 ) - sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 0.5 ) ), 0.5 ) - sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 1 ) ), 1 ) - - return scene - - def testLiveAttributes( self ) : - - self.writeAttributeSCC() - - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - - # its a link before it is expanded - scene = IECoreHoudini.LiveScene( xform.path() ) - self.assertEqual( scene.attributeNames(), [ IECoreScene.LinkedScene.linkAttribute ] ) - self.assertTrue( scene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( - scene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), - IECore.CompoundData( { - "time" : IECore.DoubleData( 0 ), - "fileName" : IECore.StringData( self._testFile ), - "root" : IECore.InternedStringVectorData( [] ) - } ) - ) - - # the link disapears once expanded - xform.parm( "expand" ).pressButton() - self.assertEqual( scene.attributeNames(), [] ) - self.assertFalse( scene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( scene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), None ) - - # nodes expose their attributes - a = scene.child( "1" ) - self.assertEqual( sorted(a.attributeNames()), [ "color", "label", "sceneInterface:animatedObjectPrimVars" ] ) - for attr in a.attributeNames() : - self.assertTrue( a.hasAttribute( attr ) ) - self.assertFalse( a.hasAttribute( "material" ) ) - self.assertEqual( a.readAttribute( "label", 0 ), IECore.StringData( "a" ) ) - self.assertEqual( a.readAttribute( "color", 0 ), IECore.Color3fData( imath.Color3f( 0.5 ) ) ) - - b = a.child( "2" ) - self.assertEqual( sorted(b.attributeNames()), [ "label", "material", "sceneInterface:animatedObjectPrimVars" ] ) - for attr in b.attributeNames() : - self.assertTrue( b.hasAttribute( attr ) ) - self.assertFalse( b.hasAttribute( "color" ) ) - self.assertEqual( b.readAttribute( "label", 0 ), IECore.StringData( "b" ) ) - self.assertEqual( b.readAttribute( "material", 0 ), IECore.StringData( "rubber" ) ) - - c = b.child( "3" ) - self.assertEqual( sorted(c.attributeNames()), [ "animColor", "label", "sceneInterface:animatedObjectPrimVars" ] ) - for attr in c.attributeNames() : - self.assertTrue( c.hasAttribute( attr ) ) - self.assertFalse( c.hasAttribute( "color" ) ) - self.assertFalse( c.hasAttribute( "material" ) ) - self.assertEqual( c.readAttribute( "label", 0 ), IECore.StringData( "c" ) ) - self.assertEqual( c.readAttribute( "animColor", 0 ), IECore.Color3fData( imath.Color3f( 0 ) ) ) - self.assertEqual( c.readAttribute( "animColor", 0.5 ), IECore.Color3fData( imath.Color3f( 0.5 ) ) ) - self.assertEqual( c.readAttribute( "animColor", 1 ), IECore.Color3fData( imath.Color3f( 1 ) ) ) - - def testFullPathName( self ) : - - self.writeSCC() - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - - # make sure the full path doesn't load until the parm has a value - self.assertEqual( node.parm( "fullPathName" ).eval(), "" ) - self.assertEqual( node.geometry().findPrimAttrib( "path" ), None ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name"] ) - - # now lets load it an validate the paths - node.parm( "fullPathName" ).set( "path" ) - self.assertEqual( sorted( [ x.name() for x in node.geometry().primAttribs() ] ), ["Cd", "ieMeshInterpolation", "name", "path"] ) - - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - pathAttr = node.geometry().findPrimAttrib( "path" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - self.assertEqual( pathAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - for path in pathAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "path" ) == path ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - pathAttr = node.geometry().findPrimAttrib( "path" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - self.assertEqual( pathAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - for path in pathAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "path" ) == path ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1/2" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 12 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - pathAttr = node.geometry().findPrimAttrib( "path" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/3' ] ) ) - self.assertEqual( pathAttr.strings(), tuple( [ '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - for path in pathAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "path" ) == path ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 3, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - node.parm( "root" ).set( "/1/2/3" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 6 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - pathAttr = node.geometry().findPrimAttrib( "path" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/' ] ) ) - self.assertEqual( pathAttr.strings(), tuple( [ '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - for path in pathAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "path" ) == path ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 6, 0, 0 ) ) - - def testReloadButton( self ) : - - def testNode( node ) : - - self.assertEqual( node.cookCount(), 0 ) - node.cook() - self.assertEqual( node.cookCount(), 1 ) - node.cook() - self.assertEqual( node.cookCount(), 1 ) - node.parm( "reload" ).pressButton() - node.cook() - self.assertEqual( node.cookCount(), 2 ) - node.cook() - self.assertEqual( node.cookCount(), 2 ) - node.parm( "reload" ).pressButton() - node.cook() - self.assertEqual( node.cookCount(), 3 ) - - self.writeSCC() - testNode( self.sop() ) - testNode( self.xform() ) - testNode( self.geometry() ) - testNode( self.sopXform() ) - - def writeAnimSCC( self, rotate = False, scale=False, includeMesh=True, writeMRef=False ) : - - scene = self.writeSCC( includeMesh=includeMesh ) - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - if includeMesh: - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - - for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - - matrix = imath.M44d().translate( imath.V3d( 1, time, 0 ) ) - if rotate : - matrix.rotate( imath.V3d( time, 0, 0 ) ) - if scale : - matrix.scale( imath.V3d( time, 1, 1 ) ) - sc1.writeTransform( IECore.M44dData( matrix ), time ) - if writeMRef: - sc1.writeAttribute( "user:Mref", IECore.M44dData( matrix ), time ) - if not includeMesh: - sc1.writeBound( imath.Box3d( imath.V3d(0), imath.V3d(0) ), time ) - - if includeMesh: - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( time, 1, 0 ) ] * 6 ) ) - sc2.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) - if rotate : - matrix.rotate( imath.V3d( time, 0, 0 ) ) - if not includeMesh: - sc2.writeBound( imath.Box3d( imath.V3d(0), imath.V3d(0) ), time ) - sc2.writeTransform( IECore.M44dData( matrix ), time ) - if writeMRef: - sc2.writeAttribute( "user:Mref", IECore.M44dData( matrix ), time ) - - matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) - if rotate : - matrix.rotate( imath.V3d( time, 0, 0 ) ) - if not includeMesh: - sc3.writeBound( imath.Box3d( imath.V3d(0), imath.V3d(0) ), time ) - sc3.writeTransform( IECore.M44dData( matrix ), time ) - if writeMRef: - sc3.writeAttribute( "user:Mref", IECore.M44dData( matrix ), time ) - - return scene - - def testAnimatedScene( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - sop = self.sop() - for time in times : - hou.setTime( time - spf ) - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, time, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 2*time, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 3*time, 0 ) ) - self.assertEqual( prims[6].attribValue( "Cd" ), ( time, 1, 0 ) ) - - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, time + 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, 2*time + 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, 3*time + 0.5, 0.5 ) ) - - xform = self.xform() - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - b = [ x for x in a.children() if x.name() != "geo" ][0] - c = [ x for x in b.children() if x.name() != "geo" ][0] - for time in times : - if hou.applicationVersion()[0] >= 14 : - self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time * 2, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, time * 3, 0 ) ) ) - else : - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - - for time in times : - hou.setTime( time - spf ) - self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - b = xform.children()[1] - c = xform.children()[2] - for time in times : - if hou.applicationVersion()[0] >= 14 : - self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.localTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, 2*time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, 3*time, 0 ) ) ) - else : - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, 2*time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, 3*time, 0 ) ) ) - - for time in times : - hou.setTime( time - spf ) - self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - - def testSopXformNameMode( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - node = self.sopXform() - - # prims transform according to their name - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3.5, time*2 - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6.5, time*3 - 0.5, -0.5 ) ) - - # names are relative to the root parm, and non-matching names are ignored - node.parm( "root" ).set( "/1/2" ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - - # making the names relative again so the transformations take effect - node.inputConnections()[0].inputNode().inputConnections()[1].inputNode().parm( "name1" ).set( "/" ) - node.inputConnections()[0].inputNode().inputConnections()[2].inputNode().parm( "name1" ).set( "/3" ) - - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/', '/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - # still doesn't animate because /1 doesn't match any child of /1/2 - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - # these ones are proper relative paths - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3.5, time*2 - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6.5, time*3 - 0.5, -0.5 ) ) - - # testing invert toggle - node.parm( "invert" ).set( True ) - node.parm( "root" ).set( "/" ) - node.inputConnections()[0].inputNode().inputConnections()[1].inputNode().parm( "name1" ).set( "/1/2" ) - node.inputConnections()[0].inputNode().inputConnections()[2].inputNode().parm( "name1" ).set( "/1/2/3" ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertTrue( prims[0].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -0.5, -time - 0.5, -0.5 ) ) ) - self.assertTrue( prims[6].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -2.5, -time*2 - 0.5, -0.5 ) ) ) - self.assertTrue( prims[12].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -5.5, -time*3 - 0.5, -0.5 ) ) ) - - def testSopXformRootMode( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - node = self.sopXform() - node.parm( "mode" ).set( 1 ) - - # in root mode all prims transform to match the root transform, regardless of name - node.parm( "root" ).set( "/1" ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - - node.parm( "root" ).set( "/1/2" ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 3.5, 2*time - 0.5, -0.5 ) ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 3.5, 2*time - 0.5, -0.5 ) ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 3.5, 2*time - 0.5, -0.5 ) ) - - # testing invert toggle - node.parm( "invert" ).set( True ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertTrue( prims[0].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -2.5, -2*time - 0.5, -0.5 ) ) ) - self.assertTrue( prims[6].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -2.5, -2*time - 0.5, -0.5 ) ) ) - self.assertTrue( prims[12].vertex( 0 ).point().position().isAlmostEqual( hou.Vector3( -2.5, -2*time - 0.5, -0.5 ) ) ) - - def testSopXformSpaces( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - node = self.sopXform() - node.parm( "root" ).set( "/1" ) - node.inputConnections()[0].inputNode().inputConnections()[0].inputNode().parm( "name1" ).set( "/" ) - node.inputConnections()[0].inputNode().inputConnections()[1].inputNode().parm( "name1" ).set( "/2" ) - node.inputConnections()[0].inputNode().inputConnections()[2].inputNode().parm( "name1" ).set( "/2/3" ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.World ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3.5, time*2 - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6.5, time*3 - 0.5, -0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Path ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 2.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 5.5,time*2 - 0.5, -0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Local ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 2.5, time - 0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 3.5, time - 0.5, -0.5 ) ) - - node.parm( "space" ).set( IECoreHoudini.SceneCacheNode.Space.Object ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/2', '/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 0.5, -0.5, -0.5 ) ) - - def testSopXformRestDoesNotTransform( self ) : - - self.writeAnimSCC() - - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - source = self.sop() - source.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - source.parm( "attributeCopy" ).set( "P:Pref" ) - xform = source.createOutputNode( "ieSceneCacheTransform" ) - xform.parm( "file" ).set( self._testFile ) - - for time in times : - hou.setTime( time - spf ) - prims = xform.geometry().prims() - self.assertEqual( len(prims), 18 ) - # positions are double transformed (once by the source sop and once by the xform) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 2, 2*time, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 6, 4*time, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 12, 6*time, 0 ) ) - # rest doesn't transform from either source or xform - self.assertEqual( prims[0].vertex( 0 ).point().attribValue( "rest" ), ( 0, 0, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().attribValue( "rest" ), ( 0, 0, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().attribValue( "rest" ), ( 0, 0, 0 ) ) - - def testOBJOutputParms( self ) : - - self.writeAnimSCC() - xform = self.xform() - xform.parm( "expand" ).pressButton() - c = hou.node( xform.path()+"/1/2/3" ) - - spf = 1.0 / hou.fps() - hou.setTime( 0 - spf ) - self.assertEqual( c.cookCount(), 0 ) - self.assertEqual( c.parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( c.parmTuple( "outR" ).eval(), ( 0, 0, 0 ) ) - self.assertEqual( c.parmTuple( "outS" ).eval(), ( 1, 1, 1 ) ) - # evaluating the output parms forces a cook - self.assertEqual( c.cookCount(), 0 ) - - # referencing the output parms forces a cook - null = hou.node( "/obj" ).createNode( "null" ) - self.assertEqual( null.parmTuple( "t" ).eval(), ( 0, 0, 0 ) ) - null.parm( "tx" ).setExpression( 'ch( "%s/outTx" )' % c.path() ) - null.parm( "ty" ).setExpression( 'ch( "%s/outTy" )' % c.path() ) - null.parm( "tz" ).setExpression( 'ch( "%s/outTz" )' % c.path() ) - self.assertEqual( null.parmTuple( "t" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( c.parmTuple( "outT" ).eval(), ( 3, 0, 0 ) ) - self.assertEqual( c.cookCount(), 0 ) - - # changing the time updates the output parms - hou.setTime( 2.5 - spf ) - self.assertEqual( null.parmTuple( "t" ).eval(), ( 3, 2.5, 0 ) ) - self.assertEqual( c.parmTuple( "outT" ).eval(), ( 3, 2.5, 0 ) ) - self.assertEqual( c.cookCount(), 0 ) - - # referencing the node via origin returns the same results - null2 = hou.node( "/obj" ).createNode( "null" ) - self.assertEqual( null2.parmTuple( "t" ).eval(), ( 0, 0, 0 ) ) - null2.parm( "tx" ).setExpression( 'origin( "", "%s", "TX" )' % c.path() ) - null2.parm( "ty" ).setExpression( 'origin( "", "%s", "TY" )' % c.path() ) - null2.parm( "tz" ).setExpression( 'origin( "", "%s", "TZ" )' % c.path() ) - if hou.applicationVersion()[0] >= 14 : - self.assertEqual( null2.parmTuple( "t" ).eval(), ( 6, 2.5 * 3, 0 ) ) - else : - self.assertEqual( null2.parmTuple( "t" ).eval(), ( 3, 2.5, 0 ) ) - self.assertEqual( c.parmTuple( "outT" ).eval(), ( 3, 2.5, 0 ) ) - self.assertEqual( c.cookCount(), 1 ) - - # evaluating at different times also works - self.assertEqual( c.parmTuple( "outT" ).evalAtTime( 2.75 - spf ), ( 3, 2.75, 0 ) ) - self.assertEqual( null.parmTuple( "t" ).evalAtTime( 5.25 - spf ), ( 3, 5.25, 0 ) ) - self.assertEqual( c.cookCount(), 1 ) - - def compareScene( self, a, b, time = 0, bakedObjects = [], parentTransform = None, ignoreAttributes = [] ) : - - self.assertEqual( a.name(), b.name() ) - self.assertEqual( a.path(), b.path() ) - if b.name() in bakedObjects : - aTransform = a.readTransformAsMatrix( time ) - parentTransform = aTransform if parentTransform is None else aTransform * parentTransform - self.assertEqual( b.readTransformAsMatrix( time ), imath.M44d() ) - else : - self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.LocalTag)), set(b.readTags(IECoreScene.SceneInterface.LocalTag)) ) - self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.DescendantTag)), set(b.readTags(IECoreScene.SceneInterface.DescendantTag)) ) - self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.AncestorTag)), set(b.readTags(IECoreScene.SceneInterface.AncestorTag)) ) - self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.EveryTag)), set(b.readTags(IECoreScene.SceneInterface.EveryTag)) ) - self.assertTrue( a.readTransformAsMatrix( time ).equalWithAbsError( b.readTransformAsMatrix( time ), 1e-6 ) ) - ab = a.readBound( time ) - bb = b.readBound( time ) - self.assertTrue( ab.min().equalWithAbsError( bb.min(), 1e-6 ) ) - self.assertTrue( ab.max().equalWithAbsError( bb.max(), 1e-6 ) ) - - aAttrs = a.attributeNames() - bAttrs = b.attributeNames() - - aAttrs = list( set( aAttrs ) - set( ignoreAttributes ) ) - bAttrs = list( set( bAttrs ) - set( ignoreAttributes ) ) - - # need to remove the animatedObjectPrimVars attribute since it doesn't exist in some circumstances - if "sceneInterface:animatedObjectPrimVars" in aAttrs : - aAttrs.remove( "sceneInterface:animatedObjectPrimVars" ) - if "sceneInterface:animatedObjectPrimVars" in bAttrs : - bAttrs.remove( "sceneInterface:animatedObjectPrimVars" ) - self.assertEqual( sorted( aAttrs ), sorted( bAttrs ) ) - for attr in aAttrs : - self.assertTrue( a.hasAttribute( attr ) ) - self.assertTrue( b.hasAttribute( attr ) ) - self.assertEqual( a.readAttribute( attr, time ), b.readAttribute( attr, time ) ) - - self.assertEqual( a.hasObject(), b.hasObject() ) - if a.hasObject() : - ma = a.readObject( time ) - mb = b.readObject( time ) - # need to adjust P for baked objects - if b.name() in bakedObjects : - IECoreScene.TransformOp()( input=ma, copyInput=False, matrix=IECore.M44dData( parentTransform ) ) - self.assertEqual( ma, mb ) - - self.assertEqual( sorted( a.childNames() ), sorted( b.childNames() ) ) - for child in a.childNames() : - self.compareScene( a.child( child ), b.child( child ), time = time, bakedObjects = bakedObjects, parentTransform = parentTransform ) - - def testRopHierarchy( self ) : - - # test a parented xform - self.writeTaggedSCC() - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "expand" ).pressButton() - rop = self.rop( xform ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testOutFile ) ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output ) - - # test a subnet xform - os.remove( self._testOutFile ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "expand" ).pressButton() - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output ) - - # test a mixed subnet/parented xform - os.remove( self._testOutFile ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - a.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - a.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - a.parm( "expand" ).pressButton() - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output ) - - def testRopFlattened( self ) : - - # test a flat xform - self.writeSCC() - xform = self.xform() - rop = self.rop( xform ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.FlatGeometry ) - xform.parm( "expand" ).pressButton() - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output, bakedObjects = [ "1", "2", "3" ] ) - - # test a mixed subnet/flat xform - os.remove( self._testOutFile ) - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - a.parm( "expand" ).pressButton() - b = a.children()[1] - b.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.FlatGeometry ) - b.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - b.parm( "expand" ).pressButton() - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output, bakedObjects = [ "3" ] ) - - # test a OBJ Geo - os.remove( self._testOutFile ) - geo = self.geometry() - geo.parm( "expand" ).pressButton() - rop.parm( "rootObject" ).set( geo.path() ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output, bakedObjects = [ "1", "2", "3" ] ) - - def testRopFlattenedWithGaps( self ) : - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - - sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) - sc.writeObject( mesh, 0 ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 2 ) ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) - sc.writeObject( mesh, 0 ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0 ) - - del scene, sc - - geo = self.geometry() - geo.parm( "expand" ).pressButton() - self.assertEqual( len(geo.children()), 1 ) - node = geo.children()[0] - self.assertEqual( node.name(), "root" ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 2 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - - rop = self.rop( geo ) - rop.parm( "rootObject" ).set( geo.path() ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, output, bakedObjects = [ "1", "2", "3" ] ) - - def testRopTopLevelGeo( self ) : - - self.writeSCC() - geo = self.geometry() - geo.parm( "expand" ).pressButton() - attr = geo.children()[0].createOutputNode( "attribute" ) - attr.parm( "primdel" ).set( "name" ) - attr.setDisplayFlag( True ) - attr.setRenderFlag( True ) - rop = self.rop( geo ) - rop.parm( "trange" ).set( 1 ) - rop.parmTuple( "f" ).set( ( 1, 10, 1 ) ) - - rop.parm( "execute" ).pressButton() - - # unable to convert the 3 cortex objects. - # "Error converting SOP: '/obj/ieSceneCacheGeometry1' to scc. Potentially unsupported prim types found: [ CortexObject ]" - self.assertEqual( len( rop.errors() ) , 1 ) - - def testRopFlattenedWithErrors( self ) : - - self.writeSCC() - geo = self.geometry() - geo.parm( "expand" ).pressButton() - rop = self.rop( geo ) - rop.parm( "rootObject" ).set( geo.path() ) - rop.parm( "trange" ).set( 1 ) - rop.parmTuple( "f" ).set( ( 1, 10, 1 ) ) - geo.renderNode().parm( "file" ).set( self._fake ) - rop.parm( "execute" ).pressButton() - self.assertNotEqual( len( rop.errors()) , 0 ) - self.assertTrue(geo.renderNode().path() in "".join(rop.errors())) - self.assertTrue("".join(geo.renderNode().errors()) in "".join(rop.errors())) - - def testRopLinked( self ) : - - self.writeTaggedSCC() - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - a.parm( "expand" ).pressButton() - # leaving b and below as a link - - rop = self.rop( xform ) - rop.parm( "file" ).set( self._testLinkedOutFile ) - self.assertFalse( os.path.exists( self._testLinkedOutFile ) ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testLinkedOutFile ) ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - linked = IECoreScene.LinkedScene( self._testLinkedOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, linked, ignoreAttributes = ['linkLocations'] ) - - # make sure there really is a link - unlinked = IECoreScene.SceneCache( self._testLinkedOutFile, IECore.IndexedIO.OpenMode.Read ) - a = unlinked.child( "1" ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.timeLinkAttribute ) ) - b = a.child( "2" ) - self.assertEqual( b.childNames(), [] ) - self.assertFalse( b.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertTrue( b.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertTrue( b.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute, 0 ), IECore.StringData( self._testFile ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.rootLinkAttribute, 0 ), IECore.InternedStringVectorData( [ "1", "2" ] ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.timeLinkAttribute, 0 ), IECore.DoubleData( 1.0 / hou.fps() ) ) - - # make sure we can force link expansion - xform.parm( "collapse" ).pressButton() - xform.parm( "file" ).set( self._testLinkedOutFile ) - self.assertEqual( xform.children(), tuple() ) - self.assertEqual( xform.parm( "expanded" ).eval(), False ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "expand" ).pressButton() - rop.parm( "file" ).set( self._testOutFile ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testOutFile ) ) - expanded = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, expanded, ignoreAttributes = ['linkLocations'] ) - self.compareScene( expanded, linked ) - - # make sure we can read back the whole structure in Houdini - xform.parm( "collapse" ).pressButton() - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - xform.parm( "expand" ).pressButton() - live = IECoreHoudini.LiveScene( xform.path(), rootPath = [ xform.name() ] ) - self.compareScene( orig, live, ignoreAttributes = ['linkLocations'] ) - - # make sure it doesn't crash if the linked scene doesn't exist anymore - xform.parm( "collapse" ).pressButton() - os.remove( self._testFile ) - IECoreScene.SharedSceneInterfaces.clear() - xform.parm( "reload" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertEqual( xform.parm( "root" ).menuItems(), ( "/", "/1", "/1/2" ) ) - - def testRopForceObjects( self ) : - - s = self.writeAttributeSCC() - d = s.child( "1" ).createChild( "4" ) - e = d.createChild( "5" ) - box = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - d.writeObject( box, 0 ) - e.writeObject( box, 0 ) - - del s, d, e - - def testLinks( bakedObjects = None ) : - - if os.path.exists( self._testLinkedOutFile ) : - os.remove( self._testLinkedOutFile ) - - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testLinkedOutFile ) ) - linked = IECoreScene.LinkedScene( self._testLinkedOutFile, IECore.IndexedIO.OpenMode.Read ) - if bakedObjects : - live = IECoreHoudini.LiveScene( xform.path(), rootPath = [ xform.name() ] ) - self.compareScene( linked, live, bakedObjects = bakedObjects, ignoreAttributes = ['linkLocations'] ) - else : - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, linked, ignoreAttributes = ['linkLocations'] ) - - # make sure the links are where we expect - unlinked = IECoreScene.SceneCache( self._testLinkedOutFile, IECore.IndexedIO.OpenMode.Read ) - a = unlinked.child( "1" ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertFalse( a.hasAttribute( IECoreScene.LinkedScene.timeLinkAttribute ) ) - b = a.child( "2" ) - self.assertEqual( b.childNames(), [] ) - self.assertFalse( b.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertTrue( b.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertTrue( b.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute, 0 ), IECore.StringData( self._testFile ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.rootLinkAttribute, 0 ), IECore.InternedStringVectorData( [ "1", "2" ] ) ) - self.assertEqual( b.readAttribute( IECoreScene.LinkedScene.timeLinkAttribute, 0 ), IECore.DoubleData( 0 ) ) - d = a.child( "4" ) - self.assertFalse( d.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertFalse( d.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertFalse( d.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertFalse( d.hasAttribute( IECoreScene.LinkedScene.timeLinkAttribute ) ) - - # force b and below as links even though they are expanded - hou.setTime( -1.0 / hou.fps() ) - xform = self.xform() - xform.parm( "expand" ).pressButton() - rop = self.rop( xform ) - rop.parm( "file" ).set( self._testLinkedOutFile ) - rop.parm( "forceObjects" ).set( "*4*" ) - testLinks() - - # make sure parents expand if their child is forced - rop.parm( "forceObjects" ).set( "*5*" ) - testLinks() - - # make sure normal geo gets expanded regardless - geo = xform.createNode( "geo", "real" ) - geo.createNode( "box" ) - testLinks( bakedObjects = [ "real" ] ) - unlinked = IECoreScene.SceneCache( self._testLinkedOutFile, IECore.IndexedIO.OpenMode.Read ) - real = unlinked.child( "real" ) - self.assertFalse( real.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertFalse( real.hasAttribute( IECoreScene.LinkedScene.fileNameLinkAttribute ) ) - self.assertFalse( real.hasAttribute( IECoreScene.LinkedScene.rootLinkAttribute ) ) - self.assertFalse( real.hasAttribute( IECoreScene.LinkedScene.timeLinkAttribute ) ) - self.assertTrue( real.hasObject() ) - geo.destroy() - - # make sure natural links (unexpanded branches) still work - hou.node( xform.path() + "/1/2" ).parm( "collapse" ).pressButton() - testLinks() - - # make sure normal SceneCaches aren't broken by forceObjects - rop.parm( "file" ).set( self._testOutFile ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testOutFile ) ) - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - result = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.compareScene( orig, result ) - - def testRopErrors( self ) : - - xform = self.xform() - rop = self.rop( xform ) - rop.parm( "file" ).set( self._badFile ) - rop.parm( "execute" ).pressButton() - self.assertNotEqual( len( rop.errors()) , 0 ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - - rop.parm( "file" ).set( self._testOutFile ) - rop.parm( "rootObject" ).set( "/obj/fake/object" ) - self.assertNotEqual( len( rop.errors()) , 0 ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - - rop.parm( "rootObject" ).set( xform.path() ) - xform.destroy() - self.assertNotEqual( len( rop.errors()) , 0 ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - - sop = self.sop() - rop.parm( "rootObject" ).set( sop.path() ) - rop.parm( "execute" ).pressButton() - self.assertNotEqual( len( rop.errors()) , 0 ) - self.assertFalse( os.path.exists( self._testOutFile ) ) - - newXform = self.xform() - rop.parm( "rootObject" ).set( newXform.path() ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertTrue( os.path.exists( self._testOutFile ) ) - - def testAnimatedRop( self ) : - - self.writeAnimSCC() - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) - xform.parm( "expand" ).pressButton() - rop = self.rop( xform ) - rop.parm( "trange" ).set( 1 ) - rop.parmTuple( "f" ).set( ( 0, 10 * hou.fps(), 1 ) ) - rop.parm( "execute" ).pressButton() - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - for time in times : - self.compareScene( orig, output, time ) - - def testRopCookCounts( self ) : - - self.writeAnimSCC() - xform = self.xform() - xform.parm( "expand" ).pressButton() - a = hou.node( xform.path()+"/1/geo/1" ) # static - b = hou.node( xform.path()+"/1/2/geo/2" ) # animated - c = hou.node( xform.path()+"/1/2/3/geo/3" ) # static - # make sure nothing has been cooked - self.assertEqual( a.cookCount(), 0 ) - self.assertEqual( b.cookCount(), 0 ) - self.assertEqual( c.cookCount(), 0 ) - - # cook current frame - rop = self.rop( xform ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertEqual( a.cookCount(), 1 ) - self.assertEqual( b.cookCount(), 1 ) - self.assertEqual( c.cookCount(), 1 ) - - # cook single frame that is not the current frame - self.assertNotEqual( hou.frame(), 10 ) - rop.parm( "trange" ).set( 1 ) - rop.parm( "f1" ).set( 10 ) - rop.parm( "f2" ).set( 10 ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertEqual( a.cookCount(), 1 ) - self.assertEqual( b.cookCount(), 2 ) - self.assertEqual( c.cookCount(), 1 ) - - # cook a range - rop.parm( "f1" ).set( 1 ) - rop.parm( "f2" ).set( 10 ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - self.assertEqual( a.cookCount(), 1 ) - self.assertEqual( b.cookCount(), 12 ) - self.assertEqual( c.cookCount(), 1 ) - - # with flat geo - sop = self.sop() - self.assertEqual( sop.cookCount(), 0 ) - rop.parm( "rootObject" ).set( sop.parent().path() ) - rop.parm( "trange" ).set( 1 ) - rop.parm( "f1" ).set( 10 ) - rop.parm( "f2" ).set( 10 ) - rop.parm( "execute" ).pressButton() - self.assertEqual( sop.cookCount(), 1 ) - - def testRopDynamicSopHierarchy( self ) : - - self.writeAnimSCC() - obj = self.geometry() - obj.parm( "expand" ).pressButton() - delete = obj.renderNode().createOutputNode( "delete" ) - delete.parm( "groupop" ).set( 1 ) # by range - delete.parm( "rangestart" ).set( 2 ) - delete.parm( "rangeend" ).set( 2 ) - switch = obj.renderNode().createOutputNode( "switch" ) - switch.setInput( 1, delete ) - switch.parm( "input" ).setExpression( "if hou.frame() >= 5 :\n\treturn 0\nelse :\n\treturn 1", hou.exprLanguage.Python ) - switch.setRenderFlag( True ) - - rop = self.rop( obj ) - rop.parm( "trange" ).set( 1 ) - rop.parm( "f1" ).set( 1 ) - rop.parm( "f2" ).set( 20 ) - rop.parm( "execute" ).pressButton() - - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - a = output.child( "1" ) - b = a.child( "2" ) - c = b.child( "3" ) - attr = "scene:visible" - self.assertFalse( a.hasAttribute( attr ) ) - self.assertFalse( b.hasAttribute( attr ) ) - self.assertTrue( c.hasAttribute( attr ) ) - self.assertEqual( c.readAttribute( attr, 0 ), IECore.BoolData( False ) ) - self.assertEqual( c.readAttribute( attr, 0.2083 ), IECore.BoolData( False ) ) - self.assertEqual( c.readAttribute( attr, 0.2084 ), IECore.BoolData( True ) ) - self.assertEqual( c.readAttribute( attr, 1 ), IECore.BoolData( True ) ) - - del output, a, b, c - IECoreScene.SharedSceneInterfaces.clear() - - # make sure it can appear and disappear correctly - switch.parm( "input" ).setExpression( "if hou.frame() < 5 or hou.frame() >= 10 :\n\treturn 1\nelse :\n\treturn 0", hou.exprLanguage.Python ) - rop.parm( "execute" ).pressButton() - hou.hipFile.save( "/tmp/bunk.hip" ) - output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - a = output.child( "1" ) - b = a.child( "2" ) - c = b.child( "3" ) - self.assertFalse( a.hasAttribute( attr ) ) - self.assertFalse( b.hasAttribute( attr ) ) - self.assertTrue( c.hasAttribute( attr ) ) - self.assertEqual( c.readAttribute( attr, 0 ), IECore.BoolData( False ) ) - self.assertEqual( c.readAttribute( attr, 0.2083 ), IECore.BoolData( False ) ) - self.assertEqual( c.readAttribute( attr, 0.2084 ), IECore.BoolData( True ) ) - self.assertEqual( c.readAttribute( attr, 0.3 ), IECore.BoolData( True ) ) - self.assertEqual( c.readAttribute( attr, 0.4167 ), IECore.BoolData( False ) ) - self.assertEqual( c.readAttribute( attr, 1 ), IECore.BoolData( False ) ) - - def testROPRelativeNodePath( self ): - - self.writeAnimSCC() - obj = self.geometry() - - parent = obj.node( ".." ) - ropNet = parent.createNode( "ropnet" ) - - rop = self.rop( obj, ropNet.path() ) - relativePath = rop.relativePathTo( obj ) - rop.parm( "rootObject" ).set( relativePath ) - rop.parm( "trange" ).set( 1 ) - rop.parm( "f1" ).set( 1 ) - rop.parm( "f2" ).set( 20 ) - rop.parm( "execute" ).pressButton() - - self.assertNotEqual( len( rop.errors()) , 0 ) - - # make sure full path still works. - rop.parm( "rootObject" ).set( obj.path() ) - - self.assertNotEqual( len( rop.errors()) , 0 ) - - def testLiveScene( self ) : - - self.writeTaggedSCC() - xform = self.xform() - xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.SubNetworks ) - xform.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.Children ) - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - a.parm( "expand" ).pressButton() - b = a.children()[1] - b.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.FlatGeometry ) - b.parm( "depth" ).set( IECoreHoudini.SceneCacheNode.Depth.AllDescendants ) - b.parm( "expand" ).pressButton() - orig = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Read ) - live = IECoreHoudini.LiveScene( xform.path(), rootPath = [ xform.name() ] ) - self.compareScene( orig, live, bakedObjects = [ "3" ] ) - - def testLiveSceneSupportOutputNode( self ): - - sop = self.sopScene() - sop.setRenderFlag( True ) - parent = sop.node( ".." ) - - scene = IECoreHoudini.LiveScene( parent.path() ) - self.assertEqual( len( scene.childNames() ), 1 ) - geo = scene.readObject( 0 ) - - outputNode = sop.createOutputNode( "output" ) - null = parent.createNode("null") - null.setRenderFlag( True ) - - scene = IECoreHoudini.LiveScene( parent.path() ) - outputGeo = scene.readObject( 0 ) - - self.assertEqual( geo, outputGeo ) - self.assertEqual( len( scene.childNames() ), 1 ) - - def testTopologyChanges( self ) : - - plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) - box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) - box["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) - box2 = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 2 ), imath.V3f( 3 ) ) ) - box2["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) - - s = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - a = s.createChild( "a" ) - b = a.createChild( "b" ) - c = a.createChild( "c" ) - d = a.createChild( "d" ) - - # animated topology - b.writeObject( box, 0 ) - b.writeObject( plane, 1 ) - - # static - c.writeObject( box, 0 ) - c.writeObject( box, 1 ) - - # animated P and Cd - d.writeObject( box, 0 ) - d.writeObject( box2, 1 ) - del s, a, b, c, d - - spf = 1.0 / hou.fps() - hou.setTime( 0 - spf ) - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - self.assertEqual( len(node.geometry().points()), 24 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( set(nameAttr.strings()), set([ '/a/b', '/a/c', '/a/d' ]) ) - bPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/b' ] - cPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/c' ] - dPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/d' ] - self.assertEqual( len(bPrims), 6 ) - self.assertEqual( len(cPrims), 6 ) - self.assertEqual( len(dPrims), 6 ) - self.assertEqual( bPrims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( cPrims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( dPrims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( bPrims[0].attribValue( "Cd" ), ( 1, 0, 0 ) ) - self.assertEqual( cPrims[0].attribValue( "Cd" ), ( 1, 0, 0 ) ) - self.assertEqual( dPrims[0].attribValue( "Cd" ), ( 1, 0, 0 ) ) - - hou.setTime( 1 - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 13 ) - self.assertEqual( len(node.geometry().points()), 20 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( set(nameAttr.strings()), set([ '/a/b', '/a/c', '/a/d' ]) ) - bPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/b' ] - cPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/c' ] - dPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/d' ] - self.assertEqual( len(bPrims), 1 ) - self.assertEqual( len(cPrims), 6 ) - self.assertEqual( len(dPrims), 6 ) - self.assertEqual( bPrims[0].vertex( 0 ).point().position(), hou.Vector3( -1, 1, 0 ) ) - self.assertEqual( cPrims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( dPrims[0].vertex( 0 ).point().position(), hou.Vector3( 2, 2, 2 ) ) - self.assertEqual( bPrims[0].attribValue( "Cd" ), ( 0, 0, 0 ) ) - self.assertEqual( cPrims[0].attribValue( "Cd" ), ( 1, 0, 0 ) ) - self.assertEqual( dPrims[0].attribValue( "Cd" ), ( 0, 1, 0 ) ) - - hou.setTime( 0.5 - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 13 ) - self.assertEqual( len(node.geometry().points()), 20 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( set(nameAttr.strings()), set([ '/a/b', '/a/c', '/a/d' ]) ) - bPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/b' ] - cPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/c' ] - dPrims = [ x for x in prims if x.attribValue( nameAttr ) == '/a/d' ] - self.assertEqual( len(bPrims), 1 ) - self.assertEqual( len(cPrims), 6 ) - self.assertEqual( len(dPrims), 6 ) - self.assertEqual( bPrims[0].vertex( 0 ).point().position(), hou.Vector3( -1, 1, 0 ) ) - self.assertEqual( cPrims[0].vertex( 0 ).point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( dPrims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 1, 1 ) ) - self.assertEqual( bPrims[0].attribValue( "Cd" ), ( 0, 0, 0 ) ) - self.assertEqual( cPrims[0].attribValue( "Cd" ), ( 1, 0, 0 ) ) - self.assertEqual( dPrims[0].attribValue( "Cd" ), ( 0.5, 0.5, 0 ) ) - - def testSaveLoadCortexObjects( self ) : - - self.writeSCC() - sop = self.sop() - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - null = sop.createOutputNode( "null" ) - nullPath = null.path() - prims = null.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - # make sure they survive the locks - null.setHardLocked( True ) - null.setInput( 0, None ) - prims = null.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - # make sure they survive a scene save/load - hou.hipFile.save( self._testHip ) - hou.hipFile.load( self._testHip ) - null = hou.node( nullPath ) - prims = null.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - # make sure they survive bgeo caching - writer = null.createOutputNode( "file" ) - writer.parm( "file" ).set( self._testBgeo ) - writer.parm( "filemode" ).set( 2 ) # write - writer.cook( force = True ) - reader = null.parent().createNode( "file" ) - reader.parm( "file" ).set( self._testBgeo ) - prims = reader.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - # make sure they survive bgeo.gz caching - writer.parm( "file" ).set( self._testBgeoGz ) - writer.cook( force = True ) - reader = null.parent().createNode( "file" ) - reader.parm( "file" ).set( self._testBgeoGz ) - prims = reader.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - # make sure they survive geo caching - writer.parm( "file" ).set( self._testGeo ) - writer.cook( force = True ) - reader = null.parent().createNode( "file" ) - reader.parm( "file" ).set( self._testGeo ) - prims = reader.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, 3 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - def testStashing( self ) : - - self.writeSCC() - sop = self.sop() - writer = sop.createOutputNode( "file" ) - writer.parm( "file" ).set( self._testBgeo ) - writer.parm( "filemode" ).set( 2 ) # write - writer.cook( force = True ) - reader = sop.parent().createNode( "file" ) - reader.parm( "file" ).set( self._testBgeo ) - reader.cook( force = True ) - reader.cook( force = True ) - - def testNonPrimitiveCortexObjects( self ) : - - scene = self.writeAnimSCC() - coordChild = scene.child( "1" ).createChild( "coord" ) - coord = IECoreScene.CoordinateSystem() - coord.setName( "testing" ) - coord.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) - coordChild.writeObject( coord, 0 ) - coord.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1, 5, 5 ) ) ) ) - coordChild.writeObject( coord, 1 ) - intsChild = scene.createChild( "ints" ) - intsChild.writeObject( IECore.IntVectorData( [ 1, 10, 20, 30 ] ), 0 ) - - del scene, coordChild, intsChild - - spf = 1.0 / hou.fps() - hou.setTime( 0 - spf ) - sop = self.sop() - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 5 ) - - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted(nameAttr.strings()), ['/1', '/1/2', '/1/2/3', '/1/coord', '/ints'] ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - - for i in range( 0, 5 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - aPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1' ][0] - bPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/2' ][0] - cPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/2/3' ][0] - coordPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/coord' ][0] - intsPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/ints' ][0] - - self.assertEqual( aPrim.vertices()[0].point().position(), hou.Vector3( 1.5, 0.5, 0.5 ) ) - self.assertEqual( bPrim.vertices()[0].point().position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( cPrim.vertices()[0].point().position(), hou.Vector3( 6.5, 0.5, 0.5 ) ) - self.assertEqual( coordPrim.vertices()[0].point().position(), hou.Vector3( 2, 2, 3 ) ) - self.assertEqual( intsPrim.vertices()[0].point().position(), hou.Vector3( 0, 0, 0 ) ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( isinstance( converter, IECoreHoudini.FromHoudiniCompoundObjectConverter ) ) - result = converter.convert() - self.assertTrue( isinstance( result, IECore.CompoundObject ) ) - self.assertEqual( sorted( result.keys() ), ['/1', '/1/2', '/1/2/3', '/1/coord', '/ints'] ) - self.assertTrue( isinstance( result["/1"], IECoreScene.MeshPrimitive ) ) - self.assertTrue( isinstance( result["/1/2"], IECoreScene.MeshPrimitive ) ) - self.assertTrue( isinstance( result["/1/2/3"], IECoreScene.MeshPrimitive ) ) - self.assertTrue( isinstance( result["/1/coord"], IECoreScene.CoordinateSystem ) ) - self.assertEqual( result["/ints"], IECore.IntVectorData( [ 1, 10, 20, 30 ] ) ) - - hou.setTime( 1 - spf ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 5 ) - - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted(nameAttr.strings()), ['/1', '/1/2', '/1/2/3', '/1/coord', '/ints'] ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - - for i in range( 0, 5 ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - - aPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1' ][0] - bPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/2' ][0] - cPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/2/3' ][0] - coordPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/1/coord' ][0] - intsPrim = [ x for x in prims if x.attribValue( nameAttr ) == '/ints' ][0] - - self.assertEqual( aPrim.vertices()[0].point().position(), hou.Vector3( 1.5, 1.5, 0.5 ) ) - self.assertEqual( bPrim.vertices()[0].point().position(), hou.Vector3( 3.5, 2.5, 0.5 ) ) - self.assertEqual( cPrim.vertices()[0].point().position(), hou.Vector3( 6.5, 3.5, 0.5 ) ) - self.assertEqual( coordPrim.vertices()[0].point().position(), hou.Vector3( 2, 6, 5 ) ) - self.assertEqual( intsPrim.vertices()[0].point().position(), hou.Vector3( 0, 0, 0 ) ) - - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 18 ) - self.assertTrue( "/1/coord" in "".join(sop.warnings()) ) - self.assertTrue( "/ints" in "".join(sop.warnings()) ) - - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, 1, 0 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, 2, 0 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, 3, 0 ) ) - - def testCoordinateSystemNoTransform( self ) : - - scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) - coordChild = scene.createChild( "coord") - coord = IECoreScene.CoordinateSystem() - coord.setName( "testing" ) - coordChild.writeObject( coord, 0 ) - coordChild2 = coordChild.createChild( "other") - coordChild2.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ), 0 ) - coordChild2.writeObject( coord, 0 ) - - del scene, coordChild, coordChild2 - - sop = self.sop() - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - prims = sop.geometry().prims() - self.assertEqual( len(prims), 2 ) - - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted(nameAttr.strings()), [ "/coord", "/coord/other" ] ) - self.assertEqual( prims[0].attribValue( "name" ), "/coord" ) - self.assertEqual( prims[0].type(), hou.primType.Custom ) - self.assertEqual( prims[0].vertices()[0].point().number(), 0 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 0, 0, 0 ) ) - self.assertEqual( prims[1].attribValue( "name" ), "/coord/other" ) - self.assertEqual( prims[1].type(), hou.primType.Custom ) - self.assertEqual( prims[1].vertices()[0].point().number(), 1 ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 1, 2, 3 ) ) - - def testObjectMerge( self ) : - - self.writeSCC() - xform = self.xform() - xform.parm( "expand" ).pressButton() - origSop = hou.node( xform.path()+"/1/2/geo/2" ) - merge = hou.node( "/obj" ).createNode( "geo" ).createNode( "object_merge" ) - merge.parm( "objpath1" ).set( origSop.path() ) - - # not transformed because we haven't set "Into this Object" - geo = merge.geometry() - self.assertEqual( geo.points()[0].position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( geo.boundingBox(), hou.BoundingBox( 0, 0, 0, 1, 1, 1 ) ) - - # transformed to its world position - merge.parm( "xformtype" ).set( 1 ) # "Into this Object" - geo = merge.geometry() - self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 0, 0, 4, 1, 1 ) ) - mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( merge ).convert() - self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 0, 0 ), imath.V3f( 4, 1, 1 ) ) ) - - # didn't affect the original SOP because it stores it's own copy of the prim - geo = origSop.geometry() - self.assertEqual( geo.points()[0].position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) - self.assertEqual( geo.boundingBox(), hou.BoundingBox( 0, 0, 0, 1, 1, 1 ) ) - mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( origSop ).convert() - self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) - - # transformable at the SOP level as well - sopXform = merge.createOutputNode( "xform" ) - sopXform.parm( "ty" ).set( 7 ) - geo = sopXform.geometry() - self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 7.5, 0.5 ) ) - self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 7, 0, 4, 8, 1 ) ) - mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( sopXform ).convert() - self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 7, 0 ), imath.V3f( 4, 8, 1 ) ) ) - - # didn't affect the input SOP because it stores it's own copy of the prim - geo = merge.geometry() - self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) - self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 0, 0, 4, 1, 1 ) ) - mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( merge ).convert() - self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 0, 0 ), imath.V3f( 4, 1, 1 ) ) ) - - def testPointsDontAccumulate( self ) : - - obj = hou.node("/obj") - geo = obj.createNode("geo", run_init_scripts=False) - box = geo.createNode( "box" ) - facet = geo.createNode( "facet" ) - facet.parm("postnml").set(True) - points = geo.createNode( "scatter" ) - points.parm( "npts" ).set( 5000 ) - facet.setInput( 0, box ) - points.setInput( 0, facet ) - points.setRenderFlag( True ) - points.setDisplayFlag( True ) - - rop = self.rop( geo ) - rop.parm( "trange" ).set( 1 ) - rop.parmTuple( "f" ).set( ( 1, 10, 1 ) ) - rop.parm( "execute" ).pressButton() - - sop = self.sop() - sop.parm( "file" ).set( self._testOutFile ) - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - - for t in range( 0, 10 ) : - hou.setTime( t ) - self.assertEqual( len(sop.geometry().points()), 5000 ) - self.assertEqual( len(sop.geometry().prims()), 1 ) - - def testTimeDependent( self ) : - - self.writeSCC() - xform = self.xform() - xform.parm( "expand" ).pressButton() - self.assertFalse( hou.node( xform.path()+"/1" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo/1" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/geo/2" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3/geo/3" ).isTimeDependent() ) - - scene = self.writeSCC() - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - - for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - - matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) - sc2.writeTransform( IECore.M44dData( matrix ), time ) - - matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) - sc3.writeTransform( IECore.M44dData( matrix ), time ) - - del scene, sc1, sc2, sc3 - - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertFalse( hou.node( xform.path()+"/1" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo/1" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/geo/2" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3/geo/3" ).isTimeDependent() ) - - scene = self.writeSCC() - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - - matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) - sc2.writeTransform( IECore.M44dData( matrix ), time ) - - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( time, 1, 0 ) ] * 6 ) ) - sc2.writeObject( mesh, time ) - - del scene, sc1, sc2, sc3 - - xform.parm( "collapse" ).pressButton() - xform.parm( "expand" ).pressButton() - self.assertFalse( hou.node( xform.path()+"/1" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/geo/1" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/geo/2" ).isTimeDependent() ) - if hou.applicationVersion()[0] >= 14 : - self.assertTrue( hou.node( xform.path()+"/1/2/3" ).isTimeDependent() ) - else : - self.assertFalse( hou.node( xform.path()+"/1/2/3" ).isTimeDependent() ) - self.assertTrue( hou.node( xform.path()+"/1/2/3/geo" ).isTimeDependent() ) - self.assertFalse( hou.node( xform.path()+"/1/2/3/geo/3" ).isTimeDependent() ) - - def testSceneMethod( self ) : - - def testNode( node ) : - - sceneNode = IECoreHoudini.SceneCacheNode( node ) - shared = IECoreScene.SharedSceneInterfaces.get( self._testFile ) - self.assertTrue( sceneNode.scene().isSame( shared ) ) - node.parm( "root" ).set( "/1/fake" ) - self.assertEqual( sceneNode.scene(), None ) - node.parm( "root" ).set( "/1/2" ) - self.compareScene( sceneNode.scene(), shared.scene( [ "1", "2" ] ) ) - - self.writeSCC() - testNode( self.sop() ) - testNode( self.xform() ) - testNode( self.geometry() ) - testNode( self.sopXform() ) - - def testTransformOverride( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - xform = self.xform() - xform.parm( "expand" ).pressButton() - a = xform.children()[0] - b = [ x for x in a.children() if x.name() != "geo" ][0] - c = [ x for x in b.children() if x.name() != "geo" ][0] - for time in times : - if hou.applicationVersion()[0] >= 14 : - self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time * 2, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, time * 3, 0 ) ) ) - else : - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - - for time in times : - hou.setTime( time - spf ) - self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) - - a.parm( "overrideTransform" ).set( True ) - c.parm( "overrideTransform" ).set( True ) - c.parm( "tx" ).setExpression( "$T+1/$FPS" ) - - for time in times : - if hou.applicationVersion()[0] >= 14 : - self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2 + time, time, 0 ) ) ) - else : - self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) - - for time in times : - hou.setTime( time - spf ) - self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) - self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) - self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) - self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) - - def testGeometryTypes( self ) : - - self.writeAnimSCC() - times = list(range( 0, 10)) - halves = [ x + 0.5 for x in times ] - quarters = [ x + 0.25 for x in times ] - times.extend( [ x + 0.75 for x in times ] ) - times.extend( halves ) - times.extend( quarters ) - times.sort() - - spf = 1.0 / hou.fps() - - node = self.sop() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Cortex ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - self.assertEqual( prims[0].vertices()[0].point().position(), hou.Vector3( 1.5, time + 0.5, 0.5 ) ) - self.assertEqual( prims[1].vertices()[0].point().position(), hou.Vector3( 3.5, time*2 + 0.5, 0.5 ) ) - self.assertEqual( prims[2].vertices()[0].point().position(), hou.Vector3( 6.5, time*3 + 0.5, 0.5 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, time, 0 ) ) - self.assertEqual( prims[4].vertex( 0 ).point().position(), hou.Vector3( 2, time + 1, 1 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, time*2, 0 ) ) - self.assertEqual( prims[10].vertex( 0 ).point().position(), hou.Vector3( 4, time*2 + 1, 1 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, time*3, 0 ) ) - self.assertEqual( prims[16].vertex( 0 ).point().position(), hou.Vector3( 7, time*3 + 1, 1 ) ) - - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.BoundingBox ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 18 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - self.assertEqual( prims[0].vertex( 0 ).point().position(), hou.Vector3( 1, time, 0 ) ) - self.assertEqual( prims[4].vertex( 0 ).point().position(), hou.Vector3( 7, time*3 + 1, 1 ) ) - self.assertEqual( prims[6].vertex( 0 ).point().position(), hou.Vector3( 3, time*2, 0 ) ) - self.assertEqual( prims[10].vertex( 0 ).point().position(), hou.Vector3( 7, time*3 + 1, 1 ) ) - self.assertEqual( prims[12].vertex( 0 ).point().position(), hou.Vector3( 6, time*3, 0 ) ) - self.assertEqual( prims[16].vertex( 0 ).point().position(), hou.Vector3( 7, time*3 + 1, 1 ) ) - - # re-write with rotation to prove point cloud basis vectors are accurate - self.writeAnimSCC( rotate = True ) - - scene = IECoreScene.SharedSceneInterfaces.get( self._testFile ) - - a = scene.child( "1" ) - b = a.child( "2" ) - c = b.child( "3" ) - - node.parm( "reload" ).pressButton() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.PointCloud ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 3 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - - aPoint = prims[0].vertices()[0].point() - bPoint = prims[1].vertices()[0].point() - cPoint = prims[2].vertices()[0].point() - - aWorld = a.readTransformAsMatrix( time ) * scene.readTransformAsMatrix( time ) - bWorld = b.readTransformAsMatrix( time ) * aWorld - cWorld = c.readTransformAsMatrix( time ) * bWorld - - self.assertTrue( imath.V3d( list(aPoint.position()) ).equalWithAbsError( aWorld.multVecMatrix( a.readBound( time ).center() ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(bPoint.position()) ).equalWithAbsError( bWorld.multVecMatrix( b.readBound( time ).center() ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(cPoint.position()) ).equalWithAbsError( cWorld.multVecMatrix( c.readBound( time ).center() ), 1e-6 ) ) - - self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( aWorld[0][0], aWorld[0][1], aWorld[0][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( aWorld[1][0], aWorld[1][1], aWorld[1][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( aWorld[2][0], aWorld[2][1], aWorld[2][2] ), 1e-6 ) ) - - self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( bWorld[0][0], bWorld[0][1], bWorld[0][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( bWorld[1][0], bWorld[1][1], bWorld[1][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( bWorld[2][0], bWorld[2][1], bWorld[2][2] ), 1e-6 ) ) - - self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( cWorld[0][0], cWorld[0][1], cWorld[0][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( cWorld[1][0], cWorld[1][1], cWorld[1][2] ), 1e-6 ) ) - self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( cWorld[2][0], cWorld[2][1], cWorld[2][2] ), 1e-6 ) ) - - # re-write with rotation and no geo to prove transform point cloud basis vectors and transforms are accurate - self.writeAnimSCC( rotate=True, scale=True, includeMesh=False, writeMRef=True ) - scene = IECoreScene.SharedSceneInterfaces.get( self._testFile ) - a = scene.child( "1" ) - b = a.child( "2" ) - c = b.child( "3" ) - - node.parm( "reload" ).pressButton() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.TransformPointCloud ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - self.assertEqual( len(prims), 4 ) - nameAttr = node.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ '/', '/1', '/1/2', '/1/2/3' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 1 ) - - aPoint = prims[1].vertices()[0].point() - bPoint = prims[2].vertices()[0].point() - cPoint = prims[3].vertices()[0].point() - - aWorld = a.readTransformAsMatrix( time ) * scene.readTransformAsMatrix( time ) - bWorld = b.readTransformAsMatrix( time ) * aWorld - cWorld = c.readTransformAsMatrix( time ) * bWorld - - data = { - aPoint : ( aWorld, prims[1], a ), - bPoint : ( bWorld, prims[2], b ), - cPoint : ( cWorld, prims[3], c ), - } - - for point, ( transform, prim, location ) in data.items(): - self.assertTrue( imath.V3d( list(point.position() ) ).equalWithAbsError( transform.multVecMatrix( imath.V3f(0) ), 1e-6 ) ) - - self.assertTrue( imath.M44d( *list(point.attribValue( "transform" )) ).equalWithAbsError( transform, 1e-6 ) ) - - s = imath.V3d() - transform.extractScaling( s ) - pscale = ( abs( s.x ) + abs( s.y ) + abs( s.z ) ) / 3.0 - self.assertTrue( abs( pscale - point.attribValue( "pscale" ) ) < 1e-6 ) - self.assertTrue( - imath.V3d( list(point.attribValue( "scale" ) ) ).equalWithAbsError( - s / pscale, - 1e-6 - ) - ) - - rotationMatrix = imath.M44d( transform ) - rotationMatrix.removeScalingAndShear() - q = imath.Quatf( imath.M44f( rotationMatrix ) ) - sceneOrientation = imath.V4f( q.v().x, q.v().y, q.v().z, q.r() ) - houdiniOrientation = imath.V4f( *list(point.attribValue( "orient" )) ) - for i in range( 4 ): - # sign may flip so we use abs for both - self.assertTrue( abs( sceneOrientation[i] ) - abs( houdiniOrientation[i] ) < 1e-6 ) - - # check rest transform and rest position - restTransform = location.readAttribute( "user:Mref", time ).value - self.assertTrue( imath.M44d( *list(point.attribValue( "resttransform" )) ).equalWithAbsError( restTransform, 1e-6 ) ) - self.assertTrue( imath.V3d( list(point.attribValue( "restposition" ) ) ).equalWithAbsError( restTransform.multVecMatrix( imath.V3f(0) ), 1e-6 ) ) - - # no transform - self.assertTrue( point.attribValue( "hasobject" ) == 0 ) - - # write with shape - self.writeAnimSCC( rotate=True, scale=True, writeMRef=True ) - scene = IECoreScene.SharedSceneInterfaces.get( self._testFile ) - a = scene.child( "1" ) - b = a.child( "2" ) - c = b.child( "3" ) - - node.parm( "reload" ).pressButton() - node.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.TransformPointCloud ) - for time in times : - hou.setTime( time - spf ) - prims = node.geometry().prims() - - aPoint = prims[1].vertices()[0].point() - bPoint = prims[2].vertices()[0].point() - cPoint = prims[3].vertices()[0].point() - - for point in ( aPoint, bPoint, cPoint ): - self.assertTrue( point.attribValue( "hasobject" ) == 1 ) - - def testNonExistantAttributes( self ) : - - self.writeSCC() - - node = self.xform() - node.parm( "expand" ).pressButton() - scene = IECoreHoudini.LiveScene( node.path(), rootPath = [ node.name() ] ) - self.assertEqual( scene.attributeNames(), [] ) - self.assertFalse( scene.hasAttribute( "test" ) ) - self.assertEqual( scene.readAttribute( "test", 0 ), None ) - - def testAttribWrangleName( self ) : - - geo = hou.node( "/obj" ).createNode( "geo" ) - torus = geo.createNode( "torus" ) - torus.parm( "rows" ).set( 10 ) - torus.parm( "cols" ).set( 10 ) - name = torus.createOutputNode( "name" ) - name.parm( "name1" ).set( "/a" ) - wrangle = name.createOutputNode( "attribwrangle" ) - wrangle.parm( "class" ).set( 1 ) # primitive - wrangle.parm( "snippet" ).set( 's@name = "/b";' ) - rop = self.rop( geo ) - - # since the geo is named it doesn't count as a - # local object, but rather as a child scene. - - name.setRenderFlag( True ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - scene = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "a" ] ) - childScene = scene.child( "a" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - # this is still true after wrangling the name attrib, - # which we are testing because attribwrangle nodes - # do not clean up the mess they've made with the - # string table for attributes. - - wrangle.setRenderFlag( True ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - scene = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "b" ] ) - childScene = scene.child( "b" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - # it works for nested names too - - wrangle.parm( "snippet" ).set( 's@name = "/c/d/e";' ) - rop.parm( "execute" ).pressButton() - self.assertEqual( len( rop.errors() ) , 0 ) - scene = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) - self.assertFalse( scene.hasObject() ) - self.assertEqual( scene.childNames(), [ "c" ] ) - childScene = scene.child( "c" ) - self.assertFalse( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [ "d" ] ) - childScene = childScene.child( "d" ) - self.assertFalse( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [ "e" ] ) - childScene = childScene.child( "e" ) - self.assertTrue( childScene.hasObject() ) - self.assertEqual( childScene.childNames(), [] ) - self.assertEqual( childScene.readObject( 0 ).variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 100 ) - - def testSceneNameTakesPrecedence( self ) : - - def write() : - - scene = self.writeSCC() - sc = scene.createChild( str( 4 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) - mesh.blindData()["name"] = IECore.StringData( "blindName" ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - for time in ( 0, 1, 2 ) : - sc.writeObject( mesh, time ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - write() - - spf = 1.0 / hou.fps() - - sop = self.sop() - sop.parm( "geometryType" ).set( IECoreHoudini.SceneCacheNode.GeometryType.Houdini ) - - for time in ( 0, 1, 2 ) : - - hou.setTime( time - spf ) - geometry = sop.geometry() - prims = geometry.prims() - nameAttr = geometry.findPrimAttrib( "name" ) - self.assertTrue( "blindName" not in nameAttr.strings() ) - self.assertEqual( nameAttr.strings(), tuple( [ '/1', '/1/2', '/1/2/3', '/4' ] ) ) - for name in nameAttr.strings() : - self.assertEqual( len([ x for x in prims if x.attribValue( "name" ) == name ]), 6 ) - - - def testVisibility( self ): - """ - Test support for animated visibility. - """ - parent = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - sop = parent.createNode( "ieSceneCacheSource" ) - sop.parm( "file" ).set( "test/IECoreScene/data/animatedVisibility.scc" ) - - # visibility is on - hou.setTime( ( 1011 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 1 ) - - # visibility is off but visibility filter is off so we should get a prim - hou.setTime( ( 1012 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 1 ) - - sop.parm( "visibilityFilter" ).set( True ) - - # visibility is on - hou.setTime( ( 1011 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 1 ) - - # visibility is off and visibility filter is on so we should get no prim - hou.setTime( ( 1012 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 0 ) - - # make sure subsequent frame are still hidden - hou.setTime( ( 1013 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 0 ) - - # make sure we support making the location re visible - hou.setTime( ( 1024 - 1 ) / hou.fps() ) - self.assertEqual( len( sop.geometry().prims() ), 1 ) - - def testVisibilityExpression( self ): - """ - Test support for animated visibility with hierarchy expanded. - """ - parent = hou.node( "/obj" ) - xform = parent.createNode( "ieSceneCacheTransform" ) - - xform.parm( "file" ).set( "test/IECoreScene/data/animatedVisibility.scc" ) - xform.parm( "expand" ).pressButton() - - parentVisibility = xform.node( "parentVisibility" ) - inheritedVisibility = parentVisibility.node( "inherited" ) - - xform.parm( "visibilityFilter" ).set( True ) - xform.parm( "push" ).pressButton() - - self.assertEqual( parentVisibility.parm( "tdisplay" ).eval(), 1 ) - self.assertEqual( inheritedVisibility.parm( "tdisplay" ).eval(), 1 ) - - # visibility is on - hou.setTime( ( 1011 - 1 ) / hou.fps() ) - self.assertEqual( parentVisibility.parm( "display" ).eval(), 1 ) - self.assertEqual( inheritedVisibility.parm( "display" ).eval(), 1 ) - - # visibility is off and visibility filter is on so we should get disabled display - hou.setTime( ( 1012 - 1 ) / hou.fps() ) - self.assertEqual( parentVisibility.parm( "display" ).eval(), 0 ) - self.assertEqual( inheritedVisibility.parm( "display" ).eval(), 0 ) - - # make sure subsequent frame are still hidden - hou.setTime( ( 1013 - 1 ) / hou.fps() ) - self.assertEqual( parentVisibility.parm( "display" ).eval(), 0 ) - self.assertEqual( inheritedVisibility.parm( "display" ).eval(), 0 ) - - # make sure we support making the location re visible - hou.setTime( ( 1024 - 1 ) / hou.fps() ) - self.assertEqual( parentVisibility.parm( "display" ).eval(), 1 ) - self.assertEqual( inheritedVisibility.parm( "display" ).eval(), 1 ) - - # test we are clearing expression correctly - xform.parm( "visibilityFilter" ).set( False ) - xform.parm( "push" ).pressButton() - - self.assertEqual( parentVisibility.parm( "tdisplay" ).eval(), 0 ) - self.assertEqual( inheritedVisibility.parm( "tdisplay" ).eval(), 0 ) - - self.assertEqual( parentVisibility.parm( "display" ).eval(), 1 ) - self.assertEqual( inheritedVisibility.parm( "display" ).eval(), 1 ) - - def testCurveAndPoint( self ): - """ - Test to avoid points without a particle system mixed with curve primitive - """ - parent = hou.node( "/obj" ) - geo = parent.createNode( "geo", run_init_scripts=False ) - - curve = geo.createNode( "line" ) - point = geo.createNode( "add" ) - if hou.applicationVersion()[0] < 19 : - point.parm( "usept0" ).set( True ) - else : - point.parm( "points" ).set( 1 ) - merge = geo.createNode( "merge" ) - - merge.setInput( 0, curve ) - merge.setInput( 1, point ) - - merge.setDisplayFlag( True ) - merge.setRenderFlag( True ) - - writer = hou.node( "/out" ).createNode( "ieSceneCacheWriter" ) - writer.parm( "file" ).set( "/tmp/testCurveAndPoint.scc" ) - writer.parm( "rootObject" ).set( geo.path() ) - - self.assertRaises( hou.OperationFailed , functools.partial( writer.render, [1,1] ) ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/TemporaryParameterValuesTest.py b/test/IECoreHoudini/TemporaryParameterValuesTest.py deleted file mode 100644 index c85520d382..0000000000 --- a/test/IECoreHoudini/TemporaryParameterValuesTest.py +++ /dev/null @@ -1,193 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import hou - -import IECore -import IECoreHoudini - -class TemporaryParameterValuesTest( IECoreHoudini.TestCase ) : - - def testParmTypes( self ) : - - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - node = geo.createNode( "attribcreate", exact_type_name=True ) - node.parm( "class" ).set( 1 ) - node.parm( "writevalues" ).set( True ) - node.parm( "size" ).set( 4 ) - node.parm( "default1" ).set( 10.5 ) - node.parm( "string" ).set( "hi" ) - node.parmTuple( "value" ).set( ( 1.25, 2.5, 3.75, 4.99 ) ) - nodePath = node.path() - - context = IECoreHoudini.TemporaryParameterValues( - { - nodePath + "/class" : 2, - nodePath + "/writevalues" : False, - nodePath + "/size" : 2, - nodePath + "/default1" : 20.5, - nodePath + "/string" : "bye", - nodePath + "/value" : ( 9.25, 6.5, 54.12, 5636.4 ), - } - ) - - self.assertEqual( node.parm( "class" ).eval(), 1 ) - self.assertEqual( node.parm( "writevalues" ).eval(), True ) - self.assertEqual( node.parm( "size" ).eval(), 4 ) - self.assertEqual( node.parm( "default1" ).eval(), 10.5 ) - self.assertEqual( node.parm( "string" ).eval(), "hi" ) - value = node.parmTuple( "value" ).eval() - realValue = [ 1.25, 2.5, 3.75, 4.99 ] - for i in range( 0, 4 ) : - self.assertAlmostEqual( value[i], realValue[i], 3 ) - - with context : - - self.assertEqual( node.parm( "class" ).eval(), 2 ) - self.assertEqual( node.parm( "writevalues" ).eval(), False ) - self.assertEqual( node.parm( "size" ).eval(), 2 ) - self.assertEqual( node.parm( "default1" ).eval(), 20.5 ) - self.assertEqual( node.parm( "string" ).eval(), "bye" ) - value = node.parmTuple( "value" ).eval() - tempValue = [ 9.25, 6.5, 54.12, 5636.4 ] - for i in range( 0, 4 ) : - self.assertAlmostEqual( value[i], tempValue[i], 3 ) - - self.assertEqual( node.parm( "class" ).eval(), 1 ) - self.assertEqual( node.parm( "writevalues" ).eval(), True ) - self.assertEqual( node.parm( "size" ).eval(), 4 ) - self.assertEqual( node.parm( "default1" ).eval(), 10.5 ) - self.assertEqual( node.parm( "string" ).eval(), "hi" ) - value = node.parmTuple( "value" ).eval() - realValue = [ 1.25, 2.5, 3.75, 4.99 ] - for i in range( 0, 4 ) : - self.assertAlmostEqual( value[i], realValue[i], 3 ) - - def testExpressions( self ) : - - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - node = geo.createNode( "attribcreate", exact_type_name=True ) - node.parm( "class" ).setExpression( "$F" ) - node.parm( "writevalues" ).setExpression( "$F" ) - node.parm( "size" ).setExpression( "$F+1" ) - node.parm( "default1" ).setExpression( "$FF*5" ) - node.parm( "string" ).setExpression( 'opfullpath( "." )' ) - nodePath = node.path() - - context = IECoreHoudini.TemporaryParameterValues( - { - nodePath + "/class" : 3, - nodePath + "/writevalues" : False, - nodePath + "/size" : 3, - nodePath + "/default1" : 20.5, - nodePath + "/string" : "bye", - } - ) - - hou.setFrame( 1 ) - - self.assertEqual( node.parm( "class" ).eval(), 1 ) - self.assertEqual( node.parm( "writevalues" ).eval(), True ) - self.assertEqual( node.parm( "size" ).eval(), 2 ) - self.assertEqual( node.parm( "default1" ).eval(), 5.0 ) - self.assertEqual( node.parm( "string" ).eval(), nodePath ) - - with context : - - self.assertEqual( node.parm( "class" ).eval(), 3 ) - self.assertEqual( node.parm( "writevalues" ).eval(), False ) - self.assertEqual( node.parm( "size" ).eval(), 3 ) - self.assertEqual( node.parm( "default1" ).eval(), 20.5 ) - self.assertEqual( node.parm( "string" ).eval(), "bye" ) - - self.assertEqual( node.parm( "class" ).eval(), 1 ) - self.assertEqual( node.parm( "writevalues" ).eval(), True ) - self.assertEqual( node.parm( "size" ).eval(), 2 ) - self.assertEqual( node.parm( "default1" ).eval(), 5.0 ) - self.assertEqual( node.parm( "string" ).eval(), nodePath ) - - hou.setFrame( 0 ) - - with context : - - self.assertEqual( node.parm( "class" ).eval(), 3 ) - self.assertEqual( node.parm( "writevalues" ).eval(), False ) - self.assertEqual( node.parm( "size" ).eval(), 3 ) - self.assertEqual( node.parm( "default1" ).eval(), 20.5 ) - self.assertEqual( node.parm( "string" ).eval(), "bye" ) - - self.assertEqual( node.parm( "class" ).eval(), 0 ) - self.assertEqual( node.parm( "writevalues" ).eval(), False ) - self.assertEqual( node.parm( "size" ).eval(), 1 ) - self.assertEqual( node.parm( "default1" ).eval(), 0.0 ) - self.assertEqual( node.parm( "string" ).eval(), nodePath ) - - def testUnexpandedStrings( self ) : - - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - node = geo.createNode( "attribcreate", exact_type_name=True ) - parm = node.parm( "string" ) - parm.set( "hi" ) - - self.assertEqual( parm.eval(), "hi" ) - self.assertEqual( parm.unexpandedString(), "hi" ) - - with IECoreHoudini.TemporaryParameterValues( { parm.path() : "${OS}test$F4" } ) : - - self.assertEqual( parm.eval(), "attribcreate1test0001" ) - self.assertEqual( parm.unexpandedString(), "${OS}test$F4" ) - - self.assertEqual( parm.eval(), "hi" ) - self.assertEqual( parm.unexpandedString(), "hi" ) - - parm.set( "${OS}test$F4" ) - - self.assertEqual( parm.eval(), "attribcreate1test0001" ) - self.assertEqual( parm.unexpandedString(), "${OS}test$F4" ) - - with IECoreHoudini.TemporaryParameterValues( { parm.path() : "bye" } ) : - - self.assertEqual( parm.eval(), "bye" ) - self.assertEqual( parm.unexpandedString(), "bye" ) - - self.assertEqual( parm.eval(), "attribcreate1test0001" ) - self.assertEqual( parm.unexpandedString(), "${OS}test$F4" ) - -if __name__ == "__main__": - IECoreHoudini.TestProgram() diff --git a/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py b/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py deleted file mode 100644 index d0a337ddc9..0000000000 --- a/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py +++ /dev/null @@ -1,363 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestToHoudiniCompoundObjectConverter( IECoreHoudini.TestCase ) : - - __testScene = "test/converterTest.hip" - - def mesh( self ) : - - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ 1, 5, 4, 0, 2, 6, 5, 1, 3, 7, 6, 2, 0, 4, 7, 3, 2, 1, 0, 3, 5, 6, 7, 4 ] ) - mesh = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) - - intRange = list(range( 1, 25)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - primitiveInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - vertexInterpolation = IECoreScene.PrimitiveVariable.Interpolation.FaceVarying - - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - ], IECore.GeometricData.Interpretation.Point ) - mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) - mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) - mesh["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData[:8] ) - mesh["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData[:8], IECore.IntVectorData( list(range( 0, 8)) ) ) - - mesh["floatPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, floatVectorData[:6] ) - mesh["color3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, color3fVectorData[:6] ) - mesh["stringPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, stringVectorData[:6], IECore.IntVectorData( list(range( 0, 6)) ) ) - - mesh["floatVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, floatVectorData ) - mesh["color3fVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, color3fVectorData ) - mesh["stringVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 24)) ) ) - - return mesh - - def points( self ) : - - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), - ] ) - - points = IECoreScene.PointsPrimitive( pData ) - - intRange = list(range( 1, 13)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - uniformInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - - points["floatPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, floatVectorData[:1] ) - points["color3fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, color3fVectorData[:1] ) - points["stringPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, stringVectorData[:1], IECore.IntVectorData( [ 0 ] ) ) - - points["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData ) - points["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData ) - points["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 12)) ) ) - - return points - - def ints( self ) : - - return IECore.IntVectorData( list(range( 0, 10)) ) - - def compound( self ) : - - return IECore.CompoundObject( { - "mesh" : self.mesh(), - "points" : self.points(), - "ints" : self.ints() - } ) - - def emptySop( self ) : - - return hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ).createNode( "null" ) - - def meshSop( self ) : - - box = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ).createNode( "box" ) - facet = box.createOutputNode( "facet" ) - facet.parm( "postnml" ).set(True) - name = facet.createOutputNode( "name" ) - name.parm( "name1" ).set( "realGeo" ) - return name - - def pointsSop( self ) : - - return self.meshSop().createOutputNode( "scatter" ) - - def testCreateConverter( self ) : - - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( self.compound() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCompoundObjectConverter ) ) ) - - self.assertRaises( Exception, IECore.curry( IECoreHoudini.ToHoudiniCompoundObjectConverter, self.mesh() ) ) - - def testFactory( self ) : - - obj = self.compound() - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( obj ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCompoundObjectConverter ) ) ) - - del obj["ints"] - - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( obj ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCompoundObjectConverter ) ) ) - - self.assertTrue( IECore.TypeId.CompoundObject in IECoreHoudini.ToHoudiniGeometryConverter.supportedTypes() ) - - def verifySop( self, sop, obj, name = "" ) : - - prims = sop.geometry().prims() - self.assertEqual( len(prims), 3 ) - for i in range( 0, len(prims) ) : - self.assertEqual( prims[i].type(), hou.primType.Custom ) - self.assertEqual( prims[i].vertices()[0].point().number(), i ) - self.assertEqual( prims[i].attribValue( "name" ), obj.keys()[i] ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, name ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCompoundObjectConverter ) ) ) - self.assertEqual( obj, converter.convert() ) - - def testConversionIntoEmptySop( self ) : - - obj = self.compound() - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ).convert( sop ) ) - self.verifySop( sop, obj ) - - def testConversionIntoExistingSop( self ) : - - obj = self.compound() - sop = self.meshSop() - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertNotEqual( obj, converter.convert() ) - - self.assertTrue( IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ).convert( sop ) ) - self.verifySop( sop, obj ) - - def verifyAppendedSop( self, sop, obj, orig, origName = "realGeo", numAppends = 1 ) : - - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - origNumPolys = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - - prims = sop.geometry().prims() - numCustom = len(obj.values()) * numAppends - self.assertEqual( len(prims), origNumPolys + numCustom ) - origPrims = prims[:-numCustom] - for prim in origPrims : - self.assertEqual( prim.type(), hou.primType.Polygon ) - self.assertEqual( prim.attribValue( "name" ), origName ) - - newPrims = prims[len(prims) - numCustom:] - for i in range( 0, len(newPrims) ) : - prim = newPrims[i] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.vertices()[0].point().number(), origNumPoints + i ) - - for i in range( 0, len(newPrims), len(obj.keys()) ) : - for j in range( 0, len(obj.keys()) ) : - self.assertEqual( newPrims[i+j].attribValue( "name" ), obj.keys()[j] ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, "* ^"+origName ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCompoundObjectConverter ) ) ) - self.assertEqual( obj, converter.convert() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, origName ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testAppendingIntoExistingSop( self ) : - - obj = self.compound() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, obj ) - - self.assertTrue( not sop.isHardLocked() ) - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, obj, orig ) - - sop.setHardLocked( False ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testAppendingIntoLockedSop( self ) : - - obj = self.compound() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, obj ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, obj, orig ) - - sop.setHardLocked( False ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testSaveLoad( self ) : - - hou.hipFile.clear( suppress_save_prompt=True ) - - obj = self.compound() - sop = self.emptySop() - sopPath = sop.path() - - self.assertTrue( IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ).convert( sop ) ) - self.verifySop( sop, obj ) - - hou.hipFile.save( TestToHoudiniCompoundObjectConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniCompoundObjectConverter.__testScene ) - - newSop = hou.node( sopPath ) - self.assertTrue( newSop.isHardLocked() ) - self.verifySop( newSop, obj ) - - def testMultipleConversions( self ) : - - obj = self.compound() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, obj ) - - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - self.verifyAppendedSop( sop, obj, orig ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - self.verifyAppendedSop( sop, obj, orig, numAppends = 2 ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - self.verifyAppendedSop( sop, obj, orig, numAppends = 3 ) - - def testObjectWasDeleted( self ) : - - obj = self.compound() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - self.assertTrue( converter.convert( sop ) ) - self.verifySop( sop, obj ) - - del obj - - result = IECoreHoudini.FromHoudiniCompoundObjectConverter( sop ).convert() - self.verifySop( sop, result ) - - def testName( self ) : - - obj = self.compound() - sop = self.emptySop() - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - - # members of the CompoundObject maintain their names - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted( nameAttr.strings() ), [ "ints", "mesh", "points" ] ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "ints" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "mesh" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "points" ]), 1 ) - - # blindData is meaningless - obj["mesh"].blindData()["name"] = IECore.StringData( "blindMesh" ) - converter = IECoreHoudini.ToHoudiniCompoundObjectConverter( obj ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted( nameAttr.strings() ), [ "ints", "mesh", "points" ] ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "ints" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "mesh" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "points" ]), 1 ) - - # name parameter adds parent name - converter["name"].setTypedValue( "compound" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( sorted( nameAttr.strings() ), [ "compound/ints", "compound/mesh", "compound/points" ] ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "compound/ints" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "compound/mesh" ]), 1 ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "compound/points" ]), 1 ) - - def tearDown( self ) : - - if os.path.isfile( TestToHoudiniCompoundObjectConverter.__testScene ) : - os.remove( TestToHoudiniCompoundObjectConverter.__testScene ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py b/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py deleted file mode 100644 index cb748ec6f2..0000000000 --- a/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py +++ /dev/null @@ -1,431 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestToHoudiniCortexObjectConverter( IECoreHoudini.TestCase ) : - - __testScene = "test/converterTest.hip" - - def mesh( self ) : - - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ 1, 5, 4, 0, 2, 6, 5, 1, 3, 7, 6, 2, 0, 4, 7, 3, 2, 1, 0, 3, 5, 6, 7, 4 ] ) - mesh = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) - - intRange = list(range( 1, 25)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - primitiveInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - vertexInterpolation = IECoreScene.PrimitiveVariable.Interpolation.FaceVarying - - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - ], IECore.GeometricData.Interpretation.Point ) - mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) - mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) - mesh["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData[:8] ) - mesh["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData[:8], IECore.IntVectorData( list(range( 0, 8)) ) ) - - mesh["floatPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, floatVectorData[:6] ) - mesh["color3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, color3fVectorData[:6] ) - mesh["stringPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, stringVectorData[:6], IECore.IntVectorData( list(range( 0, 6)) ) ) - - mesh["floatVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, floatVectorData ) - mesh["color3fVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, color3fVectorData ) - mesh["stringVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 24)) ) ) - - return mesh - - def points( self ) : - - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), - ] ) - - points = IECoreScene.PointsPrimitive( pData ) - - intRange = list(range( 1, 13)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - uniformInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - - points["floatPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, floatVectorData[:1] ) - points["color3fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, color3fVectorData[:1] ) - points["stringPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, stringVectorData[:1], IECore.IntVectorData( [ 0 ] ) ) - - points["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData ) - points["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData ) - points["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 12)) ) ) - - return points - - def ints( self ) : - - return IECore.IntVectorData( list(range( 0, 10)) ) - - def emptySop( self ) : - - return hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ).createNode( "null" ) - - def meshSop( self ) : - - box = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ).createNode( "box" ) - facet = box.createOutputNode( "facet" ) - facet.parm( "postnml" ).set(True) - name = facet.createOutputNode( "name" ) - name.parm( "name1" ).set( "realGeo" ) - return name - - def pointsSop( self ) : - - return self.meshSop().createOutputNode( "scatter" ) - - def testCreateConverter( self ) : - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( self.mesh() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCortexObjectConverter ) ) ) - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( self.points() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCortexObjectConverter ) ) ) - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( self.ints() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCortexObjectConverter ) ) ) - - def testFactory( self ) : - - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( self.ints() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCortexObjectConverter ) ) ) - - # meshes still get polygons - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( self.mesh() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniPolygonsConverter ) ) ) - - self.assertTrue( IECore.TypeId.Object in IECoreHoudini.ToHoudiniGeometryConverter.supportedTypes() ) - - def verifySop( self, sop, obj, name = "" ) : - - prims = sop.geometry().prims() - self.assertEqual( len(prims), 1 ) - self.assertEqual( prims[0].type(), hou.primType.Custom ) - self.assertEqual( prims[0].vertices()[0].point().number(), 0 ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, name ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCortexObjectConverter ) ) ) - self.assertEqual( obj, converter.convert() ) - - def testConversionIntoEmptySop( self ) : - - mesh = self.mesh() - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ).convert( sop ) ) - self.verifySop( sop, mesh ) - - points = self.points() - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( points ).convert( sop ) ) - self.verifySop( sop, points ) - - ints = self.ints() - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( ints ).convert( sop ) ) - self.verifySop( sop, ints ) - - def testConversionIntoExistingSop( self ) : - - mesh = self.mesh() - sop = self.meshSop() - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertNotEqual( mesh, converter.convert() ) - - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ).convert( sop, False ) ) - self.verifySop( sop, mesh ) - - points = self.points() - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( points ).convert( sop ) ) - self.verifySop( sop, points ) - - ints = self.ints() - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( ints ).convert( sop ) ) - self.verifySop( sop, ints ) - - def verifyAppendedSop( self, sop, obj, orig, name = "", origName = "realGeo", numAppends = 1 ) : - - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - origNumPolys = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) - - prims = sop.geometry().prims() - self.assertEqual( len(prims), origNumPolys + numAppends ) - origPrims = prims[:-numAppends] - for prim in origPrims : - self.assertEqual( prim.type(), hou.primType.Polygon ) - self.assertEqual( prim.attribValue( "name" ), origName ) - - newPrims = prims[len(prims) - numAppends:] - for i in range( 0, len(newPrims) ) : - prim = newPrims[i] - self.assertEqual( prim.type(), hou.primType.Custom ) - self.assertEqual( prim.vertices()[0].point().number(), origNumPoints + i ) - - self.assertEqual( newPrims[-1].attribValue( "name" ), name ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, name ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniCortexObjectConverter ) ) ) - self.assertEqual( obj, converter.convert() ) - - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop, origName ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testAppendingIntoExistingSop( self ) : - - mesh = self.mesh() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, mesh ) - - self.assertTrue( not sop.isHardLocked() ) - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - converter["name"].setTypedValue( "myMesh" ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, mesh, orig, "myMesh" ) - - sop.setHardLocked( False ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testAppendingIntoLockedSop( self ) : - - mesh = self.mesh() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, mesh ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - converter["name"].setTypedValue( "myMesh" ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, mesh, orig, "myMesh" ) - - sop.setHardLocked( False ) - converter = IECoreHoudini.FromHoudiniGeometryConverter.create( sop ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPolygonsConverter ) ) ) - self.assertEqual( orig, converter.convert() ) - - def testSaveLoad( self ) : - - hou.hipFile.clear( suppress_save_prompt=True ) - - mesh = self.mesh() - sop = self.emptySop() - sopPath = sop.path() - - self.assertTrue( IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ).convert( sop ) ) - self.verifySop( sop, mesh ) - - hou.hipFile.save( TestToHoudiniCortexObjectConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniCortexObjectConverter.__testScene ) - - newSop = hou.node( sopPath ) - self.assertTrue( newSop.isHardLocked() ) - self.verifySop( newSop, mesh ) - - def testMultipleConversions( self ) : - - mesh = self.mesh() - points = self.points() - ints = self.ints() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, mesh ) - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - converter["name"].setTypedValue( "myMesh" ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, mesh, orig, "myMesh" ) - - self.assertTrue( sop.isHardLocked() ) - converter["src"].setValue( points ) - converter["name"].setTypedValue( "myPoints" ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, points, orig, "myPoints", numAppends = 2 ) - - self.assertTrue( sop.isHardLocked() ) - converter["src"].setValue( ints ) - converter["name"].setTypedValue( "myInts" ) - self.assertTrue( converter.convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.verifyAppendedSop( sop, ints, orig, "myInts", numAppends = 3 ) - - def testObjectWasDeleted( self ) : - - mesh = self.mesh() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - self.verifySop( sop, mesh ) - - del mesh - - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.verifySop( sop, result ) - - def testName( self ) : - - mesh = self.mesh() - sop = self.emptySop() - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - - # unnamed unless we set the parameter - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sop.geometry().findPrimAttrib( "name" ), None ) - - converter["name"].setTypedValue( "testObject" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testObject" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testObject" ]), 1 ) - - # blindData still works for backwards compatibility - mesh.blindData()["name"] = IECore.StringData( "blindMesh" ) - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "blindMesh" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "blindMesh" ]), 1 ) - - # name parameter takes preference over blindData - converter["name"].setTypedValue( "testObject" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testObject" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testObject" ]), 1 ) - - def testAttributeFilter( self ) : - - mesh = self.mesh() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.assertEqual( result.keys(), [ 'P', 'color3fPoint', 'color3fPrim', 'color3fVert', 'floatPoint', 'floatPrim', 'floatVert', 'stringPoint', 'stringPrim', 'stringVert' ] ) - - converter.parameters()["attributeFilter"].setTypedValue( "P *3f*" ) - self.assertTrue( converter.convert( sop ) ) - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.assertEqual( result.keys(), [ 'P', 'color3fPoint', 'color3fPrim', 'color3fVert' ] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^color* ^string*" ) - self.assertTrue( converter.convert( sop ) ) - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.assertEqual( result.keys(), [ 'P', 'floatPoint', 'floatPrim', 'floatVert' ] ) - - # verify From filter works as well - fromConverter = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ) - fromConverter.parameters()["attributeFilter"].setTypedValue( "P *Prim" ) - result = fromConverter.convert() - self.assertEqual( result.keys(), [ 'P', 'floatPrim' ] ) - - # verify we can filter uvs - mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) - mesh = IECoreScene.MeshAlgo.triangulate( mesh ) - IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) - mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) - mesh["Pref"] = mesh["P"] - - # have to filter the source attrs - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( mesh ) - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest" ) - self.assertTrue( converter.convert( sop ) ) - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.assertEqual( result.keys(), [ 'Cs', 'N', 'P', 'Pref', 'width' ] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^width ^Pref" ) - self.assertTrue( converter.convert( sop ) ) - result = IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert() - self.assertEqual( result.keys(), [ 'Cs', 'N', 'P' ] ) - - # verify non-primitives do not break - converter = IECoreHoudini.ToHoudiniCortexObjectConverter( IECore.IntData( 1 ) ) - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( IECoreHoudini.FromHoudiniCortexObjectConverter( sop ).convert(), IECore.IntData( 1 ) ) - - def tearDown( self ) : - - if os.path.isfile( TestToHoudiniCortexObjectConverter.__testScene ) : - os.remove( TestToHoudiniCortexObjectConverter.__testScene ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/ToHoudiniCurvesConverter.py b/test/IECoreHoudini/ToHoudiniCurvesConverter.py deleted file mode 100644 index 8ed43bb12d..0000000000 --- a/test/IECoreHoudini/ToHoudiniCurvesConverter.py +++ /dev/null @@ -1,1041 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestToHoudiniCurvesConverter( IECoreHoudini.TestCase ) : - - if hou.applicationVersion()[0] >= 16: - PointPositionAttribs = ['P'] - else: - PointPositionAttribs = ['P', 'Pw'] - - __testScene = "test/converterTest.hip" - - __curveCoordinates = [ - IECore.V3fVectorData( [ imath.V3f( 2.42892,0,-1.04096 ), imath.V3f( 1.69011,0,-9.88746 ), imath.V3f( 5.74288,0,-4.50183 ), imath.V3f( 2.69113,0,-2.78439 ), imath.V3f( 5.8923,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,2.03933 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 1.76971,0,-0.632637 ) ] ), - IECore.V3fVectorData( [ imath.V3f( -0.560781,0,-1.04096 ), imath.V3f( 2.21995,0,-6.31734 ), imath.V3f( 4.77513,0,-6.61752 ), imath.V3f( 4.10862,0,-2.78439 ), imath.V3f( 4.29081,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,3.7489 ), imath.V3f( -2.61584,0,2.5738 ), imath.V3f( -1.45801,0,0.780965 ) ] ), - IECore.V3fVectorData( [ imath.V3f( 2.42892,0,-1.04096 ), imath.V3f( 2.21995,0,-4.51254 ), imath.V3f( 4.77513,0,-4.50183 ), imath.V3f( 6.32944,0,-2.78439 ), imath.V3f( 7.231,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,3.7489 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 1.76971,0,0.780965 ) ] ), - IECore.V3fVectorData( [ imath.V3f( 5.83427,0,-1.04096 ), imath.V3f( 2.21995,0,-4.51254 ), imath.V3f( 6.14141,0,-4.50183 ), imath.V3f( 7.48932,0,-2.78439 ), imath.V3f( 9.0197,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,1.2141 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 3.23728,0,0.780965 ) ] ) - ] - - def curves( self, basis=IECore.CubicBasisf.linear(), periodic=False, numCurves=4 ) : - vertsPerCurve = IECore.IntVectorData() - pData = IECore.V3fVectorData() - pData.setInterpretation( IECore.GeometricData.Interpretation.Point ) - - for i in range( 0, numCurves ) : - p = TestToHoudiniCurvesConverter.__curveCoordinates[i%4] - - if not periodic and basis == IECore.CubicBasisf.bSpline() : - vertsPerCurve.append( len(p) + 4 ) - else : - vertsPerCurve.append( len(p) ) - - pData.extend( p ) - - curves = IECoreScene.CurvesPrimitive( vertsPerCurve, basis, periodic ) - - floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) - intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) - stringData = IECore.StringData( "this is a string" ) - - intRange = list(range( 1, pData.size()+1)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - primitiveInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - - # add all valid detail attrib types - curves["floatDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, floatData ) - curves["v2fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2fData ) - curves["v3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3fData ) - curves["color3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, color3fData ) - curves["intDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, intData ) - curves["v2iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2iData ) - curves["v3iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3iData ) - curves["stringDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, stringData ) - - # add all valid point attrib types - if not periodic and basis == IECore.CubicBasisf.bSpline() : - - modPData = IECore.V3fVectorData() - modPData.setInterpretation( IECore.GeometricData.Interpretation.Point ) - floatPointData = IECore.FloatVectorData() - v2fPointData = IECore.V2fVectorData() - v3fPointData = IECore.V3fVectorData() - color3fPointData = IECore.Color3fVectorData() - intPointData = IECore.IntVectorData() - v2iPointData = IECore.V2iVectorData() - v3iPointData = IECore.V3iVectorData() - stringPointData = IECore.StringVectorData() - - datas = [ modPData, floatPointData, v2fPointData, v3fPointData, color3fPointData, intPointData, v2iPointData, v3iPointData, stringPointData ] - rawDatas = [ pData, floatVectorData, v2fVectorData, v3fVectorData, color3fVectorData, intVectorData, v2iVectorData, v3iVectorData, stringVectorData ] - - pIndex = 0 - for i in range( 0, numCurves ) : - for j in range( 0, len(datas) ) : - index = 8*i - datas[j].extend( [ rawDatas[j][index], rawDatas[j][index] ] ) - datas[j].extend( rawDatas[j][index:index+8] ) - datas[j].extend( [ rawDatas[j][index+7], rawDatas[j][index+7] ] ) - - curves["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, modPData ) - curves["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatPointData ) - curves["v2fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation,v2fPointData ) - curves["v3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3fPointData ) - curves["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fPointData ) - curves["intPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, intPointData ) - curves["v2iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2iPointData ) - curves["v3iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3iPointData ) - else : - curves["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) - curves["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8*numCurves] ) - curves["v2fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2fVectorData[:8*numCurves] ) - curves["v3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3fVectorData[:8*numCurves] ) - curves["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData[:8*numCurves] ) - curves["intPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, intVectorData[:8*numCurves] ) - curves["v2iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2iVectorData[:8*numCurves] ) - curves["v3iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3iVectorData[:8*numCurves] ) - curves["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData[:8*numCurves], IECore.IntVectorData( list(range( 0, 8*numCurves)) ) ) - - # add all valid primitive attrib types - curves["floatPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, floatVectorData[:numCurves] ) - curves["v2fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v2fVectorData[:numCurves] ) - curves["v3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v3fVectorData[:numCurves] ) - curves["color3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, color3fVectorData[:numCurves] ) - curves["intPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, intVectorData[:numCurves] ) - curves["v2iPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v2iVectorData[:numCurves] ) - curves["v3iPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v3iVectorData[:numCurves] ) - curves["stringPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, stringVectorData[:numCurves], IECore.IntVectorData( list(range( 0, numCurves)) ) ) - - self.assertTrue( curves.arePrimitiveVariablesValid() ) - - return curves - - def emptySop( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - null = geo.createNode( "null" ) - - return null - - def curveSop( self, order=2, periodic=False, parent=None, coordIndex=0 ) : - - if not parent : - obj = hou.node("/obj") - parent = obj.createNode("geo", run_init_scripts=False) - - if hou.applicationVersion()[0] >= 19 : - curve = parent.createNode( "curve::" ) - else : - curve = parent.createNode( "curve" ) - - curve.parm( "type" ).set( 1 ) # NURBS - curve.parm( "order" ).set( order ) - curve.parm( "close" ).set( periodic ) - - coordStr = "" - coords = TestToHoudiniCurvesConverter.__curveCoordinates[coordIndex] - for p in coords : - coordStr += "%f,%f,%f " % ( p[0], p[1], p[2] ) - - curve.parm( "coords" ).set( coordStr ) - - return curve - - def curvesSop( self, numCurves=4, order=2, periodic=False ) : - - curves = [ self.curveSop( order, periodic ) ] - - geo = curves[0].parent() - - for i in range( 0, numCurves-1 ) : - curves.append( self.curveSop( order, periodic, geo, i%4 ) ) - - merge = geo.createNode( "merge" ) - - for i in range( 0, len(curves) ) : - merge.setInput( i, curves[i] ) - - return merge - - def comparePrimAndSop( self, prim, sop ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail" ] : - self.assertEqual( tuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPoints = geo.points() - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[i].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPoints[i].attribValue( key ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[i].attribValue( "stringPoint" ) ) - - sopPrims = geo.prims() - self.assertEqual( len(sopPrims), prim.numCurves() ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[i].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[i].attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPrims[i].attribValue( "stringPrim" ) ) - - sopVerts = [] - for i in range( 0, len(sopPrims) ) : - verts = list(sopPrims[i].vertices()) - self.assertEqual( len(verts), prim.verticesPerCurve()[i] ) - verts.reverse() - sopVerts.extend( verts ) - - self.assertEqual( len(sopVerts), prim["P"].data.size() ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertEqual( result.verticesPerCurve(), prim.verticesPerCurve() ) - self.assertEqual( result.keys(), prim.keys() ) - for key in prim.keys() : - self.assertEqual( result[key], prim[key] ) - self.assertEqual( result, prim ) - - def compareOpenSplinePrimAndSop( self, prim, sop ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail" ] : - self.assertEqual( tuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPrims = geo.prims() - - pIndex = 0 - for i in range( prim.numCurves() ) : - hVertices = sopPrims[i].vertices() - self.assertEqual( len(hVertices) + 4, prim.verticesPerCurve()[i] ) - for j in range( len(hVertices) ) : - - for attr in geo.pointAttribs() : - if attr.name() == "Pw" : - continue - - data = prim[attr.name()].data - if attr.name() in [ "floatPoint", "intPoint" ] : - self.assertEqual( data[pIndex], hVertices[j].point().attribValue( attr.name() ) ) - else : - self.assertEqual( tuple(data[pIndex]), hVertices[j].point().attribValue( attr.name() ) ) - - if ( j == 0 or j == len(hVertices)-1 ) : - if attr.name() in [ "floatPoint", "intPoint" ] : - self.assertEqual( data[pIndex+1], hVertices[j].point().attribValue( attr.name() ) ) - self.assertEqual( data[pIndex+2], hVertices[j].point().attribValue( attr.name() ) ) - else : - self.assertEqual( tuple(data[pIndex+1]), hVertices[j].point().attribValue( attr.name() ) ) - self.assertEqual( tuple(data[pIndex+2]), hVertices[j].point().attribValue( attr.name() ) ) - - if ( j == 0 or j == len(hVertices)-1 ) : - pIndex += 3 - else : - pIndex += 1 - - self.assertEqual( len(sopPrims), prim.numCurves() ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[i].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[i].attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPrims[i].attribValue( "stringPrim" ) ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertEqual( result.verticesPerCurve(), prim.verticesPerCurve() ) - self.assertEqual( result.keys(), prim.keys() ) - for key in prim.keys() : - self.assertEqual( result[key], prim[key] ) - self.assertEqual( result, prim ) - - def comparePrimAndAppendedSop( self, prim, sop, origSopPrim, multipleConversions=False ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail" ] : - self.assertEqual( tuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPoints = geo.points() - numPoints = prim.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - origNumPoints = origSopPrim.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( len(sopPoints), origNumPoints + numPoints ) - - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origNumPoints - - for i in range( 0, origNumPoints ) : - self.assertEqual( defaultValue[i], sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[ origNumPoints + i ].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint" ] : - data = prim[key].data - - if multipleConversions or key is "P" : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origNumPoints - - for i in range( 0, origNumPoints ) : - self.assertEqual( tuple(defaultValue[i]), sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPoints[ origNumPoints + i ].attribValue( key ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - - if multipleConversions : - defaultData = origSopPrim["stringPoint"].data - defaultIndices = origSopPrim["stringPoint"].indices - for i in range( 0, origNumPoints ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopPoints[ i ].attribValue( "stringPoint" ) ) - else : - defaultValues = [ "" ] * origNumPoints - for i in range( 0, origNumPoints ) : - self.assertEqual( defaultValues[i], sopPoints[ i ].attribValue( "stringPoint" ) ) - - sopPrims = geo.prims() - origNumPrims = origSopPrim.numCurves() - self.assertEqual( len(sopPrims), origNumPrims + prim.numCurves() ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origNumPrims - - for i in range( 0, origNumPrims ) : - self.assertEqual( defaultValue[i], sopPrims[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[ origNumPrims + i ].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origNumPrims - - for i in range( 0, origNumPrims ) : - self.assertEqual( tuple(defaultValue[i]), sopPrims[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[ origNumPrims + i ].attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - - if multipleConversions : - defaultData = origSopPrim["stringPrim"].data - defaultIndices = origSopPrim["stringPrim"].indices - for i in range( 0, origNumPrims ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopPrims[ i ].attribValue( "stringPrim" ) ) - else : - defaultValues = [ "" ] * origNumPrims - for i in range( 0, origNumPrims ) : - self.assertEqual( defaultValues[i], sopPrims[ i ].attribValue( "stringPrim" ) ) - - sopVerts = [] - for i in range( 0, len(sopPrims) ) : - verts = list(sopPrims[i].vertices()) - verts.reverse() - sopVerts.extend( verts ) - if i > origNumPrims : - self.assertEqual( len(verts), prim.verticesPerCurve()[i-origNumPrims] ) - - self.assertEqual( len(sopVerts), origSopPrim["P"].data.size() + prim["P"].data.size() ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertEqual( result.verticesPerCurve()[origNumPrims:], prim.verticesPerCurve() ) - for key in prim.keys() : - self.assertTrue( key in result.keys() ) - - def testCreateConverter( self ) : - converter = IECoreHoudini.ToHoudiniCurvesConverter( self.curves() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCurvesConverter ) ) ) - - def testFactory( self ) : - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( self.curves() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniCurvesConverter ) ) ) - self.assertTrue( IECoreScene.TypeId.CurvesPrimitive in IECoreHoudini.ToHoudiniGeometryConverter.supportedTypes() ) - - def testLinearConversion( self ) : - sop = self.emptySop() - - curves = self.curves() - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( periodic=True ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( numCurves=1 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( periodic=True, numCurves=1 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( numCurves=100 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( periodic=True, numCurves=100 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - def testSplineConversion( self ) : - sop = self.emptySop() - spline = IECore.CubicBasisf.bSpline() - - curves = self.curves( basis=spline ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.compareOpenSplinePrimAndSop( curves, sop ) - - curves = self.curves( basis=spline, periodic=True ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( basis=spline, numCurves=1 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.compareOpenSplinePrimAndSop( curves, sop ) - - curves = self.curves( basis=spline, periodic=True, numCurves=1 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - curves = self.curves( basis=spline, numCurves=100 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.compareOpenSplinePrimAndSop( curves, sop ) - - curves = self.curves( basis=spline, periodic=True, numCurves=100 ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - self.comparePrimAndSop( curves, sop ) - - def testConversionIntoExistingSop( self ) : - curves = self.curves() - sop = self.curvesSop() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertNotEqual( orig, curves ) - - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, False ) ) - - self.comparePrimAndSop( curves, sop ) - - def testAppendingIntoExistingSop( self ) : - curves = self.curves() - curvesNumPoints = curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.curvesSop() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, curves ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testAppendingIntoLockedSop( self ) : - curves = self.curves() - curvesNumPoints = curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.curvesSop() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, curves ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testSaveLoad( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - curves = self.curves() - curvesNumPoints = curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.curvesSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, curves ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniCurvesConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniCurvesConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, newSop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( newSop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - def testSaveLoadWithLockedSop( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - curves = self.curves() - curvesNumPoints = curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.curvesSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, curves ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniCurvesConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniCurvesConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, newSop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( newSop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - def testMultipleConversions( self ) : - curves = self.curves() - curvesNumPoints = curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.curvesSop() - - orig = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, curves ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, orig ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, result, multipleConversions=True ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + 2*curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + curvesNumPoints + i ], curves["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( curves, sop, result, multipleConversions=True ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + 3*curvesNumPoints ) - for i in range( 0, curves["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], curves["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + curvesNumPoints + i ], curves["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + 2*curvesNumPoints + i ], curves["P"].data[i] ) - - def testObjectWasDeleted( self ) : - curves = self.curves() - sop = self.curvesSop() - - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - - self.assertTrue( converter.convert( sop, False ) ) - - self.comparePrimAndSop( curves, sop ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - - del curves - - sop.setHardLocked( False ) - self.assertNotEqual( IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert(), result ) - self.assertTrue( converter.convert( sop, False ) ) - self.assertEqual( IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert(), result ) - - def testWithUnacceptablePrimVars( self ) : - curves = self.curves() - curves["badDetail"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.TransformationMatrixfData() ) - curves["badPoint"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - curves["badPrim"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - curves["badVert"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - - self.assertTrue( "badDetail" not in [ x.name() for x in sop.geometry().globalAttribs() ] ) - self.assertTrue( "badPoint" not in [ x.name() for x in sop.geometry().pointAttribs() ] ) - self.assertTrue( "badPrim" not in [ x.name() for x in sop.geometry().primAttribs() ] ) - self.assertTrue( "badVert" not in [ x.name() for x in sop.geometry().vertexAttribs() ] ) - - result = IECoreHoudini.FromHoudiniCurvesConverter( sop ).convert() - self.assertNotEqual( result, curves ) - self.assertTrue( "badDetail" not in result ) - self.assertTrue( "badPoint" not in result ) - self.assertTrue( "badPrim" not in result ) - self.assertTrue( "badVert" not in result ) - - del curves["badDetail"] - del curves["badPoint"] - del curves["badPrim"] - del curves["badVert"] - self.comparePrimAndSop( curves, sop ) - - def testConvertingOverExistingAttribs( self ) : - curves = self.curves() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 0 ) # float - detailAttr.parm( "size" ).set( 1 ) # 1 element - detailAttr.parm( "value1" ).set( 123.456 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 2 ) # point - pointAttr.parm( "type" ).set( 0 ) # float - pointAttr.parm( "size" ).set( 1 ) # 1 element - pointAttr.parm( "value1" ).set( 123.456 ) - - primAttr = pointAttr.createOutputNode( "attribcreate", exact_type_name=True ) - primAttr.parm( "name" ).set( "floatPrim" ) - primAttr.parm( "class" ).set( 1 ) # prim - primAttr.parm( "type" ).set( 0 ) # float - primAttr.parm( "size" ).set( 1 ) # 1 element - primAttr.parm( "value1" ).set( 123.456 ) - - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( primAttr ) ) - self.comparePrimAndSop( curves, primAttr ) - - def testConvertingOverExistingAttribsWithDifferentTypes( self ) : - curves = self.curves() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 1 ) # int - detailAttr.parm( "size" ).set( 3 ) # 3 elements - detailAttr.parm( "value1" ).set( 10 ) - detailAttr.parm( "value2" ).set( 11 ) - detailAttr.parm( "value3" ).set( 12 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 1 ) # point - pointAttr.parm( "type" ).set( 1 ) # int - pointAttr.parm( "size" ).set( 3 ) # 3 elements - pointAttr.parm( "value1" ).set( 10 ) - pointAttr.parm( "value2" ).set( 11 ) - pointAttr.parm( "value3" ).set( 12 ) - - primAttr = pointAttr.createOutputNode( "attribcreate", exact_type_name=True ) - primAttr.parm( "name" ).set( "floatPrim" ) - primAttr.parm( "class" ).set( 1 ) # point - primAttr.parm( "type" ).set( 1 ) # int - primAttr.parm( "size" ).set( 3 ) # 3 elements - primAttr.parm( "value1" ).set( 10 ) - primAttr.parm( "value2" ).set( 11 ) - primAttr.parm( "value3" ).set( 12 ) - - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( primAttr ) ) - self.comparePrimAndSop( curves, primAttr ) - - def testVertAttribsCantBeConverted( self ) : - curves = self.curves() - curves["floatVert"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.FloatVectorData( 1 ) ) - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - - allAttribs = [ x.name() for x in sop.geometry().globalAttribs() ] - allAttribs.extend( [ x.name() for x in sop.geometry().pointAttribs() ] ) - allAttribs.extend( [ x.name() for x in sop.geometry().primAttribs() ] ) - allAttribs.extend( [ x.name() for x in sop.geometry().vertexAttribs() ] ) - self.assertTrue( "floatVert" not in allAttribs ) - - del curves["floatVert"] - self.comparePrimAndSop( curves, sop ) - - def testBadCurve( self ) : - - curves = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 7 ] ), IECore.CubicBasisf.bSpline(), False ) - curves['P'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 2 ), imath.V3f( 2 ) ] ) ) - self.assertTrue( curves.arePrimitiveVariablesValid() ) - - sop = self.emptySop() - self.assertFalse( IECoreHoudini.ToHoudiniCurvesConverter( curves ).convert( sop ) ) - - def testName( self ) : - - sop = self.emptySop() - curves = self.curves() - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - - # unnamed unless we set the parameter - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sop.geometry().findPrimAttrib( "name" ), None ) - - converter["name"].setTypedValue( "testCurves" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testCurves" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testCurves" ]), curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # blindData still works for backwards compatibility - curves.blindData()["name"] = IECore.StringData( "blindCurves" ) - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "blindCurves" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "blindCurves" ]), curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # name parameter takes preference over blindData - converter["name"].setTypedValue( "testCurves" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testCurves" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testCurves" ]), curves.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - def testAttributeFilter( self ) : - - curves = self.curves() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'intPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'floatPrim', 'intPrim', 'stringPrim', 'v2fPrim', 'v2iPrim', 'v3fPrim', 'v3iPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'floatDetail', 'intDetail', 'stringDetail', 'v2fDetail', 'v2iDetail', 'v3fDetail', 'v3iDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "P *3f*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['color3fPoint', 'v3fPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'v3fPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'v3fDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^*Detail ^int*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'floatPrim', 'stringPrim', 'v2fPrim', 'v2iPrim', 'v3fPrim', 'v3iPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - # verify we can filter uvs - for key in curves.keys() : - if key != "P" : - del curves[key] - rand = imath.Rand32() - curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ imath.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) - curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) - curves["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 32 ) ) - curves["Pref"] = curves["P"] - - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['pscale', 'rest', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['Cd'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - # have to filter the source attrs - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]),TestToHoudiniCurvesConverter.PointPositionAttribs + ['pscale', 'rest'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['Cd'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^width ^Pref" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['Cd'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^width ^Cs" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['rest', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - def testStandardAttributeConversion( self ) : - - sop = self.emptySop() - curves = self.curves() - for key in curves.keys() : - if key != "P" : - del curves[key] - rand = imath.Rand32() - curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ imath.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) - curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) - curves["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 32 ) ) - curves["Pref"] = curves["P"] - - self.assertTrue( curves.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sorted([ x.name() for x in geo.pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['pscale', 'rest', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in geo.primAttribs() ]), ['Cd'] ) - self.assertEqual( sorted([ x.name() for x in geo.vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in geo.globalAttribs() ]), [] ) - - uvData = curves["uv"].data - uvs = geo.findPointAttrib( "uv" ) - - i = 0 - for point in geo.points() : - uvValues = point.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[i][0] ) - self.assertAlmostEqual( uvValues[1], uvData[i][1] ) - i += 1 - - converter["convertStandardAttributes"].setTypedValue( False ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sorted([ x.name() for x in geo.pointAttribs() ]), TestToHoudiniCurvesConverter.PointPositionAttribs + ['Pref', 'uv', 'width'] ) - self.assertEqual( sorted([ x.name() for x in geo.primAttribs() ]), ['Cs'] ) - self.assertEqual( sorted([ x.name() for x in geo.vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in geo.globalAttribs() ]), [] ) - - i = 0 - uvData = curves["uv"].data - uvIndices = curves["uv"].indices - uvs = geo.findPointAttrib( "uv" ) - for point in geo.points() : - uvValues = point.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[i][0] ) - self.assertAlmostEqual( uvValues[1], uvData[i][1] ) - i += 1 - - def testLinearCurvesAreConvertedToPolyLines( self ) : - - vertsPerCurve = IECore.IntVectorData( [3, 3, 2] ) - positions = IECore.V3fVectorData( [ - imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), - imath.V3f( 0, 0, 0 ), imath.V3f( 0, 0, 1 ), imath.V3f( 1, 0, 1 ), - imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) - ], IECore.GeometricData.Interpretation.Point ) - - uvs = IECore.V2fVectorData( [imath.V2f( 0, 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 0 )], IECore.GeometricData.Interpretation.UV ) - - curves = IECoreScene.CurvesPrimitive( vertsPerCurve, IECore.CubicBasisf.linear(), False ) - curves["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, positions ) - curves["testUV"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, uvs ) - - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniCurvesConverter( curves ) - self.assertTrue( converter.convert( sop ) ) - - actualVertices = [] - actualTopology = [] - actualUVs = [] - geo = sop.geometry() - self.assertEqual( 3, len( geo.prims() ) ) - for prim in geo.prims() : - self.assertTrue( isinstance( prim, hou.Polygon ) ) - self.assertFalse( prim.isClosed() ) - uv = prim.attribValue( "testUV" ) - actualUVs.append( imath.V2f( uv[0], uv[1] )) - - actualTopology.append( len( prim.vertices() ) ) - for vertex in prim.vertices() : - p = vertex.point().position() - actualVertices.append( imath.V3f( p.x(), p.y(), p.z() ) ) - - self.assertEqual( IECore.V3fVectorData( actualVertices, IECore.GeometricData.Interpretation.Point ), positions ) - self.assertEqual( IECore.IntVectorData( actualTopology ), vertsPerCurve ) - self.assertEqual( IECore.V2fVectorData( actualUVs, IECore.GeometricData.Interpretation.UV ), uvs ) - - def tearDown( self ) : - - if os.path.isfile( TestToHoudiniCurvesConverter.__testScene ) : - os.remove( TestToHoudiniCurvesConverter.__testScene ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/ToHoudiniPointsConverter.py b/test/IECoreHoudini/ToHoudiniPointsConverter.py deleted file mode 100644 index 51e592dd1b..0000000000 --- a/test/IECoreHoudini/ToHoudiniPointsConverter.py +++ /dev/null @@ -1,719 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestToHoudiniPointsConverter( IECoreHoudini.TestCase ) : - - if hou.applicationVersion()[0] >= 16: - PointPositionAttribs = ['P'] - else: - PointPositionAttribs = ['P', 'Pw'] - - __testScene = "test/converterTest.hip" - - def points( self ) : - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), - ] ) - - points = IECoreScene.PointsPrimitive( pData ) - - floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) - v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) - intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) - stringData = IECore.StringData( "this is a string" ) - m33fData = IECore.M33fData( imath.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) ) - m44fData = IECore.M44fData( imath.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) ) - - intRange = list(range( 1, 13)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - quatVectorData = IECore.QuatfVectorData( [ imath.Quatf( x, x+0.25, x+0.5, x+0.75 ) for x in intRange ] ) - intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) - m33fVectorData = IECore.M33fVectorData( [ imath.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) for x in intRange ] ) - m44fVectorData = IECore.M44fVectorData( [ imath.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - uniformInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - - # add all valid detail attrib types - points["floatDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, floatData ) - points["v2fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2fData ) - points["v3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3fData ) - points["color3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, color3fData ) - points["intDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, intData ) - points["v2iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2iData ) - points["v3iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3iData ) - points["stringDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, stringData ) - points["m33fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, m33fData ) - points["m44fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, m44fData ) - - # add all valid prim attrib types - points["floatPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, floatVectorData[:1] ) - points["v2fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, v2fVectorData[:1] ) - points["v3fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, v3fVectorData[:1] ) - points["color3fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, color3fVectorData[:1] ) - points["quatPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, quatVectorData[:1] ) - points["intPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, intVectorData[:1] ) - points["v2iPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, v2iVectorData[:1] ) - points["v3iPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, v3iVectorData[:1] ) - points["stringPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, stringVectorData[:1], IECore.IntVectorData( [ 0 ] ) ) - points["m33fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, m33fVectorData[:1] ) - points["m44fPrim"] = IECoreScene.PrimitiveVariable( uniformInterpolation, m44fVectorData[:1] ) - - # add all valid point attrib types - points["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData ) - points["v2fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2fVectorData ) - points["v3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3fVectorData ) - points["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData ) - points["quatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, quatVectorData ) - points["intPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, intVectorData ) - points["v2iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2iVectorData ) - points["v3iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3iVectorData ) - points["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 12)) ) ) - points["m33fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, m33fVectorData ) - points["m44fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, m44fVectorData ) - - return points - - def emptySop( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - null = geo.createNode( "null" ) - - return null - - def pointsSop( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - box = geo.createNode( "box" ) - facet = box.createOutputNode( "facet" ) - facet.parm( "postnml" ).set(True) - points = facet.createOutputNode( "scatter" ) - - return points - - def comparePrimAndSop( self, prim, sop ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - def toTuple( v ): - if isinstance( v, imath.M33f ): - return ( - v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2] - ) - elif isinstance( v, imath.M44f ): - return ( - v[0][0], v[0][1], v[0][2], v[0][3], - v[1][0], v[1][1], v[1][2], v[1][3], - v[2][0], v[2][1], v[2][2], v[2][3], - v[3][0], v[3][1], v[3][2], v[3][3] - ) - else: - return tuple( v ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail", "m33fDetail", "m44fDetail" ] : - self.assertEqual( toTuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPrims = geo.prims() - for key in [ "floatPrim", "intPrim", "stringPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[i].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim", "m33fPrim", "m44fPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( toTuple(data[i]), sopPrims[i].attribValue( key ) ) - - self.assertEqual( geo.findPrimAttrib( "quatPrim" ).qualifier(), "Quaternion" ) - data = prim["quatPrim"].data - for i in range( 0, data.size() ) : - components = ( data[i].v()[0], data[i].v()[1], data[i].v()[2], data[i].r() ) - self.assertEqual( components, sopPrims[i].attribValue( "quatPrim" ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPrims[i].attribValue( "stringPrim" ) ) - - sopPoints = geo.points() - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[i].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint", "m33fPoint", "m44fPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( toTuple(data[i]), sopPoints[i].attribValue( key ) ) - - self.assertEqual( geo.findPointAttrib( "quatPoint" ).qualifier(), "Quaternion" ) - data = prim["quatPoint"].data - for i in range( 0, data.size() ) : - components = ( data[i].v()[0], data[i].v()[1], data[i].v()[2], data[i].r() ) - self.assertEqual( components, sopPoints[i].attribValue( "quatPoint" ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[i].attribValue( "stringPoint" ) ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.keys(), prim.keys() ) - for key in prim.keys() : - self.assertEqual( result[key], prim[key], (result[key].interpolation, result[key].data, prim[key].interpolation, prim[key].data) ) - self.assertEqual( result, prim ) - - def comparePrimAndAppendedSop( self, prim, sop, origSopPrim, multipleConversions=0 ) : - geo = sop.geometry() - # verify detail attribs - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - def toTuple( v ): - if isinstance( v, imath.M33f ): - return ( - v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2] - ) - elif isinstance( v, imath.M44f ): - return ( - v[0][0], v[0][1], v[0][2], v[0][3], - v[1][0], v[1][1], v[1][2], v[1][3], - v[2][0], v[2][1], v[2][2], v[2][3], - v[3][0], v[3][1], v[3][2], v[3][3] - ) - else: - return tuple( v ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail", "m33fDetail", "m44fDetail" ] : - self.assertEqual( toTuple(prim[key].data.value), geo.attribValue( key ) ) - - # verify prim attribs - sopPrims = geo.prims() - numPrims = multipleConversions + 1 - self.assertEqual( len(sopPrims), numPrims ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - for sopPrim in sopPrims : - self.assertEqual( data[i], sopPrim.attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim", "m33fPrim", "m44fPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - for sopPrim in sopPrims : - self.assertEqual( toTuple(data[i]), sopPrim.attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - for i in range( 0, data.size() ) : - for sopPrim in sopPrims : - self.assertEqual( data[ dataIndices[i] ], sopPrim.attribValue( "stringPrim" ) ) - - # verify points attribs - sopPoints = geo.points() - self.assertEqual( len(sopPoints), origSopPrim.numPoints + prim.numPoints ) - - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origSopPrim.numPoints - - for i in range( 0, origSopPrim.numPoints ) : - self.assertEqual( defaultValue[i], sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[ origSopPrim.numPoints + i ].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint", "m33fPoint", "m44fPoint" ] : - data = prim[key].data - - if multipleConversions or key is "P" : - defaultValue = origSopPrim[key].data - elif isinstance( data, IECore.M33fVectorData ) : - defaultValue = [ [ 0 ] * 9 ] * origSopPrim.numPoints - elif isinstance( data, IECore.M44fVectorData ) : - defaultValue = [ [ 0 ] * 16 ] * origSopPrim.numPoints - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origSopPrim.numPoints - - for i in range( 0, origSopPrim.numPoints ) : - self.assertEqual( toTuple(defaultValue[i]), sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( toTuple(data[i]), sopPoints[ origSopPrim.numPoints + i ].attribValue( key ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - - if multipleConversions : - defaultData = origSopPrim["stringPoint"].data - defaultIndices = origSopPrim["stringPoint"].indices - for i in range( 0, origSopPrim.numPoints ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopPoints[ i ].attribValue( "stringPoint" ) ) - else : - defaultValues = [ "" ] * origSopPrim.numPoints - for i in range( 0, origSopPrim.numPoints ) : - self.assertEqual( defaultValues[i], sopPoints[ i ].attribValue( "stringPoint" ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[ origSopPrim.numPoints + i ].attribValue( "stringPoint" ) ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - for key in prim.keys() : - # prim attribs don't make it through on multiple conversions because the interpolation size is incorrect - if not( multipleConversions and "Prim" in key ) : - self.assertTrue( key in result.keys() ) - - def testCreateConverter( self ) : - converter = IECoreHoudini.ToHoudiniPointsConverter( self.points() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniPointsConverter ) ) ) - - def testFactory( self ) : - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( self.points() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniPointsConverter ) ) ) - self.assertTrue( IECoreScene.TypeId.PointsPrimitive in IECoreHoudini.ToHoudiniGeometryConverter.supportedTypes() ) - - def testConversionIntoEmptySop( self ) : - points = self.points() - sop = self.emptySop() - - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( sop ).convert(), points ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop ) ) - - self.comparePrimAndSop( points, sop ) - - def testConversionIntoExistingSop( self ) : - points = self.points() - sop = self.pointsSop() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, False ) ) - - self.comparePrimAndSop( points, sop ) - - def testAppendingIntoExistingSop( self ) : - points = self.points() - sop = self.pointsSop() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testAppendingIntoLockedSop( self ) : - points = self.points() - sop = self.pointsSop() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testSaveLoad( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - points = self.points() - sop = self.pointsSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniPointsConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniPointsConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, newSop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( newSop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - def testSaveLoadWithLockedSop( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - points = self.points() - sop = self.pointsSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniPointsConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniPointsConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, newSop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( newSop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - def testMultipleConversions( self ) : - points = self.points() - sop = self.pointsSop() - - orig = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( orig, points ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, orig ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, result, multipleConversions=1 ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + 2*points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - self.assertEqual( result["P"].data[ orig.numPoints + points.numPoints + i ], points["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( points, sop, result, multipleConversions=2 ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertEqual( result.numPoints, orig.numPoints + 3*points.numPoints ) - for i in range( 0, points["P"].data.size() ) : - self.assertEqual( result["P"].data[ orig.numPoints + i ], points["P"].data[i] ) - self.assertEqual( result["P"].data[ orig.numPoints + points.numPoints + i ], points["P"].data[i] ) - self.assertEqual( result["P"].data[ orig.numPoints + 2*points.numPoints + i ], points["P"].data[i] ) - - def testObjectWasDeleted( self ) : - points = self.points() - sop = self.pointsSop() - - converter = IECoreHoudini.ToHoudiniPointsConverter( points ) - - self.assertTrue( converter.convert( sop, False ) ) - - self.comparePrimAndSop( points, sop ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - - del points - - sop.setHardLocked( False ) - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( sop ).convert(), result ) - self.assertTrue( converter.convert( sop, False ) ) - self.assertEqual( IECoreHoudini.FromHoudiniPointsConverter( sop ).convert(), result ) - - def testWithUnacceptablePrimVars( self ) : - points = self.points() - points["badDetail"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.TransformationMatrixfData() ) - points["badPoint"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - sop = self.emptySop() - - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( sop ).convert(), points ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop ) ) - - self.assertTrue( "badDetail" not in [ x.name() for x in sop.geometry().globalAttribs() ] ) - self.assertTrue( "badPoint" not in [ x.name() for x in sop.geometry().pointAttribs() ] ) - - result = IECoreHoudini.FromHoudiniPointsConverter( sop ).convert() - self.assertNotEqual( result, points ) - self.assertTrue( "badDetail" not in result ) - self.assertTrue( "badPoint" not in result ) - - del points["badDetail"] - del points["badPoint"] - self.comparePrimAndSop( points, sop ) - - def testConvertingOverExistingAttribs( self ) : - points = self.points() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 0 ) # float - detailAttr.parm( "size" ).set( 1 ) # 1 element - detailAttr.parm( "value1" ).set( 123.456 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 2 ) # point - pointAttr.parm( "type" ).set( 0 ) # float - pointAttr.parm( "size" ).set( 1 ) # 1 element - pointAttr.parm( "value1" ).set( 123.456 ) - - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( pointAttr ).convert(), points ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( pointAttr ) ) - self.comparePrimAndSop( points, pointAttr ) - - def testConvertingOverExistingAttribsWithDifferentTypes( self ) : - points = self.points() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 1 ) # int - detailAttr.parm( "size" ).set( 3 ) # 3 elements - detailAttr.parm( "value1" ).set( 10 ) - detailAttr.parm( "value2" ).set( 11 ) - detailAttr.parm( "value3" ).set( 12 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 2 ) # point - pointAttr.parm( "type" ).set( 1 ) # int - pointAttr.parm( "size" ).set( 3 ) # 3 elements - pointAttr.parm( "value1" ).set( 10 ) - pointAttr.parm( "value2" ).set( 11 ) - pointAttr.parm( "value3" ).set( 12 ) - - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( pointAttr ).convert(), points ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( pointAttr ) ) - self.comparePrimAndSop( points, pointAttr ) - - def testVertAttribsCantBeConverted( self ) : - points = self.points() - points["floatVert"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.FloatVectorData( 1 ) ) - sop = self.emptySop() - - self.assertNotEqual( IECoreHoudini.FromHoudiniPointsConverter( sop ).convert(), points ) - self.assertTrue( IECoreHoudini.ToHoudiniPointsConverter( points ).convert( sop ) ) - - allAttribs = [ x.name() for x in sop.geometry().globalAttribs() ] - allAttribs.extend( [ x.name() for x in sop.geometry().pointAttribs() ] ) - allAttribs.extend( [ x.name() for x in sop.geometry().primAttribs() ] ) - allAttribs.extend( [ x.name() for x in sop.geometry().vertexAttribs() ] ) - self.assertTrue( "floatVert" not in allAttribs ) - - del points["floatVert"] - - self.comparePrimAndSop( points, sop ) - - def testAttributeFilter( self ) : - - points = self.points() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniPointsConverter( points ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPointsConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'intPoint', 'm33fPoint', 'm44fPoint', 'quatPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'floatPrim', 'intPrim', 'm33fPrim', 'm44fPrim', 'quatPrim', 'stringPrim', 'v2fPrim', 'v2iPrim', 'v3fPrim', 'v3iPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'floatDetail', 'intDetail', 'm33fDetail', 'm44fDetail', 'stringDetail', 'v2fDetail', 'v2iDetail', 'v3fDetail', 'v3iDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "P *3f*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPointsConverter.PointPositionAttribs + ['color3fPoint', 'm33fPoint', 'v3fPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'm33fPrim', 'v3fPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'm33fDetail', 'v3fDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^*Detail ^int* ^*Prim" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPointsConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'm33fPoint', 'm44fPoint', 'quatPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - def testStandardAttributeConversion( self ) : - - sop = self.emptySop() - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 1 ) ] * 10 ) ) - points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 10, IECore.GeometricData.Interpretation.Color ) ) - points["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 10 ) ) - points["Pref"] = points["P"] - - self.assertTrue( points.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.ToHoudiniPointsConverter( points ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), sorted( TestToHoudiniPointsConverter.PointPositionAttribs + ['Cd', 'pscale', 'rest'] ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - converter["convertStandardAttributes"].setTypedValue( False ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), sorted( TestToHoudiniPointsConverter.PointPositionAttribs + ['Cs', 'Pref', 'width'] ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), [] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - def testName( self ) : - - sop = self.emptySop() - points = self.points() - converter = IECoreHoudini.ToHoudiniPointsConverter( points ) - - # unnamed unless we set the parameter - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sop.geometry().findPrimAttrib( "name" ), None ) - - converter["name"].setTypedValue( "testPoints" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testPoints" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testPoints" ]), points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # blindData still works for backwards compatibility - points.blindData()["name"] = IECore.StringData( "blindPoints" ) - converter = IECoreHoudini.ToHoudiniPointsConverter( points ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "blindPoints" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "blindPoints" ]), points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # name parameter takes preference over blindData - converter["name"].setTypedValue( "testPoints" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testPoints" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testPoints" ]), points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - def tearDown( self ) : - - if os.path.isfile( TestToHoudiniPointsConverter.__testScene ) : - os.remove( TestToHoudiniPointsConverter.__testScene ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/ToHoudiniPolygonsConverter.py b/test/IECoreHoudini/ToHoudiniPolygonsConverter.py deleted file mode 100644 index 4c83b64305..0000000000 --- a/test/IECoreHoudini/ToHoudiniPolygonsConverter.py +++ /dev/null @@ -1,1123 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import hou -import imath -import IECore -import IECoreScene -import IECoreHoudini -import unittest -import os - -class TestToHoudiniPolygonsConverter( IECoreHoudini.TestCase ) : - - __testScene = "test/converterTest.hip" - - if hou.applicationVersion()[0] >= 16: - PointPositionAttribs = ['P'] - else: - PointPositionAttribs = ['P', 'Pw'] - - def mesh( self ) : - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ 1, 5, 4, 0, 2, 6, 5, 1, 3, 7, 6, 2, 0, 4, 7, 3, 2, 1, 0, 3, 5, 6, 7, 4 ] ) - mesh = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) - - floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ), IECore.GeometricData.Interpretation.Vector ) - v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) - intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) - stringData = IECore.StringData( "this is a string" ) - - intRange = list(range( 1, 25)) - floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ], IECore.GeometricData.Interpretation.Normal ) - color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) - stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) - - detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant - pointInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Vertex - primitiveInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform - vertexInterpolation = IECoreScene.PrimitiveVariable.Interpolation.FaceVarying - - # add all valid detail attrib types - mesh["floatDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, floatData ) - mesh["v2fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2fData ) - mesh["v3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3fData ) - mesh["color3fDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, color3fData ) - mesh["intDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, intData ) - mesh["v2iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v2iData ) - mesh["v3iDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, v3iData ) - mesh["stringDetail"] = IECoreScene.PrimitiveVariable( detailInterpolation, stringData ) - - # add all valid point attrib types - pData = IECore.V3fVectorData( [ - imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), - imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), - ], IECore.GeometricData.Interpretation.Point ) - mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) - mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) - mesh["v2fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2fVectorData[:8] ) - mesh["v3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3fVectorData[:8] ) - mesh["color3fPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, color3fVectorData[:8] ) - mesh["intPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, intVectorData[:8] ) - mesh["v2iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v2iVectorData[:8] ) - mesh["v3iPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, v3iVectorData[:8] ) - mesh["stringPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, stringVectorData[:8], IECore.IntVectorData( list(range( 0, 8)) ) ) - - # add all valid primitive attrib types - mesh["floatPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, floatVectorData[:6] ) - mesh["v2fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v2fVectorData[:6] ) - mesh["v3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v3fVectorData[:6] ) - mesh["color3fPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, color3fVectorData[:6] ) - mesh["intPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, intVectorData[:6] ) - mesh["v2iPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v2iVectorData[:6] ) - mesh["v3iPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, v3iVectorData[:6] ) - mesh["stringPrim"] = IECoreScene.PrimitiveVariable( primitiveInterpolation, stringVectorData[:6], IECore.IntVectorData( list(range( 0, 6)) ) ) - - # add all valid vertex attrib types - mesh["floatVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, floatVectorData ) - mesh["v2fVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, v2fVectorData ) - mesh["v3fVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, v3fVectorData ) - mesh["color3fVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, color3fVectorData ) - mesh["intVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, intVectorData ) - mesh["v2iVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, v2iVectorData ) - mesh["v3iVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, v3iVectorData ) - mesh["stringVert"] = IECoreScene.PrimitiveVariable( vertexInterpolation, stringVectorData, IECore.IntVectorData( list(range( 0, 24)) ) ) - - return mesh - - def emptySop( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - null = geo.createNode( "null" ) - - return null - - def meshSop( self ) : - obj = hou.node( "/obj" ) - geo = obj.createNode( "geo", run_init_scripts=False ) - box = geo.createNode( "box" ) - facet = box.createOutputNode( "facet" ) - facet.parm( "postnml" ).set(True) - - return facet - - def comparePrimAndSop( self, prim, sop ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail" ] : - self.assertEqual( tuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPoints = geo.points() - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[i].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPoints[i].attribValue( key ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[i].attribValue( "stringPoint" ) ) - - sopPrims = geo.prims() - self.assertEqual( len(sopPrims), prim.numFaces() ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[i].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[i].attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPrims[i].attribValue( "stringPrim" ) ) - - sopVerts = [] - for i in range( 0, len(sopPrims) ) : - verts = list(sopPrims[i].vertices()) - self.assertEqual( len(verts), prim.verticesPerFace[i] ) - verts.reverse() - sopVerts.extend( verts ) - - self.assertEqual( len(sopVerts), prim.vertexIds.size() ) - for i in range( 0, len(sopVerts) ) : - self.assertEqual( sopVerts[i].point().number(), prim.vertexIds[i] ) - - for key in [ "floatVert", "intVert" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopVerts[i].attribValue( key ) ) - - for key in [ "v2fVert", "v3fVert", "color3fVert", "v2iVert", "v3iVert" ] : - data = prim[key].data - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopVerts[i].attribValue( key ) ) - - data = prim["stringVert"].data - dataIndices = prim["stringVert"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopVerts[i].attribValue( "stringVert" ) ) - - self.assertTrue( geo.findGlobalAttrib( "v2fDetail" ).isTransformedAsVector() ) - self.assertTrue( geo.findPointAttrib( "v3fPoint" ).isTransformedAsNormal() ) - self.assertTrue( geo.findPrimAttrib( "v3fPrim" ).isTransformedAsNormal() ) - self.assertTrue( geo.findVertexAttrib( "v3fVert" ).isTransformedAsNormal() ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertEqual( result.verticesPerFace, prim.verticesPerFace ) - self.assertEqual( result.vertexIds, prim.vertexIds ) - self.assertEqual( result.keys(), prim.keys() ) - for key in prim.keys() : - self.assertEqual( result[key], prim[key] ) - self.assertEqual( result, prim ) - - self.assertTrue( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( result["v2fDetail"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertTrue( result["v3fPoint"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertTrue( result["v3fPrim"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertTrue( result["v3fVert"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - def comparePrimAndAppendedSop( self, prim, sop, origSopPrim, multipleConversions=False ) : - geo = sop.geometry() - for key in [ "floatDetail", "intDetail", "stringDetail", "stringDetail" ] : - self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) - - for key in [ "v2fDetail", "v3fDetail", "color3fDetail", "v2iDetail", "v3iDetail" ] : - self.assertEqual( tuple(prim[key].data.value), geo.attribValue( key ) ) - - sopPoints = geo.points() - numPoints = prim.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - origNumPoints = origSopPrim.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( len(sopPoints), origNumPoints + numPoints ) - - for key in [ "floatPoint", "intPoint" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origNumPoints - - for i in range( 0, origNumPoints ) : - self.assertEqual( defaultValue[i], sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPoints[ origNumPoints + i ].attribValue( key ) ) - - for key in [ "P", "v2fPoint", "v3fPoint", "color3fPoint", "v2iPoint", "v3iPoint" ] : - data = prim[key].data - - if multipleConversions or key is "P" : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origNumPoints - - for i in range( 0, origNumPoints ) : - self.assertEqual( tuple(defaultValue[i]), sopPoints[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPoints[ origNumPoints + i ].attribValue( key ) ) - - data = prim["stringPoint"].data - dataIndices = prim["stringPoint"].indices - - if multipleConversions : - defaultData = origSopPrim["stringPoint"].data - defaultIndices = origSopPrim["stringPoint"].indices - for i in range( 0, origNumPoints ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopPoints[ i ].attribValue( "stringPoint" ) ) - else : - defaultValues = [ "" ] * origNumPoints - for i in range( 0, origNumPoints ) : - self.assertEqual( defaultValues[i], sopPoints[ i ].attribValue( "stringPoint" ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[ origNumPoints + i ].attribValue( "stringPoint" ) ) - - sopPrims = geo.prims() - origNumPrims = origSopPrim.numFaces() - self.assertEqual( len(sopPrims), origNumPrims + prim.numFaces() ) - - for key in [ "floatPrim", "intPrim" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origNumPrims - - for i in range( 0, origNumPrims ) : - self.assertEqual( defaultValue[i], sopPrims[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopPrims[ origNumPrims + i ].attribValue( key ) ) - - for key in [ "v2fPrim", "v3fPrim", "color3fPrim", "v2iPrim", "v3iPrim" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origNumPrims - - for i in range( 0, origNumPrims ) : - self.assertEqual( tuple(defaultValue[i]), sopPrims[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopPrims[ origNumPrims + i ].attribValue( key ) ) - - data = prim["stringPrim"].data - dataIndices = prim["stringPrim"].indices - - if multipleConversions : - defaultData = origSopPrim["stringPrim"].data - defaultIndices = origSopPrim["stringPrim"].indices - for i in range( 0, origNumPrims ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopPrims[ i ].attribValue( "stringPrim" ) ) - else : - defaultValues = [ "" ] * origNumPrims - for i in range( 0, origNumPrims ) : - self.assertEqual( defaultValues[i], sopPrims[ i ].attribValue( "stringPrim" ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPrims[ origNumPrims + i ].attribValue( "stringPrim" ) ) - - sopVerts = [] - for i in range( 0, len(sopPrims) ) : - verts = list(sopPrims[i].vertices()) - verts.reverse() - sopVerts.extend( verts ) - if i > origNumPrims : - self.assertEqual( len(verts), prim.verticesPerFace[i-origNumPrims] ) - - origNumVerts = origSopPrim.vertexIds.size() - self.assertEqual( len(sopVerts), origNumVerts + prim.vertexIds.size() ) - for i in range( 0, len(prim.vertexIds) ) : - self.assertEqual( sopVerts[origNumVerts+i].point().number() - origNumPoints, prim.vertexIds[i] ) - - for key in [ "floatVert", "intVert" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ 0 ] * origNumVerts - - for i in range( 0, origNumVerts ) : - self.assertEqual( defaultValue[i], sopVerts[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[i], sopVerts[ origNumVerts + i ].attribValue( key ) ) - - for key in [ "v2fVert", "v3fVert", "color3fVert", "v2iVert", "v3iVert" ] : - data = prim[key].data - - if multipleConversions : - defaultValue = origSopPrim[key].data - else : - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origNumVerts - - for i in range( 0, origNumVerts ) : - self.assertEqual( tuple(defaultValue[i]), sopVerts[ i ].attribValue( key ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( tuple(data[i]), sopVerts[ origNumVerts + i ].attribValue( key ) ) - - data = prim["stringVert"].data - dataIndices = prim["stringVert"].indices - - if multipleConversions : - defaultData = origSopPrim["stringVert"].data - defaultIndices = origSopPrim["stringVert"].indices - for i in range( 0, origNumVerts ) : - val = "" if ( defaultIndices[i] >= defaultData.size() ) else defaultData[ defaultIndices[i] ] - self.assertEqual( val, sopVerts[ i ].attribValue( "stringVert" ) ) - else : - defaultValues = [ "" ] * origNumVerts - for i in range( 0, origNumVerts ) : - self.assertEqual( defaultValues[i], sopVerts[ i ].attribValue( "stringVert" ) ) - - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopVerts[ origNumVerts + i ].attribValue( "stringVert" ) ) - - self.assertTrue( geo.findGlobalAttrib( "v2fDetail" ).isTransformedAsVector() ) - self.assertTrue( geo.findPointAttrib( "v3fPoint" ).isTransformedAsNormal() ) - self.assertTrue( geo.findPrimAttrib( "v3fPrim" ).isTransformedAsNormal() ) - self.assertTrue( geo.findVertexAttrib( "v3fVert" ).isTransformedAsNormal() ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertEqual( result.verticesPerFace[origNumPrims:], prim.verticesPerFace ) - for i in range( 0, len(prim.vertexIds) ) : - self.assertEqual( result.vertexIds[origNumVerts + i], prim.vertexIds[i] + origNumPoints ) - for key in prim.keys() : - self.assertTrue( key in result.keys() ) - - self.assertTrue( result["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( result["v2fDetail"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertTrue( result["v3fPoint"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertTrue( result["v3fPrim"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertTrue( result["v3fVert"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - def testCreateConverter( self ) : - converter = IECoreHoudini.ToHoudiniPolygonsConverter( self.mesh() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniPolygonsConverter ) ) ) - - def testFactory( self ) : - converter = IECoreHoudini.ToHoudiniGeometryConverter.create( self.mesh() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.ToHoudiniPolygonsConverter ) ) ) - - self.assertTrue( IECoreScene.TypeId.MeshPrimitive in IECoreHoudini.ToHoudiniGeometryConverter.supportedTypes() ) - - def testConversionIntoEmptySop( self ) : - mesh = self.mesh() - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - self.comparePrimAndSop( mesh, sop ) - - def testConversionIntoExistingSop( self ) : - mesh = self.mesh() - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( orig, mesh ) - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, False ) ) - - self.comparePrimAndSop( mesh, sop ) - - def testAppendingIntoExistingSop( self ) : - mesh = self.mesh() - meshNumPoints = mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, mesh ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testAppendingIntoLockedSop( self ) : - mesh = self.mesh() - meshNumPoints = mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, mesh ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - sop.setHardLocked( False ) - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints ) - self.assertTrue( "floatDetail" not in result.keys() ) - self.assertTrue( "floatPoint" not in result.keys() ) - - def testSaveLoad( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - mesh = self.mesh() - meshNumPoints = mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.meshSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, mesh ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniPolygonsConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniPolygonsConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, newSop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( newSop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - def testSaveLoadWithLockedSop( self ) : - hou.hipFile.clear( suppress_save_prompt=True ) - - mesh = self.mesh() - meshNumPoints = mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.meshSop() - sopPath = sop.path() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, mesh ) - - sop.setHardLocked( True ) - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - hou.hipFile.save( TestToHoudiniPolygonsConverter.__testScene ) - hou.hipFile.clear( suppress_save_prompt=True ) - hou.hipFile.load( TestToHoudiniPolygonsConverter.__testScene ) - - newSop = hou.node( sopPath ) - - self.assertTrue( newSop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, newSop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( newSop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - def testMultipleConversions( self ) : - - mesh = self.mesh() - meshNumPoints = mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - sop = self.meshSop() - - orig = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - origNumPoints = orig.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertNotEqual( orig, mesh ) - - self.assertTrue( not sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, orig ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, result, multipleConversions=True ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + 2*meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + meshNumPoints + i ], mesh["P"].data[i] ) - - self.assertTrue( sop.isHardLocked() ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop, True ) ) - self.assertTrue( sop.isHardLocked() ) - - self.comparePrimAndAppendedSop( mesh, sop, result, multipleConversions=True ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - resultNumPoints = result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( resultNumPoints, origNumPoints + 3*meshNumPoints ) - for i in range( 0, mesh["P"].data.size() ) : - self.assertEqual( result["P"].data[ origNumPoints + i ], mesh["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + meshNumPoints + i ], mesh["P"].data[i] ) - self.assertEqual( result["P"].data[ origNumPoints + 2*meshNumPoints + i ], mesh["P"].data[i] ) - - def testObjectWasDeleted( self ) : - mesh = self.mesh() - sop = self.meshSop() - - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - - self.assertTrue( converter.convert( sop, False ) ) - - self.comparePrimAndSop( mesh, sop ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - - del mesh - - sop.setHardLocked( False ) - self.assertNotEqual( IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert(), result ) - self.assertTrue( converter.convert( sop, False ) ) - self.assertEqual( IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert(), result ) - - def testWithUnacceptablePrimVars( self ) : - mesh = self.mesh() - mesh["badDetail"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.TransformationMatrixfData() ) - mesh["badPoint"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - mesh["badPrim"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - mesh["badVert"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.DoubleVectorData( [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5 ] ) ) - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - self.assertTrue( "badDetail" not in [ x.name() for x in sop.geometry().globalAttribs() ] ) - self.assertTrue( "badPoint" not in [ x.name() for x in sop.geometry().pointAttribs() ] ) - self.assertTrue( "badPrim" not in [ x.name() for x in sop.geometry().primAttribs() ] ) - self.assertTrue( "badVert" not in [ x.name() for x in sop.geometry().vertexAttribs() ] ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertNotEqual( result, mesh ) - self.assertTrue( "badDetail" not in result ) - self.assertTrue( "badPoint" not in result ) - self.assertTrue( "badPrim" not in result ) - self.assertTrue( "badVert" not in result ) - - del mesh["badDetail"] - del mesh["badPoint"] - del mesh["badPrim"] - del mesh["badVert"] - self.comparePrimAndSop( mesh, sop ) - - def testConvertingOverExistingAttribs( self ) : - mesh = self.mesh() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 0 ) # float - detailAttr.parm( "size" ).set( 1 ) # 1 element - detailAttr.parm( "value1" ).set( 123.456 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 2 ) # point - pointAttr.parm( "type" ).set( 0 ) # float - pointAttr.parm( "size" ).set( 1 ) # 1 element - pointAttr.parm( "value1" ).set( 123.456 ) - - primAttr = pointAttr.createOutputNode( "attribcreate", exact_type_name=True ) - primAttr.parm( "name" ).set( "floatPrim" ) - primAttr.parm( "class" ).set( 1 ) # prim - primAttr.parm( "type" ).set( 0 ) # float - primAttr.parm( "size" ).set( 1 ) # 1 element - primAttr.parm( "value1" ).set( 123.456 ) - - vertexAttr = primAttr.createOutputNode( "attribcreate", exact_type_name=True ) - vertexAttr.parm( "name" ).set( "floatVert" ) - vertexAttr.parm( "class" ).set( 3 ) # vertex - vertexAttr.parm( "type" ).set( 0 ) # float - vertexAttr.parm( "size" ).set( 1 ) # 1 element - vertexAttr.parm( "value1" ).set( 123.456 ) - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( vertexAttr ) ) - self.comparePrimAndSop( mesh, vertexAttr ) - - def testConvertingOverExistingAttribsWithDifferentTypes( self ) : - mesh = self.mesh() - sop = self.emptySop() - detailAttr = sop.createOutputNode( "attribcreate", exact_type_name=True ) - detailAttr.parm( "name" ).set( "floatDetail" ) - detailAttr.parm( "class" ).set( 0 ) # detail - detailAttr.parm( "type" ).set( 1 ) # int - detailAttr.parm( "size" ).set( 3 ) # 3 elements - detailAttr.parm( "value1" ).set( 10 ) - detailAttr.parm( "value2" ).set( 11 ) - detailAttr.parm( "value3" ).set( 12 ) - - pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True ) - pointAttr.parm( "name" ).set( "floatPoint" ) - pointAttr.parm( "class" ).set( 2 ) # point - pointAttr.parm( "type" ).set( 1 ) # int - pointAttr.parm( "size" ).set( 3 ) # 3 elements - pointAttr.parm( "value1" ).set( 10 ) - pointAttr.parm( "value2" ).set( 11 ) - pointAttr.parm( "value3" ).set( 12 ) - - primAttr = pointAttr.createOutputNode( "attribcreate", exact_type_name=True ) - primAttr.parm( "name" ).set( "floatPrim" ) - primAttr.parm( "class" ).set( 1 ) # prim - primAttr.parm( "type" ).set( 1 ) # int - primAttr.parm( "size" ).set( 3 ) # 3 elements - primAttr.parm( "value1" ).set( 10 ) - primAttr.parm( "value2" ).set( 11 ) - primAttr.parm( "value3" ).set( 12 ) - - vertexAttr = primAttr.createOutputNode( "attribcreate", exact_type_name=True ) - vertexAttr.parm( "name" ).set( "floatVert" ) - vertexAttr.parm( "class" ).set( 3 ) # vert - vertexAttr.parm( "type" ).set( 1 ) # int - vertexAttr.parm( "size" ).set( 3 ) # 3 elements - vertexAttr.parm( "value1" ).set( 10 ) - vertexAttr.parm( "value2" ).set( 11 ) - vertexAttr.parm( "value3" ).set( 12 ) - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( vertexAttr ) ) - self.comparePrimAndSop( mesh, vertexAttr ) - - def testEmptyString( self ) : - mesh = self.mesh() - sop = self.emptySop() - mesh['stringPoint'].data[0] = "" - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - geo = sop.geometry() - sopPoints = geo.points() - data = mesh["stringPoint"].data - dataIndices = mesh["stringPoint"].indices - for i in range( 0, data.size() ) : - self.assertEqual( data[ dataIndices[i] ], sopPoints[i].attribValue( "stringPoint" ) ) - - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertEqual( result.verticesPerFace, mesh.verticesPerFace ) - self.assertEqual( result.vertexIds, mesh.vertexIds ) - self.assertEqual( result.keys(), mesh.keys() ) - - self.assertEqual( result["stringPoint"], mesh["stringPoint"] ) - - def testName( self ) : - - sop = self.emptySop() - mesh = self.mesh() - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - - # unnamed unless we set the parameter - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sop.geometry().findPrimAttrib( "name" ), None ) - - converter["name"].setTypedValue( "testMesh" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testMesh" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testMesh" ]), mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # blindData still works for backwards compatibility - mesh.blindData()["name"] = IECore.StringData( "blindMesh" ) - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "blindMesh" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "blindMesh" ]), mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - # name parameter takes preference over blindData - converter["name"].setTypedValue( "testMesh" ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - nameAttr = sop.geometry().findPrimAttrib( "name" ) - self.assertEqual( nameAttr.strings(), tuple( [ "testMesh" ] ) ) - self.assertEqual( len([ x for x in geo.prims() if x.attribValue( "name" ) == "testMesh" ]), mesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) - - def testAttributeFilter( self ) : - - mesh = self.mesh() - sop = self.emptySop() - - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPolygonsConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'intPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'floatPrim', 'ieMeshInterpolation', 'intPrim', 'stringPrim', 'v2fPrim', 'v2iPrim', 'v3fPrim', 'v3iPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['color3fVert', 'floatVert', 'intVert', 'stringVert', 'v2fVert', 'v2iVert', 'v3fVert', 'v3iVert'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'floatDetail', 'intDetail', 'stringDetail', 'v2fDetail', 'v2iDetail', 'v3fDetail', 'v3iDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "P *3f*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPolygonsConverter.PointPositionAttribs + ['color3fPoint', 'v3fPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'ieMeshInterpolation', 'v3fPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['color3fVert', 'v3fVert'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), ['color3fDetail', 'v3fDetail'] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^*Detail ^int*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), TestToHoudiniPolygonsConverter.PointPositionAttribs + ['color3fPoint', 'floatPoint', 'stringPoint', 'v2fPoint', 'v2iPoint', 'v3fPoint', 'v3iPoint'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['color3fPrim', 'floatPrim', 'ieMeshInterpolation', 'stringPrim', 'v2fPrim', 'v2iPrim', 'v3fPrim', 'v3iPrim'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['color3fVert', 'floatVert', 'stringVert', 'v2fVert', 'v2iVert', 'v3fVert', 'v3iVert'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - # verify we can filter uvs - mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) - mesh = IECoreScene.MeshAlgo.triangulate( mesh ) - IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) - mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) - mesh["Pref"] = mesh["P"] - - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - converter.parameters()["attributeFilter"].setTypedValue( "*" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), sorted( TestToHoudiniPolygonsConverter.PointPositionAttribs + ['N', 'pscale', 'rest'] ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['ieMeshInterpolation', ] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['Cd', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - # have to filter the source attrs - converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), sorted( TestToHoudiniPolygonsConverter.PointPositionAttribs + ['N', 'pscale', 'rest'] ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['ieMeshInterpolation', ] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['Cd'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - converter.parameters()["attributeFilter"].setTypedValue( "* ^width ^Pref" ) - self.assertTrue( converter.convert( sop ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().pointAttribs() ]), sorted( TestToHoudiniPolygonsConverter.PointPositionAttribs + ['N'] ) ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().primAttribs() ]), ['ieMeshInterpolation', ] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().vertexAttribs() ]), ['Cd', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) - - def testStandardAttributeConversion( self ) : - - sop = self.emptySop() - mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) - mesh = IECoreScene.MeshAlgo.triangulate( mesh ) - IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) - mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) - mesh["Pref"] = mesh["P"] - - self.assertTrue( mesh.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sorted([ x.name() for x in geo.pointAttribs() ]), sorted( TestToHoudiniPolygonsConverter.PointPositionAttribs + ['N', 'pscale', 'rest'] ) ) - self.assertEqual( sorted([ x.name() for x in geo.primAttribs() ]), ['ieMeshInterpolation'] ) - self.assertEqual( sorted([ x.name() for x in geo.vertexAttribs() ]), ['Cd', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in geo.globalAttribs() ]), [] ) - - uvData = mesh["uv"].data - indices = mesh["uv"].indices - - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[indices[i]][0] ) - self.assertAlmostEqual( uvValues[1], uvData[indices[i]][1] ) - i += 1 - - converter["convertStandardAttributes"].setTypedValue( False ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - self.assertEqual( sorted([ x.name() for x in geo.pointAttribs() ]), sorted( TestToHoudiniPolygonsConverter.PointPositionAttribs + ['N', 'Pref', 'width'] ) ) - self.assertEqual( sorted([ x.name() for x in geo.primAttribs() ]), ['ieMeshInterpolation', ] ) - self.assertEqual( sorted([ x.name() for x in geo.vertexAttribs() ]), ['Cs', 'uv'] ) - self.assertEqual( sorted([ x.name() for x in geo.globalAttribs() ]), [] ) - - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[indices[i]][0] ) - self.assertAlmostEqual( uvValues[1], uvData[indices[i]][1] ) - i += 1 - - def testCannotTransformRest( self ) : - - sop = self.emptySop() - mergeGeo = hou.node( "/obj" ).createNode( "geo", run_init_scripts=False ) - mergeGeo.parm( "tx" ).set( 10 ) - merge = mergeGeo.createNode( "object_merge" ) - merge.parm( "xformtype" ).set( 1 ) - merge.parm( "objpath1" ).set( sop.path() ) - - mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) - mesh = IECoreScene.MeshAlgo.triangulate( mesh ) - IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Pref"] = mesh["P"] - prefData = mesh["Pref"].data - self.assertTrue( mesh.arePrimitiveVariablesValid() ) - - converter = IECoreHoudini.ToHoudiniPolygonsConverter( mesh ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - geo2 = merge.geometry() - - i = 0 - for point in geo.points() : - restValue = point.attribValue( "rest" ) - self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) - self.assertTrue( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) - i += 1 - - i = 0 - for point in geo2.points() : - restValue = point.attribValue( "rest" ) - self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) - self.assertFalse( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) - i += 1 - - # Pref shouldn't transform either - converter["convertStandardAttributes"].setTypedValue( False ) - self.assertTrue( converter.convert( sop ) ) - geo = sop.geometry() - geo2 = merge.geometry() - - i = 0 - for point in geo.points() : - restValue = point.attribValue( "Pref" ) - self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) - self.assertTrue( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) - i += 1 - - i = 0 - for point in geo2.points() : - restValue = point.attribValue( "Pref" ) - self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) - self.assertFalse( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) - i += 1 - - def testInterpolation( self ) : - - mesh = self.mesh() - sop = self.emptySop() - self.assertEqual( mesh.interpolation, "linear" ) - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - self.assertTrue( "ieMeshInterpolation" in [ x.name() for x in sop.geometry().primAttribs() ] ) - attrib = sop.geometry().findPrimAttrib( "ieMeshInterpolation" ) - for prim in sop.geometry().prims() : - self.assertEqual( prim.attribValue( attrib ), "poly" ) - - mesh.interpolation = "catmullClark" - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - self.assertTrue( "ieMeshInterpolation" in [ x.name() for x in sop.geometry().primAttribs() ] ) - attrib = sop.geometry().findPrimAttrib( "ieMeshInterpolation" ) - for prim in sop.geometry().prims() : - self.assertEqual( prim.attribValue( attrib ), "subdiv" ) - - def testExpandedUVRoundTrip( self ) : - - mesh = IECore.Reader.create( "test/IECore/data/cobFiles/twoTrianglesWithSharedUVs.cob" ).read() - mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, mesh["uv"].expandedData(), None ) - mesh["uv"].indices = None - uvData = mesh["uv"].data - - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - geo = sop.geometry() - self.assertTrue( "uv" in [ x.name() for x in geo.vertexAttribs() ] ) - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[i][0] ) - self.assertAlmostEqual( uvValues[1], uvData[i][1] ) - i += 1 - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( sop ) - result = converter.convert() - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - # we cannot guarantee to generate the same data when extracting from Houdini - # because we always generate indices, but we can generate correctly indexed data - self.assertEqual( result["uv"].data.size(), 4 ) - self.assertEqual( result["uv"].indices.size(), 6 ) - for i in range( 0, mesh.variableSize( mesh["uv"].interpolation ) ) : - self.assertEqual( mesh["uv"].data[i], result["uv"].data[ result["uv"].indices[i] ] ) - - def testIndexedUVRoundTrip( self ) : - - mesh = IECore.Reader.create( "test/IECore/data/cobFiles/twoTrianglesWithSharedUVs.cob" ).read() - uvData = mesh["uv"].data - uvIndices = mesh["uv"].indices - - sop = self.emptySop() - - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - geo = sop.geometry() - self.assertTrue( "uv" in [ x.name() for x in geo.vertexAttribs() ] ) - uvs = geo.findVertexAttrib( "uv" ) - - i = 0 - for prim in geo.prims() : - verts = list(prim.vertices()) - verts.reverse() - for vert in verts : - uvValues = vert.attribValue( uvs ) - self.assertAlmostEqual( uvValues[0], uvData[uvIndices[i]][0] ) - self.assertAlmostEqual( uvValues[1], uvData[uvIndices[i]][1] ) - i += 1 - - converter = IECoreHoudini.FromHoudiniPolygonsConverter( sop ) - result = converter.convert() - self.assertEqual( result["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - # we cannot guarantee to generate the same indices when extracting from Houdini - # nor the same data, but we can generate correctly indexed data - self.assertEqual( result["uv"].data.size(), 4 ) - self.assertEqual( result["uv"].indices.size(), 6 ) - for i in range( 0, mesh.variableSize( mesh["uv"].interpolation ) ) : - self.assertEqual( mesh["uv"].data[ mesh["uv"].indices[i] ], result["uv"].data[ result["uv"].indices[i] ] ) - - def testCornersAndCreases( self ) : - - mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) - # normals and UVs complicate the testing, and we don't need them to verify corners and creases - del mesh["N"] - del mesh["uv"] - cornerIds = [ 5 ] - cornerSharpnesses = [ 10.0 ] - mesh.setCorners( IECore.IntVectorData( cornerIds ), IECore.FloatVectorData( cornerSharpnesses ) ) - creaseLengths = [ 3, 2 ] - creaseIds = [ 1, 2, 3, 4, 5 ] # note that these are vertex ids - creaseSharpnesses = [ 1, 5 ] - mesh.setCreases( IECore.IntVectorData( creaseLengths ), IECore.IntVectorData( creaseIds ), IECore.FloatVectorData( creaseSharpnesses ) ) - - sop = self.emptySop() - self.assertTrue( IECoreHoudini.ToHoudiniPolygonsConverter( mesh ).convert( sop ) ) - - geo = sop.geometry() - self.assertTrue( "cornerweight" in [ x.name() for x in geo.pointAttribs() ] ) - self.assertTrue( "creaseweight" in [ x.name() for x in geo.vertexAttribs() ] ) - - # test corners - cornerWeight = geo.findPointAttrib( "cornerweight" ) - for point in geo.points() : - sharpness = 0.0 - if point.number() in cornerIds : - sharpness = cornerSharpnesses[ cornerIds.index( point.number() ) ] - self.assertEqual( point.attribValue( cornerWeight ), sharpness ) - - # test creases - expectedSharpnesses = [ 0 ] * 24 - # edge 1-2 - expectedSharpnesses[1] = 1 - expectedSharpnesses[2] = 1 - # edge 2-3 - expectedSharpnesses[6] = 1 - expectedSharpnesses[18] = 1 - # edge 4-5 - expectedSharpnesses[4] = 5 - expectedSharpnesses[10] = 5 - - self.assertEqual( list(geo.vertexFloatAttribValues( "creaseweight" )), expectedSharpnesses ) - - # make sure it round trips well enough - result = IECoreHoudini.FromHoudiniPolygonsConverter( sop ).convert() - self.assertEqual( result.cornerIds(), mesh.cornerIds() ) - self.assertEqual( result.cornerSharpnesses(), mesh.cornerSharpnesses() ) - self.assertEqual( result.creaseLengths(), IECore.IntVectorData( [ 2, 2, 2 ] ) ) - self.assertEqual( result.creaseIds(), IECore.IntVectorData( [ 2, 3, 1, 2, 4, 5 ] ) ) - self.assertEqual( result.creaseSharpnesses(), IECore.FloatVectorData( [ 1, 1, 5 ] ) ) - # if we re-align result creases, everything else is an exact match - mesh.setCreases( result.creaseLengths(), result.creaseIds(), result.creaseSharpnesses() ) - self.assertEqual( result, mesh ) - - def tearDown( self ) : - - if os.path.isfile( TestToHoudiniPolygonsConverter.__testScene ) : - os.remove( TestToHoudiniPolygonsConverter.__testScene ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/UpdateMode.py b/test/IECoreHoudini/UpdateMode.py deleted file mode 100644 index e1e27b6945..0000000000 --- a/test/IECoreHoudini/UpdateMode.py +++ /dev/null @@ -1,83 +0,0 @@ -########################################################################## -# -# Copyright (c) 2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import hou -import IECoreHoudini -import unittest - -class TestUpdateMode( IECoreHoudini.TestCase ) : - - def testSetMode( self ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - with IECoreHoudini.UpdateMode( hou.updateMode.Manual ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.Manual ) - - with IECoreHoudini.UpdateMode( hou.updateMode.AutoUpdate ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.Manual ) - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - def testSetCurrentMode( self ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - with IECoreHoudini.UpdateMode( hou.updateMode.AutoUpdate ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - def testRaising( self ) : - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - - try : - with IECoreHoudini.UpdateMode( hou.updateMode.Manual ) : - - raise RuntimeError("This error is intentional") - - except RuntimeError: - - self.assertEqual( hou.updateModeSetting(), hou.updateMode.AutoUpdate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreHoudini/data/otls/testHDAs.otl b/test/IECoreHoudini/data/otls/testHDAs.otl deleted file mode 100644 index 7dcc916fea..0000000000 Binary files a/test/IECoreHoudini/data/otls/testHDAs.otl and /dev/null differ diff --git a/test/IECoreHoudini/data/torus.cob b/test/IECoreHoudini/data/torus.cob deleted file mode 100644 index f861cfa53b..0000000000 Binary files a/test/IECoreHoudini/data/torus.cob and /dev/null differ diff --git a/test/IECoreHoudini/data/torusH14.cob b/test/IECoreHoudini/data/torusH14.cob deleted file mode 100644 index 82c2d20ca3..0000000000 Binary files a/test/IECoreHoudini/data/torusH14.cob and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.0250.fio b/test/IECoreHoudini/data/torusVertCache.0250.fio deleted file mode 100644 index afb23d0c7b..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.0250.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.0300.fio b/test/IECoreHoudini/data/torusVertCache.0300.fio deleted file mode 100644 index afb23d0c7b..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.0300.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.0450.fio b/test/IECoreHoudini/data/torusVertCache.0450.fio deleted file mode 100644 index 1cf644fe32..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.0450.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.0500.fio b/test/IECoreHoudini/data/torusVertCache.0500.fio deleted file mode 100644 index 1cf644fe32..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.0500.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.0750.fio b/test/IECoreHoudini/data/torusVertCache.0750.fio deleted file mode 100644 index a02067f5e6..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.0750.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusVertCache.1000.fio b/test/IECoreHoudini/data/torusVertCache.1000.fio deleted file mode 100644 index afa39da42d..0000000000 Binary files a/test/IECoreHoudini/data/torusVertCache.1000.fio and /dev/null differ diff --git a/test/IECoreHoudini/data/torusWithVertexNormals.bgeo b/test/IECoreHoudini/data/torusWithVertexNormals.bgeo deleted file mode 100644 index 185f044b7b..0000000000 Binary files a/test/IECoreHoudini/data/torusWithVertexNormals.bgeo and /dev/null differ diff --git a/test/IECoreHoudini/data/torus_with_normals.cob b/test/IECoreHoudini/data/torus_with_normals.cob deleted file mode 100644 index 89a1d216d5..0000000000 Binary files a/test/IECoreHoudini/data/torus_with_normals.cob and /dev/null differ diff --git a/test/IECoreHoudini/ops/cobReader/cobReader-1.py b/test/IECoreHoudini/ops/cobReader/cobReader-1.py deleted file mode 100644 index 8791fccdcb..0000000000 --- a/test/IECoreHoudini/ops/cobReader/cobReader-1.py +++ /dev/null @@ -1,31 +0,0 @@ -import IECore - -class cobReader( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that reads a COB from disk.", - IECore.ObjectParameter( - name = "result", - description = "The Cortex Object read from disk.", - defaultValue = IECore.NullObject(), - type = IECore.TypeId.Object - ) - ) - - self.parameters().addParameter( - - IECore.PathParameter( - name = "filename", - description = "The path to the COB on disk.", - defaultValue = "", - ) - ) - - def doOperation( self, args ) : - filename = args['filename'].value - obj = IECore.Reader.create(filename).read() - return obj - -IECore.registerRunTimeTyped( cobReader ) diff --git a/test/IECoreHoudini/ops/meshMerge/meshMerge-1.py b/test/IECoreHoudini/ops/meshMerge/meshMerge-1.py deleted file mode 100644 index 3a904263c3..0000000000 --- a/test/IECoreHoudini/ops/meshMerge/meshMerge-1.py +++ /dev/null @@ -1 +0,0 @@ -from IECoreScene import MeshMergeOp as meshMerge diff --git a/test/IECoreHoudini/ops/meshNormalsOp/meshNormalsOp-1.py b/test/IECoreHoudini/ops/meshNormalsOp/meshNormalsOp-1.py deleted file mode 100644 index d3eb88cad0..0000000000 --- a/test/IECoreHoudini/ops/meshNormalsOp/meshNormalsOp-1.py +++ /dev/null @@ -1 +0,0 @@ -from IECoreScene import MeshNormalsOp as meshNormalsOp diff --git a/test/IECoreHoudini/ops/multiTypeObject/multiTypeObject-1.py b/test/IECoreHoudini/ops/multiTypeObject/multiTypeObject-1.py deleted file mode 100644 index 3296baceb6..0000000000 --- a/test/IECoreHoudini/ops/multiTypeObject/multiTypeObject-1.py +++ /dev/null @@ -1,35 +0,0 @@ -import IECore -import IECoreScene - -class multiTypeObject( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that returns either a MeshPrimitive or a PointsPrimitive, depending on the input type.", - IECore.ObjectParameter( - name = "result", - description = "", - defaultValue = IECoreScene.Group(), - type = IECoreScene.TypeId.Primitive - ) - ) - - self.parameters().addParameter( - IECore.ObjectParameter( - name = "input", - description = "An object parameter that accepts multiple types.", - defaultValue = IECore.V3fVectorData([]), - types = [ IECoreScene.TypeId.Primitive, IECore.TypeId.V3fVectorData ] - ), - ) - - def doOperation( self, args ) : - obj = args['input'] - - if isinstance( obj, IECore.V3fVectorData ) : - return IECoreScene.PointsPrimitive( obj ) - - return obj - -IECore.registerRunTimeTyped( multiTypeObject ) diff --git a/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py b/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py deleted file mode 100644 index 7a6a0f3261..0000000000 --- a/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py +++ /dev/null @@ -1,67 +0,0 @@ -import imath -import IECore -import IECoreScene -import hou - -class noiseDeformer( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that displaces verts along their normals using some noise.", - IECoreScene.PrimitiveParameter( - name = "result", - description = "The primitive with displaced verts.", - defaultValue = IECoreScene.PointsPrimitive(IECore.V3fVectorData()), - ) - ) - - self.parameters().addParameters([ - IECoreScene.PrimitiveParameter( - name = "input", - description = "The primitive to work on.", - defaultValue = IECoreScene.PointsPrimitive(IECore.V3fVectorData()) ), - IECore.FloatParameter( - name = "magnitude", - description = "The amount to displace by.", - defaultValue = 1.0 ), - IECore.V3fParameter( - name = "frequency", - description = "The frequency of the displacement noise.", - defaultValue = imath.V3f(1.0) ) - ] - ) - - def doOperation( self, args ) : - - # take a copy of our input parameter - prim = args['input'].copy() - - # check for P & N - if not "P" in prim: - raise Exception("Must have primvar 'P' in primitive!") - if not "N" in prim: - IECore.error( "Must have primvar 'N' in primitive!" ) - return IECoreScene.PointsPrimitive( 1 ) - - # get our magnitude & frequency parameters - mag = args['magnitude'].value - freq = args['frequency'].value - - # calculate a new set of positions - p_data = prim['P'].data - new_p = [] - for p in p_data: - noise_val = mag * ( hou.hmath.noise3d( [p.x * freq.x, p.y * freq.y, p.z * freq.z] ) - hou.Vector3(.5,.5,.5) ) * 2 - new_p.append( p + imath.V3f( noise_val[0], noise_val[1], noise_val[2] ) ) - - # overwrite with our new P and return from the Op - prim['P'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( new_p ) ) - - # recalculate normals - if prim.typeId()==IECoreScene.TypeId.MeshPrimitive: - IECoreScene.MeshNormalsOp()( input=prim, copyInput=False ) - - return prim - -IECore.registerRunTimeTyped( noiseDeformer ) diff --git a/test/IECoreHoudini/ops/objectDebug/objectDebug-1.py b/test/IECoreHoudini/ops/objectDebug/objectDebug-1.py deleted file mode 100644 index e5710ef7e8..0000000000 --- a/test/IECoreHoudini/ops/objectDebug/objectDebug-1.py +++ /dev/null @@ -1,53 +0,0 @@ -import IECore -import IECoreScene - -class objectDebug( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that prints out debug information about an object parameter.", - IECore.ObjectParameter( - name = "result", - description = "A pass through of the input object parameter.", - defaultValue = IECore.NullObject(), - type = IECore.TypeId.Object - ) - ) - - self.parameters().addParameter( - - IECore.ObjectParameter( - name = "input", - description = "The input object.", - defaultValue = IECore.NullObject(), - type = IECore.TypeId.Object - ) - ) - self.parameters().addParameter( - - IECore.BoolParameter( - name = "quiet", - description = "Silences the debug output.", - defaultValue = False - ) - ) - - def doOperation( self, args ) : - object = args['input'] - quiet = args['quiet'].value - if not quiet: - - # Print the objects name and its str() representation - print(object.typeName(), object) - - # For meshes & points we can print out more verbose information - if object.typeId()==IECoreScene.TypeId.MeshPrimitive or object.typeId()==IECoreScene.TypeId.PointsPrimitive: - for k in object.keys(): - primvar = object[k] - print("[%s]" % k, primvar.interpolation, primvar.data.typeName()) - print("\t", primvar.data) - - return object - -IECore.registerRunTimeTyped( objectDebug ) diff --git a/test/IECoreHoudini/ops/objectDebug/objectDebug-2.py b/test/IECoreHoudini/ops/objectDebug/objectDebug-2.py deleted file mode 100644 index 90b13d464a..0000000000 --- a/test/IECoreHoudini/ops/objectDebug/objectDebug-2.py +++ /dev/null @@ -1,54 +0,0 @@ -import IECore -import IECoreScene - -class objectDebug( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that prints out debug information about an object parameter.", - IECore.ObjectParameter( - name = "result", - description = "A pass through of the input object parameter.", - defaultValue = IECore.NullObject(), - type = IECore.TypeId.Object - ) - ) - - self.parameters().addParameter( - IECore.ObjectParameter( - name = "input", - description = "The input object.", - defaultValue = IECore.NullObject(), - type = IECore.TypeId.Object - ) - ) - - levelPresets = [ ( str(x), int(x) ) for x in IECore.MessageHandler.Level.values.values() if x != IECore.MessageHandler.Level.Invalid ] - - self.parameters().addParameters( [ - IECore.IntParameter( - name = "messageLevel", - description = "The IECore Message Level of the debug info", - defaultValue = IECore.MessageHandler.Level.Debug, - presets = levelPresets, - presetsOnly = True, - ) - ] ) - - def doOperation( self, args ) : - - obj = args['input'] - - level = IECore.MessageHandler.Level( args["messageLevel"].value ) - IECore.msg( level, "objectDebug", obj.typeName() + " " + str(obj) ) - - if obj.isInstanceOf( IECoreScene.TypeId.Primitive ) : - for k in obj.keys() : - primvar = obj[k] - msg = "[%s], %s, %s, %s" % ( k, primvar.interpolation, primvar.data.typeName(), str(primvar.data) ) - IECore.msg( level, "objectDebug", msg ) - - return obj - -IECore.registerRunTimeTyped( objectDebug ) diff --git a/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py b/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py deleted file mode 100644 index 7a20cc755e..0000000000 --- a/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py +++ /dev/null @@ -1,145 +0,0 @@ -import imath -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreScene - -class compoundParameters( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op with some compound parameters.", - IECore.ObjectParameter( - name = "result", - description = "Dummy.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData() ), - type = IECoreScene.TypeId.PointsPrimitive - ) - ) - - self.parameters().addParameters( [ - - IECore.CompoundParameter( - name = "compound_1", - description = "a compound parameter", - userData = { "UI" : { "label" : IECore.StringData( "My Compound 1" ) } }, - members = [ - IECore.V3dParameter( - name = "j", - description = "a v3d", - defaultValue = IECore.V3dData( imath.V3d( 8, 16, 32 ) ), - userData = { "UI" : { "label" : IECore.StringData( "A Vector" ) } }, - ), - IECore.Color3fParameter( - name = "k", - description = "an m44f", - defaultValue = imath.Color3f(1,0.5,0), - userData = { "UI" : { "label" : IECore.StringData( "A Colour" ) } }, - ), - ] - ), - - IECore.CompoundParameter( - name = "compound_2", - description = "a compound parameter", - userData = { "UI" : { "label" : IECore.StringData( "My Compound 2" ) } }, - members = [ - IECore.V3dParameter( - name = "j", - description = "a v3d", - defaultValue = IECore.V3dData( imath.V3d( 8, 16, 32 ) ), - presets = ( - ( "one", imath.V3d( 1 ) ), - ( "two", imath.V3d( 2 ) ) - ), - userData = { "UI" : { "label" : IECore.StringData( "Compound->V3d" ) } }, - ), - IECore.V2fParameter( - name = "k", - description = "an v2f", - defaultValue = imath.V2f(1,1) - ), - ] - ), - - IECore.CompoundParameter( - name = "compound_3", - description = "a compound parameter", - userData ={ "UI" : { "label" : IECore.StringData( "My Compound 3" ) } }, - members = [ - IECore.CompoundParameter( - name = "compound_4", - description = "a compound parameter", - userData = { "UI" : { "label" : IECore.StringData( "My Compound 4" ) } }, - members = [ - IECore.IntParameter( - name = "some_int", - description = "Int", - defaultValue = 123, - userData = { "UI" : { "label" : IECore.StringData( "Int" ) } }, - ), - ] - ) - ] - ), - - IECore.FloatParameter( - name="blah", - description="blah", - defaultValue = 123.0 - ), - - IECore.CompoundParameter( - name = "compound_5", - description = "a compound parameter", - userData = { "UI" : { "label" : IECore.StringData( "Another Compound Parameter" ) } }, - members = [ - IECore.BoolParameter( - name = "bool_1", - description = "a boolean parameter", - defaultValue = True - ) - ] - ) - ] ) - - def doOperation( self, args ) : - return IECoreScene.PointsPrimitive( IECore.V3fVectorData() ) - -IECore.registerRunTimeTyped( compoundParameters ) diff --git a/test/IECoreHoudini/ops/parameters/primitives/pointParam/pointParam-1.py b/test/IECoreHoudini/ops/parameters/primitives/pointParam/pointParam-1.py deleted file mode 100644 index 359084ea21..0000000000 --- a/test/IECoreHoudini/ops/parameters/primitives/pointParam/pointParam-1.py +++ /dev/null @@ -1,28 +0,0 @@ -import IECore -import IECoreScene - -class pointParam( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that has point parameters.", - IECoreScene.PointsPrimitiveParameter( - name = "result", - description = "A pass through of the input primitive parameter.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [] ) ) - ) - ) - - self.parameters().addParameter( - IECoreScene.PointsPrimitiveParameter( - name = "input", - description = "The input object.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [] ) ) - ) - ) - - def doOperation( self, args ) : - return args['input'].copy() - -IECore.registerRunTimeTyped( pointParam ) diff --git a/test/IECoreHoudini/ops/parameters/primitives/polyParam/polyParam-1.py b/test/IECoreHoudini/ops/parameters/primitives/polyParam/polyParam-1.py deleted file mode 100644 index 50fbfd5536..0000000000 --- a/test/IECoreHoudini/ops/parameters/primitives/polyParam/polyParam-1.py +++ /dev/null @@ -1,28 +0,0 @@ -import IECore -import IECoreScene - -class polyParam( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that has point parameters.", - IECoreScene.MeshPrimitiveParameter( - name = "result", - description = "A pass through of the input primitive parameter.", - defaultValue = IECoreScene.MeshPrimitive() - ) - ) - - self.parameters().addParameter( - IECoreScene.MeshPrimitiveParameter( - name = "input", - description = "The input object.", - defaultValue = IECoreScene.MeshPrimitive() - ) - ) - - def doOperation( self, args ) : - return args['input'].copy() - -IECore.registerRunTimeTyped( polyParam ) diff --git a/test/IECoreHoudini/ops/parameters/primitives/preset/preset-1.py b/test/IECoreHoudini/ops/parameters/primitives/preset/preset-1.py deleted file mode 100644 index 893357049e..0000000000 --- a/test/IECoreHoudini/ops/parameters/primitives/preset/preset-1.py +++ /dev/null @@ -1,51 +0,0 @@ -import IECore -import IECoreScene - -class preset( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that has two group parameters.", - IECoreScene.PrimitiveParameter( - name = "result", - description = "A pass through the first child of the input parameter.", - defaultValue = IECoreScene.MeshPrimitive() - ) - ) - - self.parameters().addParameters( [ - IECore.IntParameter( - name = "switch", - description = "Switch between the groups", - defaultValue = 20, - presets = ( - ( "A", 20 ), - ( "B", 30 ), - ), - presetsOnly=True - ), - - IECoreScene.PrimitiveParameter( - name = "inputA", - description = "The first input object.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData([]) ) - ), - - IECoreScene.PrimitiveParameter( - name = "inputB", - description = "The second input object.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData([]) ) - ) - ] ) - - def doOperation( self, args ) : - - primitive = args["inputA"] if args["switch"].value == 20 else args["inputB"] - - if primitive: - return primitive - - return self.resultParameter().defaultValue.copy() - -IECore.registerRunTimeTyped( preset ) diff --git a/test/IECoreHoudini/ops/parameters/primitives/primParam/primParam-1.py b/test/IECoreHoudini/ops/parameters/primitives/primParam/primParam-1.py deleted file mode 100644 index fe1eabc9ad..0000000000 --- a/test/IECoreHoudini/ops/parameters/primitives/primParam/primParam-1.py +++ /dev/null @@ -1,28 +0,0 @@ -import IECore -import IECoreScene - -class primParam( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that has primitive parameters.", - IECoreScene.PrimitiveParameter( - name = "result", - description = "A pass through of the input primitive parameter.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData([]) ) - ) - ) - - self.parameters().addParameter( - IECoreScene.PrimitiveParameter( - name = "input", - description = "The input object.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData([]) ) - ) - ) - - def doOperation( self, args ) : - return args['input'].copy() - -IECore.registerRunTimeTyped( primParam ) diff --git a/test/IECoreHoudini/ops/swapAttribute/swapAttribute-1.py b/test/IECoreHoudini/ops/swapAttribute/swapAttribute-1.py deleted file mode 100644 index fcded4f822..0000000000 --- a/test/IECoreHoudini/ops/swapAttribute/swapAttribute-1.py +++ /dev/null @@ -1,48 +0,0 @@ -import IECore -import IECoreScene -import hou - -class swapAttribute( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that replaces an attribute on one mesh with that from another.", - IECoreScene.PrimitiveParameter( - name = "result", - description = "The primitive with replaced attribute.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData() ), - ) - ) - - self.parameters().addParameters( [ - IECoreScene.PrimitiveParameter( - name = "destination", - description = "The primitive with an attribute to be added/replaced.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData() ) - ), - IECoreScene.PrimitiveParameter( - name = "source", - description = "The primitive with an attribute to use.", - defaultValue = IECoreScene.PointsPrimitive( IECore.V3fVectorData() ) - ), - IECore.StringParameter( - name = "name", - description = "The name of the attribute to copy from input2 onto input1.", - defaultValue = "P" - ) - ] ) - - def doOperation( self, args ) : - dst = args['destination'].copy() - src = args['source'] - attribute = args['name'].value - - # check for attribute on source - if not attribute in src: - raise Exception("Must have primvar '%s' in source primitive!" % attribute) - - dst[attribute] = src[attribute] - return dst - -IECore.registerRunTimeTyped( swapAttribute ) diff --git a/test/IECoreHoudini/ops/vectors/V3fVectorAdder/V3fVectorAdder-1.py b/test/IECoreHoudini/ops/vectors/V3fVectorAdder/V3fVectorAdder-1.py deleted file mode 100644 index 6a0723340a..0000000000 --- a/test/IECoreHoudini/ops/vectors/V3fVectorAdder/V3fVectorAdder-1.py +++ /dev/null @@ -1,40 +0,0 @@ -import IECore - -class V3fVectorAdder( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that adds two V3fVectorData objects together.", - IECore.ObjectParameter( - name = "result", - description = "A V3fVectorData object.", - defaultValue = IECore.V3fVectorData(), - type = IECore.TypeId.V3fVectorData - ) - ) - - self.parameters().addParameters([ - IECore.ObjectParameter( - name = "vector1", - description = "The first V3fVectorData object.", - defaultValue = IECore.V3fVectorData(), - type = IECore.TypeId.V3fVectorData - ), - IECore.ObjectParameter( - name = "vector2", - description = "The second V3fVectorData object.", - defaultValue = IECore.V3fVectorData(), - type = IECore.TypeId.V3fVectorData - ) ] - ) - - def doOperation( self, args ) : - v1 = args['vector1'] - v2 = args['vector2'] - if len(v1)!=len(v2): - raise "Vector array lengths must match!" - result = IECore.V3fVectorData( [ x+y for (x,y) in zip(v1,v2) ] ) - return result - -IECore.registerRunTimeTyped( V3fVectorAdder ) diff --git a/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py b/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py deleted file mode 100644 index bb7a6a6e14..0000000000 --- a/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py +++ /dev/null @@ -1,38 +0,0 @@ -import imath -import IECore - -class V3fVectorCreator( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "Op that generates a V3fVectorData object.", - IECore.ObjectParameter( - name = "result", - description = "A V3fVectorData object.", - defaultValue = IECore.V3fVectorData(), - type = IECore.TypeId.V3fVectorData - ) - ) - - self.parameters().addParameters([ - IECore.IntParameter( - name = "size", - description = "The number of elements to put in the result vector.", - defaultValue = 1 - ), - IECore.V3fParameter( - name = "value", - description = "Value to put in each of the vector elements.", - defaultValue = imath.V3f(1) - ) ] - ) - - def doOperation( self, args ) : - size = args['size'].value - value = args['value'].value - data = [ value for x in range(size) ] - result = IECore.V3fVectorData( data ) - return result - -IECore.registerRunTimeTyped( V3fVectorCreator ) diff --git a/test/IECoreMaya/All.py b/test/IECoreMaya/All.py deleted file mode 100644 index ce9cf6e090..0000000000 --- a/test/IECoreMaya/All.py +++ /dev/null @@ -1,101 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2014, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import sys -import unittest - -import IECore -import IECoreMaya - -from ConverterHolder import * -from PlaybackFrameList import * -from ParameterisedHolder import * -from FromMayaCurveConverterTest import * -from PluginLoadUnload import * -from NamespacePollution import * -from FromMayaMeshConverterTest import * -from FromMayaParticleConverterTest import * -from FromMayaPlugConverterTest import * -from FromMayaUnitPlugConverterTest import * -from FromMayaGroupConverterTest import * -from FromMayaCameraConverterTest import * -from FromMayaConverterTest import * -from FromMayaObjectConverterTest import * -from FromMayaInstancerConverterTest import * -from FnParameterisedHolderTest import * -from ToMayaPlugConverterTest import * -from ToMayaMeshConverterTest import * -from ToMayaCurveConverterTest import * -from MayaTypeIdTest import * -from FromMayaTransformConverterTest import * -from CallbackIdTest import * -from TemporaryAttributeValuesTest import * -from SplineParameterHandlerTest import * -from DAGPathParametersTest import * -from FromMayaSkinClusterConverterTest import * -from FromMayaSkinClusterWeightsConverterTest import * -from ToMayaSkinClusterConverterTest import * -from ToMayaSkinClusterWeightsConverterTest import * -from ToMayaGroupConverterTest import ToMayaGroupConverterTest -from RunTimeTypedTest import RunTimeTypedTest -from ToMayaParticleConverterTest import ToMayaParticleConverterTest -from ImageConverterTest import ImageConverterTest -from ObjectDataTest import ObjectDataTest -from ToMayaCameraConverterTest import ToMayaCameraConverterTest -from LiveSceneTest import * -from SceneShapeTest import SceneShapeTest -from SceneShapeProxyTest import SceneShapeProxyTest -from FnSceneShapeTest import FnSceneShapeTest -from FromMayaLocatorConverterTest import FromMayaLocatorConverterTest -from ToMayaLocatorConverterTest import ToMayaLocatorConverterTest -from UndoTest import UndoTest - -IECoreMaya.TestProgram( - - testRunner = unittest.TextTestRunner( - stream = IECore.CompoundStream( - [ - sys.stderr, - open( "test/IECoreMaya/resultsPython.txt", "w" ) - ] - ), - verbosity = 2 - ), - - plugins = [ "ieCore" ], - -) diff --git a/test/IECoreMaya/CallbackIdTest.py b/test/IECoreMaya/CallbackIdTest.py deleted file mode 100644 index b319415e50..0000000000 --- a/test/IECoreMaya/CallbackIdTest.py +++ /dev/null @@ -1,79 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import weakref - -import maya.cmds -import maya.OpenMaya - -import IECore -import IECoreMaya - -class CallbackIdTest( IECoreMaya.TestCase ) : - - def test( self ) : - - # callback function just counts the number of times it has been invoked - CallbackIdTest.numCalls = 0 - def callback( node, name, userData ) : - - CallbackIdTest.numCalls += 1 - - # make a sphere and get the MObject from it - sphere = maya.cmds.sphere()[0] - s = maya.OpenMaya.MSelectionList() - s.add( sphere ) - o = maya.OpenMaya.MObject() - s.getDependNode( 0, o ) - - # attach a name changed callback - c = IECoreMaya.CallbackId( maya.OpenMaya.MNodeMessage.addNameChangedCallback( o, callback ) ) - - # check that the callback is invoked - self.assertEqual( CallbackIdTest.numCalls, 0 ) - sphere = maya.cmds.rename( sphere, sphere + "Different" ) - self.assertEqual( CallbackIdTest.numCalls, 1 ) - - # delete the CallbackId object and make sure the callback is removed and therefore not invoked any more - del c - sphere = maya.cmds.rename( sphere, sphere + "DifferentAgain" ) - self.assertEqual( CallbackIdTest.numCalls, 1 ) - - # also check that maya isn't holding onto any unecessary references to the callback function. - w = weakref.ref( callback ) - del callback - self.assertEqual( w(), None ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ConverterHolder.py b/test/IECoreMaya/ConverterHolder.py deleted file mode 100644 index 1e92444de4..0000000000 --- a/test/IECoreMaya/ConverterHolder.py +++ /dev/null @@ -1,55 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os.path - -import maya.cmds - -import IECore -import IECoreMaya - -class TestConverterHolder( IECoreMaya.TestCase ) : - - def test( self ) : - - """ Test ConverterHolder """ - n = maya.cmds.createNode( "ieConverterHolder" ) - c = IECoreMaya.FnConverterHolder( str(n) ) - self.assertTrue( c ) - - # \todo Add a FromMayaMeshConverter, pass in a mesh shape, and assert that we get a MeshPrimitive out - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/DAGPathParametersTest.py b/test/IECoreMaya/DAGPathParametersTest.py deleted file mode 100644 index 960571c427..0000000000 --- a/test/IECoreMaya/DAGPathParametersTest.py +++ /dev/null @@ -1,46 +0,0 @@ -########################################################################## -# -# Copyright (c) 2009-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya - -class DAGPathParametersTest( IECoreMaya.TestCase ) : - - def test( self ) : - - p1 = IECoreMaya.DAGPathVectorParameter( "n", "d" ) - p2 = IECoreMaya.DAGPathParameter( "n", "d" ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FnParameterisedHolderTest.py b/test/IECoreMaya/FnParameterisedHolderTest.py deleted file mode 100644 index 8a185c4b1e..0000000000 --- a/test/IECoreMaya/FnParameterisedHolderTest.py +++ /dev/null @@ -1,861 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import os -import unittest - -import maya.cmds -import maya.OpenMaya -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class TestOp( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, "Tests stuff", - IECore.IntParameter( - name = "result", - description = "", - defaultValue = 0 - ) - ) - - self.parameters().addParameters( - [ - IECore.IntParameter( - name = "i", - description = "i", - defaultValue = 1 - ), - ] - ) - - def doOperation( self, args ) : - - return IECore.IntData( 10 ) - -class FnParameterisedHolderTest( IECoreMaya.TestCase ) : - - def test( self ) : - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - self.assertEqual( fnPH.getParameterised(), ( None, "", 0, "" ) ) - - op = TestOp() - fnPH.setParameterised( op ) - parameterisedTuple = fnPH.getParameterised() - self.assertTrue( parameterisedTuple[0].isSame( op ) ) - self.assertEqual( parameterisedTuple[1:], ( "", 0, "" ) ) - self.assertEqual( parameterisedTuple[0](), IECore.IntData( 10 ) ) - - iPlug = fnPH.parameterPlug( op["i"] ) - self.assertTrue( isinstance( iPlug, maya.OpenMaya.MPlug ) ) - self.assertTrue( iPlug.asInt(), 1 ) - - self.assertTrue( fnPH.plugParameter( iPlug ).isSame( op["i"] ) ) - self.assertTrue( fnPH.plugParameter( iPlug.name() ).isSame( op["i"] ) ) - - iPlug.setInt( 2 ) - fnPH.setParameterisedValue( op["i"] ) - self.assertTrue( op["i"].getNumericValue(), 2 ) - - op["i"].setNumericValue( 3 ) - fnPH.setNodeValue( op["i"] ) - self.assertTrue( iPlug.asInt(), 3 ) - - iPlug.setInt( 10 ) - fnPH.setParameterisedValues() - self.assertTrue( op["i"].getNumericValue(), 10 ) - - op["i"].setNumericValue( 11 ) - fnPH.setNodeValues() - self.assertTrue( iPlug.asInt(), 11 ) - - def testFullPathName( self ) : - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - self.assertEqual( node, fnPH.fullPathName() ) - - def testSetNodeValuesUndo( self ) : - - # make an opholder - ########################################################################## - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - - op = IECore.ClassLoader.defaultOpLoader().load( "parameterTypes", 1 )() - op.parameters().removeParameter( "m" ) # no color4f support in maya - - fnPH.setParameterised( op ) - - # check we have the starting values we expect - ########################################################################### - - self.assertEqual( op["a"].getNumericValue(), 1 ) - aPlug = fnPH.parameterPlug( op["a"] ) - self.assertEqual( aPlug.asInt(), 1 ) - - self.assertEqual( op["b"].getNumericValue(), 2 ) - bPlug = fnPH.parameterPlug( op["b"] ) - self.assertEqual( bPlug.asFloat(), 2 ) - - self.assertEqual( op["c"].getNumericValue(), 3 ) - cPlug = fnPH.parameterPlug( op["c"] ) - self.assertEqual( cPlug.asDouble(), 3 ) - - self.assertEqual( op["d"].getTypedValue(), "ssss" ) - dPlug = fnPH.parameterPlug( op["d"] ) - self.assertEqual( dPlug.asString(), "ssss" ) - - self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 4, -1, 2 ] ) ) - ePlug = fnPH.parameterPlug( op["e"] ) - fnE = maya.OpenMaya.MFnIntArrayData( ePlug.asMObject() ) - self.assertEqual( fnE[0], 4 ) - self.assertEqual( fnE[1], -1 ) - self.assertEqual( fnE[2], 2 ) - self.assertEqual( fnE.length(), 3 ) - - self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "one", "two", "three" ] ) ) - fPlug = fnPH.parameterPlug( op["f"] ) - fnF = maya.OpenMaya.MFnStringArrayData( fPlug.asMObject() ) - fList = [] - fnF.copyTo( fList ) - self.assertEqual( fList, [ "one", "two", "three" ] ) - - self.assertEqual( op["g"].getTypedValue(), imath.V2f( 1, 2 ) ) - gPlug = fnPH.parameterPlug( op["g"] ) - self.assertEqual( gPlug.child( 0 ).asFloat(), 1 ) - self.assertEqual( gPlug.child( 1 ).asFloat(), 2 ) - - self.assertEqual( op["h"].getTypedValue(), imath.V3f( 1, 1, 1 ) ) - hPlug = fnPH.parameterPlug( op["h"] ) - self.assertEqual( hPlug.child( 0 ).asFloat(), 1 ) - self.assertEqual( hPlug.child( 1 ).asFloat(), 1 ) - self.assertEqual( hPlug.child( 2 ).asFloat(), 1 ) - - self.assertEqual( op["q"].getTypedValue(), False ) - qPlug = fnPH.parameterPlug( op["q"] ) - self.assertEqual( qPlug.asBool(), False ) - - self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) - tPlug = fnPH.parameterPlug( op["t"] ) - self.assertEqual( tPlug.child( 0 ).child( 0 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 0 ).child( 1 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 0 ).child( 2 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 1 ).child( 0 ).asFloat(), 1 ) - self.assertEqual( tPlug.child( 1 ).child( 1 ).asFloat(), 1 ) - self.assertEqual( tPlug.child( 1 ).child( 2 ).asFloat(), 1 ) - - # change all the node values, making sure undo is enabled - ############################################################################# - - self.assertTrue( maya.cmds.undoInfo( query=True, state=True ) ) - - # change the parameters - op["a"].setNumericValue( 10 ) - op["b"].setNumericValue( 100 ) - op["c"].setNumericValue( 12 ) - op["d"].setTypedValue( "a" ) - op["e"].setValue( IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) - op["f"].setValue( IECore.StringVectorData( [ "hi" ] ) ) - op["g"].setTypedValue( imath.V2f( 10, 100 ) ) - op["h"].setTypedValue( imath.V3f( -1, -2, -3 ) ) - op["q"].setTypedValue( True ) - op["t"].setTypedValue( imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) - - # check they are changed - self.assertEqual( op["a"].getNumericValue(), 10 ) - self.assertEqual( op["b"].getNumericValue(), 100 ) - self.assertEqual( op["c"].getNumericValue(), 12 ) - self.assertEqual( op["d"].getTypedValue(), "a" ) - self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) - self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) - self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) - - # push the changes onto the node - fnPH.setNodeValues() - - # check the node values are changed - ############################################################################# - - self.assertEqual( aPlug.asInt(), 10 ) - self.assertEqual( bPlug.asFloat(), 100 ) - self.assertEqual( cPlug.asDouble(), 12 ) - self.assertEqual( dPlug.asString(), "a" ) - - fnE = maya.OpenMaya.MFnIntArrayData( ePlug.asMObject() ) - self.assertEqual( fnE[0], 1 ) - self.assertEqual( fnE[1], 2 ) - self.assertEqual( fnE[2], 3 ) - self.assertEqual( fnE[3], 4 ) - self.assertEqual( fnE.length(), 4 ) - - fnF = maya.OpenMaya.MFnStringArrayData( fPlug.asMObject() ) - fList = [] - fnF.copyTo( fList ) - self.assertEqual( fList, [ "hi" ] ) - - self.assertEqual( gPlug.child( 0 ).asFloat(), 10 ) - self.assertEqual( gPlug.child( 1 ).asFloat(), 100 ) - - self.assertEqual( hPlug.child( 0 ).asFloat(), -1 ) - self.assertEqual( hPlug.child( 1 ).asFloat(), -2 ) - self.assertEqual( hPlug.child( 2 ).asFloat(), -3 ) - - self.assertEqual( qPlug.asBool(), True ) - - self.assertEqual( tPlug.child( 0 ).child( 0 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 0 ).child( 1 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 0 ).child( 2 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 1 ).child( 0 ).asFloat(), 0 ) - self.assertEqual( tPlug.child( 1 ).child( 1 ).asFloat(), 0 ) - self.assertEqual( tPlug.child( 1 ).child( 2 ).asFloat(), 0 ) - - # check that the parameter values are unchanged in the process of - # pushing them to maya - ############################################################################# - - self.assertEqual( op["a"].getNumericValue(), 10 ) - self.assertEqual( op["b"].getNumericValue(), 100 ) - self.assertEqual( op["c"].getNumericValue(), 12 ) - self.assertEqual( op["d"].getTypedValue(), "a" ) - self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) - self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) - self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) - - - # undo, and check the node values are back to before - ############################################################################# - - maya.cmds.undo() - - self.assertEqual( aPlug.asInt(), 1 ) - self.assertEqual( bPlug.asFloat(), 2 ) - self.assertEqual( cPlug.asDouble(), 3 ) - self.assertEqual( dPlug.asString(), "ssss" ) - - fnE = maya.OpenMaya.MFnIntArrayData( ePlug.asMObject() ) - self.assertEqual( fnE[0], 4 ) - self.assertEqual( fnE[1], -1 ) - self.assertEqual( fnE[2], 2 ) - self.assertEqual( fnE.length(), 3 ) - - fnF = maya.OpenMaya.MFnStringArrayData( fPlug.asMObject() ) - fList = [] - fnF.copyTo( fList ) - self.assertEqual( fList, [ "one", "two", "three" ] ) - - self.assertEqual( gPlug.child( 0 ).asFloat(), 1 ) - self.assertEqual( gPlug.child( 1 ).asFloat(), 2 ) - - self.assertEqual( hPlug.child( 0 ).asFloat(), 1 ) - self.assertEqual( hPlug.child( 1 ).asFloat(), 1 ) - self.assertEqual( hPlug.child( 2 ).asFloat(), 1 ) - - self.assertEqual( qPlug.asBool(), False ) - - self.assertEqual( tPlug.child( 0 ).child( 0 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 0 ).child( 1 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 0 ).child( 2 ).asFloat(), -1 ) - self.assertEqual( tPlug.child( 1 ).child( 0 ).asFloat(), 1 ) - self.assertEqual( tPlug.child( 1 ).child( 1 ).asFloat(), 1 ) - self.assertEqual( tPlug.child( 1 ).child( 2 ).asFloat(), 1 ) - - # check that the parameter values are unchanged in the undo process - ############################################################################# - - self.assertEqual( op["a"].getNumericValue(), 10 ) - self.assertEqual( op["b"].getNumericValue(), 100 ) - self.assertEqual( op["c"].getNumericValue(), 12 ) - self.assertEqual( op["d"].getTypedValue(), "a" ) - self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) - self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) - self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) - - # redo, and check they are changed again - ############################################################################# - - maya.cmds.redo() - - self.assertEqual( aPlug.asInt(), 10 ) - self.assertEqual( bPlug.asFloat(), 100 ) - self.assertEqual( cPlug.asDouble(), 12 ) - self.assertEqual( dPlug.asString(), "a" ) - - fnE = maya.OpenMaya.MFnIntArrayData( ePlug.asMObject() ) - self.assertEqual( fnE[0], 1 ) - self.assertEqual( fnE[1], 2 ) - self.assertEqual( fnE[2], 3 ) - self.assertEqual( fnE[3], 4 ) - self.assertEqual( fnE.length(), 4 ) - - fnF = maya.OpenMaya.MFnStringArrayData( fPlug.asMObject() ) - fList = [] - fnF.copyTo( fList ) - self.assertEqual( fList, [ "hi" ] ) - - self.assertEqual( gPlug.child( 0 ).asFloat(), 10 ) - self.assertEqual( gPlug.child( 1 ).asFloat(), 100 ) - - self.assertEqual( hPlug.child( 0 ).asFloat(), -1 ) - self.assertEqual( hPlug.child( 1 ).asFloat(), -2 ) - self.assertEqual( hPlug.child( 2 ).asFloat(), -3 ) - - self.assertEqual( qPlug.asBool(), True ) - - self.assertEqual( tPlug.child( 0 ).child( 0 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 0 ).child( 1 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 0 ).child( 2 ).asFloat(), -10 ) - self.assertEqual( tPlug.child( 1 ).child( 0 ).asFloat(), 0 ) - self.assertEqual( tPlug.child( 1 ).child( 1 ).asFloat(), 0 ) - self.assertEqual( tPlug.child( 1 ).child( 2 ).asFloat(), 0 ) - - # check that the parameter values are unchanged in the redo process - ############################################################################# - - self.assertEqual( op["a"].getNumericValue(), 10 ) - self.assertEqual( op["b"].getNumericValue(), 100 ) - self.assertEqual( op["c"].getNumericValue(), 12 ) - self.assertEqual( op["d"].getTypedValue(), "a" ) - self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) - self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) - self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) - - def testSetNodeValueUndo( self ) : - - p = IECore.Parameterised( "" ) - p.parameters().addParameters( - [ - IECore.IntParameter( - "i", - "", - 1 - ), - IECore.FloatParameter( - "f", - "", - 2 - ) - ] - ) - - node = maya.cmds.createNode( "ieParameterisedHolderLocator" ) - fnOH = IECoreMaya.FnParameterisedHolder( node ) - fnOH.setParameterised( p ) - - # check the start values are as expected - - self.assertEqual( p["i"].getNumericValue(), 1 ) - self.assertEqual( p["f"].getNumericValue(), 2 ) - - self.assertEqual( fnOH.parameterPlug( p["i"] ).asInt(), 1 ) - self.assertEqual( fnOH.parameterPlug( p["f"] ).asInt(), 2 ) - - # change both parameters - - self.assertTrue( maya.cmds.undoInfo( query=True, state=True ) ) - - p["i"].setNumericValue( 10 ) - p["f"].setNumericValue( 11 ) - - self.assertEqual( p["i"].getNumericValue(), 10 ) - self.assertEqual( p["f"].getNumericValue(), 11 ) - - self.assertEqual( fnOH.parameterPlug( p["i"] ).asInt(), 1 ) - self.assertEqual( fnOH.parameterPlug( p["f"] ).asInt(), 2 ) - - # but push only one into maya - - fnOH.setNodeValue( p["i"] ) - - # and check we see what we expect - - self.assertEqual( p["i"].getNumericValue(), 10 ) - self.assertEqual( p["f"].getNumericValue(), 11 ) - - self.assertEqual( fnOH.parameterPlug( p["i"] ).asInt(), 10 ) - self.assertEqual( fnOH.parameterPlug( p["f"] ).asInt(), 2 ) - - # undo and check - - maya.cmds.undo() - - self.assertEqual( p["i"].getNumericValue(), 10 ) - self.assertEqual( p["f"].getNumericValue(), 11 ) - - self.assertEqual( fnOH.parameterPlug( p["i"] ).asInt(), 1 ) - self.assertEqual( fnOH.parameterPlug( p["f"] ).asInt(), 2 ) - - # redo and check - - maya.cmds.redo() - - self.assertEqual( p["i"].getNumericValue(), 10 ) - self.assertEqual( p["f"].getNumericValue(), 11 ) - - self.assertEqual( fnOH.parameterPlug( p["i"] ).asInt(), 10 ) - self.assertEqual( fnOH.parameterPlug( p["f"] ).asInt(), 2 ) - - def testExcessReferenceEdits( self ) : - - IECoreMaya.FnOpHolder.create( "testOp", "maths/multiply", 2 ) - - # Save the scene out so we can reference it - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "referenceEditCounts.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # New scene, and read it in. - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - # Check there are no reference edits - - fnOH = IECoreMaya.FnOpHolder( 'ns1:testOp' ) - op = fnOH.getOp() - - aPath = fnOH.parameterPlugPath( op["a"] ) - bPath = fnOH.parameterPlugPath( op["b"] ) - self.assertEqual( maya.cmds.getAttr( aPath ), 1 ) - self.assertEqual( maya.cmds.getAttr( bPath ), 2 ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # set values, but with no changes - - with fnOH.parameterModificationContext() : - op["a"].setNumericValue( 1 ) - op["b"].setNumericValue( 2 ) - - # Check the values are the same, and there are still no reference edits - - self.assertEqual( maya.cmds.getAttr( aPath ), 1 ) - self.assertEqual( maya.cmds.getAttr( bPath ), 2 ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # change a value to a genuinely new value - with fnOH.parameterModificationContext() : - op["a"].setNumericValue( 100 ) - - # Check the maya value is updated and there is 1 reference edit - - self.assertEqual( maya.cmds.getAttr( aPath ), 100 ) - self.assertEqual( maya.cmds.getAttr( bPath ), 2 ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 1 ) - - # Undo and check there is still 1 reference edit. Ideally there would be none but - # maya isn't that clever. - - maya.cmds.undo() - - self.assertEqual( maya.cmds.getAttr( aPath ), 1 ) - self.assertEqual( maya.cmds.getAttr( bPath ), 2 ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 1 ) - - def testExcessClassParameterReferenceEdits( self ) : - - # Save a scene with a ClassParameter in it - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - self.assertEqual( op["cp"].getClass( True )[1:], ( "maths/multiply", 1, "IECORE_OP_PATHS" ) ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "referenceEditCounts.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # And reference it back in to a new scene - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # Make a modification which does nothing and check that there are no reference edits - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - with fnOH.parameterModificationContext() : - pass - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # Make a modification which happens to set things to the values they're already at and - # check that there are no reference edits - - op = fnOH.getOp() - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - def testExcessClassVectorParameterReferenceEdits( self ) : - - # Save a scene with a ClassParameter in it - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - - op["cv"].setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ( "coIO", "compoundObjectInOut", 1 ), - ] - - ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "referenceEditCounts.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # And reference it back in to a new scene - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # Make a modification which does nothing and check that there are no reference edits - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - with fnOH.parameterModificationContext() : - pass - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - # Make a modification which happens to set things to the values they're already at and - # check that there are no reference edits - - with fnOH.parameterModificationContext() : - - op["cv"].setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ( "coIO", "compoundObjectInOut", 1 ), - ] - - ) - - self.assertEqual( len(maya.cmds.referenceQuery( referenceScene, editStrings=True )), 0 ) - - def testSetParameterValuesUsingContext( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "testOp", "maths/multiply", 2 ) - op = fnOH.getOp() - aPath = fnOH.parameterPlugPath( op["a"] ) - - self.assertEqual( maya.cmds.getAttr( aPath ), 1 ) - - with fnOH.parameterModificationContext() : - - op["a"].setNumericValue( 10023 ) - - self.assertEqual( maya.cmds.getAttr( aPath ), 10023 ) - - maya.cmds.undo() - - self.assertEqual( maya.cmds.getAttr( aPath ), 1 ) - - maya.cmds.redo() - - self.assertEqual( maya.cmds.getAttr( aPath ), 10023 ) - - def testSetParameterValuesAndClassesUsingContext( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - - with fnOH.parameterModificationContext() as op : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - op["cp"]["a"].setNumericValue( 10101 ) - - aPath = fnOH.parameterPlugPath( op["cp"]["a"] ) - self.assertEqual( maya.cmds.getAttr( aPath ), 10101 ) - - maya.cmds.undo() - - self.assertEqual( op["cp"].getClass(), None ) - - maya.cmds.redo() - - self.assertEqual( op["cp"].getClass( True )[1:], ( "maths/multiply", 1, "IECORE_OP_PATHS" ) ) - - self.assertEqual( maya.cmds.getAttr( aPath ), 10101 ) - - def testBoxDefaultValue( self ) : - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - - op = IECore.ClassLoader.defaultOpLoader().load( "parameterTypes", 1 )() - op.parameters().removeParameter( "m" ) # no color4f support in maya - - fnPH.setParameterised( op ) - - node, plug = fnPH.parameterPlugPath( op["s"] ).split( "." ) - self.assertEqual( maya.cmds.attributeQuery( plug + "Min", listDefault=True, node=node ), [ -1.0, -1.0 ] ) - self.assertEqual( maya.cmds.attributeQuery( plug + "Max", listDefault=True, node=node ), [ 1.0, 1.0 ] ) - - node, plug = fnPH.parameterPlugPath( op["t"] ).split( "." ) - self.assertEqual( maya.cmds.attributeQuery( plug + "Min", listDefault=True, node=node ), [ -1.0, -1.0, -1.0 ] ) - self.assertEqual( maya.cmds.attributeQuery( plug + "Max", listDefault=True, node=node ), [ 1.0, 1.0, 1.0 ] ) - - def testArrayPlugCreation( self ) : - - op = IECore.Op( 'test op', IECore.IntParameter( 'result', '', 0 ) ) - op.parameters().addParameters( [ - IECore.V3fVectorParameter( 'v3fVector', '', IECore.V3fVectorData() ), - IECore.V3dVectorParameter( 'v3dVector', '', IECore.V3dVectorData() ), - IECore.StringVectorParameter( 'stringVector', '', IECore.StringVectorData() ), - IECore.DoubleVectorParameter( 'doubleVector', '', IECore.DoubleVectorData() ), - IECore.FloatVectorParameter( 'floatVector', '', IECore.FloatVectorData() ), - IECore.IntVectorParameter( 'intVector', '', IECore.IntVectorData() ), - IECore.BoolVectorParameter( 'boolVector', '', IECore.BoolVectorData() ), - IECore.M44fVectorParameter( 'm44fVector', '', IECore.M44fVectorData() ), - IECore.M44dVectorParameter( 'm44dVector', '', IECore.M44dVectorData() ), - ] ) - - node = maya.cmds.createNode( 'ieOpHolderNode' ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - - self.assertTrue( not maya.cmds.objExists( node+'.parm_v3fVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_v3dVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_stringVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_doubleVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_floatVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_intVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_boolVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_m44fVector' ) ) - self.assertTrue( not maya.cmds.objExists( node+'.parm_m44dVector' ) ) - - fnPH.setParameterised( op ) - - self.assertTrue( maya.cmds.objExists( node+'.parm_v3fVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_v3dVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_stringVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_doubleVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_floatVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_intVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_boolVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_m44fVector' ) ) - self.assertTrue( maya.cmds.objExists( node+'.parm_m44dVector' ) ) - - self.assertEqual( maya.cmds.getAttr( node+'.parm_v3fVector', type=True ), 'vectorArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_v3dVector', type=True ), 'vectorArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_stringVector', type=True ), 'stringArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_doubleVector', type=True ), 'doubleArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_floatVector', type=True ), 'doubleArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_intVector', type=True ), 'Int32Array' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_boolVector', type=True ), 'Int32Array' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_m44fVector', type=True ), 'doubleArray' ) - self.assertEqual( maya.cmds.getAttr( node+'.parm_m44dVector', type=True ), 'doubleArray' ) - - def testMatrixVectorPlugs( self ) : - - m44fVector = IECore.M44fVectorData( [ imath.M44f( 1 ), imath.M44f( 2 ), imath.M44f( 3 ) ] ) - m44dVector = IECore.M44dVectorData( [ imath.M44d( 1 ), imath.M44d( 2 ), imath.M44d( 3 ) ] ) - reverseM44fVector = IECore.M44fVectorData( [ imath.M44f( 3 ), imath.M44f( 2 ), imath.M44f( 1 ) ] ) - reverseM44dVector = IECore.M44dVectorData( [ imath.M44d( 3 ), imath.M44d( 2 ), imath.M44d( 1 ) ] ) - - mayaArray = [] - for i in range( 0, 3 ) : - for j in range( 0, 16 ) : - mayaArray.append( i+1 ) - - reverseMayaArray = list(mayaArray) - reverseMayaArray.reverse() - - op = IECore.Op( 'test op', IECore.IntParameter( 'result', '', 0 ) ) - op.parameters().addParameters( [ - IECore.M44fVectorParameter( 'm44fVector', '', IECore.M44fVectorData() ), - IECore.M44dVectorParameter( 'm44dVector', '', IECore.M44dVectorData() ), - ] ) - - node = maya.cmds.createNode( 'ieOpHolderNode' ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - fnPH.setParameterised( op ) - - # set from cortex to maya - self.assertNotEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44fVector' ) ) - self.assertNotEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44dVector' ) ) - fnPH.getParameterised()[0].parameters()['m44fVector'].setValue( m44fVector ) - fnPH.getParameterised()[0].parameters()['m44dVector'].setValue( m44dVector ) - fnPH.setNodeValues() - self.assertEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44fVector' ) ) - self.assertEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44dVector' ) ) - - # set from maya to cortex - self.assertNotEqual( reverseM44fVector, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() ) - self.assertNotEqual( reverseM44dVector, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() ) - maya.cmds.setAttr( node+'.parm_m44fVector', reverseMayaArray, type="doubleArray" ) - maya.cmds.setAttr( node+'.parm_m44dVector', reverseMayaArray, type="doubleArray" ) - fnPH.setParameterisedValues() - self.assertEqual( reverseM44fVector, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() ) - self.assertEqual( reverseM44dVector, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() ) - - # set to incorrect length from maya - maya.cmds.setAttr( node+'.parm_m44fVector', [0,1,2], type="doubleArray" ) - maya.cmds.setAttr( node+'.parm_m44dVector', [0,1,2], type="doubleArray" ) - fnPH.setParameterisedValues() - self.assertEqual( None, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() ) - self.assertEqual( None, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() ) - - def testResultAttrSaveLoad( self ) : - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnOpHolder( node ) - fnPH.setOp( "floatParameter" ) - - self.assertNotEqual( maya.cmds.getAttr( node + ".parm_f" ), 50.5 ) - self.assertNotEqual( maya.cmds.getAttr( node + ".result" ), 50.5 ) - maya.cmds.setAttr( node + ".parm_f", 50.5 ) - self.assertEqual( maya.cmds.getAttr( node + ".parm_f" ), 50.5 ) - self.assertEqual( maya.cmds.getAttr( node + ".result" ), 50.5 ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "resultAttrLoadTest.ma" ) ) - testScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - maya.cmds.file( testScene, f = True, o = True ) - self.assertEqual( maya.cmds.getAttr( node + ".parm_f" ), 50.5 ) - self.assertEqual( maya.cmds.getAttr( node + ".result" ), 50.5 ) - - @unittest.skipIf( maya.OpenMaya.MGlobal.apiVersion() < 201600, "Inactive node state causes a seg fault prior to Maya 2016" ) - def testResultAttrSaveLoadMeshConnections( self ) : - - box = maya.cmds.listRelatives( maya.cmds.polyCube(), shapes=True )[0] - torus = maya.cmds.listRelatives( maya.cmds.polyTorus(), shapes=True )[0] - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnOpHolder( node ) - fnPH.setOp( "meshMerge" ) - - maya.cmds.connectAttr( box + ".outMesh", node + ".parm_input" ) - maya.cmds.connectAttr( torus + ".outMesh", node + ".parm_mesh" ) - mesh = maya.cmds.createNode( "mesh" ) - maya.cmds.connectAttr( node + ".result", mesh + ".inMesh" ) - quads = maya.cmds.polyQuad( mesh )[0] - joint = maya.cmds.createNode( "joint" ) - cluster = maya.cmds.skinCluster( mesh, joint ) - - fnMesh = maya.OpenMaya.MFnMesh( IECoreMaya.dependencyNodeFromString( mesh ) ) - self.assertEqual( fnMesh.numVertices(), 408 ) - self.assertEqual( fnMesh.numPolygons(), 406 ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "resultAttrLoadTest.ma" ) ) - testScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - maya.cmds.file( testScene, f = True, o = True ) - - fnMesh = maya.OpenMaya.MFnMesh( IECoreMaya.dependencyNodeFromString( mesh ) ) - self.assertEqual( fnMesh.numVertices(), 408 ) - self.assertEqual( fnMesh.numPolygons(), 406 ) - - self.assertEqual( maya.cmds.getAttr( quads + ".nodeState" ), 0 ) - - def testParameterPlugForMissingPlug( self ) : - - ## Make sure that null plugs are returned from the parameterPlug() method - # if no plug exists. - - node = maya.cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnOpHolder( node ) - fnPH.setOp( "floatParameter" ) - - op = fnPH.getOp() - - plug = fnPH.parameterPlug( op.parameters() ) - self.assertTrue( isinstance( plug, maya.OpenMaya.MPlug ) ) - self.assertTrue( plug.isNull() ) - - def testLsMethods( self ) : - - # create a couple of holders: - opHolderNode = maya.cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opHolderNode ) - fnOH.setOp( "floatParameter" ) - - converterHolderNode = maya.cmds.createNode( "ieConverterHolder" ) - fnCH = IECoreMaya.FnConverterHolder( converterHolderNode ) - #fnCH.setOp( "floatParameter" ) - - # do an ls on the op holders: should only be one - opHolders = IECoreMaya.FnOpHolder.ls() - self.assertEqual( len( opHolders ), 1 ) - self.assertTrue( isinstance( opHolders[0], IECoreMaya.FnOpHolder ) ) - self.assertEqual( opHolders[0].fullPathName(), opHolderNode ) - - # do an ls on the converter holders, this time just returning node names: - converterHolders = IECoreMaya.FnConverterHolder.ls( fnSets=False ) - self.assertEqual( len( converterHolders ), 1 ) - self.assertEqual( converterHolders[0], converterHolderNode ) - - - def tearDown( self ) : - - for f in [ - "test/IECoreMaya/referenceEditCounts.ma", - "test/IECoreMaya/resultAttrLoadTest.ma", - "test/IECoreMaya/resultGetParameterisedTest.ma", - ] : - - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/FnSceneShapeTest.py b/test/IECoreMaya/FnSceneShapeTest.py deleted file mode 100644 index 5b5cd2e8c7..0000000000 --- a/test/IECoreMaya/FnSceneShapeTest.py +++ /dev/null @@ -1,482 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import os -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FnSceneShapeTest( IECoreMaya.TestCase ) : - - __testFile = "test/test.scc" - - def setUp( self ) : - - scene = IECoreScene.SceneCache( FnSceneShapeTest.__testFile, IECore.IndexedIO.OpenMode.Write ) - sc = scene.createChild( str(1) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) - sc.writeObject( mesh, 0.0 ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) - - sc = sc.createChild( "child" ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ) ] * 6 ) ) - sc.writeObject( mesh, 0.0 ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) - - sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) - sc.writeObject( mesh, 0.0 ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) - - return scene - - def __setupTableProp( self ): - boxSize = imath.Box3f( imath.V3f( -.5, -.5, -.5 ), imath.V3f( .5, .5, .5 ) ) - - table = IECoreScene.SceneCache( FnSceneShapeTest.__testFile, IECore.IndexedIO.Write ) - table.writeAttribute( 'scene:visible', IECore.BoolData( True ), 0 ) - table.writeAttribute( 'user:testBool', IECore.BoolData( True ), 0 ) - table.writeAttribute( 'user:testShort', IECore.ShortData( 2 ), 0 ) - table.writeAttribute( 'user:testInt', IECore.IntData( 3 ), 0 ) - table.writeAttribute( 'user:testInt64', IECore.Int64Data( 4 ), 0 ) - table.writeAttribute( 'user:testFloat', IECore.FloatData( 5 ), 0 ) - table.writeAttribute( 'user:testDouble', IECore.DoubleData( 6 ), 0 ) - table.writeAttribute( 'user:testString', IECore.StringData( 'seven' ), 0 ) - mat = imath.M44d( ( 8, 9, 10, 11 ), ( 12, 13, 14, 15 ), ( 16, 17, 18, 19 ), ( 20, 21, 22, 23 ) ) - table.writeAttribute( 'user:testMatrixd', IECore.M44dData(mat), 0 ) - mat = imath.M44f( ( 24, 25, 26, 27 ), ( 28, 29, 30, 31 ), ( 32, 33, 34, 35 ), ( 36, 37, 38, 39 ) ) - table.writeAttribute( 'user:testMatrixf', IECore.M44fData(mat), 0 ) - - pedestal_GEO = table.createChild( 'pedestal_GEO' ) - pedestal_GEO.writeObject( IECoreScene.MeshPrimitive.createBox(boxSize), 0 ) - s = imath.V3d(15, 1, 15) - r = imath.Eulerd() - t = imath.V3d(0, .5, 0) - mat = IECore.TransformationMatrixd( s, r, t ) - pedestal_GEO.writeTransform( IECore.TransformationMatrixdData(mat), 0 ) - - column_GEO = pedestal_GEO.createChild( 'column_GEO' ) - column_GEO.writeObject( IECoreScene.MeshPrimitive.createBox(boxSize), 0 ) - s = imath.V3d(.25, 20, .25) - r = imath.Eulerd() - t = imath.V3d(0, 10.5, 0) - mat = IECore.TransformationMatrixd( s, r, t ) - column_GEO.writeTransform( IECore.TransformationMatrixdData(mat), 0 ) - - tableTop_GEO = column_GEO.createChild( 'tableTop_GEO' ) - tableTop_GEO.writeObject( IECoreScene.MeshPrimitive.createBox(boxSize), 0 ) - s = imath.V3d(10, 0.05, 10) - r = imath.Eulerd() - t = imath.V3d(0, .525, 0) - mat = IECore.TransformationMatrixd( s, r, t ) - tableTop_GEO.writeTransform( IECore.TransformationMatrixdData(mat), 0 ) - - def testClassTypeInstantiation( self ): - - sceneShapeNode = maya.cmds.createNode( "ieSceneShape" ) - sceneShapeFn = IECoreMaya.FnSceneShape( sceneShapeNode ) - self.assertEqual( sceneShapeFn.__class__, IECoreMaya.FnSceneShape ) - - sceneShapeProxyNode = maya.cmds.createNode( "ieSceneShapeProxy" ) - sceneShapeProxyFn = IECoreMaya.FnSceneShape( sceneShapeProxyNode ) - self.assertEqual( sceneShapeProxyFn.__class__, IECoreMaya._FnSceneShapeProxy ) - - def testCreateShapeType( self ): - - sceneShapeTransform = maya.cmds.createNode( "transform" ) - sceneShapeFn = IECoreMaya.FnSceneShape.createShape( sceneShapeTransform, shapeType="ieSceneShape") - self.assertEqual( sceneShapeFn.__class__, IECoreMaya.FnSceneShape ) - - sceneShapeNode = maya.cmds.listRelatives( sceneShapeTransform, shapes=True) - self.assertTrue( maya.cmds.objectType( sceneShapeNode, isType="ieSceneShape" )) - - sceneShapeProxyTransform = maya.cmds.createNode( "transform" ) - sceneShapeProxyFn = IECoreMaya.FnSceneShape.createShape( sceneShapeProxyTransform, shapeType="ieSceneShapeProxy" ) - self.assertEqual( sceneShapeProxyFn.__class__, IECoreMaya._FnSceneShapeProxy ) - - sceneShapeProxyNode = maya.cmds.listRelatives( sceneShapeProxyTransform, shapes=True) - self.assertTrue( maya.cmds.objectType( sceneShapeProxyNode, isType="ieSceneShapeProxy" )) - - def testSceneInterface( self ) : - - maya.cmds.file( new=True, f=True ) - node = maya.cmds.createNode( "ieSceneShape" ) - maya.cmds.setAttr( node+'.file', FnSceneShapeTest.__testFile,type='string' ) - - fn = IECoreMaya.FnSceneShape( node ) - - # Check scene for a wrong path - maya.cmds.setAttr( node+'.root', 'blabla', type='string' ) - scene = fn.sceneInterface() - self.assertEqual( scene, None ) - - maya.cmds.setAttr( node+'.root', '/', type='string' ) - scene = fn.sceneInterface() - self.assertTrue( isinstance( scene, IECoreScene.SceneCache ) ) - self.assertEqual( scene.childNames(), ['1'] ) - self.assertFalse( scene.hasObject() ) - - maya.cmds.setAttr( node+'.root', '/1', type='string' ) - scene = fn.sceneInterface() - self.assertTrue( isinstance( scene, IECoreScene.SceneCache ) ) - self.assertEqual( scene.childNames(), ['child'] ) - self.assertTrue( scene.hasObject() ) - - def testCreationName( self ) : - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "bob" ) - self.assertEqual( fn.fullPathName(), u"|bob|bobSceneShape" ) - - fn = IECoreMaya.FnSceneShape.create( "bob1") - self.assertEqual( fn.fullPathName(), u"|bob1|bobSceneShape1" ) - - fn = IECoreMaya.FnSceneShape.create( "bob" ) - self.assertEqual( fn.fullPathName(), u"|bob2|bobSceneShape2" ) - - def testCreationSetup( self ) : - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - - self.assertTrue( maya.cmds.sets( fn.fullPathName(), isMember="initialShadingGroup" ) ) - self.assertTrue( maya.cmds.getAttr( fn.fullPathName()+".objectOnly", l=True ) ) - self.assertFalse( maya.cmds.getAttr( fn.fullPathName()+".objectOnly" ) ) - self.assertTrue( maya.cmds.isConnected( "time1.outTime", fn.fullPathName()+".time" ) ) - - def testExpandOnce( self ) : - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - - result = fn.expandOnce() - - self.assertTrue( maya.cmds.getAttr( fn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".queryPaths[0]" ), "/1" ) - - self.assertTrue( len(result) == 1 ) - childFn = result[0] - self.assertTrue( isinstance( childFn, IECoreMaya.FnSceneShape ) ) - self.assertEqual( childFn.fullPathName(), "|test|sceneShape_1|sceneShape_SceneShape1" ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".root" ), "/1" ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outTranslate", "|test|sceneShape_1.translate" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outRotate", "|test|sceneShape_1.rotate" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outScale", "|test|sceneShape_1.scale" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTime", childFn.fullPathName()+".time" ) ) - - maya.cmds.setAttr( childFn.fullPathName()+".drawGeometry", 1 ) - result = childFn.expandOnce() - - self.assertTrue( maya.cmds.getAttr( childFn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".queryPaths[0]" ), "/child" ) - - self.assertTrue( len(result) == 1 ) - self.assertTrue( isinstance( result[0], IECoreMaya.FnSceneShape ) ) - self.assertEqual( result[0].fullPathName(), "|test|sceneShape_1|child|childSceneShape" ) - self.assertEqual( maya.cmds.getAttr( result[0].fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( result[0].fullPathName()+".root" ), "/1/child" ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outTranslate", "|test|sceneShape_1|child.translate" ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outRotate", "|test|sceneShape_1|child.rotate" ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outScale", "|test|sceneShape_1|child.scale" ) ) - self.assertEqual( maya.cmds.getAttr( result[0].fullPathName()+".drawGeometry"), 1 ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTime", result[0].fullPathName()+".time" ) ) - - def testExpandOnceNamespace( self ) : - - maya.cmds.file( new=True, f=True ) - - namespace = "INPUT" - - if not maya.cmds.namespace( exists=namespace ): - maya.cmds.namespace( addNamespace=namespace ) - - def addnamespace( path ): - return path.replace( "|", "|" + namespace + ":" ) - - fn = IECoreMaya.FnSceneShape.create( namespace + ":" + "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile, type='string' ) - - result = fn.expandOnce( preserveNamespace=True ) - self.assertTrue( len(result) == 1 ) - - childFn = result[ 0 ] - self.assertTrue( isinstance( childFn, IECoreMaya.FnSceneShape ) ) - self.assertEqual( childFn.fullPathName(), addnamespace ( "|test|sceneShape_1|sceneShape_SceneShape1" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outTranslate", addnamespace ( "|test|sceneShape_1.translate" ) ) ) - - def testExpandAll( self ) : - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 1 ) - - result = fn.expandAll() - - self.assertTrue( maya.cmds.getAttr( fn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".queryPaths[0]" ), "/1" ) - - self.assertTrue( len(result) == 3 ) - childFn = result[0] - self.assertTrue( isinstance( childFn, IECoreMaya.FnSceneShape ) ) - self.assertEqual( childFn.fullPathName(), "|test|sceneShape_1|sceneShape_SceneShape1" ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".root" ), "/1" ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outTranslate", "|test|sceneShape_1.translate" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outRotate", "|test|sceneShape_1.rotate" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outScale", "|test|sceneShape_1.scale" ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTime", childFn.fullPathName()+".time" ) ) - - self.assertTrue( maya.cmds.getAttr( childFn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".queryPaths[0]" ), "/child" ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".drawGeometry"), 1 ) - - self.assertTrue( isinstance( result[1], IECoreMaya.FnSceneShape ) ) - self.assertEqual( result[1].fullPathName(), "|test|sceneShape_1|child|childSceneShape" ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".root" ), "/1/child" ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outTranslate", "|test|sceneShape_1|child.translate" ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outRotate", "|test|sceneShape_1|child.rotate" ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outScale", "|test|sceneShape_1|child.scale" ) ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".drawGeometry"), 1 ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTime", result[1].fullPathName()+".time" ) ) - - def testExpandAllNamespace( self ) : - - namespace = "INPUT" - - if not maya.cmds.namespace( exists=namespace ): - maya.cmds.namespace( addNamespace=namespace ) - - def addnamespace( path ): - return path.replace( "|", "|" + namespace + ":" ) - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( namespace + ":" + "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 1 ) - - result = fn.expandAll( preserveNamespace=True ) - - self.assertTrue( maya.cmds.getAttr( fn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".queryPaths[0]" ), "/1" ) - - self.assertTrue( len(result) == 3 ) - childFn = result[0] - self.assertTrue( isinstance( childFn, IECoreMaya.FnSceneShape ) ) - self.assertEqual( childFn.fullPathName(), addnamespace( "|test|sceneShape_1|sceneShape_SceneShape1" ) ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".root" ), "/1" ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outTranslate", addnamespace( "|test|sceneShape_1.translate" ) ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outRotate", addnamespace( "|test|sceneShape_1.rotate" ) ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTransform[0].outScale", addnamespace( "|test|sceneShape_1.scale" ) ) ) - self.assertTrue( maya.cmds.isConnected( fn.fullPathName()+".outTime", childFn.fullPathName()+".time" ) ) - - self.assertTrue( maya.cmds.getAttr( childFn.fullPathName()+".objectOnly" ) ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".queryPaths[0]" ), "/child" ) - self.assertEqual( maya.cmds.getAttr( childFn.fullPathName()+".drawGeometry"), 1 ) - - self.assertTrue( isinstance( result[1], IECoreMaya.FnSceneShape ) ) - self.assertEqual( result[1].fullPathName(), addnamespace( "|test|sceneShape_1|child|childSceneShape" ) ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".file" ), FnSceneShapeTest.__testFile ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".root" ), "/1/child" ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outTranslate", addnamespace( "|test|sceneShape_1|child.translate" ) ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outRotate", addnamespace( "|test|sceneShape_1|child.rotate" ) ) ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTransform[0].outScale", addnamespace( "|test|sceneShape_1|child.scale" ) ) ) - self.assertEqual( maya.cmds.getAttr( result[1].fullPathName()+".drawGeometry"), 1 ) - self.assertTrue( maya.cmds.isConnected( childFn.fullPathName()+".outTime", result[1].fullPathName()+".time" ) ) - - def testCollapse( self ) : - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - - result = fn.expandOnce() - result[0].expandOnce() - - children = set( ["|test|testSceneShape", "|test|sceneShape_1", "|test|sceneShape_1|sceneShape_SceneShape1", "|test|sceneShape_1|child", "|test|sceneShape_1|child|childSceneShape"] ) - self.assertEqual( set(maya.cmds.listRelatives( "|test", ad=True, f=True )), children ) - - fn.collapse() - self.assertEqual( maya.cmds.listRelatives( "|test", ad=True, f=True ), ["|test|testSceneShape"] ) - - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".objectOnly" ), 0 ) - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".visibility" ), 1 ) - - def testConvertAllToGeometry( self ): - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - - fn.convertAllToGeometry() - - children = ["|test|testSceneShape", "|test|sceneShape_1"] - self.assertEqual( maya.cmds.listRelatives( "|test", f=True ), children ) - self.assertEqual( maya.cmds.getAttr( fn.fullPathName()+".intermediateObject" ), 0 ) - - children = ["|test|sceneShape_1|sceneShape_SceneShape1", "|test|sceneShape_1|child", "|test|sceneShape_1|sceneShape_Shape1"] - self.assertEqual( maya.cmds.listRelatives( "|test|sceneShape_1", f=True ), children ) - self.assertEqual( maya.cmds.getAttr( "|test|sceneShape_1|sceneShape_SceneShape1.intermediateObject" ), 1 ) - self.assertEqual( maya.cmds.nodeType( "|test|sceneShape_1|sceneShape_Shape1" ), "mesh") - - self.assertEqual( maya.cmds.getAttr( "|test|sceneShape_1|sceneShape_SceneShape1.queryPaths[1]" ), "/" ) - self.assertTrue( maya.cmds.isConnected( "|test|sceneShape_1|sceneShape_SceneShape1.outObjects[1]", "|test|sceneShape_1|sceneShape_Shape1.inMesh" ) ) - - def testComponentNames( self ): - - maya.cmds.file( new=True, f=True ) - fn = IECoreMaya.FnSceneShape.create( "test" ) - maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' ) - maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 0 ) - self.assertEqual( fn.componentNames(), [] ) - - maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 1 ) - self.assertEqual( fn.componentNames(), ['/', '/1', '/1/child', '/1/child/3'] ) - - fn.selectComponentNames( ['/', '/1', '/1/child/3'] ) - self.assertEqual( fn.selectedComponentNames(), set( ['/', '/1', '/1/child/3'] ) ) - - def testQuery( self ): - - maya.cmds.file( new=True, f=True ) - - def createSceneFile(): - scene = IECoreScene.SceneCache( FnSceneShapeTest.__testFile, IECore.IndexedIO.OpenMode.Write ) - sc = scene.createChild( str(1) ) - curves = IECoreScene.CurvesPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) # 6 curves. - sc.writeObject( curves, 0.0 ) - matrix = imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) - sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) - - createSceneFile() - - node = maya.cmds.createNode( "ieSceneShape" ) - maya.cmds.setAttr( node+'.file', FnSceneShapeTest.__testFile,type='string' ) - maya.cmds.setAttr( node+'.root', '/',type='string' ) - fn = IECoreMaya.FnSceneShape( node ) - - self.assertEqual( maya.cmds.getAttr(fn.fullPathName()+".outObjects[0]", type=True), None ) - self.assertEqual( maya.cmds.getAttr(fn.fullPathName()+".outObjects[1]", type=True), None ) - - maya.cmds.setAttr( fn.fullPathName()+".queryPaths[0]" , "/1", type="string") - maya.cmds.setAttr( fn.fullPathName()+".queryPaths[1]" , "/1", type="string") - - maya.cmds.setAttr( fn.fullPathName()+".queryConvertParameters[0]", "-index 0", type="string" ) # Set it to output 0 th box curve. - maya.cmds.setAttr( fn.fullPathName()+".queryConvertParameters[1]", "-index 1", type="string" ) # Set it to output 1 th box curve. - - self.assertEqual( maya.cmds.getAttr(fn.fullPathName()+".outObjects[0]", type=True), "nurbsCurve" ) - self.assertEqual( maya.cmds.getAttr(fn.fullPathName()+".outObjects[1]", type=True), "nurbsCurve" ) - - curveShape0 = maya.cmds.createNode( "nurbsCurve" ) - curveShape1 = maya.cmds.createNode( "nurbsCurve" ) - maya.cmds.connectAttr( fn.fullPathName()+ ".outObjects[0]", curveShape0 + '.create' ) - maya.cmds.connectAttr( fn.fullPathName()+ ".outObjects[1]", curveShape1 + '.create' ) - - self.assertNotEqual( maya.cmds.pointPosition(curveShape0 + '.cv[0]' ), maya.cmds.pointPosition(curveShape1 + '.cv[0]' ) ) - - maya.cmds.setAttr( fn.fullPathName()+".queryConvertParameters[1]", "-index 0", type="string" ) - - self.assertEqual( maya.cmds.pointPosition(curveShape0 + '.cv[0]' ), maya.cmds.pointPosition(curveShape1 + '.cv[0]' ) ) - - def testPromotableAttributeNames( self ): - maya.cmds.file( new=True, force=True ) - self.__setupTableProp() - - sceneShapeFn = IECoreMaya.FnSceneShape.create( 'table' ) - sceneShapeFn.findPlug( 'file' ).setString( FnSceneShapeTest.__testFile ) - - expectedAttrs = [ - 'user:testBool', 'user:testShort', 'user:testInt', 'user:testInt64', 'user:testFloat', - 'user:testDouble', 'user:testString', 'user:testMatrixd', 'user:testMatrixf', 'scene:visible' - ] - - self.assertEqual( set( sceneShapeFn.promotableAttributeNames() ), set( expectedAttrs ) ) - - def testPromoteAttribute( self ): - maya.cmds.file( new=True, force=True ) - self.__setupTableProp() - - sceneShapeFn = IECoreMaya.FnSceneShape.create( 'table' ) - sceneShapeFn.findPlug( 'file' ).setString( FnSceneShapeTest.__testFile ) - - for pAttr in sceneShapeFn.promotableAttributeNames(): - sceneShapeFn.promoteAttribute( pAttr ) - - sceneShape = sceneShapeFn.fullPathName() - table = maya.cmds.listRelatives( sceneShape, parent=True )[0] - testVisibility = maya.cmds.getAttr( table + '.' + str( IECoreMaya.LiveScene.visibilityOverrideName ) ) - testBool = maya.cmds.getAttr( table + '.ieAttr_testBool' ) - testShort = maya.cmds.getAttr( table + '.ieAttr_testShort' ) - testInt = maya.cmds.getAttr( table + '.ieAttr_testInt' ) - testInt64 = maya.cmds.getAttr( table + '.ieAttr_testInt64' ) - testFloat = maya.cmds.getAttr( table + '.ieAttr_testFloat' ) - testDouble = maya.cmds.getAttr( table + '.ieAttr_testDouble' ) - testString = maya.cmds.getAttr( table + '.ieAttr_testString' ) - testMatrixd = maya.cmds.getAttr( table + '.ieAttr_testMatrixd' ) - testMatrixf = maya.cmds.getAttr( table + '.ieAttr_testMatrixf' ) - - self.assertTrue( testVisibility ) - self.assertTrue( testBool ) - self.assertEqual( testShort, 2 ) - self.assertEqual( testInt, 3 ) - self.assertEqual( testInt64, 4 ) - self.assertEqual( testFloat, 5. ) - self.assertEqual( testDouble, 6. ) - self.assertEqual( testString, 'seven' ) - self.assertEqual( testMatrixd, [ 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23. ] ) - self.assertEqual( testMatrixf, [ 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39. ] ) - - def tearDown( self ) : - - if os.path.exists( FnSceneShapeTest.__testFile ) : - os.remove( FnSceneShapeTest.__testFile ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/FromMayaCameraConverterTest.py b/test/IECoreMaya/FromMayaCameraConverterTest.py deleted file mode 100644 index 7414627d68..0000000000 --- a/test/IECoreMaya/FromMayaCameraConverterTest.py +++ /dev/null @@ -1,195 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya - -import IECore -import IECoreScene -import IECoreMaya - -import imath - -INCH_TO_MM = 25.400051 - -class FromMayaCameraConverterTest( IECoreMaya.TestCase ) : - def assertIECoreCamAndMayaCamEqual( self, coreCam, mayaCam ) : - - self.assertEqual( coreCam.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( mayaCam+".nearClipPlane" ), maya.cmds.getAttr( mayaCam+".farClipPlane" ) ) ) - self.assertEqual( coreCam.getApertureOffset(), imath.V2f( maya.cmds.getAttr( mayaCam+".horizontalFilmOffset" ), maya.cmds.getAttr( mayaCam+".verticalFilmOffset" ) ) * INCH_TO_MM ) - - sel = maya.OpenMaya.MSelectionList() - sel.add( mayaCam ) - dag = maya.OpenMaya.MDagPath() - sel.getDagPath( 0, dag ) - fn = maya.OpenMaya.MFnCamera( dag ) - - if coreCam.parameters()["projection"].value == "perspective" : - self.assertFalse( maya.cmds.getAttr( mayaCam+".orthographic" ) ) - self.assertAlmostEqual( coreCam.getFocalLength(), fn.focalLength() ) - self.assertAlmostEqual( coreCam.getAperture()[0], fn.horizontalFilmAperture() * INCH_TO_MM, places = 6 ) - self.assertAlmostEqual( coreCam.getAperture()[1], fn.verticalFilmAperture() * INCH_TO_MM, places = 6 ) - else : - self.assertTrue( maya.cmds.getAttr( mayaCam+".orthographic" ) ) - self.assertEqual( coreCam.getAperture(), imath.V2f( maya.cmds.getAttr( mayaCam+".orthographicWidth" ) ) ) - - # Check that the actual frustum computed by Maya matches the frustum computed by Cortex - utils = [ maya.OpenMaya.MScriptUtil() for i in range(4)] - utilPtrs = [ i.asDoublePtr() for i in utils ] - fn.getFilmFrustum( 1, *utilPtrs ) - mayaFrustum = [ maya.OpenMaya.MScriptUtil.getDouble( i ) for i in utilPtrs ] - - cortexFrustum = coreCam.frustum( IECoreScene.Camera.FilmFit.Distort ) - self.assertAlmostEqual( mayaFrustum[0], cortexFrustum.size()[0], places = 6 ) - self.assertAlmostEqual( mayaFrustum[1], cortexFrustum.size()[1], places = 6 ) - - # Note the ridiculous conversion factor because the offset returned by getFilmFrustum - # isn't actually relative to the focalLength you have to pass in ( Thanks, Maya ) - self.assertAlmostEqual( mayaFrustum[2] * INCH_TO_MM / fn.focalLength(), cortexFrustum.center()[0] ) - self.assertAlmostEqual( mayaFrustum[3] * INCH_TO_MM / fn.focalLength(), cortexFrustum.center()[1] ) - - - def testFactory( self ) : - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "perspShape" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaCameraConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "perspShape", IECoreScene.Camera.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaCameraConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "perspShape", IECoreScene.Renderable.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaCameraConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "perspShape", IECore.Writer.staticTypeId() ) - self.assertEqual( converter, None ) - - def test( self ) : - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "perspShape" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCameraConverter ) ) ) - - camera = converter.convert() - self.assertTrue( camera.isInstanceOf( IECoreScene.Camera.staticTypeId() ) ) - self.assertIECoreCamAndMayaCamEqual( camera, "perspShape" ) - - def testConstructor( self ) : - - converter = IECoreMaya.FromMayaCameraConverter( "perspShape" ) - camera = converter.convert() - self.assertTrue( camera.isInstanceOf( IECoreScene.Camera.staticTypeId() ) ) - - def testPerspective( self ) : - - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - - self.assertFalse( camera.hasResolution() ) - self.assertEqual( camera.getClippingPlanes(), imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) - self.assertEqual( camera.getProjection(), "perspective" ) - self.assertEqual( camera.getAperture(), imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) * INCH_TO_MM ) - self.assertAlmostEqual( camera.getFocalLength(), maya.cmds.getAttr( "perspShape.focalLength" ) ) - self.assertIECoreCamAndMayaCamEqual( camera, "perspShape" ) - - def testOrthographic( self ) : - - camera = IECoreMaya.FromMayaCameraConverter( "topShape" ).convert() - - self.assertFalse( camera.hasResolution() ) - self.assertEqual( camera.getClippingPlanes(), imath.V2f( maya.cmds.getAttr( "topShape.nearClipPlane" ), maya.cmds.getAttr( "topShape.farClipPlane" ) ) ) - self.assertEqual( camera.getProjection(), "orthographic" ) - self.assertEqual( camera.getAperture(), imath.V2f( maya.cmds.getAttr( "topShape.orthographicWidth" ) ) ) - self.assertIECoreCamAndMayaCamEqual( camera, "topShape" ) - - def testOverrideResolution( self ) : - - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertFalse( camera.hasResolution() ) - self.assertFalse( camera.hasFilmFit() ) - self.assertFalse( camera.hasPixelAspectRatio() ) - - maya.cmds.addAttr( "perspShape", ln="ieCamera_overrideResolution", at="long2" ) - maya.cmds.addAttr( "perspShape", ln="ieCamera_overrideResolutionX", at="long", p = "ieCamera_overrideResolution", dv = 1024 ) - maya.cmds.addAttr( "perspShape", ln="ieCamera_overrideResolutionY", at="long", p = "ieCamera_overrideResolution", dv = 778 ) - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertTrue( camera.hasResolution() ) - self.assertEqual( camera.getResolution(), imath.V2i( 1024, 778 ) ) - self.assertFalse( camera.hasPixelAspectRatio() ) - self.assertFalse( camera.hasFilmFit() ) - - maya.cmds.deleteAttr( "perspShape", attribute= "ieCamera_overrideResolution" ) - maya.cmds.addAttr( "perspShape", ln= "ieCamera_overridePixelAspectRatio", at="float", dv=2.0 ) - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertFalse( camera.hasResolution() ) - self.assertTrue( camera.hasPixelAspectRatio() ) - self.assertEqual( camera.getPixelAspectRatio(), 2.0 ) - self.assertFalse( camera.hasFilmFit() ) - - maya.cmds.deleteAttr( "perspShape", attribute= "ieCamera_overridePixelAspectRatio" ) - fitModeNames = list(IECoreScene.Camera.FilmFit.names.keys()) - maya.cmds.addAttr( "perspShape", ln= "ieCamera_overrideFilmFit", at="enum", en=":".join( fitModeNames ) ) - - - for i in range( len( fitModeNames ) ): - maya.cmds.setAttr( "perspShape.ieCamera_overrideFilmFit", i ) - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertFalse( camera.hasResolution() ) - self.assertFalse( camera.hasPixelAspectRatio() ) - self.assertTrue( camera.hasFilmFit() ) - self.assertEqual( camera.getFilmFit(), IECoreScene.Camera.FilmFit.names[ fitModeNames[i] ] ) - - maya.cmds.deleteAttr( "perspShape", attribute= "ieCamera_overrideFilmFit" ) - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertFalse( camera.hasResolution() ) - self.assertFalse( camera.hasFilmFit() ) - self.assertFalse( camera.hasPixelAspectRatio() ) - - def testFilmOffset( self ) : - - for x in [ -0.5, -0.25, 0, 0.25, 0.5 ] : - - for y in [ -0.5, -0.25, 0, 0.25, 0.5 ] : - - maya.cmds.setAttr( "perspShape.horizontalFilmOffset", x ) - maya.cmds.setAttr( "perspShape.verticalFilmOffset", y ) - camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - - self.assertFalse( camera.hasResolution() ) - self.assertEqual( camera.getClippingPlanes(), imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) - self.assertEqual( camera.getProjection(), "perspective" ) - self.assertEqual( camera.getAperture(), INCH_TO_MM * imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) - self.assertEqual( camera.getApertureOffset(), INCH_TO_MM * imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmOffset" ), maya.cmds.getAttr( "perspShape.verticalFilmOffset" ) ) ) - self.assertIECoreCamAndMayaCamEqual( camera, "perspShape" ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaConverterTest.py b/test/IECoreMaya/FromMayaConverterTest.py deleted file mode 100644 index ea588e419b..0000000000 --- a/test/IECoreMaya/FromMayaConverterTest.py +++ /dev/null @@ -1,93 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - sphereTransform = maya.cmds.polySphere()[0] - sphereShape = maya.cmds.listRelatives( sphereTransform, shapes=True )[0] - - # get a converter for a plug - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ) + ".translateX" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaUnitPlugConverterd.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ) + ".translateX", IECore.TypeId.FloatData ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - - # get a converter for a dag node - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaDagNodeConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ), IECoreScene.TypeId.Group ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaDagNodeConverter.staticTypeId() ) ) - - # get a converter for a shape node - converter = IECoreMaya.FromMayaConverter.create( str( sphereShape ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaShapeConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaConverter.create( str( sphereShape ), IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaShapeConverter.staticTypeId() ) ) - - def testTransformationMatrixConverter( self ): - - sphereTransform = maya.cmds.polySphere()[0] - radToAng = 180./3.14159265 - maya.cmds.setAttr( str( sphereTransform ) + ".rotate", -1000*radToAng, 30*radToAng, 100*radToAng, type="double3" ) - - ## \todo This section sometimes fails due to use of the unpredictable default conversion (see FromMayaObjectConverter.h - # for a description). We probably need to remove the default conversion so that people aren't exposed to it, or fix it - # so we can define which the default conversion is. - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ) ) - res = converter.convert() - self.assertTrue( not res.isInstanceOf( IECore.TransformationMatrixfData.staticTypeId() ) ) - self.assertTrue( not res.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - - # test TransformationMatrixData converter - converter = IECoreMaya.FromMayaConverter.create( str( sphereTransform ), IECore.TypeId.TransformationMatrixfData ) - self.assertTrue( converter ) - transform = converter.convert() - self.assertTrue( transform.isInstanceOf( IECore.TransformationMatrixfData.staticTypeId() ) ) - self.assertAlmostEqual( (transform.value.rotate - imath.Eulerf( -1000, 30, 100 )).length(), 0, 2 ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaCurveConverterTest.py b/test/IECoreMaya/FromMayaCurveConverterTest.py deleted file mode 100644 index e7adc7ffc1..0000000000 --- a/test/IECoreMaya/FromMayaCurveConverterTest.py +++ /dev/null @@ -1,266 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaCurveConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - circle = maya.cmds.circle( ch = False )[0] - circle = str( maya.cmds.listRelatives( circle, shapes=True )[0] ) - - converter = IECoreMaya.FromMayaShapeConverter.create( circle, IECoreScene.CurvesPrimitive.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - converter = IECoreMaya.FromMayaShapeConverter.create( circle, IECoreScene.Primitive.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - converter = IECoreMaya.FromMayaShapeConverter.create( circle ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( circle, IECoreScene.CurvesPrimitive.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( circle, IECoreScene.Primitive.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( circle ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - def testCubicCircle( self ) : - - circle = maya.cmds.circle( ch = False )[0] - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( circle ), IECoreScene.CurvesPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - curve = converter.convert() - - self.assertTrue( curve.isInstanceOf( IECoreScene.CurvesPrimitive.staticTypeId() ) ) - - # check topology - self.assertEqual( curve.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 8 ) - self.assertEqual( curve.verticesPerCurve(), IECore.IntVectorData( [ 8 ] ) ) - self.assertEqual( curve.basis(), IECore.CubicBasisf.bSpline() ) - self.assertEqual( curve.periodic(), True ) - - # check primvars - self.assertEqual( list(curve.keys()), [ "P" ] ) - self.assertEqual( curve["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - p = curve["P"].data - self.assertEqual( len( p ), 8 ) - for pp in p : - self.assertEqual( pp.z, 0 ) - self.assertAlmostEqual( pp.length(), 1.1, 1 ) - - def testLinearCircle( self ) : - - circle = maya.cmds.circle( ch = False, degree=1 )[0] - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( circle ), IECoreScene.CurvesPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaCurveConverter ) ) ) - - curve = converter.convert() - self.assertTrue( curve.isInstanceOf( IECoreScene.CurvesPrimitive.staticTypeId() ) ) - - # check topology - # bizarrely maya doesn't make linear circles as periodic - it just repeats the first point - # at the end instead. - self.assertEqual( curve.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 9 ) - self.assertEqual( curve.verticesPerCurve(), IECore.IntVectorData( [ 9 ] ) ) - self.assertEqual( curve.basis(), IECore.CubicBasisf.linear() ) - self.assertEqual( curve.periodic(), False ) - - # check primvars - self.assertEqual( list(curve.keys()), [ "P" ] ) - self.assertEqual( curve["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - p = curve["P"].data - self.assertEqual( len( p ), 9 ) - for pp in p : - self.assertEqual( pp.z, 0 ) - self.assertAlmostEqual( pp.length(), 1, 5 ) - - def testCubicArc( self ) : - - arc = maya.cmds.circle( ch = False, sweep=180 )[0] - arc = maya.cmds.listRelatives( arc, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( arc ), IECoreScene.CurvesPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaCurveConverter.staticTypeId() ) ) - - curve = converter.convert() - IECore.Writer.create( curve, "/tmp/curve.cob" ).write() - self.assertTrue( curve.isInstanceOf( IECoreScene.CurvesPrimitive.staticTypeId() ) ) - - # check topology - self.assertEqual( curve.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 15 ) - self.assertEqual( curve.verticesPerCurve(), IECore.IntVectorData( [ 15 ] ) ) - self.assertEqual( curve.basis(), IECore.CubicBasisf.bSpline() ) - self.assertEqual( curve.periodic(), False ) - - # check primvars - self.assertEqual( list(curve.keys()), [ "P" ] ) - self.assertEqual( curve["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - p = curve["P"].data - self.assertEqual( len( p ), 15 ) - for pp in p : - self.assertEqual( pp.z, 0 ) - self.assertTrue( pp.length() > 0.999 and pp.length() < 1.11) - - self.assertEqual( p[0], p[1] ) - self.assertEqual( p[1], p[2] ) - self.assertEqual( p[-1], p[-2] ) - self.assertEqual( p[-2], p[-3] ) - - def testSpaces( self ) : - - arc = maya.cmds.circle( ch = False, sweep=180 )[0] - maya.cmds.move( 1, 2, 3, arc ) - arc = maya.cmds.listRelatives( arc, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( arc ), IECoreScene.CurvesPrimitive.staticTypeId() ) - - self.assertEqual( converter["space"].getNumericValue(), IECoreMaya.FromMayaCurveConverter.Space.Object ) - c = converter.convert() - self.assertTrue( - IECore.BoxAlgo.contains( - imath.Box3f( imath.V3f( -1.1, -1.01, -0.01 ), imath.V3f( 0.01, 1.01, 0.01 ) ), - c.bound() - ) - ) - - converter["space"].setNumericValue( IECoreMaya.FromMayaCurveConverter.Space.World ) - c = converter.convert() - self.assertTrue( - IECore.BoxAlgo.contains( - imath.Box3f( imath.V3f( -0.1, 0.99, 2.99 ), imath.V3f( 1.01, 3.01, 3.01 ) ), - c.bound() - ) - ) - - def testCubicCircleAsLinear( self ) : - - circle = maya.cmds.circle( ch = False )[0] - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( circle ), IECoreScene.CurvesPrimitive.staticTypeId() ) - converter["linearBasis"].setTypedValue( True ) - - curve = converter.convert() - self.assertTrue( curve.isInstanceOf( IECoreScene.CurvesPrimitive.staticTypeId() ) ) - - # check topology - self.assertEqual( curve.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 8 ) - self.assertEqual( curve.verticesPerCurve(), IECore.IntVectorData( [ 8 ] ) ) - self.assertEqual( curve.basis(), IECore.CubicBasisf.linear() ) - self.assertEqual( curve.periodic(), True ) - - # check primvars - self.assertEqual( list(curve.keys()), [ "P" ] ) - self.assertEqual( curve["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - p = curve["P"].data - self.assertEqual( len( p ), 8 ) - for pp in p : - self.assertEqual( pp.z, 0 ) - self.assertTrue( pp.length() > 0.999 and pp.length() < 1.11) - - def testBlindData( self ) : - - circle = maya.cmds.circle( ch = False )[0] - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - maya.cmds.addAttr( circle, dataType="string", longName="ieString" ) - maya.cmds.setAttr( circle + ".ieString", "banana", type="string" ) - - converter = IECoreMaya.FromMayaShapeConverter.create( str( circle ), IECoreScene.CurvesPrimitive.staticTypeId() ) - converter['blindDataAttrPrefix'] = IECore.StringData("ie") - curve = converter.convert() - - self.assertEqual( len( list(curve.blindData().keys()) ), 2 ) - self.assertEqual( curve.blindData()["name"], IECore.StringData( "nurbsCircleShape1" ) ) - self.assertEqual( curve.blindData()["ieString"], IECore.StringData( "banana" ) ) - - def testPrimVars( self ) : - - circle = maya.cmds.circle( ch = False )[0] - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - maya.cmds.addAttr( circle, attributeType="float", longName="iePrimVarDouble", defaultValue=1 ) - - converter = IECoreMaya.FromMayaShapeConverter.create( str( circle ), IECoreScene.CurvesPrimitive.staticTypeId() ) - curve = converter.convert() - - self.assertEqual( len( list(curve.keys()) ), 2 ) - self.assertEqual( curve["Double"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( curve["Double"].data, IECore.FloatData( 1 ) ) - - def testConvertFromPlug( self ) : - - circle = maya.cmds.circle( ch = False )[0] - maya.cmds.move( 1, 2, 3, circle ) - circle = maya.cmds.listRelatives( circle, shapes=True )[0] - - converter = IECoreMaya.FromMayaPlugConverter.create( circle + ".worldSpace" ) - - converter["space"].setNumericValue( IECoreMaya.FromMayaShapeConverter.Space.World ) - curve = converter.convert() - self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( - IECore.BoxAlgo.contains( - imath.Box3f( imath.V3f( -1.11 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.11 ) + imath.V3f( 1, 2, 3 ) ), - curve.bound() - ) - ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaGroupConverterTest.py b/test/IECoreMaya/FromMayaGroupConverterTest.py deleted file mode 100644 index a2c97710ce..0000000000 --- a/test/IECoreMaya/FromMayaGroupConverterTest.py +++ /dev/null @@ -1,69 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaGroupConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - sphereTransform = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False )[0] - - converter = IECoreMaya.FromMayaDagNodeConverter.create( str( sphereTransform ), IECoreScene.TypeId.Group ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaGroupConverter ) ) ) - - def testConversion( self ) : - - cubeTransform = maya.cmds.polyCube()[0] - maya.cmds.move( 1, 2, 3, cubeTransform ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( str( cubeTransform ), IECoreScene.TypeId.Group ) - - converted = converter.convert() - - self.assertTrue( converted.isInstanceOf( IECoreScene.Group.staticTypeId() ) ) - self.assertEqual( converted.getTransform().transform(), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) - - self.assertEqual( len( converted.children() ), 1 ) - convertedCube = converted.children()[0] - self.assertTrue( convertedCube.isInstanceOf( IECoreScene.MeshPrimitive.staticTypeId() ) ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaInstancerConverterTest.py b/test/IECoreMaya/FromMayaInstancerConverterTest.py deleted file mode 100644 index 588454159c..0000000000 --- a/test/IECoreMaya/FromMayaInstancerConverterTest.py +++ /dev/null @@ -1,180 +0,0 @@ -########################################################################## -# -# Copyright (c) 2018, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya - -import imath -import math - -import IECore -import IECoreScene -import IECoreMaya - - -class FromMayaInstancerConverter( IECoreMaya.TestCase ) : - - def setUp( self ) : - - super( FromMayaInstancerConverter, self ).setUp() - - def makeScene( self ): - - maya.cmds.polyCube() - maya.cmds.polySphere() - - maya.cmds.particle( p = [[4, 0, 0], [4, 4, 0], [0, 4, 0], [0, 0, 0]], c = 1 ) - maya.cmds.addAttr( "particleShape1", ln = "rotationPP", dt = "vectorArray" ) - maya.cmds.addAttr( "particleShape1", ln = "instancePP", dt = "doubleArray" ) - maya.cmds.select( ["particle1", "pCube1", "pSphere1"], r = True ) - maya.cmds.particleInstancer( addObject = True, object = ["pCube1","pSphere1"] ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", rotation = "rotationPP" ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", objectIndex = "instancePP" ) - - maya.cmds.setAttr( "particleShape1.rotationPP", 4, ( 45, 0, 0 ), ( 0, 45, 0 ), ( 0, 0, 45 ), ( 45, 45, 0 ), type = "vectorArray" ) - maya.cmds.setAttr( "particleShape1.instancePP", [0, 1, 0, 1], type = "doubleArray" ) - - def makeRotationOrderOrUnitScene( self, rotationOrder, useRadians ) : - - maya.cmds.polyCube() - - maya.cmds.particle( p = [[0, 0, 0]], c = 1 ) - maya.cmds.addAttr( "particleShape1", ln = "rotationPP", dt = "vectorArray" ) - maya.cmds.addAttr( "particleShape1", ln = "instancePP", dt = "doubleArray" ) - maya.cmds.select( ["particle1", "pCube1" ], r = True ) - maya.cmds.particleInstancer( addObject = True, object = ["pCube1"] ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", rotation = "rotationPP" ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", objectIndex = "instancePP" ) - - maya.cmds.setAttr( "instancer1.rotationOrder", rotationOrder ) # ZYX - if useRadians : - maya.cmds.setAttr( "instancer1.rotationAngleUnits", 1 ) - - maya.cmds.setAttr( "particleShape1.rotationPP", 1, ( 90, 90, 0 ), type = "vectorArray" ) - maya.cmds.setAttr( "particleShape1.instancePP", [0, 1, 0, 1], type = "doubleArray" ) - - def testCanCreateConverterOfCorrectType( self ) : - - self.makeScene() - converter = IECoreMaya.FromMayaDagNodeConverter.create( "instancer1" ) - assert (converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaInstancerConverter ) )) - - def assertUnorderedEqual( self, a, b ) : - self.assertEqual( len( a ), len( b ) ) - self.assertEqual( set( a ), set( b ) ) - - def testConvertsToPointsPrimitive( self ) : - - self.makeScene() - converter = IECoreMaya.FromMayaDagNodeConverter.create( "instancer1" ) - convertedPoints = converter.convert() - - self.assertTrue( convertedPoints.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - self.assertEqual( convertedPoints.numPoints, 4 ) - - self.assertUnorderedEqual( list(convertedPoints.keys()), ['P', 'age', 'id', 'instances', 'instanceType', 'orient'] ) - - self.assertEqual( convertedPoints["P"].data[0], imath.V3f( 4, 0, 0 ) ) - self.assertEqual( convertedPoints["P"].data[1], imath.V3f( 4, 4, 0 ) ) - self.assertEqual( convertedPoints["P"].data[2], imath.V3f( 0, 4, 0 ) ) - self.assertEqual( convertedPoints["P"].data[3], imath.V3f( 0, 0, 0 ) ) - - self.assertEqual( convertedPoints["id"].data[0], 0 ) - self.assertEqual( convertedPoints["id"].data[1], 1 ) - self.assertEqual( convertedPoints["id"].data[2], 2 ) - self.assertEqual( convertedPoints["id"].data[3], 3 ) - - self.assertEqual( convertedPoints["age"].data[0], 0.0 ) - self.assertEqual( convertedPoints["age"].data[1], 0.0 ) - self.assertEqual( convertedPoints["age"].data[2], 0.0 ) - self.assertEqual( convertedPoints["age"].data[3], 0.0 ) - - # instance indices to ensure we can instance the correct object - self.assertEqual( convertedPoints["instanceType"].data[0], 0 ) - self.assertEqual( convertedPoints["instanceType"].data[1], 1 ) - self.assertEqual( convertedPoints["instanceType"].data[2], 0 ) - self.assertEqual( convertedPoints["instanceType"].data[3], 1 ) - - # rotation is converted to orient - self.assertEqual( convertedPoints["orient"].data[0], imath.Eulerf( math.pi / 4.0, 0, 0 ).toQuat() ) - self.assertEqual( convertedPoints["orient"].data[1], imath.Eulerf( 0, math.pi / 4.0, 0 ).toQuat() ) - self.assertEqual( convertedPoints["orient"].data[2], imath.Eulerf( 0, 0, math.pi / 4.0 ).toQuat() ) - self.assertEqual( convertedPoints["orient"].data[3], imath.Eulerf( math.pi / 4.0, math.pi / 4.0, 0 ).toQuat() ) - - # check we're capturing the locations in maya we're instancing - self.assertEqual( convertedPoints["instances"].data, IECore.StringVectorData( ['/pCube1', '/pSphere1'] ) ) - - def testCanConvertEmptyInstancer( self ) : - - self.makeScene() - - # disconnect the particles from the instancer - maya.cmds.disconnectAttr( "particleShape1.instanceData[0].instancePointData", "instancer1.inputPoints" ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "instancer1" ) - convertedPoints = converter.convert() - - self.assertTrue( convertedPoints.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - - self.assertTrue( "P" in list(convertedPoints.keys()) ) - self.assertEqual( convertedPoints["P"].data, IECore.V3fVectorData( [], IECore.GeometricData.Interpretation.Point ) ) - - def testCanChangeInstancerRotationOrder( self ): - self.makeRotationOrderOrUnitScene( 5, False ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "instancer1" ) - convertedPoints = converter.convert() - - self.assertTrue( convertedPoints.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - self.assertEqual( convertedPoints.numPoints, 1 ) - - self.assertUnorderedEqual( list(convertedPoints.keys()), ['P', 'age', 'id', 'instances', 'instanceType', 'orient'] ) - - self.assertEqual( convertedPoints["orient"].data[0], imath.Eulerf( math.pi / 2.0, math.pi / 2.0, 0, imath.Eulerf.ZYX ).toQuat() ) - - def testCanChangeInstancerRotationUnits( self ) : - self.makeRotationOrderOrUnitScene( 0, True ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "instancer1" ) - convertedPoints = converter.convert() - - self.assertTrue( convertedPoints.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - self.assertEqual( convertedPoints.numPoints, 1 ) - - self.assertUnorderedEqual( list(convertedPoints.keys()), ['P', 'age', 'id', 'instances', 'instanceType', 'orient'] ) - - self.assertEqual( convertedPoints["orient"].data[0], imath.Eulerf( 90.0, 90.0, 0, imath.Eulerf.XYZ ).toQuat() ) - -if __name__ == "__main__" : - IECoreMaya.TestProgram( plugins = ["ieCore"] ) diff --git a/test/IECoreMaya/FromMayaLocatorConverterTest.py b/test/IECoreMaya/FromMayaLocatorConverterTest.py deleted file mode 100644 index 051decb667..0000000000 --- a/test/IECoreMaya/FromMayaLocatorConverterTest.py +++ /dev/null @@ -1,93 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaLocatorConverterTest( IECoreMaya.TestCase ) : - - def setUp( self ) : - - maya.cmds.file( new=True, f=True ) - - locatorShape = maya.cmds.createNode( "locator", name = "myLocator" ) - locatorTransform = "locator1" - maya.cmds.setAttr( locatorTransform + ".translate", 1,2,3 ) - maya.cmds.setAttr( locatorShape + ".localPosition", 10,20,30 ) - maya.cmds.setAttr( locatorShape + ".localScale", 1,2,3 ) - - def testFactory( self ) : - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "myLocator" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaLocatorConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "myLocator", IECoreScene.CoordinateSystem.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaLocatorConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "myLocator", IECoreScene.Renderable.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaLocatorConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "myLocator", IECore.Writer.staticTypeId() ) - self.assertEqual( converter, None ) - - def test( self ) : - - converter = IECoreMaya.FromMayaDagNodeConverter.create( "myLocator" ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaLocatorConverter ) ) ) - - locator = converter.convert() - self.assertTrue( locator.isInstanceOf( IECoreScene.CoordinateSystem.staticTypeId() ) ) - - self.assertEqual( locator.getName(), "myLocator" ) - m = locator.getTransform().transform() - s, h, r, t = imath.V3f(), imath.V3f(), imath.V3f(), imath.V3f() - m.extractSHRT( s, h, r, t ) - self.assertEqual( s, imath.V3f(1,2,3) ) - self.assertEqual( t, imath.V3f(10,20,30) ) - self.assertEqual( r, imath.V3f(0,0,0) ) - self.assertEqual( h, imath.V3f(0,0,0) ) - - def testConstructor( self ) : - - converter = IECoreMaya.FromMayaLocatorConverter( "myLocator" ) - camera = converter.convert() - self.assertTrue( camera.isInstanceOf( IECoreScene.CoordinateSystem.staticTypeId() ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaMeshConverterTest.py b/test/IECoreMaya/FromMayaMeshConverterTest.py deleted file mode 100644 index f558c2db78..0000000000 --- a/test/IECoreMaya/FromMayaMeshConverterTest.py +++ /dev/null @@ -1,487 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os.path -import maya.cmds -import maya.OpenMaya as OpenMaya -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaMeshConverterTest( IECoreMaya.TestCase ) : - - __testFile = "/tmp/test.scc" - - def writeTestScc( self ): - - scene = IECoreScene.SceneCache( self.__testFile, IECore.IndexedIO.OpenMode.Write ) - sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - - creaseLengths = [ 3, 2 ] - creaseIds = [ 1, 2, 3, 4, 5 ] - creaseSharpnesses = [ 1, 5 ] - mesh.setCreases( IECore.IntVectorData( creaseLengths ), IECore.IntVectorData( creaseIds ), IECore.FloatVectorData( creaseSharpnesses ) ) - - sc.writeObject( mesh, 0 ) - - del scene, sc - - def testFactory( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere, IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere, IECoreScene.TypeId.Primitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sphere ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sphere, IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sphere, IECoreScene.TypeId.Primitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaMeshConverter ) ) ) - - def testConstructor( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaMeshConverter( sphere ) - - m = converter.convert() - - self.assertTrue( isinstance( m, IECoreScene.MeshPrimitive ) ) - - def testParameters( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere ) - self.assertEqual( converter["interpolation"].getTypedValue(), "default" ) - p = converter.convert() - self.assertEqual( p.interpolation, "linear" ) - self.assertTrue( "N" in p ) - converter["interpolation"].setTypedValue( "linear" ) - p = converter.convert() - self.assertEqual( p.interpolation, "linear" ) - converter["interpolation"].setTypedValue( "catmullClark" ) - p = converter.convert() - self.assertFalse( "N" in p ) - self.assertEqual( p.interpolation, "catmullClark" ) - - def testInterpolationType( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - # first time creates the plug - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere, "catmullClark" ) - mesh = IECoreMaya.FromMayaShapeConverter.create( sphere ).convert() - self.assertEqual( mesh.interpolation, "catmullClark" ) - - # second time, just update the plug - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere, "linear" ) - mesh = IECoreMaya.FromMayaShapeConverter.create( sphere ).convert() - self.assertEqual( mesh.interpolation, "linear" ) - - # accepts the labels for the presets "subdiv" -> "catmullClark" - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere, "subdiv" ) - mesh = IECoreMaya.FromMayaShapeConverter.create( sphere ).convert() - self.assertEqual( mesh.interpolation, "catmullClark" ) - - # accepts the labels for the presets "poly" -> "linear" - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere, "poly" ) - mesh = IECoreMaya.FromMayaShapeConverter.create( sphere ).convert() - self.assertEqual( mesh.interpolation, "linear" ) - - def testSphere( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere ) - - m = converter.convert() - - # check topology - self.assertEqual( m.verticesPerFace.size(), 50 ) - self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 50 ) - self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 42 ) - self.assertEqual( m["P"].data.size(), 42 ) - self.assertEqual( m["N"].data.size(), 180 ) - self.assertEqual( m["uv"].data.size(), 64 ) - self.assertEqual( m["uv"].indices.size(), 180 ) - self.assertEqual( m["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( m["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertEqual( m["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ), imath.V3f( 1.0001 ) ), m.bound() ) ) - self.assertTrue( IECore.BoxAlgo.contains( m.bound(), imath.Box3f( imath.V3f( -0.90 ), imath.V3f( 0.90 ) ) ) ) - - def testSpaces( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - maya.cmds.move( 1, 2, 3, sphere ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere ) - - self.assertEqual( converter["space"].getNumericValue(), IECoreMaya.FromMayaCurveConverter.Space.Object ) - m = converter.convert() - self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ), imath.V3f( 1.0001 ) ), m.bound() ) ) - - converter["space"].setNumericValue( IECoreMaya.FromMayaShapeConverter.Space.World ) - m = converter.convert() - self.assertTrue( imath.Box3f( imath.V3f( -1.0001 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.0001 ) + imath.V3f( 1, 2, 3 ) ), m.bound() ) - - def testNormalsOnlyWhenLinear( self ) : - - # adding normals to a mesh which will be rendered subdivided is a very bad thing to do. - # make sure we aren't doing it. - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( sphere ) - - m = converter.convert() - self.assertTrue( "N" in m ) - self.assertEqual( m["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - - converter["interpolation"].setTypedValue( "catmullClark" ) - m = converter.convert() - self.assertTrue( not "N" in m ) - - def testWindingOrder( self ) : - - plane = maya.cmds.polyPlane( ch=False, subdivisionsX=1, subdivisionsY=1 ) - plane = maya.cmds.listRelatives( plane, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( plane ) - - m = converter.convert() - - p = m["P"].data - vertexIds = m.vertexIds - self.assertEqual( vertexIds.size(), 4 ) - loop = IECore.V3fVectorData( [ p[vertexIds[0]], p[vertexIds[1]], p[vertexIds[2]], p[vertexIds[3]] ] ) - - self.assertTrue( IECore.polygonNormal( loop ).equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.0001 ) ) - - def testBlindData( self ) : - - plane = maya.cmds.polyPlane( ch=False, subdivisionsX=1, subdivisionsY=1 ) - plane = maya.cmds.listRelatives( plane, shapes=True )[0] - - maya.cmds.addAttr( plane, dataType="string", longName="ieString" ) - maya.cmds.setAttr( plane + ".ieString", "banana", type="string" ) - - converter = IECoreMaya.FromMayaShapeConverter.create( plane ) - converter['blindDataAttrPrefix'] = IECore.StringData("ie") - m = converter.convert() - - self.assertEqual( len( list(m.blindData().keys()) ), 2 ) - self.assertEqual( m.blindData()["name"], IECore.StringData( "pPlaneShape1" ) ) - self.assertEqual( m.blindData()["ieString"], IECore.StringData( "banana" ) ) - - def testPrimVars( self ) : - - plane = maya.cmds.polyPlane( ch=False, subdivisionsX=1, subdivisionsY=1 ) - plane = maya.cmds.listRelatives( plane, shapes=True )[0] - - maya.cmds.addAttr( plane, attributeType="float", longName="iePrimVarDouble", defaultValue=1 ) - maya.cmds.addAttr( plane, dataType="doubleArray", longName="iePrimVarDoubleArray" ) - maya.cmds.setAttr( plane + ".iePrimVarDoubleArray", ( 10, 11, 12, 13 ), type="doubleArray" ) - - converter = IECoreMaya.FromMayaShapeConverter.create( plane, IECoreScene.MeshPrimitive.staticTypeId() ) - m = converter.convert() - - self.assertEqual( set( m.keys() ), set( [ "P", "N", "uv", "Double", "DoubleArray" ] ) ) - self.assertEqual( m["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( m["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 1 ) ], IECore.GeometricData.Interpretation.UV ) ) - self.assertEqual( m["uv"].indices, IECore.IntVectorData( [ 0, 1, 3, 2 ] ) ) - self.assertEqual( m["Double"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( m["Double"].data, IECore.FloatData( 1 ) ) - self.assertEqual( m["DoubleArray"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( m["DoubleArray"].data, IECore.FloatVectorData( [ 10, 11, 12, 13 ] ) ) - - def testConvertFromPlug( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - maya.cmds.move( 1, 2, 3, sphere ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - converter = IECoreMaya.FromMayaPlugConverter.create( sphere + ".worldMesh" ) - - converter["space"].setNumericValue( IECoreMaya.FromMayaShapeConverter.Space.World ) - m = converter.convert() - self.assertEqual( m["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( m["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.0001 ) + imath.V3f( 1, 2, 3 ) ), m.bound() ) ) - - def testSharedUVIndices( self ) : - - maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/twoTrianglesWithSharedUVs.ma", force = True, open = True ) - - mesh = IECoreMaya.FromMayaShapeConverter.create( "pPlaneShape1" ).convert() - - self.assertTrue( "uv" in mesh ) - self.assertEqual( mesh["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( mesh["uv"].indices, IECore.IntVectorData( [ 0, 1, 2, 2, 1, 3 ] ) ) - self.assertEqual( mesh["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - def testSplitUVIndices( self ) : - - maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/twoTrianglesWithSplitUVs.ma", force = True, open = True ) - - mesh = IECoreMaya.FromMayaShapeConverter.create( "pPlaneShape1" ).convert() - - self.assertTrue( "uv" in mesh ) - self.assertEqual( mesh["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( mesh["uv"].indices, IECore.IntVectorData( [ 0, 1, 5, 2, 4, 3 ] ) ) - self.assertEqual( mesh["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - def testExtraSTs( self ) : - - plane = maya.cmds.polyPlane( ch=False, subdivisionsX=1, subdivisionsY=1 ) - plane = maya.cmds.listRelatives( plane, shapes=True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( plane, IECoreScene.MeshPrimitive.staticTypeId() ) - m = converter.convert() - - self.assertIn( "uv", m ) - # map1 is the default set - self.assertNotIn( "map1", m ) - - maya.cmds.polyUVSet( plane, copy=True, uvSet="map1", newUVSet="map2" ) - - m = converter.convert() - - self.assertIn( "uv", m ) - self.assertNotIn( "map1", m ) - self.assertIn( "map2", m ) - - self.assertEqual( m["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - self.assertEqual( m["map2"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - # Test that all uvs are ignored when the uv parameter is False - converter["uv"].setTypedValue( False ) - m = converter.convert() - self.assertNotIn( "uv", m ) - self.assertNotIn( "map1", m ) - self.assertNotIn( "map2", m ) - - def testManyUVConversionsFromPlug( self ) : - - # load a mesh with indexed UVs - scc = IECoreScene.SceneCache( "test/IECore/data/sccFiles/animatedSpheres.scc", IECore.IndexedIO.OpenMode.Read ) - coreMesh = scc.scene( [ "A", "a" ] ).readObject( 0 ) - self.assertTrue( "uv" in coreMesh ) - self.assertEqual( coreMesh["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - - for i in range( 0, 7 ) : - coreMesh[ "testUVSet%d" % i ] = IECoreScene.PrimitiveVariable( coreMesh["uv"].interpolation, coreMesh["uv"].data.copy(), coreMesh["uv"].indices.copy() ) - - self.assertTrue( coreMesh.arePrimitiveVariablesValid() ) - - fn = IECoreMaya.FnOpHolder.create( "test", "meshMerge" ) - - mayaMesh = maya.cmds.ls( maya.cmds.polyPlane(), dag=True, type="mesh" )[0] - maya.cmds.connectAttr( fn.name()+".result", mayaMesh+".inMesh", force=True ) - - op = fn.getOp() - with fn.parameterModificationContext() : - op["input"].setValue( coreMesh ) - - maya.cmds.file( rename="/tmp/test.ma" ) - maya.cmds.file( save=True ) - maya.cmds.file( new=True, f=True ) - maya.cmds.file( "/tmp/test.ma", open=True ) - - result = IECoreMaya.FromMayaMeshConverter( mayaMesh ).convert() - - self.assertTrue( result.arePrimitiveVariablesValid() ) - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 400 ) - self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 1560 ) - - self.assertEqual( coreMesh["uv"], result["uv"] ) - - for i in range( 0, 7 ) : - self.assertEqual( coreMesh[ "testUVSet%d" % i ], result[ "testUVSet%d" % i ] ) - - def testColors( self ): - - # test alpha to rgb conversion - mesh = "pPlaneShape1" - maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/colouredPlane.ma", force = True, open = True ) - sel = OpenMaya.MSelectionList() - sel.add( mesh ) - planeObj = OpenMaya.MObject() - sel.getDependNode( 0, planeObj ) - fnMesh = OpenMaya.MFnMesh( planeObj ) - fnMesh.setCurrentColorSetName( "cAlpha" ) - converter = IECoreMaya.FromMayaShapeConverter.create( mesh, IECoreScene.MeshPrimitive.staticTypeId() ) - converter['colors'] = True - m = converter.convert() - self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ imath.Color3f(0), imath.Color3f(1), imath.Color3f(0.8), imath.Color3f(0.5) ] ) ) - - # test rgba to rgb conversion - maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/colouredPlane.ma", force = True, open = True ) - sel = OpenMaya.MSelectionList() - sel.add( mesh ) - planeObj = OpenMaya.MObject() - sel.getDependNode( 0, planeObj ) - fnMesh = OpenMaya.MFnMesh( planeObj ) - fnMesh.setCurrentColorSetName( "cRGBA" ) - converter = IECoreMaya.FromMayaShapeConverter.create( mesh, IECoreScene.MeshPrimitive.staticTypeId() ) - converter['colors'] = True - m = converter.convert() - self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ imath.Color3f( 1, 1, 0 ), imath.Color3f( 1, 1, 1 ), imath.Color3f( 0, 1, 1 ), imath.Color3f( 0, 1, 0 ) ] ) ) - - def testExtraColors( self ): - - maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/colouredPlane.ma", force = True, open = True ) - - mesh = "pPlaneShape1" - converter = IECoreMaya.FromMayaShapeConverter.create( mesh, IECoreScene.MeshPrimitive.staticTypeId() ) - converter['extraColors'] = True - m = converter.convert() - self.assertEqual( m['cAlpha_Cs'].data, IECore.FloatVectorData( [ 0, 1, 0.8, 0.5 ] ) ) - self.assertEqual( m['cRGB_Cs'].data, IECore.Color3fVectorData( [ imath.Color3f(1,0,0), imath.Color3f(0), imath.Color3f(0,0,1), imath.Color3f(0,1,0) ] ) ) - self.assertEqual( m['cRGBA_Cs'].data, IECore.Color4fVectorData( [ imath.Color4f( 1, 1, 0, 0.5 ), imath.Color4f( 1, 1, 1, 1 ), imath.Color4f( 0, 1, 1, 1 ), imath.Color4f( 0, 1, 0, 0.5 ) ] ) ) - - def testCreases( self ): - - cube = maya.cmds.polyCube()[0] - fnMesh = OpenMaya.MFnMesh( IECoreMaya.dagPathFromString(cube) ) - - cornerIds = OpenMaya.MUintArray() - cornerIds.append( 5 ) - - cornerSharpnesses = OpenMaya.MDoubleArray() - cornerSharpnesses.append( 10 ) - - fnMesh.setCreaseVertices( cornerIds, cornerSharpnesses ) - - edgeIds = OpenMaya.MUintArray() - edgeIds.append( 0 ) - edgeIds.append( 1 ) - - edgeSharpnesses = OpenMaya.MDoubleArray() - edgeSharpnesses.append( 1 ) - edgeSharpnesses.append( 5 ) - - fnMesh.setCreaseEdges( edgeIds, edgeSharpnesses ) - - # store which vertices belong to the affected edges - - util = OpenMaya.MScriptUtil() - - vertices = [] - for edgeId in edgeIds : - - edgeVertices = util.asInt2Ptr() - fnMesh.getEdgeVertices( edgeId, edgeVertices ) - - vertices.append( util.getInt2ArrayItem( edgeVertices, 0, 0 ) ) - vertices.append( util.getInt2ArrayItem( edgeVertices, 0, 1 ) ) - - # convert and test - - cube = maya.cmds.listRelatives( cube, shapes=True )[0] - - converter = IECoreMaya.FromMayaMeshConverter.create( cube, IECoreScene.MeshPrimitive.staticTypeId() ) - cortexCube = converter.convert() - - self.assertEqual( cortexCube.cornerIds(), IECore.IntVectorData( [ 5 ] ) ) - self.assertEqual( cortexCube.cornerSharpnesses(), IECore.FloatVectorData( [ 10.0 ] ) ) - - self.assertEqual( cortexCube.creaseLengths(), IECore.IntVectorData( [ 2, 2 ] ) ) - self.assertEqual( cortexCube.creaseIds(), IECore.IntVectorData( vertices ) ) - self.assertEqual( cortexCube.creaseSharpnesses(), IECore.FloatVectorData( [ 1, 5 ] ) ) - - def testCreasesFromPlug( self ): - - self.writeTestScc() - - maya.cmds.file( new=True, f=True ) - node = maya.cmds.createNode( 'ieSceneShape' ) - maya.cmds.setAttr( node+'.file', FromMayaMeshConverterTest.__testFile, type='string' ) - maya.cmds.setAttr( node+".queryPaths[0]", "/1", type="string") - - # Test mesh coming out of the sceneshape - - converter = IECoreMaya.FromMayaPlugConverter.create( node + ".outObjects[0]" ) - cortexCube = converter.convert() - - self.assertEqual( cortexCube.numFaces(), 6 ) # checking that we got the right mesh - - self.assertEqual( cortexCube.creaseLengths(), IECore.IntVectorData( [ 2, 2, 2 ] ) ) - self.assertEqual( cortexCube.creaseIds(), IECore.IntVectorData( [ 3, 2, 2, 1, 5, 4 ] ) ) - self.assertEqual( cortexCube.creaseSharpnesses(), IECore.FloatVectorData( [ 1, 1, 5 ] ) ) - - # Test mesh flowing into the mesh node - - mesh = maya.cmds.createNode( 'mesh' ) - maya.cmds.connectAttr( node+".outObjects[0]", mesh + ".inMesh" ) - - converter = IECoreMaya.FromMayaPlugConverter.create( mesh + ".inMesh" ) - cortexCube = converter.convert() - - self.assertEqual( cortexCube.numFaces(), 6 ) # checking that we got the right mesh - - self.assertEqual( cortexCube.creaseLengths(), IECore.IntVectorData( [ 2, 2, 2 ] ) ) - self.assertEqual( cortexCube.creaseIds(), IECore.IntVectorData( [ 3, 2, 2, 1, 5, 4 ] ) ) - self.assertEqual( cortexCube.creaseSharpnesses(), IECore.FloatVectorData( [ 1, 1, 5 ] ) ) - - def tearDown( self ) : - - for f in [ FromMayaMeshConverterTest.__testFile ]: - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/FromMayaObjectConverterTest.py b/test/IECoreMaya/FromMayaObjectConverterTest.py deleted file mode 100644 index 83bdf23507..0000000000 --- a/test/IECoreMaya/FromMayaObjectConverterTest.py +++ /dev/null @@ -1,55 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaObjectConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - sphereTransform = maya.cmds.polySphere()[0] - sphereShape = maya.cmds.listRelatives( sphereTransform, shapes=True )[0] - - converter = IECoreMaya.FromMayaObjectConverter.create( sphereShape ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId(IECoreMaya.TypeId.FromMayaMeshConverter) ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sphereShape, IECoreScene.TypeId.MeshPrimitive ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId(IECoreMaya.TypeId.FromMayaMeshConverter) ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaParticleConverterTest.py b/test/IECoreMaya/FromMayaParticleConverterTest.py deleted file mode 100644 index a7e610f7fd..0000000000 --- a/test/IECoreMaya/FromMayaParticleConverterTest.py +++ /dev/null @@ -1,241 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya - -class FromMayaParticleConverterTest( IECoreMaya.TestCase ) : - - def testSimple( self ) : - - particle = maya.cmds.particle( n = 'particles' )[0] - particle = maya.cmds.listRelatives( particle, shapes = True )[0] - - converter = IECoreMaya.FromMayaShapeConverter.create( str( particle ), IECoreScene.PointsPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaParticleConverter ) ) ) - - particle = converter.convert() - - self.assertTrue( particle.isInstanceOf( IECoreScene.PointsPrimitive.staticTypeId() ) ) - self.assertTrue( particle.arePrimitiveVariablesValid() ) - self.assertEqual( particle.numPoints, maya.cmds.particle( 'particles', q = True, count = True ) ) - - self.assertTrue( "P" in particle ) - self.assertTrue( particle["P"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( particle["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( "velocity" in particle ) - self.assertTrue( particle["velocity"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( particle["velocity"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertTrue( "mass" in particle ) - self.assertTrue( "type" in particle ) - - def testEmitter( self ) : - - maya.cmds.emitter( speed = 2.00, rate = 1000, n = 'emitter' ) - particle = maya.cmds.particle( n = 'particles' )[0] - particle = maya.cmds.listRelatives( particle, shapes = True )[0] - maya.cmds.connectDynamic( 'particles', em = 'emitter' ) - - maya.cmds.addAttr( particle, ln="ieParticleAttributes", dt="string") - # ensure we can split on any of the following: ' ', ':', ',' - maya.cmds.setAttr( "{}.ieParticleAttributes".format(particle), "radiusPP=width,userScalar1PP:userScalar2PP userScalar3PP", type="string" ) - - maya.cmds.addAttr( particle, ln="radiusPP", dt="doubleArray") - maya.cmds.addAttr( particle, ln="radiusPP0", dt="doubleArray") - - maya.cmds.addAttr( particle, ln="userScalar1PP", dt="doubleArray") - maya.cmds.addAttr( particle, ln="userScalar1PP0", dt="doubleArray") - - maya.cmds.addAttr( particle, ln="userScalar2PP", dt="doubleArray") - maya.cmds.addAttr( particle, ln="userScalar2PP0", dt="doubleArray") - - maya.cmds.addAttr( particle, ln="userScalar3PP", dt="doubleArray") - maya.cmds.addAttr( particle, ln="userScalar3PP0", dt="doubleArray") - - maya.cmds.addAttr( particle, ln="userScalar4PP", dt="doubleArray") - maya.cmds.addAttr( particle, ln="userScalar4PP0", dt="doubleArray") - - for i in range( 0, 25 ) : - maya.cmds.currentTime( i ) - - converter = IECoreMaya.FromMayaShapeConverter.create( str( particle ), IECoreScene.PointsPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaParticleConverter ) ) ) - - particleConvert = converter.convert() - - self.assertTrue( particleConvert.isInstanceOf( IECoreScene.PointsPrimitive.staticTypeId() ) ) - self.assertTrue( particleConvert.arePrimitiveVariablesValid() ) - self.assertEqual( particleConvert.numPoints, maya.cmds.particle( 'particles', q = True, count = True ) ) - self.assertTrue( particleConvert.numPoints > 900 ) - self.assertTrue( particleConvert.numPoints < 1100 ) - self.assertTrue( "P" in particleConvert ) - self.assertTrue( particleConvert["P"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( particleConvert["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertTrue( "velocity" in particleConvert ) - self.assertTrue( particleConvert["velocity"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( particleConvert["velocity"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertTrue( "mass" in particleConvert ) - self.assertTrue( particleConvert["mass"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "width" in particleConvert ) - self.assertTrue( particleConvert["width"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertEqual( list( particleConvert["width"].data ), [ 2.0 * rad for rad in maya.cmds.getAttr( "{}.radiusPP".format( particle ) ) ] ) - self.assertTrue( "userScalar1PP" in particleConvert ) - self.assertTrue( particleConvert["userScalar1PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "userScalar2PP" in particleConvert ) - self.assertTrue( particleConvert["userScalar2PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "userScalar3PP" in particleConvert ) - self.assertTrue( particleConvert["userScalar3PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "type" in particleConvert ) - - # userScalar4PP is defined on the particles not specified in ieParticleAttributes and therefore shouldn't be converted - self.assertTrue( "userScalar4PP" not in particleConvert ) - - def testErrors( self ) : - - particle = maya.cmds.particle( n = 'particles' )[0] - particle = maya.cmds.listRelatives( particle, shapes = True )[0] - - self.assertFalse( IECoreMaya.FromMayaShapeConverter.create( str( particle ), IECoreScene.MeshPrimitive.staticTypeId() ) ) - - def testNParticle( self ): - import imath - - points = [ ( 0, 0, 0 ), ( 3, 5, 6 ), ( 5, 6, 7) , ( 9, 9, 9 ) ] - transform, nParticle = maya.cmds.nParticle( p=points ) - - maya.cmds.addAttr( nParticle, ln="ieParticleAttributes", dt="string" ) - - # ensure we can split on any of the following: ' ', ':', ',' - maya.cmds.setAttr( "{}.ieParticleAttributes".format(nParticle), "radiusPP=width,userScalar1PP:userScalar2PP userScalar3PP rgbPP=Cs rotationPP=orientation rotationPP=euler", type="string" ) - - maya.cmds.addAttr( nParticle, ln="radiusPP", dt="doubleArray" ) - maya.cmds.addAttr( nParticle, ln="radiusPP0", dt="doubleArray" ) - - maya.cmds.addAttr(nParticle, ln="rotationPP", dt="vectorArray") - maya.cmds.addAttr(nParticle, ln="rotationPP0", dt="vectorArray") - - maya.cmds.addAttr( nParticle, ln="userScalar1PP", dt="doubleArray" ) - maya.cmds.addAttr( nParticle, ln="userScalar1PP0", dt="doubleArray" ) - - maya.cmds.addAttr( nParticle, ln="userScalar2PP", dt="doubleArray" ) - maya.cmds.addAttr( nParticle, ln="userScalar2PP0", dt="doubleArray" ) - - maya.cmds.addAttr( nParticle, ln="userScalar3PP", dt="doubleArray" ) - maya.cmds.addAttr( nParticle, ln="userScalar3PP0", dt="doubleArray" ) - - maya.cmds.addAttr( nParticle, ln="userScalar4PP", dt="doubleArray" ) - maya.cmds.addAttr( nParticle, ln="userScalar4PP0", dt="doubleArray" ) - - converter = IECoreMaya.FromMayaShapeConverter.create( str( nParticle ), IECoreScene.PointsPrimitive.staticTypeId() ) - - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaParticleConverter ) ) ) - - nParticleConvert = converter.convert() - - self.assertTrue( nParticleConvert.isInstanceOf( IECoreScene.PointsPrimitive.staticTypeId() ) ) - self.assertTrue( nParticleConvert.arePrimitiveVariablesValid() ) - self.assertEqual( nParticleConvert.numPoints, maya.cmds.particle( nParticle, q = True, count = True ) ) - self.assertEqual( nParticleConvert.numPoints, 4 ) - self.assertTrue( "P" in nParticleConvert ) - self.assertTrue( nParticleConvert["P"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( nParticleConvert["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assertEqual( list( nParticleConvert["P"].data ), [ imath.V3f( *vec ) for vec in points ] ) - self.assertTrue( "velocity" in nParticleConvert ) - self.assertTrue( nParticleConvert["velocity"].data.isInstanceOf( IECore.TypeId.V3fVectorData ) ) - self.assertEqual( nParticleConvert["velocity"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - self.assertTrue( "mass" in nParticleConvert ) - self.assertTrue( nParticleConvert["mass"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "userScalar1PP" in nParticleConvert ) - self.assertTrue( nParticleConvert["userScalar1PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "userScalar2PP" in nParticleConvert ) - self.assertTrue( nParticleConvert["userScalar2PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - self.assertTrue( "userScalar3PP" in nParticleConvert ) - self.assertTrue( nParticleConvert["userScalar3PP"].data.isInstanceOf( IECore.TypeId.FloatVectorData ) ) - - # check radius to width conversion - self.assertTrue( "width" in nParticleConvert ) - self.assertEqual( list( nParticleConvert["width"].data ), [ 2.0 * rad for rad in maya.cmds.getAttr( "{}.radiusPP".format( nParticle ) ) ] ) - self.assertEqual( nParticleConvert["width"].data.typeId(), IECore.TypeId.FloatVectorData ) - - # check rotation - self.assertTrue( "orientation" in nParticleConvert ) - self.assertTrue( "euler" in nParticleConvert ) - self.assertEqual( nParticleConvert["orientation"].data.typeId(), IECore.TypeId.QuatfVectorData ) - self.assertEqual( nParticleConvert["euler"].data.typeId(), IECore.TypeId.V3fVectorData ) - - # check constant color - maya.cmds.setAttr( "{}.colorInput".format( nParticle ), 0 ) - maya.cmds.setAttr( "{}.color[0].color_Color".format( nParticle ), 0.1, 0.1, 0.1, type="double3" ) - nParticleConvert = converter.convert() - self.assertTrue( "Cs" in nParticleConvert ) - self.assertEqual( nParticleConvert["Cs"].data.typeId(), IECore.TypeId.Color3fData ) - self.assertEqual( nParticleConvert["Cs"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( nParticleConvert["Cs"].data, IECore.Color3fData( imath.Color3f( 0.1 ) ) ) - - # check per-particle color - maya.cmds.setAttr( "{}.colorInput".format( nParticle ), 1 ) - maya.cmds.setAttr( "{}.color[0].color_Color".format( nParticle ), 0.3, 0.3, 0.3, type="double3" ) - nParticleConvert = converter.convert() - self.assertTrue( "Cs" in nParticleConvert ) - self.assertTrue( nParticleConvert["Cs"].data.typeId(), IECore.TypeId.Color3fVectorData ) - self.assertEqual( nParticleConvert["Cs"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - self.assertEqual( nParticleConvert["Cs"].data[0], imath.Color3f( 0.3 ) ) - - # userScalar4PP is defined on the nParticle not specified in ieParticleAttributes and therefore shouldn't be converted - self.assertTrue( "userScalar4PP" not in nParticleConvert ) - - # test particleRenderType conversion - self.assertEqual( maya.cmds.getAttr( "{}.particleRenderType".format( nParticle ) ), 3 ) # points - self.assertEqual( nParticleConvert["type"].data, IECore.StringData( "disk" ) ) - - maya.cmds.setAttr( "{}.particleRenderType".format( nParticle ), 4 ) # spheres - nParticleConvert = converter.convert() - self.assertEqual( nParticleConvert["type"].data, IECore.StringData( "sphere" ) ) - - maya.cmds.setAttr( "{}.particleRenderType".format( nParticle ), 5 ) # sprites - nParticleConvert = converter.convert() - self.assertEqual( nParticleConvert["type"].data, IECore.StringData( "patch" ) ) - - maya.cmds.setAttr( "{}.particleRenderType".format( nParticle ), 1 ) # something else - nParticleConvert = converter.convert() - self.assertEqual( nParticleConvert["type"].data, IECore.StringData( "disk" ) ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaPlugConverterTest.py b/test/IECoreMaya/FromMayaPlugConverterTest.py deleted file mode 100644 index f200130a9b..0000000000 --- a/test/IECoreMaya/FromMayaPlugConverterTest.py +++ /dev/null @@ -1,251 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class FromMayaPlugConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - locator = maya.cmds.spaceLocator( position=( 1, 2, 3 ) )[0] - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".translateX" ) - self.assertTrue( converter ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".scaleX" ) - self.assertTrue( converter ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".scale" ) - self.assertTrue( converter ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString( locator + ".translateX" ) ) - self.assertTrue( converter ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaPlugConverter.staticTypeId() ) ) - - def testNumericConverterFactory( self ) : - - locator = maya.cmds.spaceLocator( position=( 1, 2, 3 ) )[0] - maya.cmds.addAttr(ln="testEnum", at="enum", en="A:B:C") - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".scaleX" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaNumericPlugConverterdd.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".scaleX", IECore.Data.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaNumericPlugConverterdd.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( locator + ".scaleX", IECore.FloatData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaNumericPlugConverterdf.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".testEnum", IECore.StringData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaEnumPlugConverterst.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".testEnum", IECore.ShortData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaEnumPlugConvertersh.staticTypeId() ) ) - - def testTypedConverterFactory( self ) : - - texture = maya.cmds.createNode( "file" ) - - converter = IECoreMaya.FromMayaPlugConverter.create( texture + ".fileTextureName" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaStringPlugConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( texture + ".fileTextureName", IECore.StringData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaStringPlugConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( texture + ".fileTextureName", IECore.Data.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaStringPlugConverter.staticTypeId() ) ) - - def testTransformationMatrix( self ) : - - locator = maya.cmds.spaceLocator( position=( 1, 2, 3 ) )[0] - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".worldMatrix", IECore.TransformationMatrixdData.staticTypeId() ) - self.assertTrue( converter ) - - transform = converter.convert() - self.assertTrue( transform.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - - def testPointArrayData( self ) : - - import itertools - import maya.OpenMaya as om - - data = [ [ 0.1, 0.2, 0.3, 1 ], [ 0.4, 0.5, 0.6, 1 ] ] - - locator = maya.cmds.spaceLocator()[0] - maya.cmds.addAttr( locator, ln="myPoints", dt="pointArray" ) - maya.cmds.setAttr( locator + "." + "myPoints", 2, *data, type="pointArray" ) - - sl = om.MSelectionList() - sl.add( locator ) - o = om.MObject() - sl.getDependNode( 0, o ) - fn = om.MFnDependencyNode( o ) - plug = fn.findPlug( "myPoints" ) - - converter = IECoreMaya.FromMayaPlugConverter.create( plug ) - self.assertTrue( converter ) - - converted = converter.convert() - self.assertTrue( converted.isInstanceOf( IECore.V3dVectorData.staticTypeId() ) ) - - for point, index in itertools.product( list(range( 2)), list(range( 3)) ): - self.assertAlmostEqual( converted[ point ][ index ], data[ point ][ index ] ) - - self.assertEqual( converted.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - - def testColorData( self ) : - import maya.OpenMaya as om - - locator = maya.cmds.spaceLocator()[0] - maya.cmds.addAttr( locator, longName="color", usedAsColor=True, attributeType="float3" ) - maya.cmds.addAttr( locator, longName="__colorR", parent="color", attributeType="float", defaultValue=1 ) - maya.cmds.addAttr( locator, longName="__colorG", parent="color", attributeType="float", defaultValue=2 ) - maya.cmds.addAttr( locator, longName="__colorB", parent="color", attributeType="float", defaultValue=3 ) - - sl = om.MSelectionList() - sl.add( locator ) - o = om.MObject() - sl.getDependNode( 0, o ) - fn = om.MFnDependencyNode( o ) - plug = fn.findPlug( "color" ) - - converter = IECoreMaya.FromMayaPlugConverter.create( plug ) - self.assertTrue( converter ) - - converted = converter.convert() - self.assertTrue( converted.isInstanceOf( IECore.Color3fData.staticTypeId() ) ) - self.assertTrue( list( converted.value ), [1, 2, 3] ) - - def testVectorArrayData( self ) : - - import itertools - import maya.OpenMaya as om - - data = [ [ 0.1, 0.2, 0.3 ], [ 0.4, 0.5, 0.6 ] ] - - locator = maya.cmds.spaceLocator()[0] - maya.cmds.addAttr( locator, ln="myVectors", dt="vectorArray" ) - maya.cmds.setAttr( locator + "." + "myVectors", 2, *data, type="vectorArray" ) - - sl = om.MSelectionList() - sl.add( locator ) - o = om.MObject() - sl.getDependNode( 0, o ) - fn = om.MFnDependencyNode( o ) - plug = fn.findPlug( "myVectors" ) - - converter = IECoreMaya.FromMayaPlugConverter.create( plug ) - self.assertTrue( converter ) - - converted = converter.convert() - self.assertTrue( converted.isInstanceOf( IECore.V3dVectorData.staticTypeId() ) ) - - for point, index in itertools.product( list(range( 2)), list(range( 3)) ): - self.assertAlmostEqual( converted[ point ][ index ], data[ point ][ index ] ) - - self.assertEqual( converted.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - - def testMultiPlug( self ): - - maya.cmds.polyPlane(sx=1, sy=1) - bs = maya.cmds.blendShape()[0] - multi = bs + '.inputTarget[0].baseWeights' - maya.cmds.setAttr(multi + '[1]', 8) - maya.cmds.setAttr(multi + '[3]', 9) - - converter = IECoreMaya.FromMayaPlugConverter.create(multi) - self.assertTrue( converter ) - data = converter.convert() - - self.assertEqual(data['indices'][0], 1) - self.assertEqual(data['indices'][1], 3) - self.assertEqual(data['data'][0], 8) - self.assertEqual(data['data'][1], 9) - - def testSingleNumericPlugs(self): - - locator = maya.cmds.spaceLocator()[0] - - attr = ("tBool", IECore.BoolData, True) - maya.cmds.addAttr(ln=attr[0], at="bool") - maya.cmds.setAttr(locator + '.' + attr[0], attr[2]) - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString(locator + '.' + attr[0]) ) - self.assertTrue(converter) - cValue = converter.convert() - self.assertTrue(isinstance(cValue, attr[1])) - self.assertAlmostEqual(cValue.value, attr[2]) - - attr = ("tFloat", IECore.FloatData, 0.123456) - maya.cmds.addAttr(ln=attr[0], at="float") - maya.cmds.setAttr(locator + '.' + attr[0], attr[2]) - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString(locator + '.' + attr[0]) ) - self.assertTrue(converter) - cValue = converter.convert() - self.assertTrue(isinstance(cValue, attr[1])) - self.assertAlmostEqual(cValue.value, attr[2]) - - attr = ("tDouble", IECore.DoubleData, 0.123456) - maya.cmds.addAttr(ln=attr[0], at="double") - maya.cmds.setAttr(locator + '.' + attr[0], attr[2]) - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString(locator + '.' + attr[0]) ) - self.assertTrue(converter) - cValue = converter.convert() - self.assertTrue(isinstance(cValue, attr[1])) - self.assertAlmostEqual(cValue.value, attr[2]) - - attr = ("tShort", IECore.ShortData, 1) - maya.cmds.addAttr(ln=attr[0], at="enum", en="A:B:C") - maya.cmds.setAttr(locator + '.' + attr[0], attr[2]) - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString(locator + '.' + attr[0]) ) - self.assertTrue(converter) - cValue = converter.convert() - self.assertTrue(isinstance(cValue, attr[1])) - self.assertAlmostEqual(cValue.value, attr[2]) - - # read enum as string - converter = IECoreMaya.FromMayaPlugConverter.create( IECoreMaya.plugFromString(locator + '.' + attr[0]), IECore.StringData.staticTypeId() ) - self.assertTrue(converter) - cValue = converter.convert() - self.assertTrue(isinstance(cValue, IECore.StringData)) - self.assertAlmostEqual(cValue.value, "B") - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaSkinClusterConverterTest.py b/test/IECoreMaya/FromMayaSkinClusterConverterTest.py deleted file mode 100644 index be3c2d893a..0000000000 --- a/test/IECoreMaya/FromMayaSkinClusterConverterTest.py +++ /dev/null @@ -1,105 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya - - -class FromMayaSkinClusterConverterTest( IECoreMaya.TestCase ) : - - def buildTestSetup( self ) : - # create simple hierarchy - j1 = maya.cmds.joint( n = 'joint1', p =[0,-2,0]) ; - j2 = maya.cmds.joint( n = 'joint2', p =[0,0,0]) ; - j3 = maya.cmds.joint( n = 'joint3', p =[0,2,0]) ; - - # create geo & bind it - geo = maya.cmds.polyCube( n = "myGeo", w = 1, h = 4, d = 1, sx = 1, sy = 3, sz = 1, ax = [ 0, 1, 0 ],cuv = 4, ch = 0) - maya.cmds.skinCluster( 'joint1', 'myGeo', dr=4.5) - - # get the skin cluster objectname - scName = maya.cmds.ls(type="skinCluster")[0] - return scName - - def testFactory( self ) : - - sc = self.buildTestSetup() - - converter = IECoreMaya.FromMayaObjectConverter.create( sc ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaSkinClusterConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sc, IECoreScene.SmoothSkinningData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaSkinClusterConverter.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaObjectConverter.create( sc, IECore.Data.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaSkinClusterConverter.staticTypeId() ) ) - - def testSimple( self ) : - sc = self.buildTestSetup() - # test factory - converter = IECoreMaya.FromMayaObjectConverter.create( sc ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.FromMayaSkinClusterConverter ) ) ) - # convert it - ssd = converter.convert() - self.assertTrue( ssd.isInstanceOf( IECoreScene.SmoothSkinningData.staticTypeId() ) ) - - - def testConvert ( self ): - #test if the data is valid - sc = self.buildTestSetup() - converter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - - converter.parameters()["influenceName"].setValue(IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full) - - ssd = converter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['|joint1', '|joint1|joint2', '|joint1|joint2|joint3'] ) ) - - converter.parameters()["influenceName"].setValue(IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial) - ssd = converter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2','joint3'] ) ) - - self.assertEqual( len(ssd.influencePose()), 3) - self.assertEqual( len(ssd.pointInfluenceCounts()), 16) - self.assertEqual( len(ssd.pointInfluenceIndices()), 32) - - ssd.validate() - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaSkinClusterWeightsConverterTest.py b/test/IECoreMaya/FromMayaSkinClusterWeightsConverterTest.py deleted file mode 100644 index 6ce051e044..0000000000 --- a/test/IECoreMaya/FromMayaSkinClusterWeightsConverterTest.py +++ /dev/null @@ -1,124 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import imath -import IECore -import IECore.RandomAlgo -import IECoreScene -import IECoreMaya - -class FromMayaSkinClusterWeightsConverterTest( IECoreMaya.TestCase ) : - - def buildTestSetup( self ) : - - maya.cmds.select(d=True) - j1 = maya.cmds.joint( p=(4,0,0)) - j2 = maya.cmds.joint( p=(-2,0,2)) - j3 = maya.cmds.joint( p=(0,0,-5)) - geo = maya.cmds.polyPlane(sx=4, sy=4, w=10, h=10)[0] - maya.cmds.select( j1,add=True ) - - sc = maya.cmds.skinCluster([j1, j2, j3], geo, toSelectedBones=True, bindMethod=0, skinMethod=0, normalizeWeights=1)[0] - return sc, geo, [j1,j2,j3] - - def setRandomWeights(self, seed, skinCluster, geo, joints): - r = imath.Rand32(seed) - weights = [] - for i in range( 0, 25 ) : - val = IECore.RandomAlgo.barycentricRandf( r ) - weights.extend([val[0], val[1], val[2]]) - maya.cmds.skinPercent( skinCluster, '%s.vtx[%d]' % ( geo, i ), transformValue=[(joints[0], val[0]), (joints[1], val[1]), (joints[2], val[2]) ]) - return weights - - def testUncompressedWeightsConverter(self): - - sc, geo, joints = self.buildTestSetup() - self.setRandomWeights(123, sc, geo, joints) - - weights = [] - for i in range( 0, 25 ) : - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[0], q=True)) - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[1], q=True)) - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[2], q=True)) - - c = IECoreMaya.FromMayaSkinClusterWeightsConverter.create(sc, IECore.TypeId.CompoundObject) - c["useCompression"].setTypedValue(False) - wConverted = c.convert() - - for i in range( 0, 25 ): - self.assertAlmostEqual(wConverted['pointInfluenceWeights'][i], weights[i]) - - for obj in joints + [geo, sc]: - if maya.cmds.objExists(obj): - maya.cmds.delete(obj) - - def testCompressedWeightsConverter(self): - - sc, geo, joints = self.buildTestSetup() - self.setRandomWeights(123, sc, geo, joints) - - w1 = [] - for i in range( 0, 25 ) : - w1.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[0], q=True)) - w1.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[1], q=True)) - w1.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[2], q=True)) - - c = IECoreMaya.FromMayaSkinClusterWeightsConverter.create(sc, IECore.TypeId.CompoundObject) - c["useCompression"].setTypedValue(True) - wConverted = c.convert() - - c2 = IECoreMaya.ToMayaSkinClusterWeightsConverter.create( wConverted ) - c2.convert( sc ) - - w2 = [] - for i in range( 0, 25 ) : - w2.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[0], q=True)) - w2.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[1], q=True)) - w2.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[2], q=True)) - - for i in range( 0, 25 ): - self.assertTrue( abs(w1[i] - w2[i]) < 1e-05 ) - - for obj in joints + [geo, sc]: - if maya.cmds.objExists(obj): - maya.cmds.delete(obj) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaTransformConverterTest.py b/test/IECoreMaya/FromMayaTransformConverterTest.py deleted file mode 100644 index b280ab5f3e..0000000000 --- a/test/IECoreMaya/FromMayaTransformConverterTest.py +++ /dev/null @@ -1,107 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreMaya - -class FromMayaTransformConverterTest( IECoreMaya.TestCase ) : - - def test( self ) : - - locatorTransform = maya.cmds.spaceLocator()[0] - - c = IECoreMaya.FromMayaDagNodeConverter.create( str( locatorTransform ), IECore.TypeId.TransformationMatrixdData ) - - self.assertEqual( IECoreMaya.TypeId.FromMayaTransformConverter, IECoreMaya.FromMayaTransformConverter.staticTypeId() ) - self.assertEqual( c.typeId(), IECoreMaya.FromMayaTransformConverter.staticTypeId() ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d() ) - - maya.cmds.xform( locatorTransform, translation=( 1, 2, 3 ) ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) - - group = maya.cmds.group( locatorTransform ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) - - maya.cmds.xform( group, translation=( 1, 0, 10 ) ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) - - c["space"].setValue( "Local" ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) - - # test custom space - customSpace = imath.M44f() - customSpace.setScale( imath.V3f( 0.5, 0.5, 0.5 ) ) - c["space"].setValue( "Custom" ) - c["customSpace"].setValue( IECore.M44fData( customSpace ) ) - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - expectedResult = imath.M44d( 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 4, 4, 26, 1 ) - self.assertEqual( t.value.transform, expectedResult ) - # sanity check: if we apply the custom space to the result we should get the world space result - self.assertEqual( t.value.transform * imath.M44d().scale( imath.V3d( 0.5, 0.5, 0.5 ) ), imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) - - locatorShape = maya.cmds.listRelatives( locatorTransform, children=True )[0] - - c = IECoreMaya.FromMayaTransformConverter( str( locatorShape ) ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) - - c["space"].setValue( "Local" ) - - t = c.convert() - self.assertTrue( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, imath.M44d() ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaUnitPlugConverterTest.py b/test/IECoreMaya/FromMayaUnitPlugConverterTest.py deleted file mode 100644 index 709c331e45..0000000000 --- a/test/IECoreMaya/FromMayaUnitPlugConverterTest.py +++ /dev/null @@ -1,122 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - - -class FromMayaUnitPlugConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - locator = maya.cmds.spaceLocator()[0] - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX" ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaUnitPlugConverterd.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX", IECore.DoubleData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaUnitPlugConverterd.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX", IECore.FloatData.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaUnitPlugConverterf.staticTypeId() ) ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX", IECore.Data.staticTypeId() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.FromMayaUnitPlugConverterd.staticTypeId() ) ) - - def testDistance( self ) : - - locator = maya.cmds.spaceLocator()[0] - maya.cmds.move( 1, 2, 3, locator ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX" ) - v = converter.convert() - self.assertTrue( v.isInstanceOf( IECore.DoubleData.staticTypeId() ) ) - self.assertEqual( v.value, 1 ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateY", IECore.FloatData.staticTypeId() ) - v = converter.convert() - self.assertTrue( v.isInstanceOf( IECore.FloatData.staticTypeId() ) ) - self.assertEqual( v.value, 2 ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateZ" ) - self.assertEqual( converter["distanceUnit"].getCurrentPresetName(), "Centimeters" ) - converter["distanceUnit"].setValue( "Meters" ) - v = converter.convert() - self.assertTrue( v.isInstanceOf( IECore.DoubleData.staticTypeId() ) ) - self.assertEqual( v.value, 0.03 ) - - def testAngle( self ) : - - locator = maya.cmds.spaceLocator()[0] - maya.cmds.setAttr(locator + '.rotateX', 90.0 ) - - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".rotateX" ) - self.assertEqual( converter["angleUnit"].getCurrentPresetName(), "Radians" ) - v = converter.convert() - self.assertTrue( v.isInstanceOf( IECore.DoubleData.staticTypeId() ) ) - self.assertAlmostEqual( v.value, IECore.degreesToRadians(90.0) ) - - converter["angleUnit"].setValue( "Degrees" ) - v = converter.convert() - self.assertTrue( v.isInstanceOf( IECore.DoubleData.staticTypeId() ) ) - self.assertAlmostEqual( v.value, 90.0 ) - - def testTime( self ) : - timeNode = maya.cmds.createNode('time') - converter = IECoreMaya.FromMayaPlugConverter.create( str( timeNode ) + ".outTime" ) - - maya.cmds.currentUnit( time='film' ) # set to 24fps - maya.cmds.setAttr(timeNode + '.outTime', 1.23 ) - time = maya.cmds.getAttr(timeNode + '.outTime') - self.assertAlmostEqual(converter.convert().value * 24.0, time) - - maya.cmds.currentUnit( time='show' ) # set to 48fps - maya.cmds.setAttr(timeNode + '.outTime', 1.23 ) - time = maya.cmds.getAttr(timeNode + '.outTime') - converter["timeUnit"].setValue( "Hours" ) - self.assertAlmostEqual(converter.convert().value * 48.0, time / (60**2) ) - - def testTypeIds( self ) : - - locator = maya.cmds.spaceLocator()[0] - converter = IECoreMaya.FromMayaPlugConverter.create( str( locator ) + ".translateX" ) - self.assertEqual( converter.typeId(), IECoreMaya.TypeId.FromMayaUnitPlugConverterd ) - self.assertEqual( converter.typeName(), "FromMayaUnitPlugConverterd" ) - - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ImageConverterTest.py b/test/IECoreMaya/ImageConverterTest.py deleted file mode 100644 index b935508046..0000000000 --- a/test/IECoreMaya/ImageConverterTest.py +++ /dev/null @@ -1,62 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreImage -import IECoreMaya - -class ImageConverterTest( IECoreMaya.TestCase ) : - - def test( self ) : - - imageA = IECore.Reader.create( "test/IECoreImage/data/exr/colorBarsWithAlpha.exr" ).read() - - toMaya = IECoreMaya.ToMayaImageConverter( imageA ) - - mImage = maya.OpenMaya.MImage() - toMaya.convert( mImage ) - - fromMaya = IECoreMaya.FromMayaImageConverter( mImage ) - imageB = fromMaya.convert() - - self.assertFalse( - - IECoreImage.ImageDiffOp()( imageA=imageA, imageB=imageB, maxError=1.0/256 ).value - - ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/LiveSceneTest.py b/test/IECoreMaya/LiveSceneTest.py deleted file mode 100644 index d09d66f143..0000000000 --- a/test/IECoreMaya/LiveSceneTest.py +++ /dev/null @@ -1,1500 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os - -import maya.cmds -import maya.OpenMaya as OpenMaya - -import IECore -import IECoreScene -import IECoreMaya - -import imath - -class LiveSceneTest( IECoreMaya.TestCase ) : - - __testFile = "test/liveSceneTest.scc" - - def setUp( self ) : - - maya.cmds.file( new=True, f=True ) - - def tearDown( self ) : - - if os.path.exists( LiveSceneTest.__testFile ) : - os.remove( LiveSceneTest.__testFile ) - - def testFileName( self ) : - - scene = IECoreMaya.LiveScene() - self.assertRaises( RuntimeError, scene.fileName ) - - def testChildNames( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - sphere2 = maya.cmds.polySphere( name="pSphere2" ) - sphere3 = maya.cmds.polySphere( name="pSphere3" ) - - maya.cmds.parent( "pSphere2", "pSphere1" ) - maya.cmds.parent( "pSphere3", "pSphere1" ) - - scene = IECoreMaya.LiveScene() - child = scene.child( "pSphere1" ) - - self.assertEqual( set( child.childNames() ), set( [ "pSphere2", "pSphere3" ] ) ) - - self.assertEqual( scene.child( "pSphere1" ).child( "pSphere2" ).childNames(), [] ) - - def testHasChild( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - sphere2 = maya.cmds.polySphere( name="pSphere2" ) - sphere3 = maya.cmds.polySphere( name="pSphere3" ) - - maya.cmds.parent( "pSphere2", "pSphere1" ) - maya.cmds.parent( "pSphere3", "pSphere1" ) - - scene = IECoreMaya.LiveScene() - child = scene.child( "pSphere1" ) - - self.assertEqual( scene.hasChild("pSphere1"), True ) - - self.assertEqual( child.hasChild("pSphere1Shape"), False ) - self.assertEqual( child.hasChild("pSphere2"), True ) - self.assertEqual( child.hasChild("pSphere3"), True ) - self.assertEqual( child.hasChild("pSphere3Shape"), False ) - self.assertEqual( child.hasChild("pSphere2Shape"), False ) - - self.assertEqual( child.hasChild("asdfasdf"), False ) - - - def testNames( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - sphere2 = maya.cmds.polySphere( name="pSphere2" ) - sphere3 = maya.cmds.polySphere( name="pSphere3" ) - - maya.cmds.parent( "pSphere2", "pSphere1" ) - maya.cmds.parent( "pSphere3", "pSphere1" ) - - scene = IECoreMaya.LiveScene() - - sphere1 = scene.child( "pSphere1" ) - - sphere2 = sphere1.child( "pSphere2" ) - - sphere3 = sphere1.child( "pSphere3" ) - - self.assertEqual( str( scene.name() ), "/" ) - self.assertEqual( str( sphere1.name() ), "pSphere1" ) - - self.assertEqual( str( sphere2.name() ), "pSphere2" ) - - self.assertEqual( str( sphere3.name() ), "pSphere3" ) - - def testPaths( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - sphere2 = maya.cmds.polySphere( name="pSphere2" ) - sphere3 = maya.cmds.polySphere( name="pSphere3" ) - - maya.cmds.parent( "pSphere2", "pSphere1" ) - maya.cmds.parent( "pSphere3", "pSphere1" ) - - scene = IECoreMaya.LiveScene() - - sphere1 = scene.child( "pSphere1" ) - - sphere2 = sphere1.child( "pSphere2" ) - - sphere3 = sphere1.child( "pSphere3" ) - - self.assertEqual( scene.path(), [] ) - self.assertEqual( sphere1.path(), [ "pSphere1" ] ) - - self.assertEqual( sphere2.path(), [ "pSphere1", "pSphere2" ] ) - - self.assertEqual( sphere3.path(), [ "pSphere1", "pSphere3" ] ) - - def testSceneMethod( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - sphere2 = maya.cmds.polySphere( name="pSphere2" ) - sphere3 = maya.cmds.polySphere( name="pSphere3" ) - - maya.cmds.parent( "pSphere2", "pSphere1" ) - maya.cmds.parent( "pSphere3", "pSphere1" ) - - scene = IECoreMaya.LiveScene() - - self.assertEqual( str( scene.scene( ["pSphere1"] ).name() ), "pSphere1" ) - - # does it still return absolute paths if we've gone to another location? - scene = scene.scene( ["pSphere1"] ) - self.assertEqual( str( scene.scene( [] ).name() ), "/" ) - self.assertEqual( str( scene.scene( ["pSphere1", "pSphere2"] ).name() ), "pSphere2" ) - self.assertEqual( str( scene.scene( ["pSphere1", "pSphere3"] ).name() ), "pSphere3" ) - - self.assertEqual( scene.scene( ["idontexist"], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - self.assertRaises( RuntimeError, IECore.curry( scene.scene, ["idontexist"] ) ) - - def testHasObject( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - scene = IECoreMaya.LiveScene() - child = scene.child( "pSphere1" ) - - self.assertEqual( scene.hasObject(), False ) - self.assertEqual( child.hasObject(), True ) - - def testReadTransformMethods( self ) : - - # create a little hierarchy - transfromythingy = maya.cmds.createNode( "transform", name="transform1" ) - maya.cmds.setAttr( "transform1.tx", 0.1 ) - maya.cmds.setAttr( "transform1.ty", 0.2 ) - maya.cmds.setAttr( "transform1.tz", 0.3 ) - - maya.cmds.setAttr( "transform1.rx", 0.1 ) - maya.cmds.setAttr( "transform1.ry", 0.2 ) - maya.cmds.setAttr( "transform1.rz", 0.3 ) - - maya.cmds.setAttr( "transform1.sx", 0.1 ) - maya.cmds.setAttr( "transform1.sy", 0.2 ) - maya.cmds.setAttr( "transform1.sz", 0.3 ) - - sphere = maya.cmds.polySphere( name="pSphere1" ) - maya.cmds.parent( "pSphere1", "transform1" ) - - maya.cmds.setAttr( "pSphere1.tx", 1 ) - maya.cmds.setAttr( "pSphere1.ty", 2 ) - maya.cmds.setAttr( "pSphere1.tz", 3 ) - - maya.cmds.setAttr( "pSphere1.rx", 10 ) - maya.cmds.setAttr( "pSphere1.ry", 20 ) - maya.cmds.setAttr( "pSphere1.rz", 30 ) - - maya.cmds.setAttr( "pSphere1.sx", 4 ) - maya.cmds.setAttr( "pSphere1.sy", 5 ) - maya.cmds.setAttr( "pSphere1.sz", 6 ) - - scene = IECoreMaya.LiveScene() - transformChild = scene.child( "transform1" ).child( "pSphere1" ) - - # test it returns the correct transform in local space - maya.cmds.currentTime( "0.0sec" ) - transform = transformChild.readTransform( 0 ).value - - import math - - self.assertAlmostEqual( transform.translate.x, 1, 5 ) - self.assertAlmostEqual( transform.translate.y, 2, 5 ) - self.assertAlmostEqual( transform.translate.z, 3, 5 ) - - self.assertAlmostEqual( transform.rotate.x * 180.0 / math.pi, 10.0, 5 ) - self.assertAlmostEqual( transform.rotate.y * 180.0 / math.pi, 20.0, 5 ) - self.assertAlmostEqual( transform.rotate.z * 180.0 / math.pi, 30.0, 5 ) - - self.assertAlmostEqual( transform.scale.x, 4, 5 ) - self.assertAlmostEqual( transform.scale.y, 5, 5 ) - self.assertAlmostEqual( transform.scale.z, 6, 5 ) - - self.assertEqual( transform.transform, transformChild.readTransformAsMatrix( 0 ) ) - - # Test rotation order - maya.cmds.setAttr( "pSphere1.rotateOrder", 2 ) - transform = transformChild.readTransform( 0 ).value - self.assertEqual( transform.rotate.order().name, 'ZXY' ) - - def testTimeException( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - maya.cmds.setKeyframe( "pSphere1", attribute="tx", t="0sec", v=1 ) - maya.cmds.setKeyframe( "pSphere1", attribute="ty", t="0sec", v=2 ) - maya.cmds.setKeyframe( "pSphere1", attribute="tz", t="0sec", v=3 ) - - maya.cmds.setKeyframe( "pSphere1", attribute="tx", t="1sec", v=4 ) - maya.cmds.setKeyframe( "pSphere1", attribute="ty", t="1sec", v=5 ) - maya.cmds.setKeyframe( "pSphere1", attribute="tz", t="1sec", v=6 ) - - scene = IECoreMaya.LiveScene() - transformChild = scene.child( "pSphere1" ) - - # move to frame -1: - maya.cmds.currentTime( -1 ) - - # test it returns the correct transform in local space - self.assertRaises( RuntimeError, IECore.curry( transformChild.readTransform, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( transformChild.readTransform, 0.5 ) ) - self.assertRaises( RuntimeError, IECore.curry( transformChild.readTransform, 1.0 ) ) - - - def testAnimatedTransform( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - maya.cmds.setKeyframe( "pSphere1", attribute="tx", t="0sec", v=1 ) - maya.cmds.setKeyframe( "pSphere1", attribute="ty", t="0sec", v=2 ) - maya.cmds.setKeyframe( "pSphere1", attribute="tz", t="0sec", v=3 ) - - maya.cmds.setKeyframe( "pSphere1", attribute="tx", t="1sec", v=4 ) - maya.cmds.setKeyframe( "pSphere1", attribute="ty", t="1sec", v=5 ) - maya.cmds.setKeyframe( "pSphere1", attribute="tz", t="1sec", v=6 ) - - scene = IECoreMaya.LiveScene() - transformChild = scene.child( "pSphere1" ) - - # test it returns the correct transform in local space - maya.cmds.currentTime( "0sec" ) - transform0 = transformChild.readTransform( 0 ).value - maya.cmds.currentTime( "0.5sec" ) - transform0_5 = transformChild.readTransform( 0.5 ).value - maya.cmds.currentTime( "1sec" ) - transform1 = transformChild.readTransform( 1 ).value - - self.assertEqual( transform0.translate, imath.V3d( 1, 2, 3 ) ) - - self.assertAlmostEqual( transform0_5.translate.x, 2.5, 5 ) - self.assertAlmostEqual( transform0_5.translate.y, 3.5, 5 ) - self.assertAlmostEqual( transform0_5.translate.z, 4.5, 5 ) - - self.assertEqual( transform1.translate, imath.V3d( 4, 5, 6 ) ) - - - def testDeletedDagPath( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - scene = IECoreMaya.LiveScene() - child = scene.child( "pSphere1" ) - - maya.cmds.delete( "pSphere1" ) - - self.assertRaises( RuntimeError, IECore.curry( child.child, "pSphereShape1" ) ) - self.assertRaises( RuntimeError, child.childNames ) - self.assertRaises( RuntimeError, IECore.curry( child.hasChild, "asdd" ) ) - self.assertRaises( RuntimeError, child.name ) - self.assertRaises( RuntimeError, child.path ) - self.assertRaises( RuntimeError, child.hasObject ) - self.assertRaises( RuntimeError, IECore.curry( child.readBound, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( child.readObject, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( child.readTransform, 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( child.readTransformAsMatrix, 0.0 ) ) - - # this doesn't need to throw an exception does it? - self.assertEqual( child.scene( [ "pSphere1", "pSphereShape1" ], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ), None ) - - # I guess this does... - self.assertRaises( RuntimeError, IECore.curry( child.scene, [ "pSphere1", "pSphereShape1" ] ) ) - - def testReadMesh( self ) : - - # create a cube: - maya.cmds.polyCube( name = "pCube1" ) - - # transform a bit, so we can check it's returning the mesh in world space: - maya.cmds.setAttr( "pCube1.tx", 0.1 ) - maya.cmds.setAttr( "pCube1.ty", 0.2 ) - maya.cmds.setAttr( "pCube1.tz", 0.3 ) - - maya.cmds.setAttr( "pCube1.rx", 10 ) - maya.cmds.setAttr( "pCube1.ry", 20 ) - maya.cmds.setAttr( "pCube1.rz", 30 ) - - scene = IECoreMaya.LiveScene() - cube = scene.child( "pCube1" ) - - # read mesh at time 0: - maya.cmds.currentTime( "0.0sec" ) - mesh = cube.readObject( 0 ) - - vertList = list( mesh["P"].data ) - - # check it's got the right length: - self.assertEqual( len( vertList ), 8 ) - - # check it's got the right verts: - self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, -0.5 ) ), 1 ) - - # check read primvars - self.assertEqual( mesh["P"], cube.readObjectPrimitiveVariables( [ "P" ], 0 )["P"] ) - - def testAnimatedMesh( self ) : - - cube = maya.cmds.polyCube( name = "pCube1" ) - - # create a skin cluster to animate vertex 0: - maya.cmds.select( cl=True ) - maya.cmds.select( "pCube1.vtx[0]", r=True ) - cluster = maya.mel.eval( 'newCluster "-envelope 1"' )[1] - - maya.cmds.setKeyframe( cluster, attribute="tx", t="0sec" ) - maya.cmds.setKeyframe( cluster, attribute="tx", t="1sec", v=-1 ) - - scene = IECoreMaya.LiveScene() - cube = scene.child( "pCube1" ) - - # read mesh at different times: - maya.cmds.currentTime( "0.0sec" ) - mesh0 = cube.readObject( 0 ) - maya.cmds.currentTime( "0.5sec" ) - mesh0_5 = cube.readObject( 0.5 ) - maya.cmds.currentTime( "1.0sec" ) - mesh1 = cube.readObject( 1 ) - - # have we moved vertex 0? - self.assertEqual( mesh0["P"].data[0].x, -0.5 ) - self.assertEqual( mesh0_5["P"].data[0].x, -1 ) - self.assertEqual( mesh1["P"].data[0].x, -1.5 ) - - def testReadBound( self ) : - - # create some cubes: - maya.cmds.polyCube( name = "pCube1" ) - maya.cmds.polyCube( name = "pCube2" ) - maya.cmds.polyCube( name = "pCube3" ) - maya.cmds.polyCube( name = "pCube4" ) - - maya.cmds.parent( "pCube2", "pCube1" ) - maya.cmds.parent( "pCube3", "pCube1" ) - - maya.cmds.setAttr( "pCube4.tx", 3 ) - maya.cmds.setAttr( "pCube4.ty", 3 ) - maya.cmds.setAttr( "pCube4.tz", 3 ) - - maya.cmds.setAttr( "pCube2.tx", 1 ) - maya.cmds.setAttr( "pCube2.ty", 1 ) - maya.cmds.setAttr( "pCube2.tz", 1 ) - - maya.cmds.setAttr( "pCube3.tx", -1 ) - maya.cmds.setAttr( "pCube3.ty", -1 ) - maya.cmds.setAttr( "pCube3.tz", -1 ) - - scene = IECoreMaya.LiveScene() - cube4Transform = scene.child( "pCube4" ) - cube1Transform = scene.child( "pCube1" ) - - maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( scene.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 3.5, 3.5, 3.5 ) ) ) - - self.assertEqual( cube4Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - - # check it's including its children: - self.assertEqual( cube1Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 1.5, 1.5, 1.5 ) ) ) - - maya.cmds.setAttr( "pCube1.tx", 1 ) - maya.cmds.setAttr( "pCube1.ty", 1 ) - maya.cmds.setAttr( "pCube1.tz", 1 ) - - # should be in object space!!! - self.assertEqual( cube1Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 1.5, 1.5, 1.5 ) ) ) - - cube2Transform = cube1Transform.child( "pCube2" ) - self.assertEqual( cube2Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - - cube3Transform = cube1Transform.child( "pCube3" ) - self.assertEqual( cube3Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - - def testAnimatedMeshBound( self ) : - - # Currently fails, because I'm pulling on the boundingBox plugs at arbitrary - # times, and that doesn't work, although it kind of should! - - maya.cmds.polyCube( name = "pCube2" ) - - # create a skin cluster to animate vertex 0: - maya.cmds.select( cl=True ) - maya.cmds.select( "pCube2.vtx[0]", r=True ) - cluster = maya.mel.eval( 'newCluster "-envelope 1"' )[1] - - maya.cmds.setKeyframe( cluster, attribute="tx", t="0sec" ) - maya.cmds.setKeyframe( cluster, attribute="tx", t="1sec", v=-1 ) - - scene = IECoreMaya.LiveScene() - transformChild = scene.child( "pCube2" ) - - maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( transformChild.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - maya.cmds.currentTime( "0.5sec" ) - self.assertEqual( transformChild.readBound( 0.5 ), imath.Box3d( imath.V3d( -1.0, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - maya.cmds.currentTime( "1.0sec" ) - self.assertEqual( transformChild.readBound( 1.0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - - def testAnimatedBound( self ) : - - # Currently fails, because I'm pulling on the boundingBox plugs at arbitrary - # times, and that doesn't work, although it kind of should! - - maya.cmds.polyCube( name = "pCube1" ) - maya.cmds.createNode( "transform", name = "pCube1Parent" ) - - maya.cmds.parent( "pCube1", "pCube1Parent" ) - - maya.cmds.setKeyframe( "pCube1", attribute="tx", t="0sec", v=0 ) - maya.cmds.setKeyframe( "pCube1", attribute="tx", t="1sec", v=-1 ) - - scene = IECoreMaya.LiveScene() - transformChild = scene.child( "pCube1Parent" ) - - maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( transformChild.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) - maya.cmds.currentTime( "0.5sec" ) - self.assertEqual( transformChild.readBound( 0.5 ), imath.Box3d( imath.V3d( -1.0, -0.5, -0.5 ), imath.V3d( 0.0, 0.5, 0.5 ) ) ) - maya.cmds.currentTime( "1.0sec" ) - self.assertEqual( transformChild.readBound( 1.0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( -0.5, 0.5, 0.5 ) ) ) - - def testMeshChange( self ) : - - sphere = maya.cmds.polySphere( name="pSphere1" ) - - scene = IECoreMaya.LiveScene() - sphere = scene.child( "pSphere1" ) - - maya.cmds.currentTime( "0.0sec" ) - mesh = sphere.readObject( 0 ) - - # should default to 382 verts: - self.assertEqual( len( mesh["P"].data ), 382 ) - - maya.cmds.setAttr( "polySphere1.subdivisionsAxis", 3 ) - maya.cmds.setAttr( "polySphere1.subdivisionsHeight", 3 ) - - mesh = sphere.readObject( 0 ) - - # should be 8 verts now: - self.assertEqual( len( mesh["P"].data ), 8 ) - - def testWriteExceptions( self ) : - - scene = IECoreMaya.LiveScene() - - self.assertRaises( RuntimeError, IECore.curry( scene.writeBound, imath.Box3d(), 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( scene.writeTransform, IECore.M44dData( imath.M44d() ), 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( scene.writeAttribute, "asdfs", IECore.BoolData( False ), 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( scene.writeObject, IECoreScene.SpherePrimitive(), 0.0 ) ) - - def testSceneShapeCustomReaders( self ): - - # make sure we are at time 0 - maya.cmds.currentTime( "0sec" ) - scene = IECoreMaya.LiveScene() - - envShape = str( IECoreMaya.FnSceneShape.create( "ieScene1" ).fullPathName() ) - envNode = 'ieScene1' - - envScene = scene.child( envNode ) - self.assertFalse( envScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - - maya.cmds.setAttr( envShape+'.file', 'test/IECore/data/sccFiles/environment.lscc',type='string' ) - - self.assertTrue( envScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - - spheresShape = str( IECoreMaya.FnSceneShape.create( "ieScene2" ).fullPathName() ) - spheresNode = 'ieScene2' - maya.cmds.setAttr( spheresShape+'.file', 'test/IECore/data/sccFiles/animatedSpheres.scc',type='string' ) - - self.assertEqual( set( scene.childNames() ).intersection([ envNode, spheresNode ]) , set( [ envNode, spheresNode ] ) ) - self.assertTrue( IECoreScene.LinkedScene.linkAttribute in envScene.attributeNames() ) - self.assertEqual( envScene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), IECore.CompoundData( { "fileName":IECore.StringData('test/IECore/data/sccFiles/environment.lscc'), "root":IECore.InternedStringVectorData() } ) ) - self.assertFalse( envScene.hasObject() ) - - spheresScene = scene.child( spheresNode ) - self.assertTrue( spheresScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( spheresScene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), IECore.CompoundData( { "fileName":IECore.StringData('test/IECore/data/sccFiles/animatedSpheres.scc'), "root":IECore.InternedStringVectorData() } ) ) - self.assertFalse( spheresScene.hasObject() ) - - # expand the scene - fnSpheres = IECoreMaya.FnSceneShape( spheresShape ) - fnSpheres.expandAll() - - self.assertFalse( spheresScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - leafScene = spheresScene.child("A").child("a") - self.assertTrue( leafScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( leafScene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), IECore.CompoundData( { "fileName":IECore.StringData('test/IECore/data/sccFiles/animatedSpheres.scc'), "root":IECore.InternedStringVectorData([ 'A', 'a' ]) } ) ) - self.assertFalse( leafScene.hasObject() ) - - # expand scene to meshes - fnSpheres.convertAllToGeometry() - self.assertFalse( leafScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertTrue( leafScene.hasObject() ) - self.assertTrue( isinstance( leafScene.readObject(0), IECoreScene.MeshPrimitive) ) - - # test time remapped scene readers... - spheresShape = str( maya.cmds.createNode( 'ieSceneShape' ) ) - maya.cmds.setAttr( spheresShape+'.file', 'test/IECore/data/sccFiles/animatedSpheres.scc',type='string' ) - maya.cmds.setAttr( spheresShape+'.time', 24.0*10 ) - - spheresScene = scene.child( 'ieScene3' ) - - self.assertTrue( spheresScene.hasAttribute( IECoreScene.LinkedScene.linkAttribute ) ) - self.assertEqual( spheresScene.readAttribute( IECoreScene.LinkedScene.linkAttribute, 0 ), IECore.CompoundData( { "fileName":IECore.StringData('test/IECore/data/sccFiles/animatedSpheres.scc'), "root":IECore.InternedStringVectorData(), "time":IECore.DoubleData(10.0) } ) ) - - def testReadRootAttribute( self ): - - maya.cmds.file( new=True, f=True ) - # make sure we are at time 0 - maya.cmds.currentTime( "0sec" ) - scene = IECoreMaya.LiveScene() - - # tests a bug where calling attributeNames at the root raised an exception - scene.attributeNames() - - def testTags( self ) : - - t = maya.cmds.createNode( "transform" ) - maya.cmds.addAttr( t, ln="ieTags", dt="string" ) - maya.cmds.setAttr( t + ".ieTags", "pizza burger", type="string" ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - - self.assertEqual( set( transformScene.readTags() ), set( [IECore.InternedString("pizza"), IECore.InternedString("burger") ] ) ) - - def testCustomTags( self ) : - - t = maya.cmds.createNode( "transform" ) - maya.cmds.select( clear = True ) - sphere = maya.cmds.polySphere( name="pSphere" ) - - doTest = True - - def hasMyTags( node, tag, tagFilter ) : - #'archivable' should be on all transforms and 'renderable' only at shape transforms. - - if not doTest: - return False - - if tag not in ( "renderable", "archivable" ) : - return False - - if tag == "archivable" : - return True - - dagPath = IECoreMaya.StringUtil.dagPathFromString(node) - try: - dagPath.extendToShapeDirectlyBelow(0) - except: - return False - - if not ( tagFilter & IECoreScene.SceneInterface.TagFilter.LocalTag ) : - return False - - if dagPath.apiType() != maya.OpenMaya.MFn.kMesh : - return False - - return dagPath.fullPathName().endswith("Shape") - - def readMyTags( node, tagFilter ) : - #'archivable' should be on all transforms and 'renderable' only at shape transforms. - - if not doTest: - return [] - - result = [ "archivable" ] - - dagPath = IECoreMaya.StringUtil.dagPathFromString(node) - try: - dagPath.extendToShapeDirectlyBelow(0) - except: - return result - - if tagFilter & IECoreScene.SceneInterface.TagFilter.LocalTag and dagPath.apiType() == maya.OpenMaya.MFn.kMesh : - result.append( "renderable" ) - - return result - - IECoreMaya.LiveScene.registerCustomTags( hasMyTags, readMyTags ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - sphereScene = scene.child('pSphere') - self.assertFalse( scene.hasTag( 'renderable' ) ) - self.assertFalse( scene.hasTag( 'archivable' ) ) - self.assertEqual( scene.readTags(), [] ) - self.assertFalse( transformScene.hasTag( 'renderable' ) ) - self.assertTrue( transformScene.hasTag( 'archivable' ) ) - self.assertEqual( transformScene.readTags(), [ IECore.InternedString('archivable') ] ) - self.assertEqual( set(sphereScene.readTags()), set([ IECore.InternedString('renderable'), IECore.InternedString('archivable') ]) ) - self.assertEqual( set(sphereScene.readTags( IECoreScene.SceneInterface.TagFilter.EveryTag )), set([ IECore.InternedString('renderable'), IECore.InternedString('archivable') ]) ) - self.assertEqual( sphereScene.readTags( IECoreScene.SceneInterface.TagFilter.AncestorTag ), [ IECore.InternedString('archivable') ] ) - self.assertTrue( sphereScene.hasTag( 'renderable') ) - self.assertTrue( sphereScene.hasTag( 'archivable') ) - - # Disable custom tag functions so they don't mess with other tests - doTest = False - - def testAttributes( self ) : - - maya.cmds.currentTime( "0sec" ) - t = maya.cmds.createNode( "transform", name="t1" ) - - maya.cmds.addAttr( t, ln="ieAttr_bool", at="bool" ) - maya.cmds.addAttr( t, ln="ieAttr_float", at="float" ) - maya.cmds.addAttr( t, ln="ieAttr_double", at="double" ) - maya.cmds.addAttr( t, ln="ieAttr_doubleAngle", at="doubleAngle" ) - maya.cmds.addAttr( t, ln="ieAttr_doubleLinear", at="doubleLinear" ) - maya.cmds.addAttr( t, ln="ieAttr_message", at="message" ) - maya.cmds.addAttr( t, ln="ieAttr_time", at="time" ) - maya.cmds.addAttr( t, ln="ieAttr_fltMatrix", at="fltMatrix" ) - maya.cmds.addAttr( t, ln="ieAttr_string", dt="string" ) - maya.cmds.addAttr( t, ln="ieAttr_with__namespace", dt="string" ) - - maya.cmds.addAttr( t, ln="ieAttr_enum", at="enum", en="ABC:DEF:" ) - maya.cmds.addAttr( t, ln="ieAttr_enumAsString", at="enum", en="GHI:JKL:" ) - - # add ieConvertToStringData category - p = IECoreMaya.plugFromString( t+'.ieAttr_enumAsString' ) - fn = OpenMaya.MFnEnumAttribute( p.attribute() ) - fn.addToCategory( IECoreMaya.FromMayaEnumPlugConverterst.convertToStringCategory ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - - self.assertEqual( set( transformScene.attributeNames()), - set( [ - "scene:visible", - "user:bool", - "user:enum", - "user:enumAsString", - "user:float", - "user:double", - "user:doubleAngle", - "user:doubleLinear", - "user:message", - "user:time", - "user:fltMatrix", - "user:string", - "user:with:namespace" - ] ) - ) - - self.assertTrue( isinstance( transformScene.readAttribute("user:bool",0), IECore.BoolData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:enum",0), IECore.ShortData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:enumAsString",0), IECore.StringData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:float",0), IECore.FloatData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:double",0), IECore.DoubleData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:doubleAngle",0), IECore.DoubleData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:doubleLinear",0), IECore.DoubleData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:message",0), IECore.NullObject ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:time",0), IECore.DoubleData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:fltMatrix",0), IECore.M44dData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:string",0), IECore.StringData ) ) - self.assertTrue( isinstance( transformScene.readAttribute("user:with:namespace",0), IECore.StringData ) ) - - def testHasAttribute( self ): - maya.cmds.currentTime( '0sec' ) - t = maya.cmds.createNode( 'transform', name='t1' ) - maya.cmds.addAttr( t, longName='ieAttr_bool', attributeType='bool' ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child( str( t ) ) - - self.assertTrue( transformScene.hasAttribute( 'user:bool' ) ) - - def testCustomAttributes( self ) : - - t = maya.cmds.createNode( "transform" ) - maya.cmds.select( clear = True ) - sphere = maya.cmds.polySphere( name="pSphere" ) - maya.cmds.currentTime( "0sec" ) - - doTest = True - - def myAttributeNames( node ) : - - if not doTest: - return [] - if not node: - return ["root"] - - dagPath = IECoreMaya.StringUtil.dagPathFromString(node) - try: - dagPath.extendToShapeDirectlyBelow(0) - except: - return ["transformAttribute"] - - if dagPath.apiType() != maya.OpenMaya.MFn.kMesh : - return [] - - return ["shapeAttribute"] - - def readMyAttribute( node, attr ) : - - if not doTest: - return None - - if not node : - if attr == "root": - return IECore.BoolData( True ) - return None - - dagPath = IECoreMaya.StringUtil.dagPathFromString(node) - try: - dagPath.extendToShapeDirectlyBelow(0) - except: - if attr == "shapeAttribute": - return None - return IECore.FloatData( 5 ) - - if attr == "transformAttribute": - return None - - if dagPath.apiType() != maya.OpenMaya.MFn.kMesh : - return None - - return IECore.StringData("mesh") - - try: - IECoreMaya.LiveScene.registerCustomAttributes( myAttributeNames, readMyAttribute ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - sphereScene = scene.child('pSphere') - self.assertEqual( set( scene.attributeNames() ), set( [ "scene:visible", "root" ] ) ) - self.assertEqual( scene.readAttribute("anyAttr", 0.0), IECore.NullObject.defaultNullObject() ) - self.assertEqual( scene.readAttribute("scene:visible", 0.0), IECore.BoolData(True) ) - self.assertEqual( scene.readAttribute("root", 0.0), IECore.BoolData(True) ) - - self.assertEqual( transformScene.attributeNames(), [ IECore.InternedString("scene:visible"), IECore.InternedString("transformAttribute") ] ) - self.assertEqual( transformScene.hasAttribute("shapeAttribute"), False ) - self.assertEqual( transformScene.readAttribute("shapeAttribute", 0.0), IECore.NullObject.defaultNullObject() ) - self.assertEqual( transformScene.readAttribute( "transformAttribute", 0.0), IECore.FloatData(5) ) - self.assertEqual( sphereScene.attributeNames(), [ IECore.InternedString("scene:visible"), IECore.InternedString('shapeAttribute') ] ) - self.assertEqual( sphereScene.readAttribute( "shapeAttribute", 0.0), IECore.StringData("mesh") ) - - finally: - # Disable custom attribute functions so they don't mess with other tests - doTest = False - - def testCustomAttributesMightHave( self ) : - - t = maya.cmds.createNode( "transform" ) - maya.cmds.select( clear = True ) - sphere = maya.cmds.polySphere( name="pSphere" ) - maya.cmds.currentTime( "0sec" ) - - attrFnResult = [] - mightHaveFnResult = [] - - doTest = True - - def readMyAttribute( node, attr ) : - return None - - def myAttributeNames( node ) : - if not doTest: - return [] - - attrFnResult.append( node ) - - return [ "mightHaveAttribute2" ] - - def myAttributeMightHave( node, attr ) : - if not doTest: - return False - - mightHaveFnResult.append( ( node, attr ) ) - - return attr in [ "mightHaveAttribute1", "mightHaveAttribute2" ] - - try: - IECoreMaya.LiveScene.registerCustomAttributes( myAttributeNames, readMyAttribute, myAttributeMightHave ) - - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - - self.assertEqual( transformScene.hasAttribute("nonExistentCustomAttribute"), False ) - self.assertEqual( mightHaveFnResult[0][1], "nonExistentCustomAttribute" ) # myAttributeMightHave() should always be called when specified. - self.assertEqual( len( attrFnResult ), 0 ) # myAttributeNames() should not have been called because myAttributeMightHave had returned False. - - self.assertEqual( transformScene.hasAttribute("mightHaveAttribute1"), False ) - self.assertEqual( mightHaveFnResult[1][1], "mightHaveAttribute1" ) - self.assertEqual( len( attrFnResult ), 1 ) # myAttributeNames() should have been called because myAttributeMightHave had returned True. - - self.assertEqual( transformScene.hasAttribute("mightHaveAttribute2"), True ) - self.assertEqual( mightHaveFnResult[2][1], "mightHaveAttribute2" ) - self.assertEqual( len( attrFnResult ), 2 ) - - finally: - # Disable custom attribute functions so they don't mess with other tests - doTest = False - - def testNoDuplicateAttributeNames( self ) : - - t = maya.cmds.createNode( "transform" ) - maya.cmds.currentTime( "0sec" ) - - maya.cmds.addAttr( t, ln="ieAttr_test", at="bool" ) - - doDuplicateNameTest = True - - def myAttributeNames( node ): - if not doDuplicateNameTest: - return [] - return["user:test"] - - def readMyAttribute( node, attr ): - if not doDuplicateNameTest: - return None - if attr == "user:test": - return IECore.IntData( 1 ) - - IECoreMaya.LiveScene.registerCustomAttributes( myAttributeNames, readMyAttribute ) - - try: - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - - # we've specified an attribute called "user:test" in two ways - once through an ieAttr_, - # once through a custom reader. The name "user:test" should only appear once: - self.assertEqual( len( transformScene.attributeNames() ), 2 ) - self.assertEqual( set( transformScene.attributeNames() ), set( ["scene:visible", "user:test"] ) ) - - # The ieAttr_ should override the custom reader - self.assertTrue( isinstance( transformScene.readAttribute( "user:test", 0 ), IECore.BoolData ) ) - finally: - doDuplicateNameTest = False - - def testCustomAttributePrecedence( self ) : - - doCustomAttributePrecedenceTest = True - - t = maya.cmds.createNode( "transform" ) - maya.cmds.currentTime( "0sec" ) - - def myAttributeNames1( node ): - if not doCustomAttributePrecedenceTest: - return [] - return["test"] - - def readMyAttribute1( node, attr ): - if not doCustomAttributePrecedenceTest: - return None - if attr == "test": - return IECore.IntData( 1 ) - - def myAttributeNames2( node ): - if not doCustomAttributePrecedenceTest: - return [] - return["test"] - - def readMyAttribute2( node, attr ): - if not doCustomAttributePrecedenceTest: - return None - if attr == "test": - return IECore.IntData( 2 ) - - IECoreMaya.LiveScene.registerCustomAttributes( myAttributeNames1, readMyAttribute1 ) - IECoreMaya.LiveScene.registerCustomAttributes( myAttributeNames2, readMyAttribute2 ) - - try: - scene = IECoreMaya.LiveScene() - transformScene = scene.child(str(t)) - - # The second custom reader we registered should have taken precedence: - self.assertEqual( transformScene.readAttribute( "test", 0 ), IECore.IntData(2) ) - finally: - doCustomAttributePrecedenceTest = False - - - def testSceneVisible( self ) : - - maya.cmds.createNode( "transform", name = "t1" ) - - scene = IECoreMaya.LiveScene() - t1 = scene.child( "t1" ) - - # Root should always be visible - self.assertEqual( scene.hasAttribute( "scene:visible" ), True ) - self.assertIn( 'scene:visible', scene.attributeNames() ) - self.assertEqual( scene.readAttribute( "scene:visible", 0 ), IECore.BoolData( True ) ) - - # Test visibility on transform - self.assertEqual( t1.attributeNames(), ["scene:visible"] ) - self.assertEqual( t1.hasAttribute( "scene:visible" ), True ) - self.assertEqual( t1.readAttribute( "scene:visible", 0 ), IECore.BoolData( True ) ) - - maya.cmds.setAttr( "t1.visibility", False ) - self.assertEqual( t1.readAttribute( "scene:visible", 0 ), IECore.BoolData( False ) ) - - # Test override of maya visibility with visibilityOverrideName attribute - maya.cmds.addAttr( "t1", ln=IECoreMaya.LiveScene.visibilityOverrideName, at="bool" ) - maya.cmds.setAttr( "t1." + IECoreMaya.LiveScene.visibilityOverrideName.value(), True ) - self.assertEqual( t1.readAttribute( "scene:visible", 0 ), IECore.BoolData( True ) ) - - maya.cmds.setAttr( "t1.visibility", True ) - maya.cmds.setAttr( "t1." + IECoreMaya.LiveScene.visibilityOverrideName.value(), False ) - self.assertEqual( t1.readAttribute( "scene:visible", 0 ), IECore.BoolData( False ) ) - - def testSceneShapeVisible( self ) : - - # make sure we are at time 0 - maya.cmds.currentTime( "0sec" ) - scene = IECoreMaya.LiveScene() - - envShape = str( IECoreMaya.FnSceneShape.create( "ieScene1" ).fullPathName() ) - envNode = 'ieScene1' - - envScene = scene.child( envNode ) - self.assertTrue( IECore.InternedString( "scene:visible" ) in envScene.attributeNames() ) - - maya.cmds.setAttr( envShape+'.file', 'test/IECore/data/sccFiles/animatedSpheres.scc',type='string' ) - self.assertTrue( IECore.InternedString( "scene:visible" ) in envScene.attributeNames() ) - - maya.cmds.setAttr( "ieScene1.visibility", False ) - self.assertEqual( envScene.readAttribute( "scene:visible", 0 ), IECore.BoolData( False ) ) - - maya.cmds.setAttr( "ieScene1.visibility", True ) - self.assertEqual( envScene.readAttribute( "scene:visible", 0 ), IECore.BoolData( True ) ) - - # This test asserts that shape nodes no longer affect the transform visibility - maya.cmds.setAttr( envShape + ".visibility", False ) - self.assertEqual( envScene.readAttribute( "scene:visible", 0 ), IECore.BoolData( True ) ) - - def testMultiCurves( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - maya.cmds.curve( d=1, p=[ ( 0, 0, 0 ), ( 1, 0, 0 ) ], k=( 0, 1 ), n="curve1" ) - maya.cmds.curve( d=1, p=[ ( 0, 0, 0 ), ( 0, 0, 1 ) ], k=( 0, 1 ), n="curve2" ) - maya.cmds.curve( d=1, p=[ ( 0, 0, 0 ), ( 0, 0, 1 ) ], k=( 0, 1 ), n="curve2" ) - - maya.cmds.select( "curveShape1", "curveShape2", "curveShape3", "sharedParent") - maya.cmds.parent( s=True, r=True ) - - maya.cmds.setAttr( "curveShape3.intermediateObject", 1 ) - - scene = IECoreMaya.LiveScene() - scene = scene.child('sharedParent') - maya.cmds.currentTime( "0.0sec" ) - mergedCurves = scene.readObject( 0 ) - self.assertEqual( mergedCurves.numCurves(), 2 ) - - def testMultiCurvesWithDifferentDegrees( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - maya.cmds.curve( d=3, p=[ ( 0, 0, 0 ), ( 1, 0, 0 ), ( 2, 0, 0 ), ( 3, 0, 0 ) ], k=( 0, 0, 0, 1, 1, 1 ), n="curve1" ) - maya.cmds.curve( d=1, p=[ ( 0, 0, 0 ), ( 0, 0, 1 ) ], k=( 0, 1 ), n="curve2" ) - maya.cmds.curve( d=1, p=[ ( 0, 0, 0 ), ( 0, 0, 1 ) ], k=( 0, 1 ), n="curve3" ) - - maya.cmds.select( "curveShape1", "curveShape2", "curveShape3", "sharedParent") - maya.cmds.parent( s=True, r=True ) - - scene = IECoreMaya.LiveScene() - scene = scene.child('sharedParent') - maya.cmds.currentTime( "0.0sec" ) - curve = scene.readObject( 0 ) - self.assertEqual( curve.numCurves(), 1 ) # Still has object but curves are not merged. - - def testMultiCurvesWithDifferentForms( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - maya.cmds.curve( d=3, per=True, p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9), (0, 0, 0), (3, 5, 6), (5, 6, 7)], k=[-2,-1,0,1,2,3,4,5,6], n="curve1" ) - maya.cmds.curve( d=3, p=[ ( 0, 0, 0 ), ( 1, 0, 0 ), ( 2, 0, 0 ), ( 3, 0, 0 ) ], k=( 0, 0, 0, 1, 1, 1 ), n="curve2" ) - maya.cmds.curve( d=3, p=[ ( 0, 0, 0 ), ( 1, 0, 0 ), ( 2, 0, 0 ), ( 3, 0, 0 ) ], k=( 0, 0, 0, 1, 1, 1 ), n="curve3" ) - - maya.cmds.select( "curveShape1", "curveShape2", "curveShape3", "sharedParent") - maya.cmds.parent( s=True, r=True ) - - scene = IECoreMaya.LiveScene() - scene = scene.child('sharedParent') - maya.cmds.currentTime( "0.0sec" ) - curve = scene.readObject( 0 ) - self.assertEqual( curve.numCurves(), 1 ) # Still has object but curves are not merged. - - def testMultiMeshes( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - maya.cmds.polyPyramid() - maya.cmds.polyPyramid() - maya.cmds.polyPyramid() - - maya.cmds.select( "pPyramidShape1", "pPyramidShape2", "pPyramidShape3", "sharedParent" ) - maya.cmds.parent( s=True, r=True ) - - maya.cmds.setAttr( "pPyramidShape3.intermediateObject", 1 ) - - scene = IECoreMaya.LiveScene() - scene = scene.child('sharedParent') - maya.cmds.currentTime( "0.0sec" ) - mergedMeshes = scene.readObject( 0 ) - self.assertEqual( mergedMeshes.numFaces(), 10 ) - - def testSetsWithoutExportAttributeAreNotExported( self ) : - maya.cmds.createNode( "transform", name="sharedParent" ) - - sphere = maya.cmds.polySphere( name="pSphere" )[0] - - maya.cmds.select( sphere ) - maya.cmds.sets(name="mySet") - - root = IECoreMaya.LiveScene() - tags = root.child('pSphere').readTags() - - self.assertEqual( len(tags), 0) - - - def testSetWithExportSetToFalseIsNotExported( self ) : - maya.cmds.createNode( "transform", name="sharedParent" ) - - sphere = maya.cmds.polySphere( name="pSphere" )[0] - - maya.cmds.select( sphere ) - maya.cmds.sets(name="mySet") - - maya.cmds.addAttr("mySet", longName="ieExport", at="bool") - maya.cmds.setAttr("mySet.ieExport", False) - - root = IECoreMaya.LiveScene() - tags = root.child('pSphere').readTags() - - self.assertEqual( len(tags), 0) - - def testConvertsMayaSetsToTags( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - sphere = maya.cmds.polySphere( name="pSphere" )[0] - - maya.cmds.select( sphere ) - maya.cmds.sets(name="mySet") - - maya.cmds.addAttr("mySet", longName="ieExport", at="bool") - maya.cmds.setAttr("mySet.ieExport", True) - - root = IECoreMaya.LiveScene() - tags = root.child('pSphere').readTags() - - self.assertEqual( len(tags), 1) - self.assertEqual( tags[0], "mySet") - - def testConvertsMayaSetsOfSetsToTags( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - sphere = maya.cmds.polySphere( name="pSphere" )[0] - - maya.cmds.select( sphere ) - maya.cmds.sets(name="mySet") - - maya.cmds.addAttr("mySet", longName="ieExport", at="bool") - maya.cmds.setAttr("mySet.ieExport", True) - - maya.cmds.select( "mySet" ) - maya.cmds.sets(name="mySet2") - - maya.cmds.addAttr("mySet2", longName="ieExport", at="bool") - maya.cmds.setAttr("mySet2.ieExport", True) - - root = IECoreMaya.LiveScene() - tags = root.child('pSphere').readTags() - - self.assertEqual( len(tags), 2) - self.assertEqual( set(tags), set([IECore.InternedString("mySet"), IECore.InternedString("mySet2")])) - - - def testOnlyObjectInSetIsExported( self ) : - - maya.cmds.createNode( "transform", name="sharedParent" ) - - s = maya.cmds.polySphere( name="pSphere" )[0] - - maya.cmds.select( "{0}.f[1]".format(s) ) - maya.cmds.sets(name="mySet") - - maya.cmds.addAttr("mySet", longName="ieExport", at="bool") - maya.cmds.setAttr("mySet.ieExport", True) - - root = IECoreMaya.LiveScene() - tags = root.child(IECore.InternedString(str(s))).readTags() - - self.assertEqual( len(tags), 0) - - def testMayaInstancerIsExported( self ): - - def makeScene(): - - maya.cmds.polyCube() - maya.cmds.polySphere() - - maya.cmds.particle( p = [[4, 0, 0], [4, 4, 0], [0, 4, 0], [0, 0, 0]], c = 1 ) - maya.cmds.addAttr( "particleShape1", ln = "rotationPP", dt = "vectorArray" ) - maya.cmds.addAttr( "particleShape1", ln = "instancePP", dt = "doubleArray" ) - maya.cmds.select( ["particle1", "pCube1", "pSphere1"], r = True ) - maya.cmds.particleInstancer( addObject = True, object = ["pCube1","pSphere1"] ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", rotation = "rotationPP" ) - maya.cmds.particleInstancer( "particleShape1", e = True, name = "instancer1", objectIndex = "instancePP" ) - - maya.cmds.setAttr( "particleShape1.rotationPP", 4, ( 45, 0, 0 ), ( 0, 45, 0 ), ( 0, 0, 45 ), ( 45, 45, 0 ), type = "vectorArray" ) - maya.cmds.setAttr( "particleShape1.instancePP", [0, 1, 0, 1], type = "doubleArray" ) - - makeScene() - - maya.cmds.currentTime( "0.0sec" ) - - root = IECoreMaya.LiveScene() - self.assertTrue( 'instancer1' in root.childNames() ) - - instancer1 = root.child("instancer1") - - self.assertTrue( instancer1.hasObject() ) - - convertedPoints = instancer1.readObject(0.0) - self.assertTrue( convertedPoints.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) - self.assertEqual( convertedPoints.numPoints, 4) - - def testRecursiveGeoConvert( self ): - """Tests if the recursive geometry conversion works as expected and is only affecting the desired geo - """ - - def createSCC(): - outScene = IECoreScene.SceneCache( LiveSceneTest.__testFile, IECore.IndexedIO.OpenMode.Write ) - - rootSc = outScene.createChild('rootXform') - expandSc = rootSc.createChild('expand') - boxASc = expandSc.createChild('boxA') - boxASc.writeTags(['EXPAND']) - - notExpandSc = rootSc.createChild('notExpand') - boxBSc = notExpandSc.createChild('boxB') - - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0), imath.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable(IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData([imath.V3f(0, 1, 0)] * 6)) - boxASc.writeObject(mesh, 0) - boxBSc.writeObject(mesh, 0) - - # create test scene - createSCC() - - # create shape with SCC path - nodeName = 'sceneFile' - sceneShape = str(IECoreMaya.FnSceneShape.create(nodeName).fullPathName()) - maya.cmds.setAttr(sceneShape + '.file', LiveSceneTest.__testFile, type='string') - maya.cmds.setAttr(sceneShape + '.root', '/', type='string') - - # test live scene content - maya.cmds.currentTime("0sec") - liveScene = IECoreMaya.LiveScene() - linkedScene = IECoreScene.LinkedScene(liveScene) - nodeScene = linkedScene.child(nodeName) - - self.assertEqual(nodeScene.name(), nodeName) - self.assertFalse(nodeScene.hasAttribute(IECoreScene.LinkedScene.linkAttribute)) - self.assertEqual(nodeScene.childNames(), ['rootXform']) - - fnShape = IECoreMaya.FnSceneShape(sceneShape) - fnShape.convertAllToGeometry(tagName='EXPAND', preserveNamespace=True) - - expandScene = linkedScene.scene([nodeName, 'rootXform', 'expand']) - self.assertEqual(expandScene.childNames(), ['boxA']) - - notExpandScene = linkedScene.scene([nodeName, 'rootXform', 'notExpand']) - self.assertEqual(notExpandScene.childNames(), ['boxB']) - self.assertEqual(maya.cmds.listRelatives("{}|rootXform|notExpand".format(nodeName), children=True, type='transform') or [], []) - - def testAnimatedPromotedAttributes( self ): - def setupAnimAttrSCC(): - maya.cmds.file( new=True, force=True ) - scene = IECoreScene.SceneCache( LiveSceneTest.__testFile, IECore.IndexedIO.Write ) - scene.writeAttribute( 'scene:visible', IECore.BoolData( True ), time0 ) - scene.writeAttribute( 'user:testBool', IECore.BoolData( True ), time0 ) - scene.writeAttribute( 'user:testShort', IECore.ShortData( 2 ), time0 ) - scene.writeAttribute( 'user:testInt', IECore.IntData( 3 ), time0 ) - scene.writeAttribute( 'user:testInt64', IECore.Int64Data( 4 ), time0 ) - scene.writeAttribute( 'user:testFloat', IECore.FloatData( 5 ), time0 ) - scene.writeAttribute( 'user:testDouble', IECore.DoubleData( 6 ), time0 ) - scene.writeAttribute( 'user:testString', IECore.StringData( 'seven' ), time0 ) - mat = imath.M44d( ( 8, 9, 10, 11 ), ( 12, 13, 14, 15 ), ( 16, 17, 18, 19 ), ( 20, 21, 22, 23 ) ) - scene.writeAttribute( 'user:testMatrixd', IECore.M44dData(mat), time0 ) - mat = imath.M44f( ( 24, 25, 26, 27 ), ( 28, 29, 30, 31 ), ( 32, 33, 34, 35 ), ( 36, 37, 38, 39 ) ) - scene.writeAttribute( 'user:testMatrixf', IECore.M44fData(mat), time0 ) - - scene.writeAttribute( 'scene:visible', IECore.BoolData( False ), time1 ) - scene.writeAttribute( 'user:testBool', IECore.BoolData( False ), time1 ) - scene.writeAttribute( 'user:testShort', IECore.ShortData( 20 ), time1 ) - scene.writeAttribute( 'user:testInt', IECore.IntData( 30 ), time1 ) - scene.writeAttribute( 'user:testInt64', IECore.Int64Data( 40 ), time1 ) - scene.writeAttribute( 'user:testFloat', IECore.FloatData( 50 ), time1 ) - scene.writeAttribute( 'user:testDouble', IECore.DoubleData( 60 ), time1 ) - scene.writeAttribute( 'user:testString', IECore.StringData( 'seventy' ), time1 ) - mat = imath.M44d( ( 80, 90, 100, 110 ), ( 120, 130, 140, 150 ), ( 160, 170, 180, 190 ), ( 200, 210, 220, 230 ) ) - scene.writeAttribute( 'user:testMatrixd', IECore.M44dData(mat), time1 ) - mat = imath.M44f( ( 240, 250, 260, 270 ), ( 280, 290, 300, 310 ), ( 320, 330, 340, 350 ), ( 360, 370, 380, 390 ) ) - scene.writeAttribute( 'user:testMatrixf', IECore.M44fData(mat), time1 ) - - childScene = scene.createChild('cube_GEO') - boxSize = imath.Box3f( imath.V3f( -.5, -.5, -.5 ), imath.V3f( .5, .5, .5 ) ) - childScene.writeObject( IECoreScene.MeshPrimitive.createBox(boxSize), time0 ) - childScene.writeObject( IECoreScene.MeshPrimitive.createBox(boxSize), time1 ) - - time0, time1 = 0.0, 1.1 - setupAnimAttrSCC() - - # Prepare the maya scene - sceneTransform = 'scene' - sceneShapeFn = IECoreMaya.FnSceneShape.create( sceneTransform ) - sceneShape = sceneShapeFn.fullPathName() - maya.cmds.setAttr( sceneShape + '.file', LiveSceneTest.__testFile, type='string' ) - maya.cmds.setAttr( sceneShape + '.root', '/', type='string' ) - - liveRoot = IECoreMaya.LiveScene() - liveScene = liveRoot.child( sceneTransform ) - - # Read animated attributes before promotion - maya.cmds.currentTime( str( time0 ) + 'sec' ) - # Not reading scene:visible because LiveScene will ignore the cached value unless it's promoted - self.assertEqual( liveScene.readAttribute( 'user:testBool', time0 ), IECore.BoolData( True ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time0 ), IECore.ShortData( 2 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time0 ), IECore.IntData( 3 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time0 ), IECore.Int64Data( 4 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time0 ), IECore.FloatData( 5 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time0 ), IECore.DoubleData( 6 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testString', time0 ), IECore.StringData( 'seven' ) ) - mat = imath.M44d( ( 8, 9, 10, 11 ), ( 12, 13, 14, 15 ), ( 16, 17, 18, 19 ), ( 20, 21, 22, 23 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time0 ), IECore.M44dData( mat ) ) - mat = imath.M44f( ( 24, 25, 26, 27 ), ( 28, 29, 30, 31 ), ( 32, 33, 34, 35 ), ( 36, 37, 38, 39 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time0 ), IECore.M44fData( mat ) ) - - maya.cmds.currentTime( str( time1 ) + 'sec' ) - # Not reading scene:visible because LiveScene will ignore the cached value unless it's promoted - self.assertEqual( liveScene.readAttribute( 'user:testBool', time1 ), IECore.BoolData( False ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time1 ), IECore.ShortData( 20 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time1 ), IECore.IntData( 30 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time1 ), IECore.Int64Data( 40 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time1 ), IECore.FloatData( 50 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time1 ), IECore.DoubleData( 60 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testString', time1 ), IECore.StringData( 'seventy' ) ) - mat = imath.M44d( ( 80, 90, 100, 110 ), ( 120, 130, 140, 150 ), ( 160, 170, 180, 190 ), ( 200, 210, 220, 230 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time1 ), IECore.M44dData( mat ) ) - mat = imath.M44f( ( 240, 250, 260, 270 ), ( 280, 290, 300, 310 ), ( 320, 330, 340, 350 ), ( 360, 370, 380, 390 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time1 ), IECore.M44fData( mat ) ) - - # Read animated values after promotion - for attr in sceneShapeFn.promotableAttributeNames(): - sceneShapeFn.promoteAttribute( attr ) - - maya.cmds.currentTime( str( time0 ) + 'sec' ) - self.assertEqual( liveScene.readAttribute( 'scene:visible', time0 ), IECore.BoolData( True ) ) - self.assertEqual( liveScene.readAttribute( 'user:testBool', time0 ), IECore.BoolData( True ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time0 ), IECore.ShortData( 2 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time0 ), IECore.IntData( 3 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time0 ), IECore.IntData( 4 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time0 ), IECore.FloatData( 5 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time0 ), IECore.DoubleData( 6 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testString', time0 ), IECore.StringData( 'seven' ) ) - mat = imath.M44d( ( 8, 9, 10, 11 ), ( 12, 13, 14, 15 ), ( 16, 17, 18, 19 ), ( 20, 21, 22, 23 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time0 ), IECore.M44dData( mat ) ) - mat = imath.M44d( ( 24, 25, 26, 27 ), ( 28, 29, 30, 31 ), ( 32, 33, 34, 35 ), ( 36, 37, 38, 39 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time0 ), IECore.M44dData( mat ) ) - - maya.cmds.currentTime( str( time1 ) + 'sec' ) - self.assertEqual( liveScene.readAttribute( 'scene:visible', time1 ), IECore.BoolData( False ) ) - self.assertEqual( liveScene.readAttribute( 'user:testBool', time1 ), IECore.BoolData( False ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time1 ), IECore.ShortData( 20 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time1 ), IECore.IntData( 30 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time1 ), IECore.IntData( 40 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time1 ), IECore.FloatData( 50 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time1 ), IECore.DoubleData( 60 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testString', time1 ), IECore.StringData( 'seventy' ) ) - mat = imath.M44d( ( 80, 90, 100, 110 ), ( 120, 130, 140, 150 ), ( 160, 170, 180, 190 ), ( 200, 210, 220, 230 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time1 ), IECore.M44dData( mat ) ) - mat = imath.M44d( ( 240, 250, 260, 270 ), ( 280, 290, 300, 310 ), ( 320, 330, 340, 350 ), ( 360, 370, 380, 390 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time1 ), IECore.M44dData( mat ) ) - - # Read overridden animated attributes - destPlugs = [ attr for attr in maya.cmds.listConnections('sceneSceneShape', plugs=True, source=False, destination=True) if attr.startswith( 'scene.ie' ) ] - for destPlug in destPlugs: - sourcePlug = maya.cmds.connectionInfo( destPlug, sourceFromDestination=True ) - maya.cmds.disconnectAttr( sourcePlug, destPlug ) - - maya.cmds.currentTime( str( time0 ) + 'sec' ) - maya.cmds.setAttr( sceneTransform + '.' + str( IECoreMaya.LiveScene.visibilityOverrideName ), False ) - maya.cmds.setKeyframe( sceneTransform + '.' + str( IECoreMaya.LiveScene.visibilityOverrideName ) ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testBool' , False ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testBool' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testShort', 20 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testShort' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testInt', 30 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testInt' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testInt64', 40 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testInt64' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testFloat', 50 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testFloat' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testDouble', 60 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testDouble' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testString', 'seventy', type='string' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testMatrixd', [ 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230 ], type='matrix' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testMatrixf', [ 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390 ], type='matrix' ) - - maya.cmds.currentTime( str( time1 ) + 'sec' ) - maya.cmds.setAttr( sceneTransform + '.' + str( IECoreMaya.LiveScene.visibilityOverrideName ) , True ) - maya.cmds.setKeyframe( sceneTransform + '.' + str( IECoreMaya.LiveScene.visibilityOverrideName ) ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testBool' , True ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testBool' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testShort', 2 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testShort' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testInt', 3 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testInt' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testInt64', 4 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testInt64' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testFloat', 5 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testFloat' ) - maya.cmds.setAttr( sceneTransform + '.ieAttr_testDouble', 6 ) - maya.cmds.setKeyframe( sceneTransform + '.ieAttr_testDouble' ) - - maya.cmds.currentTime( str( time0 ) + 'sec' ) - self.assertEqual( liveScene.readAttribute( 'scene:visible', time0 ), IECore.BoolData( False ) ) - self.assertEqual( liveScene.readAttribute( 'user:testBool', time0 ), IECore.BoolData( False ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time0 ), IECore.ShortData( 20 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time0 ), IECore.IntData( 30 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time0 ), IECore.IntData( 40 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time0 ), IECore.FloatData( 50 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time0 ), IECore.DoubleData( 60 ) ) - - # Data attributes are not keyable - self.assertEqual( liveScene.readAttribute( 'user:testString', time0 ), IECore.StringData( 'seventy' ) ) - mat = imath.M44d( ( 80, 90, 100, 110 ), ( 120, 130, 140, 150 ), ( 160, 170, 180, 190 ), ( 200, 210, 220, 230 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time0 ), IECore.M44dData( mat ) ) - mat = imath.M44d( ( 240, 250, 260, 270 ), ( 280, 290, 300, 310 ), ( 320, 330, 340, 350 ), ( 360, 370, 380, 390 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time0 ), IECore.M44dData( mat ) ) - - maya.cmds.currentTime( str( time1 ) + 'sec' ) - self.assertEqual( liveScene.readAttribute( 'scene:visible', time1 ), IECore.BoolData( True ) ) - self.assertEqual( liveScene.readAttribute( 'user:testBool', time1 ), IECore.BoolData( True ) ) - self.assertEqual( liveScene.readAttribute( 'user:testShort', time1 ), IECore.ShortData( 2 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt', time1 ), IECore.IntData( 3 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testInt64', time1 ), IECore.IntData( 4 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testFloat', time1 ), IECore.FloatData( 5 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testDouble', time1 ), IECore.DoubleData( 6 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testString', time1 ), IECore.StringData( 'seventy' ) ) - mat = imath.M44d( ( 80, 90, 100, 110 ), ( 120, 130, 140, 150 ), ( 160, 170, 180, 190 ), ( 200, 210, 220, 230 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixd', time1 ), IECore.M44dData( mat ) ) - mat = imath.M44d( ( 240, 250, 260, 270 ), ( 280, 290, 300, 310 ), ( 320, 330, 340, 350 ), ( 360, 370, 380, 390 ) ) - self.assertEqual( liveScene.readAttribute( 'user:testMatrixf', time1 ), IECore.M44dData( mat ) ) - - def testToFromMayaAttributeName( self ): - cortexUserAttr = 'user:attrName' - mayaUserAttr = 'ieAttr_attrName' - self.assertEqual( cortexUserAttr, IECoreMaya.LiveScene.fromMayaAttributeName( mayaUserAttr ) ) - self.assertEqual( mayaUserAttr, IECoreMaya.LiveScene.toMayaAttributeName( cortexUserAttr ) ) - - cortexUserAttrWithNameSpace = 'user:ns:attrName' - mayaUserAttrWithNameSpace = 'ieAttr_ns__attrName' - self.assertEqual( cortexUserAttrWithNameSpace, IECoreMaya.LiveScene.fromMayaAttributeName( mayaUserAttrWithNameSpace ) ) - self.assertEqual( mayaUserAttrWithNameSpace, IECoreMaya.LiveScene.toMayaAttributeName( cortexUserAttrWithNameSpace ) ) - - mayaVisibilityAttr = IECoreMaya.LiveScene.visibilityOverrideName - cortexVisibilityAttr = IECoreScene.SceneInterface.visibilityName - self.assertEqual( cortexVisibilityAttr, IECoreMaya.LiveScene.fromMayaAttributeName( mayaVisibilityAttr ) ) - self.assertEqual( mayaVisibilityAttr, IECoreMaya.LiveScene.toMayaAttributeName( cortexVisibilityAttr ) ) - - cortexAttrWithoutMayaEquivalent = 'notForMaya:attrName' - mayaAttrWithoutCortexEquivalent = 'notForCortex' - self.assertFalse( IECoreMaya.LiveScene.fromMayaAttributeName( mayaAttrWithoutCortexEquivalent ) ) - self.assertFalse( IECoreMaya.LiveScene.toMayaAttributeName( cortexAttrWithoutMayaEquivalent ) ) - - def testVisibilityOverrideName( self ) : - self.assertEqual( IECoreMaya.LiveScene.visibilityOverrideName, 'ieVisibility' ) - - def testDagPath( self ): - group = str( maya.cmds.group( empty=True ) ) - cube = str( maya.cmds.polyCube( constructionHistory=False )[0] ) - maya.cmds.parent( cube, group ) - - liveScene = IECoreMaya.LiveScene() - cubeScene = liveScene.scene( [group, cube] ) - self.assertEqual( cubeScene.dagPath(), '|{}|{}'.format( group, cube ) ) - - def testDagPathToPath( self ): - group = str( maya.cmds.group( empty=True ) ) - cubeTransform = maya.cmds.polyCube( constructionHistory=False )[0] - maya.cmds.parent( cubeTransform, group ) - cubeTransform = str( maya.cmds.ls( cubeTransform, long=True )[0] ) - cubeShape = str( maya.cmds.listRelatives( cubeTransform, fullPath=True )[0] ) - - dagTransform = OpenMaya.MDagPath() - dagShape = OpenMaya.MDagPath() - sel = OpenMaya.MSelectionList() - sel.add( cubeTransform ) - sel.add( cubeShape ) - sel.getDagPath( 0, dagTransform ) - sel.getDagPath( 0, dagShape ) - - pathTransform = IECoreMaya.LiveScene.dagPathToPath( dagTransform.fullPathName() ) - self.assertEqual( pathTransform, cubeTransform[1:].split('|') ) - - pathShape = IECoreMaya.LiveScene.dagPathToPath( dagShape.fullPathName() ) - self.assertEqual( pathShape, cubeTransform[1:].split('|') ) - - pathRoot = IECoreMaya.LiveScene.dagPathToPath( '' ) - self.assertEqual( pathRoot, [] ) - - self.assertRaises( Exception, IECoreMaya.LiveScene.dagPathToPath, '|invalid' ) - - def testPathToDagPath( self ): - group = str( maya.cmds.group( empty=True ) ) - cube = str( maya.cmds.polyCube( constructionHistory=False )[0] ) - maya.cmds.parent( cube, group ) - - path = [group, cube] - dagTransform = IECoreMaya.LiveScene.pathToDagPath( path ) - self.assertEqual( dagTransform, '|{}|{}'.format( group, cube ) ) - - dagRoot = IECoreMaya.LiveScene.pathToDagPath( [] ) - self.assertEqual( dagRoot, '' ) - - self.assertRaises( Exception, IECoreMaya.LiveScene.pathToDagPath, ['invalid'] ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) - diff --git a/test/IECoreMaya/MayaTypeIdTest.py b/test/IECoreMaya/MayaTypeIdTest.py deleted file mode 100644 index fc8be4dd3e..0000000000 --- a/test/IECoreMaya/MayaTypeIdTest.py +++ /dev/null @@ -1,56 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya - -import IECore -import IECoreMaya - -class MayaTypeIdTest( IECoreMaya.TestCase ) : - - def test( self ) : - - a = IECoreMaya.MayaTypeId.ProceduralHolder - self.assertEqual( a.id(), 0x00110DCB ) - - b = maya.OpenMaya.MTypeId( a ) - self.assertEqual( b.id(), 0x00110DCB ) - - def testErrors( self ) : - - self.assertRaises( RuntimeError, getattr, IECoreMaya.MayaTypeId, "NonExistentTypeId" ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/NamespacePollution.py b/test/IECoreMaya/NamespacePollution.py deleted file mode 100644 index 04156648de..0000000000 --- a/test/IECoreMaya/NamespacePollution.py +++ /dev/null @@ -1,51 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreMaya - -class NamespacePollutionTest( IECoreMaya.TestCase ) : - - def test( self) : - - for m in IECore, IECoreMaya : - - d = dir( m ) - for n in [ "os", "glob", "re", "shutil", "IECore", "IECoreMaya", "shlex", "sys", - "traceback", "inspect", "string", "maya", "cmds", "OpenMaya", "OpenMayaAnim", "OpenMayaUI", "OpenMayaFX" ] : - self.assertTrue( not n in d ) - - -if __name__ == "__main__" : - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ObjectDataTest.py b/test/IECoreMaya/ObjectDataTest.py deleted file mode 100644 index ba393f7516..0000000000 --- a/test/IECoreMaya/ObjectDataTest.py +++ /dev/null @@ -1,104 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import maya.cmds -import maya.OpenMaya - -import IECore -import IECoreMaya - -class ObjectDataTest( IECoreMaya.TestCase ) : - - def setUp( self ) : - - IECoreMaya.TestCase.setUp( self ) - - if not maya.cmds.pluginInfo( "ObjectDataTestNode.py", query=True, loaded=True ) : - maya.cmds.loadPlugin( "ObjectDataTestNode.py" ) - - def testReadWrite( self ) : - - node = maya.cmds.createNode( "ieObjectDataTestNode" ) - - compoundData = IECore.CompoundData( { - "val1" : IECore.FloatData( 1 ), - "val2" : IECore.StringData( "val2Data" ), - "val3" : { - "val3.val1" : IECore.IntData( 100 ), - }, - } ) - - IECoreMaya.ToMayaPlugConverter.create( compoundData ).convert( node + ".objectData" ) - plugValue = IECoreMaya.FromMayaPlugConverter.create( node + ".objectData" ).convert() - self.assertEqual( plugValue, compoundData ) - - # try saving and loading an ascii file - - maya.cmds.file( rename = os.getcwd() + "/test/IECoreMaya/objectDataTest.ma" ) - sceneFileName = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - maya.cmds.file( new=True, force=True ) - maya.cmds.file( sceneFileName, force=True, open=True ) - - loadedCompoundData = IECoreMaya.FromMayaPlugConverter.create( node + ".objectData" ).convert() - self.assertEqual( loadedCompoundData, compoundData ) - - # try saving and loading a binary file - - maya.cmds.file( rename = os.getcwd() + "/test/IECoreMaya/objectDataTest.mb" ) - sceneFileName = maya.cmds.file( force = True, type = "mayaBinary", save = True ) - - maya.cmds.file( new=True, force=True ) - maya.cmds.file( sceneFileName, force=True, open=True ) - - loadedCompoundData = IECoreMaya.FromMayaPlugConverter.create( node + ".objectData" ).convert() - self.assertEqual( loadedCompoundData, compoundData ) - - def tearDown( self ) : - - maya.cmds.file( new = True, force = True ) - maya.cmds.flushUndo() - maya.cmds.unloadPlugin( "ObjectDataTestNode.py" ) - - for f in [ - "./test/IECoreMaya/objectDataTest.ma", - "./test/IECoreMaya/objectDataTest.mb", - ] : - - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/ParameterisedHolder.py b/test/IECoreMaya/ParameterisedHolder.py deleted file mode 100644 index c40c4579b8..0000000000 --- a/test/IECoreMaya/ParameterisedHolder.py +++ /dev/null @@ -1,1921 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import os.path - -import maya.cmds as cmds -import maya.OpenMaya as OpenMaya - -import IECore -import imath - -import IECoreScene -import IECoreMaya - -import sys - -class TestParameterisedHolder( IECoreMaya.TestCase ) : - - def __checkAllParameterPlugs( self, fnOH, parameter=None ) : - - if parameter is not None : - plug = fnOH.parameterPlug( parameter ) - self.assertFalse( plug.isNull() ) - else : - parameter = fnOH.getParameterised()[0].parameters() - - if parameter.isInstanceOf( IECore.CompoundParameter.staticTypeId() ) : - for p in parameter.values() : - self.__checkAllParameterPlugs( fnOH, p ) - - def testNode( self ): - """ Test ParameterisedHolderNode """ - n = cmds.createNode( "ieParameterisedHolderNode" ) - h = IECoreMaya.FnParameterisedHolder( str(n) ) - self.assertTrue( h ) - - p = IECore.SequenceLsOp() - - h.setParameterised( p ) - - p.parameters()["dir"] = "testValue" - h.setNodeValue( p.parameters()["dir"] ) - pl = h.parameterPlug( p.parameters()["dir"] ) - v = IECoreMaya.FromMayaPlugConverter.create( pl, IECore.TypeId.StringData ).convert() - self.assertEqual( v.value, "testValue" ) - - cmds.setAttr( pl.name(), "testValue2", typ="string" ) - h.setParameterisedValue( p.parameters()["dir"] ) - self.assertEqual( p.parameters()["dir"].getValue().value, "testValue2" ) - - - def testParameterisedHolderSetReference( self ): - """ Test multiple references to ieParameterisedHolderSet nodes """ - - nodeType = "ieParameterisedHolderSet" - - nodeName = cmds.createNode( nodeType ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "reference.ma" ) ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, reference = True, namespace = "ns1" ) - cmds.file( scene, reference = True, namespace = "ns2" ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "referenceMaster.ma" ) ) - masterScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( masterScene, force = True, open = True ) - - nodeName1 = "ns1:" + nodeName - nodeName2 = "ns2:" + nodeName - - l = OpenMaya.MSelectionList() - l.add( nodeName1 ) - l.add( nodeName2 ) - - node1 = OpenMaya.MObject() - l.getDependNode( 0, node1 ) - node2 = OpenMaya.MObject() - l.getDependNode( 1, node2 ) - - fn1 = OpenMaya.MFnDependencyNode( node1 ) - fn2 = OpenMaya.MFnDependencyNode( node2 ) - - self.assertTrue( fn1.userNode() ) - self.assertTrue( fn2.userNode() ) # This failure is due to a Maya bug. When referencing the same scene twice, as an optimisation Maya will duplicate existing nodes instead of creating new ones. There is a bug in MPxObjectSet::copy() which gets exercised here. Setting the environment variable MAYA_FORCE_REF_READ to 1 will disable this optimisation, however. - - def testChangeDefault( self ) : - """ Test that changing parameter defaults is correctly reflected in Maya attributes """ - - def makeOp( defaultValue ) : - - class TestOp( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, "Tests stuff", - IECore.IntParameter( - name = "result", - description = "", - defaultValue = 0 - ) - ) - - self.parameters().addParameters( - [ - IECore.Color3fParameter( - name = "c", - description = "", - defaultValue = defaultValue - ), - ] - ) - - return TestOp() - - - n = cmds.createNode( "ieParameterisedHolderNode" ) - h = IECoreMaya.FnParameterisedHolder( str(n) ) - self.assertTrue( h ) - - p = makeOp( IECore.Color3fData( imath.Color3f( 0, 0, 0 ) ) ) - h.setParameterised( p ) - dv = cmds.attributeQuery ( "parm_c", node = n, listDefault = True ) - self.assertEqual( dv, [ 0, 0, 0 ] ) - - p = makeOp( imath.Color3f( 1, 1, 1 ) ) - h.setParameterised( p ) - dv = cmds.attributeQuery ( "parm_c", node = n, listDefault = True ) - self.assertEqual( dv, [ 1, 1, 1 ] ) - - def testDirectSettingOfOp( self ) : - - class TestOp( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "", - IECore.FloatParameter( - "result", - "", - 0.0 - ), - ) - - self.parameters().addParameter( - - IECore.FloatParameter( - "a", - "", - 0.0 - ) - - ) - - def doOperation( self, operands ) : - - return IECore.FloatData( operands["a"].value ) - - node = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnParameterisedHolder( str( node ) ) - - op = TestOp() - fnOH.setParameterised( op ) - - self.assertTrue( cmds.objExists( node + ".result" ) ) - - aAttr = fnOH.parameterPlugPath( op["a"] ) - - cmds.setAttr( aAttr, 10 ) - self.assertEqual( cmds.getAttr( node + ".result" ), 10 ) - - cmds.setAttr( aAttr, 20 ) - self.assertEqual( cmds.getAttr( node + ".result" ), 20 ) - - def testObjectParameterIOProblem( self ) : - - fnOP = IECoreMaya.FnOpHolder.create( "opHolder", "compoundObjectInOut", 1 ) - op = fnOP.getOp() - - c = IECore.CompoundObject( { - "s" : IECore.StringData( "this" ), - "t" : IECore.TimeCodeData( IECore.TimeCode( 12, 5, 3, 15, dropFrame = True, bgf1 = True, binaryGroup6 = 12 ) ), - } ) - op.parameters()["input"].setValue( c ) - fnOP.setNodeValues() - node = fnOP.name() - - cmds.file( rename = os.getcwd() + "/test/IECoreMaya/objectParameterIO.ma" ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - fnOP = IECoreMaya.FnOpHolder( node ) - fnOP.setParameterisedValues() - op = fnOP.getOp() - - self.assertEqual( op.parameters()["input"].getValue(), c ) - - def testObjectMFnDataParameterIOProblem( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "matrixParameter", 1 ) - op = fnOH.getOp() - - locator = cmds.spaceLocator()[0] - - parameterPlugPath = fnOH.parameterPlugPath( op.parameters()['matrix'] ) - attrPlugPath = '%s.worldMatrix' % ( locator ) - cmds.connectAttr( attrPlugPath, parameterPlugPath ) - - cmds.file( rename = os.getcwd() + "/test/IECoreMaya/objectMFnDataParameterIO.ma" ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - connections = cmds.listConnections( parameterPlugPath, plugs=True, connections=True ) or [] - - self.assertTrue( attrPlugPath in connections ) - self.assertTrue( parameterPlugPath in connections ) - - def testNonStorableObjectParameter( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "unstorable", 1 ) - op = fnOH.getOp() - node = fnOH.fullPathName() - - testObj = IECore.CompoundObject( { "someData" : IECore.BoolData( False ) } ) - - with fnOH.parameterModificationContext() : - op["input"].setValue( testObj ) - - self.assertEqual( op["input"].getValue(), testObj ) - - cmds.file( rename = os.getcwd() + "/test/IECoreMaya/nonStorableObjectParameter.ma" ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - fnPH = IECoreMaya.FnParameterisedHolder( node ) - fnPH.setParameterisedValues() - - op = fnPH.getParameterised()[0] - self.assertEqual( op["input"].getValue(), op["input"].defaultValue ) - - def testMeshParameterIOProblem( self ) : - - fnOP = IECoreMaya.FnOpHolder.create( "merge", "meshMerge" ) - op = fnOP.getOp() - - mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -2, -2, -2 ), imath.V3f( 2, 3, 4 ) ) ) - mesh[ "N" ] = IECoreScene.PrimitiveVariable( mesh[ "N" ].interpolation, mesh[ "N" ].expandedData() ) - op.parameters()[ "input" ].setValue( mesh ) - fnOP.setNodeValues() - - cmds.file( rename = os.getcwd() + "/test/IECoreMaya/meshParameterIO.ma" ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - fnOP = IECoreMaya.FnOpHolder( "merge" ) - fnOP.setParameterisedValues() - op = fnOP.getOp() - - mesh2 = op.parameters()["input"].getValue() - self.assertTrue( mesh2.arePrimitiveVariablesValid() ) - self.assertEqual( mesh2, mesh ) - - def testOpHolder( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "maths/multiply", 2 ) - op = fnOH.getOp() - - self.assertEqual( cmds.attributeQuery( "result", node="opHolder", storable=True ), False ) - self.assertEqual( cmds.attributeQuery( "result", node="opHolder", writable=True ), False ) - - aPlug = fnOH.parameterPlugPath( op["a"] ) - bPlug = fnOH.parameterPlugPath( op["b"] ) - - cmds.setAttr( aPlug, 20 ) - cmds.setAttr( bPlug, 100 ) - - self.assertTrue( cmds.getAttr( "opHolder.result" ), 2000 ) - - def testParameterTypes( self ) : - - node = cmds.createNode( "ieOpHolderNode" ) - fnPH = IECoreMaya.FnParameterisedHolder( node ) - - op = IECore.ClassLoader.defaultOpLoader().load( "parameterTypes", 1 )() - op.parameters().removeParameter( "m" ) # no color4f support in maya - - fnPH.setParameterised( op ) - - for parameter in op.parameters().values() : - - self.assertTrue( cmds.objExists( fnPH.parameterPlugPath( parameter ) ) ) - - def testCompoundObjectConnections( self ) : - - fnOHA = IECoreMaya.FnOpHolder.create( "opA", "compoundObjectInOut", 1 ) - - fnOHB = IECoreMaya.FnOpHolder.create( "opB", "compoundObjectInOut", 1 ) - opB = fnOHB.getOp() - - inputPlug = fnOHB.parameterPlugPath( opB["input"] ) - cmds.connectAttr( "opA.result", inputPlug ) - - self.assertEqual( cmds.listConnections( inputPlug, source=True, destination=False, plugs=True ), [ "opA.result" ] ) - self.assertEqual( cmds.listConnections( inputPlug, source=False, destination=True, plugs=True ), None ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "compoundObjectConnections.ma" ) ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - self.assertEqual( cmds.listConnections( inputPlug, source=True, destination=False, plugs=True ), [ "opA.result" ] ) - self.assertEqual( cmds.listConnections( inputPlug, source=False, destination=True, plugs=True ), None ) - - def testDefaultConnections( self ) : - - # make an opholder for an op with default connections - # and make sure they are made. - - fnOH = IECoreMaya.FnOpHolder.create( "opA", "mayaUserData", 1 ) - op = fnOH.getOp() - - tPlug = fnOH.parameterPlugPath( op["t"] ) - - self.assertEqual( cmds.listConnections( tPlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), [ "time1.outTime" ] ) - self.assertEqual( cmds.listConnections( tPlug, source=False, destination=True, plugs=True ), None ) - - ePlug = fnOH.parameterPlugPath( op["e"] ) - - eInputPlugs = cmds.listConnections( ePlug, source=True, destination=False, plugs=True ) - eInputNodes = cmds.listConnections( ePlug, source=True, destination=False ) - self.assertEqual( len( eInputNodes ), 1 ) - self.assertEqual( cmds.nodeType( eInputNodes[0] ), "expression" ) - - # save the file - - cmds.file( rename = os.getcwd() + "/test/IECoreMaya/defaultConnections.ma" ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # load it again and check the connections are still there - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - self.assertEqual( cmds.listConnections( tPlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), [ "time1.outTime" ] ) - self.assertEqual( cmds.listConnections( tPlug, source=False, destination=True, plugs=True ), None ) - - eInputNodes = cmds.listConnections( ePlug, source=True, destination=False ) - self.assertEqual( len( eInputNodes ), 1 ) - self.assertEqual( cmds.nodeType( eInputNodes[0] ), "expression" ) - - # remove the connections and save - - cmds.disconnectAttr( "time1.outTime", tPlug ) - cmds.disconnectAttr( eInputPlugs[0], ePlug ) - - self.assertEqual( cmds.listConnections( tPlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), None ) - self.assertEqual( cmds.listConnections( ePlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), None ) - - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # load again and check they remain disconnected - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - self.assertEqual( cmds.listConnections( tPlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), None ) - self.assertEqual( cmds.listConnections( ePlug, source=True, destination=False, plugs=True, skipConversionNodes=True ), None ) - - def testConnectedNodeNameValueProvider( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opA", "mayaUserData", 1 ) - op = fnOH.getOp() - - fnOH.setParameterisedValues() - self.assertEqual( op["s"].getTypedValue(), "" ) - - sPlug = fnOH.parameterPlugPath( op["s"] ) - cmds.connectAttr( "time1.outTime", sPlug ) - - fnOH.setParameterisedValues() - self.assertEqual( op["s"].getTypedValue(), "time1" ) - - def testReferencedConnectedNodeNameValueProvider( self ) : - - # Create a scene with a ClassVector parameter containing a StringParameter - # that uses the "connectedNodeName" value provider, and hook it up. - ########################################################################## - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 2 ) - op = fnOH.getOp() - c = op["cv"] - - with fnOH.parameterModificationContext() : - c.setClasses( - [ - ( "mud", "mayaUserData", 1 ), - ] - ) - - plugPath = fnOH.parameterPlugPath( c["mud"]["s"] ) - - camera = cmds.createNode( "camera" ) - cmds.connectAttr( "%s.message" % camera, plugPath ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "connectedNodeReference.ma" ) ) - referenceScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # Reference this scene into a new one, and add another class. - ############################################################# - - cmds.file( new = True, force = True ) - cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - op = fnOH.getOp() - c = op["cv"] - - with fnOH.parameterModificationContext() : - c.setClasses( - [ - ( "mud", "mayaUserData", 1 ), - ( "maths", "maths/multiply", 1 ) - ] - ) - - plugPath = fnOH.parameterPlugPath( c["mud"]["s"] ) - - self.assertTrue( cmds.isConnected( "ns1:%s.message" % camera, plugPath ) ) - - # Save, and re-open scene, and make sure that the message connection survived - ############################################################################# - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "connectedNodeReference2.ma" ) ) - thisScene = cmds.file( force = True, type = "mayaAscii", save = True ) - cmds.file( thisScene, open = True, force = True ) - - self.assertTrue( cmds.isConnected( "ns1:%s.message" % camera, plugPath ) ) - - def testClassParameter( self ) : - - class TestOp( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "", - IECore.FloatParameter( - "result", - "", - 0.0 - ), - ) - - self.parameters().addParameter( - - IECore.ClassParameter( - "cp", - "", - "IECORE_OP_PATHS" - ) - - ) - - def doOperation( self, operands ) : - - return IECore.FloatData( 1 ) - - node = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnParameterisedHolder( str( node ) ) - - op = TestOp() - fnOH.setParameterised( op ) - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["a"] ) - bPlugPath = fnOH.parameterPlugPath( op["cp"]["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 1 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 2 ) - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "stringParsing", 1, "IECORE_OP_PATHS" ) - - self.assertFalse( cmds.objExists( aPlugPath ) ) - self.assertFalse( cmds.objExists( bPlugPath ) ) - - emptyStringPlugPath = fnOH.parameterPlugPath( op["cp"]["emptyString"] ) - self.assertEqual( cmds.getAttr( emptyStringPlugPath ), "notEmpty" ) - - def testClassParameterSaveAndLoad( self ) : - - # make an opholder with a ClassParameter, and set the held class - #################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - - op = fnOH.getOp() - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - # check that maya has appropriate attributes for the held class, - # and that the held class hasn't changed in the process. - #################################################################### - - heldClass2, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - self.assertTrue( heldClass is heldClass2 ) - - # change some parameter values and push them into maya. - #################################################################### - - op["cp"]["a"].setNumericValue( 10 ) - op["cp"]["b"].setNumericValue( 20 ) - fnOH.setNodeValues() - - self.assertEqual( cmds.getAttr( fnOH.parameterPlugPath( op["cp"]["a"] ) ), 10 ) - self.assertEqual( cmds.getAttr( fnOH.parameterPlugPath( op["cp"]["b"] ) ), 20 ) - - # save the scene - #################################################################### - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classParameter.ma" ) ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - cmds.file( new = True, force = True ) - - # reload it and check we have the expected class and attributes - #################################################################### - - cmds.file( scene, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "node" ) - - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - self.assertEqual( cmds.getAttr( fnOH.parameterPlugPath( op["cp"]["a"] ) ), 10 ) - self.assertEqual( cmds.getAttr( fnOH.parameterPlugPath( op["cp"]["b"] ) ), 20 ) - - def testClassParameterUndo( self ) : - - # make an opholder with a ClassParameter, and check that there is - # no class loaded - #################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - # check that undo is enabled - #################################################################### - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - # set the class and verify it worked - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( heldClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( heldClass["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 1 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 2 ) - - # undo and check the class is unset - ##################################################################### - - cmds.undo() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - self.assertFalse( cmds.objExists( aPlugPath ) ) - self.assertFalse( cmds.objExists( bPlugPath ) ) - - def testClassParameterUndoWithPreviousValues( self ) : - - # make an opholder with a ClassParameter, and check that there is - # no class loaded - #################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - # set the class and check it worked - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( heldClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( heldClass["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 1 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 2 ) - - # change some attribute values - #################################################################### - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 20 ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - # check that undo is enabled - #################################################################### - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - # change the class to something else and check it worked - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "stringParsing", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "stringParsing" ) - self.assertEqual( className, "stringParsing" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - plugPaths = [] - for p in heldClass.parameters().values() : - - plugPath = fnOH.parameterPlugPath( p ) - self.assertTrue( cmds.objExists( plugPath ) ) - plugPaths.append( plugPath ) - - self.assertFalse( cmds.objExists( aPlugPath ) ) - self.assertFalse( cmds.objExists( bPlugPath ) ) - - # undo and check the previous class reappears, along with the - # previous attribute values - ##################################################################### - - cmds.undo() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( heldClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( heldClass["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - for p in plugPaths : - - self.assertFalse( cmds.objExists( plugPath ) ) - - def testClassParameterRemovalUndoWithChildren( self ) : - - # make an opholder with a ClassParameter, and check that there is - # no class loaded - #################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - # set the class and check it worked - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "classParameterTest", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "classParameterTest" ) - self.assertEqual( className, "classParameterTest" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - # put a class inside the class and check it worked - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"]["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["a"] ) - bPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 1 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 2 ) - - # change some attribute values - #################################################################### - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 20 ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - # check that undo is enabled - #################################################################### - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - # remove the top level class - #################################################################### - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "", -1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, -1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - self.assertFalse( cmds.objExists( aPlugPath ) ) - self.assertFalse( cmds.objExists( bPlugPath ) ) - - # undo and check the previous class reappears, along with the child - # class and previous attribute values - ##################################################################### - - cmds.undo() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "classParameterTest" ) - self.assertEqual( className, "classParameterTest" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - childClass, childClassName, childClassVersion, childSearchPath = heldClass["cp"].getClass( True ) - self.assertEqual( childClass.typeName(), "multiply" ) - self.assertEqual( childClassName, "maths/multiply" ) - self.assertEqual( childClassVersion, 1 ) - self.assertEqual( childSearchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( childClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( childClass["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - def testClassParameterReferenceEdits( self ) : - - # make a file with a class parameter with no held class - ####################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classParameterReference.ma" ) ) - referenceScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # make a new scene referencing that file - ####################################################################### - - cmds.file( new = True, force = True ) - cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - # set the held class and change some attribute values - ####################################################################### - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( heldClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( heldClass["b"] ) - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 20 ) - - # save the scene - ####################################################################### - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classParameterReferencer.ma" ) ) - referencerScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # reload it and check all is well - ####################################################################### - - cmds.file( new = True, force = True ) - cmds.file( referencerScene, force = True, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "multiply" ) - self.assertEqual( className, "maths/multiply" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( heldClass["a"] ) - bPlugPath = fnOH.parameterPlugPath( heldClass["b"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - def testClassParameterReferenceEditsWithFloatParameters( self ) : - - # make a file with a class parameter with no held class - ####################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classParameterTest", 1 ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass, None ) - self.assertEqual( className, "" ) - self.assertEqual( classVersion, 0 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classParameterReference.ma" ) ) - referenceScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # make a new scene referencing that file - ####################################################################### - - cmds.file( new = True, force = True ) - cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - # set the held class and change some attribute values - ####################################################################### - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "floatParameter", 1, "IECORE_OP_PATHS" ) - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "floatParameter" ) - self.assertEqual( className, "floatParameter" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - fPlugPath = fnOH.parameterPlugPath( heldClass["f"] ) - - cmds.setAttr( fPlugPath, -1 ) - self.assertEqual( cmds.getAttr( fPlugPath ), -1 ) - - # save the scene - ####################################################################### - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classParameterReferencer.ma" ) ) - referencerScene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # reload it and check all is well - ####################################################################### - - cmds.file( new = True, force = True ) - cmds.file( referencerScene, force = True, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:node" ) - op = fnOH.getOp() - - heldClass, className, classVersion, searchPath = op["cp"].getClass( True ) - self.assertEqual( heldClass.typeName(), "floatParameter" ) - self.assertEqual( className, "floatParameter" ) - self.assertEqual( classVersion, 1 ) - self.assertEqual( searchPath, "IECORE_OP_PATHS" ) - - fPlugPath = fnOH.parameterPlugPath( heldClass["f"] ) - - self.assertEqual( cmds.getAttr( fPlugPath ), -1 ) - - def testClassParameterCompactPlugs( self ) : - - class TestOp( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "", - IECore.FloatParameter( - "result", - "", - 0.0 - ), - ) - - self.parameters().addParameter( - - IECore.ClassParameter( - "cp", - "", - "IECORE_OP_PATHS" - ) - - ) - - def doOperation( self, operands ) : - - return IECore.FloatData( 1 ) - - node = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnParameterisedHolder( str( node ) ) - - op = TestOp() - fnOH.setParameterised( op ) - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1, "IECORE_OP_PATHS" ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["a"] ) - bPlugPath = fnOH.parameterPlugPath( op["cp"]["b"] ) - cpPlugPath = fnOH.parameterPlugPath( op["cp"] ) - - self.assertEqual( cmds.getAttr( cpPlugPath ), [ "maths/multiply", "1", "IECORE_OP_PATHS" ] ) - self.assertTrue( not cmds.objExists( cpPlugPath + "__className" ) ) - self.assertTrue( not cmds.objExists( cpPlugPath + "__classVersion" ) ) - self.assertTrue( not cmds.objExists( cpPlugPath + "__searchPathEnvVar" ) ) - self.assertEqual( cmds.getAttr( aPlugPath ), 1 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 2 ) - - def testOpHolderImport( self ) : - - # make a file with an op holder in it - ####################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "maths/multiply", 2 ) - op = fnOH.getOp() - - aPlugPath = fnOH.parameterPlugPath( op["a"] ) - bPlugPath = fnOH.parameterPlugPath( op["b"] ) - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "op.ma" ) ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # import it into a new scene - ####################################################################### - - cmds.file( new = True, force = True ) - cmds.file( scene, i = True ) - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 12 ) - - self.assertEqual( cmds.getAttr( "node.result" ), 120 ) - - def testClassVectorParameter( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - c = op["cv"] - self.assertEqual( c.typeName(), "ClassVectorParameter" ) - - self.assertEqual( len( c.getClasses() ), 0 ) - - with fnOH.parameterModificationContext() : - - c.setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ( "coIO", "compoundObjectInOut", 1 ), - ] - - ) - - cl = c.getClasses() - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0].typeName(), "multiply" ) - self.assertEqual( cl[1].typeName(), "compoundObjectInOut" ) - - self.assertEqual( len( c ), 2 ) - self.assertEqual( list(c.keys()), [ "mult", "coIO" ] ) - self.assertEqual( list(c["mult"].keys()), [ "a", "b" ] ) - self.assertEqual( list(c["coIO"].keys()), [ "input" ] ) - - cl = c.getClasses( True ) - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0][0].typeName(), "multiply" ) - self.assertEqual( cl[1][0].typeName(), "compoundObjectInOut" ) - self.assertEqual( cl[0][1], "mult" ) - self.assertEqual( cl[1][1], "coIO" ) - self.assertEqual( cl[0][2], "maths/multiply" ) - self.assertEqual( cl[1][2], "compoundObjectInOut" ) - self.assertEqual( cl[0][3], 1 ) - self.assertEqual( cl[1][3], 1 ) - - self.__checkAllParameterPlugs( fnOH, c ) - - def testClassVectorParameterSaveAndLoad( self ) : - - # make an opholder with a ClassVectorParameter, and modify some plug - # values - ##################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - c = op["cv"] - self.assertEqual( c.typeName(), "ClassVectorParameter" ) - - self.assertEqual( len( c.getClasses() ), 0 ) - - with fnOH.parameterModificationContext() : - - c.setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ( "coIO", "compoundObjectInOut", 1 ), - ] - - ) - - cl = c.getClasses() - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0].typeName(), "multiply" ) - self.assertEqual( cl[1].typeName(), "compoundObjectInOut" ) - - self.__checkAllParameterPlugs( fnOH, c ) - - aPlugPath = fnOH.parameterPlugPath( c["mult"]["a"] ) - bPlugPath = fnOH.parameterPlugPath( c["mult"]["b"] ) - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 20 ) - - # save the scene - #################################################################### - - cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "classVectorParameter.ma" ) ) - scene = cmds.file( force = True, type = "mayaAscii", save = True ) - - # reload it and check we still have what we expect - #################################################################### - - cmds.file( new = True, force = True ) - cmds.file( scene, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "node" ) - - op = fnOH.getOp() - - cl = op["cv"].getClasses() - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0].typeName(), "multiply" ) - self.assertEqual( cl[1].typeName(), "compoundObjectInOut" ) - - self.__checkAllParameterPlugs( fnOH, op["cv"] ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - def testClassVectorParameterUndo( self ) : - - # make an opholder and set a ClassVectorParameter - ########################################################################## - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - c = op["cv"] - self.assertEqual( c.typeName(), "ClassVectorParameter" ) - - self.assertEqual( len( c.getClasses() ), 0 ) - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - with fnOH.parameterModificationContext() : - - c.setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ( "str", "stringParsing", 1 ), - ] - - ) - - cl = c.getClasses() - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0].typeName(), "multiply" ) - self.assertEqual( cl[1].typeName(), "stringParsing" ) - - self.assertEqual( len( c ), 2 ) - self.assertEqual( list(c.keys()), [ "mult", "str" ] ) - self.assertEqual( list(c["mult"].keys()), [ "a", "b" ] ) - self.assertEqual( list(c["str"].keys()), [ "emptyString", "normalString", "stringWithSpace", "stringWithManySpaces" ] ) - - cl = c.getClasses( True ) - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0][0].typeName(), "multiply" ) - self.assertEqual( cl[1][0].typeName(), "stringParsing" ) - self.assertEqual( cl[0][1], "mult" ) - self.assertEqual( cl[1][1], "str" ) - self.assertEqual( cl[0][2], "maths/multiply" ) - self.assertEqual( cl[1][2], "stringParsing" ) - self.assertEqual( cl[0][3], 1 ) - self.assertEqual( cl[1][3], 1 ) - - self.__checkAllParameterPlugs( fnOH, c ) - - # undo and check we're back to square one - ########################################################################## - - cmds.undo() - - self.assertEqual( c.getClasses(), [] ) - - def testClassVectorParameterUndoWithPreviousValues( self ) : - - # make an opholder with a ClassVectorParameter, and modify some plug - # values - ##################################################################### - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - c = op["cv"] - self.assertEqual( c.typeName(), "ClassVectorParameter" ) - - self.assertEqual( len( c.getClasses() ), 0 ) - - with fnOH.parameterModificationContext() : - - c.setClasses( - - [ - ( "mult", "maths/multiply", 1 ), - ] - - ) - - cl = c.getClasses( True ) - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 1 ) - self.assertEqual( cl[0][0].typeName(), "multiply" ) - self.assertEqual( cl[0][1], "mult" ) - self.assertEqual( cl[0][2], "maths/multiply" ) - self.assertEqual( cl[0][3], 1 ) - - self.__checkAllParameterPlugs( fnOH, c ) - - aPlugPath = fnOH.parameterPlugPath( c["mult"]["a"] ) - bPlugPath = fnOH.parameterPlugPath( c["mult"]["b"] ) - - cmds.setAttr( aPlugPath, 10 ) - cmds.setAttr( bPlugPath, 20 ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - # change set of held classes to something totally different - # and check that it worked - ##################################################################### - - with fnOH.parameterModificationContext() : - - c.setClasses( - - [ - ( "str", "stringParsing", 1 ), - ( "spl", "splineInput", 1 ), - ] - - ) - - cl = c.getClasses( True ) - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 2 ) - self.assertEqual( cl[0][0].typeName(), "stringParsing" ) - self.assertEqual( cl[1][0].typeName(), "splineInput" ) - self.assertEqual( cl[0][1], "str" ) - self.assertEqual( cl[1][1], "spl" ) - self.assertEqual( cl[0][2], "stringParsing" ) - self.assertEqual( cl[1][2], "splineInput" ) - self.assertEqual( cl[0][3], 1 ) - self.assertEqual( cl[1][3], 1 ) - - self.__checkAllParameterPlugs( fnOH, c ) - - # undo and check we're back where we want to be - ##################################################################### - - cmds.undo() - - cl = c.getClasses( True ) - self.assertTrue( isinstance( cl, list ) ) - self.assertEqual( len( cl ), 1 ) - self.assertEqual( cl[0][0].typeName(), "multiply" ) - self.assertEqual( cl[0][1], "mult" ) - self.assertEqual( cl[0][2], "maths/multiply" ) - self.assertEqual( cl[0][3], 1 ) - - self.__checkAllParameterPlugs( fnOH, c ) - - self.assertEqual( cmds.getAttr( aPlugPath ), 10 ) - self.assertEqual( cmds.getAttr( bPlugPath ), 20 ) - - def testSetParameterisedUndo( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "stringParsing", 1 ) - op = fnOH.getOp() - - self.assertEqual( op.typeName(), "stringParsing" ) - - self.__checkAllParameterPlugs( fnOH ) - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - fnOH.setOp( "maths/multiply", 1 ) - - op = fnOH.getOp() - self.assertEqual( op.typeName(), "multiply" ) - self.__checkAllParameterPlugs( fnOH ) - - cmds.undo() - - op = fnOH.getOp() - self.assertEqual( op.typeName(), "stringParsing" ) - self.__checkAllParameterPlugs( fnOH ) - - cmds.redo() - - op = fnOH.getOp() - self.assertEqual( op.typeName(), "multiply" ) - self.__checkAllParameterPlugs( fnOH ) - - def testCreateOpHolderUndo( self ) : - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "stringParsing", 1 ) - - self.assertTrue( cmds.objExists( "opHolder" ) ) - - cmds.undo() - - self.assertFalse( cmds.objExists( "opHolder" ) ) - - def testCreateParameterisedHolderSetUndo( self ) : - - self.assertTrue( cmds.undoInfo( query=True, state=True ) ) - - fnOH = IECoreMaya.FnParameterisedHolderSet.create( "mySet", "stringParsing", 1, "IECORE_OP_PATHS" ) - - self.assertTrue( cmds.objExists( "mySet" ) ) - - cmds.undo() - - self.assertFalse( cmds.objExists( "mySet" ) ) - - def testSetParameterisedCallbacks( self ) : - - self.__numCallbacks = 0 - def c( fnPH ) : - - self.assertEqual( fnPH.fullPathName(), "opHolder" ) - self.__numCallbacks += 1 - - IECoreMaya.FnParameterisedHolder.addSetParameterisedCallback( c ) - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "stringParsing", 1 ) - self.assertEqual( self.__numCallbacks, 1 ) - - fnOH.setOp( "maths/multiply", 1 ) - self.assertEqual( self.__numCallbacks, 2 ) - - cmds.undo() - self.assertEqual( self.__numCallbacks, 3 ) - - cmds.redo() - self.assertEqual( self.__numCallbacks, 4 ) - - IECoreMaya.FnParameterisedHolder.removeSetParameterisedCallback( c ) - - def testEditClassParameters( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "classParameterTest", 1 ) - - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "classParameterTest", 1 ) - op["cp"]["cp"].setClass( "maths/multiply", 1 ) - - self.__checkAllParameterPlugs( fnOH ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["a"] ) - self.assertTrue( cmds.objExists( aPlugPath ) ) - - cmds.undo() - - self.__checkAllParameterPlugs( fnOH ) - self.assertEqual( op["cp"].getClass(), None ) - self.assertFalse( cmds.objExists( aPlugPath ) ) - - cmds.redo() - - self.__checkAllParameterPlugs( fnOH ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["a"] ) - self.assertTrue( cmds.objExists( aPlugPath ) ) - - def testChangeClassAndRevertToClassWithClassParameters( self ) : - - ## create a holder and put an op using ClassParameter in there - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "classParameterTest", 1 ) - - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "classParameterTest", 1 ) - op["cp"]["cp"].setClass( "maths/multiply", 1 ) - - self.__checkAllParameterPlugs( fnOH ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["a"] ) - self.assertTrue( cmds.objExists( aPlugPath ) ) - - ## change the values being held - - cmds.setAttr( aPlugPath, 123 ) - - ## change the op to be something simple - fnOH.setOp( "maths/multiply", 1 ) - self.assertFalse( cmds.objExists( aPlugPath ) ) - - ## undo, and check we get all the original held classes and values back - - cmds.undo() - - op = fnOH.getOp() - - self.assertEqual( op["cp"]["cp"].getClass( True )[1:3], ( "maths/multiply", 1 ) ) - - self.assertEqual( op["cp"]["cp"]["a"].getNumericValue(), 123 ) - - aPlugPath = fnOH.parameterPlugPath( op["cp"]["cp"]["a"] ) - self.assertEqual( cmds.getAttr( aPlugPath ), 123 ) - - def testUpgradeClassWithClassVectorParameter( self ) : - - # create a holder with a ClassVectorParameter with some classes - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "classVectorParameterTest", 1 ) - - op = fnOH.getOp() - - with fnOH.parameterModificationContext() : - - op["cv"].setClasses( [ - ( "m", "maths/multiply", 1 ), - ( "n", "maths/multiply", 1 ), - ] ) - - c = op["cv"].getClasses( True ) - self.assertEqual( len( c ), 2 ) - self.assertEqual( c[0][1:], ( "m", "maths/multiply", 1 ) ) - self.assertEqual( c[1][1:], ( "n", "maths/multiply", 1 ) ) - - aPlugPath = fnOH.parameterPlugPath( op["cv"]["m"]["a"] ) - - # upgrade the parameterised class - - fnOH.setOp( "classVectorParameterTest", 2 ) - - self.assertEqual( fnOH.getParameterised()[1:-1], ( "classVectorParameterTest", 2 ) ) - - # and check the classes are still intact - - op = fnOH.getOp() - - c = op["cv"].getClasses( True ) - self.assertEqual( len( c ), 2 ) - self.assertEqual( c[0][1:], ( "m", "maths/multiply", 1 ) ) - self.assertEqual( c[1][1:], ( "n", "maths/multiply", 1 ) ) - - # undo the upgrade - - cmds.undo() - - self.assertEqual( fnOH.getParameterised()[1:-1], ( "classVectorParameterTest", 1 ) ) - - # and check the classes are still intact again - - op = fnOH.getOp() - - c = op["cv"].getClasses( True ) - self.assertEqual( len( c ), 2 ) - self.assertEqual( c[0][1:], ( "m", "maths/multiply", 1 ) ) - self.assertEqual( c[1][1:], ( "n", "maths/multiply", 1 ) ) - - def testClassParameterCallbacks( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "classParameterTest", 1 ) - op = fnOH.getOp() - - self.__numCallbacks = 0 - def c( fnPH, parameter ) : - - self.assertEqual( fnPH.fullPathName(), "opHolder" ) - self.assertEqual( parameter.name, "cp" ) - self.__numCallbacks += 1 - - IECoreMaya.FnParameterisedHolder.addSetClassParameterClassCallback( c ) - - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1 ) - self.assertEqual( self.__numCallbacks, 1 ) - - cmds.undo() - self.assertEqual( self.__numCallbacks, 2 ) - - cmds.redo() - self.assertEqual( self.__numCallbacks, 3 ) - - # setting the class to the same thing it already is should have - # no effect. - with fnOH.parameterModificationContext() : - op["cp"].setClass( "maths/multiply", 1 ) - self.assertEqual( self.__numCallbacks, 3 ) - - IECoreMaya.FnParameterisedHolder.removeSetClassParameterClassCallback( c ) - - def testClassVectorParameterCallbacks( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "opHolder", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - self.__numCallbacks = 0 - def c( fnPH, parameter ) : - - self.assertEqual( fnPH.fullPathName(), "opHolder" ) - self.assertEqual( parameter.name, "cv" ) - self.__numCallbacks += 1 - - IECoreMaya.FnParameterisedHolder.addSetClassVectorParameterClassesCallback( c ) - - with fnOH.parameterModificationContext() : - op["cv"].setClasses( [ - ( "m", "maths/multiply", 1 ), - ( "n", "maths/multiply", 1 ), - ] ) - self.assertEqual( self.__numCallbacks, 1 ) - - cmds.undo() - self.assertEqual( self.__numCallbacks, 2 ) - - cmds.redo() - self.assertEqual( self.__numCallbacks, 3 ) - - # setting the class to the same thing it already is should have - # no effect. - with fnOH.parameterModificationContext() : - op["cv"].setClasses( [ - ( "m", "maths/multiply", 1 ), - ( "n", "maths/multiply", 1 ), - ] ) - self.assertEqual( self.__numCallbacks, 3 ) - - IECoreMaya.FnParameterisedHolder.removeSetClassVectorParameterClassesCallback( c ) - - def testClassVectorParameterCompactPlugs( self ) : - - fnOH = IECoreMaya.FnOpHolder.create( "node", "classVectorParameterTest", 1 ) - op = fnOH.getOp() - - c = op["cv"] - self.assertEqual( c.typeName(), "ClassVectorParameter" ) - self.assertEqual( len( c.getClasses() ), 0 ) - - with fnOH.parameterModificationContext() : - c.setClasses( [ - ( "mult", "maths/multiply", 1 ), - ( "coIO", "compoundObjectInOut", 1 ), - ] ) - - cPlugPath = fnOH.parameterPlugPath( c ) - self.assertEqual( cmds.getAttr( cPlugPath ), [ "mult", "maths/multiply", "1", "coIO", "compoundObjectInOut", "1" ] ) - self.assertTrue( not cmds.objExists( cPlugPath + "__parameterNames" ) ) - self.assertTrue( not cmds.objExists( cPlugPath + "__classNames" ) ) - self.assertTrue( not cmds.objExists( cPlugPath + "__classVersions" ) ) - - def testNumericParameterMinMax( self ) : - - # test no range - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0 - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), False ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), False ) - - # test min only - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0, - minValue = -10 - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minimum=True, node=opNode )[0], -10 ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), False ) - - # test min and max - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0, - minValue = -10, - maxValue = 10 - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minimum=True, node=opNode )[0], -10 ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maximum=True, node=opNode )[0], 10 ) - - def testNumericParameterRangeAdded( self ) : - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0 - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), False ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), False ) - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0, - minValue = -2, - maxValue = 2, - ) - ) - - fnOH.setParameterised( op ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minimum=True, node=opNode )[0], -2 ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maximum=True, node=opNode )[0], 2 ) - - def testNumericParameterRangeRemoved( self ) : - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0, - minValue = -2, - maxValue = 2, - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minimum=True, node=opNode )[0], -2 ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maximum=True, node=opNode )[0], 2 ) - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0 - ) - ) - - fnOH.setParameterised( op ) - - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], minExists=True, node=opNode ), False ) - self.assertEqual( cmds.attributeQuery( iPlugPath.rpartition( "." )[-1], maxExists=True, node=opNode ), False ) - - def testParameterTypeChanges( self ) : - - """Test maya attribute type with changing parameters types.""" - - n = cmds.createNode( 'ieParameterisedHolderNode' ) - - a = IECore.Parameterised( "a" ) - a.parameters().addParameter( IECore.IntParameter( "theParameter", "", 1 ) ) - - b = IECore.Parameterised( "b" ) - b.parameters().addParameter( IECore.StringParameter( "theParameter", "", "" ) ) - - c = IECore.Parameterised( "c" ) - c.parameters().addParameter( IECore.FloatParameter( "theParameter", "", 1.0 ) ) - - fnPH = IECoreMaya.FnParameterisedHolder( n ) - - fnPH.setParameterised( a ) - fnPH.setNodeValues() - - # Check the Maya attribute holds an int. - plugPath = fnPH.parameterPlugPath( a["theParameter"] ) - cmds.setAttr( plugPath, 2.75 ) - self.assertEqual( cmds.getAttr(plugPath), 3 ) - - fnPH.setParameterised( b ) - fnPH.setNodeValues() - - # Should be a string now - plugPath = fnPH.parameterPlugPath( b["theParameter"] ) - cmds.setAttr( plugPath, "test", type="string" ) - self.assertEqual( cmds.getAttr(plugPath), "test" ) - - fnPH.setParameterised( c ) - fnPH.setNodeValues() - - # Should be a float now - plugPath = fnPH.parameterPlugPath( c["theParameter"] ) - cmds.setAttr( plugPath, 3.75 ) - self.assertEqual( cmds.getAttr(plugPath), 3.75 ) - - fnPH.setParameterised( a ) - fnPH.setNodeValues() - - # Should be an int again - plugPath = fnPH.parameterPlugPath( a["theParameter"] ) - cmds.setAttr( plugPath, 4.75 ) - self.assertEqual( cmds.getAttr(plugPath), 5 ) - - def testRemoveLockedAttributes( self ) : - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.IntParameter( - "i", - "d", - 0 - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - iPlugPath = fnOH.parameterPlugPath( op["i"] ) - cmds.setAttr( iPlugPath, lock=True ) - - del op.parameters()["i"] - fnOH.setParameterised( op ) - - self.assertFalse( cmds.objExists( iPlugPath ) ) - - def testRemoveLockedChildAttributes( self ) : - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameter( - IECore.V3fParameter( - "v", - "d", - imath.V3f( 0 ), - ) - ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - vPlugPath = fnOH.parameterPlugPath( op["v"] ) - cmds.setAttr( vPlugPath + "X", lock=True ) - - del op.parameters()["v"] - fnOH.setParameterised( op ) - - self.assertFalse( cmds.objExists( vPlugPath ) ) - - def testStorable( self ) : - - op = IECore.Op( "", IECore.IntParameter( "result", "", 0 ) ) - op.parameters().addParameters( [ - - IECore.BoolParameter( - name = "a", - description = "", - defaultValue = True, - ), - IECore.IntParameter( - name = "b", - description = "", - defaultValue = 1, - userData = IECore.CompoundObject( { "maya" : { "storable" : IECore.BoolData( False ) } } ) - ), - IECore.StringParameter( - name = "c", - description = "", - defaultValue = "", - userData = IECore.CompoundObject( { "maya" : { "storable" : IECore.BoolData( True ) } } ) - ), - - ] ) - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - fnOH.setParameterised( op ) - - self.assertEqual( cmds.attributeQuery( fnOH.parameterPlugPath( op["a"] ).split( "." )[-1], storable=True, node=opNode ), True ) - self.assertEqual( cmds.attributeQuery( fnOH.parameterPlugPath( op["b"] ).split( "." )[-1], storable=True, node=opNode ), False ) - self.assertEqual( cmds.attributeQuery( fnOH.parameterPlugPath( op["c"] ).split( "." )[-1], storable=True, node=opNode ), True ) - - with fnOH.parameterModificationContext() : - op["a"].userData()["maya"] = IECore.CompoundObject( { "storable" : IECore.BoolData( False ) } ) - op["b"].userData()["maya"]["storable"] = IECore.BoolData( True ) - - self.assertEqual( cmds.attributeQuery( fnOH.parameterPlugPath( op["a"] ).split( "." )[-1], storable=True, node=opNode ), False ) - self.assertEqual( cmds.attributeQuery( fnOH.parameterPlugPath( op["b"] ).split( "." )[-1], storable=True, node=opNode ), True ) - - def testBadArgsDoNotSegFault( self ) : - - opNode = cmds.createNode( "ieOpHolderNode" ) - fnOH = IECoreMaya.FnOpHolder( opNode ) - self.assertRaises( RuntimeError, IECore.curry( fnOH.setOp, "fake", -1 ) ) - - def testDrawableHolderCanHoldParameterised( self ) : - - n = cmds.createNode( "ieDrawable" ) - h = IECoreMaya.FnParameterisedHolder( str(n) ) - self.assertTrue( h ) - - h.setParameterised( "floatParameter", 1, "IECORE_OP_PATHS" ) - self.assertEqual( h.getParameterised()[1:], ( "floatParameter", 1, "IECORE_OP_PATHS" ) ) - - cmds.setAttr( n + ".parm_f", 1.5 ) - h.setParameterisedValues() - self.assertEqual( h.getParameterised()[0]["f"].getNumericValue(), 1.5 ) - - def tearDown( self ) : - - for f in [ - "test/IECoreMaya/op.ma" , - "test/IECoreMaya/defaultConnections.ma" , - "test/IECoreMaya/compoundObjectConnections.ma" , - "test/IECoreMaya/reference.ma" , - "test/IECoreMaya/referenceMaster.ma", - "test/IECoreMaya/classParameterReference.ma" , - "test/IECoreMaya/classParameterReferencer.ma" , - "test/IECoreMaya/objectParameterIO.ma", - "test/IECoreMaya/objectMFnDataParameterIO.ma", - "test/IECoreMaya/imageProcedural.ma", - "test/IECoreMaya/classParameter.ma", - "test/IECoreMaya/classVectorParameter.ma", - "test/IECoreMaya/nonStorableObjectParameter.ma", - "test/IECoreMaya/connectedNodeReference.ma", - "test/IECoreMaya/connectedNodeReference2.ma", - "test/IECoreMaya/meshParameterIO.ma", - "test/IECoreMaya/shouldSaveAttributes.ma", - ] : - - if os.path.exists( f ) : - - os.remove( f ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/PlaybackFrameList.py b/test/IECoreMaya/PlaybackFrameList.py deleted file mode 100644 index 0a403bc6d8..0000000000 --- a/test/IECoreMaya/PlaybackFrameList.py +++ /dev/null @@ -1,53 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class TestPlaybackFrameList( IECoreMaya.TestCase ) : - - def test( self ): - """ Test PlaybackFrameList """ - - r = IECoreMaya.PlaybackFrameList( IECoreMaya.PlaybackFrameList.Range.Animation ) - - l = r.asList() - - self.assertEqual( l, list(range( int( maya.cmds.playbackOptions( query=True, animationStartTime=True ) ), - int( maya.cmds.playbackOptions( query=True, animationEndTime=True ) + 1 ))) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/PluginLoadUnload.py b/test/IECoreMaya/PluginLoadUnload.py deleted file mode 100644 index b44996dc31..0000000000 --- a/test/IECoreMaya/PluginLoadUnload.py +++ /dev/null @@ -1,70 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - -class TestPluginLoadUnload( IECoreMaya.TestCase ) : - - def test( self ): - """ Test loading/unloading of plugin """ - - # Plugin should be loaded by MayaUnitTest.TestProgram when we get here - self.assertTrue( maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) ) - - for i in range( 0, 20 ) : - - self.assertFalse( maya.cmds.pluginInfo( "ieCore", query = True, serviceDescriptions = True ) ) - - maya.cmds.unloadPlugin( "ieCore" ) - self.assertFalse( maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) ) - - maya.cmds.loadPlugin( "ieCore" ) - self.assertTrue( maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) ) - - - self.assertTrue( maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) ) - - def tearDown( self ): - - if not maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) : - maya.cmds.loadPlugin( "ieCore" ) - - # Make sure plugin is definitely loaded when we exit tests - assert( maya.cmds.pluginInfo( "ieCore", query = True, loaded = True ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/RunTimeTypedTest.py b/test/IECoreMaya/RunTimeTypedTest.py deleted file mode 100644 index ac63fe0cf3..0000000000 --- a/test/IECoreMaya/RunTimeTypedTest.py +++ /dev/null @@ -1,72 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import IECore -import IECoreMaya - -class RunTimeTypedTest( unittest.TestCase ) : - - def test( self ) : - - typeNames = {} - typeIds = {} - - for c in [ getattr( IECoreMaya, x ) for x in dir( IECoreMaya ) ] : - - try : - if not issubclass( c, IECore.RunTimeTyped ) : - continue - except TypeError : - continue # c wasn't a class - - self.assertFalse( c.staticTypeId() in typeIds ) - self.assertFalse( c.staticTypeName() in typeNames ) - - typeIds[c.staticTypeId()] = c - typeNames[c.staticTypeName()] = c - - self.assertEqual( IECore.RunTimeTyped.typeNameFromTypeId( c.staticTypeId() ), c.staticTypeName() ) - self.assertEqual( IECore.RunTimeTyped.typeIdFromTypeName( c.staticTypeName() ), c.staticTypeId() ) - - self.assertTrue( c.staticTypeId() in IECoreMaya.TypeId.values or c.staticTypeId() in IECore.TypeId.values ) - - if c.staticTypeId() in IECoreMaya.TypeId.values : - self.assertEqual( c.staticTypeId(), getattr( IECoreMaya.TypeId, c.staticTypeName() ) ) - else : - self.assertEqual( c.staticTypeId(), getattr( IECore.TypeId, c.staticTypeName() ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/SceneShapeProxyTest.py b/test/IECoreMaya/SceneShapeProxyTest.py deleted file mode 100644 index c63f0fc783..0000000000 --- a/test/IECoreMaya/SceneShapeProxyTest.py +++ /dev/null @@ -1,49 +0,0 @@ -########################################################################## -# -# Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - - -import IECoreMaya -import maya.cmds - -import SceneShapeTest - -class SceneShapeProxyTest( SceneShapeTest.SceneShapeTest ): - - def setUp( self ): - IECoreMaya.TestCase.setUp(self) - self._shapeType = "ieSceneShapeProxy" - self._node = maya.cmds.createNode( self._shapeType ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/SceneShapeTest.py b/test/IECoreMaya/SceneShapeTest.py deleted file mode 100644 index 026e14db0a..0000000000 --- a/test/IECoreMaya/SceneShapeTest.py +++ /dev/null @@ -1,668 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - - -import os -import imath -import IECore -import IECoreScene -import IECoreMaya -import maya.cmds -import unittest - -class SceneShapeTest( IECoreMaya.TestCase ) : - - __testFile = "test/test.scc" - __testPlugFile = "test/testPlug.scc" - __testPlugAnimFile = "test/testPlugAnim.scc" - __testPlugAttrFile = "test/testPlugAttr.scc" - __testLinkFile = "test/test.lscc" - - def setUp( self ): - super( SceneShapeTest, self ).setUp() - self._shapeType = "ieSceneShape" - self._node = maya.cmds.createNode( self._shapeType ) - - def writeSCC( self, file, rotation=imath.V3d( 0, 0, 0 ), time=0 ) : - - scene = IECoreScene.SceneCache( file, IECore.IndexedIO.OpenMode.Write ) - sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - sc = sc.createChild( str( 2 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - sc.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) - matrix = matrix.rotate( rotation ) - sc.writeTransform( IECore.M44dData( matrix ), time ) - - return scene - - def writeAnimSCC( self, file ) : - - scene = self.writeSCC( file ) - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) - - for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - - matrix = imath.M44d().translate( imath.V3d( 1, time, 0 ) ) - sc1.writeTransform( IECore.M44dData( matrix ), time ) - - sc2.writeObject( mesh, time ) - matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) - sc2.writeTransform( IECore.M44dData( matrix ), time ) - - matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) - sc3.writeTransform( IECore.M44dData( matrix ), time ) - - return scene - - def writeAttributeSCC( self, file ) : - - scene = self.writeSCC( file ) - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - - sc1.writeAttribute( "boolAttr", IECore.BoolData( True ), 0.0 ) - sc1.writeAttribute( "floatAttr", IECore.FloatData( 5.20 ), 0.0 ) - - sc2.writeAttribute( "boolAttr", IECore.BoolData( False ), 0.0 ) - sc2.writeAttribute( "floatAttr", IECore.FloatData( 2.0 ), 0.0 ) - - sc3.writeAttribute( "intAttr", IECore.IntData( 12 ), 0.0 ) - sc3.writeAttribute( "strAttr", IECore.StringData( "blah" ), 0.0 ) - sc3.writeAttribute( "doubleAttr", IECore.DoubleData( 1.2 ), 0.0 ) - - return scene - - def writeTagSCC( self, file ) : - - scene = self.writeSCC( file ) - sc1 = scene.child( str( 1 ) ) - sc2 = sc1.child( str( 2 ) ) - sc3 = sc2.child( str( 3 ) ) - scene.writeTags( [ "top" ] ) - sc1.writeTags( [ "a" ] ) - sc2.writeTags( [ "b" ] ) - sc3.writeTags( [ "c" ] ) - - return scene - - def testComputePlugs( self ) : - - self.writeSCC( file = SceneShapeTest.__testFile ) - - node = self._node - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testFile,type='string' ) - maya.cmds.setAttr( node+'.root',"/",type='string' ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), None) - - maya.cmds.setAttr( node+".queryPaths[0]", "/1", type="string") - maya.cmds.setAttr( node+".queryPaths[1]", "/1/2", type="string") - maya.cmds.setAttr( node+".queryPaths[2]", "/1/2/3", type="string") - - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), None) - - # Check only the plugs we trigger get computed - maya.cmds.getAttr( node+".outTransform[0].outTranslate" ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), [0]) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), None) - - maya.cmds.getAttr( node+".outTransform[2].outTranslate" ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), [0, 2]) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), None) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), None) - - maya.cmds.getAttr( node+".outTransform[1].outTranslate" ) - maya.cmds.getAttr( node+".outBound[1].outBoundCenter" ) - - mesh = maya.cmds.createNode("mesh") - maya.cmds.connectAttr( node+'.outObjects[2]', mesh+".inMesh" ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), [0, 1, 2]) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), [1]) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), [2]) - - maya.cmds.setAttr( node+".queryPaths[3]", "/", type="string"); - self.assertEqual( maya.cmds.getAttr( node+".outTransform", mi=True ), [0, 1, 2]) - self.assertEqual( maya.cmds.getAttr( node+".outBound", mi=True ), [1]) - self.assertEqual( maya.cmds.getAttr( node+".outObjects", mi=True ), [2]) - - def testPlugValues( self ) : - - self.writeSCC( file=SceneShapeTest.__testPlugFile, rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) - - node = self._node - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testPlugFile,type='string' ) - maya.cmds.setAttr( node+'.root',"/",type='string' ) - - maya.cmds.setAttr( node+".queryPaths[0]", "/1", type="string") - maya.cmds.setAttr( node+".queryPaths[1]", "/1/2", type="string") - maya.cmds.setAttr( node+".queryPaths[2]", "/1/2/3", type="string") - - # World space - maya.cmds.setAttr( node+".querySpace", 0) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateX"), 2.732050895 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateY"), -1.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateZ"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateZ")), -60.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateX"), 4.232050895 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateY"), -3.598076105 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateZ"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateZ")), -90.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - # Local space - maya.cmds.setAttr( node+".querySpace", 1) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(2.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(3.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - # Change the root path - maya.cmds.setAttr( node+'.root', "/1",type='string' ) - - maya.cmds.setAttr( node+".queryPaths[0]", "/", type="string") - maya.cmds.setAttr( node+".queryPaths[1]", "/2", type="string") - maya.cmds.setAttr( node+".queryPaths[2]", "/2/3", type="string") - - # World space - maya.cmds.setAttr( node+".querySpace", 0) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(0.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateZ")), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateX"), 2.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateY"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate.outTranslateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateX"), 4.5980763 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateY"), -1.5 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate.outTranslateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateZ")), -60.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - # Local space - maya.cmds.setAttr( node+".querySpace", 1) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[0].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(2.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[1].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(3.0, 0.0, 0.0)] ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateX"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateY"), 0.0 ) - self.assertEqual( round(maya.cmds.getAttr( node+".outTransform[2].outRotate.outRotateZ")), -30.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - maya.cmds.setAttr( node+'.time', 5 ) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 5 ) - - def testAnimPlugValues( self ) : - - self.writeAnimSCC( file=SceneShapeTest.__testPlugAnimFile ) - - node = self._node - maya.cmds.connectAttr( "time1.outTime", node+".time" ) - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testPlugAnimFile,type='string' ) - - maya.cmds.setAttr( node+'.root',"/",type='string' ) - - maya.cmds.setAttr( node+".queryPaths[0]", "/1", type="string") - maya.cmds.setAttr( node+".queryPaths[1]", "/1/2", type="string") - maya.cmds.setAttr( node+".queryPaths[2]", "/1/2/3", type="string") - - maya.cmds.currentTime( 0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 0 ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(3.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(6.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - maya.cmds.currentTime( 48 ) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 48 ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 2.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(3.0, 4.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(6.0, 6.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - maya.cmds.currentTime( 60 ) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 60 ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 2.5, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(3.0, 5.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(6.0, 7.5, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - maya.cmds.currentTime( 0 ) - maya.cmds.setAttr( node+".querySpace", 1) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 0 ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(2.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(3.0, 0.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - maya.cmds.currentTime( 48 ) - self.assertEqual( maya.cmds.getAttr( node+".outTime" ), 48 ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outTranslate"), [(1.0, 2.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[0].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[0].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outTranslate"), [(2.0, 2.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[1].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[1].outScale"), [(1.0, 1.0, 1.0)] ) - - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outTranslate"), [(3.0, 2.0, 0.0)] ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateX"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateY"), 0.0 ) - self.assertAlmostEqual( maya.cmds.getAttr( node+".outTransform[2].outRotateZ"), 0.0 ) - self.assertEqual( maya.cmds.getAttr( node+".outTransform[2].outScale"), [(1.0, 1.0, 1.0)] ) - - def testQueryAttributes( self ) : - - self.writeAttributeSCC( file=SceneShapeTest.__testPlugAttrFile ) - - node = self._node - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testPlugAttrFile,type='string' ) - - maya.cmds.setAttr( node+".queryPaths[0]", "/1", type="string") - maya.cmds.setAttr( node+".queryPaths[1]", "/1/2", type="string") - maya.cmds.setAttr( node+".queryPaths[2]", "/1/2/3", type="string") - - maya.cmds.setAttr( node+".queryAttributes[0]", "boolAttr", type="string") - maya.cmds.setAttr( node+".queryAttributes[1]", "floatAttr", type="string") - maya.cmds.setAttr( node+".queryAttributes[2]", "intAttr", type="string") - maya.cmds.setAttr( node+".queryAttributes[3]", "strAttr", type="string") - maya.cmds.setAttr( node+".queryAttributes[4]", "blablAttr", type="string") - maya.cmds.setAttr( node+".queryAttributes[5]", "doubleAttr", type="string") - - self.assertEqual( maya.cmds.getAttr( node+".attributes[0].attributeValues[0]" ), True ) - self.assertEqual( round(maya.cmds.getAttr( node+".attributes[0].attributeValues[1]"), 6 ), 5.2 ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[0].attributeValues[2]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[0].attributeValues[3]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[0].attributeValues[4]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[0].attributeValues[5]" ), None ) - - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[0]" ), False ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[1]" ), 2.0 ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[2]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[3]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[4]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[1].attributeValues[5]" ), None ) - - self.assertEqual( maya.cmds.getAttr( node+".attributes[2].attributeValues[0]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[2].attributeValues[1]" ), None ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[2].attributeValues[2]" ), 12 ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[2].attributeValues[3]" ), "blah" ) - self.assertEqual( maya.cmds.getAttr( node+".attributes[2].attributeValues[4]" ), None ) - self.assertEqual( round(maya.cmds.getAttr( node+".attributes[2].attributeValues[5]" ), 6), 1.2 ) - - def testTags( self ) : - - self.writeTagSCC( file=SceneShapeTest.__testFile ) - - node = self._node - fn = IECoreMaya.FnSceneShape( node ) - transform = str(maya.cmds.listRelatives( node, parent=True )[0]) - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testFile, type='string' ) - - scene = IECoreMaya.LiveScene().child( transform ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.TagFilter.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c", "top" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - for tag in scene.readTags(IECoreScene.SceneInterface.TagFilter.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - - # double expanding because the first level has all the same tags - childFn = fn.expandOnce()[0].expandOnce()[0] - scene = childFn.sceneInterface() - self.assertEqual( set([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.TagFilter.DescendantTag|IECoreScene.SceneInterface.TagFilter.LocalTag ) ]), set([ "ObjectType:MeshPrimitive", "b", "c" ]) ) - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), [ "ObjectType:MeshPrimitive", "b" ] ) - for tag in scene.readTags(IECoreScene.SceneInterface.TagFilter.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - - childFn = childFn.expandOnce()[0] - scene = childFn.sceneInterface() - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.TagFilter.DescendantTag|IECoreScene.SceneInterface.TagFilter.LocalTag ) ]), [ "ObjectType:MeshPrimitive", "c" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), [ "ObjectType:MeshPrimitive", "c" ] ) - for tag in scene.readTags(IECoreScene.SceneInterface.TagFilter.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - - def testLiveSceneTags( self ) : - - self.writeTagSCC( file=SceneShapeTest.__testFile ) - - node = self._node - fn = IECoreMaya.FnSceneShape( node ) - transform = str(maya.cmds.listRelatives( node, parent=True )[0]) - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testFile, type='string' ) - - scene = IECoreMaya.LiveScene().child( transform ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.TagFilter.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c", "top" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - for tag in scene.readTags(IECoreScene.SceneInterface.TagFilter.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - - # expand once: - child1Fn = fn.expandOnce()[0] - child1 = scene.child("sceneShape_1") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - - child2Fn = child1Fn.expandOnce()[0] - child2 = child1.child("sceneShape_2") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - self.assertEqual( sorted([ str(x) for x in child2.readTags() ]), ["ObjectType:MeshPrimitive","b"] ) - - child3Fn = child2Fn.expandOnce()[0] - child3 = child2.child("sceneShape_3") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - self.assertEqual( sorted([ str(x) for x in child2.readTags() ]), ["ObjectType:MeshPrimitive","b"] ) - self.assertEqual( sorted([ str(x) for x in child3.readTags() ]), ["ObjectType:MeshPrimitive","c"] ) - - def testLinkedLiveSceneTags( self ) : - - self.writeTagSCC( file=SceneShapeTest.__testFile ) - - node = self._node - fn = IECoreMaya.FnSceneShape( node ) - transform = str(maya.cmds.listRelatives( node, parent=True )[0]) - maya.cmds.setAttr( node+'.file', SceneShapeTest.__testFile, type='string' ) - - scene = IECoreScene.LinkedScene( IECoreMaya.LiveScene() ).child( transform ) - self.assertEqual( sorted([ str(x) for x in scene.readTags( IECoreScene.SceneInterface.TagFilter.EveryTag ) ]), [ "ObjectType:MeshPrimitive", "a", "b", "c", "top" ] ) - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - for tag in scene.readTags(IECoreScene.SceneInterface.TagFilter.EveryTag) : - self.assertTrue( scene.hasTag( tag, IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - self.assertFalse( scene.hasTag( "fakeTag", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) - - # expand once: - child1Fn = fn.expandOnce()[0] - child1 = scene.child("sceneShape_1") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - - child2Fn = child1Fn.expandOnce()[0] - child2 = child1.child("sceneShape_2") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - self.assertEqual( sorted([ str(x) for x in child2.readTags() ]), ["ObjectType:MeshPrimitive","b"] ) - - child3Fn = child2Fn.expandOnce()[0] - child3 = child2.child("sceneShape_3") - self.assertEqual( sorted([ str(x) for x in scene.readTags() ]), ["top"] ) - self.assertEqual( sorted([ str(x) for x in child1.readTags() ]), ["ObjectType:MeshPrimitive","a"] ) - self.assertEqual( sorted([ str(x) for x in child2.readTags() ]), ["ObjectType:MeshPrimitive","b"] ) - self.assertEqual( sorted([ str(x) for x in child3.readTags() ]), ["ObjectType:MeshPrimitive","c"] ) - - def testReadSceneShapeLink( self ): - - # Create an .lscc with three child locations that we will time remap once we have read it back into maya - self.writeAnimSCC( SceneShapeTest.__testFile ) - - sceneCache = IECoreScene.SceneCache( SceneShapeTest.__testFile, IECore.IndexedIO.OpenMode.Read ) - linkedScene = IECoreScene.LinkedScene( SceneShapeTest.__testLinkFile, IECore.IndexedIO.OpenMode.Write ) - - noRemapLocation = linkedScene.createChild( "NoRemap" ) - noRemapLocation.writeLink( sceneCache ) - remapLocation = linkedScene.createChild( "Remap" ) - remapLocation.writeLink( sceneCache ) - holdLocation = linkedScene.createChild( "Hold" ) - holdLocation.writeLink( sceneCache ) - - del noRemapLocation, remapLocation, holdLocation - del linkedScene - - # Create a root level scene shape node to read in the .lscc - rootFn = IECoreMaya.FnSceneShape.create( "Root", shapeType=self._shapeType ) - maya.cmds.setAttr( rootFn.name() + ".file", SceneShapeTest.__testLinkFile, type="string" ) - maya.cmds.setAttr( rootFn.name() + ".root", "/", type="string" ) - - holdFn, noRemapFn, remapFn = rootFn.expandOnce() - - # check that we don't have any other value than global maya time - mayaTime = maya.cmds.currentTime( query=True ) - self.assertEqual( maya.cmds.getAttr( holdFn.name() + ".time" ), mayaTime ) - self.assertEqual( maya.cmds.getAttr( noRemapFn.name() + ".time" ), mayaTime ) - self.assertEqual( maya.cmds.getAttr( remapFn.name() + ".time" ), mayaTime ) - - # break the time connection to create a time hold - maya.cmds.disconnectAttr( rootFn.name() + ".outTime", holdFn.name() + ".time" ) - maya.cmds.setAttr( holdFn.name() + ".time", 5.0 ) - self.assertEqual( maya.cmds.getAttr( holdFn.name() + ".time" ), 5.0 ) - - # add an offset to create a time remapping - addNode = maya.cmds.createNode( "addDoubleLinear" ) - maya.cmds.connectAttr( "time1.outTime", addNode + ".input1" ) - maya.cmds.setAttr( addNode + ".input2", 10.0 ) - maya.cmds.connectAttr( addNode + ".output", remapFn.name() + ".time", force=True ) - self.assertEqual( maya.cmds.getAttr( remapFn.name() + ".time" ), 11.0 ) - - # set up the LiveScenes for actual testing - holdFn.expandAll() - holdLiveScene = IECoreMaya.LiveScene() - holdLocation = holdLiveScene.child( "|Root|Hold" ) - holdChild1 = holdLocation.child( holdLocation.childNames()[0] ) - holdChild2 = holdChild1.child( holdChild1.childNames()[0] ) - holdChild3 = holdChild2.child( holdChild2.childNames()[0] ) - holdLocations = [holdLocation, holdChild1, holdChild2, holdChild3] - - noRemapFn.expandAll() - noRemapLiveScene = IECoreMaya.LiveScene() - noRemapLocation = noRemapLiveScene.child( "|Root|NoRemap" ) - noRemapChild1 = noRemapLocation.child( noRemapLocation.childNames()[0] ) - noRemapChild2 = noRemapChild1.child( noRemapChild1.childNames()[0] ) - noRemapChild3 = noRemapChild2.child( noRemapChild2.childNames()[0] ) - noRemapLocations = [noRemapLocation, noRemapChild1, noRemapChild2, noRemapChild3] - - remapFn.expandAll() - remapLiveScene = IECoreMaya.LiveScene() - remapLocation = remapLiveScene.child( "|Root|Remap" ) - remapChild1 = remapLocation.child( remapLocation.childNames()[0] ) - remapChild2 = remapChild1.child( remapChild1.childNames()[0] ) - remapChild3 = remapChild2.child( remapChild2.childNames()[0] ) - remapLocations = [remapLocation, remapChild1, remapChild2, remapChild3] - - # set up some constants used during testing - FPS = 24 - TIME_HOLD = 5.0 - TIME_OFFSET = 10.0 - - for time in [1.0, 5.0, 10.0, 50.0, 100.0]: - - maya.cmds.currentTime( time, edit=True ) - mayaTime = maya.cmds.currentTime( query=True ) - # check that we actually moved in time - self.assertEqual( mayaTime, time ) - - # test no time remap - for location in noRemapLocations: - nodeTime = maya.cmds.getAttr( str(location.dagPath()) + ".outTime" ) - linkAttr = location.readAttribute( IECoreScene.LinkedScene.linkAttribute, mayaTime ) - self.assertFalse( linkAttr.has_key( "time" ) ) - self.assertEqual( nodeTime, mayaTime ) - - # test time remap - for location in remapLocations: - linkAttr = location.readAttribute( IECoreScene.LinkedScene.linkAttribute, mayaTime ) - self.assertTrue( linkAttr.has_key( "time" ) ) - self.assertEqual( linkAttr["time"].value * FPS, mayaTime + TIME_OFFSET ) - - # test time hold - for location in holdLocations: - linkAttr = location.readAttribute( IECoreScene.LinkedScene.linkAttribute, mayaTime ) - self.assertTrue( linkAttr.has_key( "time" ) ) - self.assertEqual( linkAttr["time"].value * FPS, TIME_HOLD ) - - - def tearDown( self ) : - - for f in [ - SceneShapeTest.__testFile, SceneShapeTest.__testPlugFile, - SceneShapeTest.__testPlugAnimFile, SceneShapeTest.__testPlugAttrFile, - SceneShapeTest.__testLinkFile - ]: - if os.path.exists( f ) : - os.remove( f ) - - - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/SplineParameterHandlerTest.py b/test/IECoreMaya/SplineParameterHandlerTest.py deleted file mode 100644 index 8d9fbc8a47..0000000000 --- a/test/IECoreMaya/SplineParameterHandlerTest.py +++ /dev/null @@ -1,434 +0,0 @@ -########################################################################## -# -# Copyright (c) 2009-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import random -import os -import unittest - -import maya.cmds -import imath - -import IECore -import IECoreMaya - -class SplineParameterHandlerTest( IECoreMaya.TestCase ) : - - class TestClassFloat( IECore.Parameterised ) : - - def __init__( self ) : - - IECore.Parameterised.__init__( self, "description" ) - - self.parameters().addParameter( - IECore.SplineffParameter( - name = "spline", - description = "description", - defaultValue = IECore.SplineffData( - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, 1 ), - ( 0, 1 ), - ( 1, 0 ), - ( 1, 0 ), - ), - ), - ), - ) - ) - - class TestClassColor( IECore.Parameterised ) : - - def __init__( self ) : - - IECore.Parameterised.__init__( self, "description" ) - - self.parameters().addParameter( - IECore.SplinefColor3fParameter( - name = "spline", - description = "description", - defaultValue = IECore.SplinefColor3fData( - IECore.SplinefColor3f( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, imath.Color3f( 1, 1, 1 ) ), - ( 0, imath.Color3f( 1, 1, 1 ) ), - ( 1, imath.Color3f( 0, 0, 0 ) ), - ( 1, imath.Color3f( 0, 0, 0 ) ), - ), - ), - ), - ) - ) - - def testRoundTripFloat( self ) : - - node = maya.cmds.createNode( "ieParameterisedHolderNode" ) - - parameterised = SplineParameterHandlerTest.TestClassFloat() - fnPH = IECoreMaya.FnParameterisedHolder( node ) - fnPH.setParameterised( parameterised ) - - random.seed( 199 ) - numTests = 100 - - for i in range( 0, numTests ) : - - numPoints = int( random.random() * 12 ) + 2 - - splinePoints = [] - - for j in range( 0, numPoints ) : - - splinePoints.append( ( random.random(), random.random() ) ) - - splinePoints.sort() - - splinePoints.insert( 0, splinePoints[0] ) - splinePoints.append( splinePoints[-1] ) - assert( len( splinePoints ) >= 4 ) - - splineData = IECore.SplineffData( - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), - splinePoints - ) - ) - - parameterised.parameters()["spline"].setValue( splineData ) - - # Put the value to the node's attributes - fnPH.setNodeValue( parameterised.parameters()["spline"], False ) - - # Retrieve the value from the node's attributes - fnPH.setParameterisedValue( parameterised.parameters()["spline"] ) - - # The parameter value should not have changed - - data = parameterised.parameters()["spline"].getValue() - self.assertEqual( len( data.value ), len( splineData.value ) ) - - for i in range( 0, len( data.value ) ) : - - self.assertAlmostEqual( list(data.value.keys())[i], list(splineData.value.keys())[i] ) - self.assertAlmostEqual( list(data.value.values())[i], list(splineData.value.values())[i] ) - - def testRoundTripColor( self ) : - - node = maya.cmds.createNode( "ieParameterisedHolderNode" ) - - parameterised = SplineParameterHandlerTest.TestClassColor() - fnPH = IECoreMaya.FnParameterisedHolder( node ) - fnPH.setParameterised( parameterised ) - - random.seed( 205 ) - numTests = 10 - - for i in range( 0, numTests ) : - - numPoints = int( random.random() * 12 ) + 2 - - splinePoints = [] - - for j in range( 0, numPoints ) : - - splinePoints.append( ( random.random(), imath.Color3f( random.random(), random.random(), random.random() ) ) ) - - splinePoints.sort() - - splinePoints.insert( 0, splinePoints[0] ) - splinePoints.append( splinePoints[-1] ) - assert( len( splinePoints ) >= 4 ) - - splineData = IECore.SplinefColor3fData( - IECore.SplinefColor3f( - IECore.CubicBasisf.catmullRom(), - splinePoints - ) - ) - - parameterised.parameters()["spline"].setValue( splineData ) - - # Put the value to the node's attributes - fnPH.setNodeValue( parameterised.parameters()["spline"], False ) - - # Retrieve the value from the node's attributes - fnPH.setParameterisedValue( parameterised.parameters()["spline"] ) - - # The parameter value should not have changed - - data = parameterised.parameters()["spline"].getValue() - self.assertEqual( len( data.value ), len( splineData.value ) ) - - for i in range( 0, len( data.value ) ) : - - self.assertAlmostEqual( list(data.value.keys())[i], list(splineData.value.keys())[i] ) - - c1 = list(data.value.values())[i] - c2 = list(splineData.value.values())[i] - - v1 = imath.V3f( c1[0], c1[1], c1[2] ) - v2 = imath.V3f( c2[0], c2[1], c2[2] ) - - - self.assertTrue( ( v1 - v2 ).length() < 1.e-4 ) - - def testRoundTripAfterSerialisation( self ) : - - # make a scene with an OpHolder holding an op with a spline parameter - fnOH = IECoreMaya.FnOpHolder.create( "test", "splineInput", 1 ) - opNode = fnOH.fullPathName() - op = fnOH.getOp() - - # save it - maya.cmds.file( rename = os.getcwd() + "/test/IECoreMaya/splineParameterHandlerTest.ma" ) - sceneFileName = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # load it - maya.cmds.file( new=True, force=True ) - maya.cmds.file( sceneFileName, force=True, open=True ) - - fnOH = IECoreMaya.FnOpHolder( opNode ) - op = fnOH.getOp() - - # stick a new value on - splineData = IECore.SplineffData( - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), ( - ( 0, 0.644737 ), - ( 0, 0.644737 ), - ( 0.257426, 0.0789474 ), - ( 1, -0.3 ), - ( 1, -0.3 ) - ) - ) - ) - - op["spline"].setValue( splineData ) - - # convert the value to maya - fnOH.setNodeValue( op["spline"] ) - - # convert it back - fnOH.setParameterisedValue( op["spline"] ) - - # make sure it worked - splineData2 = op["spline"].getValue() - self.assertEqual( splineData, splineData2 ) - - # do it all again just for kicks - op["spline"].setValue( splineData ) - fnOH.setNodeValue( op["spline"] ) - fnOH.setParameterisedValue( op["spline"] ) - splineData2 = op["spline"].getValue() - self.assertEqual( splineData, splineData2 ) - - def testSparseEntries( self ) : - - # load a scene where we have a spline parameter with sparse entries. - maya.cmds.file( os.getcwd() + "/test/IECoreMaya/scenes/splineWithSparseEntries.ma", force=True, open=True ) - - fnOH = IECoreMaya.FnOpHolder( "test" ) - op = fnOH.getOp() - - # stick a new value on - splineData = IECore.SplineffData( - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), ( - ( 0, 0.644737 ), - ( 0, 0.644737 ), - ( 0.257426, 0.0789474 ), - ( 1, -0.3 ), - ( 1, -0.3 ) - ) - ) - ) - - op["spline"].setValue( splineData ) - - # convert the value to maya - fnOH.setNodeValue( op["spline"] ) - - # convert it back - fnOH.setParameterisedValue( op["spline"] ) - - # make sure it worked - splineData2 = op["spline"].getValue() - self.assertEqual( splineData, splineData2 ) - - # do it all again just for kicks - op["spline"].setValue( splineData ) - fnOH.setNodeValue( op["spline"] ) - fnOH.setParameterisedValue( op["spline"] ) - splineData2 = op["spline"].getValue() - self.assertEqual( splineData, splineData2 ) - - @unittest.skipIf( maya.OpenMaya.MGlobal.apiVersion() >= 201500, "Reference edits for splines don't work in Maya 2016" ) - def testAddColorSplineToReferencedNode( self ) : - - # make a scene with an empty op holder - ###################################### - - maya.cmds.createNode( "ieOpHolderNode" ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReference.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # reference it in and add an op with a color spline - ################################################### - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:ieOpHolderNode1" ) - fnOH.setOp( "colorSplineInput", 1 ) - - fnOH.setParameterisedValues() - - self.assertEqual( - fnOH.getOp()["spline"].getValue().value, - IECore.SplinefColor3f( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, imath.Color3f( 1 ) ), - ( 0, imath.Color3f( 1 ) ), - ( 1, imath.Color3f( 0 ) ), - ( 1, imath.Color3f( 0 ) ), - ), - ) - ) - - # save the scene, and reload it. check that we've worked - # around another wonderful maya referencing bug - ######################################################## - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReferencer.ma" ) ) - referencerScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referencerScene, force = True, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:ieOpHolderNode1" ) - - fnOH.setParameterisedValues() - - self.assertEqual( - fnOH.getOp()["spline"].getValue().value, - IECore.SplinefColor3f( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, imath.Color3f( 1 ) ), - ( 0, imath.Color3f( 1 ) ), - ( 1, imath.Color3f( 0 ) ), - ( 1, imath.Color3f( 0 ) ), - ), - ) - ) - - @unittest.skipIf( maya.OpenMaya.MGlobal.apiVersion() >= 201500, "Reference edits for splines don't work in Maya 2016" ) - def testAddFloatSplineToReferencedNode( self ) : - - # make a scene with an empty op holder - ###################################### - - maya.cmds.createNode( "ieOpHolderNode" ) - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReference.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # reference it in and add an op with a color spline - ################################################### - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:ieOpHolderNode1" ) - fnOH.setOp( "splineInput", 1 ) - - fnOH.setParameterisedValues() - - self.assertEqual( - fnOH.getOp()["spline"].getValue().value, - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, 1 ), - ( 0, 1 ), - ( 1, 0 ), - ( 1, 0 ), - ), - ) - ) - - # save the scene, and reload it. check that we've worked - # around another wonderful maya referencing bug - ######################################################## - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReferencer.ma" ) ) - referencerScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referencerScene, force = True, open = True ) - - fnOH = IECoreMaya.FnOpHolder( "ns1:ieOpHolderNode1" ) - - fnOH.setParameterisedValues() - - self.assertEqual( - fnOH.getOp()["spline"].getValue().value, - IECore.Splineff( - IECore.CubicBasisf.catmullRom(), - ( - ( 0, 1 ), - ( 0, 1 ), - ( 1, 0 ), - ( 1, 0 ), - ), - ) - ) - - def tearDown( self ) : - - paths = [ - os.getcwd() + "/test/IECoreMaya/splineParameterHandlerTest.ma", - os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReference.ma" ), - os.path.join( os.getcwd(), "test", "IECoreMaya", "opHolderReferencer.ma" ), - ] - - for path in paths : - if os.path.exists( path ) : - os.remove( path ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/TemporaryAttributeValuesTest.py b/test/IECoreMaya/TemporaryAttributeValuesTest.py deleted file mode 100644 index 1cd3be64e8..0000000000 --- a/test/IECoreMaya/TemporaryAttributeValuesTest.py +++ /dev/null @@ -1,212 +0,0 @@ -########################################################################## -# -# Copyright (c) 2009-2012, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import os - -import maya.cmds -import imath - -import IECore -import IECoreMaya - -class TemporaryAttributeValuesTest( IECoreMaya.TestCase ) : - - def test( self ) : - - s = maya.cmds.spaceLocator()[0] - - maya.cmds.addAttr( s, at="enum", sn="enumTest", enumName="A:B:C", defaultValue = 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".enumTest" ), 1 ) - - maya.cmds.addAttr( s, at="bool", sn="boolTest", defaultValue=1 ) - self.assertEqual( maya.cmds.getAttr( s + ".boolTest" ), 1 ) - - maya.cmds.addAttr( s, at="float", sn="floatTest" ) - self.assertEqual( maya.cmds.getAttr( s + ".floatTest" ), 0 ) - - maya.cmds.addAttr( s, at="long", sn="intTest" ) - self.assertEqual( maya.cmds.getAttr( s + ".intTest" ), 0 ) - - maya.cmds.addAttr( s, at="float2", sn="float2Test" ) - maya.cmds.addAttr( s, at="float", sn="float2TestX", parent="float2Test" ) - maya.cmds.addAttr( s, at="float", sn="float2TestY", parent="float2Test" ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestX" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestY" ), 0 ) - - maya.cmds.addAttr( s, at="long2", sn="int2Test" ) - maya.cmds.addAttr( s, at="long", sn="int2TestX", parent="int2Test", defaultValue=1 ) - maya.cmds.addAttr( s, at="long", sn="int2TestY", parent="int2Test", defaultValue=2 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestX" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestY" ), 2 ) - - maya.cmds.addAttr( s, at="float3", sn="float3Test" ) - maya.cmds.addAttr( s, at="float", sn="float3TestX", parent="float3Test", defaultValue=10 ) - maya.cmds.addAttr( s, at="float", sn="float3TestY", parent="float3Test", defaultValue=20 ) - maya.cmds.addAttr( s, at="float", sn="float3TestZ", parent="float3Test", defaultValue=30 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestX" ), 10 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestY" ), 20 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestZ" ), 30 ) - - - maya.cmds.addAttr( s, at="short3", sn="short3Test" ) - maya.cmds.addAttr( s, at="short", sn="short3TestX", parent="short3Test", defaultValue=101 ) - maya.cmds.addAttr( s, at="short", sn="short3TestY", parent="short3Test", defaultValue=201 ) - maya.cmds.addAttr( s, at="short", sn="short3TestZ", parent="short3Test", defaultValue=301 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestX" ), 101 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestY" ), 201 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestZ" ), 301 ) - - maya.cmds.addAttr( s, dt="string", sn="stringTest" ) - maya.cmds.setAttr( s + ".stringTest", "hi", type="string" ) - self.assertEqual( maya.cmds.getAttr( s + ".stringTest" ), "hi" ) - - context = IECoreMaya.TemporaryAttributeValues( - { - s + ".enumTest" : 2, - s + ".boolTest" : False, - s + ".floatTest" : 10, - s + ".intTest" : 20, - s + ".float2Test" : ( 1, 2 ), - s + ".int2Test" : imath.V2i( 3, 4 ), - s + ".float3Test" : ( 9, 6, 1 ), - s + ".short3Test" : ( 500, 2, -1 ), - s + ".stringTest" : "bye", - } - ) - - with context : - - self.assertEqual( maya.cmds.getAttr( s + ".enumTest" ), 2 ) - self.assertEqual( maya.cmds.getAttr( s + ".boolTest" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".floatTest" ), 10 ) - self.assertEqual( maya.cmds.getAttr( s + ".intTest" ), 20 ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestX" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestY" ), 2 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestX" ), 3 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestY" ), 4 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestX" ), 9 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestY" ), 6 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestZ" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestX" ), 500 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestY" ), 2 ) - self.assertEqual( maya.cmds.getAttr( s + ".short3TestZ" ), -1 ) - self.assertEqual( maya.cmds.getAttr( s + ".stringTest" ), "bye" ) - - self.assertEqual( maya.cmds.getAttr( s + ".enumTest" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".boolTest" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".floatTest" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".intTest" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestX" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".float2TestY" ), 0 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestX" ), 1 ) - self.assertEqual( maya.cmds.getAttr( s + ".int2TestY" ), 2 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestX" ), 10 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestY" ), 20 ) - self.assertEqual( maya.cmds.getAttr( s + ".float3TestZ" ), 30 ) - self.assertEqual( maya.cmds.getAttr( s + ".stringTest" ), "hi" ) - - def testNameSpaceAttributes( self ) : - - maya.cmds.namespace( add="ns1" ) - s = maya.cmds.spaceLocator()[0] - maya.cmds.addAttr( s, at="enum", sn="enumTest", enumName="A:B:C", defaultValue = 1 ) - s = maya.cmds.rename( s, "ns1:"+s ) - plugPath = s + ".enumTest" - maya.cmds.namespace( set=":" ) - - self.assertEqual( plugPath, "ns1:locator1.enumTest" ) - self.assertEqual( maya.cmds.namespace( exists="ns1" ), True ) - self.assertEqual( maya.cmds.namespaceInfo( currentNamespace=True ), ":" ) - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - with IECoreMaya.TemporaryAttributeValues( { plugPath : 2 } ) : - self.assertEqual( maya.cmds.getAttr( plugPath ), 2 ) - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - def testReferenceAttributes( self ) : - - s = maya.cmds.spaceLocator()[0] - - maya.cmds.addAttr( s, at="enum", sn="enumTest", enumName="A:B:C", defaultValue = 1 ) - - plugPath = s + ".enumTest" - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - with IECoreMaya.TemporaryAttributeValues( { plugPath : 2 } ) : - self.assertEqual( maya.cmds.getAttr( plugPath ), 2 ) - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - # save it to a file - ####################################################################### - - maya.cmds.file( rename = os.path.join( os.getcwd(), "test", "IECoreMaya", "temporaryAttributeReference.ma" ) ) - referenceScene = maya.cmds.file( force = True, type = "mayaAscii", save = True ) - - # make a new scene referencing that file - ####################################################################### - - maya.cmds.file( new = True, force = True ) - maya.cmds.file( referenceScene, reference = True, namespace = "ns1" ) - - plugPath = "ns1:" + s + ".enumTest" - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - with IECoreMaya.TemporaryAttributeValues( { plugPath : 2 } ) : - self.assertEqual( maya.cmds.getAttr( plugPath ), 2 ) - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - with IECoreMaya.TemporaryAttributeValues( { plugPath : 0 } ) : - self.assertEqual( maya.cmds.getAttr( plugPath ), 0 ) - - self.assertEqual( maya.cmds.getAttr( plugPath ), 1 ) - - def tearDown( self ) : - - for f in [ - "test/IECoreMaya/temporaryAttributeReference.ma" , - ] : - - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaCameraConverterTest.py b/test/IECoreMaya/ToMayaCameraConverterTest.py deleted file mode 100644 index 5f1d3a4960..0000000000 --- a/test/IECoreMaya/ToMayaCameraConverterTest.py +++ /dev/null @@ -1,357 +0,0 @@ -########################################################################## -# -# Copyright (c) 2012-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreScene -import IECoreMaya -import unittest - -import imath -import random - -INCH_TO_MM = 25.400051 - -class ToMayaCameraConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - converter = IECoreMaya.ToMayaObjectConverter.create( IECoreScene.Camera() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaCameraConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.ToMayaCameraConverter ) ) ) - - def assertMayaCamsEqual( self, camA, camB ) : - - self.assertAlmostEqual( maya.cmds.getAttr( camA+".nearClipPlane" ), maya.cmds.getAttr( camB+".nearClipPlane" ) ) - self.assertAlmostEqual( maya.cmds.getAttr( camA+".farClipPlane" ), maya.cmds.getAttr( camB+".farClipPlane" ) ) - self.assertEqual( maya.cmds.getAttr( camA+".orthographic" ), maya.cmds.getAttr( camB+".orthographic" ) ) - - if maya.cmds.getAttr( camA+".orthographic" ): - self.assertAlmostEqual( maya.cmds.getAttr( camA+".orthographicWidth" ), maya.cmds.getAttr( camB+".orthographicWidth" ) ) - else: - self.assertAlmostEqual( maya.cmds.getAttr( camA+".horizontalFilmAperture" ), maya.cmds.getAttr( camB+".horizontalFilmAperture" ) ) - self.assertAlmostEqual( maya.cmds.getAttr( camA+".verticalFilmAperture" ), maya.cmds.getAttr( camB+".verticalFilmAperture" ) ) - self.assertAlmostEqual( maya.cmds.getAttr( camA+".horizontalFilmOffset" ), maya.cmds.getAttr( camB+".horizontalFilmOffset" ) ) - self.assertAlmostEqual( maya.cmds.getAttr( camA+".verticalFilmOffset" ), maya.cmds.getAttr( camB+".verticalFilmOffset" ) ) - - def assertMayaCamsNotEqual( self, camA, camB ) : - - self.assertNotAlmostEqual( maya.cmds.getAttr( camA+".nearClipPlane" ), maya.cmds.getAttr( camB+".nearClipPlane" ) ) - self.assertNotAlmostEqual( maya.cmds.getAttr( camA+".farClipPlane" ), maya.cmds.getAttr( camB+".farClipPlane" ) ) - self.assertNotAlmostEqual( maya.cmds.getAttr( camA+".orthographic" ), maya.cmds.getAttr( camB+".orthographic" ) ) - - def assertIECoreCamsAlmostEqual( self, camA, camB, names=False ) : - - self.assertEqual( list(camA.parameters().keys()), list(camB.parameters().keys()) ) - - for a in camA.parameters().keys(): - if type( camA.parameters()[a] ) == IECore.V2fData: - self.assertTrue( camA.parameters()[a].value.equalWithRelError( camB.parameters()[a].value, 0.000001 ) ) - elif type( camA.parameters()[a] ) == float: - self.assertAlmostEqual( camA.parameters()[a], camB.parameters()[a] ) - else: - self.assertEqual( camA.parameters()[a], camB.parameters()[a] ) - - - def assertIECoreCamAndMayaCamEqual( self, coreCam, mayaCam ) : - - sel = maya.OpenMaya.MSelectionList() - sel.add( mayaCam ) - dag = maya.OpenMaya.MDagPath() - sel.getDagPath( 0, dag ) - fn = maya.OpenMaya.MFnCamera( dag ) - - self.assertEqual( coreCam.getClippingPlanes(), imath.V2f( maya.cmds.getAttr( mayaCam+".nearClipPlane" ), maya.cmds.getAttr( mayaCam+".farClipPlane" ) ) ) - - # If the focal length is less than 2.5, we can check the specific parameters for matching, since - # Maya doesn't allow focal lengths less than 2.5, but we can still check that the frustum matches - if coreCam.getFocalLength() >= 2.5: - self.assertAlmostEqual( coreCam.getApertureOffset()[0], maya.cmds.getAttr( mayaCam+".horizontalFilmOffset" ) * INCH_TO_MM, places = 6 ) - self.assertAlmostEqual( coreCam.getApertureOffset()[1], maya.cmds.getAttr( mayaCam+".verticalFilmOffset" ) * INCH_TO_MM, places = 6 ) - - - if coreCam.parameters()["projection"].value == "perspective" : - self.assertFalse( maya.cmds.getAttr( mayaCam+".orthographic" ) ) - self.assertAlmostEqual( coreCam.getFocalLength(), fn.focalLength() ) - self.assertAlmostEqual( coreCam.getAperture()[0], fn.horizontalFilmAperture() * INCH_TO_MM, places = 5 ) - self.assertAlmostEqual( coreCam.getAperture()[1], fn.verticalFilmAperture() * INCH_TO_MM, places = 5 ) - else : - self.assertTrue( maya.cmds.getAttr( mayaCam+".orthographic" ) ) - self.assertEqual( coreCam.getAperture(), imath.V2f( maya.cmds.getAttr( mayaCam+".orthographicWidth" ) ) ) - - if coreCam.getFStop() > 0.0: - self.assertTrue( fn.isDepthOfField() ) - self.assertEqual( coreCam.getFStop(), fn.fStop() ) - else: - self.assertFalse( fn.isDepthOfField() ) - - self.assertEqual( coreCam.getFocusDistance(), fn.focusDistance() ) - - # Check that the actual frustum computed by Maya matches the frustum computed by Cortex - utils = [ maya.OpenMaya.MScriptUtil() for i in range(4)] - utilPtrs = [ i.asDoublePtr() for i in utils ] - fn.getFilmFrustum( 1, *utilPtrs ) - mayaFrustum = [ maya.OpenMaya.MScriptUtil.getDouble( i ) for i in utilPtrs ] - - cortexFrustum = coreCam.frustum( IECoreScene.Camera.FilmFit.Distort ) - self.assertAlmostEqual( mayaFrustum[0], cortexFrustum.size()[0], places = 5 ) - self.assertAlmostEqual( mayaFrustum[1], cortexFrustum.size()[1], places = 5 ) - - # Note the ridiculous conversion factor because the offset returned by getFilmFrustum - # isn't actually relative to the focalLength you have to pass in ( Thanks, Maya ) - self.assertAlmostEqual( mayaFrustum[2] * INCH_TO_MM / fn.focalLength(), cortexFrustum.center()[0], places = 6 ) - self.assertAlmostEqual( mayaFrustum[3] * INCH_TO_MM / fn.focalLength(), cortexFrustum.center()[1], places = 6 ) - - - def testExistingCam( self ) : - - maya.cmds.setAttr( "topShape.nearClipPlane", 1 ) - maya.cmds.setAttr( "topShape.farClipPlane", 1000 ) - maya.cmds.setAttr( "topShape.horizontalFilmAperture", 2 ) - maya.cmds.setAttr( "topShape.verticalFilmAperture", 1 ) - - self.assertMayaCamsNotEqual( "perspShape", "topShape" ) - - persp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - top = IECoreMaya.FromMayaCameraConverter( "topShape" ).convert() - self.assertNotEqual( persp, top ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( persp ).convert( "topShape" ) ) - self.assertMayaCamsEqual( "perspShape", "topShape" ) - self.assertIECoreCamAndMayaCamEqual( persp, "topShape" ) - - newTop = IECoreMaya.FromMayaCameraConverter( "topShape" ).convert() - self.assertEqual( persp.parameters(), newTop.parameters() ) - - def testExistingCamParent( self ) : - - maya.cmds.setAttr( "frontShape.nearClipPlane", 1 ) - maya.cmds.setAttr( "frontShape.farClipPlane", 1000 ) - maya.cmds.setAttr( "frontShape.orthographicWidth", 2 ) - - self.assertMayaCamsNotEqual( "frontShape", "perspShape" ) - - front = IECoreMaya.FromMayaCameraConverter( "frontShape" ).convert() - persp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertNotEqual( front, persp ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( front ).convert( "persp" ) ) - self.assertMayaCamsEqual( "frontShape", "perspShape" ) - self.assertIECoreCamAndMayaCamEqual( front, "perspShape" ) - - newPersp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertEqual( front.parameters(), newPersp.parameters() ) - - def testNewCam( self ) : - - persp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - - parent = maya.cmds.createNode( "transform" ) - self.assertTrue( IECoreMaya.ToMayaCameraConverter( persp ).convert( parent ) ) - - cams = maya.cmds.listRelatives( parent, children=True, fullPath=True, type="camera" ) - self.assertEqual( len(cams), 1 ) - self.assertMayaCamsEqual( "|persp|perspShape", cams[0] ) - self.assertIECoreCamAndMayaCamEqual( persp, cams[0] ) - - newCam = IECoreMaya.FromMayaCameraConverter( cams[0] ).convert() - self.assertEqual( persp.parameters(), newCam.parameters() ) - - def testWrongIECoreObject( self ) : - - converter = IECoreMaya.ToMayaCameraConverter( IECoreScene.MeshPrimitive() ) - - messageHandler = IECore.CapturingMessageHandler() - with messageHandler : - self.assertFalse( converter.convert( "topShape" ) ) - - self.assertEqual( len( messageHandler.messages ), 1 ) - self.assertEqual( messageHandler.messages[0].level, IECore.MessageHandler.Level.Warning ) - self.assertEqual( messageHandler.messages[0].context, "ToMayaCameraConverter::doConversion" ) - - def testWrongMayaNode( self ) : - - maya.cmds.polySphere( name="pSphere" ) - persp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - converter = IECoreMaya.ToMayaCameraConverter( persp ) - - messageHandler = IECore.CapturingMessageHandler() - with messageHandler : - self.assertFalse( converter.convert( "pSphereShape" ) ) - - self.assertEqual( len( messageHandler.messages ), 1 ) - self.assertEqual( messageHandler.messages[0].level, IECore.MessageHandler.Level.Warning ) - self.assertEqual( messageHandler.messages[0].context, "ToMayaCameraConverter::doConversion" ) - - def testFilmOffset( self ) : - for x in [ -0.5, -0.25, 0, 0.25, 0.5 ] : - - maya.cmds.setAttr( "perspShape.horizontalFilmOffset", x ) - self.assertNotAlmostEqual( maya.cmds.getAttr( "frontShape.horizontalFilmOffset" ), maya.cmds.getAttr( "perspShape.horizontalFilmOffset" ) ) - - for y in [ -0.5, -0.25, 0, 0.25, 0.5 ] : - - maya.cmds.setAttr( "perspShape.verticalFilmOffset", y ) - self.assertNotAlmostEqual( maya.cmds.getAttr( "frontShape.verticalFilmOffset" ), maya.cmds.getAttr( "perspShape.verticalFilmOffset" ) ) - - front = IECoreMaya.FromMayaCameraConverter( "frontShape" ).convert() - persp = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() - self.assertNotEqual( front, persp ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( persp ).convert( "front" ) ) - self.assertMayaCamsEqual( "frontShape", "perspShape" ) - self.assertIECoreCamAndMayaCamEqual( persp, "frontShape" ) - - newFront = IECoreMaya.FromMayaCameraConverter( "frontShape" ).convert() - self.assertEqual( persp.parameters(), newFront.parameters() ) - - def testRandomCameras( self ) : - - random.seed( 42 ) - for i in range( 40 ): - randomCamera = maya.cmds.camera()[0] - cortexCamera = IECoreScene.Camera() - projection = "orthographic" if random.random() > 0.5 else "perspective" - cortexCamera.setProjection( projection ) - cortexCamera.setAperture( imath.V2f( random.uniform( 1, 20 ), random.uniform( 1, 20 ) ) ) - cortexCamera.setApertureOffset( imath.V2f( random.uniform( -10, 10 ), random.uniform( -10, 10 ) ) ) - if projection != "orthographic": - cortexCamera.setFocalLength( random.uniform( 2.5, 200 ) ) - - cortexCamera.setClippingPlanes( random.uniform( 1, 1000 ) + imath.V2f( 0, random.uniform( 1, 1000 ) ) ) - - cortexCamera.setFStop( random.uniform( 1, 10 ) ) - cortexCamera.setFocusDistance( random.uniform( 0, 1000 ) ) - - if cortexCamera.getProjection() == "orthographic": - # Remove settings which we know will fail on ortho cameras in Maya ( see test below ) - del cortexCamera.parameters()["apertureOffset"] - - # Only square apertures supported - cortexCamera.setAperture( imath.V2f( cortexCamera.getAperture()[0] ) ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( randomCamera ) ) - self.assertIECoreCamAndMayaCamEqual( cortexCamera, randomCamera ) - roundTrip = IECoreMaya.FromMayaCameraConverter( randomCamera ).convert() - self.assertIECoreCamsAlmostEqual( cortexCamera, roundTrip ) - - maya.cmds.delete( randomCamera ) - - # Maya doesn't allow ortho cameras with rectangular apertures or aperture offsets - # That means that this test can never pass - it's just here to document that we can't successfully - # round trip all cameras - @unittest.expectedFailure - def testUnrepresentable( self ) : - - testCamera = maya.cmds.camera()[0] - cortexCamera = IECoreScene.Camera() - cortexCamera.setProjection( "orthographic" ) - cortexCamera.setAperture( imath.V2f( 1, 2 ) ) - cortexCamera.setClippingPlanes( imath.V2f( 1, 100 ) ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( testCamera ) ) - self.assertIECoreCamAndMayaCamEqual( cortexCamera, testCamera ) - roundTrip = IECoreMaya.FromMayaCameraConverter( testCamera ).convert() - self.assertIECoreCamsAlmostEqual( cortexCamera, roundTrip ) - - cortexCamera.setApertureOffset( imath.V2f( 3, 4 ) ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( testCamera ) ) - self.assertIECoreCamAndMayaCamEqual( cortexCamera, testCamera ) - roundTrip = IECoreMaya.FromMayaCameraConverter( testCamera ).convert() - self.assertIECoreCamsAlmostEqual( cortexCamera, roundTrip ) - - maya.cmds.delete( testCamera ) - - # For small focal lengths, we have to clamp focalLength to at least 2.5, and adjust aperture accordingly - # ( Due to silly limitation of Maya ) - def testSmallFocalLengths( self ) : - - random.seed( 42 ) - for i in range( 40 ): - randomCamera = maya.cmds.camera()[0] - cortexCamera = IECoreScene.Camera() - cortexCamera.setProjection( "perspective" ) - cortexCamera.setAperture( imath.V2f( random.uniform( 0.1, 0.5 ), random.uniform( 0.1, 0.5 ) ) ) - cortexCamera.setApertureOffset( imath.V2f( random.uniform( -0.5, 0.5 ), random.uniform( -0.5, 0.5 ) ) ) - cortexCamera.setFocalLength( random.uniform( 0.1, 1 ) ) - - cortexCamera.setClippingPlanes( random.uniform( 1, 1000 ) + imath.V2f( 0, random.uniform( 1, 1000 ) ) ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( randomCamera ) ) - self.assertIECoreCamAndMayaCamEqual( cortexCamera, randomCamera ) - - maya.cmds.delete( randomCamera ) - - def testFocalLengthWorldScale( self ) : - - testCamera = maya.cmds.camera()[0] - cortexCamera = IECoreScene.Camera() - cortexCamera.setProjection( "perspective" ) - cortexCamera.setAperture( imath.V2f( 36, 24 ) ) - cortexCamera.setFocalLength( 35 ) - cortexCamera.setClippingPlanes( imath.V2f( 1, 100 ) ) - cortexCamera.setApertureOffset( imath.V2f( 0 ) ) - cortexCamera.setFocusDistance( 1 ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( testCamera ) ) - self.assertIECoreCamAndMayaCamEqual( cortexCamera, testCamera ) - roundTrip = IECoreMaya.FromMayaCameraConverter( testCamera ).convert() - self.assertIECoreCamsAlmostEqual( cortexCamera, roundTrip ) - - for scale in [ 1.0, 0.01 ]: - cortexCamera.setFocalLengthWorldScale( scale ) - - self.assertTrue( IECoreMaya.ToMayaCameraConverter( cortexCamera ).convert( testCamera ) ) - - sel = maya.OpenMaya.MSelectionList() - sel.add( testCamera ) - dag = maya.OpenMaya.MDagPath() - sel.getDagPath( 0, dag ) - fn = maya.OpenMaya.MFnCamera( dag ) - self.assertAlmostEqual( fn.focalLength(), cortexCamera.getFocalLength() * scale / 0.1, places = 6 ) - - roundTrip = IECoreMaya.FromMayaCameraConverter( testCamera ).convert() - self.assertAlmostEqual( roundTrip.getFocalLength(), cortexCamera.getFocalLength() * scale / 0.1, places = 6 ) - - # Check that despite using different units for focalLength and aperture, we still get the - # same frustum - self.assertEqual( roundTrip.frustum(), cortexCamera.frustum() ) - - maya.cmds.delete( testCamera ) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaCurveConverterTest.py b/test/IECoreMaya/ToMayaCurveConverterTest.py deleted file mode 100644 index 6414f2b1bd..0000000000 --- a/test/IECoreMaya/ToMayaCurveConverterTest.py +++ /dev/null @@ -1,217 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.OpenMaya as OpenMaya -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaCurveConverterTest( IECoreMaya.TestCase ) : - - def testConstructor( self ) : - - i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) - - converter = IECoreMaya.ToMayaCurveConverter( coreCurves ) - transform = maya.cmds.createNode( "transform" ) - converter.convert( transform ) - self.assertEqual( maya.cmds.nodeType( maya.cmds.listRelatives( transform, shapes=True )[0] ), "nurbsCurve" ) - - def testConversion( self ) : - - # open, cubic curve: - i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaCurveConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaObjectConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.FromCoreConverter.staticTypeId() ) ) - - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaCurve = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMin" ), [( 0, 0, 0 )] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMax" ), [( 3, 3, 3 )] ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".degree" ), 3 ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".cv[*]" ), [(0,0,0),(1,1,1),(2,2,2),(3,3,3)] ) - - def testPeriodic( self ) : - - i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 1, 0, 0 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), True, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaCurve = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMin" ), [( 0, 0, 0 )] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMax" ), [( 1, 1, 0 )] ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".degree" ), 3 ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".cv[*]" ), [(0,0,0),(0,0,0),(0,0,0),(0,1,0),(1,1,0),(1,0,0)] ) - - def testOpenLinear( self ) : - - # open, cubic curve: - i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.linear(), False, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaCurve = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMin" ), [( 0, 0, 0 )] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMax" ), [( 3, 3, 3 )] ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".degree" ), 1 ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".cv[*]" ), [(0,0,0),(1,1,1),(2,2,2),(3,3,3)] ) - - def testPeriodicLinear( self ) : - - i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 1, 0, 0 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.linear(), True, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaCurve = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMin" ), [( 0, 0, 0 )] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".boundingBoxMax" ), [( 1, 1, 0 )] ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".degree" ), 1 ) - - self.assertEqual( maya.cmds.getAttr( mayaCurve + ".cv[*]" ), [(0,0,0),(0,1,0),(1,1,0),(1,0,0)] ) - - def testCurveIndex( self ): - - i = IECore.IntVectorData( [ 8, 9, 10, 11] ) - cvs = [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] - cvs.extend([ imath.V3f( 4 ), imath.V3f( 4 ), imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), imath.V3f( 8 ), imath.V3f( 8 ), imath.V3f( 8 ) ]) - cvs.extend([ imath.V3f( 9 ), imath.V3f( 9 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), imath.V3f( 12 ), imath.V3f( 13 ), imath.V3f( 14 ), imath.V3f( 14 ), imath.V3f( 14 ) ]) - cvs.extend([ imath.V3f( 15 ), imath.V3f( 15 ), imath.V3f( 15 ), imath.V3f( 16 ), imath.V3f( 17 ), imath.V3f( 18 ), imath.V3f( 19 ), imath.V3f( 20 ), imath.V3f( 21 ), imath.V3f( 21 ), imath.V3f( 21 ) ]) - p = IECore.V3fVectorData( cvs ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - transform1 = maya.cmds.createNode( "transform" ) - transform2 = maya.cmds.createNode( "transform" ) - transform3 = maya.cmds.createNode( "transform" ) - transform4 = maya.cmds.createNode( "transform" ) - - # should default to converting curve zero: - self.assertEqual( converter["index"].getNumericValue(), 0 ) - - # convert the curves separately: - self.assertTrue( converter.convert( transform1 ) ) - converter["index"].setNumericValue( 1 ) - self.assertTrue( converter.convert( transform2 ) ) - converter["index"].setNumericValue( 2 ) - self.assertTrue( converter.convert( transform3 ) ) - converter["index"].setNumericValue( 3 ) - self.assertTrue( converter.convert( transform4 ) ) - - mayaCurve1 = maya.cmds.listRelatives( transform1, shapes=True )[0] - mayaCurve2 = maya.cmds.listRelatives( transform2, shapes=True )[0] - mayaCurve3 = maya.cmds.listRelatives( transform3, shapes=True )[0] - mayaCurve4 = maya.cmds.listRelatives( transform4, shapes=True )[0] - - self.assertEqual( maya.cmds.getAttr( mayaCurve1 + ".cv[*]" ), [ (n,n,n) for n in range( 0,4 ) ] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve2 + ".cv[*]" ), [ (n,n,n) for n in range( 4,9 ) ] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve3 + ".cv[*]" ), [ (n,n,n) for n in range( 9,15 ) ] ) - self.assertEqual( maya.cmds.getAttr( mayaCurve4 + ".cv[*]" ), [ (n,n,n) for n in range( 15,22 ) ] ) - - # should error gracefully if we specify a rubbish curve index: - converter["index"].setNumericValue( -1 ) - self.assertFalse( converter.convert( transform1 ) ) - converter["index"].setNumericValue( 4 ) - self.assertFalse( converter.convert( transform1 ) ) - - def testWrongCubicCurve( self ): - - i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - transform = maya.cmds.createNode( "transform" ) - self.assertFalse( converter.convert( transform ) ) - - def testToMayaAndBack( self ): - - # open, cubic curve: - i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) - coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaCurve = maya.cmds.listRelatives( transform, shapes=True )[0] - converter = IECoreMaya.FromMayaShapeConverter.create( mayaCurve, IECoreScene.CurvesPrimitive.staticTypeId() ) - curve = converter.convert() - - self.assertEqual( curve['P'], coreCurves['P'] ) - self.assertEqual( curve.numCurves(), coreCurves.numCurves() ) - self.assertEqual( curve.basis(), coreCurves.basis() ) - self.assertEqual( curve.verticesPerCurve(), coreCurves.verticesPerCurve() ) - - - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/ToMayaGroupConverterTest.py b/test/IECoreMaya/ToMayaGroupConverterTest.py deleted file mode 100644 index 0d219b1e5d..0000000000 --- a/test/IECoreMaya/ToMayaGroupConverterTest.py +++ /dev/null @@ -1,130 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaGroupConverterTest( IECoreMaya.TestCase ) : - - def testConversion( self ) : - - g = IECoreScene.Group() - g.setTransform( IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) - - c1 = IECoreScene.Group() - c1.addChild( IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) ) - c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) ) - g.addChild( c1 ) - - c2 = IECoreScene.Group() - c2.addChild( IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -2, 0, 0 ) ) ) ) - g.addChild( c2 ) - - p = maya.cmds.createNode( "transform" ) - - IECoreMaya.ToMayaGroupConverter( g ).convert( p ) - - mg = maya.cmds.listRelatives( p, fullPath=True ) - - self.assertEqual( len( mg ), 1 ) - self.assertEqual( maya.cmds.nodeType( mg[0] ), "transform" ) - self.assertEqual( maya.cmds.getAttr( mg[0] + ".translate" ), [ ( 0, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mg[0] + ".rotate" ), [ ( 0, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mg[0] + ".scale" ), [ ( 2, 2, 2 ) ] ) - - mgg = maya.cmds.listRelatives( mg[0], fullPath=True ) - - self.assertEqual( len( mgg ), 2 ) - - self.assertEqual( maya.cmds.nodeType( mgg[0] ), "transform" ) - self.assertEqual( maya.cmds.getAttr( mgg[0] + ".translate" ), [ ( 2, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mgg[0] + ".rotate" ), [ ( 0, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mgg[0] + ".scale" ), [ ( 1, 1, 1 ) ] ) - - self.assertEqual( maya.cmds.nodeType( mgg[1] ), "transform" ) - self.assertEqual( maya.cmds.getAttr( mgg[1] + ".translate" ), [ ( -2, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mgg[1] + ".rotate" ), [ ( 0, 0, 0 ) ] ) - self.assertEqual( maya.cmds.getAttr( mgg[1] + ".scale" ), [ ( 1, 1, 1 ) ] ) - - m1 = maya.cmds.listRelatives( mgg[0], fullPath=True ) - self.assertEqual( len( m1 ), 1 ) - self.assertEqual( maya.cmds.nodeType( m1[0] ), "mesh" ) - self.assertEqual( maya.cmds.polyEvaluate( m1[0], face=True ), 6 ) - - m2 = maya.cmds.listRelatives( mgg[1], fullPath=True ) - self.assertEqual( len( m2 ), 1 ) - self.assertEqual( maya.cmds.nodeType( m2[0] ), "mesh" ) - self.assertEqual( maya.cmds.polyEvaluate( m2[0], face=True ), 6 ) - - def testNamedConversion( self ): - - g = IECoreScene.Group() - g.addState( IECoreScene.AttributeState( { "name" : IECore.StringData( "topLevel" ) } ) ) - - c1 = IECoreScene.Group() - c1.addState( IECoreScene.AttributeState( { "name" : IECore.StringData( "topLevel/child1" ) } ) ) - g.addChild( c1 ) - - c2 = IECoreScene.Group() - c2.addState( IECoreScene.AttributeState( { "name" : IECore.StringData( "child2" ) } ) ) - g.addChild( c2 ) - - c3 = IECoreScene.Group() - c3.addState( IECoreScene.AttributeState( { "name" : IECore.StringData( "topLevel/child1/child3" ) } ) ) - c1.addChild( c3 ) - - # nameless group - g.addChild( IECoreScene.Group() ) - - p = maya.cmds.createNode( "transform" ) - - IECoreMaya.ToMayaGroupConverter( g ).convert( p ) - - mg = maya.cmds.listRelatives( p, fullPath=True, ad=True ) - - expectedNames = set( [ "|transform1|topLevel|child1|child3", "|transform1|topLevel|child1", "|transform1|topLevel|child2", "|transform1|topLevel|transform2", "|transform1|topLevel" ] ) - - actualNames = set() - for name in mg: - actualNames.add( str( name ) ) - - self.assertEqual( expectedNames, actualNames ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaLocatorConverterTest.py b/test/IECoreMaya/ToMayaLocatorConverterTest.py deleted file mode 100644 index b781c07349..0000000000 --- a/test/IECoreMaya/ToMayaLocatorConverterTest.py +++ /dev/null @@ -1,100 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaLocatorConverterTest( IECoreMaya.TestCase ) : - - def setUp( self ) : - - maya.cmds.file( new=True, f=True ) - - def testFactory( self ) : - - converter = IECoreMaya.ToMayaObjectConverter.create( IECoreScene.CoordinateSystem() ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaLocatorConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.ToMayaLocatorConverter ) ) ) - - def testNewLocator( self ) : - - m = imath.M44f().scale( imath.V3f(1,2,3) ) * imath.M44f().translate( imath.V3f(10,20,30) ) - coordSys = IECoreScene.CoordinateSystem( "myNamedCoordSys", IECoreScene.MatrixTransform( m ) ) - - parent = maya.cmds.createNode( "transform" ) - self.assertTrue( IECoreMaya.ToMayaLocatorConverter( coordSys ).convert( parent ) ) - - locators = maya.cmds.listRelatives( parent, children=True, fullPath=True, type="locator" ) - self.assertEqual( len(locators), 1 ) - self.assertEqual( locators[0].split( "|" )[-1], "myNamedCoordSys" ) - self.assertEqual( maya.cmds.getAttr( locators[0] + ".localPosition" )[0], (10,20,30) ) - self.assertEqual( maya.cmds.getAttr( locators[0] + ".localScale" )[0], (1,2,3) ) - - newCoordSys = IECoreMaya.FromMayaLocatorConverter( locators[0] ).convert() - self.assertEqual( coordSys.getName(), newCoordSys.getName() ) - self.assertEqual( coordSys.getTransform(), newCoordSys.getTransform() ) - - def testWrongIECoreObject( self ) : - - converter = IECoreMaya.ToMayaLocatorConverter( IECoreScene.MeshPrimitive() ) - - parent = maya.cmds.createNode( "transform" ) - messageHandler = IECore.CapturingMessageHandler() - with messageHandler : - self.assertFalse( converter.convert( parent ) ) - - self.assertEqual( len( messageHandler.messages ), 1 ) - self.assertEqual( messageHandler.messages[0].level, IECore.MessageHandler.Level.Warning ) - self.assertEqual( messageHandler.messages[0].context, "ToMayaLocatorConverter::doConversion" ) - - def testWrongMayaNode( self ) : - - maya.cmds.polySphere( name="pSphere" ) - coordSys = IECoreScene.CoordinateSystem( "myNamedCoordSys", IECoreScene.MatrixTransform( imath.M44f() ) ) - converter = IECoreMaya.ToMayaLocatorConverter( coordSys ) - - messageHandler = IECore.CapturingMessageHandler() - with messageHandler : - self.assertFalse( converter.convert( "pSphereShape" ) ) - - self.assertEqual( len( messageHandler.messages ), 1 ) - self.assertEqual( messageHandler.messages[0].level, IECore.MessageHandler.Level.Warning ) - self.assertEqual( messageHandler.messages[0].context, "ToMayaLocatorConverter::doConversion" ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaMeshConverterTest.py b/test/IECoreMaya/ToMayaMeshConverterTest.py deleted file mode 100644 index 245b1f189c..0000000000 --- a/test/IECoreMaya/ToMayaMeshConverterTest.py +++ /dev/null @@ -1,393 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import maya.cmds -import maya.OpenMaya as OpenMaya -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaMeshConverterTest( IECoreMaya.TestCase ) : - - def testConversion( self ) : - - coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaObjectConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.FromCoreConverter.staticTypeId() ) ) - - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - mayaMesh = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, vertex=True ), 8 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, face=True ), 6 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, boundingBox=True ), ( (-10, 10), (-10, 10), (-10, 10) ) ) - - def testUVConversion( self ) : - - coreMesh = IECore.Reader.create( "test/IECore/data/cobFiles/pSphereShape1.cob" ).read() - - self.assertTrue( "uv" in coreMesh ) - - coreMesh[ "testUVSet" ] = IECoreScene.PrimitiveVariable( coreMesh["uv"].interpolation, coreMesh["uv"].data.copy() ) - - converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaObjectConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.FromCoreConverter.staticTypeId() ) ) - - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - mayaMesh = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, vertex=True ), 382 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, face=True ), 760 ) - - bb = maya.cmds.polyEvaluate( mayaMesh, boundingBox=True ) - - self.assertAlmostEqual( bb[0][0], -1, 4 ) - self.assertAlmostEqual( bb[0][1], 1, 4 ) - self.assertAlmostEqual( bb[1][0], -1, 4 ) - self.assertAlmostEqual( bb[1][1], 1, 4 ) - self.assertAlmostEqual( bb[2][0], -1, 4 ) - self.assertAlmostEqual( bb[2][1], 1, 4 ) - - l = OpenMaya.MSelectionList() - l.add( mayaMesh ) - p = OpenMaya.MDagPath() - l.getDagPath( 0, p ) - - fnMesh = OpenMaya.MFnMesh( p ) - u = OpenMaya.MFloatArray() - v = OpenMaya.MFloatArray() - - fnMesh.getUVs( u, v ) - - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - - self.assertEqual( u[0], coreMesh[ "uv" ].data[0][0] ) - self.assertEqual( v[0], coreMesh[ "uv" ].data[0][1] ) - - fnMesh.getUVs( u, v, "testUVSet" ) - - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - - self.assertEqual( u[12], coreMesh[ "testUVSet" ].data[12][0] ) - self.assertEqual( v[12], coreMesh[ "testUVSet" ].data[12][1] ) - - def testUVConversionFromPlug( self ) : - - coreMesh = IECore.Reader.create( "test/IECore/data/cobFiles/pSphereShape1.cob" ).read() - - self.assertTrue( "uv" in coreMesh ) - - coreMesh[ "testUVSet" ] = IECoreScene.PrimitiveVariable( coreMesh["uv"].interpolation, coreMesh["uv"].data.copy() ) - - fn = IECoreMaya.FnOpHolder.create( "test", "meshMerge" ) - op = fn.getOp() - with fn.parameterModificationContext() : - op["input"].setValue( coreMesh ) - - mayaMesh = maya.cmds.ls( maya.cmds.polyPlane(), dag=True, type="mesh" )[0] - maya.cmds.connectAttr( fn.name()+".result", mayaMesh+".inMesh", force=True ) - - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, vertex=True ), 382 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, face=True ), 760 ) - - bb = maya.cmds.polyEvaluate( mayaMesh, boundingBox=True ) - - self.assertAlmostEqual( bb[0][0], -1, 4 ) - self.assertAlmostEqual( bb[0][1], 1, 4 ) - self.assertAlmostEqual( bb[1][0], -1, 4 ) - self.assertAlmostEqual( bb[1][1], 1, 4 ) - self.assertAlmostEqual( bb[2][0], -1, 4 ) - self.assertAlmostEqual( bb[2][1], 1, 4 ) - - l = OpenMaya.MSelectionList() - l.add( mayaMesh ) - p = OpenMaya.MDagPath() - l.getDagPath( 0, p ) - - fnMesh = OpenMaya.MFnMesh( p ) - u = OpenMaya.MFloatArray() - v = OpenMaya.MFloatArray() - - fnMesh.getUVs( u, v ) - - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - - self.assertEqual( u[0], coreMesh[ "uv" ].data[0][0] ) - self.assertEqual( v[0], coreMesh[ "uv" ].data[0][1] ) - - fnMesh.getUVs( u, v, "testUVSet" ) - - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - - self.assertEqual( u[12], coreMesh[ "testUVSet" ].data[12][0] ) - self.assertEqual( v[12], coreMesh[ "testUVSet" ].data[12][1] ) - - @unittest.skipIf( maya.OpenMaya.MGlobal.apiVersion() < 201600, "Invisible meshes with 6+ UV sets cause seg faults prior to Maya 2016" ) - def testManyUVConversionsFromPlug( self ) : - - coreMesh = IECore.Reader.create( "test/IECore/data/cobFiles/pSphereShape1.cob" ).read() - - self.assertTrue( "uv" in coreMesh ) - - for i in range( 0, 7 ) : - coreMesh[ "testUVSet%d" % i ] = IECoreScene.PrimitiveVariable( coreMesh["uv"].interpolation, coreMesh["uv"].data.copy() ) - - fn = IECoreMaya.FnOpHolder.create( "test", "meshMerge" ) - - mayaMesh = maya.cmds.ls( maya.cmds.polyPlane(), dag=True, type="mesh" )[0] - maya.cmds.connectAttr( fn.name()+".result", mayaMesh+".inMesh", force=True ) - - op = fn.getOp() - with fn.parameterModificationContext() : - op["input"].setValue( coreMesh ) - - maya.cmds.file( rename="/tmp/test.ma" ) - maya.cmds.file( save=True ) - maya.cmds.file( new=True, f=True ) - maya.cmds.file( "/tmp/test.ma", open=True ) - - fnMesh = OpenMaya.MFnMesh( IECoreMaya.dagPathFromString( mayaMesh ) ) - self.assertEqual( fnMesh.numPolygons(), 760 ) - # When calling fnMesh.numFaceVertices() (and other MFnMesh API calls), given a mesh with 6 - # or more UV sets, which has never been evaluated before, the first call throws kFailure. - # From within the ToMayaMeshConverter itself, the output plug appears fine, and the API calls - # evaluate as expected. Despite this, the resulting mesh cannot be evaluated on the first try. - # Making the mesh visible, or making any attempt to evaluate it, will trigger some unknown - # internal updating, and subsequent attempts to evaluate it will succeed. Meshes with 5 or less - # UV sets do not suffer from this problem. This was fixed in Maya 2016, but I'll leave - # this explanation so users of ToMayaMeshConverter have breadcrumbs to follow. - self.assertEqual( fnMesh.numFaceVertices(), 2280 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, vertex=True ), 382 ) - self.assertEqual( maya.cmds.polyEvaluate( mayaMesh, face=True ), 760 ) - - u = OpenMaya.MFloatArray() - v = OpenMaya.MFloatArray() - - fnMesh.getUVs( u, v ) - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - self.assertEqual( u[0], coreMesh[ "uv" ].data[0][0] ) - self.assertEqual( v[0], coreMesh[ "uv" ].data[0][1] ) - - for i in range( 0, 7 ) : - - fnMesh.getUVs( u, v, "testUVSet%d" % i ) - self.assertEqual( u.length(), 2280 ) - self.assertEqual( v.length(), 2280 ) - self.assertEqual( u[12], coreMesh[ "testUVSet%d" % i ].data[12][0] ) - self.assertEqual( v[12], coreMesh[ "testUVSet%d" % i ].data[12][1] ) - - def testUVConversionFromMayaMesh( self ) : - - mayaMesh = maya.cmds.ls( maya.cmds.polyPlane(), dag=True, type="mesh" )[0] - coreMesh = IECoreMaya.FromMayaMeshConverter( mayaMesh ).convert() - - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( IECoreMaya.ToMayaMeshConverter( coreMesh ).convert( transform ) ) - mayaMesh2 = maya.cmds.listRelatives( transform, shapes=True )[0] - - l = OpenMaya.MSelectionList() - l.add( mayaMesh ) - l.add( mayaMesh2 ) - p = OpenMaya.MDagPath() - p2 = OpenMaya.MDagPath() - l.getDagPath( 0, p ) - l.getDagPath( 1, p2 ) - - uvSets = [] - fnMesh = OpenMaya.MFnMesh( p ) - fnMesh.getUVSetNames( uvSets ) - - uvSets2 = [] - fnMesh2 = OpenMaya.MFnMesh( p2 ) - fnMesh2.getUVSetNames( uvSets2 ) - - self.assertEqual( uvSets, uvSets2 ) - - # Check uvIndices - coreMesh2 = IECoreMaya.FromMayaMeshConverter( mayaMesh2 ).convert() - # self.assertEqual( coreMesh["uv"].data, coreMesh2["uv"].data ) - self.assertEqual( coreMesh["uv"].indices, coreMesh2["uv"].indices ) - - def testShadingGroup( self ) : - - coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) - converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) - transform = maya.cmds.createNode( "transform" ) - converter.convert( transform ) - mayaMesh = maya.cmds.listRelatives( transform, shapes=True )[0] - - self.assertTrue( mayaMesh in maya.cmds.sets( "initialShadingGroup", query=True ) ) - - def testConstructor( self ) : - - coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) - - converter = IECoreMaya.ToMayaMeshConverter( coreMesh ) - transform = maya.cmds.createNode( "transform" ) - converter.convert( transform ) - self.assertEqual( maya.cmds.nodeType( maya.cmds.listRelatives( transform, shapes=True )[0] ), "mesh" ) - - def testNormals( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=4, subdivisionsY=3, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - maya.cmds.polySoftEdge( sphere, angle=145 ) - - mesh = IECoreMaya.FromMayaShapeConverter.create( sphere ).convert() - self.assertTrue( "N" in mesh ) - self.assertTrue( mesh.arePrimitiveVariablesValid() ) - self.assertEqual( mesh["N"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertTrue( isinstance( mesh["N"].data, IECore.V3fVectorData ) ) - - transform = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaObjectConverter.create( mesh ).convert( transform ) - newSphere = maya.cmds.listRelatives( transform, shapes=True )[0] - - normals3d = IECore.DataConvertOp()( data=mesh["N"].data, targetType=IECore.TypeId.V3dVectorData ) - del mesh["N"] - mesh["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, normals3d ) - self.assertTrue( mesh.arePrimitiveVariablesValid() ) - self.assertTrue( isinstance( mesh["N"].data, IECore.V3dVectorData ) ) - - transform2 = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaObjectConverter.create( mesh ).convert( transform2 ) - newSphere2 = maya.cmds.listRelatives( transform2, shapes=True )[0] - - for i in range( 0, len(maya.cmds.ls( sphere+'.vtx[*]', fl=True )) ) : - origNormal = maya.cmds.polyNormalPerVertex( sphere+'.vtx['+str(i)+']', query=True, xyz=True ) - normal3f = maya.cmds.polyNormalPerVertex( newSphere+'.vtx['+str(i)+']', query=True, xyz=True ) - normal3d = maya.cmds.polyNormalPerVertex( newSphere2+'.vtx['+str(i)+']', query=True, xyz=True ) - for j in range( 0, len(origNormal) ) : - self.assertAlmostEqual( origNormal[j], normal3f[j], 6 ) - self.assertAlmostEqual( origNormal[j], normal3d[j], 6 ) - - def testSetMeshInterpolation( self ) : - - sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False ) - sphere = maya.cmds.listRelatives( sphere, shapes=True )[0] - - self.assertRaises( ValueError, maya.cmds.getAttr, sphere + ".ieMeshInterpolation" ) - - IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere ) - self.assertEqual( maya.cmds.getAttr( sphere + ".ieMeshInterpolation" ), 0 ) - - coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) - coreMesh.interpolation = "catmullClark" - converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - mayaMesh = maya.cmds.listRelatives( transform, shapes=True )[0] - self.assertEqual( maya.cmds.getAttr( mayaMesh + ".ieMeshInterpolation" ), 1 ) - - def testCreases( self ) : - - cortexCube = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) - - cornerIds = [ 5 ] - cornerSharpnesses = [ 10.0 ] - - cortexCube.setCorners( IECore.IntVectorData( cornerIds ), IECore.FloatVectorData( cornerSharpnesses ) ) - - creaseLengths = [ 3, 2 ] - creaseIds = [ 1, 2, 3, 4, 5 ] # note that these are vertex ids - creaseSharpnesses = [ 1, 5 ] - - cortexCube.setCreases( IECore.IntVectorData( creaseLengths ), IECore.IntVectorData( creaseIds ), IECore.FloatVectorData( creaseSharpnesses ) ) - - converter = IECoreMaya.ToMayaObjectConverter.create( cortexCube ) - transform = maya.cmds.createNode( "transform" ) - self.assertTrue( converter.convert( transform ) ) - - mayaMesh = maya.cmds.listRelatives( transform, shapes=True )[0] - - l = OpenMaya.MSelectionList() - l.add( mayaMesh ) - p = OpenMaya.MDagPath() - l.getDagPath( 0, p ) - - fnMesh = OpenMaya.MFnMesh( p ) - - # Test corners - - cornerIds = OpenMaya.MUintArray() - cornerSharpnesses = OpenMaya.MDoubleArray() - fnMesh.getCreaseVertices( cornerIds, cornerSharpnesses ) - - testIds = OpenMaya.MUintArray() - testIds.append( 5 ) - self.assertEqual( cornerIds, testIds ) - - testSharpnesses = OpenMaya.MFloatArray() - testSharpnesses.append( 10 ) - self.assertEqual( cornerSharpnesses, testSharpnesses ) - - # Test edges - - edgeIds = OpenMaya.MUintArray() - edgeSharpnesses = OpenMaya.MDoubleArray() - fnMesh.getCreaseEdges( edgeIds, edgeSharpnesses ) - - util = OpenMaya.MScriptUtil() - - result = [] - for edgeId, sharpness in zip( edgeIds, edgeSharpnesses ) : - - edgeVertices = util.asInt2Ptr() - fnMesh.getEdgeVertices( edgeId, edgeVertices ) - - result.append( (util.getInt2ArrayItem( edgeVertices, 0, 1 ), - util.getInt2ArrayItem( edgeVertices, 0, 0 ), - sharpness) ) - - # we compare sets because maya reorders by edge index - self.assertEqual( set( result ), set( [ ( 1, 2, 1.0 ), ( 2, 3, 1.0 ), ( 4, 5, 5.0 ) ] ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/ToMayaParticleConverterTest.py b/test/IECoreMaya/ToMayaParticleConverterTest.py deleted file mode 100644 index f60bab785d..0000000000 --- a/test/IECoreMaya/ToMayaParticleConverterTest.py +++ /dev/null @@ -1,129 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaParticleConverterTest( IECoreMaya.TestCase ) : - - def testFactory( self ) : - - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) - converter = IECoreMaya.ToMayaObjectConverter.create( points ) - self.assertTrue( isinstance( converter, IECoreMaya.ToMayaParticleConverter ) ) - - def testConversion( self ) : - - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) - - parent = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) - - children = maya.cmds.listRelatives( parent ) - self.assertEqual( len( children ), 1 ) - - particleShape = children[0] - self.assertEqual( maya.cmds.nodeType( particleShape ), "particle" ) - - self.assertEqual( maya.cmds.particle( particleShape, query=True, count=True ), 10 ) - - for i in range( 0, 10 ) : - self.assertEqual( maya.cmds.particle( attribute="position", q=True, order=i ), [ i, i, i ] ) - - self.assertFalse( "P" in maya.cmds.particle( particleShape, query=True, perParticleVector=True ) ) - - def testConversionFromDoubles( self ) : - - points = IECoreScene.PointsPrimitive( 10 ) - points["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ imath.V3d( x ) for x in range( 0, 10 ) ] ) ) - points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ imath.V3d( x ) for x in range( 10, 20 ) ] ) ) - - parent = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) - - children = maya.cmds.listRelatives( parent ) - self.assertEqual( len( children ), 1 ) - - particleShape = children[0] - self.assertEqual( maya.cmds.nodeType( particleShape ), "particle" ) - - self.assertEqual( maya.cmds.particle( particleShape, query=True, count=True ), 10 ) - - for i in range( 0, 10 ) : - self.assertEqual( maya.cmds.particle( attribute="position", q=True, order=i ), [ i, i, i ] ) - - self.assertFalse( "P" in maya.cmds.particle( particleShape, query=True, perParticleVector=True ) ) - - def testRGBPPConversion( self ) : - - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) - points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( x ) for x in range( 10, 20 ) ] ) ) - parent = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) - - children = maya.cmds.listRelatives( parent ) - self.assertEqual( len( children ), 1 ) - - particleShape = children[0] - self.assertEqual( maya.cmds.nodeType( particleShape ), "particle" ) - - self.assertEqual( maya.cmds.particle( particleShape, query=True, count=True ), 10 ) - - for i in range( 0, 10 ) : - self.assertEqual( maya.cmds.particle( attribute="rgbPP", q=True, order=i ), [ i+10, i+10, i+10 ] ) - - def testCsConversion( self ) : - - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) - points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( x ) for x in range( 10, 20 ) ] ) ) - parent = maya.cmds.createNode( "transform" ) - IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) - - children = maya.cmds.listRelatives( parent ) - self.assertEqual( len( children ), 1 ) - - particleShape = children[0] - self.assertEqual( maya.cmds.nodeType( particleShape ), "particle" ) - - self.assertEqual( maya.cmds.particle( particleShape, query=True, count=True ), 10 ) - - for i in range( 0, 10 ) : - self.assertEqual( maya.cmds.particle( attribute="rgbPP", q=True, order=i ), [ i+10, i+10, i+10 ] ) - -if __name__ == "__main__": - IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/ToMayaPlugConverterTest.py b/test/IECoreMaya/ToMayaPlugConverterTest.py deleted file mode 100644 index 85f8c3aab4..0000000000 --- a/test/IECoreMaya/ToMayaPlugConverterTest.py +++ /dev/null @@ -1,138 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import IECore -import IECoreMaya - - -class ToMayaPlugConverterTest( IECoreMaya.TestCase ) : - - def testSinglePlugConversion( self ) : - - locator = maya.cmds.spaceLocator()[0] - - converter = IECoreMaya.ToMayaPlugConverter.create( IECore.DoubleData( 10 ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaPlugConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECoreMaya.ToMayaConverter.staticTypeId() ) ) - self.assertTrue( converter.isInstanceOf( IECore.FromCoreConverter.staticTypeId() ) ) - - converter.convert( locator + ".translateX" ) - self.assertAlmostEqual( maya.cmds.getAttr( locator + ".translateX" ), 10 ) - - def testUnitPlugConversion(self): - - timeNode = maya.cmds.createNode('time') - maya.cmds.currentUnit( time='film' ) # set to 24fps - converter = IECoreMaya.ToMayaPlugConverter.create( IECore.DoubleData( 1.23 ) ) - converter.convert(timeNode + '.outTime') - self.assertAlmostEqual(maya.cmds.getAttr(timeNode + '.outTime'), 1.23 * 24.0) - - locator = maya.cmds.spaceLocator()[0] - converter = IECoreMaya.ToMayaPlugConverter.create( IECore.DoubleData( IECore.degreesToRadians(90.0) ) ) - converter.convert(locator + '.rotateX' ) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.rotateX'), 90.0) - - converter = IECoreMaya.ToMayaPlugConverter.create( IECore.DoubleData( 1.23456) ) - converter.convert(locator + '.translateX' ) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.translateX'), 1.23456) - - def testNumericPlugConversion(self): - - locator = maya.cmds.spaceLocator()[0] - - attr = ('tInt', 'long', IECore.IntData(7)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tShort', 'short', IECore.ShortData(8)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tByte', 'byte', IECore.ShortData(9)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tBool', 'bool', IECore.BoolData(True)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tFloat', 'float', IECore.FloatData(1.23456)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tDouble', 'double', IECore.DoubleData(2.3456)) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - attr = ('tChar', 'char', IECore.CharData('A')) - maya.cmds.addAttr(ln=attr[0], at=attr[1]) - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertEqual(maya.cmds.getAttr(locator + '.' + attr[0]), ord(str(attr[2].value))) - - attr = ('tEnum', 'enum', IECore.ShortData(2)) - maya.cmds.addAttr(ln=attr[0], at=attr[1], en="A:B:C:D:E") - converter = IECoreMaya.ToMayaPlugConverter.create(attr[2]) - converter.convert(locator + '.' + attr[0]) - self.assertAlmostEqual(maya.cmds.getAttr(locator + '.' + attr[0]), attr[2].value) - - def testMultiPlugConversion(self): - - maya.cmds.polyPlane() - bs = maya.cmds.blendShape()[0] - multi = bs + '.inputTarget[0].baseWeights' - - data = IECore.CompoundData({'data' : IECore.FloatVectorData( [8, 9]), 'indices' : IECore.IntVectorData( [3, 5])}) - converter = IECoreMaya.ToMayaPlugConverter.create(data) - converter.convert(multi) - self.assertEqual(maya.cmds.getAttr(multi + '[3]'), 8) - self.assertEqual(maya.cmds.getAttr(multi + '[5]'), 9) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaSkinClusterConverterTest.py b/test/IECoreMaya/ToMayaSkinClusterConverterTest.py deleted file mode 100644 index c6b30cefaf..0000000000 --- a/test/IECoreMaya/ToMayaSkinClusterConverterTest.py +++ /dev/null @@ -1,326 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import imath - -import IECore -import IECoreScene -import IECoreMaya - -class ToMayaSkinClusterConverterTest( IECoreMaya.TestCase ) : - - def buildTestSetup( self ) : - # create simple hierarchy - j1 = maya.cmds.joint( n = 'joint1', p =[0,-2,0] ) - maya.cmds.joint( n = 'joint2', p =[0,0,0] ) - maya.cmds.joint( n = 'joint3', p =[0,2,0] ) - - maya.cmds.select( clear=True ) - j4 = maya.cmds.joint( n = 'joint4', p =[0,-2,0] ) - j5 = maya.cmds.joint( n = 'joint5', p =[0,0,0] ) - j6 = maya.cmds.joint( n = 'joint6', p =[0,2,0] ) - maya.cmds.rotate( 0, 0, -20, j4, r=True, os=True ) - maya.cmds.rotate( 0, 0, 40, j5, r=True, os=True ) - maya.cmds.rotate( 0, 0, -20, j6, r=True, os=True ) - - # create geo - geo = maya.cmds.polyCube( n = "myGeo", w = 1, h = 4, d = 1, sx = 1, sy = 3, sz = 1, ax = [ 0, 1, 0 ],cuv = 4, ch = 0 )[0] - geo2 = maya.cmds.polyCube( n = "myGeo2", w = 1, h = 4, d = 1, sx = 1, sy = 3, sz = 1, ax = [ 0, 1, 0 ],cuv = 4, ch = 0 )[0] - - # bind it - sc = maya.cmds.skinCluster( j1, geo, dr=4.5 )[0] - sc2 = maya.cmds.skinCluster( j4, geo2, dr=4.5 )[0] - - # change the weights on sc2 - r = imath.Rand32() - for i in range( 0, 15 ) : - val = IECore.RandomAlgo.barycentricRandf( r ) - maya.cmds.skinPercent( sc2, '%s.vtx[%d]' % ( geo2, i ), transformValue=[(j4, val[0]), (j5, val[1]), (j6, val[2]) ]) - - return ( sc, sc2 ) - - def testSimple( self ) : - # test factory - ssd = IECoreScene.SmoothSkinningData() - converter = IECoreMaya.ToMayaObjectConverter.create( ssd ) - self.assertTrue( converter.isInstanceOf( IECore.TypeId( IECoreMaya.TypeId.ToMayaSkinClusterConverter ) ) ) - - def testConvert( self ) : - # test conversion - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['|joint1', '|joint1|joint2', '|joint1|joint2|joint3'] ) ) - self.assertEqual( len(ssd.influencePose()), 3 ) - self.assertEqual( len(ssd.pointInfluenceCounts()), 16 ) - self.assertEqual( len(ssd.pointInfluenceIndices()), 32 ) - ssd.validate() - - del fromConverter - - # make sure everything is different at first - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc2 ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['|joint4', '|joint4|joint5', '|joint4|joint5|joint6'] ) ) - self.assertEqual( len(ssd2.influencePose()), 3 ) - self.assertEqual( len(ssd2.pointInfluenceCounts()), 16 ) - self.assertEqual( len(ssd2.pointInfluenceIndices()), 47 ) - self.assertNotEqual( ssd.influenceNames(), ssd2.influenceNames() ) - self.assertNotEqual( ssd.influencePose(), ssd2.influencePose() ) - self.assertNotEqual( ssd.pointIndexOffsets(), ssd2.pointIndexOffsets() ) - self.assertNotEqual( ssd.pointInfluenceCounts(), ssd2.pointInfluenceCounts() ) - self.assertNotEqual( ssd.pointInfluenceIndices(), ssd2.pointInfluenceIndices() ) - self.assertNotEqual( ssd.pointInfluenceWeights(), ssd2.pointInfluenceWeights() ) - self.assertNotEqual( ssd, ssd2 ) - - del fromConverter - del ssd2 - - # convert - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - toConverter.convert( sc2 ) - - # make sure everything is the same now - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc2 ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['|joint1', '|joint1|joint2', '|joint1|joint2|joint3'] ) ) - self.assertEqual( ssd.influenceNames(), ssd2.influenceNames() ) - self.assertEqual( ssd.influencePose(), ssd2.influencePose() ) - self.assertEqual( ssd.pointIndexOffsets(), ssd2.pointIndexOffsets() ) - self.assertEqual( ssd.pointInfluenceCounts(), ssd2.pointInfluenceCounts() ) - self.assertEqual( ssd.pointInfluenceIndices(), ssd2.pointInfluenceIndices() ) - self.assertEqual( ssd.pointInfluenceWeights(), ssd2.pointInfluenceWeights() ) - self.assertEqual( ssd, ssd2 ) - - def testSSDInfluenceNotInScene( self ) : - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2', 'joint3'] ) ) - ssd.validate() - - maya.cmds.parent( 'joint3', 'joint1' ) - maya.cmds.delete( 'joint2' ) - newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) - - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc ) ) - toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) - toConverter.convert( sc ) - - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['joint1', 'joint3'] ) ) - self.assertEqual( ssd2.influencePose(), newPose ) - self.assertEqual( ssd2.pointIndexOffsets(), IECore.IntVectorData( [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] ) ) - self.assertEqual( ssd2.pointInfluenceCounts(), IECore.IntVectorData( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ) ) - self.assertEqual( ssd2.pointInfluenceIndices(), IECore.IntVectorData( [ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ] ) ) - newWeights = IECore.FloatVectorData( [ ssd.pointInfluenceWeights()[x] for x in range(0,ssd.pointInfluenceWeights().size()) if ssd.pointInfluenceIndices()[x] != 1 ] ) - self.assertEqual( ssd2.pointInfluenceWeights(), newWeights ) - - def testSSDInfluenceInSceneButNotAJoint( self ) : - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2', 'joint3'] ) ) - ssd.validate() - - maya.cmds.parent( 'joint3', 'joint1' ) - maya.cmds.delete( 'joint2' ) - maya.cmds.polyCube( n = "joint2", w = 1, h = 4, d = 1, sx = 1, sy = 3, sz = 1, ax = [ 0, 1, 0 ],cuv = 4, ch = 0 ) - newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) - - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc ) ) - toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) - toConverter.convert( sc ) - - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['joint1', 'joint3'] ) ) - self.assertEqual( ssd2.influencePose(), newPose ) - self.assertEqual( ssd2.pointIndexOffsets(), IECore.IntVectorData( [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] ) ) - self.assertEqual( ssd2.pointInfluenceCounts(), IECore.IntVectorData( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ) ) - self.assertEqual( ssd2.pointInfluenceIndices(), IECore.IntVectorData( [ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ] ) ) - newWeights = IECore.FloatVectorData( [ ssd.pointInfluenceWeights()[x] for x in range(0,ssd.pointInfluenceWeights().size()) if ssd.pointInfluenceIndices()[x] != 1 ] ) - self.assertEqual( ssd2.pointInfluenceWeights(), newWeights ) - - def testSkinClusterInfluencesWereRenamed( self ) : - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2', 'joint3'] ) ) - ssd.validate() - - maya.cmds.rename( 'joint2', 'fakeJoint' ) - newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ] ) - - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) - toConverter.convert( sc ) - - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['joint1', 'joint3', 'fakeJoint'] ) ) - self.assertEqual( ssd2.influencePose(), newPose ) - self.assertEqual( ssd2.pointIndexOffsets(), IECore.IntVectorData( [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] ) ) - self.assertEqual( ssd2.pointInfluenceCounts(), IECore.IntVectorData( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ) ) - self.assertEqual( ssd2.pointInfluenceIndices(), IECore.IntVectorData( [ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ] ) ) - newWeights = IECore.FloatVectorData( [ ssd.pointInfluenceWeights()[x] for x in range(0,ssd.pointInfluenceWeights().size()) if ssd.pointInfluenceIndices()[x] != 1 ] ) - self.assertEqual( ssd2.pointInfluenceWeights(), newWeights ) - - def testSkinClusterInfluencesWereRenamedAndOldNamesStillExist( self ) : - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2', 'joint3'] ) ) - ssd.validate() - - maya.cmds.rename( 'joint2', 'fakeJoint' ) - maya.cmds.rename( 'joint5', 'joint2' ) - newPose = ssd.influencePose() - newPose.append( imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ) - - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) - toConverter.convert( sc ) - - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Partial ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['joint1', 'joint2', 'joint3', 'fakeJoint'] ) ) - self.assertEqual( ssd2.influencePose(), newPose ) - self.assertEqual( ssd2.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( ssd2.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( ssd2.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( ssd2.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - - def testIgnoreBindPose( self ) : - - # test conversion - ( sc, sc2 ) = self.buildTestSetup() - - bindPoses = maya.cmds.ls( type="dagPose" ) - maya.cmds.delete( bindPoses ) - - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd = fromConverter.convert() - self.assertEqual( ssd.influenceNames(), IECore.StringVectorData( ['|joint1', '|joint1|joint2', '|joint1|joint2|joint3'] ) ) - self.assertEqual( len(ssd.influencePose()), 3 ) - self.assertEqual( len(ssd.pointInfluenceCounts()), 16 ) - self.assertEqual( len(ssd.pointInfluenceIndices()), 32 ) - ssd.validate() - - del fromConverter - - # make sure everything is different at first - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc2 ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['|joint4', '|joint4|joint5', '|joint4|joint5|joint6'] ) ) - self.assertEqual( len(ssd2.influencePose()), 3 ) - self.assertEqual( len(ssd2.pointInfluenceCounts()), 16 ) - self.assertEqual( len(ssd2.pointInfluenceIndices()), 47 ) - self.assertNotEqual( ssd.influenceNames(), ssd2.influenceNames() ) - self.assertNotEqual( ssd.influencePose(), ssd2.influencePose() ) - self.assertNotEqual( ssd.pointIndexOffsets(), ssd2.pointIndexOffsets() ) - self.assertNotEqual( ssd.pointInfluenceCounts(), ssd2.pointInfluenceCounts() ) - self.assertNotEqual( ssd.pointInfluenceIndices(), ssd2.pointInfluenceIndices() ) - self.assertNotEqual( ssd.pointInfluenceWeights(), ssd2.pointInfluenceWeights() ) - self.assertNotEqual( ssd, ssd2 ) - - del fromConverter - del ssd2 - - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc2 ) ) - toConverter.parameters()["ignoreBindPose"].setTypedValue( True ) - self.assertTrue( toConverter.convert( sc2 ) ) - - # make sure everything is the same now - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc2 ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd2 = fromConverter.convert() - self.assertEqual( ssd2.influenceNames(), IECore.StringVectorData( ['|joint1', '|joint1|joint2', '|joint1|joint2|joint3'] ) ) - self.assertEqual( ssd.influenceNames(), ssd2.influenceNames() ) - self.assertEqual( ssd.influencePose(), ssd2.influencePose() ) - self.assertEqual( ssd.pointIndexOffsets(), ssd2.pointIndexOffsets() ) - self.assertEqual( ssd.pointInfluenceCounts(), ssd2.pointInfluenceCounts() ) - self.assertEqual( ssd.pointInfluenceIndices(), ssd2.pointInfluenceIndices() ) - self.assertEqual( ssd.pointInfluenceWeights(), ssd2.pointInfluenceWeights() ) - self.assertEqual( ssd, ssd2 ) - - def testErrorStates( self ) : - - # test converting non-skinCluster node - ( sc, sc2 ) = self.buildTestSetup() - fromConverter = IECoreMaya.FromMayaSkinClusterConverter.create( sc ) - fromConverter.parameters()["influenceName"].setValue( IECoreMaya.FromMayaSkinClusterConverter.InfluenceName.Full ) - ssd = fromConverter.convert() - geo = maya.cmds.ls( "myGeo" )[0] - toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, geo ) ) - - # test invalid bindPose - bindPose = maya.cmds.listConnections( sc2+'.bindPose' )[0] - maya.cmds.delete( bindPose ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc2 ) ) - maya.cmds.connectAttr( geo+'.message', sc2+'.bindPose' ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc2 ) ) - - # test non-existant influences - maya.cmds.delete( ['joint2', 'joint3'] ) - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc2 ) ) - - # test influences that aren't joints - ssd.influenceNames()[1] = geo - self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc2 ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/ToMayaSkinClusterWeightsConverterTest.py b/test/IECoreMaya/ToMayaSkinClusterWeightsConverterTest.py deleted file mode 100644 index 17b284947c..0000000000 --- a/test/IECoreMaya/ToMayaSkinClusterWeightsConverterTest.py +++ /dev/null @@ -1,97 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds - -import imath -import IECore -import IECore.RandomAlgo -import IECoreScene -import IECoreMaya - -class ToMayaSkinClusterWeightsConverterTest( IECoreMaya.TestCase ) : - - def buildTestSetup( self ) : - - maya.cmds.select(d=True) - j1 = maya.cmds.joint( p=(4,0,0)) - j2 = maya.cmds.joint( p=(-2,0,2)) - j3 = maya.cmds.joint( p=(0,0,-5)) - geo = maya.cmds.polyPlane(sx=4, sy=4, w=10, h=10)[0] - maya.cmds.select( j1,add=True ) - - sc = maya.cmds.skinCluster([j1, j2, j3], geo, toSelectedBones=True, bindMethod=0, skinMethod=0, normalizeWeights=1)[0] - return sc, geo, [j1,j2,j3] - - def getRandomWeights(self, seed): - r = imath.Rand32(seed) - weights = [] - for i in range( 0, 25 ) : - val = IECore.RandomAlgo.barycentricRandf( r ) - weights.extend([val[0], val[1], val[2]]) - return weights - - def testWeightsConverter(self): - - sc, geo, joints = self.buildTestSetup() - weightsIn = self.getRandomWeights(13) - weightData = IECore.CompoundObject({ - 'pointIndexOffsets':IECore.IntVectorData( [ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72 ] ), - 'pointInfluenceCounts':IECore.IntVectorData( [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ] ), - 'pointInfluenceIndices':IECore.IntVectorData( [ 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2 ] ), - 'pointInfluenceWeights':IECore.FloatVectorData( weightsIn ) - }) - - c = IECoreMaya.ToMayaSkinClusterWeightsConverter.create(weightData) - c.convert(sc) - - weights = [] - for i in range( 0, 25 ) : - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[0], q=True)) - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[1], q=True)) - weights.append(maya.cmds.skinPercent(sc, '%s.vtx[%d]' % ( geo, i ), transform=joints[2], q=True)) - - for i in range( 0, 25 ): - self.assertAlmostEqual(weightsIn[i], weights[i]) - - for obj in joints + [geo, sc]: - if maya.cmds.objExists(obj): - maya.cmds.delete(obj) - - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/UndoTest.py b/test/IECoreMaya/UndoTest.py deleted file mode 100644 index 377af0dd2d..0000000000 --- a/test/IECoreMaya/UndoTest.py +++ /dev/null @@ -1,61 +0,0 @@ -########################################################################## -# -# Copyright (c) 2016, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import maya.cmds -import maya.mel - -import IECore -import IECoreMaya - -class UndoTest( IECoreMaya.TestCase ) : - - def test( self ) : - - maya.cmds.undoInfo(stateWithoutFlush=True ) - - with IECoreMaya.UndoChunk('test1'): - cube = maya.cmds.createNode('polyCube') - sphere = maya.cmds.createNode('polySphere') - - with IECoreMaya.UndoDisabled(): - plane = maya.cmds.createNode('polyPlane') - - maya.cmds.undo() - - self.assertFalse( maya.cmds.objExists( cube ) ) - self.assertFalse( maya.cmds.objExists( sphere ) ) - self.assertTrue( maya.cmds.objExists( plane ) ) - -if __name__ == "__main__": - IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/plugins/ObjectDataTestNode.py b/test/IECoreMaya/plugins/ObjectDataTestNode.py deleted file mode 100644 index 3d9991f2e9..0000000000 --- a/test/IECoreMaya/plugins/ObjectDataTestNode.py +++ /dev/null @@ -1,82 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECoreMaya - -import maya.OpenMaya as OpenMaya -import maya.OpenMayaMPx as OpenMayaMPx - -class ObjectDataTestNode( OpenMayaMPx.MPxNode ): - - typeId = OpenMaya.MTypeId( 0x00070000 ) - - objectDataAttr = OpenMaya.MObject() - - def __init__( self ): - OpenMayaMPx.MPxNode.__init__( self ) - - @staticmethod - def creator(): - - return OpenMayaMPx.asMPxPtr( ObjectDataTestNode() ) - - @staticmethod - def initialize(): - - fnData = OpenMaya.MFnPluginData() - - tAttr = OpenMaya.MFnTypedAttribute() - ObjectDataTestNode.objectDataAttr = tAttr.create( - "objectData", - "od", - IECoreMaya.MayaTypeId.ObjectData, - # should have a default value of ObjectData here, but maya will - # leak it and prevent the plugin unloading if we do that. - ) - tAttr.setStorable( True ) - tAttr.setReadable( True ) - tAttr.setWritable( True ) - - ObjectDataTestNode.addAttribute( ObjectDataTestNode.objectDataAttr ) - - -def initializePlugin( obj ) : - - plugin = OpenMayaMPx.MFnPlugin( obj ) - s = plugin.registerNode( "ieObjectDataTestNode", ObjectDataTestNode.typeId, ObjectDataTestNode.creator, ObjectDataTestNode.initialize ) - -def uninitializePlugin( obj ) : - - plugin = OpenMayaMPx.MFnPlugin( obj ) - plugin.deregisterNode( ObjectDataTestNode.typeId ) diff --git a/test/IECoreMaya/scenes/colouredPlane.ma b/test/IECoreMaya/scenes/colouredPlane.ma deleted file mode 100644 index 12067bad9c..0000000000 --- a/test/IECoreMaya/scenes/colouredPlane.ma +++ /dev/null @@ -1,240 +0,0 @@ -//Maya ASCII 2009 scene -//Name: colouredPlane.ma -//Last modified: Thu, Sep 22, 2011 12:39:43 PM -//Codeset: UTF-8 -requires maya "2009"; -currentUnit -l centimeter -a degree -t film; -fileInfo "application" "maya"; -fileInfo "product" "Maya Unlimited 2009"; -fileInfo "version" "2009 x64"; -fileInfo "cutIdentifier" "200809110001-734661"; -fileInfo "osv" "Linux 2.6.18-53.el5 #1 SMP Mon Nov 12 02:14:55 EST 2007 x86_64"; -createNode transform -s -n "persp"; - setAttr ".v" no; - setAttr ".t" -type "double3" 9.9006239165358831 25.442289249049587 17.287463882019363 ; - setAttr ".r" -type "double3" -51.938352729602919 29.800000000000495 0 ; -createNode camera -s -n "perspShape" -p "persp"; - setAttr -k off ".v" no; - setAttr ".fl" 34.999999999999993; - setAttr ".coi" 32.313910992652936; - setAttr ".imn" -type "string" "persp"; - setAttr ".den" -type "string" "persp_depth"; - setAttr ".man" -type "string" "persp_mask"; - setAttr ".hc" -type "string" "viewSet -p %camera"; -createNode transform -s -n "top"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 100.1 0 ; - setAttr ".r" -type "double3" -89.999999999999986 0 0 ; -createNode camera -s -n "topShape" -p "top"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "top"; - setAttr ".den" -type "string" "top_depth"; - setAttr ".man" -type "string" "top_mask"; - setAttr ".hc" -type "string" "viewSet -t %camera"; - setAttr ".o" yes; -createNode transform -s -n "front"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 0 100.1 ; -createNode camera -s -n "frontShape" -p "front"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "front"; - setAttr ".den" -type "string" "front_depth"; - setAttr ".man" -type "string" "front_mask"; - setAttr ".hc" -type "string" "viewSet -f %camera"; - setAttr ".o" yes; -createNode transform -s -n "side"; - setAttr ".v" no; - setAttr ".t" -type "double3" 100.1 0 0 ; - setAttr ".r" -type "double3" 0 89.999999999999986 0 ; -createNode camera -s -n "sideShape" -p "side"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "side"; - setAttr ".den" -type "string" "side_depth"; - setAttr ".man" -type "string" "side_mask"; - setAttr ".hc" -type "string" "viewSet -s %camera"; - setAttr ".o" yes; -createNode transform -n "pPlane1"; - setAttr ".t" -type "double3" 0.51224083890427963 0 -3.4379430057545175 ; -createNode mesh -n "pPlaneShape1" -p "pPlane1"; - addAttr -ci true -sn "mso" -ln "miShadingSamplesOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "msh" -ln "miShadingSamples" -min 0 -smx 8 -at "float"; - addAttr -ci true -sn "mdo" -ln "miMaxDisplaceOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "mmd" -ln "miMaxDisplace" -min 0 -smx 1 -at "float"; - setAttr -k off ".v"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcol" yes; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ccls" -type "string" "cRGBA"; - setAttr -s 3 ".clst"; - setAttr ".clst[0].clsn" -type "string" "cAlpha"; - setAttr ".clst[0].rprt" 1; - setAttr ".clst[1].clsn" -type "string" "cRGB"; - setAttr ".clst[1].rprt" 3; - setAttr ".clst[2].clsn" -type "string" "cRGBA"; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; -createNode lightLinker -n "lightLinker1"; - setAttr -s 2 ".lnk"; - setAttr -s 2 ".slnk"; -createNode displayLayerManager -n "layerManager"; -createNode displayLayer -n "defaultLayer"; -createNode renderLayerManager -n "renderLayerManager"; -createNode renderLayer -n "defaultRenderLayer"; - setAttr ".g" yes; -createNode polyPlane -n "polyPlane1"; - setAttr ".w" 22.053920378979818; - setAttr ".h" 17.016760263289374; - setAttr ".sw" 1; - setAttr ".sh" 1; - setAttr ".cuv" 2; -createNode createColorSet -n "createColorSet1"; - setAttr ".colos" -type "string" "cAlpha"; - setAttr ".clam" no; - setAttr ".rprt" 1; -createNode createColorSet -n "createColorSet2"; - setAttr ".colos" -type "string" "cRGB"; - setAttr ".clam" no; - setAttr ".rprt" 3; -createNode createColorSet -n "createColorSet3"; - setAttr ".colos" -type "string" "cRGBA"; - setAttr ".clam" no; -createNode polyColorPerVertex -n "polyColorPerVertex1"; - setAttr ".uopa" yes; - setAttr -s 4 ".vclr"; - setAttr ".vclr[0].vfcl[0].vfal" 0; - setAttr ".vclr[2].vfcl[0].vfal" 0.5; - setAttr ".vclr[3].vfcl[0].vfal" 0.80000001192092896; - setAttr ".cn" -type "string" "cAlpha"; - setAttr ".clam" no; - setAttr ".rprt" 1; -createNode polyColorPerVertex -n "polyColorPerVertex2"; - setAttr ".uopa" yes; - setAttr -s 4 ".vclr"; - setAttr ".vclr[0].vfcl[0].frgb" -type "float3" 1 0 0 ; - setAttr ".vclr[2].vfcl[0].frgb" -type "float3" 0 1 0 ; - setAttr ".vclr[3].vfcl[0].frgb" -type "float3" 0 0 1 ; - setAttr ".cn" -type "string" "cRGB"; - setAttr ".clam" no; - setAttr ".rprt" 3; -createNode polyColorPerVertex -n "polyColorPerVertex3"; - setAttr ".uopa" yes; - setAttr -s 4 ".vclr"; - setAttr ".vclr[0].vfcl[0].frgb" -type "float3" 1 1 0 ; - setAttr ".vclr[0].vfcl[0].vfal" 0.5; - setAttr ".vclr[1].vfcl[0].frgb" -type "float3" 1 1 1 ; - setAttr ".vclr[2].vfcl[0].frgb" -type "float3" 0 1 0 ; - setAttr ".vclr[2].vfcl[0].vfal" 0.5; - setAttr ".vclr[3].vfcl[0].frgb" -type "float3" 0 1 1 ; - setAttr ".cn" -type "string" "cRGBA"; - setAttr ".clam" no; -createNode script -n "uiConfigurationScriptNode"; - setAttr ".b" -type "string" ( - "// Maya Mel UI Configuration File.\n//\n// This script is machine generated. Edit at your own risk.\n//\n//\n\nglobal string $gMainPane;\nif (`paneLayout -exists $gMainPane`) {\n\n\tglobal int $gUseScenePanelConfig;\n\tint $useSceneConfig = $gUseScenePanelConfig;\n\tint $menusOkayInPanels = `optionVar -q allowMenusInPanels`;\tint $nVisPanes = `paneLayout -q -nvp $gMainPane`;\n\tint $nPanes = 0;\n\tstring $editorName;\n\tstring $panelName;\n\tstring $itemFilterName;\n\tstring $panelConfig;\n\n\t//\n\t// get current state of the UI\n\t//\n\tsceneUIReplacement -update $gMainPane;\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Top View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n" - + " -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n" - + " -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n" - + " -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n" - + " -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Side View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n" - + " -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n" - + " -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n" - + " -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n" - + " -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Front View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n" - + " -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n" - + " -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n" - + " -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n" - + " -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n" - + " -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n" - + " -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Persp View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n" - + " -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n" - + " -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n" - + " -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n" - + " -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"outlinerPanel\" (localizedPanelLabel(\"Outliner\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `outlinerPanel -unParent -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels `;\n" - + "\t\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\toutlinerPanel -edit -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n" - + " -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n" - + " -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"graphEditor\" (localizedPanelLabel(\"Graph Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"graphEditor\" -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dopeSheetPanel\" (localizedPanelLabel(\"Dope Sheet\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dopeSheetPanel\" -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"clipEditorPanel\" (localizedPanelLabel(\"Trax Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"clipEditorPanel\" -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n" - + "\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels $panelName;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperGraphPanel\" (localizedPanelLabel(\"Hypergraph Hierarchy\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperGraphPanel\" -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n" - + " -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n" - + " $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperShadePanel\" (localizedPanelLabel(\"Hypershade\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperShadePanel\" -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"visorPanel\" (localizedPanelLabel(\"Visor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"visorPanel\" -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"polyTexturePlacementPanel\" (localizedPanelLabel(\"UV Texture Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"polyTexturePlacementPanel\" -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"multiListerPanel\" (localizedPanelLabel(\"Multilister\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"multiListerPanel\" -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"renderWindowPanel\" (localizedPanelLabel(\"Render View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"renderWindowPanel\" -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"blendShapePanel\" (localizedPanelLabel(\"Blend Shape\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tblendShapePanel -unParent -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tblendShapePanel -edit -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n" - + "\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynRelEdPanel\" (localizedPanelLabel(\"Dynamic Relationships\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynRelEdPanel\" -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"devicePanel\" (localizedPanelLabel(\"Devices\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tdevicePanel -unParent -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tdevicePanel -edit -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n" - + "\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"relationshipPanel\" (localizedPanelLabel(\"Relationship Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"relationshipPanel\" -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"referenceEditorPanel\" (localizedPanelLabel(\"Reference Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"referenceEditorPanel\" -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"componentEditorPanel\" (localizedPanelLabel(\"Component Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"componentEditorPanel\" -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynPaintScriptedPanelType\" (localizedPanelLabel(\"Paint Effects\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynPaintScriptedPanelType\" -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"scriptEditorPanel\" (localizedPanelLabel(\"Script Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"scriptEditorPanel\" -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\tif ($useSceneConfig) {\n\t\tscriptedPanel -e -to $panelName;\n\t}\n\n\n\tif ($useSceneConfig) {\n string $configName = `getPanel -cwl (localizedPanelLabel(\"Current Layout\"))`;\n if (\"\" != $configName) {\n\t\t\tpanelConfiguration -edit -label (localizedPanelLabel(\"Current Layout\")) \n\t\t\t\t-defaultImage \"\"\n\t\t\t\t-image \"\"\n\t\t\t\t-sc false\n\t\t\t\t-configString \"global string $gMainPane; paneLayout -e -cn \\\"vertical2\\\" -ps 1 20 100 -ps 2 80 100 $gMainPane;\"\n" - + "\t\t\t\t-removeAllPanels\n\t\t\t\t-ap false\n\t\t\t\t\t(localizedPanelLabel(\"Outliner\")) \n\t\t\t\t\t\"outlinerPanel\"\n\t\t\t\t\t\"$panelName = `outlinerPanel -unParent -l (localizedPanelLabel(\\\"Outliner\\\")) -mbv $menusOkayInPanels `;\\n$editorName = $panelName;\\noutlinerEditor -e \\n -showShapes 1\\n -showAttributes 0\\n -showConnected 0\\n -showAnimCurvesOnly 0\\n -showMuteInfo 0\\n -organizeByLayer 1\\n -showAnimLayerWeight 1\\n -autoExpandLayers 1\\n -autoExpand 0\\n -showDagOnly 1\\n -showAssets 1\\n -showContainedOnly 1\\n -showPublishedAsConnected 0\\n -showContainerContents 1\\n -ignoreDagHierarchy 0\\n -expandConnections 0\\n -showUnitlessCurves 1\\n -showCompounds 1\\n -showLeafs 1\\n -showNumericAttrsOnly 0\\n -highlightActive 1\\n -autoSelectNewObjects 0\\n -doNotSelectNewObjects 0\\n -dropIsParent 1\\n -transmitFilters 0\\n -setFilter \\\"defaultSetFilter\\\" \\n -showSetMembers 1\\n -allowMultiSelection 1\\n -alwaysToggleSelect 0\\n -directSelect 0\\n -displayMode \\\"DAG\\\" \\n -expandObjects 0\\n -setsIgnoreFilters 1\\n -containersIgnoreFilters 0\\n -editAttrName 0\\n -showAttrValues 0\\n -highlightSecondary 0\\n -showUVAttrsOnly 0\\n -showTextureNodesOnly 0\\n -attrAlphaOrder \\\"default\\\" \\n -animLayerFilterOptions \\\"allAffecting\\\" \\n -sortOrder \\\"none\\\" \\n -longNames 0\\n -niceNames 1\\n -showNamespace 1\\n $editorName\"\n" - + "\t\t\t\t\t\"outlinerPanel -edit -l (localizedPanelLabel(\\\"Outliner\\\")) -mbv $menusOkayInPanels $panelName;\\n$editorName = $panelName;\\noutlinerEditor -e \\n -showShapes 1\\n -showAttributes 0\\n -showConnected 0\\n -showAnimCurvesOnly 0\\n -showMuteInfo 0\\n -organizeByLayer 1\\n -showAnimLayerWeight 1\\n -autoExpandLayers 1\\n -autoExpand 0\\n -showDagOnly 1\\n -showAssets 1\\n -showContainedOnly 1\\n -showPublishedAsConnected 0\\n -showContainerContents 1\\n -ignoreDagHierarchy 0\\n -expandConnections 0\\n -showUnitlessCurves 1\\n -showCompounds 1\\n -showLeafs 1\\n -showNumericAttrsOnly 0\\n -highlightActive 1\\n -autoSelectNewObjects 0\\n -doNotSelectNewObjects 0\\n -dropIsParent 1\\n -transmitFilters 0\\n -setFilter \\\"defaultSetFilter\\\" \\n -showSetMembers 1\\n -allowMultiSelection 1\\n -alwaysToggleSelect 0\\n -directSelect 0\\n -displayMode \\\"DAG\\\" \\n -expandObjects 0\\n -setsIgnoreFilters 1\\n -containersIgnoreFilters 0\\n -editAttrName 0\\n -showAttrValues 0\\n -highlightSecondary 0\\n -showUVAttrsOnly 0\\n -showTextureNodesOnly 0\\n -attrAlphaOrder \\\"default\\\" \\n -animLayerFilterOptions \\\"allAffecting\\\" \\n -sortOrder \\\"none\\\" \\n -longNames 0\\n -niceNames 1\\n -showNamespace 1\\n $editorName\"\n" - + "\t\t\t\t-ap false\n\t\t\t\t\t(localizedPanelLabel(\"Persp View\")) \n\t\t\t\t\t\"modelPanel\"\n" - + "\t\t\t\t\t\"$panelName = `modelPanel -unParent -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels `;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t\t\"modelPanel -edit -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels $panelName;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t$configName;\n\n setNamedPanelLayout (localizedPanelLabel(\"Current Layout\"));\n }\n\n panelHistory -e -clear mainPanelHistory;\n setFocus `paneLayout -q -p1 $gMainPane`;\n sceneUIReplacement -deleteRemaining;\n sceneUIReplacement -clear;\n\t}\n\n\ngrid -spacing 5 -size 12 -divisions 5 -displayAxes yes -displayGridLines yes -displayDivisionLines yes -displayPerspectiveLabels no -displayOrthographicLabels no -displayAxesBold yes -perspectiveLabelPosition axis -orthographicLabelPosition edge;\nviewManip -drawCompass 0 -compassAngle 0 -frontParameters \"\" -homeParameters \"\" -selectionLockParameters \"\";\n}\n"); - setAttr ".st" 3; -createNode script -n "sceneConfigurationScriptNode"; - setAttr ".b" -type "string" "playbackOptions -min 1 -max 24 -ast 1 -aet 48 "; - setAttr ".st" 6; -select -ne :time1; - setAttr ".o" 1; -select -ne :renderPartition; - setAttr -s 2 ".st"; -select -ne :renderGlobalsList1; -select -ne :defaultShaderList1; - setAttr -s 2 ".s"; -select -ne :postProcessList1; - setAttr -s 2 ".p"; -select -ne :lightList1; -select -ne :initialShadingGroup; - setAttr ".ro" yes; -select -ne :initialParticleSE; - setAttr ".ro" yes; -select -ne :hardwareRenderGlobals; - setAttr ".ctrs" 256; - setAttr ".btrs" 512; -select -ne :defaultHardwareRenderGlobals; - setAttr ".fn" -type "string" "im"; - setAttr ".res" -type "string" "ntsc_4d 646 485 1.333"; -connectAttr "polyColorPerVertex3.out" "pPlaneShape1.i"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[0].llnk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[0].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[1].llnk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.lnk[1].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[0].sllk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.slnk[0].solk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[1].sllk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.slnk[1].solk"; -connectAttr "layerManager.dli[0]" "defaultLayer.id"; -connectAttr "renderLayerManager.rlmi[0]" "defaultRenderLayer.rlid"; -connectAttr "polyPlane1.out" "createColorSet1.ig"; -connectAttr "createColorSet1.og" "createColorSet2.ig"; -connectAttr "createColorSet2.og" "createColorSet3.ig"; -connectAttr "createColorSet3.og" "polyColorPerVertex1.ip"; -connectAttr "polyColorPerVertex1.out" "polyColorPerVertex2.ip"; -connectAttr "polyColorPerVertex2.out" "polyColorPerVertex3.ip"; -connectAttr "lightLinker1.msg" ":lightList1.ln" -na; -connectAttr "pPlaneShape1.iog" ":initialShadingGroup.dsm" -na; -// End of colouredPlane.ma diff --git a/test/IECoreMaya/scenes/splineWithSparseEntries.ma b/test/IECoreMaya/scenes/splineWithSparseEntries.ma deleted file mode 100644 index e3c242f186..0000000000 --- a/test/IECoreMaya/scenes/splineWithSparseEntries.ma +++ /dev/null @@ -1,137 +0,0 @@ -//Maya ASCII 2009 scene -//Name: splineParameterHandlerTest.ma -//Last modified: Thu, Dec 03, 2009 12:32:33 PM -//Codeset: ANSI_X3.4-1968 -requires maya "2009"; -requires "ieCore" "1.0"; -currentUnit -l centimeter -a degree -t film; -fileInfo "application" "maya"; -fileInfo "product" "Maya Render 2009"; -fileInfo "version" "2009 x64"; -fileInfo "cutIdentifier" "200809110001-734661"; -fileInfo "osv" "Linux 2.6.18-53.el5 #1 SMP Mon Nov 12 02:14:55 EST 2007 x86_64"; -createNode transform -s -n "persp"; - setAttr ".v" no; - setAttr ".t" -type "double3" 28 21 28 ; - setAttr ".r" -type "double3" -27.938352729602379 44.999999999999972 -5.172681101354183e-14 ; -createNode camera -s -n "perspShape" -p "persp"; - setAttr -k off ".v" no; - setAttr ".fl" 34.999999999999993; - setAttr ".coi" 44.82186966202994; - setAttr ".imn" -type "string" "persp"; - setAttr ".den" -type "string" "persp_depth"; - setAttr ".man" -type "string" "persp_mask"; - setAttr ".hc" -type "string" "viewSet -p %camera"; -createNode transform -s -n "top"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 100.1 0 ; - setAttr ".r" -type "double3" -89.999999999999986 0 0 ; -createNode camera -s -n "topShape" -p "top"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "top"; - setAttr ".den" -type "string" "top_depth"; - setAttr ".man" -type "string" "top_mask"; - setAttr ".hc" -type "string" "viewSet -t %camera"; - setAttr ".o" yes; -createNode transform -s -n "front"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 0 100.1 ; -createNode camera -s -n "frontShape" -p "front"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "front"; - setAttr ".den" -type "string" "front_depth"; - setAttr ".man" -type "string" "front_mask"; - setAttr ".hc" -type "string" "viewSet -f %camera"; - setAttr ".o" yes; -createNode transform -s -n "side"; - setAttr ".v" no; - setAttr ".t" -type "double3" 100.1 0 0 ; - setAttr ".r" -type "double3" 0 89.999999999999986 0 ; -createNode camera -s -n "sideShape" -p "side"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "side"; - setAttr ".den" -type "string" "side_depth"; - setAttr ".man" -type "string" "side_mask"; - setAttr ".hc" -type "string" "viewSet -s %camera"; - setAttr ".o" yes; -createNode lightLinker -n "lightLinker1"; - setAttr -s 2 ".lnk"; - setAttr -s 2 ".slnk"; -createNode displayLayerManager -n "layerManager"; -createNode displayLayer -n "defaultLayer"; -createNode renderLayerManager -n "renderLayerManager"; -createNode renderLayer -n "defaultRenderLayer"; - setAttr ".g" yes; -createNode ieOpHolderNode -n "test"; - addAttr -ci true -m -sn "parm_spline" -ln "parm_spline" -bt "UNKN" -at "compound" - -nc 3; - addAttr -ci true -sn "parm_splinep" -ln "parm_spline_Position" -bt "UNKN" -at "float" - -p "parm_spline"; - addAttr -ci true -sn "parm_splinefv" -ln "parm_spline_FloatValue" -bt "UNKN" -at "float" - -p "parm_spline"; - addAttr -ci true -sn "parm_splinei" -ln "parm_spline_Interp" -bt "UNKN" -dv 1 -min - 0 -max 3 -en "None:Linear:Smooth:Spline" -at "enum" -p "parm_spline"; - addAttr -ci true -k true -sn "result" -ln "result" -bt "UNKN" -min -2147483648 -max - 2147483647 -at "long"; - setAttr ".cch" no; - setAttr ".ihi" 2; - setAttr ".nds" 0; - setAttr ".clas" -type "string" "splineInput"; - setAttr ".ver" 1; - setAttr ".spev" -type "string" "IECORE_OP_PATHS"; - - setAttr -s 7 ".parm_spline"; - setAttr ".parm_spline[0:3]" 0 0.4166666567325592 3 1 0.3684210479259491 - 3 0.089108914136886597 0.56578946113586426 3 0.15807560086250305 0.32017543911933899 - 3; - setAttr ".parm_spline[5:7]" 0.84536081552505493 0.23684211075305939 - 3 0.22852233052253723 0.2850877046585083 3 0.48969072103500366 0.24561403691768646 - 3; - -createNode script -n "uiConfigurationScriptNode"; - setAttr ".b" -type "string" "// Maya Mel UI Configuration File.\n// No UI generated in batch mode.\n"; - setAttr ".st" 3; -createNode script -n "sceneConfigurationScriptNode"; - setAttr ".b" -type "string" "playbackOptions -min 1 -max 24 -ast 1 -aet 48 "; - setAttr ".st" 6; -select -ne :time1; - setAttr ".o" 1; -select -ne :renderPartition; - setAttr -s 2 ".st"; -select -ne :renderGlobalsList1; -select -ne :defaultShaderList1; - setAttr -s 2 ".s"; -select -ne :postProcessList1; - setAttr -s 2 ".p"; -select -ne :lightList1; -select -ne :initialShadingGroup; - setAttr ".ro" yes; -select -ne :initialParticleSE; - setAttr ".ro" yes; -select -ne :hardwareRenderGlobals; - setAttr ".ctrs" 256; - setAttr ".btrs" 512; -select -ne :defaultHardwareRenderGlobals; - setAttr ".fn" -type "string" "im"; - setAttr ".res" -type "string" "ntsc_4d 646 485 1.333"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[0].llnk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[0].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[1].llnk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.lnk[1].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[0].sllk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.slnk[0].solk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[1].sllk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.slnk[1].solk"; -connectAttr "layerManager.dli[0]" "defaultLayer.id"; -connectAttr "renderLayerManager.rlmi[0]" "defaultRenderLayer.rlid"; -connectAttr "lightLinker1.msg" ":lightList1.ln" -na; -// End of splineParameterHandlerTest.ma diff --git a/test/IECoreMaya/scenes/twoTrianglesWithSharedUVs.ma b/test/IECoreMaya/scenes/twoTrianglesWithSharedUVs.ma deleted file mode 100644 index 2e107c5cb3..0000000000 --- a/test/IECoreMaya/scenes/twoTrianglesWithSharedUVs.ma +++ /dev/null @@ -1,185 +0,0 @@ -//Maya ASCII 2009 scene -//Name: twoTrianglesWithSharedUVs.ma -//Last modified: Tue, Oct 27, 2009 03:35:08 PM -//Codeset: UTF-8 -requires maya "2009"; -currentUnit -l centimeter -a degree -t film; -fileInfo "application" "maya"; -fileInfo "product" "Maya Complete 2009"; -fileInfo "version" "2009 x64"; -fileInfo "cutIdentifier" "200809110001-734661"; -fileInfo "osv" "Linux 2.6.18-53.el5 #1 SMP Mon Nov 12 02:14:55 EST 2007 x86_64"; -createNode transform -s -n "persp"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0.29055677905216287 2.0515137147532414 -0.0030428147031733789 ; - setAttr ".r" -type "double3" -81.938352729625748 90.599999999998658 -6.1066649884099522e-13 ; -createNode camera -s -n "perspShape" -p "persp"; - setAttr -k off ".v" no; - setAttr ".fl" 34.999999999999986; - setAttr ".coi" 2.0719896289303996; - setAttr ".imn" -type "string" "persp"; - setAttr ".den" -type "string" "persp_depth"; - setAttr ".man" -type "string" "persp_mask"; - setAttr ".hc" -type "string" "viewSet -p %camera"; -createNode transform -s -n "top"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 100.1 0 ; - setAttr ".r" -type "double3" -89.999999999999986 0 0 ; -createNode camera -s -n "topShape" -p "top"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "top"; - setAttr ".den" -type "string" "top_depth"; - setAttr ".man" -type "string" "top_mask"; - setAttr ".hc" -type "string" "viewSet -t %camera"; - setAttr ".o" yes; -createNode transform -s -n "front"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 0 100.1 ; -createNode camera -s -n "frontShape" -p "front"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "front"; - setAttr ".den" -type "string" "front_depth"; - setAttr ".man" -type "string" "front_mask"; - setAttr ".hc" -type "string" "viewSet -f %camera"; - setAttr ".o" yes; -createNode transform -s -n "side"; - setAttr ".v" no; - setAttr ".t" -type "double3" 100.1 0 0 ; - setAttr ".r" -type "double3" 0 89.999999999999986 0 ; -createNode camera -s -n "sideShape" -p "side"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "side"; - setAttr ".den" -type "string" "side_depth"; - setAttr ".man" -type "string" "side_mask"; - setAttr ".hc" -type "string" "viewSet -s %camera"; - setAttr ".o" yes; -createNode transform -n "pPlane1"; -createNode mesh -n "pPlaneShape1" -p "pPlane1"; - addAttr -ci true -sn "mso" -ln "miShadingSamplesOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "msh" -ln "miShadingSamples" -min 0 -smx 8 -at "float"; - addAttr -ci true -sn "mdo" -ln "miMaxDisplaceOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "mmd" -ln "miMaxDisplace" -min 0 -smx 1 -at "float"; - setAttr -k off ".v"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".pv" -type "double2" 0 1 ; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; -createNode lightLinker -n "lightLinker1"; - setAttr -s 2 ".lnk"; - setAttr -s 2 ".slnk"; -createNode displayLayerManager -n "layerManager"; -createNode displayLayer -n "defaultLayer"; -createNode renderLayerManager -n "renderLayerManager"; -createNode renderLayer -n "defaultRenderLayer"; - setAttr ".g" yes; -createNode polyPlane -n "polyPlane1"; - setAttr ".sw" 1; - setAttr ".sh" 1; - setAttr ".cuv" 2; -createNode polyTriangulate -n "polyTriangulate1"; - setAttr ".ics" -type "componentList" 1 "f[*]"; -createNode script -n "uiConfigurationScriptNode"; - setAttr ".b" -type "string" ( - "// Maya Mel UI Configuration File.\n//\n// This script is machine generated. Edit at your own risk.\n//\n//\n\nglobal string $gMainPane;\nif (`paneLayout -exists $gMainPane`) {\n\n\tglobal int $gUseScenePanelConfig;\n\tint $useSceneConfig = $gUseScenePanelConfig;\n\tint $menusOkayInPanels = `optionVar -q allowMenusInPanels`;\tint $nVisPanes = `paneLayout -q -nvp $gMainPane`;\n\tint $nPanes = 0;\n\tstring $editorName;\n\tstring $panelName;\n\tstring $itemFilterName;\n\tstring $panelConfig;\n\n\t//\n\t// get current state of the UI\n\t//\n\tsceneUIReplacement -update $gMainPane;\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Top View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n" - + " -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n" - + " -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n" - + " -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n" - + " -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Side View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n" - + " -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n" - + " -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n" - + " -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n" - + " -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Front View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n" - + " -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n" - + " -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n" - + " -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n" - + " -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n" - + " -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n" - + " -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Persp View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n" - + " -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n" - + " -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n" - + " -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n" - + " -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"outlinerPanel\" (localizedPanelLabel(\"Outliner\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `outlinerPanel -unParent -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels `;\n" - + "\t\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\toutlinerPanel -edit -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n" - + " -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n" - + " -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"graphEditor\" (localizedPanelLabel(\"Graph Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"graphEditor\" -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dopeSheetPanel\" (localizedPanelLabel(\"Dope Sheet\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dopeSheetPanel\" -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"clipEditorPanel\" (localizedPanelLabel(\"Trax Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"clipEditorPanel\" -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n" - + "\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels $panelName;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperGraphPanel\" (localizedPanelLabel(\"Hypergraph Hierarchy\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperGraphPanel\" -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n" - + " -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n" - + " $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperShadePanel\" (localizedPanelLabel(\"Hypershade\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperShadePanel\" -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"visorPanel\" (localizedPanelLabel(\"Visor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"visorPanel\" -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"polyTexturePlacementPanel\" (localizedPanelLabel(\"UV Texture Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"polyTexturePlacementPanel\" -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"multiListerPanel\" (localizedPanelLabel(\"Multilister\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"multiListerPanel\" -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"renderWindowPanel\" (localizedPanelLabel(\"Render View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"renderWindowPanel\" -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"blendShapePanel\" (localizedPanelLabel(\"Blend Shape\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tblendShapePanel -unParent -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tblendShapePanel -edit -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n" - + "\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynRelEdPanel\" (localizedPanelLabel(\"Dynamic Relationships\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynRelEdPanel\" -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"devicePanel\" (localizedPanelLabel(\"Devices\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tdevicePanel -unParent -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tdevicePanel -edit -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n" - + "\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"relationshipPanel\" (localizedPanelLabel(\"Relationship Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"relationshipPanel\" -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"referenceEditorPanel\" (localizedPanelLabel(\"Reference Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"referenceEditorPanel\" -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"componentEditorPanel\" (localizedPanelLabel(\"Component Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"componentEditorPanel\" -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynPaintScriptedPanelType\" (localizedPanelLabel(\"Paint Effects\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynPaintScriptedPanelType\" -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"scriptEditorPanel\" (localizedPanelLabel(\"Script Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"scriptEditorPanel\" -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\tif ($useSceneConfig) {\n\t\tscriptedPanel -e -to $panelName;\n\t}\n\n\n\tif ($useSceneConfig) {\n string $configName = `getPanel -cwl (localizedPanelLabel(\"Current Layout\"))`;\n if (\"\" != $configName) {\n\t\t\tpanelConfiguration -edit -label (localizedPanelLabel(\"Current Layout\")) \n\t\t\t\t-defaultImage \"\"\n\t\t\t\t-image \"\"\n\t\t\t\t-sc false\n\t\t\t\t-configString \"global string $gMainPane; paneLayout -e -cn \\\"single\\\" -ps 1 100 100 $gMainPane;\"\n" - + "\t\t\t\t-removeAllPanels\n\t\t\t\t-ap false\n\t\t\t\t\t(localizedPanelLabel(\"Persp View\")) \n\t\t\t\t\t\"modelPanel\"\n" - + "\t\t\t\t\t\"$panelName = `modelPanel -unParent -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels `;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t\t\"modelPanel -edit -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels $panelName;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t$configName;\n\n setNamedPanelLayout (localizedPanelLabel(\"Current Layout\"));\n }\n\n panelHistory -e -clear mainPanelHistory;\n setFocus `paneLayout -q -p1 $gMainPane`;\n sceneUIReplacement -deleteRemaining;\n sceneUIReplacement -clear;\n\t}\n\n\ngrid -spacing 5 -size 12 -divisions 5 -displayAxes yes -displayGridLines yes -displayDivisionLines yes -displayPerspectiveLabels no -displayOrthographicLabels no -displayAxesBold yes -perspectiveLabelPosition axis -orthographicLabelPosition edge;\nviewManip -drawCompass 0 -compassAngle 0 -frontParameters \"\" -homeParameters \"\" -selectionLockParameters \"\";\n}\n"); - setAttr ".st" 3; -createNode script -n "sceneConfigurationScriptNode"; - setAttr ".b" -type "string" "playbackOptions -min 1 -max 24 -ast 1 -aet 48 "; - setAttr ".st" 6; -select -ne :time1; - setAttr ".o" 1; -select -ne :renderPartition; - setAttr -s 2 ".st"; -select -ne :renderGlobalsList1; -select -ne :defaultShaderList1; - setAttr -s 2 ".s"; -select -ne :postProcessList1; - setAttr -s 2 ".p"; -select -ne :lightList1; -select -ne :initialShadingGroup; - setAttr ".ro" yes; -select -ne :initialParticleSE; - setAttr ".ro" yes; -select -ne :hardwareRenderGlobals; - setAttr ".ctrs" 256; - setAttr ".btrs" 512; -select -ne :defaultHardwareRenderGlobals; - setAttr ".fn" -type "string" "im"; - setAttr ".res" -type "string" "ntsc_4d 646 485 1.333"; -connectAttr "polyTriangulate1.out" "pPlaneShape1.i"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[0].llnk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[0].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[1].llnk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.lnk[1].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[0].sllk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.slnk[0].solk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[1].sllk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.slnk[1].solk"; -connectAttr "layerManager.dli[0]" "defaultLayer.id"; -connectAttr "renderLayerManager.rlmi[0]" "defaultRenderLayer.rlid"; -connectAttr "polyPlane1.out" "polyTriangulate1.ip"; -connectAttr "lightLinker1.msg" ":lightList1.ln" -na; -connectAttr "pPlaneShape1.iog" ":initialShadingGroup.dsm" -na; -// End of twoTrianglesWithSharedUVs.ma diff --git a/test/IECoreMaya/scenes/twoTrianglesWithSplitUVs.ma b/test/IECoreMaya/scenes/twoTrianglesWithSplitUVs.ma deleted file mode 100644 index 275c413c2a..0000000000 --- a/test/IECoreMaya/scenes/twoTrianglesWithSplitUVs.ma +++ /dev/null @@ -1,189 +0,0 @@ -//Maya ASCII 2009 scene -//Name: twoTrianglesWithSplitUVs.ma -//Last modified: Tue, Oct 27, 2009 03:35:36 PM -//Codeset: UTF-8 -requires maya "2009"; -currentUnit -l centimeter -a degree -t film; -fileInfo "application" "maya"; -fileInfo "product" "Maya Complete 2009"; -fileInfo "version" "2009 x64"; -fileInfo "cutIdentifier" "200809110001-734661"; -fileInfo "osv" "Linux 2.6.18-53.el5 #1 SMP Mon Nov 12 02:14:55 EST 2007 x86_64"; -createNode transform -s -n "persp"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0.29055677905216287 2.0515137147532414 -0.0030428147031733789 ; - setAttr ".r" -type "double3" -81.938352729625748 90.599999999998658 -6.1066649884099522e-13 ; -createNode camera -s -n "perspShape" -p "persp"; - setAttr -k off ".v" no; - setAttr ".fl" 34.999999999999986; - setAttr ".coi" 2.0719896289303996; - setAttr ".imn" -type "string" "persp"; - setAttr ".den" -type "string" "persp_depth"; - setAttr ".man" -type "string" "persp_mask"; - setAttr ".hc" -type "string" "viewSet -p %camera"; -createNode transform -s -n "top"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 100.1 0 ; - setAttr ".r" -type "double3" -89.999999999999986 0 0 ; -createNode camera -s -n "topShape" -p "top"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "top"; - setAttr ".den" -type "string" "top_depth"; - setAttr ".man" -type "string" "top_mask"; - setAttr ".hc" -type "string" "viewSet -t %camera"; - setAttr ".o" yes; -createNode transform -s -n "front"; - setAttr ".v" no; - setAttr ".t" -type "double3" 0 0 100.1 ; -createNode camera -s -n "frontShape" -p "front"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "front"; - setAttr ".den" -type "string" "front_depth"; - setAttr ".man" -type "string" "front_mask"; - setAttr ".hc" -type "string" "viewSet -f %camera"; - setAttr ".o" yes; -createNode transform -s -n "side"; - setAttr ".v" no; - setAttr ".t" -type "double3" 100.1 0 0 ; - setAttr ".r" -type "double3" 0 89.999999999999986 0 ; -createNode camera -s -n "sideShape" -p "side"; - setAttr -k off ".v" no; - setAttr ".rnd" no; - setAttr ".coi" 100.1; - setAttr ".ow" 30; - setAttr ".imn" -type "string" "side"; - setAttr ".den" -type "string" "side_depth"; - setAttr ".man" -type "string" "side_mask"; - setAttr ".hc" -type "string" "viewSet -s %camera"; - setAttr ".o" yes; -createNode transform -n "pPlane1"; -createNode mesh -n "pPlaneShape1" -p "pPlane1"; - addAttr -ci true -sn "mso" -ln "miShadingSamplesOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "msh" -ln "miShadingSamples" -min 0 -smx 8 -at "float"; - addAttr -ci true -sn "mdo" -ln "miMaxDisplaceOverride" -min 0 -max 1 -at "bool"; - addAttr -ci true -sn "mmd" -ln "miMaxDisplace" -min 0 -smx 1 -at "float"; - setAttr -k off ".v"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".pv" -type "double2" 0 1 ; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; -createNode lightLinker -n "lightLinker1"; - setAttr -s 2 ".lnk"; - setAttr -s 2 ".slnk"; -createNode displayLayerManager -n "layerManager"; -createNode displayLayer -n "defaultLayer"; -createNode renderLayerManager -n "renderLayerManager"; -createNode renderLayer -n "defaultRenderLayer"; - setAttr ".g" yes; -createNode polyPlane -n "polyPlane1"; - setAttr ".sw" 1; - setAttr ".sh" 1; - setAttr ".cuv" 2; -createNode polyTriangulate -n "polyTriangulate1"; - setAttr ".ics" -type "componentList" 1 "f[*]"; -createNode script -n "uiConfigurationScriptNode"; - setAttr ".b" -type "string" ( - "// Maya Mel UI Configuration File.\n//\n// This script is machine generated. Edit at your own risk.\n//\n//\n\nglobal string $gMainPane;\nif (`paneLayout -exists $gMainPane`) {\n\n\tglobal int $gUseScenePanelConfig;\n\tint $useSceneConfig = $gUseScenePanelConfig;\n\tint $menusOkayInPanels = `optionVar -q allowMenusInPanels`;\tint $nVisPanes = `paneLayout -q -nvp $gMainPane`;\n\tint $nPanes = 0;\n\tstring $editorName;\n\tstring $panelName;\n\tstring $itemFilterName;\n\tstring $panelConfig;\n\n\t//\n\t// get current state of the UI\n\t//\n\tsceneUIReplacement -update $gMainPane;\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Top View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n" - + " -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n" - + " -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n" - + " -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Top View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"top\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n" - + " -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Side View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n" - + " -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n" - + " -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n" - + "\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Side View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"side\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n" - + " -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n" - + " -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Front View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n" - + " -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n" - + " -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n" - + " -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Front View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"front\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"wireframe\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n" - + " -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n" - + " -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n" - + " -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"modelPanel\" (localizedPanelLabel(\"Persp View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `modelPanel -unParent -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels `;\n\t\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n" - + " -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n" - + " -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n" - + " -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tmodelPanel -edit -l (localizedPanelLabel(\"Persp View\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n modelEditor -e \n -camera \"persp\" \n -useInteractiveMode 0\n -displayLights \"default\" \n -displayAppearance \"smoothShaded\" \n -activeOnly 0\n -wireframeOnShaded 0\n -headsUpDisplay 1\n -selectionHiliteDisplay 1\n -useDefaultMaterial 0\n -bufferMode \"double\" \n -twoSidedLighting 1\n -backfaceCulling 0\n -xray 0\n -jointXray 0\n -activeComponentsXray 0\n -displayTextures 0\n -smoothWireframe 0\n -lineWidth 1\n -textureAnisotropic 0\n -textureHilight 1\n -textureSampling 2\n" - + " -textureDisplay \"modulate\" \n -textureMaxSize 8192\n -fogging 0\n -fogSource \"fragment\" \n -fogMode \"linear\" \n -fogStart 0\n -fogEnd 100\n -fogDensity 0.1\n -fogColor 0.5 0.5 0.5 1 \n -maxConstantTransparency 1\n -rendererName \"base_OpenGL_Renderer\" \n -colorResolution 256 256 \n -bumpResolution 512 512 \n -textureCompression 0\n -transparencyAlgorithm \"frontAndBackCull\" \n -transpInShadows 0\n -cullingOverride \"none\" \n -lowQualityLighting 0\n -maximumNumHardwareLights 1\n -occlusionCulling 0\n -shadingModel 0\n -useBaseRenderer 0\n -useReducedRenderer 0\n -smallObjectCulling 0\n -smallObjectThreshold -1 \n -interactiveDisableShadows 0\n -interactiveBackFaceCull 0\n -sortTransparent 1\n -nurbsCurves 1\n -nurbsSurfaces 1\n" - + " -polymeshes 1\n -subdivSurfaces 1\n -planes 1\n -lights 1\n -cameras 1\n -controlVertices 1\n -hulls 1\n -grid 1\n -joints 1\n -ikHandles 1\n -deformers 1\n -dynamics 1\n -fluids 1\n -hairSystems 1\n -follicles 1\n -nCloths 1\n -nParticles 1\n -nRigids 1\n -dynamicConstraints 1\n -locators 1\n -manipulators 1\n -dimensions 1\n -handles 1\n -pivots 1\n -textures 1\n -strokes 1\n -shadows 0\n $editorName;\nmodelEditor -e -viewSelected 0 $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"outlinerPanel\" (localizedPanelLabel(\"Outliner\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `outlinerPanel -unParent -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels `;\n" - + "\t\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\toutlinerPanel -edit -l (localizedPanelLabel(\"Outliner\")) -mbv $menusOkayInPanels $panelName;\n\t\t$editorName = $panelName;\n outlinerEditor -e \n -showShapes 1\n -showAttributes 0\n -showConnected 0\n -showAnimCurvesOnly 0\n -showMuteInfo 0\n" - + " -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 1\n -showAssets 1\n -showContainedOnly 1\n -showPublishedAsConnected 0\n -showContainerContents 1\n -ignoreDagHierarchy 0\n -expandConnections 0\n -showUnitlessCurves 1\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 0\n -highlightActive 1\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"defaultSetFilter\" \n -showSetMembers 1\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n" - + " -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"graphEditor\" (localizedPanelLabel(\"Graph Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"graphEditor\" -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Graph Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 1\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 1\n -showCompounds 0\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 1\n -doNotSelectNewObjects 0\n -dropIsParent 1\n -transmitFilters 1\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"GraphEd\");\n animCurveEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 1\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -showResults \"off\" \n -showBufferCurves \"off\" \n -smoothness \"fine\" \n -resultSamples 1\n -resultScreenSamples 0\n -resultUpdate \"delayed\" \n -constrainDrag 0\n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dopeSheetPanel\" (localizedPanelLabel(\"Dope Sheet\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dopeSheetPanel\" -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n" - + " -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n" - + " -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dope Sheet\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"OutlineEd\");\n outlinerEditor -e \n -showShapes 1\n -showAttributes 1\n -showConnected 1\n -showAnimCurvesOnly 1\n -showMuteInfo 0\n -organizeByLayer 1\n -showAnimLayerWeight 1\n -autoExpandLayers 1\n -autoExpand 0\n -showDagOnly 0\n -showAssets 1\n -showContainedOnly 0\n -showPublishedAsConnected 0\n -showContainerContents 0\n -ignoreDagHierarchy 0\n -expandConnections 1\n -showUnitlessCurves 0\n -showCompounds 1\n -showLeafs 1\n -showNumericAttrsOnly 1\n -highlightActive 0\n -autoSelectNewObjects 0\n -doNotSelectNewObjects 1\n -dropIsParent 1\n -transmitFilters 0\n -setFilter \"0\" \n -showSetMembers 0\n" - + " -allowMultiSelection 1\n -alwaysToggleSelect 0\n -directSelect 0\n -displayMode \"DAG\" \n -expandObjects 0\n -setsIgnoreFilters 1\n -containersIgnoreFilters 0\n -editAttrName 0\n -showAttrValues 0\n -highlightSecondary 0\n -showUVAttrsOnly 0\n -showTextureNodesOnly 0\n -attrAlphaOrder \"default\" \n -animLayerFilterOptions \"allAffecting\" \n -sortOrder \"none\" \n -longNames 0\n -niceNames 1\n -showNamespace 1\n $editorName;\n\n\t\t\t$editorName = ($panelName+\"DopeSheetEd\");\n dopeSheetEditor -e \n -displayKeys 1\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"integer\" \n -snapValue \"none\" \n" - + " -outliner \"dopeSheetPanel1OutlineEd\" \n -showSummary 1\n -showScene 0\n -hierarchyBelow 0\n -showTicks 1\n -selectionWindow 0 0 0 0 \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"clipEditorPanel\" (localizedPanelLabel(\"Trax Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"clipEditorPanel\" -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n" - + "\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Trax Editor\")) -mbv $menusOkayInPanels $panelName;\n\n\t\t\t$editorName = clipEditorNameFromPanel($panelName);\n clipEditor -e \n -displayKeys 0\n -displayTangents 0\n -displayActiveKeys 0\n -displayActiveKeyTangents 0\n -displayInfinities 0\n -autoFit 0\n -snapTime \"none\" \n -snapValue \"none\" \n $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperGraphPanel\" (localizedPanelLabel(\"Hypergraph Hierarchy\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperGraphPanel\" -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels `;\n\n\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n" - + " -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n $editorName;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypergraph Hierarchy\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\t\t$editorName = ($panelName+\"HyperGraphEd\");\n hyperGraph -e \n -graphLayoutStyle \"hierarchicalLayout\" \n -orientation \"horiz\" \n -mergeConnections 0\n -zoom 1\n -animateTransition 0\n -showRelationships 1\n -showShapes 0\n -showDeformers 0\n -showExpressions 0\n -showConstraints 0\n -showUnderworld 0\n -showInvisible 0\n -transitionFrames 1\n -opaqueContainers 0\n -freeform 0\n -imagePosition 0 0 \n -imageScale 1\n -imageEnabled 0\n -graphType \"DAG\" \n -heatMapDisplay 0\n -updateSelection 1\n -updateNodeAdded 1\n -useDrawOverrideColor 0\n -limitGraphTraversal -1\n -range 0 0 \n -iconSize \"smallIcons\" \n -showCachedConnections 0\n" - + " $editorName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"hyperShadePanel\" (localizedPanelLabel(\"Hypershade\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"hyperShadePanel\" -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Hypershade\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"visorPanel\" (localizedPanelLabel(\"Visor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"visorPanel\" -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Visor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"polyTexturePlacementPanel\" (localizedPanelLabel(\"UV Texture Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"polyTexturePlacementPanel\" -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"UV Texture Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"multiListerPanel\" (localizedPanelLabel(\"Multilister\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"multiListerPanel\" -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Multilister\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"renderWindowPanel\" (localizedPanelLabel(\"Render View\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"renderWindowPanel\" -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Render View\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"blendShapePanel\" (localizedPanelLabel(\"Blend Shape\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tblendShapePanel -unParent -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tblendShapePanel -edit -l (localizedPanelLabel(\"Blend Shape\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n" - + "\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynRelEdPanel\" (localizedPanelLabel(\"Dynamic Relationships\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynRelEdPanel\" -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Dynamic Relationships\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextPanel \"devicePanel\" (localizedPanelLabel(\"Devices\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\tdevicePanel -unParent -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels ;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tdevicePanel -edit -l (localizedPanelLabel(\"Devices\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n" - + "\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"relationshipPanel\" (localizedPanelLabel(\"Relationship Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"relationshipPanel\" -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Relationship Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"referenceEditorPanel\" (localizedPanelLabel(\"Reference Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"referenceEditorPanel\" -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Reference Editor\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"componentEditorPanel\" (localizedPanelLabel(\"Component Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"componentEditorPanel\" -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Component Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"dynPaintScriptedPanelType\" (localizedPanelLabel(\"Paint Effects\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"dynPaintScriptedPanelType\" -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Paint Effects\")) -mbv $menusOkayInPanels $panelName;\n" - + "\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\n\n\t$panelName = `sceneUIReplacement -getNextScriptedPanel \"scriptEditorPanel\" (localizedPanelLabel(\"Script Editor\")) `;\n\tif (\"\" == $panelName) {\n\t\tif ($useSceneConfig) {\n\t\t\t$panelName = `scriptedPanel -unParent -type \"scriptEditorPanel\" -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels `;\n\t\t}\n\t} else {\n\t\t$label = `panel -q -label $panelName`;\n\t\tscriptedPanel -edit -l (localizedPanelLabel(\"Script Editor\")) -mbv $menusOkayInPanels $panelName;\n\t\tif (!$useSceneConfig) {\n\t\t\tpanel -e -l $label $panelName;\n\t\t}\n\t}\n\tif ($useSceneConfig) {\n\t\tscriptedPanel -e -to $panelName;\n\t}\n\n\n\tif ($useSceneConfig) {\n string $configName = `getPanel -cwl (localizedPanelLabel(\"Current Layout\"))`;\n if (\"\" != $configName) {\n\t\t\tpanelConfiguration -edit -label (localizedPanelLabel(\"Current Layout\")) \n\t\t\t\t-defaultImage \"\"\n\t\t\t\t-image \"\"\n\t\t\t\t-sc false\n\t\t\t\t-configString \"global string $gMainPane; paneLayout -e -cn \\\"single\\\" -ps 1 100 100 $gMainPane;\"\n" - + "\t\t\t\t-removeAllPanels\n\t\t\t\t-ap false\n\t\t\t\t\t(localizedPanelLabel(\"Persp View\")) \n\t\t\t\t\t\"modelPanel\"\n" - + "\t\t\t\t\t\"$panelName = `modelPanel -unParent -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels `;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t\t\"modelPanel -edit -l (localizedPanelLabel(\\\"Persp View\\\")) -mbv $menusOkayInPanels $panelName;\\n$editorName = $panelName;\\nmodelEditor -e \\n -cam `findStartUpCamera persp` \\n -useInteractiveMode 0\\n -displayLights \\\"default\\\" \\n -displayAppearance \\\"smoothShaded\\\" \\n -activeOnly 0\\n -wireframeOnShaded 0\\n -headsUpDisplay 1\\n -selectionHiliteDisplay 1\\n -useDefaultMaterial 0\\n -bufferMode \\\"double\\\" \\n -twoSidedLighting 1\\n -backfaceCulling 0\\n -xray 0\\n -jointXray 0\\n -activeComponentsXray 0\\n -displayTextures 0\\n -smoothWireframe 0\\n -lineWidth 1\\n -textureAnisotropic 0\\n -textureHilight 1\\n -textureSampling 2\\n -textureDisplay \\\"modulate\\\" \\n -textureMaxSize 8192\\n -fogging 0\\n -fogSource \\\"fragment\\\" \\n -fogMode \\\"linear\\\" \\n -fogStart 0\\n -fogEnd 100\\n -fogDensity 0.1\\n -fogColor 0.5 0.5 0.5 1 \\n -maxConstantTransparency 1\\n -rendererName \\\"base_OpenGL_Renderer\\\" \\n -colorResolution 256 256 \\n -bumpResolution 512 512 \\n -textureCompression 0\\n -transparencyAlgorithm \\\"frontAndBackCull\\\" \\n -transpInShadows 0\\n -cullingOverride \\\"none\\\" \\n -lowQualityLighting 0\\n -maximumNumHardwareLights 1\\n -occlusionCulling 0\\n -shadingModel 0\\n -useBaseRenderer 0\\n -useReducedRenderer 0\\n -smallObjectCulling 0\\n -smallObjectThreshold -1 \\n -interactiveDisableShadows 0\\n -interactiveBackFaceCull 0\\n -sortTransparent 1\\n -nurbsCurves 1\\n -nurbsSurfaces 1\\n -polymeshes 1\\n -subdivSurfaces 1\\n -planes 1\\n -lights 1\\n -cameras 1\\n -controlVertices 1\\n -hulls 1\\n -grid 1\\n -joints 1\\n -ikHandles 1\\n -deformers 1\\n -dynamics 1\\n -fluids 1\\n -hairSystems 1\\n -follicles 1\\n -nCloths 1\\n -nParticles 1\\n -nRigids 1\\n -dynamicConstraints 1\\n -locators 1\\n -manipulators 1\\n -dimensions 1\\n -handles 1\\n -pivots 1\\n -textures 1\\n -strokes 1\\n -shadows 0\\n $editorName;\\nmodelEditor -e -viewSelected 0 $editorName\"\n" - + "\t\t\t\t$configName;\n\n setNamedPanelLayout (localizedPanelLabel(\"Current Layout\"));\n }\n\n panelHistory -e -clear mainPanelHistory;\n setFocus `paneLayout -q -p1 $gMainPane`;\n sceneUIReplacement -deleteRemaining;\n sceneUIReplacement -clear;\n\t}\n\n\ngrid -spacing 5 -size 12 -divisions 5 -displayAxes yes -displayGridLines yes -displayDivisionLines yes -displayPerspectiveLabels no -displayOrthographicLabels no -displayAxesBold yes -perspectiveLabelPosition axis -orthographicLabelPosition edge;\nviewManip -drawCompass 0 -compassAngle 0 -frontParameters \"\" -homeParameters \"\" -selectionLockParameters \"\";\n}\n"); - setAttr ".st" 3; -createNode script -n "sceneConfigurationScriptNode"; - setAttr ".b" -type "string" "playbackOptions -min 1 -max 24 -ast 1 -aet 48 "; - setAttr ".st" 6; -createNode polyMapCut -n "polyMapCut1"; - setAttr ".uopa" yes; - setAttr ".ics" -type "componentList" 1 "e[0:4]"; -select -ne :time1; - setAttr ".o" 1; -select -ne :renderPartition; - setAttr -s 2 ".st"; -select -ne :renderGlobalsList1; -select -ne :defaultShaderList1; - setAttr -s 2 ".s"; -select -ne :postProcessList1; - setAttr -s 2 ".p"; -select -ne :lightList1; -select -ne :initialShadingGroup; - setAttr ".ro" yes; -select -ne :initialParticleSE; - setAttr ".ro" yes; -select -ne :hardwareRenderGlobals; - setAttr ".ctrs" 256; - setAttr ".btrs" 512; -select -ne :defaultHardwareRenderGlobals; - setAttr ".fn" -type "string" "im"; - setAttr ".res" -type "string" "ntsc_4d 646 485 1.333"; -connectAttr "polyMapCut1.out" "pPlaneShape1.i"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[0].llnk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[0].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.lnk[1].llnk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.lnk[1].olnk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[0].sllk"; -connectAttr ":initialShadingGroup.msg" "lightLinker1.slnk[0].solk"; -connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[1].sllk"; -connectAttr ":initialParticleSE.msg" "lightLinker1.slnk[1].solk"; -connectAttr "layerManager.dli[0]" "defaultLayer.id"; -connectAttr "renderLayerManager.rlmi[0]" "defaultRenderLayer.rlid"; -connectAttr "polyPlane1.out" "polyTriangulate1.ip"; -connectAttr "polyTriangulate1.out" "polyMapCut1.ip"; -connectAttr "lightLinker1.msg" ":lightList1.ln" -na; -connectAttr "pPlaneShape1.iog" ":initialShadingGroup.dsm" -na; -// End of twoTrianglesWithSplitUVs.ma diff --git a/test/IECoreNuke/All.py b/test/IECoreNuke/All.py deleted file mode 100644 index e5a564c734..0000000000 --- a/test/IECoreNuke/All.py +++ /dev/null @@ -1,64 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import IECore -import sys - -sys.path.append( "test/IECoreNuke" ) - -from KnobAccessorsTest import * -from FnAxisTest import * -from LensDistortTest import * -from StringUtilTest import * -from KnobConvertersTest import * -from ParameterisedHolderTest import ParameterisedHolderTest -from ObjectKnobTest import ObjectKnobTest -from OpHolderTest import OpHolderTest -from SceneCacheReaderTest import SceneCacheReaderTest -from PNGReaderTest import PNGReaderTest -from LiveSceneKnobTest import LiveSceneKnobTest -from SceneCacheWriterTest import SceneCacheWriterTest - -unittest.TestProgram( - testRunner = unittest.TextTestRunner( - stream = IECore.CompoundStream( - [ - sys.stderr, - open( "test/IECoreNuke/resultsPython.txt", "w" ) - ] - ), - verbosity = 2 - ) -) diff --git a/test/IECoreNuke/FnAxisTest.py b/test/IECoreNuke/FnAxisTest.py deleted file mode 100644 index 72af0df8a7..0000000000 --- a/test/IECoreNuke/FnAxisTest.py +++ /dev/null @@ -1,57 +0,0 @@ -########################################################################## -# -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import IECoreNuke -import imath -import IECore -import nuke - -class FnAxisTest( IECoreNuke.TestCase ) : - - def test( self ) : - - n = nuke.nodes.Axis() - - f = IECoreNuke.FnAxis( n ) - self.assertEqual( f.getLocalMatrix(), imath.M44f() ) - - IECoreNuke.setKnobValue( n.knob( "translate" ), imath.V3f( 1, 2, 3 ) ) - self.assertEqual( f.getLocalMatrix(), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) - - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/KnobAccessorsTest.py b/test/IECoreNuke/KnobAccessorsTest.py deleted file mode 100644 index 8a511d799c..0000000000 --- a/test/IECoreNuke/KnobAccessorsTest.py +++ /dev/null @@ -1,54 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import IECoreNuke -import imath -import IECore -import nuke - -class KnobAccessorsTest( IECoreNuke.TestCase ) : - - def test( self ) : - - n = nuke.nodes.RadialDistort() - k = n.knob( "scale" ) - - self.assertEqual( IECoreNuke.getKnobValue( k ), imath.V3f( 1 ) ) - self.assertEqual( IECoreNuke.getKnobValue( k, resultType=imath.V3d ), imath.V3d( 1 ) ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/KnobConvertersTest.py b/test/IECoreNuke/KnobConvertersTest.py deleted file mode 100644 index a42d4497b7..0000000000 --- a/test/IECoreNuke/KnobConvertersTest.py +++ /dev/null @@ -1,235 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import IECoreNuke -import imath -import IECore -import nuke - -class KnobConvertersTest( IECoreNuke.TestCase ) : - - @staticmethod - def __parameters() : - - return IECore.CompoundParameter( - name = "", description = "", - members = [ - IECore.IntParameter( - name = "A", description = "", - defaultValue = 1 - ), - IECore.CompoundParameter( - name = "B", description = "", - members = [ - - IECore.DoubleParameter( - name = "C", description = "", - defaultValue = 2 - ), - - IECore.FloatParameter( - name = "D", description = "", - defaultValue = 3 - ), - - ] - ), - - IECore.StringParameter( - name = "E", description = "", - defaultValue = "4" - ), - - IECore.CompoundParameter( - name = "F", description = "", - members = [ - - IECore.FloatVectorParameter( - name = "G", description = "", - defaultValue = IECore.FloatVectorData( [ 5,6,7 ] ) - ), - - IECore.IntVectorParameter( - name = "H", description = "", - defaultValue = IECore.IntVectorData( [ 8 ] ) - ), - - IECore.DoubleVectorParameter( - name = "I", description = "", - defaultValue = IECore.DoubleVectorData() - ), - - ] - ), - - IECore.StringVectorParameter( - name = "J", description = "", - defaultValue = IECore.StringVectorData( ["10", "11", "12"] ) - ), - - IECore.FileNameParameter( - name = "K", description = "", - defaultValue = "/tmp/test.dpx", - ), - - IECore.DirNameParameter( - name = "L", description = "", - defaultValue = "/tmp" - ), - - IECore.FileSequenceParameter( - name = "M", description = "", - defaultValue = "/tmp/test.####.dpx", - ), - - IECore.BoolParameter( - name = "N", description = "", - defaultValue = True - ), - - IECore.TransformationMatrixfParameter( - name = "O", description = "", - defaultValue = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f(1), imath.Eulerf(), imath.V3f(1) ) ), - presets = ( - ( "preset0", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(1))) ), - ( "preset1", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(2))) ), - ( "preset2", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(3))) ), - ( "preset3", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(4))) ), - ), - presetsOnly = True - ) - - ] - ) - - # this class simulates a knob holder, such as nukescripts.PythonPanel or a nuke.Node - class KnobHolder : - - def __init__( self ) : - self.__knobs = {} - - def knobs( self ) : - return self.__knobs - - def addKnob( self, knob ): - self.__knobs[ knob.name() ] = knob - - def testKnobCreation( self ) : - knobHolder = KnobConvertersTest.KnobHolder() - IECoreNuke.createKnobsFromParameter( knobHolder, KnobConvertersTest.__parameters() ) - knobs = knobHolder.knobs() - self.assertEqual( knobs["parm_A"].getValue(), 1 ) - self.assertEqual( knobs["parm_B_C"].getValue(), 2.0 ) - self.assertEqual( knobs["parm_B_D"].getValue(), 3.0 ) - self.assertEqual( knobs["parm_E"].getText(), "4" ) - self.assertEqual( knobs["parm_F_G"].getText(), "5.0 6.0 7.0" ) - self.assertEqual( knobs["parm_F_H"].getText(), "8" ) - self.assertEqual( knobs["parm_F_I"].getText(), "" ) - self.assertEqual( knobs["parm_J"].getText(), "10\n11\n12" ) - self.assertEqual( knobs["parm_K"].getText(), "/tmp/test.dpx" ) - self.assertEqual( knobs["parm_L"].getText(), "/tmp" ) - self.assertEqual( knobs["parm_M"].getText(), "/tmp/test.%04d.dpx" ) - self.assertEqual( knobs["parm_N"].getValue(), True ) - self.assertEqual( knobs["parm_O"].value(), "preset0" ) - - def testSettingKnobValues( self ) : - - params = KnobConvertersTest.__parameters() - knobHolder = KnobConvertersTest.KnobHolder() - IECoreNuke.createKnobsFromParameter( knobHolder, params ) - # modify parameters - params[ 'A' ] = 2 - params[ 'F' ][ 'G' ] = IECore.FloatVectorData() - params[ 'F' ][ 'I' ] = IECore.DoubleVectorData( [ 9 ] ) - params[ 'M' ] = "/tmp/anotherTest.%d.dpx" - params[ 'N' ] = False - params[ 'O' ] = IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(3))) - IECoreNuke.setKnobsFromParameter( knobHolder, params ) - knobs = knobHolder.knobs() - self.assertEqual( knobs["parm_A"].getValue(), 2 ) - self.assertEqual( knobs["parm_F_G"].getText(), "" ) - self.assertEqual( knobs["parm_F_I"].getText(), "9.0" ) - self.assertEqual( knobs["parm_M"].getText(), "/tmp/anotherTest.%d.dpx" ) - self.assertEqual( knobs["parm_N"].getValue(), False ) - self.assertEqual( knobs["parm_O"].value(), "preset2" ) - - def testGettingKnobValues( self ) : - - params = KnobConvertersTest.__parameters() - knobHolder = KnobConvertersTest.KnobHolder() - IECoreNuke.createKnobsFromParameter( knobHolder, params ) - knobs = knobHolder.knobs() - IECoreNuke.setParameterFromKnobs( knobHolder, params ) - self.assertEqual( params["A"].getNumericValue(), 1 ) - self.assertEqual( params["B"]["C"].getNumericValue(), 2.0 ) - self.assertEqual( params["B"]["D"].getNumericValue(), 3.0 ) - - knobs["parm_A"].setValue( 10 ) - knobs["parm_B_C"].setValue( 20.0 ) - knobs["parm_B_D"].setValue( 30.0 ) - knobs["parm_E"].setValue( "40" ) - knobs["parm_F_G"].setValue( "50 60 70" ) - knobs["parm_F_H"].setValue( "80" ) - knobs["parm_F_I"].setValue( "90" ) - knobs["parm_J"].setValue( "100\n110\n120" ) - knobs["parm_K"].setValue( "/tmp2/test.dpx" ) - knobs["parm_L"].setValue( "/tmp2" ) - knobs["parm_M"].setValue( "/tmp2/test.%02d.dpx" ) - knobs["parm_N"].setValue( False ) - knobs["parm_O"].setValue( "preset3" ) - IECoreNuke.setParameterFromKnobs( knobHolder, params ) - - self.assertEqual( params["A"].getNumericValue(), 10 ) - self.assertEqual( params["B"]["C"].getNumericValue(), 20.0 ) - self.assertEqual( params["B"]["D"].getNumericValue(), 30.0 ) - self.assertEqual( params["E"].getTypedValue(), "40" ) - self.assertEqual( params["F"]["G"].getValue(), IECore.FloatVectorData( [ 50,60,70 ] ) ) - self.assertEqual( params["F"]["H"].getValue(), IECore.IntVectorData( [ 80 ] ) ) - self.assertEqual( params["F"]["I"].getValue(), IECore.DoubleVectorData( [ 90 ] ) ) - self.assertEqual( params["J"].getValue(), IECore.StringVectorData( [ "100", "110", "120" ] ) ) - self.assertEqual( params["K"].getTypedValue(), "/tmp2/test.dpx" ) - self.assertEqual( params["L"].getTypedValue(), "/tmp2" ) - self.assertEqual( params["M"].getTypedValue(), "/tmp2/test.##.dpx" ) - self.assertEqual( params["N"].getTypedValue(), False ) - self.assertEqual( params["O"].getValue(), IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(4))) ) - # raises exception when trying to convert an invalid file sequence syntax - knobs["parm_M"].setValue( "/tmp2/test.%2d.dpx" ) - self.assertRaises( RuntimeError, IECoreNuke.setParameterFromKnobs, knobHolder, params ) - - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/LensDistortTest.py b/test/IECoreNuke/LensDistortTest.py deleted file mode 100644 index 97362cc893..0000000000 --- a/test/IECoreNuke/LensDistortTest.py +++ /dev/null @@ -1,191 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import math -import unittest - -import nuke -import imath - -import IECore -import IECoreImage -import IECoreNuke - -class LensDisortTest( IECoreNuke.TestCase ) : - - def __outputPath( self ) : - return "test/IECoreNuke/nukeLensDistortOutput.exr" - - def __paths( self ) : - paths = { - 'path' : "test/IECoreNuke/nukeLensDistortInput.exr", - 'croppedPath' : "test/IECoreNuke/nukeLensDistortInputCropped.exr", - 'croppedOffsetPath' : "test/IECoreNuke/nukeLensDistortInputCroppedOffset.exr", - 'offsetPath' : "test/IECoreNuke/nukeLensDistortInputOffset.exr" - } - return paths - - def setUp( self ) : - - paths = self.__paths() - for p in paths.keys() : - if os.path.exists( p ) : - os.remove( p ) - - # Set the default format to be something fun. - nuke.root()["format"].fromScript("1144 862 0 0 1144 862 2 CortexTestAlexaProxyAnamorphic(2.66)") - - # Create a colourful test image that we will distort. - n1 = nuke.createNode("ColorWheel") - n2 = nuke.createNode("ColorBars") - n3 = nuke.createNode("CheckerBoard2") - m1 = nuke.createNode("Merge2") - m2 = nuke.createNode("Merge2") - m1.setInput( 0, n1 ) - m1.setInput( 1, n2 ) - m2.setInput( 0, m1 ) - m2.setInput( 1, n3 ) - m2["operation"].setValue(1) - - # Create a write node so that we can save the image to disk. - w = nuke.createNode("Write") - w.setInput( 0, m2 ) - w["file"].setText( paths['path'] ) - - # Crop the image and generate another test image. - c = nuke.createNode("Crop") - c["box"].setValue( ( 29, -74, 374, 448 ) ) - c.setInput( 0, m2 ) - - w2 = nuke.createNode("Write") - w2.setInput( 0, c ) - w2["file"].setText( paths['croppedPath'] ) - - # Create the test files. - nuke.execute( w, 1, 1 ) - nuke.execute( w2, 1, 1 ) - - # Finally, read back the images and offset their display windows to make the - # tests even more interesting... - offsetImg = IECore.Reader.create( paths['path'] ).read() - offsetDisplayWindow = imath.Box2i( offsetImg.displayWindow.min() + imath.V2i( -261, 172 ), offsetImg.displayWindow.max() + imath.V2i( -261, 172 ) ) - offsetImg.displayWindow = offsetDisplayWindow - IECore.Writer.create( offsetImg, paths['offsetPath'] ).write() - - croppedOffsetImg = IECore.Reader.create( paths['croppedPath'] ).read() - offsetDisplayWindow = imath.Box2i( croppedOffsetImg.displayWindow.min() + imath.V2i( 120, -100 ), croppedOffsetImg.displayWindow.max() + imath.V2i( 120, -100 ) ) - croppedOffsetImg.displayWindow = offsetDisplayWindow - IECore.Writer.create( croppedOffsetImg, paths['croppedOffsetPath'] ).write() - - def __testLens( self ) : - # Create a nice asymetric lens distortion. - o = IECore.Reader.create("test/IECoreImage/data/lens/StandardRadialLens.cob").read() - return o - - def testLensDistortAgainstLensDistortOp( self ) : - """Test that the output of the Cortex LensDistortOp and the LensDistort node are the same.\n""" - - paths = self.__paths() - for p in paths.keys() : - self.assertTrue( os.path.exists( paths[p] ) ) - - outputPath = self.__outputPath() - if os.path.exists( outputPath ) : - os.remove( outputPath ) - - # Set the default format to be something fun. - nuke.root()["format"].fromScript("1144 862 0 0 1144 862 2 CortexTestAlexaProxyAnamorphic(2.66)") - - r = nuke.createNode("Read") - - # Create a LensDistort node. - l = nuke.createNode("ieLensDistort") - l["mode"].setValue( IECore.LensModel.Undistort ) - l.setInput( 0, r ) - - # Set the parameters of the lens distort node. - l['lensFileSequence'].fromScript( os.path.abspath( "test/IECoreImage/data/lens/StandardRadialLens.cob" ) ) - - # Create a write node. - w = nuke.createNode("Write") - w.setInput( 0, l ) - w["file"].setText( outputPath ) - - # Create the op that we will compare the result of the nuke LensDistort node with. - lensDistortOp = IECoreImage.LensDistortOp() - lensDistortOp["mode"].setValue( IECore.LensModel.Undistort ) - lensDistortOp['lensModel'].setValue( self.__testLens() ) - - for path in paths.keys() : - # Update the read node. - r["file"].setText( paths[path] ) - - if path == 'path' : - # When the format is the same as the data window, nuke doesn't create a black border around the image. - # As a result, we shouldn't create one using our LensDistortOp either. - lensDistortOp["boundMode"].setValue( IECoreImage.WarpOp.BoundMode.Clamp ) - else : - lensDistortOp["boundMode"].setValue( IECoreImage.WarpOp.BoundMode.SetToBlack ) - - # Write out the result of the LensDistort so that we can compare it to the output of the cortex op. - nuke.execute( w, 1, 1 ) - - img = IECore.Reader.create( paths[path] ).read() - lensDistortOp["input"].setValue( img ) - - cortexImg = lensDistortOp() - nukeImg = IECore.Reader.create( outputPath ).read() - - # Assert that the two images are almost identical. - # We expect a little bit of error as the cortex op uses a different sampling filter to the nuke node. - imageDiffOp = IECoreImage.ImageDiffOp() - imageDiffOp["alignDisplayWindows"].setValue( True ) - res = imageDiffOp( - imageA = cortexImg, - imageB = nukeImg, - ) - self.assertFalse( res.value ) - - def tearDown( self ) : - paths = self.__paths() - paths['output'] = self.__outputPath() - - for p in paths.keys() : - if os.path.exists( paths[p] ) : - os.remove( paths[p] ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/LiveSceneKnobTest.py b/test/IECoreNuke/LiveSceneKnobTest.py deleted file mode 100644 index 581484643d..0000000000 --- a/test/IECoreNuke/LiveSceneKnobTest.py +++ /dev/null @@ -1,383 +0,0 @@ -########################################################################## -# -# Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import nuke - -import IECore -import IECoreNuke - -class LiveSceneKnobTest( IECoreNuke.TestCase ) : - - def testNameAndLabel( self ) : - - n = nuke.createNode( "ieLiveScene" ) - - k = n.knob( "scene" ) - - self.assertEqual( k.name(), "scene" ) - self.assertEqual( k.label(), "Scene" ) - - def testEmptyScene( self ) : - import imath - - n = nuke.createNode( "ieLiveScene" ) - liveScene = n.knob( "scene" ).getValue() - - self.assertEqual( liveScene.childNames(), [] ) - self.assertEqual( liveScene.readTransform( 0 ).value.transform, imath.M44d() ) - self.assertEqual( liveScene.readBound( 0 ), imath.Box3d() ) - self.assertTrue( isinstance( liveScene.readObject( 0 ), IECore.NullObject ) ) - - def testAccessors( self ) : - - n = nuke.createNode( "ieLiveScene" ) - - k = n.knob( "scene" ) - - self.assertTrue( isinstance( k, IECoreNuke.LiveSceneKnob ) ) - - self.assertTrue( isinstance( k.getValue(), IECoreNuke.LiveScene ) ) - - def testQueryScene( self ) : - - sph = nuke.createNode( "Sphere" ) - cub = nuke.createNode( "Cube" ) - sn = nuke.createNode( "Scene") - sn.setInput( 0, sph ) - sn.setInput( 1, cub ) - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sn ) - - k = n.knob( "scene" ) - - self.assertTrue( isinstance( k, IECoreNuke.LiveSceneKnob ) ) - - self.assertTrue( isinstance( k.getValue(), IECoreNuke.LiveScene ) ) - - def testNameAndPath( self ): - import IECoreScene - sph = nuke.createNode( "Sphere" ) - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sph ) - - liveScene = n.knob( "scene" ).getValue() - - self.assertEqual( liveScene.name(), "/" ) - self.assertEqual( liveScene.path(), [] ) - - sceneFile = "test/IECoreNuke/scripts/animatedSpheres.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - n.setInput( 0, sceneReader ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - self.assertEqual( liveScene.name(), expectedScene.name() ) - self.assertEqual( liveScene.path(), expectedScene.path() ) - - sceneA = liveScene.scene( ["A"] ) - expectedSceneA = expectedScene.scene( ["A"] ) - - self.assertEqual( sceneA.name(), expectedSceneA.name() ) - self.assertEqual( sceneA.path(), expectedSceneA.path() ) - - sceneBb = liveScene.scene( ["B", "b"] ) - expectedSceneBb = expectedScene.scene( ["B", "b"] ) - - self.assertEqual( sceneBb.name(), expectedSceneBb.name() ) - self.assertEqual( sceneBb.path(), expectedSceneBb.path() ) - - def testChildNames( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - - self.assertEqual( sorted( liveScene.childNames() ) , sorted( expectedScene.childNames() ) ) - - self.assertTrue( liveScene.hasChild( "B" ) ) - self.assertFalse( liveScene.hasChild( "wrongChild" ) ) - - self.assertRaises( RuntimeError, liveScene.child, "wrongChild" ) - self.assertFalse( liveScene.child( "wrongChild", IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ) ) - self.assertRaises( RuntimeError, liveScene.child, "wrongChild", IECoreScene.SceneInterface.MissingBehaviour.CreateIfMissing ) - - for subPath in ( ["B"], ["A"] ): - subScene = liveScene.scene( subPath ) - subExpectedScene = expectedScene.scene( subPath ) - - self.assertEqual( subScene.childNames(), subExpectedScene.childNames() ) - - self.assertRaises( RuntimeError, liveScene.scene, ["B", "wrongChild"] ) - self.assertFalse( liveScene.scene( ["B", "wrongChild"], IECoreScene.SceneInterface.MissingBehaviour.NullIfMissing ) ) - self.assertRaises( RuntimeError, liveScene.scene, ["B", "wrongChild"], IECoreScene.SceneInterface.MissingBehaviour.CreateIfMissing ) - - def assertAlmostEqualBound( self, box1, box2 ): - for dim in range( 3 ): - self.assertAlmostEqual( box1.size()[dim], box2.size()[dim], 4 ) - - def testBounds( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - for time in (0, 1, 2, 3): - liveSceneBound = liveScene.readBound( time ) - expectedSceneBound = expectedScene.readBound( time ) - self.assertAlmostEqualBound( liveSceneBound, expectedSceneBound ) - - for subPath in ( ["B"], ["A"] ): - subScene = liveScene.scene( subPath ) - subExpectedScene = expectedScene.scene( subPath ) - - self.assertEqual( subScene.readBound(0), subExpectedScene.readBound(0) ) - - def testDuplicatedParent( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/duplicateParent.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/groupA/cube','/root/groupA/sphere', '/root/groupB/sphere'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - self.assertEqual( set( liveScene.childNames() ), set( expectedScene.childNames() ) ) - - def testFilterDifferentParent( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/duplicateParent.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/groupA/cube','/root/groupA/sphere', '/root/groupB/sphere'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - - for subPath in ( ["groupA"], ["groupB"] ): - subScene = liveScene.scene( subPath ) - subExpectedScene = expectedScene.scene( subPath ) - - self.assertCountEqual( subScene.childNames(), subExpectedScene.childNames() ) - - def testAnimatedBounds( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/animatedTransform.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/group/cube'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - for time in (0, 1, 2): - liveSceneBound = liveScene.readBound( time ) - expectedSceneBound = expectedScene.readBound( time ) - self.assertAlmostEqualBound( liveSceneBound, expectedSceneBound ) - - for subPath in ( ["group"], ["group", "cube"] ): - subScene = liveScene.scene( subPath ) - subExpectedScene = expectedScene.scene( subPath ) - - self.assertEqual( subScene.readBound(0), subExpectedScene.readBound(0) ) - - def assertAlmostEqualTransform( self, tran1, tran2 ): - for x in range( 4 ): - for y in range( 4 ): - self.assertAlmostEqual( tran1[x][y], tran2[x][y], 4 ) - - def _checkNukeSceneTransform( self, liveScene, expectedScene, matrix, time ): - import imath - # combine the matrix of each parent as the SceneCacheReader does - matrix = expectedScene.readTransform( time ).value * matrix - if liveScene.childNames(): - # each parent location have an identity matrix - self.assertEqual( liveScene.readTransform( time ).value.transform, imath.M44d() ) - for childName in liveScene.childNames(): - self._checkNukeSceneTransform( liveScene.child( childName ), expectedScene.child( childName ), matrix, time ) - else: - # check the leaf matrix is the same as the combined parents' matrix - self.assertAlmostEqualTransform( liveScene.readTransform( time ).value.transform, matrix ) - - def testTransform( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - for time in (0, 1, 2, 3): - liveSceneTransform = liveScene.readTransform( time ) - expectedSceneTransform = expectedScene.readTransform( time ) - self.assertEqual( liveSceneTransform.value.transform, expectedSceneTransform.value ) - - # check the leaf has the world matrix - for childName in liveScene.childNames(): - # root transform - matrix = expectedScene.readTransform( 0 ).value - self._checkNukeSceneTransform( liveScene.child( childName ), expectedScene.child( childName ), matrix, 0 ) - - def testAnimatedTransform( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/animatedTransform.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/group/cube'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - for time in (0, 1, 2): - liveSceneTransform = liveScene.readTransform( time ) - expectedSceneTransform = expectedScene.readTransform( time ) - self.assertEqual( liveSceneTransform.value.transform, expectedSceneTransform.value ) - - # check the leaf has the world matrix - for childName in liveScene.childNames(): - # root transform - matrix = expectedScene.readTransform( 0 ).value - self._checkNukeSceneTransform( liveScene.child( childName ), expectedScene.child( childName ), matrix, 0 ) - - def testHasObject( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - self.assertFalse( liveScene.hasObject() ) - - for subPath in ( ["A"], ["B"] ): - self.assertFalse( liveScene.scene( subPath ).hasObject() ) - - for subPath in ( ["A", "a"], ["B", "b"] ): - self.assertTrue( liveScene.scene( subPath ).hasObject() ) - - def testReadObjet( self ): - import IECoreScene - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - n = nuke.createNode( "ieLiveScene" ) - n.setInput( 0, sceneReader ) - - liveScene = n.knob( "scene" ).getValue() - objectA = liveScene.scene( [ "A", "a" ] ).readObject( 0 ) - expectedObjectA = expectedScene.scene( [ "A", "a" ] ).readObject( 0 ) - - self.assertEqual( objectA.topologyHash(), expectedObjectA.topologyHash() ) - self.assertEqual( objectA.keys(), [ "P", "uv" ] ) - - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/ObjectKnobTest.py b/test/IECoreNuke/ObjectKnobTest.py deleted file mode 100644 index baf671fbc8..0000000000 --- a/test/IECoreNuke/ObjectKnobTest.py +++ /dev/null @@ -1,180 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import unittest -import os -import weakref - -import nuke - -import IECore -import IECoreNuke - -class ObjectKnobTest( IECoreNuke.TestCase ) : - - def testNameAndLabel( self ) : - - n = nuke.createNode( "ieObject" ) - - k = n.knob( "object" ) - - self.assertEqual( k.name(), "object" ) - self.assertEqual( k.label(), "Object" ) - - def testAccessors( self ) : - - n = nuke.createNode( "ieObject" ) - - k = n.knob( "object" ) - - self.assertTrue( isinstance( k, IECoreNuke.ObjectKnob ) ) - - self.assertEqual( k.getValue(), None ) - - i = IECore.IntData( 10 ) - k.setValue( i ) - self.assertFalse( k.getValue().isSame( i ) ) - - self.assertEqual( k.getValue(), IECore.IntData( 10 ) ) - i.value = 20 - self.assertEqual( k.getValue(), IECore.IntData( 10 ) ) - - @unittest.skip("Foundry explained that Knob memory clean up is not a bug but a feature when calling scriptClear") - def testLifetime( self ) : - - n = nuke.createNode( "ieObject" ) - - k = n.knob( "object" ) - - nuke.scriptClear() - - self.assertRaises( RuntimeError, k.name ) - self.assertRaises( RuntimeError, k.label ) - self.assertRaises( RuntimeError, k.setValue, None ) - self.assertRaises( RuntimeError, k.getValue ) - - w = weakref.ref( k ) - self.assertFalse( w() is None ) - - del k - - self.assertFalse( w() is not None ) - - def testSetValueReturn( self ) : - - n = nuke.createNode( "ieObject" ) - - k = n.knob( "object" ) - - self.assertEqual( k.setValue( None ), False ) - self.assertEqual( k.setValue( IECore.IntData( 1 ) ), True ) - self.assertEqual( k.setValue( IECore.IntData( 1 ) ), False ) - self.assertEqual( k.setValue( IECore.IntData( 10 ) ), True ) - self.assertEqual( k.setValue( None ), True ) - - def testCopyPaste( self ) : - - n = nuke.createNode( "ieObject" ) - self.assertEqual( nuke.selectedNodes(), [ n ] ) - - n.knob( "object" ).setValue( IECore.IntData( 10 ) ) - - nuke.nodeCopy( "test/IECoreNuke/objectKnob.nk" ) - - nuke.scriptClear() - - n2 = nuke.nodePaste( "test/IECoreNuke/objectKnob.nk" ) - self.assertEqual( n2.knob( "object" ).getValue(), IECore.IntData( 10 ) ) - - def testCopyPasteNoValue( self ) : - - n = nuke.createNode( "ieObject" ) - self.assertEqual( nuke.selectedNodes(), [ n ] ) - - nuke.nodeCopy( "test/IECoreNuke/objectKnob.nk" ) - - nuke.scriptClear() - - n2 = nuke.nodePaste( "test/IECoreNuke/objectKnob.nk" ) - self.assertEqual( n2.knob( "object" ).getValue(), None ) - - def testUndo( self ) : - - # check our custom knob undoes in the same way as - # standard knobs - - n = nuke.createNode( "ieObject" ) - n2 = nuke.createNode( "Blur" ) - - self.assertEqual( n.knob( "object" ).getValue(), None ) - self.assertEqual( n2.knob( "size" ).getValue(), 0 ) - - self.assertEqual( nuke.Undo.disabled(), True ) - - with IECoreNuke.UndoEnabled() : - - self.assertEqual( nuke.Undo.disabled(), False ) - - with IECoreNuke.UndoBlock() : - - n.knob( "object" ).setValue( IECore.IntData( 10 ) ) - self.assertEqual( n.knob( "object" ).getValue(), IECore.IntData( 10 ) ) - - n2.knob( "size" ).setValue( 10 ) - self.assertEqual( n2.knob( "size" ).getValue(), 10 ) - - self.assertEqual( nuke.Undo.disabled(), True ) - - self.assertEqual( n.knob( "object" ).getValue(), IECore.IntData( 10 ) ) - self.assertEqual( n2.knob( "size" ).getValue(), 10 ) - - nuke.undo() - - self.assertEqual( n2.knob( "size" ).getValue(), 0 ) - self.assertEqual( n.knob( "object" ).getValue(), None ) - - def tearDown( self ) : - - for f in [ - "test/IECoreNuke/objectKnob.nk", - ] : - - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/OpHolderTest.py b/test/IECoreNuke/OpHolderTest.py deleted file mode 100644 index b062d947c0..0000000000 --- a/test/IECoreNuke/OpHolderTest.py +++ /dev/null @@ -1,140 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import os - -import nuke - -import IECore -import IECoreScene -import IECoreImage -import IECoreNuke - -class OpHolderTest( IECoreNuke.TestCase ) : - - def testExecute( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "maths/multiply", 2 ) - - with fnOH.parameterModificationContext() as parameters : - - parameters["a"].setNumericValue( 10 ) - parameters["b"].setNumericValue( 20 ) - - fnOH.getOp() - - result = fnOH.execute() - self.assertEqual( result, IECore.IntData( 200 ) ) - - def testExecuteWithMeshInputs( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "meshMerge", 1 ) - - self.assertEqual( fnOH.node().minimumInputs(), 2 ) - self.assertEqual( fnOH.node().maximumInputs(), 2 ) - - card1 = nuke.nodes.Card() - card2 = nuke.nodes.Card() - - fnOH.node().setInput( 0, card1 ) - fnOH.node().setInput( 1, card2 ) - - merged = fnOH.execute() - - self.assertTrue( isinstance( merged, IECoreScene.MeshPrimitive ) ) - self.assertEqual( merged.numFaces(), 2 ) - self.assertEqual( merged.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 8 ) - - def testExecuteWithObjectVectorInput( self ) : - - fnOHMult1 = IECoreNuke.FnOpHolder.create( "mult1", "maths/multiply", 2 ) - with fnOHMult1.parameterModificationContext() as parameters : - parameters["a"].setNumericValue( 10 ) - parameters["b"].setNumericValue( 20 ) - - fnOHMult2 = IECoreNuke.FnOpHolder.create( "mult2", "maths/multiply", 2 ) - with fnOHMult2.parameterModificationContext() as parameters : - parameters["a"].setNumericValue( 12 ) - parameters["b"].setNumericValue( 10 ) - - fnOH = IECoreNuke.FnOpHolder.create( "merge", "objectVectorInOut", 1 ) - - self.assertEqual( fnOH.node().minimumInputs(), 0 ) - self.assertEqual( fnOH.node().maximumInputs(), 100 ) - - fnOH.node().setInput( 0, fnOHMult1.node() ) - fnOH.node().setInput( 1, fnOHMult2.node() ) - fnOH.node().setInput( 2, fnOHMult1.node() ) - fnOH.node().setInput( 3, fnOHMult2.node() ) - - self.assertEqual( fnOH.execute(), IECore.ObjectVector( [ IECore.IntData( 200 ), IECore.IntData( 120 ), IECore.IntData( 200 ), IECore.IntData( 120 ) ] ) ) - - def testExecuteWithImageInput( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "imagePrimitiveInOut", 1 ) - - self.assertEqual( fnOH.node().minimumInputs(), 1 ) - self.assertEqual( fnOH.node().maximumInputs(), 1 ) - - check = nuke.nodes.CheckerBoard() - - fnOH.node().setInput( 0, check ) - - # get the image as output by the op - image = fnOH.execute() - - # write the same image direct to disk without using the op - write = nuke.nodes.Write() - write.setInput( 0, check ) - write.knob( "file" ).setValue( "test/IECoreNuke/check.exr" ) - write.knob( "channels" ).setValue( "rgba" ) - nuke.execute( write, 1, 1 ) - - # check that they are the same in terms of size and channel data. - # allow a slight difference due to one having been saved as half float and reloaded. - - image2 = IECore.Reader.create( "test/IECoreNuke/check.exr" ).read() - self.assertEqual( IECoreImage.ImageDiffOp()( imageA = image, imageB = image2, maxError = 0.001 ).value, False ) - - def tearDown( self ) : - - for f in [ - "test/IECoreNuke/check.exr" - ] : - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreNuke/PNGReaderTest.py b/test/IECoreNuke/PNGReaderTest.py deleted file mode 100644 index e544899f14..0000000000 --- a/test/IECoreNuke/PNGReaderTest.py +++ /dev/null @@ -1,55 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest - -import nuke - -import IECore -import IECoreImage -import IECoreNuke - -class PNGReaderTest( IECoreNuke.TestCase ) : - - def test( self ) : - - # this raises an exception if cortex has been built with a libpng - # which is incompatible with Nuke's libpng. - r = IECore.Reader.create( "test/IECoreImage/data/png/uvMap.512x256.png" ) - self.assertTrue( r.isComplete() ) - self.assertTrue( r.read().channelsValid() ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/ParameterisedHolderTest.py b/test/IECoreNuke/ParameterisedHolderTest.py deleted file mode 100644 index 38a0ba5b27..0000000000 --- a/test/IECoreNuke/ParameterisedHolderTest.py +++ /dev/null @@ -1,325 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -from __future__ import with_statement - -import unittest -import os - -import nuke -import imath - -import IECore -import IECoreScene -import IECoreNuke - -class ParameterisedHolderTest( IECoreNuke.TestCase ) : - - def __checkParameterKnobs( self, parameter, node, knobName=None, parameterPath=None, ignore=set() ) : - - if knobName is None : - knobName = "parm" - - if parameterPath in ignore : - return - - if isinstance( parameter, IECore.CompoundParameter ) : - for k in parameter.keys() : - childKnobName = knobName + "_" + parameter[k].name - if not parameterPath : - childParameterPath = k - else : - childParameterPath = parameterPath + "." + k - self.__checkParameterKnobs( parameter[k], node, childKnobName, childParameterPath, ignore ) - else : - - knob = node.knob( knobName ) - self.assertTrue( knob is not None ) - - if isinstance( knob, nuke.Enumeration_Knob ) : - self.assertEqual( knob.value(), parameter.getCurrentPresetName() ) - else : - - knobValue = None - try : - knobValue = IECoreNuke.getKnobValue( knob ) - if isinstance( parameter, IECore.V2dParameter ) : - # getKnobValue defaults to V2f - knobValue = imath.V2d( knobValue[0], knobValue[1] ) - elif isinstance( parameter, IECore.V3dParameter ) : - knobValue = imath.V3d( knobValue[0], knobValue[1], knobValue[2] ) - except : - # not all knob types have accessors yet. some of the numeric - # knobs don't have them because nuke has bugs and returns those - # knobs as the wrong type. try to get the value another way. - knobValue = knob.getValue() - - self.assertEqual( parameter.getValue().value, knobValue ) - - def testModifyParametersAndTransferToKnobs( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "mult", "maths/multiply", 2 ) - - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 1 ) - self.assertEqual( fnOH.node().knob( "parm_b" ).getValue(), 2 ) - - with fnOH.parameterModificationContext() as parameters : - - parameters["a"].setNumericValue( 10 ) - parameters["b"].setNumericValue( 20 ) - - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 10 ) - self.assertEqual( fnOH.node().knob( "parm_b" ).getValue(), 20 ) - - def testModifyParametersAndUndo( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "mult", "maths/multiply", 2 ) - - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 1 ) - self.assertEqual( fnOH.node().knob( "parm_b" ).getValue(), 2 ) - - with IECoreNuke.UndoEnabled() : - - with fnOH.parameterModificationContext() as parameters : - - parameters["a"].setNumericValue( 10 ) - parameters["b"].setNumericValue( 20 ) - - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 10 ) - self.assertEqual( fnOH.node().knob( "parm_b" ).getValue(), 20 ) - - nuke.undo() - - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 1 ) - self.assertEqual( fnOH.node().knob( "parm_b" ).getValue(), 2 ) - - def testClassParameterSetClass( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - parameterised["cp"].setClass( "maths/multiply", 2 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testClassParameterSetClassAndValues( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - parameterised["cp"].setClass( "maths/multiply", 2 ) - parameterised["cp"]["a"].setNumericValue( 10 ) - parameterised["cp"]["a"].setNumericValue( 20 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testClassParameterSetClassAndValues( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - parameterised["cp"].setClass( "maths/multiply", 2 ) - parameterised["cp"]["a"].setNumericValue( 10 ) - parameterised["cp"]["a"].setNumericValue( 20 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - nuke.nodeCopy( "test/IECoreNuke/parameterisedHolder.nk" ) - - nuke.scriptClear() - - n = nuke.nodePaste( "test/IECoreNuke/parameterisedHolder.nk" ) - - fnOH = IECoreNuke.FnOpHolder( n ) - - parameterised2 = fnOH.getParameterised()[0] - - self.assertEqual( parameterised.parameters().getValue(), parameterised2.parameters().getValue() ) - - def testNestedClassParameterSetClass( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - parameterised["cp"].setClass( "classParameterTest", 1 ) - parameterised["cp"]["cp"].setClass( "maths/multiply", 2 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testClassVectorParameter( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classVectorParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - cv = parameterised["cv"] - cv.setClasses( [ - ( "p0", "maths/multiply", 1 ), - ( "p1", "floatParameter", 1 ), - - ] ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testNestedClassVectorParameter( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classVectorParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - cv = parameterised["cv"] - cv.setClasses( [ - ( "p0", "classParameterTest", 1 ), - ] ) - - cp = parameterised["cv"]["p0"]["cp"] - cp.setClass( "maths/multiply", 2 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testMoreNestedClassVectorParameter( self ) : - - fnOH = IECoreNuke.FnOpHolder.create( "test", "classVectorParameterTest", 1 ) - - with fnOH.parameterModificationContext() as parameterised : - - cv = parameterised["cv"] - cv.setClasses( [ - ( "p0", "classVectorParameterTest", 1 ), - - ] ) - - cv2 = cv["p0"]["cv"] - - cv2.setClasses( [ - ( "p0", "classParameterTest", 1 ), - ] ) - - cp = cv2["p0"]["cp"] - cp.setClass( "maths/multiply", 2 ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node() ) - - self.assertEqual( parameterised.parameters().getValue(), fnOH.getParameterised()[0].parameters().getValue() ) - - def testParameterTypes( self ) : - - # the parameters for which we know we have no handler - unsupported = { "c", "e", "f", "compound.k", "m", "s", "u", "v", "x", "y", "p1", "p4" } - # the parameters for which we'll do our own testing because they are not straightforward to deal with in __checkParameterKnobs - notEasy = set ( ( "p2", "p3" ) ) - - mh = IECore.CapturingMessageHandler() - with mh : - fnOH = IECoreNuke.FnOpHolder.create( "test", "parameterTypes", 1 ) - - # make sure there's an error reported for each unsupported parameter - self.assertEqual( len( mh.messages ), len( unsupported ) ) - for n in unsupported : - found = False - t = "for parameter \"%s\"" % n.split( "." )[-1] - for m in mh.messages : - if t in m.message : - found = True - break - self.assertEqual( found, True ) - - self.__checkParameterKnobs( fnOH.getParameterised()[0].parameters(), fnOH.node(), ignore=unsupported | notEasy ) - - self.assertEqual( fnOH.node().knob( "parm_p2Start" ).getValue(), [ 1, 1, 1 ] ) - self.assertEqual( fnOH.node().knob( "parm_p2End" ).getValue(), [ 1, 1, 1 ] ) - - with fnOH.parameterModificationContext() as parameterised : - - parameterised.parameters()["d"].setTypedValue( "lalal" ) - parameterised.parameters()["p2"].setTypedValue( IECore.LineSegment3f( imath.V3f( 10, 11, 12 ), imath.V3f( 12, 10, 9 ) ) ) - - self.__checkParameterKnobs( parameterised.parameters(), fnOH.node(), ignore=unsupported | notEasy ) - self.__checkParameterKnobs( fnOH.getParameterised()[0].parameters(), fnOH.node(), ignore=unsupported | notEasy ) - - self.assertEqual( fnOH.node().knob( "parm_p2Start" ).getValue(), [ 10, 11, 12 ] ) - self.assertEqual( fnOH.node().knob( "parm_p2End" ).getValue(), [ 2, -1, -3 ] ) - - def testDefaultExpression( self ) : - - # create opholder and check the default expression we asked for works - - fnOH = IECoreNuke.FnOpHolder.create( "op", "add", 1 ) - self.assertEqual( fnOH.node().knob( "parm_a" ).toScript(), '{"frame * 2"}' ) - self.assertTrue( fnOH.node().knob( "parm_a" ).isAnimated() ) - - self.assertEqual( nuke.frame(), 1 ) - self.assertEqual( fnOH.node().knob( "parm_a" ).getValue(), 2 ) - - # remove the expression, cut and paste the node, and make sure - # it doesn't reappear - - fnOH.node().knob( "parm_a" ).clearAnimated() - self.assertFalse( fnOH.node().knob( "parm_a" ).isAnimated() ) - - nuke.nodeCopy( "test/IECoreNuke/parameterisedHolder.nk" ) - - nuke.scriptClear() - - n = nuke.nodePaste( "test/IECoreNuke/parameterisedHolder.nk" ) - - fnOH = IECoreNuke.FnOpHolder( n ) - self.assertEqual( fnOH.node().knob( "parm_a" ).toScript(), "2" ) - - def tearDown( self ) : - - for f in [ - "test/IECoreNuke/parameterisedHolder.nk", - ] : - - if os.path.exists( f ) : - os.remove( f ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/SceneCacheReaderTest.py b/test/IECoreNuke/SceneCacheReaderTest.py deleted file mode 100644 index 97b728d065..0000000000 --- a/test/IECoreNuke/SceneCacheReaderTest.py +++ /dev/null @@ -1,132 +0,0 @@ -########################################################################## -# -# Copyright (c) 2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import os -import glob -import unittest - -import nuke - -import IECore -import IECoreImage -import IECoreNuke - -class SceneCacheReaderTest( IECoreNuke.TestCase ) : - - def setUp( self ) : - nuke.scriptClear() - - def tearDown( self ) : - nuke.scriptClear() - for f in glob.glob( "test/IECoreNuke/scripts/data/sceneCacheTestResults*.exr" ) : - try: - os.remove(f) - except: - pass - - def testLoadedScriptWithRetime( self ) : - - nuke.scriptOpen("test/IECoreNuke/scripts/sceneCacheTest.nk" ) - w = nuke.toNode("Write1") - frames = [ 1, 10, 20, 30, 40, 50, 60, 70, 80 ] - nuke.executeMultiple( [ w ], [(f,f,1) for f in frames] ) - for f in frames : - imageA = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheExpectedResults.%04d.exr" % f )() - imageB = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheTestResults.%04d.exr" % f )() - self.assertEqual( IECoreImage.ImageDiffOp()( imageA = imageA, imageB = imageB, maxError = 0.05 ).value, False ) - - n = nuke.toNode("ieSceneCacheReader4") - v = n.knob('sceneView') - self.assertEqual( set(v.getSelectedItems()), set(['/root/A/a']) ) - - # now force loading A+B and test in frame 20 - v.setSelectedItems(['/root/A/a', '/root/B/b', '/root/bezier1', '/root/particle1']) - self.assertEqual( set(v.getSelectedItems()), set(['/root/A/a', '/root/B/b', '/root/bezier1', '/root/particle1' ]) ) - nuke.executeMultiple( [ w ], [(20,20,1)] ) - imageA = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheExpectedResultsB.0020.exr" )() - imageB = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheTestResults.0020.exr" )() - self.assertEqual( IECoreImage.ImageDiffOp()( imageA = imageA, imageB = imageB, maxError = 0.05 ).value, False ) - - def testUVMapping( self ): - - nuke.scriptOpen("test/IECoreNuke/scripts/sceneCacheTestUV.nk" ) - w = nuke.toNode("Write1") - frames = [ 1, 10, 20, 30, 40, 50 ] - nuke.executeMultiple( [ w ], [(f,f,1) for f in frames] ) - for f in frames : - imageA = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.%04d.exr" % f )() - imageB = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheTestResultsUV.%04d.exr" % f )() - self.assertEqual( IECoreImage.ImageDiffOp()( imageA = imageA, imageB = imageB, maxError = 0.05 ).value, False ) - - def testSelectionHash( self ): - """ - Test selection hash refresh when using motion blur - """ - for i in range( 10 ): - constant = nuke.createNode( "Constant" ) - constant.knob( "color" ).setValue( 1 ) - constant.knob( "channels" ).setValue( "rgba" ) - - reader = nuke.createNode( "ieSceneCacheReader" ) - reader.knob( "file" ).setValue( "test/IECoreNuke/scripts/animatedSpheres.scc" ) - reader.forceValidate() - widget = reader.knob( "sceneView" ) - widget.setSelectedItems( ["/root/A/a"] ) - - camera = nuke.createNode( "Camera2") - camera.knob( "translate" ).setValue( [0,0,12] ) - render = nuke.createNode( "ScanlineRender" ) - - render.setInput( 0, camera ) - render.setInput( 1, reader ) - render.setInput( 2, constant ) - render.knob( "samples" ).setValue( 2 ) - - writer = nuke.createNode( "Write" ) - writer.knob( "file" ).setValue( "test/IECoreNuke/scripts/data/sceneCacheTestResultsSelectionHash.####.exr" ) - writer.setInput( 0, render ) - writer.knob( "file_type" ).setValue( "exr" ) - nuke.execute( writer, 1, 2, 1 ) - - widget = reader.knob( "sceneView" ) - widget.setSelectedItems( ["/root/A/a"] ) - opHashes = reader.opHashes() - widget.setSelectedItems( ["/root/B/b"] ) - diffOpHashes = reader.opHashes() - - self.assertNotEqual( opHashes, diffOpHashes ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/SceneCacheWriterTest.py b/test/IECoreNuke/SceneCacheWriterTest.py deleted file mode 100644 index c23d524708..0000000000 --- a/test/IECoreNuke/SceneCacheWriterTest.py +++ /dev/null @@ -1,184 +0,0 @@ -########################################################################## -# -# Copyright (c) 2022, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import os -import shutil -import tempfile - -import nuke - -import imath - -import IECore -import IECoreScene -import IECoreNuke - -class SceneCacheWriterTest( IECoreNuke.TestCase ) : - - def setUp( self ) : - self.__temporaryDirectory = None - - def tearDown( self ) : - if self.__temporaryDirectory is not None : - shutil.rmtree( self.__temporaryDirectory ) - - def temporaryDirectory( self ) : - - if self.__temporaryDirectory is None : - self.__temporaryDirectory = tempfile.mkdtemp( prefix = "ieCoreNukeTest" ) - - return self.__temporaryDirectory - - def testWriteEmptyScene( self ): - - outputFile = os.path.join( self.temporaryDirectory(), "empty.scc" ) - - writer = nuke.createNode( "WriteGeo" ) - writer["file"].fromScript( outputFile ) - - nuke.execute( writer, 1001, 1001 ) - - self.assertTrue( os.path.exists( outputFile ) ) - - scene = IECoreScene.SharedSceneInterfaces.get( outputFile ) - self.assertEqual( scene.childNames(), [] ) - - def testWriteSimpleSphere( self ): - - outputFile = os.path.join( self.temporaryDirectory(), "sphere.scc" ) - - sphere = nuke.createNode( "Sphere" ) - writer = nuke.createNode( "WriteGeo" ) - writer["file"].fromScript( outputFile ) - - nuke.execute( writer, 1001, 1001 ) - - self.assertTrue( os.path.exists( outputFile ) ) - - scene = IECoreScene.SharedSceneInterfaces.get( outputFile ) - - self.assertEqual( scene.childNames(), ["object0"] ) - self.assertEqual( scene.readTransform( 0 ).value, imath.M44d() ) - - liveSceneHolder = nuke.createNode( "ieLiveScene" ) - liveSceneHolder.setInput( 0, sphere ) - - liveScene = liveSceneHolder["scene"].getValue() - - liveSceneMesh = liveScene.scene( ["object0"] ).readObject( 0 ) - mesh = scene.scene( ["object0"] ).readObject( 0 ) - - self.assertEqual( mesh.topologyHash(), liveSceneMesh.topologyHash() ) - - def testWriteSceneCacheReader( self ): - import random - import IECoreScene - - outputFile = os.path.join( self.temporaryDirectory(), "scene.scc" ) - - sceneFile = "test/IECoreNuke/scripts/data/liveSceneData.scc" - sceneReader = nuke.createNode( "ieSceneCacheReader" ) - sceneReader.knob( "file" ).setValue( sceneFile ) - expectedScene = IECoreScene.SharedSceneInterfaces.get( sceneFile ) - - sceneReader.forceValidate() - widget = sceneReader.knob( "sceneView" ) - widget.setSelectedItems( ['/root/A/a', '/root/B/b'] ) - - writer = nuke.createNode( "WriteGeo" ) - writer["file"].fromScript( outputFile ) - - nuke.execute( writer, 1, 48 ) - - scene = IECoreScene.SharedSceneInterfaces.get( outputFile ) - - self.assertEqual( scene.childNames(), expectedScene.childNames() ) - for time in range( 0, 3 ): - self.assertAlmostEqual( scene.readBound( time ).min(), expectedScene.readBound( time ).min() ) - mesh = scene.scene( ["B", "b"] ).readObject( time ) - expectedMesh = expectedScene.scene( ["B", "b"] ).readObject( time ) - random.seed( 12 ) - for i in range( 12 ): - pointIndex = random.choice( range( len( mesh["P"].data ) ) ) - self.assertAlmostEqual( mesh["P"].data[pointIndex], expectedMesh["P"].data[pointIndex], 4 ) - - def testWriteParticle( self ): - - outputFile = os.path.join( self.temporaryDirectory(), "particle.scc" ) - - noise = nuke.createNode( "Noise") - card = nuke.createNode( "Card2" ) - card.setInput( 0, noise ) - particle = nuke.createNode( "ParticleEmitter" ) - particle.setInput( 1, card ) - particle["size_variation"].setValue( 2 ) - particle["color_from_texture"].setValue( True ) - particle["spread"].setValue( .3 ) - writer = nuke.createNode( "WriteGeo" ) - writer["file"].fromScript( outputFile ) - - nuke.execute( writer, 0, 24 ) - - self.assertTrue( os.path.exists( outputFile ) ) - - scene = IECoreScene.SharedSceneInterfaces.get( outputFile ) - - self.assertEqual( scene.childNames(), ["object0"] ) - - pointsPrim = scene.scene( ["object0",] ).readObject( 1 ) - self.assertEqual( set( pointsPrim.keys() ), set( ["Cs", "P", "pid", "width", "velocity", "alpha"] ) ) - - self.assertEqual( pointsPrim.numPoints, 100 ) - self.assertEqual( scene.scene( ["object0",] ).readObject( 0.04 ).numPoints, 10 ) - self.assertEqual( scene.scene( ["object0",] ).readObject( 0.5 ).numPoints, 100 ) - - self.assertAlmostEqual( pointsPrim["P"].data[12], imath.V3f(-0.559, 1.797, 1.677), delta=.015 ) - self.assertAlmostEqual( pointsPrim["Cs"].data[21], imath.Color4f(0.241325, 0.241325, 0.241325, 1), delta=.015 ) - self.assertAlmostEqual( pointsPrim["alpha"].data[72], 1.0, delta=.015 ) - self.assertAlmostEqual( pointsPrim["width"].data[99], .105, delta=.015 ) - self.assertAlmostEqual( pointsPrim["pid"].data[92], 197, delta=.015 ) - self.assertAlmostEqual( pointsPrim["velocity"].data[72], imath.V3f(-18.424, 4.602, 14.675), delta=.015 ) - - def assertAlmostEqual( self, left, right, delta=None ): - if isinstance( left, ( imath.V3f, imath.Color3f, imath.Color4f ) ): - for index, _ in enumerate( left ): - super( SceneCacheWriterTest, self ).assertAlmostEqual( left[index], right[index], delta=delta ) - else: - super( SceneCacheWriterTest, self ).assertAlmostEqual( left, right, delta=delta ) - -if __name__ == "__main__": - unittest.main() - - diff --git a/test/IECoreNuke/StringUtilTest.py b/test/IECoreNuke/StringUtilTest.py deleted file mode 100644 index 6228b32f5b..0000000000 --- a/test/IECoreNuke/StringUtilTest.py +++ /dev/null @@ -1,60 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import IECoreNuke -import IECore -import nuke - -class StringUtilTest( IECoreNuke.TestCase ) : - - def testNukeFileSequence( self ) : - - self.assertEqual( IECoreNuke.nukeFileSequence( "/tmp/test.dpx" ), "/tmp/test.dpx" ) - self.assertEqual( IECoreNuke.nukeFileSequence( "/tmp/test.#.dpx" ), "/tmp/test.%d.dpx" ) - self.assertEqual( IECoreNuke.nukeFileSequence( "/tmp/test.##.dpx" ), "/tmp/test.%02d.dpx" ) - self.assertEqual( IECoreNuke.nukeFileSequence( "/tmp/test_#########_test.dpx" ), "/tmp/test_%09d_test.dpx" ) - - def testIeCoreFileSequence( self ) : - - self.assertEqual( IECoreNuke.ieCoreFileSequence( "/tmp/test.dpx" ), "/tmp/test.dpx" ) - self.assertEqual( IECoreNuke.ieCoreFileSequence( "/tmp/test.%d.dpx" ), "/tmp/test.#.dpx" ) - self.assertEqual( IECoreNuke.ieCoreFileSequence( "/tmp/test.%02d.dpx" ), "/tmp/test.##.dpx" ) - self.assertEqual( IECoreNuke.ieCoreFileSequence( "/tmp/test_%09d_test.dpx" ), "/tmp/test_#########_test.dpx" ) - self.assertRaises( RuntimeError, IECoreNuke.ieCoreFileSequence, "/tmp/test.%2d.dpx" ) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreNuke/ops/add/add-1.py b/test/IECoreNuke/ops/add/add-1.py deleted file mode 100644 index 827cfba37b..0000000000 --- a/test/IECoreNuke/ops/add/add-1.py +++ /dev/null @@ -1,78 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore - -class add( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, - "", - IECore.IntParameter( - name = "result", - description = "", - defaultValue = 0, - ) - ) - - self.parameters().addParameter( - - IECore.IntParameter( - name = "a", - description = "", - defaultValue = 0, - userData = { - "nuke" : { - "defaultExpression" : IECore.StringData( '{"frame * 2"}' ), - } - } - ) - ) - - self.parameters().addParameter( - - IECore.IntParameter( - name = "b", - description = "", - defaultValue = 0, - ) - - ) - - def doOperation( self, operands ) : - - return IECore.IntData( operands["a"].value + operands["b"].value ) - -IECore.registerRunTimeTyped( add ) diff --git a/test/IECoreNuke/ops/imagePrimitiveInOut/imagePrimitiveInOut-1.py b/test/IECoreNuke/ops/imagePrimitiveInOut/imagePrimitiveInOut-1.py deleted file mode 100644 index 162eb1dfd0..0000000000 --- a/test/IECoreNuke/ops/imagePrimitiveInOut/imagePrimitiveInOut-1.py +++ /dev/null @@ -1,65 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011-2017, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreImage - -class imagePrimitiveInOut( IECore.Op ) : - - def __init__( self ) : - - IECore.Op.__init__( self, "", - - IECoreImage.ImagePrimitiveParameter( - "result", "", - defaultValue = IECoreImage.ImagePrimitive() - ) - - ) - - self.parameters().addParameter( - - IECoreImage.ImagePrimitiveParameter( - "input", - "", - defaultValue = IECoreImage.ImagePrimitive(), - ), - - ) - - def doOperation( self, args ) : - - return args["input"].copy() - -IECore.registerRunTimeTyped( imagePrimitiveInOut ) diff --git a/test/IECoreNuke/scripts/animatedSpheres.scc b/test/IECoreNuke/scripts/animatedSpheres.scc deleted file mode 100644 index 1e68e86373..0000000000 Binary files a/test/IECoreNuke/scripts/animatedSpheres.scc and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/animatedTransform.scc b/test/IECoreNuke/scripts/data/animatedTransform.scc deleted file mode 100644 index 5012579de1..0000000000 Binary files a/test/IECoreNuke/scripts/data/animatedTransform.scc and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/cubeUDIM.scc b/test/IECoreNuke/scripts/data/cubeUDIM.scc deleted file mode 100644 index 85a7a6ef92..0000000000 Binary files a/test/IECoreNuke/scripts/data/cubeUDIM.scc and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/duplicateParent.scc b/test/IECoreNuke/scripts/data/duplicateParent.scc deleted file mode 100644 index a034844d08..0000000000 Binary files a/test/IECoreNuke/scripts/data/duplicateParent.scc and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/liveSceneData.scc b/test/IECoreNuke/scripts/data/liveSceneData.scc deleted file mode 100644 index a84d8141c6..0000000000 Binary files a/test/IECoreNuke/scripts/data/liveSceneData.scc and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0001.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0001.exr deleted file mode 100644 index 12a916038d..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0001.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0010.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0010.exr deleted file mode 100644 index 92862e689a..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0010.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0020.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0020.exr deleted file mode 100644 index 242823af57..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0020.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0030.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0030.exr deleted file mode 100644 index da1e7aca84..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0030.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0040.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0040.exr deleted file mode 100644 index ba0135a3e6..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0040.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0050.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0050.exr deleted file mode 100644 index c37c3607e2..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0050.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0060.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0060.exr deleted file mode 100644 index da2ba80e42..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0060.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0070.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0070.exr deleted file mode 100644 index ca59ce039b..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0070.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0080.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0080.exr deleted file mode 100644 index 983ab19ad4..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResults.0080.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedResultsB.0020.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedResultsB.0020.exr deleted file mode 100644 index 0644364bbf..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedResultsB.0020.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0001.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0001.exr deleted file mode 100644 index e8ebefe75a..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0001.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0010.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0010.exr deleted file mode 100644 index db33136c02..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0010.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0020.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0020.exr deleted file mode 100644 index c51f729487..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0020.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0030.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0030.exr deleted file mode 100644 index 4703f97ae8..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0030.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0040.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0040.exr deleted file mode 100644 index ddb209f645..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0040.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0050.exr b/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0050.exr deleted file mode 100644 index 4be717290f..0000000000 Binary files a/test/IECoreNuke/scripts/data/sceneCacheExpectedUVResults.0050.exr and /dev/null differ diff --git a/test/IECoreNuke/scripts/sceneCacheTest.nk b/test/IECoreNuke/scripts/sceneCacheTest.nk deleted file mode 100644 index bccfe0698b..0000000000 --- a/test/IECoreNuke/scripts/sceneCacheTest.nk +++ /dev/null @@ -1,205 +0,0 @@ -#! /software/apps/nuke/9.0v6/cent6.x86_64/libnuke-9.0.6.so -nx -#write_info Write1 file:"[file dirname [value root.name] ]/data/sceneCacheTestResults.%04d.exr" format:"640 480 1" chans:":rgba.red:rgba.green:rgba.blue:" framerange:"1 80" fps:"0" colorspace:"default (linear)" datatype:"16 bit half" transfer:"unknown" views:"main" -version 9.0 v6 -define_window_layout_xml { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} -Root { - inputs 0 - name /home/lucienf/dev/git/cortex/test/IECoreNuke/scripts/sceneCacheTest.nk - last_frame 80 - lock_range true - format "640 480 0 0 640 480 1 PC_Video" - proxy_type scale - proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)" - luts {linear {} - sRGB {} - rec709 {} - Cineon {} - CineonBlackpoint0 {(pow(10,(1023*x-685)/300)-.0052)/(1-.0052)} - Panalog {"-0.042784 + 0.042784 * exp(4.971170*(x*1.06674-0.066736))"} - ieAlexaV3LogC {"(x > 0.1496582 ? pow(10.0, (x - 0.385537) / 0.2471896) : x / 0.9661776 - 0.04378604) * 0.18 - 0.00937677"}} - defaultViewerLUT "OCIO LUTs" - OCIOConfigPath /data/jobs/IDR/sequences/rnd/shots/pipeline/config/openColorIO/config.ocio - addUserKnob {20 IE} - addUserKnob {1 IEENV_WORKING_PATH +DISABLED} - IEENV_WORKING_PATH /data/jobs/FSQ/sequences/rnd/shots/pipe -} -Read { - inputs 0 - file "\[file dirname \[value root.name] ]/data/sceneCacheExpectedResults.####.exr" - format "640 480 0 0 640 480 1 PC_Video" - last 80 - origlast 80 - origset true - on_error black - version 23 - name Read1 - xpos 153 - ypos 279 -} -Camera2 { - inputs 0 - translate {0 0 50} - name Camera1 - xpos -146 - ypos 194 -} -CheckerBoard2 { - inputs 0 - name CheckerBoard1 - xpos -10 - ypos -29 -} -set N719ca10 [stack 0] -ieSceneCacheReader { - file "\[file dirname \[value root.name] ]/animatedSpheres.scc" - sceneRoot / - filterByTag None - filterByName "" - sceneView {{0} imported: 0 1 2 3 selected: 0 2 3 items: /root/A/a /root/B/b /root/bezier1 /root/particle1} - translate {8 0 0} - loadAll true - name ieSceneCacheReader3 - xpos 285 - ypos 74 -} -FrameHold { - first_frame 70 - name FrameHold1 - xpos 322 - ypos 158 -} -push $N719ca10 -ieSceneCacheReader { - file "\[file dirname \[value root.name] ]/animatedSpheres.scc" - sceneRoot / - filterByTag None - filterByName "" - sceneView {{0} imported: 0 1 2 3 selected: 0 items: /root/A/a /root/B/b /root/bezier1 /root/particle1} - translate {5 0 0} - loadAll true - name ieSceneCacheReader4 - xpos 140 - ypos 72 -} -set N711e890 [stack 0] -TimeOffset { - time_offset 30 - time "" - name TimeOffset2 - xpos 186 - ypos 151 -} -push $N711e890 -push $N719ca10 -ieSceneCacheReader { - file "\[file dirname \[value root.name] ]/animatedSpheres.scc" - sceneRoot / - filterByTag None - filterByName "" - sceneView {{0} imported: 0 1 2 3 selected: 0 1 2 3 items: /root/A/a /root/B/b /root/bezier1 /root/particle1} - loadAll true - name ieSceneCacheReader2 - xpos -10 - ypos 84 -} -TimeOffset { - time_offset 10 - time "" - name TimeOffset1 - xpos -10 - ypos 130 -} -push $N719ca10 -ieSceneCacheReader { - file "\[file dirname \[value root.name] ]/animatedSpheres.scc" - sceneRoot / - filterByTag None - filterByName "" - sceneView {{0} imported: 0 1 2 3 selected: 0 1 2 3 items: /root/A/a /root/B/b /root/bezier1 /root/particle1} - translate {-5 0 0} - loadAll true - name ieSceneCacheReader1 - xpos -161 - ypos 85 -} -Scene { - inputs 5 - name Scene1 - xpos 0 - ypos 188 -} -push 0 -ScanlineRender { - inputs 3 - shutteroffset centred - shuttercustomoffset 0.25 - motion_vectors_type distance - name ScanlineRender1 - xpos -10 - ypos 293 -} -ModifyMetaData { - metadata { - {remove exr/jabuka* ""} - {set exr/jabukaNukeScript /home/lucienf/dev/git/cortex/test/IECoreNuke/scripts/sceneCacheTest.nk} - {set exr/jabukaSourceList "\[]"} - {set exr/jabukaContents ""} - {set exr/jabukaNukeUnpublishedFiles "\[]"} - } - name ModifyMetaData1 - xpos -10 - ypos 319 -} -Write { - file "\[file dirname \[value root.name] ]/data/sceneCacheTestResults.####.exr" - file_type exr - metadata "default metadata and exr/*" - version 7 - name Write1 - xpos -10 - ypos 345 -} -Viewer { - frame 1 - frame_range 1-80 - input_process false - name Viewer1 - xpos -10 - ypos 448 -} diff --git a/test/IECoreNuke/scripts/sceneCacheTestUV.nk b/test/IECoreNuke/scripts/sceneCacheTestUV.nk deleted file mode 100644 index 1a965e27a8..0000000000 --- a/test/IECoreNuke/scripts/sceneCacheTestUV.nk +++ /dev/null @@ -1,423 +0,0 @@ -#! /software/apps/nuke/11.2v3/cent7.x86_64/libnuke-11.2.3.so -nx -#write_info Write1 file:"[file dirname [value root.name] ]/data/sceneCacheTestUVResults.%04d.exr" format:"640 480 1" chans:":rgba.red:rgba.green:rgba.blue:" framerange:"1 50" fps:"0" colorspace:"default (linear)" datatype:"16 bit half" transfer:"unknown" views:"main" colorManagement:"Nuke" -version 11.2 v3 -define_window_layout_xml { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} -Root { - inputs 0 - name /home/lucienf/dev/git/cortex/test/IECoreNuke/scripts/sceneCacheTestUV.nk - frame 20 - last_frame 50 - lock_range true - format "640 480 0 0 640 480 1 PC_Video" - proxy_type scale - proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)" - colorManagement Nuke - defaultViewerLUT "OCIO LUTs" - workingSpaceLUT linear - monitorLut sRGB - int8Lut sRGB - int16Lut sRGB - logLut Cineon - floatLut linear - luts {linear {} - sRGB {} - rec709 {} - Cineon {} - Gamma1.8 {} - Gamma2.2 {} - Gamma2.4 {} - Gamma2.6 {} - Panalog {"-0.042784 + 0.042784 * exp(4.971170*(x*1.06674-0.066736))"} - REDLog {} - ViperLog {} - AlexaV3LogC {} - PLogLin {} - SLog {} - SLog1 {} - SLog2 {} - SLog3 {} - CLog {} - Log3G10 {} - Log3G12 {} - HybridLogGamma {} - Protune {} - BT1886 {} - HDR2084 {} - REDSpace {} - CineonBlackpoint0 {(pow(10,(1023*x-685)/300)-.0052)/(1-.0052)} - ieAlexaV3LogC {"(x > 0.1496582 ? pow(10.0, (x - 0.385537) / 0.2471896) : x / 0.9661776 - 0.04378604) * 0.18 - 0.00937677"}} - addUserKnob {20 IE} - addUserKnob {1 IEENV_WORKING_PATH +DISABLED} - IEENV_WORKING_PATH /data/jobs/FSQ/sequences/rnd/shots/pipe -} -Read { - inputs 0 - file_type exr - file "\[file dirname \[value root.name] ]/data/sceneCacheExpectedUVResults.####.exr" - format "640 480 0 0 640 480 1 PC_Video" - last 50 - origlast 50 - origset true - on_error "nearest frame" - version 30 - name Read1 - xpos -427 - ypos 220 -} -Axis2 { - inputs 0 - rot_order XYZ - rotate {{curve K x1 0 x39 0} {curve K x1 0 x10 90 x20 180 x29 270 x39 0} {curve K x1 0 x29 0 x39 90 270}} - name Axis1 - xpos -808 - ypos 243 -} -Camera2 { - translate {4.798048496 0.4263817072 -0.05023089424} - rotate {-5.07801086 90.59980923 0} - name Camera3 - xpos -808 - ypos 360 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard7 - xpos -775 - ypos 65 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message "1022\n" - old_message {{49 48 50 50 10} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 4 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text6 - xpos -775 - ypos 137 -} -UVTile2 { - udim 1022 - udim_enable true - name UVTile6 - xpos -775 - ypos 172 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard6 - xpos -775 - ypos -99 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message "1021\n" - old_message {{49 48 50 49 10} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 4 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text5 - xpos -775 - ypos -27 -} -UVTile2 { - udim 1021 - udim_enable true - name UVTile5 - xpos -775 - ypos 8 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard5 - xpos -770 - ypos -303 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message "1012\n" - old_message {{49 48 49 50 10} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 4 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text4 - xpos -770 - ypos -231 -} -UVTile2 { - udim 1012 - udim_enable true - name UVTile4 - xpos -770 - ypos -196 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard4 - xpos -723 - ypos -493 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message "1011\n" - old_message {{49 48 49 49 10} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 5 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text3 - xpos -723 - ypos -421 -} -UVTile2 { - udim 1011 - udim_enable true - name UVTile3 - xpos -723 - ypos -385 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard2 - xpos -764 - ypos -662 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message 1001 - old_message {{49 48 48 49} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 4 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text1 - xpos -764 - ypos -590 -} -UVTile2 { - udim_enable true - name UVTile1 - xpos -764 - ypos -554 -} -CheckerBoard2 { - inputs 0 - format "256 256 0 0 256 256 1 square_256" - name CheckerBoard3 - xpos -568 - ypos -757 -} -Text2 { - font_size_toolbar 100 - font_width_toolbar 100 - font_height_toolbar 100 - cliptype none - message 1002 - old_message {{49 48 48 50} - } - box {0 0 {width} {height}} - transforms {{0 2} - } - cursor_position 4 - center {320 240} - cursor_initialised true - autofit_bbox false - initial_cursor_position {{0 480} - } - group_animations {{0} imported: 0 selected: items: "root transform/"} - animation_layers {{1 11 320 240 0 0 1 1 0 0 0 0} - } - name Text2 - xpos -568 - ypos -685 -} -UVTile2 { - udim 1002 - udim_enable true - name UVTile2 - xpos -568 - ypos -650 -} -MergeMat { - inputs 2 - name MergeMat1 - xpos -568 - ypos -554 -} -MergeMat { - inputs 2 - name MergeMat2 - xpos -568 - ypos -385 -} -MergeMat { - inputs 2 - name MergeMat3 - xpos -568 - ypos -196 -} -MergeMat { - inputs 2 - name MergeMat4 - xpos -568 - ypos 8 -} -MergeMat { - inputs 2 - name MergeMat5 - xpos -568 - ypos 172 -} -ieSceneCacheReader { - file "\[file dirname \[value root.name] ]/data/cubeUDIM.scc" - sceneRoot / - filterByTag None - visibilityFilter false - filterByName "" - sceneView {{0} imported: 0 selected: 0 items: /root/geo1} - worldSpace false - loadAll true - name ieSceneCacheReader6 - xpos -568 - ypos 237 -} -push 0 -ScanlineRender { - inputs 3 - conservative_shader_sampling false - overscan {0 0} - shutteroffset centred - motion_vectors_type distance - name ScanlineRender2 - xpos -568 - ypos 380 -} -Write { - file "\[file dirname \[value root.name] ]/data/sceneCacheTestResultsUV.####.exr" - file_type exr - metadata "default metadata and exr/*" - first_part rgba - version 7 - name Write1 - xpos -568 - ypos 438 -} -Viewer { - frame 20 - frame_range 1-50 - input_process false - name Viewer1 - xpos -10 - ypos 448 -}