Created
June 18, 2015 13:43
-
-
Save zeffii/bdfb9ec945446883d91f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ##### BEGIN GPL LICENSE BLOCK ##### | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software Foundation, | |
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
# | |
# ##### END GPL LICENSE BLOCK ##### | |
# Author Dealga McArdle | |
# yanked some boilerplate written by Linus Yng for 'generic note node' | |
# pep8 | |
bl_info = { | |
"name": "", | |
"description": "", | |
"author": "", | |
"version": (0, 0, 1), | |
"blender": (2, 7, 4), | |
"location": "Node Editor, N-Panel", | |
"category": "Node", | |
"warning": "The node will not work for people without this addon", | |
"wiki-url": "", | |
} | |
import importlib | |
import bpy | |
import nodeitems_builtins | |
from nodeitems_utils import NodeItem | |
from nodeitems_builtins import ( | |
CompositorNodeCategory, | |
ShaderNewNodeCategory, | |
ShaderOldNodeCategory, | |
TextureNodeCategory) | |
from bpy.props import BoolProperty, FloatProperty | |
class GenericBorderRenderNode(bpy.types.Node): | |
bl_idname = 'GenericBorderRenderNode' | |
bl_label = 'RenderBorder' | |
bl_icon = 'OUTLINER_OB_EMPTY' | |
@classmethod | |
def poll(cls, ntree): | |
return True | |
def updateNode(self, context): | |
scn = bpy.context.scene | |
if self.enable: | |
scn.render.use_border = True | |
scn.render.border_min_x = self.bx | |
scn.render.border_min_y = self.by | |
scn.render.border_max_x = self.bx + self.bw | |
scn.render.border_max_y = self.by + self.bh | |
else: | |
scn.render.use_border = False | |
bx = FloatProperty(min=0.0, max=1.0, options={'ANIMATABLE'}, update=updateNode) | |
by = FloatProperty(min=0.0, max=1.0, options={'ANIMATABLE'}, update=updateNode) | |
bw = FloatProperty(min=0.0, max=1.0, options={'ANIMATABLE'}, update=updateNode) | |
bh = FloatProperty(min=0.0, max=1.0, options={'ANIMATABLE'}, update=updateNode) | |
enable = BoolProperty(options={'ANIMATABLE'}, update=updateNode) | |
def draw_buttons(self, context, layout): | |
col = layout.column(align=True) | |
col.prop(self, "enable", text="use border") | |
if self.enable: | |
col.prop(self, "bx", text="start x") | |
col.prop(self, "by", text="start y") | |
col.prop(self, "bw", text="box width") | |
col.prop(self, "bh", text="box hight") | |
# replacement layout categories | |
menu_categories = { | |
"CMP_LAYOUT": CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[ | |
NodeItem("NodeFrame"), | |
NodeItem("NodeReroute"), | |
NodeItem("GenericBorderRenderNode"), | |
NodeItem("CompositorNodeSwitch"), | |
]), | |
"TEX_LAYOUT": TextureNodeCategory("TEX_LAYOUT", "Layout", items=[ | |
NodeItem("NodeFrame"), | |
NodeItem("NodeReroute"), | |
NodeItem("GenericBorderRenderNode"), | |
]), | |
"SH_NEW_LAYOUT": ShaderNewNodeCategory("SH_NEW_LAYOUT", "Layout", items=[ | |
NodeItem("NodeFrame"), | |
NodeItem("NodeReroute"), | |
NodeItem("GenericBorderRenderNode"), | |
]), | |
"SH_LAYOUT": ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[ | |
NodeItem("NodeFrame"), | |
NodeItem("NodeReroute"), | |
NodeItem("GenericBorderRenderNode"), | |
]) | |
} | |
def register_menus(): | |
# remove, replace, add back the menus | |
nodeitems_builtins.unregister() | |
menus = [ | |
nodeitems_builtins.shader_node_categories, | |
nodeitems_builtins.compositor_node_categories, | |
nodeitems_builtins.texture_node_categories, | |
] | |
# nodeitems_builtins.shader_node_categories.append( | |
for menu in menus: | |
for index, node_cat in enumerate(menu): | |
if node_cat.identifier in menu_categories: | |
new_menu = menu_categories[node_cat.identifier] | |
menu[index] = new_menu | |
nodeitems_builtins.register() | |
def unregister_menus(): | |
try: | |
nodeitems_builtins.unregister() | |
except: | |
pass | |
importlib.reload(nodeitems_builtins) | |
nodeitems_builtins.register() | |
def register(): | |
bpy.utils.register_module(__name__) | |
register_menus() | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
unregister_menus() | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment