Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-08-02 Thread Alessandro Terenzi
I'm trying the Javier's CappingEffect example and it seems to work fine...but 
only when I look at the scene from one side...if I move the camera to the 
opposite side I still see the cappings that are drawn over my geometry (they 
should be hidden instead)...please refer to the attachments to see what I mean.

In order to use the CappingEffect I modified osgviewer in this way:


Code:
osg::ClipNode* clipnode = new osg::ClipNode;
osg::ClipPlane* clipplane = new osg::ClipPlane(); 
clipplane-setClipPlane(0, 1, 0, 1); 

clipnode-addClipPlane(clipplane);
clipnode-addChild(loadedModel.get());

CappingEffect* capping_effect = new CappingEffect;
capping_effect-addChild(clipnode);

scene-addChild(capping_effect);
viewer.setSceneData(scene);




How can I solve the issue?
Thanks.
Alessandro

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




Attachments: 
http://forum.openscenegraph.org//files/capping_2_434.png
http://forum.openscenegraph.org//files/capping_1_109.png


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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-08-01 Thread Cory Riddell
Javier,

Thanks so much for the link. I haven't seen this thread before.

I'm looking at your code and I'm not exactly sure how the CappingEffect
node fits into the scene graph.

Say I want to cut the cow in half and cap it. I am going to need a
ClipNode / ClipPlane and the CappingEffect node, correct? Do I then have
to have a topmost group node, with CappingEffect and ClipNode children
then have the cow scene be a child to both of those nodes?

Cory



On 7/26/2011 6:44 AM, Javier Taibo wrote:
   Hi Cory,

   Sorry I came a bit late to this thread, but just in case you sill
 find it useful, I sent some code to the list about a year ago, that
 implements the stencil technique described in the red book. It is in
 this message:

 http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2010-September/044664.html


   Regards,


 On Wed, Jul 20, 2011 at 5:48 PM, Cory Riddell c...@codeware.com wrote:
 I've been thinking about using a ClipNode to cut my model in two to
 expose the inside details like a cutaway drawing. Just sticking a
 ClipNode at the root of my model graph does remove half of it, but the
 model ends up looking hollow rather than solid. I want to cap the open
 side. For example, if a sphere is cut in two, I would cap the open side
 with a circle.

 A bit of searching for how to do this with OpenGL turned up this page
 (http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
 using the stencil buffer. Does the technique outlined in the article
 look like a reasonable OSG-friendly approach? Any advice or pointers to
 other examples? Grepping the example code turns up a bunch of stencil
 code, but I'm still a little lost (OpenGL newbie).

 Thanks,
 Cory
 ___
 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


[osg-users] using ClipNode to cut a model in two, then cap the open side

2011-08-01 Thread Sergey Kurdakov
Hi

just an example of what can be done with ogs in this respect

http://forum.openscenegraph.org/viewtopic.php?t=8512 ( also some hints )

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-08-01 Thread Paul Martz
ClipNode is positional state (like lights). It just needs to be somewhere in 
your scene graph, and it it in effect at *any* part of your scene graph that 
enables GL_CLIP_PLANEn. So the placement of ClipNode relative to the cow is 
irrelevant.


Don't know about Javier's CappingEffect; I'd just use a Camera node to 
post-render a fullscreen quad with appropriate stencil settings. It'll only show 
up on the capped area if done correctly. Be sure to specify a normal that 
matches your clip plane for correct lighting.

   -Paul


On 8/1/2011 2:15 PM, Cory Riddell wrote:

Javier,

Thanks so much for the link. I haven't seen this thread before.

I'm looking at your code and I'm not exactly sure how the CappingEffect
node fits into the scene graph.

Say I want to cut the cow in half and cap it. I am going to need a
ClipNode / ClipPlane and the CappingEffect node, correct? Do I then have
to have a topmost group node, with CappingEffect and ClipNode children
then have the cow scene be a child to both of those nodes?

Cory



On 7/26/2011 6:44 AM, Javier Taibo wrote:

   Hi Cory,

   Sorry I came a bit late to this thread, but just in case you sill
find it useful, I sent some code to the list about a year ago, that
implements the stencil technique described in the red book. It is in
this message:

http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2010-September/044664.html


   Regards,


On Wed, Jul 20, 2011 at 5:48 PM, Cory Riddellc...@codeware.com  wrote:

I've been thinking about using a ClipNode to cut my model in two to
expose the inside details like a cutaway drawing. Just sticking a
ClipNode at the root of my model graph does remove half of it, but the
model ends up looking hollow rather than solid. I want to cap the open
side. For example, if a sphere is cut in two, I would cap the open side
with a circle.

A bit of searching for how to do this with OpenGL turned up this page
(http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
using the stencil buffer. Does the technique outlined in the article
look like a reasonable OSG-friendly approach? Any advice or pointers to
other examples? Grepping the example code turns up a bunch of stencil
code, but I'm still a little lost (OpenGL newbie).

Thanks,
Cory
___
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





--
  -Paul Martz  Skew Matrix Software
   http://www.skew-matrix.com/

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-26 Thread Javier Taibo
  Hi Cory,

  Sorry I came a bit late to this thread, but just in case you sill
find it useful, I sent some code to the list about a year ago, that
implements the stencil technique described in the red book. It is in
this message:

http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2010-September/044664.html


  Regards,


On Wed, Jul 20, 2011 at 5:48 PM, Cory Riddell c...@codeware.com wrote:
 I've been thinking about using a ClipNode to cut my model in two to
 expose the inside details like a cutaway drawing. Just sticking a
 ClipNode at the root of my model graph does remove half of it, but the
 model ends up looking hollow rather than solid. I want to cap the open
 side. For example, if a sphere is cut in two, I would cap the open side
 with a circle.

 A bit of searching for how to do this with OpenGL turned up this page
 (http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
 using the stencil buffer. Does the technique outlined in the article
 look like a reasonable OSG-friendly approach? Any advice or pointers to
 other examples? Grepping the example code turns up a bunch of stencil
 code, but I'm still a little lost (OpenGL newbie).

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




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


[osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Cory Riddell
I've been thinking about using a ClipNode to cut my model in two to
expose the inside details like a cutaway drawing. Just sticking a
ClipNode at the root of my model graph does remove half of it, but the
model ends up looking hollow rather than solid. I want to cap the open
side. For example, if a sphere is cut in two, I would cap the open side
with a circle.

A bit of searching for how to do this with OpenGL turned up this page
(http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
using the stencil buffer. Does the technique outlined in the article
look like a reasonable OSG-friendly approach? Any advice or pointers to
other examples? Grepping the example code turns up a bunch of stencil
code, but I'm still a little lost (OpenGL newbie).

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Paul Martz
Using stencil for capping is an old trick and works well. I don't know of any 
example code for it, and it's been years, more than a decade, since I've done it 
myself. Your only other option would be some type of CSG approach, which would 
be computationally expensive, especially if the clip plane is dynamic.

   -Paul


On 7/20/2011 9:48 AM, Cory Riddell wrote:

I've been thinking about using a ClipNode to cut my model in two to
expose the inside details like a cutaway drawing. Just sticking a
ClipNode at the root of my model graph does remove half of it, but the
model ends up looking hollow rather than solid. I want to cap the open
side. For example, if a sphere is cut in two, I would cap the open side
with a circle.

A bit of searching for how to do this with OpenGL turned up this page
(http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
using the stencil buffer. Does the technique outlined in the article
look like a reasonable OSG-friendly approach? Any advice or pointers to
other examples? Grepping the example code turns up a bunch of stencil
code, but I'm still a little lost (OpenGL newbie).

Thanks,
Cory

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Cory Riddell
Paul, thanks for the opinion. I think I'm getting close to the limits of
what I can do with OSG without knowing a thing about OpenGL (and I'm
pretty stoked about how much I was able to accomplish without really
knowing what I'm doing).

Time to buckle down and learn some (modern) OpenGL. I'm going to start
with Joe Groff's tutorial
(http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html)
and build from there.

Thanks,
Cory

On 7/20/2011 12:00 PM, Paul Martz wrote:
 Using stencil for capping is an old trick and works well. I don't know
 of any example code for it, and it's been years, more than a decade,
 since I've done it myself. Your only other option would be some type
 of CSG approach, which would be computationally expensive, especially
 if the clip plane is dynamic.
-Paul


 On 7/20/2011 9:48 AM, Cory Riddell wrote:
 I've been thinking about using a ClipNode to cut my model in two to
 expose the inside details like a cutaway drawing. Just sticking a
 ClipNode at the root of my model graph does remove half of it, but the
 model ends up looking hollow rather than solid. I want to cap the open
 side. For example, if a sphere is cut in two, I would cap the open side
 with a circle.

 A bit of searching for how to do this with OpenGL turned up this page
 (http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
 using the stencil buffer. Does the technique outlined in the article
 look like a reasonable OSG-friendly approach? Any advice or pointers to
 other examples? Grepping the example code turns up a bunch of stencil
 code, but I'm still a little lost (OpenGL newbie).

 Thanks,
 Cory
 ___
 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] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Robert Osfield
Hi Cory,

Have a look at the osgreflect example to see how you can set up
stencil buffer usage in the OSG.

Robert.

On Wed, Jul 20, 2011 at 7:27 PM, Cory Riddell c...@codeware.com wrote:
 Paul, thanks for the opinion. I think I'm getting close to the limits of
 what I can do with OSG without knowing a thing about OpenGL (and I'm
 pretty stoked about how much I was able to accomplish without really
 knowing what I'm doing).

 Time to buckle down and learn some (modern) OpenGL. I'm going to start
 with Joe Groff's tutorial
 (http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html)
 and build from there.

 Thanks,
 Cory

 On 7/20/2011 12:00 PM, Paul Martz wrote:
 Using stencil for capping is an old trick and works well. I don't know
 of any example code for it, and it's been years, more than a decade,
 since I've done it myself. Your only other option would be some type
 of CSG approach, which would be computationally expensive, especially
 if the clip plane is dynamic.
    -Paul


 On 7/20/2011 9:48 AM, Cory Riddell wrote:
 I've been thinking about using a ClipNode to cut my model in two to
 expose the inside details like a cutaway drawing. Just sticking a
 ClipNode at the root of my model graph does remove half of it, but the
 model ends up looking hollow rather than solid. I want to cap the open
 side. For example, if a sphere is cut in two, I would cap the open side
 with a circle.

 A bit of searching for how to do this with OpenGL turned up this page
 (http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
 using the stencil buffer. Does the technique outlined in the article
 look like a reasonable OSG-friendly approach? Any advice or pointers to
 other examples? Grepping the example code turns up a bunch of stencil
 code, but I'm still a little lost (OpenGL newbie).

 Thanks,
 Cory
 ___
 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

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Cory Riddell
Hi Robert,

The osgreflect example is the one I was using as a guide along with the 
article I linked to in my first post. I didn't get it working, but I
have an inkling of how it should work. I really need to step back though
and learn some fundamentals first.

Cory

On 7/20/2011 3:14 PM, Robert Osfield wrote:
 Hi Cory,

 Have a look at the osgreflect example to see how you can set up
 stencil buffer usage in the OSG.

 Robert.

 On Wed, Jul 20, 2011 at 7:27 PM, Cory Riddell c...@codeware.com wrote:
 Paul, thanks for the opinion. I think I'm getting close to the limits of
 what I can do with OSG without knowing a thing about OpenGL (and I'm
 pretty stoked about how much I was able to accomplish without really
 knowing what I'm doing).

 Time to buckle down and learn some (modern) OpenGL. I'm going to start
 with Joe Groff's tutorial
 (http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html)
 and build from there.

 Thanks,
 Cory

 On 7/20/2011 12:00 PM, Paul Martz wrote:
 Using stencil for capping is an old trick and works well. I don't know
 of any example code for it, and it's been years, more than a decade,
 since I've done it myself. Your only other option would be some type
 of CSG approach, which would be computationally expensive, especially
 if the clip plane is dynamic.
-Paul


 On 7/20/2011 9:48 AM, Cory Riddell wrote:
 I've been thinking about using a ClipNode to cut my model in two to
 expose the inside details like a cutaway drawing. Just sticking a
 ClipNode at the root of my model graph does remove half of it, but the
 model ends up looking hollow rather than solid. I want to cap the open
 side. For example, if a sphere is cut in two, I would cap the open side
 with a circle.

 A bit of searching for how to do this with OpenGL turned up this page
 (http://glbook.gamedev.net/moglgp/advclip.asp) that caps the open side
 using the stencil buffer. Does the technique outlined in the article
 look like a reasonable OSG-friendly approach? Any advice or pointers to
 other examples? Grepping the example code turns up a bunch of stencil
 code, but I'm still a little lost (OpenGL newbie).

 Thanks,
 Cory
 ___
 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

 ___
 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] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Paul Martz

On 7/20/2011 12:27 PM, Cory Riddell wrote:

Paul, thanks for the opinion. I think I'm getting close to the limits of
what I can do with OSG without knowing a thing about OpenGL (and I'm
pretty stoked about how much I was able to accomplish without really
knowing what I'm doing).

Time to buckle down and learn some (modern) OpenGL. I'm going to start
with Joe Groff's tutorial
(http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html)
and build from there.


:-) There are a lot of people that try to write OSG code without knowing what's 
going on under the hood. I strongly recommend the OpenGL red book:


http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321552628/ref=sr_1_1?s=booksie=UTF8qid=1311193922sr=1-1

Enjoy,
   -Paul

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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Cory Riddell
On 7/20/2011 3:34 PM, Paul Martz wrote:
 :-) There are a lot of people that try to write OSG code without
 knowing what's going on under the hood. I strongly recommend the
 OpenGL red book:

 http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321552628/ref=sr_1_1?s=booksie=UTF8qid=1311193922sr=1-1



I think that speaks a great deal about what the quality of the OSG
abstraction. With only the vaguest of notions of how this stuff is
working, I've been able to put together some really neat stuff.

I'm curious, why didn't you suggest your own book? Because it isn't for
version 3+? Do you recommend the red book over the superbible? One of
the superbible reviews on Amazon says that they teach their toolkit
rather than the underlying API and that worries me a bit. The red book
reviews are even worse!

Cory


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


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Chris 'Xenon' Hanson
On 7/20/2011 2:42 PM, Cory Riddell wrote:
 I'm curious, why didn't you suggest your own book?

  Modesty?

  I'll recommend Paul's book for LEARNING.

  The Red Book is fine, for reference. But having a Toyota Service manual 
doesn't help you
understand how to drive a Camry.

 Because it isn't for
 version 3+?

  So little OGL3 is being done right now that I don't feel this is a limitation.

 Do you recommend the red book over the superbible? One of
 the superbible reviews on Amazon says that they teach their toolkit
 rather than the underlying API and that worries me a bit. The red book
 reviews are even worse!

  I was a technical editor on the latest SuperBible and I think it's a good 
book. It does
use some underlying library code to gloss over some fiddly bits and make it 
possible to
actually write understandable demo programs without having to invent fire and
blacksmithing on every page. They do explain WHAT the library does and how it 
does it, so
I think it's reasonable. I would not call it a toolkit. they teach using the 
OpenGL API,
but they use the library code to fill in the boring parts that they're NOT 
teaching. I'd
consider it slightly above the GLUT library -- stuff you have to do, but aren't 
interested
in seeing over and over once you know what it's doing under the hood.

  I think everyone should own the Red Book, period (and Orange book while 
you're at it).
But I think Distilled and SuperBible are much better for learning.

 Cory

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
There is no Truth. There is only Perception. To Perceive is to Exist. - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Paul Martz

On 7/20/2011 2:42 PM, Cory Riddell wrote:

I'm curious, why didn't you suggest your own book?


_OpenGL Distilled_ was intended for people that already knew 3D graphics 
concepts and just wanted an introduction to the OpenGL API. I assumed the reader 
already knew what a stencil buffer was, for example. I had to do this to keep 
the book small and (relatively) affordable, and there were already plenty of 
books on those subjects.


On the other hand, if you'd like a copy and you're in the US, email me offline 
and I'll send you a free one.


 Because it isn't for

version 3+?


Yeah, that too. _OpenGL Distilled_'s black cover was appropriate, as it was sort 
of a tombstone for the old fixed-function pipeline, probably the last OpenGL 
book to focus solely on non-shader based rendering.


 Do you recommend the red book over the superbible? One of

the superbible reviews on Amazon says that they teach their toolkit
rather than the underlying API and that worries me a bit. The red book
reviews are even worse!


Honestly I haven't looked at the current versions of either book, but (in my 
opinion, based on older versions of both books) the red book generally does a 
more complete job of covering basic 3D concepts (and algorithms such as stencil 
capping) than the SuperBible. (I mean no disrespect to the SuperBible; I think 
the red book is superior thanks to the ARB's input, and Addison Wesley's 
expertise in the 3D field.) But this is subjective and others will certainly 
disagree with me. If you can afford it, reading through both books will only 
reinforce your 3D dexterity.


--
  -Paul Martz  Skew Matrix Software
   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] using ClipNode to cut a model in two, then cap the open side

2011-07-20 Thread Paul Martz

On 7/20/2011 3:16 PM, Chris 'Xenon' Hanson wrote:

   I think everyone should own the Red Book, period (and Orange book while 
you're at it).
But I think Distilled and SuperBible are much better for learning.


Can I hire you as my PR man? :-)

--
  -Paul Martz  Skew Matrix Software
   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org