Jump to content


* - - - - 1 votes

Creating a Library of API Objects


  • Please log in to reply
1 reply to this topic

#1 IBtheSarge

IBtheSarge

    First Class Member

  • Moderator
  • PipPipPipPipPipPipPipPip
  • 10,718 posts
  • Location:Central Florida

Posted 30 March 2006 - 12:22 PM

First, you cannot create a usable LibraryObjects file of API objects unless you have both the API and SCA versions of the object.  This tutorial is for those who create their own objects and export in both formats, or where the original designer has provided both formats.  Second, you will need SCASM, Notepad, and Wordpad to create the file -- SCASM does the compiling, Notepad edits the API file, Wordpad edits the SCA file and creates the XML LibObj file.

=====================================================

Step 1:  Make a working directory and place SCASM and the API/SCA files that you are going to work with in this directory.  MAKE SURE THE API AND SCA HAVE THE SAME NAME (i.e., car01.api and car01.sca); it can work with different names, but it's MUCH easier on you if they're the same, plus the API and SCA will always be side-by-side in the directory.  If you have a thumbnail of each object, name it the same as the API and you'll have all three next to each other; that makes it VERY easy to pick the objects you want to place, and do a quality-control check to make sure you have both the API and SCA so placement will actually occur.   :D

Step 2:  Use Notepad to open the API file.  You will need to change some data.

If you want to make the API a little less framerate unfriendly, scroll down until you find the line ShadowCall( :PC02 ).  Delete it.  Four lines below that you should find the line :PC02; delete it, too.  Those two lines cause the object to cast a ground shadow, which is a feature of scenery objects that can absolutely KILL framerates, depending on how many objects are in view.

Now, scroll all the way to the bottom of the file where you will find the lines
Return
:Exit
EndA
You're going to add a line just before Return; but to do it, you will need to create a GUID for the object.  This can be anything you want it to be, as long as it consists of four blocks of eight characters per block -- something like this:  
CallLibObj( 0 32135765 32135765 32135765 00000001 )
Notice the spacing in that line -- no space between LibObj and the parenthesis, space after the parenthesis, a 0 and a space before the first block of eight characters, space between each block, space between the last character of the last block and the closing parenthesis.  Your line must look EXACTLY like this when you're finished.  It is STRONGLY suggested that you keep a list of the GUIDs you create and the names of the objects that goes with them.  Keep a running list somewhere -- on paper, in a spreadsheet, whatever.  (Mine are entered into an Excel spreadsheet that lists the GUID, object name, size of the object [aka footprint], and the textures that go with the object.)

The first three blocks can be any eight characters you want them to be; just try to keep it unique to yourself and something you can remember.  You're going to be creating this line for every API you add to the LibObj file; but, you can simply copy-paste the line in and only change the last block.  The last block is the numerical identifier of the object, usually sequential (first API is 00000001, second is 00000002, etc.).  After adding this line, you should see this (with your own numbers in the block, of course):  
CallLibObj( 0 32135765 32135765 32135765 00000001 )
Return
:Exit
EndA
Exit Notepad and click "Yes" to save the edited file.

Step 3:  Use Wordpad to open and modify the SCA file of the API you just modified.  You don't have to change any data in this file, only remove some lines of code that are not needed.  Scroll down until you find the line BGLVersion( 0800 ).  Delete everything above this line, but NOT this line.  Now scroll down to the bottom of the file where you will find the lines
TransformEnd
Return
:Exit
EndA
Delete the last two lines so the bottom now looks like
TransformEnd
Return
Close Wordpad and click "Yes" to save the edited file.

Step 5:  It is now time to create the library file.  Be sure that you are able to change filename extensions in your "Rename" option; you will need to be able to do it after you save the file you are about to create.  When you're ready, open Wordpad and create the following:  
; **********************************
; MY TEST LIBRARY.BGL FILE
; **********************************
Header( 1 80 -80 -179 180 ); object header
CopyRight( YOUR NAME © 2003 )
Set( BUF 1024 )
Set( areamx 1024 )
Set( LINBUF 2048 )

;***********************************
; MYBOX OBJECT
;***********************************
ObjId( 32135765 32135765 32135765 00000001  )
LibObj( PWR 0 SIZE 10 SCALE 1 TYPE 0x401 NAME red_box_object  ) 
Include( mybox.sca )
Return
EndObj
There are two lines in the first part that you will change -- the header line (between the asterisks) and the copyright line.  Here's the way I've done it -- it's up to you what you put in there:  
; **********************************
; MILITARY API OBJECTS
; **********************************
Header( 1 80 -80 -179 180 ); object header
CopyRight( Check Six! Designs © 2005 )
Set( BUF 1024 )
Set( areamx 1024 )
Set( LINBUF 2048 )
Now for the second section.  Rename the header MYBOX OBJECT with the name of the particular API, replace the 32135765 32135765 32135765 00000001 with the GUID you created for that API (notice there's no "0" between the open parenthesis and the first character of the first block).  Change red_box_object to the name of the API file, MINUS the file extension, and change mybox.sca to the name of the SCA file WITH the file extension.  Your code should now look similar to this:  
; **********************************
; MILITARY API OBJECTS
; **********************************
Header( 1 80 -80 -179 180 ); object header
CopyRight( Check Six! Designs © 2005 )
Set( BUF 1024 )
Set( areamx 1024 )
Set( LINBUF 2048 )

;***********************************
; FB-111A HANGAR FLO-THRU NUMBER 1
;***********************************
ObjId( 12345678 90123456 78901234 00000001  )
LibObj( PWR 0 SIZE 10 SCALE 1 TYPE 0x401 NAME FtrHgr_FT  ) 
Include( FtrHgr_FT.sca )
Return
EndObj
With your own data in the appropriate places, of course.  To add more APIs to the library, simply add copies of the second section -- i.e.,
**********************************
; MILITARY API OBJECTS
; **********************************
Header( 1 80 -80 -179 180 ); object header
CopyRight( Check Six! Designs © 2005 )
Set( BUF 1024 )
Set( areamx 1024 )
Set( LINBUF 2048 )

;***********************************
; FIGHTER HANGAR FLO-THRU
;***********************************
ObjId( 12345678 90123456 78901234 00000001  )
LibObj( PWR 0 SIZE 10 SCALE 1 TYPE 0x401 NAME FtrHgr_FT  ) 
Include( FtrHgr_FT.sca )
Return
EndObj

;***********************************
; BOMBER HANGAR TAXI-IN
;***********************************
ObjId( 12345678 90123456 78901234 00000002  )
LibObj( PWR 0 SIZE 10 SCALE 1 TYPE 0x401 NAME BmbrHgr_TI  ) 
Include( BmbrHgr_TI.sca )
Return
EndObj
and so on.  On the Wordpad toolbar, select "File" and Save As."  Save the file to the working directory and give it a name -- i.e., MilObjs -- and click "Save."  Exit Wordpad, right click on the file you just created, select "Rename" and change the file extension to "SCA."

Step 6:  Drag-and-drop your LibObjs SCA file on the SCASM icon.  If you have followed this tutorial precisely, careful about spacing and character count and everything else, in a few seconds you should see a BGL file appear with the same name as the SCA file (MilObjs.bgl for example).

=====================================================

That's it.  You now have a Library Objects file for API objects.  As you make/find new API objects (with the associated SCA file, remember that you need both), you can add them by simply placing the API/SCA files in your working directory, editing the SCA library file, and dropping it on the SCASM icon.  If you provide your scenery to others, all you need to provide is the PLACEMENT BGL (that's another tutorial) and the textures for the objects.  The library file stays with you.

:D

Edited by sarge, 30 March 2006 - 04:08 PM.


#2 Jon

Jon

    Administrator

  • Admin
  • PipPipPipPipPipPip
  • 3,140 posts
  • Location:South Carolina, USA

Posted 05 April 2006 - 09:09 PM

Added to Knowledge Base :D