pyffi.spells.nif
— NetImmerse/Gamebryo File/Keyframe (.nif/.kf/.kfa) spells¶
Module which contains all spells that check something in a NIF file.
Spells for dumping particular blocks from nifs.
pyffi.spells.nif.fix
— spells to fix errors¶
Module which contains all spells that fix something in a nif.
Implementation¶
-
class
pyffi.spells.nif.fix.
SpellDelTangentSpace
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Delete tangentspace if it is present.
-
class
pyffi.spells.nif.fix.
SpellAddTangentSpace
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Add tangentspace if none is present.
-
class
pyffi.spells.nif.fix.
SpellFFVT3RSkinPartition
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Create or update skin partition, with settings that work for Freedom Force vs. The 3rd Reich.
-
class
pyffi.spells.nif.fix.
SpellFixTexturePath
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.fix.SpellParseTexturePath
Fix the texture path. Transforms 0x0a into n and 0x0d into r. This fixes a bug in nifs saved with older versions of nifskope. Also transforms / into . This fixes problems when packing files into a bsa archive. Also if the version is 20.0.0.4 or higher it will check for bad texture path form of e.g. c:program filesbethsoftobtexturesfilepath.dds and replace it with e.g. texturesfilepath.dds.
-
class
pyffi.spells.nif.fix.
SpellDetachHavokTriStripsData
(*args, **kwargs)¶ Bases:
pyffi.spells.nif.NifSpell
For NiTriStrips if their NiTriStripsData also occurs in a bhkNiTriStripsShape, make deep copy of data in havok. This is mainly useful as a preperation for other spells that act on NiTriStripsData, to ensure that the havok data remains untouched.
-
class
pyffi.spells.nif.fix.
SpellClampMaterialAlpha
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Clamp corrupted material alpha values.
-
class
pyffi.spells.nif.fix.
SpellSendGeometriesToBindPosition
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.SpellVisitSkeletonRoots
Transform skinned geometries so similar bones have the same bone data, and hence, the same bind position, over all geometries.
-
class
pyffi.spells.nif.fix.
SpellSendDetachedGeometriesToNodePosition
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.SpellVisitSkeletonRoots
Transform geometries so each set of geometries that shares bones is aligned with the transform of the root bone of that set.
-
class
pyffi.spells.nif.fix.
SpellSendBonesToBindPosition
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.SpellVisitSkeletonRoots
Transform bones so bone data agrees with bone transforms, and hence, all bones are in bind position.
-
class
pyffi.spells.nif.fix.
SpellMergeSkeletonRoots
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Merges skeleton roots in the NIF file so that no skeleton root has another skeleton root as child. Warns if merge is impossible (this happens if the global skin data of the geometry is not the unit transform).
-
class
pyffi.spells.nif.fix.
SpellApplySkinDeformation
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Apply skin deformation to nif.
-
class
pyffi.spells.nif.fix.
SpellScale
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Scale a model.
-
class
pyffi.spells.nif.fix.
SpellFixCenterRadius
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.check.SpellCheckCenterRadius
Recalculate geometry centers and radii.
-
class
pyffi.spells.nif.fix.
SpellFixSkinCenterRadius
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.check.SpellCheckSkinCenterRadius
Recalculate skin centers and radii.
-
class
pyffi.spells.nif.fix.
SpellFixMopp
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.check.SpellCheckMopp
Recalculate mopp data from collision geometry.
-
class
pyffi.spells.nif.fix.
SpellCleanStringPalette
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Remove unused strings from string palette.
-
branchentry
(branch)¶ Parses string palette of either a single controller sequence, or of all controller sequences in a controller manager.
>>> seq = NifFormat.NiControllerSequence() >>> seq.string_palette = NifFormat.NiStringPalette() >>> block = seq.add_controlled_block() >>> block.string_palette = seq.string_palette >>> block.set_variable_1("there") >>> block.set_node_name("hello") >>> block.string_palette.palette.add_string("test") 12 >>> seq.string_palette.palette.get_all_strings() [b'there', b'hello', b'test'] >>> SpellCleanStringPalette().branchentry(seq) pyffi.toaster:INFO:parsing string palette False >>> seq.string_palette.palette.get_all_strings() [b'hello', b'there'] >>> block.get_variable_1() b'there' >>> block.get_node_name() b'hello'
-
substitute
(old_string)¶ Helper function to substitute strings in the string palette, to allow subclasses of this spell can modify the strings. This implementation returns string unmodified.
-
-
class
pyffi.spells.nif.fix.
SpellDelUnusedRoots
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Remove root branches that shouldn’t be root branches and are unused in the file such as NiProperty branches that are not properly parented.
-
class
pyffi.spells.nif.fix.
SpellFixEmptySkeletonRoots
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Fix empty skeleton roots in an as sane as possible way.
Regression tests¶
Spells for optimizing NIF files.
-
class
pyffi.spells.nif.optimize.
SpellCleanRefLists
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Remove empty and duplicate entries in reference lists.
-
cleanreflist
(reflist, category)¶ Return a cleaned copy of the given list of references.
-
-
class
pyffi.spells.nif.optimize.
SpellMergeDuplicates
(*args, **kwargs)¶ Bases:
pyffi.spells.nif.NifSpell
Remove duplicate branches.
-
class
pyffi.spells.nif.optimize.
SpellOptimizeGeometry
(*args, **kwargs)¶ Bases:
pyffi.spells.nif.NifSpell
Optimize all geometries: - remove duplicate vertices - triangulate - recalculate skin partition - recalculate tangent space
-
branchentry
(branch)¶ Optimize a NiTriStrips or NiTriShape block:
- remove duplicate vertices
- retriangulate for vertex cache
- recalculate skin partition
- recalculate tangent space
Todo
Limit the size of shapes (see operation optimization mod for Oblivion!)
-
-
class
pyffi.spells.nif.optimize.
SpellOptimize
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.SpellCleanFarNifSpellDelUnusedRootsSpellCleanRefListsSpellDetachHavokTriStripsDataSpellFixTexturePathSpellClampMaterialAlphaSpellFixBhkSubShapesSpellFixEmptySkeletonRootsSpellOptimizeGeometrySpellOptimizeCollisionBoxSpellOptimizeCollisionGeometrySpellMergeDuplicates
Global fixer and optimizer spell.
-
class
pyffi.spells.nif.optimize.
SpellDelUnusedBones
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Remove nodes that are not used for anything.
pyffi.spells.nif.modify
— spells to make modifications¶
Module which contains all spells that modify a nif.
-
class
pyffi.spells.nif.modify.
SpellTexturePath
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.fix.SpellParseTexturePath
Changes the texture path while keeping the texture names.
-
class
pyffi.spells.nif.modify.
SpellSubstituteTexturePath
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.fix.SpellFixTexturePath
Runs a regex replacement on texture paths.
-
substitute
(old_path)¶ Returns modified texture path, and reports if path was modified.
-
-
class
pyffi.spells.nif.modify.
SpellLowResTexturePath
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.modify.SpellSubstituteTexturePath
Changes the texture path by replacing ‘textures*’ with ‘textureslowres*’ - used mainly for making _far.nifs
-
class
pyffi.spells.nif.modify.
SpellCollisionType
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Sets the object collision to be a different type
-
class
pyffi.spells.nif.modify.
SpellCollisionMaterial
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Sets the object’s collision material to be a different type
-
class
pyffi.spells.nif.modify.
SpellScaleAnimationTime
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Scales the animation time.
-
class
pyffi.spells.nif.modify.
SpellReverseAnimation
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Reverses the animation by reversing datas in relation to the time.
-
class
pyffi.spells.nif.modify.
SpellSubstituteStringPalette
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.fix.SpellCleanStringPalette
Substitute strings in a string palette.
-
substitute
(old_string)¶ Returns modified string, and reports if string was modified.
-
-
class
pyffi.spells.nif.modify.
SpellChangeBonePriorities
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Changes controlled block priorities based on controlled block name.
-
class
pyffi.spells.nif.modify.
SpellSetInterpolatorTransRotScale
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Changes specified bone(s) translations/rotations in their NiTransformInterpolator.
-
class
pyffi.spells.nif.modify.
SpellDelInterpolatorTransformData
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Deletes the specified bone(s) NiTransformData(s).
-
class
pyffi.spells.nif.modify.
SpellDelBranches
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Delete blocks that match the exclude list.
-
branchentry
(branch)¶ Strip branch if it is flagged for deletion.
-
is_branch_to_be_deleted
(branch)¶ Returns
True
for those branches that must be deleted. The default implementation returnsTrue
for branches that are not admissible as specified by include/exclude options of the toaster. Override in subclasses that must delete specific branches.
-
-
class
pyffi.spells.nif.modify.
_SpellDelBranchClasses
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.modify.SpellDelBranches
Delete blocks that match a given list. Only useful as base class for other spells.
-
BRANCH_CLASSES_TO_BE_DELETED
= ()¶ List of branch classes that have to be deleted.
-
-
class
pyffi.spells.nif.modify.
SpellDelSkinShapes
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.modify.SpellDelBranches
Delete any geometries with a material name of ‘skin’
-
class
pyffi.spells.nif.modify.
SpellDisableParallax
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Disable parallax shader (for Oblivion, but may work on other nifs too).
-
class
pyffi.spells.nif.modify.
SpellAddStencilProperty
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.NifSpell
Adds a NiStencilProperty to each geometry if it is not present.
-
class
pyffi.spells.nif.modify.
SpellDelVertexColor
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.nif.modify.SpellDelBranches
Delete vertex color properties and vertex color data.
-
class
pyffi.spells.nif.modify.
SpellMakeSkinlessNif
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.SpellDelSkinShapesSpellAddStencilProperty
Spell to make fleshless CMR (Custom Model Races) clothing/armour type nifs.
-
class
pyffi.spells.nif.modify.
SpellCleanFarNif
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.SpellDelVertexColorPropertySpellDelAlphaPropertySpellDelSpecularPropertySpellDelBSXFlagsSpellDelStringExtraDatasSpellDelTangentSpaceSpellDelCollisionDataSpellDelAnimationSpellDisableParallax
Spell to clean _far type nifs (for even more optimizations, combine this with the optimize spell).
-
class
pyffi.spells.nif.modify.
SpellMakeFarNif
(toaster=None, data=None, stream=None)¶ Bases:
pyffi.spells.SpellDelVertexColorPropertySpellDelAlphaPropertySpellDelSpecularPropertySpellDelBSXFlagsSpellDelStringExtraDatasSpellDelTangentSpaceSpellDelCollisionDataSpellDelAnimationSpellDisableParallaxSpellLowResTexturePath
Spell to make _far type nifs (for even more optimizations, combine this with the optimize spell).