Ground polygons (ASM tweak)

From FSDeveloper Wiki
Revision as of 09:05, 1 October 2006 by Arno (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

By default the source code generated by GMax is not really suitable to draw ground polygons with. As a result of this "wrong" code you can see shimmering with the mesh below and also the wrong display of shadows. With the tweaks described in this article, you will be able to turn your polygons into proper ground polygons again.

One note before we continue, this tweak is for the Fs2002 gamepack only. The new Fs2004 MDL structure is totally unsuitable for ground polygons and I discourage anybody from using a MDL for ground polygons. Instead use the old gamepack for them.

To draw correct ground polygons, you need to make the following changes. First find the following lines of code in your main ASM file:

OBJECT_0_START label word
IFIN1 OBJECT_0_FAIL, image_complex, 2, 32767
ADDOBJ OBJECT_0_SCALE
SHADOW_CALL OBJECT_0_SCALE
OBJECT_0_FAIL label BGLCODE

In this code you need to replace the ADDOBJ command with a ADDCAT command. This defines makes sure the polygons are layered properly and not seen as a 3D object. Also you need to remove the SHADOW_CALL command, as a ground polygon does not cast a shadow on the ground. So after that you code looks like this:

OBJECT_0_START label word
IFIN1 OBJECT_0_FAIL, image_complex, 2, 32767
ADDCAT OBJECT_0_SCALE, 8
OBJECT_0_FAIL label BGLCODE

As you have probably seen, the ADDCAT command also has an extra parameter. This is the layer number at which you want your polygon to display. If you are trying to place some polygons in a specific order you can use this number to give them the correct sequence.

One final note. This change only works if your source only contains ground polygons. If you have a mixed source with ground polygons and 3D objects the result will not be as you want. Due to the way GMax structurizes the source code it is not easy to add both a ADDCAT and a ADDOBJ command in one source. For this solution to work correct both commands should call the piece of code they apply to. So the ADDCAT command should call the piece of code with the ground polygons and the ADDOBJ command should call the code of the 3D objects. But in the file GMax makes this code is not separated.

The best way to solve this problem is to make two source file, one for the ground polygons and another one for the 3D objects. This can be done by selecting all objects belonging to these categories in GMax and then using the ``Export selected... option of GMax.