Module export_nif :: Class NifExport
[hide private]
[frames] | no frames]

Class NifExport

source code

nif_common.NifImportExport --+
                             |
                            NifExport

Instance Methods [hide private]
 
rebuildBonesExtraMatrices(self)
Recover bone extra matrices.
source code
 
setBoneExtraMatrixInv(self, bonename, mat)
Set bone extra matrix, inverted.
source code
 
getBoneExtraMatrixInv(self, bonename)
Get bone extra matrix, inverted.
source code
 
rebuildFullNames(self)
Recovers the full object names from the text buffer and rebuilds the names dictionary.
source code
 
getUniqueName(self, blender_name)
Returns an unique name for use in the NIF file, from the name of a Blender object.
source code
 
getFullName(self, blender_name)
Returns the original imported name if present, or the name by which the object was exported already.
source code
 
getExportedObjects(self)
Return a list of exported objects.
source code
 
__init__(self, **config)
Main export function.
source code
 
exportNode(self, ob, space, parent_block, node_name)
Export a mesh/armature/empty object ob as child of parent_block.
source code
 
exportKeyframes(self, ipo, space, parent_block, bind_mat=None, extra_mat_inv=None) source code
 
exportVertexColorProperty(self, block_parent, flags=1, vertex_mode=0, lighting_mode=1)
Create a vertex color property, and attach it to an existing block (typically, the root of the nif tree).
source code
 
exportZBufferProperty(self, block_parent, flags=15, function=3)
Create a z-buffer property, and attach it to an existing block (typically, the root of the nif tree).
source code
 
exportAnimGroups(self, animtxt, block_parent)
Parse the animation groups buffer and write an extra string data block, and attach it to an existing block (typically, the root of the nif tree).
source code
 
exportTextureFilename(self, texture)
Returns file name from texture.
source code
 
exportSourceTexture(self, texture=None, filename=None)
Export a NiSourceTexture.
source code
 
exportFlipController(self, fliptxt, texture, target, target_tex) source code
 
exportTriShapes(self, ob, space, parent_block, trishape_name=None) source code
 
exportMaterialControllers(self, b_material, n_geom)
Export material animation data for given geometry.
source code
 
exportMaterialAlphaController(self, b_material, n_geom)
Export the material alpha controller data.
source code
 
exportMaterialUVController(self, b_material, n_geom)
Export the material UV controller data.
source code
 
exportBones(self, arm, parent_block)
Export the bones of an armature.
source code
 
exportChildren(self, obj, parent_block)
Export all children of blender object ob as children of parent_block.
source code
 
exportMatrix(self, obj, space, block)
Set a block's transform matrix to an object's transformation matrix in rest pose.
source code
 
getObjectMatrix(self, obj, space)
Get an object's matrix as NifFormat.Matrix44
source code
 
getObjectSRT(self, obj, space='localspace')
Find scale, rotation, and translation components of an object in the rest pose.
source code
 
decomposeSRT(self, mat)
Decompose Blender transform matrix as a scale, rotation matrix, and translation vector.
source code
 
getBoneRestMatrix(self, bone, space, extra=True, tail=False)
Get bone matrix in rest position ("bind pose").
source code
 
createBlock(self, blocktype, b_obj=None)
Helper function to create a new block, register it in the list of exported blocks, and associate it with a Blender object.
source code
 
registerBlock(self, block, b_obj=None)
Helper function to register a newly created block in the list of exported blocks and to associate it with a Blender object.
source code
 
registerBlenderObject(self, block, b_obj)
Helper function to associate a nif block with a Blender object.
source code
 
exportCollision(self, obj, parent_block)
Main function for adding collision object obj to a node.
source code
 
exportCollisionHelper(self, obj, parent_block)
Helper function to add collision objects to a node.
source code
 
exportCollisionPacked(self, obj, colbody, layer, material)
Add object ob as packed collision object to collision body colbody.
source code
 
exportCollisionSingle(self, obj, colbody, layer, material)
Add collision object to colbody.
source code
 
exportCollisionList(self, obj, colbody, layer, material)
Add collision object obj to the list of collision objects of colbody.
source code
 
exportCollisionObject(self, obj, layer, material)
Export object obj as box, sphere, capsule, or convex hull.
source code
 
exportConstraints(self, b_obj, root_block)
Export the constraints of an object.
source code
 
exportAlphaProperty(self, flags=0x00ED, threshold=0)
Return existing alpha property with given flags, or create new one if an alpha property with required flags is not found.
source code
 
exportSpecularProperty(self, flags=0x0001)
Return existing specular property with given flags, or create new one if a specular property with required flags is not found.
source code
 
exportWireframeProperty(self, flags=0x0001)
Return existing wire property with given flags, or create new one if an wire property with required flags is not found.
source code
 
exportStencilProperty(self)
Return existing stencil property with given flags, or create new one if an identical stencil property.
source code
 
exportMaterialProperty(self, name='', flags=0x0001, ambient=(1.0,1.0,1.0), diffuse=(1.0,1.0,1.0), specular=(0.0,0.0,0.0), emissive=(0.0,0.0,0.0), glossiness=10.0, alpha=1.0, emitmulti=1.0)
Return existing material property with given settings, or create a new one if a material property with these settings is not found.
source code
 
exportTexDesc(self, texdesc=None, uvlayers=None, mtex=None)
Helper function for exportTexturingProperty to export each texture slot.
source code
 
exportTexturingProperty(self, flags=0x0001, applymode=None, uvlayers=None, basemtex=None, glowmtex=None, bumpmtex=None, glossmtex=None, darkmtex=None, detailmtex=None, refmtex=None)
Export texturing property.
source code
 
exportBSShaderProperty(self, basemtex=None, bumpmtex=None, glowmtex=None)
Export a Bethesda shader property block.
source code
 
exportTextureEffect(self, mtex=None)
Export a texture effect block from material texture mtex (MTex, not Texture).
source code
 
exportBSBound(self, obj, block_parent)
Export an Oblivion bounding box.
source code
 
addShaderIntegerExtraDatas(self, trishape)
Add extra data blocks for shader indices.
source code
 
exportEgm(self, keyblocks) source code

Inherited from nif_common.NifImportExport: get_bone_name_for_blender, get_bone_name_for_nif, get_extend_from_flags, get_flags_from_extend, msg_progress

Class Variables [hide private]
  IDENTITY44 = NifFormat.Matrix44()
  APPLYMODE = {Blender.Texture.BlendModes ["MIX"]: NifFormat.App...
  FLOAT_MIN = -3.4028234663852886e+38
  FLOAT_MAX = + 3.4028234663852886e+38

Inherited from nif_common.NifImportExport: EXTRA_SHADER_TEXTURES, USED_EXTRA_SHADER_TEXTURES, progress_bar

Method Details [hide private]

setBoneExtraMatrixInv(self, bonename, mat)

source code 

Set bone extra matrix, inverted. The bonename is first converted to blender style (to ensure compatibility with older imports).

getBoneExtraMatrixInv(self, bonename)

source code 

Get bone extra matrix, inverted. The bonename is first converted to blender style (to ensure compatibility with older imports).

exportNode(self, ob, space, parent_block, node_name)

source code 

Export a mesh/armature/empty object ob as child of parent_block. Export also all children of ob.

  • space is 'none', 'worldspace', or 'localspace', and determines relative to what object the transformation should be stored.
  • parent_block is the parent nif block of the object (None for the root node)
  • for the root node, ob is None, and node_name is usually the base filename (either with or without extension)

exportVertexColorProperty(self, block_parent, flags=1, vertex_mode=0, lighting_mode=1)

source code 

Create a vertex color property, and attach it to an existing block (typically, the root of the nif tree).

Parameters:
  • block_parent - The block to which to attach the new property.
  • flags - The flags of the new property.
  • vertex_mode - The vertexMode of the new property.
  • lighting_mode - The lightingMode of the new property.
Returns:
The new property block.

exportZBufferProperty(self, block_parent, flags=15, function=3)

source code 

Create a z-buffer property, and attach it to an existing block (typically, the root of the nif tree).

Parameters:
  • block_parent - The block to which to attach the new property.
  • flags - The flags of the new property.
  • function - The function of the new property.
Returns:
The new property block.

exportTextureFilename(self, texture)

source code 

Returns file name from texture.

Parameters:
  • texture - The texture object in blender.
Returns:
The file name of the image used in the texture.

exportSourceTexture(self, texture=None, filename=None)

source code 

Export a NiSourceTexture.

Parameters:
  • texture - The texture object in blender to be exported.
  • filename - The full or relative path to the texture file (this argument is used when exporting NiFlipControllers and when exporting default shader slots that have no use in being imported into Blender).
Returns:
The exported NiSourceTexture block.

getObjectMatrix(self, obj, space)

source code 

Get an object's matrix as NifFormat.Matrix44

Note: for objects parented to bones, this will return the transform relative to the bone parent head in nif coordinates (that is, including the bone correction); this differs from getMatrix which returns the transform relative to the armature.

getObjectSRT(self, obj, space='localspace')

source code 

Find scale, rotation, and translation components of an object in the rest pose. Returns a triple (bs, br, bt), where bs is a scale float, br is a 3x3 rotation matrix, and bt is a translation vector. It should hold that

ob.getMatrix(space) == bs * br * bt

Note: for objects parented to bones, this will return the transform relative to the bone parent head including bone correction.

space is either 'none' (gives identity transform) or 'localspace'

getBoneRestMatrix(self, bone, space, extra=True, tail=False)

source code 

Get bone matrix in rest position ("bind pose"). Space can be ARMATURESPACE or BONESPACE. This returns also a 4x4 matrix if space is BONESPACE (translation is bone head plus tail from parent bone). If tail is True then the matrix translation includes the bone tail.

createBlock(self, blocktype, b_obj=None)

source code 

Helper function to create a new block, register it in the list of exported blocks, and associate it with a Blender object.

Parameters:
  • blocktype (str) - The nif block type (for instance "NiNode").
  • b_obj - The Blender object.
Returns:
The newly created block.

registerBlock(self, block, b_obj=None)

source code 

Helper function to register a newly created block in the list of exported blocks and to associate it with a Blender object.

Parameters:
  • block - The nif block.
  • b_obj - The Blender object.
Returns:
block

registerBlenderObject(self, block, b_obj)

source code 

Helper function to associate a nif block with a Blender object.

Parameters:
  • block - The nif block.
  • b_obj - The Blender object.
Returns:
block

exportCollisionHelper(self, obj, parent_block)

source code 

Helper function to add collision objects to a node. This function exports the rigid body, and calls the appropriate function to export the collision geometry in the desired format.

Parameters:
  • obj - The object to export as collision.
  • parent_block - The NiNode parent of the collision.

exportCollisionPacked(self, obj, colbody, layer, material)

source code 

Add object ob as packed collision object to collision body colbody. If parent_block hasn't any collisions yet, a new packed list is created. If the current collision system is not a packed list of collisions (bhkPackedNiTriStripsShape), then a ValueError is raised.

exportCollisionSingle(self, obj, colbody, layer, material)

source code 

Add collision object to colbody. If colbody already has a collision shape, throw ValueError.

exportCollisionList(self, obj, colbody, layer, material)

source code 

Add collision object obj to the list of collision objects of colbody. If colbody has no collisions yet, a new list is created. If the current collision system is not a list of collisions (bhkListShape), then a ValueError is raised.

exportCollisionObject(self, obj, layer, material)

source code 

Export object obj as box, sphere, capsule, or convex hull. Note: polyheder is handled by exportCollisionPacked.

exportConstraints(self, b_obj, root_block)

source code 

Export the constraints of an object.

Parameters:
  • b_obj - The object whose constraints to export.
  • root_block - The root of the nif tree (required for updateAB).

exportTexturingProperty(self, flags=0x0001, applymode=None, uvlayers=None, basemtex=None, glowmtex=None, bumpmtex=None, glossmtex=None, darkmtex=None, detailmtex=None, refmtex=None)

source code 

Export texturing property. The parameters basemtex, glowmtex, bumpmtex, ... are the Blender material textures (MTex, not Texture) that correspond to the base, glow, bump map, ... textures. The uvlayers parameter is a list of uvlayer strings, that is, mesh.getUVLayers().


Class Variable Details [hide private]

APPLYMODE

Value:
{Blender.Texture.BlendModes ["MIX"]: NifFormat.ApplyMode.APPLY_MODULAT\
E, Blender.Texture.BlendModes ["LIGHTEN"]: NifFormat.ApplyMode.APPLY_H\
ILIGHT, Blender.Texture.BlendModes ["MULTIPLY"]: NifFormat.ApplyMode.A\
PPLY_HILIGHT2}