History: MovableTextOverlay
Source of version: 1
- «
- »
Copy to clipboard
!!Introduction
I started from ((ObjectTextDisplay|Xavier's ObjectTextDisplay)) example and eventually came up with these three classes, that do all the Text ((Overlay)) positioning for you.
The MovableTextOverlay class takes an Ogre ((MovableObject)), an Ogre String and a MovableTextOverlayAttributes pointer and
makes your text moves with the Object on the screen, displaying it centered above the object (((HUD)) / heads up display).
The MovableTextOverlayAttributes contain all the ((Font)) / ((Material] / Colour Overlay attributes. I put them into a separate class with the intention of creating "groups" of MovableTextOverlay objects that share same "attributes".
The RectLayoutManager class is generic. It manages a list of non-overlapping rectangles within certain bounds. To find a non-overlapping position for a certain rectangle, it translates the rectangle on the Y axis until it finds a suitable position. I tried to optimise this class for speed as much as I could, any ideas are welcome.
ÿ9ÿThe Codeÿ10ÿ
ÿ11ÿMovableTextOverlay.hÿ12ÿ
ÿ0ÿ
ÿ13ÿMovableTextOverlay.cppÿ14ÿ
ÿ1ÿ
ÿ15ÿRectLayoutManager.hÿ16ÿ
ÿ2ÿ
ÿ17ÿHow to use itÿ18ÿ
Add a global vector to hold your MovableTextOverlay pointers
ÿ3ÿ
'''In your createScene'''
ÿ4ÿ
'''In your frameStarted'''
ÿ5ÿ
'''Media'''
ÿ6ÿ
ÿ19ÿHow it looks likeÿ20ÿ
[[Image:Robots.jpg))
((Category:Code Snippet))