Research:Rendering

From OpenMW Wiki
Jump to navigation Jump to search


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:
    if actor scenegraph root node has a NIF box bounding volume:
        # Morrowind Bug: Note that the extents aren't multiplied by 2 to get the full dimensions.
        # This affects all other calculations and is probably unwanted.
        box_dimensions = sceneNode.boxBV.extents
    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 with local scale vfxScale. It is positioned at entity centre + (0, 0, offset_z).

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