Difference between revisions of "User:DavidJCobb"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>DavidJCobb
(→‎Scratchpad: Creating combined statics out of individual vanilla pieces, using NifSkope and NifUtilsSuite.)
imported>DavidJCobb
(→‎Scratchpad: fixed a thing)
Line 34: Line 34:
*#* Use "mesh data" as the Collision Source, and "name of NiTriShape" as the Collision Material.
*#* Use "mesh data" as the Collision Source, and "name of NiTriShape" as the Collision Material.
* '''Common pitfalls when creating combined statics'''
* '''Common pitfalls when creating combined statics'''
** NifSkope ''does not'' appear to use the right Euler rotations for Skyrim! Skyrim uses extrinsic left-handed ZYX; NifSkope uses intrinsic and a different order. This issue both Rotation values and cameras -- rotation values won't work the same way they do in the CK, and "Front" isn't actually a front view.
** It seems that NifSkope doesn't always use the right Euler conventions for Skyrim. As such, rotation values won't work quite the same way as they do in the Creation Kit.
** NifUtilsSuite needs to be able to access NifSkope's nif.xml. If that file is in an administrator-only location (e.g. Program Files), you will need to run NifUtilsSuite as an administrator.
** NifUtilsSuite needs to be able to access NifSkope's nif.xml. If that file is in an administrator-only location (e.g. Program Files), you will need to run NifUtilsSuite as an administrator.
** NifUtilsSuite will crash if you accidentally tell it to read from a non-existent file, so maybe don't do that. Check your pathnames.
** NifUtilsSuite will crash if you accidentally tell it to read from a non-existent file, so maybe don't do that. Check your pathnames.

Revision as of 01:05, 5 February 2015

My work

Rotation library
A library for working with rotations in Skyrim. If you need to position and rotate one object relative to another, this'd be the code to do that.

Current projects

Atronach Crossing
A home decoration mod with a dual focus on customization and usability. Currently in early development. Already features many "firsts" in Skyrim, such as bookshelves that can be moved around at run-time.

Scratchpad

  • Combining multiple vanilla statics into a single NIF
    • Programs needed:
      • NifSkope
      • NifUtilsSuite
        • Make sure this is configured properly. It needs to know where NifSkope's nif.xml is, and it needs to be able to access that file.
    1. Create NifUtilsSuite template file.
      1. Pick the vanilla static whose collision is most representative of the combined static you're building. If you're adding stuff onto a building, pick the building.
      2. Extract its NIF and open it in NifSkope. Delete every block that isn't the root block, a BSXFlags, or a bhkCollisionObject.
      3. Save this stripped-down NIF.
    2. Create the merged static, minus collision.
      • You can copy and paste NiTriShapes from NIF to NIF. Paste all of your statics' NiTriShapes into a single file (under the root node).
      • You can reposition a NiTriShape by selecting it in the sidebar, and then editing its Translation and Rotation in the bottom pane.
      • You can rename a NiTriShape (to keep track of them easier) by selecting it in the sidebar, and then double-clicking the "Txt" icon shown next to the name in the bottom pane.
      • Be sure to delete all collision-related information (which should pretty much just be any bhkCollisionObject blocks).
    3. Create the merged collision mesh.
      1. Use NifUtilsSuite's ChunkExtract to rip each individual static's collision mesh as a NIF. Make sure that ChunkExtract sets NiTriShape names from the collision material.
        • NiTriShape Name: From material
      2. Use NifSkope to combine the individual collision meshes into a single mesh, similarly to how you combined statics earlier. Do not rename any NiTriShapes.
    4. Apply the merged collision mesh to the merged static using NifUtilsSuite's ChunkMerge.
      • Use the template file you created earlier.
      • Be aware that this will overwrite the input file. You should probably create a backup of your merged static.
      • Use "mesh data" as the Collision Source, and "name of NiTriShape" as the Collision Material.
  • Common pitfalls when creating combined statics
    • It seems that NifSkope doesn't always use the right Euler conventions for Skyrim. As such, rotation values won't work quite the same way as they do in the Creation Kit.
    • NifUtilsSuite needs to be able to access NifSkope's nif.xml. If that file is in an administrator-only location (e.g. Program Files), you will need to run NifUtilsSuite as an administrator.
    • NifUtilsSuite will crash if you accidentally tell it to read from a non-existent file, so maybe don't do that. Check your pathnames.

Miscellaneous tips

Code snippets

Quality? Functionality? Efficiency? Here, I guarantee nothing!!

Is an ObjectReference an item?

Works as well as is possible given the methods available to us.

Bool Function IsItem(ObjectReference akObject)
   Form akForm = akObject.GetBaseObject()
   If !akForm
      return false
   EndIf
   If akForm as Book
      ;
      ; SKSE grants read access to the Playable flag for books.
      ;
      return (akForm as Book).IsTakeable()
   EndIf
   If (akForm as Ammo) || (akForm as Armor) || (akForm as Ingredient) || (akForm as Key) || (akForm as MiscObject) || (akForm as Potion) || (akForm as Scroll) || (akForm as SoulGem) || (akForm as Weapon)
      ;
      ; Other object types don't have a script-accessible player flag. Sux.
      ;
      return true
   EndIf
   return false
EndFunction