Browse Source

Add Plasma layer options panel to Texture context.

- Add an opacity value for exported layer.
- Add a conversion button in the toolbar for old PyPRP Ages
which used the diffuse color factor as the opacity value.
pull/9/head
Joseph Davies 10 years ago
parent
commit
a208ee21d3
  1. 5
      korman/exporter/material.py
  2. 19
      korman/operators/op_toolbox.py
  3. 2
      korman/properties/__init__.py
  4. 27
      korman/properties/prop_texture.py
  5. 1
      korman/ui/__init__.py
  6. 32
      korman/ui/ui_texture.py
  7. 3
      korman/ui/ui_toolbox.py

5
korman/exporter/material.py

@ -255,8 +255,11 @@ class MaterialConverter:
elif slot.blend_type == "MULTIPLY":
state.blendFlags |= hsGMatState.kBlendMult
# Export the specific texture type
# Apply custom layer properties
texture = slot.texture
layer.opacity = texture.plasma_layer.opacity / 100
# Export the specific texture type
self._tex_exporters[texture.type](bo, hsgmat, layer, slot)
hsgmat.addLayer(layer.key)
return num_exported

19
korman/operators/op_toolbox.py

@ -48,3 +48,22 @@ class PlasmaEnableTexturesOperator(ToolboxOperator, bpy.types.Operator):
continue
slot.use = True
return {"FINISHED"}
class PlasmaConvertLayerOpacitiesOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "texture.plasma_convert_layer_opacities"
bl_label = "Layer Opacities"
bl_description = "Convert layer opacities from diffuse color factor"
def execute(self, context):
for mesh in bpy.data.meshes:
for material in mesh.materials:
if material is None:
continue
for slot in material.texture_slots:
if slot is None:
continue
slot.texture.plasma_layer.opacity = slot.diffuse_color_factor * 100
slot.diffuse_color_factor = 1.0
return {"FINISHED"}

2
korman/properties/__init__.py

@ -17,11 +17,13 @@ import bpy
from . import modifiers
from .prop_object import *
from .prop_texture import *
from .prop_world import *
def register():
bpy.types.Object.plasma_net = bpy.props.PointerProperty(type=PlasmaNet)
bpy.types.Object.plasma_object = bpy.props.PointerProperty(type=PlasmaObject)
bpy.types.Texture.plasma_layer = bpy.props.PointerProperty(type=PlasmaLayer)
bpy.types.World.plasma_age = bpy.props.PointerProperty(type=PlasmaAge)
bpy.types.World.plasma_fni = bpy.props.PointerProperty(type=PlasmaFni)

27
korman/properties/prop_texture.py

@ -0,0 +1,27 @@
# 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 PlasmaLayer(bpy.types.PropertyGroup):
bl_idname = "texture.plasma_layer"
opacity = FloatProperty(name="Layer Opacity",
description="Opacity of the texture",
default=100,
min=0,
max=100,
subtype="PERCENTAGE")

1
korman/ui/__init__.py

@ -15,5 +15,6 @@
from .ui_modifiers import *
from .ui_object import *
from .ui_texture import *
from .ui_toolbox import *
from .ui_world import *

32
korman/ui/ui_texture.py

@ -0,0 +1,32 @@
# 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
class TextureButtonsPanel:
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "texture"
@classmethod
def poll(cls, context):
return context.texture and context.scene.render.engine == "PLASMA_GAME"
class PlasmaLayerPanel(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Plasma Layer Options"
def draw(self, context):
layout = self.layout
layout.prop(context.texture.plasma_layer, "opacity")

3
korman/ui/ui_toolbox.py

@ -36,3 +36,6 @@ class PlasmaToolboxPanel(ToolboxPanel, bpy.types.Panel):
col.label("Enable All:")
col.operator("object.plasma_enable_all_objects", icon="OBJECT_DATA")
col.operator("texture.plasma_enable_all_textures", icon="TEXTURE")
col.label("Convert All:")
col.operator("texture.plasma_convert_layer_opacities", icon="IMAGE_RGB_ALPHA")

Loading…
Cancel
Save