Hi Nebi, Can you come up with a compilable sample (not only snippets) so I can check it here? I believe it is the setup of the quaternion. Just send me a file with all of it, like main.cpp. I did this before including the scissors so relax I will help you ;-)
On Sun, Feb 20, 2022 at 8:37 PM Nebi Sarikaya <[email protected]> wrote: > Another question is, How can I apply glscissors or similar kind of > clipping functionality to osg::Text? I want to limit the space the HUD is > drawn and I want to clip the 2D Space. How can I do that and I apply it it > osg::Text? > > Thanks > > On Sunday, February 20, 2022 at 1:31:40 PM UTC-5 Nebi Sarikaya wrote: > >> Hello Nick, >> >> First of all, thank you for your answer. Actually, I tried all of the >> methods you indicated. My may problem here is I think to place the Group >> Node on the 2D space. Think of the HUD example of OSG. There are lines of >> osg::Text's there. And they are positioned on the 2D Ortho projection >> Matrix. But I think since I can not place the root node (group node) of >> osg::Texts on 2D ortho projection matrix >> (renderInfo.getCurrentCamera()->setProjectionMatrix(osg::Matrix::ortho2D(0, >> width, 0, height));) This does not work. You may see that on the picture >> below, The texts does not rotate based on the center. If I solve this >> problem, I will be very relieved. Here is my Drawable implemetation: >> >> osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform; >> >> >> HUDDrawable::HUDDrawable(osg::ref_ptr<osg::Group> geode) : _geode(geode) { >> timesFont = "fonts/arial.ttf"; >> addTexts (); >> transform->addChild(_geode); // OSG::TEXTs ARE ADDED AS SHILD TO >> _geode Group in a function. >> } >> >> void HUDDrawable::setRotate(float& rotate) { >> _rotate = rotate; >> osg::Quat q; >> q.makeRotate(osg::Vec3(0, 1, 0), osg::Vec3(0, _rotate, 0)); // >> THESE INSTRUCTION DOES NOT WORK.... >> >> >> osg::Matrix myRotateMatrix; >> myRotateMatrix = osg::Matrix::rotate(q); >> >> >> transform->setMatrix(myRotateMatrix); >> } >> >> void HUDDrawable::drawImplementation(osg::RenderInfo& renderInfo) const >> >> >> { >> >> Viewport* viewPort = renderInfo.getCurrentCamera()->getViewport(); >> >> double width = viewPort->width(); >> double height = viewPort->height(); >> >> double orgX = width / 2; >> double orgY = height / 2; >> >> osg::Vec3 position(orgX, orgY, 0.0); // CENTER OF THE HUD >> >> for (short int i = 0; i < 34; i++) { // HERE I POSITION THE >> OSG::TEXTs ON THE HUD BEASED ON THE CENTER OF THE 2D SPACE AND OFFSET THAT >> SET IN THE BELOW FUNCTION. >> >> pozitivePitchLadderLabelsArray[i]->setPosition(position); >> // IN THIS ARRAY EACH ELEMENT IS AN OSG::TEXT >> negativePitchLadderLabelsArray[i]->setPosition(position); >> } >> >> >> renderInfo.getCurrentCamera()->setProjectionMatrix(osg::Matrix::ortho2D(0, >> width, 0, height)); >> >> glPushMatrix(); >> >> >> glEnable(GL_LINE_SMOOTH); >> glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); >> glEnable(GL_BLEND); >> glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); >> >> glTranslated(orgX, orgY, 0); >> glRotated(_rotate, 0, 0, 1); >> glTranslated(-orgX, -orgY, 0); >> >> //// DRAW PITCH LADDDERSAND OTHER STUFF HERE WITH OPENGL COMMANDS /// >> >> glPopMatrix(); //FINISH DRAWING >> } >> >> void HUDDrawable::addTexts() { >> for (short int i = 0; i < 34; i++) { >> osg::Text* text= new osg::Text; >> text->setOffser(offset); // I APPLY AN OFFSET TO TEXT SO >> TEXT IS NOT PLACED ON THE CENTER OF THE HUD >> _geode->addChild text); // HERE OSG::TEXTs ADDED AS CHILD >> TO osg::Group, BUT osg::Group DOWS NOT HAVE POSITION ON 2D SPACE, HOW I AM >> GOING TO DO THAT??? >> pozitivePitchLadderLabelsArray[i] = text ; >> } >> >> for (short int i = 0; i < 34; i++) { >> osg::Text* text= new osg::Text; >> text->setOffser(offset); // I APPLY AN OFFSET TO TEXT SO >> TEXT IS NOT PLACED ON THE CENTER OF THE HUD >> _geode->addChild(text ); >> negativePitchLadderLabelsArray[i] = text ; >> } >> } >> >> Thanks >> [image: 1.png] >> On Sunday, February 20, 2022 at 1:11:07 AM UTC-5 [email protected] >> wrote: >> >>> Hi Nebi, >>> >>> You can put osg::MatrixTransform on top of the group and >>> setMatrix(myRotateMatrix). And you construct myRotateMatrix >>> with Quaternion, something like this: >>> >>> osg::Quat q; >>> q.makeRotate(osg::Vec3(0,1,0),osg::Vec3(0,angle,0)); >>> >>> osg::Matrix myRotateMatrix; >>> myRotateMatrix = osg::Matrix::rotate(q); >>> >>> osgh::ref_ptr<osg;;MatrixTransform> mxt = new osg::MatrixTransform; >>> mxt.setMatrix(myRotateMatrix); >>> >>> mxt->addChild(myTextGroup); >>> >>> Something like this >>> >>> On Sun, Feb 20, 2022 at 5:03 AM Nebi Sarikaya <[email protected]> wrote: >>> >>>> Hello, >>>> >>>> This may be an old subject, but how do you rotate all osg::Text's as a >>>> group in 2D space? >>>> >>>> Thanks >>>> >>>> On Monday, January 7, 2019 at 5:20:25 AM UTC-5 [email protected] >>>> wrote: >>>> >>>>> Well, it's hard to say because I don't really know how you are doing >>>>> it now, but it seems to me like you're spending a lot of effort rotating >>>>> and positioning each text element individually. Normally, I don't go >>>>> through that process. >>>>> >>>>> Normally, I make a hierarchy of a few groups, each with various >>>>> children individually positioned. Then, I can adjust the overall position >>>>> and rotation of the whole set by applying position and rotation transforms >>>>> to the Group node, not to each text or other sub-element. >>>>> >>>>> From your description (maybe I misinterpreted what you were saying) it >>>>> didn't sound like you were doing it this way, and I worried that you were >>>>> making unnecessary work for yourself as a result. >>>>> >>>>> >>>>> >>>>> On Mon, Jan 7, 2019 at 8:40 AM Nebi Sarikaya <[email protected]> wrote: >>>>> >>>>>> Hi Chris; >>>>>> >>>>>> Can you be more specific on "I usually put all of the text and HUD >>>>>> elements into a group and position them relative to the group and then >>>>>> rotate and shift that group. All the sub-children will rotate properly. >>>>>> " ? >>>>>> >>>>>> Thank you! >>>>>> >>>>>> Cheers, >>>>>> Nebi >>>>>> >>>>>> ------------------ >>>>>> Read this topic online here: >>>>>> http://forum.openscenegraph.org/viewtopic.php?p=75394#75394 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> osg-users mailing list >>>>>> [email protected] >>>>>> >>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>>>>> >>>>> >>>>> >>>>> -- >>>>> Chris 'Xenon' Hanson, omo sanza lettere. [email protected] >>>>> http://www.alphapixel.com/ >>>>> Training • Consulting • Contracting >>>>> 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • >>>>> OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL >>>>> Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • >>>>> osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile >>>>> • >>>>> iPhone/iPad/iOS • Android >>>>> @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775) >>>>> 623-PIXL [7495] >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "OpenSceneGraph Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/osg-users/fa4f53fd-c5cc-4e3e-bf9a-a27a3eb766ban%40googlegroups.com >>>> <https://groups.google.com/d/msgid/osg-users/fa4f53fd-c5cc-4e3e-bf9a-a27a3eb766ban%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> trajce nikolov nick >>> >> -- > You received this message because you are subscribed to the Google Groups > "OpenSceneGraph Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/osg-users/ae20cd1a-9120-4609-b5ab-d10f0a2ad129n%40googlegroups.com > <https://groups.google.com/d/msgid/osg-users/ae20cd1a-9120-4609-b5ab-d10f0a2ad129n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- trajce nikolov nick -- You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/CAO-%2Bzi%3Dbg19DGexPtbiTpZviNidTWRUxE500zmjbyesJ_7tfzg%40mail.gmail.com.
