Browse Source

Implement environment map Vis Regions

pull/24/head
Adam Johnson 9 years ago
parent
commit
a36c922dce
  1. 12
      korman/exporter/material.py
  2. 1
      korman/operators/__init__.py
  3. 61
      korman/operators/op_texture.py
  4. 10
      korman/properties/prop_texture.py
  5. 37
      korman/ui/ui_texture.py

12
korman/exporter/material.py

@ -347,6 +347,18 @@ class MaterialConverter:
pl_env.color = utils.color(texture.plasma_layer.envmap_color)
pl_env.fogStart = pl_fog.fog_start
# EffVisSets
# Whoever wrote this PyHSPlasma binding didn't follow the convention. Sigh.
visregions = []
for region in texture.plasma_layer.vis_regions:
rgn = bpy.data.objects.get(region.region_name, None)
if rgn is None:
raise ExportError("'{}': VisControl '{}' not found".format(texture.name, region.region_name))
if not rgn.plasma_modifiers.visregion.enabled:
raise ExportError("'{}': '{}' is not a VisControl".format(texture.name, region.region_name))
visregions.append(self._mgr.find_create_key(plVisRegion, bl=rgn))
pl_env.visRegions = visregions
if isinstance(pl_env, plDynamicCamMap):
faces = (pl_env,)

1
korman/operators/__init__.py

@ -17,6 +17,7 @@ from . import op_export as exporter
from . import op_lightmap as lightmap
from . import op_modifier as modifier
from . import op_nodes as nodes
from . import op_texture as texture
from . import op_toolbox as toolbox
from . import op_world as world

61
korman/operators/op_texture.py

@ -0,0 +1,61 @@
# 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 <http://www.gnu.org/licenses/>.
import bpy
from bpy.props import *
class TextureOperator:
@classmethod
def poll(cls, context):
return context.scene.render.engine == "PLASMA_GAME" and context.texture
class TextureCollectionAddOperator(TextureOperator, bpy.types.Operator):
bl_idname = "texture.plasma_collection_add"
bl_label = "Add Item"
bl_description = "Adds an item to the collection"
group = StringProperty(name="Modifier", description="Attribute name of the PropertyGroup")
collection = StringProperty(name="Collection", description="Attribute name of the collection property")
name_prefix = StringProperty(name="Name Prefix", description="Prefix for autogenerated item names", default="Item")
name_prop = StringProperty(name="Name Property", description="Attribute name of the item name property")
def execute(self, context):
mod = getattr(context.texture, self.group)
collection = getattr(mod, self.collection)
idx = len(collection)
collection.add()
if self.name_prop:
setattr(collection[idx], self.name_prop, "{} {}".format(self.name_prefix, idx+1))
return {"FINISHED"}
class TextureCollectionRemoveOperator(TextureOperator, bpy.types.Operator):
bl_idname = "texture.plasma_collection_remove"
bl_label = "Remove Item"
bl_description = "Removes an item from the collection"
group = StringProperty(name="Modifier", description="Attribute name of the PropertyGroup")
collection = StringProperty(name="Collection", description="Attribute name of the collection property")
index = IntProperty(name="Index", description="Item index to remove")
def execute(self, context):
mod = getattr(context.texture, self.group)
collection = getattr(mod, self.collection)
if len(collection) > self.index:
collection.remove(self.index)
return {"FINISHED"}
else:
return {"CANCELLED"}

10
korman/properties/prop_texture.py

@ -16,6 +16,12 @@
import bpy
from bpy.props import *
class EnvMapVisRegion(bpy.types.PropertyGroup):
enabled = BoolProperty(default=True)
region_name = StringProperty(name="Control",
description="Object defining a Plasma Visibility Control")
class PlasmaLayer(bpy.types.PropertyGroup):
bl_idname = "texture.plasma_layer"
@ -33,6 +39,10 @@ class PlasmaLayer(bpy.types.PropertyGroup):
default=(1.0, 1.0, 1.0),
subtype="COLOR")
vis_regions = CollectionProperty(name="Visibility Regions",
type=EnvMapVisRegion)
active_region_index = IntProperty(options={"HIDDEN"})
anim_auto_start = BoolProperty(name="Auto Start",
description="Automatically start layer animation",
default=True)

37
korman/ui/ui_texture.py

@ -24,6 +24,40 @@ class TextureButtonsPanel:
def poll(cls, context):
return context.texture and context.scene.render.engine == "PLASMA_GAME"
class PlasmaEnvMapPanel(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Plasma Environment Map"
@classmethod
def poll(cls, context):
if super().poll(context):
return context.texture.type == "ENVIRONMENT_MAP"
return False
def draw(self, context):
layer_props = context.texture.plasma_layer
layout = self.layout
layout.label("Visibility Sets:")
row = layout.row()
row.template_list("VisRegionListUI", "vis_regions", layer_props, "vis_regions", layer_props, "active_region_index",
rows=2, maxrows=3)
col = row.column(align=True)
op = col.operator("texture.plasma_collection_add", icon="ZOOMIN", text="")
op.group = "plasma_layer"
op.collection = "vis_regions"
op = col.operator("texture.plasma_collection_remove", icon="ZOOMOUT", text="")
op.group = "plasma_layer"
op.collection = "vis_regions"
op.index = layer_props.active_region_index
rgns = layer_props.vis_regions
if layer_props.vis_regions:
layout.prop_search(rgns[layer_props.active_region_index], "region_name", bpy.data, "objects")
layout.separator()
layout.prop(layer_props, "envmap_color")
class PlasmaLayerPanel(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Plasma Layer Options"
@ -43,6 +77,3 @@ class PlasmaLayerPanel(TextureButtonsPanel, bpy.types.Panel):
col = split.column()
col.label("General:")
col.prop(layer_props, "opacity", text="Opacity")
col = col.column()
col.enabled = texture.type == "ENVIRONMENT_MAP"
col.prop(layer_props, "envmap_color")

Loading…
Cancel
Save