Re: [osg-users] EditorConfig file?

2019-04-15 Thread Michael Weiblen
FWIW, clang-formating is a requirement before creating pull requests for
the Vulkan repos at https://github.com/KhronosGroup
-- mew




On Sun, Apr 14, 2019 at 9:52 AM Robert Osfield 
wrote:

> Hi Chris, Michael et. al,
>
> On Sun, 14 Apr 2019 at 15:50, michael kapelko  wrote:
> > I would guess it might be not exactly appropriate to update
> > OpenSceneGraph sources just to have the order in spaces and tabs.
> > However, I think VulkanSceneGraph would definitely benefit
> > EditorConfig rules. So once VSG has its place at GitHub, I would
> > recommend re-raising this issue and creating a pull request.
>
> For the VSG I've adopted clang-format to enforce standard formatting,
> I run this periodically to make sure we don't deviate for too long.
>
> The .clang-format file is:
>
> https://github.com/vsg-dev/VulkanSceneGraphPrototype/blob/master/.clang-format
>
> I am not familiar with EditorConfig, for the VSG it won't be critical
> for enforcing format.  I'm open to suggestons but don't want to liter
> the code base with things that aren't critical to the use of the code
> base.
>
> Robert.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Mike Weiblen -- Black Hawk, Colorado USA -- http://mew.cx/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Where is CreateContextAttribs() being used?

2019-04-15 Thread Glenn Waldron
Let's try that again:
https://gist.github.com/gwaldron/a56b0e77e7fa8587b698717d21f9366d

Glenn Waldron


On Mon, Apr 15, 2019 at 3:33 PM Glenn Waldron  wrote:

> Here's a quick reference for building OSG (and osgEarth) for GL CORE...
> may be helpful.
>
> Glenn Waldron
>
>
> On Thu, Apr 11, 2019 at 10:49 AM Sebastian Messerschmidt <
> sebastian.messerschm...@gmx.de> wrote:
>
>> Merlin,
>>
>>
>>
>> As Chris already mentioned the complete application needs to run on
>> core-profile. That means there is no fixed function pipeline and no
>> backward-compatibility features.
>>
>> In order to get your application running in core-profile you need to
>> write shaders for everything and IIRC compile OSG with GL3 enabled. I
>> haven’t used OSG in a while now, but I think there is mechanism to decorate
>> the scene graph with shaders automatically.
>>
>>
>>
>> I started to refactor my project some years ago to fully support
>> core-only scenarios, but I gave up due to a lot features no longer working
>> out-of-the-box.
>>
>> Can you maybe try to explain what you’re trying to debug? There might be
>> some more options for you.
>>
>>
>>
>>
>>
>> Cheers
>>
>> Sebastian
>>
>>
>>
>> *From:* osg-users  *On
>> Behalf Of *Rowley, Marlin R
>> *Sent:* Donnerstag, 11. April 2019 16:24
>> *To:* OpenSceneGraph Users 
>> *Subject:* Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Where is
>> CreateContextAttribs() being used?
>>
>>
>>
>> Sebastian,
>>
>>
>>
>> What does “core OpenGL profile” mean with regards to the graphics
>> context?  I’m still not getting it to work.
>>
>>
>>
>> Here is my code structure:
>>
>>
>>
>> …
>>
>> osg::ref_ptr traits = new osg::
>> GraphicsContext::Traits;
>>
>> traits->x = aXPosition;
>>
>> traits->y = aYPosition;
>>
>> traits->width  = aWidth;
>>
>> traits->height = aHeight;
>>
>> traits->stencil = 8;
>>
>> traits->doubleBuffer = true;
>>
>> traits->windowDecoration = false;
>>
>> #if defined(WIN32)
>>
>> traits->inheritedWindowData = new osgViewer::
>> GraphicsWindowWin32::WindowData( aWindow );
>>
>> #elif defined(__linux__)
>>
>>traits->inheritedWindowData = new
>> osgViewer::GraphicsWindowX11::WindowData( aWindow );
>>
>> #endif
>>
>> // gl graphics context version and profile mask
>>
>> *traits**->**glContextVersion **=* *"3.3"**;*
>>
>> *traits**->**glContextProfileMask = 0x1;*
>>
>>
>>
>> // create the graphics window from the context
>>
>> osgViewer::GraphicsWindow* gw = dynamic_cast> GraphicsWindow*>(osg::GraphicsContext
>> ::createGraphicsContext(traits.get()));
>>
>>
>>
>> …
>>
>>
>>
>> // set the main camera to use the window
>>
>> mainCamera->setGraphicsContext( gw );
>>
>>
>>
>> …
>>
>>
>>
>> I assume here that setting the traits variable with the major/minor
>> version of OpenGL and setting the profile mask to 1 (‘core’??) would be all
>> I need.  But that’s obviously not the case.
>>
>>
>>
>> -M
>>
>>
>>
>> 
>>
>> Marlin Rowley
>>
>> Software Engineer, Staff
>>
>> [image: cid:image002.jpg@01D39374.DEC5A2E0]
>>
>> *Missiles and Fire Control*
>>
>> 972-603-1931 (office)
>>
>> 214-926-0622 (mobile)
>>
>> marlin.r.row...@lmco.com
>>
>>
>>
>> *From:* osg-users  *On
>> Behalf Of *sebastian.messerschm...@gmx.de
>> *Sent:* Thursday, April 11, 2019 9:01 AM
>> *To:* 'OpenSceneGraph Users' 
>> *Subject:* EXTERNAL: Re: [osg-users] EXTERNAL: Re: Where is
>> CreateContextAttribs() being used?
>>
>>
>>
>> Hi Marlin,
>>
>>
>>
>> In order for RenderDoc (and most tools I’m aware of) you’re application
>> needs to run on core OpenGL profile.
>>
>> You might want to look here for some debugging options:
>> https://www.khronos.org/opengl/wiki/Debugging_Tools
>>
>> I personally used Nvidia Nsight for quite a while, as it at least helps
>> with framebuffer debugging etc.
>>
>>
>>
>> Cheers
>>
>> Sebastian
>>
>>
>>
>>
>>
>> *From:* osg-users  *On
>> Behalf Of *Rowley, Marlin R
>> *Sent:* Donnerstag, 11. April 2019 14:52
>> *To:* OpenSceneGraph Users 
>> *Subject:* Re: [osg-users] EXTERNAL: Re: Where is CreateContextAttribs()
>> being used?
>>
>>
>>
>> We are using Win10-x64.
>>
>>
>>
>> We are trying to get RenderDoc to be able to see our application so we
>> can do some graphics debugging.  It’s shouting back that the current device
>> context wasn’t created using CreateContextAttrib, so I started looking. So
>> since we are using Win64, doesn’t look like osg will go the WindowWin32
>> route. Hmm…
>>
>>
>>
>> How are you debugging the GPU?  It’s incredibly difficult trying to solve
>> realtime pipeline problems without the use of a graphics debugger.
>>
>>
>>
>> 
>>
>> Marlin Rowley
>>
>> Software Engineer, Staff
>>
>> [image: cid:image002.jpg@01D39374.DEC5A2E0]
>>
>> *Missiles and Fire Control*
>>
>> 972-603-1931 (office)
>>
>> 214-926-0622 (mobile)
>>
>> 

Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Where is CreateContextAttribs() being used?

2019-04-15 Thread Glenn Waldron
Here's a quick reference for building OSG (and osgEarth) for GL CORE... may
be helpful.

Glenn Waldron


On Thu, Apr 11, 2019 at 10:49 AM Sebastian Messerschmidt <
sebastian.messerschm...@gmx.de> wrote:

> Merlin,
>
>
>
> As Chris already mentioned the complete application needs to run on
> core-profile. That means there is no fixed function pipeline and no
> backward-compatibility features.
>
> In order to get your application running in core-profile you need to write
> shaders for everything and IIRC compile OSG with GL3 enabled. I haven’t
> used OSG in a while now, but I think there is mechanism to decorate the
> scene graph with shaders automatically.
>
>
>
> I started to refactor my project some years ago to fully support core-only
> scenarios, but I gave up due to a lot features no longer working
> out-of-the-box.
>
> Can you maybe try to explain what you’re trying to debug? There might be
> some more options for you.
>
>
>
>
>
> Cheers
>
> Sebastian
>
>
>
> *From:* osg-users  *On Behalf
> Of *Rowley, Marlin R
> *Sent:* Donnerstag, 11. April 2019 16:24
> *To:* OpenSceneGraph Users 
> *Subject:* Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Where is
> CreateContextAttribs() being used?
>
>
>
> Sebastian,
>
>
>
> What does “core OpenGL profile” mean with regards to the graphics
> context?  I’m still not getting it to work.
>
>
>
> Here is my code structure:
>
>
>
> …
>
> osg::ref_ptr traits = new osg::
> GraphicsContext::Traits;
>
> traits->x = aXPosition;
>
> traits->y = aYPosition;
>
> traits->width  = aWidth;
>
> traits->height = aHeight;
>
> traits->stencil = 8;
>
> traits->doubleBuffer = true;
>
> traits->windowDecoration = false;
>
> #if defined(WIN32)
>
> traits->inheritedWindowData = new osgViewer::
> GraphicsWindowWin32::WindowData( aWindow );
>
> #elif defined(__linux__)
>
>traits->inheritedWindowData = new
> osgViewer::GraphicsWindowX11::WindowData( aWindow );
>
> #endif
>
> // gl graphics context version and profile mask
>
> *traits**->**glContextVersion **=* *"3.3"**;*
>
> *traits**->**glContextProfileMask = 0x1;*
>
>
>
> // create the graphics window from the context
>
> osgViewer::GraphicsWindow* gw = dynamic_cast GraphicsWindow*>(osg::GraphicsContext
> ::createGraphicsContext(traits.get()));
>
>
>
> …
>
>
>
> // set the main camera to use the window
>
> mainCamera->setGraphicsContext( gw );
>
>
>
> …
>
>
>
> I assume here that setting the traits variable with the major/minor
> version of OpenGL and setting the profile mask to 1 (‘core’??) would be all
> I need.  But that’s obviously not the case.
>
>
>
> -M
>
>
>
> 
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg@01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.row...@lmco.com
>
>
>
> *From:* osg-users  *On Behalf
> Of *sebastian.messerschm...@gmx.de
> *Sent:* Thursday, April 11, 2019 9:01 AM
> *To:* 'OpenSceneGraph Users' 
> *Subject:* EXTERNAL: Re: [osg-users] EXTERNAL: Re: Where is
> CreateContextAttribs() being used?
>
>
>
> Hi Marlin,
>
>
>
> In order for RenderDoc (and most tools I’m aware of) you’re application
> needs to run on core OpenGL profile.
>
> You might want to look here for some debugging options:
> https://www.khronos.org/opengl/wiki/Debugging_Tools
>
> I personally used Nvidia Nsight for quite a while, as it at least helps
> with framebuffer debugging etc.
>
>
>
> Cheers
>
> Sebastian
>
>
>
>
>
> *From:* osg-users  *On Behalf
> Of *Rowley, Marlin R
> *Sent:* Donnerstag, 11. April 2019 14:52
> *To:* OpenSceneGraph Users 
> *Subject:* Re: [osg-users] EXTERNAL: Re: Where is CreateContextAttribs()
> being used?
>
>
>
> We are using Win10-x64.
>
>
>
> We are trying to get RenderDoc to be able to see our application so we can
> do some graphics debugging.  It’s shouting back that the current device
> context wasn’t created using CreateContextAttrib, so I started looking. So
> since we are using Win64, doesn’t look like osg will go the WindowWin32
> route. Hmm…
>
>
>
> How are you debugging the GPU?  It’s incredibly difficult trying to solve
> realtime pipeline problems without the use of a graphics debugger.
>
>
>
> 
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg@01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.row...@lmco.com
>
>
>
> *From:* osg-users  *On Behalf
> Of *Robert Osfield
> *Sent:* Thursday, April 11, 2019 7:16 AM
> *To:* OpenSceneGraph Users 
> *Subject:* EXTERNAL: Re: [osg-users] Where is CreateContextAttribs()
> being used?
>
>
>
> Hi Marlin,
>
>
>
> A great for CreateContextttribs in the OSG shows:
>
>
>
> $ grep -r CreateContextAttribs .
> Binary file ./lib/libosgViewer.so.3.6.4 

Re: [osg-users] Volume Rendering and Depth Buffer

2019-04-15 Thread Chris Hanson
Instead of reading Z depth values, can you simply run an intersection of
the click ray-vector against the model data (polygonal and volumetric) when
they click to place markdown points?

On Mon, Apr 15, 2019 at 2:34 PM Anna Osvin  wrote:

> We are working on medical software for Dentists. We need to render CBCT
> and give user possibility to place some markdown points on it, for future
> diagnostics. Also sometimes it's required to render polygonal jaw models
> alongside with CBCT. As I said earlier, we nailed down the rendering and
> even "hit detection", but there is a nasty bag with Z Buffer values of the
> background being incorrect, therefore user can place points onto nothing.
>
> ...
>
> Thank you!
>
> Cheers,
> Anna
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75839#75839
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
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  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EditorConfig file?

2019-04-15 Thread Chris Djali
Hi all,


kornerr wrote:
> Hi, Chris.
> 
> I would guess it might be not exactly appropriate to update
> OpenSceneGraph sources just to have the order in spaces and tabs.
> However, I think VulkanSceneGraph would definitely benefit
> EditorConfig rules. So once VSG has its place at GitHub, I would
> recommend re-raising this issue and creating a pull request.
> 
> Regards,
> Michael.
> 
> On Fri, 12 Apr 2019 at 21:27, Chris Djali <> wrote:
> 
> > 
> > Hi,
> > 
> > Here's a list by file extension of which indentation styles are used. 
> > Annoyingly, a lot of the file extensions that always have tabs somewhere 
> > often have spaces, too, so it's not quite as simple as declaring all .java 
> > files use tabs (although I'm assuming they all used tabs when they were 
> > added and then were edited later to have tabs in places).
> > 
> > I'm going to use my best judgement based on how things look and what 
> > directory they're in etc. but I'm just posting this to illustrate that it's 
> > become a mess and that's why I've not just jumped in with a pull request. 
> > Hopefully, when it's done for OSG, it'll be convincing enough that 
> > VulkanSceneGraph has a .editorconfig file from early on in the project, and 
> > whitespace problems will never come up.
> > 
> > 
> > 
> > > .1: unindented
> > > .README: unindented
> > > .bat: unindented
> > > .c: mixed, spacey, tabby
> > > .cfg: spacey
> > > .cmake: mixed, spacey, unindented
> > > .cpp: mixed, spacey, tabby, unindented
> > > .css: tabby
> > > .h: mixed, spacey, tabby, unindented
> > > .hpp: spacey, unindented
> > > .html: mixed, tabby, unindented
> > > .in: spacey, unindented
> > > .inst: tabby
> > > .java: mixed, tabby
> > > .js: spacey
> > > .l: mixed
> > > .m: mixed, spacey
> > > .md: spacey, unindented
> > > .mk: tabby
> > > .mm: mixed, spacey
> > > .nib: spacey, tabby
> > > .osgt: spacey
> > > .plist: spacey
> > > .properties: unindented
> > > .rc2: unindented
> > > .rc: spacey, unindented
> > > .strings: unindented
> > > .txt: mixed, spacey, unindented
> > > .xml: mixed, spacey, tabby
> > > .y: spacey
> > > .yml: spacey
> > > : mixed, spacey, tabby, unindented
> > > 
> > > 
> > 
> > 
> > Cheers,
> > Chris
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=75831#75831
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum



An .editorconfig file wouldn't actually edit anything immeditately, but in 
supported editors, any new changes would have the correct indentation applied 
(and if someone applied their editor's autoformat tool, that would also apply 
the correct indentation, just like how if they did that now, it would apply 
whatever their editor preferences were set to).


robertosfield wrote:
> Hi Chris, Michael et. al,
> 
> On Sun, 14 Apr 2019 at 15:50, michael kapelko <> wrote:
> 
> > I would guess it might be not exactly appropriate to update
> > OpenSceneGraph sources just to have the order in spaces and tabs.
> > However, I think VulkanSceneGraph would definitely benefit
> > EditorConfig rules. So once VSG has its place at GitHub, I would
> > recommend re-raising this issue and creating a pull request.
> > 
> 
> For the VSG I've adopted clang-format to enforce standard formatting,
> I run this periodically to make sure we don't deviate for too long.
> 
> The .clang-format file is:
> https://github.com/vsg-dev/VulkanSceneGraphPrototype/blob/master/.clang-format
> 
> I am not familiar with EditorConfig, for the VSG it won't be critical
> for enforcing format.  I'm open to suggestons but don't want to liter
> the code base with things that aren't critical to the use of the code
> base.
> 
> Robert.
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum


It seems that clang-format has a lot of similarities in aim with EditorConfig, 
with the main difference being that it seems to be a standalone tool that 
reformats things whereas EditorConfig comes as a library to either integrate 
into existing editors or create plugins for editors so that mistakes can't be 
made in the first place.

Helpfully, Visual Studio 2017 (and later) seems to enforce the rules specified 
in a .clang-format file when one is found as you type, just as it would for an 
.editorconfig file. However, it doesn't look like any other editors do that, 
even with plugins, so running it as a separate pass is still necessary. Aside 
from the decreased chance of messing up git blame, I don't see any reason why 
VSG would 

Re: [osg-users] Volume Rendering and Depth Buffer

2019-04-15 Thread Anna Osvin
We are working on medical software for Dentists. We need to render CBCT and 
give user possibility to place some markdown points on it, for future 
diagnostics. Also sometimes it's required to render polygonal jaw models 
alongside with CBCT. As I said earlier, we nailed down the rendering and even 
"hit detection", but there is a nasty bag with Z Buffer values of the 
background being incorrect, therefore user can place points onto nothing.

... 

Thank you!

Cheers,
Anna

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





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


Re: [osg-users] Volume Rendering and Depth Buffer

2019-04-15 Thread Chris Hanson
Just out of curiousity, what are you volume rendering and what are your
requirements? We did some interesting volume rendering work a few years ago
for Iowa State University's Ames Lab.

On Mon, Apr 15, 2019 at 1:08 PM Anna Osvin  wrote:

> Hi. In a project that I'm working on I have an osgVolume::VolumeScene
> containing one volume model and some polygonal models. I need to do some
> depth buffer checks on that scene, so I've attached depth buffer to viewer
> camera. When I fetch osg::Image representing depth buffer content,
> everything is fine, except background values are not calculated properly
> (they should be 1, but instead it's ~0.15). And when I add osg::Depth(
> osg::Depth::Function::LESS, zNear, zFar ) attribute to the camera,
> background values are calculated correctly, but I lose all of the polygonal
> models data (they are no longer visible, and not presented in depth buffer).
>
> Here is function that does depth buffer checking:
>
> Code:
>
> bool pickZBufferIntersection( osgViewer::View& view, bool
> perspectiveProjection, const osg::Vec2& point2d, osg::Vec3& pickedPoint )
> {
> osg::Camera* camera = view.getCamera();
> if ( camera == nullptr )
> {
> Q_ASSERT_X( false, "bool pickZBufferIntersection( ... )", "View
> has no camera." );
> return false;
> }
>
> const osg::Image* zImage =
> camera->getBufferAttachmentMap()[osg::Camera::BufferComponent::DEPTH_BUFFER]._image;
> if ( zImage == nullptr )
> {
> Q_ASSERT_X( false, "bool pickZBufferIntersection( ... )", "ZBuffer
> is not attached to view camera." );
> return false;
> }
>
> osg::Vec3f cameraPos;
> osg::Vec3f center;
> osg::Vec3f up;
> camera->getViewMatrixAsLookAt( cameraPos, center, up );
>
> osg::Matrixd prInv = osg::Matrixd::inverse(
> camera->getProjectionMatrix() );
> osg::Matrixd viewInv = osg::Matrixd::inverse( camera->getViewMatrix()
> );
>
> const osg::Viewport* viewPort = camera->getViewport();
>
> int x = point2d.x() - viewPort->x();
> int y = point2d.y() - viewPort->y();
>
> osg::Vec3 s(0, 0, -1);
> s[0] = (point2d[0] / viewPort->width()) * 2.0 - 1.0;
> s[1] = (point2d[1] / viewPort->height()) * 2.0 - 1.0;
> s = s * prInv * viewInv;
>
> osg::Vec3d v = s - cameraPos;
>
> double zNear = 1.0f;
> double zFar = 1.0f;
>
> static uint pickNumber = 0;
>
> double zV, z_n, z;
> osg::Vec3f point;
>
> zV = ( (float*)zImage->data( x, y ) )[ 0 ];
>
> if( perspectiveProjection )
> {
> z_n = 2.0*zV - 1.0;
> z = 2.0 * zNear * zFar / ( zFar + zNear - z_n * ( zFar - zNear ) );
>
> point = cameraPos + v*z;
> }
> else
> {
> z = ( zFar - zNear )*zV;
> point = s + ( center - cameraPos )*z;
> }
>
> if( z > zNear + 1e-8 && z < zFar - 1 - 1e-8 )
> {
> pickedPoint = point;
> return true;
> }
> return false;
> }
>
>
>
>
> And here is viewer setup bit:
>
> Code:
>
> QWidget* createViewWidget(osgQt::GraphicsWindowQt* gw,
> osgVolume::VolumeScene& scene)
> {
> osgViewer::View* view = new osgViewer::View;
> /* ... */
> osg::Camera* camera = view->getCamera();
> camera->setGraphicsContext(gw);
>
> camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
>
> const osg::GraphicsContext::Traits* traits = gw->getTraits();
> camera->setClearColor(osgColor( SCENE3D_BACKGROUND_COLOR ));
> camera->setViewport(new osg::Viewport(0, 0, traits->width,
> traits->height));
>
> osg::ref_ptr zImage = new osg::Image();
> zImage->allocateImage(1000, 1000, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
> camera->attach(osg::Camera::DEPTH_BUFFER, zImage);
>
> const int orthoRange = 120;
> const float zNear = 1.0f;
> const float zFar = 1.0f;
> camera->setProjectionMatrixAsOrtho(-orthoRange, orthoRange,
> -orthoRange, orthoRange, zNear, zFar);
> //camera->getOrCreateStateSet()->setAttribute( new osg::Depth(
> osg::Depth::Function::LESS, zNear, zFar ), osg::StateAttribute::ON |
> osg::StateAttribute::OVERRIDE );
>
> /* ... */
>
> view->setSceneData();
> view->addEventHandler(new osgViewer::StatsHandler);
>
> gw->setTouchEventsEnabled(true);
>
> return gw->getGLWidget();
> }
>
>
>
>
> ...
>
> Thank you!
>
> Cheers,
> Annie[/img]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75829#75829
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/depth_buffer_depthrange_185.png
> http://forum.openscenegraph.org//files/depth_buffer_154.png
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene 

[osg-users] Volume Rendering and Depth Buffer

2019-04-15 Thread Anna Osvin
Hi. In a project that I'm working on I have an osgVolume::VolumeScene 
containing one volume model and some polygonal models. I need to do some depth 
buffer checks on that scene, so I've attached depth buffer to viewer camera. 
When I fetch osg::Image representing depth buffer content, everything is fine, 
except background values are not calculated properly (they should be 1, but 
instead it's ~0.15). And when I add osg::Depth( osg::Depth::Function::LESS, 
zNear, zFar ) attribute to the camera, background values are calculated 
correctly, but I lose all of the polygonal models data (they are no longer 
visible, and not presented in depth buffer).

Here is function that does depth buffer checking:

Code:

bool pickZBufferIntersection( osgViewer::View& view, bool 
perspectiveProjection, const osg::Vec2& point2d, osg::Vec3& pickedPoint )
{
osg::Camera* camera = view.getCamera();
if ( camera == nullptr )
{
Q_ASSERT_X( false, "bool pickZBufferIntersection( ... )", "View has no 
camera." );
return false;
}

const osg::Image* zImage = 
camera->getBufferAttachmentMap()[osg::Camera::BufferComponent::DEPTH_BUFFER]._image;
if ( zImage == nullptr )
{
Q_ASSERT_X( false, "bool pickZBufferIntersection( ... )", "ZBuffer is 
not attached to view camera." );
return false;
}

osg::Vec3f cameraPos;
osg::Vec3f center;
osg::Vec3f up;
camera->getViewMatrixAsLookAt( cameraPos, center, up );

osg::Matrixd prInv = osg::Matrixd::inverse( camera->getProjectionMatrix() );
osg::Matrixd viewInv = osg::Matrixd::inverse( camera->getViewMatrix() );

const osg::Viewport* viewPort = camera->getViewport();

int x = point2d.x() - viewPort->x();
int y = point2d.y() - viewPort->y();

osg::Vec3 s(0, 0, -1);
s[0] = (point2d[0] / viewPort->width()) * 2.0 - 1.0;
s[1] = (point2d[1] / viewPort->height()) * 2.0 - 1.0;
s = s * prInv * viewInv;

osg::Vec3d v = s - cameraPos;

double zNear = 1.0f;
double zFar = 1.0f;

static uint pickNumber = 0;

double zV, z_n, z;
osg::Vec3f point;

zV = ( (float*)zImage->data( x, y ) )[ 0 ];

if( perspectiveProjection )
{
z_n = 2.0*zV - 1.0;
z = 2.0 * zNear * zFar / ( zFar + zNear - z_n * ( zFar - zNear ) );

point = cameraPos + v*z;
}
else
{
z = ( zFar - zNear )*zV;
point = s + ( center - cameraPos )*z;
}

if( z > zNear + 1e-8 && z < zFar - 1 - 1e-8 )
{
pickedPoint = point;
return true;
}
return false;
}




And here is viewer setup bit:

Code:

QWidget* createViewWidget(osgQt::GraphicsWindowQt* gw, osgVolume::VolumeScene& 
scene)
{
osgViewer::View* view = new osgViewer::View;
/* ... */
osg::Camera* camera = view->getCamera();
camera->setGraphicsContext(gw);
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);

const osg::GraphicsContext::Traits* traits = gw->getTraits();
camera->setClearColor(osgColor( SCENE3D_BACKGROUND_COLOR ));
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));

osg::ref_ptr zImage = new osg::Image();
zImage->allocateImage(1000, 1000, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
camera->attach(osg::Camera::DEPTH_BUFFER, zImage);

const int orthoRange = 120;
const float zNear = 1.0f;
const float zFar = 1.0f;
camera->setProjectionMatrixAsOrtho(-orthoRange, orthoRange, -orthoRange, 
orthoRange, zNear, zFar);
//camera->getOrCreateStateSet()->setAttribute( new osg::Depth( 
osg::Depth::Function::LESS, zNear, zFar ), osg::StateAttribute::ON | 
osg::StateAttribute::OVERRIDE );

/* ... */

view->setSceneData();
view->addEventHandler(new osgViewer::StatsHandler);

gw->setTouchEventsEnabled(true);

return gw->getGLWidget();
}




... 

Thank you!

Cheers,
Annie[/img]

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




Attachments: 
http://forum.openscenegraph.org//files/depth_buffer_depthrange_185.png
http://forum.openscenegraph.org//files/depth_buffer_154.png


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


[osg-users] [forum] How to add text in osgviewer application

2019-04-15 Thread Jai Singla
Hi,

in case i want to highlight text in osgviewer based application to protect 
this, how to do that ?


Thank you!

Cheers,
Jai

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





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