OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Colored Bounding Box over osgText::Text


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
dhhabyc
User


Joined: 17 Nov 2018
Posts: 24

PostPosted: Fri Apr 05, 2019 12:43 pm    Post subject:
Colored Bounding Box over osgText::Text
Reply with quote

Hello,

I'm trying to draw a bounding box around a osgText::Text instance. Setting the draw mode to 'osgText::Text::TEXT|osgText::Text::BOUNDINGBOX' draws a white box around the text. Does anyone knows a simple way to get this box color match the text color? Or, better yet, a way to draw the box myself? The text is dynamic in nature, so I need to be able to resize the box as the text changes.

I look at the osgText::Text source code but there is too much GL stuff for a newbie like me.

Any help will be very much appreciated.

Thank you!

Cheers.
Back to top
View user's profile Send private message
dhhabyc
User


Joined: 17 Nov 2018
Posts: 24

PostPosted: Sat Apr 06, 2019 9:27 pm    Post subject:
Reply with quote

Hello,

I've found a workaround my problem. I had to inherit a class from osgText::Text and override the drawImplementation method like so:

Code:
void MyTextNode::drawImplementation(osg::RenderInfo& renderInfo) const
{
   osg::Vec4 color = getColor(); # stored custom color
   osgText::Text::drawImplementation(*renderInfo.getState(), color);
}


on the constructor od my class I had to set the BOUNDINGBOX drawmode:

Code:
MyTextNode::MyTextNode():
        osgText::Text()
{
   setDataVariance(osg::Object::DYNAMIC);
        ....
   setDrawMode(osgText::Text::TEXT|osgText::Text::BOUNDINGBOX);
   ...
}


Cheers,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How to add text in osgviewer application jaisingla General [forum] 0 Mon Apr 15, 2019 10:44 am View latest post
No new posts culling / bounding calculation for sh... christoph General 3 Thu Mar 28, 2019 1:17 pm View latest post
No new posts osgText::Text dissapears when reparen... dhhabyc General 0 Wed Mar 27, 2019 1:48 pm View latest post
No new posts Cannot pick HUD text bclay General 3 Thu Feb 28, 2019 3:34 pm View latest post
No new posts Working with osg::Text on animation dhhabyc General 5 Thu Dec 20, 2018 1:39 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP