Sign in to follow this  
edgarone

Dynamic objects problem

Recommended Posts

Hello all. AutoAsm can create large numbers of animated objects linked to VTP lines, an obvious application being the creation of moving traffic on roads. However, I've hit a problem. It works fine up to about 400 objects, but above that bglc starts to generate error messages. Here's a typical error message: created_path.asm(1297) : error A2054 :forced error : value not equal to 0 : 65536ERRS16(1): Macro called from ADD_OBJECT(8): Macro Called from created_path.asm(1297): Include FileThe lines that seem to create these errors are similar to:object_416 label wordDCALL object_path_0_0I'm using Edgar Knobloch's macro. Thanks to Edgar for his tutorial, that's what got me started. I've included a shortened version of the ASM file below. Does anyone have any ideas? Is there a documented limit to the number of dynamic objects? Just one other basic question. The SDK has a list of objects you can use, including the refuelling truck. How does one use other objects as dynamic objects? Many thanks. Best regards, Chris ASM file for 420 dynamic objects:******************************************************************************************************include dyn_header.incdata_base label word; DATABASE HEADER ********************************************************dw 0001 ;00 world set numberdd 9890619 dd -9890619 dd 2135553183 dd -2135553184 dd 0 ;18 VOR_DATAdw 0 ;22 lowest vor freq (channel 0-199)dw 0 ;24 highest vor freq (108.00-117.95)dd 0 ;26 seeds level 8dd 0 ;30 seeds level 9dd 0 ;34 seeds level 10dd 0 ;38 seeds level 11dd 0 ;42 seeds level 12dd 0 ;46 seeds level 13dd 0 ;50 seeds level 14dd 0 ;54 seeds level 15dd 0 ;58 OBJECT_DATAdd 0 ;62 LIBRARY_DATAdd 0 ;66 FACILITIES_DATAdd 0 ;70 ANCHOR POINT DATAdd 0 ;74 COM RADIO DATAdd 0 ;78 ADF DATD_LAT48Add dyn_path_data - data_base ;82 DYNAMIC OBJECT PATHSdd 0,0 ;86 Library id mindd 0,0 ;94 Library id maxdd 0 ;102 MISC_DATA (ground alt db)dd 0 ;106 TITLE AND DESCRIPTION DATAdd 0 ;110dd 0 ;114 EXCEPTION LIST PTRdd 0 ;118dd 0 ;122 (not saved to filelist)dw 0 ;126 (not saved to filelist); DYN_PATH DATABASE *********************************************************dyn_path_data label wordrel_base = dyn_path_dataLATBAND_REL 4406, 4514, dyn_data_1EOL; loading section ***********************************************************dyn_data_1 label wordFE_DYNAMIC_HEADER 4514, 4406,4696, 4605, dynamic_endDYN_PATH_HEAD 4516, 4403,4698, 4603; activation section ******************************************************** SET_LAT_ANCHOR 2283732, 60074 object_1 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_1, 00110000bobject_2 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_2, 00110000bobject_3 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_3, 00110000bobject_4 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_4, 00110000bobject_5 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_5, 00110000b ETC ETC.......object_419 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_419, 00110000bobject_420 label word ADD_OBJECT MODEL_NEW_FUEL_TRUCK_ID,object_definition_420, 00110000b DYN_EOF;************** OBJECT 1 *******************object_definition_1 label wordSET_COLOR 0,C_DARK_OLIVE ; spinner SET_COLOR 1,C_DARK_OLIVE ; top fuselage SET_COLOR 2,C_LIGHT_BLUE ; bottom fuselage SET_COLOR 3,C_DARK_OLIVE ; stabs SET_COLOR 4,C_DARK_OLIVE ; wing ANTI_COLLISION_OFF TRUE SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE MOVE_XYZ 211, 5, 0, 0 SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE DCALL object_path_0_0 DJUMP object_definition_1;************** OBJECT 2 *******************object_definition_2 label wordSET_COLOR 0,C_DARK_OLIVE ; spinner SET_COLOR 1,C_DARK_OLIVE ; top fuselage SET_COLOR 2,C_LIGHT_BLUE ; bottom fuselage SET_COLOR 3,C_DARK_OLIVE ; stabs SET_COLOR 4,C_DARK_OLIVE ; wing ANTI_COLLISION_OFF TRUE SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE MOVE_XYZ 160, 5, 0, 0 SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE DCALL object_path_0_0 DJUMP object_definition_2 ETC ETC..............;************** OBJECT 418 *******************object_definition_418 label wordSET_COLOR 0,C_DARK_OLIVE ; spinner SET_COLOR 1,C_DARK_OLIVE ; top fuselage SET_COLOR 2,C_LIGHT_BLUE ; bottom fuselage SET_COLOR 3,C_DARK_OLIVE ; stabs SET_COLOR 4,C_DARK_OLIVE ; wing ANTI_COLLISION_OFF TRUE SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE MOVE_XYZ 246, 5, 0, 0 SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE DCALL object_path_0_0 DJUMP object_definition_418;************** OBJECT 419 *******************object_definition_419 label wordSET_COLOR 0,C_DARK_OLIVE ; spinner SET_COLOR 1,C_DARK_OLIVE ; top fuselage SET_COLOR 2,C_LIGHT_BLUE ; bottom fuselage SET_COLOR 3,C_DARK_OLIVE ; stabs SET_COLOR 4,C_DARK_OLIVE ; wing ANTI_COLLISION_OFF TRUE SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE MOVE_XYZ 53, 5, 0, 0 SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE DCALL object_path_0_0 DJUMP object_definition_419;************** OBJECT 420 *******************object_definition_420 label wordSET_COLOR 0,C_DARK_OLIVE ; spinner SET_COLOR 1,C_DARK_OLIVE ; top fuselage SET_COLOR 2,C_LIGHT_BLUE ; bottom fuselage SET_COLOR 3,C_DARK_OLIVE ; stabs SET_COLOR 4,C_DARK_OLIVE ; wing ANTI_COLLISION_OFF TRUE SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE MOVE_XYZ 32, 5, 0, 0 SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE DCALL object_path_0_0 DJUMP object_definition_420;*****************************************************************object_path_0_0 label word SET_LLA 2307934, 49208 , 305260498, 48227 , 0, 0 ANTI_COLLISION_OFF TRUE SET_HEADING 47671 MOVE_XYZ 15, -7,0,-1 SET_LLA 2307934, 49208 , 305259782, 58854 , 0, 0 ANTI_COLLISION_OFF TRUE SET_HEADING 32768 MOVE_XYZ 15, 0,0,-325 SET_LLA 2307609, 11342 , 305259782, 58854 , 0, 0 ANTI_COLLISION_OFF TRUE ETC ETC......... SET_LLA 2283794, 19768 , 305259782, 58854 , 0, 0 ANTI_COLLISION_OFF TRUE SET_HEADING 32768 MOVE_XYZ 15, 0,0,-325 SET_LLA 2283468, 47438 , 305259782, 58854 , 0, 0 ANTI_COLLISION_OFF TRUE SET_HEADING 32768 MOVE_XYZ 15, 0,0,-325 DRETURNdynamic_end label wordEOL

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi Chris,I think this error means that the label you are calling is further then 64 kB away in the resulting BGL file and I guess the command only has enough variable space for a 64 kB jump.Sometimes this can be solved by rewriting the source code a bit, so that the labels to jump to are closer. But if that is not possible you have reached the maximum number of objects :).

Share this post


Link to post
Share on other sites

Hello Chris,Arno is correct. This is not a limitation of the number of possible dynamic objects, but a limitation of the 16bit code structure in dynamic BGLs, which causes this compilation error.Basically ADD_OBJECT checks, if its behaviour function/address (the 2nd parameter) is not further away than 64kb.As a test you could provide all objects from the activation section with the same function "object_definition_1". This should compile.As a workaround you could try to outsource some of the functionality of "object_definition_XXX" into subroutines (a rekursive level of 1 is allowed for dynamic sceneries).Another point would be to drop the repetition of "ANTI_COLLISION_OFF TRUE" commands. This behaviour is either swithed on or off. So one command per "object_definition_XXX" function would be enough. (And if I remember right, on per scenery bgl file is sufficient).This should shrink the size of your "object_definition_XXX" functions.Nevertheless there is still the danger with this code, that at some point the 64k limit will be reached again.BTW, an interesting idea to populate the landscape!Cheers, Edgar

Share this post


Link to post
Share on other sites

Edgar - and Arno - many thanks for that. It makes perfect sense, in fact several things I had noticed are completely consistent with it. Fortunately, as you say, it does suggest possible solutions. Funnily enough, yesterday I did think about the ANTI_COLLISION command. I took it out and then for 420 objects there were no errors. But when I bumped it up to 450 the errors were back. I could probably also remove the SET_COLOR commands as they're redundant for the fuel truck. As a matter of interest, I added the ANTI_COLLISION command for a reason. In the earlier code the trucks were placed backwards depending on the road direction, and this had an interesting result. Quite often, because a truck was pointing backwards, both the truck and the trucks behind came to a halt, forming a large and static traffic jam! After a bit of head-scratching, I came to the conclusion that the LLA command always re-enabled anti collision. Adding ANTI_COLLISION after every LLA fixed this. But it's not needed now as the code always correctly sets the truck direction. It should be possible to re-arrange the text so that the components for each VTP line are placed relatively close together. If it works it may result in a 400 object limit for each road, which is considerably better than a 400 object limit for the entire scenery! I should be able to write the code for that today and I'll let you know how I get on. Could I just ask another question? Is there a way to use other objects as dynamic objects? The SDK wasn't very helpful on this unless I missed it. If all the road traffic consists of fuel trucks and nothing else it will be very boring.... Best regards and many thanks, Chris

Share this post


Link to post
Share on other sites

Arno, many thanks, I'm sure that's spot-on. Today I should be able to write some code that fixes this. A 400 object limit for each road wouldn't be too much of a problem! Best regards, Chris

Share this post


Link to post
Share on other sites

Hello Chris,> It should be possible to re-arrange the text so that the>components for each VTP line are placed relatively close>together. If it works it may result in a 400 object limit for>each road, which is considerably better than a 400 object>limit for the entire scenery! Do you want to create separate BGLs per road? This would interfere with the "only one active dynamic scenery at a time" limitation.Or do I misunderstand your suggestion?> Could I just ask another question? Is there a way to use>other objects as dynamic objects? The SDK wasn't very helpful>on this unless I missed it. If all the road traffic consists>of fuel trucks and nothing else it will be very boring....Unfortunately I never figured it out either...Regards, Edgar

Share this post


Link to post
Share on other sites

> Could I just ask another question? Is there a way to use>other objects as dynamic objects? The SDK wasn't very helpful>on this unless I missed it. If all the road traffic consists>of fuel trucks and nothing else it will be very boring....Hi Chris,Yes there is. I am posting an example with one object (I had 5 or 6 but I cut for the sake of clarification. One AirbusA340 jet was left). It is Scasm and I hope it could be useful. Regards, LuisSet( areamx 64 )Header( 1 37:30:00.0000 36:30:00.0000 -7:30:00.0000 -8:30:00.0000 )LatRange( 36:30:00.0000 37:30:00.0000 )Macro( "C:FSASDv2ASDesignMacrosXD_Start.scm" 37:00:52.0745 -7:58:08.8068 10 20 )Macro( "C:FSASDv2ASDesignMacrosXD_P_A340.scm" 4 )ExitMacro( "C:FSASDv2ASDesignMacrosXD_A340.scm" 37:01:07.0717 -7:57:58.8384 0.000000 9.0 static )End15;ASDesign Compatible Macro;Name=D_Start, Type=Dynamic, Bitmap=dyn.bmp, ;FixedLength=20, FixedWidth=20, ;Latitude, Longitude, Internal=10, External=20, ; Parameters; 1 = latitude; 2 = longitude; 3 = internal radius (in km); 4 = external radius (in km) Uvar( $maxlat [%1 + [%3 / 111.120]] )Uvar( $minlat [%1 - [%3 / 111.120]] )Uvar( $maxlon [%2 + [%3 / [111.120 * cos(%1)]]] )Uvar( $minlon [%2 - [%3 / [111.120 * cos(%1)]]] ) Uvar( $maxlat2 [%1 + [%4 / 111.120]] )Uvar( $minlat2 [%1 - [%4 / 111.120]] )Uvar( $maxlon2 [%2 + [%4 / [111.120 * cos(%1)]]] )Uvar( $minlon2 [%2 - [%4 / [111.120 * cos(%1)]]] )Area15( [$maxlat] [$minlat] [$maxlon] [$minlon] [$maxlat2] [$minlat2] [$maxlon2] [$minlon2] )LatRef( %1 );ASDesign Compatible Macro;Name= D_P_A340, Type=Dynamic, Bitmap=dyn.bmp, ;FixedLength=20, FixedWidth=20, ;Density=4,; Parameter; 1 = complexity ( 0 1 2 3 4 ) :WA340CallDLibObj( :A340 3 %1 D8C414C0 B02300DE FCBC053C BB50258B );ASDesign Compatible Macro;Name= D_A340, Type=Dynamic, Bitmap=dyn.bmp, ;FixedLength=58, FixedWidth=62, ;Latitude, Longitude, Elevation=0, Rotation=0, ;PathName=static, ; Parameters:; 1 = latitude; 2 = longitude; 3 = elevation above sea level; 4 = heading; 5 = pathname:A340 SetPos( %1 %2 %3 ) Heading( %4 )Dyn_Path( %5 ) Jump( :A340 )

Share this post


Link to post
Share on other sites

Hello Edgar, I'm only creating one bgl file - I knew about the limitation. My idea was to re-arrange the elements in the ASM file so that they are close to the road they belong to. I've written some new code. It breaks up the sections in the file and places all of the sections for a given road close together. It works beautifully. In the test I had ten roads. So far I have tested it up to 20,000 objects total with no errors. The ASM file was 5.3 Mb and the bgl file was 440Kb. It worked in FS apart from the problem I'm just coming to. That's the good news. The bad news is that there may be a limit to the total number of objects. I assigned 50 objects per road. The first 4 roads spawned objects at a normal rate. The next road spawned objects at a much lower rate, and the other roads had no objects at all. This strongly suggests a limit something over 200, possibly 256. I hope this limit, if that's what it is, can be removed, otherwise the traffic is going to be pretty sparse! I recall that FSRail could create large numbers of road vehicles, possibly in the thousands, so maybe it can be done. I'm not completely surprised, though. In my experience FS tends to be riddled with arbitrary limits. I remember quite a few years ago the use of dynamic objects was quite limited because the data could not exceed 32k. Even in those days 32k was a tiny amount, the memory equivalent of loose change.... Best regards, Chris

Share this post


Link to post
Share on other sites

Luis, thank you very much for that. Unfortunately I'm not using Scasm and I know very little about it. But I'll take a look to see if it offers any hints.... Best regards, Chris

Share this post


Link to post
Share on other sites

Hello,Chris, why you thinking only about machines?A nice (Gmax)

Share this post


Link to post
Share on other sites

Hi Chris,> Could I just ask another question? Is there a way to use>other objects as dynamic objects? The SDK wasn't very helpful>on this unless I missed it. If all the road traffic consists>of fuel trucks and nothing else it will be very boring....I have read somewhere how someone converted a GMax objects to a dynamic library. But it is quite some time ago, so I can't remember where it was. But I think you should be able to use your own library objects (only the library format is different).

Share this post


Link to post
Share on other sites

Hi all.Here's the link to the Dynamic lirbary object creation:http://forums.avsim.net/dcboard.php?az=sho...17234&mode=full( The lack of shadows I was complaining about are set as aircraft shadows... which I had shut off in my sim to increase framerates ).If you look at the code, I hack a bit into the _0.asm code, while Gerd hacks just the .asm code ( with the same effect ).note: these gmax codes are from the FS2002 MakeMDL.I never did resolve the "floating" of the objects, and I have had some problems with objects tilting as well... as if they have landing gear deployed! :(As a side note, It is generally easier to make FS2002 libraries ( Dynamic or not ) from SCASM, as the code is generally easier to read. The problem is that we cannot convert our FS2002 ASM code to SCASM easily. But I did stumble on a way to do just this. The _0.asm code is RAW BGL code, so I made a tool to convert the _0.asm file to SCASM DB code:http://www.cfcforums.com/showpost.php?p=147687&postcount=1As that article explains, we can "Include" this raw SCASM code to complete the library object. Kind of a neat way to meld SCASM and ASM.Please also note, the code used is for a "damagable" CFS2 library object. A Dynamic library object should also be able to use a variation of this code and a RAW SCASM include derived from GMAX's _0.asm code.Dick

Share this post


Link to post
Share on other sites

>Hello,>Chris, why you thinking only about machines?>A nice (Gmax)

Share this post


Link to post
Share on other sites

Hello Chris,I followed the link to the post from the user Au Mav/ wozzo to the freeflight forum and remembered my poor approach using dynamics in FS and the tools.I could not get grips to that!(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this