From 27e537140074700ebaee518fd0073c15e0b8e9e1 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 25 Sep 2020 19:04:52 -0400 Subject: [PATCH] Add Runtime Color Setting Adds a FloatVectorProperty to set the Runtime color. --- korman/exporter/material.py | 4 ++- korman/properties/__init__.py | 2 ++ korman/properties/prop_material.py | 29 +++++++++++++++++++++ korman/ui/__init__.py | 1 + korman/ui/ui_material.py | 41 ++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 korman/properties/prop_material.py create mode 100644 korman/ui/ui_material.py diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 4b973e4..54c0c8e 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -1207,7 +1207,7 @@ class MaterialConverter: # Colors layer.ambient = utils.color(bpy.context.scene.world.ambient_color) layer.preshade = utils.color(bm.diffuse_color) - layer.runtime = utils.color(bm.diffuse_color) + layer.runtime = utils.color(bm.plasma_mat.runtime_color) layer.specular = utils.color(bm.specular_color) layer.specularPower = min(100.0, float(bm.specular_hardness)) @@ -1221,6 +1221,8 @@ class MaterialConverter: bm.diffuse_color.g * emit_scale, bm.diffuse_color.b * emit_scale, 1.0) + # fix runtime color for emit + layer.runtime = hsColorRGBA(1.0, 1.0, 1.0, 1.0) def _requires_single_user(self, bo, bm): if bo.data.show_double_sided: diff --git a/korman/properties/__init__.py b/korman/properties/__init__.py index fa3b5e4..9059a2f 100644 --- a/korman/properties/__init__.py +++ b/korman/properties/__init__.py @@ -18,6 +18,7 @@ import bpy from .prop_camera import * from .prop_image import * from .prop_lamp import * +from .prop_material import * from . import modifiers from .prop_object import * from .prop_scene import * @@ -31,6 +32,7 @@ def register(): bpy.types.Camera.plasma_camera = bpy.props.PointerProperty(type=PlasmaCamera) bpy.types.Image.plasma_image = bpy.props.PointerProperty(type=PlasmaImage) bpy.types.Lamp.plasma_lamp = bpy.props.PointerProperty(type=PlasmaLamp) + bpy.types.Material.plasma_mat = bpy.props.PointerProperty(type=PlasmaMaterial) bpy.types.Object.plasma_net = bpy.props.PointerProperty(type=PlasmaNet) bpy.types.Object.plasma_object = bpy.props.PointerProperty(type=PlasmaObject) bpy.types.Scene.plasma_scene = bpy.props.PointerProperty(type=PlasmaScene) diff --git a/korman/properties/prop_material.py b/korman/properties/prop_material.py new file mode 100644 index 0000000..d946fea --- /dev/null +++ b/korman/properties/prop_material.py @@ -0,0 +1,29 @@ +# This file is part of Korman. +# +# Korman is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Korman is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Korman. If not, see . + +import bpy +from bpy.props import * + +from .. import idprops + +class PlasmaMaterial(bpy.types.PropertyGroup): + bl_idname = "material.plasma_mat" + + runtime_color = FloatVectorProperty(name="Runtime Color:", + description="Sets the Runtime Color for Animated and Kickable Objects", + min=0.0, + max=1.0, + default=(0.0, 0.0, 0.0), + subtype="COLOR") diff --git a/korman/ui/__init__.py b/korman/ui/__init__.py index 5f0ddca..8ecc5ba 100644 --- a/korman/ui/__init__.py +++ b/korman/ui/__init__.py @@ -17,6 +17,7 @@ from .ui_camera import * from .ui_image import * from .ui_lamp import * from .ui_list import * +from .ui_material import * from .ui_menus import * from .ui_modifiers import * from .ui_object import * diff --git a/korman/ui/ui_material.py b/korman/ui/ui_material.py new file mode 100644 index 0000000..f0ccfcd --- /dev/null +++ b/korman/ui/ui_material.py @@ -0,0 +1,41 @@ +# This file is part of Korman. +# +# Korman is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Korman is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Korman. If not, see . + +import bpy + +from . import ui_list + +class MaterialButtonsPanel: + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material and context.scene.render.engine == "PLASMA_GAME" + +class RuntimeColorPanel(MaterialButtonsPanel, bpy.types.Panel): + bl_label = "Runtime" + + def draw(self, context): + material, slot = context.material, getattr(context, "material_slot", None) + mat_props = material.plasma_mat + layout = self.layout + + split = layout.split() + col = split.column() + col.prop(mat_props, "runtime_color") + + col = split.column() \ No newline at end of file