1 Canvas - A 2D Drawing API
2 =========================
4 Author: Thomas Geymayer <admin@tomprogs.at>
10 With the increasing complexity of (glass) cockpits the need for a simple API to
11 draw on a 2D surface without modifying the C++ core increased heavily in the
12 last time. The 2D canvas is an effort to satisfy this needs. It is now possible
13 to create offscreen rendertargets only by using the property tree and placing
14 them on any 3D object on the aircraft by using certain filter criteria.
16 Currently it is only possible to place text on the canvas but 2d shapes (using
17 OpenVG) are going to follow.
22 A new canvas can be instantiated by creating a node /canvas/texture[<INDEX>]
23 with at least the following children:
25 <size n="0" type="int"> The width of the underlying texture
26 <size n="1" type="int"> The height of the underlying texture
28 <view n="0" type="int"> The width of the canvas
29 <view n="1" type="int"> The height of the canvas
31 The dimensions of the canvas are needed to be able to use textures with
32 different resolutions but use the same units for rendering to the canvas.
33 Therefore you can choose any texture size with the same canvas size and always
34 get the same results (apart from resolution dependent artifacts).
38 Optionally you can enable mipmapping and/or multisampling (Coverage Sampling
41 <mipmapping type="bool"> Use mipmapping (default: false)
42 <coverage-samples type="int"> Coverage Samples (default: 0)
43 <color-samples type="int"> Color Samples (default: 0, always
44 have to be <= coverage-samples)
48 Drawing to the canvas is accomplished by creating nodes as childs of the
49 canvas root node. Every shape has to be a child of a <group> node. Currently
50 only drawing Text is possible:
53 The following parameters are used by multiple elements:
56 A color can be specified by the following subtree (NAME is replaced by
57 another name depending on the usage of the color)
67 Create a <text> node and configure with the following properties:
69 <text type="string"> The text to be displayed
70 <font type="string"> The font to be used (Searched in
74 4. Default osg font paths
75 <character-size type="float"> The font size (default: 32)
76 <character-aspect-ratio type="float"> Ratio between character height and width
78 <tf> A 3x3 transformation matrix specified by 6 values
79 (child elements <m n="0">, ..., <m n="5"> which equal to a,
80 ...,f used in the SVG standard) See
81 http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined
83 You can also use shortcuts and use an alternative to
84 specifying six values:
85 - Translation: <t n="0">, <t n="1"> (both default to 0)
87 - Scale: <s n="0">, <s n="1"> (s[0] is required, s[1]
89 <alginment type="string"> Text alignment (default: "left-baseline") One of:
107 "left-bottom-baseline"
108 "center-bottom-baseline"
109 "right-bottom-baseline"
110 <draw-mode type="int"> A bitwise combination of the following values
113 4 (Filled boundingbox)
114 8 (Alignment -> Draw a cross at the position
116 <padding type="float"> Padding between for the boundingbox (default: 0)
118 <color-fill> Fill color (for the bounding box)
123 To place the canvas into the scene one ore more <placement> elements can be
124 added to the texture node. By setting at least on of the following nodes
125 the objects where the canvas texture should be placed on are selected:
127 <texture type="string"> Match objects with the given texture assigned
128 <node type="string"> Match objects with the given name
129 <parent type="string"> Match objects with a parent matching the given name
130 (Not necessarily the direct parent)
137 <size n="0" type="int">384</size-x>
138 <size n="1" type="int">512</size-y>
139 <view n="0" type="int">768</view-width>
140 <view n="1" type="int">1024</view-height>
141 <mipmapping type="bool">false</mipmapping>
142 <coverage-samples type="int">0</coverage-samples>
143 <color-samples type="int">0</color-samples>
145 <red type="float">0</red>
146 <green type="float">0.02</green>
147 <blue type="float">0</blue>
148 <alpha type="float">1</alpha>
152 <text type="string">TEST MESSAGE</text>
153 <font type="string">helvetica_bold.txf</font>
154 <character-size type="float">40</character-size>
156 <!-- Translate (18|50) -->
163 <!-- Place on objects with the texture EICAS.png
164 and a parent called HDD 1 -->
165 <texture type="string">EICAS.png</texture>
166 <parent type="string">HDD 1</parent>