seedhartha

TOOL:KotorBlender (for Blender 2.93+)

Recommended Posts

KotorBlender (for Blender 2.93+)


This add-on is a fork of KotorBlender, upgraded to support newer versions of Blender. KotorBlender is in turn based on NeverBlender, forked from version 1.23a.

## Features

  • Import & export MDL models, including walkmeshes
  • Import & export LYT files
  • Import & export PTH files

## Installation

  1. Clone GitHub repository or download the latest release
  2. Copy **kotorblender** folder into Blender addons directory, e.g. "C:/Users/USERNAME/AppData/Roaming/Blender Foundation/Blender/BLENDER_VERSION/scripts/addons"
  3. Enable add-on "Import-Export: KotorBlender" in Blender Preferences via Edit → Preferences → Add-ons

## Usage

### Modelling

  1. Extract MDL, MDX and, optionally, TPC, WOK, PWK, DWK, and LYT files (Kotor Tool, reone-tools, etc.)
  2. Convert TPC files to TGA/TXI (reone-tools)
  3. Import MDL into Blender via File → Import → KotOR Model (.mdl)
  4. Edit model
  5. Select a MDL root object to be exported
  6. Export MDL via File → Export → KotOR Model (.mdl)

### Lightmapping

Most of the time, it will not be possible to use vanilla lighting and UV maps to recreate lightmaps. Depending on the scene, it might be necessary to tweak or replace both.

UV mapping:

  1. Select objects having the same lightmap texture and enter Edit mode
  2. Unwrap faces via UV → Lightmap Pack (increase Margin to avoid overlapping faces)

Baking lightmaps:

  1. Select objects to bake lightmaps for
    1. If no object is selected, all objects from active collection will be used
  2. In Render Properties
    1. Set Render Engine to Cycles
    2. Set Device to GPU Compute, if available
  3. In Render Properties → KotOR Lightmaps
    1. Tweak number of Samples (higher numbers increase quality, but also increase render time)
    2. Tweak Margin
    3. Press the Bake button

Fine-tuning:

  1. In Outliner disable rendering of obstructing geometry, e.g. skyboxes
  2. Enable Ambient Occlusion in World Properties and tweak Factor to increase contrast 

### Connecting Room Walkmeshes

  1. Select a room walkmesh
  2. Enter Edit mode and select two vertices adjacent to another room
  3. Determine 0-based index of the other room into the LYT file
  4. Enter Vertex Paint mode and set brush color to (0.0, G, 0.0), where G = (200 + room index) / 255
  5. Ensure that brush blending mode is set to Mix, and brush strength is set to 1.0
  6. Paint over the selected vertices

### Editing Paths

  1. Extract PTH file from the module's RIM file, e.g. "modules/danm13_s.rim" (Kotor Tool, reone-tools, etc.)
  2. Import PTH into Blender via File → Import → KotOR Path (.pth)
  3. Create/move path points, or modify path connections via Object Properties
  4. Export PTH via File → Export → KotOR Path (.pth)

## Compatibility

Known to work with Blender 2.93 and 3.2.

## License

GPL 3.0 or later


 

Share this post


Link to post
Share on other sites

When trying to export a mesh with a dangly mesh I get the following error:

On line 1107 in nvb_node.py:  RuntimeError: Error: Mesh "(insert danglymesh name here)" is outside of main database and cannot be removed from it.

Share this post


Link to post
Share on other sites
2 hours ago, Hunters Run said:

When trying to export a mesh with a dangly mesh I get the following error:

On line 1107 in nvb_node.py:  RuntimeError: Error: Mesh "(insert danglymesh name here)" is outside of main database and cannot be removed from it.

Fix is in the repository (mesh removal made redundant after upgrade).

  • Like 1

Share this post


Link to post
Share on other sites

Status update: I've done a couple of beta releases (now at beta 4), where I've improved compatibility with MDLedit and added support for editing PTH files. For those interested in baking lightmaps or editing PTH files in KotorBlender, I've listed the necessary steps in the description.

  • Thanks 1

Share this post


Link to post
Share on other sites

Status update: I'm releasing version 2.0.0, which is the first non-beta version of the updated add-on. I've tested it on quite a few models, doing modelling, texturing, rigging, animation, etc. I think KotorBlender is now on par with KotorMax in terms of functionality: it works equally well for editing (and creating) character and area models, and I'm quite happy with the result.

Here's the excerpt from the release changelog:

  • Rewritten handling of materials and lights (Eevee)
  • Made materials configurable from Object Properties
  • Implemented import & export of LYT files
  • Implemented import & export of ASCII PTH files (reone-tools)
  • Implemented armature creation (no animations yet)
  • Fixed MDLedit compatibility issues
  • Removed NWN-specific functionality
  • Disabled minimap rendering (until later)
  • Code cleanup and refactoring in accordance with Blender and Python code styles
  • Like 2

Share this post


Link to post
Share on other sites

Hey I just wanted to say this is amazing. I've been using blender for awhile and much prefer it to the other main 3D packages, especially Max. Until recently, my workflow has been to import a file into blender 2.79, manually change the textures, so on so on. You can image that this gets pretty annoying real quick. Really excited to see what you can do with it. 

Share this post


Link to post
Share on other sites

When you import a supermodel, some animations on the right arm rotate in a circle. To see what I mean import s_male02 (k1 or k2) and look at animation pausestl. Decompiled with both mdledit and mdlops. This also applies to s_female03.

Share this post


Link to post
Share on other sites

my novice nature is showing but can this tool be useful for making new characters for a recruitment mod. i have a rough draft in my head that involve Ord Mantell by Redhawke.

Share this post


Link to post
Share on other sites
49 minutes ago, Hunters Run said:

When you import a supermodel, some animations on the right arm rotate in a circle. To see what I mean import s_male02 (k1 or k2) and look at animation pausestl. Decompiled with both mdledit and mdlops. This also applies to s_female03.

That is a known issue - same goes for pre-2.8 version of the add-on. Apparently, it has something to do with keyframe interpolation. Exported animations and imported armatures work OK though, so it's not exactly high on my todo list.

4 minutes ago, DeathScepter said:

my novice nature is showing but can this tool be useful for making new characters for a recruitment mod. i have a rough draft in my head that involve Ord Mantell by Redhawke.

I'm not aware of any hard limitations of KotorBlender, with regards to creating new characters. It may not have as many utilities as NWmax, it lacks tutorials, but you can certainly model, texture and rig new characters using KB.

  • Like 1

Share this post


Link to post
Share on other sites
17 minutes ago, seedhartha said:

That is a known issue - same goes for pre-2.8 version of the add-on. Apparently, it has something to do with keyframe interpolation. Exported animations and imported armatures work OK though, so it's not exactly high on my todo list.

I'm not aware of any hard limitations of KotorBlender, with regards to creating new characters. It may not have as many utilities as NWmax, it lacks tutorials, but you can certainly model, texture and rig new characters using KB.

I am interested in re using one of the female Revan heads(Angelina Jolie one with the red braid) as a base and maybe using other's assets to make a Recruitable character. 

Share this post


Link to post
Share on other sites

The latest version of kotorblender (2.1.0) lacks the folder kotorblender. So it puts the files directly into the plugins folder. 

Also, exporting txi properties throws a traceback error.

Share this post


Link to post
Share on other sites

Is this compatible with Blender 2.93? I'm trying to install it, but all I get is this Traceback Error.

Traceback (most recent call last):
  File "D:\Steam\steamapps\common\Blender\2.93\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "D:\Steam\steamapps\common\Blender\2.93\scripts\addons\kotorblender\__init__.py", line 44, in <module>
    from .ops.mdl.importop import KB_OT_import_mdl
  File "D:\Steam\steamapps\common\Blender\2.93\scripts\addons\kotorblender\ops\mdl\importop.py", line 24, in <module>
    from ...format.bwm.loader import BwmLoader
  File "D:\Steam\steamapps\common\Blender\2.93\scripts\addons\kotorblender\format\bwm\loader.py", line 19, in <module>
    from ...exception.malformedbwm import MalformedBwm
ModuleNotFoundError: No module named 'kotorblender.exception.malformedbwm'

Share this post


Link to post
Share on other sites

Currently the latest version is improperly packaged.  You can fix this by going to the installation location and putting all of kotorblender's   files in a folder named kotorblender.

Share this post


Link to post
Share on other sites

Hey, guys. Just wanted to give you a heads up that I'm in the middle of updating the add-on, enabling import and export of binary models based on MDLedit. I noticed that @Arson Hole is using the master version from GitHub. This one is not being properly tested and could be unstable. Please use version 2.1.0 from this site instead, and make sure to put all addon files under a folder named kotorblender, as @Hunters Run just said.

  • Like 1

Share this post


Link to post
Share on other sites

For those interested, version 3.0 of KotorBlender is out. ASCII MDL / PTH workflow has been dropped in favor of binary importer & exporter. Binary MDL support is mostly on par with MDLops/MDLedit, except it lacks smoothing groups and cannot export saber meshes.

I will fix these as I go. Other plans include streamlining the editing process, e.g. one-click lightmap baking and working with multi-material objects, armature animation export, advanced shader node setups, etc.

Also, an interesting discovery I made about the MDL format - both MDLops and MDLedit expect per-vertex "tangent space" data to have the following layout: Bx By Bz Tx Ty Tz Nx Ny Nz, where B is a bitangent, T is a tangent and N is a normal. However, my experiments show that "tangent space" is actually a transposed TBN matrix, which makes a lot more sense from the engine standpoint: Tx Bx Nx Ty By Ny Tz Bz Nz.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

So does this mean that KBlender will be able to import/export the model's original normals directly rather than dealing with MDLEdit/KMax's hacky conversion to/from Max smoothing groups (which is a legacy of MDLOps/NWMax's ASCII format)? Because that is the single biggest problem with the current Max/GMax workflow, causing all sorts of broken shading issues, especially on head models.

  • Thanks 1

Share this post


Link to post
Share on other sites
Quote

So does this mean that KBlender will be able to import/export the model's original normals directly rather than dealing with MDLEdit/KMax's hacky conversion to/from Max smoothing groups (which is a legacy of MDLOps/NWMax's ASCII format)?

Just tested this and yeah - we can import and export original normals, no problem.

  • Thanks 1

Share this post


Link to post
Share on other sites

So we no longer need to convert a binary model to ASCII—messing it up in the process—in order to modify it, but we still need to use MDLEdit to port it to the other title?

Share this post


Link to post
Share on other sites
7 minutes ago, La Ingobernable said:

So we no longer need to convert a binary model to ASCII—messing it up in the process—in order to modify it, but we still need to use MDLEdit to port it to the other title?

Nope, you just check or uncheck "Export for TSL". No need for MDLedit at all.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.