Package pyffi :: Package formats :: Package nif :: Class NifFormat :: Class NiNode
[hide private]
[frames] | no frames]

Class NiNode

source code

                  object --+                                        
                           |                                        
      utils.graph.DetailNode --+                                    
                               |                                    
          utils.graph.GlobalNode --+                                
                                   |                                
object_models.xml.struct_.StructBase --+                            
                                       |                            
                     NifFormat._NiObject --+                        
                                           |                        
                          NifFormat.NiObject --+                    
                                               |                    
                          NifFormat._NiObjectNET --+                
                                                   |                
                               NifFormat.NiObjectNET --+            
                                                       |            
                                   NifFormat._NiAVObject --+        
                                                           |        
                                        NifFormat.NiAVObject --+    
                                                               |    
                                               NifFormat._NiNode --+
                                                                   |
                                                                  NifFormat.NiNode
Known Subclasses:

>>> from pyffi.formats.nif import NifFormat
>>> x = NifFormat.NiNode()
>>> y = NifFormat.NiNode()
>>> z = NifFormat.NiNode()
>>> x.num_children =1
>>> x.children.update_size()
>>> y in x.children
False
>>> x.children[0] = y
>>> y in x.children
True
>>> x.add_child(z, front = True)
>>> x.add_child(y)
>>> x.num_children
2
>>> x.children[0] is z
True
>>> x.remove_child(y)
>>> y in x.children
False
>>> x.num_children
1
>>> e = NifFormat.NiSpotLight()
>>> x.add_effect(e)
>>> x.num_effects
1
>>> e in x.effects
True
>>> from pyffi.formats.nif import NifFormat
>>> node = NifFormat.NiNode()
>>> child1 = NifFormat.NiNode()
>>> child1.name = "hello"
>>> child_2 = NifFormat.NiNode()
>>> child_2.name = "world"
>>> node.get_children()
[]
>>> node.set_children([child1, child_2])
>>> [child.name for child in node.get_children()]
['hello', 'world']
>>> [child.name for child in node.children]
['hello', 'world']
>>> node.set_children([])
>>> node.get_children()
[]
>>> # now set them the other way around
>>> node.set_children([child_2, child1])
>>> [child.name for child in node.get_children()]
['world', 'hello']
>>> [child.name for child in node.children]
['world', 'hello']
>>> node.remove_child(child_2)
>>> [child.name for child in node.children]
['hello']
>>> node.add_child(child_2)
>>> [child.name for child in node.children]
['hello', 'world']
>>> from pyffi.formats.nif import NifFormat
>>> node = NifFormat.NiNode()
>>> effect1 = NifFormat.NiSpotLight()
>>> effect1.name = "hello"
>>> effect2 = NifFormat.NiSpotLight()
>>> effect2.name = "world"
>>> node.get_effects()
[]
>>> node.set_effects([effect1, effect2])
>>> [effect.name for effect in node.get_effects()]
['hello', 'world']
>>> [effect.name for effect in node.effects]
['hello', 'world']
>>> node.set_effects([])
>>> node.get_effects()
[]
>>> # now set them the other way around
>>> node.set_effects([effect2, effect1])
>>> [effect.name for effect in node.get_effects()]
['world', 'hello']
>>> [effect.name for effect in node.effects]
['world', 'hello']
>>> node.remove_effect(effect2)
>>> [effect.name for effect in node.effects]
['hello']
>>> node.add_effect(effect2)
>>> [effect.name for effect in node.effects]
['hello', 'world']
Nested Classes [hide private]

Inherited from object_models.xml.struct_.StructBase: __metaclass__

Instance Methods [hide private]
 
add_child(self, child, front=False)
Add block to child list.
source code
 
remove_child(self, child)
Remove a block from the child list.
source code
list of L{NifFormat.NiAVObject}
get_children(self)
Return a list of the children of the block.
source code
 
set_children(self, childlist)
Set the list of children from the given list (destroys existing list).
source code
 
add_effect(self, effect)
Add an effect to the list of effects.
source code
 
remove_effect(self, effect)
Remove a block from the effect list.
source code
list of L{NifFormat.NiDynamicEffect}
get_effects(self)
Return a list of the effects of the block.
source code
 
set_effects(self, effectlist)
Set the list of effects from the given list (destroys existing list).
source code
 
merge_external_skeleton_root(self, skelroot)
Attach skinned geometry to self (which will be the new skeleton root of the nif at the given skeleton root).
source code
 
merge_skeleton_roots(self)
This function will look for other geometries whose skeleton root is a (possibly indirect) child of this node.
source code
 
get_skinned_geometries(self)
This function yields all skinned geometries which have self as skeleton root.
source code
float
send_geometries_to_bind_position(self)
Call this on the skeleton root of geometries.
source code
 
send_detached_geometries_to_node_position(self)
Some nifs (in particular in Morrowind) have geometries that are skinned but that do not share bones.
source code
float
send_bones_to_bind_position(self)
This function will send all bones of geometries of this skeleton root to their bind position.
source code

Inherited from NiAVObject: add_property, apply_scale, get_properties, get_transform, remove_property, set_properties, set_transform

Inherited from NiObjectNET: add_controller, add_extra_data, add_integer_extra_data, get_controllers, get_extra_datas, remove_extra_data, set_extra_datas

Inherited from NiObject: find, find_chain, is_interchangeable, tree

Inherited from NiObject (private): _validateTree

Inherited from object_models.xml.struct_.StructBase: __init__, __str__, deepcopy, fix_links, get_attribute, get_basic_attribute, get_detail_child_names, get_detail_child_nodes, get_global_child_nodes, get_global_display, get_hash, get_links, get_refs, get_size, get_strings, get_template_attribute, read, replace_global_node, set_attribute, set_basic_attribute, set_template_attribute, write

Inherited from utils.graph.GlobalNode: get_global_child_edge_types, get_global_iterator

Inherited from utils.graph.DetailNode: get_detail_child_edge_types, get_detail_display, get_detail_iterator

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from object_models.xml.struct_.StructBase: get_games, get_versions

Class Variables [hide private]
  _attribute_list = [<pyffi.object_models.xml.StructAttribute ob...

Inherited from _NiNode (private): _attrs, _games, _is_template, _names

Inherited from _NiObjectNET (private): _has_links, _has_refs, _has_strings

Inherited from object_models.xml.struct_.StructBase: arg

Properties [hide private]

Inherited from _NiNode: children, effects, num_children, num_effects

Inherited from _NiAVObject: bounding_box, collision_object, flags, has_bounding_box, num_properties, properties, rotation, scale, translation, unknown_1, unknown_2, unknown_short_1, velocity

Inherited from _NiObjectNET: controller, extra_data, extra_data_list, has_old_extra_data, name, num_extra_data_list, old_extra_internal_id, old_extra_prop_name, old_extra_string, unknown_byte

Inherited from object: __class__

Method Details [hide private]

add_child(self, child, front=False)

source code 
Add block to child list.
Parameters:
  • child (L{NifFormat.NiAVObject}) - The child to add.
  • front (bool) - Whether to add to the front or to the end of the list (default is at end).

remove_child(self, child)

source code 
Remove a block from the child list.
Parameters:
  • child (L{NifFormat.NiAVObject}) - The child to remove.

get_children(self)

source code 
Return a list of the children of the block.
Returns: list of L{NifFormat.NiAVObject}
The list of children.

set_children(self, childlist)

source code 
Set the list of children from the given list (destroys existing list).
Parameters:
  • childlist (list of L{NifFormat.NiAVObject}) - The list of child blocks to set.

add_effect(self, effect)

source code 
Add an effect to the list of effects.
Parameters:
  • effect (L{NifFormat.NiDynamicEffect}) - The effect to add.

remove_effect(self, effect)

source code 
Remove a block from the effect list.
Parameters:
  • effect (L{NifFormat.NiDynamicEffect}) - The effect to remove.

get_effects(self)

source code 
Return a list of the effects of the block.
Returns: list of L{NifFormat.NiDynamicEffect}
The list of effects.

set_effects(self, effectlist)

source code 
Set the list of effects from the given list (destroys existing list).
Parameters:
  • effectlist (list of L{NifFormat.NiDynamicEffect}) - The list of effect blocks to set.

merge_external_skeleton_root(self, skelroot)

source code 
Attach skinned geometry to self (which will be the new skeleton root of the nif at the given skeleton root). Use this function if you move a skinned geometry from one nif into a new nif file. The bone links will be updated to point to the tree at self, instead of to the external tree.

merge_skeleton_roots(self)

source code 

This function will look for other geometries whose skeleton root is a (possibly indirect) child of this node. It will then reparent those geometries to this node. For example, it will unify the skeleton roots in Morrowind's cliffracer.nif file, or of the (official) body skins. This makes it much easier to import skeletons in for instance Blender: there will be only one skeleton root for each bone, over all geometries.

The merge fails for those geometries whose global skin data transform does not match the inverse geometry transform relative to the skeleton root (the maths does not work out in this case!)

Returns list of all new blocks that have been reparented (and added to the skeleton root children list), and a list of blocks for which the merge failed.

send_geometries_to_bind_position(self)

source code 
Call this on the skeleton root of geometries. This function will transform the geometries, such that all skin data transforms coincide, or at least coincide partially.
Returns: float
A number quantifying the remaining difference between bind positions.

send_detached_geometries_to_node_position(self)

source code 

Some nifs (in particular in Morrowind) have geometries that are skinned but that do not share bones. In such cases, send_geometries_to_bind_position cannot reposition them. This function will send such geometries to the position of their root node.

Examples of such nifs are the official Morrowind skins (after merging skeleton roots).

Returns list of detached geometries that have been moved.

send_bones_to_bind_position(self)

source code 
This function will send all bones of geometries of this skeleton root to their bind position. For best results, call L{send_geometries_to_bind_position} first.
Returns: float
A number quantifying the remaining difference between bind positions.

Class Variable Details [hide private]

_attribute_list

Value:
[<pyffi.object_models.xml.StructAttribute object at 0x2db5cd0>,
 <pyffi.object_models.xml.StructAttribute object at 0x2db5d10>,
 <pyffi.object_models.xml.StructAttribute object at 0x2db5d90>,
 <pyffi.object_models.xml.StructAttribute object at 0x2db5e90>,
 <pyffi.object_models.xml.StructAttribute object at 0x2db5f90>,
 <pyffi.object_models.xml.StructAttribute object at 0x2dbb050>,
 <pyffi.object_models.xml.StructAttribute object at 0x2dbb090>,
 <pyffi.object_models.xml.StructAttribute object at 0x2dbb0d0>,
...