Canvas - A 2D Drawing API ========================= Author: Thomas Geymayer Revision: 2012/05/04 Introduction ------------ With the increasing complexity of (glass) cockpits the need for a simple API to draw on a 2D surface without modifying the C++ core increased heavily in the last time. The 2D canvas is an effort to satisfy this needs. It is now possible to create offscreen rendertargets only by using the property tree and placing them on any 3D object on the aircraft by using certain filter criteria. Currently it is only possible to place text on the canvas but 2d shapes (using OpenVG) are going to follow. Creating a canvas ----------------- A new canvas can be instantiated by creating a node /canvas/texture[] with at least the following children: The width of the underlying texture The height of the underlying texture The width of the canvas The height of the canvas The dimensions of the canvas are needed to be able to use textures with different resolutions but use the same units for rendering to the canvas. Therefore you can choose any texture size with the same canvas size and always get the same results (apart from resolution dependent artifacts). * Filtering: Optionally you can enable mipmapping and/or multisampling (Coverage Sampling Antialiasing): Use mipmapping (default: false) Coverage Samples (default: 0) Color Samples (default: 0, always have to be <= coverage-samples) Drawing ------- Drawing to the canvas is accomplished by creating nodes as childs of the canvas root node. Every shape has to be a child of a node. Currently only drawing Text is possible: * General: The following parameters are used by multiple elements: Color: A color can be specified by the following subtree (NAME is replaced by another name depending on the usage of the color) * Text: Create a node and configure with the following properties: The text to be displayed The font to be used (Searched in 1. aircraft-dir/Fonts 2. aircraft-dir 3. $FG_DATA/Fonts 4. Default osg font paths The font size (default: 32) A 3x3 transformation matrix specified by 6 values (child elements , ..., ) See http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined for details. You can also use shortcuts and use an alternative to specifying six values: - Translation: , (ty, ty default to 0) - Totation: - Scale: , (sx is required, sy defaults to sx) Text alignment (default: "left-baseline") One of: "left-top" "left-center" "left-bottom" "center-top" "center-center" "center-bottom" "right-top" "right-center" "right-bottom" "left-baseline" "center-baseline" "right-baseline" "left-bottom-baseline" "center-bottom-baseline" "right-bottom-baseline" A bitwise combination of the following values 1 (Text - default) 2 (Boundingbox) 4 (Filled boundingbox) 8 (Alignment -> Draw a cross at the position of the text) Padding between for the boundingbox (default: 0) Text color Fill color (for the bounding box) Placement --------- To place the canvas into the scene one ore more elements can be added to the texture node. By setting at least on of the following nodes the objects where the canvas texture should be placed on are selected: Match objects with the given texture assigned Match objects with the given name Match objects with a parent matching the given name (Not necessarily the direct parent) Example ------- 384 512 768 1024 false 0 0 TEST MESSAGE helvetica_bold.txf 18 50 EICAS.png HDD 1