OSG Text: Difference between revisions

Jump to navigation Jump to search
m
Indentation, fix typos, links, printf() → sprintf() (it's not printed ;) )
m (<code> tags)
m (Indentation, fix typos, links, printf() → sprintf() (it's not printed ;) ))
Line 1: Line 1:
Using '''OSG Text''' one can add text to models in FlightGear.  The text can be modified runtime and can be animated using many of the animations available.
Using '''OSG Text''', one can add text to models in FlightGear.  The text can be modified runtime and can be animated using many of the animations available.


Text are scene nodes configured using XML and may appear within a model description file, like other models or the particle system.
Text are scene nodes configured using [[XML]] and may appear within a model description file, like other models or the [[Particle System|particle system]].


== Syntax example ==
== Syntax example ==
Line 7: Line 7:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <!-- Must be enclosed by a <text/> node -->
<!-- Must be enclosed by a <text/> node -->
  <text>
<text>
     <!-- It should have a name. Can be used for other animations -->
     <!-- It should have a name. Can be used for other animations -->
     <name>My first Text</name>
     <name>My first Text</name>
     <!-- Use offsets for the initial placement -->
     <!-- Use offsets for the initial placement -->
     <offsets>
     <offsets>
      <pitch-deg>0</pitch-deg>
        <pitch-deg>0</pitch-deg>
      <heading-deg>0</heading-deg>
        <heading-deg>0</heading-deg>
      <roll-deg>0</roll-deg>
        <roll-deg>0</roll-deg>
      <x-m>0</x-m>
        <x-m>0</x-m>
      <y-m>0</y-m>
        <y-m>0</y-m>
      <z-m>0</z-m>
        <z-m>0</z-m>
     </offsets>
     </offsets>
    
    
Line 42: Line 42:
     <type type="string">text-value</type>
     <type type="string">text-value</type>
     <property type="string">some/property</property>
     <property type="string">some/property</property>
     <format type="string">%s</format> <!-- the printf() format to display the value -->
     <format type="string">%s</format> <!-- the sprintf() format to display the value -->
   
   
     <!-- A number from a property -->
     <!-- A number from a property -->
     <type type="string">number-value</type>
     <type type="string">number-value</type>
     <property type="string">position/latitude-deg</property>
     <property type="string">position/latitude-deg</property>
     <factor type="double">1.0</factor> <!-- optional, scale the propertie's value -->
     <factor type="double">1.0</factor> <!-- optional, scale the property's value -->
     <offset type="double">0.0</offset> <!-- optional, shift the propertie's value -->
     <offset type="double">0.0</offset> <!-- optional, shift the property's value -->
     <format type="string">%5.2lf</format> <!-- printf() format to display -->
     <format type="string">%5.2lf</format> <!-- sprintf() format to display -->
     <truncate type="bool">false</truncate> <!-- truncate to an integer value -->
     <truncate type="bool">false</truncate> <!-- truncate to an integer value -->
   
   
Line 68: Line 68:
     <max-width>0.040</max-width> <!-- the maximum width of the text -->
     <max-width>0.040</max-width> <!-- the maximum width of the text -->
     <font-resolution>
     <font-resolution>
      <width type="int">32</width>
        <width type="int">32</width>
      <height type="int">32</height>
        <height type="int">32</height>
     </font-resolution>
     </font-resolution>
   
   
Line 96: Line 96:
     -->
     -->
   
   
  </text>
</text>
</syntaxhighlight>
</syntaxhighlight>


Line 106: Line 106:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <model>
<model>
     <path>may-fancy-model.ac</path>
     <path>my_fancy_model.ac</path>
     <text include="HelloWorld.xml"/>
     <text include="HelloWorld.xml"/>
  </model>
</model>
</syntaxhighlight>
</syntaxhighlight>


Line 116: Line 116:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
<PropertyList>
  <name>Hello World</name>
    <name>Hello World</name>
  <font>Helvetica.txf</font>
    <font>Helvetica.txf</font>
  <type type="string">literal</type>
    <type type="string">literal</type>
  <text type="string">Hello, world!</text>
    <text type="string">Hello, world!</text>
  <!-- etc. - you get the idea -->
    <!-- etc. - you get the idea -->
</PropertyList>
</PropertyList>
</syntaxhighlight>
</syntaxhighlight>

Navigation menu