CM3D2 Converter.misc_TEXTURE_PT_context_texture

   1# 「プロパティ」エリア → 「テクスチャ」タブ
   2import os
   3import bpy
   4import bmesh
   5import mathutils
   6from . import common
   7from . import compat
   8from . import cm3d2_data
   9from .translations.pgettext_functions import *
  10
  11LAYOUT_FACTOR = 0.3
  12
  13
  14# メニュー等に項目追加
  15def menu_func(self, context):
  16    ob = context.active_object
  17    if ob is None or compat.IS_LEGACY is False:
  18        return
  19    try:
  20        tex_slot = context.texture_slot
  21        tex = context.texture
  22        mate = ob.active_material
  23        mate['shader1']
  24        mate['shader2']
  25    except:
  26        return
  27    if not tex_slot:
  28        return
  29
  30    if tex_slot.use:
  31        slot_type = 'tex'
  32    else:
  33        slot_type = 'col' if tex_slot.use_rgb_to_intensity else 'f'
  34
  35    base_name = common.remove_serial_number(tex.name)
  36
  37    box = self.layout.box()
  38    box.label(text="CM3D2用", icon_value=common.kiss_icon())
  39    split = compat.layout_split(box, factor=1 / 3)
  40    split.label(text="設定値タイプ:")
  41    row = split.row()
  42
  43    if slot_type == 'tex':
  44        row.label(text="テクスチャ", icon='TEXTURE')
  45    elif slot_type == 'col':
  46        row.label(text="色", icon='COLOR')
  47    elif slot_type == 'f':
  48        row.label(text="値", icon='ARROW_LEFTRIGHT')
  49
  50    check_row = row.row(align=True)
  51
  52    check_row.prop(tex_slot, 'use', text="")
  53    sub_row = check_row.row()
  54    sub_row.prop(tex_slot, 'use_rgb_to_intensity', text="")
  55    if tex_slot.use:
  56        sub_row.enabled = False
  57
  58    box.prop(tex, 'name', icon='SORTALPHA', text="設定値名")
  59
  60    if slot_type == "tex":
  61        if tex.type == 'IMAGE':
  62            img = tex.image
  63            if img:
  64                if img.source == 'FILE':
  65                    common.setup_image_name(img)
  66
  67                    sub_box = box.box()
  68                    row = compat.layout_split(sub_box, factor=1 / 3, align=True)
  69                    row.label(text="テクスチャ名:")
  70                    row.template_ID(tex, 'image', open='image.open')
  71                    if 'cm3d2_path' not in img:
  72                        img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
  73                    sub_box.prop(img, '["cm3d2_path"]', text="テクスチャパス")
  74
  75                    if base_name == "_ToonRamp":
  76                        sub_box.menu('TEXTURE_MT_context_texture_ToonRamp', icon='NLA')
  77                    elif base_name == "_ShadowRateToon":
  78                        sub_box.menu('TEXTURE_MT_context_texture_ShadowRateToon', icon='NLA')
  79                    elif base_name == "_OutlineToonRamp":
  80                        sub_box.menu('TEXTURE_MT_context_texture_OutlineToonRamp', icon='NLA')
  81
  82                    split = compat.layout_split(sub_box, factor=1 / 3, align=True)
  83                    split.label(text="オフセット:")
  84                    row = split.row(align=True)
  85                    row.prop(tex_slot, 'color', index=0, text="")
  86                    row.prop(tex_slot, 'color', index=1, text="")
  87
  88                    split = compat.layout_split(sub_box, factor=1 / 3, align=True)
  89                    split.label(text="拡大/縮小:")
  90                    row = split.row(align=True)
  91                    row.prop(tex_slot, 'color', index=2, text="")
  92                    row.prop(tex_slot, 'diffuse_color_factor', text="")
  93
  94                    row = sub_box.row()
  95                    row.operator('image.show_image', text="画像を表示", icon='ZOOM_IN').image_name = img.name
  96                    if len(img.pixels):
  97                        row.operator('image.quick_export_cm3d2_tex', text="texで保存", icon='FILESEL').node_name = tex.name
  98                    else:
  99                        row.operator('image.replace_cm3d2_tex', icon='BORDERMOVE')
 100
 101    elif slot_type == "col":
 102        sub_box = box.box()
 103
 104        # row = compat.layout_split(sub_box, factor=0.7, align=True)
 105        row = sub_box.row(align=True)
 106        row.prop(tex_slot, 'color', text="")
 107        row.operator('texture.auto_set_color_value', icon='AUTO', text="自動設定")
 108        row.operator('texture.set_color_value_old', text="", icon=compat.icon('SHADING_SOLID')).color = [0, 0, 0] + [tex_slot.diffuse_color_factor]
 109        row.operator('texture.set_color_value_old', text="", icon=compat.icon('MESH_CIRCLE')).color = [1, 1, 1] + [tex_slot.diffuse_color_factor]
 110
 111        row = sub_box.row(align=True)
 112        row.operator('texture.set_color_value_old', text="", icon='TRIA_LEFT').color = list(tex_slot.color) + [0]
 113        row.prop(tex_slot, 'diffuse_color_factor', icon='IMAGE_RGB_ALPHA', text="色の透明度", slider=True)
 114        row.operator('texture.set_color_value_old', text="", icon='TRIA_RIGHT').color = list(tex_slot.color) + [1]
 115
 116    elif slot_type == "f":
 117        sub_box = box.box()
 118        row = sub_box.row(align=True)
 119        row.prop(tex_slot, 'diffuse_color_factor', icon='ARROW_LEFTRIGHT', text="値")
 120
 121        data_path = 'texture_slot.diffuse_color_factor'
 122        if base_name == '_Shininess':
 123            row.menu('TEXTURE_MT_context_texture_values_normal', icon='DOWNARROW_HLT', text="")
 124
 125            row = sub_box.row(align=True)
 126            row.operator('texture.set_color_value_old', text="0.0", icon='MESH_CIRCLE').color = list(tex_slot.color) + [0.0]
 127            row.operator('texture.set_color_value_old', text="0.25").color = list(tex_slot.color) + [0.25]
 128            row.operator('texture.set_color_value_old', text="0.5").color = list(tex_slot.color) + [0.5]
 129            row.operator('texture.set_color_value_old', text="0.75").color = list(tex_slot.color) + [0.75]
 130            row.operator('texture.set_color_value_old', text="1.0", icon=compat.icon('NODE_MATERIAL')).color = list(tex_slot.color) + [1.0]
 131
 132        elif base_name == '_OutlineWidth':
 133            row.menu('TEXTURE_MT_context_texture_values_OutlineWidth', icon='DOWNARROW_HLT', text="")
 134
 135            row = sub_box.row(align=True)
 136            row.operator('texture.set_color_value_old', text="0.001", icon='MATSPHERE').color = list(tex_slot.color) + [0.001]
 137            row.operator('texture.set_color_value_old', text="0.0015").color = list(tex_slot.color) + [0.0015]
 138            row.operator('texture.set_color_value_old', text="0.002", icon='ANTIALIASED').color = list(tex_slot.color) + [0.002]
 139
 140            split = compat.layout_split(sub_box, factor=0.3)
 141            split.label(text="正確な値: ")
 142            split.label(text=str(tex_slot.diffuse_color_factor))
 143
 144        elif base_name == '_RimPower':
 145            row.menu('TEXTURE_MT_context_texture_values_RimPower', icon='DOWNARROW_HLT', text="")
 146
 147            row = sub_box.row(align=True)
 148            row.operator('texture.set_color_value_old', text="1", icon='BRUSH_TEXFILL').color = list(tex_slot.color) + [1]
 149            row.operator('texture.set_color_value_old', text="10").color = list(tex_slot.color) + [10]
 150            row.operator('texture.set_color_value_old', text="20").color = list(tex_slot.color) + [20]
 151            row.operator('texture.set_color_value_old', text="30", icon=compat.icon('SHADING_RENDERED')).color = list(tex_slot.color) + [30]
 152
 153        elif base_name == '_RimShift':
 154            row.menu('TEXTURE_MT_context_texture_values_normal', icon='DOWNARROW_HLT', text="")
 155
 156            row = sub_box.row(align=True)
 157            row.operator('texture.set_color_value_old', text="0.0", icon='FULLSCREEN_EXIT').color = list(tex_slot.color) + [0.0]
 158            row.operator('texture.set_color_value_old', text="0.25").color = list(tex_slot.color) + [0.25]
 159            row.operator('texture.set_color_value_old', text="0.5").color = list(tex_slot.color) + [0.5]
 160            row.operator('texture.set_color_value_old', text="0.75").color = list(tex_slot.color) + [0.75]
 161            row.operator('texture.set_color_value_old', text="1.0", icon='FULLSCREEN_ENTER').color = list(tex_slot.color) + [1.0]
 162
 163        elif base_name == '_ZTest':
 164            row.menu('TEXTURE_MT_context_texture_values_ZTest', icon='DOWNARROW_HLT', text="")
 165            col = sub_box.column(align=True)
 166            row = col.row(align=True)
 167            row.operator('texture.set_color_value_old', text="Disabled").color = list(tex_slot.color) + [0]
 168            row.operator('texture.set_color_value_old', text="Never").color = list(tex_slot.color) + [1]
 169            row.operator('texture.set_color_value_old', text="Less ").color = list(tex_slot.color) + [2]
 170            row.operator('texture.set_color_value_old', text="Equal").color = list(tex_slot.color) + [3]
 171            row.operator('texture.set_color_value_old', text="LessEqual").color = list(tex_slot.color) + [4]
 172            row = col.row(align=True)
 173            row.operator('texture.set_color_value_old', text="Greater").color = list(tex_slot.color) + [5]
 174            row.operator('texture.set_color_value_old', text="NotEqual").color = list(tex_slot.color) + [6]
 175            row.operator('texture.set_color_value_old', text="GreaterEqual").color = list(tex_slot.color) + [7]
 176            row.operator('texture.set_color_value_old', text="Always").color = list(tex_slot.color) + [8]
 177
 178        elif base_name == '_ZTest2':
 179            row = sub_box.row(align=True)
 180            row.operator('texture.set_color_value_old', text="0").color = list(tex_slot.color) + [0]
 181            row.operator('texture.set_color_value_old', text="1").color = list(tex_slot.color) + [1]
 182
 183        elif base_name == '_ZTest2Alpha':
 184            row.menu('TEXTURE_MT_context_texture_values_ZTest2Alpha', icon='DOWNARROW_HLT', text="")
 185            row = sub_box.row(align=True)
 186            row.operator('texture.set_color_value_old', text="0").color = list(tex_slot.color) + [0]
 187            row.operator('texture.set_color_value_old', text="0.8").color = list(tex_slot.color) + [0.8]
 188            row.operator('texture.set_color_value_old', text="1").color = list(tex_slot.color) + [1]
 189
 190    box.operator('texture.sync_tex_color_ramps', icon='LINKED')
 191
 192    description = cm3d2_data.PROP_DESC.get(base_name, '')
 193    if description != '':
 194        sub_box = box.box()
 195        col = sub_box.column(align=True)
 196        col.label(text="解説", icon='TEXT')
 197        for line in description:
 198            col.label(text=line)
 199
 200
 201# _ToonRamp設定メニュー
 202@compat.BlRegister(only_legacy=True)
 203class TEXTURE_MT_context_texture_ToonRamp(bpy.types.Menu):
 204    bl_idname = 'TEXTURE_MT_context_texture_ToonRamp'
 205    bl_label = "_ToonRamp 設定"
 206
 207    def draw(self, context):
 208        l = self.layout
 209        cmd = 'texture.set_default_toon_textures'
 210        for toon_tex in cm3d2_data.TOON_TEXES:
 211            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
 212            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
 213
 214
 215# _ShadowRateToon設定メニュー
 216@compat.BlRegister(only_legacy=True)
 217class TEXTURE_MT_context_texture_ShadowRateToon(bpy.types.Menu):
 218    bl_idname = 'TEXTURE_MT_context_texture_ShadowRateToon'
 219    bl_label = "_ShadowRateToon 設定"
 220
 221    def draw(self, context):
 222        l = self.layout
 223        cmd = 'texture.set_default_toon_textures'
 224        for toon_tex in cm3d2_data.TOON_TEXES:
 225            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
 226            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
 227
 228
 229# _OutlineToonRamp設定メニュー
 230@compat.BlRegister(only_legacy=True)
 231class TEXTURE_MT_context_texture_OutlineToonRamp(bpy.types.Menu):
 232    bl_idname = 'TEXTURE_MT_context_texture_OutlineToonRamp'
 233    bl_label = "_OutlineToonRamp 設定"
 234
 235    def draw(self, context):
 236        l = self.layout
 237        cmd = 'texture.set_default_toon_textures'
 238        for toon_tex in cm3d2_data.TOON_TEXES:
 239            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
 240            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
 241
 242
 243# 0.0~1.0までの値設定メニュー
 244@compat.BlRegister()
 245class TEXTURE_MT_context_texture_values_normal(bpy.types.Menu):
 246    bl_idname = 'TEXTURE_MT_context_texture_values_normal'
 247    bl_label = "値リスト"
 248
 249    def draw(self, context):
 250        tex_slot = context.texture_slot
 251        for i in range(11):
 252            value = round(i * 0.1, 1)
 253            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
 254            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
 255
 256
 257# _OutlineWidth用の値設定メニュー
 258@compat.BlRegister()
 259class TEXTURE_MT_context_texture_values_OutlineWidth(bpy.types.Menu):
 260    bl_idname = 'TEXTURE_MT_context_texture_values_OutlineWidth'
 261    bl_label = "値リスト"
 262
 263    def draw(self, context):
 264        tex_slot = context.texture_slot
 265        for i in range(16):
 266            value = round(i * 0.0002, 4)
 267            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
 268            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
 269
 270
 271# _RimPower用の値設定メニュー
 272@compat.BlRegister()
 273class TEXTURE_MT_context_texture_values_RimPower(bpy.types.Menu):
 274    bl_idname = 'TEXTURE_MT_context_texture_values_RimPower'
 275    bl_label = "値リスト"
 276
 277    def draw(self, context):
 278        tex_slot = context.texture_slot
 279        for i in range(16):
 280            value = round(i * 2, 0)
 281            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
 282            if value == 0:
 283                icon = 'ERROR'
 284            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
 285
 286
 287# _ZTest用の値設定メニュー
 288@compat.BlRegister(only_legacy=True)
 289class TEXTURE_MT_context_texture_values_ZTest_old(bpy.types.Menu):
 290    bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
 291    bl_label = "値リスト"
 292
 293    def draw(self, context):
 294        tex_slot = context.texture_slot
 295        for i in range(9):
 296            value = round(i, 0)
 297            self.layout.operator('texture.set_color_value_old', text=str(value)).color = list(tex_slot.color) + [value]
 298
 299
 300# _ZTest用の値設定メニュー
 301@compat.BlRegister(only_latest=True)
 302class TEXTURE_MT_context_texture_values_ZTest(bpy.types.Menu):
 303    bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
 304    bl_label = "値リスト"
 305
 306    node_name = bpy.props.StringProperty(name='NodeName')
 307
 308    @classmethod
 309    def poll(cls, context):
 310        ob = context.active_object
 311        if ob:
 312            mate = ob.active_material
 313            if mate:
 314                return mate.use_nodes
 315        return False
 316
 317    def draw(self, context):
 318        ob = context.active_object
 319        mate = ob.active_material
 320        if mate.use_nodes:
 321            mate.node_tree.nodes.get()
 322        tex_slot = context.texture_slot
 323        for i in range(9):
 324            value = round(i, 0)
 325            opr = self.layout.operator('texture.set_value', text=str(value))
 326            opr.node_name, opr.color = node_name, list(tex_slot.color) + [value]
 327
 328
 329@compat.BlRegister()
 330class CNV_OT_show_image(bpy.types.Operator):
 331    bl_idname = 'image.show_image'
 332    bl_label = "画像を表示"
 333    bl_description = "指定の画像をUV/画像エディターに表示します"
 334    bl_options = {'REGISTER', 'UNDO'}
 335
 336    image_name = bpy.props.StringProperty(name="画像名")
 337
 338    def execute(self, context):
 339        if self.image_name in context.blend_data.images:
 340            img = context.blend_data.images[self.image_name]
 341        else:
 342            self.report(type={'ERROR'}, message="指定された画像が見つかりません")
 343            return {'CANCELLED'}
 344
 345        area = common.get_request_area(context, 'IMAGE_EDITOR')
 346        if area:
 347            common.set_area_space_attr(area, 'image', img)
 348        else:
 349            self.report(type={'ERROR'}, message="画像を表示できるエリアが見つかりませんでした")
 350            return {'CANCELLED'}
 351        return {'FINISHED'}
 352
 353
 354@compat.BlRegister(only_legacy=True)
 355class CNV_OT_replace_cm3d2_tex_old(bpy.types.Operator):
 356    bl_idname = 'image.replace_cm3d2_tex'
 357    bl_label = "テクスチャを探す"
 358    bl_description = "CM3D2本体のインストールフォルダからtexファイルを探して開きます"
 359    bl_options = {'REGISTER', 'UNDO'}
 360
 361    @classmethod
 362    def poll(cls, context):
 363        tex = getattr(context, 'texture')
 364        if tex:
 365            return hasattr(tex, 'image')
 366        return False
 367
 368    def execute(self, context):
 369        tex = context.texture
 370        img = tex.image
 371        if not common.replace_cm3d2_tex(img, reload_path=True):
 372            self.report(type={'ERROR'}, message="見つかりませんでした")
 373            return {'CANCELLED'}
 374        tex.image_user.use_auto_refresh = True
 375        return {'FINISHED'}
 376
 377
 378@compat.BlRegister(only_latest=True)
 379class CNV_OT_replace_cm3d2_tex(bpy.types.Operator, common.NodeHandler):
 380    bl_idname = 'image.replace_cm3d2_tex'
 381    bl_label = "テクスチャを探す"
 382    bl_description = "CM3D2本体のインストールフォルダからtexファイルを探して開きます"
 383    bl_options = {'REGISTER', 'UNDO'}
 384
 385    @classmethod
 386    def poll(cls, context):
 387        mate = context.material
 388        return mate and mate.use_nodes
 389        # ob = bpy.context.active_object
 390        # if ob:
 391        # 	mate = ob.active_material
 392        # 	if mate:
 393        # 		return mate.use_nodes
 394        # return False
 395
 396    def execute(self, context):
 397        node = self.get_node(context)
 398        if node and node.type == 'TEX_IMAGE':
 399            img = node.image
 400            if img and common.replace_cm3d2_tex(img, reload_path=True):
 401                self.report(type={'INFO'}, message=f_tip_("テクスチャファイルを読み込みました。file={}", img.filepath))
 402                node.image_user.use_auto_refresh = True
 403                return {'FINISHED'}
 404            else:
 405                msg = f_tip_("テクスチャファイルが見つかりませんでした。file={}", img.filepath) if img else f_tip_("イメージが設定されていません。")
 406                self.report(type={'ERROR'}, message=msg)
 407        else:
 408            self.report(type={'ERROR'}, message="テクスチャノードが見つからないため、スキップしました。")
 409        return {'CANCELLED'}
 410
 411
 412@compat.BlRegister()
 413class CNV_OT_sync_tex_color_ramps(bpy.types.Operator):
 414    bl_idname = 'texture.sync_tex_color_ramps'
 415    bl_label = "設定をプレビューに同期"
 416    bl_description = "設定値をテクスチャのプレビューに適用してわかりやすくします"
 417    bl_options = {'REGISTER', 'UNDO'}
 418
 419    @classmethod
 420    def poll(cls, context):
 421        if getattr(context, 'material'):
 422            return True
 423
 424        return getattr(context, 'texture_slot') and getattr(context, 'texture')
 425
 426    def execute(self, context):
 427        for mate in context.blend_data.materials:
 428            if 'shader1' in mate and 'shader2' in mate:
 429                for slot in mate.texture_slots:
 430                    if slot:
 431                        common.set_texture_color(slot)
 432        return {'FINISHED'}
 433
 434
 435@compat.BlRegister(only_legacy=True)
 436class CNV_OT_set_default_toon_textures_old(bpy.types.Operator):
 437    bl_idname = 'texture.set_default_toon_textures'
 438    bl_label = "トゥーンを選択"
 439    bl_description = "CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます"
 440    bl_options = {'REGISTER', 'UNDO'}
 441
 442    name = bpy.props.StringProperty(name="テクスチャ名")
 443    # dir = bpy.props.StringProperty(name="パス", default="Assets\\texture\\texture\\toon\\")
 444
 445    @classmethod
 446    def poll(cls, context):
 447        tex = getattr(context, 'texture')
 448        if hasattr(context, 'texture_slot') and tex:
 449            name = common.remove_serial_number(tex.name)
 450            return name in ["_ToonRamp", "_ShadowRateToon", "_OutlineToonRamp"]
 451        return False
 452
 453    def execute(self, context):
 454        img = context.texture.image
 455        img.name = self.name
 456
 457        dirname = os.path.dirname(bpy.path.abspath(img.filepath))
 458        png_path = os.path.join(dirname, self.name + ".png")
 459        tex_path = os.path.join(dirname, self.name + ".tex")
 460        if not os.path.exists(png_path):
 461            if os.path.exists(tex_path):
 462                tex_data = common.load_cm3d2tex(tex_path)
 463                if tex_data is None:
 464                    return {'CANCELLED'}
 465                tex_format = tex_data[1]
 466                if not (tex_format == 3 or tex_format == 5):
 467                    return {'CANCELLED'}
 468                with open(png_path, 'wb') as png_file:
 469                    png_file.write(tex_data[-1])
 470        img.filepath = png_path
 471        img.reload()
 472
 473        if 'cm3d2_path' not in img:
 474            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
 475        return {'FINISHED'}
 476
 477
 478@compat.BlRegister(only_latest=True)
 479class CNV_OT_set_default_toon_textures(bpy.types.Operator, common.NodeHandler):
 480    bl_idname = 'texture.set_default_toon_textures'
 481    bl_label = "トゥーンを選択"
 482    bl_description = "CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます"
 483    bl_options = {'REGISTER', 'UNDO'}
 484
 485    tex_name = bpy.props.StringProperty(name="テクスチャ名")
 486
 487    @classmethod
 488    def poll(cls, context):
 489        ob = context.active_object
 490        if ob:
 491            mate = ob.active_material
 492            if mate and mate.use_nodes:
 493                return True
 494
 495        return False
 496
 497    def execute(self, context):
 498        node = self.get_node(context)
 499        if node is None:
 500            self.report(type={'ERROR'}, message=f_tip_("対象のノードが見つかりません={}", self.node_name))
 501            return {'CANCELLED'}
 502
 503        texpathes = common.get_texpath_dict()
 504        texpath = texpathes.get(self.tex_name.lower())
 505        if texpath is None:
 506            if node.image is None:
 507                node.image = context.blend_data.images.new(self.tex_name, 128, 128)
 508                node.image.source = 'FILE'
 509            # 見つからない場合でも、テクスチャ名、ファイルパスに変更を反映
 510            node.image.name = self.tex_name
 511            node.image.filepath = self.tex_name + ".png"
 512        else:
 513
 514            if node.image is None:
 515                node.image = bpy.data.images.load(texpath)
 516                node.image.source = 'FILE'
 517            else:
 518                node.image.filepath = texpath
 519                node.image.reload()
 520
 521        node.image['cm3d2_path'] = common.get_tex_cm3d2path(node.image.filepath)
 522        self.report(type={'INFO'}, message=f_tip_("ノード({})のテクスチャを再設定しました。filepath={}", self.node_name, node.image.filepath))
 523        return {'FINISHED'}
 524
 525
 526@compat.BlRegister(only_latest=True)
 527class CNV_OT_reload_textures(bpy.types.Operator):
 528    bl_idname = 'texture.reload_textures'
 529    bl_label = "イメージの再読込み"
 530    bl_description = "実ファイルパスの設定から、再読込み"
 531    bl_options = {'REGISTER', 'UNDO'}
 532
 533    tex_name = bpy.props.StringProperty(name="テクスチャ名")
 534
 535    @classmethod
 536    def poll(cls, context):
 537        return len(context.blend_data.images) > 0
 538
 539    def execute(self, context):
 540        image = context.blend_data.images.get(self.tex_name)
 541        if image:
 542            image.reload()
 543            return {'FINISHED'}
 544
 545        self.report(type={'ERROR'}, message=f_tip_("対象のイメージが見つかりません={}", self.tex_name))
 546        return {'CANCELLED'}
 547
 548
 549@compat.BlRegister(only_legacy=True)
 550class CNV_OT_auto_set_color_value_old(bpy.types.Operator):
 551    bl_idname = 'texture.auto_set_color_value'
 552    bl_label = "色設定値を自動設定"
 553    bl_description = "色関係の設定値をテクスチャの色情報から自動で設定します"
 554    bl_options = {'REGISTER', 'UNDO'}
 555
 556    is_all = bpy.props.BoolProperty(name="全てが対象", default=True)
 557    saturation_multi = bpy.props.FloatProperty(name="彩度の乗算値", default=2.2, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
 558    value_multi = bpy.props.FloatProperty(name="明度の乗算値", default=0.3, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
 559
 560    @classmethod
 561    def poll(cls, context):
 562        ob = context.active_object
 563        if not ob or ob.type != 'MESH':
 564            return False
 565
 566        mate = ob.active_material
 567        if not mate:
 568            return False
 569
 570        me = ob.data
 571        for slot in mate.texture_slots:
 572            if not slot:
 573                continue
 574            tex = slot.texture
 575            name = common.remove_serial_number(tex.name)
 576            if name == '_MainTex':
 577                img = tex.image
 578                if img and len(img.pixels):
 579                    break
 580                if me.uv_textures.active:
 581                    if me.uv_textures.active.data[0].image:
 582                        if len(me.uv_textures.active.data[0].image.pixels):
 583                            break
 584        else:
 585            return False
 586
 587        tex = getattr(context, 'texture')
 588        slot = getattr(context, 'texture_slot')
 589        if slot and tex:
 590            name = common.remove_serial_number(tex.name)
 591            if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
 592                return True
 593        return False
 594
 595    def invoke(self, context, event):
 596        return context.window_manager.invoke_props_dialog(self)
 597
 598    def draw(self, context):
 599        self.layout.prop(self, 'is_all', icon='ACTION')
 600        row = self.layout.row()
 601        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
 602        row.prop(self, 'saturation_multi')
 603        row = self.layout.row()
 604        row.label(text="", icon='SOLID')
 605        row.prop(self, 'value_multi')
 606
 607    def execute(self, context):
 608        ob = context.active_object
 609        me = ob.data
 610        mate = ob.active_material
 611        active_slot = context.texture_slot
 612        active_tex = context.texture
 613        tex_name = common.remove_serial_number(active_tex.name)
 614
 615        target_slots = []
 616        if self.is_all:
 617            for slot in mate.texture_slots:
 618                if not slot:
 619                    continue
 620                name = common.remove_serial_number(slot.texture.name)
 621                if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
 622                    target_slots.append(slot)
 623        else:
 624            target_slots.append(active_slot)
 625
 626        for slot in mate.texture_slots:
 627            if not slot:
 628                continue
 629            name = common.remove_serial_number(slot.texture.name)
 630            if name == '_MainTex':
 631                img = slot.texture.image
 632                if img:
 633                    if len(img.pixels):
 634                        break
 635        else:
 636            img = me.uv_textures.active.data[0].image
 637
 638        sample_count = 10
 639        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
 640
 641        bm = bmesh.new()
 642        bm.from_mesh(me)
 643        uv_lay = bm.loops.layers.uv.active
 644        uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
 645        bm.free()
 646
 647        average_color = mathutils.Color([0, 0, 0])
 648        seek_interval = len(uvs) / sample_count
 649        for sample_index in range(sample_count):
 650
 651            uv_index = int(seek_interval * sample_index)
 652            x, y = uvs[uv_index]
 653            x, y = int(x * img_width), int(y * img_height)
 654
 655            pixel_index = ((y * img_width) + x) * img_channel
 656            color = mathutils.Color(img.pixels[pixel_index: pixel_index + 3])
 657
 658            average_color += color
 659        average_color /= sample_count
 660        average_color.s *= self.saturation_multi
 661        average_color.v *= self.value_multi
 662
 663        for slot in target_slots:
 664            slot.color = average_color[:3]
 665            common.set_texture_color(slot)
 666
 667        return {'FINISHED'}
 668
 669
 670@compat.BlRegister(only_latest=True)
 671class CNV_OT_auto_set_color_value(bpy.types.Operator):
 672    bl_idname = 'texture.auto_set_color_value'
 673    bl_label = "色設定値を自動設定"
 674    bl_description = "色関係の設定値をテクスチャの色情報から自動で設定します"
 675    bl_options = {'REGISTER', 'UNDO'}
 676
 677    is_all = bpy.props.BoolProperty(name="全てが対象", default=True)
 678    saturation_multi = bpy.props.FloatProperty(name="彩度の乗算値", default=2.2, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
 679    value_multi = bpy.props.FloatProperty(name="明度の乗算値", default=0.3, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
 680    node_name = bpy.props.StringProperty(name='NodeName')
 681
 682    @classmethod
 683    def poll(cls, context):
 684        ob = context.active_object
 685        if not ob or ob.type != 'MESH':
 686            return False
 687
 688        mate = ob.active_material
 689        if not mate or mate.use_nodes is False:
 690            return False
 691
 692        tex_node = mate.node_tree.nodes.get('_MainTex')
 693        # if tex_node is None:  # serial_numberが入っているケースを考慮する場合
 694        # 	for node in mate.node_tree.nodes:
 695        # 		if node.name.startswith('_MainTex.'):
 696        # 			name = common.remove_serial_number(node.name)
 697        # 			if name == '_MainTex':
 698        # 				tex_node = node
 699        # 				break
 700        if tex_node is None:
 701            return False
 702
 703        img = tex_node.image
 704        return img and len(img.pixels)
 705
 706        # found = False
 707        # if img and len(img.pixels):
 708        # 	found = True
 709        # else:
 710        # 	layer = me.uv_layers.active
 711        # 	if layer and len(layer.data):
 712        # 		# TODO imageはアクセスできないため、代替がないか確認
 713        # 		if layer.data[0].image:
 714        # 			if len(layer.data[0].image.pixels):
 715        # 				found = True
 716        # return found
 717
 718    def invoke(self, context, event):
 719        return context.window_manager.invoke_props_dialog(self)
 720
 721    def draw(self, context):
 722        self.layout.prop(self, 'is_all', icon='ACTION')
 723        row = self.layout.row()
 724        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
 725        row.prop(self, 'saturation_multi')
 726        row = self.layout.row()
 727        row.label(text="", icon=compat.icon('SHADING_SOLID'))
 728        row.prop(self, 'value_multi')
 729
 730    def execute(self, context):
 731        ob = context.active_object
 732        me = ob.data
 733        mate = ob.active_material
 734        # active_slot = context.texture_slot
 735        # active_tex = context.texture
 736        # tex_name = common.remove_serial_number(active_tex.name)
 737
 738        target_slots = []
 739        if self.is_all:
 740            for node in mate.node_tree.nodes:
 741                node_name = common.remove_serial_number(node.name)
 742                if node_name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
 743                    target_slots.append(node)
 744        else:
 745            target_slots.append(mate.node_tree.nodes)
 746
 747        main_node = mate.node_tree.nodes.get('_MainTex')
 748        if main_node is None:
 749            for node in mate.node_tree.nodes:
 750                if node.type == 'TEX_IMAGE':
 751                    name = common.remove_serial_number(node.name)
 752                    if name == '_MainTex':
 753                        main_node = node
 754                        break
 755        img = None
 756        if main_node:
 757            img = main_node.image
 758
 759        if img is None or len(img.pixels) == 0:
 760            layer = me.uv_layers.active
 761            if len(layer.data) > 0:
 762                img = layer.data[0].image
 763
 764        if img is None or len(img.pixels) == 0:
 765            return {'CANCELLED'}
 766
 767        sample_count = 10
 768        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
 769
 770        bm = bmesh.new()
 771        try:
 772            bm.from_mesh(me)
 773            uv_lay = bm.loops.layers.uv.active
 774            uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
 775        finally:
 776            bm.free()
 777
 778        avg_color = mathutils.Color([0, 0, 0])
 779        seek_interval = len(uvs) / sample_count
 780        for sample_index in range(sample_count):
 781            uv_index = int(seek_interval * sample_index)
 782            x, y = uvs[uv_index]
 783            x, y = int(x * img_width), int(y * img_height)
 784
 785            pixel_index = ((y * img_width) + x) * img_channel
 786            color = mathutils.Color(img.pixels[pixel_index:pixel_index + 3])
 787
 788            avg_color += color
 789        avg_color /= sample_count
 790        avg_color.s *= self.saturation_multi
 791        avg_color.v *= self.value_multi
 792
 793        for slot in target_slots:
 794            slot.outputs[0].default_value = (avg_color[0], avg_color[1], avg_color[2], 1.0)
 795
 796        return {'FINISHED'}
 797
 798
 799@compat.BlRegister()
 800class CNV_OT_quick_export_cm3d2_tex(bpy.types.Operator):
 801    bl_idname = 'image.quick_export_cm3d2_tex'
 802    bl_label = "texで保存"
 803    bl_description = "テクスチャの画像を同フォルダにtexとして保存します"
 804    bl_options = {'REGISTER'}
 805
 806    node_name = bpy.props.StringProperty(name="NodeName")
 807
 808    def execute(self, context):
 809        img = compat.get_tex_image(context, self.node_name)
 810        if img is None or len(img.pixels) == 0:
 811            self.report(type={'ERROR'}, message=f_tip_("イメージの取得に失敗しました。{}", self.node_name))
 812            return {'CANCELLED'}
 813
 814        override = context.copy()
 815        override['edit_image'] = img
 816
 817        filepath = os.path.splitext(bpy.path.abspath(img.filepath))[0] + ".tex"
 818        if 'cm3d2_path' in img:
 819            path = img['cm3d2_path']
 820        else:
 821            path = common.get_tex_cm3d2path(img.filepath)
 822            img['cm3d2_path'] = path
 823
 824        # 既存のファイルがあればそこから、バージョンとサイズを取得
 825        version = '1000'
 826        uv_rects = None
 827        if os.path.exists(filepath):
 828            tex_data = common.load_cm3d2tex(filepath, skip_data=True)
 829            if tex_data:
 830                version = str(tex_data[0])
 831                uv_rects = tex_data[2]
 832        bpy.types.Scene.MyUVRects = uv_rects
 833        bpy.ops.image.export_cm3d2_tex(override, filepath=filepath, path=path, version=version)
 834
 835        self.report(type={'INFO'}, message="同フォルダにtexとして保存しました。" + filepath)
 836        return {'FINISHED'}
 837
 838
 839@compat.BlRegister(only_legacy=True)
 840class CNV_OT_set_color_value_old(bpy.types.Operator):
 841    bl_idname = 'texture.set_color_value_old'
 842    bl_label = "色設定値を設定"
 843    bl_description = "色タイプの設定値を設定します"
 844    bl_options = {'REGISTER', 'UNDO'}
 845
 846    color = bpy.props.FloatVectorProperty(name="色", default=(0, 0, 0, 0), subtype='COLOR', size=4)
 847
 848    @classmethod
 849    def poll(cls, context):
 850        if hasattr(context, 'texture_slot') and hasattr(context, 'texture'):
 851            return True
 852        return False
 853
 854    def execute(self, context):
 855        slot = context.texture_slot
 856        slot.color = self.color[:3]
 857        slot.diffuse_color_factor = self.color[3]
 858        common.set_texture_color(slot)
 859        return {'FINISHED'}
 860
 861
 862@compat.BlRegister(only_latest=True)
 863class CNV_OT_set_color_value(bpy.types.Operator, common.NodeHandler):
 864    bl_idname = 'texture.set_color_value'
 865    bl_label = "色設定値を設定"
 866    bl_description = "色タイプの設定値を設定します"
 867    bl_options = {'REGISTER', 'UNDO'}
 868
 869    color = bpy.props.FloatVectorProperty(name="色", default=(0, 0, 0, 0), subtype='COLOR', size=4)
 870
 871    @classmethod
 872    def poll(cls, context):
 873        mate = context.material
 874        return mate and mate.use_nodes
 875
 876    def execute(self, context):
 877        node = self.get_node(context)
 878        if node is None:
 879            return {'CANCELLED'}
 880
 881        node.outputs[0].default_value = self.color
 882        return {'FINISHED'}
 883
 884
 885@compat.BlRegister()
 886class CNV_OT_set_value(bpy.types.Operator, common.NodeHandler):
 887    bl_idname = 'texture.set_value'
 888    bl_label = "設定値を設定"
 889    bl_description = "floatタイプの設定値を設定します"
 890    bl_options = {'REGISTER', 'UNDO'}
 891
 892    value = bpy.props.FloatProperty(name='value')
 893
 894    @classmethod
 895    def poll(cls, context):
 896        if compat.IS_LEGACY:
 897            if getattr(context, 'texture_slot') and getattr(context, 'texture'):
 898                return True
 899        else:
 900            mate = context.material
 901            return mate and mate.use_nodes
 902        return False
 903
 904    def execute(self, context):
 905        if compat.IS_LEGACY:
 906            slot = context.texture_slot
 907            slot.color = self.color[:3]
 908            slot.diffuse_color_factor = self.color[3]
 909            common.set_texture_color(slot)
 910        else:
 911            node = self.get_node(context)
 912            if node is None:  # or node.type != 'VALUE':
 913                return {'CANCELLED'}
 914            node.outputs[0].default_value = self.value
 915
 916        return {'FINISHED'}
 917
 918
 919@compat.BlRegister(only_latest=True)
 920class CNV_OT_texture_reset_offset(bpy.types.Operator, common.NodeHandler):
 921    bl_idname = 'texture.reset_offset'
 922    bl_label = "テクスチャのオフセットをリセット"
 923    bl_description = "テクスチャのオフセットに初期値(0, 0)を設定します"
 924    bl_options = {'REGISTER', 'UNDO'}
 925
 926    def execute(self, context):
 927        node = self.get_node(context)
 928        if node and node.type == 'TEX_IMAGE':
 929            node.texture_mapping.translation[0] = 0
 930            node.texture_mapping.translation[1] = 0
 931            return {'FINISHED'}
 932
 933        return {'CANCELLED'}
 934
 935
 936@compat.BlRegister(only_latest=True)
 937class CNV_OT_texture_reset_scale(bpy.types.Operator, common.NodeHandler):
 938    bl_idname = 'texture.reset_scale'
 939    bl_label = "テクスチャのスケールをリセット"
 940    bl_description = "テクスチャのスケールに初期値(1, 1)を設定します"
 941    bl_options = {'REGISTER', 'UNDO'}
 942
 943    def execute(self, context):
 944        node = self.get_node(context)
 945        if node and node.type == 'TEX_IMAGE':
 946            node.texture_mapping.scale[0] = 1
 947            node.texture_mapping.scale[1] = 1
 948            return {'FINISHED'}
 949
 950        return {'CANCELLED'}
 951
 952
 953@compat.BlRegister(only_latest=True)
 954class CNV_OT_set_cm3d2path(bpy.types.Operator, common.NodeHandler):
 955    bl_idname = 'texture.set_cm3d2path'
 956    bl_label = "CM3D2パスを設定"
 957    bl_description = "texタイプのCM3D2パスを自動設定します"
 958    bl_options = {'REGISTER', 'UNDO'}
 959
 960    def execute(self, context):
 961        node = self.get_node(context)
 962        if node and node.type == 'TEX_IMAGE':
 963            img = node.image
 964            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
 965            return {'FINISHED'}
 966        return {'CANCELLED'}
 967
 968
 969@compat.BlRegister(only_latest=True)
 970class CNV_OT_setup_image_name(bpy.types.Operator, common.NodeHandler):
 971    bl_idname = 'texture.setup_image_name'
 972    bl_label = "イメージ名から拡張子を除外"
 973    bl_description = "texタイプのイメージ名から拡張子を除外します"
 974    bl_options = {'REGISTER', 'UNDO'}
 975
 976    def execute(self, context):
 977        node = self.get_node(context)
 978        if node and node.type == 'TEX_IMAGE':
 979            img = node.image
 980            common.setup_image_name(img)
 981            return {'FINISHED'}
 982        return {'CANCELLED'}
 983
 984
 985# Toon設定メニュー
 986class ToonSelectMenuBase():
 987    bl_label = "toon tex 選択"
 988
 989    def draw(self, context):
 990        layout = self.layout
 991        cmd = 'texture.set_default_toon_textures'
 992        for toon_tex in cm3d2_data.TOON_TEXES:
 993            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
 994            opr = layout.operator(cmd, text=toon_tex, icon=icon)
 995            opr.node_name, opr.tex_name = self.node_name(), toon_tex
 996
 997    def node_name(self):
 998        pass
 999
1000
1001@compat.BlRegister(only_latest=True)
1002class TEXTURE_MT_texture_ToonRamp(bpy.types.Menu, ToonSelectMenuBase):
1003    bl_idname = 'TEXTURE_MT_texture_ToonRamp'
1004
1005    def node_name(self):
1006        return '_ToonRamp'
1007
1008
1009@compat.BlRegister(only_latest=True)
1010class TEXTURE_MT_texture_ShadowRateToon(bpy.types.Menu, ToonSelectMenuBase):
1011    bl_idname = 'TEXTURE_MT_texture_ShadowRateToon'
1012
1013    def node_name(self):
1014        return '_ShadowRateToon'
1015
1016
1017@compat.BlRegister(only_latest=True)
1018class TEXTURE_MT_texture_OutlineToonRamp(bpy.types.Menu, ToonSelectMenuBase):
1019    bl_idname = 'TEXTURE_MT_texture_OutlineToonRamp'
1020
1021    def node_name(self):
1022        return '_OutlineToonRamp'
LAYOUT_FACTOR = 0.3
@compat.BlRegister(only_legacy=True)
class TEXTURE_MT_context_texture_ToonRamp(bpy_types.Menu):
203@compat.BlRegister(only_legacy=True)
204class TEXTURE_MT_context_texture_ToonRamp(bpy.types.Menu):
205    bl_idname = 'TEXTURE_MT_context_texture_ToonRamp'
206    bl_label = "_ToonRamp 設定"
207
208    def draw(self, context):
209        l = self.layout
210        cmd = 'texture.set_default_toon_textures'
211        for toon_tex in cm3d2_data.TOON_TEXES:
212            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
213            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
bl_idname = 'TEXTURE_MT_context_texture_ToonRamp'
bl_label = '_ToonRamp 設定'
def draw(self, context):
208    def draw(self, context):
209        l = self.layout
210        cmd = 'texture.set_default_toon_textures'
211        for toon_tex in cm3d2_data.TOON_TEXES:
212            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
213            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bl_rna
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class TEXTURE_MT_context_texture_ShadowRateToon(bpy_types.Menu):
217@compat.BlRegister(only_legacy=True)
218class TEXTURE_MT_context_texture_ShadowRateToon(bpy.types.Menu):
219    bl_idname = 'TEXTURE_MT_context_texture_ShadowRateToon'
220    bl_label = "_ShadowRateToon 設定"
221
222    def draw(self, context):
223        l = self.layout
224        cmd = 'texture.set_default_toon_textures'
225        for toon_tex in cm3d2_data.TOON_TEXES:
226            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
227            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
bl_idname = 'TEXTURE_MT_context_texture_ShadowRateToon'
bl_label = '_ShadowRateToon 設定'
def draw(self, context):
222    def draw(self, context):
223        l = self.layout
224        cmd = 'texture.set_default_toon_textures'
225        for toon_tex in cm3d2_data.TOON_TEXES:
226            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
227            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bl_rna
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class TEXTURE_MT_context_texture_OutlineToonRamp(bpy_types.Menu):
231@compat.BlRegister(only_legacy=True)
232class TEXTURE_MT_context_texture_OutlineToonRamp(bpy.types.Menu):
233    bl_idname = 'TEXTURE_MT_context_texture_OutlineToonRamp'
234    bl_label = "_OutlineToonRamp 設定"
235
236    def draw(self, context):
237        l = self.layout
238        cmd = 'texture.set_default_toon_textures'
239        for toon_tex in cm3d2_data.TOON_TEXES:
240            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
241            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
bl_idname = 'TEXTURE_MT_context_texture_OutlineToonRamp'
bl_label = '_OutlineToonRamp 設定'
def draw(self, context):
236    def draw(self, context):
237        l = self.layout
238        cmd = 'texture.set_default_toon_textures'
239        for toon_tex in cm3d2_data.TOON_TEXES:
240            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
241            l.operator(cmd, text=toon_tex, icon=icon).name = toon_tex
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bl_rna
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class TEXTURE_MT_context_texture_values_normal(bpy_types.Menu):
245@compat.BlRegister()
246class TEXTURE_MT_context_texture_values_normal(bpy.types.Menu):
247    bl_idname = 'TEXTURE_MT_context_texture_values_normal'
248    bl_label = "値リスト"
249
250    def draw(self, context):
251        tex_slot = context.texture_slot
252        for i in range(11):
253            value = round(i * 0.1, 1)
254            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
255            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_idname = 'TEXTURE_MT_context_texture_values_normal'
bl_label = '値リスト'
def draw(self, context):
250    def draw(self, context):
251        tex_slot = context.texture_slot
252        for i in range(11):
253            value = round(i * 0.1, 1)
254            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
255            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_rna = <bpy_struct, Struct("TEXTURE_MT_context_texture_values_normal")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class TEXTURE_MT_context_texture_values_OutlineWidth(bpy_types.Menu):
259@compat.BlRegister()
260class TEXTURE_MT_context_texture_values_OutlineWidth(bpy.types.Menu):
261    bl_idname = 'TEXTURE_MT_context_texture_values_OutlineWidth'
262    bl_label = "値リスト"
263
264    def draw(self, context):
265        tex_slot = context.texture_slot
266        for i in range(16):
267            value = round(i * 0.0002, 4)
268            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
269            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_idname = 'TEXTURE_MT_context_texture_values_OutlineWidth'
bl_label = '値リスト'
def draw(self, context):
264    def draw(self, context):
265        tex_slot = context.texture_slot
266        for i in range(16):
267            value = round(i * 0.0002, 4)
268            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
269            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_rna = <bpy_struct, Struct("TEXTURE_MT_context_texture_values_OutlineWidth")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class TEXTURE_MT_context_texture_values_RimPower(bpy_types.Menu):
273@compat.BlRegister()
274class TEXTURE_MT_context_texture_values_RimPower(bpy.types.Menu):
275    bl_idname = 'TEXTURE_MT_context_texture_values_RimPower'
276    bl_label = "値リスト"
277
278    def draw(self, context):
279        tex_slot = context.texture_slot
280        for i in range(16):
281            value = round(i * 2, 0)
282            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
283            if value == 0:
284                icon = 'ERROR'
285            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_idname = 'TEXTURE_MT_context_texture_values_RimPower'
bl_label = '値リスト'
def draw(self, context):
278    def draw(self, context):
279        tex_slot = context.texture_slot
280        for i in range(16):
281            value = round(i * 2, 0)
282            icon = 'LAYER_USED' if i % 2 else 'LAYER_ACTIVE'
283            if value == 0:
284                icon = 'ERROR'
285            self.layout.operator('texture.set_color_value_old', text=str(value), icon=icon).color = list(tex_slot.color) + [value]
bl_rna = <bpy_struct, Struct("TEXTURE_MT_context_texture_values_RimPower")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class TEXTURE_MT_context_texture_values_ZTest_old(bpy_types.Menu):
289@compat.BlRegister(only_legacy=True)
290class TEXTURE_MT_context_texture_values_ZTest_old(bpy.types.Menu):
291    bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
292    bl_label = "値リスト"
293
294    def draw(self, context):
295        tex_slot = context.texture_slot
296        for i in range(9):
297            value = round(i, 0)
298            self.layout.operator('texture.set_color_value_old', text=str(value)).color = list(tex_slot.color) + [value]
bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
bl_label = '値リスト'
def draw(self, context):
294    def draw(self, context):
295        tex_slot = context.texture_slot
296        for i in range(9):
297            value = round(i, 0)
298            self.layout.operator('texture.set_color_value_old', text=str(value)).color = list(tex_slot.color) + [value]
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bl_rna
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class TEXTURE_MT_context_texture_values_ZTest(bpy_types.Menu):
302@compat.BlRegister(only_latest=True)
303class TEXTURE_MT_context_texture_values_ZTest(bpy.types.Menu):
304    bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
305    bl_label = "値リスト"
306
307    node_name = bpy.props.StringProperty(name='NodeName')
308
309    @classmethod
310    def poll(cls, context):
311        ob = context.active_object
312        if ob:
313            mate = ob.active_material
314            if mate:
315                return mate.use_nodes
316        return False
317
318    def draw(self, context):
319        ob = context.active_object
320        mate = ob.active_material
321        if mate.use_nodes:
322            mate.node_tree.nodes.get()
323        tex_slot = context.texture_slot
324        for i in range(9):
325            value = round(i, 0)
326            opr = self.layout.operator('texture.set_value', text=str(value))
327            opr.node_name, opr.color = node_name, list(tex_slot.color) + [value]
bl_idname = 'TEXTURE_MT_context_texture_values_ZTest'
bl_label = '値リスト'
node_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName'}>
@classmethod
def poll(cls, context):
309    @classmethod
310    def poll(cls, context):
311        ob = context.active_object
312        if ob:
313            mate = ob.active_material
314            if mate:
315                return mate.use_nodes
316        return False
def draw(self, context):
318    def draw(self, context):
319        ob = context.active_object
320        mate = ob.active_material
321        if mate.use_nodes:
322            mate.node_tree.nodes.get()
323        tex_slot = context.texture_slot
324        for i in range(9):
325            value = round(i, 0)
326            opr = self.layout.operator('texture.set_value', text=str(value))
327            opr.node_name, opr.color = node_name, list(tex_slot.color) + [value]
bl_rna = <bpy_struct, Struct("TEXTURE_MT_context_texture_values_ZTest")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class CNV_OT_show_image(bpy_types.Operator):
330@compat.BlRegister()
331class CNV_OT_show_image(bpy.types.Operator):
332    bl_idname = 'image.show_image'
333    bl_label = "画像を表示"
334    bl_description = "指定の画像をUV/画像エディターに表示します"
335    bl_options = {'REGISTER', 'UNDO'}
336
337    image_name = bpy.props.StringProperty(name="画像名")
338
339    def execute(self, context):
340        if self.image_name in context.blend_data.images:
341            img = context.blend_data.images[self.image_name]
342        else:
343            self.report(type={'ERROR'}, message="指定された画像が見つかりません")
344            return {'CANCELLED'}
345
346        area = common.get_request_area(context, 'IMAGE_EDITOR')
347        if area:
348            common.set_area_space_attr(area, 'image', img)
349        else:
350            self.report(type={'ERROR'}, message="画像を表示できるエリアが見つかりませんでした")
351            return {'CANCELLED'}
352        return {'FINISHED'}
bl_idname = 'image.show_image'
bl_label = '画像を表示'
bl_description = '指定の画像をUV/画像エディターに表示します'
bl_options = {'REGISTER', 'UNDO'}
image_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': '画像名', 'attr': 'image_name'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': '画像名', 'attr': 'image_name'}>
def execute(self, context):
339    def execute(self, context):
340        if self.image_name in context.blend_data.images:
341            img = context.blend_data.images[self.image_name]
342        else:
343            self.report(type={'ERROR'}, message="指定された画像が見つかりません")
344            return {'CANCELLED'}
345
346        area = common.get_request_area(context, 'IMAGE_EDITOR')
347        if area:
348            common.set_area_space_attr(area, 'image', img)
349        else:
350            self.report(type={'ERROR'}, message="画像を表示できるエリアが見つかりませんでした")
351            return {'CANCELLED'}
352        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("IMAGE_OT_show_image")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class CNV_OT_replace_cm3d2_tex_old(bpy_types.Operator):
355@compat.BlRegister(only_legacy=True)
356class CNV_OT_replace_cm3d2_tex_old(bpy.types.Operator):
357    bl_idname = 'image.replace_cm3d2_tex'
358    bl_label = "テクスチャを探す"
359    bl_description = "CM3D2本体のインストールフォルダからtexファイルを探して開きます"
360    bl_options = {'REGISTER', 'UNDO'}
361
362    @classmethod
363    def poll(cls, context):
364        tex = getattr(context, 'texture')
365        if tex:
366            return hasattr(tex, 'image')
367        return False
368
369    def execute(self, context):
370        tex = context.texture
371        img = tex.image
372        if not common.replace_cm3d2_tex(img, reload_path=True):
373            self.report(type={'ERROR'}, message="見つかりませんでした")
374            return {'CANCELLED'}
375        tex.image_user.use_auto_refresh = True
376        return {'FINISHED'}
bl_idname = 'image.replace_cm3d2_tex'
bl_label = 'テクスチャを探す'
bl_description = 'CM3D2本体のインストールフォルダからtexファイルを探して開きます'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
362    @classmethod
363    def poll(cls, context):
364        tex = getattr(context, 'texture')
365        if tex:
366            return hasattr(tex, 'image')
367        return False
def execute(self, context):
369    def execute(self, context):
370        tex = context.texture
371        img = tex.image
372        if not common.replace_cm3d2_tex(img, reload_path=True):
373            self.report(type={'ERROR'}, message="見つかりませんでした")
374            return {'CANCELLED'}
375        tex.image_user.use_auto_refresh = True
376        return {'FINISHED'}
Inherited Members
bpy_types.Operator
as_keywords
bl_rna
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_replace_cm3d2_tex(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
379@compat.BlRegister(only_latest=True)
380class CNV_OT_replace_cm3d2_tex(bpy.types.Operator, common.NodeHandler):
381    bl_idname = 'image.replace_cm3d2_tex'
382    bl_label = "テクスチャを探す"
383    bl_description = "CM3D2本体のインストールフォルダからtexファイルを探して開きます"
384    bl_options = {'REGISTER', 'UNDO'}
385
386    @classmethod
387    def poll(cls, context):
388        mate = context.material
389        return mate and mate.use_nodes
390        # ob = bpy.context.active_object
391        # if ob:
392        # 	mate = ob.active_material
393        # 	if mate:
394        # 		return mate.use_nodes
395        # return False
396
397    def execute(self, context):
398        node = self.get_node(context)
399        if node and node.type == 'TEX_IMAGE':
400            img = node.image
401            if img and common.replace_cm3d2_tex(img, reload_path=True):
402                self.report(type={'INFO'}, message=f_tip_("テクスチャファイルを読み込みました。file={}", img.filepath))
403                node.image_user.use_auto_refresh = True
404                return {'FINISHED'}
405            else:
406                msg = f_tip_("テクスチャファイルが見つかりませんでした。file={}", img.filepath) if img else f_tip_("イメージが設定されていません。")
407                self.report(type={'ERROR'}, message=msg)
408        else:
409            self.report(type={'ERROR'}, message="テクスチャノードが見つからないため、スキップしました。")
410        return {'CANCELLED'}
bl_idname = 'image.replace_cm3d2_tex'
bl_label = 'テクスチャを探す'
bl_description = 'CM3D2本体のインストールフォルダからtexファイルを探して開きます'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
386    @classmethod
387    def poll(cls, context):
388        mate = context.material
389        return mate and mate.use_nodes
390        # ob = bpy.context.active_object
391        # if ob:
392        # 	mate = ob.active_material
393        # 	if mate:
394        # 		return mate.use_nodes
395        # return False
def execute(self, context):
397    def execute(self, context):
398        node = self.get_node(context)
399        if node and node.type == 'TEX_IMAGE':
400            img = node.image
401            if img and common.replace_cm3d2_tex(img, reload_path=True):
402                self.report(type={'INFO'}, message=f_tip_("テクスチャファイルを読み込みました。file={}", img.filepath))
403                node.image_user.use_auto_refresh = True
404                return {'FINISHED'}
405            else:
406                msg = f_tip_("テクスチャファイルが見つかりませんでした。file={}", img.filepath) if img else f_tip_("イメージが設定されていません。")
407                self.report(type={'ERROR'}, message=msg)
408        else:
409            self.report(type={'ERROR'}, message="テクスチャノードが見つからないため、スキップしました。")
410        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("IMAGE_OT_replace_cm3d2_tex")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class CNV_OT_sync_tex_color_ramps(bpy_types.Operator):
413@compat.BlRegister()
414class CNV_OT_sync_tex_color_ramps(bpy.types.Operator):
415    bl_idname = 'texture.sync_tex_color_ramps'
416    bl_label = "設定をプレビューに同期"
417    bl_description = "設定値をテクスチャのプレビューに適用してわかりやすくします"
418    bl_options = {'REGISTER', 'UNDO'}
419
420    @classmethod
421    def poll(cls, context):
422        if getattr(context, 'material'):
423            return True
424
425        return getattr(context, 'texture_slot') and getattr(context, 'texture')
426
427    def execute(self, context):
428        for mate in context.blend_data.materials:
429            if 'shader1' in mate and 'shader2' in mate:
430                for slot in mate.texture_slots:
431                    if slot:
432                        common.set_texture_color(slot)
433        return {'FINISHED'}
bl_idname = 'texture.sync_tex_color_ramps'
bl_label = '設定をプレビューに同期'
bl_description = '設定値をテクスチャのプレビューに適用してわかりやすくします'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
420    @classmethod
421    def poll(cls, context):
422        if getattr(context, 'material'):
423            return True
424
425        return getattr(context, 'texture_slot') and getattr(context, 'texture')
def execute(self, context):
427    def execute(self, context):
428        for mate in context.blend_data.materials:
429            if 'shader1' in mate and 'shader2' in mate:
430                for slot in mate.texture_slots:
431                    if slot:
432                        common.set_texture_color(slot)
433        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_sync_tex_color_ramps")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class CNV_OT_set_default_toon_textures_old(bpy_types.Operator):
436@compat.BlRegister(only_legacy=True)
437class CNV_OT_set_default_toon_textures_old(bpy.types.Operator):
438    bl_idname = 'texture.set_default_toon_textures'
439    bl_label = "トゥーンを選択"
440    bl_description = "CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます"
441    bl_options = {'REGISTER', 'UNDO'}
442
443    name = bpy.props.StringProperty(name="テクスチャ名")
444    # dir = bpy.props.StringProperty(name="パス", default="Assets\\texture\\texture\\toon\\")
445
446    @classmethod
447    def poll(cls, context):
448        tex = getattr(context, 'texture')
449        if hasattr(context, 'texture_slot') and tex:
450            name = common.remove_serial_number(tex.name)
451            return name in ["_ToonRamp", "_ShadowRateToon", "_OutlineToonRamp"]
452        return False
453
454    def execute(self, context):
455        img = context.texture.image
456        img.name = self.name
457
458        dirname = os.path.dirname(bpy.path.abspath(img.filepath))
459        png_path = os.path.join(dirname, self.name + ".png")
460        tex_path = os.path.join(dirname, self.name + ".tex")
461        if not os.path.exists(png_path):
462            if os.path.exists(tex_path):
463                tex_data = common.load_cm3d2tex(tex_path)
464                if tex_data is None:
465                    return {'CANCELLED'}
466                tex_format = tex_data[1]
467                if not (tex_format == 3 or tex_format == 5):
468                    return {'CANCELLED'}
469                with open(png_path, 'wb') as png_file:
470                    png_file.write(tex_data[-1])
471        img.filepath = png_path
472        img.reload()
473
474        if 'cm3d2_path' not in img:
475            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
476        return {'FINISHED'}
bl_idname = 'texture.set_default_toon_textures'
bl_label = 'トゥーンを選択'
bl_description = 'CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます'
bl_options = {'REGISTER', 'UNDO'}
name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名'}>
@classmethod
def poll(cls, context):
446    @classmethod
447    def poll(cls, context):
448        tex = getattr(context, 'texture')
449        if hasattr(context, 'texture_slot') and tex:
450            name = common.remove_serial_number(tex.name)
451            return name in ["_ToonRamp", "_ShadowRateToon", "_OutlineToonRamp"]
452        return False
def execute(self, context):
454    def execute(self, context):
455        img = context.texture.image
456        img.name = self.name
457
458        dirname = os.path.dirname(bpy.path.abspath(img.filepath))
459        png_path = os.path.join(dirname, self.name + ".png")
460        tex_path = os.path.join(dirname, self.name + ".tex")
461        if not os.path.exists(png_path):
462            if os.path.exists(tex_path):
463                tex_data = common.load_cm3d2tex(tex_path)
464                if tex_data is None:
465                    return {'CANCELLED'}
466                tex_format = tex_data[1]
467                if not (tex_format == 3 or tex_format == 5):
468                    return {'CANCELLED'}
469                with open(png_path, 'wb') as png_file:
470                    png_file.write(tex_data[-1])
471        img.filepath = png_path
472        img.reload()
473
474        if 'cm3d2_path' not in img:
475            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
476        return {'FINISHED'}
Inherited Members
bpy_types.Operator
as_keywords
bl_rna
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_set_default_toon_textures(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
479@compat.BlRegister(only_latest=True)
480class CNV_OT_set_default_toon_textures(bpy.types.Operator, common.NodeHandler):
481    bl_idname = 'texture.set_default_toon_textures'
482    bl_label = "トゥーンを選択"
483    bl_description = "CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます"
484    bl_options = {'REGISTER', 'UNDO'}
485
486    tex_name = bpy.props.StringProperty(name="テクスチャ名")
487
488    @classmethod
489    def poll(cls, context):
490        ob = context.active_object
491        if ob:
492            mate = ob.active_material
493            if mate and mate.use_nodes:
494                return True
495
496        return False
497
498    def execute(self, context):
499        node = self.get_node(context)
500        if node is None:
501            self.report(type={'ERROR'}, message=f_tip_("対象のノードが見つかりません={}", self.node_name))
502            return {'CANCELLED'}
503
504        texpathes = common.get_texpath_dict()
505        texpath = texpathes.get(self.tex_name.lower())
506        if texpath is None:
507            if node.image is None:
508                node.image = context.blend_data.images.new(self.tex_name, 128, 128)
509                node.image.source = 'FILE'
510            # 見つからない場合でも、テクスチャ名、ファイルパスに変更を反映
511            node.image.name = self.tex_name
512            node.image.filepath = self.tex_name + ".png"
513        else:
514
515            if node.image is None:
516                node.image = bpy.data.images.load(texpath)
517                node.image.source = 'FILE'
518            else:
519                node.image.filepath = texpath
520                node.image.reload()
521
522        node.image['cm3d2_path'] = common.get_tex_cm3d2path(node.image.filepath)
523        self.report(type={'INFO'}, message=f_tip_("ノード({})のテクスチャを再設定しました。filepath={}", self.node_name, node.image.filepath))
524        return {'FINISHED'}
bl_idname = 'texture.set_default_toon_textures'
bl_label = 'トゥーンを選択'
bl_description = 'CM3D2にデフォルトで入っているトゥーンテクスチャを選択できます'
bl_options = {'REGISTER', 'UNDO'}
tex_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名', 'attr': 'tex_name'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名', 'attr': 'tex_name'}>
@classmethod
def poll(cls, context):
488    @classmethod
489    def poll(cls, context):
490        ob = context.active_object
491        if ob:
492            mate = ob.active_material
493            if mate and mate.use_nodes:
494                return True
495
496        return False
def execute(self, context):
498    def execute(self, context):
499        node = self.get_node(context)
500        if node is None:
501            self.report(type={'ERROR'}, message=f_tip_("対象のノードが見つかりません={}", self.node_name))
502            return {'CANCELLED'}
503
504        texpathes = common.get_texpath_dict()
505        texpath = texpathes.get(self.tex_name.lower())
506        if texpath is None:
507            if node.image is None:
508                node.image = context.blend_data.images.new(self.tex_name, 128, 128)
509                node.image.source = 'FILE'
510            # 見つからない場合でも、テクスチャ名、ファイルパスに変更を反映
511            node.image.name = self.tex_name
512            node.image.filepath = self.tex_name + ".png"
513        else:
514
515            if node.image is None:
516                node.image = bpy.data.images.load(texpath)
517                node.image.source = 'FILE'
518            else:
519                node.image.filepath = texpath
520                node.image.reload()
521
522        node.image['cm3d2_path'] = common.get_tex_cm3d2path(node.image.filepath)
523        self.report(type={'INFO'}, message=f_tip_("ノード({})のテクスチャを再設定しました。filepath={}", self.node_name, node.image.filepath))
524        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_set_default_toon_textures")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_reload_textures(bpy_types.Operator):
527@compat.BlRegister(only_latest=True)
528class CNV_OT_reload_textures(bpy.types.Operator):
529    bl_idname = 'texture.reload_textures'
530    bl_label = "イメージの再読込み"
531    bl_description = "実ファイルパスの設定から、再読込み"
532    bl_options = {'REGISTER', 'UNDO'}
533
534    tex_name = bpy.props.StringProperty(name="テクスチャ名")
535
536    @classmethod
537    def poll(cls, context):
538        return len(context.blend_data.images) > 0
539
540    def execute(self, context):
541        image = context.blend_data.images.get(self.tex_name)
542        if image:
543            image.reload()
544            return {'FINISHED'}
545
546        self.report(type={'ERROR'}, message=f_tip_("対象のイメージが見つかりません={}", self.tex_name))
547        return {'CANCELLED'}
bl_idname = 'texture.reload_textures'
bl_label = 'イメージの再読込み'
bl_description = '実ファイルパスの設定から、再読込み'
bl_options = {'REGISTER', 'UNDO'}
tex_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名', 'attr': 'tex_name'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'テクスチャ名', 'attr': 'tex_name'}>
@classmethod
def poll(cls, context):
536    @classmethod
537    def poll(cls, context):
538        return len(context.blend_data.images) > 0
def execute(self, context):
540    def execute(self, context):
541        image = context.blend_data.images.get(self.tex_name)
542        if image:
543            image.reload()
544            return {'FINISHED'}
545
546        self.report(type={'ERROR'}, message=f_tip_("対象のイメージが見つかりません={}", self.tex_name))
547        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_reload_textures")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class CNV_OT_auto_set_color_value_old(bpy_types.Operator):
550@compat.BlRegister(only_legacy=True)
551class CNV_OT_auto_set_color_value_old(bpy.types.Operator):
552    bl_idname = 'texture.auto_set_color_value'
553    bl_label = "色設定値を自動設定"
554    bl_description = "色関係の設定値をテクスチャの色情報から自動で設定します"
555    bl_options = {'REGISTER', 'UNDO'}
556
557    is_all = bpy.props.BoolProperty(name="全てが対象", default=True)
558    saturation_multi = bpy.props.FloatProperty(name="彩度の乗算値", default=2.2, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
559    value_multi = bpy.props.FloatProperty(name="明度の乗算値", default=0.3, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
560
561    @classmethod
562    def poll(cls, context):
563        ob = context.active_object
564        if not ob or ob.type != 'MESH':
565            return False
566
567        mate = ob.active_material
568        if not mate:
569            return False
570
571        me = ob.data
572        for slot in mate.texture_slots:
573            if not slot:
574                continue
575            tex = slot.texture
576            name = common.remove_serial_number(tex.name)
577            if name == '_MainTex':
578                img = tex.image
579                if img and len(img.pixels):
580                    break
581                if me.uv_textures.active:
582                    if me.uv_textures.active.data[0].image:
583                        if len(me.uv_textures.active.data[0].image.pixels):
584                            break
585        else:
586            return False
587
588        tex = getattr(context, 'texture')
589        slot = getattr(context, 'texture_slot')
590        if slot and tex:
591            name = common.remove_serial_number(tex.name)
592            if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
593                return True
594        return False
595
596    def invoke(self, context, event):
597        return context.window_manager.invoke_props_dialog(self)
598
599    def draw(self, context):
600        self.layout.prop(self, 'is_all', icon='ACTION')
601        row = self.layout.row()
602        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
603        row.prop(self, 'saturation_multi')
604        row = self.layout.row()
605        row.label(text="", icon='SOLID')
606        row.prop(self, 'value_multi')
607
608    def execute(self, context):
609        ob = context.active_object
610        me = ob.data
611        mate = ob.active_material
612        active_slot = context.texture_slot
613        active_tex = context.texture
614        tex_name = common.remove_serial_number(active_tex.name)
615
616        target_slots = []
617        if self.is_all:
618            for slot in mate.texture_slots:
619                if not slot:
620                    continue
621                name = common.remove_serial_number(slot.texture.name)
622                if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
623                    target_slots.append(slot)
624        else:
625            target_slots.append(active_slot)
626
627        for slot in mate.texture_slots:
628            if not slot:
629                continue
630            name = common.remove_serial_number(slot.texture.name)
631            if name == '_MainTex':
632                img = slot.texture.image
633                if img:
634                    if len(img.pixels):
635                        break
636        else:
637            img = me.uv_textures.active.data[0].image
638
639        sample_count = 10
640        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
641
642        bm = bmesh.new()
643        bm.from_mesh(me)
644        uv_lay = bm.loops.layers.uv.active
645        uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
646        bm.free()
647
648        average_color = mathutils.Color([0, 0, 0])
649        seek_interval = len(uvs) / sample_count
650        for sample_index in range(sample_count):
651
652            uv_index = int(seek_interval * sample_index)
653            x, y = uvs[uv_index]
654            x, y = int(x * img_width), int(y * img_height)
655
656            pixel_index = ((y * img_width) + x) * img_channel
657            color = mathutils.Color(img.pixels[pixel_index: pixel_index + 3])
658
659            average_color += color
660        average_color /= sample_count
661        average_color.s *= self.saturation_multi
662        average_color.v *= self.value_multi
663
664        for slot in target_slots:
665            slot.color = average_color[:3]
666            common.set_texture_color(slot)
667
668        return {'FINISHED'}
bl_idname = 'texture.auto_set_color_value'
bl_label = '色設定値を自動設定'
bl_description = '色関係の設定値をテクスチャの色情報から自動で設定します'
bl_options = {'REGISTER', 'UNDO'}
is_all: <_PropertyDeferred, <built-in function BoolProperty>, {'name': '全てが対象', 'default': True}> = <_PropertyDeferred, <built-in function BoolProperty>, {'name': '全てが対象', 'default': True}>
saturation_multi: <_PropertyDeferred, <built-in function FloatProperty>, {'name': '彩度の乗算値', 'default': 2.2, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2}> = <_PropertyDeferred, <built-in function FloatProperty>, {'name': '彩度の乗算値', 'default': 2.2, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2}>
value_multi: <_PropertyDeferred, <built-in function FloatProperty>, {'name': '明度の乗算値', 'default': 0.3, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2}> = <_PropertyDeferred, <built-in function FloatProperty>, {'name': '明度の乗算値', 'default': 0.3, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2}>
@classmethod
def poll(cls, context):
561    @classmethod
562    def poll(cls, context):
563        ob = context.active_object
564        if not ob or ob.type != 'MESH':
565            return False
566
567        mate = ob.active_material
568        if not mate:
569            return False
570
571        me = ob.data
572        for slot in mate.texture_slots:
573            if not slot:
574                continue
575            tex = slot.texture
576            name = common.remove_serial_number(tex.name)
577            if name == '_MainTex':
578                img = tex.image
579                if img and len(img.pixels):
580                    break
581                if me.uv_textures.active:
582                    if me.uv_textures.active.data[0].image:
583                        if len(me.uv_textures.active.data[0].image.pixels):
584                            break
585        else:
586            return False
587
588        tex = getattr(context, 'texture')
589        slot = getattr(context, 'texture_slot')
590        if slot and tex:
591            name = common.remove_serial_number(tex.name)
592            if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
593                return True
594        return False
def invoke(self, context, event):
596    def invoke(self, context, event):
597        return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
599    def draw(self, context):
600        self.layout.prop(self, 'is_all', icon='ACTION')
601        row = self.layout.row()
602        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
603        row.prop(self, 'saturation_multi')
604        row = self.layout.row()
605        row.label(text="", icon='SOLID')
606        row.prop(self, 'value_multi')
def execute(self, context):
608    def execute(self, context):
609        ob = context.active_object
610        me = ob.data
611        mate = ob.active_material
612        active_slot = context.texture_slot
613        active_tex = context.texture
614        tex_name = common.remove_serial_number(active_tex.name)
615
616        target_slots = []
617        if self.is_all:
618            for slot in mate.texture_slots:
619                if not slot:
620                    continue
621                name = common.remove_serial_number(slot.texture.name)
622                if name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
623                    target_slots.append(slot)
624        else:
625            target_slots.append(active_slot)
626
627        for slot in mate.texture_slots:
628            if not slot:
629                continue
630            name = common.remove_serial_number(slot.texture.name)
631            if name == '_MainTex':
632                img = slot.texture.image
633                if img:
634                    if len(img.pixels):
635                        break
636        else:
637            img = me.uv_textures.active.data[0].image
638
639        sample_count = 10
640        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
641
642        bm = bmesh.new()
643        bm.from_mesh(me)
644        uv_lay = bm.loops.layers.uv.active
645        uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
646        bm.free()
647
648        average_color = mathutils.Color([0, 0, 0])
649        seek_interval = len(uvs) / sample_count
650        for sample_index in range(sample_count):
651
652            uv_index = int(seek_interval * sample_index)
653            x, y = uvs[uv_index]
654            x, y = int(x * img_width), int(y * img_height)
655
656            pixel_index = ((y * img_width) + x) * img_channel
657            color = mathutils.Color(img.pixels[pixel_index: pixel_index + 3])
658
659            average_color += color
660        average_color /= sample_count
661        average_color.s *= self.saturation_multi
662        average_color.v *= self.value_multi
663
664        for slot in target_slots:
665            slot.color = average_color[:3]
666            common.set_texture_color(slot)
667
668        return {'FINISHED'}
Inherited Members
bpy_types.Operator
as_keywords
bl_rna
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_auto_set_color_value(bpy_types.Operator):
671@compat.BlRegister(only_latest=True)
672class CNV_OT_auto_set_color_value(bpy.types.Operator):
673    bl_idname = 'texture.auto_set_color_value'
674    bl_label = "色設定値を自動設定"
675    bl_description = "色関係の設定値をテクスチャの色情報から自動で設定します"
676    bl_options = {'REGISTER', 'UNDO'}
677
678    is_all = bpy.props.BoolProperty(name="全てが対象", default=True)
679    saturation_multi = bpy.props.FloatProperty(name="彩度の乗算値", default=2.2, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
680    value_multi = bpy.props.FloatProperty(name="明度の乗算値", default=0.3, min=0, max=5, soft_min=0, soft_max=5, step=10, precision=2)
681    node_name = bpy.props.StringProperty(name='NodeName')
682
683    @classmethod
684    def poll(cls, context):
685        ob = context.active_object
686        if not ob or ob.type != 'MESH':
687            return False
688
689        mate = ob.active_material
690        if not mate or mate.use_nodes is False:
691            return False
692
693        tex_node = mate.node_tree.nodes.get('_MainTex')
694        # if tex_node is None:  # serial_numberが入っているケースを考慮する場合
695        # 	for node in mate.node_tree.nodes:
696        # 		if node.name.startswith('_MainTex.'):
697        # 			name = common.remove_serial_number(node.name)
698        # 			if name == '_MainTex':
699        # 				tex_node = node
700        # 				break
701        if tex_node is None:
702            return False
703
704        img = tex_node.image
705        return img and len(img.pixels)
706
707        # found = False
708        # if img and len(img.pixels):
709        # 	found = True
710        # else:
711        # 	layer = me.uv_layers.active
712        # 	if layer and len(layer.data):
713        # 		# TODO imageはアクセスできないため、代替がないか確認
714        # 		if layer.data[0].image:
715        # 			if len(layer.data[0].image.pixels):
716        # 				found = True
717        # return found
718
719    def invoke(self, context, event):
720        return context.window_manager.invoke_props_dialog(self)
721
722    def draw(self, context):
723        self.layout.prop(self, 'is_all', icon='ACTION')
724        row = self.layout.row()
725        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
726        row.prop(self, 'saturation_multi')
727        row = self.layout.row()
728        row.label(text="", icon=compat.icon('SHADING_SOLID'))
729        row.prop(self, 'value_multi')
730
731    def execute(self, context):
732        ob = context.active_object
733        me = ob.data
734        mate = ob.active_material
735        # active_slot = context.texture_slot
736        # active_tex = context.texture
737        # tex_name = common.remove_serial_number(active_tex.name)
738
739        target_slots = []
740        if self.is_all:
741            for node in mate.node_tree.nodes:
742                node_name = common.remove_serial_number(node.name)
743                if node_name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
744                    target_slots.append(node)
745        else:
746            target_slots.append(mate.node_tree.nodes)
747
748        main_node = mate.node_tree.nodes.get('_MainTex')
749        if main_node is None:
750            for node in mate.node_tree.nodes:
751                if node.type == 'TEX_IMAGE':
752                    name = common.remove_serial_number(node.name)
753                    if name == '_MainTex':
754                        main_node = node
755                        break
756        img = None
757        if main_node:
758            img = main_node.image
759
760        if img is None or len(img.pixels) == 0:
761            layer = me.uv_layers.active
762            if len(layer.data) > 0:
763                img = layer.data[0].image
764
765        if img is None or len(img.pixels) == 0:
766            return {'CANCELLED'}
767
768        sample_count = 10
769        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
770
771        bm = bmesh.new()
772        try:
773            bm.from_mesh(me)
774            uv_lay = bm.loops.layers.uv.active
775            uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
776        finally:
777            bm.free()
778
779        avg_color = mathutils.Color([0, 0, 0])
780        seek_interval = len(uvs) / sample_count
781        for sample_index in range(sample_count):
782            uv_index = int(seek_interval * sample_index)
783            x, y = uvs[uv_index]
784            x, y = int(x * img_width), int(y * img_height)
785
786            pixel_index = ((y * img_width) + x) * img_channel
787            color = mathutils.Color(img.pixels[pixel_index:pixel_index + 3])
788
789            avg_color += color
790        avg_color /= sample_count
791        avg_color.s *= self.saturation_multi
792        avg_color.v *= self.value_multi
793
794        for slot in target_slots:
795            slot.outputs[0].default_value = (avg_color[0], avg_color[1], avg_color[2], 1.0)
796
797        return {'FINISHED'}
bl_idname = 'texture.auto_set_color_value'
bl_label = '色設定値を自動設定'
bl_description = '色関係の設定値をテクスチャの色情報から自動で設定します'
bl_options = {'REGISTER', 'UNDO'}
is_all: <_PropertyDeferred, <built-in function BoolProperty>, {'name': '全てが対象', 'default': True, 'attr': 'is_all'}> = <_PropertyDeferred, <built-in function BoolProperty>, {'name': '全てが対象', 'default': True, 'attr': 'is_all'}>
saturation_multi: <_PropertyDeferred, <built-in function FloatProperty>, {'name': '彩度の乗算値', 'default': 2.2, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2, 'attr': 'saturation_multi'}> = <_PropertyDeferred, <built-in function FloatProperty>, {'name': '彩度の乗算値', 'default': 2.2, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2, 'attr': 'saturation_multi'}>
value_multi: <_PropertyDeferred, <built-in function FloatProperty>, {'name': '明度の乗算値', 'default': 0.3, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2, 'attr': 'value_multi'}> = <_PropertyDeferred, <built-in function FloatProperty>, {'name': '明度の乗算値', 'default': 0.3, 'min': 0, 'max': 5, 'soft_min': 0, 'soft_max': 5, 'step': 10, 'precision': 2, 'attr': 'value_multi'}>
node_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName', 'attr': 'node_name'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName', 'attr': 'node_name'}>
@classmethod
def poll(cls, context):
683    @classmethod
684    def poll(cls, context):
685        ob = context.active_object
686        if not ob or ob.type != 'MESH':
687            return False
688
689        mate = ob.active_material
690        if not mate or mate.use_nodes is False:
691            return False
692
693        tex_node = mate.node_tree.nodes.get('_MainTex')
694        # if tex_node is None:  # serial_numberが入っているケースを考慮する場合
695        # 	for node in mate.node_tree.nodes:
696        # 		if node.name.startswith('_MainTex.'):
697        # 			name = common.remove_serial_number(node.name)
698        # 			if name == '_MainTex':
699        # 				tex_node = node
700        # 				break
701        if tex_node is None:
702            return False
703
704        img = tex_node.image
705        return img and len(img.pixels)
706
707        # found = False
708        # if img and len(img.pixels):
709        # 	found = True
710        # else:
711        # 	layer = me.uv_layers.active
712        # 	if layer and len(layer.data):
713        # 		# TODO imageはアクセスできないため、代替がないか確認
714        # 		if layer.data[0].image:
715        # 			if len(layer.data[0].image.pixels):
716        # 				found = True
717        # return found
def invoke(self, context, event):
719    def invoke(self, context, event):
720        return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
722    def draw(self, context):
723        self.layout.prop(self, 'is_all', icon='ACTION')
724        row = self.layout.row()
725        row.label(text="", icon=compat.icon('SHADING_RENDERED'))
726        row.prop(self, 'saturation_multi')
727        row = self.layout.row()
728        row.label(text="", icon=compat.icon('SHADING_SOLID'))
729        row.prop(self, 'value_multi')
def execute(self, context):
731    def execute(self, context):
732        ob = context.active_object
733        me = ob.data
734        mate = ob.active_material
735        # active_slot = context.texture_slot
736        # active_tex = context.texture
737        # tex_name = common.remove_serial_number(active_tex.name)
738
739        target_slots = []
740        if self.is_all:
741            for node in mate.node_tree.nodes:
742                node_name = common.remove_serial_number(node.name)
743                if node_name in ['_ShadowColor', '_RimColor', '_OutlineColor']:
744                    target_slots.append(node)
745        else:
746            target_slots.append(mate.node_tree.nodes)
747
748        main_node = mate.node_tree.nodes.get('_MainTex')
749        if main_node is None:
750            for node in mate.node_tree.nodes:
751                if node.type == 'TEX_IMAGE':
752                    name = common.remove_serial_number(node.name)
753                    if name == '_MainTex':
754                        main_node = node
755                        break
756        img = None
757        if main_node:
758            img = main_node.image
759
760        if img is None or len(img.pixels) == 0:
761            layer = me.uv_layers.active
762            if len(layer.data) > 0:
763                img = layer.data[0].image
764
765        if img is None or len(img.pixels) == 0:
766            return {'CANCELLED'}
767
768        sample_count = 10
769        img_width, img_height, img_channel = img.size[0], img.size[1], img.channels
770
771        bm = bmesh.new()
772        try:
773            bm.from_mesh(me)
774            uv_lay = bm.loops.layers.uv.active
775            uvs = [l[uv_lay].uv[:] for f in bm.faces if f.material_index == ob.active_material_index for l in f.loops]
776        finally:
777            bm.free()
778
779        avg_color = mathutils.Color([0, 0, 0])
780        seek_interval = len(uvs) / sample_count
781        for sample_index in range(sample_count):
782            uv_index = int(seek_interval * sample_index)
783            x, y = uvs[uv_index]
784            x, y = int(x * img_width), int(y * img_height)
785
786            pixel_index = ((y * img_width) + x) * img_channel
787            color = mathutils.Color(img.pixels[pixel_index:pixel_index + 3])
788
789            avg_color += color
790        avg_color /= sample_count
791        avg_color.s *= self.saturation_multi
792        avg_color.v *= self.value_multi
793
794        for slot in target_slots:
795            slot.outputs[0].default_value = (avg_color[0], avg_color[1], avg_color[2], 1.0)
796
797        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_auto_set_color_value")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class CNV_OT_quick_export_cm3d2_tex(bpy_types.Operator):
800@compat.BlRegister()
801class CNV_OT_quick_export_cm3d2_tex(bpy.types.Operator):
802    bl_idname = 'image.quick_export_cm3d2_tex'
803    bl_label = "texで保存"
804    bl_description = "テクスチャの画像を同フォルダにtexとして保存します"
805    bl_options = {'REGISTER'}
806
807    node_name = bpy.props.StringProperty(name="NodeName")
808
809    def execute(self, context):
810        img = compat.get_tex_image(context, self.node_name)
811        if img is None or len(img.pixels) == 0:
812            self.report(type={'ERROR'}, message=f_tip_("イメージの取得に失敗しました。{}", self.node_name))
813            return {'CANCELLED'}
814
815        override = context.copy()
816        override['edit_image'] = img
817
818        filepath = os.path.splitext(bpy.path.abspath(img.filepath))[0] + ".tex"
819        if 'cm3d2_path' in img:
820            path = img['cm3d2_path']
821        else:
822            path = common.get_tex_cm3d2path(img.filepath)
823            img['cm3d2_path'] = path
824
825        # 既存のファイルがあればそこから、バージョンとサイズを取得
826        version = '1000'
827        uv_rects = None
828        if os.path.exists(filepath):
829            tex_data = common.load_cm3d2tex(filepath, skip_data=True)
830            if tex_data:
831                version = str(tex_data[0])
832                uv_rects = tex_data[2]
833        bpy.types.Scene.MyUVRects = uv_rects
834        bpy.ops.image.export_cm3d2_tex(override, filepath=filepath, path=path, version=version)
835
836        self.report(type={'INFO'}, message="同フォルダにtexとして保存しました。" + filepath)
837        return {'FINISHED'}
bl_idname = 'image.quick_export_cm3d2_tex'
bl_label = 'texで保存'
bl_description = 'テクスチャの画像を同フォルダにtexとして保存します'
bl_options = {'REGISTER'}
node_name: <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName', 'attr': 'node_name'}> = <_PropertyDeferred, <built-in function StringProperty>, {'name': 'NodeName', 'attr': 'node_name'}>
def execute(self, context):
809    def execute(self, context):
810        img = compat.get_tex_image(context, self.node_name)
811        if img is None or len(img.pixels) == 0:
812            self.report(type={'ERROR'}, message=f_tip_("イメージの取得に失敗しました。{}", self.node_name))
813            return {'CANCELLED'}
814
815        override = context.copy()
816        override['edit_image'] = img
817
818        filepath = os.path.splitext(bpy.path.abspath(img.filepath))[0] + ".tex"
819        if 'cm3d2_path' in img:
820            path = img['cm3d2_path']
821        else:
822            path = common.get_tex_cm3d2path(img.filepath)
823            img['cm3d2_path'] = path
824
825        # 既存のファイルがあればそこから、バージョンとサイズを取得
826        version = '1000'
827        uv_rects = None
828        if os.path.exists(filepath):
829            tex_data = common.load_cm3d2tex(filepath, skip_data=True)
830            if tex_data:
831                version = str(tex_data[0])
832                uv_rects = tex_data[2]
833        bpy.types.Scene.MyUVRects = uv_rects
834        bpy.ops.image.export_cm3d2_tex(override, filepath=filepath, path=path, version=version)
835
836        self.report(type={'INFO'}, message="同フォルダにtexとして保存しました。" + filepath)
837        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("IMAGE_OT_quick_export_cm3d2_tex")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_legacy=True)
class CNV_OT_set_color_value_old(bpy_types.Operator):
840@compat.BlRegister(only_legacy=True)
841class CNV_OT_set_color_value_old(bpy.types.Operator):
842    bl_idname = 'texture.set_color_value_old'
843    bl_label = "色設定値を設定"
844    bl_description = "色タイプの設定値を設定します"
845    bl_options = {'REGISTER', 'UNDO'}
846
847    color = bpy.props.FloatVectorProperty(name="色", default=(0, 0, 0, 0), subtype='COLOR', size=4)
848
849    @classmethod
850    def poll(cls, context):
851        if hasattr(context, 'texture_slot') and hasattr(context, 'texture'):
852            return True
853        return False
854
855    def execute(self, context):
856        slot = context.texture_slot
857        slot.color = self.color[:3]
858        slot.diffuse_color_factor = self.color[3]
859        common.set_texture_color(slot)
860        return {'FINISHED'}
bl_idname = 'texture.set_color_value_old'
bl_label = '色設定値を設定'
bl_description = '色タイプの設定値を設定します'
bl_options = {'REGISTER', 'UNDO'}
color: <_PropertyDeferred, <built-in function FloatVectorProperty>, {'name': '色', 'default': (0, 0, 0, 0), 'subtype': 'COLOR', 'size': 4}> = <_PropertyDeferred, <built-in function FloatVectorProperty>, {'name': '色', 'default': (0, 0, 0, 0), 'subtype': 'COLOR', 'size': 4}>
@classmethod
def poll(cls, context):
849    @classmethod
850    def poll(cls, context):
851        if hasattr(context, 'texture_slot') and hasattr(context, 'texture'):
852            return True
853        return False
def execute(self, context):
855    def execute(self, context):
856        slot = context.texture_slot
857        slot.color = self.color[:3]
858        slot.diffuse_color_factor = self.color[3]
859        common.set_texture_color(slot)
860        return {'FINISHED'}
Inherited Members
bpy_types.Operator
as_keywords
bl_rna
poll_message_set
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_set_color_value(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
863@compat.BlRegister(only_latest=True)
864class CNV_OT_set_color_value(bpy.types.Operator, common.NodeHandler):
865    bl_idname = 'texture.set_color_value'
866    bl_label = "色設定値を設定"
867    bl_description = "色タイプの設定値を設定します"
868    bl_options = {'REGISTER', 'UNDO'}
869
870    color = bpy.props.FloatVectorProperty(name="色", default=(0, 0, 0, 0), subtype='COLOR', size=4)
871
872    @classmethod
873    def poll(cls, context):
874        mate = context.material
875        return mate and mate.use_nodes
876
877    def execute(self, context):
878        node = self.get_node(context)
879        if node is None:
880            return {'CANCELLED'}
881
882        node.outputs[0].default_value = self.color
883        return {'FINISHED'}
bl_idname = 'texture.set_color_value'
bl_label = '色設定値を設定'
bl_description = '色タイプの設定値を設定します'
bl_options = {'REGISTER', 'UNDO'}
color: <_PropertyDeferred, <built-in function FloatVectorProperty>, {'name': '色', 'default': (0, 0, 0, 0), 'subtype': 'COLOR', 'size': 4, 'attr': 'color'}> = <_PropertyDeferred, <built-in function FloatVectorProperty>, {'name': '色', 'default': (0, 0, 0, 0), 'subtype': 'COLOR', 'size': 4, 'attr': 'color'}>
@classmethod
def poll(cls, context):
872    @classmethod
873    def poll(cls, context):
874        mate = context.material
875        return mate and mate.use_nodes
def execute(self, context):
877    def execute(self, context):
878        node = self.get_node(context)
879        if node is None:
880            return {'CANCELLED'}
881
882        node.outputs[0].default_value = self.color
883        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_set_color_value")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister()
class CNV_OT_set_value(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
886@compat.BlRegister()
887class CNV_OT_set_value(bpy.types.Operator, common.NodeHandler):
888    bl_idname = 'texture.set_value'
889    bl_label = "設定値を設定"
890    bl_description = "floatタイプの設定値を設定します"
891    bl_options = {'REGISTER', 'UNDO'}
892
893    value = bpy.props.FloatProperty(name='value')
894
895    @classmethod
896    def poll(cls, context):
897        if compat.IS_LEGACY:
898            if getattr(context, 'texture_slot') and getattr(context, 'texture'):
899                return True
900        else:
901            mate = context.material
902            return mate and mate.use_nodes
903        return False
904
905    def execute(self, context):
906        if compat.IS_LEGACY:
907            slot = context.texture_slot
908            slot.color = self.color[:3]
909            slot.diffuse_color_factor = self.color[3]
910            common.set_texture_color(slot)
911        else:
912            node = self.get_node(context)
913            if node is None:  # or node.type != 'VALUE':
914                return {'CANCELLED'}
915            node.outputs[0].default_value = self.value
916
917        return {'FINISHED'}
bl_idname = 'texture.set_value'
bl_label = '設定値を設定'
bl_description = 'floatタイプの設定値を設定します'
bl_options = {'REGISTER', 'UNDO'}
value: <_PropertyDeferred, <built-in function FloatProperty>, {'name': 'value', 'attr': 'value'}> = <_PropertyDeferred, <built-in function FloatProperty>, {'name': 'value', 'attr': 'value'}>
@classmethod
def poll(cls, context):
895    @classmethod
896    def poll(cls, context):
897        if compat.IS_LEGACY:
898            if getattr(context, 'texture_slot') and getattr(context, 'texture'):
899                return True
900        else:
901            mate = context.material
902            return mate and mate.use_nodes
903        return False
def execute(self, context):
905    def execute(self, context):
906        if compat.IS_LEGACY:
907            slot = context.texture_slot
908            slot.color = self.color[:3]
909            slot.diffuse_color_factor = self.color[3]
910            common.set_texture_color(slot)
911        else:
912            node = self.get_node(context)
913            if node is None:  # or node.type != 'VALUE':
914                return {'CANCELLED'}
915            node.outputs[0].default_value = self.value
916
917        return {'FINISHED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_set_value")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_texture_reset_offset(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
920@compat.BlRegister(only_latest=True)
921class CNV_OT_texture_reset_offset(bpy.types.Operator, common.NodeHandler):
922    bl_idname = 'texture.reset_offset'
923    bl_label = "テクスチャのオフセットをリセット"
924    bl_description = "テクスチャのオフセットに初期値(0, 0)を設定します"
925    bl_options = {'REGISTER', 'UNDO'}
926
927    def execute(self, context):
928        node = self.get_node(context)
929        if node and node.type == 'TEX_IMAGE':
930            node.texture_mapping.translation[0] = 0
931            node.texture_mapping.translation[1] = 0
932            return {'FINISHED'}
933
934        return {'CANCELLED'}
bl_idname = 'texture.reset_offset'
bl_label = 'テクスチャのオフセットをリセット'
bl_description = 'テクスチャのオフセットに初期値(0, 0)を設定します'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
927    def execute(self, context):
928        node = self.get_node(context)
929        if node and node.type == 'TEX_IMAGE':
930            node.texture_mapping.translation[0] = 0
931            node.texture_mapping.translation[1] = 0
932            return {'FINISHED'}
933
934        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_reset_offset")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_texture_reset_scale(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
937@compat.BlRegister(only_latest=True)
938class CNV_OT_texture_reset_scale(bpy.types.Operator, common.NodeHandler):
939    bl_idname = 'texture.reset_scale'
940    bl_label = "テクスチャのスケールをリセット"
941    bl_description = "テクスチャのスケールに初期値(1, 1)を設定します"
942    bl_options = {'REGISTER', 'UNDO'}
943
944    def execute(self, context):
945        node = self.get_node(context)
946        if node and node.type == 'TEX_IMAGE':
947            node.texture_mapping.scale[0] = 1
948            node.texture_mapping.scale[1] = 1
949            return {'FINISHED'}
950
951        return {'CANCELLED'}
bl_idname = 'texture.reset_scale'
bl_label = 'テクスチャのスケールをリセット'
bl_description = 'テクスチャのスケールに初期値(1, 1)を設定します'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
944    def execute(self, context):
945        node = self.get_node(context)
946        if node and node.type == 'TEX_IMAGE':
947            node.texture_mapping.scale[0] = 1
948            node.texture_mapping.scale[1] = 1
949            return {'FINISHED'}
950
951        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_reset_scale")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_set_cm3d2path(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
954@compat.BlRegister(only_latest=True)
955class CNV_OT_set_cm3d2path(bpy.types.Operator, common.NodeHandler):
956    bl_idname = 'texture.set_cm3d2path'
957    bl_label = "CM3D2パスを設定"
958    bl_description = "texタイプのCM3D2パスを自動設定します"
959    bl_options = {'REGISTER', 'UNDO'}
960
961    def execute(self, context):
962        node = self.get_node(context)
963        if node and node.type == 'TEX_IMAGE':
964            img = node.image
965            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
966            return {'FINISHED'}
967        return {'CANCELLED'}
bl_idname = 'texture.set_cm3d2path'
bl_label = 'CM3D2パスを設定'
bl_description = 'texタイプのCM3D2パスを自動設定します'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
961    def execute(self, context):
962        node = self.get_node(context)
963        if node and node.type == 'TEX_IMAGE':
964            img = node.image
965            img['cm3d2_path'] = common.get_tex_cm3d2path(img.filepath)
966            return {'FINISHED'}
967        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_set_cm3d2path")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class CNV_OT_setup_image_name(bpy_types.Operator, CM3D2 Converter.common.NodeHandler):
970@compat.BlRegister(only_latest=True)
971class CNV_OT_setup_image_name(bpy.types.Operator, common.NodeHandler):
972    bl_idname = 'texture.setup_image_name'
973    bl_label = "イメージ名から拡張子を除外"
974    bl_description = "texタイプのイメージ名から拡張子を除外します"
975    bl_options = {'REGISTER', 'UNDO'}
976
977    def execute(self, context):
978        node = self.get_node(context)
979        if node and node.type == 'TEX_IMAGE':
980            img = node.image
981            common.setup_image_name(img)
982            return {'FINISHED'}
983        return {'CANCELLED'}
bl_idname = 'texture.setup_image_name'
bl_label = 'イメージ名から拡張子を除外'
bl_description = 'texタイプのイメージ名から拡張子を除外します'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
977    def execute(self, context):
978        node = self.get_node(context)
979        if node and node.type == 'TEX_IMAGE':
980            img = node.image
981            common.setup_image_name(img)
982            return {'FINISHED'}
983        return {'CANCELLED'}
bl_rna = <bpy_struct, Struct("TEXTURE_OT_setup_image_name")>
Inherited Members
bpy_types.Operator
as_keywords
poll_message_set
CM3D2 Converter.common.NodeHandler
node_name
get_node
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
class ToonSelectMenuBase:
987class ToonSelectMenuBase():
988    bl_label = "toon tex 選択"
989
990    def draw(self, context):
991        layout = self.layout
992        cmd = 'texture.set_default_toon_textures'
993        for toon_tex in cm3d2_data.TOON_TEXES:
994            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
995            opr = layout.operator(cmd, text=toon_tex, icon=icon)
996            opr.node_name, opr.tex_name = self.node_name(), toon_tex
997
998    def node_name(self):
999        pass
bl_label = 'toon tex 選択'
def draw(self, context):
990    def draw(self, context):
991        layout = self.layout
992        cmd = 'texture.set_default_toon_textures'
993        for toon_tex in cm3d2_data.TOON_TEXES:
994            icon = 'LAYER_ACTIVE' if 'Shadow' not in toon_tex else 'LAYER_USED'
995            opr = layout.operator(cmd, text=toon_tex, icon=icon)
996            opr.node_name, opr.tex_name = self.node_name(), toon_tex
def node_name(self):
998    def node_name(self):
999        pass
@compat.BlRegister(only_latest=True)
class TEXTURE_MT_texture_ToonRamp(bpy_types.Menu, ToonSelectMenuBase):
1002@compat.BlRegister(only_latest=True)
1003class TEXTURE_MT_texture_ToonRamp(bpy.types.Menu, ToonSelectMenuBase):
1004    bl_idname = 'TEXTURE_MT_texture_ToonRamp'
1005
1006    def node_name(self):
1007        return '_ToonRamp'
bl_idname = 'TEXTURE_MT_texture_ToonRamp'
def node_name(self):
1006    def node_name(self):
1007        return '_ToonRamp'
bl_rna = <bpy_struct, Struct("TEXTURE_MT_texture_ToonRamp")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
ToonSelectMenuBase
bl_label
draw
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class TEXTURE_MT_texture_ShadowRateToon(bpy_types.Menu, ToonSelectMenuBase):
1010@compat.BlRegister(only_latest=True)
1011class TEXTURE_MT_texture_ShadowRateToon(bpy.types.Menu, ToonSelectMenuBase):
1012    bl_idname = 'TEXTURE_MT_texture_ShadowRateToon'
1013
1014    def node_name(self):
1015        return '_ShadowRateToon'
bl_idname = 'TEXTURE_MT_texture_ShadowRateToon'
def node_name(self):
1014    def node_name(self):
1015        return '_ShadowRateToon'
bl_rna = <bpy_struct, Struct("TEXTURE_MT_texture_ShadowRateToon")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
ToonSelectMenuBase
bl_label
draw
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data
@compat.BlRegister(only_latest=True)
class TEXTURE_MT_texture_OutlineToonRamp(bpy_types.Menu, ToonSelectMenuBase):
1018@compat.BlRegister(only_latest=True)
1019class TEXTURE_MT_texture_OutlineToonRamp(bpy.types.Menu, ToonSelectMenuBase):
1020    bl_idname = 'TEXTURE_MT_texture_OutlineToonRamp'
1021
1022    def node_name(self):
1023        return '_OutlineToonRamp'
bl_idname = 'TEXTURE_MT_texture_OutlineToonRamp'
def node_name(self):
1022    def node_name(self):
1023        return '_OutlineToonRamp'
bl_rna = <bpy_struct, Struct("TEXTURE_MT_texture_OutlineToonRamp")>
Inherited Members
bpy_types.Menu
path_menu
draw_preset
draw_collapsible
bpy_types._GenericUI
is_extended
append
prepend
remove
ToonSelectMenuBase
bl_label
draw
builtins.bpy_struct
keys
values
items
get
pop
as_pointer
keyframe_insert
keyframe_delete
driver_add
driver_remove
is_property_set
property_unset
is_property_hidden
is_property_readonly
is_property_overridable_library
property_overridable_library_set
path_resolve
path_from_id
type_recast
bl_rna_get_subclass_py
bl_rna_get_subclass
id_properties_ensure
id_properties_clear
id_properties_ui
id_data