root/OpenSceneGraph/trunk/include/osg/ProxyNode @ 10341

Revision 10341, 6.0 kB (checked in by robert, 6 years ago)

From Mathias Froehlich, "attached is a change to the ProxyNode? that also includes ProxyNode? local
database options like recently added to PagedLOD.

Also there is a change to the traverse method:
The previous ProxyNode? checks the VisitorType? to be a CULL_VISITOR and the
presence of a request handler to submit a database request.
In contrast to that PagedLOD uses the request handler if it is there - even if
the visitor type is not a cull visitor.
The change removes the cull visitor test from the ProxyNode? so that it behaves
like the PagedLOD.
I believe that the presence of a request handler in a visitor might be
sufficient to trigger the requests as this is done in the PagedLOD anyway.

Based on rev 10332."

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_ProxyNode
15#define OSG_ProxyNode 1
16
17#include <osg/Group>
18
19namespace osg {
20
21/** ProxyNode.
22*/
23class OSG_EXPORT ProxyNode : public Group
24{
25    public :
26   
27        ProxyNode();
28
29        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
30        ProxyNode(const ProxyNode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
31
32        META_Node(osg, ProxyNode);
33       
34        typedef osg::BoundingSphere::vec_type vec_type;
35        typedef osg::BoundingSphere::value_type value_type;
36
37        virtual void traverse(NodeVisitor& nv);
38       
39        virtual bool addChild(Node *child);
40        virtual bool addChild(Node *child, const std::string& filename);
41       
42        virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
43
44
45        /** Set the optional database osgDB::Options object to use when loaded children.*/
46        void setDatabaseOptions(osg::Referenced* options) { _databaseOptions = options; }
47
48        /** Get the optional database osgDB::Options object used when loaded children.*/
49        osg::Referenced* getDatabaseOptions() { return _databaseOptions.get(); }
50
51        /** Get the optional database osgDB::Options object used when loaded children.*/
52        const osg::Referenced* getDatabaseOptions() const { return _databaseOptions.get(); }
53
54
55        /** Set the database path to prepend to children's filenames.*/
56        void setDatabasePath(const std::string& path);
57        /** Get the database path used to prepend to children's filenames.*/
58        inline const std::string& getDatabasePath() const { return _databasePath; }
59
60        void setFileName(unsigned int childNo, const std::string& filename) { expandFileNameListTo(childNo); _filenameList[childNo].first=filename; }
61        const std::string& getFileName(unsigned int childNo) const { return _filenameList[childNo].first; }
62        unsigned int getNumFileNames() const { return _filenameList.size(); }
63
64        /** Return the DatabaseRequest object used by the DatabasePager to keep track of file load requests
65          * being carried on behalf of the DatabasePager.
66          * Note, in normal OSG usage you should not set this value yourself, as this will be managed by
67          * the osgDB::DatabasePager.*/
68        osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) { return _filenameList[childNo].second; }
69       
70        /** Return the const DatabaseRequest object.*/
71        const osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) const { return _filenameList[childNo].second; }
72
73
74        /** Modes which control how the center of object should be determined when computed which child is active.*/
75        enum CenterMode
76        {
77            USE_BOUNDING_SPHERE_CENTER,
78            USER_DEFINED_CENTER
79        };
80
81        /** Set how the center of object should be determined when computed which child is active.*/
82        void setCenterMode(CenterMode mode) { _centerMode=mode; }
83
84        /** Get how the center of object should be determined when computed which child is active.*/
85        CenterMode getCenterMode() const { return _centerMode; }
86       
87        /** Modes which control how the proxynode external reference are loaded.*/
88        enum LoadingExternalReferenceMode
89        {
90            LOAD_IMMEDIATELY,
91            DEFER_LOADING_TO_DATABASE_PAGER,
92            NO_AUTOMATIC_LOADING
93        };
94
95        /** Set how the child loading is done.*/
96        void setLoadingExternalReferenceMode(LoadingExternalReferenceMode mode) { _loadingExtReference=mode; }
97
98        /** Get the setted mode of loading.*/
99        LoadingExternalReferenceMode getLoadingExternalReferenceMode() const { return _loadingExtReference; }
100
101        /** Sets the object-space point which defines the center of the osg::ProxyNode. 
102            center is affected by any transforms in the hierarchy above the osg::ProxyNode.*/
103        inline void setCenter(const Vec3& center) { _centerMode=USER_DEFINED_CENTER; _userDefinedCenter = center; }
104       
105        /** return the ProxyNode center point. */
106        inline const vec_type& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); }
107
108
109        /** Set the object-space reference radius of the volume enclosed by the ProxyNode.
110          * Used to determine the bounding sphere of the ProxyNode in the absence of any children.*/
111        inline void setRadius(value_type radius) { _radius = radius; }
112       
113        /** Get the object-space radius of the volume enclosed by the ProxyNode.*/
114        inline value_type getRadius() const { return _radius; }
115
116        virtual BoundingSphere computeBound() const;
117
118    protected :
119   
120        virtual ~ProxyNode() {}
121
122        void expandFileNameListTo(unsigned int pos);
123
124        typedef std::pair< std::string, osg::ref_ptr<osg::Referenced> >  FileNameDatabaseRequestPair;
125        typedef std::vector<FileNameDatabaseRequestPair>                 FileNameDatabaseRequestList;
126
127        FileNameDatabaseRequestList     _filenameList;
128        ref_ptr<Referenced>             _databaseOptions;
129        std::string                     _databasePath;
130       
131        LoadingExternalReferenceMode    _loadingExtReference;
132       
133        CenterMode                      _centerMode;
134        vec_type                        _userDefinedCenter;
135        value_type                      _radius;
136       
137};
138
139}
140
141#endif
Note: See TracBrowser for help on using the browser.