[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [525] tags/2_49_bundle/py/scripts: Updating the blender nif scripts from 2.4.12 to 2.5.4.
Amorilia
amorilia.gamebox at gmail.com
Sun Mar 28 13:16:34 CEST 2010
Revision: 525
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=525
Author: amorilia
Date: 2010-03-28 13:16:34 +0200 (Sun, 28 Mar 2010)
Log Message:
-----------
Updating the blender nif scripts from 2.4.12 to 2.5.4.
Log of all changes (taken from upstream changelog):
Version 2.5.4 (28 Mar 2010)
* fixed bone priority export for L and R bones (reported by Kilza)
* fixed morph base key name import (reported by LHammonds)
* fixed morph base key to have no float data (reported by LHammonds)
* improved export of controller start and stop times (reported by LHammonds)
* fixed consistency type on NiGeometryData to be CT_VOLATILE when exporting
morphs; this fixes for instance bow exports (reported and fix suggested by
LHammonds, based on Nicoroshi and Windy's bow tutorials)
Version 2.5.3 (19 Mar 2010)
* import and export NiLODNodes as empty with LODs as children and properties
to set extents
* added material color controller import and export (request and test files by
Alphax)
* added vis controller import and export (request and test files by Alphax)
* fixed some controller imports in case controller block had no data
* improved Fallout 3 skeleton.nif import
* fixed bhkCapsuleShape export with identical points by converting it to a
bhkSphereShape (reported by ghostwalker71)
* warn if mopp is exported for non-static objects, as these may not function
properly in-game (reported by mc.crab)
* added option to use NiBSAnimationNode when exporting animated branches for
Morrowind (suggested and tested by TheDaywalker)
Version 2.5.2 (20 Feb 2010)
* configurable game paths for test suite
* fixed display of alpha channel in textured faces (reported by vurt2, fixed
by Alphax)
* weight squash script can now limit the number of bone influences per
vertex (requested by Growlf)
* disabling combine shapes import option results in xbase_anim type nifs to
import clothing slots as bones (fixes transform issue reported by Arcimaestro
Anteres)
* added regression test and workaround for duplicate shape keys during import:
only the first is read, and duplicates are ignored (e.g. Fallout 3
skeleton.nif HeadAnims:0)
* added regression test and workaround for corrupt translation keys in
Fallout 3 interpolators (e.g. Fallout 3 h2haim.kf, reported by Malo)
* added experimental .kf export for Freedom Force and Freedom Force vs. the
3rd Reich
* fixed interpolator bug with bhkBlendControllers when exporting kf files for
creatures with bones that have havok blocks attached (reported by Spiderpig)
* added alpha controller import; export was already implemented (requested
and test files provided by Alphax)
* fixes/improvements to animation import and export
- full support for import/export of animation priority
- autoset target name to bip02 if the armature has such a bone
- new option to manually set the target name on export
- new option to bulk set the animation priority
- skip NiBSplineInterpolators on import; not fully supported and
if not skipping was causing a fatal error
* fix for bhkNiTriStripsShape import
* added experimental import and export of Empire Earth II meshes
* fixed bhkCapsuleShape import with identical points (reported by
ghostwalker71)
Version 2.5.1 (10 Jan 2010)
* updated for pyffi 2.1.0
* fixed stencil property export for Fallout 3
* Morrowind bounding box import and export
* import and export, via object properties per object, of havok object
- material
- collision layer
- motion quality
- motion system
- mass
- col filter
* import and export, via object properties per object, of havok constraint
- min angle
- max angle
- friction
* object rotation animation import bugfix (reported by Arcimaestro Anteres,
fixes for instance Morrowind animated creature imports)
* fix for Fallout 3 NiGeomMorpherController (shape key) export (reported by
Bleolakri)
* pep8 fixes
* installer detects Python 64 bit, and complains about it
* increased resolution of vertex coordinates to 1/1000 (from 1/200) on import
and export (fixes issue #2925044 reported by EuGENIUS).
* added support for Atlantica and Howling Sword import and export
Version 2.5.0 (22 Nov 2009)
* attempt to fix invalid matrices in bone extra text buffer rather than
raising a mysterious exception (reported by PacificMorrowind)
* import and export Oblivion morph controller animation data (reported by
LHammonds, addition testing and bug reports by PacificMorrowind)
* import extra nodes as empties
* extra nodes are now imported by default (suggested by PacificMorrowind)
* various object animation import and export fixes (reported by LHammonds and
Tijer)
* enable flattening skin in the export gui when 'geometry only' is selected,
for Oblivion and Fallout 3 (contributed by PacificMorrowind)
* civ4 and Sid Meier's Railroads NiNode and NiTriShape flags are now set to
16 (reported by Tijer)
* on import, set alpha to 0.0 if NiAlphaProperty is present (so it gets
re-exported) even if no textures with alpha channel are found; this fixes an
issue with Sid Meier's Railroads (reported by Tijer)
* export NiAlphaProperty threshold 150 for Sid Meier's Railroads (reported by
Tijer)
* export RRT_NormalMap_Spec_Env_CubeLight shader for Sid Meier's Railroads
(reported by Tijer)
* force TSpace flag to be 16 for Sid Meier's Railroads and Fallout 3 (reported
by Tijer and Miaximus)
* fixed windows installer & installer scripts to install to the dirs currently
expected by blender (contributed by PacificMorrowind)
* import and export egm morphs (with aid of Scanti and Carver13)
* added new experimental "morph copy" script (under scripts->mesh)
* stitch strips for Fallout 3 by default (reported by Miaximus)
* fixed texture path bug (reported by elitewolverine)
Modified Paths:
--------------
tags/2_49_bundle/py/scripts/bpymodules/nif_common.py
tags/2_49_bundle/py/scripts/export/export_nif.py
tags/2_49_bundle/py/scripts/import/import_nif.py
tags/2_49_bundle/py/scripts/mesh/mesh_niftools_hull.py
tags/2_49_bundle/py/scripts/mesh/mesh_niftools_weightsquash.py
tags/2_49_bundle/py/scripts/object/object_niftools_load_bone_pose.py
tags/2_49_bundle/py/scripts/object/object_niftools_save_bone_pose.py
tags/2_49_bundle/py/scripts/object/object_niftools_set_bone_priority.py
Added Paths:
-----------
tags/2_49_bundle/py/scripts/mesh/mesh_niftools_morphcopy.py
Modified: tags/2_49_bundle/py/scripts/bpymodules/nif_common.py
===================================================================
--- tags/2_49_bundle/py/scripts/bpymodules/nif_common.py 2010-03-28 11:16:20 UTC (rev 524)
+++ tags/2_49_bundle/py/scripts/bpymodules/nif_common.py 2010-03-28 11:16:34 UTC (rev 525)
@@ -1,14 +1,14 @@
"""Common functions for the Blender nif import and export scripts."""
-__version__ = "2.4.12"
-__requiredpyffiversion__ = "2.0.2"
+__version__ = "2.5.4"
+__requiredpyffiversion__ = "2.1.4"
__requiredblenderversion__ = "245"
# ***** BEGIN LICENSE BLOCK *****
#
# BSD License
#
-# Copyright (c) 2005-2009, NIF File Format Library and Tools
+# Copyright (c) 2005-2010, NIF File Format Library and Tools
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -53,11 +53,11 @@
__blenderversion__ = Blender.Get('version')
if cmp_versions(__blenderversion__, __requiredblenderversion__) == -1:
- print("""--------------------------
-ERROR\nThis script requires Blender %s or higher.
-It seems that you have an older version installed (%s).
-Get a newer version at http://www.blender.org/
---------------------------"""%(__requiredblenderversion__, __blenderversion__))
+ print("--------------------------"
+ "ERROR\nThis script requires Blender %s or higher."
+ "It seems that you have an older version installed (%s)."
+ "Get a newer version at http://www.blender.org/"
+ "--------------------------"%(__requiredblenderversion__, __blenderversion__))
Blender.Draw.PupMenu("ERROR%t|Blender outdated, check console for details")
raise ImportError
@@ -65,33 +65,40 @@
try:
from pyffi import __version__ as __pyffiversion__
- from pyffi.formats.nif import NifFormat
except ImportError:
- print("""--------------------------
-ERROR\nThis script requires the Python File Format Interface (PyFFI).
-Make sure that PyFFI resides in your Python path or in your Blender scripts folder.
-If you do not have it: http://pyffi.sourceforge.net/
---------------------------""")
+ print("--------------------------"
+ "ERROR\nThis script requires the Python File Format Interface (PyFFI)."
+ "Make sure that PyFFI resides in your Python path or in your Blender scripts folder."
+ "If you do not have it: http://pyffi.sourceforge.net/"
+ "--------------------------")
Blender.Draw.PupMenu("ERROR%t|PyFFI not found, check console for details")
raise
# check PyFFI version
if cmp_versions(__pyffiversion__, __requiredpyffiversion__) == -1:
- print("""--------------------------
-ERROR\nThis script requires Python File Format Interface %s or higher.
-It seems that you have an older version installed (%s).
-Get a newer version at http://pyffi.sourceforge.net/
---------------------------"""%(__requiredpyffiversion__, __pyffiversion__))
+ print("--------------------------"
+ "ERROR\nThis script requires Python File Format Interface %s or higher."
+ "It seems that you have an older version installed (%s)."
+ "Get a newer version at http://pyffi.sourceforge.net/"
+ "--------------------------"""
+ %(__requiredpyffiversion__, __pyffiversion__))
Blender.Draw.PupMenu("ERROR%t|PyFFI outdated, check console for details")
raise ImportError
+# import PyFFI format classes
+
+from pyffi.formats.nif import NifFormat
+from pyffi.formats.egm import EgmFormat
+
+# other imports
+
from Blender import Draw, Registry
import logging
import sys
import os
-def initLoggers():
+def init_loggers():
"""Set up loggers."""
niftoolslogger = logging.getLogger("niftools")
niftoolslogger.setLevel(logging.WARNING)
@@ -105,12 +112,17 @@
pyffilogger.addHandler(loghandler)
# set up the loggers: call it as a function to avoid polluting namespace
-initLoggers()
+init_loggers()
class NifImportExport:
"""Abstract base class for import and export. Contains utility functions
that are commonly used in both import and export."""
+ VERTEX_RESOLUTION = 1000
+ NORMAL_RESOLUTION = 100
+ UV_RESOLUTION = 10000
+ VCOL_RESOLUTION = 100
+
EXTRA_SHADER_TEXTURES = [
"EnvironmentMapIndex",
"NormalMapIndex",
@@ -127,7 +139,61 @@
"Civilization IV": (3, 0, 1, 2)}
"""The default ordering of the extra data blocks for different games."""
- def getBoneNameForBlender(self, name):
+ # Oblivion(and FO3) collision settings dicts for Anglicized names
+ # on Object Properties for havok items
+ OB_LAYER = [
+ "Unidentified", "Static", "AnimStatic", "Transparent", "Clutter",
+ "Weapon", "Projectile", "Spell", "Biped", "Props",
+ "Water", "Trigger", "Terrain", "Trap", "NonCollidable",
+ "CloudTrap", "Ground", "Portal", "Stairs", "CharController",
+ "AvoidBox", "?", "?", "CameraPick", "ItemPick",
+ "LineOfSight", "PathPick", "CustomPick1", "CustomPick2", "SpellExplosion",
+ "DroppingPick", "Other", "Head", "Body", "Spine1",
+ "Spine2", "LUpperArm", "LForeArm", "LHand", "LThigh",
+ "LCalf", "LFoot", "RUpperArm", "RForeArm", "RHand",
+ "RThigh", "RCalf", "RFoot", "Tail", "SideWeapon",
+ "Shield", "Quiver", "BackWeapon", "BackWeapon?", "PonyTail",
+ "Wing", "Null"]
+
+ MOTION_SYS = [
+ "Invalid", "Dynamic", "Sphere", "Sphere Inertia", "Box",
+ "Box Stabilized", "Keyframed", "Fixed", "Thin BOx", "Character"]
+
+ HAVOK_MATERIAL = [
+ "Stone", "Cloth", "Dirt", "Glass", "Grass",
+ "Metal", "Organic", "Skin", "Water", "Wood",
+ "Heavy Stone", "Heavy Metal", "Heavy Wood", "Chain", "Snow",
+ "Stone Stairs", "Cloth Stairs", "Dirt Stairs", "Glass Stairs", "Metal Stairs",
+ "Organic Stairs", "Skin Stairs", "Water Stairs", "Wood Stairs", "Heavy Stone Stairs",
+ "Heavy Metal Stairs" "Heavy Wood Stairs", "Chain Stairs", "Snow Stairs", "Elevator"]
+
+ QUALITY_TYPE = [
+ "Invalid", "Fixed", "Keyframed", "Debris", "Moving",
+ "Critical", "Bullet", "User", "Character", "Keyframed Report"]
+
+ progress_bar = 0
+ """Level of the progress bar."""
+
+ def msg_progress(self, message, progbar=None):
+ """Message wrapper for the Blender progress bar."""
+ # update progress bar level
+ if progbar is None:
+ if self.progress_bar > 0.89:
+ # reset progress bar
+ self.progress_bar = 0
+ Blender.Window.DrawProgressBar(0, message)
+ self.progress_bar += 0.1
+ else:
+ self.progress_bar = progbar
+ # draw the progress bar
+ Blender.Window.DrawProgressBar(self.progress_bar, message)
+
+ def get_b_children(self, b_obj):
+ """Return children of a blender object."""
+ return [child for child in Blender.Object.Get()
+ if child.parent == b_obj]
+
+ def get_bone_name_for_blender(self, name):
"""Convert a bone name to a name that can be used by Blender: turns
'Bip01 R xxx' into 'Bip01 xxx.R', and similar for L.
@@ -142,7 +208,7 @@
return "Bip01 " + name[8:] + ".R"
return name
- def getBoneNameForNif(self, name):
+ def get_bone_name_for_nif(self, name):
"""Convert a bone name to a name that can be used by the nif file:
turns 'Bip01 xxx.R' into 'Bip01 R xxx', and similar for L.
@@ -178,6 +244,73 @@
"Unsupported extend type in blend, using clamped.")
return 4
+ def get_b_ipol_from_n_ipol(self, n_ipol):
+ if n_ipol == NifFormat.KeyType.LINEAR_KEY:
+ return Blender.IpoCurve.InterpTypes.LINEAR
+ elif n_ipol == NifFormat.KeyType.QUADRATIC_KEY:
+ return Blender.IpoCurve.InterpTypes.BEZIER
+ elif n_ipol == 0:
+ # guessing, not documented in nif.xml
+ return Blender.IpoCurve.InterpTypes.CONST
+
+ self.logger.warning(
+ "Unsupported interpolation mode in nif, using quadratic/bezier.")
+ return Blender.IpoCurve.InterpTypes.BEZIER
+
+ def get_n_ipol_from_b_ipol(self, b_ipol):
+ if b_ipol == Blender.IpoCurve.InterpTypes.LINEAR:
+ return NifFormat.KeyType.LINEAR_KEY
+ elif b_ipol == Blender.IpoCurve.InterpTypes.BEZIER:
+ return NifFormat.KeyType.QUADRATIC_KEY
+ elif b_ipol == Blender.IpoCurve.InterpTypes.CONST:
+ # guessing, not documented in nif.xml
+ return 0
+
+ self.logger.warning(
+ "Unsupported interpolation mode in blend, using quadratic/bezier.")
+ return NifFormat.KeyType.QUADRATIC_KEY
+
+ def find_controller(self, niBlock, controller_type):
+ """Find a controller."""
+ ctrl = niBlock.controller
+ while ctrl:
+ if isinstance(ctrl, controller_type):
+ break
+ ctrl = ctrl.next_controller
+ return ctrl
+
+ def find_property(self, niBlock, property_type):
+ """Find a property."""
+ for prop in niBlock.properties:
+ if isinstance(prop, property_type):
+ return prop
+ return None
+
+ def find_extra(self, niBlock, extratype):
+ """Find extra data."""
+ # pre-10.x.x.x system: extra data chain
+ extra = niBlock.extra_data
+ while extra:
+ if isinstance(extra, extratype):
+ break
+ extra = extra.next_extra_data
+ if extra:
+ return extra
+
+ # post-10.x.x.x system: extra data list
+ for extra in niBlock.extra_data_list:
+ if isinstance(extra, extratype):
+ return extra
+ return None
+
+ def isinstance_blender_object(self, b_obj):
+ """Unfortunately, isinstance(b_obj, Blender.Object.Object) does not
+ work because the Object class is not exposed in the API.
+ This method provides an alternative check.
+ """
+ # lame and slow, but functional
+ return b_obj in Blender.Object.Get()
+
class NifConfig:
"""Class which handles configuration of nif import and export in Blender.
@@ -216,7 +349,11 @@
LOG_LEVEL = logging.WARNING, # log level
IMPORT_SKELETON = 0, # 0 = normal import, 1 = import file as skeleton, 2 = import mesh and attach to skeleton
IMPORT_KEYFRAMEFILE = '', # keyframe file for animations
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list