Jump to content
Sign in to follow this  
Guest gorchi

API to Library object?

Recommended Posts

Guest GeorgeDorkofikis

Hello all,Long time... Limited free time keeps me away from scenery design.I have another hard question for you. How do I make a library out of APIs and how do I access the library objects from within SCASM or Airport for windows? I have a lot of 3D objects in my designs that are practically the same just repeating and I thought that if I make them library objects FS would load them only once istof 40-50 times it does now.Any (detailed, for dummies) help appreciated!Thanks!George DorkofikisAthens, Greece

Share this post


Link to post
Share on other sites
Guest gorchi

Hi George!It is not so easy thouh it is not as well complicated. Making library bgl will still need a calling API, but is is a loooot smaller. If You do not need to pass any variables to library bgl (i.e. Lights on-off, variable for different colors, variable for choosing texture etc.) then it is easy. Calling api substituetes all Points(), Texpolys, Calls... into one CallLibObj().In library BGL, You put everything You have substituted with CallLibObj() in the enclosement StartLibObj()/EndObj.This is more or less general how to, for more details see the word document attached to API kcarlib.zip (Andreas Klisch) on www.flightsim.com and from him also look for tutorial on http://www.combatflight.de/html/start.html.Passing variables is quite tricky and I needed some time to guess how it works. But remember:- if You have LoadBitmap() instructions and they are seson sensitive or light sensitive, they will work in Library BGL- if You need do turn on/off some lights, You will need to pass variable 28c there. Global variables must be passed to library bgl so object will work as expected- You can not pass name of texture from API to library BGL. I have seen a long time ago on flight sim forum, that it can be possible butI havent succeeded yet.This is for start. Hope it will help You!Best regards,Goran BrumenFS Slovenija 2002 teamhttp://slovenia.avsim.net

Share this post


Link to post
Share on other sites
Guest GeorgeDorkofikis

Hi Goran!Thanks for the reply!Fortunately I do not need to pass any variable EXCEPT the 28C for the lights control.flightsim.com is hard to access but I did find the tutorial over at combatflight.de. So, I'll start with that and see how it goes.Thanks for the help!George DorkofikisAthens, Greece

Share this post


Link to post
Share on other sites

I never passed any variable to my libraries and still they work fine. Just by using them in the library code like you would do in normal code.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites
Guest GerrishGray

Hi guysI think this got a bit misleading. There is no problem with normal global variables in library objects, as Arno says. The problem is when you try to pass user parameters - the 'user variables' reserved in the global variable list don't work correctly. So one has to use a true local variable defined in the calling code and set the variable base to local before calling the library object. Then the library object can 'receive' and read the local variable value OK. See Andreas Klisch's karlib for an excellent example/tutorial.CheersGerrish

Share this post


Link to post
Share on other sites
Guest GeorgeDorkofikis

So, to get it right. :-)Global FS variable like daytime control, a/c delta etc are NOT required to be passed to the libraries and they are used as I already used them in the original API.Correct ?Thanks for your help guys,Much appreciated!George DorkofikisAthens, Greece

Share this post


Link to post
Share on other sites
Guest GerrishGray

Yes, that's right George. You can do just about anything in a section 10 library object that you can do in a section 9 API after you have set the Lat/Lon location and scale. The only global variables that cannot be correctly tested inside a library object are the five 'user variables' at offsets 0x312 etc. And you cannot change the Lat/Lon location or the scale, but you can use the commands that transform the local coordinates for the object (i.e. TransformCall, RotatedCall, RotateToAircraft, Transform_Mat, Animate). With the old style of crash detection there was a special way of setting it up for library objects using the CrashIndirect command because of the reliance on Lat/Lon position etc., but if you use the new style with a CrashOctTree there is no problem and no special setup or CrashIndirect is needed in the calling API.CheersGerrish

Share this post


Link to post
Share on other sites

Hi Gerrish,I have made animations that use the user variables as well and these also work fine when I place them in a library. So I didn't notice that limitation.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites
Guest GerrishGray

Hi ArnoBut how did you use the variable(s)? If you simply used them inside the object to control the animation, then all should be fine (providing that no other scenery or animation interferes and changes the value of the selected variable while the animation is running). The problems occur when you try to use one of the global user variables to pass an argument from the calling code to the object - there is a tendency for all instances of the library object to receive the same fixed value that was passed when the object was first instantiated, and it can be difficult (impossible?) to change the value. Things works much better if you create unique local variables and use those to pass values to the object(s), because (a) there is no risk of outside interference, and (:( each separate object call has its own unique instance of the variable and reliably receives the correct value.CheersGerrish

Share this post


Link to post
Share on other sites

That must be it then. I set and read the variable only inside the library object, I don't use it to pass something.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites
Guest gorchi

Hi Arno and Gerrish!I do not remember but as I remember, I had problems when lights on library BGL objects should go on after the dark and I haven't found any better solution but sending variable 28C into library BGL using VarBase... I think I should try again using these variables...Thanks for Your opinions!Best regards,Goran BrumenFS Slovenija 2002 teamhttp://slovenia.avsim.net

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...