Research:Rendering: Difference between revisions

From OpenMW Wiki
Jump to navigation Jump to search
No edit summary
 
Line 3: Line 3:


==Spell effect VFX==
==Spell effect VFX==
Used for spell visuals attached to references. e.g. soul trap.
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Parameters: Reference reference, float sourceScale
Parameters: Reference reference, float sourceScale


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


</syntaxhighlight>
</syntaxhighlight>
Line 21: Line 24:
     if actor scenegraph root node has a NIF box bounding volume:
     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.
         # 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.
         # This affects all other calculations and is probably unwanted. This particularly affects flying creatures.
         box_dimensions = sceneNode.boxBV.extents
         box_dimensions = sceneNode.boxBV.extents
     else:
     else:
Line 46: Line 49:
vfxScale = max(1.0, sourceScale * finalScale)
vfxScale = max(1.0, sourceScale * finalScale)


Attaches visual effect with local scale vfxScale. It is positioned at entity centre + (0, 0, offset_z).
Attaches visual effect with local scale vfxScale. It is positioned at entity origin + (0, 0, offset_z).


</syntaxhighlight>
</syntaxhighlight>
This is preliminary research, please verify it matches standard Morrowind.
This is preliminary research, please verify it matches standard Morrowind.

Latest revision as of 20:59, 15 May 2022


Spell effect VFX

Used for spell visuals attached to references. e.g. soul trap.

Parameters: Reference reference, float sourceScale

sourceScale is normally 1.0, except:
    Physical projectile hits use sourceScale = 0.5
    Area spell effects use sourceScale  = 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. This particularly affects flying creatures.
        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 origin + (0, 0, offset_z).

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