[osg-users] Changing minFilter/magFilter of texture in osgVolume::RayTracedTechnique

2019-04-16 Thread Sailesh Sidhwani
I have RayTracedTechnique putting graphics on the screen, but things aren't 
rendering correctly. The culprit is the 'osg::Texture3D::LINEAR' choice that is 
used by default as the min/mag filter for the Texture3D object created by 
RayTracedTechnique. I'd like to change to NEAREST as I'm working with 
segmented/ labeled volume.   The problem I'm seeing is that when I use the 
setMinFilter and setMaxFilter methods on the associated ImageLayer, things 
aren't getting updated for some reason. I know that's what's going on because 
if I actually edit the code in RayTracedTechnique.cpp to use NEAREST for the 
min/max filter on the Texture3D, I get the texture I want on the screen.


Here is some code for context:

osg::ref_ptr volume = new osgVolume::Volume;

osg::ref_ptr tile = new 
osgVolume::VolumeTile;
volume->addChild(tile.get());

osg::ref_ptr image_3d = 
createTexture3D(data,xfer_table);

osg::ref_ptr layer = new 
osgVolume::ImageLayer(image_3d.get());

tile->setLayer(layer.get());

layer->addProperty(new osgVolume::AlphaFuncProperty(0.02f));

osg::ref_ptr technique = new 
osgVolume:: RayTracedTechnique ();
technique->setNumSlices(200);
tile->setVolumeTechnique(technique);

layer->setMagFilter(osg::Texture3D:: NEAREST);
layer->setMinFilter(osg::Texture3D:: NEAREST);


Here is how the output looks when I edit RayTracedTechnique.cpp to use NEAREST 
minFilter/magFilter. This is how I expect it to look

[cid:image001.png@01D4F464.82427F50]



Default RayTracedTechnique.cpp (which uses LINEAR minFilter/magFilter): (Not 
expected)
[cid:image003.png@01D4F466.84604450]


How can I force the Texture3D object created by RayTracedTechnique to use 
NEAREST for minFilter/magFiltering?


I'm using OSG 3.0. I know I need to upgrade, but I didn't see any way to do 
this even in OSG 3.6


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


Re: [osg-users] Image capture in memory

2019-04-16 Thread sam
https://github.com/openscenegraph/OpenSceneGraph/blob/master/examples/osgposter/osgposter.cpp


On Tue, Apr 16, 2019 at 12:22 PM Catalin Flower  wrote:

> Hi,
>
> What is the canonical way to capture an image of a view to memory with
> different resolutions?
>
> Thank you!
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75830#75830
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Removing objects with shared GL state from scene graph

2019-04-16 Thread Chris Djali
Hi,

The following basically simulates the use case that's causing problems.


Code:
#include 

#include 
#include 
#include 
#include 

#include 

#include 

/** A representation of something that gets edited.
 *  Pretend it's actually more complicated than this so that reference counting 
the number of attached text nodes is a nuisance. */
class World
{
public:
World() : mScene(new osg::Group)
{
// add things so the viewer doesn't automatically zoom too far in to 
see the 'objects'

auto worldCorners = { osg::Vec3(-11, -11, -11), osg::Vec3(-11, -11, 11),
  osg::Vec3(-11, 11, -11), osg::Vec3(-11, 11, 11),
  osg::Vec3(11, -11, -11), osg::Vec3(11, -11, 11),
  osg::Vec3(11, 11, -11), osg::Vec3(11, 11, 11) };

for (auto corner : worldCorners)
{
osg::ref_ptr pat = new 
osg::PositionAttitudeTransform();
pat->setPosition(corner);
pat->addChild(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0, 
0, 0), 0.1)));
mScene->addChild(pat);
}
}

osg::ref_ptr getScene() { return mScene; }

/** Adds an object with a label to the scene based on something the user 
has done. */
void addObject(std::string name)
{
osg::ref_ptr object = new 
osg::PositionAttitudeTransform();
object->setName(name);

static std::random_device r;
static std::default_random_engine randEngine(r());
static std::uniform_real_distribution<> dist(-10, 10);

object->setPosition(osg::Vec3(dist(randEngine), dist(randEngine), 
dist(randEngine)));

osg::ref_ptr objectLabel = new osgText::Text();
osg::ref_ptr autoTransform = new 
osg::AutoTransform();
autoTransform->addChild(objectLabel);
autoTransform->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
object->addChild(autoTransform);
autoTransform->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, 
osg::StateAttribute::OFF);
objectLabel->setText(name);
objectLabel->setCharacterSize(1);

osg::ref_ptr shape = new osg::Sphere(osg::Vec3(0, 0, 0), 1);
object->addChild(new osg::ShapeDrawable(shape));

mScene->addChild(object);
}

/** Removes an object from the scene based on something the user has done. 
*/
void removeObject(std::string name)
{
osg::ref_ptr child;
for (unsigned int i = 0; i < mScene->getNumChildren(); ++i)
{
if (mScene->getChild(i)->getName() == name)
{
child = mScene->getChild(i);
mScene->removeChild(i);
break;
}
}

// If we call child->releaseGLObjects() here, the text program will be 
released, too, even though it could still be being used by other labels.
// If we don't, we may be detaching the last text node from the scene 
graph, and so the text program may never get released.
}

private:
osg::ref_ptr mScene;
};


World world;
bool useNewViewer = true;

class EventHandler : public osgGA::GUIEventHandler
{
public:
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if (ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN)
return false;

// The user may wish to close the 3D view to work on something else and 
then reopen it later.
// That would be a pain to implement directly, so instead, we simulate 
it by reopening the 3D view when it's closed if Return was pressed while it was 
open.
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Return)
{
useNewViewer = true;
return true;
}
// Press a letter key without shift to add an object.
else if (ea.getKey() >= 'a' && ea.getKey() <= 'z')
{
std::string name(1, ea.getKey());
world.addObject(name);
return true;
}
// Press a letter key with shift to remove an object.
else if (ea.getKey() >= 'A' && ea.getKey() <= 'Z')
{
std::string name(1, ea.getKey() - ('Z' - 'z'));
world.removeObject(name);
return true;
}

return false;
}
};

int main()
{
osg::ref_ptr currentViewer;

int returnCode = 0;

while (useNewViewer)
{
currentViewer = new osgViewer::Viewer;
currentViewer->setSceneData(world.getScene());
currentViewer->addEventHandler(new EventHandler);

useNewViewer = false;

returnCode = currentViewer->run();
}

return returnCode;
}




Imagine this is part of a world editor for a game or CAD software or one of any 
number of types of software packages where you edit something and might want a 
3D view of it, but wouldn't necessarily always want that 3D view taking up 
space in the window, so you'd possibly close it and then reopen it 

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

2019-04-16 Thread Chris Hanson
Yeah, I wouldn't totally expect it would, but you can probably do that
intersection test yourself if needed. I think it'll be faster and more
accurate than the Z-buffer.

I did a tool that relied on the Z-buffer once. It was a bad choice...

On Tue, Apr 16, 2019 at 1:05 PM Anna Osvin  wrote:

> If you mean osgViewer::View::computeIntersections, then we tried it. For
> some reason it does not check intersections with volume model.
>
> Here is raycast intersection check code:
>
> Code:
>
> bool pickPolygonalSceneIntersection( osgViewer::View& view, const
> osg::Vec2& point2d, osg::Vec3& pickedPoint )
> {
> const osg::Camera* camera = view.getCamera();
> if ( camera == nullptr ) {
> Q_ASSERT_X( false, "bool pickPolygonalSceneIntersection( ... )",
> "View has no camera." );
> return false;
> }
>
> osgUtil::LineSegmentIntersector::Intersections intersections;
>
> if ( view.computeIntersections( camera,
> osgUtil::Intersector::CoordinateFrame::WINDOW, point2d.x(), point2d.y(),
> intersections ) )
> {
> for (osgUtil::LineSegmentIntersector::Intersections::iterator hitr
> = intersections.begin();
> hitr != intersections.end();
> ++hitr)
> {
> if (hitr->nodePath.size() > 4)
> {
> pickedPoint = hitr->getWorldIntersectPoint();
>
> return true;
> }
> }
> }
>
> return false;
> }
>
>
>
>
>
> Chris Hanson wrote:
> > 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 (
> http://forum.openscenegraph.org/viewtopic.php?p=75839#75839)
> > >
> > >
> > >
> > >
> > >
> > > ___
> > > osg-users mailing list
> > >  ()
> > >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> )
> > >
> >
> >
> >
> > --
> > Chris 'Xenon' Hanson, omo sanza lettere.  http://www.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 (https://twitter.com/alphapixel) facebook.com/alphapixel (
> http://facebook.com/alphapixel) (775) 623-PIXL [7495]
> >
> >  --
> > Post generated by Mail2Forum
> [/code]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75845#75845
>
>
>
>
>
> ___
> 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] Image capture in memory

2019-04-16 Thread Alberto Luaces
"Catalin Flower" writes:

> Hi,
>
> What is the canonical way to capture an image of a view to memory with 
> different resolutions?

Hi, I think that examples/osgposter/osgposter.cpp might be what you are
looking for.

-- 
Alberto

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


[osg-users] Missing features with GL Core profile

2019-04-16 Thread Hugo Laloge
Hi,

I use OpenSceneGraph and I want to use some features of OpenGL 3.3 and the Core 
profile. I compiled OpenSceneGraph with the option -DOPENGL_PROFILE=GL3. I got 
the features I wanted, however, some features of OSG do not work anymore, as 
lighting with osg::Light, osg::LineWidth, osg::LineStipple on so on.

I know OSG is mainly built uppon GL2 features, and that Fixed Function Pipeline 
is not available in core profile, but I expected for "basic" features as light 
or lines to work.

It the support of those features in Core profile is planned? Or do I have to 
implement shaders myself? Or are there any existing implementation?


Thank you for your time,
Hugo

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





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


[osg-users] Image capture in memory

2019-04-16 Thread Catalin Flower
Hi,

What is the canonical way to capture an image of a view to memory with 
different resolutions?

Thank you!

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





___
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-16 Thread Anna Osvin
If you mean osgViewer::View::computeIntersections, then we tried it. For some 
reason it does not check intersections with volume model.

Here is raycast intersection check code:

Code:

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

osgUtil::LineSegmentIntersector::Intersections intersections;

if ( view.computeIntersections( camera, 
osgUtil::Intersector::CoordinateFrame::WINDOW, point2d.x(), point2d.y(), 
intersections ) )
{
for (osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin();
hitr != intersections.end();
++hitr)
{
if (hitr->nodePath.size() > 4)
{
pickedPoint = hitr->getWorldIntersectPoint();

return true;
}
}
}

return false;
}





Chris Hanson wrote:
> 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 
> > (http://forum.openscenegraph.org/viewtopic.php?p=75839#75839)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
> 
> -- 
> Chris 'Xenon' Hanson, omo sanza lettere.  http://www.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 (https://twitter.com/alphapixel) facebook.com/alphapixel 
> (http://facebook.com/alphapixel) (775) 623-PIXL [7495]
> 
>  --
> Post generated by Mail2Forum
[/code]

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





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