Hi Robert

"Lower levels of detail aren't unreferenced but kept around in any paged
database, this includes a osgTerrain::TerrainTile based paged database."

I was expecting this.

With regards to active tiles, my problem is that going this approach I
cant figure out how to extract the state information from the
scenegraph. From what I understand the TerrainTiles that I process
during my read file callback will not provide any information on when
they are invalidated by the loading of higher resolution tiles, right?

I understand that the physics part is specific to my application, but
an interface or "pattern" for syncronising the active scenegraph
generated when running an osgTerrain::TerrainTile based paged database
with a given application is usefull in other places.

As I said so far we have been using a cullvisitor that runs through
the entire scenegraph looking for "terrain" nodes. It then checks if
these nodes are already in our set of nodes. If its not a new physics
object is generated by pulling the geometry using a trianglevisitor.
This method is both slow, repeats bookkeping already performed in the
Terrain/Scene graph machinery and uses way more memmory than is
neccecery. Basically I end up generating 3 unique vertices and 3
indecies for each triangle rendered. This will consime roughly 28
times the amount of memmory that would be needed if I could use the
heightfield data directly.

Brgs. Ralf

2009/4/6 Robert Osfield <robert.osfi...@gmail.com>:
> Hi Ralf,
>
> Lower levels of detail aren't unreferenced but kept around in any paged
> database, this includes a osgTerrain::TerrainTile based paged database.
>
> As how to manage the mapping of which physics tiles should be active... well
> I don't know what to recommend, there a lots of different ways you could
> probably tackle it.  My job is the scene graph, I'll leave application dev
> issues to members of the community.
>
> Robert.
>
> On Mon, Apr 6, 2009 at 3:12 PM, Ralf Stokholm <alfma...@arenalogic.com>
> wrote:
>>
>> Hi Robert
>>
>> I have gotten a bit further with this, and there are some indications
>> it might be a viable solution.
>>
>> But I have run into a problem, it seams that Im not removing patches
>> from my physics engine when higher resolutions patches replaces them.
>>
>> Can You confirm that If a given osgTerrain::TerrainTile is replaced by
>> its four higher resolution children the acociated heightfields are not
>> deleted, and as a result the observer callback is not called?
>>
>> And if this is the case do you have any good ideas on how to figure
>> out when to disable these patches in the physics engine, so that I
>> dont have multiple patches loaded for the same area?
>>
>> Brgs.
>>
>> Ralf Stokholm
>>
>> 2009/4/3 Robert Osfield <robert.osfi...@gmail.com>:
>> > Hi Ralf,
>> >
>> > Use the osg::Observer mechanism for watching when objects get deleted.
>> > Just
>> > register your observer with the TerrainTile/HeightField you've set up
>> > your
>> > physics for then you'll be able to get your observer called when it goes
>> > out
>> > of scope.   osg::observert_ptr<> uses osg::Observer, as does osg::State
>> > so
>> > have a look at these for usage of Observer.
>> >
>> > Robert.
>> >
>> > On Fri, Apr 3, 2009 at 11:44 AM, Ralf Stokholm <alfma...@arenalogic.com>
>> > wrote:
>> >>
>> >> Hi Robert
>> >>
>> >> Its not that I need to keep the memmory around.
>> >>
>> >> I need to know when a terrain tile is unloaded from the scene and use
>> >> that event to unload the physics heightfield as well.
>> >>
>> >> Im guessing the life of a TerrainTile is similar to this:
>> >>
>> >> 1. Loaded/created by the database pager
>> >> 2. Added to the scenegraph by the databasepager.
>> >> 3. Disabled/hidden by the CullVisitor.
>> >> 4. Enabled/Shown by the CullVisitor. (possibly if it is only culled
>> >> out for a short time OSG 2.6.1)
>> >> 5. Unloaded/Destroyed.
>> >>
>> >> I need a way to catch at least event 1 and 5. Could this be done using
>> >> reference counting or is there a better way?
>> >>
>> >> Brgs.
>> >>
>> >> Ralf Stokholm
>> >>
>> >> 2009/4/3 Robert Osfield <robert.osfi...@gmail.com>:
>> >> > Hi Ralf,
>> >> >
>> >> > If you need to keep the memory around then use a ref_ptr<> to the
>> >> > HeightField, but... this will keep the memory around so if you do no
>> >> > longer
>> >> > need it you might want to implement a scheme to free it, such as
>> >> > watching
>> >> > when the ref count goes to one.
>> >> >
>> >> > The other approach is to use an observer_ptr<> that doesn't change
>> >> > the
>> >> > ref
>> >> > count of the HeightFiled, and gets reset to 0 when the HeightField
>> >> > get
>> >> > deleted.  You can also use a custom osg::Observer to watch for object
>> >> > deletions as well.
>> >> >
>> >> > Robert
>> >> >
>> >> > On Fri, Apr 3, 2009 at 11:22 AM, Ralf Stokholm
>> >> > <alfma...@arenalogic.com>
>> >> > wrote:
>> >> >>
>> >> >> Hi Robert (list)
>> >> >>
>> >> >> Im trying to use the ReadFileCallback to load the heightfield int my
>> >> >> physics engine.
>> >> >>
>> >> >> So far I have been using a CullVisitor to grap the triangles from
>> >> >> the
>> >> >> finished scene, but it has major drawback in that it forces me to
>> >> >> load
>> >> >> the data as meshes which is terrible for memmory and takes a long
>> >> >> time
>> >> >> to load.
>> >> >>
>> >> >> It seams im able to load the data as heightfields from the
>> >> >> ReadFileCallback, but this leads to my next problem. I need a way to
>> >> >> reference the data later, to be able to remove it when tiles are
>> >> >> deletet and disable it when tiles are disabled by the scene
>> >> >> cullvisitor.
>> >> >>
>> >> >> Is there a way to relate the nodes i visit in my ReadFileCallback to
>> >> >> nodes i visit in a special cullvisitor for the final scenegraph?
>> >> >>
>> >> >> Basically do you have any hints on how to syncronise the state of my
>> >> >> physics engine with the state of my Paged VPB terrain?
>> >> >>
>> >> >> Brgs.
>> >> >>
>> >> >> Ralf Stokholm
>> >> >>
>> >> >>
>> >> >> 2009/4/2 Ralf Stokholm <alfma...@arenalogic.com>:
>> >> >> > Hi Robert
>> >> >> >
>> >> >> > Thanks a lot, was starting to get at this but using a more
>> >> >> > primitive
>> >> >> > approach of running through all the children of the node that I
>> >> >> > did
>> >> >> > get.
>> >> >> >
>> >> >> > Will try to implement your method.
>> >> >> >
>> >> >> > Brgs.
>> >> >> >
>> >> >> > Ralf Stokholm
>> >> >> >
>> >> >> > 2009/4/2 Robert Osfield <robert.osfi...@gmail.com>:
>> >> >> >> Hi Ralf,
>> >> >> >>
>> >> >> >> You'll need to write a custom NodeVisitor that traverses through
>> >> >> >> the
>> >> >> >> loaded
>> >> >> >> scene graph and picks out the TerrainTile using dyanmic cast.
>> >> >> >> It
>> >> >> >> just
>> >> >> >> so
>> >> >> >> happens that I'm actually working on a ReadFileCallback/custom
>> >> >> >> Visitor
>> >> >> >> that
>> >> >> >> does pick out all the TerrainTile's in a subgraph (there will
>> >> >> >> typically
>> >> >> >> be
>> >> >> >> one, two or four due to the quad tree structure generated by
>> >> >> >> VPB.)
>> >> >> >>
>> >> >> >> The visitor looks like:
>> >> >> >>
>> >> >> >> class FindTerrainTileVisitor : public osg::NodeVisitor
>> >> >> >> {
>> >> >> >> public:
>> >> >> >>     FindTerrainTileVisitor():
>> >> >> >>         osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
>> >> >> >>     {
>> >> >> >>     }
>> >> >> >>
>> >> >> >>     void reset()
>> >> >> >>     {
>> >> >> >>         _terrainTiles.clear();
>> >> >> >>     }
>> >> >> >>
>> >> >> >>     void apply(osg::Group& group)
>> >> >> >>     {
>> >> >> >>         osgTerrain::TerrainTile* terrainTile =
>> >> >> >> dynamic_cast<osgTerrain::TerrainTile*>(&group);
>> >> >> >>         if (terrainTile)
>> >> >> >>         {
>> >> >> >>             _terrainTiles.push_back(terrainTile);
>> >> >> >>         }
>> >> >> >>         else
>> >> >> >>         {
>> >> >> >>             traverse(group);
>> >> >> >>         }
>> >> >> >>     }
>> >> >> >>
>> >> >> >>     typedef std::list< osg::ref_ptr<osgTerrain::TerrainTile> >
>> >> >> >> TerrainTiles;
>> >> >> >>     TerrainTiles _terrainTiles;
>> >> >> >> };
>> >> >> >>
>> >> >> >> The custom ReadFileCallback's readNode method looks like:
>> >> >> >>
>> >> >> >>     virtual osgDB::ReaderWriter::ReadResult readNode(const
>> >> >> >> std::string&
>> >> >> >> filename, const osgDB::ReaderWriter::Options* options)
>> >> >> >>     {
>> >> >> >>         osg::notify(osg::NOTICE)<<"Loading tile
>> >> >> >> "<<filename<<std::endl;
>> >> >> >>         osgDB::ReaderWriter::ReadResult result =
>> >> >> >>
>> >> >> >>
>> >> >> >> osgDB::Registry::instance()->readNodeImplementation(filename,options);
>> >> >> >>         if (result.validNode())
>> >> >> >>         {
>> >> >> >>             FindTerrainTileVisitor fttv;
>> >> >> >>             result.getNode()->accept(fttv);
>> >> >> >>             for(FindTerrainTileVisitor::TerrainTiles::iterator
>> >> >> >> itr =
>> >> >> >> fttv._terrainTiles.begin();
>> >> >> >>                 itr != fttv._terrainTiles.end();
>> >> >> >>                 ++itr)
>> >> >> >>             {
>> >> >> >>                 osgTerrain::TerrainTile* terrainTile =
>> >> >> >> itr->get();
>> >> >> >>                 ///.... my stuff omitted, put your  stuff here
>> >> >> >>             }
>> >> >> >>          }
>> >> >> >>       }
>> >> >> >>
>> >> >> >>
>> >> >> >> Robert.
>> >> >> >>
>> >> >> >> On Thu, Apr 2, 2009 at 1:05 PM, Ralf Stokholm
>> >> >> >> <alfma...@arenalogic.com>
>> >> >> >> wrote:
>> >> >> >>>
>> >> >> >>> Hi List
>> >> >> >>>
>> >> >> >>> Im trying to get the heightfiled data from a VPB terrain using
>> >> >> >>> ReadFileCallback.
>> >> >> >>>
>> >> >> >>> I use the code from readfile callback like this.
>> >> >> >>>
>> >> >> >>>   class MyReadFileCallback : public
>> >> >> >>> osgDB::Registry::ReadFileCallback
>> >> >> >>>   {
>> >> >> >>>   public:
>> >> >> >>>      virtual osgDB::ReaderWriter::ReadResult readNode(const
>> >> >> >>> std::string& fileName, const osgDB::ReaderWriter::Options*
>> >> >> >>> options)
>> >> >> >>>      {
>> >> >> >>>         // note when calling the Registry to do the read you
>> >> >> >>> have
>> >> >> >>> to
>> >> >> >>> call readNodeImplementation NOT readNode, as this will
>> >> >> >>>         // cause on infinite recusive loop.
>> >> >> >>>         osgDB::ReaderWriter::ReadResult result =
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> osgDB::Registry::instance()->readNodeImplementation(fileName,options);
>> >> >> >>>         if (result.validHeightField())
>> >> >> >>>         {
>> >> >> >>>            LOG_ERROR("Found a valid HeightField");
>> >> >> >>>         }
>> >> >> >>>         return result;
>> >> >> >>>      }
>> >> >> >>>   };
>> >> >> >>>
>> >> >> >>> The idea was simply to see if I had the heightfield available,
>> >> >> >>> but
>> >> >> >>> even though I have verified that it gets called it is never a
>> >> >> >>> valid
>> >> >> >>> heightfield.
>> >> >> >>>
>> >> >> >>> This is on a terrain build using VPB with the --TERRAIN option.
>> >> >> >>>
>> >> >> >>> Shouldent I be able to get the heightfieldnodes?
>> >> >> >>>
>> >> >> >>> Brgs.
>> >> >> >>>
>> >> >> >>> Ralf Stokholm
>> >> >> >>> _______________________________________________
>> >> >> >>> 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
>> >> >
>> >> >
>> >> _______________________________________________
>> >> 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
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to