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

Class NiBSplineData

source code

                  object --+                        
                           |                        
      utils.graph.DetailNode --+                    
                               |                    
          utils.graph.GlobalNode --+                
                                   |                
object_models.xml.struct_.StructBase --+            
                                       |            
                     NifFormat._NiObject --+        
                                           |        
                          NifFormat.NiObject --+    
                                               |    
                        NifFormat._NiBSplineData --+
                                                   |
                                                  NifFormat.NiBSplineData

>>> # a doctest
>>> from pyffi.formats.nif import NifFormat
>>> block = NifFormat.NiBSplineData()
>>> block.num_short_control_points = 50
>>> block.short_control_points.update_size()
>>> for i in range(block.num_short_control_points):
...     block.short_control_points[i] = 20 - i
>>> list(block.get_short_data(12, 4, 3))
[(8, 7, 6), (5, 4, 3), (2, 1, 0), (-1, -2, -3)]
>>> offset = block.append_short_data([(1,2),(4,3),(13,14),(8,2),(33,33)])
>>> offset
50
>>> list(block.get_short_data(offset, 5, 2))
[(1, 2), (4, 3), (13, 14), (8, 2), (33, 33)]
>>> list(block.get_comp_data(offset, 5, 2, 10.0, 32767.0))
[(11.0, 12.0), (14.0, 13.0), (23.0, 24.0), (18.0, 12.0), (43.0, 43.0)]
>>> block.append_float_data([(1.0,2.0),(3.0,4.0),(0.5,0.25)])
0
>>> list(block.get_float_data(0, 3, 2))
[(1.0, 2.0), (3.0, 4.0), (0.5, 0.25)]
>>> block.append_comp_data([(1,2),(4,3)])
(60, 2.5, 1.5)
>>> list(block.get_short_data(60, 2, 2))
[(-32767, -10922), (32767, 10922)]
>>> list(block.get_comp_data(60, 2, 2, 2.5, 1.5)) # doctest: +ELLIPSIS
[(1.0, 2.00...), (4.0, 2.99...)]
Nested Classes [hide private]

Inherited from object_models.xml.struct_.StructBase: __metaclass__

Instance Methods [hide private]
 
_getData(self, offset, num_elements, element_size, controlpoints)
Helper function for get_float_data and get_short_data.
source code
 
_appendData(self, data, controlpoints)
Helper function for append_float_data and append_short_data.
source code
 
get_short_data(self, offset, num_elements, element_size)
Get an iterator to the data.
source code
 
get_comp_data(self, offset, num_elements, element_size, bias, multiplier)
Get an interator to the data, converted to float with extra bias and multiplication factor.
source code
 
append_short_data(self, data)
Append data.
source code
 
append_comp_data(self, data)
Append data as compressed list.
source code
 
get_float_data(self, offset, num_elements, element_size)
Get an iterator to the data.
source code
 
append_float_data(self, data)
Append data.
source code

Inherited from NiObject: apply_scale, 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 _NiBSplineData (private): _attrs, _games, _is_template, _names

Inherited from object_models.xml.struct_.StructBase: arg

Properties [hide private]

Inherited from _NiBSplineData: float_control_points, num_float_control_points, num_short_control_points, short_control_points

Inherited from object: __class__

Method Details [hide private]

_getData(self, offset, num_elements, element_size, controlpoints)

source code 
Helper function for get_float_data and get_short_data. For internal use only.

_appendData(self, data, controlpoints)

source code 
Helper function for append_float_data and append_short_data. For internal use only.

get_short_data(self, offset, num_elements, element_size)

source code 
Get an iterator to the data.
Parameters:
  • offset - The offset in the data where to start.
  • num_elements - Number of elements to get.
  • element_size - Size of a single element.
Returns:
A list of C{num_elements} tuples of size C{element_size}.

get_comp_data(self, offset, num_elements, element_size, bias, multiplier)

source code 
Get an interator to the data, converted to float with extra bias and multiplication factor. If C{x} is the short value, then the returned value is C{bias + x * multiplier / 32767.0}.
Parameters:
  • offset - The offset in the data where to start.
  • num_elements - Number of elements to get.
  • element_size - Size of a single element.
  • bias - Value bias.
  • multiplier - Value multiplier.
Returns:
A list of C{num_elements} tuples of size C{element_size}.

append_short_data(self, data)

source code 
Append data.
Parameters:
  • data - A list of elements, where each element is a tuple of integers. (Note: cannot be an interator; maybe this restriction will be removed in a future version.)
Returns:
The offset at which the data was appended.

append_comp_data(self, data)

source code 
Append data as compressed list.
Parameters:
  • data - A list of elements, where each element is a tuple of integers. (Note: cannot be an interator; maybe this restriction will be removed in a future version.)
Returns:
The offset, bias, and multiplier.

get_float_data(self, offset, num_elements, element_size)

source code 
Get an iterator to the data.
Parameters:
  • offset - The offset in the data where to start.
  • num_elements - Number of elements to get.
  • element_size - Size of a single element.
Returns:
A list of C{num_elements} tuples of size C{element_size}.

append_float_data(self, data)

source code 
Append data.
Parameters:
  • data - A list of elements, where each element is a tuple of floats. (Note: cannot be an interator; maybe this restriction will be removed in a future version.)
Returns:
The offset at which the data was appended.

Class Variable Details [hide private]

_attribute_list

Value:
[<pyffi.object_models.xml.StructAttribute object at 0x2e9d290>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9dd50>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9de50>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9dfd0>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9d290>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9dd50>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9de50>,
 <pyffi.object_models.xml.StructAttribute object at 0x2e9dfd0>]