Edit by Gigantus: this article is available with pictures here as PDF file.
After some testing by volunteers, I've got a beta release of a Python
strat model converter for use with Milkshape. It can be downloaded
from here:
http://www.twcenter.net/forums/downl...o=file&id=1797
To run it double-click the file (after unzipping of course)
stratmodelconverter_ver1_1.py. It will display a file chooser. Double click
a .cas file in model_strat to convert it to .ms3d format. Then open in
Milkshape and mod it. To back convert, run the script again and select the
modded .ms3d file and it will convert it back to the .cas file format.
-------------------------------------------------------------------------
End of release statement, known deficiencies.
-------------------------------------------------------------------------
There are a lot of files in model_strat, this converter can't deal with some
of them. Can't do:
-------------------------------------------------------------------------Code:barb_strat_map_captain bishop - has 68 animation frames ? captain_drag_model cardinal - has 68 animation frames ? carthage_strat_captain character_pontus crossed_swords diplomat - has 68 animation frames ? flood_water general_pontus good_old_blue inquisitor - don't care about the above, this sucks. late_captain_northern_shadow - don't know what to think about this. navy_eastern - old stuff, boring. navy_egypt navy_greek navy_roman navy_roman_shadow priest - 68 animation frames ? princess - ditto resource_chocolate - multiple meshes, multiple texture files resource_mine - same as above resource_wool - this file is death, will clobber your computer, I've set a trap for it so you can't touch it. symbols - anything RTW can't be converted, anything M2TW can.
End of known deficiencies, beginning of tutorial.
-------------------------------------------------------------------------
To illustrate its use we will follow Alletun's excellent strat models reloaded
tutorial and try to do the same thing using only Milkshape and the converter.
(Yes, this is what I did over the holidays, this is what
happens during re-run season.)
I'll use mailed_knights as the example but pick anything
you like. We're going to make a new late_general_northern.cas file using
mailed_knights and put it in game. I apologize if I'm giving too much detail
in the following, but I just learned most of this over the holidays by trying to
write up this tutorial; besides too much is better than too little.
First step is to convert mailed_knights_lod0.mesh to .ms3d format using
GrumpyOldMan's converter. I'll assume this is done. Now open in Milkshape.
There are multiple bodies, arms, legs, etc. that we don't need so we need to
get rid of these. Before proceeding I'm going to do a "save as" to another name
so I don't destroy my original mailed_knights_lod0.ms3d. I'll call it mailed_knights_example.
The figure below shows the model with the groups tab open showing multiple groups.
Having done this once, I know the animations don't
work right with the shield present (bone_Lelbow isn't rotated correctly to have
the shield vertical so it looks stupid). The figure below shows what I mean
when I merged my first try with the Strat_general_walk.cas animation.
We'll remove all the shields, all multiple
bodies, arms, etc. including the lance so only one sword is left.
To remove them I used the groups tab and selected each
group in turn numbered higher than _01 by select, then delete. For instance, there
is one lance (delete it) and a bunch of secondary swords, delete all but the first
(i.e. keep sword_secondary_26 but delete 27 to 34). Also delete all the kite shields
for reasons explained above.
After removing all the duplicates, you should only have seven groups (or meshes
in 3ds Max parlance). The groups tab should look like the following:
Now the sword is assigned to the attachments material like it should
for a battle model but strat models only have one material so assign it to
Figure instead of Attachments. Under the groups tab select the sword, then go to the
materials tab, select Figure, then click the assign button. Go back to the groups
tab and check that the sword (and every other group) is now assigned to the Figure material.
Now we are ready to export the geometry and uv information to 3ds format.
To export, go to the file menu item and scroll down to export --> Autodesk 3ds
and export as "mailed_knights_example.3ds", my name choice for this tutorial.
This is shown in the figure below:
Now we have the geometry (and the uv's). We just need the right skeleton.
To get the skeleton, we will use the Python converter, "stratmodelconverter.py",
which you can download from the first link above. We will convert "late_general_northern.cas"
from the models_strat directory of your unpacked files.
Run the converter by double-clicking on it in explorer. You should see a file chooser
like that shown below.
Choose late_general_northern.cas in the file chooser by double-clicking it and you
should produce a "late_general_northern.ms3d" file in the same directory. (I put all
the needed files in one directory to start with, for convenience.) Open this file
in Milkshape and you should see the following:
Before we do anything I want to do a "save as" so I don't overwrite my original
late_general_northern.ms3d file. I'll save as "late_general_northern_mailed_knights"
so I can remember what this is for.
Now we have to delete all the geometry, leaving only the bones.
This is easy at this point because all the vertices came in selected so just hit the delete button
on the keyboard. (If yours aren't selected, go to the model
tab, hit the select button, then make sure the select options box at the bottom of the model
pane is set to vertex. Now select a box around the entire model so that all the vertices are
selected. Then hit delete.) You should be left with only the RTW style bones as shown below:
Now we import the .3ds file we created before. Go to the file menu item and
select Import --> Autodesk 3ds as shown below:
Then mouse to whereever you stored your .3ds file, I called mine mailed_knights_example.3ds.
After you select it your model should now look like the figure below:
Let's fix up the group names (some have trailing spaces).
On the groups tab select head_01 then select the string "head_01" in the edit
box next to the rename button. You should notice it has a trailing space. Start typing in
"head_01" (without the quotes) and it should overwrite the original string. Once input
click the rename button. You should notice the entry in the listbox get smaller now that
the trailing space is removed. I don't know if this step is necessary, but just to be sure I'll
do it anyway. Rename the other groups to "arms_Lmail_01", "legs_01", "hands_01", "L_mail_body_01",
"teeth", and "sword".
Now assign vertices to bones. Following Alletun we first assign everything to
a "check" bone. We'll use bone_cloak_bottom for this since at the end nothing should be assigned
to this bone. Go to the joints tab and double click on bone_cloak_bottom. It should show up in
the edit box next to the rename button showing it is selected. Then go to the models tab
and click the select button and make sure the selection options shows the vertex button is
pushed in. Now select all vertices by dragging a selection box around them. If you got them
all it should look like the following:
Then go to the joints tab and click the assign button. Now everything is assigned to
bone_cloak_bottom. We are now going to assign them to their correct bones, if we omit any vertices
at the end we can click on bone_cloak_bottom and see them. Let's assign the vertices around
the waist and the scabbard to bone_pelvis. To zoom in go back to the models tab, unclick the select button,
hold down the shift key and left click and hold the mouse button and move it upwards to zoom in.
The front view is the most convenient for assigning. After you have a nice zoomed
view of the middle section go to the joints tab and double click bone_pelvis so it is ready for
assigning (it appears in the edit box next to the rename button). Now go back to the model
tab, click the select button and then drag a box around the vertices
to select. Then go back to the joint tab and click the assign button.
Now select the vertices at the tip of the scabbard and click assign again. If you check the
checkbox labeled "draw vertex weights", you can see what vertices are assigned to a bone
by double-clicking the bone name. If you do this you should see something like the figure below:
Now do bone_abs by double clicking it to appear in the edit box.
We just want the line of vertices across the middle of the chest.
The vertices I've selected and assigned to bone_abs are shown below:
Do bone_torso by double clicking it. Then select the vertices of the upper torso.
Don't worry if you get part of the neck and head, we'll fix that next. The vertices
I assigned look like
Now double click bone_head and then go to the group tab and click the group head_01 and
then the select button. Then to the joint tab and the assign button. Now go back to the
group tab and do teeth the same way. Keep going until you have assigned everything to
the left and right bone_upperarm, bone_elbow, bone_hand and the leg parts to left and right
bone_thighs, bone_lowerlegs, and bone_foot.
At this point, two checks are done. Go to the joint tab and, making sure the check box "draw vertex weights"
is still checked,
then double click bone_cloak_bottom to see if any vertices are still assigned to it. If so,
assign them to their correct bone. Another check is to click selUnassigned button just to see
if any vertices didn't get assigned to bone_cloak_bottom to start with. It is worth
checking all of this carefully. Another visual check is to check the check box
"draw vertices with bone colors" (this unchecks the "draw vertex weight" checkbox.) Now
go to the perspective viewport, right click, and select flat or smooth shaded. Go to any
other viewport and do the same. You should see something like the figure below:
Now let's pull in the texture for mailed_knights and do an adjustment for the sword.
From the modeldb file we know the Figure texture is en_lmail_hmail_england.texture
for the english faction so let's pull this is. The .texture format is CA's own so it
needs to be converted to either a .dds file or a .tga. Use alpaca's converter to make
a dds file (or use a hex editor to delete the first 48 bytes, up to the DDS string).
Now go to the materials tab. You'll see FOUR materials because we dragged in two more
during the import.
THE FOLLOWING IS VERY IMPORTANT:
The last two don't have the needed comments in them so we will delete them.
Select the second Figure material and click the comment button to be sure there is no comment
for it. If not, then delete it by clicking the delete button. Do the same for the second
attachments material.
AGAIN, CHECK TO MAKE SURE FIGURE AND ATTACHMENTS COMMENTS HAVE DATA IN THEM. IF NOT,
YOU CANNOT BACK CONVERT!
Now select the first Figure material. Then go to the top long button
labeled <none> and click it and mouse to whereever this file or a copy of it exists. Double
click the en_lmail_hmail_england.dds file. You'll see a circular picture of it on the
materials tab. To see it in the viewports right-click in a given viewport and select
textured from the context menu (you'll need to go back to the joints tab and unselect the
"draw vertices with bone colors" checkbox to see it correctly). Doing this in all four viewports
gives you the picture shown below:
Now we just have to fix up the sword and scabbard uv coordinates (you can see they have
black bits on them because their uv coordinates think they are on the attachments texture,
not the Figure one). Go to the groups tab and select sword then call up the texture coordinates
editor under the Window menu item. You should see something like the figure below:
Now because I don't know Photoshop and because I'm lazy, I'm not going to try and
make a sword and scabbard on this texture; I'm just going to move and rotate these
two items to make them acceptable. First select the sword and move it down onto
the mail; this makes the sword sort of metallic. Second, select the scabbard, then click
rotate, type in 90 to rotate it 90 degrees then click the little R button, then click move
and move it onto the red color of one of the
body textures. When done it should look somewhat like this:
Now click off the texture coordinate editor and your model should look like this
Not perfect, but the sword looks metallic and the scabbard is red, so call it done.
Also, if you've noticed the viewports have switched around it's because I'm finishing up
at home with different defaults.
At this point we could save the model, backconvert with stratmodelconverter, and put it in
game but I deliberately made a mistake earlier on for pedagogical reasons. Let's animate
the model and see how it looks in Milkshape. For this we save the model as it stands
and then use the Python animation utilities to merge it with one of the Strat_General
animations from Caliban's directory. The animation utilities can be
downloaded from here:
http://www.twcenter.net/forums/downl...o=file&id=1469
Run animationutilities.py by double clicking on it and then clicking the animmerge button,
the utility is shown below:
A file chooser will be displayed with a *.ms3d filter. First select your model
(mine at this point is late_general_northern_mailed_knights.ms3d) from the file chooser.
Then select the Strat_General_attack.cas under the subdirectory Stratmap_General
in the next file chooser displayed. Finally input the desired frames per second in
the last dialog (5 is a good choice).
This will produce the file with the very long name late_general_northern_mailed_knights_animby_Strat_General_attack.ms3d.
Open this in another Milkshape window and then click the Anim button down at the bottom
right corner and then click the button labeled by > to play the animation. If you catch
the right frames you can see this ugly bit shown below (circled in red):
Arggh! we need to assign some of those vertices to bone_torso instead of bone_head so it
doesn't do that. At this point you can also check how the legs and arms move from frame
to frame and see if any other adjustments are needed. It is much easier to see these things
here than on the strategy map. So back to the model. Below we show the vertices we've selected
to assign to bone_torso
Repeating the steps above we merge again and check it in Milkshape. The results
are shown below:
Much better! Now we're ready to put in game. Save the model (not the animated one).
Then run stratmodelconverter.py and select your model. Mine is
late_general_northern_mailed_knights.ms3d. This should produce a .cas file
with the same name but with _converted appended to it (to prevent overwrites of original
files).
Now follow Alletun's tutorial for this part. In your mod folder under the data
subdirectory you need to copy in descr_model_strat.txt. Under data you need to make
a folder model_strat. Under this folder make a folder textures. Copy your model
to model_strat then rename to late_general_northern.cas.
The game wants .tga files so open en_lmail_hmail_england.dds
in Photoshop and do a "save as" to late_general_northern_strat.tga choosing
the Targa .tga format to save to. Copy this .tga to textures.
Now launch your game with your mod folder and voila! you should see
mailed_knights as your generals:
So it's late at night, I'm done, but you're not. This only does england, you
have to convert all the en_lmail_hmail_factionname.textures over to .tga files
or all the other generals that use your new model are screwed up. The steps
are the above, it just takes some Photoshop stuff.
Acknowledgements: Many thanks to Alletun for the strat model reloaded tutorial and
to the testers who used my first stab at this and found so many of the bugs.
PS: I think I'm getting the hang of this modelling stuff now.
Edit by Gigantus: this article is available with pictures here as PDF file.
.