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

Class NiGeometry

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._NiGeometry --+
                                                                   |
                                                                  NifFormat.NiGeometry
Known Subclasses:

>>> from pyffi.formats.nif import NifFormat
>>> id44 = NifFormat.Matrix44()
>>> id44.set_identity()
>>> skelroot = NifFormat.NiNode()
>>> skelroot.name = 'skelroot'
>>> skelroot.set_transform(id44)
>>> bone1 = NifFormat.NiNode()
>>> bone1.name = 'bone1'
>>> bone1.set_transform(id44)
>>> bone2 = NifFormat.NiNode()
>>> bone2.name = 'bone2'
>>> bone2.set_transform(id44)
>>> bone21 = NifFormat.NiNode()
>>> bone21.name = 'bone21'
>>> bone21.set_transform(id44)
>>> bone22 = NifFormat.NiNode()
>>> bone22.name = 'bone22'
>>> bone22.set_transform(id44)
>>> bone211 = NifFormat.NiNode()
>>> bone211.name = 'bone211'
>>> bone211.set_transform(id44)
>>> skelroot.add_child(bone1)
>>> bone1.add_child(bone2)
>>> bone2.add_child(bone21)
>>> bone2.add_child(bone22)
>>> bone21.add_child(bone211)
>>> geom = NifFormat.NiTriShape()
>>> geom.name = 'geom'
>>> geom.set_transform(id44)
>>> geomdata = NifFormat.NiTriShapeData()
>>> skininst = NifFormat.NiSkinInstance()
>>> skindata = NifFormat.NiSkinData()
>>> skelroot.add_child(geom)
>>> geom.data = geomdata
>>> geom.skin_instance = skininst
>>> skininst.skeleton_root = skelroot
>>> skininst.data = skindata
>>> skininst.num_bones = 4
>>> skininst.bones.update_size()
>>> skininst.bones[0] = bone1
>>> skininst.bones[1] = bone2
>>> skininst.bones[2] = bone22
>>> skininst.bones[3] = bone211
>>> skindata.num_bones = 4
>>> skindata.bone_list.update_size()
>>> [child.name for child in skelroot.children]
['bone1', 'geom']
>>> skindata.set_transform(id44)
>>> for bonedata in skindata.bone_list:
...     bonedata.set_transform(id44)
>>> affectedbones = geom.flatten_skin()
>>> [bone.name for bone in affectedbones]
['bone1', 'bone2', 'bone22', 'bone211']
>>> [child.name for child in skelroot.children]
['geom', 'bone1', 'bone21', 'bone2', 'bone22', 'bone211']
Nested Classes [hide private]

Inherited from object_models.xml.struct_.StructBase: __metaclass__

Instance Methods [hide private]
 
is_skin(self)
Returns True if geometry is skinned.
source code
 
_validate_skin(self)
Check that skinning blocks are valid.
source code
 
add_bone(self, bone, vert_weights)
Add bone with given vertex weights.
source code
 
get_vertex_weights(self)
Get vertex weights in a convenient format: list bone and weight per vertex.
source code
 
flatten_skin(self)
Reposition all bone blocks and geometry block in the tree to be direct children of the skeleton root.
source code
 
get_skin_deformation(self)
Returns a list of vertices and normals in their final position after skinning, in geometry space.
source code
 
send_bones_to_bind_position(self)
Send all bones to their bind position.
source code
 
update_bind_position(self)
Make current position of the bones the bind position for this geometry.
source code
 
get_skin_partition(self)
Return the skin partition block.
source code
 
set_skin_partition(self, skinpart)
Set skin partition block.
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 _NiGeometry (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 _NiGeometry: active_material, data, dirty_flag, has_shader, material_extra_data, material_name, num_materials, shader_name, skin_instance, unknown_byte, unknown_integer, unknown_integer_2

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

Inherited from object: __class__

Method Details [hide private]

_validate_skin(self)

source code 
Check that skinning blocks are valid. Will raise NifError exception if not.

add_bone(self, bone, vert_weights)

source code 
Add bone with given vertex weights. After adding all bones, the geometry skinning information should be set from the current position of the bones using the L{update_bind_position} function.
Parameters:
  • bone - The bone NiNode block.
  • vert_weights - A dictionary mapping each influenced vertex index to a vertex weight.

flatten_skin(self)

source code 

Reposition all bone blocks and geometry block in the tree to be direct children of the skeleton root.

Returns list of all used bones by the skin.

send_bones_to_bind_position(self)

source code 

Send all bones to their bind position.

@deprecated: Use L{NifFormat.NiNode.send_bones_to_bind_position} instead of
this function.

update_bind_position(self)

source code 

Make current position of the bones the bind position for this geometry.

Sets the NiSkinData overall transform to the inverse of the geometry transform relative to the skeleton root, and sets the NiSkinData of each bone to the geometry transform relative to the skeleton root times the inverse of the bone transform relative to the skeleton root.


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>,
...