Browse Source

Implement Layer SDL Animations

pull/43/head
Adam Johnson 8 years ago
parent
commit
df056603ec
  1. 18
      korman/exporter/material.py
  2. 3
      korman/nodes/node_messages.py
  3. 3
      korman/properties/prop_texture.py
  4. 26
      korman/ui/ui_texture.py

18
korman/exporter/material.py

@ -282,7 +282,7 @@ class MaterialConverter:
fcurves = [] fcurves = []
mat_action = harvest_fcurves(bm, fcurves, "texture_slots[{}]".format(idx)) mat_action = harvest_fcurves(bm, fcurves, "texture_slots[{}]".format(idx))
tex_action = harvest_fcurves(bm.texture_slots[idx].texture, fcurves) tex_action = harvest_fcurves(tex_slot.texture, fcurves)
if not fcurves: if not fcurves:
return base_layer return base_layer
@ -294,7 +294,7 @@ class MaterialConverter:
if ctrl is not None: if ctrl is not None:
if layer_animation is None: if layer_animation is None:
name = "{}_LayerAnim".format(base_layer.key.name) name = "{}_LayerAnim".format(base_layer.key.name)
layer_animation = self._mgr.find_create_object(plLayerAnimation, bl=bo, name=name) layer_animation = self.get_texture_animation_key(bo, bm, tex_slot=tex_slot).object
setattr(layer_animation, attr, ctrl) setattr(layer_animation, attr, ctrl)
# Alrighty, if we exported any controllers, layer_animation is a plLayerAnimation. We need to do # Alrighty, if we exported any controllers, layer_animation is a plLayerAnimation. We need to do
@ -318,6 +318,8 @@ class MaterialConverter:
atc.flags |= plAnimTimeConvert.kLoop atc.flags |= plAnimTimeConvert.kLoop
atc.loopBegin = atc.begin atc.loopBegin = atc.begin
atc.loopEnd = atc.end atc.loopEnd = atc.end
if layer_props.anim_sdl_var:
layer_animation.varName = layer_props.anim_sdl_var
return layer_animation return layer_animation
# Well, we had some FCurves but they were garbage... Too bad. # Well, we had some FCurves but they were garbage... Too bad.
@ -598,13 +600,21 @@ class MaterialConverter:
def get_materials(self, bo): def get_materials(self, bo):
return self._obj2mat.get(bo, []) return self._obj2mat.get(bo, [])
def get_texture_animation_key(self, bo, bm, tex_name): def get_texture_animation_key(self, bo, bm, tex_name=None, tex_slot=None):
"""Finds or creates the appropriate key for sending messages to an animated Texture""" """Finds or creates the appropriate key for sending messages to an animated Texture"""
assert tex_name or tex_slot
if tex_slot is None:
tex_slot = bm.texture_slots.get(tex_name, None) tex_slot = bm.texture_slots.get(tex_name, None)
if tex_slot is None: if tex_slot is None:
raise ExportError("Material '{}' does not contain Texture '{}'".format(bm.name, tex_name)) raise ExportError("Material '{}' does not contain Texture '{}'".format(bm.name, tex_name))
if tex_name is None:
tex_name = tex_slot.name
name = "{}_{}_LayerAnim".format(bm.name, tex_name) name = "{}_{}_LayerAnim".format(bm.name, tex_name)
return self._mgr.find_create_key(plLayerAnimation, bl=bo, name=name) layer = tex_slot.texture.plasma_layer
pClass = plLayerSDLAnimation if layer.anim_sdl_var else plLayerAnimation
return self._mgr.find_create_key(pClass, bl=bo, name=name)
@property @property
def _mgr(self): def _mgr(self):

3
korman/nodes/node_messages.py

@ -189,8 +189,11 @@ class PlasmaAnimCmdMsgNode(PlasmaMessageNode, bpy.types.Node):
if material is None: if material is None:
self.raise_error("invalid material: '{}'".format(self.material_name)) self.raise_error("invalid material: '{}'".format(self.material_name))
target = exporter.mesh.material.get_texture_animation_key(obj, material, self.texture_name) target = exporter.mesh.material.get_texture_animation_key(obj, material, self.texture_name)
if target is None: if target is None:
raise RuntimeError() raise RuntimeError()
if isinstance(target.object, plLayerSDLAnimation):
self.raise_error("Cannot control an SDL Animation")
msg.addReceiver(target) msg.addReceiver(target)
# Check the enum properties to see what commands we need to add # Check the enum properties to see what commands we need to add

3
korman/properties/prop_texture.py

@ -50,6 +50,9 @@ class PlasmaLayer(bpy.types.PropertyGroup):
anim_loop = BoolProperty(name="Loop", anim_loop = BoolProperty(name="Loop",
description="Loop layer animation", description="Loop layer animation",
default=True) default=True)
anim_sdl_var = StringProperty(name="SDL Variable",
description="Name of the SDL Variable to use for this animation",
options=set())
is_detail_map = BoolProperty(name="Detail Fade", is_detail_map = BoolProperty(name="Detail Fade",
description="Texture fades out as distance from the camera increases", description="Texture fades out as distance from the camera increases",

26
korman/ui/ui_texture.py

@ -69,15 +69,26 @@ class PlasmaLayerPanel(TextureButtonsPanel, bpy.types.Panel):
split = layout.split() split = layout.split()
col = split.column() col = split.column()
col.label("Animation:") col.label("Animation:")
col.enabled = self._has_animation_data(context) and not slot.use_stencil col.active = self._has_animation_data(context) and not slot.use_stencil
col.prop(layer_props, "anim_auto_start") col.prop(layer_props, "anim_auto_start")
col.prop(layer_props, "anim_loop") col.prop(layer_props, "anim_loop")
col.separator()
col.label("SDL Animation:")
col.prop(layer_props, "anim_sdl_var", text="")
col = split.column() col = split.column()
col.label("Miscellaneous:") col.label("Miscellaneous:")
col.active = not slot.use_stencil col.active = not slot.use_stencil
col.prop(layer_props, "opacity", text="Opacity") col.prop(layer_props, "opacity", text="Opacity")
layout.separator() col.separator()
col = col.column()
col.enabled = True
col.label("Z Depth:")
col.prop(layer_props, "alpha_halo")
col.prop(layer_props, "skip_depth_write")
col.prop(layer_props, "skip_depth_test")
col.prop(layer_props, "z_bias")
split = layout.split() split = layout.split()
col = split.column() col = split.column()
@ -87,17 +98,12 @@ class PlasmaLayerPanel(TextureButtonsPanel, bpy.types.Panel):
col.active = texture.use_mipmap and layer_props.is_detail_map col.active = texture.use_mipmap and layer_props.is_detail_map
col.prop(layer_props, "detail_fade_start") col.prop(layer_props, "detail_fade_start")
col.prop(layer_props, "detail_fade_stop") col.prop(layer_props, "detail_fade_stop")
col.separator() col = split.column(align=True)
col.active = texture.use_mipmap and layer_props.is_detail_map
col.label(text="")
col.prop(layer_props, "detail_opacity_start") col.prop(layer_props, "detail_opacity_start")
col.prop(layer_props, "detail_opacity_stop") col.prop(layer_props, "detail_opacity_stop")
col = split.column()
col.label("Z Depth:")
col.prop(layer_props, "alpha_halo")
col.prop(layer_props, "skip_depth_write")
col.prop(layer_props, "skip_depth_test")
col.prop(layer_props, "z_bias")
def _has_animation_data(self, context): def _has_animation_data(self, context):
tex = getattr(context, "texture", None) tex = getattr(context, "texture", None)
if tex is not None: if tex is not None:

Loading…
Cancel
Save