Skip to content

Commit 89cfac0

Browse files
authored
Merge pull request #461 from niftools/release/v0.0.9
Release/v0.0.9
2 parents 44770d3 + f60dc96 commit 89cfac0

20 files changed

Lines changed: 408 additions & 179 deletions

File tree

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ Version v0.0.9
22
==============
33

44
- #446 Updates to normal and tangent import/export
5+
Export of normals now respects edges that are marked sharp.
6+
Vertices with different UV coordinates get different tangents on export.
7+
Export now uses Blender tangents instead of pyffi tangent generation.
8+
Nif vertex normals are now imported correctly when dealing with non-normalized normals (i.e. not length 1).
9+
When exporting a skinned mesh that uses partitions, that has faces without partitions, the correct faces are now selected.
10+
The normal map Y channel is now inverted when creating a shader on import.
11+
The selection for collision layer now depends on the game.
12+
A NONE game as the default in the scene tab.
13+
Unresolved texture paths are now stored as they are found in the nif file, meaning they remain functional upon re-export.
14+
Body parts use face maps rather than vertex groups.
15+
516
- #444 Some polygons of "...." not assigned to any body part.The unassigned polygons have been selected in the mesh so they can easily be identified.
617
- #449 Error while export, Game not set
718

docs/development/api/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Contents:
1616
User Interface
1717
--------------
1818

19-
* The user first activates the addon via **File** > **User Preferences** > **Addons**.
19+
* The user first activates the addon via **Edit** > **Preferences** > **Addons**.
2020

2121
.. note::
2222

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.. _development-design-decisions:
2+
3+
################
4+
Design Decisions
5+
################
6+
7+
.. _development-design-decisions-geometrydata:
8+
9+
*************
10+
Geometry Data
11+
*************
12+
13+
.. _development-design-decisions-geometrydata-tangents:
14+
15+
Tangents
16+
========
17+
18+
Tangents and bitangents are exported from Blender's tangents. This has two caveats:
19+
* These are not the exact same as those of vanilla (Skyrim) assets.
20+
* These tangents will only work completely correctly with normal maps that were generated with those tangents.
21+
The first point is because we do not yet know by which method the vanilla tangents were generated. It is possible
22+
that the generation method differs per model, and that there is no method which matches all vanilla models.
23+
24+
The second point is true for all tangent space normal maps. For more information on normal maps, see
25+
`http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Tangent_Basis the polycount page`_. For information on how
26+
the tangents get used in calculating surface direction, see
27+
`http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/ the OpenGL tutorial`_. The main
28+
characteristics that need to be the same between the renderer (the game) and the normal map baking software are:
29+
* The tangent direction
30+
* Whether the bitangent is calculated per-vertex or per-pixel (see
31+
`https://bgolus.medium.com/generating-perfect-normal-maps-for-unity-f929e673fc57#c473 this page`_).
32+
Making sure that the tangent space is the same for the baker as it is in the nif is done by exporting a common
33+
tangent space. The tangents from Blender are from `http://www.mikktspace.com/ MikkTSpace`_. This standard tangent space
34+
is also an option in xNormal and Substance.
35+
36+
Because the bitangents are stored in the nif file, it can be assumed that they are not per-pixel in-game. Whether the
37+
bitangent is calculated per-vertex or per-pixel is an option in xNormal and Substance. Blender calculates its bitangent
38+
for baking per-pixel, which means that normal maps baked in Blender will not correctly display in-game, though the
39+
difference may be minimal enough not to notice.
40+
41+
Blender tangent and bitangent to nif tangent and bitangent is not 1:1. In Blender, the tangent points in the positive U
42+
direction and the bitangent points in positive V direction (Blender texture coordinates). In nifs, tangents point in
43+
the positive V direction and bitangents point in the positive U direction (nif texture coordinates). Therefore, tangents
44+
and bitangents are swapped between Blender and nif. However, because the nif V coordinate can be calculated from the
45+
Blender V coordinate via::
46+
47+
nif_V = 1 - blender_V
48+
49+
This means that the direction for positive V coordinate is reversed. This results in the conversion as follows.::
50+
51+
nif_tangent = blender_bitangent
52+
nif_bitangent = blender_tangent

docs/user/features/armature/armature.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Armatures
55
Armature Bones
66
==============
77

8-
* The following section deals with Armatures
8+
* The following section deals with Armatures. Note that, in order for any animations to display in Blender like they
9+
would in-game, ``Preserve Volume`` must be turned off in the Armature modifier.
910

1011
.. _armature-flags:
1112

docs/user/features/geometry/geometry.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Double Sided Mesh
4747

4848
- Adds a :class:`~pyffi.formats.nif.NifFormat.NiStencilProperty` or similiar, see :ref:`Properties - Stencil Property
4949
<properties-stencil>` for more info.
50+
- For Skyrim, tick the Shader Property flag "Double Sided" in the Niftools Shader Panel.
5051

5152
.. _geometry-uv:
5253

@@ -82,14 +83,14 @@ Vertex Color & Alpha
8283
**Example:**
8384

8485
#. :ref:`Create a mesh-object <geometry-mesh>`.
85-
#. Switch to Vertex Paint mode, this automatically adds a base vertex colour layer. Make sure you name this layer 'RGBA'
86-
#. Apply the desired vertex colours evenly to the vertex.
86+
#. Switch to Vertex Paint mode, this automatically adds a base vertex color layer. Make sure you name this layer 'RGBA'
87+
#. Apply the desired vertex colors evenly to the vertex.
8788
#. You can alter the alpha channel using the 'Add Alpha' and 'Erase Alpha' brushes.
8889

8990
**Notes:**
9091

91-
* The Nif format only supports a single colour per vertex, whereas Blender vertex colour per face vertex.
92+
* The Nif format only supports a single color per vertex, whereas Blender vertex color per face vertex.
9293
* Blender treats the vertex as if the faces had been split apart, each face can have a different colour for that vertex.
9394
* `This image should clarify per-face vertex colouring
9495
<http://i211.photobucket.com/albums/bb189/NifTools/Blender/documentation/per_face_vertex_color.jpg>`_
95-
* On export, the scripts will take an average of colours.
96+
* On export, the scripts will create extra vertices for different vertex colors per face.
Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
.. _user-features-iosettings-export:
12
Export Settings
23
===============
3-
.. _user-features-iosettings-export:
44

55
This section explains the import and export settings.
66

@@ -9,26 +9,55 @@ This section explains the import and export settings.
99
This is due to the fact that they are ported directly from the old addon and as such, will functionally remain the
1010
same.
1111

12+
.. _user-features-iosettings-export-scale:
1213
Scale correction
1314
----------------
14-
.. _user-features-iosettings-export-scale:
1515

1616
This value is used to globally re-scale the Blender system of measurement units to the Nif Format units.
1717

1818
* The ratio of a Nif Units (NU) to Blender Units (BU) is 1Bu:0.1Nu. or each NU is about 10x larger than a BU.
1919
* The Blender Niftools Addon applies a default correction of 10
2020
* The default setting ensures the imported model fits into the view Blender viewport.
2121

22+
.. _user-features-iosettings-export-armature:
23+
Armature
24+
--------
25+
26+
.. _user-features-iosettings-export-flattenskin:
27+
Flatten Skin
28+
^^^^^^^^^^^^
29+
30+
This option should remove the hierarchy of the bones in the exported nif. However, it is currently not used in export.
31+
In order to flatten the hierarchy before export with Blender: Select the bones in object mode, then go into edit mode
32+
and use ``Alt+P`` to unparent the bones with the``Clear Parent`` option.
33+
34+
.. _iosettings-padnsort:
35+
Pad & Sort Bones
36+
^^^^^^^^^^^^^^^^
37+
38+
Adjusts the number of bones in a given partition to match the total number of bones used for the dismember instance.
2239

40+
.. _iosettings-maxpartitionbones:
41+
Max Partition Bones
42+
^^^^^^^^^^^^^^^^^^^
43+
44+
The maximum number of bones that a single dismember partition can use before starting a new partition.
45+
46+
.. _iosettings-maxvertexbones:
47+
Max Vertex Bones
48+
^^^^^^^^^^^^^^^^
49+
50+
The maximum number of bone weight values that can be applied to a single vertex.
51+
52+
.. _user-features-iosettings-export-game:
2353
Game
2454
----
25-
.. _user-features-iosettings-export-game:
2655

2756
A list of supported games which the addon will export working nif files.
2857

29-
Process
58+
.. _user-features-iosettings-export-animation:
59+
Animation
3060
-------
31-
.. _user-features-iosettings-export-process:
3261

3362
Determines how to export the data in the blend file.
3463

@@ -38,46 +67,37 @@ Export options include
3867
* Geometry only (nif) - Only geometry to a single nif.
3968
* Animation only (kf) - Only animation to a single kf.
4069

41-
Smooth Inter-Object Seams
42-
-------------------------
43-
.. _user-features-iosettings-export-smoothseams:
44-
45-
This option combines the normals data for all vertices containing the same XYZ location data along an edge and uses
46-
the same normal tangent and bi-tangent values for all affected vertices.
47-
48-
Use NiBSAnimationNode
49-
---------------------
5070
.. _iosettings-bsanimationnode:
71+
Use NiBSAnimationNode
72+
^^^^^^^^^^^^^^^^^^^^^
5173

5274
NiBSAnimationNode is specific to "The Elder Scrolls - Morrowind" and should only be used when exporting animated
5375
items for that game.
5476

55-
Flatten Skin
56-
------------
57-
.. _user-features-iosettings-export-flattenskin:
58-
59-
This option does something to the thing, no really it does, but I can't tell you because it's a sekret.
60-
61-
Pad & Sort Bones
62-
----------------
63-
.. _iosettings-padnsort:
64-
65-
Adjusts the number of bones in a given partition to match the total number of bones used for the dismember instance.
77+
.. _user-features-io_settings-export-optimise:
78+
Optimise
79+
--------
6680

67-
Max Partition Bones
68-
-------------------
69-
.. _iosettings-maxpartitionbones:
81+
.. _user-features-io_settings-export-stripifygeometries:
82+
Stripify Geometries
83+
^^^^^^^^^^^^^^^^^^^
7084

71-
The maximum number of bones that a single dismember partition can use before starting a new partition.
85+
Export with NiTriStrips instead of NiTriShapes.
7286

73-
Max Vertex Bones
74-
----------------
75-
.. _iosettings-maxvertexbones:
87+
.. _user-features-iosettings-export-stitchstrips:
88+
Stitch Strips
89+
^^^^^^^^^^^^^
7690

77-
The maximum number of bone weight values that can be applied to a single vertex.
91+
Whether to stitch NiTriStrips (if they are used). Important for Civilization IV.
7892

79-
Force DDS
80-
---------
8193
.. _user-features-iosettings-export-forcedds:
94+
Force DDS
95+
^^^^^^^^^
8296

8397
Changes the suffix for the texture file path in the nif to use .dds
98+
99+
.. _user-features-io_settings-export-optimisematerials:
100+
Optimise Materials
101+
^^^^^^^^^^^^^^^^^^
102+
103+
Remove duplicate materials. Currently not used.

docs/user/features/properties/shader/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ BS Effect Shader Property
246246

247247
.. Describe this type
248248
249-
Skyrim non-PP shader model, used primarily for transparency effects, often as a decal.
249+
Skyrim non-PP shader model, used primarily for transparency effects, often as a decal. Has the same shader flags as
250+
BSLightingShaderProperty.
250251

251252
+-------------------------------+---------------------------------------------------------------+
252253
| Property | Description |

io_scene_niftools/kf_export.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def execute(self):
6969
directory = os.path.dirname(NifOp.props.filepath)
7070
filebase, fileext = os.path.splitext(os.path.basename(NifOp.props.filepath))
7171

72+
if bpy.context.scene.niftools_scene.game == 'NONE':
73+
raise NifError("You have not selected a game. Please select a game in the scene tab.")
74+
7275
prefix = "x" if bpy.context.scene.niftools_scene.game in ('MORROWIND',) else ""
7376
self.version, data = scene.get_version_data()
7477
# todo[anim] - change to KfData, but create_controller() [and maybe more] has to be updated first

io_scene_niftools/modules/nif_export/collision/havok.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def export_collision_helper(self, b_obj, parent_block):
9090

9191
# linear_velocity = b_obj.rigid_body.deactivate_linear_velocity
9292
# angular_velocity = b_obj.rigid_body.deactivate_angular_velocity
93-
layer = b_obj.nifcollision.oblivion_layer
93+
layer = int(b_obj.nifcollision.collision_layer)
9494

9595
# TODO [object][collision][flags] export bsxFlags
9696
# self.export_bsx_upb_flags(b_obj, parent_block)
@@ -100,7 +100,7 @@ def export_collision_helper(self, b_obj, parent_block):
100100
# bhkCollisionObject -> bhkRigidBody
101101
if not parent_block.collision_object:
102102
# note: collision settings are taken from lowerclasschair01.nif
103-
if layer == "OL_BIPED":
103+
if layer == NifFormat.OblivionLayer.OL_BIPED:
104104
# special collision object for creatures
105105
n_col_obj = self.export_bhk_blend_collision(b_obj)
106106

@@ -135,7 +135,7 @@ def export_bhk_rigid_body(self, b_obj, n_col_obj):
135135

136136
n_r_body = block_store.create_block("bhkRigidBody", b_obj)
137137
n_col_obj.body = n_r_body
138-
n_r_body.layer = getattr(NifFormat.OblivionLayer, b_obj.nifcollision.oblivion_layer)
138+
n_r_body.layer = int(b_obj.nifcollision.collision_layer)
139139
n_r_body.col_filter = b_obj.nifcollision.col_filter
140140
n_r_body.unknown_short = 0
141141
n_r_body.unknown_int_1 = 0
@@ -185,11 +185,11 @@ def export_bhk_rigid_body(self, b_obj, n_col_obj):
185185
return n_r_body
186186

187187
def export_bhk_collison_object(self, b_obj):
188-
layer = b_obj.nifcollision.oblivion_layer
188+
layer = int(b_obj.nifcollision.collision_layer)
189189
col_filter = b_obj.nifcollision.col_filter
190190

191191
n_col_obj = block_store.create_block("bhkCollisionObject", b_obj)
192-
if layer == "OL_ANIM_STATIC" and col_filter != 128:
192+
if layer == NifFormat.OblivionLayer.OL_ANIM_STATIC and col_filter != 128:
193193
# animated collision requires flags = 41
194194
# unless it is a constrainted but not keyframed object
195195
n_col_obj.flags = 41

0 commit comments

Comments
 (0)