Added GeometryTechinque to osgTerrain. Added usage of GeometryTechnique into osgterrain example
Added --width and --height command line options to osgdistortion to allow users to control the window size.
This commit is contained in:
@@ -22,12 +22,11 @@ namespace osg {
|
||||
|
||||
/** TransferFunction used to manage the mapping for 1D, 2D or 3D input to output Vec4 values.
|
||||
*/
|
||||
class OSG_EXPORT TransferFunction
|
||||
class OSG_EXPORT TransferFunction : public osg::Referenced
|
||||
{
|
||||
public :
|
||||
|
||||
TransferFunction();
|
||||
virtual ~TransferFunction();
|
||||
|
||||
osg::Image* getImage() { return _image.get(); }
|
||||
const osg::Image* getImage() const { return _image.get(); }
|
||||
@@ -40,6 +39,8 @@ class OSG_EXPORT TransferFunction
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TransferFunction();
|
||||
|
||||
typedef std::vector<osg::Vec4> Colors;
|
||||
Colors _colors;
|
||||
osg::ref_ptr<osg::Image> _image;
|
||||
|
||||
56
include/osgTerrain/GeometryTechnique
Normal file
56
include/osgTerrain/GeometryTechnique
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library 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
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGTERRAIN_GEOMETRYTECHNIQUE
|
||||
#define OSGTERRAIN_GEOMETRYTECHNIQUE 1
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <osgTerrain/TerrainTechnique>
|
||||
|
||||
namespace osgTerrain {
|
||||
|
||||
class OSGTERRAIN_EXPORT GeometryTechnique : public TerrainTechnique
|
||||
{
|
||||
public:
|
||||
|
||||
GeometryTechnique();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
GeometryTechnique(const GeometryTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
virtual void update(osgUtil::UpdateVisitor* nv);
|
||||
|
||||
virtual void cull(osgUtil::CullVisitor* nv);
|
||||
|
||||
virtual void cleanSceneGraph() {}
|
||||
|
||||
/** Dirty so that cached data structurese are updated.*/
|
||||
virtual void dirty() { _dirty = true; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~GeometryTechnique();
|
||||
|
||||
osg::ref_ptr<osg::Geode> _geode;
|
||||
osg::ref_ptr<osg::Geometry> _geometry;
|
||||
bool _dirty;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,8 +40,7 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
|
||||
|
||||
virtual ~Layer();
|
||||
|
||||
|
||||
osg::ref_ptr<Locator> _locator;
|
||||
osg::ref_ptr<Locator> _locator;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
#define OSGTERRAIN_LOCATOR 1
|
||||
|
||||
#include <osg/Object>
|
||||
#include <osg/Vec3d>
|
||||
|
||||
#include <osgTerrain/Export>
|
||||
|
||||
namespace osgTerrain {
|
||||
|
||||
class TerrainNode;
|
||||
|
||||
class OSGTERRAIN_EXPORT Locator : public osg::Object
|
||||
{
|
||||
public:
|
||||
@@ -31,6 +30,8 @@ class OSGTERRAIN_EXPORT Locator : public osg::Object
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Locator(const Locator&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) = 0;
|
||||
virtual bool convertModelToWorld(const osg::Vec3d& local, osg::Vec3d& world) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
#define OSGTERRAIN_TERRAINNODE 1
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/Image>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include <osg/TransferFunction>
|
||||
|
||||
#include <osgTerrain/TerrainTechnique>
|
||||
#include <osgTerrain/Layer>
|
||||
#include <osgTerrain/Locator>
|
||||
|
||||
namespace osgTerrain {
|
||||
|
||||
@@ -49,20 +50,40 @@ class OSGTERRAIN_EXPORT TerrainNode : public osg::Group
|
||||
const TerrainTechnique* getTerrainTechnique() const { return _terrainTechnique.get(); }
|
||||
|
||||
|
||||
void setHeightLayer(osgTerrain::Layer* layer);
|
||||
osgTerrain::Layer* getHeightLayer();
|
||||
/** Set the coordinate frame locator of the terrain node.
|
||||
* The locator takes non-dimensional s,t coordinates into the X,Y,Z world coords and back.*/
|
||||
void setLocator(Locator* locator) { _locator = locator; }
|
||||
|
||||
/** Get the coordinate frame locator of the terrain node.*/
|
||||
Locator* getLocator() { return _locator.get(); }
|
||||
|
||||
/** Get the coordinate frame locator of the terrain node.*/
|
||||
const Locator* getLocator() const { return _locator.get(); }
|
||||
|
||||
|
||||
void setElevationLayer(Layer* layer);
|
||||
Layer* getElevationLayer() { return _elevationLayer.get(); }
|
||||
const Layer* getElevationLayer() const { return _elevationLayer.get(); }
|
||||
|
||||
void addColorLayer(osgTerrain::Layer* layer);
|
||||
void removeColorLayer(osgTerrain::Layer* layer);
|
||||
void setColorLayer(osgTerrain::Layer* layer);
|
||||
Layer* getColorLayer() { return _colorLayer.get(); }
|
||||
const Layer* getColorLayer() const { return _colorLayer.get(); }
|
||||
|
||||
void setColorTransferFunction(osg::TransferFunction* tf);
|
||||
osg::TransferFunction* getColorTransferFunction() { return _colorTransferFunction.get(); }
|
||||
const osg::TransferFunction* getColorTransferFunction() const { return _colorTransferFunction.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TerrainNode();
|
||||
|
||||
osg::ref_ptr<TerrainTechnique> _terrainTechnique;
|
||||
osg::ref_ptr<Locator> _locator;
|
||||
|
||||
osg::ref_ptr<TerrainTechnique> _terrainTechnique;
|
||||
|
||||
osg::ref_ptr<Layer> _heightLayer;
|
||||
osg::ref_ptr<Layer> _elevationLayer;
|
||||
|
||||
osg::ref_ptr<Layer> _colorLayer;
|
||||
osg::ref_ptr<osg::TransferFunction> _colorTransferFunction;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -34,16 +34,22 @@ class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
TerrainTechnique(const TerrainTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgTerrain, TerrainTechnique);
|
||||
|
||||
TerrainNode* getTerrainNode() { return _terrainNode; }
|
||||
const TerrainNode* getTerrainNode() const { return _terrainNode; }
|
||||
|
||||
virtual void initialize() = 0;
|
||||
virtual void initialize();
|
||||
|
||||
virtual void heightFieldHasBeenModified() = 0;
|
||||
virtual void update(osgUtil::UpdateVisitor* nv);
|
||||
|
||||
virtual void update(osgUtil::UpdateVisitor* nv) = 0;
|
||||
virtual void cull(osgUtil::CullVisitor* nv);
|
||||
|
||||
virtual void cull(osgUtil::CullVisitor* nv) = 0;
|
||||
/** Clean scene graph from any terrain technique specific nodes.*/
|
||||
virtual void cleanSceneGraph();
|
||||
|
||||
/** Dirty so that cached data structurese are updated.*/
|
||||
virtual void dirty();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user