Difference between revisions of "Arcane University:CK-CMD for Skyrim"

The Beyond Skyrim Wiki — Hosted by UESP
Jump to: navigation, search
(bugs are fixed in 1.0.279)
(reorganized, removing rig exporting since it has its own page)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''CK-CMD''' is a command prompt application that can convert fbx files into nif files for use in appropriate game engines. This makes it software-agnostic unlike most exporter plugin solutions, and it is not easily affected by version changes in the modeling software used for exporting the fbx. Essentially, it makes it possible to export a finished asset as an fbx from nearly any modeling software, and create a nif file that is 95% ready for game import with only one command.
+
'''CK-CMD''' is a command prompt application that can convert between fbx and [[Arcane_University:NIF_Data_Format|NIF]] files, and generate behavior files for animations. This makes it software-agnostic, unlike most nif conversion methods, and thus not as affected by changes in the modeling software. CK-CMD makes it possible to export a finished asset as an fbx from nearly any modeling software, and create a nif file that is 95% ready for game import with only one command.
  
 
It properly transfers vertex coloring to nif files from an fbx, and materials settings and paths are translated from modeling software to BSLightingShaderProperty nodes. It also applies all necessary strings, flags, and values in the resulting nif. Visual adjustments may be desired through [[AU:Nifskope for Skyrim|NifSkope]], but if properly prepared, the resulting nif is game-ready.
 
It properly transfers vertex coloring to nif files from an fbx, and materials settings and paths are translated from modeling software to BSLightingShaderProperty nodes. It also applies all necessary strings, flags, and values in the resulting nif. Visual adjustments may be desired through [[AU:Nifskope for Skyrim|NifSkope]], but if properly prepared, the resulting nif is game-ready.
  
==Download Links==
+
==Download==
* The full description and documentation are at https://github.com/aerisarn/ck-cmd.
+
* [https://github.com/aerisarn/ck-cmd ck-cmd on GitHub]: Download the latest ck-cmd.zip from the releases (ck-gui is a related but different program).
* You can download the most recent working build of CK-CMD at  https://ci.appveyor.com/project/aerisarn/ck-cmd/branch/master/artifacts, however CK-CMD is still in active development so there might not always ''be'' a working build.
 
* You can download an older working build here: [[File:CK-CMD-Mar2020.zip]].
 
  
 
==System Preparations==
 
==System Preparations==
Line 17: Line 15:
 
Ensure all faces have the intended materials applied, as ck-cmd will create BSLightingShaderProperty nodes with any applicable materials in the FBX. Note that some material shaders do not translate correctly to  BSLightingShaderProperty nodes, so check this first if the generated BSLightingShaderProperty nodes have issues. Standard blinn materials are recommended. The application will also use the same file paths as your 3D software’s material shaders, meaning that if you set up materials with the textures already in their proper end-user location in \Data\Textures, you may not need to change the paths in the nif later.
 
Ensure all faces have the intended materials applied, as ck-cmd will create BSLightingShaderProperty nodes with any applicable materials in the FBX. Note that some material shaders do not translate correctly to  BSLightingShaderProperty nodes, so check this first if the generated BSLightingShaderProperty nodes have issues. Standard blinn materials are recommended. The application will also use the same file paths as your 3D software’s material shaders, meaning that if you set up materials with the textures already in their proper end-user location in \Data\Textures, you may not need to change the paths in the nif later.
  
Contrary to the documentation on github, assets should '''not''' be combined into a single object, as ck-cmd currently has a bug that creates many duplicate vertices in this function. Instead, separate the object by material. The name of your mesh or submeshes in your software’s outliner (or specific term for object heirarchy) will be used to create strings in the nif. The other usual pre-export checks apply (freeze any transformations, check pivot/origin, apply any modifiers, etc). The application will properly transfer any vertex coloring to the resulting nif. (Note however that in some modeling software, using vertex colors on some nodes but not otherwise leads to strange results when converted. Consequently, you may need to flood your model with the default white color before vertex painting shadow areas.) If your nif is to include a [[AU:Mesh Collisions|collision mesh]], the same pre-export checks apply (see [[#Including Collision|below]] for further details).
+
Contrary to the documentation on github, assets should '''not''' be combined into a single object, as ck-cmd currently has a bug that creates many duplicate vertices in this function. Instead, separate the object by material. The name of your mesh or submeshes in your software’s outliner (or specific term for object heirarchy) will be used to create strings in the nif. The other usual pre-export checks apply (freeze any transformations, check pivot/origin, apply any modifiers, etc). The application will properly transfer any vertex coloring to the resulting nif. (Note however that in some modeling software, using vertex colors on some nodes but not otherwise leads to strange results when converted. Consequently, you may need to flood your model with the default white color before vertex painting shadow areas.) If your nif is to include a [[AU:Mesh Collisions|collision mesh]], the same pre-export checks apply (see [[#Collision|below]] for further details).
  
===Animations===
+
===Scale===
{{main|[[AU:Exporting animated statics using ck-cmd|Exporting animated statics using ck-cmd]]}}
+
Different modeling software will have different default settings for the meaning of one measurement unit. When your asset is correctly scaled for its intended in-game size in comparison to the grid or even other exported Skyrim assets, it may import into Nifskope with a different per-unit measurement, and the engine reading the nif could interpret an intended scale of five meters as five centimeters, or vice versa. This problem is almost always a matter of centimeters versus meters, so check this first if your asset looks about 100 times larger or smaller than intended.
 
 
It is usually not necessary to flip or change export settings to compensate for Z-up vs Y-up modeling software. However, animations that use rotation may require proper export settings. Skyrim usually uses Y-forward, Z-up. Additionally, if you are including translations, be sure animation simplification is disabled in the fbx export settings. If it is enabled, the animation may be lost upon export. This will leave some extraneous transform controllers in the controller sequence, but they can be removed manually without too much trouble.
 
  
==Scale Matching==
+
In Blender, setting "Apply Scaling" in the fbx export to "FBX All" is usually the safest. The units in Blender will be equivalent to Skyrim units. For example, an object 128 "meters" tall in Blender will be 128 Skyrim units after converting, which is equal to 6 feet in game.
Different modeling software will have different default settings for the meaning of one measurement unit. When your asset is correctly scaled for its intended in-game size in comparison to the grid or even other exported Skyrim assets, it may import into Nifskope with a different per-unit measurement, and the engine reading the nif could interpret an intended scale of five meters as five centimeters, or vice versa. This problem is almost always a matter of centimeters versus meters, so check this first if your asset looks about 100 times larger or smaller than intended.
 
  
In Blender, setting "Apply Scaling" in the fbx export to "FBX All" is usually the safest. In Maya, it is necessary to set the scale of the grid to meters, instead of the default centimeters, then export the fbx with the Units dropdown changed to no automatic scaling, and file units converted to centimeters. This is a matter of Maya to game engine workflow, not specific to ck-cmd.
+
In Maya, it is necessary to set the scale of the grid to meters, instead of the default centimeters, then export the fbx with the Units dropdown changed to no automatic scaling, and file units converted to centimeters. This is a matter of Maya to game engine workflow, not specific to ck-cmd.
  
==Including Collision==
+
===Collision===
[[File:ck-cmd collision hierarchy.png|thumb|right|An example collision hierarchy in Blender 2.92]]
+
[[File:ck-cmd collision hierarchy.png|thumb|right|An example collision hierarchy in Blender]]
 
To include a [[AU:Mesh Collisions|collision mesh]], arrange your outliner/hierarchy as shown in the figure at right before exporting it all as a single FBX.
 
To include a [[AU:Mesh Collisions|collision mesh]], arrange your outliner/hierarchy as shown in the figure at right before exporting it all as a single FBX.
  
In this example using Blender 2.92, 'Scene_rb_mopp_mesh' is the collision object, contained within a hierarchy of empty objects. Note that the name of the material is 'SKY_HAV_MAT_STONE', which will be interpreted as the collision material. Multiple materials on the collision mesh will be interpreted as multiple collision materials (stone, wood, stairs, etc).
+
In this example using Blender, 'Scene_rb_mopp_mesh' is the collision object, contained within a hierarchy of empty objects. Note that the name of the material is 'SKY_HAV_MAT_STONE', which will be interpreted as the collision material. Multiple materials on the collision mesh will be interpreted as multiple collision materials (stone, wood, stairs, etc).
 +
 
 +
===Animated statics===
 +
{{main|[[AU:Exporting animated statics using ck-cmd|Exporting animated statics using ck-cmd]]}}
 +
 
 +
It is usually not necessary to flip or change export settings to compensate for Z-up vs Y-up modeling software. However, animations that use rotation may require proper export settings. Skyrim usually uses Y-forward, Z-up. Additionally, if you are including translations, be sure animation simplification is disabled in the fbx export settings. If it is enabled, the animation may be lost upon export. This will leave some extraneous transform controllers in the controller sequence, but they can be removed manually without too much trouble.
  
 
==Converting FBX to NIF==
 
==Converting FBX to NIF==
 
Open the command prompt.
 
Open the command prompt.
 
Navigate to CK-Cmd’s location.
 
Navigate to CK-Cmd’s location.
Use the command: ck-cmd.exe importfbx (full input path\Example.fbx) -e (full output path)
+
Use the command:
 +
ck-cmd.exe importfbx (full input path\Example.fbx) -e (full output path)
 
Wait for the process to finish.
 
Wait for the process to finish.
 
Open the resulting nif in [[AU:Nifskope for Skyrim|NifSkope]] for inspection. It is generated in the output location with the same name as the fbx file originally used for input.
 
Open the resulting nif in [[AU:Nifskope for Skyrim|NifSkope]] for inspection. It is generated in the output location with the same name as the fbx file originally used for input.
  
[https://www.youtube.com/watch?v=3f_9evNUiGU CK-CMD FBX to NIF Video Tutorial] by Thog
+
Video tutorial: [https://www.youtube.com/watch?v=3f_9evNUiGU CK-CMD FBX to NIF] by Thog
  
 
==Adjustments in NifSkope==
 
==Adjustments in NifSkope==
 
Ck-cmd should have created a nif file with all basic setup complete, such as strings, [[AU:NIF Data Format#BSXFlags node|BSX flags]], collision meshes, etc. It should have also approximated your material shader settings in the resulting BSLightingShaderProperty nodes. If your asset appears untextured (bright magenta in color), you will need to direct NifSkope to the proper texture paths. You will still need to adjust visuals via BSLightingShaderProperty settings that are not present in your default modeling software’s materials, such as the global glossiness value, switching [[AU:NIF Data Format#Shader Types|shader types]], adding shader flags such as emission or environment mapping, etc, as well as other arbitrary settings in the nif, such as audio material settings.
 
Ck-cmd should have created a nif file with all basic setup complete, such as strings, [[AU:NIF Data Format#BSXFlags node|BSX flags]], collision meshes, etc. It should have also approximated your material shader settings in the resulting BSLightingShaderProperty nodes. If your asset appears untextured (bright magenta in color), you will need to direct NifSkope to the proper texture paths. You will still need to adjust visuals via BSLightingShaderProperty settings that are not present in your default modeling software’s materials, such as the global glossiness value, switching [[AU:NIF Data Format#Shader Types|shader types]], adding shader flags such as emission or environment mapping, etc, as well as other arbitrary settings in the nif, such as audio material settings.
  
==Building from Source==
+
==Actor/creature animations==
Requires CMake to be built.
+
{{main|[[AU:Implementation of Custom Animations|Implementation of Custom Animations]]}}
 
+
Another of ck-cmd's functions is creating custom animations for actors. This can be used to replace animations of vanilla npcs or creatures, or add new animations by editing the behavior files. ck-cmd can also be used to create entirely new actor rigs with custom animations.
Cloning the repo
 
git clone https://github.com/aerisarn/ck-cmd.git ck-cmd
 
cd ck-cmd
 
Downloading modules:
 
git submodule update --init --recursive
 
Downloading libraries:
 
Put all the libraries into rootDir/lib The required libraries are:
 
 
 
bsa : GitHub
 
DirectXTex : GitHub
 
fbx : GitHub
 
loadorder :
 
loki : Website
 
nif : GitHub
 
xedit : GitHub
 
zlib : GitHub
 
The expected file structure is here.
 
 
 
Running CMake:
 
mkdir build
 
cd build
 
cmake -G "Visual Studio 15 2017" -A Win32 ..
 
Then use Visual studio to build the generated ck-cmd solutions (ck-cmd.sln)
 
 
 
==Exporting vanilla animations from Skyrim with ck-cmd==
 
Transcribed by URL#8070 (discord) / @urlknight (twitter). Pictures and initial info from aerisarn#8437 (discord) Last updated 8/16/2020
 
 
 
===Intro===
 
This tutorial will tell you how to export rigs from Skyrim with root motion intact, using ck-cmd. This is not a tutorial about importing rigs into Skyrim, which is more complex.
 
 
 
Tools Needed
 
*Skyrim LE
 
*Skyrim BSA Extractor
 
*ck-cmd
 
 
 
Extract the Animation BSAs; Navigate to your Skyrim LE Data folder (Important: anything from Skyrim SSE can NOT be used) and find “Skyrim - Animations.bsa”. Open the BSA Extractor and drop the Animations BSA in there. If you want to see meshes/skins too, you’ll have to extract the Meshes01.bsa as well. Using the BSA Extractor is pretty straightforward.
 
 
 
===The exporting command===
 
(picture missing)
 
You will use this command to export an animated rig. Pick a creature folder from your Skyrim LE extracted animation bsa. Here’s an example path for if we were to use the dragon:
 
 
 
D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.hkx
 
 
 
(picture missing)
 
So, the command would be ck-cmd exportrig “D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.hkx”
 
 
 
ck-cmd will read that file and output a skeleton fbx, which you can import into a 3d program like Blender.
 
 
 
(picture missing)
 
If you want to also have the physics and the ragdoll, add the path to the mesh’s bsa skeleton nif.
 
(picture missing)
 
So, ck-cmd exportrig “D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.hkx” “D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.nif”
 
 
 
You will get this:
 
(picture missing)
 
Yellow capsules are the single element of the ragdoll. The other capsules are collision areas that generate events for the behavior. The big red box is the creature Creation Kit collision, which is used to see if it will fit through stuff and how much space it takes in the CK.
 
 
 
If we want the skeletal animation exported with some animations, we can add the --a parameter with a folder containing the vanilla animations.
 
 
 
(picture missing)
 
ck-cmd exportrig “D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.hkx” --a=”D:\git\resources\in\havok_bin\meshes\actors\dragon\animations”
 
 
 
This will batch convert all of the animation .hkx inside that folder.
 
 
 
If you want the mesh added to that, you can use the --n parameter with a folder. (Note: all of the nifs in that folder will be added to the scene) The mesh nif should also come from the extracted meshes BSA.
 
(picture missing)
 
ck-cmd exportrig “D:\git\resources\in\havok_bin\meshes\actors\dragon\character assets\skeleton.hkx” --a=”D:\git\resources\in\havok_bin\meshes\actors\dragon\animations” --n=”D:\git\resources\in\skyrim\meshes\actors\alduin\temp”
 
(picture missing)
 
Creatures actually have root motion and behavior events embedded inside an animation. To export that from the game, two more parameters are necessary- the path to the animation cache, and the one to the behavior file, --c and --b.
 
 
 
The animation cache is in meshes/animationdata. In this case, it’s better seen using a walking creature, like the draugr.
 
(picture missing)
 
Adding --c="D:\git\resources\in\havok_bin\meshes\animationdata\draugrproject.txt" --b="D:\git\resources\in\havok_bin\meshes\actors\draugr\behaviors"
 
 
 
Gives us FBX animations with root movement, which we can view in a 3d program.
 
  
 
==Known Bugs==
 
==Known Bugs==
 
*'''FBX -> Nif'''
 
*'''FBX -> Nif'''
 
**While ck-cmd can automatically separate objects with multiple materials on export, it duplicates many vertices in the process. Instead, simply separate each object by material before export.
 
**While ck-cmd can automatically separate objects with multiple materials on export, it duplicates many vertices in the process. Instead, simply separate each object by material before export.
 +
 +
==Links==
 +
* [https://github.com/aerisarn/ck-cmd ck-cmd on GitHub]
  
 
[[Category:Arcane University-3D Art-Mesh Export to NIF]] [[Category:Arcane University-Animation]]
 
[[Category:Arcane University-3D Art-Mesh Export to NIF]] [[Category:Arcane University-Animation]]

Latest revision as of 17:08, 20 October 2022

CK-CMD is a command prompt application that can convert between fbx and NIF files, and generate behavior files for animations. This makes it software-agnostic, unlike most nif conversion methods, and thus not as affected by changes in the modeling software. CK-CMD makes it possible to export a finished asset as an fbx from nearly any modeling software, and create a nif file that is 95% ready for game import with only one command.

It properly transfers vertex coloring to nif files from an fbx, and materials settings and paths are translated from modeling software to BSLightingShaderProperty nodes. It also applies all necessary strings, flags, and values in the resulting nif. Visual adjustments may be desired through NifSkope, but if properly prepared, the resulting nif is game-ready.

Download[edit]

  • ck-cmd on GitHub: Download the latest ck-cmd.zip from the releases (ck-gui is a related but different program).

System Preparations[edit]

No special considerations need to be made for where ck-cmd is located on your computer, but commands include file paths, so it may be advisable to place it somewhere with a short and simple path. It is convenient to create a common folder for fbx input and nif output, as in the example: D:\CK-CMD > Input > Output\

Model Preparations[edit]

Ensure all faces have the intended materials applied, as ck-cmd will create BSLightingShaderProperty nodes with any applicable materials in the FBX. Note that some material shaders do not translate correctly to BSLightingShaderProperty nodes, so check this first if the generated BSLightingShaderProperty nodes have issues. Standard blinn materials are recommended. The application will also use the same file paths as your 3D software’s material shaders, meaning that if you set up materials with the textures already in their proper end-user location in \Data\Textures, you may not need to change the paths in the nif later.

Contrary to the documentation on github, assets should not be combined into a single object, as ck-cmd currently has a bug that creates many duplicate vertices in this function. Instead, separate the object by material. The name of your mesh or submeshes in your software’s outliner (or specific term for object heirarchy) will be used to create strings in the nif. The other usual pre-export checks apply (freeze any transformations, check pivot/origin, apply any modifiers, etc). The application will properly transfer any vertex coloring to the resulting nif. (Note however that in some modeling software, using vertex colors on some nodes but not otherwise leads to strange results when converted. Consequently, you may need to flood your model with the default white color before vertex painting shadow areas.) If your nif is to include a collision mesh, the same pre-export checks apply (see below for further details).

Scale[edit]

Different modeling software will have different default settings for the meaning of one measurement unit. When your asset is correctly scaled for its intended in-game size in comparison to the grid or even other exported Skyrim assets, it may import into Nifskope with a different per-unit measurement, and the engine reading the nif could interpret an intended scale of five meters as five centimeters, or vice versa. This problem is almost always a matter of centimeters versus meters, so check this first if your asset looks about 100 times larger or smaller than intended.

In Blender, setting "Apply Scaling" in the fbx export to "FBX All" is usually the safest. The units in Blender will be equivalent to Skyrim units. For example, an object 128 "meters" tall in Blender will be 128 Skyrim units after converting, which is equal to 6 feet in game.

In Maya, it is necessary to set the scale of the grid to meters, instead of the default centimeters, then export the fbx with the Units dropdown changed to no automatic scaling, and file units converted to centimeters. This is a matter of Maya to game engine workflow, not specific to ck-cmd.

Collision[edit]

An example collision hierarchy in Blender

To include a collision mesh, arrange your outliner/hierarchy as shown in the figure at right before exporting it all as a single FBX.

In this example using Blender, 'Scene_rb_mopp_mesh' is the collision object, contained within a hierarchy of empty objects. Note that the name of the material is 'SKY_HAV_MAT_STONE', which will be interpreted as the collision material. Multiple materials on the collision mesh will be interpreted as multiple collision materials (stone, wood, stairs, etc).

Animated statics[edit]

Main article: Exporting animated statics using ck-cmd

It is usually not necessary to flip or change export settings to compensate for Z-up vs Y-up modeling software. However, animations that use rotation may require proper export settings. Skyrim usually uses Y-forward, Z-up. Additionally, if you are including translations, be sure animation simplification is disabled in the fbx export settings. If it is enabled, the animation may be lost upon export. This will leave some extraneous transform controllers in the controller sequence, but they can be removed manually without too much trouble.

Converting FBX to NIF[edit]

Open the command prompt. Navigate to CK-Cmd’s location. Use the command:

ck-cmd.exe importfbx (full input path\Example.fbx) -e (full output path)

Wait for the process to finish. Open the resulting nif in NifSkope for inspection. It is generated in the output location with the same name as the fbx file originally used for input.

Video tutorial: CK-CMD FBX to NIF by Thog

Adjustments in NifSkope[edit]

Ck-cmd should have created a nif file with all basic setup complete, such as strings, BSX flags, collision meshes, etc. It should have also approximated your material shader settings in the resulting BSLightingShaderProperty nodes. If your asset appears untextured (bright magenta in color), you will need to direct NifSkope to the proper texture paths. You will still need to adjust visuals via BSLightingShaderProperty settings that are not present in your default modeling software’s materials, such as the global glossiness value, switching shader types, adding shader flags such as emission or environment mapping, etc, as well as other arbitrary settings in the nif, such as audio material settings.

Actor/creature animations[edit]

Main article: Implementation of Custom Animations

Another of ck-cmd's functions is creating custom animations for actors. This can be used to replace animations of vanilla npcs or creatures, or add new animations by editing the behavior files. ck-cmd can also be used to create entirely new actor rigs with custom animations.

Known Bugs[edit]

  • FBX -> Nif
    • While ck-cmd can automatically separate objects with multiple materials on export, it duplicates many vertices in the process. Instead, simply separate each object by material before export.

Links[edit]