OSG Text

From FlightGear wiki
Revision as of 13:24, 3 July 2014 by Flyingfisch (Talk | contribs) (Created page with "This document describes the syntax for text objects in the scene graph. Text nodes are configured using XML and may appear within a model description file, like other models o...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This document describes the syntax for text objects in the scene graph. Text nodes are configured using XML and may appear within a model description file, like other models or the particlesystem.

For the anxious reader, here is a complete example of a text node:

   <name>My first Text</name>
   <offsets>
     <pitch-deg>0</pitch-deg>
     <heading-deg>0</heading-deg>
     <roll-deg>0</roll-deg>
     <x-m>0</x-m>
     <y-m>0</y-m>
     <z-m>0</z-m>
   </offsets>
 
   <axis-alignment>xy-plane</axis-alignment>
 
   <type type="string">literal</type>
   <text type="string">Hello, world!</text>
   <type type="string">text-value</type>
   <property type="string">some/property</property>
   <format type="string">%s</format> 

   <type type="string">number-value</type>
   <property type="string">position/latitude-deg</property>
   <factor type="double">1.0</factor> 
   <offset type="double">0.0</offset> 
   <format type="string">%5.2lf</format> 
   <truncate type="bool">false</truncate> 

   <layout>left-to-right</layout> 
 
   <draw-text type="bool">true</draw-text> 
   <draw-alignment type="bool">false</draw-alignment> 
   <draw-boundingbox type="bool">false</draw-boundingbox> 

   led.txf 
   <character-size type="double">0.01</character-size> 
   <character-aspect-ratio type="double">1.0</character-aspect-ratio>
   <max-height>0.012</max-height> 
   <max-width>0.040</max-width> 
   <font-resolution>
     <width type="int">32</width>
     <height type="int">32</height>
   </font-resolution>

   <kerning>default</kerning>

   <alignment>center-center</alignment> 

 </text>

The <text/> node may appear within <model/> or <PropertyList/> nodes. If you place your text directly within your model file, use <text></text> nodes. You can also put your <text> configuration into a separate file using the well known include directive:

Your model.xml file:

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

 Your HelloWorld.xml:
 <PropertyList>
   <name>Hello World</name>
   Helvetica.txf
   <type type="string">literal</type>
   <text type="string">Hello, world!</text>
 </PropertyList>

Animation can be applied to text nodes like any other object. To give your text some color, use the material animation, or translate, rotate, scale or spin your text as you like.