OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Different views hide/show different nodes shared scene graph


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Wed Apr 17, 2019 9:56 am    Post subject:
Different views hide/show different nodes shared scene graph
Reply with quote

Hi,

I have an old application using OpengGL and I am porting it to OSG.
I have one scene graph shared by multiple views. The problem is some views have some objects hidden.

My solution:

I have used osg::Drawable::CullCallback to hide some objects by implementing
virtual bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const;

It works great. Is this the canonical way to hide objects with a share scene graph in multiple views?

My next problem is picking objects. How do I pick objects in shared scene graph in multiple views when I use CullCallback to hide some objects(nodes) ? How can I make the picker behave like the rendering which used CullCallback ?

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
Voerman, L.
Guest





PostPosted: Wed Apr 17, 2019 11:04 am    Post subject:
Different views hide/show different nodes
Reply with quote

Hi Catalin,the normal way to do this is with nodemasks. That way the picking can use te mask for the view you want to pick for.
Laurens.


On Wed, Apr 17, 2019 at 11:55 AM Catalin Flower < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

I have an old application using OpengGL and I am porting it to OSG.
I have one scene graph shared by multiple views. The problem is some views have some objects hidden.

My solution:

I have used osg::Drawable::CullCallback to hide some objects by implementing
virtual bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const;

It works great. Is this the canonical way to hide objects with a share scene graph in multiple views?

My next problem is picking objects. How do I pick objects in shared scene graph in multiple views when I use CullCallback to hide some objects(nodes) ? How can I make the picker behave like the rendering which used CullCallback ?

Thank you!

Cheers,
Catalin

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Wed Apr 17, 2019 11:18 am    Post subject:
Reply with quote

Hi,

Does the node mask allow to continue with the the childrens if the current node is masked out? I need to continue the scene graph traversal even if that node is hidden.

The scene graph is shared between views, will masking affect this?

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
Voerman, L.
Guest





PostPosted: Wed Apr 17, 2019 1:40 pm    Post subject:
Different views hide/show different nodes shared scene graph
Reply with quote

Seems like you want the nodemask on the drawables, as the mask on a group node stops the traversal.Laurens.


On Wed, Apr 17, 2019 at 1:17 PM Catalin Flower < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

Does the node mask allow to continue with the the childrens if the current node is masked out? I need to continue the scene graph traversal even if that node is hidden.

Thank you!

Cheers,
Catalin

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Wed Apr 17, 2019 4:55 pm    Post subject:
Different views hide/show different nodes
Reply with quote

Ho Catalin,

Quote:
I have an old application using OpengGL and I am porting it to OSG.
I have one scene graph shared by multiple views. The problem is some views have some objects hidden.

You can use a combination of NodeMask's on the Nodes in your scene
graph, and TraversalMask associated with the Cameras on each View, you
can also set these TraversalMasks for any traversals you make into the
scene. As a visitor traverses the scene the subgraph is traversed if
the (Node.getNodeMask() & visitor.getTraversalMask()) value is non
null.

This approach allows you to share the same scene graph between
different views but still have parts that render differently in each
view. The osgstereimage example illustrates such an approach,
although in this instance for a left and right eye Camera traversal
rather than multiple views. The general approach is the same, you
just set the cull traverasal mask for the different View Camera's as
you want them.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Wed Apr 17, 2019 5:44 pm    Post subject:
Reply with quote

Hi Robert,

I was looking of a solution that depends on camera. Because only the view/camera knows which object is hidden. The TraversalMask will do the trick then. I see also a CullMask, guess this is not good and it will not help with the picking issue.

My understanding the mask is a 32 bit value, this means I can only have a maximum 32 types of nodes to be shown/hidden because an AND operation is performed?


Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Thu Apr 18, 2019 8:00 am    Post subject:
Different views hide/show different nodes shared scene graph
Reply with quote

Hi Catalin,

On Thu, 18 Apr 2019 at 00:42, Catalin Flower <> wrote:
Quote:
I was looking of a solution that depends on camera. Because only the view/camera knows which object is hidden. The TraversalMask will do the trick then. I see also a CullMask, guess this is not good and it will not help with the picking issue.

The View::computeIntersections(..) method allows you to pass in the
TraversalMask to use, it's 0xffffffff by default.

Quote:
My understanding the mask is a 32 bit value, this means I can only have a maximum 32 types of nodes to be shown/hidden because an AND operation is performed?

Yes. Typically one would have broad catagories of nodes that you want
to interact with in different ways. If you need more than 32
categories then you'll need to use custom callback or node inserted in
the scene graph in combination to state attached to the visitor to
decide whether a subgraph should be traversed or not.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Thu Apr 18, 2019 9:07 am    Post subject:
Reply with quote

Hi Robert,

The only way that I found to add TraversalMask to the camera is by this:

viewer.getUpdateVisitor()->setTraversalMask(0x00000001)

This means some nodes will be skipped during update traversal.

But in this book that I read it says there are 4 traversals:

1 event traversal
2 update traversal
3 cull traversal
4 draw traversal

My question is: What happens during cull and draw traversal, is the traversal mask used there also? Are some nodes skipped in update traversal but not skipped in the next two traversals?

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Thu Apr 18, 2019 10:09 am    Post subject:
Reply with quote

Hi Robert,

To hide the objects in views I found this solution:

getViewer()->getUpdateVisitor()->setTraversalMask(0b101); // skip update for hidden objects
getViewer()->getCamera()->setCullMask(0b101); // cull objects that are hidden

This is the solutions that I found for the views. Is this the way to do it?

Regarding your solution for the other issue, picking objects, it works by passing the traversal mask to that bool computeIntersections (float x.... osg::Node::NodeMask traversalMask) like you have said.

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Thu Apr 18, 2019 10:27 am    Post subject:
Different views hide/show different nodes shared scene graph
Reply with quote

Hi Catalin

On Thu, 18 Apr 2019 at 10:12, Catalin Flower <> wrote:
Quote:
My question is: What happens during cull and draw traversal, is the traversal mask used there also? Are some nodes skipped in update traversal but not skipped in the next two traversals?

The draw traversal doesn't touch the scene graph nodes so
NodeMasks/TraversalMask have no baring on it.

The OSG's cull traversal builds the internal rendering graphs each
frame and the draw traversal simply traversals these rendering graphs.
So to control the draw traversal you use the masks in the cull
traversal.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Thu Apr 18, 2019 10:28 am    Post subject:
Different views hide/show different nodes shared scene graph
Reply with quote

Hi Catalin,

On Thu, 18 Apr 2019 at 11:07, Catalin Flower <> wrote:
Quote:
To hide the objects in views I found this solution:

getViewer()->getUpdateVisitor()->setTraversalMask(0b101); // skip update for hidden objects
getViewer()->getCamera()->setCullMask(0b101); // cull objects that are hidden

This is the solutions that I found for the views. Is this the way to do it?

For multiple views the way to do it with the OSG is to use the
osgViewer::CompositeViewer class, and then each osgViewer::View you
set up the approrpiate Camera's CullMask.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Thu Apr 18, 2019 2:15 pm    Post subject:
Reply with quote

Hi Robert,

The object is made up of different sub-types which I can hide/show using the masks. Is works fine with the NodeMask for sub-types and CullMask on the camera.

However I need an extra layer to show/hide the entire object. Remember I have a shared graph with multiple views. I have many objects: Obj1, Obj2, ...

During the rendering I need to show/hide Obj1, Obj2 etc.

This is my problem now and that can be fixed during rendering if I have access to RenderInfo somehow during cull traversal.

I know there is bool osg::Drawable::Cullback::cull (osg::NodeVisitor *nv, osg::Drawable *drawable, osg::RenderInfo *renderInfo) but this is called only for osg::Drawable nodes, I need one to be called for every node in the scene graph.

Also I see there is osg::Node::setCullCallback() by using NodeCallback but it doesn't have access to RenderInfo or Camera and it doesn't return a bool value.

I need a callback with bool as return during cull traversal and to have access to RenderInfo or the camera.

Hope this makes sense to you.


Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
AnyOldName3 (Chris Djali)
User


Joined: 08 Sep 2017
Posts: 24

PostPosted: Thu Apr 18, 2019 3:35 pm    Post subject:
Reply with quote

Hi,

You should be able to dynamic_cast or asCullVisitor the arguments to a regular node callback to get a cull visitor pointer, and then from that, you can access the camera. You don't need to have a version with a boolean return value, either. Just don't traverse the node's children from the cull callback when you want the node to be skipped.

Cheers,
Chris
Back to top
View user's profile Send private message
icf80
Newbie


Joined: 12 Apr 2019
Posts: 18

PostPosted: Fri Apr 19, 2019 1:03 pm    Post subject:
Reply with quote

Hi Chris,

It has worked, thank you very much.

1) setCullCallback(NodeCallback) on the nodes

2) Implementing void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osgUtil::CullVisitor* cullvisitor = dynamic_cast < osgUtil::CullVisitor* >(nv);
osg::Camera* pCamera = cullvisitor->getCurrentCamera();

...

if (...) traverse(node, nv);
}

I could not find nv->asCullVisitor(). I am using OSG 3.4.

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Dragging individual model nodes arfaa General [forum] 9 Tue Apr 23, 2019 1:10 pm View latest post
No new posts How to hide mouse cursor? Ligvest General 1 Thu Mar 28, 2019 1:40 pm View latest post
No new posts Removing objects with shared GL state... AnyOldName3 General 10 Wed Mar 20, 2019 5:05 pm View latest post
No new posts Deep cloning an active root scene node Robert Lockyer General 7 Thu Feb 28, 2019 5:52 pm View latest post
No new posts show mouse cursor in embedded osg Meldryt General 1 Thu Feb 28, 2019 5:13 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP