Dynamic object creation
The dynamic scenery consists mainly of two different filetypes. One file that holds all the object data, Fs often calls them something with “lib”. Secondary a file that controls the object how to behave, if it should move, change color or textures and much more. This file I will refer to as the dynfile. If we want to texture the object we also need a texturefile ! This first tutorial is about the libfile and how to create it. I often use dynamic objects when creating scenery. Why ? The main reason is that it’s easy to have control in “runtime” of the objects. Then you avoid the continous loading and reloading of textures. The textures are loaded as long as the dynamic scenery is loaded and the dynamic scenery is loaded as long as you are in the area defined by the dynfile. When you work with the dynfile you don’t have to restart FS over and over again to see the result, you only have to deactivate/reactivate the dynamic scenery ( Option/Settings/Display/Add-on Dynamic Scenery ) and you see the new dynfile. It must have the same name, though. The disadvantage is that you have no software with a fancy GUI to use for this purpose so notepad, or similar, will become your nearest friend ! But first we need a dynamic object and where do we find them ? Unfortunately we find them nowhere so we have to make them ourselves.
If you have coded an object in FSDS.2 and saved as a sca-file, you have a header like this :
Header( 1 42:30:00.0000 41:30:00.0000 -86:30:00.0000 -88:30:00.0000 ) LatRange( 41:30:00.0000 42:30:00.0000 ) Area( 6 41:51:25.8498 -87:36:30.3435 35 ) PerspectiveCall( :PCall ) ShadowCall( :PCall2 ) Jump32( :Exit ) :PCall Perspective :PCall2 RefPoint( 7 :Skip 0.100000 41:51:25.8498 -87:36:30.3435 E= 264 v1= 32000 V2= 20 ) Jump( :Continue ) :Skip Return :Continue ; CRASH Detection IfVarRange3( :NoCrash 37E -100 100 382 -100 100 386 -100 100 ) SetVar( 0284 14 ) :NoCrash BGLVersion( 0800 ) MaterialList( 0 .......objectcode.... EndA
You have to change it to :
Header( 1 80 -80 -179 180 ) LatRange( S94:21:19.18 N94:21:19.18 ) ObjId( DD0000B0 0AB345AE A9000000 00000D33 ) LibObj( PWR 100 SIZE 2 SCALE 1.0 TYPE 2 NAME "MyObject" ) ShadowPosInd( 0000 ) ReScale( :L014 0 0 1.0000 ) ShadowCallVI( :L044 0018 ) :L014 RefPoint( ofs :L036 0 0 0000 ) ReScale( :L036 0 0 1.0000 ) PBHCall( :L044 0018 ) :L036 Return :L044 MaterialList( 0 ........object code EndObj
The third line “ObjId ( DD0000B0 0AB345AE A9000000 00000D33 )” holds the Guid of the object and it has to be formatted this way. All in the header that has to do with scale or scaling sets of course the scale of the object. I have found out that you have to set the scale to 1/10 of what you use in common Api´s and if you are not satisfied, experiment ! If you don’t want shadows comment out the shadow like this ;
;ShadowPosInd ( 0000 )
If you work with Gmax you have to compile it with FS2002 gamepack, then decompile it with BglAnalyzer,
And you will have a header like this :
ObjID(DD0000B0 0AB345AE A9000000 00000D33) LibObj( PWR 100 SIZE 3 SCALE 0.500 TYPE 0 NAME "OneMoreObject" ) BGLVersion( 0800 ) TextureList( 0 1 FF 255 255 255 OneMoreObj.BMP ; texture 0 ) MaterialList( 0 ...more code EndA
The change of header is similar, replace with the same as the FSDScode. You can change the header in the same manner if you use EOD or have a Zmodeler file. Don’t forget to change the last line to “EndObj” instead of “EndA” An extra line like “Set ( Logfile 1 )” makes the compilator write a logfile and you will be able to see what eventually went wrong !
Almost ready. Probably you now will see your object a couple of meters above the ground. Well, it is a flightsimulator eh…? The solution is the Transform_Mat command.
Example :
Transform_Mat (a 0 -10 0 0 0 0 ) ...objectcode... TransformEnd
Or like this in a Fsds-Object:
Transform_Mat (a 0 -10 0 0 0 0 ) ; Draw Main Model Call32( :Part000000 ) Call32( :Part000001 ) Call32( :Part000002 ) Call32( :Part000003 ) TransformEnd Return
Or like this in a Eod-Object:
Transform_Mat (a 0 -10 0 0 0 0 ) Call( :Lamps1 ) Call( :Lamps2 ) TransformCall( :part000 0 6 0 0 0 0 0 0 0 ) ;Custom object 1 TransformCall( :part001 33 12 0 0 0 0 0 0 0 ) ;Cube 3 TransformCall( :part002 -71 12 0 0 0 0 0 0 0 ) ;Cube 6 TransformCall( :part003 -68 39 0 0 0 0 0 0 0 ) ;Extended Cube 7 TransformCall( :part005 -220 0 0 0 0 0 0 0 0 ) ;Base 9 TransformCall( :part006 0 15 0 0 0 0 0 0 0 ) ;Custom object 1_02 TransformCall( :part007 -81 45 0 0 0 0 0 0 0 ) ;Cylinder 11 TransformCall( :part008 -84 12 0 0 0 0 0 0 0 ) ;Cube 6_02 TransformEnd Return
and if you have a decompiled Gmax-Object :
Transform_Mat (a
0 -10 0
0 0 0
)
DrawTriList( q
20 59 52 ; poly=30 part=1
56 57 47 ; poly=2 part=1
53 51 57 ; poly=3 part=1
77 53 57 ; poly=4 part=1
76 77 57 ; poly=5 part=1
76 57 56 ; poly=6 part=1
67 53 77 ; poly=7 part=1
60 67 77 ; poly=8 part=1
……………….
TransformEnd
Here I have moved the object 10 units down. The size of the units is depending on the scalefactor of the object.
The axisorder in the first line with numbers, is DirectX-standard, X, Z, Y and it’s the Z-axis we want to change.
Line three in this command, here “0 0 0 “, represent pitch, bank and heading. So if you have an object created “in the wrong direction” you can turn it by, for example, 90 degrees clockwise this way :
Transform_Mat (a 0 -10 0 0 0 90 ) ...objectcode... TransformEnd
To test your object you can use the code below. Copy and paste it to a text/sca file.
It will show the object in the middle of RWY24/06 at ESCN/Tullinge.
Set( Area15mx 32 )
Header( 1 N59:12:41 N59:07:18 E018:00:15 E017:49:44 )
LatRange( N59:07:18 N59:12:41 )
; Dynamic Scenery section
Area15( N59:12:41 N59:07:18 E018:00:15 E017:49:44 )
LatRef( N59:10 )
CallDLibObj( :DYN01 3 3 DD0000B0 0AB345AE A9000000 00000D33 )
Exit
:DYN01 ;
SetPos( N59:10:56.3844 E017:55:11.7516 55 )
Heading( 243.6614 )
ACS( 1 ) ; crash control= OFF
Hold ( 5 )
Sleep
Jump( :DYN01 )
End15
Set ( Logfile 1 )
Compile with scasm, install the bgl´s in an active sceneryfolder and enjoy !
Good Luck, Peter
Where to find Scasm and info:
Scasmdoc :http://www.scasm.de/doc/index.htm