Editing NPC Models

Post » Sun Sep 08, 2013 4:44 pm

There is probably a better way to edit NPC models, but I couldn't find much so I figured out a method on my own. Thought I would share for others who are having issues.

Changing the Default Models (Mr Potatoe Head Style):

Spoiler

Md6Mesh files use a pretty strait forward, human readable format. If you open one up and take a look:

W:\Rage\base\decls\md6def\settlers_wellspring_ginny.md6def

At the top there is an "init" block where you see the mesh sub-parts defined with names. There is also a "numMeshes" and "numJoints" declaration.

Then you have the Joint declarations and finally the mesh sub-parts. Each mesh subpart includes the the vertices, the joint connection information and texture mapping information. Since these subparts contain so much information, we can swap mesh subparts from various md6mesh files that share the same skeleton (most humanoid models). Sort of like playing Mr. Potato head.

Start up rage tool kit
MEDIA_B -> decls -> md6def -> settlers -> wellspring -> ginny.md6
Right click "ginny.md6" -> duplicate -> "yourmod/scratch.md6"

Browse to the duplicate:

MEDIA_B -> decls -> md6def -> yourmod -> scratch.md6

First thing to note is that this just created the file:

W:\Rage\base\decls\md6def\yourmod\scratch.md6def

Open this plain-text file up in your favorite editor. Change the internally declared scratch.md6 mesh to point to:

md6/yourmod/mesh/scratch.md6mesh

Then create the directory:

W:\Rage\base\md6\yourmod\mesh

And copy

W:\Rage\base\md6\characters\settlers\mesh\ginny.md6mesh

to

W:\Rage\base\md6\yourmod\mesh\scratch.md6mesh

Using ID Studio, you can browse through the various NPCs and note things

that you may want to compbine or substitute. For example, if we wanted to

put Elizabeths torso on Ginny:

I open up

W:\Rage\base\md6\characters\settlers\mesh\Elizabeth.md6mesh

can copy/paste the submeshes "elizabeth4", "elizabeth5" and "elizabeth6"

to the bottom of my scratch.md6mesh.

Then I edit the init section of the scratch.md6mesh and add

"elizabeth4;elizabeth5;elizabeth6; " to the end of the commandline block

I remove the original torso: Object43, "fem_bikini_low3", "fem_neck1_low01",

"fem_shortsleeve_low01", "shoulder_low01" and "wrist1_low"

Not only do I remove the submesh names from the command line, but I delete their

definitions and texture mapping infor lower in the file. Finally I update the num-meshes.

As you remove/add meshes, try to keep the order of the listing at the top
consitent with the order of the mesh definitions. Also make sure to keep
the total number of meshes up to date.

As for previewing what you are doing, if you open up the scratch
model that we have created using ID Studio (decls -> md6 -> yourmod -> scratch)

You will notice a little button in the preview toolbar which reads "Reload Everything"
when you hover over it. This will reload the mesh and textures, allowing you
to swap in/out parts to your hearts content using notepad and see how it looks
without having to restart ID Studio every time. (Sometimes you have to restart

anyway...)

The key take away point is that you can swap sub-meshes between md6mesh files using a text editor so long as the original models share the same skeleton (most humanoids do).

User avatar
how solid
 
Posts: 3434
Joined: Mon Apr 23, 2007 5:27 am

Post » Sun Sep 08, 2013 10:59 am

Changing Model With Blender:

Spoiler

IDStudio comes with the ability to export models to lwo format. The issue is that when you export, you lose texture mapping and armature linking information. The exported meshes are simply a large list of vertex points that create the hull. Furthermore, sub-mesh information is lost, so it is more or less impossible to remap the exported model to its original textures.

There is however a way to get around this.

Using the method I described above, you can edit a scratch md6mesh file so that only 1 sub-mesh is defined (num-meshes = 1). For my current model I did this by hand, however I will likely make a script that automatically breaks an md6mesh up into separate md6mesh files for each sub-mesh (named after the sub-mesh).

You then open up these md6 files within ID Studio and export each one to an lzo file. In my case, I created the following lzo files:

eye_shadow02.lwo

fem_bikini_low03.lwo

fem_boot1_lo01.lwo

fem_girlshorts_low02.lwo

fem_leg_low02.lwo

fem_neck1_low01.lwo

fem_shortsleeve_low01.lwo

gogglelens_low.lwo

helm2_low.lwo

jarmila_lo01.lwo

Object43.lwo

objmodels_characters_common2_tongue04.lwo

objobject__27.lwo

polySurface1.lwo

shoulder_low01.lwo

wrist1_low.lwo

Now, you can open up blender and import the various lzo files one at a time. Each time you import, the lzo file goes to a new layer named after the file. This means in blender you can isolate the various sub-meshes so that you can edit the model as a whole while maintaining modularity of the layers/submeshes.

The tricky part.... You can't do anything that adds new vertices. Why? Because it is trivial to write a merge script that can merge your changes back into the original md6mesh if the number of vertices is the same. But if there are extra verticies or fewer verties... there is no way of knowing what bones to attach them to. Only a true blender import/export plugin that understands ID TEch5 bone and animation system would allow new verticies. And I have looked. I don't think one exists. (as of this post).

So after you make your edits, how do you get it back out? Simple... export to obj format (also human readable), and then you can either copy the new vertices into the md6mesh file by hand... or you can run a script to auto-merge the changes for you. I made such a script in python. I will post it in my next post....

The key take away point is that you can break md6mesh files up so that you have an md6 file for each subpart. This allows you to import and export the changes with a little effort and a simple restriction: You can't add or remove vertices.

User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Sun Sep 08, 2013 11:15 am

Tricky thing about python is that spacing matters. So posting python code in a forum doesn't normally work so well.

I did however create a publically shared google doc:

https://docs.google.com/file/d/0B0VAFIuYmSp5N1dZR21saUxmcG8

Be aware that if you click "Open" and you have python installed, it will execute. So you probably want to "Save As"

User avatar
Brandon Bernardi
 
Posts: 3481
Joined: Tue Sep 25, 2007 9:06 am

Post » Sun Sep 08, 2013 7:30 am

They still haven't released the md6 model update, have they?

I really want to make my own bandits and such, but I'm just a modeler not programmer

User avatar
Natalie Harvey
 
Posts: 3433
Joined: Fri Aug 18, 2006 12:15 pm


Return to Othor Games