Re: [osg-users] Fast move a lot of nodes to another group

2017-04-18 Thread Sebastian Messerschmidt



Am 4/15/2017 um 6:24 PM schrieb Yura Ivanov:

Hi,

I created stateset with bool uniform to indicate that node is selected and mat 
uniform with current mouse transform. To select nodes, I set this uniforms to 
nodes and all transformation preforms in shader. On mouse release, all 
transform applies to nodes by calling setMatrix and mat uniform sets to 
identity. Everything works fast and after all I don’t have extra nodes and 
statesets. Maybe my approach in this task is wrong, but many editors, for 
example 3dsMax, can work with big number of objects. And bad structure of scene 
in this case is user problem.
Thank you very much, especially for optimize.


This will disable "native" picking of the nodes however. Also I wonder 
why this should be more efficient than putting every node under a 
transform in the first place.
What you're doing is effectively a poor implementation of instancing. A 
better approach (if you want to use the uniform approach) is to setup a 
uniform buffer object (see [0]) containing the matrices and to use the 
draw-instanced version of your geometry to fetch it based on its 
gl_InstanceId. A version that scales better is to use a texture object 
to hold the matrices (see [1])



[0]
http://3dcgtutorials.blogspot.de/2013/09/instancing-with-openscenegraph-part-ii.html

[1]
http://3dcgtutorials.blogspot.de/2013/08/instancing-with-openscenegraph.html

Cheers
Sebastian



Cheers,
Yura

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





___
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] Fast move a lot of nodes to another group

2017-04-15 Thread Yura Ivanov
Hi,

I created stateset with bool uniform to indicate that node is selected and mat 
uniform with current mouse transform. To select nodes, I set this uniforms to 
nodes and all transformation preforms in shader. On mouse release, all 
transform applies to nodes by calling setMatrix and mat uniform sets to 
identity. Everything works fast and after all I don’t have extra nodes and 
statesets. Maybe my approach in this task is wrong, but many editors, for 
example 3dsMax, can work with big number of objects. And bad structure of scene 
in this case is user problem. 
Thank you very much, especially for optimize.

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-10 Thread Sebastian Messerschmidt

Hi Yura,

Hi,

Quads are unique and images are different.
Sorry but I cant make screenshot of real images because of author. It is just 
like big puzzle. This is editor, and user decides how many objects can be.
I am using PagedLods to draw images and have no problem with memory. I have 
problem with moving a lot of nodes by user input. If I put put them into matrix 
i can move only it. This is fast but i need to move nodes to another group. 
Maybe I can use NodeCallback?


I think you need to think outside of the box here. There is more than 
one way to draw a collection of quads. You could render them as a big 
vertex array or even instanced and modify the sub-region of your vertex 
buffer/instance matrices instead of moving individual nodes around. If 
you need individual texturing, that still could be done via texture 
arrays or atlas-texturing.


If you absolutely want to keep them in your tree-structure you can still 
keep duplicates and simply turn them off by setting an appropriate 
node-mask (copy them to the new transform and disable drawing in the 
original group),
As a second step you could periodically sort the child vectors by the 
nodemask and batch-remove non-drawn childs from it (this is faster, 
since sorting doesn't need to resize the vector and removing a 
contiguous number of elements from the end of a vector is essentially free).


You could also apply the sort-prune algorithm in a custom osg::Group 
which will mark elements to be deleted instead of directly removing 
them. In the update phase it then could efficiently batch-sort and remove.


Anyways, this all theory as it still unclear what you want to achieve 
with your puzzle. We need more details or a small example to look at. If 
you cannot present the work, try to create a minimal example to 
demonstrate the problem (as a compilable example, so lazy people like me 
will take an actual look at it)


Cheers
Sebastian






Thank you!

Cheers,
Yura

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





___
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] Fast move a lot of nodes to another group

2017-04-10 Thread Yura Ivanov
Hi,

Quads are unique and images are different.
Sorry but I cant make screenshot of real images because of author. It is just 
like big puzzle. This is editor, and user decides how many objects can be.
I am using PagedLods to draw images and have no problem with memory. I have 
problem with moving a lot of nodes by user input. If I put put them into matrix 
i can move only it. This is fast but i need to move nodes to another group. 
Maybe I can use NodeCallback?


Thank you!

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Robert Osfield
On 7 April 2017 at 12:22, Yura Ivanov  wrote:
> I am agree with you, that maybe I have bad structure. My program is just 
> editor, where i must be able to see all 300k tiles of image at once, select, 
> move and distort them.

Are the tiles just quads?  Are the images all the same, or different
for each tile?  Screenshot would be useful.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Yura Ivanov
I am agree with you, that maybe I have bad structure. My program is just 
editor, where i must be able to see all 300k tiles of image at once, select, 
move and distort them. My current question was about optimizer. I will put it 
in another topic, if i will not success.
Thank you very much for your advices, they very helpful for me.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Robert Osfield
On 7 April 2017 at 10:09, Yura Ivanov  wrote:
> I just want to add new childs in a group and want group to be optimized. So 
> if many elements changed, I need to remove  all groups that created by 
> optimizer, before call optimize again?

I can't work out what you mean.

The only thing I know is that you are almost certainly going the wrong
direction by trying to add and remove large numbers of objects from
the scene graph.  It's a broken approach.  I have suggested that you
provide the details so we can help you take a better approach.

It seems pretty pointless me trying to help you if you aren't open to
taking a step back and fixing the problem.

Others can pitch in, but for now I'm taking a step back.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Yura Ivanov
Hi,

I just want to add new childs in a group and want group to be optimized. So if 
many elements changed, I need to remove  all groups that created by optimizer, 
before call optimize again?

Thank you!

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Robert Osfield
HI Yura,

On 7 April 2017 at 09:09, Yura Ivanov  wrote:
> How can I add children into already optimized group.

An optimized group is no different to an non optimized group you can
add or remove children as you like.  If the structure changes too much
then it may no longer be efficient.

> I need to remove all groups created by optimizer, add child and then call 
> optimize again?

Why do you need to remove all the groups?

--

As a general note, I'll call back to my original suggestions, the way
you are tackling the tasks sounds inefficient, running tools like the
Optimizer can help hide this but in the end you're still using the
wrong tool for the job.  You've never gone into the details of the
subgraphs to be able to give specific advice.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-07 Thread Yura Ivanov
Hi,

How can I add children into already optimized group. I need to remove all 
groups created by optimizer, add child and then call optimize again? 

Thank you!

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-06 Thread Robert Osfield
Hi Yura,

On 6 April 2017 at 06:16, Yura Ivanov  wrote:
> When I put my nodes into subgroups, removeChild becoming fast and cull is 
> faster. Thank you.
> Is there any functions to make tree like structure of my group, or i must do 
> it by hand?

For optimal performance a balanced quad tree is typically best for
scene graph applications, while groups containing a large number of
children breaks this efficiency forcing the traversals to visit all
children all the time.

The osgUtil::Optimizer::SpatializeGroupsVisitor can be used to
reorganize large flat groups of children into a quad tree.  You can
call this visitor on it's own or as part of the wider
Optimizer::optimizer(Node*,int options) operation if you include the
osgUtil::OptimizeSPATIALIZE_GROUPS bit mask to the options parameter.
The class can be found in include/osgUtil/Optimizer.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-05 Thread Yura Ivanov
When I put my nodes into subgroups, removeChild becoming fast and cull is 
faster. Thank you. 
Is there any functions to make tree like structure of my group, or i must do it 
by hand?

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
I will try to give more information tomorrow. Thank you for your advices.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Robert Osfield
Hi Yura,

On 4 April 2017 at 16:03, Yura Ivanov  wrote:
> I tried to subclass osg::group to implement my own removeChildren, but i cant 
> call some osg::node functions because my class was not friend of osg::node. 
> Implementing move of node is more difficult.
> Noded unique because User can move vertex of each node.
> Maybe I should made one node and work with geometry but 300k is maximum and 
> performance is fine.

If it was completely fine you wouldn't have started this thread :-)

You haven't provided enough information to suggest specific approach
but from what you have written so far I don't think your current
approach is the best way to tackle the problem, and would recommend
changing the approach rather than trying to workaround the performance
issues you've seen.

Once you've provided a clear enough picture of what you are trying to
achieve it should be straight forward to recommend a good way forward.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
I tried to subclass osg::group to implement my own removeChildren, but i cant 
call some osg::node functions because my class was not friend of osg::node. 
Implementing move of node is more difficult.
Noded unique because User can move vertex of each node.
Maybe I should made one node and work with geometry but 300k is maximum and 
performance is fine. 
I cant make screenshot now because I am not near computer. The goal of program 
is build one image from it parts.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Robert Osfield
Hi Yura,

On 4 April 2017 at 14:53, Yura Ivanov  wrote:
> Nodes are unique quads with editable geometry. I had no problem with 
> performance exept removeChild when i tried to move them into transform matrix.
>  I would be nice if osg will have function to move node to another group 
> whithout internal std remove and erease.
> P.S. Sorry if my english is bad.

The OSG isn't design for large scale changes in the scene graph
structure at runtime, what you are attempting to do is pretty non
standard in terms of usage.  If you really really want to do something
that the OSG core doesn't specifically optimize then you can always
subclass from osg::Group and do what you want.

However, the basic scene graph structure sounds horribly inefficient,
which is why I'm flagging up that you are likely to tackling the
problem in the wrong way.   My guess is tackling the problem in a
different way will provide *massively* better performance all round.
When I say massive I'm tackling 100's of times improvement of
performance may well be achievable.  Having hundreds of thousands of
OSG nodes to draw simple geometry is always going to bad way to do
things.

When you say the geometry is editable, what exactly do you mean?
Again a screenshot would be useful.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Sebastian Messerschmidt



Am 4/4/2017 um 3:53 PM schrieb Yura Ivanov:

Nodes are unique quads with editable geometry. I had no problem with 
performance exept removeChild when i tried to move them into transform matrix.
If you're actually holding all the childs in a single group, the remove 
will become horribly expensive (due to removal somewhere in the vector). 
Try to restructure your group to have a tree-like substructure 
(basically a quad-tree) to have smaller sets to work with.



 I would be nice if osg will have function to move node to another group 
whithout internal std remove and erease.
P.S. Sorry if my english is bad.


Cheers
Sebastian


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





___
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] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
Nodes are unique quads with editable geometry. I had no problem with 
performance exept removeChild when i tried to move them into transform matrix.
 I would be nice if osg will have function to move node to another group 
whithout internal std remove and erease. 
P.S. Sorry if my english is bad.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Robert Osfield
On 4 April 2017 at 13:52, Yura Ivanov  wrote:
> I have 300k nodes, and i must have ability to see them all at once and select 
> any part of them to drag by mouse. I looks like big puzzle.

What are the subgraphs composed of?  Repeating geometries?  Unique
geometries?  What about state?  Do they share textures etc?

A screenshot would help get an idea.

The reason why I'm asking all these questions is that knowing what you
are trying to achieve will narrow down what type of techniques are
best to address the problems you are trying to tackle.

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
I have 300k nodes, and i must have ability to see them all at once and select 
any part of them to drag by mouse. I looks like big puzzle.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Robert Osfield
Hi Yura,

On 4 April 2017 at 13:05, Yura Ivanov  wrote:
> So i a have 300k nodes, I should add 300k switch into a group and 300k into 
> transform. I will try and see how fast it will be.

With this number of nodes one has to wonder if using nodes is the
appropriate approach at all, perhaps there is a better way to manage
your scene graph.  Could you take a step back and tell us what you are
trying to do with this part of your scene graph?  For instance what do
the subgraphs below group/transform represent?

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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
Hi,

So i a have 300k nodes, I should add 300k switch into a group and 300k into 
transform. I will try and see how fast it will be.
 
Thank you!

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Werner Modenbach

Ah OK,

so why not adding them as children into 2 switch nodes and just 
switching them an and off as needed.
It should not really be an overhead since the pointers are shared and 
disabled nodes are ignored.


- Werner -

Am 04.04.2017 um 12:33 schrieb Yura Ivanov:

I already have such transform to move all nodes in a group. But I need to move 
nodes selected by user.

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





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


--
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: i...@texion.eu
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
I already have such transform to move all nodes in a group. But I need to move 
nodes selected by user.

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Werner Modenbach

Hi Yura,

just make the transform node a permanent member of your scene and
let it be identity or your specific transform as needed.

- Werner -

Am 31.03.2017 um 10:05 schrieb Yura Ivanov:

Hi,
I need to move a lot of nodes from Group to MatrixTransform to translate them 
into new position by user input, and then move them back into Group with new 
position. Call addChild and removeChild for each node is slow because of 
removeChild. Also I cant use removeChildren to remove all nodes at once because 
my node list is not continuous.



Thank you!

Cheers,
Yura

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





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


--
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: i...@texion.eu
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Yura Ivanov
Hi,

How can I move to "transform" next node of "group" without calling 
group->removeChild? I need only one "transform" after all.

Thank you!

Cheers,
Yura

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





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


Re: [osg-users] Fast move a lot of nodes to another group

2017-04-04 Thread Sebastian Messerschmidt



Hi Yura,

Hi,
I need to move a lot of nodes from Group to MatrixTransform to translate them 
into new position by user input, and then move them back into Group with new 
position. Call addChild and removeChild for each node is slow because of 
removeChild. Also I cant use removeChildren to remove all nodes at once because 
my node list is not continuous.
You could use the replaceChild like this: (assuming node is the Node to 
move and group its current parent)


transform = new MatrixTransform
transform->addChild(node);
group->replaceChild(node, transform);

This way the child list (implemented as a vector) is not changed in size 
for every operation.


Cheers
Sebastian



>



Thank you!

Cheers,
Yura

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





___
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