2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-08-27 06:09:15 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* 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
|
2003-08-27 06:09:15 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-08-27 06:09:15 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-08-27 06:09:15 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
//osgFX - Copyright (C) 2003 Marco Jez
|
|
|
|
|
|
|
|
#ifndef OSGFX_SCRIBE_
|
|
|
|
#define OSGFX_SCRIBE_
|
|
|
|
|
|
|
|
#include <osgFX/Export>
|
|
|
|
#include <osgFX/Effect>
|
|
|
|
|
|
|
|
#include <osg/Material>
|
|
|
|
#include <osg/LineWidth>
|
|
|
|
|
|
|
|
namespace osgFX
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2012-03-22 01:36:20 +08:00
|
|
|
This is a two-passes effect; the first pass renders the subgraph as usual
|
|
|
|
while the second pass switches to wireframe mode, sets up lighting and
|
2003-08-27 06:09:15 +08:00
|
|
|
material to obtain a fixed (user-defined) color and then renders the subgraph.
|
2012-03-22 01:36:20 +08:00
|
|
|
This effect uses the PolygonOffset attribute to avoid Z-fighting, so it
|
2003-08-27 06:09:15 +08:00
|
|
|
requires at least OpenGL version 1.1.
|
|
|
|
*/
|
|
|
|
class OSGFX_EXPORT Scribe: public Effect {
|
|
|
|
public:
|
|
|
|
Scribe();
|
2005-04-29 14:32:13 +08:00
|
|
|
Scribe(const Scribe& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
2003-08-27 06:09:15 +08:00
|
|
|
|
|
|
|
// effect class informations
|
|
|
|
META_Effect(
|
2012-03-22 01:36:20 +08:00
|
|
|
osgFX,
|
|
|
|
Scribe,
|
|
|
|
|
|
|
|
"Scribe",
|
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
"This is a two-passes effect; the first pass renders the subgraph as usual "
|
|
|
|
"while the second pass switches to wireframe mode, sets up lighting and "
|
|
|
|
"material to obtain a fixed (user-defined) color and then renders the subgraph.\n"
|
|
|
|
"This effect uses the PolygonOffset attribute to avoid Z-fighting, so it "
|
|
|
|
"requires at least OpenGL version 1.1.",
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
"Marco Jez");
|
|
|
|
|
|
|
|
/** get the wireframe color */
|
2005-04-29 14:32:13 +08:00
|
|
|
inline const osg::Vec4& getWireframeColor() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the wireframe color */
|
2005-04-29 14:32:13 +08:00
|
|
|
inline void setWireframeColor(const osg::Vec4& color);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** get the wireframe line width */
|
|
|
|
inline float getWireframeLineWidth() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the wireframe line width */
|
|
|
|
inline void setWireframeLineWidth(float w);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Scribe() {}
|
2005-04-29 14:32:13 +08:00
|
|
|
Scribe& operator=(const Scribe&) { return *this; }
|
2003-08-27 06:09:15 +08:00
|
|
|
|
|
|
|
bool define_techniques();
|
|
|
|
|
|
|
|
private:
|
2005-04-29 14:32:13 +08:00
|
|
|
osg::ref_ptr<osg::Material> _wf_mat;
|
|
|
|
osg::ref_ptr<osg::LineWidth> _wf_lw;
|
2003-08-27 06:09:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// INLINE METHODS
|
|
|
|
|
2005-04-29 14:32:13 +08:00
|
|
|
inline const osg::Vec4& Scribe::getWireframeColor() const
|
2003-08-27 06:09:15 +08:00
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _wf_mat->getEmission(osg::Material::FRONT_AND_BACK);
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 14:32:13 +08:00
|
|
|
inline void Scribe::setWireframeColor(const osg::Vec4& color)
|
2003-08-27 06:09:15 +08:00
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_wf_mat->setEmission(osg::Material::FRONT_AND_BACK, color);
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline float Scribe::getWireframeLineWidth() const
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _wf_lw->getWidth();
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline void Scribe::setWireframeLineWidth(float w)
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_wf_lw->setWidth(w);
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|