Skip to content

seedhartha/kotorblender

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KotorBlender

This add-on is a fork of KotORBlender 1.01 by Purifier and Ndix UR, upgraded to support Blender versions 2.80 and above, which are notable by a redesigned user interface and a new real-time render engine. KotORBlender is in turn based on NeverBlender by Symmetric, forked from version 1.23a.

Significant changes have been introduced since KotORBlender 1.01, including, but not limited to, replacing ASCII model import/export with binary format, and ability to import/export layouts and path files.

Features

  • Import & export MDL models, including animations and walkmeshes
  • Import & export LYT files
  • Import & export PTH files
  • Lightmap texture baking
  • Area minimap rendering

Compatibility

Current version of KotorBlender is fully compatible with Blender versions 3.6 and 4.2, and was tested with version 4.4. Blender development moves fast and is known to introduce breaking changes, therefore compatibility with any other version of Blender is not guaranteed.

Installation

From DeadlyStream

  1. Download latest release of KotorBlender from Deadly Stream
  2. Install extension from disk as described in Blender documentation

From GitHub

  1. Clone GitHub repository
  2. When using Blender 4.2+, create a symlink to io_scene_kotor directory in current user's Blender extensions directory:
    1. Set cloned repository as current directory
    2. Create a symlink on Windows: mklink /D "%APPDATA%\Blender Foundation\Blender\4.2\extensions\user_default\io_scene_kotor" "%CD%/io_scene_kotor"
    3. Create a symlink on Linux: ln -s $(pwd)/io_scene_kotor ~/.config/blender/4.2/extensions/user_default/io_scene_kotor
  3. When using Blender 3.6, create a symlink to io_scene_kotor directory in current user's Blender addons directory:
    1. Set cloned repository as current directory
    2. Create a symlink on Windows: mklink /D "%APPDATA%\Blender Foundation\Blender\3.6\scripts\addons\io_scene_kotor" "%CD%/io_scene_kotor"
    3. Create a symlink on Linux: ln -s $(pwd)/io_scene_kotor ~/.config/blender/3.6/scripts/addons/io_scene_kotor

Usage

Data Preparation

Extract models, textures, walkmeshes, LYT and PTH files into a working directory, using a tool of your choice, e.g. reone toolkit. Recommended directory structure:

  • data — extract all BIF archives here without subdirectories
  • texturepacks
    • swpc_tex_tpa — extract swpc_tex_tpa ERF archive here

If you plan to edit textures, batch-convert TPC to TGA / TXI files using reone toolkit, although TPC textures are also supported by KotorBlender.

Model Import and Export

  1. Import via File → Import → KotOR Model (.mdl)
  2. Select top-level MDL root object to be exported
  3. Export via File → Export → KotOR Model (.mdl)

Editing Animations

To edit list of model animations and corresponding events, select MDL root object and navigate to Object → KotOR Animations. KotorBlender supports both object and armature-based edits. To create an armature from objects, navigate to KotOR Animations → Armature and press Rebuild Armature and Apply Object Keyframes. Before exporting a model, make sure to copy armature keyframes back to objects by pressing Unapply Object Keyframes.

Lightmapping

  1. Select objects for which you want lightmaps to be recreated, or unselect all objects to recreate all lightmaps
  2. Press KotOR → Lightmaps → Bake (auto)
  3. Open and save each individual lightmap image from UV Editing tab

UV mapping:

  1. Select objects having the same lightmap texture and enter Edit mode
  2. For every object, ensure that UVMap_lm UV layer is active
  3. Select all faces and unwrap UVs via UV → Lightmap Pack, increase Margin to avoid face overlapping

Fine-tuning:

  1. Increase lightmap image size via UV Editing → Image → Resize
  2. Tweak ambient color via Scene → World → Surface → Color
  3. Manually toggle rendering of objects in Outliner and press KotOR → Lightmaps → Bake (manual)
  4. In Scene → Render, set Device to GPU Compute to improve performance, set Render Engine to Cycles if not already
  5. In Scene → Render → Sampling → Render increase Max Samples to improve quality

Minimap Rendering

  1. Press KotOR → Minimap → Render (auto)
  2. Open "Render Result" image in UV Editing tab and save it as "lbl_map{modulename}.tga"
  3. Open "MinimapCoords" text in Scripting tab and copy-paste generated properties into module .ARE file using any GFF editor

Fine-tuning:

  1. Tweak background color via Scene → World → Surface → Color
  2. Manually toggle rendering of objects in Outliner and press KotOR → Minimap → Render (manual)

Connecting Rooms

  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 toolkit, 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)

License

GPL 3.0 or later

About

Blender add-on to import & export KotOR models

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • Makefile 0.1%