Research:Rendering: Difference between revisions

From OpenMW Wiki
Jump to navigation Jump to search
(Add Spell effect VFX.)
 
mNo edit summary
Line 4: Line 4:
==Spell effect VFX==
==Spell effect VFX==
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Parameters: entity, sourceScale
Parameters: Reference reference, float sourceScale


sourceScale is normally 1.0, except:
sourceScale is normally 1.0, except:
Line 12: Line 12:
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
entity = reference.baseEntity


if entity is an NPC:
if entity is an NPC:
     offset_z = 0
     offset_z = 0
     vfxScale = entity.scale * entity.height
     vfxScale = reference.scale * entity.height
else:
else:
     # entity.bounds are from the "Bounding Box" named node.
     # entity.bounds are from the "Bounding Box" named node.
Line 22: Line 24:
     scaleFactor_xy = max(box_dimensions.x, box_dimensions.y) / 64.0
     scaleFactor_xy = max(box_dimensions.x, box_dimensions.y) / 64.0
     scaleFactor_z = box_dimensions.z / 128.0
     scaleFactor_z = box_dimensions.z / 128.0
     scaleFactor = entity.scale * max(factor_xy, factor_z)
     scaleFactor = reference.scale * max(factor_xy, factor_z)


     offset_z = 0
     offset_z = 0

Revision as of 16:35, 23 May 2021


Spell effect VFX

Parameters: Reference reference, float sourceScale

sourceScale is normally 1.0, except:
    Physical projectile hits use 0.5
    Area spell effects use 2 * spell area radius
entity = reference.baseEntity 

if entity is an NPC:
    offset_z = 0
    vfxScale = reference.scale * entity.height
else:
    # entity.bounds are from the "Bounding Box" named node.
    box_dimensions = entity.bounds.box.max - entity.bounds.box.min

    scaleFactor_xy = max(box_dimensions.x, box_dimensions.y) / 64.0
    scaleFactor_z = box_dimensions.z / 128.0
    scaleFactor = reference.scale * max(factor_xy, factor_z)

    offset_z = 0
    if box_dimensions.z >= 128.0:
        if box_dimensions.z < (box_dimensions.x + box_dimensions.y):
            offset_z = 128.0 - box_dimensions.z
    else:
        offset_z = box_dimensions.z - 128.0

    if entity is a flying actor:
        offset_z = offset_z * 0.05

    offset_z = offset_z * scaleFactor
    vfxScale = scaleFactor

vfxScale = max(1.0, sourceScale * finalScale)

Attaches visual effect at entity centre + (0, 0, offset_z), scale vfxScale.

This is preliminary research, please verify it matches standard Morrowind.