77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
/* -*-c++-*- */
|
|
/* osgEarth - Geospatial SDK for OpenSceneGraph
|
|
* Copyright 2020 Pelican Mapping
|
|
* http://osgearth.org
|
|
*
|
|
* osgEarth is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
#ifndef OSGEARTHSYMBOLOGY_INSTANCE_RESOURCE_H
|
|
#define OSGEARTHSYMBOLOGY_INSTANCE_RESOURCE_H 1
|
|
|
|
#include <osgEarth/Common>
|
|
#include <osgEarth/Resource>
|
|
#include <osgEarth/InstanceSymbol>
|
|
#include <osgEarth/URI>
|
|
#include <map>
|
|
|
|
namespace osgEarth { namespace Util
|
|
{
|
|
/**
|
|
* A resource that materializes an InstanceSymbol, which is a single-point object
|
|
* that resolves to an osg::Node. Instances are usually used for point-model
|
|
* substitution.
|
|
*/
|
|
class OSGEARTH_EXPORT InstanceResource : public Resource
|
|
{
|
|
public:
|
|
|
|
/** dtor */
|
|
virtual ~InstanceResource() { }
|
|
|
|
/**
|
|
* Creates a new Node representing the instance.
|
|
*/
|
|
osg::Node* createNode(const osgDB::Options* readOptions) const;
|
|
|
|
/** Whether this instance type is 2D (orthographic screen space) */
|
|
virtual bool is2D() const =0;
|
|
|
|
public:
|
|
/** Source location of the actual data to load. */
|
|
optional<URI>& uri() { return _uri; }
|
|
const optional<URI>& uri() const { return _uri; }
|
|
|
|
//! For programmaticly set nodes only
|
|
osg::ref_ptr<osg::Node>& node() { return _node; }
|
|
const osg::ref_ptr<osg::Node>& node() const { return _node; }
|
|
|
|
public: // serialization methods
|
|
|
|
virtual Config getConfig() const;
|
|
void mergeConfig( const Config& conf );
|
|
|
|
protected:
|
|
/** Constructs a new resource. */
|
|
InstanceResource( const Config& conf =Config() );
|
|
|
|
optional<URI> _uri;
|
|
osg::ref_ptr<osg::Node> _node;
|
|
|
|
virtual osg::Node* createNodeFromURI( const URI& uri, const osgDB::Options* dbOptions ) const =0;
|
|
};
|
|
} }
|
|
|
|
#endif // OSGEARTHSYMBOLOGY_MARKER_RESOURCE_H
|