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-x type="int"> The width of the underlying texture
26 <size-y type="int"> The height of the underlying texture
28 <view-width type="int"> The width of the canvas
29 <view-height 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)
66 Create a <text> node and configure with the following properties:
68 <text type="string"> The text to be displayed
69 <font type="string"> The font to be used (Searched in
73 4. Default osg font paths
74 <size type="float"> The font size (default: 32)
75 <tf> A 3x3 transformation matrix specified by 6 values
76 (child elements <a>, ..., <f>) See
77 http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined
79 You can also use shortcuts and use an alternative to
80 specifying six values:
81 - Translation: <tx>, <ty> (ty, ty default to 0)
83 - Scale: <sx>, <sy> (sx is required, sy defaults to sx)
84 <alginment type="string"> Text alignment (default: "left-baseline") One of:
102 "left-bottom-baseline"
103 "center-bottom-baseline"
104 "right-bottom-baseline"
105 <draw-mode type="int"> A bitwise combination of the following values
108 4 (Filled boundingbox)
109 8 (Alignment -> Draw a cross at the position
111 <padding type="float"> Padding between for the boundingbox (default: 0)
113 <color-fill> Fill color (for the bounding box)
118 To place the canvas into the scene one ore more <placement> elements can be
119 added to the texture node. By setting at least on of the following nodes
120 the objects where the canvas texture should be placed on are selected:
122 <texture type="string"> Match objects with the given texture assigned
123 <node type="string"> Match objects with the given name
124 <parent type="string"> Match objects with a parent matching the given name
125 (Not necessarily the direct parent)
132 <size-x type="int">384</size-x>
133 <size-y type="int">512</size-y>
134 <view-width type="int">768</view-width>
135 <view-height type="int">1024</view-height>
136 <mipmapping type="bool">false</mipmapping>
137 <coverage-samples type="int">0</coverage-samples>
138 <color-samples type="int">0</color-samples>
141 <text type="string">TEST MESSAGE</text>
142 <font type="string">helvetica_bold.txf</font>
144 <!-- Translate (18|50) -->
151 <!-- Place on objects with the texture EICAS.png
152 and a parent called HDD 1 -->
153 <texture type="string">EICAS.png</texture>
154 <parent type="string">HDD 1</parent>