├── .gitignore ├── README.md ├── ocio_functionality └── source │ ├── ocio_functionality.cpp │ └── ocio_functionality.h ├── ocio_houdini ├── CMakeLists.txt ├── media │ ├── COP2_OCIOCDLTransform.png │ ├── COP2_OCIOColorspace.png │ ├── COP2_OCIOFileTransform.png │ └── COP2_OCIOLogConvert.png ├── script │ ├── ocio_houdini_hcustom_compile_settings.txt │ └── ocio_nodes.shelf └── source │ ├── ocio_cdl_transform.cpp │ ├── ocio_cdl_transform.h │ ├── ocio_colorspace.cpp │ ├── ocio_colorspace.h │ ├── ocio_file_transform.cpp │ ├── ocio_file_transform.h │ ├── ocio_log_convert.cpp │ ├── ocio_log_convert.h │ ├── ocio_plugin.cpp │ ├── ocio_types.cpp │ └── ocio_types.h ├── ocio_maya ├── CMakeLists.txt ├── script │ ├── AEOCIOCDLTransformTemplate.mel │ ├── AEOCIOColorSpaceTemplate.mel │ ├── AEOCIOFileTransformTemplate.mel │ ├── AEOCIOLogConvertTemplate.mel │ ├── update_plugin_OCIOCDLTransform.py │ ├── update_plugin_OCIOColorSpace.py │ ├── update_plugin_OCIOFileTransform.py │ ├── update_plugin_OCIOLogConvert.py │ ├── update_plugin_ocio_simple_transform.py │ └── update_plugin_ocio_test.py └── source │ ├── ocio_cdl_transform.cpp │ ├── ocio_cdl_transform.h │ ├── ocio_colorspace.cpp │ ├── ocio_colorspace.h │ ├── ocio_export_cc.cpp │ ├── ocio_export_cc.h │ ├── ocio_file_transform.cpp │ ├── ocio_file_transform.h │ ├── ocio_log_convert.cpp │ ├── ocio_log_convert.h │ ├── ocio_plugin.cpp │ ├── ocio_simple_transform.cpp │ ├── ocio_simple_transform.h │ ├── ocio_test.cpp │ └── ocio_test.h └── ocio_view ├── CMakeLists.txt ├── media ├── inspect_view.ui └── ocio_view.ui └── source ├── image_label.cpp ├── image_label.h ├── inspect_view.cpp ├── inspect_view.h ├── main.cpp ├── ocio_view.cpp └── ocio_view.h /.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore 2 | 3 | ocio_maya_build 4 | ocio_view_build 5 | ocio_houdini_build 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | OpenColorIO_Tools 3 | ================= 4 | 5 | My set of OpenColorIO tools and plugins. It currently contains plugins for Houdini and Maya, as well as a tiny Qt standalone application. [Download a precompiled binary here](http://www.kiiia.com/opencolorio/OpenColorIO_houdini_install.zip). 6 | 7 | ----------------------- 8 | 9 | Abstract - What is OCIO 10 | ----------------------- 11 | 12 |

13 | 14 | 15 | 16 | 17 |

18 | 19 | ----------------------- 20 | 21 | [OpenColorIO](http://opencolorio.org/) is a library developed by Sony Pictures Imageworks, where it is part of their OpenSource initiative amongst other libraries and frameworks like OIIO, Alembic and OSL to name few. 22 | [OCIO](http://opencolorio.org/) aims to enable consistent color management across programs by providing a unified color environment. Central to this is the idea of .ocio files which define the working color environment, by specifying 23 | a set of LUTs that can be used. [OCIO](http://opencolorio.org/) provides an interface to a variety of LUT formats, in much the same way as OIIO does to image formats. These LUTs are then used for colortransformation on the CPU or GPU. 24 | [OCIO](http://opencolorio.org/) is increasingly used in commercial software like NUKE or MARI. [here](http://opencolorio.org/CompatibleSoftware.html) is a list of compatible software. 25 | 26 | ----------------------- 27 | 28 | Goal of OpenColorIO_Tools 29 | ------------------------- 30 | 31 | Since [OCIO](http://opencolorio.org/) is a color management solution geared towards unifying the color management in an animation/vfx pipeline it makes sense for all tools in the pipeline to natively support it. 32 | Therefore the primary goal is to create a set of Houdini COP nodes (Houdinis compositing network) as equivalents to the NUKE OCIO nodes which ship natively. 33 | Additionaly i plan on developing a set of Maya nodes for color managing textures, to become familiar with the library. 34 | My personal interest in this project is to enhance my C++ programming and to become familiar with the Houdini Development Kit. 35 | 36 | ----------------------- 37 | 38 | Nuke OCIO nodes for Houdini 39 | --------------------------- 40 | 41 | The list of nodes i want to make available as Houdini COP2 nodes 42 | 43 | * **OCIOCDLTransform** 44 | Applies an ASC CDL (American Society of Cinematographers Color Decision List) grade based on the OpenColorIO Library 45 | * **OCIOColorSpace** 46 | Apply a color transformation based on a .ocio file. Ocio files are yaml based and describe the complete available colorenvironment. The color environment in turn usualy consists of a dozen Lut files which describe transformations to/from the reference color space to the target space. 47 | * **OCIOFileTransform** 48 | Accepts a path to a specific color lut file and does a color transformation based on it. 49 | * **OCIOLogConvert** 50 | Do a color transformation from Lin to Log, or the other way round, based on the Lin and Log roles of the given .ocio config file. 51 | 52 | 53 | For more infos visit [my website](http://www.timmwagener.com/ocio.html). -------------------------------------------------------------------------------- /ocio_functionality/source/ocio_functionality.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_FUNCTIONALITY_H 4 | #define OCIO_FUNCTIONALITY_H 5 | 6 | //Ocio_functionality Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //OCIO 25 | #include 26 | //Own 27 | 28 | 29 | //OCIO Namespace 30 | namespace OCIO = OCIO_NAMESPACE; 31 | 32 | 33 | //Ocio_functionality 34 | //----------------------------------------------- 35 | 36 | namespace OCIO_functionality 37 | { 38 | 39 | //OCIO 40 | OCIO::ConstConfigRcPtr get_config_from_env(); 41 | OCIO::ConstConfigRcPtr get_config_from_file(std::string&); 42 | std::vector get_colorspace_names(OCIO::ConstConfigRcPtr&); 43 | int get_colorspace_count(OCIO::ConstConfigRcPtr&); 44 | std::string get_colorspace_name_from_index(OCIO::ConstConfigRcPtr&, int); 45 | OCIO::ConstProcessorRcPtr get_processor(OCIO::ConstConfigRcPtr&, std::string&, std::string&); 46 | OCIO::ConstProcessorRcPtr get_processor(int, std::string&, int); 47 | OCIO::ConstProcessorRcPtr get_processor_from_file_transform(std::string, std::string, int, int); 48 | OCIO::ConstProcessorRcPtr get_processor_from_cdl_transform(float*&, float, int); 49 | std::string get_xml_from_cdl_transform(float*&, float, int); 50 | void color_transform_single_pixel(float*&, float*&, float*&, OCIO::ConstProcessorRcPtr&); 51 | void color_transform_rgb_array(float*&, float*&, float*&, OCIO::ConstProcessorRcPtr&, int, int); 52 | std::string get_config_info(OCIO::ConstConfigRcPtr&); 53 | //Temp 54 | void print_config_info(OCIO::ConstConfigRcPtr&); 55 | 56 | } 57 | 58 | 59 | #endif -------------------------------------------------------------------------------- /ocio_houdini/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | #CMake file for ocio_houdini 4 | #--------------------------------------- 5 | 6 | #Ream Me 7 | #This CMake file only creates the bare VS project. 8 | #It is neccessary to use hcustom and copy the aquired flags 9 | #for the compiler and linker in the "Additional Options" 10 | #textfield in VS in order for the compilation to succeed. 11 | 12 | #--------------------------------------- 13 | 14 | 15 | cmake_minimum_required(VERSION 2.8.8) 16 | 17 | #solution 18 | #--------------------------------------- 19 | project(ocio_houdini) 20 | 21 | 22 | 23 | 24 | 25 | #CMake settings 26 | #--------------------------------------- 27 | 28 | #Build Type 29 | IF (NOT CMAKE_BUILD_TYPE) 30 | SET(CMAKE_BUILD_TYPE Release) 31 | ENDIF (NOT CMAKE_BUILD_TYPE) 32 | 33 | #Generator toolset (which visual studio version is used for compilation. Standard is: IDE Editing: VS2013 Compilation: VS2010) 34 | if(MSVC OR MSVC_IDE) 35 | set(CMAKE_GENERATOR_TOOLSET "v110" CACHE STRING "Platform Toolset" FORCE) 36 | endif() 37 | 38 | #CMAKE Variables 39 | #ocio 40 | set(OCIO_INCLUDE_DIR "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO/export" CACHE PATH "OCIO default include path. Must contain the files: OpenColorIO.h, OpenColorTransforms.h and OpenColorTypes.h") 41 | set(OCIO_ABI_INCLUDE_DIR "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO_build/msvc11/x64/export" CACHE PATH "OCIO ABI header include path. This header is built by cmake and therefore can be found in the build directory. Must contain the file: OpenColorABI.h") 42 | set(OCIO_FUNCTIONALITY_INCLUDE_DIR "C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_functionality/source" CACHE FILEPATH "Additional include directory") 43 | set(OCIO_LIBRARY_DIR_DEBUG "C:/symlinks/libraries/OpenColorIO/x64/msvc11/static/debug/OpenColorIO.lib" CACHE FILEPATH "OCIO library to link against") 44 | set(OCIO_LIBRARY_DIR_RELEASE "C:/symlinks/libraries/OpenColorIO/x64/msvc11/static/release/OpenColorIO.lib" CACHE FILEPATH "OCIO library to link against") 45 | #boost 46 | set(BOOST_ROOT "C:/symlinks/boost/boost_1_54_0" CACHE PATH "Boost Root, for example: C:/boost_1_54_0") 47 | set(BOOST_INCLUDEDIR "C:/symlinks/boost/boost_1_54_0/boost" CACHE PATH "Boost include dir, for example: C:/boost_1_54_0/boost") 48 | set(BOOST_LIBRARYDIR "C:/symlinks/boost/boost_1_54_0/stage/x64/msvc11/python26/lib" CACHE PATH "Boost library dir, for example: C:/boost_1_54_0/stage/x64/msvc11/python26/lib") 49 | #custom 50 | set(ADDITIONAL_SOURCE_DIR_1 "" CACHE PATH "Additional include directories. Will be scanned for .h and .cpp files") 51 | set(ADDITIONAL_SOURCE_DIR_2 "" CACHE PATH "Additional include directories. Will be scanned for .h and .cpp files") 52 | 53 | 54 | 55 | 56 | 57 | 58 | #Find packages 59 | #------------------------------------------------------------- 60 | set(Boost_USE_STATIC_LIBS ON) 61 | find_package(Boost REQUIRED) 62 | 63 | 64 | 65 | 66 | 67 | #Headers 68 | #--------------------------------------- 69 | file(GLOB HEADERS 70 | ${CMAKE_CURRENT_SOURCE_DIR}/source/*.h 71 | ${OCIO_FUNCTIONALITY_INCLUDE_DIR}/*.h 72 | ${ADDITIONAL_SOURCE_DIR_1}/*.h 73 | ${ADDITIONAL_SOURCE_DIR_2}/*.h 74 | ) 75 | 76 | 77 | #Source files 78 | #--------------------------------------- 79 | file (GLOB SOURCES 80 | ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp 81 | ${OCIO_FUNCTIONALITY_INCLUDE_DIR}/*.cpp 82 | ${ADDITIONAL_SOURCE_DIR_1}/*.cpp 83 | ${ADDITIONAL_SOURCE_DIR_2}/*.cpp 84 | ) 85 | 86 | 87 | 88 | 89 | #Filters 90 | #--------------------------------------- 91 | source_group(headers FILES ${HEADERS}) 92 | source_group(sources FILES ${SOURCES}) 93 | 94 | 95 | 96 | 97 | 98 | #Add library 99 | #--------------------------------------- 100 | 101 | #project 102 | add_library(ocio_houdini SHARED ${SOURCES} ${HEADERS}) 103 | 104 | #cxx flags / command line options copied from hcustom 105 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /sdl-" ) 106 | 107 | #preprocessor definitions 108 | add_definitions(-DUNICODE -D_UNICODE) 109 | 110 | #include directories 111 | include_directories( 112 | ${OCIO_INCLUDE_DIR} 113 | ${OCIO_ABI_INCLUDE_DIR} 114 | ${OCIO_FUNCTIONALITY_INCLUDE_DIR} 115 | ${Boost_INCLUDE_DIR} 116 | ) 117 | 118 | #target link libraries debug 119 | target_link_libraries(ocio_houdini debug 120 | #Maya 121 | ${OCIO_LIBRARY_DIR_DEBUG} 122 | ) 123 | 124 | #target link libraries release 125 | target_link_libraries(ocio_houdini optimized 126 | #Maya 127 | ${OCIO_LIBRARY_DIR_RELEASE} 128 | ) -------------------------------------------------------------------------------- /ocio_houdini/media/COP2_OCIOCDLTransform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timmwagener/OpenColorIO_Tools/6299a40de7c0a1083eef26c0925bc6452c5c163f/ocio_houdini/media/COP2_OCIOCDLTransform.png -------------------------------------------------------------------------------- /ocio_houdini/media/COP2_OCIOColorspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timmwagener/OpenColorIO_Tools/6299a40de7c0a1083eef26c0925bc6452c5c163f/ocio_houdini/media/COP2_OCIOColorspace.png -------------------------------------------------------------------------------- /ocio_houdini/media/COP2_OCIOFileTransform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timmwagener/OpenColorIO_Tools/6299a40de7c0a1083eef26c0925bc6452c5c163f/ocio_houdini/media/COP2_OCIOFileTransform.png -------------------------------------------------------------------------------- /ocio_houdini/media/COP2_OCIOLogConvert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timmwagener/OpenColorIO_Tools/6299a40de7c0a1083eef26c0925bc6452c5c163f/ocio_houdini/media/COP2_OCIOLogConvert.png -------------------------------------------------------------------------------- /ocio_houdini/script/ocio_houdini_hcustom_compile_settings.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Whats this? 5 | =========== 6 | 7 | .. note:: 8 | Compile settings are aquired by the hcustom command line tool. They are specific to the system 9 | and therefore need to be aquired for each system and Houdini version. 10 | The values here can just be copied and pasted into the appropiate generated Visual Studio project 11 | in the compilation command line settings. 12 | 13 | This file is just information to ease the process of generating the compile ready Viusual Studio 14 | project. It is not a necessary ingredient of the build. 15 | 16 | 17 | 18 | Home 19 | ==== 20 | 21 | 13.0.260 22 | -------- 23 | 24 | Compile 25 | ******* 26 | 27 | -nologo 28 | -TP 29 | -Zc:forScope 30 | -DVERSION="13.0.260" 31 | -DI386 32 | -DWIN32 33 | -DSWAP_BITFIELDS 34 | -D_WIN32_WINNT=0x0501 35 | -DWINVER=0x0501 36 | -DNOMINMAX 37 | -DSTRICT 38 | -DWIN32_LEAN_AND_MEAN 39 | -D_USE_MATH_DEFINES 40 | -D_CRT_SECURE_NO_DEPRECATE 41 | -D_CRT_NONSTDC_NO_DEPRECATE 42 | -D_SCL_SECURE_NO_WARNINGS 43 | -DBOOST_ALL_NO_LIB 44 | -DSESI_LITTLE_ENDIAN 45 | -DAMD64 46 | -DSIZEOF_VOID_P=8 47 | -DFBX_ENABLED=1 48 | -DOPENCL_ENABLED=1 49 | -DOPENVDB_ENABLED=1 50 | -I . 51 | -I "D:/tools/SIDEEF~1/HOUDIN~1.260/toolkit/include" 52 | -I "C:/PROGRA~2/MICROS~3.0/VC/include" 53 | -I "C:/Program Files (x86)/Windows Kits/8.0/Include/um" 54 | -I "C:/Program Files (x86)/Windows Kits/8.0/Include/shared" 55 | -wd4355 56 | -w14996 57 | -O2 58 | -DNDEBUG 59 | -MD 60 | -EHsc 61 | -GR 62 | -bigobj 63 | -DMAKING_DSO 64 | 65 | Link 66 | **** 67 | 68 | /machine:x64 69 | -LIBPATH:"C:/PROGRA~2/MICROS~3.0/VC/lib/amd64" 70 | -LIBPATH:"C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x64" 71 | -LIBPATH:"D:/tools/SIDEEF~1/HOUDIN~1.260/custom/houdini/dsolib" 72 | "D:/tools/SIDEEF~1/HOUDIN~1.260/custom/houdini/dsolib/*.a" 73 | "D:/tools/SIDEEF~1/HOUDIN~1.260/custom/houdini/dsolib/*.lib" 74 | 75 | 76 | 77 | 78 | 79 | Aka 80 | === 81 | 82 | 13.0.314 83 | -------- 84 | 85 | Compile 86 | ******* 87 | 88 | -nologo 89 | -TP 90 | -Zc:forScope 91 | -DVERSION="13.0.314" 92 | -DI386 93 | -DWIN32 94 | -DSWAP_BITFIELDS 95 | -D_WIN32_WINNT=0x0501 96 | -DWINVER=0x0501 97 | -DNOMINMAX 98 | -DSTRICT 99 | -DWIN32_LEAN_AND_MEAN 100 | -D_USE_MATH_DEFINES 101 | -D_CRT_SECURE_NO_DEPRECATE 102 | -D_CRT_NONSTDC_NO_DEPRECATE 103 | -D_SCL_SECURE_NO_WARNINGS 104 | -DBOOST_ALL_NO_LIB 105 | -DSESI_LITTLE_ENDIAN 106 | -DAMD64 107 | -DSIZEOF_VOID_P=8 108 | -DFBX_ENABLED=1 109 | -DOPENCL_ENABLED=1 110 | -DOPENVDB_ENABLED=1 111 | -I . 112 | -I "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.314/toolkit/include" 113 | -I "C:/PROGRA~2/MICROS~3.0/VC/include" 114 | -I "C:/Program Files (x86)/Windows Kits/8.0/Include/um" 115 | -I "C:/ProgramFiles (x86)/Windows Kits/8.0/Include/shared" 116 | -wd4355 117 | -w14996 118 | -O2 119 | -DNDEBUG 120 | -MD 121 | -EHsc 122 | -GR 123 | -bigobj 124 | -DMAKING_DSO 125 | 126 | 127 | Link 128 | **** 129 | 130 | /machine:x64 131 | -LIBPATH:"C:/PROGRA~2/MICROS~3.0/VC/lib/amd64" 132 | -LIBPATH:"C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x64" 133 | -LIBPATH:"C:/PROGRA~1/SIDEEF~1/HOUDIN~1.314/custom/houdini/dsolib" 134 | "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.314/custom/houdini/dsolib/*.a" 135 | "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.314/custom/houdini/dsolib/*.lib" 136 | 137 | 138 | 139 | 13.0.401 140 | -------- 141 | 142 | Compile 143 | ******* 144 | 145 | -nologo 146 | -TP 147 | -Zc:forScope 148 | -DVERSION="13.0.401" 149 | -DI386 150 | -DWIN32 151 | -DSWAP_BITFIELDS 152 | -D_WIN32_WINNT=0x0501 153 | -DWINVER=0x0501 154 | -DNOMINMAX 155 | -DSTRICT 156 | -DWIN32_LEAN_AND_MEAN 157 | -D_USE_MATH_DEFINES 158 | -D_CRT_SECURE_NO_DEPRECATE 159 | -D_CRT_NONSTDC_NO_DEPRECATE 160 | -D_SCL_SECURE_NO_WARNINGS 161 | -DBOOST_ALL_NO_LIB 162 | -DSESI_LITTLE_ENDIAN 163 | -DAMD64 164 | -DSIZEOF_VOID_P=8 165 | -DFBX_ENABLED=1 166 | -DOPENCL_ENABLED=1 167 | -DOPENVDB_ENABLED=1 168 | -I . 169 | -I "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.401/toolkit/include" 170 | -I "C:/PROGRA~2/MICROS~3.0/VC/include" 171 | -I "C:/Program Files (x86)/Windows Kits/8.0/Include/um" 172 | -I "C:/Program Files (x86)/Windows Kits/8.0/Include/shared" 173 | -wd4355 174 | -w14996 175 | -O2 176 | -DNDEBUG 177 | -MD 178 | -EHsc 179 | -GR 180 | -bigobj 181 | -DMAKING_DSO 182 | 183 | 184 | Link 185 | **** 186 | 187 | /machine:x64 188 | -LIBPATH:"C:/PROGRA~2/MICROS~3.0/VC/lib/amd64" 189 | -LIBPATH:"C:/Program Files(x86)/Windows Kits/8.0/Lib/win8/um/x64" 190 | -LIBPATH:"C:/PROGRA~1/SIDEEF~1/HOUDIN~1.401/custom/houdini/dsolib" 191 | "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.401/custom/houdini/dsolib/*.a" 192 | "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.401/custom/houdini/dsolib/*.lib" -------------------------------------------------------------------------------- /ocio_houdini/script/ocio_nodes.shelf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | operator:Cop2/OCIOColorspace 8 | 9 | 10 | COP2 11 | 12 | 13 | COP2 14 | 15 | 16 | Cop2/OCIOColorspace 17 | 18 | 19 | OpenColorIO 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | operator:Cop2/OCIOLogConvert 31 | 32 | 33 | COP2 34 | 35 | 36 | COP2 37 | 38 | 39 | Cop2/OCIOLogConvert 40 | 41 | 42 | OpenColorIO 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | operator:Cop2/OCIOFileTransform 54 | 55 | 56 | COP2 57 | 58 | 59 | COP2 60 | 61 | 62 | Cop2/OCIOFileTransform 63 | 64 | 65 | OpenColorIO 66 | 67 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | operator:Cop2/OCIOCDLTransform 77 | 78 | 79 | COP2 80 | 81 | 82 | COP2 83 | 84 | 85 | Cop2/OCIOCDLTransform 86 | 87 | 88 | OpenColorIO 89 | 90 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_cdl_transform.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_CDL_TRANSFORM_H 4 | #define OCIO_CDL_TRANSFORM_H 5 | 6 | //Ocio_cdl_transform Declaration 7 | //----------------------------------------------- 8 | 9 | /* 10 | Ocio_cdl_transform 11 | A COP2_MaskOp node that allows to grade pixel values according to the ACES standard. 12 | */ 13 | 14 | //Constants 15 | //----------------------------------------------- 16 | 17 | 18 | 19 | //include 20 | //----------------------------------------------- 21 | //Std 22 | #include 23 | #include 24 | #include 25 | #include 26 | //Boost 27 | #include "boost/format.hpp" 28 | #include "boost/lexical_cast.hpp" 29 | //Houdini 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | //Own 45 | #include "ocio_functionality.h" 46 | #include "ocio_types.h" 47 | 48 | 49 | 50 | 51 | 52 | //OCIO Namespace 53 | namespace OCIO = OCIO_NAMESPACE; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | //Ocio_cdl_transform 66 | //----------------------------------------------- 67 | class Ocio_cdl_transform : public COP2_MaskOp 68 | { 69 | public: 70 | 71 | //Attributes 72 | //----------------------------------------------- 73 | //----------------------------------------------- 74 | 75 | //Operator Creation 76 | //----------------------------------------------- 77 | static OP_TemplatePair template_pair; 78 | static OP_VariablePair variable_pair; 79 | static PRM_Template template_list[]; 80 | static CH_LocalVariable local_variable_list[]; 81 | static const char* input_labels_list[]; 82 | //OCIO_houdini_functionality 83 | //----------------------------------------------- 84 | OCIO_houdini_functionality OCIO_houdini_functionality; 85 | //OCIO 86 | //----------------------------------------------- 87 | OCIO::ConstProcessorRcPtr processor; 88 | //Misc 89 | //----------------------------------------------- 90 | bool first_execution; 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | //Methods 99 | //----------------------------------------------- 100 | //----------------------------------------------- 101 | 102 | //COP2 Static Defaults 103 | //----------------------------------------------- 104 | //Factory method 105 | static OP_Node* ocio_cdl_transform_factory(OP_Network*, 106 | const char *, 107 | OP_Operator *); 108 | 109 | //static filter called in cookFullImage 110 | static OP_ERROR filter_static(COP2_Context& context, 111 | const TIL_Region* input, 112 | TIL_Region* output, 113 | COP2_Node* node); 114 | 115 | //Set information on how to thread 116 | virtual void getMaxNumThreadsInCook(COP2_Context &, 117 | int &maxp, 118 | int &maxn, 119 | int &op) 120 | const 121 | { 122 | maxp = 1; maxn = op = TIL_MAX_THREADS; 123 | }; 124 | 125 | //Build dependencies tree for cooking operation (COP2 node specialty) 126 | virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo& output_area, 127 | const COP2_CookAreaList& input_areas, 128 | COP2_CookAreaList& needed_areas); 129 | 130 | //OCIO 131 | //----------------------------------------------- 132 | void set_processor(float*& ptr_slope, 133 | float*& ptr_offset, 134 | float*& ptr_power, 135 | float saturation, 136 | int direction); 137 | void set_processor(std::string, std::string, int, int); 138 | bool processor_exists(); 139 | std::string get_cc_xml(float*& ptr_slope, 140 | float*& ptr_offset, 141 | float*& ptr_power, 142 | float saturation, 143 | int direction); 144 | void write_to_file(std::string&, std::string&); 145 | static int export_grade(void *data, int, float, const PRM_Template*); 146 | 147 | 148 | 149 | //Getter & Setter 150 | //----------------------------------------------- 151 | int get_int_parameter(const char* parameter_name); 152 | bool get_bool_parameter(const char* parameter_name); 153 | float get_float_parameter(const char* parameter_name); 154 | std::string get_string_parameter(const char* parameter_name); 155 | void get_color_parameter(const char* parameter_name, float*&, int length = 3); 156 | 157 | void set_parameter(const char* parameter_name, std::string parameter_value); 158 | void set_parameter(const char* parameter_name, int parameter_value); 159 | void set_parameter(const char* parameter_name, float parameter_value); 160 | void set_parameter(const char* parameter_name, float* parameter_value, int length = 3); 161 | 162 | //Temp 163 | //----------------------------------------------- 164 | 165 | 166 | protected: 167 | 168 | 169 | //Methods 170 | //----------------------------------------------- 171 | //----------------------------------------------- 172 | 173 | //COP2 Defaults 174 | //----------------------------------------------- 175 | //Constructor 176 | Ocio_cdl_transform(OP_Network*, const char *, OP_Operator *); 177 | //Destructor 178 | virtual ~Ocio_cdl_transform(); 179 | 180 | //Aquire and stash context data (PRM information etc.) 181 | virtual COP2_ContextData* newContextData(const TIL_Plane* plane, 182 | int array_index, 183 | float time, 184 | int xres, 185 | int yres, 186 | int thread, 187 | int max_threads); 188 | 189 | //doCookMyTile - Classic cook method for COP2_Node. Must be reimplemented 190 | //to start cookFullImage, which is a convenience function to combine 191 | //all tiles and cook them 192 | virtual OP_ERROR doCookMyTile(COP2_Context&, TIL_TileList* ); 193 | 194 | //updateParmsFlags 195 | bool updateParmsFlags(); 196 | 197 | //disableParms 198 | unsigned disableParms(); 199 | 200 | //getOperationInfo 201 | virtual const char* getOperationInfo(); 202 | 203 | }; 204 | 205 | 206 | 207 | 208 | 209 | 210 | //Ocio_cdl_transform_context_data 211 | //----------------------------------------------- 212 | class Ocio_cdl_transform_context_data : public COP2_ContextData 213 | { 214 | public: 215 | //Attributes 216 | UT_Lock image_lock; 217 | std::string plane_name; 218 | int component_count; 219 | 220 | //Methods 221 | Ocio_cdl_transform_context_data() {} 222 | virtual ~Ocio_cdl_transform_context_data() {} 223 | 224 | }; 225 | 226 | 227 | #endif -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_colorspace.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_COLORSPACE_H 4 | #define OCIO_COLORSPACE_H 5 | 6 | //Ocio_colorspace Declaration 7 | //----------------------------------------------- 8 | 9 | /* 10 | Ocio_colorspace 11 | A COP2_MaskOp node that grades the incoming pixel array with OCIO. 12 | It is not multithreaded as i expect OCIO doing smart threading on the whole array. 13 | */ 14 | 15 | //Constants 16 | //----------------------------------------------- 17 | 18 | 19 | 20 | //include 21 | //----------------------------------------------- 22 | //Std 23 | #include 24 | #include 25 | #include 26 | #include 27 | //Boost 28 | #include "boost/format.hpp" 29 | #include "boost/lexical_cast.hpp" 30 | //Houdini 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | //Own 45 | #include "ocio_functionality.h" 46 | #include "ocio_types.h" 47 | 48 | 49 | 50 | 51 | 52 | //OCIO Namespace 53 | namespace OCIO = OCIO_NAMESPACE; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | //Ocio_colorspace 67 | //----------------------------------------------- 68 | class Ocio_colorspace : public COP2_MaskOp 69 | { 70 | public: 71 | 72 | //Attributes 73 | //----------------------------------------------- 74 | //----------------------------------------------- 75 | 76 | //Operator Creation 77 | //----------------------------------------------- 78 | static OP_TemplatePair template_pair; 79 | static OP_VariablePair variable_pair; 80 | static PRM_Template template_list[]; 81 | static CH_LocalVariable local_variable_list[]; 82 | static const char* input_labels_list[]; 83 | //OCIO_houdini_functionality 84 | //----------------------------------------------- 85 | OCIO_houdini_functionality OCIO_houdini_functionality; 86 | //OCIO 87 | //----------------------------------------------- 88 | OCIO::ConstConfigRcPtr config; 89 | OCIO::ConstProcessorRcPtr processor; 90 | std::vector vec_colorspace_names; 91 | //Misc 92 | //----------------------------------------------- 93 | bool first_execution; 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | //Methods 102 | //----------------------------------------------- 103 | //----------------------------------------------- 104 | 105 | //COP2 Static Defaults 106 | //----------------------------------------------- 107 | //Factory method 108 | static OP_Node* ocio_colorspace_factory(OP_Network*, 109 | const char *, 110 | OP_Operator *); 111 | 112 | //static filter called in cookFullImage 113 | static OP_ERROR filter_static(COP2_Context& context, 114 | const TIL_Region* input, 115 | TIL_Region* output, 116 | COP2_Node* node); 117 | 118 | //Set information on how to thread 119 | virtual void getMaxNumThreadsInCook(COP2_Context &, 120 | int &maxp, 121 | int &maxn, 122 | int &op) 123 | const 124 | { 125 | maxp = 1; maxn = op = TIL_MAX_THREADS; 126 | }; 127 | 128 | //Build dependencies tree for cooking operation (COP2 node specialty) 129 | virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo& output_area, 130 | const COP2_CookAreaList& input_areas, 131 | COP2_CookAreaList& needed_areas); 132 | 133 | //update_colorspace_menu 134 | static void update_colorspace_menu(void* data, 135 | PRM_Name *, 136 | int, 137 | const PRM_SpareData *, 138 | const PRM_Parm *); 139 | //Force refresh of colorspace menu 140 | void force_refresh_colorspace_menu(); 141 | 142 | //OCIO 143 | //----------------------------------------------- 144 | void set_config(int env_or_file = 0); 145 | bool config_exists(); 146 | void set_processor(); 147 | bool processor_exists(); 148 | void set_colorspace_names(); 149 | void print_config_info(); 150 | //States 151 | //----------------------------------------------- 152 | void node_created(); 153 | void env_or_file_changed(); 154 | void colorspace_changed(); 155 | void config_file_path_changed(); 156 | //Getter & Setter 157 | //----------------------------------------------- 158 | bool get_env_or_file(float time); 159 | void set_last_env_or_file(int new_value, float time); 160 | bool get_last_env_or_file(float time); 161 | std::string get_config_file_path(float time); 162 | void set_last_config_file_path(std::string new_value, float time); 163 | std::string get_last_config_file_path(float time); 164 | std::string get_colorspace(Colorspace_in_or_out colorspace_in_or_out = INPUT_COLORSPACE); 165 | int get_colorspace_index(Colorspace_in_or_out colorspace_in_or_out = INPUT_COLORSPACE); 166 | void set_colorspace_by_index(int new_colorspace_index, 167 | Colorspace_in_or_out colorspace_in_or_out = INPUT_COLORSPACE); 168 | int get_internal_colorspace_index(Colorspace_in_or_out colorspace_in_or_out = INPUT_COLORSPACE); 169 | void set_internal_colorspace_index(int new_internal_colorspace_index, 170 | Colorspace_in_or_out colorspace_in_or_out = INPUT_COLORSPACE); 171 | void set_config_info(); 172 | //Temp 173 | //----------------------------------------------- 174 | 175 | 176 | protected: 177 | 178 | 179 | //Methods 180 | //----------------------------------------------- 181 | //----------------------------------------------- 182 | 183 | //COP2 Defaults 184 | //----------------------------------------------- 185 | //Constructor 186 | Ocio_colorspace(OP_Network*, const char *, OP_Operator *); 187 | //Destructor 188 | virtual ~Ocio_colorspace(); 189 | 190 | //Aquire and stash context data (PRM information etc.) 191 | virtual COP2_ContextData* newContextData(const TIL_Plane* plane, 192 | int array_index, 193 | float time, 194 | int xres, 195 | int yres, 196 | int thread, 197 | int max_threads); 198 | 199 | //doCookMyTile - Classic cook method for COP2_Node. Must be reimplemented 200 | //to start cookFullImage, which is a convenience function to combine 201 | //all tiles and cook them 202 | virtual OP_ERROR doCookMyTile(COP2_Context&, TIL_TileList* ); 203 | 204 | //updateParmsFlags 205 | bool updateParmsFlags(); 206 | 207 | //disableParms 208 | unsigned disableParms(); 209 | 210 | //Set image bounds for operation 211 | /*virtual void computeImageBounds(COP2_Context&);*/ 212 | 213 | //getOperationInfo 214 | virtual const char* getOperationInfo(); 215 | 216 | }; 217 | 218 | 219 | 220 | 221 | 222 | 223 | //Ocio_colorspace_context_data 224 | //----------------------------------------------- 225 | class Ocio_colorspace_context_data : public COP2_ContextData 226 | { 227 | public: 228 | //Attributes 229 | UT_Lock image_lock; 230 | std::string plane_name; 231 | int component_count; 232 | 233 | 234 | //Methods 235 | Ocio_colorspace_context_data() {} 236 | virtual ~Ocio_colorspace_context_data() {} 237 | 238 | 239 | }; 240 | 241 | 242 | #endif -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_file_transform.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_FILE_TRANSFORM_H 4 | #define OCIO_FILE_TRANSFORM_H 5 | 6 | //Ocio_file_transform Declaration 7 | //----------------------------------------------- 8 | 9 | /* 10 | Ocio_file_transform 11 | A COP2_MaskOp node that allows to load a lut file and processes the incoming pixel 12 | according to that file. 13 | */ 14 | 15 | //Constants 16 | //----------------------------------------------- 17 | 18 | 19 | 20 | //include 21 | //----------------------------------------------- 22 | //Std 23 | #include 24 | #include 25 | #include 26 | #include 27 | //Boost 28 | #include "boost/format.hpp" 29 | #include "boost/lexical_cast.hpp" 30 | //Houdini 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | //Own 45 | #include "ocio_functionality.h" 46 | #include "ocio_types.h" 47 | 48 | 49 | 50 | 51 | 52 | //OCIO Namespace 53 | namespace OCIO = OCIO_NAMESPACE; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | //Ocio_file_transform 66 | //----------------------------------------------- 67 | class Ocio_file_transform : public COP2_MaskOp 68 | { 69 | public: 70 | 71 | //Attributes 72 | //----------------------------------------------- 73 | //----------------------------------------------- 74 | 75 | //Operator Creation 76 | //----------------------------------------------- 77 | static OP_TemplatePair template_pair; 78 | static OP_VariablePair variable_pair; 79 | static PRM_Template template_list[]; 80 | static CH_LocalVariable local_variable_list[]; 81 | static const char* input_labels_list[]; 82 | //OCIO_houdini_functionality 83 | //----------------------------------------------- 84 | OCIO_houdini_functionality OCIO_houdini_functionality; 85 | //OCIO 86 | //----------------------------------------------- 87 | OCIO::ConstProcessorRcPtr processor; 88 | //Misc 89 | //----------------------------------------------- 90 | bool first_execution; 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | //Methods 100 | //----------------------------------------------- 101 | //----------------------------------------------- 102 | 103 | //COP2 Static Defaults 104 | //----------------------------------------------- 105 | //Factory method 106 | static OP_Node* ocio_file_transform_factory(OP_Network*, 107 | const char *, 108 | OP_Operator *); 109 | 110 | //static filter called in cookFullImage 111 | static OP_ERROR filter_static(COP2_Context& context, 112 | const TIL_Region* input, 113 | TIL_Region* output, 114 | COP2_Node* node); 115 | 116 | //Set information on how to thread 117 | virtual void getMaxNumThreadsInCook(COP2_Context &, 118 | int &maxp, 119 | int &maxn, 120 | int &op) 121 | const 122 | { 123 | maxp = 1; maxn = op = TIL_MAX_THREADS; 124 | }; 125 | 126 | //Build dependencies tree for cooking operation (COP2 node specialty) 127 | virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo& output_area, 128 | const COP2_CookAreaList& input_areas, 129 | COP2_CookAreaList& needed_areas); 130 | 131 | //OCIO 132 | //----------------------------------------------- 133 | void set_processor(std::string, std::string, int, int); 134 | bool processor_exists(); 135 | 136 | 137 | 138 | //Getter & Setter 139 | //----------------------------------------------- 140 | int get_int_parameter(const char* parameter_name); 141 | bool get_bool_parameter(const char* parameter_name); 142 | float get_float_parameter(const char* parameter_name); 143 | std::string get_string_parameter(const char* parameter_name); 144 | 145 | void set_parameter(const char* parameter_name, std::string parameter_value); 146 | void set_parameter(const char* parameter_name, int parameter_value); 147 | void set_parameter(const char* parameter_name, float parameter_value); 148 | 149 | //Temp 150 | //----------------------------------------------- 151 | 152 | 153 | protected: 154 | 155 | 156 | //Methods 157 | //----------------------------------------------- 158 | //----------------------------------------------- 159 | 160 | //COP2 Defaults 161 | //----------------------------------------------- 162 | //Constructor 163 | Ocio_file_transform(OP_Network*, const char *, OP_Operator *); 164 | //Destructor 165 | virtual ~Ocio_file_transform(); 166 | 167 | //Aquire and stash context data (PRM information etc.) 168 | virtual COP2_ContextData* newContextData(const TIL_Plane* plane, 169 | int array_index, 170 | float time, 171 | int xres, 172 | int yres, 173 | int thread, 174 | int max_threads); 175 | 176 | //doCookMyTile - Classic cook method for COP2_Node. Must be reimplemented 177 | //to start cookFullImage, which is a convenience function to combine 178 | //all tiles and cook them 179 | virtual OP_ERROR doCookMyTile(COP2_Context&, TIL_TileList* ); 180 | 181 | //updateParmsFlags 182 | bool updateParmsFlags(); 183 | 184 | //disableParms 185 | unsigned disableParms(); 186 | 187 | //getOperationInfo 188 | virtual const char* getOperationInfo(); 189 | 190 | }; 191 | 192 | 193 | 194 | 195 | 196 | 197 | //Ocio_file_transform_context_data 198 | //----------------------------------------------- 199 | class Ocio_file_transform_context_data : public COP2_ContextData 200 | { 201 | public: 202 | //Attributes 203 | UT_Lock image_lock; 204 | std::string plane_name; 205 | int component_count; 206 | 207 | 208 | //Methods 209 | Ocio_file_transform_context_data() {} 210 | virtual ~Ocio_file_transform_context_data() {} 211 | 212 | 213 | }; 214 | 215 | 216 | #endif -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_log_convert.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_LOG_CONVERT_H 4 | #define OCIO_LOG_CONVERT_H 5 | 6 | //Ocio_log_convert Declaration 7 | //----------------------------------------------- 8 | 9 | /* 10 | Ocio_log_convert 11 | A COP2_MaskOp node that converts from lin to log or the other way round. 12 | */ 13 | 14 | //Constants 15 | //----------------------------------------------- 16 | 17 | 18 | 19 | //include 20 | //----------------------------------------------- 21 | //Std 22 | #include 23 | #include 24 | #include 25 | #include 26 | //Boost 27 | #include "boost/format.hpp" 28 | #include "boost/lexical_cast.hpp" 29 | //Houdini 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | //Own 44 | #include "ocio_functionality.h" 45 | #include "ocio_types.h" 46 | 47 | 48 | 49 | 50 | 51 | //OCIO Namespace 52 | namespace OCIO = OCIO_NAMESPACE; 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | //Ocio_log_convert 65 | //----------------------------------------------- 66 | class Ocio_log_convert : public COP2_MaskOp 67 | { 68 | public: 69 | 70 | //Attributes 71 | //----------------------------------------------- 72 | //----------------------------------------------- 73 | 74 | //Operator Creation 75 | //----------------------------------------------- 76 | static OP_TemplatePair template_pair; 77 | static OP_VariablePair variable_pair; 78 | static PRM_Template template_list[]; 79 | static CH_LocalVariable local_variable_list[]; 80 | static const char* input_labels_list[]; 81 | //OCIO_houdini_functionality 82 | //----------------------------------------------- 83 | OCIO_houdini_functionality OCIO_houdini_functionality; 84 | //OCIO 85 | //----------------------------------------------- 86 | OCIO::ConstConfigRcPtr config; 87 | OCIO::ConstProcessorRcPtr processor; 88 | //Misc 89 | //----------------------------------------------- 90 | bool first_execution; 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | //Methods 99 | //----------------------------------------------- 100 | //----------------------------------------------- 101 | 102 | //COP2 Static Defaults 103 | //----------------------------------------------- 104 | //Factory method 105 | static OP_Node* ocio_log_convert_factory(OP_Network*, 106 | const char *, 107 | OP_Operator *); 108 | 109 | //static filter called in cookFullImage 110 | static OP_ERROR filter_static(COP2_Context& context, 111 | const TIL_Region* input, 112 | TIL_Region* output, 113 | COP2_Node* node); 114 | 115 | //Set information on how to thread 116 | virtual void getMaxNumThreadsInCook(COP2_Context &, 117 | int &maxp, 118 | int &maxn, 119 | int &op) 120 | const 121 | { 122 | maxp = 1; maxn = op = TIL_MAX_THREADS; 123 | }; 124 | 125 | //Build dependencies tree for cooking operation (COP2 node specialty) 126 | virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo& output_area, 127 | const COP2_CookAreaList& input_areas, 128 | COP2_CookAreaList& needed_areas); 129 | 130 | //OCIO 131 | //----------------------------------------------- 132 | void set_config(int env_or_file = 0); 133 | bool config_exists(); 134 | void set_processor(int, std::string, int); 135 | bool processor_exists(); 136 | 137 | //Getter & Setter 138 | //----------------------------------------------- 139 | bool get_env_or_file(float time); 140 | 141 | void set_last_env_or_file(int new_value, float time); 142 | bool get_last_env_or_file(float time); 143 | 144 | std::string get_config_file_path(float time); 145 | 146 | void set_last_config_file_path(std::string new_value, float time); 147 | std::string get_last_config_file_path(float time); 148 | 149 | int get_operation(float time); 150 | 151 | int get_internal_operation_index(float time); 152 | void set_internal_operation_index(int new_internal_operation_index, float time); 153 | 154 | void set_config_info(); 155 | //Temp 156 | //----------------------------------------------- 157 | 158 | 159 | protected: 160 | 161 | 162 | //Methods 163 | //----------------------------------------------- 164 | //----------------------------------------------- 165 | 166 | //COP2 Defaults 167 | //----------------------------------------------- 168 | //Constructor 169 | Ocio_log_convert(OP_Network*, const char *, OP_Operator *); 170 | //Destructor 171 | virtual ~Ocio_log_convert(); 172 | 173 | //Aquire and stash context data (PRM information etc.) 174 | virtual COP2_ContextData* newContextData(const TIL_Plane* plane, 175 | int array_index, 176 | float time, 177 | int xres, 178 | int yres, 179 | int thread, 180 | int max_threads); 181 | 182 | //doCookMyTile - Classic cook method for COP2_Node. Must be reimplemented 183 | //to start cookFullImage, which is a convenience function to combine 184 | //all tiles and cook them 185 | virtual OP_ERROR doCookMyTile(COP2_Context&, TIL_TileList* ); 186 | 187 | //updateParmsFlags 188 | bool updateParmsFlags(); 189 | 190 | //disableParms 191 | unsigned disableParms(); 192 | 193 | //getOperationInfo 194 | virtual const char* getOperationInfo(); 195 | 196 | }; 197 | 198 | 199 | 200 | 201 | 202 | 203 | //Ocio_log_convert_context_data 204 | //----------------------------------------------- 205 | class Ocio_log_convert_context_data : public COP2_ContextData 206 | { 207 | public: 208 | //Attributes 209 | UT_Lock image_lock; 210 | std::string plane_name; 211 | int component_count; 212 | 213 | 214 | //Methods 215 | Ocio_log_convert_context_data() {} 216 | virtual ~Ocio_log_convert_context_data() {} 217 | 218 | 219 | }; 220 | 221 | 222 | #endif -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_plugin.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //ocio_houdini plugin registration 5 | //----------------------------------------------- 6 | 7 | 8 | 9 | //Constants 10 | //----------------------------------------------- 11 | 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | //Houdini 17 | #include 18 | #include 19 | #include 20 | //Own 21 | #include "ocio_colorspace.h" 22 | #include "ocio_log_convert.h" 23 | #include "ocio_file_transform.h" 24 | #include "ocio_cdl_transform.h" 25 | 26 | 27 | 28 | 29 | 30 | //Registration 31 | //----------------------------------------------- 32 | //----------------------------------------------- 33 | 34 | void newCop2Operator(OP_OperatorTable *table) 35 | { 36 | 37 | //OCIOColorspace 38 | table->addOperator(new OP_Operator("OCIOColorspace", 39 | "OCIOColorspace", 40 | Ocio_colorspace::ocio_colorspace_factory, 41 | &Ocio_colorspace::template_pair, 42 | 1, 43 | 2, // optional mask input. 44 | &Ocio_colorspace::variable_pair, 45 | 0, // not generator 46 | Ocio_colorspace::input_labels_list)); 47 | 48 | //OCIOLogConvert 49 | table->addOperator(new OP_Operator("OCIOLogConvert", 50 | "OCIOLogConvert", 51 | Ocio_log_convert::ocio_log_convert_factory, 52 | &Ocio_log_convert::template_pair, 53 | 1, 54 | 2, // optional mask input. 55 | &Ocio_log_convert::variable_pair, 56 | 0, // not generator 57 | Ocio_log_convert::input_labels_list)); 58 | 59 | //OCIOFileTransform 60 | table->addOperator(new OP_Operator("OCIOFileTransform", 61 | "OCIOFileTransform", 62 | Ocio_file_transform::ocio_file_transform_factory, 63 | &Ocio_file_transform::template_pair, 64 | 1, 65 | 2, // optional mask input. 66 | &Ocio_file_transform::variable_pair, 67 | 0, // not generator 68 | Ocio_file_transform::input_labels_list)); 69 | 70 | //OCIOCDLTransform 71 | table->addOperator(new OP_Operator("OCIOCDLTransform", 72 | "OCIOCDLTransform", 73 | Ocio_cdl_transform::ocio_cdl_transform_factory, 74 | &Ocio_cdl_transform::template_pair, 75 | 1, 76 | 2, // optional mask input. 77 | &Ocio_cdl_transform::variable_pair, 78 | 0, // not generator 79 | Ocio_cdl_transform::input_labels_list)); 80 | 81 | }; -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_types Definition 4 | //----------------------------------------------- 5 | 6 | /* 7 | Ocio_types 8 | Definitions for OCIO_Houdini wide constants and types. 9 | */ 10 | 11 | 12 | 13 | 14 | 15 | 16 | //include 17 | //----------------------------------------------- 18 | 19 | //Own 20 | #include "ocio_types.h" 21 | 22 | 23 | 24 | 25 | 26 | //Constants 27 | //----------------------------------------------- 28 | //----------------------------------------------- 29 | 30 | 31 | namespace ocio_houdini_constants 32 | { 33 | //LOG_MESSAGES 34 | bool LOG_MESSAGES = false; 35 | //INTERNAL_PARMS_VISIBLE 36 | bool INTERNAL_PARMS_VISIBLE = false; 37 | //ENABLE_SCOPERGBA 38 | bool ENABLE_SCOPERGBA = false; 39 | 40 | //OCIOCOLORSPACE_OPERATION_INFO 41 | const char* OCIOCOLORSPACE_OPERATION_INFO = "This operator loads an ocio config file either from\ 42 | \nan $OCIO env. variable or a custom path.\ 43 | \nYou can then apply all LUTs and transformations\ 44 | \nthat are described in that config. If no config is\ 45 | \ngiven, the operation will result in a noOp."; 46 | //OCIOLOGCONVERT_OPERATION_INFO 47 | const char* OCIOLOGCONVERT_OPERATION_INFO = "This operator converts from linear to log or log to linear."; 48 | //OCIOFILETRANSFORM_OPERATION_INFO 49 | const char* OCIOFILETRANSFORM_OPERATION_INFO = "This operator loads a LUT file and applies its transformation."; 50 | //OCIOCDLTRANSFORM_OPERATION_INFO 51 | const char* OCIOCDLTRANSFORM_OPERATION_INFO = "This operator grades the incoming pixels according\ 52 | \nto the ACES standard. Alternatively you can load\ 53 | \na .cc grade file or export such a file from your\ 54 | \ncurrent SOP (slope, offset, power) settings."; 55 | }; 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | //Types 64 | //----------------------------------------------- 65 | //----------------------------------------------- 66 | 67 | 68 | 69 | //OCIO_houdini_functionality 70 | //----------------------------------------------- 71 | 72 | 73 | 74 | //Constructor / Destructor 75 | //----------------------------------------------- 76 | 77 | //OCIO_houdini_functionality 78 | OCIO_houdini_functionality::OCIO_houdini_functionality(){}; 79 | 80 | //~OCIO_houdini_functionality 81 | OCIO_houdini_functionality::~OCIO_houdini_functionality(){}; 82 | 83 | 84 | 85 | 86 | //Color transformation 87 | //----------------------------------------------- 88 | 89 | 90 | //filter 91 | void OCIO_houdini_functionality::filter(COP2_Context& context, 92 | const TIL_Region* input, 93 | TIL_Region* output, 94 | OCIO::ConstProcessorRcPtr& processor) 95 | { 96 | 97 | //log 98 | log("filter from ocio_types"); 99 | 100 | //Pixel operation to perform is implemented here 101 | 102 | //context_data 103 | //Custom built in newContextData() 104 | //Here live custom attributes stashed within single threaded method newContextData() 105 | 106 | //Convert context like so if needed 107 | //Ocio_cdl_transform_context_data* context_data = (Ocio_cdl_transform_context_data *)context.data(); 108 | 109 | 110 | //is_rgb_available 111 | bool is_rgb_available = rgb_available(context, input, output); 112 | 113 | 114 | //rgb available 115 | if (is_rgb_available) 116 | filter_ocio(context, input, output, processor); 117 | //rgb not available 118 | else 119 | filter_no_ocio(context, input, output); 120 | 121 | }; 122 | 123 | //rgb_available 124 | bool OCIO_houdini_functionality::rgb_available(COP2_Context& context, 125 | const TIL_Region* input, 126 | TIL_Region* output) 127 | { 128 | //is_rgb_available 129 | bool is_rgb_available = false; 130 | 131 | //ptr_input_data_red 132 | float* ptr_input_data_red = (float*)input->getImageData("r"); 133 | //ptr_input_data_green 134 | float* ptr_input_data_green = (float*)input->getImageData("g"); 135 | //ptr_input_data_blue 136 | float* ptr_input_data_blue = (float*)input->getImageData("b"); 137 | 138 | //ptr_output_data_red 139 | float* ptr_output_data_red = (float*)output->getImageData("r"); 140 | //ptr_output_data_green 141 | float* ptr_output_data_green = (float*)output->getImageData("g"); 142 | //ptr_output_data_blue 143 | float* ptr_output_data_blue = (float*)output->getImageData("b"); 144 | 145 | //check 146 | if (ptr_input_data_red && ptr_input_data_green && ptr_input_data_blue && ptr_output_data_red && ptr_output_data_green && ptr_output_data_blue) 147 | is_rgb_available = true; 148 | 149 | //log 150 | if (is_rgb_available) 151 | log("RGB is available"); 152 | else 153 | log("RGB is not available"); 154 | 155 | //return 156 | return is_rgb_available; 157 | }; 158 | 159 | //filter_ocio 160 | void OCIO_houdini_functionality::filter_ocio(COP2_Context& context, 161 | const TIL_Region* input, 162 | TIL_Region* output, 163 | OCIO::ConstProcessorRcPtr& processor) 164 | { 165 | 166 | //ptr_input_data_red 167 | float* ptr_input_data_red = (float*)input->getImageData("r"); 168 | //ptr_input_data_green 169 | float* ptr_input_data_green = (float*)input->getImageData("g"); 170 | //ptr_input_data_blue 171 | float* ptr_input_data_blue = (float*)input->getImageData("b"); 172 | 173 | //ptr_output_data_red 174 | float* ptr_output_data_red = (float*)output->getImageData("r"); 175 | //ptr_output_data_green 176 | float* ptr_output_data_green = (float*)output->getImageData("g"); 177 | //ptr_output_data_blue 178 | float* ptr_output_data_blue = (float*)output->getImageData("b"); 179 | 180 | 181 | //copy input to output for rgb 182 | std::memcpy(ptr_output_data_red, ptr_input_data_red, context.myXsize*context.myYsize * sizeof(float)); 183 | std::memcpy(ptr_output_data_green, ptr_input_data_green, context.myXsize*context.myYsize * sizeof(float)); 184 | std::memcpy(ptr_output_data_blue, ptr_input_data_blue, context.myXsize*context.myYsize * sizeof(float)); 185 | 186 | 187 | //if processor exists do colorspace conversion 188 | if (processor) 189 | //color transform 190 | OCIO_functionality::color_transform_rgb_array(ptr_output_data_red, 191 | ptr_output_data_green, 192 | ptr_output_data_blue, 193 | processor, 194 | context.myXsize, 195 | context.myYsize); 196 | //temp 197 | else 198 | log("From filter: Processor does not exist"); 199 | }; 200 | 201 | //filter_no_ocio 202 | void OCIO_houdini_functionality::filter_no_ocio(COP2_Context& context, 203 | const TIL_Region* input, 204 | TIL_Region* output) 205 | { 206 | 207 | //iterate components (rgba) and copy if existent 208 | for (int component_index = 0; component_index < PLANE_MAX_VECTOR_SIZE; component_index++) 209 | { 210 | //Get image data for component of input region and output region 211 | //(think of planes) 212 | float* input_data_ptr = (float*)input->getImageData(component_index); 213 | float* output_data_ptr = (float*)output->getImageData(component_index); 214 | 215 | //if ptrs are not null 216 | if (input_data_ptr && output_data_ptr) 217 | { 218 | //copy input to output 219 | std::memcpy(output_data_ptr, input_data_ptr, context.myXsize*context.myYsize * sizeof(float)); 220 | }; 221 | 222 | }; 223 | 224 | }; 225 | 226 | 227 | 228 | 229 | //Misc 230 | //----------------------------------------------- 231 | 232 | //log 233 | void OCIO_houdini_functionality::log(const char* msg) 234 | { 235 | //log message if log_messages == true 236 | if (ocio_houdini_constants::LOG_MESSAGES) 237 | std::cout << msg << std::endl; 238 | } 239 | 240 | //get_time 241 | float OCIO_houdini_functionality::get_time() 242 | { 243 | //ch_manager 244 | CH_Manager* ch_manager = OPgetDirector()->getChannelManager(); 245 | //fpreal_current_time 246 | fpreal fpreal_current_time = ch_manager->getEvaluateTime(); 247 | //float_current_Time 248 | float float_current_time = (float)fpreal_current_time; 249 | 250 | return float_current_time; 251 | } 252 | 253 | //colors_equal 254 | bool OCIO_houdini_functionality::colors_equal(float*& color_a, float*& color_b, int length) 255 | { 256 | //colors_equal 257 | bool colors_equal = true; 258 | 259 | //iterate and compare 260 | for (int index = 0; index < length; index++) 261 | { 262 | if (color_a[index] != color_b[index]) 263 | colors_equal = false; 264 | } 265 | 266 | return colors_equal; 267 | 268 | }; -------------------------------------------------------------------------------- /ocio_houdini/source/ocio_types.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_TYPES_H 4 | #define OCIO_TYPES_H 5 | 6 | //Ocio_types Definition 7 | //----------------------------------------------- 8 | 9 | /* 10 | Ocio_types 11 | Header that defines custom types (enums and constants) to be used with 12 | ocio houdini. 13 | */ 14 | 15 | 16 | 17 | 18 | 19 | 20 | //include 21 | //----------------------------------------------- 22 | //Std 23 | #include 24 | #include 25 | #include 26 | #include 27 | //Boost 28 | #include "boost/format.hpp" 29 | #include "boost/lexical_cast.hpp" 30 | //Houdini 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | //Own 45 | #include "ocio_functionality.h" 46 | 47 | 48 | 49 | //OCIO Namespace 50 | namespace OCIO = OCIO_NAMESPACE; 51 | 52 | 53 | 54 | 55 | 56 | 57 | //Constants 58 | //----------------------------------------------- 59 | //----------------------------------------------- 60 | 61 | 62 | namespace ocio_houdini_constants 63 | { 64 | //LOG_MESSAGES 65 | extern bool LOG_MESSAGES; 66 | //INTERNAL_PARMS_VISIBLE 67 | extern bool INTERNAL_PARMS_VISIBLE; 68 | //ENABLE_SCOPERGBA 69 | extern bool ENABLE_SCOPERGBA; 70 | 71 | //OCIOCOLORSPACE_OPERATION_INFO 72 | extern const char* OCIOCOLORSPACE_OPERATION_INFO; 73 | //OCIOLOGCONVERT_OPERATION_INFO 74 | extern const char* OCIOLOGCONVERT_OPERATION_INFO; 75 | //OCIOFILETRANSFORM_OPERATION_INFO 76 | extern const char* OCIOFILETRANSFORM_OPERATION_INFO; 77 | //OCIOCDLTRANSFORM_OPERATION_INFO 78 | extern const char* OCIOCDLTRANSFORM_OPERATION_INFO; 79 | }; 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | //Types 88 | //----------------------------------------------- 89 | //----------------------------------------------- 90 | 91 | 92 | //Colorspace_in_or_out 93 | //----------------------------------------------- 94 | 95 | enum Colorspace_in_or_out 96 | { 97 | INPUT_COLORSPACE, 98 | OUTPUT_COLORSPACE 99 | }; 100 | 101 | 102 | 103 | 104 | //OCIO_houdini_functionality 105 | //----------------------------------------------- 106 | 107 | class OCIO_houdini_functionality 108 | { 109 | public: 110 | 111 | //Constructor / Destructor 112 | //----------------------------------------------- 113 | 114 | OCIO_houdini_functionality(); 115 | ~OCIO_houdini_functionality(); 116 | 117 | 118 | //Color transformation 119 | //----------------------------------------------- 120 | 121 | //non-static filter called in each static filter 122 | void filter(COP2_Context& context, 123 | const TIL_Region* input, 124 | TIL_Region* output, 125 | OCIO::ConstProcessorRcPtr& processor); 126 | 127 | //rgb_available 128 | bool rgb_available(COP2_Context& context, 129 | const TIL_Region* input, 130 | TIL_Region* output); 131 | 132 | //filter_ocio 133 | void filter_ocio(COP2_Context& context, 134 | const TIL_Region* input, 135 | TIL_Region* output, 136 | OCIO::ConstProcessorRcPtr& processor); 137 | 138 | //filter_no_ocio 139 | void filter_no_ocio(COP2_Context& context, 140 | const TIL_Region* input, 141 | TIL_Region* output); 142 | 143 | //Misc 144 | //----------------------------------------------- 145 | void log(const char*); 146 | float get_time(); 147 | bool colors_equal(float*&, float*&, int length = 3); 148 | 149 | 150 | private: 151 | 152 | }; 153 | 154 | 155 | 156 | #endif -------------------------------------------------------------------------------- /ocio_maya/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | cmake_minimum_required(VERSION 2.8.8) 4 | 5 | #solution 6 | #--------------------------------------- 7 | project(ocio_maya) 8 | 9 | 10 | 11 | 12 | 13 | #CMake settings 14 | #--------------------------------------- 15 | 16 | #Build Type 17 | IF (NOT CMAKE_BUILD_TYPE) 18 | SET(CMAKE_BUILD_TYPE Release) 19 | ENDIF (NOT CMAKE_BUILD_TYPE) 20 | 21 | #Generator toolset (which visual studio version is used for compilation. Standard is: IDE Editing: VS2013 Compilation: VS2010) 22 | if(MSVC OR MSVC_IDE) 23 | set(CMAKE_GENERATOR_TOOLSET "v100" CACHE STRING "Platform Toolset" FORCE) 24 | endif() 25 | 26 | #CMAKE Variables 27 | #maya 28 | set(MAYA_DIR "C:/symlinks/maya/maya2014x64" CACHE PATH "Path to Maya install. For example: C:/Program Files/Autodesk/Maya2014") 29 | #ocio 30 | set(OCIO_INCLUDE_DIR "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO/export" CACHE PATH "OCIO default include path. Must contain the files: OpenColorIO.h, OpenColorTransforms.h and OpenColorTypes.h") 31 | set(OCIO_ABI_INCLUDE_DIR "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO_build/msvc10/x64/export" CACHE PATH "OCIO ABI header include path. This header is built by cmake and therefore can be found in the build directory. Must contain the file: OpenColorABI.h") 32 | set(OCIO_LIBRARY_DIR_DEBUG "C:/symlinks/libraries/OpenColorIO/x64/msvc10/static/debug/OpenColorIO.lib" CACHE FILEPATH "OCIO library to link against") 33 | set(OCIO_LIBRARY_DIR_RELEASE "C:/symlinks/libraries/OpenColorIO/x64/msvc10/static/release/OpenColorIO.lib" CACHE FILEPATH "OCIO library to link against") 34 | #boost 35 | set(BOOST_ROOT "C:/symlinks/boost/boost_1_54_0" CACHE PATH "Boost Root, for example: C:/boost_1_54_0") 36 | set(BOOST_INCLUDEDIR "C:/symlinks/boost/boost_1_54_0/boost" CACHE PATH "Boost include dir, for example: C:/boost_1_54_0/boost") 37 | set(BOOST_LIBRARYDIR "C:/symlinks/boost/boost_1_54_0/stage/x64/msvc10/python26/lib" CACHE PATH "Boost library dir, for example: C:/boost_1_54_0/stage/x64/msvc10/python26/lib") 38 | #custom 39 | set(ADDITIONAL_SOURCE_DIR_1 "C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_functionality/source" CACHE PATH "Additional include directories. Will be scanned for .h and .cpp files") 40 | set(ADDITIONAL_SOURCE_DIR_2 "" CACHE PATH "Additional include directories. Will be scanned for .h and .cpp files") 41 | set(OCIO_FUNCTIONALITY_INCLUDE_DIR "C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_functionality/source" CACHE FILEPATH "Additional include directory") 42 | 43 | 44 | #Find packages 45 | #------------------------------------------------------------- 46 | set(Boost_USE_STATIC_LIBS ON) 47 | find_package(Boost REQUIRED) 48 | 49 | 50 | 51 | 52 | 53 | #Headers 54 | #--------------------------------------- 55 | file(GLOB HEADERS 56 | ${CMAKE_CURRENT_SOURCE_DIR}/source/*.h 57 | ${ADDITIONAL_SOURCE_DIR_1}/*.h 58 | ${ADDITIONAL_SOURCE_DIR_2}/*.h 59 | ) 60 | 61 | 62 | #Source files 63 | #--------------------------------------- 64 | file (GLOB SOURCES 65 | ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp 66 | ${ADDITIONAL_SOURCE_DIR_1}/*.cpp 67 | ${ADDITIONAL_SOURCE_DIR_2}/*.cpp 68 | ) 69 | 70 | 71 | 72 | 73 | #Filters 74 | #--------------------------------------- 75 | source_group(headers FILES ${HEADERS}) 76 | source_group(sources FILES ${SOURCES}) 77 | 78 | 79 | 80 | 81 | 82 | #Add library 83 | #--------------------------------------- 84 | 85 | #project 86 | add_library(ocio_maya SHARED ${SOURCES} ${HEADERS}) 87 | #set suffix to .mll 88 | SET_TARGET_PROPERTIES(ocio_maya PROPERTIES SUFFIX .mll) 89 | #preprocessor definitions 90 | add_definitions(-DWIN32 -DNDEBUG -D_WINDOWS -DNT_PLUGIN -DREQUIRE_IOSTREAM) 91 | 92 | #include directories 93 | include_directories( 94 | ${OCIO_INCLUDE_DIR} 95 | ${OCIO_ABI_INCLUDE_DIR} 96 | "${MAYA_DIR}/include" 97 | ${OCIO_FUNCTIONALITY_INCLUDE_DIR} 98 | ${Boost_INCLUDE_DIR} 99 | ) 100 | 101 | #target link libraries debug 102 | target_link_libraries(ocio_maya debug 103 | #Maya 104 | ${OCIO_LIBRARY_DIR_DEBUG} 105 | "${MAYA_DIR}/lib/Foundation.lib" 106 | "${MAYA_DIR}/lib/OpenMaya.lib" 107 | "${MAYA_DIR}/lib/OpenMayaUI.lib" 108 | "${MAYA_DIR}/lib/OpenMayaAnim.lib" 109 | "${MAYA_DIR}/lib/OpenMayaFX.lib" 110 | "${MAYA_DIR}/lib/OpenMayaRender.lib" 111 | "${MAYA_DIR}/lib/Image.lib" 112 | #OpenGL 113 | opengl32.lib 114 | glu32.lib 115 | ) 116 | 117 | #target link libraries release 118 | target_link_libraries(ocio_maya optimized 119 | #Maya 120 | ${OCIO_LIBRARY_DIR_RELEASE} 121 | "${MAYA_DIR}/lib/Foundation.lib" 122 | "${MAYA_DIR}/lib/OpenMaya.lib" 123 | "${MAYA_DIR}/lib/OpenMayaUI.lib" 124 | "${MAYA_DIR}/lib/OpenMayaAnim.lib" 125 | "${MAYA_DIR}/lib/OpenMayaFX.lib" 126 | "${MAYA_DIR}/lib/OpenMayaRender.lib" 127 | "${MAYA_DIR}/lib/Image.lib" 128 | #OpenGL 129 | opengl32.lib 130 | glu32.lib 131 | ) -------------------------------------------------------------------------------- /ocio_maya/script/AEOCIOCDLTransformTemplate.mel: -------------------------------------------------------------------------------- 1 | 2 | //AEOCIOCDLTransformTemplate 3 | global proc AEOCIOCDLTransformTemplate( string $nodeName ) { 4 | 5 | //Vars 6 | //----------------------------------------- 7 | //----------------------------------------- 8 | string $node[]; 9 | tokenize $nodeName "." $node; 10 | 11 | 12 | 13 | 14 | 15 | 16 | //Header image 17 | //----------------------------------------- 18 | //----------------------------------------- 19 | 20 | //create header image 21 | editorTemplate -callCustom "ocio_cdl_transform_create_header_image" "ocio_cdl_transform_update_header_image" "Dummy"; 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | //scroll layout 33 | editorTemplate -beginScrollLayout; 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | //Begin Layout Input Color 46 | //----------------------------------------- 47 | //----------------------------------------- 48 | editorTemplate -beginLayout "Input Color" -collapse 0; 49 | 50 | //input_color 51 | editorTemplate -addControl "input_color"; 52 | 53 | //End Layout Input Color 54 | editorTemplate -endLayout; 55 | 56 | 57 | 58 | 59 | 60 | 61 | //Begin Layout OCIO 62 | //----------------------------------------- 63 | //----------------------------------------- 64 | editorTemplate -beginLayout "OCIO" -collapse 0; 65 | 66 | //verbose 67 | //editorTemplate -addControl "verbose"; 68 | 69 | //Separator 70 | //editorTemplate -addSeparator; 71 | 72 | 73 | 74 | 75 | 76 | 77 | //slope 78 | editorTemplate -addControl "slope"; 79 | 80 | //offset 81 | editorTemplate -addControl "offset"; 82 | 83 | //power 84 | editorTemplate -addControl "power"; 85 | 86 | //saturation 87 | editorTemplate -addControl "saturation"; 88 | 89 | 90 | 91 | //Separator 92 | editorTemplate -addSeparator; 93 | 94 | //direction 95 | editorTemplate -addControl "direction"; 96 | 97 | 98 | 99 | //Separator 100 | editorTemplate -addSeparator; 101 | 102 | //export grade 103 | editorTemplate -callCustom "ocio_cdl_transform_export_cc_build" "ocio_cdl_transform_export_cc_update" "export_cc_dummy"; 104 | 105 | 106 | //End Layout OCIO 107 | editorTemplate -endLayout; 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | //Extra controls for unspecified attributes 119 | //----------------------------------------- 120 | //----------------------------------------- 121 | editorTemplate -addExtraControls; 122 | 123 | //end scroll layout 124 | editorTemplate -endScrollLayout; 125 | 126 | 127 | 128 | 129 | 130 | 131 | } 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | //Header image procedures 142 | //----------------------------------------- 143 | //----------------------------------------- 144 | 145 | global proc ocio_cdl_transform_create_header_image(string $nodeName) 146 | { 147 | //Header 148 | image -w 400 -h 100 -image "ocio_maya_aetemplate.png"; 149 | } 150 | 151 | 152 | global proc ocio_cdl_transform_update_header_image(string $nodeName) 153 | {} 154 | 155 | 156 | 157 | 158 | 159 | //Export cc procedures 160 | //----------------------------------------- 161 | //----------------------------------------- 162 | 163 | global proc ocio_cdl_transform_export_cc_build(string $nodeName) 164 | { 165 | //node_name 166 | string $node[]; 167 | tokenize $nodeName "." $node; 168 | string $node_name = $node[0]; 169 | 170 | 171 | //btn_export 172 | button -label "Export grade as .cc" -c ("ocio_cdl_transform_export_cc(\"" + $node_name + "\")") btn_export; 173 | 174 | } 175 | 176 | 177 | global proc ocio_cdl_transform_export_cc_update(string $nodeName) 178 | { 179 | //node_name 180 | string $node[]; 181 | tokenize $nodeName "." $node; 182 | string $node_name = $node[0]; 183 | 184 | 185 | //btn_export 186 | button -e -label "Export grade as .cc" -c ("ocio_cdl_transform_export_cc(\"" + $node_name + "\")") btn_export; 187 | } 188 | 189 | 190 | global proc ocio_cdl_transform_export_cc(string $node_name) 191 | { 192 | ocio_export_cc -sn $node_name; 193 | } 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /ocio_maya/script/AEOCIOColorSpaceTemplate.mel: -------------------------------------------------------------------------------- 1 | 2 | //AEOCIOColorSpaceTemplate 3 | global proc AEOCIOColorSpaceTemplate( string $nodeName ) { 4 | 5 | //Vars 6 | //----------------------------------------- 7 | //----------------------------------------- 8 | string $node[]; 9 | tokenize $nodeName "." $node; 10 | 11 | 12 | 13 | 14 | 15 | 16 | //Header image 17 | //----------------------------------------- 18 | //----------------------------------------- 19 | 20 | //create header image 21 | editorTemplate -callCustom "ocio_colorspace_create_header_image" "ocio_colorspace_update_header_image" "Dummy"; 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | //scroll layout 30 | editorTemplate -beginScrollLayout; 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | //Begin Layout Input Color 43 | //----------------------------------------- 44 | //----------------------------------------- 45 | editorTemplate -beginLayout "Input Color" -collapse 0; 46 | 47 | //input_color 48 | editorTemplate -addControl "input_color"; 49 | 50 | //End Layout Input Color 51 | editorTemplate -endLayout; 52 | 53 | 54 | 55 | 56 | 57 | 58 | //Begin Layout OCIO 59 | //----------------------------------------- 60 | //----------------------------------------- 61 | editorTemplate -beginLayout "OCIO" -collapse 0; 62 | 63 | //verbose 64 | //editorTemplate -addControl "verbose"; 65 | 66 | //Separator 67 | //editorTemplate -addSeparator; 68 | 69 | 70 | //env_or_file 71 | editorTemplate -addControl "env_or_file"; 72 | //config_file_path 73 | editorTemplate -addControl "config_file_path"; 74 | 75 | 76 | //Separator 77 | editorTemplate -addSeparator; 78 | 79 | 80 | //input_colorspace 81 | editorTemplate -addControl "input_colorspace"; 82 | //output_colorspace 83 | editorTemplate -addControl "output_colorspace"; 84 | 85 | //End Layout Input Color 86 | editorTemplate -endLayout; 87 | 88 | 89 | 90 | 91 | 92 | //Begin Layout Config Info 93 | //----------------------------------------- 94 | //----------------------------------------- 95 | editorTemplate -beginLayout "Config Info" -collapse 0; 96 | 97 | //input_color 98 | editorTemplate -callCustom "ocio_colorspace_create_config_info" "ocio_colorspace_update_config_info" "config_info"; 99 | 100 | //End Layout Input Color 101 | editorTemplate -endLayout; 102 | 103 | 104 | 105 | 106 | 107 | 108 | //Begin Layout Do not modify 109 | //----------------------------------------- 110 | //----------------------------------------- 111 | editorTemplate -beginLayout "Do not modify" -collapse 0; 112 | 113 | //output_color 114 | editorTemplate -addControl "output_color" "ocio_colorspace_dim_output_color"; 115 | 116 | //last_env_or_file 117 | editorTemplate -addControl "last_env_or_file" "ocio_colorspace_dim_last_env_or_file"; 118 | 119 | //last_config_file_path 120 | editorTemplate -addControl "last_config_file_path" "ocio_colorspace_dim_last_config_file_path"; 121 | 122 | //internal_input_colorspace_index 123 | editorTemplate -addControl "internal_input_colorspace_index" "ocio_colorspace_dim_internal_input_colorspace_index"; 124 | 125 | //internal_output_colorspace_index 126 | editorTemplate -addControl "internal_output_colorspace_index" "ocio_colorspace_dim_internal_output_colorspace_index"; 127 | 128 | //End Layout Input Color 129 | editorTemplate -endLayout; 130 | 131 | 132 | 133 | 134 | //Extra controls for unspecified attributes 135 | //----------------------------------------- 136 | //----------------------------------------- 137 | editorTemplate -addExtraControls; 138 | 139 | //end scroll layout 140 | editorTemplate -endScrollLayout; 141 | 142 | 143 | 144 | 145 | 146 | 147 | } 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | //Header image procedures 158 | //----------------------------------------- 159 | //----------------------------------------- 160 | 161 | global proc ocio_colorspace_create_header_image(string $nodeName) 162 | { 163 | //Header 164 | image -w 400 -h 100 -image "ocio_maya_aetemplate.png"; 165 | } 166 | 167 | 168 | global proc ocio_colorspace_update_header_image(string $nodeName) 169 | {} 170 | 171 | 172 | 173 | 174 | 175 | 176 | //Config info procedures 177 | //----------------------------------------- 178 | //----------------------------------------- 179 | 180 | global proc ocio_colorspace_create_config_info(string $nodeName) 181 | { 182 | //node_name 183 | string $node[]; 184 | tokenize $nodeName "." $node; 185 | string $node_name = $node[0]; 186 | 187 | //config_info_text 188 | string $config_info_text = `getAttr $nodeName`; 189 | 190 | //test 191 | text -label $config_info_text -bgc 0.164 0.164 0.164 -ww true -align "left"; 192 | } 193 | 194 | 195 | global proc ocio_colorspace_update_config_info(string $nodeName) 196 | {} 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | //Dim attr. procedures 205 | //----------------------------------------- 206 | //----------------------------------------- 207 | 208 | 209 | global proc ocio_colorspace_dim_output_color(string $nodeName){ 210 | 211 | //Vars 212 | //----------------------------------------- 213 | //----------------------------------------- 214 | string $node[]; 215 | tokenize $nodeName "." $node; 216 | 217 | //Dim 218 | //----------------------------------------- 219 | editorTemplate -dimControl $node[0] "output_color" true; 220 | } 221 | 222 | global proc ocio_colorspace_dim_last_env_or_file(string $nodeName){ 223 | 224 | //Vars 225 | //----------------------------------------- 226 | //----------------------------------------- 227 | string $node[]; 228 | tokenize $nodeName "." $node; 229 | 230 | //Dim 231 | //----------------------------------------- 232 | editorTemplate -dimControl $node[0] "last_env_or_file" true; 233 | } 234 | 235 | global proc ocio_colorspace_dim_last_config_file_path(string $nodeName){ 236 | 237 | //Vars 238 | //----------------------------------------- 239 | //----------------------------------------- 240 | string $node[]; 241 | tokenize $nodeName "." $node; 242 | 243 | //Dim 244 | //----------------------------------------- 245 | editorTemplate -dimControl $node[0] "last_config_file_path" true; 246 | } 247 | 248 | global proc ocio_colorspace_dim_internal_input_colorspace_index(string $nodeName){ 249 | 250 | //Vars 251 | //----------------------------------------- 252 | //----------------------------------------- 253 | string $node[]; 254 | tokenize $nodeName "." $node; 255 | 256 | //Dim 257 | //----------------------------------------- 258 | editorTemplate -dimControl $node[0] "internal_input_colorspace_index" true; 259 | } 260 | 261 | global proc ocio_colorspace_dim_internal_output_colorspace_index(string $nodeName){ 262 | 263 | //Vars 264 | //----------------------------------------- 265 | //----------------------------------------- 266 | string $node[]; 267 | tokenize $nodeName "." $node; 268 | 269 | //Dim 270 | //----------------------------------------- 271 | editorTemplate -dimControl $node[0] "internal_output_colorspace_index" true; 272 | } -------------------------------------------------------------------------------- /ocio_maya/script/AEOCIOFileTransformTemplate.mel: -------------------------------------------------------------------------------- 1 | 2 | //AEOCIOFileTransformTemplate 3 | global proc AEOCIOFileTransformTemplate( string $nodeName ) { 4 | 5 | //Vars 6 | //----------------------------------------- 7 | //----------------------------------------- 8 | string $node[]; 9 | tokenize $nodeName "." $node; 10 | 11 | 12 | 13 | 14 | 15 | 16 | //Header image 17 | //----------------------------------------- 18 | //----------------------------------------- 19 | 20 | //create header image 21 | editorTemplate -callCustom "ocio_file_transform_create_header_image" "ocio_file_transform_update_header_image" "Dummy"; 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | //scroll layout 33 | editorTemplate -beginScrollLayout; 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | //Begin Layout Input Color 46 | //----------------------------------------- 47 | //----------------------------------------- 48 | editorTemplate -beginLayout "Input Color" -collapse 0; 49 | 50 | //input_color 51 | editorTemplate -addControl "input_color"; 52 | 53 | //End Layout Input Color 54 | editorTemplate -endLayout; 55 | 56 | 57 | 58 | 59 | 60 | 61 | //Begin Layout OCIO 62 | //----------------------------------------- 63 | //----------------------------------------- 64 | editorTemplate -beginLayout "OCIO" -collapse 0; 65 | 66 | //verbose 67 | //editorTemplate -addControl "verbose"; 68 | 69 | //Separator 70 | //editorTemplate -addSeparator; 71 | 72 | 73 | //lut_file_path 74 | editorTemplate -addControl "lut_file_path"; 75 | 76 | 77 | //Separator 78 | editorTemplate -addSeparator; 79 | 80 | //cccid 81 | editorTemplate -addControl "cccid"; 82 | 83 | //direction 84 | editorTemplate -addControl "direction"; 85 | //interpolation 86 | editorTemplate -addControl "interpolation"; 87 | 88 | //End Layout Input Color 89 | editorTemplate -endLayout; 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | //Extra controls for unspecified attributes 101 | //----------------------------------------- 102 | //----------------------------------------- 103 | editorTemplate -addExtraControls; 104 | 105 | //end scroll layout 106 | editorTemplate -endScrollLayout; 107 | 108 | 109 | 110 | 111 | 112 | 113 | } 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | //Header image procedures 124 | //----------------------------------------- 125 | //----------------------------------------- 126 | 127 | global proc ocio_file_transform_create_header_image(string $nodeName) 128 | { 129 | //Header 130 | image -w 400 -h 100 -image "ocio_maya_aetemplate.png"; 131 | } 132 | 133 | 134 | global proc ocio_file_transform_update_header_image(string $nodeName) 135 | {} 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /ocio_maya/script/AEOCIOLogConvertTemplate.mel: -------------------------------------------------------------------------------- 1 | 2 | //AEOCIOLogConvertTemplate 3 | global proc AEOCIOLogConvertTemplate( string $nodeName ) { 4 | 5 | //Vars 6 | //----------------------------------------- 7 | //----------------------------------------- 8 | string $node[]; 9 | tokenize $nodeName "." $node; 10 | 11 | 12 | 13 | 14 | 15 | 16 | //Header image 17 | //----------------------------------------- 18 | //----------------------------------------- 19 | 20 | //create header image 21 | editorTemplate -callCustom "ocio_log_convert_create_header_image" "ocio_log_convert_update_header_image" "Dummy"; 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | //scroll layout 33 | editorTemplate -beginScrollLayout; 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | //Begin Layout Input Color 46 | //----------------------------------------- 47 | //----------------------------------------- 48 | editorTemplate -beginLayout "Input Color" -collapse 0; 49 | 50 | //input_color 51 | editorTemplate -addControl "input_color"; 52 | 53 | //End Layout Input Color 54 | editorTemplate -endLayout; 55 | 56 | 57 | 58 | 59 | 60 | 61 | //Begin Layout OCIO 62 | //----------------------------------------- 63 | //----------------------------------------- 64 | editorTemplate -beginLayout "OCIO" -collapse 0; 65 | 66 | //verbose 67 | //editorTemplate -addControl "verbose"; 68 | 69 | //Separator 70 | //editorTemplate -addSeparator; 71 | 72 | //env_or_file 73 | editorTemplate -addControl "env_or_file"; 74 | 75 | //config_file_path 76 | editorTemplate -addControl "config_file_path"; 77 | 78 | 79 | //Separator 80 | editorTemplate -addSeparator; 81 | 82 | //operation 83 | editorTemplate -addControl "operation"; 84 | 85 | 86 | //End Layout OCIO 87 | editorTemplate -endLayout; 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | //Extra controls for unspecified attributes 99 | //----------------------------------------- 100 | //----------------------------------------- 101 | editorTemplate -addExtraControls; 102 | 103 | //end scroll layout 104 | editorTemplate -endScrollLayout; 105 | 106 | 107 | 108 | 109 | 110 | 111 | } 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | //Header image procedures 122 | //----------------------------------------- 123 | //----------------------------------------- 124 | 125 | global proc ocio_log_convert_create_header_image(string $nodeName) 126 | { 127 | //Header 128 | image -w 400 -h 100 -image "ocio_maya_aetemplate.png"; 129 | } 130 | 131 | 132 | global proc ocio_log_convert_update_header_image(string $nodeName) 133 | {} 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_OCIOCDLTransform.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'enzo_v0001_tw.png' #base_color_test_image.png 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('OCIOCDLTransform') 71 | pm.rename(ocio_node, 'OCIOCDLTransform_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | pm.select(cl = True) 114 | 115 | #connect ocio node to shader 116 | ocio_node.output_color >> shader_node.outColor 117 | pm.select(cl = True) 118 | 119 | #set texture file 120 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 121 | 122 | #polyplane_transform_node, polyplane_shape_node 123 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 124 | pm.select(cl = True) 125 | #connect plane to shader 126 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 127 | pm.select(cl = True) 128 | 129 | #render_cam 130 | render_cam_transform, render_cam_shape = pm.camera() 131 | pm.select(cl = True) 132 | pm.rename(render_cam_transform, 'render_cam') 133 | render_cam_transform.translate.set(0,13,7) 134 | render_cam_transform.rotate.set(-65,0,0) 135 | pm.setKeyframe(render_cam_transform, s = False) 136 | pm.lookThru(render_cam_transform) 137 | 138 | 139 | #select ocio node at the end 140 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_OCIOColorSpace.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'enzo_v0001_tw.png' #base_color_test_image.png 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('OCIOColorSpace') 71 | pm.rename(ocio_node, 'OCIOColorSpace_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | pm.select(cl = True) 114 | 115 | #connect ocio node to shader 116 | ocio_node.output_color >> shader_node.outColor 117 | pm.select(cl = True) 118 | 119 | #set texture file 120 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 121 | 122 | #polyplane_transform_node, polyplane_shape_node 123 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 124 | pm.select(cl = True) 125 | #connect plane to shader 126 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 127 | pm.select(cl = True) 128 | 129 | #render_cam 130 | render_cam_transform, render_cam_shape = pm.camera() 131 | pm.select(cl = True) 132 | pm.rename(render_cam_transform, 'render_cam') 133 | render_cam_transform.translate.set(0,13,7) 134 | render_cam_transform.rotate.set(-65,0,0) 135 | pm.setKeyframe(render_cam_transform, s = False) 136 | pm.lookThru(render_cam_transform) 137 | 138 | 139 | #select ocio node at the end 140 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_OCIOFileTransform.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'enzo_v0001_tw.png' #base_color_test_image.png 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('OCIOFileTransform') 71 | pm.rename(ocio_node, 'OCIOFileTransform_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | pm.select(cl = True) 114 | 115 | #connect ocio node to shader 116 | ocio_node.output_color >> shader_node.outColor 117 | pm.select(cl = True) 118 | 119 | #set texture file 120 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 121 | 122 | #polyplane_transform_node, polyplane_shape_node 123 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 124 | pm.select(cl = True) 125 | #connect plane to shader 126 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 127 | pm.select(cl = True) 128 | 129 | #render_cam 130 | render_cam_transform, render_cam_shape = pm.camera() 131 | pm.select(cl = True) 132 | pm.rename(render_cam_transform, 'render_cam') 133 | render_cam_transform.translate.set(0,13,7) 134 | render_cam_transform.rotate.set(-65,0,0) 135 | pm.setKeyframe(render_cam_transform, s = False) 136 | pm.lookThru(render_cam_transform) 137 | 138 | 139 | #select ocio node at the end 140 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_OCIOLogConvert.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'enzo_v0001_tw.png' #base_color_test_image.png 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('OCIOLogConvert') 71 | pm.rename(ocio_node, 'OCIOLogConvert_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | pm.select(cl = True) 114 | 115 | #connect ocio node to shader 116 | ocio_node.output_color >> shader_node.outColor 117 | pm.select(cl = True) 118 | 119 | #set texture file 120 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 121 | 122 | #polyplane_transform_node, polyplane_shape_node 123 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 124 | pm.select(cl = True) 125 | #connect plane to shader 126 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 127 | pm.select(cl = True) 128 | 129 | #render_cam 130 | render_cam_transform, render_cam_shape = pm.camera() 131 | pm.select(cl = True) 132 | pm.rename(render_cam_transform, 'render_cam') 133 | render_cam_transform.translate.set(0,13,7) 134 | render_cam_transform.rotate.set(-65,0,0) 135 | pm.setKeyframe(render_cam_transform, s = False) 136 | pm.lookThru(render_cam_transform) 137 | 138 | 139 | #select ocio node at the end 140 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_ocio_simple_transform.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'enzo_v0001_tw.png' #base_color_test_image.png 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('ocio_simple_transform') 71 | pm.rename(ocio_node, 'ocio_simple_transform_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | pm.select(cl = True) 114 | 115 | #connect ocio node to shader 116 | ocio_node.output_color >> shader_node.outColor 117 | pm.select(cl = True) 118 | 119 | #set texture file 120 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 121 | 122 | #polyplane_transform_node, polyplane_shape_node 123 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 124 | pm.select(cl = True) 125 | #connect plane to shader 126 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 127 | pm.select(cl = True) 128 | 129 | #render_cam 130 | render_cam_transform, render_cam_shape = pm.camera() 131 | pm.select(cl = True) 132 | pm.rename(render_cam_transform, 'render_cam') 133 | render_cam_transform.translate.set(0,13,7) 134 | render_cam_transform.rotate.set(-65,0,0) 135 | pm.setKeyframe(render_cam_transform, s = False) 136 | pm.lookThru(render_cam_transform) 137 | 138 | 139 | #select ocio node at end 140 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/script/update_plugin_ocio_test.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #update_plugin 4 | #----------------------------------------- 5 | ''' 6 | 1.Unload plugin and force new file opening in Maya 7 | 2.Copy plugin from source to target path 8 | 3.Reload plugin 9 | 4.Create setup 10 | ''' 11 | 12 | #Import 13 | #----------------------------------------- 14 | #python 15 | import os 16 | import sys 17 | import shutil 18 | #maya 19 | import maya.cmds as cmds 20 | import pymel.core as pm 21 | 22 | 23 | 24 | #Vars 25 | #----------------------------------------- 26 | verbose = True 27 | plugin_name = 'ocio_maya.mll' 28 | source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' 29 | target_dir = 'C:/symlinks/maya/maya2014x64_plugins' 30 | texture_name = 'base_color_test_image.png' #'enzo_v0001_tw.png' 31 | texture_dir = 'C:/symlinks/temp' 32 | 33 | 34 | #Unload plugin 35 | #----------------------------------------- 36 | #open new file 37 | cmds.file(new = True, f = True) 38 | #unload 39 | pm.unloadPlugin(plugin_name) 40 | if(verbose): 41 | print('Unloaded plugin: {0}'.format(plugin_name)) 42 | 43 | 44 | #Copy plugin 45 | #----------------------------------------- 46 | try: 47 | shutil.copy2(source_dir +'/' +plugin_name, target_dir) 48 | if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 49 | target_dir)) 50 | except: 51 | if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, 52 | target_dir)) 53 | 54 | #Reload plugins 55 | #----------------------------------------- 56 | try: 57 | pm.loadPlugin(plugin_name) 58 | if(verbose): 59 | print('Reloaded plugin: {0}'.format(plugin_name)) 60 | except: 61 | if(verbose): 62 | print('Error loading plugin: {0}'.format(plugin_name)) 63 | 64 | 65 | #Test setup 66 | #----------------------------------------- 67 | #----------------------------------------- 68 | 69 | #ocio_node 70 | ocio_node = pm.createNode('ocio_test') 71 | pm.rename(ocio_node, 'ocio_test_1') 72 | ocio_node.verbose.set(1) 73 | pm.select(cl = True) 74 | 75 | #file_node 76 | file_node = pm.shadingNode('file', name='file_tex', ss = True, asTexture = True) 77 | #place2d_node 78 | place2d_node = pm.createNode('place2dTexture') 79 | pm.select(cl = True) 80 | 81 | #shader_node 82 | shader_node = pm.shadingNode('surfaceShader',name='surface_mt',asShader = True) 83 | #shading_group_node 84 | shading_group_node = pm.sets(renderable = True, empty = True, name= shader_node.name() +'_SG') 85 | 86 | #connect file and place2d 87 | place2d_node.coverage >> file_node.coverage 88 | place2d_node.mirrorU >> file_node.mirrorU 89 | place2d_node.mirrorV >> file_node.mirrorV 90 | place2d_node.noiseUV >> file_node.noiseUV 91 | place2d_node.offset >> file_node.offset 92 | place2d_node.outUV >> file_node.uvCoord 93 | place2d_node.outUvFilterSize >> file_node.uvFilterSize 94 | place2d_node.repeatUV >> file_node.repeatUV 95 | place2d_node.rotateFrame >> file_node.rotateFrame 96 | place2d_node.rotateUV >> file_node.rotateUV 97 | place2d_node.stagger >> file_node.stagger 98 | place2d_node.translateFrame >> file_node.translateFrame 99 | place2d_node.vertexCameraOne >> file_node.vertexCameraOne 100 | place2d_node.vertexUvOne >> file_node.vertexUvOne 101 | place2d_node.vertexUvThree >> file_node.vertexUvThree 102 | place2d_node.vertexUvTwo >> file_node.vertexUvTwo 103 | place2d_node.wrapU >> file_node.wrapU 104 | place2d_node.wrapV >> file_node.wrapV 105 | pm.select(cl = True) 106 | 107 | #connect shader to shading group 108 | pm.connectAttr( shader_node.name() + ".outColor", shading_group_node.name() + ".surfaceShader", force = True) 109 | pm.select(cl = True) 110 | 111 | #connect file to ocio node 112 | file_node.outColor >> ocio_node.input_color 113 | file_node.outSize.outSizeX >> ocio_node.width 114 | file_node.outSize.outSizeY >> ocio_node.height 115 | pm.select(cl = True) 116 | 117 | #connect ocio node to shader 118 | ocio_node.output_color >> shader_node.outColor 119 | pm.select(cl = True) 120 | 121 | #set texture file 122 | file_node.fileTextureName.set(texture_dir +'/' +texture_name) 123 | 124 | #polyplane_transform_node, polyplane_shape_node 125 | polyplane_transform_node, polyplane_shape_node = pm.polyPlane(n = 'ocio_test_polyplane', sx = 10, sy = 10, axis = (0,1,0), width = 12.8, height = 7.8) 126 | pm.select(cl = True) 127 | #connect plane to shader 128 | pm.sets(shading_group_node, forceElement = polyplane_transform_node.name()) 129 | pm.select(cl = True) 130 | 131 | 132 | #render_cam 133 | render_cam_transform, render_cam_shape = pm.camera() 134 | pm.select(cl = True) 135 | pm.rename(render_cam_transform, 'render_cam') 136 | render_cam_transform.translate.set(0,13,7) 137 | render_cam_transform.rotate.set(-65,0,0) 138 | pm.setKeyframe(render_cam_transform, s = False) 139 | pm.lookThru(render_cam_transform) 140 | 141 | 142 | #select ocio node at end 143 | pm.select(ocio_node, r = True) -------------------------------------------------------------------------------- /ocio_maya/source/ocio_cdl_transform.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_cdl_transform Implementation 4 | //----------------------------------------------- 5 | //----------------------------------------------- 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | //----------------------------------------------- 17 | #include "ocio_cdl_transform.h" 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | //Ocio_test 27 | //----------------------------------------------- 28 | //----------------------------------------------- 29 | 30 | 31 | 32 | //Static Attributes 33 | //----------------------------------------------- 34 | //----------------------------------------------- 35 | MTypeId Ocio_cdl_transform::id(0x00005); 36 | MString Ocio_cdl_transform::type_name("OCIOCDLTransform"); 37 | 38 | MObject Ocio_cdl_transform::a_verbose; 39 | 40 | MObject Ocio_cdl_transform::a_input_color; 41 | MObject Ocio_cdl_transform::a_output_color; 42 | 43 | MObject Ocio_cdl_transform::a_slope; 44 | MObject Ocio_cdl_transform::a_last_slope; 45 | MObject Ocio_cdl_transform::a_offset; 46 | MObject Ocio_cdl_transform::a_last_offset; 47 | MObject Ocio_cdl_transform::a_power; 48 | MObject Ocio_cdl_transform::a_last_power; 49 | MObject Ocio_cdl_transform::a_saturation; 50 | MObject Ocio_cdl_transform::a_last_saturation; 51 | MObject Ocio_cdl_transform::a_direction; 52 | MObject Ocio_cdl_transform::a_last_direction; 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | //Methods 61 | //----------------------------------------------- 62 | //----------------------------------------------- 63 | 64 | 65 | 66 | 67 | 68 | //Maya 69 | //----------------------------------------------- 70 | //----------------------------------------------- 71 | 72 | //Constructor 73 | Ocio_cdl_transform::Ocio_cdl_transform() : 74 | processor(0) 75 | { 76 | }; 77 | 78 | //Destructor 79 | Ocio_cdl_transform::~Ocio_cdl_transform(){}; 80 | 81 | 82 | //create 83 | void* Ocio_cdl_transform::create() 84 | { 85 | return new Ocio_cdl_transform(); 86 | } 87 | 88 | 89 | //initialize 90 | MStatus Ocio_cdl_transform::initialize() 91 | { 92 | 93 | //MFnSets 94 | MFnEnumAttribute eAttr; 95 | MFnNumericAttribute nAttr; 96 | MFnTypedAttribute tAttr; 97 | 98 | 99 | //a_verbose 100 | a_verbose = eAttr.create("verbose", "verbose", 1); 101 | eAttr.addField("no verbose", 0); 102 | eAttr.addField("verbose", 1); 103 | addAttribute(a_verbose); 104 | 105 | //a_input_color 106 | a_input_color = nAttr.createColor("input_color", "input_color"); 107 | nAttr.setUsedAsColor(true); 108 | nAttr.setStorable(true); 109 | addAttribute(a_input_color); 110 | 111 | //a_output_color 112 | a_output_color = nAttr.createColor("output_color", "output_color"); 113 | nAttr.setUsedAsColor(true); 114 | nAttr.setStorable(false); 115 | addAttribute(a_output_color); 116 | 117 | //a_slope 118 | a_slope = nAttr.createColor("slope", "slope"); 119 | nAttr.setUsedAsColor(true); 120 | nAttr.setStorable(true); 121 | nAttr.setDefault(1.0, 1.0, 1.0); 122 | addAttribute(a_slope); 123 | 124 | //a_last_slope 125 | a_last_slope = nAttr.createColor("last_slope", "last_slope"); 126 | nAttr.setUsedAsColor(true); 127 | nAttr.setStorable(true); 128 | nAttr.setDefault(1.0, 1.0, 1.0); 129 | addAttribute(a_last_slope); 130 | 131 | //a_offset 132 | a_offset = nAttr.createColor("offset", "offset"); 133 | nAttr.setUsedAsColor(true); 134 | nAttr.setStorable(true); 135 | nAttr.setDefault(0, 0, 0); 136 | addAttribute(a_offset); 137 | 138 | //a_last_offset 139 | a_last_offset = nAttr.createColor("last_offset", "last_offset"); 140 | nAttr.setUsedAsColor(true); 141 | nAttr.setStorable(true); 142 | nAttr.setDefault(0, 0, 0); 143 | addAttribute(a_last_offset); 144 | 145 | //a_power 146 | a_power = nAttr.createColor("power", "power"); 147 | nAttr.setUsedAsColor(true); 148 | nAttr.setStorable(true); 149 | nAttr.setDefault(1.0, 1.0, 1.0); 150 | addAttribute(a_power); 151 | 152 | //a_last_power 153 | a_last_power = nAttr.createColor("last_power", "last_power"); 154 | nAttr.setUsedAsColor(true); 155 | nAttr.setStorable(true); 156 | nAttr.setDefault(1.0, 1.0, 1.0); 157 | addAttribute(a_last_power); 158 | 159 | //a_saturation 160 | a_saturation = nAttr.create("saturation", "saturation", MFnNumericData::kFloat, 1.0); 161 | nAttr.setStorable(true); 162 | addAttribute(a_saturation); 163 | 164 | //a_last_saturation 165 | a_last_saturation = nAttr.create("last_saturation", "last_saturation", MFnNumericData::kFloat, 1.0); 166 | nAttr.setStorable(true); 167 | addAttribute(a_last_saturation); 168 | 169 | //a_direction 170 | a_direction = eAttr.create("direction", "direction", 0); 171 | eAttr.addField("Forward", 0); 172 | eAttr.addField("Inverse", 1); 173 | eAttr.setStorable(true); 174 | addAttribute(a_direction); 175 | 176 | //a_last_direction 177 | a_last_direction = nAttr.create("last_direction", "last_direction", MFnNumericData::kInt, 0); 178 | nAttr.setStorable(true); 179 | nAttr.setHidden(true); 180 | addAttribute(a_last_direction); 181 | 182 | 183 | 184 | 185 | //Attribute affects 186 | attributeAffects(a_input_color, a_output_color); 187 | attributeAffects(a_slope, a_output_color); 188 | attributeAffects(a_offset, a_output_color); 189 | attributeAffects(a_power, a_output_color); 190 | attributeAffects(a_saturation, a_output_color); 191 | attributeAffects(a_direction, a_output_color); 192 | 193 | 194 | 195 | 196 | return MStatus::kSuccess; 197 | } 198 | 199 | //postConstructor 200 | void Ocio_cdl_transform::postConstructor() 201 | { 202 | //set first execution 203 | first_execution = true; 204 | 205 | //log 206 | MGlobal::displayInfo("Postconstructor executed"); 207 | }; 208 | 209 | //compute 210 | MStatus Ocio_cdl_transform::compute(const MPlug &plug, MDataBlock &data) 211 | { 212 | 213 | //wrong plug requested 214 | //----------------------------------------------- 215 | //----------------------------------------------- 216 | if ((plug != a_output_color) && (plug.parent() != a_output_color)) 217 | { 218 | return MStatus::kUnknownParameter; 219 | } 220 | 221 | 222 | 223 | 224 | 225 | //right plug requested 226 | //----------------------------------------------- 227 | //----------------------------------------------- 228 | 229 | 230 | //Get attributes 231 | //----------------------------------------------- 232 | 233 | MFloatVector vec_slope, vec_last_slope, vec_offset, vec_last_offset, vec_power, vec_last_power; 234 | get_sop_as_mfloatvectors(vec_slope, 235 | vec_last_slope, 236 | vec_offset, 237 | vec_last_offset, 238 | vec_power, 239 | vec_last_power, 240 | data); 241 | 242 | //saturation 243 | MDataHandle h_saturation = data.inputValue(a_saturation); 244 | float saturation = h_saturation.asFloat(); 245 | //last_saturation 246 | MDataHandle h_last_saturation = data.inputValue(a_last_saturation); 247 | float last_saturation = h_last_saturation.asFloat(); 248 | 249 | //direction 250 | MDataHandle h_direction = data.inputValue(a_direction); 251 | int direction = h_direction.asInt(); 252 | //last_direction 253 | MDataHandle h_last_direction = data.inputValue(a_last_direction); 254 | int last_direction = h_last_direction.asInt(); 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | //Set processor 267 | //----------------------------------------------- 268 | 269 | if (first_execution) 270 | { 271 | float* sop_ptr = new float[9]; 272 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 273 | set_processor(sop_ptr, saturation, direction); 274 | delete[] sop_ptr; 275 | 276 | } 277 | else if (vec_slope != vec_last_slope) 278 | { 279 | float* sop_ptr = new float[9]; 280 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 281 | set_processor(sop_ptr, saturation, direction); 282 | delete[] sop_ptr; 283 | set_color_attribute(std::string("last_slope"), vec_slope); 284 | } 285 | else if (vec_offset != vec_last_offset) 286 | { 287 | float* sop_ptr = new float[9]; 288 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 289 | set_processor(sop_ptr, saturation, direction); 290 | delete[] sop_ptr; 291 | set_color_attribute(std::string("last_offset"), vec_offset); 292 | } 293 | else if (vec_power != vec_last_power) 294 | { 295 | float* sop_ptr = new float[9]; 296 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 297 | set_processor(sop_ptr, saturation, direction); 298 | delete[] sop_ptr; 299 | set_color_attribute(std::string("last_power"), vec_power); 300 | } 301 | else if (saturation != last_saturation) 302 | { 303 | float* sop_ptr = new float[9]; 304 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 305 | set_processor(sop_ptr, saturation, direction); 306 | delete[] sop_ptr; 307 | set_float_attribute(std::string("last_saturation"), saturation); 308 | } 309 | else if (direction != last_direction) 310 | { 311 | float* sop_ptr = new float[9]; 312 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 313 | set_processor(sop_ptr, saturation, direction); 314 | delete[] sop_ptr; 315 | set_int_attribute(std::string("last_direction"), direction); 316 | } 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | //Color conversion 325 | //----------------------------------------------- 326 | 327 | //vec_input_color 328 | MDataHandle h_input_color = data.inputValue(a_input_color); 329 | MFloatVector& vec_input_color = h_input_color.asFloatVector(); 330 | 331 | //transform_color 332 | if (processor) 333 | color_transform(vec_input_color); 334 | 335 | //set output color 336 | set_output_color(vec_input_color, data); 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | //set first execution to false 351 | first_execution = false; 352 | 353 | //return success 354 | return MStatus::kSuccess; 355 | 356 | } 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | //OCIO 365 | //----------------------------------------------- 366 | //----------------------------------------------- 367 | 368 | //set_processor 369 | void Ocio_cdl_transform::set_processor(float*& sop, float saturation, int direction) 370 | { 371 | 372 | 373 | //set processor 374 | processor = OCIO_functionality::get_processor_from_cdl_transform(sop, saturation, direction); 375 | 376 | //display msg 377 | if (!processor) 378 | MGlobal::displayWarning("Processor empty"); 379 | else 380 | MGlobal::displayInfo("Processor set"); 381 | 382 | }; 383 | 384 | //color_transform 385 | void Ocio_cdl_transform::color_transform(MFloatVector& vec_input_color) 386 | { 387 | //pixels 388 | float pixels[3]; 389 | vec_input_color.get(pixels); 390 | 391 | //pixel_r, pixel_g, pixel_b; 392 | float* pixel_r = &pixels[0]; 393 | float* pixel_g = &pixels[1]; 394 | float* pixel_b = &pixels[2]; 395 | 396 | //convert 397 | OCIO_functionality::color_transform_single_pixel(pixel_r, pixel_g, pixel_b, processor); 398 | 399 | //set colors back to vec_input_color 400 | vec_input_color.x = pixels[0]; 401 | vec_input_color.y = pixels[1]; 402 | vec_input_color.z = pixels[2]; 403 | } 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | //States 412 | //----------------------------------------------- 413 | //----------------------------------------------- 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | //Own 427 | //----------------------------------------------- 428 | //----------------------------------------------- 429 | 430 | void Ocio_cdl_transform::get_sop_as_mfloatvectors(MFloatVector& vec_slope, 431 | MFloatVector& vec_last_slope, 432 | MFloatVector& vec_offset, 433 | MFloatVector& vec_last_offset, 434 | MFloatVector& vec_power, 435 | MFloatVector& vec_last_power, 436 | MDataBlock& data) 437 | { 438 | //vec_slope 439 | MDataHandle h_slope = data.inputValue(a_slope); 440 | vec_slope = h_slope.asFloatVector(); 441 | //vec_last_slope 442 | MDataHandle h_last_slope = data.inputValue(a_last_slope); 443 | vec_last_slope = h_last_slope.asFloatVector(); 444 | 445 | //vec_offset 446 | MDataHandle h_offset = data.inputValue(a_offset); 447 | vec_offset = h_offset.asFloatVector(); 448 | //vec_last_offset 449 | MDataHandle h_last_offset = data.inputValue(a_last_offset); 450 | vec_last_offset = h_last_offset.asFloatVector(); 451 | 452 | //vec_power 453 | MDataHandle h_power = data.inputValue(a_power); 454 | vec_power = h_power.asFloatVector(); 455 | //vec_last_power 456 | MDataHandle h_last_power = data.inputValue(a_last_power); 457 | vec_last_power = h_last_power.asFloatVector(); 458 | }; 459 | 460 | //get_sop_as_float_ptr 461 | void Ocio_cdl_transform::get_sop_as_float_ptr(float*& sop_ptr, 462 | MFloatVector& vec_slope, 463 | MFloatVector& vec_offset, 464 | MFloatVector& vec_power) 465 | { 466 | //set sop_ptr 467 | sop_ptr[0] = vec_slope.x; 468 | sop_ptr[1] = vec_slope.y; 469 | sop_ptr[2] = vec_slope.z; 470 | 471 | sop_ptr[3] = vec_offset.x; 472 | sop_ptr[4] = vec_offset.y; 473 | sop_ptr[5] = vec_offset.z; 474 | 475 | sop_ptr[6] = vec_power.x; 476 | sop_ptr[7] = vec_power.y; 477 | sop_ptr[8] = vec_power.z; 478 | }; 479 | 480 | //set_color_attribute 481 | void Ocio_cdl_transform::set_color_attribute(std::string attr_name, MFloatVector& color) 482 | { 483 | //p_plug 484 | MPlug p_plug = get_plug(attr_name); 485 | 486 | //set color 487 | p_plug.child(0).setFloat(color.x); 488 | p_plug.child(1).setFloat(color.y); 489 | p_plug.child(2).setFloat(color.z); 490 | 491 | } 492 | 493 | //set_int_attribute 494 | void Ocio_cdl_transform::set_int_attribute(std::string attr_name, int value) 495 | { 496 | //p_attr 497 | MPlug p_attr = get_plug(attr_name); 498 | 499 | //set value 500 | p_attr.setInt(value); 501 | }; 502 | 503 | //set_float_attribute 504 | void Ocio_cdl_transform::set_float_attribute(std::string attr_name, float value) 505 | { 506 | //p_attr 507 | MPlug p_attr = get_plug(attr_name); 508 | 509 | //set value 510 | p_attr.setFloat(value); 511 | }; 512 | 513 | 514 | 515 | 516 | //Helper 517 | //----------------------------------------------- 518 | //----------------------------------------------- 519 | 520 | //get_plug 521 | MPlug Ocio_cdl_transform::get_plug(std::string attr_name) 522 | { 523 | //node 524 | MObject node = thisMObject(); 525 | //fn_dep_node 526 | MFnDependencyNode fn_dep_node(node); 527 | //p_plug 528 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 529 | 530 | return p_plug; 531 | }; 532 | 533 | //attribute_exists 534 | bool Ocio_cdl_transform::attribute_exists(std::string attr_name) 535 | { 536 | //p_plug 537 | MPlug p_plug = get_plug(attr_name); 538 | 539 | return !p_plug.isNull(); 540 | 541 | }; 542 | 543 | //attr_connected 544 | bool Ocio_cdl_transform::attr_connected(std::string attr_name) 545 | { 546 | //p_plug 547 | MPlug p_plug = get_plug(attr_name); 548 | 549 | //return 550 | return p_plug.isConnected(); 551 | }; 552 | 553 | //set_output_color 554 | void Ocio_cdl_transform::set_output_color(MFloatVector& vec_color, MDataBlock& data) 555 | { 556 | MDataHandle h_output_color = data.outputValue(a_output_color); 557 | MFloatVector& vec_output_color = h_output_color.asFloatVector(); 558 | vec_output_color = vec_color; 559 | 560 | //clean handle 561 | h_output_color.setClean(); 562 | 563 | //tmp 564 | //MGlobal::displayInfo("Set output color attribute"); 565 | }; 566 | 567 | //get_instance_name 568 | std::string Ocio_cdl_transform::get_instance_name() 569 | { 570 | 571 | //ms_node_name 572 | MString ms_node_name = this->name(); 573 | 574 | //node_name 575 | std::string node_name = std::string(ms_node_name.asChar()); 576 | 577 | return node_name; 578 | }; 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | //Temp 593 | //----------------------------------------------- 594 | //----------------------------------------------- 595 | 596 | -------------------------------------------------------------------------------- /ocio_maya/source/ocio_cdl_transform.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_CDL_TRANSFORM_H 4 | #define OCIO_CDL_TRANSFORM_H 5 | 6 | //Ocio_cdl_transform Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //Own 25 | #include "ocio_functionality.h" 26 | //Maya 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | 49 | 50 | 51 | //Ocio_cdl_transform 52 | //----------------------------------------------- 53 | class Ocio_cdl_transform : public MPxNode 54 | { 55 | public: 56 | //Attributes 57 | static MTypeId id; 58 | static MString type_name; 59 | 60 | static MObject a_verbose; 61 | 62 | static MObject a_input_color; 63 | static MObject a_output_color; 64 | 65 | static MObject a_slope; 66 | static MObject a_last_slope; 67 | static MObject a_offset; 68 | static MObject a_last_offset; 69 | static MObject a_power; 70 | static MObject a_last_power; 71 | static MObject a_saturation; 72 | static MObject a_last_saturation; 73 | static MObject a_direction; 74 | static MObject a_last_direction; 75 | 76 | 77 | 78 | //Methods 79 | //Maya 80 | Ocio_cdl_transform(); 81 | virtual ~Ocio_cdl_transform(); 82 | static void* create(); 83 | static MStatus initialize(); 84 | virtual void postConstructor(); 85 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 86 | //OCIO 87 | void set_processor(float*&, float, int); 88 | void color_transform(MFloatVector&); 89 | //States 90 | //Own 91 | void get_sop_as_mfloatvectors(MFloatVector&, 92 | MFloatVector&, 93 | MFloatVector&, 94 | MFloatVector&, 95 | MFloatVector&, 96 | MFloatVector&, 97 | MDataBlock&); 98 | void get_sop_as_float_ptr(float*&, 99 | MFloatVector&, 100 | MFloatVector&, 101 | MFloatVector&); 102 | void set_color_attribute(std::string, MFloatVector&); 103 | void set_int_attribute(std::string, int); 104 | void set_float_attribute(std::string, float); 105 | //Helper 106 | MPlug get_plug(std::string); 107 | bool attribute_exists(std::string); 108 | bool attr_connected(std::string); 109 | void set_output_color(MFloatVector&, MDataBlock&); 110 | std::string get_instance_name(); 111 | //Temp 112 | 113 | 114 | 115 | private: 116 | //Attributes 117 | bool first_execution; 118 | OCIO::ConstProcessorRcPtr processor; 119 | 120 | //Methods 121 | 122 | 123 | }; 124 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_colorspace.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_COLORSPACE_H 4 | #define OCIO_COLORSPACE_H 5 | 6 | //Ocio_colorspace Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //Own 25 | #include "ocio_functionality.h" 26 | //Maya 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | 49 | 50 | 51 | //Ocio_colorspace 52 | //----------------------------------------------- 53 | class Ocio_colorspace : public MPxNode 54 | { 55 | public: 56 | //Attributes 57 | static MTypeId id; 58 | static MString type_name; 59 | 60 | static MObject a_verbose; 61 | 62 | static MObject a_input_color; 63 | static MObject a_output_color; 64 | 65 | static MObject a_env_or_file; 66 | static MObject a_last_env_or_file; 67 | static MObject a_config_file_path; 68 | static MObject a_last_config_file_path; 69 | static MObject a_internal_input_colorspace_index; 70 | static MObject a_internal_output_colorspace_index; 71 | static MObject a_config_info; 72 | 73 | //Methods 74 | //Maya 75 | Ocio_colorspace(); 76 | virtual ~Ocio_colorspace(); 77 | static void* create(); 78 | static MStatus initialize(); 79 | virtual void postConstructor(); 80 | virtual MStatus setDependentsDirty(const MPlug&, MPlugArray&); 81 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 82 | //OCIO 83 | void set_config(int); 84 | void set_config_info(); 85 | bool config_exists(); 86 | void set_colorspace_names(); 87 | void set_processor(); 88 | void color_transform(MFloatVector&); 89 | //States 90 | void node_created(); 91 | void env_or_file_changed(); 92 | void colorspace_changed(); 93 | void config_file_path_changed(); 94 | //Own 95 | MPlug get_plug(std::string); 96 | bool attribute_exists(std::string); 97 | int get_env_or_file(); 98 | int get_last_env_or_file(); 99 | void set_last_env_or_file(int); 100 | std::string get_config_file_path(); 101 | std::string get_last_config_file_path(); 102 | void set_last_config_file_path(std::string); 103 | bool attr_connected(std::string); 104 | void set_output_color(MFloatVector&, MDataBlock&); 105 | //Colorspace indices 106 | int get_input_colorspace(); 107 | void set_input_colorspace(int); 108 | int get_output_colorspace(); 109 | void set_output_colorspace(int); 110 | int get_internal_input_colorspace_index(); 111 | void set_internal_input_colorspace_index(int); 112 | int get_internal_output_colorspace_index(); 113 | void set_internal_output_colorspace_index(int); 114 | //Enum 115 | void create_dynamic_enum_attribute(std::string, std::vector&); 116 | void remove_dynamic_attribute(std::string); 117 | void update_dynamic_enum_attribute(std::string, std::vector&); 118 | //Temp 119 | void print_config_info(); 120 | 121 | 122 | private: 123 | //Attributes 124 | bool first_execution; 125 | OCIO::ConstConfigRcPtr config; 126 | OCIO::ConstProcessorRcPtr processor; 127 | std::vector vec_colorspace_names; 128 | 129 | //Methods 130 | 131 | 132 | }; 133 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_export_cc.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //Ocio_export_cc Implementation 5 | //----------------------------------------------- 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | #include "ocio_export_cc.h" 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | //Globals 25 | //----------------------------------------------- 26 | 27 | //flag_names 28 | const char* Ocio_export_cc::flag_source_node = "-sn"; 29 | const char* Ocio_export_cc::flag_long_source_node = "-source_node"; 30 | 31 | const char* Ocio_export_cc::flag_cc_path = "-cc"; 32 | const char* Ocio_export_cc::flag_long_cc_path = "-cc_path"; 33 | 34 | 35 | 36 | 37 | 38 | //Ocio_export_cc 39 | //----------------------------------------------- 40 | 41 | //Constructor 42 | Ocio_export_cc::Ocio_export_cc() {}; 43 | 44 | //creator 45 | void* Ocio_export_cc::creator() 46 | { 47 | return new Ocio_export_cc; 48 | } 49 | 50 | 51 | 52 | 53 | 54 | //doIt 55 | MStatus Ocio_export_cc::doIt(const MArgList& argument_list) 56 | { 57 | //Default values for command arguments 58 | //----------------------------------------------- 59 | 60 | //source_node 61 | MString ms_source_node("Default source node"); 62 | 63 | //cc_path 64 | MString ms_cc_path(MFileIO::currentFile()); 65 | std::string cc_dir(split_filename(ms_cc_path.asChar()).c_str()); 66 | MString cc_file_path(cc_dir.append("/grade.cc").c_str()); 67 | 68 | //status 69 | MStatus status; 70 | 71 | 72 | 73 | 74 | //arg_db 75 | //----------------------------------------------- 76 | MArgDatabase arg_db(syntax(), argument_list, &status); 77 | 78 | //return if wrong 79 | if (status != MStatus::kSuccess) 80 | return status; 81 | 82 | 83 | //get arguments if set 84 | 85 | //source_node 86 | if (arg_db.isFlagSet(flag_source_node)) 87 | arg_db.getFlagArgument(flag_source_node, 0, ms_source_node); 88 | //cc_path 89 | if (arg_db.isFlagSet(flag_cc_path)) 90 | arg_db.getFlagArgument(flag_cc_path, 0, cc_file_path); 91 | 92 | 93 | //str_cc_file_path 94 | std::string str_cc_file_path(cc_file_path.asChar()); 95 | 96 | 97 | 98 | //Export 99 | //----------------------------------------------- 100 | 101 | //source_node 102 | std::string source_node(ms_source_node.asChar()); 103 | 104 | //cc parameter vars 105 | MFloatVector vec_slope, vec_offset, vec_power; 106 | float saturation; 107 | int direction; 108 | 109 | //get cc parameters 110 | get_cc_parameters(source_node, 111 | vec_slope, 112 | vec_offset, 113 | vec_power, 114 | saturation, 115 | direction); 116 | 117 | //sop_ptr 118 | float* sop_ptr = new float[9]; 119 | get_sop_as_float_ptr(sop_ptr, vec_slope, vec_offset, vec_power); 120 | 121 | //str_xml 122 | std::string str_xml = get_cc_xml(sop_ptr, saturation, direction); 123 | 124 | //write to file 125 | write_to_file(str_xml, str_cc_file_path); 126 | 127 | 128 | //display str_xml 129 | MGlobal::displayInfo(MString("XML: ") + str_xml.c_str()); 130 | 131 | //display cc_path 132 | MGlobal::displayInfo(MString("CC File saved to: ") + str_cc_file_path.c_str()); 133 | 134 | //delete sop_ptr 135 | delete[] sop_ptr; 136 | 137 | return MS::kSuccess; 138 | } 139 | 140 | 141 | 142 | 143 | //new_syntax 144 | MSyntax Ocio_export_cc::new_syntax() 145 | { 146 | 147 | 148 | //syntax 149 | MSyntax syntax; 150 | 151 | //add flags 152 | syntax.addFlag(flag_source_node, flag_long_source_node, MSyntax::kString); 153 | syntax.addFlag(flag_cc_path, flag_long_cc_path, MSyntax::kString); 154 | 155 | 156 | return syntax; 157 | }; 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | //Own 166 | //----------------------------------------------- 167 | //----------------------------------------------- 168 | 169 | 170 | //get_cc_parameters 171 | void Ocio_export_cc::get_cc_parameters(std::string node_name, 172 | MFloatVector& vec_slope, 173 | MFloatVector& vec_offset, 174 | MFloatVector& vec_power, 175 | float& saturation, 176 | int& direction) 177 | { 178 | //p_slope 179 | MPlug p_slope = get_plug(node_name, std::string("slope")); 180 | vec_slope.x = p_slope.child(0).asFloat(); 181 | vec_slope.y = p_slope.child(1).asFloat(); 182 | vec_slope.z = p_slope.child(2).asFloat(); 183 | 184 | //p_offset 185 | MPlug p_offset = get_plug(node_name, std::string("offset")); 186 | vec_offset.x = p_offset.child(0).asFloat(); 187 | vec_offset.y = p_offset.child(1).asFloat(); 188 | vec_offset.z = p_offset.child(2).asFloat(); 189 | 190 | //p_power 191 | MPlug p_power = get_plug(node_name, std::string("power")); 192 | vec_power.x = p_power.child(0).asFloat(); 193 | vec_power.y = p_power.child(1).asFloat(); 194 | vec_power.z = p_power.child(2).asFloat(); 195 | 196 | //p_saturation 197 | MPlug p_saturation = get_plug(node_name, std::string("saturation")); 198 | saturation = p_saturation.asFloat(); 199 | 200 | //p_direction 201 | MPlug p_direction = get_plug(node_name, std::string("direction")); 202 | direction = p_direction.asInt(); 203 | 204 | 205 | }; 206 | 207 | //get_sop_as_float_ptr 208 | void Ocio_export_cc::get_sop_as_float_ptr(float*& sop_ptr, 209 | MFloatVector& vec_slope, 210 | MFloatVector& vec_offset, 211 | MFloatVector& vec_power) 212 | { 213 | //set sop_ptr 214 | sop_ptr[0] = vec_slope.x; 215 | sop_ptr[1] = vec_slope.y; 216 | sop_ptr[2] = vec_slope.z; 217 | 218 | sop_ptr[3] = vec_offset.x; 219 | sop_ptr[4] = vec_offset.y; 220 | sop_ptr[5] = vec_offset.z; 221 | 222 | sop_ptr[6] = vec_power.x; 223 | sop_ptr[7] = vec_power.y; 224 | sop_ptr[8] = vec_power.z; 225 | }; 226 | 227 | //get_cc_xml 228 | std::string Ocio_export_cc::get_cc_xml(float*& sop_ptr, 229 | float& saturation, 230 | int& direction) 231 | { 232 | //str_xml 233 | std::string str_xml = OCIO_functionality::get_xml_from_cdl_transform(sop_ptr, 234 | saturation, 235 | direction); 236 | //return str_xml 237 | return str_xml; 238 | }; 239 | 240 | //write_to_file 241 | void Ocio_export_cc::write_to_file(std::string& str_xml, std::string& file_path) 242 | { 243 | //cc_file 244 | std::ofstream cc_file; 245 | 246 | //open 247 | cc_file.open(file_path, std::ios::out | std::ios::trunc); 248 | 249 | //if open append 250 | if (cc_file.is_open()) 251 | cc_file << str_xml.c_str(); 252 | else 253 | MGlobal::displayWarning(MString("Could not open and write to file: ") + file_path.c_str()); 254 | 255 | //close 256 | cc_file.close(); 257 | 258 | } 259 | 260 | //get_plug 261 | MPlug Ocio_export_cc::get_plug(std::string node_name, std::string attr_name) 262 | { 263 | 264 | //sel_list 265 | MSelectionList sel_list; 266 | sel_list.add(MString(node_name.c_str())); 267 | 268 | //o_node 269 | MObject o_node; 270 | sel_list.getDependNode(0, o_node); 271 | 272 | //fn_dep_node 273 | MFnDependencyNode fn_dep_node(o_node); 274 | 275 | //p_plug 276 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 277 | 278 | return p_plug; 279 | }; 280 | 281 | //split_filename 282 | std::string Ocio_export_cc::split_filename(const std::string& str) 283 | { 284 | //index 285 | unsigned index = str.find_last_of("/"); 286 | 287 | //str_plit 288 | std::string str_split(str.substr(0, index)); 289 | 290 | return str_split; 291 | } -------------------------------------------------------------------------------- /ocio_maya/source/ocio_export_cc.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_EXPORT_CC 4 | #define OCIO_EXPORT_CC 5 | 6 | 7 | 8 | //Ocio_export_cc Declaration 9 | //----------------------------------------------- 10 | 11 | 12 | //Constants 13 | //----------------------------------------------- 14 | 15 | 16 | 17 | //include 18 | //----------------------------------------------- 19 | //Std 20 | #include 21 | #include 22 | #include 23 | #include 24 | //Boost 25 | #include "boost/format.hpp" 26 | #include "boost/lexical_cast.hpp" 27 | //Own 28 | #include "ocio_functionality.h" 29 | //Maya 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | 43 | 44 | 45 | 46 | //Ocio_export_cc 47 | //----------------------------------------------- 48 | class Ocio_export_cc : public MPxCommand 49 | { 50 | public: 51 | Ocio_export_cc(); 52 | virtual MStatus doIt(const MArgList&); 53 | static void* creator(); 54 | static MSyntax new_syntax(); 55 | 56 | //Own 57 | void get_cc_parameters(std::string, MFloatVector&, MFloatVector&, MFloatVector&, float&, int&); 58 | void get_sop_as_float_ptr(float*&, 59 | MFloatVector&, 60 | MFloatVector&, 61 | MFloatVector&); 62 | std::string get_cc_xml(float*&, float&, int&); 63 | void write_to_file(std::string&, std::string&); 64 | MPlug get_plug(std::string, std::string); 65 | std::string split_filename(const std::string&); 66 | 67 | private: 68 | //flag_names 69 | static const char* flag_source_node; 70 | static const char* flag_long_source_node; 71 | 72 | static const char* flag_cc_path; 73 | static const char* flag_long_cc_path; 74 | }; 75 | 76 | 77 | 78 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_file_transform.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_file_transform Implementation 4 | //----------------------------------------------- 5 | //----------------------------------------------- 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | //----------------------------------------------- 17 | #include "ocio_file_transform.h" 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | //Ocio_test 27 | //----------------------------------------------- 28 | //----------------------------------------------- 29 | 30 | 31 | 32 | //Static Attributes 33 | //----------------------------------------------- 34 | //----------------------------------------------- 35 | MTypeId Ocio_file_transform::id(0x00003); 36 | MString Ocio_file_transform::type_name("OCIOFileTransform"); 37 | 38 | MObject Ocio_file_transform::a_verbose; 39 | 40 | MObject Ocio_file_transform::a_input_color; 41 | MObject Ocio_file_transform::a_output_color; 42 | 43 | MObject Ocio_file_transform::a_lut_file_path; 44 | MObject Ocio_file_transform::a_last_lut_file_path; 45 | MObject Ocio_file_transform::a_cccid; 46 | MObject Ocio_file_transform::a_last_cccid; 47 | MObject Ocio_file_transform::a_direction; 48 | MObject Ocio_file_transform::a_last_direction; 49 | MObject Ocio_file_transform::a_interpolation; 50 | MObject Ocio_file_transform::a_last_interpolation; 51 | 52 | 53 | 54 | 55 | 56 | //Methods 57 | //----------------------------------------------- 58 | //----------------------------------------------- 59 | 60 | 61 | 62 | 63 | 64 | //Maya 65 | //----------------------------------------------- 66 | //----------------------------------------------- 67 | 68 | //Constructor 69 | Ocio_file_transform::Ocio_file_transform() : 70 | processor(0) 71 | { 72 | }; 73 | 74 | //Destructor 75 | Ocio_file_transform::~Ocio_file_transform(){}; 76 | 77 | 78 | //create 79 | void* Ocio_file_transform::create() 80 | { 81 | return new Ocio_file_transform(); 82 | } 83 | 84 | 85 | //initialize 86 | MStatus Ocio_file_transform::initialize() 87 | { 88 | 89 | //MFnSets 90 | MFnEnumAttribute eAttr; 91 | MFnNumericAttribute nAttr; 92 | MFnTypedAttribute tAttr; 93 | 94 | 95 | //a_verbose 96 | a_verbose = eAttr.create("verbose", "verbose", 1); 97 | eAttr.addField("no verbose", 0); 98 | eAttr.addField("verbose", 1); 99 | addAttribute(a_verbose); 100 | 101 | //a_input_color 102 | a_input_color = nAttr.createColor("input_color", "input_color"); 103 | nAttr.setUsedAsColor(true); 104 | nAttr.setStorable(true); 105 | addAttribute(a_input_color); 106 | 107 | //a_output_color 108 | a_output_color = nAttr.createColor("output_color", "output_color"); 109 | nAttr.setUsedAsColor(true); 110 | nAttr.setStorable(false); 111 | addAttribute(a_output_color); 112 | 113 | //a_lut_file_path 114 | a_lut_file_path = tAttr.create("lut_file_path", "lut_file_path", MFnData::kString); 115 | tAttr.setUsedAsFilename(true); 116 | tAttr.setStorable(true); 117 | addAttribute(a_lut_file_path); 118 | 119 | //a_last_lut_file_path 120 | a_last_lut_file_path = tAttr.create("last_lut_file_path", "last_lut_file_path", MFnData::kString); 121 | tAttr.setStorable(true); 122 | tAttr.setHidden(true); 123 | addAttribute(a_last_lut_file_path); 124 | 125 | //a_cccid 126 | a_cccid = tAttr.create("cccid", "cccid", MFnData::kString); 127 | tAttr.setStorable(true); 128 | addAttribute(a_cccid); 129 | 130 | //a_last_cccid 131 | a_last_cccid = tAttr.create("last_cccid", "last_cccid", MFnData::kString); 132 | tAttr.setStorable(true); 133 | tAttr.setHidden(true); 134 | addAttribute(a_last_cccid); 135 | 136 | //a_direction 137 | a_direction = eAttr.create("direction", "direction", 0); 138 | eAttr.addField("Forward", 0); 139 | eAttr.addField("Inverse", 1); 140 | eAttr.setStorable(true); 141 | addAttribute(a_direction); 142 | 143 | //a_last_direction 144 | a_last_direction = nAttr.create("last_direction", "last_direction", MFnNumericData::kInt, 0); 145 | nAttr.setStorable(true); 146 | nAttr.setHidden(true); 147 | addAttribute(a_last_direction); 148 | 149 | //a_interpolation 150 | a_interpolation = eAttr.create("interpolation", "interpolation", 1); 151 | eAttr.addField("Nearest", 0); 152 | eAttr.addField("Linear", 1); 153 | eAttr.addField("Tetrahedral", 2); 154 | eAttr.addField("Best", 3); 155 | eAttr.setStorable(true); 156 | addAttribute(a_interpolation); 157 | 158 | //a_last_interpolation 159 | a_last_interpolation = nAttr.create("last_interpolation", "last_interpolation", MFnNumericData::kInt, 0); 160 | nAttr.setStorable(true); 161 | nAttr.setHidden(true); 162 | addAttribute(a_last_interpolation); 163 | 164 | //Attribute affects 165 | attributeAffects(a_input_color, a_output_color); 166 | attributeAffects(a_lut_file_path, a_output_color); 167 | attributeAffects(a_cccid, a_output_color); 168 | attributeAffects(a_direction, a_output_color); 169 | attributeAffects(a_interpolation, a_output_color); 170 | 171 | 172 | 173 | return MStatus::kSuccess; 174 | } 175 | 176 | //postConstructor 177 | void Ocio_file_transform::postConstructor() 178 | { 179 | //set first execution 180 | first_execution = true; 181 | 182 | //log 183 | MGlobal::displayInfo("Postconstructor executed"); 184 | }; 185 | 186 | //compute 187 | MStatus Ocio_file_transform::compute(const MPlug &plug, MDataBlock &data) 188 | { 189 | 190 | //wrong plug requested 191 | //----------------------------------------------- 192 | //----------------------------------------------- 193 | if ((plug != a_output_color) && (plug.parent() != a_output_color)) 194 | { 195 | return MStatus::kUnknownParameter; 196 | } 197 | 198 | 199 | 200 | 201 | 202 | //right plug requested 203 | //----------------------------------------------- 204 | //----------------------------------------------- 205 | 206 | 207 | //Get attributes 208 | //----------------------------------------------- 209 | 210 | //lut_file_path 211 | std::string lut_file_path = get_string_attribute(std::string("lut_file_path")); 212 | //last_lut_file_path 213 | std::string last_lut_file_path = get_string_attribute(std::string("last_lut_file_path")); 214 | 215 | //cccid 216 | std::string cccid = get_string_attribute(std::string("cccid")); 217 | //last_cccid 218 | std::string last_cccid = get_string_attribute(std::string("last_cccid")); 219 | 220 | //direction 221 | int direction = data.inputValue(a_direction).asInt(); 222 | //last_direction 223 | int last_direction = data.inputValue(a_last_direction).asInt(); 224 | 225 | //interpolation 226 | int interpolation = data.inputValue(a_interpolation).asInt(); 227 | //last_interpolation 228 | int last_interpolation = data.inputValue(a_last_interpolation).asInt(); 229 | 230 | 231 | 232 | 233 | 234 | 235 | //Set processor 236 | //----------------------------------------------- 237 | 238 | //first_execution 239 | if (first_execution) 240 | set_processor(lut_file_path, 241 | cccid, 242 | direction, 243 | interpolation); 244 | //lut_file_path 245 | else if (lut_file_path.compare(last_lut_file_path) != 0) 246 | set_processor(lut_file_path, 247 | cccid, 248 | direction, 249 | interpolation); 250 | //cccid 251 | else if (cccid.compare(last_cccid) != 0) 252 | set_processor(lut_file_path, 253 | cccid, 254 | direction, 255 | interpolation); 256 | //direction 257 | else if (direction != last_direction) 258 | set_processor(lut_file_path, 259 | cccid, 260 | direction, 261 | interpolation); 262 | //interpolation 263 | else if (interpolation != last_interpolation) 264 | set_processor(lut_file_path, 265 | cccid, 266 | direction, 267 | interpolation); 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | //Color conversion 276 | //----------------------------------------------- 277 | 278 | //vec_input_color 279 | MDataHandle h_input_color = data.inputValue(a_input_color); 280 | MFloatVector& vec_input_color = h_input_color.asFloatVector(); 281 | 282 | //transform_color 283 | if (processor) 284 | color_transform(vec_input_color); 285 | 286 | //set output color 287 | set_output_color(vec_input_color, data); 288 | 289 | 290 | 291 | 292 | 293 | 294 | //Set attributes 295 | //----------------------------------------------- 296 | 297 | //last_lut_file_path 298 | set_string_attribute("last_lut_file_path", lut_file_path); 299 | //cccid 300 | set_string_attribute("last_cccid", cccid); 301 | //direction 302 | set_int_attribute("last_direction", direction); 303 | //interpolation 304 | set_int_attribute("last_interpolation", interpolation); 305 | 306 | 307 | 308 | 309 | //set first execution to false 310 | first_execution = false; 311 | 312 | //return success 313 | return MStatus::kSuccess; 314 | 315 | } 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | //OCIO 324 | //----------------------------------------------- 325 | //----------------------------------------------- 326 | 327 | //set_processor 328 | void Ocio_file_transform::set_processor(std::string lut_file_path_value, 329 | std::string cccid_value, 330 | int direction_value, 331 | int interpolation_value) 332 | { 333 | 334 | 335 | //set processor 336 | processor = OCIO_functionality::get_processor_from_file_transform(lut_file_path_value, 337 | cccid_value, 338 | direction_value, 339 | interpolation_value); 340 | //msg_processor 341 | MString msg_processor("Processor set"); 342 | //msg_empty_lut_path 343 | MString msg_empty_lut_path("No Lut file path set. No transformation will be applied. "); 344 | 345 | //display msg 346 | if (!lut_file_path_value.size()) 347 | MGlobal::displayWarning(msg_empty_lut_path + msg_processor); 348 | else 349 | MGlobal::displayInfo(msg_processor); 350 | 351 | }; 352 | 353 | //color_transform 354 | void Ocio_file_transform::color_transform(MFloatVector& vec_input_color) 355 | { 356 | //pixels 357 | float pixels[3]; 358 | vec_input_color.get(pixels); 359 | 360 | //pixel_r, pixel_g, pixel_b; 361 | float* pixel_r = &pixels[0]; 362 | float* pixel_g = &pixels[1]; 363 | float* pixel_b = &pixels[2]; 364 | 365 | //convert 366 | OCIO_functionality::color_transform_single_pixel(pixel_r, pixel_g, pixel_b, processor); 367 | 368 | //set colors back to vec_input_color 369 | vec_input_color.x = pixels[0]; 370 | vec_input_color.y = pixels[1]; 371 | vec_input_color.z = pixels[2]; 372 | } 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | //States 381 | //----------------------------------------------- 382 | //----------------------------------------------- 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | //Own 396 | //----------------------------------------------- 397 | //----------------------------------------------- 398 | 399 | //get_string_attribute 400 | std::string Ocio_file_transform::get_string_attribute(std::string attr_name) 401 | { 402 | //p_attr 403 | MPlug p_attr = get_plug(attr_name); 404 | 405 | //ms_plug_value 406 | MString ms_plug_value = p_attr.asString(); 407 | 408 | //std_plug_value 409 | std::string std_plug_value(ms_plug_value.asChar()); 410 | 411 | return std_plug_value; 412 | }; 413 | 414 | //set_string_attribute 415 | void Ocio_file_transform::set_string_attribute(std::string attr_name, 416 | std::string value) 417 | { 418 | //p_attr 419 | MPlug p_attr = get_plug(attr_name); 420 | 421 | //ms_value 422 | MString ms_value(value.c_str()); 423 | 424 | //set value 425 | p_attr.setString(ms_value); 426 | }; 427 | 428 | //set_int_attribute 429 | void Ocio_file_transform::set_int_attribute(std::string attr_name, 430 | int value) 431 | { 432 | //p_attr 433 | MPlug p_attr = get_plug(attr_name); 434 | 435 | //set value 436 | p_attr.setInt(value); 437 | }; 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | //Helper 448 | //----------------------------------------------- 449 | //----------------------------------------------- 450 | 451 | //get_plug 452 | MPlug Ocio_file_transform::get_plug(std::string attr_name) 453 | { 454 | //node 455 | MObject node = thisMObject(); 456 | //fn_dep_node 457 | MFnDependencyNode fn_dep_node(node); 458 | //p_plug 459 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 460 | 461 | return p_plug; 462 | }; 463 | 464 | //attribute_exists 465 | bool Ocio_file_transform::attribute_exists(std::string attr_name) 466 | { 467 | //p_plug 468 | MPlug p_plug = get_plug(attr_name); 469 | 470 | return !p_plug.isNull(); 471 | 472 | }; 473 | 474 | //attr_connected 475 | bool Ocio_file_transform::attr_connected(std::string attr_name) 476 | { 477 | //p_plug 478 | MPlug p_plug = get_plug(attr_name); 479 | 480 | //return 481 | return p_plug.isConnected(); 482 | }; 483 | 484 | //set_output_color 485 | void Ocio_file_transform::set_output_color(MFloatVector& vec_color, MDataBlock& data) 486 | { 487 | MDataHandle h_output_color = data.outputValue(a_output_color); 488 | MFloatVector& vec_output_color = h_output_color.asFloatVector(); 489 | vec_output_color = vec_color; 490 | 491 | //clean handle 492 | h_output_color.setClean(); 493 | 494 | //tmp 495 | //MGlobal::displayInfo("Set output color attribute"); 496 | }; 497 | 498 | //get_instance_name 499 | std::string Ocio_file_transform::get_instance_name() 500 | { 501 | 502 | //ms_node_name 503 | MString ms_node_name = this->name(); 504 | 505 | //node_name 506 | std::string node_name = std::string(ms_node_name.asChar()); 507 | 508 | return node_name; 509 | }; 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | //Temp 524 | //----------------------------------------------- 525 | //----------------------------------------------- 526 | 527 | -------------------------------------------------------------------------------- /ocio_maya/source/ocio_file_transform.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_FILE_TRANSFORM_H 4 | #define OCIO_FILE_TRANSFORM_H 5 | 6 | //Ocio_file_transform Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //Own 25 | #include "ocio_functionality.h" 26 | //Maya 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | 49 | 50 | 51 | //Ocio_file_transform 52 | //----------------------------------------------- 53 | class Ocio_file_transform : public MPxNode 54 | { 55 | public: 56 | //Attributes 57 | static MTypeId id; 58 | static MString type_name; 59 | 60 | static MObject a_verbose; 61 | 62 | static MObject a_input_color; 63 | static MObject a_output_color; 64 | 65 | static MObject a_lut_file_path; 66 | static MObject a_last_lut_file_path; 67 | static MObject a_cccid; 68 | static MObject a_last_cccid; 69 | static MObject a_direction; 70 | static MObject a_last_direction; 71 | static MObject a_interpolation; 72 | static MObject a_last_interpolation; 73 | 74 | 75 | //Methods 76 | //Maya 77 | Ocio_file_transform(); 78 | virtual ~Ocio_file_transform(); 79 | static void* create(); 80 | static MStatus initialize(); 81 | virtual void postConstructor(); 82 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 83 | //OCIO 84 | void set_processor(std::string, std::string, int, int); 85 | void color_transform(MFloatVector&); 86 | //States 87 | 88 | //Own 89 | std::string get_string_attribute(std::string); 90 | void set_string_attribute(std::string, std::string); 91 | void set_int_attribute(std::string, int); 92 | //Helper 93 | MPlug get_plug(std::string); 94 | bool attribute_exists(std::string); 95 | bool attr_connected(std::string); 96 | void set_output_color(MFloatVector&, MDataBlock&); 97 | std::string get_instance_name(); 98 | //Temp 99 | 100 | 101 | 102 | private: 103 | //Attributes 104 | bool first_execution; 105 | OCIO::ConstProcessorRcPtr processor; 106 | 107 | //Methods 108 | 109 | 110 | }; 111 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_log_convert.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_log_convert Implementation 4 | //----------------------------------------------- 5 | //----------------------------------------------- 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | //----------------------------------------------- 17 | #include "ocio_log_convert.h" 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | //Ocio_test 27 | //----------------------------------------------- 28 | //----------------------------------------------- 29 | 30 | 31 | 32 | //Static Attributes 33 | //----------------------------------------------- 34 | //----------------------------------------------- 35 | MTypeId Ocio_log_convert::id(0x00004); 36 | MString Ocio_log_convert::type_name("OCIOLogConvert"); 37 | 38 | MObject Ocio_log_convert::a_verbose; 39 | 40 | MObject Ocio_log_convert::a_input_color; 41 | MObject Ocio_log_convert::a_output_color; 42 | 43 | MObject Ocio_log_convert::a_env_or_file; 44 | MObject Ocio_log_convert::a_last_env_or_file; 45 | MObject Ocio_log_convert::a_config_file_path; 46 | MObject Ocio_log_convert::a_last_config_file_path; 47 | MObject Ocio_log_convert::a_operation; 48 | MObject Ocio_log_convert::a_last_operation; 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | //Methods 57 | //----------------------------------------------- 58 | //----------------------------------------------- 59 | 60 | 61 | 62 | 63 | 64 | //Maya 65 | //----------------------------------------------- 66 | //----------------------------------------------- 67 | 68 | //Constructor 69 | Ocio_log_convert::Ocio_log_convert() : 70 | processor(0) 71 | { 72 | }; 73 | 74 | //Destructor 75 | Ocio_log_convert::~Ocio_log_convert(){}; 76 | 77 | 78 | //create 79 | void* Ocio_log_convert::create() 80 | { 81 | return new Ocio_log_convert(); 82 | } 83 | 84 | 85 | //initialize 86 | MStatus Ocio_log_convert::initialize() 87 | { 88 | 89 | //MFnSets 90 | MFnEnumAttribute eAttr; 91 | MFnNumericAttribute nAttr; 92 | MFnTypedAttribute tAttr; 93 | 94 | 95 | //a_verbose 96 | a_verbose = eAttr.create("verbose", "verbose", 1); 97 | eAttr.addField("no verbose", 0); 98 | eAttr.addField("verbose", 1); 99 | addAttribute(a_verbose); 100 | 101 | //a_input_color 102 | a_input_color = nAttr.createColor("input_color", "input_color"); 103 | nAttr.setUsedAsColor(true); 104 | nAttr.setStorable(true); 105 | addAttribute(a_input_color); 106 | 107 | //a_output_color 108 | a_output_color = nAttr.createColor("output_color", "output_color"); 109 | nAttr.setUsedAsColor(true); 110 | nAttr.setStorable(false); 111 | addAttribute(a_output_color); 112 | 113 | //a_env_or_file 114 | a_env_or_file = eAttr.create("env_or_file", "env_or_file", 0); 115 | eAttr.addField("OCIO Environment Variable", 0); 116 | eAttr.addField("Custom Path", 1); 117 | eAttr.setStorable(true); 118 | addAttribute(a_env_or_file); 119 | 120 | //a_last_env_or_file 121 | a_last_env_or_file = nAttr.create("last_env_or_file", "last_env_or_file", MFnNumericData::kInt, 0); 122 | nAttr.setHidden(true); 123 | nAttr.setStorable(true); 124 | addAttribute(a_last_env_or_file); 125 | 126 | //a_config_file_path 127 | a_config_file_path = tAttr.create("config_file_path", "config_file_path", MFnData::kString); 128 | tAttr.setUsedAsFilename(true); 129 | tAttr.setStorable(true); 130 | addAttribute(a_config_file_path); 131 | 132 | //a_last_config_file_path 133 | a_last_config_file_path = tAttr.create("last_config_file_path", "last_config_file_path", MFnData::kString); 134 | tAttr.setHidden(true); 135 | tAttr.setStorable(true); 136 | addAttribute(a_last_config_file_path); 137 | 138 | //a_operation 139 | a_operation = eAttr.create("operation", "operation", 0); 140 | eAttr.addField("Log to Lin", 0); 141 | eAttr.addField("Lin to Log", 1); 142 | addAttribute(a_operation); 143 | 144 | //a_last_operation 145 | a_last_operation = nAttr.create("last_operation", "last_operation", MFnNumericData::kInt, 0); 146 | nAttr.setHidden(true); 147 | nAttr.setStorable(true); 148 | addAttribute(a_last_operation); 149 | 150 | 151 | 152 | 153 | 154 | 155 | //Attribute affects 156 | attributeAffects(a_input_color, a_output_color); 157 | attributeAffects(a_env_or_file, a_output_color); 158 | attributeAffects(a_config_file_path, a_output_color); 159 | attributeAffects(a_operation, a_output_color); 160 | 161 | 162 | 163 | 164 | return MStatus::kSuccess; 165 | } 166 | 167 | //postConstructor 168 | void Ocio_log_convert::postConstructor() 169 | { 170 | //set first execution 171 | first_execution = true; 172 | 173 | //log 174 | MGlobal::displayInfo("Postconstructor executed"); 175 | }; 176 | 177 | //compute 178 | MStatus Ocio_log_convert::compute(const MPlug &plug, MDataBlock &data) 179 | { 180 | 181 | //wrong plug requested 182 | //----------------------------------------------- 183 | //----------------------------------------------- 184 | if ((plug != a_output_color) && (plug.parent() != a_output_color)) 185 | { 186 | return MStatus::kUnknownParameter; 187 | } 188 | 189 | 190 | 191 | 192 | 193 | //right plug requested 194 | //----------------------------------------------- 195 | //----------------------------------------------- 196 | 197 | 198 | //Get attributes 199 | //----------------------------------------------- 200 | 201 | //env_or_file 202 | int env_or_file = data.inputValue(a_env_or_file).asInt(); 203 | //last_env_or_file 204 | int last_env_or_file = data.inputValue(a_last_env_or_file).asInt(); 205 | 206 | //config_file_path 207 | std::string config_file_path = get_string_attribute(std::string("config_file_path")); 208 | //last_config_file_path 209 | std::string last_config_file_path = get_string_attribute(std::string("last_config_file_path")); 210 | 211 | //operation 212 | int operation = data.inputValue(a_operation).asInt(); 213 | //last_operation 214 | int last_operation = data.inputValue(a_last_operation).asInt(); 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | //Set processor 225 | //----------------------------------------------- 226 | 227 | //first_execution 228 | if (first_execution) 229 | set_processor(env_or_file, 230 | config_file_path, 231 | operation); 232 | //env_or_file 233 | else if (env_or_file != last_env_or_file) 234 | set_processor(env_or_file, 235 | config_file_path, 236 | operation); 237 | //config_file_path 238 | else if (config_file_path.compare(last_config_file_path) != 0) 239 | set_processor(env_or_file, 240 | config_file_path, 241 | operation); 242 | //operation 243 | else if (operation != last_operation) 244 | set_processor(env_or_file, 245 | config_file_path, 246 | operation); 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | //Color conversion 255 | //----------------------------------------------- 256 | 257 | //vec_input_color 258 | MDataHandle h_input_color = data.inputValue(a_input_color); 259 | MFloatVector& vec_input_color = h_input_color.asFloatVector(); 260 | 261 | //transform_color 262 | if (processor) 263 | color_transform(vec_input_color); 264 | 265 | //set output color 266 | set_output_color(vec_input_color, data); 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | //Set attributes 275 | //----------------------------------------------- 276 | 277 | //last_env_or_file 278 | set_int_attribute("last_env_or_file", env_or_file); 279 | //last_config_file_path 280 | set_string_attribute("last_config_file_path", config_file_path); 281 | //last_operation 282 | set_int_attribute("last_operation", operation); 283 | 284 | 285 | 286 | //set first execution to false 287 | first_execution = false; 288 | 289 | //return success 290 | return MStatus::kSuccess; 291 | 292 | } 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | //OCIO 301 | //----------------------------------------------- 302 | //----------------------------------------------- 303 | 304 | //set_processor 305 | void Ocio_log_convert::set_processor(int env_or_file, 306 | std::string config_file_path, 307 | int operation) 308 | { 309 | 310 | 311 | //set processor 312 | processor = OCIO_functionality::get_processor(env_or_file, 313 | config_file_path, 314 | operation); 315 | //msg_processor 316 | MString msg_processor("Processor set"); 317 | //msg_empty_config_path 318 | MString msg_empty_config_path("No config file path set. No transformation will be applied. "); 319 | 320 | //display msg 321 | if ((!config_file_path.size()) && (env_or_file == 1)) 322 | MGlobal::displayWarning(msg_empty_config_path + msg_processor); 323 | else 324 | MGlobal::displayInfo(msg_processor); 325 | 326 | }; 327 | 328 | //color_transform 329 | void Ocio_log_convert::color_transform(MFloatVector& vec_input_color) 330 | { 331 | //pixels 332 | float pixels[3]; 333 | vec_input_color.get(pixels); 334 | 335 | //pixel_r, pixel_g, pixel_b; 336 | float* pixel_r = &pixels[0]; 337 | float* pixel_g = &pixels[1]; 338 | float* pixel_b = &pixels[2]; 339 | 340 | //convert 341 | OCIO_functionality::color_transform_single_pixel(pixel_r, pixel_g, pixel_b, processor); 342 | 343 | //set colors back to vec_input_color 344 | vec_input_color.x = pixels[0]; 345 | vec_input_color.y = pixels[1]; 346 | vec_input_color.z = pixels[2]; 347 | } 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | //States 356 | //----------------------------------------------- 357 | //----------------------------------------------- 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | //Own 371 | //----------------------------------------------- 372 | //----------------------------------------------- 373 | 374 | //get_string_attribute 375 | std::string Ocio_log_convert::get_string_attribute(std::string attr_name) 376 | { 377 | //p_attr 378 | MPlug p_attr = get_plug(attr_name); 379 | 380 | //ms_plug_value 381 | MString ms_plug_value = p_attr.asString(); 382 | 383 | //std_plug_value 384 | std::string std_plug_value(ms_plug_value.asChar()); 385 | 386 | return std_plug_value; 387 | }; 388 | 389 | //set_string_attribute 390 | void Ocio_log_convert::set_string_attribute(std::string attr_name, 391 | std::string value) 392 | { 393 | //p_attr 394 | MPlug p_attr = get_plug(attr_name); 395 | 396 | //ms_value 397 | MString ms_value(value.c_str()); 398 | 399 | //set value 400 | p_attr.setString(ms_value); 401 | }; 402 | 403 | //set_int_attribute 404 | void Ocio_log_convert::set_int_attribute(std::string attr_name, 405 | int value) 406 | { 407 | //p_attr 408 | MPlug p_attr = get_plug(attr_name); 409 | 410 | //set value 411 | p_attr.setInt(value); 412 | }; 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | //Helper 423 | //----------------------------------------------- 424 | //----------------------------------------------- 425 | 426 | //get_plug 427 | MPlug Ocio_log_convert::get_plug(std::string attr_name) 428 | { 429 | //node 430 | MObject node = thisMObject(); 431 | //fn_dep_node 432 | MFnDependencyNode fn_dep_node(node); 433 | //p_plug 434 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 435 | 436 | return p_plug; 437 | }; 438 | 439 | //attribute_exists 440 | bool Ocio_log_convert::attribute_exists(std::string attr_name) 441 | { 442 | //p_plug 443 | MPlug p_plug = get_plug(attr_name); 444 | 445 | return !p_plug.isNull(); 446 | 447 | }; 448 | 449 | //attr_connected 450 | bool Ocio_log_convert::attr_connected(std::string attr_name) 451 | { 452 | //p_plug 453 | MPlug p_plug = get_plug(attr_name); 454 | 455 | //return 456 | return p_plug.isConnected(); 457 | }; 458 | 459 | //set_output_color 460 | void Ocio_log_convert::set_output_color(MFloatVector& vec_color, MDataBlock& data) 461 | { 462 | MDataHandle h_output_color = data.outputValue(a_output_color); 463 | MFloatVector& vec_output_color = h_output_color.asFloatVector(); 464 | vec_output_color = vec_color; 465 | 466 | //clean handle 467 | h_output_color.setClean(); 468 | 469 | //tmp 470 | //MGlobal::displayInfo("Set output color attribute"); 471 | }; 472 | 473 | //get_instance_name 474 | std::string Ocio_log_convert::get_instance_name() 475 | { 476 | 477 | //ms_node_name 478 | MString ms_node_name = this->name(); 479 | 480 | //node_name 481 | std::string node_name = std::string(ms_node_name.asChar()); 482 | 483 | return node_name; 484 | }; 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | //Temp 499 | //----------------------------------------------- 500 | //----------------------------------------------- 501 | 502 | -------------------------------------------------------------------------------- /ocio_maya/source/ocio_log_convert.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_LOG_CONVERT_H 4 | #define OCIO_LOG_CONVERT_H 5 | 6 | //Ocio_log_convert Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //Own 25 | #include "ocio_functionality.h" 26 | //Maya 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | 49 | 50 | 51 | //Ocio_log_convert 52 | //----------------------------------------------- 53 | class Ocio_log_convert : public MPxNode 54 | { 55 | public: 56 | //Attributes 57 | static MTypeId id; 58 | static MString type_name; 59 | 60 | static MObject a_verbose; 61 | 62 | static MObject a_input_color; 63 | static MObject a_output_color; 64 | 65 | static MObject a_env_or_file; 66 | static MObject a_last_env_or_file; 67 | static MObject a_config_file_path; 68 | static MObject a_last_config_file_path; 69 | static MObject a_operation; 70 | static MObject a_last_operation; 71 | 72 | 73 | 74 | //Methods 75 | //Maya 76 | Ocio_log_convert(); 77 | virtual ~Ocio_log_convert(); 78 | static void* create(); 79 | static MStatus initialize(); 80 | virtual void postConstructor(); 81 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 82 | //OCIO 83 | void set_processor(int, std::string, int); 84 | void color_transform(MFloatVector&); 85 | //States 86 | 87 | //Own 88 | std::string get_string_attribute(std::string); 89 | void set_string_attribute(std::string, std::string); 90 | void set_int_attribute(std::string, int); 91 | //Helper 92 | MPlug get_plug(std::string); 93 | bool attribute_exists(std::string); 94 | bool attr_connected(std::string); 95 | void set_output_color(MFloatVector&, MDataBlock&); 96 | std::string get_instance_name(); 97 | //Temp 98 | 99 | 100 | 101 | private: 102 | //Attributes 103 | bool first_execution; 104 | OCIO::ConstProcessorRcPtr processor; 105 | 106 | //Methods 107 | 108 | 109 | }; 110 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_plugin.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //ocio_plugin Implementation 4 | //----------------------------------------------- 5 | /* 6 | Exported functions that maya uses to register the plugin 7 | */ 8 | 9 | //Preprocessor 10 | //----------------------------------------------- 11 | #define EXPORT __declspec(dllexport) 12 | 13 | 14 | //include 15 | //----------------------------------------------- 16 | //ocio_maya 17 | #include "ocio_test.h" 18 | #include "ocio_simple_transform.h" 19 | #include "ocio_colorspace.h" 20 | #include "ocio_file_transform.h" 21 | #include "ocio_log_convert.h" 22 | #include "ocio_cdl_transform.h" 23 | #include "ocio_export_cc.h" 24 | //Maya 25 | #include 26 | 27 | 28 | 29 | 30 | 31 | //initialize 32 | //----------------------------------------------- 33 | EXPORT MStatus initializePlugin(MObject obj) 34 | { 35 | MStatus status; 36 | 37 | //initialize plugin functionset 38 | MFnPlugin fnPlugin(obj, "Timm Wagener", "0.1", "2012"); 39 | 40 | //ocio_test 41 | status = fnPlugin.registerNode(Ocio_test::type_name, Ocio_test::id, Ocio_test::create, Ocio_test::initialize, MPxNode::kDependNode); 42 | //ocio_simple_transform 43 | status = fnPlugin.registerNode(Ocio_simple_transform::type_name, Ocio_simple_transform::id, Ocio_simple_transform::create, Ocio_simple_transform::initialize, MPxNode::kDependNode); 44 | //OCIOColorspace 45 | status = fnPlugin.registerNode(Ocio_colorspace::type_name, Ocio_colorspace::id, Ocio_colorspace::create, Ocio_colorspace::initialize, MPxNode::kDependNode); 46 | //OCIOFileTransform 47 | status = fnPlugin.registerNode(Ocio_file_transform::type_name, Ocio_file_transform::id, Ocio_file_transform::create, Ocio_file_transform::initialize, MPxNode::kDependNode); 48 | //OCIOLogConvert 49 | status = fnPlugin.registerNode(Ocio_log_convert::type_name, Ocio_log_convert::id, Ocio_log_convert::create, Ocio_log_convert::initialize, MPxNode::kDependNode); 50 | //OCIOCDLTransform 51 | status = fnPlugin.registerNode(Ocio_cdl_transform::type_name, Ocio_cdl_transform::id, Ocio_cdl_transform::create, Ocio_cdl_transform::initialize, MPxNode::kDependNode); 52 | 53 | //ocio_export_cc 54 | status = fnPlugin.registerCommand("ocio_export_cc", Ocio_export_cc::creator, Ocio_export_cc::new_syntax); 55 | 56 | 57 | return MStatus::kSuccess; 58 | } 59 | 60 | 61 | //uninitialize 62 | //----------------------------------------------- 63 | EXPORT MStatus uninitializePlugin(MObject obj) 64 | { 65 | MStatus status; 66 | 67 | //initialize plugin functionset 68 | MFnPlugin fnPlugin(obj); 69 | 70 | //ocio_test 71 | status = fnPlugin.deregisterNode(Ocio_test::id); 72 | //ocio_simple_transform 73 | status = fnPlugin.deregisterNode(Ocio_simple_transform::id); 74 | //OCIOColorspace 75 | status = fnPlugin.deregisterNode(Ocio_colorspace::id); 76 | //OCIOFileTransform 77 | status = fnPlugin.deregisterNode(Ocio_file_transform::id); 78 | //OCIOLogConvert 79 | status = fnPlugin.deregisterNode(Ocio_log_convert::id); 80 | //OCIOCDLTransform 81 | status = fnPlugin.deregisterNode(Ocio_cdl_transform::id); 82 | 83 | //ocio_export_cc 84 | status = fnPlugin.deregisterCommand("ocio_export_cc"); 85 | 86 | 87 | return MStatus::kSuccess; 88 | } 89 | -------------------------------------------------------------------------------- /ocio_maya/source/ocio_simple_transform.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_simple_transform Implementation 4 | //----------------------------------------------- 5 | 6 | 7 | //include 8 | //----------------------------------------------- 9 | #include "ocio_simple_transform.h" 10 | 11 | 12 | //Ocio_test 13 | //----------------------------------------------- 14 | 15 | //Attributes 16 | MTypeId Ocio_simple_transform::id(0x00001); 17 | MString Ocio_simple_transform::type_name("ocio_simple_transform"); 18 | 19 | MObject Ocio_simple_transform::a_verbose; 20 | MObject Ocio_simple_transform::a_input_color; 21 | MObject Ocio_simple_transform::a_output_color; 22 | 23 | 24 | //Constructor / Deconstructor 25 | //----------------------------------------------- 26 | Ocio_simple_transform::Ocio_simple_transform(): 27 | config(0), 28 | processor(0) 29 | { 30 | }; 31 | Ocio_simple_transform::~Ocio_simple_transform(){}; 32 | 33 | 34 | //create 35 | //----------------------------------------------- 36 | void* Ocio_simple_transform::create() 37 | { 38 | return new Ocio_simple_transform(); 39 | } 40 | 41 | 42 | //initialize 43 | //----------------------------------------------- 44 | MStatus Ocio_simple_transform::initialize() 45 | { 46 | 47 | //MFnSets 48 | MFnEnumAttribute eAttr; 49 | MFnNumericAttribute nAttr; 50 | 51 | 52 | //a_verbose 53 | a_verbose = eAttr.create("verbose", "verbose", 0); 54 | eAttr.addField("no verbose", 0); 55 | eAttr.addField("verbose", 1); 56 | addAttribute(a_verbose); 57 | 58 | //a_input_color 59 | a_input_color = nAttr.createColor("input_color", "input_color"); 60 | nAttr.setUsedAsColor(true); 61 | nAttr.setStorable(false); 62 | addAttribute(a_input_color); 63 | 64 | //a_output_color 65 | a_output_color = nAttr.createColor("output_color", "output_color"); 66 | nAttr.setUsedAsColor(true); 67 | nAttr.setStorable(false); 68 | addAttribute(a_output_color); 69 | 70 | 71 | 72 | //Attribute affects 73 | attributeAffects(a_input_color, a_output_color); 74 | 75 | return MStatus::kSuccess; 76 | } 77 | 78 | //postConstructor 79 | //----------------------------------------------- 80 | void Ocio_simple_transform::postConstructor() 81 | { 82 | //node 83 | MObject node = thisMObject(); 84 | 85 | //create config 86 | config = OCIO_functionality::get_config_from_env(); 87 | 88 | //processor 89 | std::string input_colorspace("sRGB"); 90 | std::string output_colorspace("SLog"); 91 | processor = OCIO_functionality::get_processor(config, input_colorspace, output_colorspace); 92 | 93 | 94 | //temp 95 | MGlobal::displayInfo("Postconstructor executed"); 96 | }; 97 | 98 | //compute 99 | //----------------------------------------------- 100 | MStatus Ocio_simple_transform::compute(const MPlug &plug, MDataBlock &data) 101 | { 102 | //wrong plug requested 103 | //----------------------------------------------- 104 | if ((plug != a_output_color) && (plug.parent() != a_output_color)) 105 | { 106 | return MStatus::kUnknownParameter; 107 | } 108 | 109 | //right plug requested 110 | //----------------------------------------------- 111 | 112 | //get attributes from datablock 113 | //----------------------------------------------- 114 | int verbose = static_cast(data.inputValue(a_verbose).asShort()); 115 | //vec_input_color 116 | MDataHandle h_input_color = data.inputValue(a_input_color); 117 | MFloatVector& vec_input_color = h_input_color.asFloatVector(); 118 | 119 | 120 | 121 | //computation 122 | //----------------------------------------------- 123 | 124 | //print_config_info 125 | //print_config_info(); 126 | 127 | //pixels 128 | float pixels[3]; 129 | vec_input_color.get(pixels); 130 | 131 | //planar_image 132 | OCIO::PlanarImageDesc planar_image(&pixels[0], &pixels[1], &pixels[2], NULL, 1, 1); 133 | //apply transform 134 | processor->apply(planar_image); 135 | 136 | //set colors back to vec_input_color 137 | vec_input_color.x = pixels[0]; 138 | vec_input_color.y = pixels[1]; 139 | vec_input_color.z = pixels[2]; 140 | 141 | //set output color 142 | set_output_color(vec_input_color, data); 143 | 144 | 145 | 146 | //log 147 | //if (verbose) 148 | // MGlobal::displayInfo("Compute executed"); 149 | //return success 150 | return MStatus::kSuccess; 151 | 152 | } 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | //Own 164 | //----------------------------------------------- 165 | 166 | 167 | //attr_connected 168 | bool Ocio_simple_transform::attr_connected(std::string attr_name) 169 | { 170 | //node 171 | MObject node = thisMObject(); 172 | //fn_dep_node 173 | MFnDependencyNode fn_dep_node(node); 174 | //p_plug 175 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 176 | 177 | //return 178 | return p_plug.isConnected(); 179 | }; 180 | 181 | //set_output_color 182 | void Ocio_simple_transform::set_output_color(MFloatVector& vec_color, MDataBlock& data) 183 | { 184 | //h_output_color 185 | MDataHandle h_output_color = data.outputValue(a_output_color); 186 | MFloatVector& vec_output_color = h_output_color.asFloatVector(); 187 | vec_output_color = vec_color; 188 | 189 | //clean handle 190 | h_output_color.setClean(); 191 | 192 | //tmp 193 | //MGlobal::displayInfo("Set output color attribute"); 194 | }; 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | //Temp 204 | //----------------------------------------------- 205 | //print_config_info 206 | void Ocio_simple_transform::print_config_info() 207 | { 208 | OCIO_functionality::print_config_info(config); 209 | }; -------------------------------------------------------------------------------- /ocio_maya/source/ocio_simple_transform.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_SIMPLE_TRANSFORM_H 4 | #define OCIO_SIMPLE_TRANSFORM_H 5 | 6 | //Ocio_simple_transform Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | //Own 25 | #include "ocio_functionality.h" 26 | //Maya 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | 49 | 50 | 51 | //Ocio_simple_transform 52 | //----------------------------------------------- 53 | class Ocio_simple_transform : public MPxNode 54 | { 55 | public: 56 | //Attributes 57 | static MTypeId id; 58 | static MString type_name; 59 | 60 | static MObject a_verbose; 61 | static MObject a_input_color; 62 | static MObject a_output_color; 63 | 64 | //Methods 65 | //Maya 66 | Ocio_simple_transform(); 67 | virtual ~Ocio_simple_transform(); 68 | static void* create(); 69 | static MStatus initialize(); 70 | virtual void postConstructor(); 71 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 72 | //Own 73 | bool attr_connected(std::string); 74 | void set_output_color(MFloatVector&, MDataBlock&); 75 | //Temp 76 | void print_config_info(); 77 | 78 | 79 | private: 80 | //Attributes 81 | OCIO::ConstConfigRcPtr config; 82 | OCIO::ConstProcessorRcPtr processor; 83 | 84 | //Methods 85 | 86 | 87 | }; 88 | #endif -------------------------------------------------------------------------------- /ocio_maya/source/ocio_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Ocio_test Implementation 4 | //----------------------------------------------- 5 | 6 | 7 | //include 8 | //----------------------------------------------- 9 | #include "ocio_test.h" 10 | 11 | 12 | //Ocio_test 13 | //----------------------------------------------- 14 | 15 | //Attributes 16 | MTypeId Ocio_test::id(0x00000); 17 | MString Ocio_test::type_name("ocio_test"); 18 | 19 | MObject Ocio_test::a_verbose; 20 | 21 | MObject Ocio_test::a_change_list; 22 | MObject Ocio_test::a_last_change_index; 23 | 24 | MObject Ocio_test::a_input_color; 25 | MObject Ocio_test::a_width; 26 | MObject Ocio_test::a_height; 27 | 28 | MObject Ocio_test::a_config_path; 29 | 30 | MObject Ocio_test::a_output_color; 31 | 32 | 33 | //Methods 34 | Ocio_test::Ocio_test(): 35 | boost_signal_helloworld(new Boost_signal_helloworld()) 36 | { 37 | }; 38 | Ocio_test::~Ocio_test(){} 39 | 40 | 41 | //create 42 | //----------------------------------------------- 43 | void* Ocio_test::create() 44 | { 45 | return new Ocio_test(); 46 | } 47 | 48 | 49 | //initialize 50 | //----------------------------------------------- 51 | MStatus Ocio_test::initialize() 52 | { 53 | 54 | //MFnSets 55 | MFnEnumAttribute eAttr; 56 | MFnNumericAttribute nAttr; 57 | MFnCompoundAttribute cAttr; 58 | MFnTypedAttribute tAttr; 59 | 60 | 61 | //a_verbose 62 | a_verbose = eAttr.create("verbose", "verbose", 0); 63 | eAttr.addField("no verbose", 0); 64 | eAttr.addField("verbose", 1); 65 | addAttribute(a_verbose); 66 | 67 | //a_change_list 68 | a_change_list = eAttr.create("change_list", "change_list", 0); 69 | eAttr.addField("type 1", 0); 70 | eAttr.addField("type 2", 1); 71 | addAttribute(a_change_list); 72 | 73 | //a_last_change_index 74 | a_last_change_index = nAttr.create("last_change_index", "last_change_index", MFnNumericData::kInt, 9999); 75 | nAttr.setStorable(false); 76 | addAttribute(a_last_change_index); 77 | 78 | //a_input_color 79 | a_input_color = nAttr.createColor("input_color", "input_color"); 80 | nAttr.setUsedAsColor(true); 81 | nAttr.setStorable(false); 82 | addAttribute(a_input_color); 83 | 84 | //a_width 85 | a_width = nAttr.create("width", "width", MFnNumericData::kInt); 86 | nAttr.setStorable(false); 87 | addAttribute(a_width); 88 | 89 | //a_height 90 | a_height = nAttr.create("height", "height", MFnNumericData::kInt); 91 | nAttr.setStorable(false); 92 | addAttribute(a_height); 93 | 94 | //a_config_path 95 | a_config_path = tAttr.create("config_path", "config_path", MFnData::kString); 96 | tAttr.setUsedAsFilename(true); 97 | tAttr.setStorable(true); 98 | addAttribute(a_config_path); 99 | 100 | //a_output_color 101 | a_output_color = nAttr.createColor("output_color", "output_color"); 102 | nAttr.setStorable(false); 103 | addAttribute(a_output_color); 104 | 105 | 106 | 107 | //Attribute affects 108 | attributeAffects(a_change_list, a_output_color); 109 | attributeAffects(a_input_color, a_output_color); 110 | attributeAffects(a_width, a_output_color); 111 | attributeAffects(a_height, a_output_color); 112 | 113 | return MStatus::kSuccess; 114 | } 115 | 116 | //postConstructor 117 | //----------------------------------------------- 118 | void Ocio_test::postConstructor() 119 | { 120 | //node 121 | MObject node = thisMObject(); 122 | 123 | //value_list 124 | std::string attribute_name("input_colorspace"); 125 | 126 | //value_list 127 | std::vector value_list; 128 | value_list.push_back("HansPeter"); 129 | value_list.push_back("Simon"); 130 | value_list.push_back("Siggi"); 131 | 132 | //create_enum_attribute 133 | create_enum_attribute(attribute_name, 134 | value_list, 135 | node); 136 | 137 | //emit test signal 138 | sig_postconstructor.connect(*boost_signal_helloworld); 139 | sig_postconstructor(); 140 | 141 | }; 142 | 143 | //setDependentsDirty 144 | //----------------------------------------------- 145 | MStatus Ocio_test::setDependentsDirty(const MPlug& plugBeingDirtied, MPlugArray& affectedPlugs) 146 | { 147 | MStatus status; 148 | MObject node = thisMObject(); 149 | MFnDependencyNode fn_dep_node(node); 150 | 151 | if(plugBeingDirtied.partialName() == "input_colorspace") 152 | { 153 | MPlug p_output = fn_dep_node.findPlug( "output_color", &status ); 154 | if(MStatus::kSuccess == status) 155 | { 156 | CHECK_MSTATUS(affectedPlugs.append(p_output)); 157 | MGlobal::displayInfo("Plug output appended"); 158 | } 159 | } 160 | 161 | 162 | 163 | return MStatus::kSuccess; 164 | }; 165 | 166 | //compute 167 | //----------------------------------------------- 168 | MStatus Ocio_test::compute(const MPlug &plug, MDataBlock &data) 169 | { 170 | //wrong plug requested 171 | //----------------------------------------------- 172 | if ((plug != a_output_color) && (plug.parent() != a_output_color)) 173 | { 174 | return MStatus::kUnknownParameter; 175 | }; 176 | 177 | 178 | //right plug requested 179 | //----------------------------------------------- 180 | 181 | //get attributes from datablock 182 | //----------------------------------------------- 183 | int verbose = static_cast(data.inputValue(a_verbose).asShort()); 184 | int change_list_index = static_cast(data.inputValue(a_change_list).asShort()); 185 | int last_change_index = data.inputValue(a_last_change_index).asInt(); 186 | 187 | int width = data.inputValue(a_width).asInt(); 188 | int height = data.inputValue(a_height).asInt(); 189 | 190 | //vec_input_color 191 | MDataHandle h_input_color = data.inputValue(a_input_color); 192 | MFloatVector& vec_input_color = h_input_color.asFloatVector(); 193 | 194 | 195 | //compute 196 | //----------------------------------------------- 197 | 198 | //check if attrs are connected 199 | if (!all_attrs_connected()) 200 | { 201 | if (verbose) 202 | MGlobal::displayInfo("Some attrs are not connected. Returning...."); 203 | return MStatus::kSuccess; 204 | }; 205 | //check if width or height == 0 206 | if (width == 0 || height == 0) 207 | { 208 | if (verbose) 209 | MGlobal::displayInfo("Either width or height is zero. Returning...."); 210 | return MStatus::kSuccess; 211 | }; 212 | 213 | //rebuild_input_colorspace 214 | if (!last_change_index == change_list_index) 215 | { 216 | //log 217 | if (verbose) 218 | MGlobal::displayInfo("Rebuild input colorspace"); 219 | //rebuild input colorspace 220 | rebuild_input_colorspace(change_list_index, data); 221 | } 222 | 223 | //print_config_info 224 | //print_config_info(); 225 | 226 | //set output color 227 | set_output_color(vec_input_color, data); 228 | 229 | //log 230 | //if (verbose) 231 | //MGlobal::displayInfo("Compute executed"); 232 | 233 | //return success 234 | return MStatus::kSuccess; 235 | 236 | } 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | //Own 248 | //----------------------------------------------- 249 | 250 | //rebuild_enum 251 | void Ocio_test::rebuild_input_colorspace(int& change_list_index, MDataBlock& data) 252 | { 253 | //config 254 | OCIO::ConstConfigRcPtr config; 255 | config = OCIO_functionality::get_config_from_env(); 256 | 257 | 258 | //config_colorspaces 259 | std::vector config_colorspaces = OCIO_functionality::get_colorspace_names(config); 260 | if (!config_colorspaces.size()) 261 | { 262 | //tmp 263 | MGlobal::displayInfo("Config colorspaces empty. Returning None"); 264 | return; 265 | }; 266 | 267 | //node 268 | MObject node = thisMObject(); 269 | 270 | //value_list 271 | std::string attribute_name("input_colorspace"); 272 | 273 | 274 | //update_enum_attribute 275 | //remove attribute 276 | remove_attribute(node, attribute_name); 277 | 278 | //create_enum_attribute 279 | create_enum_attribute(attribute_name, 280 | config_colorspaces, 281 | node); 282 | 283 | 284 | 285 | //Set last change index 286 | data.outputValue(a_last_change_index).setInt(change_list_index); 287 | //format 288 | boost::format change_index_msg("Last change index set to: %s"); 289 | change_index_msg % change_list_index; 290 | MGlobal::displayInfo(change_index_msg.str().c_str()); 291 | 292 | }; 293 | 294 | //create_enum_attribute 295 | void Ocio_test::create_enum_attribute(std::string attribute_name, 296 | std::vector& value_list, 297 | MObject& node) 298 | { 299 | //eAttr 300 | MFnEnumAttribute eAttr; 301 | 302 | //a_attribute 303 | MObject a_attribute = eAttr.create(attribute_name.c_str(), attribute_name.c_str(), 0); 304 | eAttr.setStorable(true); 305 | //iterate and add values 306 | for(int index = 0; index < value_list.size(); index++) 307 | eAttr.addField(value_list[index].c_str(), index); 308 | 309 | //dg_modifier 310 | MDGModifier dg_modifier; 311 | dg_modifier.addAttribute(node, a_attribute); 312 | dg_modifier.doIt(); 313 | 314 | //reload AE 315 | MGlobal::executeCommandOnIdle(MString("openAEWindow;")); 316 | 317 | //tmp 318 | MGlobal::displayInfo(MString("Reopened AE")); 319 | }; 320 | 321 | //remove_attribute 322 | void Ocio_test::remove_attribute(MObject& node, std::string attribute_name) 323 | { 324 | //status 325 | MStatus status; 326 | 327 | //fn_dep_node 328 | MFnDependencyNode fn_dep_node(node); 329 | 330 | //p_attribute 331 | MPlug p_attribute = fn_dep_node.findPlug(attribute_name.c_str(), &status); 332 | //o_attribute 333 | MObject o_attribute = p_attribute.attribute(); 334 | 335 | //dg_modifier 336 | MDGModifier dg_modifier; 337 | dg_modifier.removeAttribute(node, o_attribute); 338 | dg_modifier.doIt(); 339 | 340 | //tmp 341 | MGlobal::displayInfo(MString("Deleted Attr.:")+attribute_name.c_str()); 342 | }; 343 | 344 | //update_enum_attribute 345 | void Ocio_test::update_enum_attribute(std::string attribute_name, 346 | std::vector& value_list, 347 | MObject& node) 348 | { 349 | //remove attribute 350 | remove_attribute(node, attribute_name); 351 | 352 | //create_enum_attribute 353 | create_enum_attribute(attribute_name, 354 | value_list, 355 | node); 356 | 357 | }; 358 | 359 | //attr_connected 360 | bool Ocio_test::attr_connected(std::string attr_name) 361 | { 362 | //node 363 | MObject node = thisMObject(); 364 | //fn_dep_node 365 | MFnDependencyNode fn_dep_node(node); 366 | //p_plug 367 | MPlug p_plug = fn_dep_node.findPlug(attr_name.c_str(), true); 368 | 369 | //return 370 | return p_plug.isConnected(); 371 | }; 372 | 373 | //all_attrs_connected 374 | bool Ocio_test::all_attrs_connected() 375 | { 376 | //input_color 377 | if (!attr_connected(std::string("input_color"))) 378 | { 379 | //tmp 380 | MGlobal::displayInfo("input color attr. not connected"); 381 | return false; 382 | }; 383 | //width 384 | if (!attr_connected(std::string("width"))) 385 | { 386 | //tmp 387 | MGlobal::displayInfo("width attr. not connected"); 388 | return false; 389 | }; 390 | //height 391 | if (!attr_connected(std::string("height"))) 392 | { 393 | //tmp 394 | MGlobal::displayInfo("height attr. not connected"); 395 | return false; 396 | }; 397 | 398 | 399 | return true; 400 | }; 401 | 402 | //set_output_color 403 | void Ocio_test::set_output_color(MFloatVector& vec_color, MDataBlock& data) 404 | { 405 | //h_output_color 406 | MDataHandle h_output_color = data.outputValue(a_output_color); 407 | MFloatVector& vec_output_color = h_output_color.asFloatVector(); 408 | vec_output_color = vec_color; 409 | 410 | //clean handle 411 | h_output_color.setClean(); 412 | 413 | //tmp 414 | //MGlobal::displayInfo("Set output color attribute"); 415 | }; 416 | 417 | //Temp 418 | //----------------------------------------------- 419 | //print_config_info 420 | void Ocio_test::print_config_info() 421 | { 422 | //config 423 | OCIO::ConstConfigRcPtr config; 424 | config = OCIO_functionality::get_config_from_env(); 425 | 426 | //print info 427 | OCIO_functionality::print_config_info(config); 428 | }; -------------------------------------------------------------------------------- /ocio_maya/source/ocio_test.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef OCIO_TEST_H 4 | #define OCIO_TEST_H 5 | 6 | //Ocio_test Declaration 7 | //----------------------------------------------- 8 | 9 | 10 | //Constants 11 | //----------------------------------------------- 12 | 13 | 14 | 15 | //include 16 | //----------------------------------------------- 17 | //Std 18 | #include 19 | #include 20 | #include 21 | //Boost 22 | #include "boost/format.hpp" 23 | #include "boost/lexical_cast.hpp" 24 | #include "boost/Signals2.hpp" 25 | //Own 26 | #include "ocio_functionality.h" 27 | //Maya 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | 50 | //Boost_signal_helloworld 51 | //----------------------------------------------- 52 | struct Boost_signal_helloworld 53 | { 54 | //executed when signal is emitted 55 | void operator()() const 56 | { 57 | std::cout << "Hello, World from Postconstructor!" << std::endl; 58 | } 59 | }; 60 | 61 | 62 | 63 | //Ocio_test 64 | //----------------------------------------------- 65 | class Ocio_test: public MPxNode 66 | { 67 | public: 68 | //Attributes 69 | static MTypeId id; 70 | static MString type_name; 71 | 72 | static MObject a_verbose; 73 | 74 | static MObject a_change_list; 75 | static MObject a_last_change_index; 76 | 77 | static MObject a_input_color; 78 | static MObject a_width; 79 | static MObject a_height; 80 | 81 | static MObject a_config_path; 82 | 83 | static MObject a_output_color; 84 | 85 | 86 | 87 | //Methods 88 | //Maya 89 | Ocio_test(); 90 | virtual ~Ocio_test(); 91 | static void* create(); 92 | static MStatus initialize(); 93 | virtual void postConstructor(); 94 | virtual MStatus setDependentsDirty(const MPlug&, MPlugArray&); 95 | virtual MStatus compute(const MPlug &plug, MDataBlock &data); 96 | //Own 97 | void rebuild_input_colorspace(int&, MDataBlock&); 98 | void create_enum_attribute(std::string, std::vector&, MObject&); 99 | void remove_attribute(MObject&, std::string); 100 | void update_enum_attribute(std::string, std::vector&, MObject&); 101 | bool attr_connected(std::string); 102 | bool all_attrs_connected(); 103 | void set_output_color(MFloatVector&, MDataBlock&); 104 | //Temp 105 | void print_config_info(); 106 | 107 | 108 | private: 109 | //Attributes 110 | boost::signals2::signal sig_postconstructor; 111 | Boost_signal_helloworld* boost_signal_helloworld; 112 | 113 | //Methods 114 | 115 | 116 | }; 117 | #endif -------------------------------------------------------------------------------- /ocio_view/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | cmake_minimum_required(VERSION 2.8.8) 4 | 5 | #solution 6 | project(ocio_view) 7 | 8 | 9 | 10 | 11 | 12 | #CMake settings 13 | #--------------------------------------- 14 | 15 | #Build Type 16 | IF (NOT CMAKE_BUILD_TYPE) 17 | SET(CMAKE_BUILD_TYPE Release) 18 | ENDIF (NOT CMAKE_BUILD_TYPE) 19 | 20 | #Generator toolset (which visual studio version is used for compilation. Standard is: IDE Editing: VS2013 Compilation: VS2012) 21 | if(MSVC OR MSVC_IDE) 22 | set(CMAKE_GENERATOR_TOOLSET "v110" CACHE STRING "Platform Toolset" FORCE) 23 | endif() 24 | 25 | set(CMAKE_INCLUDE_CURRENT_DIR ON) #<-- Include current directory 26 | 27 | #QT 28 | #--------------------------------------- 29 | set(CUSTOM_QT_DIR "C:/symlinks/libraries/Qt/x64/msvc11/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl") 30 | set(CMAKE_AUTOMOC ON) #<-- Auto meta object compilation for Q_Object macro 31 | set(OPENGL_INCLUDE_PATH "C:/symlinks/microsoft_sdks/Windows/v7.0A/Lib") 32 | set(CMAKE_PREFIX_PATH ${CUSTOM_QT_DIR}; ${OPENGL_INCLUDE_PATH}) 33 | FIND_PACKAGE(Qt5Core REQUIRED) 34 | FIND_PACKAGE(Qt5Widgets REQUIRED) 35 | FIND_PACKAGE(Qt5Gui REQUIRED) 36 | 37 | #Boost 38 | #--------------------------------------- 39 | SET(BOOST_ROOT "C:/symlinks/boost/boost_1_54_0") 40 | SET(BOOST_INCLUDEDIR "C:/symlinks/boost/boost_1_54_0/boost") 41 | SET(BOOST_LIBRARYDIR "C:/symlinks/boost/boost_1_54_0/stage/x64/msvc11/python26/lib") 42 | find_package(Boost REQUIRED) 43 | 44 | 45 | 46 | 47 | #Headers 48 | #--------------------------------------- 49 | file (GLOB HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 50 | source/*.h) 51 | 52 | #Source files 53 | #--------------------------------------- 54 | file (GLOB SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 55 | source/*.cpp) 56 | 57 | #Forms (.ui files) 58 | #--------------------------------------- 59 | file (GLOB FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 60 | media/*.ui) 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | #Qt uic (compile .ui files to .h files) 70 | #--------------------------------------- 71 | qt5_wrap_ui(FORM_HEADERS ${FORMS}) 72 | 73 | 74 | #Filters 75 | #--------------------------------------- 76 | source_group(headers FILES ${HEADERS}) 77 | source_group(sources FILES ${SOURCES}) 78 | source_group(media FILES ${FORMS} ${FORM_HEADERS}) 79 | 80 | 81 | 82 | #project 83 | add_executable(ocio_view ${SOURCES} ${HEADERS} ${FORM_HEADERS}) 84 | 85 | #include directories 86 | include_directories( 87 | "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO/export" 88 | "C:/symlinks/libraries/OpenColorIO/build_harness/OpenColorIO_build/msvc11/x64/export" 89 | ${Boost_INCLUDE_DIR} 90 | ) 91 | 92 | #target link libraries 93 | target_link_libraries(ocio_view debug "C:/symlinks/libraries/OpenColorIO/x64/msvc11/static/debug/OpenColorIO.lib") 94 | target_link_libraries(ocio_view optimized "C:/symlinks/libraries/OpenColorIO/x64/msvc11/static/release/OpenColorIO.lib") 95 | 96 | 97 | 98 | #Use modules 99 | #--------------------------------------- 100 | qt5_use_modules(ocio_view Core Widgets) -------------------------------------------------------------------------------- /ocio_view/media/ocio_view.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OCIO_view 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | OCIO_View 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 0 23 | 0 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 0 45 | 0 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0 54 | 0 55 | 56 | 57 | 58 | Display Views 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 0 67 | 0 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Qt::Vertical 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 0 84 | 0 85 | 86 | 87 | 88 | Channels 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 0 97 | 0 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Qt::Vertical 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 0 114 | 0 115 | 116 | 117 | 118 | Gain 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 0 127 | 0 128 | 129 | 130 | 131 | 0.100000000000000 132 | 133 | 134 | 1.000000000000000 135 | 136 | 137 | 138 | 139 | 140 | 141 | Qt::Vertical 142 | 143 | 144 | 145 | 146 | 147 | 148 | Inspect 149 | 150 | 151 | 152 | 153 | 154 | 155 | Qt::Horizontal 156 | 157 | 158 | 159 | 40 160 | 20 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | Qt::Horizontal 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 0 181 | 0 182 | 800 183 | 18 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /ocio_view/source/image_label.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | //Description 7 | //----------------------------------------------- 8 | /* 9 | Implementation of Image_label 10 | */ 11 | 12 | 13 | 14 | 15 | 16 | //Include 17 | //----------------------------------------------- 18 | 19 | #include "image_label.h" 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | //Constructor / Destructor 28 | //----------------------------------------------- 29 | //----------------------------------------------- 30 | 31 | //Constructor 32 | Image_label::Image_label(QWidget* parent , Qt::WindowFlags flags, int logging): 33 | QLabel(parent, flags), 34 | logging(logging) 35 | { 36 | //setup_ui 37 | setup_ui(); 38 | }; 39 | 40 | //Destructor 41 | Image_label::~Image_label() 42 | { 43 | 44 | }; 45 | 46 | 47 | 48 | 49 | 50 | 51 | //Public Methods 52 | //----------------------------------------------- 53 | //----------------------------------------------- 54 | 55 | //setup_ui 56 | void Image_label::setup_ui() 57 | { 58 | //setScaledContents 59 | setScaledContents(true); 60 | //hover 61 | setAttribute(Qt::WA_Hover); 62 | }; 63 | 64 | 65 | //Signals 66 | //----------------------------------------------- 67 | //----------------------------------------------- 68 | 69 | 70 | 71 | //Slots 72 | //----------------------------------------------- 73 | //----------------------------------------------- 74 | 75 | 76 | 77 | //Event Handler 78 | //----------------------------------------------- 79 | //----------------------------------------------- 80 | 81 | //event 82 | bool Image_label::event(QEvent* event) 83 | { 84 | //HoverEnter 85 | if(event->type() == QEvent::HoverEnter) 86 | { 87 | //mouse_event 88 | QMouseEvent* mouse_event = static_cast(event); 89 | 90 | //pos_x & y 91 | int pos_x = mouse_event->pos().x(); 92 | int pos_y = mouse_event->pos().y(); 93 | 94 | //emit inspect_begin 95 | emit inspect_begin(pos_x, pos_y); 96 | } 97 | //HoverMove 98 | else if(event->type() == QEvent::HoverMove) 99 | { 100 | //mouse_event 101 | QMouseEvent* mouse_event = static_cast(event); 102 | 103 | //pos_x & y 104 | int pos_x = mouse_event->pos().x(); 105 | int pos_y = mouse_event->pos().y(); 106 | 107 | //emit inspect 108 | emit inspect_move(pos_x, pos_y); 109 | 110 | } 111 | //HoverLeave 112 | else if(event->type() == QEvent::HoverLeave) 113 | { 114 | //emit inspect_end 115 | emit inspect_end(); 116 | } 117 | 118 | return QLabel::event(event); 119 | }; -------------------------------------------------------------------------------- /ocio_view/source/image_label.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #ifndef IMAGE_LABEL_H 6 | #define IMAGE_LABEL_H 7 | 8 | //Description 9 | //----------------------------------------------- 10 | /* 11 | Declaration of Image_label 12 | */ 13 | 14 | 15 | 16 | //Constants 17 | //----------------------------------------------- 18 | 19 | 20 | 21 | 22 | 23 | //Include 24 | //----------------------------------------------- 25 | 26 | //STL 27 | #include 28 | #include 29 | #include 30 | #include 31 | //Qt 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | //Boost 38 | //Own 39 | //OCIO 40 | 41 | 42 | 43 | //Image_label 44 | //----------------------------------------------- 45 | 46 | class Image_label : public QLabel 47 | { 48 | 49 | Q_OBJECT 50 | 51 | 52 | public: //Constructor / Destructor 53 | Image_label(QWidget* parent = 0, Qt::WindowFlags flags = 0, int logging = 0); 54 | ~Image_label(); 55 | 56 | 57 | public: //Methods 58 | void setup_ui(); 59 | 60 | 61 | signals: //Signals 62 | void inspect_begin(int, int); 63 | void inspect_move(int, int); 64 | void inspect_end(); 65 | 66 | 67 | private slots: //Slots 68 | 69 | 70 | public: //Event Handler 71 | bool event(QEvent*); 72 | 73 | 74 | protected: //Variables 75 | 76 | 77 | private: //Variables 78 | int logging; 79 | 80 | }; 81 | 82 | #endif -------------------------------------------------------------------------------- /ocio_view/source/inspect_view.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | //Description 7 | //----------------------------------------------- 8 | /* 9 | Implementation of Inspect_view 10 | */ 11 | 12 | 13 | 14 | 15 | 16 | //Include 17 | //----------------------------------------------- 18 | 19 | #include "inspect_view.h" 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | //Constructor / Destructor 28 | //----------------------------------------------- 29 | //----------------------------------------------- 30 | 31 | //Constructor 32 | Inspect_view::Inspect_view(QWidget* parent) : 33 | QWidget(parent) 34 | { 35 | //set_initial_pointer_addresses 36 | set_initial_pointer_addresses(); 37 | 38 | //Setup Ui 39 | ui->setupUi(this); 40 | 41 | //setup_ui 42 | setup_ui(); 43 | 44 | //connect_ui 45 | connect_ui(); 46 | } 47 | 48 | //Destructor 49 | Inspect_view::~Inspect_view() 50 | { 51 | delete ui; 52 | } 53 | 54 | 55 | 56 | 57 | 58 | 59 | //Public Methods 60 | //----------------------------------------------- 61 | //----------------------------------------------- 62 | 63 | //set_initial_pointer_addresses 64 | void Inspect_view::set_initial_pointer_addresses() 65 | { 66 | //ui 67 | ui = new Ui::Inspect_view; 68 | dev = true; 69 | logging = 0; 70 | }; 71 | 72 | //setup_ui 73 | void Inspect_view::setup_ui() 74 | { 75 | //set attrs 76 | setWindowFlags(Qt::Widget | Qt::FramelessWindowHint); 77 | setAttribute(Qt::WA_NoSystemBackground, true); 78 | setAttribute(Qt::WA_TranslucentBackground, true); 79 | setAttribute(Qt::WA_PaintOnScreen); 80 | }; 81 | 82 | //connect_ui 83 | void Inspect_view::connect_ui() 84 | { 85 | 86 | }; 87 | 88 | //set_color 89 | void Inspect_view::set_color(QColor& color, std::string color_type) 90 | { 91 | //set color bars and labels based on color_type 92 | //graded 93 | if(color_type.compare("graded") == 0) 94 | { 95 | //toplevel bars 96 | set_color_label_top(color, ui->lbl_color_graded); 97 | 98 | //set color_bars 99 | 100 | //rrrgggbbb 101 | set_color_bar(color, ui->wdgt_rrrgggbbb_graded_r, "red"); 102 | set_color_bar(color, ui->wdgt_rrrgggbbb_graded_g, "green"); 103 | set_color_bar(color, ui->wdgt_rrrgggbbb_graded_b, "blue"); 104 | //rgbrgbrgb 105 | set_color_bar(color, ui->wdgt_rgbrgbrgb_graded_r, "red"); 106 | set_color_bar(color, ui->wdgt_rgbrgbrgb_graded_g, "green"); 107 | set_color_bar(color, ui->wdgt_rgbrgbrgb_graded_b, "blue"); 108 | 109 | //lbl colors 110 | set_color_label(color, ui->lbl_graded_r, "red"); 111 | set_color_label(color, ui->lbl_graded_g, "green"); 112 | set_color_label(color, ui->lbl_graded_b, "blue"); 113 | } 114 | //source 115 | else if(color_type.compare("source") == 0) 116 | { 117 | //toplevel bars 118 | set_color_label_top(color, ui->lbl_color_source); 119 | 120 | //set color_bars 121 | 122 | //rrrgggbbb 123 | set_color_bar(color, ui->wdgt_rrrgggbbb_source_r, "red"); 124 | set_color_bar(color, ui->wdgt_rrrgggbbb_source_g, "green"); 125 | set_color_bar(color, ui->wdgt_rrrgggbbb_source_b, "blue"); 126 | //rgbrgbrgb 127 | set_color_bar(color, ui->wdgt_rgbrgbrgb_source_r, "red"); 128 | set_color_bar(color, ui->wdgt_rgbrgbrgb_source_g, "green"); 129 | set_color_bar(color, ui->wdgt_rgbrgbrgb_source_b, "blue"); 130 | 131 | //lbl colors 132 | set_color_label(color, ui->lbl_source_r, "red"); 133 | set_color_label(color, ui->lbl_source_g, "green"); 134 | set_color_label(color, ui->lbl_source_b, "blue"); 135 | } 136 | //display 137 | else if(color_type.compare("display") == 0) 138 | { 139 | //toplevel bars 140 | set_color_label_top(color, ui->lbl_color_display); 141 | 142 | //set color_bars 143 | 144 | //rrrgggbbb 145 | set_color_bar(color, ui->wdgt_rrrgggbbb_display_r, "red"); 146 | set_color_bar(color, ui->wdgt_rrrgggbbb_display_g, "green"); 147 | set_color_bar(color, ui->wdgt_rrrgggbbb_display_b, "blue"); 148 | //rgbrgbrgb 149 | set_color_bar(color, ui->wdgt_rgbrgbrgb_display_r, "red"); 150 | set_color_bar(color, ui->wdgt_rgbrgbrgb_display_g, "green"); 151 | set_color_bar(color, ui->wdgt_rgbrgbrgb_display_b, "blue"); 152 | 153 | //lbl colors 154 | set_color_label(color, ui->lbl_display_r, "red"); 155 | set_color_label(color, ui->lbl_display_g, "green"); 156 | set_color_label(color, ui->lbl_display_b, "blue"); 157 | } 158 | }; 159 | 160 | //set_color_bar 161 | void Inspect_view::set_color_bar(QColor& color, QWidget*& wdgt_color_bar, std::string color_type) 162 | { 163 | //color_value 164 | std::string color_value; 165 | //stylesheet 166 | boost::format stylesheet; 167 | //size_value 168 | float size_value = 0; 169 | 170 | //assign based on color_type 171 | //red 172 | if(color_type.compare("red") == 0) 173 | { 174 | color_value = boost::lexical_cast(color.red()); 175 | stylesheet = boost::format("background-color: rgb(%s, 0, 0)"); 176 | size_value = static_cast(color.red()) * COLORBAR_SCALEFACTOR; 177 | } 178 | //green 179 | else if(color_type.compare("green") == 0) 180 | { 181 | color_value = boost::lexical_cast(color.green()); 182 | stylesheet = boost::format("background-color: rgb(0, %s, 0)"); 183 | size_value = static_cast(color.green()) * COLORBAR_SCALEFACTOR; 184 | } 185 | //blue 186 | else if(color_type.compare("blue") == 0) 187 | { 188 | color_value = boost::lexical_cast(color.blue()); 189 | stylesheet = boost::format("background-color: rgb(0, 0, %s)"); 190 | size_value = static_cast(color.blue()) * COLORBAR_SCALEFACTOR; 191 | } 192 | 193 | 194 | //format stylesheet 195 | stylesheet % color_value; 196 | 197 | //set stylesheet 198 | wdgt_color_bar->setStyleSheet(QString(stylesheet.str().c_str())); 199 | 200 | //set size 201 | wdgt_color_bar->setMinimumHeight(static_cast(size_value)); 202 | 203 | }; 204 | 205 | //set_color_label 206 | void Inspect_view::set_color_label(QColor& color, QLabel*& wdgt_color_label, std::string color_type) 207 | { 208 | //color_value 209 | std::string color_value; 210 | //stylesheet 211 | boost::format stylesheet; 212 | 213 | //assign based on color_type 214 | //red 215 | if(color_type.compare("red") == 0) 216 | { 217 | color_value = boost::lexical_cast(color.red()); 218 | stylesheet = boost::format("color: rgb(%s, 0, 0);"); 219 | } 220 | //green 221 | else if(color_type.compare("green") == 0) 222 | { 223 | color_value = boost::lexical_cast(color.green()); 224 | stylesheet = boost::format("color: rgb(0, %s, 0);"); 225 | } 226 | //blue 227 | else if(color_type.compare("blue") == 0) 228 | { 229 | color_value = boost::lexical_cast(color.blue()); 230 | stylesheet = boost::format("color: rgb(0, 0, %s);"); 231 | }; 232 | 233 | //format stylesheet 234 | stylesheet % color_value; 235 | 236 | //set label text 237 | wdgt_color_label->setText(color_value.c_str()); 238 | //set stylesheet 239 | wdgt_color_label->setStyleSheet(QString(stylesheet.str().c_str())); 240 | }; 241 | 242 | //set_color_label_top 243 | void Inspect_view::set_color_label_top(QColor& color, QLabel*& wdgt_color_label) 244 | { 245 | //color_value 246 | std::string color_value; 247 | //stylesheet 248 | boost::format stylesheet("background-color: rgb(%s, %s, %s);"); 249 | stylesheet % color.red() % color.green() % color.blue(); 250 | 251 | //set stylesheet 252 | wdgt_color_label->setStyleSheet(QString(stylesheet.str().c_str())); 253 | }; -------------------------------------------------------------------------------- /ocio_view/source/inspect_view.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #ifndef INSPECT_VIEW_H 6 | #define INSPECT_VIEW_H 7 | 8 | //Description 9 | //----------------------------------------------- 10 | /* 11 | Declaration of Inspect_view 12 | */ 13 | 14 | 15 | 16 | //Constants 17 | //----------------------------------------------- 18 | #define COLORBAR_SCALEFACTOR 0.1960784 19 | 20 | 21 | 22 | 23 | //Include 24 | //----------------------------------------------- 25 | 26 | //STL 27 | #include 28 | #include 29 | #include 30 | #include 31 | //Qt 32 | #include 33 | #include 34 | #include 35 | //Boost 36 | #include 37 | #include 38 | //Own 39 | //OCIO 40 | //From .ui 41 | #include "ui_inspect_view.h" 42 | 43 | 44 | 45 | 46 | //Inspect_view 47 | //----------------------------------------------- 48 | 49 | class Inspect_view : public QWidget 50 | { 51 | Q_OBJECT 52 | 53 | 54 | public: //Constructor / Destructor 55 | explicit Inspect_view(QWidget* parent = 0); 56 | ~Inspect_view(); 57 | 58 | 59 | public: //Methods 60 | void set_initial_pointer_addresses(); 61 | void setup_ui(); 62 | void connect_ui(); 63 | void set_color(QColor&, std::string); 64 | void set_color_bar(QColor&, QWidget*&, std::string); 65 | void set_color_label(QColor&, QLabel*&, std::string); 66 | void set_color_label_top(QColor&, QLabel*&); 67 | 68 | signals: //Signals 69 | 70 | 71 | private slots: //Slots 72 | 73 | 74 | public: //Event Handler 75 | 76 | 77 | protected: //Variables 78 | 79 | 80 | private: //Variables 81 | //ui 82 | Ui::Inspect_view* ui; 83 | bool dev; 84 | int logging; 85 | }; 86 | 87 | #endif -------------------------------------------------------------------------------- /ocio_view/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | //Include 7 | //----------------------------------------------- 8 | 9 | //Qt 10 | #include 11 | //Own 12 | #include "ocio_view.h" 13 | 14 | 15 | 16 | 17 | 18 | 19 | //main 20 | //----------------------------------------------- 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | //q_application 25 | QApplication* q_application; 26 | q_application = new QApplication(argc, argv); 27 | 28 | //node_view 29 | OCIO_view* ocio_view; 30 | ocio_view = new OCIO_view(); 31 | ocio_view->setObjectName("OCIO_view"); 32 | ocio_view->show(); 33 | 34 | //event loop 35 | return q_application->exec(); 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /ocio_view/source/ocio_view.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #ifndef OCIO_VIEW_H 6 | #define OCIO_VIEW_H 7 | 8 | //Description 9 | //----------------------------------------------- 10 | /* 11 | Declaration of OCIO_view 12 | */ 13 | 14 | 15 | 16 | //Constants 17 | //----------------------------------------------- 18 | #define EIGHT_BIT_UNSIGNED_INT 255 19 | #define INSPECT_VIEW_OFFSET_X -40 20 | #define INSPECT_VIEW_OFFSET_Y 0 21 | 22 | 23 | 24 | 25 | //Include 26 | //----------------------------------------------- 27 | 28 | //STL 29 | #include 30 | #include 31 | #include 32 | #include 33 | //Qt 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | //Boost 54 | #include "boost/shared_ptr.hpp" 55 | #include 56 | //Own 57 | #include "image_label.h" 58 | #include "inspect_view.h" 59 | //OCIO 60 | #include 61 | //From .ui 62 | #include "ui_ocio_view.h" 63 | 64 | //OCIO Namespace 65 | namespace OCIO = OCIO_NAMESPACE; 66 | 67 | 68 | //OCIO_view 69 | //----------------------------------------------- 70 | 71 | class OCIO_view : public QMainWindow 72 | { 73 | Q_OBJECT 74 | 75 | 76 | public: //Constructor / Destructor 77 | explicit OCIO_view(QWidget* parent = 0); 78 | ~OCIO_view(); 79 | 80 | 81 | public: //Methods 82 | 83 | //ui 84 | void setup_ui(); 85 | void connect_ui(); 86 | void set_initial_pointer_addresses(); 87 | void set_lbl_image(); 88 | void recreate_main_menu(); 89 | void create_file_menu(); 90 | void create_ocio_menu(); 91 | void create_bake_menu(); 92 | void create_dev_menu(); 93 | void set_theme(); 94 | void set_display_views_ui(); 95 | std::string get_display_view_ui(); 96 | void set_display_channels_ui(); 97 | void get_display_channels_ui(int (&channel_hot)[4]); 98 | std::string get_file_path(); 99 | bool path_exists(std::string&); 100 | bool config_exists(); 101 | float get_gain(); 102 | std::string get_lut_type(); 103 | std::string get_lut_format(); 104 | 105 | 106 | //image 107 | QPixmap* get_image(); 108 | int get_image_pixel_count(QPixmap*); 109 | bool image_exists(); 110 | bool image_display_exists(); 111 | void get_image_scale_factor(float (&scale_factors)[2]); 112 | QColor get_color_at_position(QPixmap*&, int, int); 113 | 114 | 115 | //pixels 116 | void set_pixels_from_image(QPixmap*, float*&, float*&, float*&, float*&); 117 | void copy_pixels(float*&, float*&, float*&, float*&, 118 | float*&, float*&, float*&, float*&); 119 | QPixmap create_pixmap_from_pixels(int, int, float*&, float*&, float*&, float*&); 120 | 121 | //ocio 122 | void set_colorspaces(); 123 | void set_display_views(); 124 | void transform_colorspace(const char*, const char*, 125 | float*&, float*&, float*&, float*&, 126 | bool set_image = false); 127 | void transform_colorspace(OCIO::DisplayTransformRcPtr&, 128 | float*&, float*&, float*&, float*&, 129 | bool set_image = false); 130 | OCIO::ConstColorSpaceRcPtr get_colorspace_from_role(const char*); 131 | 132 | 133 | 134 | signals: //Signals 135 | void config_changed(); 136 | void image_changed(); 137 | void image_colorspace_changed(); 138 | 139 | 140 | private slots: //Slots 141 | 142 | //slots_ui 143 | void set_input_colorspace(int); 144 | void set_shaper_colorspace(int); 145 | void set_output_colorspace(int); 146 | void set_logging(int); 147 | void set_lut_type(int); 148 | void set_lut_format(int); 149 | void toggle_shaper_colorspace_active(); 150 | 151 | //slots_image 152 | void set_image(); 153 | void restore_image(); 154 | void display_image(); 155 | void inspect_begin(int, int); 156 | void inspect_move(int, int); 157 | void inspect_end(); 158 | 159 | //slots_pixels 160 | void print_pixel_values(); 161 | void print_first_pixel_values(); 162 | 163 | //slots_ocio 164 | void set_config_from_env(); 165 | void set_config_from_file(); 166 | void print_config_info(); 167 | void transform_input_to_output_colorspace(); 168 | void bake_lut(); 169 | void print_bake_setup(); 170 | 171 | //slots_update 172 | void update_config_changed(); 173 | void update_image_changed(); 174 | void update_display(); 175 | 176 | 177 | //slots_dev 178 | void test_method(); 179 | void ocio_test_method(); 180 | void print_image_and_label_size(); 181 | void print_baker_writers(); 182 | 183 | 184 | public: //Event Handler 185 | 186 | 187 | protected: //Variables 188 | 189 | 190 | private: //Variables 191 | Ui::OCIO_view* ui; 192 | bool dev; 193 | int logging; 194 | 195 | Image_label* lbl_image; 196 | QPixmap* image; 197 | QPixmap* image_source; 198 | QPixmap* image_display; 199 | 200 | float* pixels_r, *pixels_g, *pixels_b, *pixels_a; 201 | float* pixels_source_r, *pixels_source_g, *pixels_source_b, *pixels_source_a; 202 | float* pixels_display_r, *pixels_display_g, *pixels_display_b, *pixels_display_a; 203 | 204 | OCIO::ConstConfigRcPtr config; 205 | std::vector vec_colorspaces; 206 | std::vector vec_display_views; 207 | 208 | int input_colorspace; 209 | int shaper_colorspace; 210 | int output_colorspace; 211 | int lut_type; 212 | int lut_format; 213 | bool shaper_colorspace_active; 214 | QAction* action_toggle_shaper_colorspace_active; 215 | 216 | Inspect_view* inspect_view; 217 | }; 218 | 219 | #endif --------------------------------------------------------------------------------