Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quality modifier to provide load masks #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions korman/properties/modifiers/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,3 +969,59 @@ def export(self, exporter, bo, so):
if not region.control_region:
raise ExportError("{}: Not all Visibility Controls are set up properly in Visibility Set".format(bo.name))
addRegion(exporter.mgr.find_create_key(plVisRegion, bl=region.control_region))

class PlasmaQualityLevels(bpy.types.PropertyGroup):
low = BoolProperty(name="Low Quality",
description="Object renders at low quality graphics level",
default=False,
options=set())

mid = BoolProperty(name="Medium Quality",
description="Object renders at medium quality graphics level",
default=False,
options=set())

high = BoolProperty(name="High Quality",
description="Object renders at high quality graphics level",
default=False,
options=set())

ultra = BoolProperty(name="Ultra Quality",
description="Object renders at ultra quality graphics level",
default=False,
options=set())

@property
def mask_value(self):
q = 0

if self.low:
q |= (1 << 0)

if self.mid:
q |= (1 << 1)

if self.high:
q |= (1 << 2)

if self.ultra:
q |= (1 << 3)

return q


class PlasmaQualityMod(PlasmaModifierProperties):
pl_id = "qualitymod"

bl_category = "Render"
bl_label = "Quality Levels"
bl_description = "Defines the quality levels at which this object is visible"

cap_minimal = PointerProperty(type=PlasmaQualityLevels)
cap_shaders = PointerProperty(type=PlasmaQualityLevels)

def export(self, exporter, bo, so):
low = 0xf0 | self.cap_minimal.mask_value
high = 0xf0 | self.cap_shaders.mask_value

so.key.mask = (high << 8) | (low)
18 changes: 18 additions & 0 deletions korman/ui/modifiers/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,21 @@ def visregion(modifier, layout, context):

# Other settings
layout.prop(modifier, "replace_normal")

def qualitymod(modifier, layout, context):
split = layout.split()
col = split.column()
col.label("Without shader support:")
box = col.box()
box.prop(modifier.cap_minimal, "low")
box.prop(modifier.cap_minimal, "mid")
box.prop(modifier.cap_minimal, "high")
box.prop(modifier.cap_minimal, "ultra")

col = split.column()
col.label("With shader support:")
box = col.box()
box.prop(modifier.cap_shaders, "low")
box.prop(modifier.cap_shaders, "mid")
box.prop(modifier.cap_shaders, "high")
box.prop(modifier.cap_shaders, "ultra")