adds color source
This commit is contained in:
parent
c0ab4bb7ad
commit
6fbf07b96c
10 changed files with 78 additions and 20 deletions
|
|
@ -5,4 +5,3 @@ if __name__ == "__main__":
|
||||||
currentVersion = versioning.get_version()
|
currentVersion = versioning.get_version()
|
||||||
nextVersion = currentVersion.bump_minor()
|
nextVersion = currentVersion.bump_minor()
|
||||||
versioning.save_version(nextVersion)
|
versioning.save_version(nextVersion)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ classes = (
|
||||||
BakeToIDMapPanel,
|
BakeToIDMapPanel,
|
||||||
BakeToIDInfoPanel,
|
BakeToIDInfoPanel,
|
||||||
BakeToIDOptionsPanel,
|
BakeToIDOptionsPanel,
|
||||||
BakeToIDAdvancedMenu,
|
|
||||||
BakeToIDProperties,
|
BakeToIDProperties,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import math
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
from ..types.colors import get_color
|
||||||
from .. types.sources import get_source
|
from .. types.sources import get_source
|
||||||
from .. types.targets import get_target
|
from .. types.targets import get_target
|
||||||
|
|
||||||
|
|
@ -33,21 +34,8 @@ class BakeToIDMapOperator(bpy.types.Operator):
|
||||||
if len(targets) < 1:
|
if len(targets) < 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
totalTargets = len(targets)
|
color = get_color(props.colors)
|
||||||
colors = []
|
colors = color.get_colors(props)
|
||||||
|
|
||||||
total_hues = props.adv_total_hues
|
|
||||||
total_satuations = props.adv_total_satuations
|
|
||||||
total_brightnesses = props.adv_total_brightnesses
|
|
||||||
|
|
||||||
satuations_break_point = math.pow(total_brightnesses, total_hues)
|
|
||||||
|
|
||||||
for i in range(totalTargets):
|
|
||||||
h = (i / total_hues) % 1
|
|
||||||
l = (math.ceil(i / total_hues) % total_brightnesses) / total_brightnesses
|
|
||||||
s = math.ceil(i / satuations_break_point) / total_satuations
|
|
||||||
|
|
||||||
colors.append(colorsys.hls_to_rgb(h, l, s))
|
|
||||||
|
|
||||||
target = get_target(props.target)
|
target = get_target(props.target)
|
||||||
self.paint_targets(props, target, targets, colors)
|
self.paint_targets(props, target, targets, colors)
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@ class BakeToIDAdvancedMenu(bpy.types.Panel):
|
||||||
layout.prop(props, "adv_total_satuations")
|
layout.prop(props, "adv_total_satuations")
|
||||||
layout.prop(props, "adv_total_brightnesses")
|
layout.prop(props, "adv_total_brightnesses")
|
||||||
layout.label(text="Max ID-count: " + str(
|
layout.label(text="Max ID-count: " + str(
|
||||||
math.pow(math.pow(props.adv_total_hues, props.adv_total_satuations), props.adv_total_brightnesses)))
|
))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
from ..types.colors import get_color
|
||||||
from .. types.sources import get_source
|
from .. types.sources import get_source
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -20,7 +21,6 @@ class BakeToIDInfoPanel(bpy.types.Panel):
|
||||||
|
|
||||||
if props.selection_mode != 'SINGLE':
|
if props.selection_mode != 'SINGLE':
|
||||||
layout.label(text="Selected Object-Count: " + str(len(context.selected_objects)))
|
layout.label(text="Selected Object-Count: " + str(len(context.selected_objects)))
|
||||||
layout.separator()
|
|
||||||
|
|
||||||
if props.selection_mode == 'SINGLE':
|
if props.selection_mode == 'SINGLE':
|
||||||
layout.label(text="ID-Total: " + str(source.estimate_ids([context.active_object])))
|
layout.label(text="ID-Total: " + str(source.estimate_ids([context.active_object])))
|
||||||
|
|
@ -43,3 +43,7 @@ class BakeToIDInfoPanel(bpy.types.Panel):
|
||||||
|
|
||||||
if props.selection_mode == 'MULTIPLE_COMBINED':
|
if props.selection_mode == 'MULTIPLE_COMBINED':
|
||||||
layout.label(text="ID-Total: " + str(source.estimate_ids(context.selected_objects)))
|
layout.label(text="ID-Total: " + str(source.estimate_ids(context.selected_objects)))
|
||||||
|
|
||||||
|
color = get_color(props.colors)
|
||||||
|
|
||||||
|
layout.label(text="Colors available: " + str(color.get_count(props)))
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,7 @@ class BakeToIDOptionsPanel(bpy.types.Panel):
|
||||||
target_settings_box = layout.box()
|
target_settings_box = layout.box()
|
||||||
for setting in target.connected_properties:
|
for setting in target.connected_properties:
|
||||||
target_settings_box.prop(props, setting)
|
target_settings_box.prop(props, setting)
|
||||||
|
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
|
layout.prop(props, "colors")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from bpy.types import (PropertyGroup)
|
from bpy.types import (PropertyGroup)
|
||||||
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty)
|
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty)
|
||||||
|
|
||||||
|
from src.types.colors import get_color_enum
|
||||||
from src.types.sources import get_source_enum
|
from src.types.sources import get_source_enum
|
||||||
from src.types.targets import get_targets_enum
|
from src.types.targets import get_targets_enum
|
||||||
|
|
||||||
|
|
@ -31,6 +32,13 @@ class BakeToIDProperties(PropertyGroup):
|
||||||
default=get_targets_enum()[0][0]
|
default=get_targets_enum()[0][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
colors: EnumProperty(
|
||||||
|
items=get_color_enum(),
|
||||||
|
name="Color Source",
|
||||||
|
description="From where to take the colors",
|
||||||
|
default=get_color_enum()[0][0]
|
||||||
|
)
|
||||||
|
|
||||||
source_materials_remove_all: BoolProperty(
|
source_materials_remove_all: BoolProperty(
|
||||||
name="Remove all source materials",
|
name="Remove all source materials",
|
||||||
default=False,
|
default=False,
|
||||||
|
|
|
||||||
24
src/types/colors/__init__.py
Normal file
24
src/types/colors/__init__.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
from . import generated
|
||||||
|
|
||||||
|
_colors = [
|
||||||
|
generated
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_color(id):
|
||||||
|
for color in _colors:
|
||||||
|
if color.color_id == id:
|
||||||
|
return color
|
||||||
|
|
||||||
|
raise Exception("Source not found: " + id)
|
||||||
|
|
||||||
|
|
||||||
|
def get_color_enum():
|
||||||
|
enum_list = []
|
||||||
|
i = 0
|
||||||
|
for color in _colors:
|
||||||
|
enum_list.append((color.color_id, color.name, color.description, i))
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return enum_list
|
||||||
|
|
||||||
32
src/types/colors/generated.py
Normal file
32
src/types/colors/generated.py
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
import colorsys
|
||||||
|
import math
|
||||||
|
|
||||||
|
color_id = 'GENERATED'
|
||||||
|
name = 'Generated'
|
||||||
|
description = 'The colors get generated on-the-fly'
|
||||||
|
|
||||||
|
MAX_BRIGHTNESS_STEPS = 8
|
||||||
|
MAX_SATURATION_STEPS = 8
|
||||||
|
MAX_HUES_STEPS = 8
|
||||||
|
|
||||||
|
def get_colors(props):
|
||||||
|
return gen_colors()
|
||||||
|
|
||||||
|
|
||||||
|
def get_count(props):
|
||||||
|
return len(gen_colors())
|
||||||
|
|
||||||
|
|
||||||
|
def gen_colors():
|
||||||
|
colors = []
|
||||||
|
for brightnessStep in range(0, MAX_BRIGHTNESS_STEPS):
|
||||||
|
v = 1 - (brightnessStep / MAX_BRIGHTNESS_STEPS)
|
||||||
|
for satuationStep in range(0, MAX_SATURATION_STEPS):
|
||||||
|
s = 1 - (satuationStep / MAX_SATURATION_STEPS)
|
||||||
|
for hueStep in range(0, MAX_HUES_STEPS):
|
||||||
|
h = hueStep / MAX_HUES_STEPS
|
||||||
|
|
||||||
|
color = colorsys.hsv_to_rgb(h, s, v)
|
||||||
|
colors.append(color)
|
||||||
|
|
||||||
|
return colors
|
||||||
Loading…
Add table
Add a link
Reference in a new issue