Browse Source

Add FogEnvironment modifier

pull/83/head
Darryl Pogue 7 years ago
parent
commit
8fcb728abb
No known key found for this signature in database
GPG Key ID: CB824715C3E6FD41
  1. 5
      korman/exporter/mesh.py
  2. 33
      korman/properties/modifiers/render.py
  3. 21
      korman/ui/modifiers/render.py

5
korman/exporter/mesh.py

@ -224,6 +224,11 @@ class MeshConverter(_MeshManager):
if mods.lighting.rt_lights:
geospan.props |= plGeometrySpan.kPropRunTimeLight
# Attach a FogEnvironment if it's non-default
fogenv = mods.fogenv.environment
if fogenv and fogenv != bpy.context.scene.world:
geospan.fogEnvironment = self._mgr.find_create_key(plFogEnvironment, bl=bo, name=fogenv.name)
# Harvest lights
permaLights, permaProjs = self._exporter().light.find_material_light_keys(bo, bm)
for i in permaLights:

33
korman/properties/modifiers/render.py

@ -82,6 +82,39 @@ class PlasmaFadeMod(PlasmaModifierProperties):
mod.farTrans = self.far_trans
fog_types = {
"none": plFogEnvironment.kNoFog,
"linear": plFogEnvironment.kLinearFog,
"exp2": plFogEnvironment.kExp2Fog
}
class PlasmaFogEnvMod(PlasmaModifierProperties):
pl_id = "fogenv"
bl_category = "Render"
bl_label = "Fog Environment"
bl_description = "Adjust per-object fog settings"
bl_icon = "MAT_SPHERE_SKY"
environment = PointerProperty(name="Environment",
description="Environment defining the fog settings for this object",
type=bpy.types.World)
def export(self, exporter, bo, so):
if self.environment is None or self.environment == bpy.context.scene.world:
# Don't generate a FogEnv for the default Age FNI fog
return
fe = exporter.mgr.find_create_object(plFogEnvironment, bl=bo, name=self.environment.name)
env = self.environment.plasma_fni
fe.type = fog_types[env.fog_method]
fe.color = hsColorRGBA(env.fog_color.r, env.fog_color.g, env.fog_color.b, 1.0)
fe.start = env.fog_start
fe.end = env.fog_end
fe.density = env.fog_density
class PlasmaFollowMod(idprops.IDPropObjectMixin, PlasmaModifierProperties):
pl_id = "followmod"

21
korman/ui/modifiers/render.py

@ -39,6 +39,27 @@ def fademod(modifier, layout, context):
# Warn the user that the values are not recommended.
layout.label("Distance values must be equal or increasing!", icon="ERROR")
def fogenv(modifier, layout, context):
row = layout.row()
row.label("Environment")
row.template_ID(modifier, "environment", new="world.new")
if modifier.environment:
fni = modifier.environment.plasma_fni
box = layout.box()
split = box.split()
col = split.column()
col.prop(fni, "fog_color", text="")
col = split.column()
col.prop(fni, "fog_method", text="")
if fni.fog_method == "linear":
col.prop(fni, "fog_start")
if fni.fog_method != "none":
col.prop(fni, "fog_end")
col.prop(fni, "fog_density")
def followmod(modifier, layout, context):
layout.row().prop(modifier, "follow_mode", expand=True)
layout.prop(modifier, "leader_type")

Loading…
Cancel
Save