|
Developer Documentation
|
#include <ACG/Scenegraph/TextNode.hh>
Public Types | |
| enum | TextMode { SCREEN_ALIGNED , SCREEN_ALIGNED_STATIC_SIZE , OBJECT_ALIGNED } |
Public Types inherited from ACG::SceneGraph::BaseNode | |
| enum | StatusMode { Active = 0x1 , HideNode = 0x2 , HideChildren = 0x4 , HideSubtree = 0x8 } |
| Status modi. More... | |
| enum | TraverseMode { NodeFirst = 0x1 , ChildrenFirst = 0x2 , SecondPass = 0x4 } |
| Node traverse types. More... | |
| typedef std::vector< BaseNode * >::const_iterator | ConstChildIter |
| allows to iterate over children | |
| typedef std::vector< BaseNode * >::iterator | ChildIter |
| allows to iterate over children | |
| typedef std::vector< BaseNode * >::const_reverse_iterator | ConstChildRIter |
| allows to reverse iterate over children | |
| typedef std::vector< BaseNode * >::reverse_iterator | ChildRIter |
| allows to reverse iterate over children | |
| enum | PASSES { NOPASS = 0 , ALLPASSES = 1 << 0 , PASS_1 = 1 << 1 , PASS_2 = 1 << 2 , PASS_3 = 1 << 3 , PASS_4 = 1 << 4 , PASS_5 = 1 << 5 , PASS_6 = 1 << 6 , PASS_7 = 1 << 7 , PASS_8 = 1 << 8 } |
| This enum should be used to enable rendering of a node in different. More... | |
| typedef unsigned int | MultipassBitMask |
| Multipass pass bit mask type. | |
Public Member Functions | |
| TextNode (BaseNode *_parent=0, const std::string &_name="<TextNode>", TextMode _textMode=SCREEN_ALIGNED, bool _alwaysOnTop=false) | |
| ~TextNode () | |
| destructor | |
| ACG_CLASSNAME (TextNode) | |
| static name of this class | |
| DrawModes::DrawMode | availableDrawModes () const override |
| return available draw modes | |
| void | boundingBox (Vec3d &_bbMin, Vec3d &_bbMax) override |
| update bounding box | |
| void | draw (GLState &_state, const DrawModes::DrawMode &_drawMode) override |
| draw Text | |
| void | enter (GLState &_state, const DrawModes::DrawMode &_drawmode) override |
| set texture and drawing states | |
| void | enterCompat (GLState &_state, const DrawModes::DrawMode &_drawmode) |
| void | leave (GLState &_state, const DrawModes::DrawMode &_drawmode) override |
| restore texture and drawing states | |
| void | leaveCompat (GLState &_state, const DrawModes::DrawMode &_drawmode) |
| void | getRenderObjects (ACG::IRenderer *_renderer, ACG::GLState &_state, const ACG::SceneGraph::DrawModes::DrawMode &_drawMode, const ACG::SceneGraph::Material *_mat) override |
| set RenderObject for Shader pipeline renderer | |
| void | setRenderingMode (TextMode _textMode) |
| void | setAlwaysOnTop (bool _alwaysOnTop) |
| draw the text always on top | |
| bool | alwaysOnTop () |
| returns wheter always on top is setted or not | |
| TextMode | renderingMode () |
| returns the rendering mode (SCREEN_ALIGNED or OBJECT_ALIGNED) | |
| void | setText (std::string _text) |
| sets the string that will be rendered | |
| void | setSize (const double _size) |
| sets the size by which the quads displaying the text will be scaled | |
| void | setPixelSize (const unsigned int _size) |
| sets the pixelsize of the text (only available for the SCREEN_ALIGNED_STATIC_SIZE mode and only works, if scaling is 1) | |
| void | setFont (const QFont &_font) |
| sets the font to be used for generating a texture with most characters of the chosen font | |
| float | lastScale () |
| returns the scaling factor for screen aligned text the text. returns 0, if textmode is not SCREEN_ALIGNED_STATIC_SIZE | |
Public Member Functions inherited from ACG::SceneGraph::BaseNode | |
| BaseNode (BaseNode *_parent=0, std::string _name="<unknown>") | |
| Default constructor. | |
| BaseNode (BaseNode *_parent, BaseNode *_child, std::string _name="<unknown>") | |
| Put this node between _parent and _child. | |
| virtual | ~BaseNode () |
| Destructor. | |
| void | delete_subtree () |
| Delete the whole subtree of this node. | |
| virtual const std::string & | className () const =0 |
| Return class name (implemented by the ACG_CLASSNAME macro) | |
| virtual void | enter (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode) |
| virtual void | leave (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode) |
| virtual void | enterPick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) |
| virtual void | pick (GLState &, PickTarget) |
| virtual void | leavePick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) |
| void | enablePicking (bool _enable) |
| bool | pickingEnabled () |
| virtual void | mouseEvent (GLState &, QMouseEvent *) |
| Handle mouse event (some interaction, e.g. modeling) | |
| void | setDirty (bool _dirty=true) |
| mark node for redrawn | |
| bool | isDirty () const |
| Check if node should be redrawn. | |
| ChildIter | childrenBegin () |
| Returns: begin-iterator of children. | |
| ConstChildIter | childrenBegin () const |
Same but cont. | |
| ChildIter | childrenEnd () |
| Returns: end-iterator of children. | |
| ConstChildIter | childrenEnd () const |
Same but const. | |
| ChildRIter | childrenRBegin () |
| Returns: reverse begin-iterator of children. | |
| ConstChildRIter | childrenRBegin () const |
| Same but const. | |
| ChildRIter | childrenREnd () |
| Returns: reverse end-iterator of children. | |
| ConstChildRIter | childrenREnd () const |
Same but const. | |
| void | push_back (BaseNode *_node) |
| Insert _node at the end of the list of children. | |
| void | remove (ChildIter _pos) |
| size_t | nChildren () const |
| number of children | |
| ChildIter | find (BaseNode *_node) |
| BaseNode * | find (const std::string &_name) |
| BaseNode * | parent () |
| Get the nodes parent node. | |
| const BaseNode * | parent () const |
| Get the nodes parent node. | |
| void | set_parent (BaseNode *_parent) |
| Set the parent of this node. | |
| StatusMode | status () const |
| Get node's status. | |
| void | set_status (StatusMode _s) |
| Set the status of this node. | |
| void | hide () |
| Hide Node: set status to HideNode. | |
| void | show () |
| Show node: set status to Active. | |
| bool | visible () |
| Is node visible (status == Active)? | |
| bool | hidden () |
| Is node not visible (status != Active)? | |
| std::string | name () const |
| Returns: name of node (needs not be unique) | |
| void | name (const std::string &_name) |
| rename a node | |
| unsigned int | id () const |
| DrawModes::DrawMode | drawMode () const |
| Return the own draw modes of this node. | |
| void | drawMode (DrawModes::DrawMode _drawMode) |
| unsigned int | traverseMode () const |
| Return how the node should be traversed. | |
| void | setTraverseMode (unsigned int _mode) |
| Set traverse mode for node. | |
| MultipassBitMask | multipassStatus () const |
| Get the current multipass settings for the nodes status functions. | |
| void | setMultipassStatus (const MultipassBitMask _passStatus) |
| Set multipass settings for the nodes status functions. | |
| void | multipassStatusSetActive (const unsigned int _i, bool _active) |
| Set multipass status to traverse in a specific pass. | |
| bool | multipassStatusActive (const unsigned int _i) const |
| Get multipass status to traverse in a specific pass. | |
| MultipassBitMask | multipassNode () const |
| Get the current multipass settings for the node. | |
| void | setMultipassNode (const MultipassBitMask _passNode) |
| Set multipass settings for the node. | |
| void | multipassNodeSetActive (const unsigned int _i, bool _active) |
| Set Node status to traverse in a specific pass. | |
| bool | multipassNodeActive (const unsigned int _i) const |
| Get Node status to traverse in a specific pass. | |
| void | setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON) |
| Set custom shaders. | |
| void | setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_tessControlShaderFile, const std::string &_tessEvalShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON) |
| Set custom shaders. | |
| void | setRenderObjectUniformPool (const GLSL::UniformPool *_pool) |
| Set uniforms for shader based rendering. | |
| const GLSL::UniformPool * | getRenderObjectUniformPool () |
| Get uniforms for shader based rendering. | |
| void | setRenderObjectTexture (int _samplerSlot, GLuint _texId, GLenum _texType=GL_TEXTURE_2D) |
| Set textures for shader based rendering. | |
| void | setRenderObjectModifier (RenderObjectModifier *_modifier) |
| Set modifier for render objects. | |
| RenderObjectModifier * | getRenderObjectModifier () |
| Get render-object modifier. | |
| void | applyRenderObjectSettings (DrawModes::DrawModePrimitive _primitive, RenderObject *_obj) const |
| Set shaders, textures and uniforms as provided by user to a render-object. | |
Static Protected Member Functions | |
| static void | updateFont () |
Private Member Functions | |
| void | updateVBO () |
| void | bindVBO () |
| binds vbo_ and sets the necessary OpenGL states | |
| void | unbindVBO () |
| unbinds vbo_ | |
| void | applyScreenAligned (GLState &_state) |
| modifies _state so that the modelviewmatrix will be screenaligned. remember to call "_state.pop_modelview_matrix();" twice | |
Static Private Member Functions | |
| static quint32 | nearestPowerOfTwo (quint32 num) |
| returns the nearest greater power of 2 to num | |
| static std::map< char, std::pair< unsigned int, unsigned int > > | createMap () |
Private Attributes | |
| double | size_ |
| scaling factor by which the quads in vbo_ are scaled | |
| unsigned | pixelSize_ |
| pixelSize of the text for the SCREEN_ALIGNED_STATIC_SIZE mode | |
| std::string | text_ |
| text to be displayed on quads in vbo_ | |
| TextMode | textMode_ |
| current display mode of text_ (SCREEN_ALIGNED, SCREEN_ALIGNED_STATIC_SIZE or OBJECT_ALIGNED) | |
| GLuint | vbo_ |
| std::vector< GLfloat > | vertexBuffer_ |
| buffer of vertex coordinates and texture coordinates of the quads | |
| size_t | oldVboSize_ |
| bool | blendEnabled_ |
| stores if GL_BLEND was enabled on entering TextNode | |
| bool | texture2dEnabled_ |
| stores if GL_TEXTURE_2D was enabled on entering TextNode | |
| bool | cullFaceEnabled_ |
| stores if GL_CULL_FACE was enabled on entering TextNode | |
| bool | depthEnabled_ |
| stores if GL_DEPTH_TEST was enabled on entering TextNode | |
| bool | alwaysOnTop_ |
| stores if text should be drawn always on top | |
| bool | alphaTest_ |
| stores if the alpha test was enabled | |
| float | alphaTestValue_ |
| stores the alpha value used for alpha test | |
| GLenum | alphaTestFunc_ |
| stores alpha test comparison function | |
| GLint | blendSrc_ |
| stores the sfactor parameter of glBlendFunc on entering TextNode | |
| GLint | blendDest_ |
| stores the dfactor parameter of glBlendFunc on entering TextNode | |
| ACG::VertexDeclaration | vertexDecl_ |
| stores the vertex declaration | |
| float | lastScale_ |
| stores the last scaling factor the text computed to SCREEN_ALIGNED_STATIC_SIZE | |
Static Private Attributes | |
| static std::map< char, std::pair< unsigned int, unsigned int > > | charToIndex_ = TextNode::createMap() |
| maps most readable characters to indices for texture coordinate calculation in updateVBO() | |
| static QFont | qfont_ = QFont("Helvetica", 30) |
| font that is used to generate the texture in updateFont() | |
| static GLuint | texture_ = 0 |
| handle for the texture into which characters from qfont_ are painted in updateFont() | |
| static int | imageWidth_ = 0 |
| width of the generated texture | |
| static int | imageHeight_ = 0 |
| height of the generated texture | |
| static QFontMetrics | fontMetric_ = (QFontMetrics(TextNode::qfont_)) |
| static const int | numberOfChars_ = 94 |
| number of characters that are drawn into the texture | |
| static const unsigned int | rows_ = 10 |
| number of rows of characters in the texture | |
| static const unsigned int | columns_ = 10 |
| number of columns of characters in the texture | |
| static bool | initialised_ = false |
| this is used to ensure that the texture is only generated once when necessary | |
| static QColor | color_ = QColor(255, 0, 0) |
| color that is used to draw the characters into the texture in updateFont() | |
CoordsysNode renders A coordinate system.
TODO: Den Fall mode_ == POSITION implementieren. 25.11.08
TextNode can be used to display a string on quads in OpenGL. This string can be set with setText(std::string _text). A TextNode can be attached to a parent node by using the function BaseObjectData::addAdditionalNode. The quads can then be set to align to the parent (OBJECT_ALIGNED) via the setRenderingMode(TextMode _textMode) function. Alternatively the quads can be aligned to the screen (SCREEN_ALIGNED). The font that is used to display text on the screen can be set with the setFont(const QFont& _font) function. Finally the quads can be scaled via the setSize(double _size) function.
Definition at line 88 of file TextNode.hh.
Definition at line 92 of file TextNode.hh.
| ACG::SceneGraph::TextNode::TextNode | ( | BaseNode * | _parent = 0, |
| const std::string & | _name = "<TextNode>", |
||
| TextMode | _textMode = SCREEN_ALIGNED, |
||
| bool | _alwaysOnTop = false |
||
| ) |
default constructor
| _parent | Define the parent Node this node gets attached to |
| _name | Name of this Node |
| _textMode | Define the text rendering style ( see TextNode::TextMode ) |
| _alwaysOnTop | Draw text on top of everything else? |
Definition at line 90 of file TextNode.cc.
| ACG::SceneGraph::TextNode::~TextNode | ( | ) |
destructor
Definition at line 125 of file TextNode.cc.
| bool ACG::SceneGraph::TextNode::alwaysOnTop | ( | ) |
returns wheter always on top is setted or not
Definition at line 180 of file TextNode.cc.
|
private |
modifies _state so that the modelviewmatrix will be screenaligned. remember to call "_state.pop_modelview_matrix();" twice
Definition at line 697 of file TextNode.cc.
|
overridevirtual |
return available draw modes
Reimplemented from ACG::SceneGraph::BaseNode.
Definition at line 147 of file TextNode.cc.
|
private |
binds vbo_ and sets the necessary OpenGL states
Definition at line 606 of file TextNode.cc.
update bounding box
Reimplemented from ACG::SceneGraph::BaseNode.
Definition at line 137 of file TextNode.cc.
|
staticprivate |
Creates a map charToIndex_ from most characters to an incrementing set of indices. These indices are used to create the texture coordinates in updateVBO().
Definition at line 223 of file TextNode.cc.
|
overridevirtual |
|
overridevirtual |
set texture and drawing states
Reimplemented from ACG::SceneGraph::BaseNode.
Definition at line 241 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::enterCompat | ( | GLState & | _state, |
| const DrawModes::DrawMode & | _drawmode | ||
| ) |
Definition at line 72 of file TextNodeGLCompat.cc.
|
overridevirtual |
set RenderObject for Shader pipeline renderer
Reimplemented from ACG::SceneGraph::BaseNode.
Definition at line 635 of file TextNode.cc.
|
inline |
returns the scaling factor for screen aligned text the text. returns 0, if textmode is not SCREEN_ALIGNED_STATIC_SIZE
screen aligned static size text will be scaled up/down in 3d space to achieve the static size in screen space lastScale returns the last scaling factor where the text was multiplied, to compute e.g. a distance which is also static in screen space
Definition at line 166 of file TextNode.hh.
|
overridevirtual |
restore texture and drawing states
Reimplemented from ACG::SceneGraph::BaseNode.
Definition at line 273 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::leaveCompat | ( | GLState & | _state, |
| const DrawModes::DrawMode & | _drawmode | ||
| ) |
Definition at line 106 of file TextNodeGLCompat.cc.
|
staticprivate |
returns the nearest greater power of 2 to num
Definition at line 330 of file TextNode.cc.
| TextNode::TextMode ACG::SceneGraph::TextNode::renderingMode | ( | ) |
returns the rendering mode (SCREEN_ALIGNED or OBJECT_ALIGNED)
Definition at line 191 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setAlwaysOnTop | ( | bool | _alwaysOnTop | ) |
draw the text always on top
Definition at line 170 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setFont | ( | const QFont & | _font | ) |
sets the font to be used for generating a texture with most characters of the chosen font
Definition at line 348 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setPixelSize | ( | const unsigned int | _size | ) |
sets the pixelsize of the text (only available for the SCREEN_ALIGNED_STATIC_SIZE mode and only works, if scaling is 1)
Definition at line 732 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setRenderingMode | ( | TextMode | _textMode | ) |
Set the rendering mode ( see TextNode::TextMode )
Definition at line 160 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setSize | ( | const double | _size | ) |
sets the size by which the quads displaying the text will be scaled
Definition at line 213 of file TextNode.cc.
| void ACG::SceneGraph::TextNode::setText | ( | std::string | _text | ) |
sets the string that will be rendered
Definition at line 202 of file TextNode.cc.
|
private |
unbinds vbo_
Definition at line 624 of file TextNode.cc.
|
staticprotected |
Generates a texture by drawing most characters into one texture. This texture is then used to draw single characters onto quads
@TODO Remove, if it works correctly on mac
Definition at line 359 of file TextNode.cc.
|
private |
generates a quad for each character in text_ and also calculates the texture coordinates for each quad's character
Definition at line 460 of file TextNode.cc.
|
private |
stores if the alpha test was enabled
Definition at line 240 of file TextNode.hh.
|
private |
stores alpha test comparison function
Definition at line 246 of file TextNode.hh.
|
private |
stores the alpha value used for alpha test
Definition at line 243 of file TextNode.hh.
|
private |
stores if text should be drawn always on top
Definition at line 237 of file TextNode.hh.
|
private |
stores the dfactor parameter of glBlendFunc on entering TextNode
Definition at line 252 of file TextNode.hh.
|
private |
stores if GL_BLEND was enabled on entering TextNode
Definition at line 225 of file TextNode.hh.
|
private |
stores the sfactor parameter of glBlendFunc on entering TextNode
Definition at line 249 of file TextNode.hh.
|
staticprivate |
maps most readable characters to indices for texture coordinate calculation in updateVBO()
Definition at line 261 of file TextNode.hh.
|
staticprivate |
color that is used to draw the characters into the texture in updateFont()
Definition at line 292 of file TextNode.hh.
|
staticprivate |
number of columns of characters in the texture
Definition at line 286 of file TextNode.hh.
|
private |
stores if GL_CULL_FACE was enabled on entering TextNode
Definition at line 231 of file TextNode.hh.
|
private |
stores if GL_DEPTH_TEST was enabled on entering TextNode
Definition at line 234 of file TextNode.hh.
|
staticprivate |
We need to store the font metric to make sure texture font metrics and rendering metrics match.
Definition at line 277 of file TextNode.hh.
|
staticprivate |
height of the generated texture
Definition at line 273 of file TextNode.hh.
|
staticprivate |
width of the generated texture
Definition at line 270 of file TextNode.hh.
|
staticprivate |
this is used to ensure that the texture is only generated once when necessary
Definition at line 289 of file TextNode.hh.
|
private |
stores the last scaling factor the text computed to SCREEN_ALIGNED_STATIC_SIZE
Definition at line 258 of file TextNode.hh.
|
staticprivate |
number of characters that are drawn into the texture
Definition at line 280 of file TextNode.hh.
|
private |
Definition at line 222 of file TextNode.hh.
|
private |
pixelSize of the text for the SCREEN_ALIGNED_STATIC_SIZE mode
Definition at line 206 of file TextNode.hh.
|
staticprivate |
font that is used to generate the texture in updateFont()
Definition at line 264 of file TextNode.hh.
|
staticprivate |
number of rows of characters in the texture
Definition at line 283 of file TextNode.hh.
|
private |
scaling factor by which the quads in vbo_ are scaled
Definition at line 203 of file TextNode.hh.
|
private |
text to be displayed on quads in vbo_
Definition at line 209 of file TextNode.hh.
|
private |
current display mode of text_ (SCREEN_ALIGNED, SCREEN_ALIGNED_STATIC_SIZE or OBJECT_ALIGNED)
Definition at line 212 of file TextNode.hh.
|
private |
stores if GL_TEXTURE_2D was enabled on entering TextNode
Definition at line 228 of file TextNode.hh.
|
staticprivate |
handle for the texture into which characters from qfont_ are painted in updateFont()
Definition at line 267 of file TextNode.hh.
|
private |
handle to the vertex buffer object, containing the quads on which the characters in text_ are rendered
Definition at line 218 of file TextNode.hh.
|
private |
buffer of vertex coordinates and texture coordinates of the quads
Definition at line 221 of file TextNode.hh.
|
private |
stores the vertex declaration
Definition at line 255 of file TextNode.hh.