Translate

Wednesday 21 August 2013

Extracting 3d model from Gray Matter

In this article I described the process of converting models (skeleton and weight are present), as well as animation of the game Gray Matter (pc) into the 3ds Max.

Note: The article is designed for users familiar with working in 3ds Max and does not cover detail things such as, for example, texturing objects, setting up materials, etc.
For the conversion process, we need the following tools:
  • 3ds Max (i use 2008 х64) should work on versions: 7-2011
  • Blender v2.49b (3d editor) Author: Blender Foundation [page]
  • Python v2.6.5 (program language libraries for Blender) Author: Python Software Foundation [page]
  • PyFFI (libraries for Blender's additional scripts) Author: Amorilia [page]
  • FBX Plug-in (3ds Max plug-in for *.fbx format) Author: Autodesk [page]
  • gray-matter-pc-b3d-importer-2010-12-19.blend (Blender script for importing *.b3d files) Author: Mariusz Szkaradek [download] [page]
  • PAK util v0.55 (unpacker for *.pak files) Author: bacter [download] [page]
1. Game archive unpacking. After installing the game all the resources are located in the Data folder in the *.pak archives. To unpack these files you will need to use the program called GrayMatter PAK util. It looks like this:
Near the .PAK file: phrase choose *.pak file, near the Directory: word choose the way of extracting and click Extract button.
I advise you to unpack the archive in its own folder with the name of the archive.
2. Model converting. All game characters, as well as some of the key gaming objects located are in the *.pak archives in the folder:
<install path>\Gray Matter\Data\characters\
For converting I took the model of Mephi as an example:
<install path>\Gray Matter\Data\characters\id_mephi.pak
After unpacking the archive, we obtain:
  • anims - folder with animations
  • mephi.fbm - folder with textures
  • mephi_dc.fbm - folder with textures (second costume)
  • mephi.b3d - 3d model of the character
  • mephi.mat - material properties for mephi.b3d file
  • mephi_dc.b3d - 3d model of the character (second costume)
  • mephi_dc.mat - material properties for mephi_dc.b3d file
Before you start converting you need to install Python, Blender and PyFFI.
For convenience, I suggest that for every unpacked archive to create a folder with the same name, so I get a folder with files/folders:
<install path>\Gray Matter\Data\characters\id_mephi\
In the creation of just the folder you need to copy the gray-matter-pc-b3d-importer-2010-12-19.blend file. Now run this file, Blender opens:
On the right - the 3d viewport. On the left - a script that needs to import *. b3d files. Below - the animation control panel.
Next, click the right button on the script (which is on the left) and run it by selecting Execute Script:After running the script above will open a small window in which you have to choose which model (they are there only two: mephi.b3d, mephi_dc.b3d) to upload:
I chose
<install path>\Gray Matter\Data\characters\id_mephi\mephi.b3d
and press Ok. After a short process model and animation (which about below) loaded into the Blender:
For exporting 3d model into *.fbx format you need to press File -> Export -> Autodesk FBX (.fbx)...:and save the model with the following parameters:
Install the latest plug-in for *.fbx files import in your 3d max. Open 3d max. And importing *.fbx file, in my case this is:
<install path>\Gray Matter\Data\characters\id_mephi\mephi.fbx
After completing the import process in a preview window you will see the following:
I suggest a little bit optimize/improve the model:
  • reposition the bones: notice that some models of the bones does not match the model, probably due to the fact that the developers used a skeleton for all the similar characters. To reposition the bones you need: select an object > enable Skin modifier > in the Advanced Parameters section remove the checkbox from Always Deform, then change position of the bones, after completion enable Always Deform
  • change direction of the normal of the individual polygons
  • apply a texture to a model
After above manipulations you get a ready-made model (I hid the bones):
Save the model as:
<install path>\Gray Matter\Data\characters\id_mephi\mephi.fbx
3. Animation converting. When you import the models in Blender animation also imported. It is automatically loaded into the program from the anims folder, from the *.bba files. You can select an animation by clicking Browses existing choices or adds NEW (1), play the animation by clicking Play Timeline (2):
Select the first animation walk.bba, press Play Timeline, this will cause motion animation of walk.
Note: To choose another animation you must first click the right mouse button on the skeleton in the scene.
Next, to export the animation in *.fbx format you need to press File -> Export -> Autodesk FBX (.fbx)... and save the file with the following parameters:
I saved the animation here:
<install path>\Gray Matter\Data\characters\id_mephi\anims\walk.fbx
Next, in 3ds max load the newly saved 3d model:
<install path>\Gray Matter\Data\characters\id_mephi\mephi.fbx
and import into the scene animation walk.fbx, get something like:
Animation is loaded into 3ds max.
4. Textures and Materials. In the Gray Matter are two main types of textures: diffuse map and normal map. All textures are in *.dds format.
5. Rendering3ds max and shaders.