MA2 Tutorial
or How to create the bounding box and the mask for an object
by herbert3000, 2012-Oct-7
Part 1: The Bounding Box
-
Run Commandos 2, start a mission.
-
Run Cheat Engine -> select process comm2.exe.
Make sure that the file comm2.lua is placed in your Cheat Engine directory before you start the program.
Also edit the file main.lua (in your Cheat Engine directory) and insert the line require("comm2") under require("defines").
- Return to to Commandos 2.
-
Point on the center of an object, press CTRL+Q,
then point on the corners of the object in a counter-clockwise(!) order and log
the coordinates as well by pressing CTRL+Q.
Finally press CTRL+W to write the complete object info to the Lua output window.

-
Copy the code block from the Cheat Engine's Lua output and close Cheat Engine.

-
Extract ST1.MA2 (
in
DATA\MISIONES\TU03) with the XmlConverter.
-
Edit the file ST1.MA2.xfiles\Description.xml and insert the ObjectInfoBlock from the Lua output:

-
The <D> tag is the (inverted) height of the polygon, we
have to set it manually.
-
Save the file, drag&drop the folder ST1.MA2.xfiles onto the
XmlConverter and restart the mission.
Enable the "Volumenes Escenario" check box to view the bounding volume.
If you are not satisfied with the height, adjust the <D> tag.

Part 2: The Object Mask
- Open the image from the extracted Y64 file with an image editing program.
Insert the black&white mask image and set the opacity to 50%.


...and insert it as a new layer.

- Fix the object mask by changing the color of all the areas that don't belong to the actual object to black.

I usually apply a stroke effect on the mask (inner stroke, 1 pixel, grey RGB127,127,127).
This will give the mask a smooth border (grey = half-transparent).

- Remember the position of the layer on the map (see the lower left corner of the screenshot above: 889, 356).
- Save the layer as a new image (PNG) in the folder ST1.MA2.xfiles.
Edit the file Description.xml and insert a new Render Info Block.
<ObjectIndex> refers to the <ObjectInfoBlock> which was defined before.

Take care that the object is inserted in the correct <ArrayOfRenderInfoBlock>
<RenderInfo>
<ArrayOfRenderInfoBlock>
object masks visible in 1st view
</ArrayOfRenderInfoBlock>
<ArrayOfRenderInfoBlock>
object masks visible in 2nd view
</ArrayOfRenderInfoBlock>
<ArrayOfRenderInfoBlock>
object masks visible in 3rd view
</ArrayOfRenderInfoBlock>
<ArrayOfRenderInfoBlock>
object masks visible in 4th view
</ArrayOfRenderInfoBlock>
</RenderInfo>
- Proceed with the other views of the object.


As you can see, the <ObjectIndex> is the same in all four views.