Scribe 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. //osgFX - Copyright (C) 2003 Marco Jez
  14. #ifndef OSGFX_SCRIBE_
  15. #define OSGFX_SCRIBE_
  16. #include <osgFX/Export>
  17. #include <osgFX/Effect>
  18. #include <osg/Material>
  19. #include <osg/LineWidth>
  20. namespace osgFX
  21. {
  22. /**
  23. This is a two-passes effect; the first pass renders the subgraph as usual
  24. while the second pass switches to wireframe mode, sets up lighting and
  25. material to obtain a fixed (user-defined) color and then renders the subgraph.
  26. This effect uses the PolygonOffset attribute to avoid Z-fighting, so it
  27. requires at least OpenGL version 1.1.
  28. */
  29. class OSGFX_EXPORT Scribe: public Effect {
  30. public:
  31. Scribe();
  32. Scribe(const Scribe& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  33. // effect class information
  34. META_Effect(
  35. osgFX,
  36. Scribe,
  37. "Scribe",
  38. "This is a two-passes effect; the first pass renders the subgraph as usual "
  39. "while the second pass switches to wireframe mode, sets up lighting and "
  40. "material to obtain a fixed (user-defined) color and then renders the subgraph.\n"
  41. "This effect uses the PolygonOffset attribute to avoid Z-fighting, so it "
  42. "requires at least OpenGL version 1.1.",
  43. "Marco Jez");
  44. /** get the wireframe color */
  45. inline const osg::Vec4& getWireframeColor() const;
  46. /** set the wireframe color */
  47. inline void setWireframeColor(const osg::Vec4& color);
  48. /** get the wireframe line width */
  49. inline float getWireframeLineWidth() const;
  50. /** set the wireframe line width */
  51. inline void setWireframeLineWidth(float w);
  52. protected:
  53. virtual ~Scribe() {}
  54. Scribe& operator=(const Scribe&) { return *this; }
  55. bool define_techniques();
  56. private:
  57. osg::ref_ptr<osg::Material> _wf_mat;
  58. osg::ref_ptr<osg::LineWidth> _wf_lw;
  59. };
  60. // INLINE METHODS
  61. inline const osg::Vec4& Scribe::getWireframeColor() const
  62. {
  63. return _wf_mat->getEmission(osg::Material::FRONT_AND_BACK);
  64. }
  65. inline void Scribe::setWireframeColor(const osg::Vec4& color)
  66. {
  67. _wf_mat->setEmission(osg::Material::FRONT_AND_BACK, color);
  68. }
  69. inline float Scribe::getWireframeLineWidth() const
  70. {
  71. return _wf_lw->getWidth();
  72. }
  73. inline void Scribe::setWireframeLineWidth(float w)
  74. {
  75. _wf_lw->setWidth(w);
  76. }
  77. }
  78. #endif