Skip to content

Blender plugins

sbobovyc edited this page Mar 11, 2021 · 16 revisions

Video tutorials
Installing Blender plugins and importer demo
Creating and Exporting Weapon Model with Blender plugins

Installing the plugins

  1. Download the zipped version of the source code (https://github.com/sbobovyc/CM2Tools/archive/master.zip)
  2. Unzip
  3. Zip io_scene_mdr directory, then follow instructions on installing Blender addons from here: https://docs.blender.org/manual/en/dev/preferences/addons.html

Exporting checklist

  1. All faces must be triangles
  2. MDR format requires that a vertex is assigned only one texture coordinate
  3. MDR format requires that parent/child relationship exists between meshes
  4. Empty arrow objects should be used for anchor points (muzzle, ejection, etc)
  5. Every object must have a material with a texture
  6. Texture files names must be lower case
  7. Before exporting, select the root object

Materials
Combat Mission uses OpenGL fixed function lighting model to render objects when shaders are off.
FinalColor = I_ambient + I_diffuse + I_specular = I_a * K_a + I_d * K_d + I_s * K_s(R * V)^n
Where:
K_a = GL_AMBIENT
K_d = GL_DIFFUSE
K_s = GL_SPECULAR
n = GL_SHININESS

The exporter script sets K_a to (1,1,1,1), K_d to Blender's Diffuse color, K_s to Blender's Specular color, and maps Blender's Specular Hardness to n. Specular Hardness maps 0 to most glossy and 511 is most dull.

Textures with alpha channel

Combat Mission textures are BMP3 format. This format has support for an alpha channel. However, GIMP does not support this format. http://www.imagemagick.org/discourse-server/viewtopic.php?t=28733

sbobovyc@terra:~/Documents$ identify tree-1-leaves.bmp
tree-1-leaves.bmp BMP3 1024x1024 1024x1024+0+0 8-bit sRGB 4.194MB 0.020u 0:00.029

To get around this, you can convert the BMP files to PNG, import PNG into GIMP and do whatever modifications you want. Export to PNG and then convert to BMP3 format. Here is an example using ImageMagick.

sbobovyc@terra:~/Documents$ convert tree-1-leaves.bmp tree-1-leaves.png
sbobovyc@terra:~/Documents$ convert -verbose tree-1-leaves.png -define BMP3:alpha=on BMP3:tree-1-leaves2.bmp
tree-1-leaves.png PNG 1024x1024 1024x1024+0+0 8-bit sRGB 2.09MB 0.090u 0:00.089
tree-1-leaves.png=>tree-1-leaves2.bmp PNG 1024x1024 1024x1024+0+0 8-bit sRGB 4.194MB 0.020u 0:00.030
sbobovyc@terra:~/Documents$ identify tree-1-leaves2.bmp
tree-1-leaves2.bmp BMP3 1024x1024 1024x1024+0+0 8-bit sRGB 4.194MB 0.030u 0:00.019

Some texture contain a single bit alpha channel

C:\Users\sbobovyc\uaz469> identify -verbose .\uaz-469-canvas.bmp
Image:
  Filename: .\uaz-469-canvas.bmp
  Format: BMP3 (Microsoft Windows bitmap image (V3))
  Class: DirectClass
  Geometry: 1024x1024+0+0
  Resolution: 28.34x28.34
  Print size: 36.1327x36.1327
  Units: PixelsPerCentimeter
  Colorspace: sRGB
  Type: TrueColorAlpha
  Base type: Undefined
  Endianness: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
    Alpha: 1-bit

Some have 8 bit alpha:

 C:\Users\sbobovyc\uaz469> identify -verbose .\uaz-469-window.bmp
Image:
  Filename: .\uaz-469-window.bmp
  Format: BMP3 (Microsoft Windows bitmap image (V3))
  Class: DirectClass
  Geometry: 64x128+0+0
  Resolution: 28.34x28.34
  Print size: 2.25829x4.51658
  Units: PixelsPerCentimeter
  Colorspace: sRGB
  Type: PaletteAlpha
  Base type: Undefined
  Endianness: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
    Alpha: 8-bit

Tagged textures
Normal maps

Clone this wiki locally