1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Editing API

Discussion in '3D Objects General' started by pierrot1951, 25/6/06.

  1. pierrot1951

    pierrot1951

    Joined:
    25/6/06
    Messages:
    305
    Country:
    france
    Hello
    I wish to change some textures in API files ; I don't have the source files.
    With Notepad, I succeeded in editing an API file created with EOD, simply in replacing the bmp file with a new one.
    I tried the same with an API file created with FSDS (oltimedomehangar), to replace the wooden walls (2wood.bmp) by rusty metal (FineCorrVrust.bmp). The modified parts are no more visible!

    in the original text:
    Code:
    ...
    :Part3
    Points( 0 
        -305     0     1       ; 0
        -305   229     1       ; 1
        -296   229     1       ; 2
        -296     0     1       ; 3
        -305     0   458       ; 4
        -305   229   458       ; 5
        -296   229   458       ; 6
        -296     0   458       ; 7
        -305     0  -454       ; 8
        -305   229  -454       ; 9
        -296   229  -454       ; 10
        -296     0  -454       ; 11
        -305     0     2       ; 12
        -305   229     2       ; 13
        -296   229     2       ; 14
        -296     0     2       ; 15
        )
    ;RGBSColor( ef 56 56 56 )
    Dwx( 2d ) ; color command
    Dbd( 56 ) ; red
    Dbx( ef ) ; flag/transparency
    Dbd( 56 ) ; green
    Dbd( 56 ) ; blue
    Poly( 0 0 -32767 -0.76   0   1   2   3   )
    Poly( 0 0 32767 457.96   7   6   5   4   )[/COLOR]
    [B]; BGL_TEXTURE: tclass=1h color=38EF3838 name=[COLOR="Red"]2wood.bmp[/COLOR]
    Dwx( 0043 0016 0000 0001 ef38 3838 )
    Dba([COLOR="red"]2wood.bmp[/COLOR])[/B]
    [COLOR="blue"]Dbx( 00 )
    TexPoly( -32767 0 0 305.64  5 2 254 1 253 254 0 253 3 4 2 3 )
    TexPoly( 32767 0 0 -297.10  2 1 255 6 254 255 7 254 2 3 1 2 )
    Poly( 0 32767 0 228.60   5   6   2   1   )
    Poly( 0 -32767 0 0.00   0   3   7   4   )
    Poly( 0 0 -32767 455.29   8   9   10   11   )
    Poly( 0 0 32767 1.91   15   14   13   12   )
    TexPoly( -32767 0 0 305.71  13 2 254 9 253 254 8 253 3 12 2 3 )
    TexPoly( 32767 0 0 -297.04  10 1 255 14 254 255 15 254 2 11 1 2 )
    Poly( 0 32767 0 228.60   13   14   10   9   )
    Poly( 0 -32767 0 0.00   8   11   15   12   )
    Return
    ... 
    By changing all occurences of 2wood.bmp into FineCorrVrust.bmp, the walls are no more visible (the texture file is present in the right directory!)

    Thanks for help!!!
    Pierrot - FMEP
    Last edited by a moderator: 25/6/06
  2. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Pierrot,

    Unfortunately FSDS uses this weird code to write the bitmaps (this is to let old version of SCASM also compile the API code). Only changing the bitmap name is not enough, you also need to change the parameter that defines the length of the LoadBitmap command (as your new texture name is longer). This code should work:

    Code:
    Dwx( 0043 001E 0000 0001 ef38 3838 )
    Dba(FineCorrVrust.bmp)
  3. pierrot1951

    pierrot1951

    Joined:
    25/6/06
    Messages:
    305
    Country:
    france
    Hello! Tanks for quick answer! It works!!!
    In fact, I have a second other new metal texture FineCorrVrustbrace.bmp for doors:
    ...
    Dwx( 0043 0018 0000 0001 ef64 4054 )
    Dba(FineCorrVrustbrace.bmp)
    ...

    Could you explain me -if possible- how to change the code number in Dwx
    What is the meaning of parameters? is there a formula?
    Original texture file name was 2woodV.bmp:
    Dwx( 0043 0018 0000 0001 ef64 4054 )
    Dba(2woodV.bmp)

    Does exist a tuto about API programming? not to write aPI! but to understand how to do minor changes in existing API, such as colors or textures?

    Thanks for answer! Pierrot -FMEP
  4. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Pierrot,

    Actually this code is not really API code, it is writing information directly in the binary BGL format. So to fully understand you need to go even a step deeper into the code. I have not seen many tutorials about that, I am mainly using the INC files of BGLC when I look for information.

    The second parameters, the one I changed, is the total number of bytes used by the texture command. All parameters have a fixed length of 12 bytes and the remaining number is the length of your texture name. These two summed together form the value given there (rounded to an even value and in hex format).
  5. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Pierrot,

    I just thought of an easier solution. You could also just delete those two Dwx/Dba lines and replace it with the SCASM LoadBitmap command (that is the same command as written there in binary form). In that case you can just change the texture name without trouble:

    Code:
    LoadBitmap( 0 6 EF 38 38 38 2woodV.bmp )
  6. pierrot1951

    pierrot1951

    Joined:
    25/6/06
    Messages:
    305
    Country:
    france
    Thanks for help.
    I'll make try as soon as possible and tell you if it works.
    In the meantime, I used an other solution.
    As the 2 texture files "2wood.bmp" and "2woodV.bmp" seem not to be used so far in other bgl, I renamed my 2 new texture files with them. Not very good, but working!

    Pierrot - FMEP

Share This Page