API macro custom object symbol

From FSDeveloper Wiki
Revision as of 06:39, 4 March 2016 by Arno (talk | contribs) (Reverted edits by MichaelCox (talk) to last revision by BASys)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

When you have made an API macro and want to place it with a program like Airport for Windows or FSSC you will often see the shape of the object on the screen. But for some object there is no shape or it is not accurate enough. This is because the object symbol is not defined correctly. In this article I will explain how you can modify the object symbol.

Code Example

The position of the object symbol should be at the top of the API macro, before any of the actual code of the object. Below you see an example of an object symbol.

mif( 0 )
; displays airport symbol
Area( 5 %1 %2 1 )
RotatedCall( :symbol 0 0 %5 )
Jump( :endsymbl )
:symbol
RefPoint( 7 : 0.5 %1 %2 )
Points( 0
-5 0 -5
-5 0 5
5 0 5
5 0 -5 )
Poly( a 0 1 2 3 )
Return
:endsymbl
EndA
mifend

Let's explain what each segment of the code does.

The first command is just the SCASM conditional check. And because there are no arguments attached to it, it will always fail. This means that when compiling this code nothing of it will end up in the BGL you make. It is only used by programs like FSSC.

Following this check you will find the Area and RotatedCall command. This last command is needed to let the symbol rotate when you enter a heading while placing the object.

The next important command is the RefPoint command. The parameter 0.5 is the scale that is used in the rest of the code to define the symbol. If you want to have a symbol that is very accurate you might want to use a lower scale, because now the smallest distance that can be displayed is 0.5 meter. In general this will be enough for a symbol though.

The next command is the point list. In here you need to define all points that you need to define your symbol. In this example I just defined a box of 5x5 meter.

The last command is the Poly command, this draws the actual symbol defining the points that are used. In this case a line is drawn from point 0 to point 1, 2, 3 and then back to point 0. For more complex symbols you might need to use more then one Poly command.

Example

Below you find the example code and a picture of how a more complex symbol could look like. In this case a bigger scale was used for the symbol, because the entire object had been designed for a scale of 0.1.

mif( 0 )
Area( 5 %1 %2 1 )
RotatedCall( :symbol 0 0 %5 )
Jump( :endsymbl )
:symbol
RefPoint( 7 : 1 %1 %2 )
Points( 1
-4 0 -111
1 0 -111
1 0 112
-4 0 112
0 0 -111
160 0 -111
160 0 112
0 0 112
-84 0 -111
-4 0 -111
-4 0 112
-84 0 112
-69 0 -126
-39 0 -126
-39 0 -111
-69 0 -111
)
Poly( a 1 2 3 4 )
Poly( a 5 6 7 8 )
Poly( a 9 10 11 12 )
Poly( a 13 14 15 16 )
Return
:endsymbl
EndA
mifend

Object symbol.jpg