Re: [osg-users] osgFX Outline Patch

2010-09-13 Thread Todd J. Furlong

On 9/8/2010 10:26 AM, Jean-Sébastien Guay wrote:

Hi Todd,


Thanks for the suggestions. I just tried that, and unfortunately this
particular exception seems to occur *after* exit. It seems to be this
error:
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/afebacc2-65e6-43f8-b7aa-73bfd5ade11d


Anyway, thanks again. I'm pretty sure this isn't an OSG problem, but
I'll post an update if it turns out to be one.


Well that post relates to VB garbage collection and Crystal Reports, so
I'm pretty sure it's not related :-)

A crash on exit is generally a double-delete... Are you using ref_ptrs
for all your OSG variables? Or are you doing weird things with memory
allocation?

Small anecdote on that subject:

A while ago we had a class in our code base that derived from an OSG
class (so from osg::Referenced indirectly) but declared its destructor
public. So users of that class could delete it while it was still in the
scene graph, and when OSG (through ref counts falling to 0 and cascading
deletes of ref_ptrs) came to delete it, it had already been deleted,
thus the app crashed on exit. So making the destructor of an
osg::Referenced-derived class public is a no-no, unless you can make
sure to remove it from all OSG structures before you delete it (which is
a lot of work for not much gain, IMHO, so just keep that destructor
protected and all will be fine).

Hope this helps,

J-S


OK, I tracked this one down and wanted to share.  I was compiling the 
Outline class with my app - my app uses OSG 2.8.3, but the class is from 
the OSG trunk.  Apparently, this line was causing the problem:

Registry::Proxy proxy(new Outline);

The class works fine without that line, so commenting it out fixed the 
problem.  I think that this wouldn't have been an issue at all if I just 
used the OSG trunk completely, but I'm trying to stick with official 
releases for apps we develop.


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


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Florian Kolbe
Salut Jean-Sébastien,

  thank you for your advice. I already had the line


Code:
osg::DisplaySettings::instance()-setMinimumNumStencilBits(1);



set as in osgoutline. Just to make sure, I disabled it to see that the line 
does not make any difference...

Then I noticed how osgViewer::View feeds the osg::GraphicsContext::Traits from 
various fields of osg::DisplaySettings, as for example in 
View::setUpViewOnSingleScreen(). Since I am using my own call to 
osg::GraphicsContext::createGraphicsContext() I was missing a line such as:


Code:
traits-stencil = ds-getMinimumNumStencilBits();



Problem solved!

Thank you!

Cheers,
Florian

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





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


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Todd J. Furlong
While we are on the topic of the Outline class, I'm experiencing 
something strange: My application crashes on exit with an unknown 
exception if an osgFX::Outline node is in the scenegraph, but it 
doesn't crash otherwise.  I haven't been able to trace this, so I was 
wondering if anyone else had a similar experience.  This is on Windows.


-Todd

On 9/8/2010 3:27 AM, Florian Kolbe wrote:

Salut Jean-Sébastien,

   thank you for your advice. I already had the line


Code:
osg::DisplaySettings::instance()-setMinimumNumStencilBits(1);



set as in osgoutline. Just to make sure, I disabled it to see that the line 
does not make any difference...

Then I noticed how osgViewer::View feeds the osg::GraphicsContext::Traits from 
various fields of osg::DisplaySettings, as for example in 
View::setUpViewOnSingleScreen(). Since I am using my own call to 
osg::GraphicsContext::createGraphicsContext() I was missing a line such as:


Code:
traits-stencil = ds-getMinimumNumStencilBits();



Problem solved!

Thank you!

Cheers,
Florian

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





___
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] osgFX Outline Patch

2010-09-08 Thread Jean-Sébastien Guay

Hello Todd,


While we are on the topic of the Outline class, I'm experiencing
something strange: My application crashes on exit with an unknown
exception if an osgFX::Outline node is in the scenegraph, but it
doesn't crash otherwise. I haven't been able to trace this, so I was
wondering if anyone else had a similar experience. This is on Windows.


Does osgoutline cow.osg work for you? If so, then you'll have to run 
your code in debug and in the debugger, in order to find the source of 
the crash. Crashes are actually pretty much the simplest bugs to find 
the source of, since the debugger will immediately point the place where 
it crashed...


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Todd J. Furlong

J-S,

Thanks for the reply. I will have to give that a try.

So far, this crash seems to be an odd one because the debugger doesn't 
seem to catch it.  All I get is this friendly message:
The exception unknown software exception (0xc0020001) occurred in the 
application at location 0x7c812afb


-Todd

On 9/8/2010 9:24 AM, Jean-Sébastien Guay wrote:

Hello Todd,


While we are on the topic of the Outline class, I'm experiencing
something strange: My application crashes on exit with an unknown
exception if an osgFX::Outline node is in the scenegraph, but it
doesn't crash otherwise. I haven't been able to trace this, so I was
wondering if anyone else had a similar experience. This is on Windows.


Does osgoutline cow.osg work for you? If so, then you'll have to run
your code in debug and in the debugger, in order to find the source of
the crash. Crashes are actually pretty much the simplest bugs to find
the source of, since the debugger will immediately point the place where
it crashed...

J-S


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


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Jean-Sébastien Guay

Hi Todd,


So far, this crash seems to be an odd one because the debugger doesn't
seem to catch it. All I get is this friendly message:
The exception unknown software exception (0xc0020001) occurred in the
application at location 0x7c812afb


In Visual Studio, enable all exceptions by going to Debug - 
Exceptions... and checking all the boxes. Then the debugger should catch 
the exception and break at the point where it was thrown. You can then 
go a few levels up the stack to pinpoint the cause.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Todd J. Furlong

On 9/8/2010 9:58 AM, Jean-Sébastien Guay wrote:

Hi Todd,


So far, this crash seems to be an odd one because the debugger doesn't
seem to catch it. All I get is this friendly message:
The exception unknown software exception (0xc0020001) occurred in the
application at location 0x7c812afb


In Visual Studio, enable all exceptions by going to Debug -
Exceptions... and checking all the boxes. Then the debugger should catch
the exception and break at the point where it was thrown. You can then
go a few levels up the stack to pinpoint the cause.

Hope this helps,

J-S


Thanks for the suggestions.  I just tried that, and unfortunately this 
particular exception seems to occur *after* exit.  It seems to be this 
error:

http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/afebacc2-65e6-43f8-b7aa-73bfd5ade11d

Anyway, thanks again.  I'm pretty sure this isn't an OSG problem, but 
I'll post an update if it turns out to be one.


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


Re: [osg-users] osgFX Outline Patch

2010-09-08 Thread Jean-Sébastien Guay

Hi Todd,


Thanks for the suggestions. I just tried that, and unfortunately this
particular exception seems to occur *after* exit. It seems to be this
error:
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/afebacc2-65e6-43f8-b7aa-73bfd5ade11d

Anyway, thanks again. I'm pretty sure this isn't an OSG problem, but
I'll post an update if it turns out to be one.


Well that post relates to VB garbage collection and Crystal Reports, so 
I'm pretty sure it's not related :-)


A crash on exit is generally a double-delete... Are you using ref_ptrs 
for all your OSG variables? Or are you doing weird things with memory 
allocation?


Small anecdote on that subject:

A while ago we had a class in our code base that derived from an OSG 
class (so from osg::Referenced indirectly) but declared its destructor 
public. So users of that class could delete it while it was still in the 
scene graph, and when OSG (through ref counts falling to 0 and cascading 
deletes of ref_ptrs) came to delete it, it had already been deleted, 
thus the app crashed on exit. So making the destructor of an 
osg::Referenced-derived class public is a no-no, unless you can make 
sure to remove it from all OSG structures before you delete it (which is 
a lot of work for not much gain, IMHO, so just keep that destructor 
protected and all will be fine).


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgFX Outline Patch

2010-09-07 Thread Florian Kolbe
Hi,

I am still facing an issue with this effect. I tried my model (a chair) with 
osgoutline (2.9.8) and it looked just fine. I integrated the code of 
osgoutline.cpp into my application and I integrated Outline* into my build 
(still using 2.8.3).

Note the attached image. The first chair has no effect, the second chair has 
the outline effect, and the third chair has the scribe effect. As you can see 
with the middle chair, the legs seem to be working but then the seats polygon 
lines get exposed? May this be an issue due to using 2.8.3 ? 

Cheers,
   Florian

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




Attachments: 
http://forum.openscenegraph.org//files/outline_878.png


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


Re: [osg-users] osgFX Outline Patch

2010-09-07 Thread Jean-Sébastien Guay

Hello Florian,


Note the attached image. The first chair has no effect, the second chair has 
the outline effect, and the third chair has the scribe effect. As you can see 
with the middle chair, the legs seem to be working but then the seats polygon 
lines get exposed? May this be an issue due to using 2.8.3 ?


You need to enable the stencil buffer when you create your graphics 
context in order for the outline effect to work correctly. If this is 
not done you'll get the problem you have (sometimes internal polygons 
are shown, sometimes not, depending on order of drawing).


You should be able to use 
osg::DisplaySettings::instance()-setMinimumNumStencilBits(8); before 
creating your viewer/window/context to do this, or modify the traits you 
pass to createGraphicsContext() if you're creating it yourself.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgFX Outline Patch

2010-09-04 Thread Ulrich Hertlein
Hi Todd and Robert,

On 4/09/10 0:21 , Todd J. Furlong wrote:
 I made a couple of changes to the osgFX::Outline class (SVN patch attached).  
 I had a
 couple of issues with it that I was trying to resolve:
 
 1. When an outline object was occluded by another object, the backfacing 
 wireframe was
 exposed.  To fix that, I removed the disabling of GL_DEPTH_TEST.

I've modified the osgoutline example to expose the issue and have verified your 
patch and
it works as advertised.  It still is a bit odd, since the depth_test=off seems 
to bleed
from the FX into other parts of the scene.

The modified files (and the patch) is attached.

Cheers,
/ulrich
Index: src/osgFX/Outline.cpp
===
--- src/osgFX/Outline.cpp   (revision 11730)
+++ src/osgFX/Outline.cpp   (working copy)
@@ -30,7 +30,8 @@
 #include osg/Texture1D
 
 
-namespace {
+namespace
+{
 const unsigned int Override_On = 
osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE;
 const unsigned int Override_Off = 
osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE;
 }
@@ -71,8 +72,9 @@
 _color = color;
 if (_material.valid()) {
 const osg::Material::Face face = osg::Material::FRONT_AND_BACK;
-_material-setAmbient(face, color);
-_material-setDiffuse(face, color);
+_material-setAmbient(face, osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+_material-setDiffuse(face, osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+_material-setSpecular(face, osg::Vec4(0.0f, 0.0f, 0.0f, 
1.0f));
 _material-setEmission(face, color);
 }
 }
@@ -119,14 +121,14 @@
 state-setAttributeAndModes(stencil, Override_On);
 
 // cull front-facing polys
-osg::CullFace* cf = new osg::CullFace;
-cf-setMode(osg::CullFace::FRONT);
-state-setAttributeAndModes(cf, Override_On);
+osg::CullFace* cullFace = new osg::CullFace;
+cullFace-setMode(osg::CullFace::FRONT);
+state-setAttributeAndModes(cullFace, Override_On);
 
 // draw back-facing polygon lines
-osg::PolygonMode* pm = new osg::PolygonMode;
-pm-setMode(osg::PolygonMode::BACK, osg::PolygonMode::LINE);
-state-setAttributeAndModes(pm, Override_On);
+osg::PolygonMode* polyMode = new osg::PolygonMode;
+polyMode-setMode(osg::PolygonMode::BACK, 
osg::PolygonMode::LINE);
+state-setAttributeAndModes(polyMode, Override_On);
 
 // outline width
 _lineWidth = new osg::LineWidth;
@@ -135,13 +137,13 @@
 
 // outline color/material
 _material = new osg::Material;
-_material-setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
+_material-setColorMode(osg::Material::OFF);
 setColor(_color);
 state-setAttributeAndModes(_material.get(), Override_On);
 
 // disable modes
 state-setMode(GL_BLEND, Override_Off);
-state-setMode(GL_DEPTH_TEST, Override_Off);
+//state-setMode(GL_DEPTH_TEST, Override_Off);
 state-setTextureMode(0, GL_TEXTURE_1D, Override_Off);
 state-setTextureMode(0, GL_TEXTURE_2D, Override_Off);
 state-setTextureMode(0, GL_TEXTURE_3D, Override_Off);
Index: examples/osgoutline/osgoutline.cpp
===
--- examples/osgoutline/osgoutline.cpp  (revision 11730)
+++ examples/osgoutline/osgoutline.cpp  (working copy)
@@ -5,6 +5,7 @@
  */
 
 #include osg/Group
+#include osg/PositionAttitudeTransform
 
 #include osgDB/ReadFile
 #include osgViewer/Viewer
@@ -18,18 +19,59 @@
 
arguments.getApplicationUsage()-setCommandLineUsage(arguments.getApplicationName()+
 [options] file);
 arguments.getApplicationUsage()-addCommandLineOption(-h or 
--help,Display this information);

-// create outline effect
-osg::ref_ptrosgFX::Outline outline = new osgFX::Outline;
-outline-setWidth(8);
-outline-setColor(osg::Vec4(1,1,0,1));
+// load outlined object
+std::string modelFilename = arguments.argc()  1 ? arguments[1] : 
dumptruck.osg;
+osg::ref_ptrosg::Node outlineModel = osgDB::readNodeFile(modelFilename);
+if (!outlineModel)
+{
+osg::notify(osg::FATAL)  Unable to load model '  modelFilename 
 '\n;
+return -1;
+}
 
+// load occluded object
+std::string occludedModelFilename = cow.osg;
+osg::ref_ptrosg::Node occludedModel = 
osgDB::readNodeFile(occludedModelFilename);
+if (!occludedModel)
+{
+osg::notify(osg::FATAL)  Unable to load model '  
occludedModelFilename  '\n;
+return -1;
+}
+
 // create scene
 osg::ref_ptrosg::Group