Re: [osg-users] culling / bounding calculation for shader scaled geometries

2019-03-28 Thread Christoph Dohmen
Thanks for the hint! 

I forgot to mention this. Using setCullingActive( false ) works, but I want the 
item to be culled if it is completely outside the viewport.

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75745#75745





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] culling / bounding calculation for shader scaled geometries

2019-03-28 Thread Christoph Dohmen
Hi all,

I need to display textured items in a pixel-constant size even on zooming. For 
my implementation I use the position as vertices and store the size in the 
normals. The vertex shader handles it all corrrectly and the image is shown in 
a constant size.

Unfortunately these items are culled if the position is outside the viewport. 
That's bad :-(

I tried to use setInitialBound() with a maximum area to define the bounding box 
to prevent these items from being culled away. But instead of keeping the items 
on screen this results in scaled items!

What other way could I go to prevent the items from beeing culled? Maybe I have 
to read back the vertices somehow? 

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75742#75742





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] I need any ideas on how to wait for all outstanding frame-calls

2019-02-27 Thread Christoph Dohmen
Hi Robert,

thanks for the quick reply. Do you mean the osgposter example?
I will dig into this over the next days.

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75664#75664





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] I need any ideas on how to wait for all outstanding frame-calls

2019-02-27 Thread Christoph Dohmen
Hi all,

I need any ideas on how to wait for all outstanding or pending frame-calls.

What I try to do is have a rendering on demand mode for a viewer showing a 
geotiff (using osgearth). Currently it takes several frame-calls to have the 
image in a clear state. And is state is the item I want to wait for, before 
start doing something else.

Currently the implementation starts with calling 
OsgMapManipulator::centerMapAtPosition(). As next step I tried doing different 
approaches like:


Code:
while (viewer->checkEvents() )
{
viewer->frame()
}




or 


Code:
while (viewer->checkEvents() )
{
viewer->renderTraversas()
}




or


Code:
while (viewer->checkNeedToDoFrame() )
{
viewer->frame()
}




Unfortunately nothing worked as I expected.

Anyone out here in the forum who is able to give me the 'right' hint which item 
to ask in which way to be sure, that the rendered viewer content could be 
labeled 'stable'?

Thank you!

Cheers,
Christoph[/list]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75662#75662





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-10-31 Thread Christoph Dohmen
Hi Laurens,

in the end it took some time but finally I could create source to create the 
eraser and it is up and running quite smooth. Thank you!

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75156#75156





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-13 Thread Christoph Dohmen
Hi Laurens,

it's working if I reduce the current drawing sources to fixed function 
pipeline. But unfortunately we use several shaders. As far as I understand the 
idea, I will need to access the ColorMask from within the fragment shader, 
right? Any hints for that or am I totally wrong?

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74736#74736





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-12 Thread Christoph Dohmen
Thank you, Laurens!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74725#74725





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-12 Thread Christoph Dohmen
Yes, Laurens, that's exactely what I was looking for!

Do you have any source which created the file?

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74720#74720





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-12 Thread Christoph Dohmen
Hi Daniel,

it's not a drawing programm.

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74718#74718





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-11 Thread Christoph Dohmen
Hi Chris,

the original goal is drawing a decorated line where the decoration interrupts 
and keep the background visible. I tried to visualize the elements and the seps 
which are acutally working. I got a few keywords like 'stencil', 'render to 
texture' but the samples are all related to textured items covering textured 
items and not to polylines covered by textured items.

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74716#74716





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Idea to implement a kind of 'rubber mode'

2018-09-11 Thread Christoph Dohmen
Well, Chris, thanks for the question. It shows that I was not precise enough.
Currently I'm drawing the black line on top of a quite complex background 
(light blue). And as a second item I draw the quad with the red frame showing 
the green symbol and having transparent colour in the background so the scene 
background hat visible and the black line.
My goal is to use the textured quad as a rubber and remove the black line but 
not the scene background like in symbol.png.

I hope that clarified it a bit more?!

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74709#74709





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Idea to implement a kind of 'rubber mode'

2018-09-11 Thread Christoph Dohmen
Hi all,

I'm looking for some inspiration for solving the following 'problem':
Currently I'm drawing basic line geometries like in attachment line.png. And 
I'm able to draw items above the geometries (combo.png). But the final goal 
must be some kind of 'rubber mode' which makes the geometry transparent and 
keeps the background (liek in symbol.png).

What may be the technique to solve this?

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74703#74703



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] strange behaviour with osgText::Text

2018-07-18 Thread Christoph Dohmen
Hi,

I have a strange effect with osgText::Text. My original goal was to have a 
constant pixel-sized Text close to the starting point of a line. Using dummy 
values everthing is fine. But using real values the textsize changes!

See the attached source. The wrong behaviour could be seen by setting 
USE_WRONG_VALUES to 1 and the right behaviour could be seen by setting it to 0.

I use OSG 3.6.1 under opensuse.

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74356#74356



#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static const char * vLineShader = {
"#version 330 core\n"
"in vec4 osg_Vertex;\n"
"in vec4 osg_Color;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"out vec4 vertexColor;\n"
"void main(void)\n"
"{\n"
"gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
"vertexColor = osg_Color; \n"
"}\n"
};

static const char * fLineShader = {
"#version 330 core\n"
"in vec4 vertexColor;\n"
"void main(void)\n"
"{\n"
"gl_FragColor = vertexColor;\n"
"}\n"
};

#define USE_WRONG_VALUES 1

osg::ref_ptr buildLine()
{
osg::ref_ptr geometry = new osg::Geometry;
geometry->setUseDisplayList(false);

osg::ref_ptr vertices = new osg::Vec3Array;
#if defined( USE_WRONG_VALUES ) && USE_WRONG_VALUES
vertices->push_back( osg::Vec3( 7300.0, 1300.0, 0.0 ) );
vertices->push_back( osg::Vec3( 7400.0, 1400.0, 0.0 ) );
vertices->push_back( osg::Vec3( 7500.0, 1400.0, 0.0 ) );
#else
vertices->push_back( osg::Vec3(  0.0,  0.0, 0.0 ) );
vertices->push_back( osg::Vec3( 10.0, 10.0, 0.0 ) );
vertices->push_back( osg::Vec3( 20.0, 10.0, 0.0 ) );
#endif

geometry->setVertexArray( vertices );


osg::ref_ptr drawElements = new osg::DrawElementsUInt( osg::PrimitiveSet::LINE_STRIP, 0 );
drawElements->push_back( 0 );
drawElements->push_back( 1 );

geometry->addPrimitiveSet( drawElements );


osg::ref_ptr color( new osg::Vec4Array );
color->push_back( osg::Vec4( 1.0, 0.0, 0.0, 1.0 ) );

geometry->setColorArray( color, osg::Array::BIND_OVERALL );


geometry->getOrCreateStateSet()->setAttributeAndModes( new osg::LineWidth( 10 ), osg::StateAttribute::ON );


osg::ref_ptr program = new osg::Program;
program->addShader(new osg::Shader(osg::Shader::VERTEX, vLineShader));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT, fLineShader));
geometry->getOrCreateStateSet()->setAttributeAndModes(program, osg::StateAttribute::ON);

return geometry;
}

osg::ref_ptr buildText()
{
osg::ref_ptr textItem = new osgText::Text;

textItem->setFont( "/home/chris/SOURCEN/OpenSceneGraph-TrainingMaterials-CAE/Data/OpenSceneGraph-Data/fonts/times.ttf" );
textItem->setColor( osg::Vec4( 0.0, 1.0, 0.0, 1.0 ) );
textItem->setText( "FOO" );
textItem->setAxisAlignment( osgText::Text::SCREEN );
textItem->setFontResolution( 40, 40 );
textItem->setCharacterSize( 32 );
textItem->setCharacterSizeMode( osgText::Text::SCREEN_COORDS );
textItem->setDrawMode( osgText::Text::TEXT | osgText::Text::BOUNDINGBOX );
textItem->setAlignment( osgText::TextBase::CENTER_CENTER );
#if defined( USE_WRONG_VALUES ) && USE_WRONG_VALUES
textItem->setPosition( osg::Vec3( 7300.0, -1500.0, 0.0 ) );
#else
textItem->setPosition( osg::Vec3( -5.0, -5.0, 0.0 ) );
#endif
return textItem;
}

osg::ref_ptr buildIt()
{
osg::Group * group = new osg::Group;

group->addChild( buildLine() );

group->addChild( buildText() );

return group;
}

int main ( int argc, char **argv )
{
// constrcut the viewer.
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments( , argv );
osgViewer::Viewer viewer( arguments );

viewer.setSceneData( buildIt() );

viewer.realize();

osg::DisplaySettings::instance()->setTextShaderTechnique( "NONE" );


osg::State * state = viewer.getCamera()->getGraphicsContext()->getState();
if ( 0 == state )
{
state = new osg::State;
}

state->setUseModelViewAndProjectionUniforms( true );
state->setUseVertexAttributeAliasing( true ) ;
viewer.getCamera()->getGraphicsContext()->setState( state );

viewer.getCamera()->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
viewer.getCamera()->getOrCreateStateSet()->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF );
viewer.getCamera()->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );

// run the viewers main loop.
return viewer.run();
}
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] conversion from .vert/.frag files to cpp inline

2018-05-15 Thread Christoph Dohmen
Hi Robert,

that's it, I tried several osg examples but missed the osg2cpp one :-(

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73643#73643





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] conversion from .vert/.frag files to cpp inline

2018-05-15 Thread Christoph Dohmen
Hi all,

is there any easy 'conversion utility' to create cpp inlined definition of 
shader sources from .vert / .frag files?

Thanks!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73641#73641





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Shaders with multiple views using ViewportCallback

2018-05-14 Thread Christoph Dohmen
Hi Robert,

I just tried the uniform setting for the camera and it worked quite nice.
But I'm not able to use a callback to do the updating stuff :-(.

I tried to install this callback:


Code:

struct ViewportCallback : public osg::Uniform::Callback
{
ViewportCallback( osg::Camera* camera )
: _camera( camera )
{
std::cout << "ViewportCallback::ViewportCallback()" << std::endl;
}

virtual void operator()( osg::Uniform* uniform, osg::NodeVisitor* /*nv*/)
{
std::cout << "ViewportCallback::operator()" << std::endl;
osg::Viewport * vp( _camera->getViewport() );
uniform->set( osg::Vec4( vp->x(), vp->y(), vp->width(), vp->height() ) 
);
}

osg::Camera* _camera;
};




and set it via


Code:

osg::Viewport * vp( viewer.getCamera()->getViewport() );
osg::Uniform * viewportUniform = new osg::Uniform( "viewport", osg::Vec4( 
vp->x(), vp->y(), vp->width(), vp->height() ) );
viewportUniform->setUpdateCallback( new ViewportCallback( 
viewer.getCamera() ) );
viewer.getCamera()->getOrCreateStateSet()->addUniform( viewportUniform );




But I don't get any output from operator() nor do I get an updated viewport 
value in my shader.

What's wrong with this?


Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73632#73632





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Shaders with multiple views using ViewportCallback

2018-05-09 Thread Christoph Dohmen
Ahhh, Robert, thanks, that's the trick :-)

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73575#73575





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Shaders with multiple views using ViewportCallback

2018-05-09 Thread Christoph Dohmen
Hi all,

I need to use the viewport dimensions for some calculations in my vertex 
shader. The most found way of doing the update of the viewport-size uniform is 
the ViewportCallback derived from osg::Uniform::Callback which encapsulates a 
camera.
But what happens if I have multiple views?
How can I fetch the viewport size in my shader per viewer?

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73573#73573





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] How to fill a polygon with a hatch pattern

2014-07-11 Thread Christoph Dohmen
Hi,

I have to fill a given polygon with a hatch pattern. The pattern could be 
horizontal, vertical, diagonal or a combination of them.
Is it possible to define a state or add something to the drawable to achieve 
this?

Thank you!

Cheers,
Christoph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60238#60238





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org