Thor the Bassist
05-29-2008, 12:26
N.B. Before I start I would like to point out that by day I'm a physicist/mathematician and so am good with logic and numbers. Words not so much. If you spot any huge problems with the flow of this explanation then pm me so I can iron out the creases.
One of the areas of modding that hasn't been explored enough in the RTW engine is the buildings and central to much of the problem is the creation of collision files that are vital to a buildings use in game. First it is important to state what the collision files do. The collision files contain all the data regarding how troops, projectiles and the cursor can interact with a building. This may seem rather vague but the area isn't as preset as many people would assume. It is indeed possible to create a fortress that are unspeakably complicated with many walls (although only one outer gate is possible) and buildings that troops can fight upon.
Associated Files
First it is important to outline what files are needed for a collision file.
xxxxxxxxx.bpi This is the actual collision file used by the engine. It is not editable directly but the game can convert a cas file to a bpi during startup.
xxxxxxxxx.cas This is the file you will create in 3dsmax. It consists of several geometries each of which gives a certain instruction to the engine.
descr_building_battle.txt This contains all the building references in the whole game (I would advise using the "include" command as CA have done). The key reference is the "physical_info" reference. This should point to your cas.
Possible geometries within the cas
So you look at me perplexed. The task now seems simple - create a cas, get your building to reference it and then the game will automatically create the bpi and everythings jolly. Unfortunately the game has a habit of spitting the cas file straight back at you with no error message if one of the geometries is a little wrong. For that I shall now list all known possible geometries, how they are implemented and some of the tricks I have found that can prevent unwanted effects.
Collision Outlines: affects troops
This is a 2D loop that encircles an area of the map that cannot or should not be reached by troops. It acts as an invisible brick wall and troops will simply walk into it and be forced to stop. The geometry is named "collision" and should be a single polygon. If two regions are wanted as collision they should be made into separate objects and named accordingly (eg collision_1 and collision_2). The game engine draws a clockwise connected loop following the edges of the geometry.
Collision Volumes: affects cursor/projectiles
This is a 3D geometry that should show where a building is and is named "collision_3d". It doesn't effect troops but the cursor will move over the building and projectiles will hit the building. This can be a simple copy of the file used to make the item though any complex details should be simplified to improve load time and lag (eg stairs changed to a slope)
Tunnels: affects troops
Tunnels are so named because they are used to get troops from lower levels to upper levels and are usually inside buildings though this is by no means a necessity (eg troops getting from ground to top of walls). They either have 2 entry points or 3 entry points and their polygons have 4 or 6 sides respectively. The smallest side of the polygon is alocated as an entrance and then every other side is an entrance. The game then directly connects these sides. The geometry is named "tunnel" and is a simple rectangle or hexagon. Troops who enter a tunnel cannnot turn around or stop they must travel all the way to the end.
Platforms: affects troops
Platforms are basically surfaces that troops can walk upon. They consist of the platform (named "platform_N_<edges>") and the slots for the platform (named "slot_platform_N_<rank>"). The platform is a simple quadrilateral that must form a plane. Bad effects also occur when a platform is not horizontal. N is the platform number (0-9) and gives the platform an identity and <edges> specifies whether an edge is clear (C - can walk off), soft (S - can fall off) or hard (H - cannot fall off). One edge also must be vertex coloured as this shows which is the "forward" edge - the front where the troops will face - and this is also the first edge to be given an edge specifier. The slots are rank positions and show where troops will stand when idle. These are made from an isoceles triange (must be isoceles). The first troops is placed at the short edge and troops are then evenly spaced about a metre apart up until the vertex of the triangle is reached. The slot must have the N value of the corresponding platform and the rank is given as a value starting at front rank being 0 and increasing to presumably 99.
(eg) platform_0_HCSC and slot_platform_0_0
Good practise: Several things I have found include that if the slots are too close to any of the edges of the platform troops will tend to fall off. Just make the platforms generously. Also the vertex painting is an absolute b***h. Re-import after exporting to check the right vertices are coloured and then fiddle till it works - this really is a bad aspect of max - Vercingetorix said it was to do with the fact that max paints the polygon and then changes the vertices or something - and if anyone has a fix...
Point of question: Although I am uncertain about this I believe that platforms can only have 4 edges as when I started on this area I got errors/CTDs on platforms with more edges - however this could just have been the fact that it was at the beginning of research. Either way it is relatively easy to make platforms with rectangles.
There are several others that are detailed here (https://forums.totalwar.org/vb/showthread.php?t=61234) but I haven't used these yet and so can only reference you to these. The above are however more commonly used.
So you have all this info but that doesn't seem to be helping you much. Actually having read through this myself I believe the words are actually more complicated than the process should be. So an example is called for.
http://a695.ac-images.myspacecdn.com/images01/73/l_c6517a9db35a9952e5dc39f6f84e6dfe.jpg
Now hopefully things make more sense. The two red arrows show two different collision data sections each a separate object and they make it impossible for troops to walk through the wall. The blue arrows are pointing at the two 3d collision sections - the wall bulk and the battlements. This means the cursor will pass over the wall and arrows will collide with the wall. The yellow/brown highlighted area shows a tunnel where troops can climb the stairs up to the wall. Notice that the smallest edges are the entrances. Finally the green highlighted area shows a platform area.
I hope this helps someone and soon we can see custom settlements sprawling across RTW landscapes.
One of the areas of modding that hasn't been explored enough in the RTW engine is the buildings and central to much of the problem is the creation of collision files that are vital to a buildings use in game. First it is important to state what the collision files do. The collision files contain all the data regarding how troops, projectiles and the cursor can interact with a building. This may seem rather vague but the area isn't as preset as many people would assume. It is indeed possible to create a fortress that are unspeakably complicated with many walls (although only one outer gate is possible) and buildings that troops can fight upon.
Associated Files
First it is important to outline what files are needed for a collision file.
xxxxxxxxx.bpi This is the actual collision file used by the engine. It is not editable directly but the game can convert a cas file to a bpi during startup.
xxxxxxxxx.cas This is the file you will create in 3dsmax. It consists of several geometries each of which gives a certain instruction to the engine.
descr_building_battle.txt This contains all the building references in the whole game (I would advise using the "include" command as CA have done). The key reference is the "physical_info" reference. This should point to your cas.
Possible geometries within the cas
So you look at me perplexed. The task now seems simple - create a cas, get your building to reference it and then the game will automatically create the bpi and everythings jolly. Unfortunately the game has a habit of spitting the cas file straight back at you with no error message if one of the geometries is a little wrong. For that I shall now list all known possible geometries, how they are implemented and some of the tricks I have found that can prevent unwanted effects.
Collision Outlines: affects troops
This is a 2D loop that encircles an area of the map that cannot or should not be reached by troops. It acts as an invisible brick wall and troops will simply walk into it and be forced to stop. The geometry is named "collision" and should be a single polygon. If two regions are wanted as collision they should be made into separate objects and named accordingly (eg collision_1 and collision_2). The game engine draws a clockwise connected loop following the edges of the geometry.
Collision Volumes: affects cursor/projectiles
This is a 3D geometry that should show where a building is and is named "collision_3d". It doesn't effect troops but the cursor will move over the building and projectiles will hit the building. This can be a simple copy of the file used to make the item though any complex details should be simplified to improve load time and lag (eg stairs changed to a slope)
Tunnels: affects troops
Tunnels are so named because they are used to get troops from lower levels to upper levels and are usually inside buildings though this is by no means a necessity (eg troops getting from ground to top of walls). They either have 2 entry points or 3 entry points and their polygons have 4 or 6 sides respectively. The smallest side of the polygon is alocated as an entrance and then every other side is an entrance. The game then directly connects these sides. The geometry is named "tunnel" and is a simple rectangle or hexagon. Troops who enter a tunnel cannnot turn around or stop they must travel all the way to the end.
Platforms: affects troops
Platforms are basically surfaces that troops can walk upon. They consist of the platform (named "platform_N_<edges>") and the slots for the platform (named "slot_platform_N_<rank>"). The platform is a simple quadrilateral that must form a plane. Bad effects also occur when a platform is not horizontal. N is the platform number (0-9) and gives the platform an identity and <edges> specifies whether an edge is clear (C - can walk off), soft (S - can fall off) or hard (H - cannot fall off). One edge also must be vertex coloured as this shows which is the "forward" edge - the front where the troops will face - and this is also the first edge to be given an edge specifier. The slots are rank positions and show where troops will stand when idle. These are made from an isoceles triange (must be isoceles). The first troops is placed at the short edge and troops are then evenly spaced about a metre apart up until the vertex of the triangle is reached. The slot must have the N value of the corresponding platform and the rank is given as a value starting at front rank being 0 and increasing to presumably 99.
(eg) platform_0_HCSC and slot_platform_0_0
Good practise: Several things I have found include that if the slots are too close to any of the edges of the platform troops will tend to fall off. Just make the platforms generously. Also the vertex painting is an absolute b***h. Re-import after exporting to check the right vertices are coloured and then fiddle till it works - this really is a bad aspect of max - Vercingetorix said it was to do with the fact that max paints the polygon and then changes the vertices or something - and if anyone has a fix...
Point of question: Although I am uncertain about this I believe that platforms can only have 4 edges as when I started on this area I got errors/CTDs on platforms with more edges - however this could just have been the fact that it was at the beginning of research. Either way it is relatively easy to make platforms with rectangles.
There are several others that are detailed here (https://forums.totalwar.org/vb/showthread.php?t=61234) but I haven't used these yet and so can only reference you to these. The above are however more commonly used.
So you have all this info but that doesn't seem to be helping you much. Actually having read through this myself I believe the words are actually more complicated than the process should be. So an example is called for.
http://a695.ac-images.myspacecdn.com/images01/73/l_c6517a9db35a9952e5dc39f6f84e6dfe.jpg
Now hopefully things make more sense. The two red arrows show two different collision data sections each a separate object and they make it impossible for troops to walk through the wall. The blue arrows are pointing at the two 3d collision sections - the wall bulk and the battlements. This means the cursor will pass over the wall and arrows will collide with the wall. The yellow/brown highlighted area shows a tunnel where troops can climb the stairs up to the wall. Notice that the smallest edges are the entrances. Finally the green highlighted area shows a platform area.
I hope this helps someone and soon we can see custom settlements sprawling across RTW landscapes.