[osg-users] Show part of geometry which intersects a specific area

Robert Osfield robert.osfield at gmail.com
Wed Mar 28 02:17:00 PDT 2018


Hi Ali,

When you put nodes underneath a ClipNode those nodes should inherit
the required GL_CLIP_PLANEi, so in theory it should work right,
however, as I've never mixed osgText with clipping I can only say I
don't see a reason in principle when it wouldn't work.  If you put the
subgraphs you want to clip in a different subgraph you'll need to set
the GL_CLIP_PLANEi.

Robert.

On 28 March 2018 at 08:46, Ali Ozdin <alinailozdin at gmail.com> wrote:
> Hi Robert,
>
> Firstly, I am using osg 3.4.1. However I dont enable any GL_CLIP_PLANEi but all geometry in geodeForgeomRight works well except osgText geometries. Sample code is below:
>
>
> Code:
>
> osg::ClipNode* clipped_subgraph;
> osg::ref_ptr<osg::Geode> geodeForgeomRight;
>
> osg::ref_ptr<osgText::Text> bottomAltitudeText = new  osgText::Text;
> osg::Vec3 position( (SCREEN_WIDTH * 0.64) + bigLineLength, (i/2)*lineBreak, 0.0f);
> std::string timesFont("fonts/arial.ttf");
> bottomAltitudeText->setAlignment(osgText::TextBase::AlignmentType::LEFT_CENTER);
> bottomAltitudeText->setFont(timesFont);
> bottomAltitudeText->setColor( osg::Vec4f(0.f, 255.f,0.f,1.f) );
> bottomAltitudeText->setPosition(position);
> bottomAltitudeText->setText("hello world" );
> bottomAltitudeText->setCharacterSize(15.0);
> geodeForgeomRight->addDrawable( bottomAltitudeText.get() );
>
>
> osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform();
> mt->addChild(geodeForgeomRight.get());
>
> clipped_subgraph = new osg::ClipNode;
> double xMin,yMin, zMin, xMax, yMax, zMax;
> xMin = (SCREEN_WIDTH * 0.64);
> yMin = SCREEN_HEIGHT*0.6 - 17*lineBreak;
> zMin = 0.0f;
> xMax = geodeForgeomRight.get()->getBoundingBox().xMax();
> yMax = SCREEN_HEIGHT*0.6;
> zMax = 0.0f;
> osg::BoundingBox bb(xMin,yMin, zMin, xMax, yMax, zMax);
> clipped_subgraph->createClipBox(bb);
> clipped_subgraph->addChild(mt);
>
> clipped_subgraph->setCullingActive(true);
> mt->setUpdateCallback(new AltitudeCallBack());
>
>
>
>
> Best regards,
>
>
> robertosfield wrote:
>> Hi Ali,
>> I haven't tested this specific combination of features, but in
>> principle it should be just a case of enabling the GL_CLIP_PLANEi mode
>> for the text subgraphs.
>>
>> Which version of the OSG are you using and what GL versions?
>>
>> The new osgText implementation in master/OSG-3.6 branch uses shaders
>> so out of the box, looking at the shader I don't see any setting of
>> the gl_ClipVertex so this could be a problem.  I will look into this.
>>
>> Robert.
>> _______________________________________________
>> osg-users mailing list
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>  ------------------
>> Post generated by Mail2Forum
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73188#73188
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


More information about the osg-users mailing list