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 

osgTerrain : how to invalidate subgraphs/tiles to enforce a reload?


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


Joined: 23 May 2009
Posts: 621

PostPosted: Mon Jun 13, 2011 10:27 am    Post subject:
osgTerrain : how to invalidate subgraphs/tiles to enforce a reload?
Reply with quote

Hi,

I need an approach to modify osgTerrain at runtime. Therefore I implemented a pseudo loader, which acts transparent to the rest of the system and modifies the loaded height values. (to flatten the terrain around a selected airport)

This approach works well, but it works not on run time, but on load time.
The frequency of modifiying terrain is not very high, only every nn minutes. The software has to provide stable framerate, so the reloading process should be performed in the background.

What would be the best approach to allow modifications during run time?

My current approach:
Force/query the DB Pager to reload the affected tiles/subgraphs and apply the new modification algorithm while loading (again, via the pseudo loader). Everytime a modified tile is loaded, the alogrithm should replace in the rendered scenegraph the old tile with the new one.

Has anyone a better approach?
How can I make the DB Pager to reload selected tiles of a osgTerrain?


Thank you!

Cheers,
Torben
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Mon Jun 13, 2011 2:38 pm    Post subject:
osgTerrain : how to invalidate subgraphs/tiles to force them to be reloaded?
Reply with quote

On 6/13/2011 4:27 AM, Torben Dannhauer wrote:
Quote:
My current approach:
Force/query the DB Pager to reload the affected tiles/subgraphs and apply the new modification algorithm while loading (again, via the pseudo loader). Everytime a modified tile is loaded, the alogrithm should replace in the rendered scenegraph the old tile with the new one.
Has anyone a better approach?
How can I make the DB Pager to reload selected tiles of a osgTerrain?

I seem to think I've done this somehow in the past, but I can't recall if it required
modifications to osgDB that were never accepted into OSG.

I can look later.

Are you saying you already implemented this technique?

I also think I wrote a generic visitor as part of the project, that could do it
post-load, but as you know, this requires rebuilding certain cached data, and isn't done
in the background loader thread.

--
Chris 'Xenon' Hanson, omo sanza lettere. 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


------------------
Post generated by Mail2Forum
Back to top
zonk
Appreciator


Joined: 23 May 2009
Posts: 621

PostPosted: Mon Jun 13, 2011 5:21 pm    Post subject:
Reply with quote

Hi Chris

Yes I implemented already a working prototype, but managing (especially reverting modifications) is not yet finished. The following lines describe what I have implemented so far.

I have a pseudo laoder, which loads file with the suffix ".terrainmod":
1. It strips the filename
2. Loads that file with the standard osgDB::ReadNode() function
3. Applys a visitor which applies the modifications on the loaded data
4. Finally returns the loaded and eventually modified data to the caller of the pseudo loader


The modification visitor iterates through the loaded node/scenegraph and performs two types of modifications:
1. If the node is a pagedLOG: Modify the entry and add to all paged filenames the ".terrainmod" suffix to ensure that they are also loaded via the pseudo loader.
2. If the node is a terrain tile: extract its extents and check if it is inside a modification ROI (region of interest). If it is, extract and modify the heightfield and/or apply a userdefined TerrainTechnique

To manage the modification areas and everything related, I have implemented a singleton class called ModificationManager. It provides the modification ROIs the visitor has to know to perform the correct modifications (the modification visitor queries it to check for each tile if it is inside a ROI managed by the ModificationManager).

So far my current status.

But there are still some unsolved issues:
Of course I could apply the modification during runtime by applying the modification visitor again. But I have to solve some problems:
1. How to avoid crashing due to multithreading? I'm sure there is a simple solution to allow that modification even multithreaded, but I don't know.
2. How to disable modifications: Because the height field values are modified, I do not have the original values available, so restoring is difficult. Your suggestion?

To allow multiple and different modification algorithms, I have a base class which defines the interface a technique has to provide. Subclassing that abstract class allows to create techniques.
Currently I have two working techniques: one sets the height value at a designated height without a transition, and the other technique sets the height to a designated height but uses a transition around the modified area to allow smooth blending into modified terrain height.

All that different modification techniques should be managed by the modification manager. It should be possible to register new techniques via shared library so the system is extendable without recompiling the whole software.

each modification ROI has a priority, so nesting terrain techniques for the same ROI is possible.


I hope you got a brief idea, I'm currently collecting ideas to solve the last issues before I will move it from osgvisual's experimental SVN to the trunk svn.

Cheers,
Torben
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Mon Jun 13, 2011 5:32 pm    Post subject:
osgTerrain : how to invalidate subgraphs/tiles to enforce a reload?
Reply with quote

On 6/13/2011 11:21 AM, Torben Dannhauer wrote:
Quote:
1. If the node is a pagedLOG: Modify the entry and add to all paged filenames the ".terrainmod" suffix to ensure that they are also loaded via the pseudo loader.

I did this too. It turns out not to be needed. If you pre-load your psuedoloader, you
will find that loaders get called for ALL file loads, not just ones matching their
filename suffix. And pre-loaded loaders get called first. So, you will get called for all
loads and at load time you can decide if you want to terrainmod them or not. This is
probably safer than modifying the loaded graph.

Quote:
1. How to avoid crashing due to multithreading? I'm sure there is a simple solution to allow that modification even multithreaed, but I don't know it.

Well, when are you applying modifications? Update()? I believe it is safe to perform
these changes only during update().

Quote:
2. How to disable modifications: Because the height field values are modified, I do not have the original values available, so restoring is difficult. Your suggestion?

You could probably find a way to keep the original data around after modification,
perhaps using the new metadata system. of course, this will increase resource consumption,
but that's the cost of being able to undo.

Quote:
Cheers,
Torben

--
Chris 'Xenon' Hanson, omo sanza lettere. 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


------------------
Post generated by Mail2Forum
Back to top
zonk
Appreciator


Joined: 23 May 2009
Posts: 621

PostPosted: Wed Jun 15, 2011 6:33 pm    Post subject:
Reply with quote

Hi Chris, thanks for your input.

1.
Thanks for your preload idea, but I had a unpleasant dicussion with robert (http://forum.openscenegraph.org/viewtopic.php?t=8538), because the term "preloading" is often named, but there is no information what this is in detail.

Can you help me and give a short overview how to preload a plugin? Additionally, do I have to "open" my loader to all file extensions? I tried it but that does not work, all subtiles are loaded then with the native .ive loader and not with my modification loader.

In the Constructor of the loader I have these calls to allow all file endings:
Code:

supportsExtension( "terrainmod", "Terrain modification pseudo loader");
supportsExtension( "*", "Terrain modification pseudo loader");


but then the plugin is not longer used, even the old behavior with he pseudoloader extension ( calling "osgviewer terrain.ive.terrainmod" ) does not work any longer.

2.
Yes, keeping the original data with meta data system looks feasible.

3.
To sum up what I havbe understood: Applying a visitor while data is displayed is only allowed during the update phase. Do I have to mark data as dynamic? The work of the visistor will stall the rendering process till its finished, right?

Because stalling the rendering process should be avoided, wouldn't it be better to reload the affected tiles by the database pager, and then replace the tiles if they are loaded? This also unifies the modification process because only modification-by-loading is done.

I thought the cleanest solution would be that all affected tiles are marked as dirty, so the database pager wuold reload the tiles.

My question is: Is there a mechanism in the databasepager to mark tiles as "dirty/to-reload ?

Sorry for all that questions, but I'm still in a phase where reading sourcecode does not clarify things, and I'm struggling wiht OSG's documentation....


Thank you!

Cheers,
Torben
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Thu Jun 16, 2011 4:14 pm    Post subject:
osgTerrain : how to invalidate subgraphs/tiles to enforce a reload?
Reply with quote

On 6/15/2011 12:33 PM, Torben Dannhauer wrote:
Quote:
Can you help me and give a short overview how to preload a plugin?

I see Robert already answered this.

Quote:
Additionally, do I have to "open" my loader to all file extensions? I tried it but that does not work, all subtiles are loaded then with the native .ive loader and not with my modification loader.

If you preload your plugin, it should get offered the ive files first.

Quote:
In the Constructor of the loader I have these calls to allow all file endings:
Code:
supportsExtension( "terrainmod", "Terrain modification pseudo loader");
supportsExtension( "*", "Terrain modification pseudo loader");

Should be fine.

Quote:
but then the plugin is not longer used, even the old behavior with he pseudoloader extension ( calling "osgviewer terrain.ive.terrainmod" ) does not work any longer.

Have you traced in to see why? This should work.

Quote:
3.
To sum up what I havbe understood: Applying a visitor while data is displayed is only allowed during the update phase. Do I have to mark data as dynamic? The work of the visistor will stall the rendering process till its finished, right?

Correct. I don't know if you need to make the data as dynamic or if simply dirty()ing it
afterward is sufficient. I suspect it should be flagged as DYNAMIC.

Quote:
Because stalling the rendering process should be avoided, wouldn't it be better to reload the affected tiles by the database pager, and then replace the tiles if they are loaded? This also unifies the modification process because only modification-by-loading is done.

Yes, that's probably a good idea.

Quote:
I thought the cleanest solution would be that all affected tiles are marked as dirty, so the database pager wuold reload the tiles.
My question is: Is there a mechanism in the databasepager to mark tiles as "dirty/to-reload ?

I think if you simply manually wipe out the child pointer in the PagedLOD (Group) on the
next cull traversal the PagedLOD will notice it is missing and queue it for reloading. In
the mean time, the next lower LOD will be displayed.

I think I had come up with a way to request the PagedLOD schedule a node for reload even
while it was already loaded. This may have been code that was not accepted into OSG.

--
Chris 'Xenon' Hanson, omo sanza lettere. 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


------------------
Post generated by Mail2Forum
Back to top
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 osgTerrain::TerrainTile not in parent... Trajce Nikolov NICK General 2 Tue Dec 06, 2016 5:38 am View latest post
No new posts PagedLOD range for 2D image tiles Bruno Oliveira General 6 Tue Sep 13, 2016 10:31 pm View latest post
No new posts About Register all tiles when reading... robertosfield Submission 0 Thu Sep 08, 2016 8:54 am View latest post
No new posts About Register all tiles when reading... zhouss General 0 Thu Sep 08, 2016 8:07 am View latest post
No new posts osgTerrain and CLAMP_TO_EDGE in Image... cbuchner1 General 1 Tue Sep 08, 2015 11:54 am 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