Difference between revisions of "Seasonal textures (ASM tweak)"

From FSDeveloper Wiki
Jump to: navigation, search
(Fs2004 gamepack)
Line 1: Line 1:
This article describes how you can add seasonal textures to your GMax generated models. You need to save the ASM files of your object first, so that you can tweak these. The two section below discuss how this can be done for the Fs2002 and Fs2004 gamepacks.
+
This article describes how you can add seasonal textures to your GMax or FSDS3 generated models. The two section below discuss how this can be done for ASM code generated by the Fs2002 and Fs2004 gamepacks.
  
 
== Fs2002 gamepack ==
 
== Fs2002 gamepack ==
Line 141: Line 141:
 
[[category:FS8_(FS2002)]]
 
[[category:FS8_(FS2002)]]
 
[[category:FS9_(FS2004)]]
 
[[category:FS9_(FS2004)]]
 +
 +
{{Template:Navbox-SceneryDesign-Navigation}}

Revision as of 15:56, 24 March 2008

This article describes how you can add seasonal textures to your GMax or FSDS3 generated models. The two section below discuss how this can be done for ASM code generated by the Fs2002 and Fs2004 gamepacks.

Fs2002 gamepack

You will need to edit the source code in two places. The first is the texture list of your object. For a simple object with only one texture this list could look like this:

TEXTURE_LIST_BEGIN
TEXTURE_DEF TEXTURE_AIRCRAFT, <255,255,255,255>, 54.999468, "TEST.BMP" ; 0
TEXTURE_LIST_END

In this list you need to add all the new seasonal textures, like shown below. If you have multiple textures in your list you need to keep an eye on the numbering of the different textures, as you need them later to assign the correct texture.

TEXTURE_LIST_BEGIN
TEXTURE_DEF TEXTURE_AIRCRAFT, <255,255,255,255>, 54.999468, "TEST.BMP" ; 0
TEXTURE_DEF TEXTURE_AIRCRAFT, <255,255,255,255>, 54.999468, "TEST_WI.BMP" ; 1
TEXTURE_DEF TEXTURE_AIRCRAFT, <255,255,255,255>, 54.999468, "TEST_SP.BMP" ; 2
TEXTURE_DEF TEXTURE_AIRCRAFT, <255,255,255,255>, 54.999468, "TEST_FA.BMP" ; 3
TEXTURE_LIST_END

The second place where you need to edit the source code, is at the location where the texture is assigned to the actual object. Such a line could look like this:

MATERIAL 0,0

Around this command that sets the material we are going to add some conditions to switch between different textures based on the season. An example of such code is shown below.

IFIN1 tex_01, 0000006f8h, 0, 0
MATERIAL 0,1
JUMP tex_verder
tex_01 label word
IFIN1 tex_02, 0000006f8h, 1, 1
MATERIAL 0,2
JUMP tex_verder
tex_02 label word
IFIN1 tex_03, 0000006f8h, 2, 2
MATERIAL 0,0
JUMP tex_verder
tex_03 label word
MATERIAL 0,3
tex_verder label word

With the IFIN1 command the value of a variable is checked, if it is a certain season that texture will be loaded with the MATERIAL command. After the material has been set, a jump is made to the end of the segment of code with the checks, so that the actual drawing with that texture can begin.

If you have multiple textures in your object, you will need to add a block of conditions around each one. Please make sure that the label names you use are unique, so do not simple copy-paste this example.

Fs2004 gamepack

If you are using the Fs2004 gamepack the principle of the tweaks is still the same as described above, but as the structure of the code in the ASM file has changed slightly a few example will be shown again.

First go and look for the TEXT (texture) section of the object. This could look like this:

hangaar_seagull_top label BGLCODE
texture_riff_start_hangaar_seagull	label	word
    db  'T','E','X','T'   
    dd  texture_riff_end_hangaar_seagull - $ - 4  
    TEXTURE_LIST_BEGIN
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 0.749090, "HO_GOLF_GROEN.BMP" ; 0
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 1.497027, "HO_SEAGULL_BORD.BMP" ; 1
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 2.449824, "HO_SEAGULL_DEUR.BMP" ; 2
    TEXTURE_LIST_END
    BGL_RETURN
texture_riff_end_hangaar_seagull label word

To this texture list you will have to add all the extra textures you want to use. So let's assume that all these textures have a variant for each season, then your final texture list could look like this:

hangaar_seagull_top label BGLCODE
texture_riff_start_hangaar_seagull	label	word
    db  'T','E','X','T'   
    dd  texture_riff_end_hangaar_seagull - $ - 4  
    TEXTURE_LIST_BEGIN
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 0.749090, "HO_GOLF_GROEN.BMP"	; 0
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 1.497027, "HO_SEAGULL_BORD.BMP" ; 1
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 2.449824, "HO_SEAGULL_DEUR.BMP" ; 2
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 0.749090, "HO_GOLF_GROEN_SP.BMP" ; 3
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 0.749090, "HO_GOLF_GROEN_FA.BMP" ; 4
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 0.749090, "HO_GOLF_GROEN_WI.BMP" ; 5
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 1.497027, "HO_SEAGULL_BORD_SP.BMP" ; 6
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 1.497027, "HO_SEAGULL_BORD_FA.BMP" ; 7
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 1.497027, "HO_SEAGULL_BORD_WI.BMP" ; 8
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 2.449824, "HO_SEAGULL_DEUR_SP.BMP" ; 9
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 2.449824, "HO_SEAGULL_DEUR_FA.BMP" ; 10
    TEXTURE_DEF TEXTURE_BUILDING    , <255,255,255,255>, 2.449824, "HO_SEAGULL_DEUR_WI.BMP" ; 11
    TEXTURE_LIST_END
    BGL_RETURN
texture_riff_end_hangaar_seagull label word

Now that you have added all the extra textures to the list, it is time to look for the piece of code where the textures are assigned to the object. This is done by calling the texture number. This number is just place of the texture in the texture list. So the HO_GOLF_GROEN.BMP texture is number 0. The seasonal variants beloning to this texture are texture number 3, 4 and 5 in this case.

You will find the texture assignment code in the BGL section. For the first texture there is a line like this for example:

MATERIAL 1,0 ; <255,255,255,255> HO_GOLF_GROEN.BMP;;;

Replace this line of code by:

IFIN1 tex_01, 06F8h, 0, 0
MATERIAL 1,5 ;  winter
JUMP tex_continue
tex_01 label word
IFIN1 tex_02, 06F8h, 1, 1
MATERIAL 1,3 ; spring
JUMP tex_continue
tex_02 label word
IFIN1 tex_03, 06F8h, 2, 2
MATERIAL 1,0 ; summer
JUMP tex_continue
tex_03 label word
MATERIAL 1,4 ; fall
tex_continue label word

What does this code do you might ask? Let's walk along the different lines.

The IFIN1 command check the value of a variable. If it is within the specified range the commands following it are executed, else a jump is made to the label specified (tex_01 in this example).

The variable 06F8h is the variable that contains the season. This variable can take 4 different values. 0 means winter, 1 means spring, 2 means summer and 3 means fall.

So the first line checks if it is winter at the moment. If this is true texture number 5 is set as active texture (remember this was the number of our winter texture). After setting this texture we jump to tex_continue, as we want to use this texture and not set the others.

If it is not winter we jump to the next check and see if it is spring at the moment. If so we set the correct texture and else we check for the next season. This continues till we have set all seasons.

You will have to repeat these steps for every MATERIAL command in your source where you want to check for seasonal texture. Please remember that label names must be unique, so for your second texture you need to use different names. You could for example replace tex_01, tex_02, tex_03 and tex_continue with tex2_01, tex2_02, tex2_03 and tex2_continue.

Better seasons

There is one other thing you should know. The seasons varaible 06F8 does not follow the seasons of the mesh. It just divides the year into 4 blocks of 3 months. If you want to match the changes in the mesh scenery you can best use the day of the year variable 038A. If you know the days at which the mesh scenery changes season, you can check in which seasons you are at the moment. For example let's say that winter is between day 0 and 59, spring is between day 60 and 239, summer is between day 240 and 299 and fall is between day 300 and 365. Then you could use the following code to change the texture:

IFIN1 tex_01, 038Ah, 0, 59
MATERIAL 0,5 ;  winter
JUMP tex_continue
tex_01 label word
IFIN1 tex_02, 038Ah, 60, 239
MATERIAL 0,3 ; spring
JUMP tex_continue
tex_02 label word
IFIN1 tex_03, 038Ah, 240, 299
MATERIAL 1,0 ; summer
JUMP tex_continue
tex_03 label word
MATERIAL 0,4 ; fall
tex_continue label word
Template:Navbox-SceneryDesign-Navigation