/Blender-NewDark-Toolkit

Blender plugin to allow export of Dark Engine .bin files, and import of .e files. Based on work by Telliamed.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Blender-NewDark-Toolkit

This addon allows Blender to export .bin files (Dark Engine objects and AI meshes) and import .e files (plain text files developed by LGS as an intermediate format for object conversion).

This is an update to Telliamed's Blender Toolkit for .e files (see the original version for motion tools). This now exports .bin files (path to BSP.exe required), and images are now only converted during import (to make them Blender compatible). The code for .bin export has been adapted from the Elendir's Dark Exporter 2 addon.

Requirements

  • The latest version was written in Blender 4.2.1. It'll probably work in older versions, but it's best to use the latest version.
  • The LGS programs BSP.exe and MeshBld.exe. Most fan-made installation tools (e.g. T2Fix, Dromed Toolkit etc) will include these.
  • Shadowspawn's MeshUp tool (from the MeshFix pack here, or various Thief/Dromed installation packs) , which converts AI meshes to the T2 format (this allows Texture Replacement to work).
  • The template .cal files which are also used for generating AI meshes. See your copy of mesh.crf.

Instructions

This addon does three things:

  • Import .e files
  • Export .bin files for objects (uses BSP.exe)
  • Export .bin and .cal files for AI meshes (uses MeshBld.exe and MeshUp.exe)

The object's textures can be copied to the /txt16 folder, but you can choose the conditions and make exceptions.

Import


There are only a few Import options. Their default values can be set via the Config file (see below):

Click to expand import options description...
  • Texture Search: When unchecked, Blender will expect the textures to be in the same folder as the .e file. When checked, it'll also search in any subfolders. If you've used User Preferences to set a Textures Directory, the addon will also look in there (and subfolders again). This is useful if you want to use a library of textures to use on multiple objects, or as a place to store stock textures that have been extracted from the .crf files.
  • Black Texture Workaround: In version 4.2, some old graphics cards (maybe just AMD) can't show materials correctly in 'Material Prieview' mode. The object's faces are shown as black. By default the addon gives all imported object's materials a 'Diffuse' shader. Enabling this option changes it the 'Emission'. Not great but it'll do.
  • Joint/Limit Plan Colour: For use with AI meshes. This allows you to choose the colour of these supporting objects in case you prefer something other than green. Note it applies to any RGB material whose name is "Green" (as we see in the original .e files in mesh.crf).
  • Forward and Up axes: These specifiy the orientation of the objects. The default values should be fine if the .e file was generated by bintoe.

Exporting (1)


The 'Scene' properties properties tab stores most of object the export parameters. Older versions of this addon had them all in the Export window itself. The benefit of the new setup is that the parameters will be saved with the file. Note that these values apply to any mesh which is exported from this file/scene.

Click to expand export options description...
  • Selection Only: When unchecked, every visible object in the scene will be exported. When true, only the selected object will be exported.
  • Center Object: Whether or not the object's bounding box is centered about 0,0,0. Recommended for most objects.
  • Apply Modifiers: Modifiers are a good way of performing non-destructive changes to a model (e.g. mirroring certain parts). In most cases this should be checked.
  • Smooth Angle: Determines the limit (angle between faces) up to which 'Phong' or 'Gouraud' shaded materials will be smoothly shaded. 89 is the default value. Lower angle = more sharp edges.
  • BSP Optimization: This affects how BSP tries to merge triangles or split them when they intersect. 0 is recommended so that what you see in Blender is as close as possible to the result in game.
  • Use Coplanar Limit - Enables the value mentioned below to be applied to the exported object.
  • Coplanar Limit: This also affects how triangles are merged (or not merged). During development of this addon it was found that a value of 1.00 produced the best results. Other values may lead to small gaps between faces or vertices being out-of-position/merged.
  • AI Mesh: Select this when exporting a creature (things with joints/limit planes etc).
  • Mesh Type: Only becomes visible when the above is selected. When the above is selected, this specifies a kind of 'template' file for the AI to ensure the mesh has all the right joints in all the right places.
  • Bin Copy: Copies the exported file to the \obj or mesh\ folders. The idea behind this option (and the above) is to save the user having to navigate to the Thief object folder each time.
  • FM/Game Dir: FM or Game folder where objects will be extracted to. Note that you need to define a list in your config file. It can be a list of just 1 item. See the Open Config File button or the Setup section below. No need to specifiy obj or mesh. The addon works that out based on object type.
  • Copy Texutres:
    • Always (textures will be copied to obj\txt16 and existing files will be overwritten). Bear in mind that you'll have to restart DromEd/the game for any texture updates to be seen.
    • Only if not present (existing files won't be overwritten - this is recommended because an existing object may use a texture that has the same but that looks vrey different to the one for your object. When you see your object in game, you'll see that it looks different, so you'll be able to rename the texture and export again).
    • Never (useful if your object is only using stock textures)
      • *Object materials have a 'Do Not Copy' property which prevents that texture being copied, even when either of the first two options is chosen.
  • Delete temp files: Before copying, the .bin file is created in the same folder the Blender object is saved in. This option deletes it when the copying is finished. Don't select this if Bin Copy is unselected otherwise you won't get any export file.
  • Extra BSP Params: The options above should meet all requirements, but the this text box allows you to type in other things to gain further control of the exported object. Details are outside the scope of this readme but you can view all available paramters by running BSP from a command line with no parameters to see the full list of what is available.
    • Example: typing in -w@ will make the entire object render in wireframe.
  • Open Config File - default values for the export parameters are stored in a .cfg file. Navigating to the file is quite a tedious process, so this button provides a handy shortcut. Blender will need to be restarted for any changes to take effect

Exporting (2)


A few more parameters. These are likely to remain the same for all time, so they're shown here mainly for a quick check before exporting. Default values are set in the config file (see above).

  • Wine prefix: a parameter for Linux users to allow this addon to work via the Windows emulator. Is ignored on Windows itself (feature was added by "Zode"). -BSP/MeshBld Dir: The full path of the folder containing "BSP.exe" and "MeshBld.exe". This addon generates .e files only. The original programs BSP and MeshBld are required to convert these to the Dark Engine's format, so this path is essential.
  • Forward and Up axes: These can adjust the orientation of the objects. Defaults should be fine.

Material Properties

The Materials tab has a panel which shows material settings supported by the Dark Engine:

Click to expand material properties description...
  • Shader Type: Smooth for Flat shading.
    • Phong/Gouraud: Object lighting is smoothed across adjacent faces that use this shader type. Note that the Dark Engine doesn't really use Phong. Selecting that will just lead to Gouraud being applied. Phong has always been listed however, so it's inclusion here is just for consistency.
      • The export options includes a Smooth Angle which can limit the effect of the smooth shading. This applies to the entire object, however.
    • Flat: Face is evenly lit, using the brightness of its centre
  • Tranparency: 0 = fully opaque (default), 100 = fully transparent.
  • Illumination: Allows faces to be fully lit, e.g. lantern glass. For animated lights the Dark Engine will automatically turn on/off faces with illuminated materials. Brightnesses can be modifed in Dromed using the Renderer > Self Illumination property (decimal, 0 - 1). Not confirmed at time of writing but I think it multiplies all 'ILLUM' material brightness values, up to a point.
  • Double Sided: Allows the face to be rendered when viewed from the back as well as the front. Effectively doubles the poly count for this material, so only use this where it's needed (e.g. where the player should be able to see both sides, e.g. flat fences, windows etc).
  • Do Not Copy Texture: This will prevent the texture being copied even when the overall Export Options do allow for copying. Useful for when some textures are new and others are from a .crf file.
  • Import Materials From Custom Properties: Older versiosn of this addon required the user to manually create custom properties to store these material parameters. This button looks for any of those and applies them to the above properties. The custom properties are not deleted, but you should remove them yourself to keep things tidy.

Installation

Click to expand. This is just standard addon installation, so if you already know about that, this section can be ignored.

Use the Code button and slect Download as ZIP File:

It can be downloaded to any folder.

In Blender, go to Edit > Preferences > Install and select the zip file:

The addons list will be automatically filtered, making it easy to enable the new addon:

Check that Auto Save Preferences is eanbled. If not, use the Save button to remember the setting:
or

Setting Default Values

There are several things to set up to allow the addon to work and be easy to use. In most cases it's clear which export option each variable refers to, so this section just states valid values. All the options are all explained fully in the Import and Export sections of this readme.

Note that the Scene tab has a button that makes it easy to open the file. Upon the first installation, the file will be created with dfault values. If updating the addon, additional values will be added to keep everything synchronised. Instead of using the button, you can access the file from your Blender addons folder: (%Appdata%\Blender Foundation\Blender[version number]\config\scripts) and open Bin_Export.cfg.

NOTE THE FORMAT OF EACH DEFAULT VARIABLE BEFORE MAKING CHANGES
Also note that the final variable does not end with a ,
Blender must be restarted for the changes to take effect

  • ai_mesh: true or false
  • autodel: true or false
  • bin_copy: true or false
  • black_tex_fix_4.2: true or false
  • bsp_meshbld_dir: Path surrounded by "s. Use \\ rather than just \ to separate each part of a path. Linux users should use / to separate instead.
  • bsp_optimization: 0 - 3
  • centering: true or false
  • game_dirs: " at start and end only. Multiple paths should be separated by a semicolon (and use \\ rather than \). Example: "C:\\Games\\Thief2;C:\\Games\\Shock2" will give you this menu:

    Note: On Linux use the path to the game under wineprefix (eg. <path to games>/games/wine/drive_c/thief2 or $HOME/.wine/drive_c/thief2)
  • selection_only: true or false
  • smooth_angle: 0 - 360 (not a fixed limit, but unlikely to need much more beyond 120)
  • tex_copy: 0, 1 or 2, which correspond with menu the menu items you see during Export
  • wineprefix: path to wine prefix (Linux only)